org.ow2.petals.microkernel.jbi.management.MBeanNameBuilderImpl Maven / Gradle / Ivy
/**
* Copyright (c) 2005-2012 EBM WebSourcing, 2012-2016 Linagora
*
* This program/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 program/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 program/library; If not, see http://www.gnu.org/licenses/
* for the GNU Lesser General Public License version 2.1.
*/
package org.ow2.petals.microkernel.jbi.management;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import org.objectweb.fractal.fraclet.annotations.Component;
import org.objectweb.fractal.fraclet.annotations.Interface;
/**
* Implement the JBI MBeanNames
element, which is offered to
* components for creating mBean names for their optional mBean elements. It
* also offers methods to the Manager
for creating JBI elements
* mBean names (binding and engine components, and system services components).
*
* @author Adrien LOUIS - EBM WebSourcing
*/
@Component(provides = @Interface(name = "service", signature = MBeanNameBuilder.class))
public class MBeanNameBuilderImpl implements MBeanNameBuilder {
private static final String BINDING = "binding";
private static final String CUSTOM = "custom";
private static final String ENGINE = "engine";
private static final String INSTALLER = "installer";
private static final String SYSTEM = "system";
private static String domain = "org.ow2.petals";
/**
* {@inheritDoc}
*/
public ObjectName createBindingComponentMBeanName(String name) {
return this.createMBeanName(name, BINDING);
}
/**
* {@inheritDoc}
*/
public ObjectName createCustomComponentMBeanName(String customName) {
return this.createMBeanName(customName, CUSTOM);
}
/**
* {@inheritDoc}
*/
public ObjectName createEngineComponentMBeanName(String name) {
return this.createMBeanName(name, ENGINE);
}
/**
* {@inheritDoc}
*/
public ObjectName createInstallerMBeanName(String name) {
return this.createMBeanName(name, INSTALLER);
}
/**
* Create a MBean name
*
* @param name
* @param type
* @return
*/
private ObjectName createMBeanName(String name, String type) {
ObjectName on = null;
String theType = type != null ? "type=" + type + "," : "";
String theName = "name=" + name;
try {
on = new ObjectName(domain + ":" + theType + theName);
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
// internal use, so exeception should never be thrown
}
return on;
}
/**
*
* @param name
* @return
*/
public ObjectName createSystemComponentMBeanName(String name) {
return this.createMBeanName(name, SYSTEM);
}
/**
*
*/
public String getJmxDomainName() {
return domain;
}
/**
* {@inheritDoc}
*/
public String getNameFromMBeanName(ObjectName objectName) {
return objectName.getKeyProperty("name");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy