Search in sources :

Example 11 with ConnectorConfigProperty

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

the class ConnectorDescriptorInfo method compareMCFConfigProperties.

/**
 * Compare the MCF Config properties in this object with the
 * passed ones. The properties in the Set of excluded properties
 * are not compared against
 *
 * @param cdi      - The ConnDescInfo object whose MCF config props are to
 *                 to be comapred against our props
 * @param excluded - list of properties to be excluded from comparison
 * @return true - if the config properties are the same
 *         false otherwise
 */
public ReconfigAction compareMCFConfigProperties(ConnectorDescriptorInfo cdi, Set excluded) {
    Set mcfConfigProps = cdi.getMCFConfigProperties();
    if (mcfConfigProps.size() != mcfConfigProperties_.size()) {
        // Cannot determine anything due to size disparity - assume restart
        return ReconfigAction.RECREATE_POOL;
    }
    boolean same = false;
    for (Object mcfConfigProp : mcfConfigProps) {
        ConnectorConfigProperty prop = (ConnectorConfigProperty) mcfConfigProp;
        // see if this property is in our list of excludes
        if (excluded.contains(prop.getName())) {
            // _logger.finest("mcfProp ignored : " + prop.getName() );
            continue;
        }
        for (ConnectorConfigProperty property : mcfConfigProperties_) {
            if (isEnvPropEqual(prop, property)) {
                // we have a match
                same = true;
                // _logger.finest("mcfprop matched : " + prop.getName());
                break;
            }
        }
        if (!same) {
            // return false;
            return ReconfigAction.RECREATE_POOL;
        }
        same = false;
    }
    return ReconfigAction.NO_OP;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty)

Example 12 with ConnectorConfigProperty

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

the class ActiveOutboundResourceAdapter method addAdminObject.

/**
 * Creates an admin object.
 *
 * @param appName         Name of application, in case of embedded rar.
 * @param connectorName   Module name of the resource adapter.
 * @param jndiName        JNDI name to be registered.
 * @param adminObjectType Interface name of the admin object.
 * @param props           <code>Properties</code> object containing name/value
 *                        pairs of properties.
 */
public void addAdminObject(String appName, String connectorName, ResourceInfo resourceInfo, String adminObjectType, String adminObjectClassName, Properties props) throws ConnectorRuntimeException {
    if (props == null) {
        // empty properties
        props = new Properties();
    }
    ConnectorRegistry registry = ConnectorRegistry.getInstance();
    ConnectorDescriptor desc = registry.getDescriptor(connectorName);
    AdminObject aoDesc = null;
    // or the combination of the both names.
    if (adminObjectClassName == null || adminObjectClassName.trim().equals("")) {
        // get AO through interface name
        List<AdminObject> adminObjects = desc.getAdminObjectsByType(adminObjectType);
        if (adminObjects.size() > 1) {
            String msg = localStrings.getString("aor.could_not_determine_aor_type", adminObjectType);
            throw new ConnectorRuntimeException(msg);
        } else {
            aoDesc = adminObjects.get(0);
        }
    } else if (adminObjectType == null || adminObjectType.trim().equals("")) {
        // get AO through class name
        List<AdminObject> adminObjects = desc.getAdminObjectsByClass(adminObjectClassName);
        if (adminObjects.size() > 1) {
            String msg = localStrings.getString("aor.could_not_determine_aor_class", adminObjectClassName);
            throw new ConnectorRuntimeException(msg);
        } else {
            aoDesc = adminObjects.get(0);
        }
    } else {
        // get AO through interface name and class name
        aoDesc = desc.getAdminObject(adminObjectType, adminObjectClassName);
    }
    if (aoDesc == null) {
        String msg = localStrings.getString("aor.could_not_determine_aor", adminObjectType, adminObjectClassName);
        throw new ConnectorRuntimeException(msg);
    }
    AdministeredObjectResource aor = new AdministeredObjectResource(resourceInfo);
    aor.initialize(aoDesc);
    aor.setResourceAdapter(connectorName);
    Object[] envProps = aoDesc.getConfigProperties().toArray();
    // Override them if same config properties are provided by the user
    for (int i = 0; i < envProps.length; i++) {
        ConnectorConfigProperty envProp = (ConnectorConfigProperty) envProps[i];
        String name = envProp.getName();
        String userValue = (String) props.remove(name);
        if (userValue != null)
            aor.addConfigProperty(new ConnectorConfigProperty(name, userValue, userValue, envProp.getType()));
        else
            aor.addConfigProperty(envProp);
    }
    // Add non-default config properties provided by the user to aor
    Iterator iter = props.keySet().iterator();
    while (iter.hasNext()) {
        String name = (String) iter.next();
        String userValue = props.getProperty(name);
        if (userValue != null)
            aor.addConfigProperty(new ConnectorConfigProperty(name, userValue, userValue));
    }
    // bind to JNDI namespace
    try {
        Reference ref = aor.createAdminObjectReference();
        connectorRuntime_.getResourceNamingService().publishObject(resourceInfo, ref, true);
    } catch (NamingException ex) {
        String i18nMsg = localStrings.getString("aira.cannot_bind_admin_obj");
        throw new ConnectorRuntimeException(i18nMsg, ex);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) Reference(javax.naming.Reference) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) AdminObject(com.sun.enterprise.deployment.AdminObject) NamingException(javax.naming.NamingException) AdministeredObjectResource(com.sun.enterprise.resource.beans.AdministeredObjectResource) AdminObject(com.sun.enterprise.deployment.AdminObject)

