java类javax.management.remote.JMXServiceURL的实例源码

JmxConnectionHelper.java 文件源码 项目:Byter 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Creates the jmxConnector with passed parameters.
 * @param host host address
 * @param port port of the host
 * @param user username (null possible)
 * @param pass password (null possible)
 * @return connected JMXConnector
 * @throws IOException IOException
 */
public static JMXConnector buildJmxMPConnector(final String host, final int port, final String user, final String pass) throws IOException {
    try {
        final JMXServiceURL serviceURL = new JMXServiceURL("jmxmp", host,port);
        if("null".equals(user) || "null".equals(pass) || user == null || pass == null){
            return JMXConnectorFactory.connect(serviceURL);
        }
        final Map<String, Object> environment = new HashMap<>();
        environment.put("jmx.remote.credentials", new String[]{user,pass});
        environment.put(Context.SECURITY_PRINCIPAL, user);
        environment.put(Context.SECURITY_CREDENTIALS, pass);
        return JMXConnectorFactory.connect(serviceURL,environment);
    } catch (MalformedURLException e) {
        log.log(Level.WARNING, "Malformed ServiceURL in buildJmxConnector");
        return null;
    }
}
ZooKeeperServerNewWizard.java 文件源码 项目:eZooKeeper 阅读 29 收藏 0 点赞 0 评论 0
@Override
public boolean performFinish() {

    String host = _Page1.getHost();
    int port = _Page1.getPort();

    _ServerDescriptor = new ZooKeeperServerDescriptor(host, port);

    if (_Page2.isJmxEnabled()) {
        JMXServiceURL jmxServiceUrl = _Page2.getServiceUrl();
        String userName = _Page2.getUserName();
        String password = _Page2.getPassword();

        // Generate a unique name
        String name = JMX_CONNECTION_NAME_PREFIX + UUID.randomUUID().toString();

        JmxConnectionDescriptor jmxConnectionDescriptor = new JmxConnectionDescriptor(name, jmxServiceUrl,
                userName, password);
        _ServerDescriptor.setJmxConnectionDescriptor(jmxConnectionDescriptor);
    }

    return true;
}
RMIConnectorLogAttributesTest.java 文件源码 项目:jdk8u-jdk 阅读 30 收藏 0 点赞 0 评论 0
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
RMIConnector.java 文件源码 项目:OpenJSharp 阅读 31 收藏 0 点赞 0 评论 0
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
JMXAgent.java 文件源码 项目:OperatieBRP 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Maak een connector server instantie.
 *
 * @return connector server
 * @throws IOException bij fouten
 */
