use of javax.management.ObjectInstance in project Activiti by Activiti.
the class DefaultManagementAgent method registerMBeanWithServer.
private void registerMBeanWithServer(Object obj, ObjectName name, boolean forceRegistration) throws JMException {
boolean exists = isRegistered(name);
if (exists) {
if (forceRegistration) {
LOG.info("ForceRegistration enabled, unregistering existing MBean with ObjectName: {}", name);
server.unregisterMBean(name);
} else {
// okay ignore we do not want to force it and it could be a shared
// instance
LOG.debug("MBean already registered with ObjectName: {}", name);
}
}
// register bean if by force or not exists
ObjectInstance instance = null;
if (forceRegistration || !exists) {
LOG.trace("Registering MBean with ObjectName: {}", name);
instance = server.registerMBean(obj, name);
}
// modify the name
if (instance != null) {
ObjectName registeredName = instance.getObjectName();
LOG.debug("Registered MBean with ObjectName: {}", registeredName);
mbeansRegistered.put(name, registeredName);
}
}
use of javax.management.ObjectInstance in project aries by apache.
the class MBeanHolder method register.
void register(final MBeanServer server) {
ObjectInstance instance;
try {
instance = server.registerMBean(mbean, requestedObjectName);
registrations.put(server, instance.getObjectName());
} catch (InstanceAlreadyExistsException e) {
log.error("register: Failure registering MBean " + mbean, e);
} catch (MBeanRegistrationException e) {
log.error("register: Failure registering MBean " + mbean, e);
} catch (NotCompliantMBeanException e) {
log.error("register: Failure registering MBean " + mbean, e);
}
}
use of javax.management.ObjectInstance in project geode by apache.
the class ManagementAdapter method handleManagerStart.
/**
* Handles all the distributed mbean creation part when a Manager is started
*/
public void handleManagerStart() throws ManagementException {
if (!isServiceInitialised("handleManagerStart")) {
return;
}
MBeanJMXAdapter jmxAdapter = service.getJMXAdapter();
Map<ObjectName, Object> registeredMBeans = jmxAdapter.getLocalGemFireMBean();
DistributedSystemBridge dsBridge = new DistributedSystemBridge(service);
this.aggregator = new MBeanAggregator(dsBridge);
// register the aggregator for Federation framework to use
service.addProxyListener(aggregator);
/*
* get the local member mbean as it need to be provided to aggregator first
*/
MemberMXBean localMember = service.getMemberMXBean();
ObjectName memberObjectName = MBeanJMXAdapter.getMemberMBeanName(InternalDistributedSystem.getConnectedInstance().getDistributedMember());
FederationComponent addedComp = service.getLocalManager().getFedComponents().get(memberObjectName);
service.afterCreateProxy(memberObjectName, MemberMXBean.class, localMember, addedComp);
for (ObjectName objectName : registeredMBeans.keySet()) {
if (objectName.equals(memberObjectName)) {
continue;
}
Object object = registeredMBeans.get(objectName);
ObjectInstance instance;
try {
instance = mbeanServer.getObjectInstance(objectName);
String className = instance.getClassName();
Class cls = ClassLoadUtil.classFromName(className);
Type[] intfTyps = cls.getGenericInterfaces();
FederationComponent newObj = service.getLocalManager().getFedComponents().get(objectName);
for (Type intfTyp1 : intfTyps) {
Class intfTyp = (Class) intfTyp1;
service.afterCreateProxy(objectName, intfTyp, object, newObj);
}
} catch (InstanceNotFoundException e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed in Registering distributed mbean ");
}
throw new ManagementException(e);
} catch (ClassNotFoundException e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed in Registering distributed mbean");
}
throw new ManagementException(e);
}
}
}
use of javax.management.ObjectInstance in project geode by apache.
the class MBeanJMXAdapter method hasNotificationSupport.
/**
* Checks whether an MBean implements notification support classes or not
*
* @param objectName
* @return if this MBean can be a notification broadcaster
*/
public boolean hasNotificationSupport(ObjectName objectName) {
try {
if (!isRegistered(objectName)) {
return false;
}
ObjectInstance instance = mbeanServer.getObjectInstance(objectName);
String className = instance.getClassName();
Class cls = ClassLoadUtil.classFromName(className);
Type[] intfTyps = cls.getGenericInterfaces();
for (int i = 0; i < intfTyps.length; i++) {
Class intfTyp = (Class) intfTyps[i];
if (intfTyp.equals(NotificationEmitter.class)) {
return true;
}
}
Class supreClassTyp = (Class) cls.getGenericSuperclass();
if (supreClassTyp != null && supreClassTyp.equals(NotificationBroadcasterSupport.class)) {
return true;
}
} catch (InstanceNotFoundException e) {
throw new ManagementException(e);
} catch (ClassNotFoundException e) {
throw new ManagementException(e);
}
return false;
}
use of javax.management.ObjectInstance in project geode by apache.
the class LocalProcessControllerJUnitTest method setUp.
@Before
public void setUp() throws Exception {
pid = ProcessUtils.identifyPid();
final Process process = new Process(pid, true);
this.objectName = ObjectName.getInstance(getClass().getSimpleName() + ":testName=" + testName.getMethodName());
this.server = ManagementFactory.getPlatformMBeanServer();
final ObjectInstance instance = this.server.registerMBean(process, objectName);
assertNotNull(instance);
}
Aggregations