Search in sources :

Example 16 with EnvironmentProperty

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

the class ConnectorsUtil method getMergedActivationConfigProperties.

/**
 * Prepares the name/value pairs for ActivationSpec. <p>
 * Rule: <p>
 * 1. The name/value pairs are the union of activation-config on
 * standard DD (message-driven) and runtime DD (mdb-resource-adapter)
 * 2. If there are duplicate property settings, the value in runtime
 * activation-config will overwrite the one in the standard
 * activation-config.
 */
public static Set getMergedActivationConfigProperties(EjbMessageBeanDescriptor msgDesc) {
    Set mergedProps = new HashSet();
    Set runtimePropNames = new HashSet();
    Set runtimeProps = msgDesc.getRuntimeActivationConfigProperties();
    if (runtimeProps != null) {
        Iterator iter = runtimeProps.iterator();
        while (iter.hasNext()) {
            EnvironmentProperty entry = (EnvironmentProperty) iter.next();
            mergedProps.add(entry);
            String propName = entry.getName();
            runtimePropNames.add(propName);
        }
    }
    Set standardProps = msgDesc.getActivationConfigProperties();
    if (standardProps != null) {
        Iterator iter = standardProps.iterator();
        while (iter.hasNext()) {
            EnvironmentProperty entry = (EnvironmentProperty) iter.next();
            String propName = entry.getName();
            if (runtimePropNames.contains(propName))
                continue;
            mergedProps.add(entry);
        }
    }
    return mergedProps;
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty)

Example 17 with EnvironmentProperty

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

the class RequiredConfigNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node for the DOM tree
 * @param the descriptor to write
 * @return the DOM tree top node
 */
