Search in sources :

Example 26 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();
    // ActionConfig must have at least one ActionConfigProperty
    // and ActionConfigProperty must have a pair of name/value
    // so filter out the entries with blank name or value
    Set activationConfig2 = new HashSet();
    for (Iterator iter = activationConfig.iterator(); iter.hasNext(); ) {
        EnvironmentProperty next = (EnvironmentProperty) iter.next();
        if (!next.getName().trim().equals("") && !next.getValue().trim().equals("")) {
            activationConfig2.add(next);
        }
    }
    if (activationConfig2.size() > 0) {
        activationConfigNode = appendChild(parent, nodeName);
        writeLocalizedDescriptions(activationConfigNode, descriptor);
        for (Iterator iter = activationConfig2.iterator(); iter.hasNext(); ) {
            Node activationConfigPropertyNode = appendChild(activationConfigNode, EjbTagNames.ACTIVATION_CONFIG_PROPERTY);
            EnvironmentProperty next = (EnvironmentProperty) iter.next();
            appendTextChild(activationConfigPropertyNode, EjbTagNames.ACTIVATION_CONFIG_PROPERTY_NAME, next.getName());
            appendTextChild(activationConfigPropertyNode, EjbTagNames.ACTIVATION_CONFIG_PROPERTY_VALUE, next.getValue());
        }
    }
    return activationConfigNode;
}
Also used : HashSet(java.util.HashSet) 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) HashSet(java.util.HashSet)

Example 27 with EnvironmentProperty

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

the class SetMethodAction method run.

/**
 * Executes the setter methods in the java bean.
 */
public Object run() throws Exception {
    Iterator it = props.iterator();
    methods = bean.getClass().getMethods();
    while (it.hasNext()) {
        EnvironmentProperty prop = (EnvironmentProperty) it.next();
        String propName = prop.getName();
        Class type = getTypeOf(prop);
        // property type
        if (type == null) {
            type = Class.forName(prop.getType());
        }
        if (prop.getResolvedValue() != null && prop.getResolvedValue().trim().length() != 0) {
            Method meth = getMutatorMethod(propName, type);
            if (meth == null) {
                // log WARNING, deployment can continue.
                logger.log(Level.WARNING, "rardeployment.no_setter_method", new Object[] { prop.getName(), bean.getClass().getName() });
            } else {
                try {
                    if (logger.isLoggable(Level.FINER)) {
                        logger.log(Level.FINER, "Invoking" + meth + " on " + bean.getClass().getName() + "with " + "value [" + prop.getResolvedValueObject().getClass() + "  , " + getFilteredPropValue(prop) + " ] ");
                    }
                    meth.invoke(bean, new Object[] { prop.getResolvedValueObject() });
                } catch (IllegalArgumentException ia) {
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, "IllegalException while trying to set " + prop.getName() + " and value " + getFilteredPropValue(prop), ia + " on an instance of " + bean.getClass() + " -- trying again with the type from bean");
                    }
                    boolean prevBoundsChecking = EnvironmentProperty.isBoundsChecking();
                    try {
                        EnvironmentProperty.setBoundsChecking(false);
                        prop.setType(type.getName());
                        if (logger.isLoggable(Level.FINE)) {
                            logger.log(Level.FINE, "2nd try :: Invoking" + meth + " on " + bean.getClass().getName() + "with value [" + prop.getResolvedValueObject().getClass() + "  , " + getFilteredPropValue(prop) + " ] ");
                        }
                        meth.invoke(bean, new Object[] { prop.getResolvedValueObject() });
                    } catch (Exception e) {
                        handleException(e, prop, bean);
                    } finally {
                        // restore boundsChecking
                        EnvironmentProperty.setBoundsChecking(prevBoundsChecking);
                    }
                } catch (Exception ex) {
                    handleException(ex, prop, bean);
                }
            }
        }
    }
    return null;
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Method(java.lang.reflect.Method) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 28 with EnvironmentProperty

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

the class RARUtils 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 = (String) 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 = (String) entry.getName();
            if (runtimePropNames.contains(propName))
                continue;
            mergedProps.add(entry);
        }
    }
    return mergedProps;
}
Also used : EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty)

Example 29 with EnvironmentProperty

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

the class ActiveJmsResourceAdapter method setValuesFromConfiguration.

private void setValuesFromConfiguration(String cfName, EjbMessageBeanDescriptor descriptor_) throws ConnectorRuntimeException {
    // todo: need to enable
    List<Property> ep = null;
    try {
        /*Resources rbeans = getAllResources();//ServerBeansFactory.getDomainBean(ctx).getResources();
            ConnectorResource res = (ConnectorResource)
                             rbeans.getResourceByName(ConnectorResource.class, cfName);*/
        String appName = descriptor_.getApplication().getAppName();
        String moduleName = ConnectorsUtil.getModuleName(descriptor_);
        ConnectorResource res = (ConnectorResource) ResourcesUtil.createInstance().getResource(cfName, appName, moduleName, ConnectorResource.class);
        if (res == null) {
            String msg = sm.getString("ajra.mdb_cf_not_created", cfName);
            throw new ConnectorRuntimeException(msg);
        }
        ConnectorConnectionPool ccp = (ConnectorConnectionPool) ResourcesUtil.createInstance().getResource(res.getPoolName(), appName, moduleName, ConnectorConnectionPool.class);
        // rbeans.getResourceByName(ConnectorConnectionPool.class, res.getPoolName());
        ep = ccp.getProperty();
    } catch (Exception ce) {
        String msg = sm.getString("ajra.mdb_cf_not_created", cfName);
        ConnectorRuntimeException cre = new ConnectorRuntimeException(msg);
        cre.initCause(ce);
        throw cre;
    }
    if (ep == null) {
        String msg = sm.getString("ajra.cannot_find_phy_dest");
        throw new ConnectorRuntimeException(msg);
    }
    for (int i = 0; i < ep.size(); i++) {
        Property prop = ep.get(i);
        String name = prop.getName();
        if (name.equals(MCFADDRESSLIST)) {
            name = ADDRESSLIST;
        }
        String val = prop.getValue();
        if (val == null || val.equals("")) {
            continue;
        }
        descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(name, val, null));
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Property(org.jvnet.hk2.config.types.Property) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) ConnectorResource(org.glassfish.connectors.config.ConnectorResource) 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)

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