use of org.apache.openejb.monitoring.ObjectNameBuilder in project tomee by apache.
the class MdbContainer method deploy.
public void deploy(final BeanContext beanContext) throws OpenEJBException {
final Object deploymentId = beanContext.getDeploymentID();
if (!beanContext.getMdbInterface().equals(messageListenerInterface)) {
throw new OpenEJBException("Deployment '" + deploymentId + "' has message listener interface " + beanContext.getMdbInterface().getName() + " but this MDB container only supports " + messageListenerInterface);
}
// create the activation spec
final ActivationSpec activationSpec = createActivationSpec(beanContext);
if (inboundRecovery != null) {
inboundRecovery.recover(resourceAdapter, activationSpec, containerID.toString());
}
final Options options = new Options(beanContext.getProperties());
final int instanceLimit = options.get("InstanceLimit", this.instanceLimit);
// create the message endpoint
final MdbInstanceFactory instanceFactory = new MdbInstanceFactory(beanContext, securityService, instanceLimit);
final EndpointFactory endpointFactory = new EndpointFactory(activationSpec, this, beanContext, instanceFactory, xaResourceWrapper);
// update the data structures
// this must be done before activating the endpoint since the ra may immedately begin delivering messages
beanContext.setContainer(this);
beanContext.setContainerData(endpointFactory);
deployments.put(deploymentId, beanContext);
// Create stats interceptor
if (StatsInterceptor.isStatsActivated()) {
final StatsInterceptor stats = new StatsInterceptor(beanContext.getBeanClass());
beanContext.addFirstSystemInterceptor(stats);
final MBeanServer server = LocalMBeanServer.get();
final ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management");
jmxName.set("J2EEServer", "openejb");
jmxName.set("J2EEApplication", null);
jmxName.set("EJBModule", beanContext.getModuleID());
jmxName.set("StatelessSessionBean", beanContext.getEjbName());
jmxName.set("j2eeType", "");
jmxName.set("name", beanContext.getEjbName());
// register the invocation stats interceptor
try {
final ObjectName objectName = jmxName.set("j2eeType", "Invocations").build();
if (server.isRegistered(objectName)) {
server.unregisterMBean(objectName);
}
server.registerMBean(new ManagedMBean(stats), objectName);
endpointFactory.jmxNames.add(objectName);
} catch (final Exception e) {
logger.error("Unable to register MBean ", e);
}
}
// activate the endpoint
CURRENT.set(beanContext);
try {
resourceAdapter.endpointActivation(endpointFactory, activationSpec);
} catch (final ResourceException e) {
// activation failed... clean up
beanContext.setContainer(null);
beanContext.setContainerData(null);
deployments.remove(deploymentId);
throw new OpenEJBException(e);
} finally {
CURRENT.remove();
}
}
use of org.apache.openejb.monitoring.ObjectNameBuilder in project tomee by apache.
the class ServiceManager method getObjectName.
protected static ObjectName getObjectName(final String serviceName) {
final ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb");
jmxName.set("type", "ServerService");
jmxName.set("name", serviceName);
return jmxName.build();
}
use of org.apache.openejb.monitoring.ObjectNameBuilder in project tomee by apache.
the class SimpleServiceManager method getDiscoveryRegistryObjectName.
private static ObjectName getDiscoveryRegistryObjectName() {
if (null == objectName) {
final ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb");
jmxName.set("type", "Server");
jmxName.set("name", "DiscoveryRegistry");
objectName = jmxName.build();
}
return objectName;
}
use of org.apache.openejb.monitoring.ObjectNameBuilder in project tomee by apache.
the class ActiveMQResourceAdapter method addJMxControl.
private void addJMxControl(final BeanContext current, final String name) throws ResourceException {
if (name == null || "false".equalsIgnoreCase(name)) {
return;
}
final ActiveMQEndpointWorker worker = getWorker(current);
final ObjectName jmxName;
try {
jmxName = "true".equalsIgnoreCase(name) ? new ObjectNameBuilder().set("J2EEServer", "openejb").set("J2EEApplication", null).set("EJBModule", current.getModuleID()).set("StatelessSessionBean", current.getEjbName()).set("j2eeType", "control").set("name", current.getEjbName()).build() : new ObjectName(name);
} catch (final MalformedObjectNameException e) {
throw new IllegalArgumentException(e);
}
mbeanNames.put(current, jmxName);
LocalMBeanServer.registerSilently(new MdbJmxControl(worker), jmxName);
log.info("Deployed MDB control for " + current.getDeploymentID() + " on " + jmxName);
}
use of org.apache.openejb.monitoring.ObjectNameBuilder in project tomee by apache.
the class RemoteResourceMonitor method registerIfNot.
public void registerIfNot() {
// do it lazily
if (objectName != null) {
return;
}
final ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management");
jmxName.set("ObjectType", "Related Hosts");
objectName = jmxName.build();
final MBeanServer server = LocalMBeanServer.get();
try {
if (server.isRegistered(objectName)) {
server.unregisterMBean(objectName);
}
server.registerMBean(this, objectName);
} catch (final Exception e) {
throw new OpenEJBRuntimeException(e);
}
}
Aggregations