Package org.jboss.web.tomcat.metadata

Examples of org.jboss.web.tomcat.metadata.ServerMetaData


      u.setValidation(false);
      u.setEntityResolver(new JBossEntityResolver());

      InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("test/metadata/server.xml");

      ServerMetaData m = ServerMetaData.class.cast(u.unmarshal(is, schema));
      assertNotNull(m);
      assertNotNull(m.getListeners());
      assertNotNull(m.getServices());
     
      assertEquals(2, m.getListeners().size());
      ListenerMetaData l = m.getListeners().get(0);
      assertNotNull(l);
      assertEquals(l.getClassName(), "org.apache.catalina.core.AprLifecycleListener");
      assertEquals("on", l.getAttributes().get("SSLEngine"));
   }
View Full Code Here


      Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
      u.setSchemaValidation(false);
      u.setValidation(false);
      u.setEntityResolver(new JBossEntityResolver());
      InputStream is = null;
      ServerMetaData serverMetaData = null;
      try {
         File configFile = new File(tomcatDeployer.getConfigFile());
         if (configFile.exists())
         {
            is = new FileInputStream(configFile);
         }
         else
         {
            is = getClass().getClassLoader().getResourceAsStream(tomcatDeployer.getConfigFile());
         }
         if (is == null) {
            log.error("Could not read configured server.xml (will try default): " + tomcatDeployer.getConfigFile());
            is = getClass().getClassLoader().getResourceAsStream("server.xml");
         }
         serverMetaData = ServerMetaData.class.cast(u.unmarshal(is, schema));
      } finally {
         if (is != null) {
            try {
               is.close();
            } catch (IOException e) {
               // Ignore
            }
         }
      }

      // FIXME: could try to do stuff with EngineConfig and HostConfig, although neither
      //        should be useful in JBoss

      // Create the Catalina instance
      Catalina catalina = new Catalina();
      catalina.setCatalinaHome(System.getProperty("jboss.server.home.dir"));

      // Set the modeler Registry MBeanServer to the that of the tomcat service
      Registry.getRegistry(null, null).setMBeanServer(server);
      // Register the Catalina instance
      Registry.getRegistry(null, null).registerComponent(catalina, objectName, "org.apache.catalina.startup.Catalina");

      // Use the server.xml metadata to create a Server instance and assign it to the Catalina instance

      // Server
      org.apache.catalina.Server catalinaServer =
         (org.apache.catalina.Server) getInstance(serverMetaData, "org.apache.catalina.core.StandardServer");
      Registry.getRegistry(null, null).registerComponent(catalinaServer,
            new ObjectName(tomcatDeployer.getDomain() + ":type=Server"), "org.apache.catalina.startup.StandardServer");
      addLifecycleListeners(catalinaServer, serverMetaData.getListeners());

      // Server/Service
      if (serverMetaData.getServices() == null)
      {
         throw new IllegalArgumentException("No services");
      }
      Iterator<ServiceMetaData> serviceMetaDatas = serverMetaData.getServices().iterator();
      if (serviceMetaDatas.hasNext())
      {
         ServiceMetaData serviceMetaData = serviceMetaDatas.next();
         org.apache.catalina.Service service =
            (org.apache.catalina.Service) getInstance(serviceMetaData, "org.apache.catalina.core.StandardService");
View Full Code Here

      Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
      u.setSchemaValidation(false);
      u.setValidation(false);
      u.setEntityResolver(new JBossEntityResolver());
      InputStream is = null;
      ServerMetaData serverMetaData = null;
      try {
         File configFile = new File(tomcatDeployer.getConfigFile());
         if (configFile.exists())
         {
            is = new FileInputStream(configFile);
         }
         else
         {
            is = getClass().getClassLoader().getResourceAsStream(tomcatDeployer.getConfigFile());
         }
         if (is == null) {
            log.error("Could not read configured server.xml (will try default): " + tomcatDeployer.getConfigFile());
            is = getClass().getClassLoader().getResourceAsStream("server.xml");
         }
         serverMetaData = ServerMetaData.class.cast(u.unmarshal(is, schema));
      } finally {
         if (is != null) {
            try {
               is.close();
            } catch (IOException e) {
               // Ignore
            }
         }
      }
     
      // FIXME: could try to do stuff with EngineConfig and HostConfig, although neither
      //        should be useful in JBoss
     
      // Create the Catalina instance
      Catalina catalina = new Catalina();
      catalina.setCatalinaHome(System.getProperty("jboss.server.home.dir"));
      catalina.setUseNaming(false);
      catalina.setUseShutdownHook(false);
      catalina.setAwait(false);
      catalina.setRedirectStreams(false);
     
      // Set the modeler Registry MBeanServer to the that of the tomcat service
      Registry.getRegistry(null, null).setMBeanServer(server);
      // Register the Catalina instance
      Registry.getRegistry(null, null).registerComponent(catalina, objectName, "org.apache.catalina.startup.Catalina");
     
      // Use the server.xml metadata to create a Server instance and assign it to the Catalina instance
     
      // Server
      org.apache.catalina.Server catalinaServer =
         (org.apache.catalina.Server) getInstance(serverMetaData, "org.apache.catalina.core.StandardServer");
      Registry.getRegistry(null, null).registerComponent(catalinaServer,
            new ObjectName(tomcatDeployer.getDomain() + ":type=Server"), "org.apache.catalina.startup.StandardServer");
      addLifecycleListeners(catalinaServer, serverMetaData.getListeners());
     
      // Server/Service
      if (serverMetaData.getServices() == null)
      {
         throw new IllegalArgumentException("No services");
      }
      Iterator<ServiceMetaData> serviceMetaDatas = serverMetaData.getServices().iterator();
      while (serviceMetaDatas.hasNext())
      {
         ServiceMetaData serviceMetaData = serviceMetaDatas.next();
         org.apache.catalina.Service service =
            (org.apache.catalina.Service) getInstance(serviceMetaData, "org.apache.catalina.core.StandardService");
View Full Code Here

      u.setValidation(false);
      u.setEntityResolver(new JBossEntityResolver());

      InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("test/metadata/server.xml");

      ServerMetaData m = ServerMetaData.class.cast(u.unmarshal(is, schema));
      assertNotNull(m);
      assertNotNull(m.getListeners());
      assertNotNull(m.getServices());
     
      assertEquals(2, m.getListeners().size());
      ListenerMetaData l = m.getListeners().get(0);
      assertNotNull(l);
      assertEquals(l.getClassName(), "org.apache.catalina.core.AprLifecycleListener");
      assertEquals("on", l.getAttributes().get("SSLEngine"));
   }
View Full Code Here

TOP

Related Classes of org.jboss.web.tomcat.metadata.ServerMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.