Search in sources :

Example 1 with ResourceAdapterConfig

use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.

the class ResourceAdapterAdminServiceImpl method updateRAConfigInDescriptor.

/**
 * Updates the connector descriptor of the connector module, with the
 * contents of a resource adapter config if specified.
 *
 * This modified ConnectorDescriptor is then bound to JNDI so that ACC
 * clients while configuring a non-system RAR could get the correct merged
 * configuration. Any updates to resource-adapter config while an ACC client
 * is in use is not transmitted to the client dynamically. All such changes
 * would be visible on ACC client restart.
 */
private void updateRAConfigInDescriptor(ConnectorDescriptor connectorDescriptor, String moduleName) {
    ResourceAdapterConfig raConfig = ConnectorRegistry.getInstance().getResourceAdapterConfig(moduleName);
    List<Property> raConfigProps = null;
    if (raConfig != null) {
        raConfigProps = raConfig.getProperty();
    }
    if (_logger.isLoggable(Level.FINE)) {
        _logger.fine("current RAConfig In Descriptor " + connectorDescriptor.getConfigProperties());
    }
    if (raConfigProps != null) {
        Set mergedProps = ConnectorDDTransformUtils.mergeProps(raConfigProps, connectorDescriptor.getConfigProperties());
        Set actualProps = connectorDescriptor.getConfigProperties();
        actualProps.clear();
        actualProps.addAll(mergedProps);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("updated RAConfig In Descriptor " + connectorDescriptor.getConfigProperties());
        }
    }
}
Also used : ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig) Property(org.jvnet.hk2.config.types.Property)

Example 2 with ResourceAdapterConfig

use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.

the class ResourceAdapterConfigManager method createConfigBean.

private ResourceAdapterConfig createConfigBean(Resources param, Properties properties) throws PropertyVetoException, TransactionFailure {
    ResourceAdapterConfig newResource = param.createChild(ResourceAdapterConfig.class);
    newResource.setResourceAdapterName(raName);
    if (threadPoolIds != null) {
        newResource.setThreadPoolIds(threadPoolIds);
    }
    newResource.setObjectType(objectType);
    if (name != null) {
        newResource.setName(name);
    }
    if (properties != null) {
        for (Map.Entry e : properties.entrySet()) {
            Property prop = newResource.createChild(Property.class);
            prop.setName((String) e.getKey());
            prop.setValue((String) e.getValue());
            newResource.getProperty().add(prop);
        }
    }
    return newResource;
}
Also used : ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig) HashMap(java.util.HashMap) Map(java.util.Map) Property(org.jvnet.hk2.config.types.Property)

Example 3 with ResourceAdapterConfig

use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.

the class ResourceAdapterConfigManager method create.

public ResourceStatus create(Resources resources, HashMap attributes, final Properties properties, String target) throws Exception {
    setParams(attributes);
    ResourceStatus validationStatus = isValid(resources);
    if (validationStatus.getStatus() == ResourceStatus.FAILURE) {
        return validationStatus;
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<Resources>() {

            public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
                ResourceAdapterConfig newResource = createConfigBean(param, properties);
                param.getResources().add(newResource);
                return newResource;
            }
        }, resources);
    } catch (TransactionFailure tfe) {
        Logger.getLogger(ResourceAdapterConfigManager.class.getName()).log(Level.SEVERE, "TransactionFailure: create-resource-adapter-config", tfe);
        String msg = localStrings.getLocalString("create.resource.adapter.config.fail", "Unable to create resource adapter config", raName) + " " + tfe.getLocalizedMessage();
        return new ResourceStatus(ResourceStatus.FAILURE, msg);
    }
    String msg = localStrings.getLocalString("create.resource.adapter.config.success", "Resource adapter config {0} created successfully", raName);
    return new ResourceStatus(ResourceStatus.SUCCESS, msg);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig) ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) Resources(com.sun.enterprise.config.serverbeans.Resources)

Example 4 with ResourceAdapterConfig

use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.

the class AppSpecificConnectorClassLoaderUtil method getModuleScopedResource.

private <T> Resource getModuleScopedResource(String name, String moduleName, Class<T> type, ApplicationInfo appInfo) {
    Resource foundRes = null;
    if (appInfo != null) {
        com.sun.enterprise.config.serverbeans.Application app = appInfo.getTransientAppMetaData(com.sun.enterprise.config.serverbeans.ServerTags.APPLICATION, com.sun.enterprise.config.serverbeans.Application.class);
        Resources resources = null;
        if (app != null) {
            Module module = null;
            List<Module> modules = app.getModule();
            for (Module m : modules) {
                if (ConnectorsUtil.getActualModuleName(m.getName()).equals(moduleName)) {
                    module = m;
                    break;
                }
            }
            if (module != null) {
                resources = appInfo.getTransientAppMetaData(module.getName() + "-resources", Resources.class);
            }
        }
        if (resources != null) {
            boolean bindableResource = BindableResource.class.isAssignableFrom(type);
            boolean poolResource = ResourcePool.class.isAssignableFrom(type);
            boolean workSecurityMap = WorkSecurityMap.class.isAssignableFrom(type);
            boolean rac = ResourceAdapterConfig.class.isAssignableFrom(type);
            Iterator itr = resources.getResources().iterator();
            while (itr.hasNext()) {
                String resourceName = null;
                Resource res = (Resource) itr.next();
                if (bindableResource && res instanceof BindableResource) {
                    resourceName = ((BindableResource) res).getJndiName();
                } else if (poolResource && res instanceof ResourcePool) {
                    resourceName = ((ResourcePool) res).getName();
                } else if (rac && res instanceof ResourceAdapterConfig) {
                    resourceName = ((ResourceAdapterConfig) res).getName();
                } else if (workSecurityMap && res instanceof WorkSecurityMap) {
                    resourceName = ((WorkSecurityMap) res).getName();
                }
                if (resourceName != null) {
                    if (!(resourceName.startsWith(ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX))) {
                        resourceName = ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX + resourceName;
                    }
                    if (!(name.startsWith(ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX))) {
                        name = ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX + name;
                    }
                    if (name.equals(resourceName)) {
                        foundRes = res;
                        break;
                    }
                }
            }
        }
    }
    return foundRes;
}
Also used : 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) ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig) WorkSecurityMap(org.glassfish.connectors.config.WorkSecurityMap) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool) BindableResource(com.sun.enterprise.config.serverbeans.BindableResource) Iterator(java.util.Iterator) Resources(com.sun.enterprise.config.serverbeans.Resources) Module(com.sun.enterprise.config.serverbeans.Module)

Example 5 with ResourceAdapterConfig

use of org.glassfish.connectors.config.ResourceAdapterConfig in project Payara by payara.

the class AppSpecificConnectorClassLoaderUtil method getApplicationScopedResource.

private <T> Resource getApplicationScopedResource(String name, Class<T> type, ApplicationInfo appInfo) {
    Resource foundRes = null;
    if (appInfo != null) {
        com.sun.enterprise.config.serverbeans.Application app = appInfo.getTransientAppMetaData(com.sun.enterprise.config.serverbeans.ServerTags.APPLICATION, com.sun.enterprise.config.serverbeans.Application.class);
        Resources resources = null;
        if (app != null) {
            resources = appInfo.getTransientAppMetaData(app.getName() + "-resources", Resources.class);
        }
        if (resources != null) {
            boolean bindableResource = BindableResource.class.isAssignableFrom(type);
            boolean poolResource = ResourcePool.class.isAssignableFrom(type);
            boolean workSecurityMap = WorkSecurityMap.class.isAssignableFrom(type);
            boolean rac = ResourceAdapterConfig.class.isAssignableFrom(type);
            Iterator itr = resources.getResources().iterator();
            while (itr.hasNext()) {
                String resourceName = null;
                Resource res = (Resource) itr.next();
                if (bindableResource && res instanceof BindableResource) {
                    resourceName = ((BindableResource) res).getJndiName();
                } else if (poolResource && res instanceof ResourcePool) {
                    resourceName = ((ResourcePool) res).getName();
                } else if (rac && res instanceof ResourceAdapterConfig) {
                    resourceName = ((ResourceAdapterConfig) res).getName();
                } else if (workSecurityMap && res instanceof WorkSecurityMap) {
                    resourceName = ((WorkSecurityMap) res).getName();
                }
                if (resourceName != null) {
                    if (!(resourceName.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX))) {
                        resourceName = ConnectorConstants.JAVA_APP_SCOPE_PREFIX + resourceName;
                    }
                    if (!(name.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX))) {
                        name = ConnectorConstants.JAVA_APP_SCOPE_PREFIX + name;
                    }
                    if (name.equals(resourceName)) {
                        foundRes = res;
                        break;
                    }
                }
            }
        }
    }
    return foundRes;
}
Also used : 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) ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig) WorkSecurityMap(org.glassfish.connectors.config.WorkSecurityMap) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool) BindableResource(com.sun.enterprise.config.serverbeans.BindableResource) Iterator(java.util.Iterator) Resources(com.sun.enterprise.config.serverbeans.Resources)

Aggregations

ResourceAdapterConfig (org.glassfish.connectors.config.ResourceAdapterConfig)11 Resources (com.sun.enterprise.config.serverbeans.Resources)4 Property (org.jvnet.hk2.config.types.Property)4 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)2 BindableResource (com.sun.enterprise.config.serverbeans.BindableResource)2 Resource (com.sun.enterprise.config.serverbeans.Resource)2 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)2 ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 ActionReport (org.glassfish.api.ActionReport)2 AdminObjectResource (org.glassfish.connectors.config.AdminObjectResource)2 ConnectorResource (org.glassfish.connectors.config.ConnectorResource)2 WorkSecurityMap (org.glassfish.connectors.config.WorkSecurityMap)2 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)2 Module (com.sun.enterprise.config.serverbeans.Module)1 SetMethodAction (com.sun.enterprise.connectors.util.SetMethodAction)1 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)1 PropertyVetoException (java.beans.PropertyVetoException)1 List (java.util.List)1