private JMXConnectorServer createConnectorServer() throws IOException {
    final Properties configuration = readConfiguration();
    final MBeanServer server = locateMBeanServer();

    final JMXServiceURL url = new JMXServiceURL(SimpleJmx.PROTOCOL,
            configuration.getProperty("jmx.host", DEFAULT_HOST), Integer.parseInt(configuration.getProperty("jmx.port", DEFAULT_PORT)));

    final Map<String,Object> environment = new HashMap<>();
    Properties authentication = new Properties();
    authentication.setProperty("admin", "admin");
    environment.put("jmx.remote.authenticator", new PropertiesAuthenticator(authentication));
    environment.put("jmx.remote.accesscontroller", new AllAccessController());

    return JMXConnectorServerFactory.newJMXConnectorServer(url, environment, server);
}
ProviderTest.java 文件源码 项目:openjdk-jdk10 阅读 28 收藏 0 点赞 0 评论 0
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
ListenerScaleTest.java 文件源码 项目:openjdk-jdk10 阅读 25 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception {
    if (Platform.isDebugBuild()) {
        System.out.println("Running on a debug build. Performance test not applicable. Skipping.");
        return;
    }
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
RMIConnector.java 文件源码 项目:jdk8u-jdk 阅读 29 收藏 0 点赞 0 评论 0
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
ConnectorStopDeadlockTest.java 文件源码 项目:jdk8u-jdk 阅读 27 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception {
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    RMIJRMPServerImplSub impl = new RMIJRMPServerImplSub();

    System.out.println("Creating connectorServer");
    connectorServer = new RMIConnectorServer(url, null, impl, mbs);
    System.out.println("Starting connectorServer");
    connectorServer.start();
    System.out.println("Making client");
    RMIConnection cc = impl.newClient(null);
    System.out.println("Closing client");
    cc.close();
    if (connectorServer.isActive()) {
        System.out.println("Stopping connectorServer");
        connectorServer.stop();
    }
    if (failure == null)
        System.out.println("TEST PASSED, no deadlock");
    else
        System.out.println("TEST FAILED");
}
TestManager.java 文件源码 项目:openjdk-jdk10 阅读 35 收藏 0 点赞 0 评论 0
private static void connect(String pid, String address) throws Exception {
    if (address == null) {
        throw new RuntimeException("Local connector address for " +
                                   pid + " is null");
    }

    System.out.println("Connect to process " + pid + " via: " + address);

    JMXServiceURL url = new JMXServiceURL(address);
    JMXConnector c = JMXConnectorFactory.connect(url);
    MBeanServerConnection server = c.getMBeanServerConnection();

    System.out.println("Connected.");

    RuntimeMXBean rt = newPlatformMXBeanProxy(server,
        RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
    System.out.println(rt.getName());

    // close the connection
    c.close();
}
IIOPURLTest.java 文件源码 项目:jdk8u-jdk 阅读 24 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception {
    JMXServiceURL inputAddr =
        new JMXServiceURL("service:jmx:iiop://");
    JMXConnectorServer s;
    try {
        s = JMXConnectorServerFactory.newJMXConnectorServer(inputAddr, null, null);
    } catch (java.net.MalformedURLException x) {
        try {
            Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie");
            throw new RuntimeException("MalformedURLException thrown but iiop appears to be supported");
        } catch (ClassNotFoundException expected) { }
        System.out.println("IIOP protocol not supported, test skipped");
        return;
    }
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    mbs.registerMBean(s, new ObjectName("a:b=c"));
    s.start();
    JMXServiceURL outputAddr = s.getAddress();
    if (!outputAddr.getURLPath().startsWith("/ior/IOR:")) {
        throw new RuntimeException("URL path should start with \"/ior/IOR:\": " +
                                   outputAddr);
    }
    System.out.println("IIOP URL path looks OK: " + outputAddr);
    JMXConnector c = JMXConnectorFactory.connect(outputAddr);
    System.out.println("Successfully got default domain: " +
                       c.getMBeanServerConnection().getDefaultDomain());
    c.close();
    s.stop();
}
DefaultPogamutPlatform.java 文件源码 项目:Pogamut3 阅读 32 收藏 0 点赞 0 评论 0
/**
 * @return Connection to a remote MBeanServer
 * @throws cz.cuni.amis.utils.exception.PogamutException
 */
public MBeanServerConnection getMBeanServerConnection() throws PogamutException {
    // connect through RMI and get the proxy
    try {
        if (mbsc == null) {
            JMXServiceURL url = getMBeanServerURL();
            JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
            mbsc = jmxc.getMBeanServerConnection();
        }
        return mbsc;
    } catch (IOException iOException) {
        throw new PogamutException("IO exception occured while creating remote MBeanServer connector.",
                iOException);
    }
}
AbstractJMXAgentObserver.java 文件源码 项目:Pogamut3 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Creates JMX wrapper for agent on specified adress and adds it to the list
 * of all connected agents.
 * @param serviceUrl URL of the JMX service where remote agent resides eg. service:jmx:rmi:///jndi/rmi://localhost:9999/server
 * @param objectName name of the MBean representing agent eg. myDomain:name=MyAgent1
 */
protected void addJMXAgentFromAdress(String serviceUrl, ObjectName objectName) throws IOException {
    JMXServiceURL url = new JMXServiceURL(serviceUrl);
    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
    MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

    IAgent agent = JMX.newMXBeanProxy(mbsc, objectName, IAgent.class);

    agents.add(agent);
}
JMXConnection.java 文件源码 项目:SuitAgent 阅读 26 收藏 0 点赞 0 评论 0
private JMXConnector getJMXConnector(JMXConnectUrlInfo jmxConnectUrlInfo) throws Exception {
    JMXServiceURL url = new JMXServiceURL(jmxConnectUrlInfo.getRemoteUrl());
    JMXConnector connector;
    if(jmxConnectUrlInfo.isAuthentication()){
        connector = JMXConnectWithTimeout.connectWithTimeout(url,jmxConnectUrlInfo.getJmxUser()
                ,jmxConnectUrlInfo.getJmxPassword(),10, TimeUnit.SECONDS);
    }else{
        connector = JMXConnectWithTimeout.connectWithTimeout(url,null,null,10, TimeUnit.SECONDS);
    }
    return connector;
}
JMXConnectWithTimeout.java 文件源码 项目:SuitAgent 阅读 35 收藏 0 点赞 0 评论 0
/**
 * JMX连接
 * @param url
 * JMX连接地址
 * @param jmxUser
 * JMX授权用户 null为无授权用户
 * @param jmxPassword
 * JMX授权密码 null为无授权密码
 * @param timeout
 * 超时时间
 * @param unit
 * 超时单位
 * @return
 * @throws IOException
 */
public static JMXConnector connectWithTimeout( final JMXServiceURL url,String jmxUser,String jmxPassword, long timeout, TimeUnit unit) throws Exception {
    final BlockingQueue<Object> blockingQueue = new ArrayBlockingQueue<>(1);
    ExecuteThreadUtil.execute(() -> {
        try {
            JMXConnector connector;
            if(jmxUser != null && jmxPassword != null){
                Map<String,Object> env = new HashMap<>();
                String[] credentials = new String[] { jmxUser, jmxPassword };
                env.put(JMXConnector.CREDENTIALS, credentials);
                connector = JMXConnectorFactory.connect(url,env);
            }else{
                connector = JMXConnectorFactory.connect(url,null);
            }
            if (!blockingQueue.offer(connector))
                connector.close();
        } catch (Throwable t) {
            blockingQueue.offer(t);
        }
    });

    Object result = BlockingQueueUtil.getResult(blockingQueue,timeout,unit);
    blockingQueue.clear();


    if (result instanceof JMXConnector){
        return (JMXConnector) result;
    }else if (result == null){
        throw new SocketTimeoutException("Connect timed out: " + url);
    }else if(result instanceof Throwable){
        throw new IOException("JMX Connect Failed : " + url,((Throwable) result));
    }
    return null;
}
ZooKeeperServerNewWizardPage2.java 文件源码 项目:eZooKeeper 阅读 25 收藏 0 点赞 0 评论 0
public JMXServiceURL getServiceUrl() {
    Text jmxUrlText = (Text) getGridComposite().getControl(CONTROL_NAME_JMX_URL_TEXT);
    String jmxServiceUrlString = jmxUrlText.getText();

    try {
        return new JMXServiceURL(jmxServiceUrlString);
    }
    catch (MalformedURLException e) {
        // Validation should ensure that this should never happen
        return null;
    }
}
JmxConnection.java 文件源码 项目:eZooKeeper 阅读 24 收藏 0 点赞 0 评论 0
public void connect() {

        close();

        // JMXServiceURL jmxUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + _HostPortString + "/jmxrmi");

        JmxConnectionDescriptor descriptor = getDescriptor();
        JMXServiceURL jmxUrl = descriptor.getJmxServiceUrl();

        String userName = descriptor.getUserName();
        String password = descriptor.getPassword();

        Map<String, String[]> env = null;

        if (userName != null) {
            env = new HashMap<String, String[]>();
            env.put(JMXConnector.CREDENTIALS, new String[] { userName, password });
        }

        try {
            _JMXConnector = JMXConnectorFactory.connect(jmxUrl, env);
            _MBeanServerConnection = _JMXConnector.getMBeanServerConnection();

            _Connected = true;

            addConnectionListener();
            addMBeanServerDelegateListener();

            // System.out.println("JMX connection opened");
            fireConnectionStateChanged(null);
        }
        catch (IOException e) {
        }

    }
JMXConnectorServerProviderImpl.java 文件源码 项目:jdk8u-jdk 阅读 30 收藏 0 点赞 0 评论 0
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL url,
                                                Map<String,?> map,
                                                MBeanServer mbeanServer)
    throws IOException {
    final String protocol = url.getProtocol();
    called = true;
    System.out.println("JMXConnectorServerProviderImpl called");
    if(protocol.equals("rmi"))
        return new RMIConnectorServer(url, map, mbeanServer);
    if(protocol.equals("throw-provider-exception"))
        throw new JMXProviderException("I have been asked to throw");

    throw new IllegalArgumentException("UNKNOWN PROTOCOL");
}
JmxConnectionNewWizardPage1.java 文件源码 项目:eZooKeeper 阅读 27 收藏 0 点赞 0 评论 0
public JMXServiceURL getServiceUrl() {
    Text jmxUrlText = (Text) getGridComposite().getControl(CONTROL_NAME_JMX_URL_TEXT);
    String jmxServiceUrlString = jmxUrlText.getText();

    try {
        return new JMXServiceURL(jmxServiceUrlString);
    }
    catch (MalformedURLException e) {
        // Validation should ensure that this should never happen
        return null;
    }
}
ServerProvider.java 文件源码 项目:openjdk-jdk10 阅读 29 收藏 0 点赞 0 评论 0
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL serviceURL,
                                                Map<String,?> environment,
                                                MBeanServer mbeanServer)
        throws IOException {
    if (!serviceURL.getProtocol().equals("rmi")) {
        throw new MalformedURLException("Protocol not rmi: " +
                                        serviceURL.getProtocol());
    }
    return new RMIConnectorServer(serviceURL, environment, mbeanServer);
}
TestRawJmx.java 文件源码 项目:csap-core 阅读 30 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
        try {
            String host = "localhost"; host = "csseredapp-dev-03";
            String port = "8356"; //port = "8356";
            String mbeanName = "java.lang:type=Memory";
            String attributeName = "HeapMemoryUsage";



            JMXServiceURL jmxUrl = new JMXServiceURL(
                    "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi" );
//          jmxUrl = new JMXServiceURL(
//                  "service:jmx:rmi://localhost/jndi/rmi://" + host + ":" + port + "/jmxrmi" );

            logger.info("Target: " + jmxUrl ) ;

            JMXConnector jmxConnection = JMXConnectorFactory.connect( jmxUrl );

            logger.info("Got connections") ;

            CompositeData resultData = (CompositeData) jmxConnection.getMBeanServerConnection()
                    .getAttribute( new ObjectName(mbeanName), attributeName) ;

            logger.log(Level.INFO, "Got mbean: heapUsed: {0}", resultData.get( "used")) ;

            Thread.sleep( 5000 );
        } catch ( Exception ex ) {
            logger.log( Level.SEVERE, "Failed connection", ex );
        } 
    }
