All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.jasmine.probe.jmxconnection.simple.JmxConnectionServiceImpl Maven / Gradle / Ivy

There is a newer version: 1.3.0
Show newest version
/**
 * JASMINe
 * Copyright (C) 2011 Bull S.A.S.
 * Contact: [email protected]
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id: JmxConnectionServiceImpl.java 8951 2011-09-20 10:57:20Z durieuxp $
 * --------------------------------------------------------------------------
 */

package org.ow2.jasmine.probe.jmxconnection.simple;

import java.util.HashMap;
import java.util.Map;

import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Invalidate;
import org.apache.felix.ipojo.annotations.Provides;
import org.apache.felix.ipojo.annotations.ServiceProperty;
import org.apache.felix.ipojo.annotations.Validate;
import org.ow2.jasmine.probe.jmxconnection.JmxConnectionException;
import org.ow2.jasmine.probe.jmxconnection.JmxConnectionFactory;
import org.ow2.jasmine.probe.jmxconnection.JmxConnectionService;
import org.ow2.util.log.Log;
import org.ow2.util.log.LogFactory;

/**
 * Simple (non pooled) implementation of the JmxConnectionService.
 * @author danesa
 */
@Component(name="JmxConnectionService", public_factory=false)
@Provides
public class JmxConnectionServiceImpl implements JmxConnectionService {

    @ServiceProperty(value="basic")
    private String nature;

    /**
     * Name of the property giving jmx connection user
     */
    static public final String PROP_USER = "user";

    /**
     * Name of the property giving jmx connection password
     */
    static public final String PROP_PASSWORD = "pwd";

    /**
     * Name of the property giving the provider pacakges
     */
    static public final String PROP_PROTOCOL_PROVIDER_PACKAGES = "provider";

    /**
     * Name of the property giving the target
     */
    static public final String PROP_TARGET = "target";

    /**
     * Name of the property giving the managed server's name
     */
    static public final String PROP_SERVER = "server";

    /**
     * Name of the property giving the managed server's domain
     */
    static public final String PROP_DOMAIN = "domain";

    /**
     * Name of the property giving the managed server's URL
     */
    static public final String PROP_URL = "url";

    /**
     * Name of the property giving the MBean's OBJECT_NAME
     */
    static public final String PROP_MBEAN = "mbean";

    /**
     * For each URL: gives the JmxConnectionFactory
     */
    private Map factories = new HashMap();

    private static Log logger = LogFactory.getLog(JmxConnectionService.class);

    @Validate
    public void start() {
        logger.debug("JmxConnectionService activated.");
    }

    @Invalidate
    public void stop() {
        logger.debug("JmxConnectionService stopped.");
    }

    /**
     * Get the JmxConnectionFactory for these parameters.
     * @param url jmx url for the target
     * @param props properties for connector creation
     * @throws JmxConnectionException Thrown if connector could not be created, contains the cause.
     */
    public synchronized JmxConnectionFactory getJmxConnectionFactory(String url, Map props)
            throws JmxConnectionException {
        logger.debug(url);
        JmxConnectionFactoryImpl fact = factories.get(url);
        if (fact == null) {
            fact = new JmxConnectionFactoryImpl(url, props);
            factories.put(url, fact);
        }
        return fact;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy