Search in sources :

Example 6 with ConnectionDefDescriptor

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

the class ActiveResourceAdapterImpl method createDefaultConnectorConnectionPools.

/**
 * Creates default connector connection pool
 *
 * @param useSunRA whether to use default pool settings or settings in sun-ra.xml
 * @throws ConnectorRuntimeException when unable to create connector connection pools
 */
protected void createDefaultConnectorConnectionPools(boolean useSunRA) throws ConnectorRuntimeException {
    for (ConnectionDefDescriptor descriptor : connectionDefs_) {
        String poolName = connectorRuntime_.getDefaultPoolName(moduleName_, descriptor.getConnectionFactoryIntf());
        PoolInfo poolInfo = new PoolInfo(poolName);
        ConnectorDescriptorInfo connectorDescriptorInfo = ConnectorDDTransformUtils.getConnectorDescriptorInfo(descriptor);
        connectorDescriptorInfo.setRarName(moduleName_);
        connectorDescriptorInfo.setResourceAdapterClassName(desc_.getResourceAdapterClass());
        ConnectorConnectionPool connectorPoolObj;
        // from sunRAXML
        if (useSunRA) {
            connectorPoolObj = ConnectionPoolObjectsUtils.createSunRaConnectorPoolObject(poolInfo, desc_, moduleName_);
        } else {
            connectorPoolObj = ConnectionPoolObjectsUtils.createDefaultConnectorPoolObject(poolInfo, moduleName_);
        }
        connectorPoolObj.setConnectorDescriptorInfo(connectorDescriptorInfo);
        connectorRuntime_.createConnectorConnectionPool(connectorPoolObj);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "Created default connection pool [ " + poolInfo + " ] ");
        }
    }
}
Also used : ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 7 with ConnectionDefDescriptor

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

the class ConnectionDefinitionHandler method handleAnnotation.

private void handleAnnotation(AnnotatedElementHandler aeHandler, ConnectionDefinition connDefn, AnnotationInfo element) {
    RarBundleContext rarContext = (RarBundleContext) aeHandler;
    ConnectorDescriptor desc = rarContext.getDescriptor();
    Class c = (Class) element.getAnnotatedElement();
    String targetClassName = c.getName();
    if (ManagedConnectionFactory.class.isAssignableFrom(c)) {
        if (!desc.getOutBoundDefined()) {
            OutboundResourceAdapter ora = new OutboundResourceAdapter();
            desc.setOutboundResourceAdapter(ora);
        }
        OutboundResourceAdapter ora = desc.getOutboundResourceAdapter();
        if (!ora.hasConnectionDefDescriptor(connDefn.connectionFactory().getName())) {
            ConnectionDefDescriptor cdd = new ConnectionDefDescriptor();
            cdd.setConnectionFactoryImpl(connDefn.connectionFactoryImpl().getName());
            cdd.setConnectionFactoryIntf(connDefn.connectionFactory().getName());
            cdd.setConnectionIntf(connDefn.connection().getName());
            cdd.setConnectionImpl(connDefn.connectionImpl().getName());
            cdd.setManagedConnectionFactoryImpl(targetClassName);
            ora.addConnectionDefDescriptor(cdd);
        }
    // else {
    // ignore the duplicates
    // duplicates can be via :
    // (i) connection-definition defined in DD
    // (ii) as part of this particular annotation processing,
    // already this connection-definition is defined
    // TODO V3 how to handle (ii)
    // }
    } else {
        getFailureResult(element, "Cant handle ConnectionDefinition annotation as the annotated class does not" + "implement ManagedConnectionFactory", true);
    }
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) RarBundleContext(com.sun.enterprise.deployment.annotation.context.RarBundleContext) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Example 8 with ConnectionDefDescriptor

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

the class ConnectorConnectionPoolDeployer method populateConnectorConnectionPool.

private void populateConnectorConnectionPool(ConnectorConnectionPool ccp, String connectionDefinitionName, String rarName, List<Property> props, List<SecurityMap> securityMaps) throws ConnectorRuntimeException {
    ConnectorDescriptor connectorDescriptor = runtime.getConnectorDescriptor(rarName);
    if (connectorDescriptor == null) {
        ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to get connection pool object");
        _logger.log(Level.SEVERE, "rardeployment.connector_descriptor_notfound_registry", rarName);
        _logger.log(Level.SEVERE, "", cre);
        throw cre;
    }
    Set connectionDefs = connectorDescriptor.getOutboundResourceAdapter().getConnectionDefs();
    ConnectionDefDescriptor cdd = null;
    Iterator it = connectionDefs.iterator();
    while (it.hasNext()) {
        cdd = (ConnectionDefDescriptor) it.next();
        if (connectionDefinitionName.equals(cdd.getConnectionFactoryIntf()))
            break;
    }
    ConnectorDescriptorInfo cdi = new ConnectorDescriptorInfo();
    cdi.setRarName(rarName);
    cdi.setResourceAdapterClassName(connectorDescriptor.getResourceAdapterClass());
    cdi.setConnectionDefinitionName(cdd.getConnectionFactoryIntf());
    cdi.setManagedConnectionFactoryClass(cdd.getManagedConnectionFactoryImpl());
    cdi.setConnectionFactoryClass(cdd.getConnectionFactoryImpl());
    cdi.setConnectionFactoryInterface(cdd.getConnectionFactoryIntf());
    cdi.setConnectionClass(cdd.getConnectionImpl());
    cdi.setConnectionInterface(cdd.getConnectionIntf());
    Properties properties = new Properties();
    // Refer Sun Bug :6579154 - Equivalent Oracle Bug :12206278
    if (rarName.trim().equals(ConnectorRuntime.DEFAULT_JMS_ADAPTER)) {
        properties.put("AddressList", "localhost");
    }
    Set mergedProps = ConnectorDDTransformUtils.mergeProps(props, cdd.getConfigProperties(), properties);
    cdi.setMCFConfigProperties(mergedProps);
    cdi.setResourceAdapterConfigProperties(connectorDescriptor.getConfigProperties());
    ccp.setConnectorDescriptorInfo(cdi);
    ccp.setSecurityMaps(SecurityMapUtils.getConnectorSecurityMaps(securityMaps));
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) ConnectorDescriptorInfo(com.sun.enterprise.connectors.ConnectorDescriptorInfo)

Example 9 with ConnectionDefDescriptor

use of com.sun.enterprise.deployment.ConnectionDefDescriptor 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 10 with ConnectionDefDescriptor

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

the class CCITest method getConnectionInterface.

/**
 * <p>
 * Returns the connection-interface that implements
 * "javax.resource.cci.Connection"
 * </p>
 * @param descriptor the deployment descriptor
 * @param result to put the result
 * @return interface name
 */
protected String getConnectionInterface(ConnectorDescriptor descriptor, Result result) {
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    OutboundResourceAdapter outboundRA = descriptor.getOutboundResourceAdapter();
    if (outboundRA == null) {
        return null;
    }
    Set connDefs = outboundRA.getConnectionDefs();
    Iterator iter = connDefs.iterator();
    while (iter.hasNext()) {
        ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor) iter.next();
        String intf = connDefDesc.getConnectionIntf();
        VerifierTestContext context = getVerifierContext();
        ClassLoader jcl = context.getRarClassLoader();
        Class intfClass = null;
        try {
            intfClass = Class.forName(intf, false, getVerifierContext().getClassLoader());
        } catch (ClassNotFoundException e) {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest.isClassLoadable.failed", "The class [ {0} ] is not contained in the archive file", new Object[] { intf }));
            continue;
        }
        if (isImplementorOf(intfClass, "javax.resource.cci.Connection")) {
            return intf;
        }
    }
    return null;
}
Also used : Set(java.util.Set) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) Iterator(java.util.Iterator) ClassLoader(java.lang.ClassLoader) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Aggregations

ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)18 OutboundResourceAdapter (com.sun.enterprise.deployment.OutboundResourceAdapter)11 Iterator (java.util.Iterator)8 Set (java.util.Set)8 Result (com.sun.enterprise.tools.verifier.Result)6 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)4 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)3 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)3 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)2 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)2 ConnectorDescriptorInfo (com.sun.enterprise.connectors.ConnectorDescriptorInfo)1 ConnectorRegistry (com.sun.enterprise.connectors.ConnectorRegistry)1 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)1 RarBundleContext (com.sun.enterprise.deployment.annotation.context.RarBundleContext)1 ClassLoader (java.lang.ClassLoader)1 Method (java.lang.reflect.Method)1 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)1 Property (org.jvnet.hk2.config.types.Property)1