Search in sources :

Example 6 with ObjectNameBuilder

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();
    }
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) Options(org.apache.openejb.loader.Options) StatsInterceptor(org.apache.openejb.monitoring.StatsInterceptor) ResourceException(javax.resource.ResourceException) NamingException(javax.naming.NamingException) OpenEJBException(org.apache.openejb.OpenEJBException) UnavailableException(javax.resource.spi.UnavailableException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SystemException(org.apache.openejb.SystemException) EjbTransactionUtil.handleApplicationException(org.apache.openejb.core.transaction.EjbTransactionUtil.handleApplicationException) EjbTransactionUtil.handleSystemException(org.apache.openejb.core.transaction.EjbTransactionUtil.handleSystemException) ApplicationException(org.apache.openejb.ApplicationException) ConstraintViolationException(javax.validation.ConstraintViolationException) ObjectName(javax.management.ObjectName) ObjectNameBuilder(org.apache.openejb.monitoring.ObjectNameBuilder) ActivationSpec(javax.resource.spi.ActivationSpec) ResourceException(javax.resource.ResourceException) ManagedMBean(org.apache.openejb.monitoring.ManagedMBean) MBeanServer(javax.management.MBeanServer) LocalMBeanServer(org.apache.openejb.monitoring.LocalMBeanServer)

Example 7 with ObjectNameBuilder

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();
}
Also used : ObjectNameBuilder(org.apache.openejb.monitoring.ObjectNameBuilder)

Example 8 with ObjectNameBuilder

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;
}
Also used : ObjectNameBuilder(org.apache.openejb.monitoring.ObjectNameBuilder)

Example 9 with ObjectNameBuilder

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);
}
Also used : ActiveMQEndpointWorker(org.apache.activemq.ra.ActiveMQEndpointWorker) ObjectNameBuilder(org.apache.openejb.monitoring.ObjectNameBuilder) MalformedObjectNameException(javax.management.MalformedObjectNameException) ObjectName(javax.management.ObjectName)

Example 10 with ObjectNameBuilder

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);
    }
}
Also used : OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) ObjectNameBuilder(org.apache.openejb.monitoring.ObjectNameBuilder) AttributeNotFoundException(javax.management.AttributeNotFoundException) ReflectionException(javax.management.ReflectionException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) MBeanServer(javax.management.MBeanServer) LocalMBeanServer(org.apache.openejb.monitoring.LocalMBeanServer)

Aggregations

ObjectNameBuilder (org.apache.openejb.monitoring.ObjectNameBuilder)16 ObjectName (javax.management.ObjectName)10 MBeanServer (javax.management.MBeanServer)8 LocalMBeanServer (org.apache.openejb.monitoring.LocalMBeanServer)8 NamingException (javax.naming.NamingException)6 OpenEJBException (org.apache.openejb.OpenEJBException)6 ApplicationException (org.apache.openejb.ApplicationException)5 ManagedMBean (org.apache.openejb.monitoring.ManagedMBean)5 StatsInterceptor (org.apache.openejb.monitoring.StatsInterceptor)5 IOException (java.io.IOException)4 EJBContext (javax.ejb.EJBContext)4 Context (javax.naming.Context)4 BeanContext (org.apache.openejb.BeanContext)4 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)4 SystemException (org.apache.openejb.SystemException)4 InstanceContext (org.apache.openejb.core.InstanceContext)4 ThreadContext (org.apache.openejb.core.ThreadContext)4 InterceptorData (org.apache.openejb.core.interceptor.InterceptorData)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 RemoteException (java.rmi.RemoteException)3