container = new Embedded(); container.setCatalinaHome(catalinaHome); container.setRealm(new MemoryRealm()); rootContext = container.createContext("", webappDir); rootContext.setLoader(loader); rootContext.setReloadable(true); Host localHost = container.createHost("127.0.0.1", new File("").getAbsolutePath()); localHost.addChild(rootContext); engine = container.createEngine(); engine.setName("localEngine"); engine.addChild(localHost); engine.setJvmRoute(jvmRoute); engine.setService(new StandardService()); container.addEngine(engine); Connector httpConnector = container.createConnector((InetAddress) null, port, false); container.addConnector(httpConnector); container.setAwait(true);
/** * Starts the embedded Tomcat server. */ public void startContainer() throws LifecycleException { // start server container.start(); // add shutdown hook to stop server Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { stopContainer(); } }); }
/** * Stops the embedded Tomcat server. */ public void stopContainer() { try { if (container != null) { container.stop(); logger.info("Stopped container"); } } catch (LifecycleException exception) { logger.warn("Cannot Stop Tomcat" + exception.getMessage()); } }
container.setCatalinaHome( configurationDir.getAbsolutePath() ); container.setCatalinaBase( configurationDir.getAbsolutePath() ); ( (Catalina) container ).setConfigFile( serverXml.getPath() ); ( (Catalina) container ).setRedirectStreams( true ); ( (Catalina) container ).setUseNaming( this.useNaming ); container.start(); container = new Embedded(); container.setCatalinaHome( configurationDir.getAbsolutePath() ); MemoryRealm memoryRealm = new MemoryRealm(); container.setRealm( memoryRealm ); container.setUseNaming( useNaming ); Host host = container.createHost( "localHost", appBase ); Engine engine = container.createEngine(); engine.setName( "localEngine-" + port ); engine.addChild( host ); engine.setDefaultHost( host.getName() ); container.addEngine( engine ); Connector httpConnector = container.createConnector( (InetAddress) null, port, protocol ); httpConnector.setMaxPostSize( maxPostSize ); if ( httpsPort > 0 ) container.addConnector( httpConnector );
public Connector createConnector(String address, int port, boolean secure) { String protocol = "http"; if (secure) { protocol = "https"; } return createConnector(address, port, protocol); }
/** * Construct a new instance of this class with specified properties. * * @param realm Realm implementation to be inherited by all components * (unless overridden further down the container hierarchy) */ public Embedded(Realm realm) { super(); setRealm(realm); setSecurityProtection(); }
/** * Start nested components ({@link Connector}s and {@link Engine}s) and * implement the requirements of * {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected void startInternal() throws LifecycleException { if( log.isInfoEnabled() ) log.info("Starting tomcat server"); // Validate the setup of our required system properties initDirs(); // Initialize some naming specific properties initNaming(); setState(LifecycleState.STARTING); // Start our defined Engines first for (int i = 0; i < engines.length; i++) { engines[i].start(); } // Start our defined Connectors second for (int i = 0; i < connectors.length; i++) { ((Lifecycle) connectors[i]).start(); } }
/** * Construct a new instance of this class with specified properties. * * @param logger Logger implementation to be inherited by all components * (unless overridden further down the container hierarchy) * @param realm Realm implementation to be inherited by all components * (unless overridden further down the container hierarchy) */ public Embedded(org.apache.catalina.Logger logger, Realm realm) { super(); setLogger(logger); setRealm(realm); setSecurityProtection(); }
public void onInitialization(String rootDir, String instanceName, boolean useNaming, Logger logger, String embeddedClassName) throws Exception { Class c = Class.forName(embeddedClassName); _embedded = (Embedded) c.newInstance(); _embedded.setUseNaming(useNaming); _embedded.setLogger(logger); _engine = _embedded.createEngine(); _embedded.addEngine(_engine); }
removeConnector(connectors[n]);
public Connector createConnector(String address, int port, boolean secure) { String protocol = "http"; if (secure) { protocol = "https"; } return createConnector(address, port, protocol); }
/** * Construct a new instance of this class with specified properties. * * @param realm Realm implementation to be inherited by all components * (unless overridden further down the container hierarchy) */ public Embedded(Realm realm) { super(); setRealm(realm); setSecurityProtection(); }
/** * Start nested components ({@link Connector}s and {@link Engine}s) and * implement the requirements of * {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected void startInternal() throws LifecycleException { if( log.isInfoEnabled() ) log.info("Starting tomcat server"); // Validate the setup of our required system properties initDirs(); // Initialize some naming specific properties initNaming(); setState(LifecycleState.STARTING); // Start our defined Engines first for (int i = 0; i < engines.length; i++) { engines[i].start(); } // Start our defined Connectors second for (int i = 0; i < connectors.length; i++) { ((Lifecycle) connectors[i]).start(); } }
removeConnector(connectors[n]); } catch (Exception ex){ log.log(Level.SEVERE, LogFacade.CONNECTOR_STOP_EXCEPTION, ex);
container = new Embedded(); container.setCatalinaHome(catalinaHome); container.setRealm(new MemoryRealm()); Context rootContext = container.createContext(path, webappDir); rootContext.setLoader(loader); rootContext.setReloadable(true); Host localHost = container.createHost("localHost", new File("target").getAbsolutePath()); localHost.addChild(rootContext); Engine engine = container.createEngine(); engine.setName("localEngine"); engine.addChild(localHost); engine.setDefaultHost(localHost.getName()); container.addEngine(engine); Connector httpConnector = container.createConnector((InetAddress) null, port, false); container.addConnector(httpConnector); container.setAwait(true); container.start(); try { if (container != null) { container.stop();
public Connector createConnector(String address, int port, boolean secure) { String protocol = "http"; if (secure) { protocol = "https"; } return createConnector(address, port, protocol); }
/** * Construct a new instance of this class with specified properties. * * @param realm Realm implementation to be inherited by all components * (unless overridden further down the container hierarchy) */ public Embedded(Realm realm) { super(); setRealm(realm); setSecurityProtection(); }
/** * Start nested components ({@link Connector}s and {@link Engine}s) and * implement the requirements of * {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected void startInternal() throws LifecycleException { if( log.isInfoEnabled() ) log.info("Starting tomcat server"); // Validate the setup of our required system properties initDirs(); // Initialize some naming specific properties initNaming(); setState(LifecycleState.STARTING); // Start our defined Engines first for (int i = 0; i < engines.length; i++) { engines[i].start(); } // Start our defined Connectors second for (int i = 0; i < connectors.length; i++) { ((Lifecycle) connectors[i]).start(); } }