public Node writeDescriptor(Node parent, Descriptor descriptor) {
    if (!(descriptor instanceof MessageListener)) {
        throw new IllegalArgumentException(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
    }
    Iterator configProps = null;
    configProps = ((MessageListener) descriptor).getRequiredConfigProperties().iterator();
    // config property info
    if (configProps != null) {
        for (; configProps.hasNext(); ) {
            EnvironmentProperty config = (EnvironmentProperty) configProps.next();
            Node configNode = appendChild(parent, ConnectorTagNames.REQUIRED_CONFIG_PROP);
            writeLocalizedDescriptions(configNode, config);
            appendTextChild(configNode, ConnectorTagNames.CONFIG_PROPERTY_NAME, config.getName());
        }
    }
    return parent;
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Node(org.w3c.dom.Node) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) MessageListener(com.sun.enterprise.deployment.MessageListener) Iterator(java.util.Iterator)

Example 18 with EnvironmentProperty

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

the class ActivationConfigNode method writeDescriptor.

@Override
public Node writeDescriptor(Node parent, String nodeName, ActivationConfigDescriptor descriptor) {
    Node activationConfigNode = null;
    Set activationConfig = descriptor.getActivationConfig();
    if (activationConfig.size() > 0) {
        activationConfigNode = appendChild(parent, nodeName);
        for (Iterator iter = activationConfig.iterator(); iter.hasNext(); ) {
            Node activationConfigPropertyNode = appendChild(activationConfigNode, RuntimeTagNames.ACTIVATION_CONFIG_PROPERTY);
            EnvironmentProperty next = (EnvironmentProperty) iter.next();
            appendTextChild(activationConfigPropertyNode, RuntimeTagNames.ACTIVATION_CONFIG_PROPERTY_NAME, next.getName());
            appendTextChild(activationConfigPropertyNode, RuntimeTagNames.ACTIVATION_CONFIG_PROPERTY_VALUE, next.getValue());
        }
    }
    return activationConfigNode;
}
Also used : Set(java.util.Set) Node(org.w3c.dom.Node) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Iterator(java.util.Iterator)

Example 19 with EnvironmentProperty

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

the class ActiveJmsResourceAdapter method updateMDBRuntimeInfo.

/**
 * This is the most appropriate time (??) to update the runtime
 * info of a 1.3 MDB into 1.4 MDB.  <p>
 *
 * Assumptions : <p>
 * 0. Assume it is a 1.3 MDB if no RA mid is specified.
 * 1. Use the default system JMS resource adapter. <p>
 * 2. The ActivationSpec of the default JMS RA will provide the
 *    setDestination, setDestinationType, setSubscriptionName methods.
 * 3. The jndi-name of the 1.3 MDB is the value for the Destination
 *    property for the ActivationSpec.
 * 4. The ActivationSpec provides setter methods for the properties
 *    defined in the CF that corresponds to the mdb-connection-factory
 *    JNDI name.
 *
 * @param descriptor_
 * @param poolDescriptor
 * @throws com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
 */
@Override
public void updateMDBRuntimeInfo(EjbMessageBeanDescriptor descriptor_, BeanPoolDescriptor poolDescriptor) throws ConnectorRuntimeException {
    String jndiName = descriptor_.getJndiName();
    if (jndiName == null || "".equals(jndiName)) {
        MessageDestinationDescriptor destDescriptor = descriptor_.getMessageDestination();
        if (destDescriptor != null)
            jndiName = destDescriptor.getJndiName();
    }
    String destinationLookup = descriptor_.getActivationConfigValue("destinationLookup");
    String destinationProp = descriptor_.getActivationConfigValue("destination");
    if (destinationLookup == null && destinationProp == null && (jndiName == null || "".equals(jndiName))) {
        if (_logger.isLoggable(Level.SEVERE)) {
            _logger.log(Level.SEVERE, JMSLoggerInfo.ERROR_IN_DD);
        }
        String msg = sm.getString("ajra.error_in_dd");
        throw new ConnectorRuntimeException(msg);
    }
    String resourceAdapterMid = ConnectorRuntime.DEFAULT_JMS_ADAPTER;
    descriptor_.setResourceAdapterMid(resourceAdapterMid);
    if (destinationLookup == null && destinationProp == null) {
        String appName = descriptor_.getApplication().getAppName();
        String moduleName = ConnectorsUtil.getModuleName(descriptor_);
        JMSDestinationDefinitionDescriptor destination = getJMSDestinationFromDescriptor(jndiName, descriptor_);
        String destName = null;
        if (isValidDestination(destination)) {
            destName = destination.getDestinationName();
        } else {
            destName = getPhysicalDestinationFromConfiguration(jndiName, appName, moduleName);
        }
        // 1.3 jndi-name ==> 1.4 setDestination
        descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION, destName, null));
        // XXX Do we really need this???
        if (descriptor_.getDestinationType() != null && !"".equals(descriptor_.getDestinationType())) {
            descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, descriptor_.getDestinationType(), null));
            if (_logger.isLoggable(Level.INFO)) {
                _logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { descriptor_.getDestinationType(), jndiName, descriptor_.getName() });
            }
        } else if (isValidDestination(destination) && ConnectorConstants.DEFAULT_JMS_ADAPTER.equals(destination.getResourceAdapter())) {
            descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, destination.getInterfaceName(), null));
            if (_logger.isLoggable(Level.INFO)) {
                _logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { destination.getInterfaceName(), destination.getName(), descriptor_.getName() });
            }
        } else {
            /*
                 * If destination type is not provided by the MDB component
                 * [typically used by EJB3.0 styled MDBs which create MDBs without
                 * a destination type activation-config property] and the MDB is for
                 * the default JMS RA, attempt to infer the destination type by trying
                 * to find out if there has been any JMS destination resource already
                 * defined for default JMS RA. This is a best attempt guess and if there
                 * are no JMS destination resources/admin-objects defined, AS would pass
                 * the properties as defined by the MDB.
                 */
            try {
                AdminObjectResource aor = (AdminObjectResource) ResourcesUtil.createInstance().getResource(jndiName, appName, moduleName, AdminObjectResource.class);
                if (aor != null && ConnectorConstants.DEFAULT_JMS_ADAPTER.equals(aor.getResAdapter())) {
                    descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(DESTINATION_TYPE, aor.getResType(), null));
                    if (_logger.isLoggable(Level.INFO)) {
                        _logger.log(Level.INFO, JMSLoggerInfo.ENDPOINT_DEST_NAME, new Object[] { aor.getResType(), aor.getJndiName(), descriptor_.getName() });
                    }
                }
            } catch (Exception e) {
            }
        }
    }
    // 1.3 durable-subscription-name == 1.4 setSubscriptionName
    descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(SUBSCRIPTION_NAME, descriptor_.getDurableSubscriptionName(), null));
    String mdbCF = null;
    try {
        mdbCF = descriptor_.getMdbConnectionFactoryJndiName();
    } catch (NullPointerException ne) {
    // Dont process connection factory.
    }
    if (mdbCF != null && !"".equals(mdbCF)) {
        setValuesFromConfiguration(mdbCF, descriptor_);
    }
    if (poolDescriptor != null) {
        descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(MAXPOOLSIZE, "" + poolDescriptor.getMaxPoolSize(), "", "java.lang.Integer"));
        descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(MINPOOLSIZE, "" + poolDescriptor.getSteadyPoolSize(), "", "java.lang.Integer"));
        descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(RESIZECOUNT, "" + poolDescriptor.getPoolResizeQuantity(), "", "java.lang.Integer"));
        descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(RESIZETIMEOUT, "" + poolDescriptor.getPoolIdleTimeoutInSeconds(), "", "java.lang.Integer"));
        /**
         * The runtime activation config property holds all the
         * vendor specific properties, unfortunately the vendor
         * specific way of configuring exception count and the
         * standard way of configuring redelivery attempts is
         * through the same property REDELIVERYCOUNT . So, we first
         * check if the user (MDB assember) has configured a value
         * if not we set the one from mdb-container props
         * We have to check for both cases here because it has been
         * documented as "endpointExceptionRedeliveryAttempts" but
         * used in the code as "EndpointExceptionRedeliveryAttempts"
         */
        if ((descriptor_.getActivationConfigValue(REDELIVERYCOUNT) == null) && (descriptor_.getActivationConfigValue(LOWERCASE_REDELIVERYCOUNT) == null)) {
            descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(REDELIVERYCOUNT, "" + MdbContainerProps.getMaxRuntimeExceptions(), "", "java.lang.Integer"));
        }
    }
    // Set SE/EE specific MQ-RA ActivationSpec properties
    try {
        boolean clustered = isClustered();
        if (_logger.isLoggable(Level.FINE))
            logFine("Are we in a Clustered contained ? " + clustered);
        if (clustered)
            setClusterActivationSpecProperties(descriptor_);
    } catch (Exception e) {
        ConnectorRuntimeException crex = new ConnectorRuntimeException(e.getMessage());
        throw (ConnectorRuntimeException) crex.initCause(e);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) MessageDestinationDescriptor(com.sun.enterprise.deployment.MessageDestinationDescriptor) JMSDestinationDefinitionDescriptor(com.sun.enterprise.deployment.JMSDestinationDefinitionDescriptor) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 20 with EnvironmentProperty

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

