Search in sources :

Example 6 with Container

use of org.apache.openejb.Container in project tomee by apache.

the class EjbSelect method execute_byte.

public static byte execute_byte(final Object obj, final String methodSignature, final Object... args) throws FinderException {
    final BeanContext beanContext = (BeanContext) obj;
    final Container container = beanContext.getContainer();
    if (!(container instanceof CmpContainer)) {
        throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
    }
    final CmpContainer cmpContainer = (CmpContainer) container;
    final Number result = (Number) cmpContainer.select(beanContext, methodSignature, "byte", args);
    return result.byteValue();
}
Also used : BeanContext(org.apache.openejb.BeanContext) FinderException(javax.ejb.FinderException) CmpContainer(org.apache.openejb.core.cmp.CmpContainer) Container(org.apache.openejb.Container) CmpContainer(org.apache.openejb.core.cmp.CmpContainer)

Example 7 with Container

use of org.apache.openejb.Container in project tomee by apache.

the class EjbSelect method execute_Object.

/**
     * The single execution stub for all non-primitive
     * select operations.  This method has an additional
     * returnType parameter used to instantiate the return
     * value.
     *
     * @param obj             The EJB object we're operating against.
     * @param methodSignature The signature of the ejbSelectxxxx method.
     * @param returnType      The return type signature of the method.
     * @param args            The select arguments.
     * @return An object of the specified type...which might be
     * one of the collection types.
     * @throws FinderException
     */
public static Object execute_Object(final Object obj, final String methodSignature, final String returnType, final Object... args) throws FinderException {
    final BeanContext beanContext = (BeanContext) obj;
    final Container container = beanContext.getContainer();
    if (!(container instanceof CmpContainer)) {
        throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
    }
    final CmpContainer cmpContainer = (CmpContainer) container;
    return cmpContainer.select(beanContext, methodSignature, returnType, args);
}
Also used : BeanContext(org.apache.openejb.BeanContext) FinderException(javax.ejb.FinderException) CmpContainer(org.apache.openejb.core.cmp.CmpContainer) Container(org.apache.openejb.Container) CmpContainer(org.apache.openejb.core.cmp.CmpContainer)

Example 8 with Container

use of org.apache.openejb.Container 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)

Example 9 with Container

use of org.apache.openejb.Container in project tomee by apache.

the class BasicClusterableRequestHandler method updateServer.

@Override
public void updateServer(final BeanContext beanContext, final ClusterableRequest req, final ClusterableResponse res) {
    final Container container = beanContext.getContainer();
    if (container instanceof ClusteredRPCContainer) {
        final ClusteredRPCContainer clusteredContainer = (ClusteredRPCContainer) container;
        final URI[] locations = clusteredContainer.getLocations(beanContext);
        if (null != locations) {
            final ServerMetaData server = new ServerMetaData(locations);
            if (req.getServerHash() != server.buildHash()) {
                res.setServer(server);
            }
        }
    }
}
Also used : ClusteredRPCContainer(org.apache.openejb.ClusteredRPCContainer) Container(org.apache.openejb.Container) URI(java.net.URI) ServerMetaData(org.apache.openejb.client.ServerMetaData) ClusteredRPCContainer(org.apache.openejb.ClusteredRPCContainer)

Example 10 with Container

use of org.apache.openejb.Container in project tomee by apache.

the class EjbSelect method execute_boolean.

public static boolean execute_boolean(final Object obj, final String methodSignature, final Object... args) throws FinderException {
    final BeanContext beanContext = (BeanContext) obj;
    final Container container = beanContext.getContainer();
    if (!(container instanceof CmpContainer)) {
        throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
    }
    final CmpContainer cmpContainer = (CmpContainer) container;
    final Boolean result = (Boolean) cmpContainer.select(beanContext, methodSignature, "byte", args);
    return result.booleanValue();
}
Also used : BeanContext(org.apache.openejb.BeanContext) FinderException(javax.ejb.FinderException) CmpContainer(org.apache.openejb.core.cmp.CmpContainer) Container(org.apache.openejb.Container) CmpContainer(org.apache.openejb.core.cmp.CmpContainer)

Aggregations

Container (org.apache.openejb.Container)16 BeanContext (org.apache.openejb.BeanContext)13 FinderException (javax.ejb.FinderException)10 CmpContainer (org.apache.openejb.core.cmp.CmpContainer)10 OpenEJBException (org.apache.openejb.OpenEJBException)5 JMXContainer (org.apache.openejb.assembler.monitoring.JMXContainer)4 IOException (java.io.IOException)3 InvalidObjectException (java.io.InvalidObjectException)3 ObjectStreamException (java.io.ObjectStreamException)3 MalformedURLException (java.net.MalformedURLException)3 URISyntaxException (java.net.URISyntaxException)3 ArrayList (java.util.ArrayList)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 DefinitionException (javax.enterprise.inject.spi.DefinitionException)3 DeploymentException (javax.enterprise.inject.spi.DeploymentException)3 InstanceNotFoundException (javax.management.InstanceNotFoundException)3 MBeanRegistrationException (javax.management.MBeanRegistrationException)3 MalformedObjectNameException (javax.management.MalformedObjectNameException)3 ObjectName (javax.management.ObjectName)3