Search in sources :

Example 1 with MessageDriven

use of javax.ejb.MessageDriven in project Payara by payara.

the class MessageDrivenHandler method setEjbDescriptorInfo.

/**
 * Set Annotation information to Descriptor.
 * This method will also be invoked for an existing descriptor with
 * annotation as user may not specific a complete xml.
 * @param ejbDesc
 * @param ainfo
 * @return HandlerProcessingResult
 */
protected HandlerProcessingResult setEjbDescriptorInfo(EjbDescriptor ejbDesc, AnnotationInfo ainfo) throws AnnotationProcessorException {
    MessageDriven mdAn = (MessageDriven) ainfo.getAnnotation();
    Class ejbClass = (Class) ainfo.getAnnotatedElement();
    EjbMessageBeanDescriptor ejbMsgBeanDesc = (EjbMessageBeanDescriptor) ejbDesc;
    HandlerProcessingResult procResult = setMessageListenerInterface(mdAn, ejbMsgBeanDesc, ejbClass, ainfo);
    doDescriptionProcessing(mdAn.description(), ejbMsgBeanDesc);
    doMappedNameProcessing(mdAn.mappedName(), ejbMsgBeanDesc);
    for (ActivationConfigProperty acProp : mdAn.activationConfig()) {
        EnvironmentProperty envProp = new EnvironmentProperty(acProp.propertyName(), TranslatedConfigView.expandValue(acProp.propertyValue()), "");
        // xml override
        switch(acProp.propertyName()) {
            case "resourceAdapter":
                ejbMsgBeanDesc.setResourceAdapterMid(envProp.getValue());
                break;
            case DescriptorConstants.MAX_POOL_SIZE:
                initialiseBeanPoolDescriptor(ejbMsgBeanDesc);
                ejbMsgBeanDesc.getIASEjbExtraDescriptors().getBeanPool().setMaxPoolSize(Integer.valueOf(envProp.getValue()));
                break;
            case DescriptorConstants.POOL_RESIZE_QTY:
                initialiseBeanPoolDescriptor(ejbMsgBeanDesc);
                ejbMsgBeanDesc.getIASEjbExtraDescriptors().getBeanPool().setPoolResizeQuantity(Integer.valueOf(envProp.getValue()));
                break;
            case DescriptorConstants.STEADY_POOL_SIZE:
                initialiseBeanPoolDescriptor(ejbMsgBeanDesc);
                ejbMsgBeanDesc.getIASEjbExtraDescriptors().getBeanPool().setSteadyPoolSize(Integer.valueOf(envProp.getValue()));
                break;
            case DescriptorConstants.MAX_WAIT_TIME:
                initialiseBeanPoolDescriptor(ejbMsgBeanDesc);
                ejbMsgBeanDesc.getIASEjbExtraDescriptors().getBeanPool().setMaxWaitTimeInMillis(Integer.valueOf(envProp.getValue()));
                break;
            case DescriptorConstants.POOL_IDLE_TIMEOUT:
                initialiseBeanPoolDescriptor(ejbMsgBeanDesc);
                ejbMsgBeanDesc.getIASEjbExtraDescriptors().getBeanPool().setPoolIdleTimeoutInSeconds(Integer.valueOf(envProp.getValue()));
                break;
            case "SingletonBeanPool":
                NameValuePairDescriptor singletonProperty = new NameValuePairDescriptor();
                singletonProperty.setName("singleton-bean-pool");
                singletonProperty.setValue(envProp.getValue());
                ejbMsgBeanDesc.getEjbBundleDescriptor().addEnterpriseBeansProperty(singletonProperty);
                break;
            default:
                if (ejbMsgBeanDesc.getActivationConfigValue(envProp.getName()) == null) {
                    ejbMsgBeanDesc.putActivationConfigProperty(envProp);
                }
                break;
        }
    }
    return procResult;
}
Also used : ActivationConfigProperty(javax.ejb.ActivationConfigProperty) EjbMessageBeanDescriptor(org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor) NameValuePairDescriptor(com.sun.enterprise.deployment.NameValuePairDescriptor) HandlerProcessingResult(org.glassfish.apf.HandlerProcessingResult) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) MessageDriven(javax.ejb.MessageDriven)

Aggregations

EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)1 NameValuePairDescriptor (com.sun.enterprise.deployment.NameValuePairDescriptor)1 ActivationConfigProperty (javax.ejb.ActivationConfigProperty)1 MessageDriven (javax.ejb.MessageDriven)1 HandlerProcessingResult (org.glassfish.apf.HandlerProcessingResult)1 EjbMessageBeanDescriptor (org.glassfish.ejb.deployment.descriptor.EjbMessageBeanDescriptor)1