Example 13 with ConnectorConfigProperty

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

the class ActiveOutboundResourceAdapter method logMergedProperties.

private void logMergedProperties(Set mergedProps) {
    if (_logger.isLoggable(Level.FINE)) {
        _logger.fine("Passing in the following properties " + "before calling RA.start of " + this.moduleName_);
        StringBuffer b = new StringBuffer();
        for (Iterator iter = mergedProps.iterator(); iter.hasNext(); ) {
            ConnectorConfigProperty element = (ConnectorConfigProperty) iter.next();
            b.append("\nName: " + element.getName() + " Value: " + element.getValue());
        }
        _logger.fine(b.toString());
    }
}
Also used : ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty)

Example 14 with ConnectorConfigProperty

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

the class ConnectorsRecoveryResourceHandler method getdbUserPasswordOfConnectorConnectionPool.

private String[] getdbUserPasswordOfConnectorConnectionPool(ConnectorConnectionPool connectorConnectionPool) {
    String[] userPassword = new String[2];
    userPassword[0] = null;
    userPassword[1] = null;
    List<Property> properties = connectorConnectionPool.getProperty();
    if (properties != null) {
        boolean foundUserPassword = false;
        for (Property elementProperty : properties) {
            String prop = elementProperty.getName().toUpperCase(locale);
            if ("USERNAME".equals(prop) || "USER".equals(prop)) {
                userPassword[0] = elementProperty.getValue();
                foundUserPassword = true;
            } else if ("PASSWORD".equals(prop)) {
                userPassword[1] = elementProperty.getValue();
                foundUserPassword = true;
            }
        }
        if (foundUserPassword == true) {
            return userPassword;
        }
    }
    PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(connectorConnectionPool);
    String rarName = connectorConnectionPool.getResourceAdapterName();
    String connectionDefName = connectorConnectionPool.getConnectionDefinitionName();
    ConnectorRegistry connectorRegistry = ConnectorRegistry.getInstance();
    ConnectorDescriptor connectorDescriptor = connectorRegistry.getDescriptor(rarName);
    ConnectionDefDescriptor cdd = connectorDescriptor.getConnectionDefinitionByCFType(connectionDefName);
    Set configProps = cdd.getConfigProperties();
    for (Iterator iter = configProps.iterator(); iter.hasNext(); ) {
        ConnectorConfigProperty envProp = (ConnectorConfigProperty) iter.next();
        String prop = envProp.getName().toUpperCase(locale);
        if ("USER".equals(prop) || "USERNAME".equals(prop)) {
            userPassword[0] = envProp.getValue();
        } else if ("PASSWORD".equals(prop)) {
            userPassword[1] = envProp.getValue();
        }
    }
    if (userPassword[0] != null && !"".equals(userPassword[0].trim())) {
        return userPassword;
    }
    // else read the default username and password from the ra.xml
    ManagedConnectionFactory mcf = connectorRegistry.getManagedConnectionFactory(poolInfo);
    userPassword[0] = ConnectionPoolObjectsUtils.getValueFromMCF("UserName", poolInfo, mcf);
    userPassword[1] = ConnectionPoolObjectsUtils.getValueFromMCF("Password", poolInfo, mcf);
    return userPassword;
}
Also used : ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ConnectorRegistry(com.sun.enterprise.connectors.ConnectorRegistry) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) Property(org.jvnet.hk2.config.types.Property)

