Search in sources :

Example 1 with BeanPoolDescriptor

use of com.sun.enterprise.deployment.runtime.BeanPoolDescriptor in project Payara by payara.

the class EjbNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node for the DOM tree
 * @param node name for the descriptor
 * @param the descriptor to write
 * @return the DOM tree top node
 */
@Override
public Node writeDescriptor(Node parent, String nodeName, EjbDescriptor ejbDescriptor) {
    Element ejbNode = (Element) super.writeDescriptor(parent, nodeName, ejbDescriptor);
    appendTextChild(ejbNode, RuntimeTagNames.EJB_NAME, ejbDescriptor.getName());
    appendTextChild(ejbNode, RuntimeTagNames.JNDI_NAME, ejbDescriptor.getJndiName());
    RuntimeDescriptorNode.writeCommonComponentInfo(ejbNode, ejbDescriptor);
    appendTextChild(ejbNode, RuntimeTagNames.PASS_BY_REFERENCE, String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().getPassByReference()));
    if (ejbDescriptor instanceof IASEjbCMPEntityDescriptor) {
        CmpNode cmpNode = new CmpNode();
        cmpNode.writeDescriptor(ejbNode, RuntimeTagNames.CMP, (IASEjbCMPEntityDescriptor) ejbDescriptor);
    }
    // principal
    if (Boolean.FALSE.equals(ejbDescriptor.getUsesCallerIdentity())) {
        RunAsIdentityDescriptor raid = ejbDescriptor.getRunAsIdentity();
        if (raid != null && raid.getPrincipal() != null) {
            Node principalNode = appendChild(ejbNode, RuntimeTagNames.PRINCIPAL);
            appendTextChild(principalNode, RuntimeTagNames.NAME, raid.getPrincipal());
        }
    }
    if (ejbDescriptor instanceof EjbMessageBeanDescriptor) {
        EjbMessageBeanDescriptor msgBeanDesc = (EjbMessageBeanDescriptor) ejbDescriptor;
        // mdb-connection-factory?
        if (ejbDescriptor.getIASEjbExtraDescriptors().getMdbConnectionFactory() != null) {
            MDBConnectionFactoryNode mcfNode = new MDBConnectionFactoryNode();
            mcfNode.writeDescriptor(ejbNode, RuntimeTagNames.MDB_CONNECTION_FACTORY, ejbDescriptor.getIASEjbExtraDescriptors().getMdbConnectionFactory());
        }
        // jms-durable-subscription-name
        if (msgBeanDesc.hasDurableSubscription()) {
            appendTextChild(ejbNode, RuntimeTagNames.DURABLE_SUBSCRIPTION, msgBeanDesc.getDurableSubscriptionName());
        }
        appendTextChild(ejbNode, RuntimeTagNames.JMS_MAX_MESSAGES_LOAD, String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().getJmsMaxMessagesLoad()));
    }
    // ior-configuration
    IORConfigurationNode iorNode = new IORConfigurationNode();
    for (EjbIORConfigurationDescriptor iorConf : ejbDescriptor.getIORConfigurationDescriptors()) {
        iorNode.writeDescriptor(ejbNode, RuntimeTagNames.IOR_CONFIG, iorConf);
    }
    appendTextChild(ejbNode, RuntimeTagNames.IS_READ_ONLY_BEAN, String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().isIsReadOnlyBean()));
    appendTextChild(ejbNode, RuntimeTagNames.REFRESH_PERIOD_IN_SECONDS, String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().getRefreshPeriodInSeconds()));
    appendTextChild(ejbNode, RuntimeTagNames.COMMIT_OPTION, ejbDescriptor.getIASEjbExtraDescriptors().getCommitOption());
    appendTextChild(ejbNode, RuntimeTagNames.CMT_TIMEOUT_IN_SECONDS, String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().getCmtTimeoutInSeconds()));
    appendTextChild(ejbNode, RuntimeTagNames.USE_THREAD_POOL_ID, ejbDescriptor.getIASEjbExtraDescriptors().getUseThreadPoolId());
    // gen-classes
    writeGenClasses(ejbNode, ejbDescriptor);
    // bean-pool
    BeanPoolDescriptor beanPoolDesc = ejbDescriptor.getIASEjbExtraDescriptors().getBeanPool();
    if (beanPoolDesc != null) {
        BeanPoolNode bpNode = new BeanPoolNode();
        bpNode.writeDescriptor(ejbNode, RuntimeTagNames.BEAN_POOL, beanPoolDesc);
    }
    // bean-cache
    BeanCacheDescriptor beanCacheDesc = ejbDescriptor.getIASEjbExtraDescriptors().getBeanCache();
    if (beanCacheDesc != null) {
        BeanCacheNode bcNode = new BeanCacheNode();
        bcNode.writeDescriptor(ejbNode, RuntimeTagNames.BEAN_CACHE, beanCacheDesc);
    }
    if (ejbDescriptor instanceof EjbMessageBeanDescriptor) {
        EjbMessageBeanDescriptor msgBeanDesc = (EjbMessageBeanDescriptor) ejbDescriptor;
        if (msgBeanDesc.hasResourceAdapterMid()) {
            MDBResourceAdapterNode mdb = new MDBResourceAdapterNode();
            mdb.writeDescriptor(ejbNode, RuntimeTagNames.MDB_RESOURCE_ADAPTER, msgBeanDesc);
        }
    } else if (ejbDescriptor instanceof EjbSessionDescriptor) {
        // web-services
        WebServiceEndpointRuntimeNode wsRuntime = new WebServiceEndpointRuntimeNode();
        wsRuntime.writeWebServiceEndpointInfo(ejbNode, ejbDescriptor);
    }
    // flush-at-end-of-method
    FlushAtEndOfMethodDescriptor flushMethodDesc = ejbDescriptor.getIASEjbExtraDescriptors().getFlushAtEndOfMethodDescriptor();
    if (flushMethodDesc != null) {
        FlushAtEndOfMethodNode flushNode = new FlushAtEndOfMethodNode();
        flushNode.writeDescriptor(ejbNode, RuntimeTagNames.FLUSH_AT_END_OF_METHOD, flushMethodDesc);
    }
    // checkpointed-methods
    // checkpoint-at-end-of-method
    CheckpointAtEndOfMethodDescriptor checkpointMethodDesc = ejbDescriptor.getIASEjbExtraDescriptors().getCheckpointAtEndOfMethodDescriptor();
    if (checkpointMethodDesc != null) {
        CheckpointAtEndOfMethodNode checkpointNode = new CheckpointAtEndOfMethodNode();
        checkpointNode.writeDescriptor(ejbNode, RuntimeTagNames.CHECKPOINT_AT_END_OF_METHOD, checkpointMethodDesc);
    }
    if (ejbDescriptor.getIASEjbExtraDescriptors().getPerRequestLoadBalancing() != null) {
        appendTextChild(ejbNode, RuntimeTagNames.PER_REQUEST_LOAD_BALANCING, String.valueOf(ejbDescriptor.getIASEjbExtraDescriptors().getPerRequestLoadBalancing()));
    }
    // availability-enabled
    setAttribute(ejbNode, RuntimeTagNames.AVAILABILITY_ENABLED, ejbDescriptor.getIASEjbExtraDescriptors().getAttributeValue(IASEjbExtraDescriptors.AVAILABILITY_ENABLED));
    return ejbNode;
}
Also used : BeanCacheDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.BeanCacheDescriptor) WebServiceEndpointRuntimeNode(com.sun.enterprise.deployment.node.runtime.WebServiceEndpointRuntimeNode) RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor) XMLElement(com.sun.enterprise.deployment.node.XMLElement) Element(org.w3c.dom.Element) ResourceEnvRefNode(com.sun.enterprise.deployment.node.runtime.ResourceEnvRefNode) WebServiceEndpointRuntimeNode(com.sun.enterprise.deployment.node.runtime.WebServiceEndpointRuntimeNode) EjbRefNode(com.sun.enterprise.deployment.node.runtime.EjbRefNode) ServiceRefNode(com.sun.enterprise.deployment.node.runtime.ServiceRefNode) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) ResourceRefNode(com.sun.enterprise.deployment.node.runtime.ResourceRefNode) Node(org.w3c.dom.Node) RuntimeDescriptorNode(com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode) MessageDestinationRefNode(com.sun.enterprise.deployment.node.runtime.MessageDestinationRefNode) EjbIORConfigurationDescriptor(com.sun.enterprise.deployment.EjbIORConfigurationDescriptor) IASEjbCMPEntityDescriptor(org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor) EjbMessageBeanDescriptor(org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor) EjbSessionDescriptor(com.sun.enterprise.deployment.EjbSessionDescriptor) FlushAtEndOfMethodDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.FlushAtEndOfMethodDescriptor) BeanPoolDescriptor(com.sun.enterprise.deployment.runtime.BeanPoolDescriptor) CheckpointAtEndOfMethodDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.CheckpointAtEndOfMethodDescriptor)

Example 2 with BeanPoolDescriptor

use of com.sun.enterprise.deployment.runtime.BeanPoolDescriptor in project Payara by payara.

the class MessageBeanContainer method createMessageBeanPool.

private void createMessageBeanPool(EjbMessageBeanDescriptor descriptor) {
    beanPoolDesc_ = descriptor.getIASEjbExtraDescriptors().getBeanPool();
    if (beanPoolDesc_ == null) {
        beanPoolDesc_ = new BeanPoolDescriptor();
    }
    MdbContainer mdbc = ejbContainerUtilImpl.getServices().<Config>getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME).getExtensionByType(MdbContainer.class);
    int maxPoolSize = beanPoolDesc_.getMaxPoolSize();
    if (maxPoolSize < 0) {
        maxPoolSize = stringToInt(mdbc.getMaxPoolSize(), appEJBName_, _logger);
    }
    maxPoolSize = validateValue(maxPoolSize, 1, -1, DEFAULT_MAX_POOL_SIZE, "max-pool-size", appEJBName_, _logger);
    beanPoolDesc_.setMaxPoolSize(maxPoolSize);
    int value = beanPoolDesc_.getSteadyPoolSize();
    if (value < 0) {
        value = stringToInt(mdbc.getSteadyPoolSize(), appEJBName_, _logger);
    }
    value = validateValue(value, 0, maxPoolSize, DEFAULT_STEADY_SIZE, "steady-pool-size", appEJBName_, _logger);
    beanPoolDesc_.setSteadyPoolSize(value);
    value = beanPoolDesc_.getPoolResizeQuantity();
    if (value < 0) {
        value = stringToInt(mdbc.getPoolResizeQuantity(), appEJBName_, _logger);
    }
    value = validateValue(value, 1, maxPoolSize, DEFAULT_RESIZE_QUANTITY, "pool-resize-quantity", appEJBName_, _logger);
    beanPoolDesc_.setPoolResizeQuantity(value);
    // if ejb pool idle-timeout-in-seconds is not explicitly set in
    // glassfish-ejb-jar.xml, returned value is -1
    value = beanPoolDesc_.getPoolIdleTimeoutInSeconds();
    if (value < MIN_IDLE_TIMEOUT) {
        value = stringToInt(mdbc.getIdleTimeoutInSeconds(), appEJBName_, _logger);
    }
    value = validateValue(value, MIN_IDLE_TIMEOUT, -1, DEFAULT_IDLE_TIMEOUT, "idle-timeout-in-seconds", appEJBName_, _logger);
    beanPoolDesc_.setPoolIdleTimeoutInSeconds(value);
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, appEJBName_ + ": Setting message-driven bean pool max-pool-size=" + beanPoolDesc_.getMaxPoolSize() + ", steady-pool-size=" + beanPoolDesc_.getSteadyPoolSize() + ", pool-resize-quantity=" + beanPoolDesc_.getPoolResizeQuantity() + ", idle-timeout-in-seconds=" + beanPoolDesc_.getPoolIdleTimeoutInSeconds());
    }
    // Create a non-blocking pool of message bean instances.
    // The protocol manager implementation enforces a limit
    // on message bean resources independent of the pool.
    ObjectFactory objFactory = new MessageBeanContextFactory();
    String val = descriptor.getEjbBundleDescriptor().getEnterpriseBeansProperty(SINGLETON_BEAN_POOL_PROP);
    messageBeanPool_ = new NonBlockingPool(getContainerId(), appEJBName_, objFactory, beanPoolDesc_.getSteadyPoolSize(), beanPoolDesc_.getPoolResizeQuantity(), beanPoolDesc_.getMaxPoolSize(), beanPoolDesc_.getPoolIdleTimeoutInSeconds(), loader, Boolean.parseBoolean(val));
}
Also used : MdbContainer(org.glassfish.ejb.config.MdbContainer) ObjectFactory(com.sun.ejb.containers.util.pool.ObjectFactory) NonBlockingPool(com.sun.ejb.containers.util.pool.NonBlockingPool) Config(com.sun.enterprise.config.serverbeans.Config) BeanPoolDescriptor(com.sun.enterprise.deployment.runtime.BeanPoolDescriptor) MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint)

