@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(); } }
doRegister(this.connectorServer, this.objectName); unregisterBeans(); throw ex;
@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(); } }
@Test public void startupWithLocatedServer() throws Exception { ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean(); bean.afterPropertiesSet(); try { checkServerConnection(getServer()); } finally { bean.destroy(); } }
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); }
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(); }
/** * Stop the {@code JMXConnectorServer} managed by an instance of this class. * Automatically called on {@code ApplicationContext} shutdown. * @throws IOException if there is an error stopping the connector server */ @Override public void destroy() throws IOException { try { if (this.connectorServer != null) { if (logger.isInfoEnabled()) { logger.info("Stopping JMX connector server: " + this.connectorServer); } this.connectorServer.stop(); } } finally { unregisterBeans(); } }
@Bean public ConnectorServerFactoryBean connectorServerFactoryBean() { log.debug("Creating connector server factory bean"); ConnectorServerFactoryBean bean = new ConnectorServerFactoryBean(); bean.setDaemon(true); return bean; }
public void setServiceUrl(String serviceUrl) { super.setServiceUrl(serviceUrl); this.serviceUrl = serviceUrl; }
public void destroy() throws Exception { if (csfb != null) { try { csfb.destroy(); } finally { csfb = null; } } }
@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(); } }
/** * Stop the {@code JMXConnectorServer} managed by an instance of this class. * Automatically called on {@code ApplicationContext} shutdown. * @throws IOException if there is an error stopping the connector server */ @Override public void destroy() throws IOException { try { if (this.connectorServer != null) { if (logger.isInfoEnabled()) { logger.info("Stopping JMX connector server: " + this.connectorServer); } this.connectorServer.stop(); } } finally { unregisterBeans(); } }
doRegister(this.connectorServer, this.objectName); unregisterBeans(); throw ex;
/** * Stop the {@code JMXConnectorServer} managed by an instance of this class. * Automatically called on {@code ApplicationContext} shutdown. * @throws IOException if there is an error stopping the connector server */ @Override public void destroy() throws IOException { try { if (this.connectorServer != null) { if (logger.isInfoEnabled()) { logger.info("Stopping JMX connector server: " + this.connectorServer); } this.connectorServer.stop(); } } finally { unregisterBeans(); } }
doRegister(this.connectorServer, this.objectName); unregisterBeans(); throw ex;