@Test public void connectionIsCreatedForLocalServer() throws IOException { JmxConnectionProvider server = mock(JmxConnectionProvider.class); MBeanServer mBeanServerConnection = mock(MBeanServer.class); when(server.isLocal()).thenReturn(true); when(server.getLocalMBeanServer()).thenReturn(mBeanServerConnection); JMXConnection jmxConnection = factory.makeObject(server); assertThat(jmxConnection.getMBeanServerConnection()).isSameAs(mBeanServerConnection); }
@Override @Nonnull public JMXConnection makeObject(@Nonnull JmxConnectionProvider server) throws IOException { if (server.isLocal()) { return new JMXConnection(null, server.getLocalMBeanServer()); } else { JMXConnector connection = server.getServerConnection(); return new JMXConnection(connection, connection.getMBeanServerConnection()); } }
MBeanServerConnectionFactory extends BaseKeyedPoolableObjectFactory<JmxConnectionProvider, JMXConnection> { @Override @Nonnull public JMXConnection makeObject(@Nonnull JmxConnectionProvider server) throws IOException { if (server.isLocal()) { return new JMXConnection(null, server.getLocalMBeanServer()); } else { JMXConnector connection = server.getServerConnection(); return new JMXConnection(connection, connection.getMBeanServerConnection()); } } }
MBeanServerConnectionFactory extends BaseKeyedPoolableObjectFactory<JmxConnectionProvider, JMXConnection> { @Override @Nonnull public JMXConnection makeObject(@Nonnull JmxConnectionProvider server) throws IOException { if (server.isLocal()) { return new JMXConnection(null, server.getLocalMBeanServer()); } else { JMXConnector connection = server.getServerConnection(); return new JMXConnection(connection, connection.getMBeanServerConnection()); } } MBeanServerConnectionFactory(); }
MBeanServerConnectionFactory extends BaseKeyedPoolableObjectFactory<JmxConnectionProvider, JMXConnection> { @Override @Nonnull public JMXConnection makeObject(@Nonnull JmxConnectionProvider server) throws IOException { if (server.isLocal()) { return new JMXConnection(null, server.getLocalMBeanServer()); } else { JMXConnector connection = server.getServerConnection(); return new JMXConnection(connection, connection.getMBeanServerConnection()); } } MBeanServerConnectionFactory(); @Override @Nonnull JMXConnection makeObject(@Nonnull JmxConnectionProvider server); @Override void destroyObject(@Nonnull JmxConnectionProvider key, @Nonnull final JMXConnection jmxConnection); @Override boolean validateObject(@Nonnull JmxConnectionProvider key, @Nonnull JMXConnection jmxConnection); }
MBeanServerConnectionFactory extends BaseKeyedPoolableObjectFactory<JmxConnectionProvider, JMXConnection> { @Override @Nonnull public JMXConnection makeObject(@Nonnull JmxConnectionProvider server) throws IOException { if (server.isLocal()) { return new JMXConnection(null, server.getLocalMBeanServer()); } else { JMXConnector connection = server.getServerConnection(); return new JMXConnection(connection, connection.getMBeanServerConnection()); } } MBeanServerConnectionFactory(); @Override @Nonnull JMXConnection makeObject(@Nonnull JmxConnectionProvider server); @Override void destroyObject(@Nonnull JmxConnectionProvider key, @Nonnull final JMXConnection jmxConnection); @Override boolean validateObject(@Nonnull JmxConnectionProvider key, @Nonnull JMXConnection jmxConnection);  }