Aggregations

BeanPoolDescriptor (com.sun.enterprise.deployment.runtime.BeanPoolDescriptor)2 NonBlockingPool (com.sun.ejb.containers.util.pool.NonBlockingPool)1 ObjectFactory (com.sun.ejb.containers.util.pool.ObjectFactory)1 Config (com.sun.enterprise.config.serverbeans.Config)1 EjbIORConfigurationDescriptor (com.sun.enterprise.deployment.EjbIORConfigurationDescriptor)1 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)1 RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)1 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 XMLElement (com.sun.enterprise.deployment.node.XMLElement)1 EjbRefNode (com.sun.enterprise.deployment.node.runtime.EjbRefNode)1 MessageDestinationRefNode (com.sun.enterprise.deployment.node.runtime.MessageDestinationRefNode)1 ResourceEnvRefNode (com.sun.enterprise.deployment.node.runtime.ResourceEnvRefNode)1 ResourceRefNode (com.sun.enterprise.deployment.node.runtime.ResourceRefNode)1 RuntimeDescriptorNode (com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode)1 ServiceRefNode (com.sun.enterprise.deployment.node.runtime.ServiceRefNode)1 WebServiceEndpointRuntimeNode (com.sun.enterprise.deployment.node.runtime.WebServiceEndpointRuntimeNode)1 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)1 MdbContainer (org.glassfish.ejb.config.MdbContainer)1 EjbMessageBeanDescriptor (org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor)1 IASEjbCMPEntityDescriptor (org.glassfish.ejb.deployment.descriptor.IASEjbCMPEntityDescriptor)1