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

org.ow2.petals.admin.jmx.JMXRegistryAdministration Maven / Gradle / Ivy

/****************************************************************************
 *
 *  Copyright (c) 2012, EBM WebSourcing
 *
 *  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 (at your option) 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *****************************************************************************/

package org.ow2.petals.admin.jmx;

import java.util.List;
import java.util.Map;

import org.ow2.petals.admin.api.RegistryAdministration;
import org.ow2.petals.admin.api.exception.RegistryAdministrationException;
import org.ow2.petals.admin.api.exception.RegistryRegexpPatternException;
import org.ow2.petals.admin.jmx.registry.JMXRegistryView;
import org.ow2.petals.admin.registry.RegistryView;
import org.ow2.petals.jmx.JMXClient;
import org.ow2.petals.jmx.exception.ConnectionErrorException;
import org.ow2.petals.jmx.exception.EndpointRegistryServiceDoesNotExistException;
import org.ow2.petals.jmx.exception.EndpointRegistryServiceErrorException;
import org.ow2.petals.jmx.exception.PetalsAdminServiceErrorException;

import com.ebmwebsourcing.easycommons.lang.UncheckedException;

/**
 * 
 * @author Nicolas Oddoux - EBM WebSourcing
 */
public class JMXRegistryAdministration implements RegistryAdministration {

    protected JMXRegistryAdministration() {
    }
    
    @Override
    public void synchronizeRegistry() throws RegistryAdministrationException {
        try {
            JMXClient client = JMXClientConnection.getJMXClient();
            client.getEndpointRegistryClient().synchronizeRegistry();
        } catch (ConnectionErrorException cee) {
            throw new RegistryAdministrationException(cee);
        } catch (PetalsAdminServiceErrorException pasee) {
            throw new RegistryAdministrationException(pasee);
        } catch (EndpointRegistryServiceDoesNotExistException ersdnee) {
            throw new RegistryAdministrationException(ersdnee);
        } catch (EndpointRegistryServiceErrorException erssee) {
            throw new RegistryAdministrationException(erssee);
        }
    }

    @Override
    public void synchronizeRegistryOnAllNodes() {
        throw new UncheckedException("Not yet implemented");
    }


    @Override
    public RegistryView getRegistryContent(String endpointNameRegex, String serviceNameRegex,
            String interfaceNameRegex) throws RegistryRegexpPatternException,
            RegistryAdministrationException {
        try {
            JMXClient client = JMXClientConnection.getJMXClient();
            List> endpointMaps = client.getEndpointRegistryClient()
                    .getAllEndpoints();
            return new JMXRegistryView(endpointMaps, endpointNameRegex, serviceNameRegex, interfaceNameRegex);
        } catch (ConnectionErrorException cee) {
            throw new RegistryAdministrationException(cee);
        } catch (NumberFormatException nfe) {
            throw new RegistryAdministrationException(nfe);
        } catch (EndpointRegistryServiceErrorException ersee) {
            throw new RegistryAdministrationException(ersee);
        } catch (EndpointRegistryServiceDoesNotExistException ersdnee) {
            throw new RegistryAdministrationException(ersdnee);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy