Search in sources :

Example 1 with SunConnector

use of com.sun.enterprise.deployment.runtime.connector.SunConnector in project Payara by payara.

the class ConnectionPoolObjectsUtils method createSunRaConnectorPoolObject.

/**
 * Creates ConnectorConnectionPool object pertaining to the pool props
 * mentioned in the sun-ra/xml i.e it represents the pool mentioned in the
 * sun-ra.xm.
 *
 * @param poolInfo Name of the pool
 * @param desc     ConnectorDescriptor which represent ra.xml and sun-ra.xml.
 * @return ConnectorConnectionPool created ConnectorConnectionPool instance
 */
public static ConnectorConnectionPool createSunRaConnectorPoolObject(PoolInfo poolInfo, ConnectorDescriptor desc, String rarName) {
    ConnectorConnectionPool connectorPoolObj = new ConnectorConnectionPool(poolInfo);
    SunConnector sundesc = desc.getSunDescriptor();
    ResourceAdapter sunRAXML = sundesc.getResourceAdapter();
    connectorPoolObj.setMaxPoolSize((String) sunRAXML.getValue(ResourceAdapter.MAX_POOL_SIZE));
    connectorPoolObj.setSteadyPoolSize((String) sunRAXML.getValue(ResourceAdapter.STEADY_POOL_SIZE));
    connectorPoolObj.setMaxWaitTimeInMillis((String) sunRAXML.getValue(ResourceAdapter.MAX_WAIT_TIME_IN_MILLIS));
    connectorPoolObj.setIdleTimeoutInSeconds((String) sunRAXML.getValue(ResourceAdapter.IDLE_TIMEOUT_IN_SECONDS));
    connectorPoolObj.setPoolResizeQuantity((String) "2");
    connectorPoolObj.setFailAllConnections(false);
    // always
    connectorPoolObj.setMatchConnections(true);
    setDefaultAdvancedPoolAttributes(connectorPoolObj);
    try {
        connectorPoolObj.setTransactionSupport(getTransactionSupportFromRaXml(rarName));
    } catch (Exception ex) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("error in setting txSupport");
        }
    }
    boolean validateAtmostEveryIdleSecs = false;
    // For SunRAPool, get the value of system property VALIDATE_ATMOST_EVERY_IDLE_SECS.
    if (validateAtmostEveryIdleSecsProperty != null && validateAtmostEveryIdleSecsProperty.equalsIgnoreCase("TRUE")) {
        validateAtmostEveryIdleSecs = true;
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "CCP.ValidateAtmostEveryIdleSecs.Set", poolInfo);
        }
    }
    connectorPoolObj.setValidateAtmostEveryIdleSecs(validateAtmostEveryIdleSecs);
    return connectorPoolObj;
}
Also used : ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) SunConnector(com.sun.enterprise.deployment.runtime.connector.SunConnector) ResourceAdapter(com.sun.enterprise.deployment.runtime.connector.ResourceAdapter) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 2 with SunConnector

use of com.sun.enterprise.deployment.runtime.connector.SunConnector in project Payara by payara.

the class AppSpecificConnectorClassLoaderUtil method detectResourceInRA.

private void detectResourceInRA(Application app, String moduleName, String jndiName) {
    // domain.xml
    Resource res = null;
    if (jndiName.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)) /*|| jndiName.startsWith("java:global/")*/
    {
        ApplicationInfo appInfo = appRegistry.get(app.getName());
        res = getApplicationScopedResource(jndiName, BindableResource.class, appInfo);
    } else if (jndiName.startsWith(ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX)) {
        ApplicationInfo appInfo = appRegistry.get(app.getName());
        res = getModuleScopedResource(jndiName, moduleName, BindableResource.class, appInfo);
    } else {
        res = ConnectorsUtil.getResourceByName(getResources(), BindableResource.class, jndiName);
    }
    // (and .ear may refer to these resources in DD)
    if (res != null) {
        if (ConnectorResource.class.isAssignableFrom(res.getClass())) {
            ConnectorResource connResource = (ConnectorResource) res;
            String poolName = connResource.getPoolName();
            Resource pool;
            ApplicationInfo appInfo = appRegistry.get(app.getName());
            if (jndiName.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)) /*|| jndiName.startsWith("java:global/")*/
            {
                pool = getApplicationScopedResource(poolName, ResourcePool.class, appInfo);
            } else if (jndiName.startsWith(ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX)) {
                pool = getModuleScopedResource(poolName, moduleName, ResourcePool.class, appInfo);
            } else {
                pool = ConnectorsUtil.getResourceByName(getResources(), ResourcePool.class, poolName);
            }
            if (ConnectorConnectionPool.class.isAssignableFrom(pool.getClass())) {
                String raName = ((ConnectorConnectionPool) pool).getResourceAdapterName();
                app.addResourceAdapter(raName);
            }
        } else if (AdminObjectResource.class.isAssignableFrom(res.getClass())) {
            String raName = ((AdminObjectResource) res).getResAdapter();
            app.addResourceAdapter(raName);
        }
    } else {
        boolean found = false;
        // detect sun-ra.xml
        // find all the standalone connector modules
        List<com.sun.enterprise.config.serverbeans.Application> applications = getApplications().getApplicationsWithSnifferType(com.sun.enterprise.config.serverbeans.ServerTags.CONNECTOR, true);
        Iterator itr = applications.iterator();
        while (itr.hasNext()) {
            com.sun.enterprise.config.serverbeans.Application application = (com.sun.enterprise.config.serverbeans.Application) itr.next();
            String appName = application.getName();
            ApplicationInfo appInfo = appRegistry.get(appName);
            if (appInfo == null) {
                // the app is not deployed on this node
                continue;
            }
            Application dolApp = appInfo.getMetaData(Application.class);
            Collection<ConnectorDescriptor> rarDescriptors = dolApp.getBundleDescriptors(ConnectorDescriptor.class);
            for (ConnectorDescriptor desc : rarDescriptors) {
                SunConnector sunraDesc = desc.getSunDescriptor();
                if (sunraDesc != null) {
                    String sunRAJndiName = (String) sunraDesc.getResourceAdapter().getValue(ResourceAdapter.JNDI_NAME);
                    if (jndiName.equals(sunRAJndiName)) {
                        app.addResourceAdapter(desc.getName());
                        found = true;
                        break;
                    }
                } else {
                    // check whether it is default resource in the connector
                    if (desc.getDefaultResourcesNames().contains(jndiName)) {
                        app.addResourceAdapter(desc.getName());
                        found = true;
                        break;
                    }
                }
            }
        }
        if (!found) {
            if (DOLUtils.getDefaultLogger().isLoggable(Level.FINEST)) {
                DOLUtils.getDefaultLogger().log(Level.FINEST, "could not find resource by name : " + jndiName);
            }
        }
    }
}
Also used : ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource) Resource(com.sun.enterprise.config.serverbeans.Resource) BindableResource(com.sun.enterprise.config.serverbeans.BindableResource) ConnectorResource(org.glassfish.connectors.config.ConnectorResource) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) BindableResource(com.sun.enterprise.config.serverbeans.BindableResource) Iterator(java.util.Iterator) SunConnector(com.sun.enterprise.deployment.runtime.connector.SunConnector) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource) Application(com.sun.enterprise.deployment.Application) ConnectorResource(org.glassfish.connectors.config.ConnectorResource)

Example 3 with SunConnector

use of com.sun.enterprise.deployment.runtime.connector.SunConnector in project Payara by payara.

the class ConnectorNode method getSunConnectorDescriptor.

/**
 * @return the descriptor instance to associate with this XMLNode
 */
public SunConnector getSunConnectorDescriptor() {
    if (connector == null) {
        connector = new SunConnector();
        descriptor.setSunDescriptor(connector);
    }
    return connector;
}
Also used : SunConnector(com.sun.enterprise.deployment.runtime.connector.SunConnector)

Example 4 with SunConnector

use of com.sun.enterprise.deployment.runtime.connector.SunConnector in project Payara by payara.

the class ConnectorNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node for the DOM tree
 * @param node name for the descriptor
 * @param the descriptor to write
 * @return the DOM tree top node
 */
public Node writeDescriptor(Node parent, String nodeName, ConnectorDescriptor connector) {
    Node connectorNode = super.writeDescriptor(parent, nodeName, connector);
    // resource-adapter
    SunConnector sunDesc = connector.getSunDescriptor();
    if (sunDesc != null) {
        ResourceAdapterNode ran = new ResourceAdapterNode();
        ran.writeDescriptor(connectorNode, RuntimeTagNames.RESOURCE_ADAPTER, sunDesc.getResourceAdapter());
        // role-map ?
        if (sunDesc.getRoleMap() != null) {
            RoleMapNode rmn = new RoleMapNode();
            rmn.writeDescriptor(connectorNode, RuntimeTagNames.ROLE_MAP, sunDesc.getRoleMap());
        }
    }
    return connectorNode;
}
Also used : RuntimeBundleNode(com.sun.enterprise.deployment.node.runtime.RuntimeBundleNode) Node(org.w3c.dom.Node) SunConnector(com.sun.enterprise.deployment.runtime.connector.SunConnector)

Aggregations

SunConnector (com.sun.enterprise.deployment.runtime.connector.SunConnector)4 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 BindableResource (com.sun.enterprise.config.serverbeans.BindableResource)1 Resource (com.sun.enterprise.config.serverbeans.Resource)1 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)1 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)1 Application (com.sun.enterprise.deployment.Application)1 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)1 RuntimeBundleNode (com.sun.enterprise.deployment.node.runtime.RuntimeBundleNode)1 ResourceAdapter (com.sun.enterprise.deployment.runtime.connector.ResourceAdapter)1 Iterator (java.util.Iterator)1 AdminObjectResource (org.glassfish.connectors.config.AdminObjectResource)1 ConnectorConnectionPool (org.glassfish.connectors.config.ConnectorConnectionPool)1 ConnectorResource (org.glassfish.connectors.config.ConnectorResource)1 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)1 Node (org.w3c.dom.Node)1