Methods Summary |
---|
private void | configureJmxConnectorServerDriver()
driver.setAuthentication(true);
driver.setAuthenticator(createJMXAuthenticator());
driver.setLogger(this.sLogger);
driver.setMBeanServer(this.getAssociatedMBS());
driver.setRmiRegistrySecureFlag(new Boolean(System.getProperty(RmiTweaks.SECURE_RMI_REGISTRY)).booleanValue());
try {
driver.setProtocol(RemoteJmxProtocol.instance(connectorConfig.getProtocol()));
driver.setPort(Integer.parseInt(connectorConfig.getPort()));
driver.setBindAddress(connectorConfig.getAddress());
handleSsl();
}
catch (final Exception e) {
throw new ServerLifecycleException(e.getMessage());
}
|
private javax.management.remote.JMXAuthenticator | createJMXAuthenticator()
final ASJMXAuthenticator authenticator = new ASJMXAuthenticator();
// TODO: If domain.xml is not present, can not configure authentication
authenticator.setRealmName(connectorConfig.getAuthRealmName());
authenticator.setLoginDriver(new ASLoginDriverImpl());
return authenticator;
|
private javax.management.MBeanServer | getAssociatedMBS()
/*
final String returnAllMBS = null;
final ArrayList list = MBeanServerFactory.findMBeanServer(returnAllMBS);
if (list.isEmpty())
throw new RuntimeException("Initialize the MBeanServers first...");
return (MBeanServer)list.get(0); //for now
*/
return ( MBeanServerFactory.getMBeanServer() );
|
private java.util.Map | getEnvironment()
final Map env = new HashMap();
return ( env );
|
private void | handleIsEnabled(java.lang.String port)Handles the enabled flag on system-jmx-connector. On dev profile, it is okay that this
flag is set to false. But for other profiles, it has to be true as the inter server
communication depends on it.
/* Implementation note: This could have been handled using the Pluggable
* Feature Factory, but since there isn't much pluggable behavior, I am going to
* rely on the system property. In general, this should not be done.
*/
if (isEE() && !isEnabled) {
//EE and not enabled is not fine
final String msg = sm.getString("rjmx.lc.disabled_ee_na", port);
throw new ServerLifecycleException(msg);
}
if (!isEE() && !isEnabled) {
//PE and not enabled is fine - log and move on
sLogger.log(Level.INFO, "rjmx.lc.not_enabled", port);
}
//other 2 cases are implicitly handled
|
private void | handleSsl()
final boolean ssl = connectorConfig.isSecurityEnabled();
RMIServerSocketFactory sf = null;
if (ssl) {
driver.setSsl(ssl);
Ssl sslc = connectorConfig.getSsl();
if (sslc == null)
sslc = initDefaultSslConfiguration();
sf = new AdminSslServerSocketFactory(sslc, connectorConfig.getAddress());
RMIClientSocketFactory cf = new AdminRMISSLClientSocketFactory();
driver.setRmiClientSocketFactory(cf);
} else sf = new RMIMultiHomedServerSocketFactory(connectorConfig.getAddress());
driver.setRmiServerSocketFactory(sf);
|
private void | handleSupportedProtocol()
final String pfc = connectorConfig.getProtocol();
if (RemoteJmxProtocol.RMIJRMP != RemoteJmxProtocol.instance(pfc)) {
final String port = connectorConfig.getPort();
final String setP = connectorConfig.getProtocol();
final String supportedP = RemoteJmxProtocol.RMIJRMP.getName();
final String msg = sm.getString("rjmx.lc.unsupported_protocol", port, setP, supportedP);
throw new ServerLifecycleException (msg);
}
|
private void | initConnectorConfig()
//This is the AdminService config bean
AdminService as = ServerBeansFactory.getConfigBean(initContext.getConfigContext()).
getAdminService();
connectorConfig = as.getJmxConnectorByName(as.getSystemJmxConnectorName());
if (connectorConfig.isEnabled()) {
this.isEnabled = true;
}
|
private com.sun.enterprise.config.serverbeans.Ssl | initDefaultSslConfiguration()
Ssl ssl = new Ssl();
ssl.setCertNickname(ServerHelper.DEFAULT_CERT_NICKNAME);
ssl.setClientAuthEnabled(false);
ssl.setSsl2Enabled(false);
ssl.setSsl3Enabled(true);
ssl.setTlsEnabled(true);
ssl.setTlsRollbackEnabled(true);
return ssl;
|
private boolean | isEE()
boolean isEE = false;
final String eepffc = SystemPropertyConstants.CLUSTER_AWARE_FEATURE_FACTORY_CLASS;
final String pn = PluggableFeatureFactory.PLUGGABLE_FEATURES_PROPERTY_NAME;
final String pv = System.getProperty(pn);
if (eepffc.equals(pv)) {
isEE = true;
}
return ( isEE );
|
public void | onInitialization(com.sun.enterprise.server.ServerContext sc)
try {
initContext = sc;
initConnectorConfig();
handleIsEnabled(connectorConfig.getPort());
handleSupportedProtocol();
if (isEnabled) {
driver = new JmxConnectorServerDriver();
configureJmxConnectorServerDriver();
}
}
catch(Exception e) {
throw new ServerLifecycleException(e.getMessage(), e);
}
|
public void | onReady(com.sun.enterprise.server.ServerContext sc)
|
public void | onShutdown()
try {
if (isEnabled) {
driver.stopConnectorServer(cs);
driver.stopConnectorServer(jconsolecs);
}
else {
final String msg = "JmxConnectorLifeCycle.onShutdown: Connector Server not enabled at port: " + connectorConfig.getPort() + ", its shutdown is not required";
sLogger.fine(msg);
}
}
catch (final Exception e) {
throw new ServerLifecycleException(e.getMessage());
}
|
public void | onStartup(com.sun.enterprise.server.ServerContext sc)
try {
setupClientSide();
if (isEnabled) {
this.cs = driver.startConnectorServer();
// start the connector server for third party jmx clients like
// JConsole on a thread
new Thread(
new Runnable() {
public void run() {
try {
jconsolecs = driver.startJconsoleConnectorServer();
} catch (IOException ex) {
sLogger.info("rjmx.connector_server.failed_startup");
}
}
} ).start();
}
else {
final String msg = "JmxConnectorLifeCycle.onStartup: Connector Server not enabled at port: " + connectorConfig.getPort();
sLogger.fine(msg);
}
} catch (Exception e) {
throw new ServerLifecycleException(e.getMessage(), e);
}
|
public void | onTermination()
|
private void | setupClientSide()A method to set up the client side of the TLS connection. Here is the scenario: When
the system jmx connector is set up with TLS enabled, all the other server instances
need to have the RMIClientSocketFactory related environment. This method ensures that.
Since this method is called when the server end is being brought up with the startup, it
ensures that the setup happens early. This is also required in case of cascading where
the server instances have the TLS setup on the jmx-connectors that are started in their
life cycle. Even if the jmx connectors are not set up with TLS, it is okay to
setup the client side.
String serverName = System.getProperty(SystemPropertyConstants.SERVER_NAME);
String certNickName = ServerHelper.getCertNickname(
initContext.getConfigContext(), serverName);
new ServerClientEnvSetter(certNickName).setup();
|