Java 类javax.management.remote.JMXConnectorProvider 实例源码

项目:karaf-eik    文件:JMXTransportRegistry.java   
/**
 * Notifies the listeners of the add/remove
 *
 * @param jmxConnectorProviders
 *      the {@link JMXConnectorProvider}s that changed
 * @param event
 *          the type of change
 */
public void notify(List<JMXConnectorProvider> jmxConnectorProviders, EventType e) {
    this.event = e;

    Object[] copiedListeners = jmxTransportListeners.getListeners();
    for (int i= 0; i < copiedListeners.length; i++) {
        listener = (IJMXTransportListener)copiedListeners[i];
        for(JMXConnectorProvider connector : jmxConnectorProviders) {
            jmxConnectorProvider = connector;
                  SafeRunner.run(this);
        }
    }

    listener = null;
    jmxConnectorProvider = null;
}
项目:karaf-eik    文件:JMXTransportRegistry.java   
private void loadTransportConfigurationElements(IConfigurationElement[] configElems) {
    for (int j = 0; j < configElems.length; j++) {
        final IConfigurationElement element = configElems[j];
        final String elementName = element.getName();
        String transport;
        if (elementName.equals("transport") //$NON-NLS-1$
                && null != element.getAttribute("class") //$NON-NLS-1$
                && null != (transport = element.getAttribute("protocol"))) //$NON-NLS-1$
        {
            try {
                Object obj = element.createExecutableExtension("class"); //$NON-NLS-1$
                if (obj instanceof JMXConnectorProvider) {
                    transports.put(transport, (JMXConnectorProvider)obj);
                }
            } catch (CoreException e) {
                KarafWorkbenchActivator.getLogger().error(e.getMessage(), e);
            }
        }
    }

    final List<JMXConnectorProvider> transportsAdded = new ArrayList<JMXConnectorProvider>();
    transportsAdded.addAll(transports.values());

    getJMXTransportrNotifier().notify(transportsAdded, EventType.ADDED);
}
项目:karaf-eik    文件:JMXTransportRegistry.java   
@Override
   public JMXConnectorProvider getConnectorProvider(String key) {
    final JMXConnectorProvider connector = transports.get(key);

    // TODO: Add logging

    return connector;
}
项目:karaf-eik    文件:JMXTransportRegistry.java   
@Override
   public JMXConnector getJMXConnector(JMXServiceDescriptor serviceDescriptor) {
    try {
        final String transport = serviceDescriptor.getUrl().getProtocol();

        final JMXConnectorProvider connectorProvider = getConnectorProvider(transport);

        final JMXServiceURL url = getJMXServiceURL(
                                serviceDescriptor.getUrl().getHost(),
                                serviceDescriptor.getUrl().getPort(),
                                serviceDescriptor.getUrl().getProtocol(),
                                serviceDescriptor.getDomain());

        Map<String, Object> environment = null;
        if (serviceDescriptor.getUsername() != null) {
            environment = new HashMap<String, Object>();
            String[] credentials = new String[] {
                        serviceDescriptor.getUsername(),
                        serviceDescriptor.getPassword()
            };
            environment.put(JMXConnector.CREDENTIALS, credentials);
        }

        return connectorProvider.newJMXConnector(url, environment);
    } catch (Exception e) {
        KarafWorkbenchActivator.getLogger().error(e.getMessage(), e);
        return null;
    }
}
项目:karaf-eik    文件:JMXTransportRegistry.java   
public JMXTransportRegistry() {
    transports = Collections.synchronizedMap(new HashMap<String, JMXConnectorProvider>());
    jmxTransportListeners = new ListenerList();
}
项目:karaf-eik    文件:IJMXTransportRegistry.java   
/**
 * Getter for a {@link JMXConnectorProvider} using its name as a retrieval
 * key
 *
 * @param name the name of the {@code JMXConnectorProvider}
 *
 * @return
 *      the {@code JMXConnectorProvider} for the given name, or null if it
 *      does not exist
 */
public JMXConnectorProvider getConnectorProvider(String name);