use of mx4j.tools.adaptor.http.HttpAdaptor in project geode by apache.
the class ConnectionNotificationFilterImpl method startHttpAdaptor.
/**
* Defines and starts the JMX Http Adaptor service from MX4J.
* <p>
* If {@link AgentConfig#isHttpEnabled} returns false, then this adaptor will not be started.
*/
private void startHttpAdaptor() {
if (!this.agentConfig.isHttpEnabled())
return;
try {
ObjectName objName = getHttpAdaptorName();
// make sure this adaptor is not already registered...
if (getMBeanServer().isRegistered(objName)) {
// dunno how we got here...
logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_HTTPADAPTOR_ALREADY_REGISTERED_AS__0, objName));
return;
}
this.httpAdaptor = new HttpAdaptor();
// validate and set host and port values...
if (this.agentConfig.getHttpPort() > 0) {
this.httpAdaptor.setPort(this.agentConfig.getHttpPort());
logger.info(LogMarker.CONFIG, LocalizedMessage.create(LocalizedStrings.AgentImpl_HTTP_ADAPTOR_LISTENING_ON_PORT__0, this.agentConfig.getHttpPort()));
} else {
logger.error(LocalizedMessage.create(LocalizedStrings.AgentImpl_INCORRECT_PORT_VALUE__0, this.agentConfig.getHttpPort()));
}
if (this.agentConfig.getHttpBindAddress() != null) {
String host = this.agentConfig.getHttpBindAddress();
logger.info(LogMarker.CONFIG, LocalizedMessage.create(LocalizedStrings.AgentImpl_HTTP_ADAPTOR_LISTENING_ON_ADDRESS__0, host));
this.httpAdaptor.setHost(host);
} else {
logger.error(LocalizedMessage.create(LocalizedStrings.AgentImpl_INCORRECT_NULL_HOSTNAME));
}
// SSL support...
MX4JServerSocketFactory socketFactory = new MX4JServerSocketFactory(this.agentConfig.isAgentSSLEnabled(), this.agentConfig.isHttpSSLRequireAuth(), this.agentConfig.getAgentSSLProtocols(), this.agentConfig.getAgentSSLCiphers(), this.agentConfig.getGfSecurityProperties());
this.httpAdaptor.setSocketFactory(socketFactory);
// authentication (user login) support...
if (this.agentConfig.isHttpAuthEnabled()) {
// this pops up a login dialog from the browser...
// only
this.httpAdaptor.setAuthenticationMethod(MX4J_HTTPADAPTOR_BASIC_AUTHENTICATION);
// basic
// works
this.httpAdaptor.addAuthorization(this.agentConfig.getHttpAuthUser(), this.agentConfig.getHttpAuthPassword());
}
// add the XsltProcessor...
this.httpAdaptor.setProcessorName(createXsltProcessor());
// register the HttpAdaptor and snap on the XsltProcessor...
getMBeanServer().registerMBean(this.httpAdaptor, objName);
this.httpAdaptor.start();
} catch (VirtualMachineError err) {
SystemFailure.initiateFailure(err);
// now, so don't let this thread continue.
throw err;
} catch (Throwable t) {
// Whenever you catch Error or Throwable, you must also
// catch VirtualMachineError (see above). However, there is
// _still_ a possibility that you are dealing with a cascading
// error condition, so you also need to check to see if the JVM
// is still usable:
SystemFailure.checkFailure();
logger.error(LocalizedMessage.create(LocalizedStrings.AgentImpl_FAILED_TO_START_HTTPADAPTOR__0, t.getMessage()));
throw new StartupException(LocalizedStrings.AgentImpl_FAILED_TO_START_HTTPADAPTOR__0.toLocalizedString(t.getMessage()), t);
}
}
use of mx4j.tools.adaptor.http.HttpAdaptor in project ignite by apache.
the class AbstractDiscoverySelfTest method afterTestsStopped.
/** {@inheritDoc} */
@Override
protected void afterTestsStopped() throws Exception {
assert spis.size() > 1;
assert spis.size() == spiRsrcs.size();
for (DiscoverySpi spi : spis) {
spi.setListener(null);
spi.spiStop();
}
for (IgniteTestResources rscrs : spiRsrcs) {
MBeanServer mBeanSrv = rscrs.getMBeanServer();
mBeanSrv.unregisterMBean(new ObjectName(HTTP_ADAPTOR_MBEAN_NAME));
rscrs.stopThreads();
}
for (HttpAdaptor adaptor : httpAdaptors) adaptor.stop();
// Clear.
spis.clear();
spiRsrcs.clear();
httpAdaptors.clear();
spiStartTime = 0;
tearDown();
}
use of mx4j.tools.adaptor.http.HttpAdaptor in project ignite by apache.
the class AbstractDiscoverySelfTest method getMBeanServer.
/**
* @param idx Index.
* @return MBean server.
* @throws Exception If failed.
*/
private MBeanServer getMBeanServer(int idx) throws Exception {
HttpAdaptor adaptor = new HttpAdaptor();
MBeanServer srv = MBeanServerFactory.createMBeanServer();
adaptor.setPort(Integer.valueOf(GridTestProperties.getProperty("discovery.mbeanserver.selftest.baseport")) + idx);
srv.registerMBean(adaptor, new ObjectName(HTTP_ADAPTOR_MBEAN_NAME));
adaptor.start();
httpAdaptors.add(adaptor);
return srv;
}
use of mx4j.tools.adaptor.http.HttpAdaptor in project ignite by apache.
the class GridTcpCommunicationSpiLanTest method getMBeanServer.
/**
* @return Configured MBean server.
* @throws Exception If failed.
*/
private MBeanServer getMBeanServer() throws Exception {
HttpAdaptor mbeanAdaptor = new HttpAdaptor();
MBeanServer mbeanSrv = MBeanServerFactory.createMBeanServer();
mbeanAdaptor.setPort(Integer.valueOf(GridTestProperties.getProperty("comm.mbeanserver.selftest.baseport")));
mbeanSrv.registerMBean(mbeanAdaptor, new ObjectName("mbeanAdaptor:protocol=HTTP"));
mbeanAdaptor.start();
return mbeanSrv;
}
Aggregations