@Test public void noRegisterWithMBeanServer() throws Exception { ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean(); bean.afterPropertiesSet(); try { // Try to get the connector bean. getServer().getObjectInstance(ObjectName.getInstance(OBJECT_NAME)); fail("Instance should not be found"); } catch (InstanceNotFoundException ex) { // expected } finally { bean.destroy(); } }
@Test public void registerWithMBeanServer() throws Exception { //Added a brief snooze here - seems to fix occasional //java.net.BindException: Address already in use errors Thread.sleep(1); ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean(); bean.setObjectName(OBJECT_NAME); bean.afterPropertiesSet(); try { // Try to get the connector bean. ObjectInstance instance = getServer().getObjectInstance(ObjectName.getInstance(OBJECT_NAME)); assertNotNull("ObjectInstance should not be null", instance); } finally { bean.destroy(); } }
@Test public void startupWithLocatedServer() throws Exception { ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean(); bean.afterPropertiesSet(); try { checkServerConnection(getServer()); } finally { bean.destroy(); } }
@Test public void startupWithSuppliedServer() throws Exception { //Added a brief snooze here - seems to fix occasional //java.net.BindException: Address already in use errors Thread.sleep(1); ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean(); bean.setServer(getServer()); bean.afterPropertiesSet(); try { checkServerConnection(getServer()); } finally { bean.destroy(); } }
@Bean public ConnectorServerFactoryBean connectorServerFactoryBean() { log.debug("Creating connector server factory bean"); ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean(); bean.setDaemon(true); return bean; }
public void afterPropertiesSet() throws Exception { csfb = new org.springframework.jmx.support.ConnectorServerFactoryBean(); csfb.setDaemon(daemon); csfb.setThreaded(threaded); csfb.setRegistrationBehavior(registrationBehavior); csfb.setEnvironmentMap(environment); csfb.setObjectName(objectName); serviceUrl = serviceUrl.replaceAll(" ", ""); csfb.setServiceUrl(serviceUrl); MBeanServer mbs = server; if (policy != null) { LOGGER.info("Configuring JMX authorization policy: {}", policy); if (mbs == null) { mbs = createProxyForPolicy(JmxUtils.locateMBeanServer()); } else { mbs = createProxyForPolicy(mbs); } } csfb.setServer(mbs); csfb.afterPropertiesSet(); LOGGER.info("JMX connector available at: {}", serviceUrl); }