@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(); } }
public void afterPropertiesSet() throws JMException, IOException { super.afterPropertiesSet(); log.info("Started remote JMX connector. Point your JMX console to: " + serviceUrl); }
public void afterPropertiesSet() throws JMException, IOException { Node node = configClientService.currentNode(); int port = node.getPort().intValue() + 1; Integer mbeanPort = node.getParameters().getMbeanPort(); if (mbeanPort != null && mbeanPort != 0) {// 做个兼容处理,<=4.2.2版本没有mbeanPort设置 port = mbeanPort; } String serviceUrl = MessageFormat.format(SERVER_URL, String.valueOf(port)); super.setServiceUrl(serviceUrl); super.setObjectName("connector:name=rmi"); // 直接使用port getRegistry(port); super.afterPropertiesSet(); }
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); }