JMXEnv.java 文件源码 项目:fuck_zookeeper 阅读 46 收藏 0 点赞 0 评论 0
public static void setUp() throws IOException {
    MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();

    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();

   JMXServiceURL addr = cs.getAddress();

   cc = JMXConnectorFactory.connect(addr);
}
HelloAgent.java 文件源码 项目:rocketmq-flink-plugin 阅读 30 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws MalformedObjectNameException,
            NotCompliantMBeanException, InstanceAlreadyExistsException,
            MBeanRegistrationException, IOException {
        // 下面这种方式不能再JConsole中使用
//      MBeanServer server = MBeanServerFactory.createMBeanServer();
// 首先建立一个MBeanServer,MBeanServer用来管理我们的MBean,通常是通过MBeanServer来获取我们MBean的信息,间接
// 调用MBean的方法,然后生产我们的资源的一个对象。
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

        String domainName = "MyMBean";

//为MBean(下面的new Hello())创建ObjectName实例
        ObjectName helloName = new ObjectName(domainName+":name=HelloWorld");
// 将new Hello()这个对象注册到MBeanServer上去
        mbs.registerMBean(new Hello(),helloName);

// Distributed Layer, 提供了一个HtmlAdaptor。支持Http访问协议,并且有一个不错的HTML界面,这里的Hello就是用这个作为远端管理的界面
// 事实上HtmlAdaptor是一个简单的HttpServer,它将Http请求转换为JMX Agent的请求
        ObjectName adapterName = new ObjectName(domainName+":name=htmladapter,port=8082");
        HtmlAdaptorServer adapter = new HtmlAdaptorServer();
        adapter.start();
        mbs.registerMBean(adapter,adapterName);

        int rmiPort = 1099;
        Registry registry = LocateRegistry.createRegistry(rmiPort);

        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:"+rmiPort+"/"+domainName);
        JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
        jmxConnector.start();
    }