Example 15 with ConnectorConfigProperty

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

the class ActiveJmsResourceAdapter method setJmsServiceProperties.

private void setJmsServiceProperties(JmsService service) throws ConnectorRuntimeException {
    JmsRaUtil jmsraUtil = new JmsRaUtil(service);
    jmsraUtil.setupAddressList();
    urlList = jmsraUtil.getUrlList();
    addressList = urlList.toString();
    if (_logger.isLoggable(Level.INFO)) {
        _logger.log(Level.INFO, JMSLoggerInfo.ADDRESSLIST_JMSPROVIDER, new Object[] { addressList });
    }
    ConnectorDescriptor cd = super.getDescriptor();
    setConnectionURL(service, urlList);
    String val = "" + jmsraUtil.getReconnectEnabled();
    ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(RECONNECTENABLED, val, val, "java.lang.Boolean");
    setProperty(cd, envProp2);
    // convert to milliseconds
    int newval = Integer.parseInt(jmsraUtil.getReconnectInterval()) * 1000;
    val = "" + newval;
    ConnectorConfigProperty envProp3 = new ConnectorConfigProperty(RECONNECTINTERVAL, val, val, "java.lang.Integer");
    setProperty(cd, envProp3);
    val = "" + jmsraUtil.getReconnectAttempts();
    ConnectorConfigProperty envProp4 = new ConnectorConfigProperty(RECONNECTATTEMPTS, val, val, "java.lang.Integer");
    setProperty(cd, envProp4);
    val = "" + jmsraUtil.getAddressListBehaviour();
    ConnectorConfigProperty envProp5 = new ConnectorConfigProperty(ADRLIST_BEHAVIOUR, val, val, "java.lang.String");
    setProperty(cd, envProp5);
    val = "" + jmsraUtil.getAddressListIterations();
    ConnectorConfigProperty envProp6 = new ConnectorConfigProperty(ADRLIST_ITERATIONS, val, val, "java.lang.Integer");
    setProperty(cd, envProp6);
    boolean useExternal = shouldUseExternalRmiRegistry(jmsraUtil);
    val = Boolean.valueOf(useExternal).toString();
    ConnectorConfigProperty envProp7 = new ConnectorConfigProperty(USEEXTERNALRMIREGISTRY, val, val, "java.lang.Boolean");
    setProperty(cd, envProp7);
    _logger.log(Level.FINE, "Start RMI registry set as " + val);
    // If MQ RA needs to use AS RMI Registry Port, then set
    // the RMI registry port, else MQ RA uses its default RMI
    // Registry port  [as of now 1099]
    String configuredRmiRegistryPort = null;
    if (!useExternal) {
        configuredRmiRegistryPort = getRmiRegistryPort();
    } else {
        /* We will be here if we are LOCAL or REMOTE, standalone
           * or clustered. We could set the Rmi registry port.
           * The RA should ignore the port if REMOTE and use it only
           * for LOCAL cases.
           */
        configuredRmiRegistryPort = getUniqueRmiRegistryPort();
    }
    val = configuredRmiRegistryPort;
    if (val != null) {
        ConnectorConfigProperty envProp8 = new ConnectorConfigProperty(RMIREGISTRYPORT, val, val, "java.lang.Integer");
        setProperty(cd, envProp8);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "RMI registry port set as " + val);
        }
    } else {
        if (_logger.isLoggable(Level.WARNING)) {
            _logger.log(Level.WARNING, JMSLoggerInfo.INVALID_RMI_PORT);
        }
    }
}
Also used : JmsRaUtil(com.sun.enterprise.connectors.jms.util.JmsRaUtil) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty)

Aggregations

ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)19 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)9 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)6 URISyntaxException (java.net.URISyntaxException)6 Set (java.util.Set)6 PrivilegedActionException (java.security.PrivilegedActionException)5 HashSet (java.util.HashSet)5 Iterator (java.util.Iterator)5 ExecutionException (java.util.concurrent.ExecutionException)5 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)5 MultiException (org.glassfish.hk2.api.MultiException)5 ArrayList (java.util.ArrayList)3 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)3 Property (org.jvnet.hk2.config.types.Property)3 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)2 JmsRaUtil (com.sun.enterprise.connectors.jms.util.JmsRaUtil)2 SetMethodAction (com.sun.enterprise.connectors.util.SetMethodAction)2 Method (java.lang.reflect.Method)2 NamingException (javax.naming.NamingException)2 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)2