the class EjbMessageBeanDescriptor method setJmsAcknowledgeMode.

/**
 * Sets how JMS messages should be acknowledged.
 * <p>
 * If the parameter is not 1 then it will be set to use dups-ok-acknowledge mode
 * as there is no checking for this.
 * @param acknowledgeMode 1 for auto-acknowledgement, 3 for dups-ok-acknowledge
 */
public void setJmsAcknowledgeMode(int acknowledgeMode) {
    String ackModeValue = (acknowledgeMode == AUTO_ACKNOWLEDGE) ? AUTO_ACK : DUPS_OK_ACK;
    EnvironmentProperty ackModeProp = new EnvironmentProperty(ACK_MODE_PROPERTY, ackModeValue, "");
    putActivationConfigProperty(ackModeProp);
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty)

Aggregations

EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)29 Result (com.sun.enterprise.tools.verifier.Result)10 Iterator (java.util.Iterator)6 Node (org.w3c.dom.Node)4 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)3 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)3 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)3 Set (java.util.Set)3 ServletFilterDescriptor (org.glassfish.web.deployment.descriptor.ServletFilterDescriptor)3 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)2 MessageListener (com.sun.enterprise.deployment.MessageListener)2 Method (java.lang.reflect.Method)2 URISyntaxException (java.net.URISyntaxException)2 PrivilegedActionException (java.security.PrivilegedActionException)2 ExecutionException (java.util.concurrent.ExecutionException)2 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)2 WebInitParam (javax.servlet.annotation.WebInitParam)2 MultiException (org.glassfish.hk2.api.MultiException)2 AdminObject (com.sun.enterprise.deployment.AdminObject)1 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)1