Package org.apache.catalina.core

Examples of org.apache.catalina.core.StandardService


     */
    public String createStandardService(String parent, String name, String domain)
        throws Exception {

        // Create a new StandardService instance
        StandardService service = new StandardService();
        service.setName(name);

        // Add the new instance to its parent component
        Server server = ServerFactory.getServer();
        server.addService(service);

        // Return the corresponding MBean name
        return (service.getObjectName().toString());

    }
View Full Code Here


    public void removeContext(String contextName) throws Exception {

        // Acquire a reference to the component to be removed
        ObjectName oname = new ObjectName(contextName);
        String domain = oname.getDomain();
        StandardService service = (StandardService) getService(oname);
        if (!service.getObjectName().getDomain().equals(domain)) {
            throw new Exception("Service with the domain is not found");
        }       
        Engine engine = (Engine) service.getContainer();
        String name = oname.getKeyProperty("name");
        name = name.substring(2);
        int i = name.indexOf("/");
        String hostName = name.substring(0,i);
        String path = name.substring(i);
View Full Code Here

    private Service getService(ObjectName oname) throws Exception {
   
        String domain = oname.getDomain();
        Server server = ServerFactory.getServer();
        Service[] services = server.findServices();
        StandardService service = null;
        for (int i = 0; i < services.length; i++) {
            service = (StandardService) services[i];
            if (domain.equals(service.getObjectName().getDomain())) {
                break;
            }
        }
        if (!service.getObjectName().getDomain().equals(domain)) {
            throw new Exception("Service with the domain is not found");
        }       
        return service;

    }
View Full Code Here

    public Vector createStandardEngineService(String parent,
            String engineName, String defaultHost, String serviceName)
        throws Exception {

        // Create a new StandardService instance
        StandardService service = new StandardService();
        service.setName(serviceName);
        // Create a new StandardEngine instance
        StandardEngine engine = new StandardEngine();
        engine.setName(engineName);
        engine.setDefaultHost(defaultHost);
        // Need to set engine before adding it to server in order to set domain
        service.setContainer(engine);
        // Add the new instance to its parent component
        Server server = ServerFactory.getServer();
        server.addService(service);
        Vector onames = new Vector();
        // FIXME service & engine.getObjectName
View Full Code Here

     */
    public String createStandardService(String parent, String name, String domain)
        throws Exception {

        // Create a new StandardService instance
        StandardService service = new StandardService();
        service.setName(name);

        // Add the new instance to its parent component
        Server server = ServerFactory.getServer();
        server.addService(service);

        // Return the corresponding MBean name
        return (service.getObjectName().toString());

    }
View Full Code Here

    public void removeContext(String contextName) throws Exception {

        // Acquire a reference to the component to be removed
        ObjectName oname = new ObjectName(contextName);
        String domain = oname.getDomain();
        StandardService service = (StandardService) getService(oname);
        if (!service.getObjectName().getDomain().equals(domain)) {
            throw new Exception("Service with the domain is not found");
        }       
        Engine engine = (Engine) service.getContainer();
        String name = oname.getKeyProperty("name");
        name = name.substring(2);
        int i = name.indexOf("/");
        String hostName = name.substring(0,i);
        String path = name.substring(i);
View Full Code Here

        if (server != null) {
            embedded = server.getService(serviceName);
            engine = (Engine) embedded.getContainer();
        } else {
            this.engine = (Engine) engineGBean.getInternalObject();
            StandardService embedded = new StandardService();

            // Assemble FileLogger as a gbean
            /*
             * FileLogger fileLog = new FileLogger(); fileLog.setDirectory("."); fileLog.setPrefix("vsjMbedTC5");
             * fileLog.setSuffix(".log"); fileLog.setTimestamp(true);
             */

            // 2. Set the relevant properties of this object itself. In particular,
            // you will want to establish the default Logger to be used, as well as
            // the default Realm if you are using container-managed security.

            //Add default contexts
            File rootContext = new File(catalinaHome + "/ROOT");

            String docBase = "";
            if (rootContext.exists()) {
                docBase = "ROOT";
            }

            Container[] hosts = engine.findChildren();
            Context defaultContext;
            ObjectName objName = objectName == null ? null : ObjectName.getInstance(objectName);
            for (Container host : hosts) {
                defaultContext = createContext("", docBase, classLoader);
                if (objName != null) {
                    defaultContext.setName(objName.getKeyProperty(NameFactory.J2EE_NAME));
                }
                if (defaultContext instanceof GeronimoStandardContext) {
                    GeronimoStandardContext ctx = (GeronimoStandardContext) defaultContext;
                    // Without this the Tomcat FallBack Application is left behind,
                    // MBean - ...J2EEApplication=none,J2EEServer=none,..........
                    ctx.setJ2EEApplication(null);
                    // if objectName != null extract J2EEServer from objectName/host
                    ctx.setJ2EEServer(objName == null ? "geronimo" : objName.getKeyProperty(NameFactory.J2EE_SERVER));
                    ctx.setJavaVMs(new String[]{});
                    ctx.setServer(objName == null ? "geronimo" : objName.getKeyProperty(NameFactory.J2EE_SERVER));
                }
                host.addChild(defaultContext);
            }

            // 6. Call addEngine() to attach this Engine to the set of defined
            // Engines for this object.
            embedded.setContainer(engine);

            if (listenerChain != null){
                LifecycleListenerGBean listenerGBean = listenerChain;
                while(listenerGBean != null){
                    embedded.addLifecycleListener((LifecycleListener)listenerGBean.getInternalObject());
                    listenerGBean = listenerGBean.getNextListener();
                }
            }

            // 9. Call start() to initiate normal operations of all the attached
            // components.
            embedded.start();
            this.embedded = embedded;
        }
        this.objectName = objectName;
        this.applicationListeners = applicationListeners;
        this.manager = manager;
View Full Code Here

                log.severe("Tuscany disabled as Tuscany webapp not found");
            } else {
                System.setProperty(TUSCANY_WAR_PROP, webappDir.getAbsolutePath());
                log.info("Using Tuscany webapp: " + webappDir.getAbsolutePath());
                StandardServer server = (StandardServer)event.getSource();
                StandardService catalina = (StandardService)server.findService("Catalina");
                for (Connector connector : catalina.findConnectors()) {
                    for (Container container : connector.getContainer().findChildren()) {
                        if (container instanceof StandardHost) {
                            for (LifecycleListener listener : ((StandardHost)container).findLifecycleListeners()) {
                                if (listener instanceof HostConfig) {
                                    ((HostConfig)listener).setContextClass("org.apache.tuscany.sca.tomcat.TuscanyStandardContext");
View Full Code Here

        System.setProperty("catalina.useNaming", "false");
       
        server = new StandardServer();
        server.setPort( -1 );
       
        service = new StandardService();
        service.setName("Tomcat");
        server.addService( service );
        return server;
    }
View Full Code Here

        if (server != null) {
            embedded = server.getService(serviceName);
            engine = (Engine) embedded.getContainer();
        } else {
            this.engine = (Engine) engineGBean.getInternalObject();
            StandardService embedded = new StandardService();

            // Assemble FileLogger as a gbean
            /*
             * FileLogger fileLog = new FileLogger(); fileLog.setDirectory("."); fileLog.setPrefix("vsjMbedTC5");
             * fileLog.setSuffix(".log"); fileLog.setTimestamp(true);
             */

            // 2. Set the relevant properties of this object itself. In particular,
            // you will want to establish the default Logger to be used, as well as
            // the default Realm if you are using container-managed security.

            //Add default contexts
            /*File rootContext = new File(catalinaHome + "/ROOT");

            String docBase = "";
            if (rootContext.exists()) {
                docBase = "ROOT";
            }

            Container[] hosts = engine.findChildren();
            Context defaultContext;
            ObjectName objName = objectName == null ? null : ObjectName.getInstance(objectName);
            for (Container host : hosts) {
                defaultContext = createContext("", classLoader, new WebAppInfo());
                defaultContext.setDocBase(docBase);
                //Set the name of default context with "", so that while accessing an un-existing context, the default one will be used
                defaultContext.setName("");
                if (defaultContext instanceof GeronimoStandardContext) {
                    GeronimoStandardContext ctx = (GeronimoStandardContext) defaultContext;
                    // Without this the Tomcat FallBack Application is left behind,
                    // MBean - ...J2EEApplication=none,J2EEServer=none,..........
                    ctx.setJ2EEApplication(null);
                    // if objectName != null extract J2EEServer from objectName/host
                    ctx.setJ2EEServer(objName == null ? "geronimo" : objName.getKeyProperty(NameFactory.J2EE_SERVER));
                    ctx.setJavaVMs(new String[]{});
                    ctx.setServer(objName == null ? "geronimo" : objName.getKeyProperty(NameFactory.J2EE_SERVER));
                    ctx.setInstanceManager(new TomcatInstanceManager(new Holder(), classLoader, null));
                }
                host.addChild(defaultContext);
            }*/

            // 6. Call addEngine() to attach this Engine to the set of defined
            // Engines for this object.
            embedded.setContainer(engine);

            if (listenerChain != null){
                LifecycleListenerGBean listenerGBean = listenerChain;
                while(listenerGBean != null){
                    embedded.addLifecycleListener((LifecycleListener)listenerGBean.getInternalObject());
                    listenerGBean = listenerGBean.getNextListener();
                }
            }

            // 9. Call start() to initiate normal operations of all the attached
            // components.
            embedded.start();
            this.embedded = embedded;

            //10. Set InstanceManager for each default Context
            //The reason for placing the codes here (not in the step 2 ) is NPE is get while invoking the getServletContext method
            /*for (Container host : hosts) {
View Full Code Here

TOP

Related Classes of org.apache.catalina.core.StandardService

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.