Search in sources :

Example 1 with JMXContainer

use of org.apache.openejb.assembler.monitoring.JMXContainer in project tomee by apache.

the class Assembler method createContainer.

public void createContainer(final ContainerInfo serviceInfo) throws OpenEJBException {
    final ObjectRecipe serviceRecipe = createRecipe(Collections.<ServiceInfo>emptyList(), serviceInfo);
    serviceRecipe.setProperty("id", serviceInfo.id);
    serviceRecipe.setProperty("transactionManager", props.get(TransactionManager.class.getName()));
    serviceRecipe.setProperty("securityService", props.get(SecurityService.class.getName()));
    serviceRecipe.setProperty("properties", new UnsetPropertiesRecipe());
    // MDB container has a resource adapter string name that
    // must be replaced with the real resource adapter instance
    replaceResourceAdapterProperty(serviceRecipe);
    final Object service = serviceRecipe.create();
    // we forced it
    serviceRecipe.getUnsetProperties().remove("id");
    // we forced it
    serviceRecipe.getUnsetProperties().remove("securityService");
    logUnusedProperties(serviceRecipe, serviceInfo);
    final Class interfce = serviceInterfaces.get(serviceInfo.service);
    checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id);
    bindService(serviceInfo, service);
    setSystemInstanceComponent(interfce, service);
    props.put(interfce.getName(), service);
    props.put(serviceInfo.service, service);
    props.put(serviceInfo.id, service);
    containerSystem.addContainer(serviceInfo.id, (Container) service);
    // Update the config tree
    config.containerSystem.containers.add(serviceInfo);
    logger.getChildLogger("service").debug("createService.success", serviceInfo.service, serviceInfo.id, serviceInfo.className);
    if (Container.class.isInstance(service) && LocalMBeanServer.isJMXActive()) {
        final ObjectName objectName = ObjectNameBuilder.uniqueName("containers", serviceInfo.id, service);
        try {
            LocalMBeanServer.get().registerMBean(new DynamicMBeanWrapper(new JMXContainer(serviceInfo, (Container) service)), objectName);
            containerObjectNames.add(objectName);
        } catch (final Exception | NoClassDefFoundError e) {
        // no-op
        }
    }
}
Also used : JMXContainer(org.apache.openejb.assembler.monitoring.JMXContainer) Container(org.apache.openejb.Container) DynamicMBeanWrapper(org.apache.openejb.monitoring.DynamicMBeanWrapper) ObjectRecipe(org.apache.xbean.recipe.ObjectRecipe) JMXContainer(org.apache.openejb.assembler.monitoring.JMXContainer) UnsetPropertiesRecipe(org.apache.xbean.recipe.UnsetPropertiesRecipe) InvalidObjectException(java.io.InvalidObjectException) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ObjectStreamException(java.io.ObjectStreamException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) UndeployException(org.apache.openejb.UndeployException) DefinitionException(javax.enterprise.inject.spi.DefinitionException) ConstructionException(org.apache.xbean.recipe.ConstructionException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ValidationException(javax.validation.ValidationException) MalformedObjectNameException(javax.management.MalformedObjectNameException) DuplicateDeploymentIdException(org.apache.openejb.DuplicateDeploymentIdException) TimeoutException(java.util.concurrent.TimeoutException) NamingException(javax.naming.NamingException) OpenEJBException(org.apache.openejb.OpenEJBException) DeploymentException(javax.enterprise.inject.spi.DeploymentException) NoSuchApplicationException(org.apache.openejb.NoSuchApplicationException) MalformedURLException(java.net.MalformedURLException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) ObjectName(javax.management.ObjectName)

Aggregations

IOException (java.io.IOException)1 InvalidObjectException (java.io.InvalidObjectException)1 ObjectStreamException (java.io.ObjectStreamException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 DefinitionException (javax.enterprise.inject.spi.DefinitionException)1 DeploymentException (javax.enterprise.inject.spi.DeploymentException)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 MBeanRegistrationException (javax.management.MBeanRegistrationException)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ObjectName (javax.management.ObjectName)1 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)1 NamingException (javax.naming.NamingException)1 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)1 ValidationException (javax.validation.ValidationException)1 Container (org.apache.openejb.Container)1 DuplicateDeploymentIdException (org.apache.openejb.DuplicateDeploymentIdException)1 NoSuchApplicationException (org.apache.openejb.NoSuchApplicationException)1