JMXListener.java 文件源码 项目:ditb 阅读 25 收藏 0 点赞 0 评论 0
public static JMXServiceURL buildJMXServiceURL(int rmiRegistryPort,
    int rmiConnectorPort) throws IOException {
  // Build jmxURL
  StringBuilder url = new StringBuilder();
  url.append("service:jmx:rmi://localhost:");
  url.append(rmiConnectorPort);
  url.append("/jndi/rmi://localhost:");
  url.append(rmiRegistryPort);
  url.append("/jmxrmi");

  return new JMXServiceURL(url.toString());

}
AuthorizationTest.java 文件源码 项目:openjdk-jdk10 阅读 35 收藏 0 点赞 0 评论 0
public void run(Map<String, Object> serverArgs, String clientArgs[]) {

        System.out.println("AuthorizationTest::run: Start") ;
        int errorCount = 0;

        try {
            // Initialise the server side
            JMXServiceURL urlToUse = createServerSide(serverArgs);

            // Run client side
            errorCount = runClientSide(clientArgs, urlToUse.toString());

            if ( errorCount == 0 ) {
                System.out.println("AuthorizationTest::run: Done without any error") ;
            } else {
                System.out.println("AuthorizationTest::run: Done with "
                        + errorCount
                        + " error(s)") ;
                throw new RuntimeException("errorCount = " + errorCount);
            }

            cs.stop();

        } catch(Exception e) {
            throw new RuntimeException(e);
        }

    }
