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());
}
}
}
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;
}
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);
}
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;
}
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;
}
Aggregations