Fields Summary |
---|
private static final String | AS_SELECTOR_PROVIDER |
private static final String | SELECTOR_PROVIDER_PROP |
private static final String | QUICK_STARTUP |
private static final String | DEFAULT_SELECTOR_PROVIDER |
private static final String | SERVER_VM_FLAG |
private static boolean | areJDKClassesCreatable |
private static final Logger | logger |
private com.sun.enterprise.config.serverbeans.Config | conf |
private com.sun.enterprise.admin.server.core.AdminChannelLifecycle | adminlc |
Methods Summary |
---|
private void | abortAdminService(com.sun.enterprise.server.ServerContext sc, int port)
try {
createAdminChannelLifecycle();
adminlc.onAbort(port);
ASSocketService.waitForClientNotification();
adminlc.onShutdown();
adminlc.onTermination();
} catch (Exception e) {
e.printStackTrace();
}
|
private static boolean | areJDKClassesCreatable()The whole quick startup for the appserver hinges on whether we can
wrap JDK socket layer. So check it.
if ( areJDKClassesCreatable ) {
return true;
}
try {
Class clazz = Class.forName(DEFAULT_SELECTOR_PROVIDER);
java.lang.reflect.Method createMeth = clazz.getMethod("create",
new Class[] {});
createMeth.invoke( null, new Object[] {} );
//Attempt to create the JDK socketimpl.
new ASPlainSocketImpl();
} catch( Exception e ) {
logFine( "Exception in areJDKClassesCreatable : " + e );
return false;
}
//Since we could invoke "create" on a DefaultSelectorProvider object
//successfully, everything is ok
areJDKClassesCreatable = true;
return true;
|
private void | createAdminChannelLifecycle()
if (adminlc == null) {
adminlc = new AdminChannelLifecycle();
}
|
private void | exitServer(com.sun.enterprise.server.ServerContext context, int port)
logFine("Stopped MQ");
abortAdminService(context, port);
logFine("Aborted admin service");
// Abort the server.
System.exit(1);
|
private boolean | initializeASSocketService()This method does the following:
- Checks if the class sun.nio.ch.DefaultSelectorProvider is present
and its "create()" method is callable
- Sets the system property that defines our impl of a SelectorProvider
- Creates and sets the SocketImplFactories for ServerSocket and Socket
If a problem occurs in any of the above steps, we simply assume that we
should use the default startup behavior and proceed
if ( isQuickStartupEnabled()) {
// Set the NIO SelectorProvider impl property
System.setProperty(SELECTOR_PROVIDER_PROP,
AS_SELECTOR_PROVIDER);
// Set the SocketImplFactories for ServerSocket and Socket
// Note: if either of these factories was already set (almost
// impossible), an exception will be thrown and server will abort.
ServerSocket.setSocketFactory( new ASServerSocketFactory() );
Socket.setSocketImplFactory( new ASClientSocketFactory() );
return true;
}
return false;
|
private void | initializeAdminService(com.sun.enterprise.server.ServerContext context)
createAdminChannelLifecycle();
adminlc.onInitialization(context);
|
public static boolean | isQuickStartupEnabled()
// enabled by default if system property absent
String quickStartValue = System.getProperty(QUICK_STARTUP);
String vmName = System.getProperty("java.vm.name", "");
if (quickStartValue == null && vmName.contains(SERVER_VM_FLAG)){
return false;
}
if ( quickStartValue == null || quickStartValue.equals("true") ) {
return areJDKClassesCreatable();
}
return false;
|
private static void | logFine(java.lang.String msg)
if (logger.isLoggable(Level.FINE)) {
logger.fine( msg );
}
|
private void | setupInitialServices(com.sun.enterprise.server.ServerContext context)
startAdminService( context );
|
private void | setupSocketListeners(com.sun.enterprise.server.ServerContext scontext)
ConfigContext ctxt = scontext.getConfigContext();
conf = ServerBeansFactory.getConfigBean( ctxt );
// Start HTTP listener ports
HttpService httpService = conf.getHttpService();
int backlog = 0;
try {
backlog = Integer.parseInt(
httpService.getConnectionPool().getMaxPendingCount());
} catch (Exception e) {
logger.log(Level.WARNING, e.getMessage());
}
HttpListener[] httpListeners = httpService.getHttpListener();
for ( int i=0; i<httpListeners.length; i++ ) {
if ( !httpListeners[i].isEnabled() )
continue;
startService(httpListeners[i], false, backlog);
logFine("Started ASSocketService for HTTP(S) ");
}
// Start IIOP listener ports
IiopService iiopService = conf.getIiopService();
IiopListener[] iiopListeners = iiopService.getIiopListener();
for ( int i=0; i<iiopListeners.length; i++ ) {
if ( !iiopListeners[i].isEnabled() )
continue;
startService(iiopListeners[i]);
logFine("Started ASSocketService for IIOP(S)");
}
// Start JMX Connector ports
AdminService adminService = conf.getAdminService();
JmxConnector[] jmxConnectors = adminService.getJmxConnector();
for ( int i=0; i<jmxConnectors.length; i++ ) {
if ( !jmxConnectors[i].isEnabled() )
continue;
startService(jmxConnectors[i], false, 0);
logFine("Started ASSocketService for JMX Connector ");
}
// Start MQ ports
JmsService jmsService_ = conf.getJmsService();
String defaultJmsHost = jmsService_.getDefaultJmsHost();
JmsHost jmsHost_ = null;
if (defaultJmsHost==null || defaultJmsHost.equals("")) {
jmsHost_ = ServerBeansFactory.getJmsHostBean(ctxt);
} else {
jmsHost_ = jmsService_.getJmsHostByName(defaultJmsHost);
}
if (jmsService_.getType().equalsIgnoreCase("embedded") &&
jmsHost_ != null && jmsHost_.isEnabled()) {
ASSocketServiceConfig ssConfig =
new ASSocketServiceConfig(jmsHost_);
ssConfig.setPortTag(ServerTags.PORT);
(new ASSocketService(ssConfig)).start();
logFine("Started ASSocketService for JMS ");
}
|
public boolean | startASSocketServices(com.sun.enterprise.server.ServerContext context)
try {
if ( initializeASSocketService() ) {
logFine("STARTING ASSocketService");
ASSocketService.initialize();
initializeAdminService(context);
setupSocketListeners(context);
setupInitialServices(context);
logger.log( Level.INFO, "socketservice.init_done");
return true;
}
logFine("Not using ASSocketService. Proceeding with normal startup");
} catch ( PortConflictException pex ) {
logger.log(Level.SEVERE, "socketservice.port_conflict",
new Object[]{String.valueOf(pex.getConflictedPort())});
exitServer(context, pex.getConflictedPort());
} catch ( Exception ex ) {
logger.log(Level.SEVERE, "socketservice.unknown_ex", ex);
exitServer(context,0);
}
return false;
|
private void | startAdminService(com.sun.enterprise.server.ServerContext context)
logFine( "About to start AdminService ");
createAdminChannelLifecycle();
adminlc.onStartup(context);
adminlc.onReady(context);
|
private void | startLifecycle(com.sun.appserv.server.ServerLifecycle lifecycle, com.sun.enterprise.server.ServerContext sc)
lifecycle.onInitialization(sc);
lifecycle.onStartup(sc);
lifecycle.onReady(sc);
|
private void | startService(com.sun.enterprise.config.ConfigBean bean)
startService(bean,true,0);
|
private void | startService(com.sun.enterprise.config.ConfigBean bean, boolean flag, int backlog)
ASSocketServiceConfig ssConfig =
new ASSocketServiceConfig(bean);
ssConfig.setAddressTag(ServerTags.ADDRESS);
ssConfig.setPortTag(ServerTags.PORT);
ssConfig.setStartSelector(flag);
ssConfig.setBacklog(backlog);
(new ASSocketService(ssConfig)).start();
|
private void | stopLifecycle(com.sun.appserv.server.ServerLifecycle lifecycle)
try {
lifecycle.onShutdown();
} catch (Throwable t) {
logger.log(Level.SEVERE, "socketservice.stop_lc_ex", t);
}
try {
lifecycle.onTermination();
} catch (Throwable t) {
logger.log(Level.SEVERE, "socketservice.stop_lc_ex", t);
}
|