ClientProvider.java 文件源码 项目:OpenJSharp 阅读 28 收藏 0 点赞 0 评论 0
public JMXConnector newJMXConnector(JMXServiceURL serviceURL,
                                    Map<String,?> environment)
        throws IOException {
    if (!serviceURL.getProtocol().equals("rmi")) {
        throw new MalformedURLException("Protocol not rmi: " +
                                        serviceURL.getProtocol());
    }
    return new RMIConnector(serviceURL, environment);
}
ServerProvider.java 文件源码 项目:OpenJSharp 阅读 39 收藏 0 点赞 0 评论 0
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL serviceURL,
                                                Map<String,?> environment,
                                                MBeanServer mbeanServer)
        throws IOException {
    if (!serviceURL.getProtocol().equals("iiop")) {
        throw new MalformedURLException("Protocol not iiop: " +
                                        serviceURL.getProtocol());
    }
    return new RMIConnectorServer(serviceURL, environment, mbeanServer);
}
ClientProvider.java 文件源码 项目:OpenJSharp 阅读 23 收藏 0 点赞 0 评论 0
public JMXConnector newJMXConnector(JMXServiceURL serviceURL,
                                    Map<String,?> environment)
        throws IOException {
    if (!serviceURL.getProtocol().equals("iiop")) {
        throw new MalformedURLException("Protocol not iiop: " +
                                        serviceURL.getProtocol());
    }
    return new RMIConnector(serviceURL, environment);
}
RMIConnectorServer.java 文件源码 项目:OpenJSharp 阅读 32 收藏 0 点赞 0 评论 0
static boolean isIiopURL(JMXServiceURL directoryURL, boolean strict)
    throws MalformedURLException {
    String protocol = directoryURL.getProtocol();
    if (protocol.equals("rmi"))
        return false;
    else if (protocol.equals("iiop"))
        return true;
    else if (strict) {

        throw new MalformedURLException("URL must have protocol " +
                                        "\"rmi\" or \"iiop\": \"" +
                                        protocol + "\"");
    }
    return false;
}
RMIConnector.java 文件源码 项目:OpenJSharp 阅读 27 收藏 0 点赞 0 评论 0
private RMIConnector(RMIServer rmiServer, JMXServiceURL address,
        Map<String, ?> environment) {
    if (rmiServer == null && address == null) throw new
            IllegalArgumentException("rmiServer and jmxServiceURL both null");
    initTransients();

    this.rmiServer = rmiServer;
    this.jmxServiceURL = address;
    if (environment == null) {
        this.env = Collections.emptyMap();
    } else {
        EnvHelp.checkAttributes(environment);
        this.env = Collections.unmodifiableMap(environment);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号