use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method generateResourceAdapterConfig.
// end of generateSecurityMap....
/**
* Generate the Resource Adapter Config
*/
private void generateResourceAdapterConfig(Node nextKid, String scope) throws Exception {
// ignore "scope" as resource-adapter-config is not a bindable resource
NamedNodeMap attributes = nextKid.getAttributes();
if (attributes == null)
return;
Resource resAdapterConfigResource = new Resource(Resource.RESOURCE_ADAPTER_CONFIG);
Node resAdapConfigNode = attributes.getNamedItem(RES_ADAPTER_CONFIG);
if (resAdapConfigNode != null) {
String resAdapConfig = resAdapConfigNode.getNodeValue();
resAdapterConfigResource.setAttribute(RES_ADAPTER_CONFIG, resAdapConfig);
}
Node poolIdNode = attributes.getNamedItem(THREAD_POOL_IDS);
if (poolIdNode != null) {
String threadPoolId = poolIdNode.getNodeValue();
resAdapterConfigResource.setAttribute(THREAD_POOL_IDS, threadPoolId);
}
Node resAdapNameNode = attributes.getNamedItem(RES_ADAPTER_NAME);
if (resAdapNameNode != null) {
String resAdapName = resAdapNameNode.getNodeValue();
resAdapterConfigResource.setAttribute(RES_ADAPTER_NAME, resAdapName);
}
NodeList children = nextKid.getChildNodes();
generatePropertyElement(resAdapterConfigResource, children);
vResources.add(resAdapterConfigResource);
resourceMap.put(resAdapterConfigResource, nextKid);
// debug strings
printResourceElements(resAdapterConfigResource);
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method sortConnectorResources.
/**
* Sort connector resources
* Resource Adapter configs are added first.
* Pools are then added to the list, so that the connection
* pools can be created prior to any other connector resource defined
* in the resources configuration xml file.
* @param connectorResources List of Resources to be sorted.
* @return The sorted list.
*/
private static List<Resource> sortConnectorResources(List<org.glassfish.resources.api.Resource> connectorResources) {
List<org.glassfish.resources.api.Resource> raconfigs = new ArrayList<Resource>();
List<Resource> ccps = new ArrayList<org.glassfish.resources.api.Resource>();
List<org.glassfish.resources.api.Resource> others = new ArrayList<org.glassfish.resources.api.Resource>();
List<Resource> finalSortedConnectorList = new ArrayList<Resource>();
for (Resource resource : connectorResources) {
if (resource.getType().equals(org.glassfish.resources.api.Resource.RESOURCE_ADAPTER_CONFIG)) {
raconfigs.add(resource);
} else if (resource.getType().equals(org.glassfish.resources.api.Resource.CONNECTOR_CONNECTION_POOL)) {
ccps.add(resource);
} else {
others.add(resource);
}
}
finalSortedConnectorList.addAll(raconfigs);
finalSortedConnectorList.addAll(ccps);
finalSortedConnectorList.addAll(others);
return finalSortedConnectorList;
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method generateMailResource.
/**
* Generate the Mail resource
*/
private void generateMailResource(Node nextKid, String scope) throws Exception {
NamedNodeMap attributes = nextKid.getAttributes();
if (attributes == null)
return;
Node jndiNameNode = attributes.getNamedItem(JNDI_NAME);
Node hostNode = attributes.getNamedItem(MAIL_HOST);
Node userNode = attributes.getNamedItem(MAIL_USER);
Node fromAddressNode = attributes.getNamedItem(MAIL_FROM_ADDRESS);
Node storeProtoNode = attributes.getNamedItem(MAIL_STORE_PROTO);
Node storeProtoClassNode = attributes.getNamedItem(MAIL_STORE_PROTO_CLASS);
Node transProtoNode = attributes.getNamedItem(MAIL_TRANS_PROTO);
Node transProtoClassNode = attributes.getNamedItem(MAIL_TRANS_PROTO_CLASS);
Node debugNode = attributes.getNamedItem(MAIL_DEBUG);
Node enabledNode = attributes.getNamedItem(ENABLED);
String jndiName = getScopedName(jndiNameNode.getNodeValue(), scope);
String host = hostNode.getNodeValue();
String user = userNode.getNodeValue();
String fromAddress = fromAddressNode.getNodeValue();
org.glassfish.resources.api.Resource mailResource = new org.glassfish.resources.api.Resource(org.glassfish.resources.api.Resource.MAIL_RESOURCE);
mailResource.setAttribute(JNDI_NAME, jndiName);
mailResource.setAttribute(MAIL_HOST, host);
mailResource.setAttribute(MAIL_USER, user);
mailResource.setAttribute(MAIL_FROM_ADDRESS, fromAddress);
if (storeProtoNode != null) {
String sStoreProto = storeProtoNode.getNodeValue();
mailResource.setAttribute(MAIL_STORE_PROTO, sStoreProto);
}
if (storeProtoClassNode != null) {
String sStoreProtoClass = storeProtoClassNode.getNodeValue();
mailResource.setAttribute(MAIL_STORE_PROTO_CLASS, sStoreProtoClass);
}
if (transProtoNode != null) {
String sTransProto = transProtoNode.getNodeValue();
mailResource.setAttribute(MAIL_TRANS_PROTO, sTransProto);
}
if (transProtoClassNode != null) {
String sTransProtoClass = transProtoClassNode.getNodeValue();
mailResource.setAttribute(MAIL_TRANS_PROTO_CLASS, sTransProtoClass);
}
if (debugNode != null) {
String sDebug = debugNode.getNodeValue();
mailResource.setAttribute(MAIL_DEBUG, sDebug);
}
if (enabledNode != null) {
String sEnabled = enabledNode.getNodeValue();
mailResource.setAttribute(ENABLED, sEnabled);
}
NodeList children = nextKid.getChildNodes();
generatePropertyElement(mailResource, children);
vResources.add(mailResource);
resourceMap.put(mailResource, nextKid);
// debug strings
printResourceElements(mailResource);
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method generateSecurityMap.
private void generateSecurityMap(String poolName, Node mapNode, String scope) throws Exception {
// scope is not needed for security map.
NamedNodeMap attributes = mapNode.getAttributes();
if (attributes == null)
return;
Node nameNode = attributes.getNamedItem(SECURITY_MAP_NAME);
Resource map = new Resource(org.glassfish.resources.api.Resource.CONNECTOR_SECURITY_MAP);
if (nameNode != null) {
String name = nameNode.getNodeValue();
map.setAttribute(SECURITY_MAP_NAME, name);
}
if (poolName != null)
map.setAttribute(POOL_NAME, poolName);
StringBuffer principal = new StringBuffer();
StringBuffer usergroup = new StringBuffer();
NodeList children = mapNode.getChildNodes();
if (children != null) {
for (int i = 0; i < children.getLength(); i++) {
Node gChild = children.item(i);
String strNodeName = gChild.getNodeName();
if (strNodeName.equals(SECURITY_MAP_PRINCIPAL)) {
String p = (gChild.getFirstChild()).getNodeValue();
principal.append(p).append(",");
}
if (strNodeName.equals(SECURITY_MAP_USER_GROUP)) {
String u = (gChild.getFirstChild()).getNodeValue();
usergroup.append(u).append(",");
}
if ((strNodeName.equals(SECURITY_MAP_BACKEND_PRINCIPAL))) {
NamedNodeMap attributes1 = (children.item(i)).getAttributes();
if (attributes1 != null) {
Node userNode = attributes1.getNamedItem(USER_NAME);
if (userNode != null) {
String userName = userNode.getNodeValue();
map.setAttribute(USER_NAME, userName);
}
Node passwordNode = attributes1.getNamedItem(PASSWORD);
if (passwordNode != null) {
String pwd = passwordNode.getNodeValue();
map.setAttribute(PASSWORD, pwd);
}
}
}
}
}
map.setAttribute(SECURITY_MAP_PRINCIPAL, convertToStringArray(principal.toString()));
map.setAttribute("user_group", convertToStringArray(usergroup.toString()));
vResources.add(map);
resourceMap.put(map, mapNode);
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method generateJDBCConnectionPoolResource.
/**
* Generate the JDBC Connection pool Resource
*/
private void generateJDBCConnectionPoolResource(Node nextKid, String scope) throws Exception {
NamedNodeMap attributes = nextKid.getAttributes();
if (attributes == null)
return;
Node nameNode = attributes.getNamedItem(CONNECTION_POOL_NAME);
String name = getScopedName(nameNode.getNodeValue(), scope);
Node nSteadyPoolSizeNode = attributes.getNamedItem(STEADY_POOL_SIZE);
Node nMaxPoolSizeNode = attributes.getNamedItem(MAX_POOL_SIZE);
Node nMaxWaitTimeInMillisNode = attributes.getNamedItem(MAX_WAIT_TIME_IN_MILLIS);
Node nPoolSizeQuantityNode = attributes.getNamedItem(POOL_SIZE_QUANTITY);
Node nIdleTimeoutInSecNode = attributes.getNamedItem(IDLE_TIME_OUT_IN_SECONDS);
Node nIsConnectionValidationRequiredNode = attributes.getNamedItem(IS_CONNECTION_VALIDATION_REQUIRED);
Node nConnectionValidationMethodNode = attributes.getNamedItem(CONNECTION_VALIDATION_METHOD);
Node nFailAllConnectionsNode = attributes.getNamedItem(FAIL_ALL_CONNECTIONS);
Node nValidationTableNameNode = attributes.getNamedItem(VALIDATION_TABLE_NAME);
Node nResType = attributes.getNamedItem(RES_TYPE);
Node nTransIsolationLevel = attributes.getNamedItem(TRANS_ISOLATION_LEVEL);
Node nIsIsolationLevelQuaranteed = attributes.getNamedItem(IS_ISOLATION_LEVEL_GUARANTEED);
Node datasourceNode = attributes.getNamedItem(DATASOURCE_CLASS);
Node validationclassnameNode = attributes.getNamedItem(VALIDATION_CLASSNAME);
Node nonTransactionalConnectionsNode = attributes.getNamedItem(NON_TRANSACTIONAL_CONNECTIONS);
Node allowNonComponentCallersNode = attributes.getNamedItem(ALLOW_NON_COMPONENT_CALLERS);
Node validateAtmostOncePeriodNode = attributes.getNamedItem(VALIDATE_ATMOST_ONCE_PERIOD_IN_SECONDS);
Node connectionLeakTimeoutNode = attributes.getNamedItem(CONNECTION_LEAK_TIMEOUT_IN_SECONDS);
Node connectionLeakReclaimNode = attributes.getNamedItem(CONNECTION_LEAK_RECLAIM);
Node connectionCreationRetryAttemptsNode = attributes.getNamedItem(CONNECTION_CREATION_RETRY_ATTEMPTS);
Node connectionCreationRetryIntervalNode = attributes.getNamedItem(CONNECTION_CREATION_RETRY_INTERVAL_IN_SECONDS);
Node statementTimeoutNode = attributes.getNamedItem(STATEMENT_TIMEOUT_IN_SECONDS);
Node lazyConnectionEnlistmentNode = attributes.getNamedItem(LAZY_CONNECTION_ENLISTMENT);
Node lazyConnectionAssociationNode = attributes.getNamedItem(LAZY_CONNECTION_ASSOCIATION);
Node associateWithThreadNode = attributes.getNamedItem(ASSOCIATE_WITH_THREAD);
Node matchConnectionsNode = attributes.getNamedItem(MATCH_CONNECTIONS);
Node maxConnectionUsageCountNode = attributes.getNamedItem(MAX_CONNECTION_USAGE_COUNT);
Node wrapJDBCObjectsNode = attributes.getNamedItem(WRAP_JDBC_OBJECTS);
Node poolingNode = attributes.getNamedItem(POOLING);
Node pingNode = attributes.getNamedItem(PING);
Node customValidationNode = attributes.getNamedItem(CUSTOM_VALIDATION);
Node driverClassNameNode = attributes.getNamedItem(DRIVER_CLASSNAME);
Node initSqlNode = attributes.getNamedItem(INIT_SQL);
Node sqlTraceListenersNode = attributes.getNamedItem(SQL_TRACE_LISTENERS);
Node statementCacheSizeNode = attributes.getNamedItem(STATEMENT_CACHE_SIZE);
Node statementLeakTimeoutNode = attributes.getNamedItem(STATEMENT_LEAK_TIMEOUT_IN_SECONDS);
Node statementLeakReclaimNode = attributes.getNamedItem(STATEMENT_LEAK_RECLAIM);
org.glassfish.resources.api.Resource jdbcConnPool = new Resource(org.glassfish.resources.api.Resource.JDBC_CONNECTION_POOL);
jdbcConnPool.setAttribute(CONNECTION_POOL_NAME, name);
if (datasourceNode != null) {
String datasource = datasourceNode.getNodeValue();
jdbcConnPool.setAttribute(DATASOURCE_CLASS, datasource);
}
if (validationclassnameNode != null) {
String validationclassname = validationclassnameNode.getNodeValue();
jdbcConnPool.setAttribute(VALIDATION_CLASSNAME, validationclassname);
}
if (nSteadyPoolSizeNode != null) {
String sSteadyPoolSize = nSteadyPoolSizeNode.getNodeValue();
jdbcConnPool.setAttribute(STEADY_POOL_SIZE, sSteadyPoolSize);
}
if (nMaxPoolSizeNode != null) {
String sMaxPoolSize = nMaxPoolSizeNode.getNodeValue();
jdbcConnPool.setAttribute(MAX_POOL_SIZE, sMaxPoolSize);
}
if (nMaxWaitTimeInMillisNode != null) {
String sMaxWaitTimeInMillis = nMaxWaitTimeInMillisNode.getNodeValue();
jdbcConnPool.setAttribute(MAX_WAIT_TIME_IN_MILLIS, sMaxWaitTimeInMillis);
}
if (nPoolSizeQuantityNode != null) {
String sPoolSizeQuantity = nPoolSizeQuantityNode.getNodeValue();
jdbcConnPool.setAttribute(POOL_SIZE_QUANTITY, sPoolSizeQuantity);
}
if (nIdleTimeoutInSecNode != null) {
String sIdleTimeoutInSec = nIdleTimeoutInSecNode.getNodeValue();
jdbcConnPool.setAttribute(IDLE_TIME_OUT_IN_SECONDS, sIdleTimeoutInSec);
}
if (nIsConnectionValidationRequiredNode != null) {
String sIsConnectionValidationRequired = nIsConnectionValidationRequiredNode.getNodeValue();
jdbcConnPool.setAttribute(IS_CONNECTION_VALIDATION_REQUIRED, sIsConnectionValidationRequired);
}
if (nConnectionValidationMethodNode != null) {
String sConnectionValidationMethod = nConnectionValidationMethodNode.getNodeValue();
jdbcConnPool.setAttribute(CONNECTION_VALIDATION_METHOD, sConnectionValidationMethod);
}
if (nFailAllConnectionsNode != null) {
String sFailAllConnection = nFailAllConnectionsNode.getNodeValue();
jdbcConnPool.setAttribute(FAIL_ALL_CONNECTIONS, sFailAllConnection);
}
if (nValidationTableNameNode != null) {
String sValidationTableName = nValidationTableNameNode.getNodeValue();
jdbcConnPool.setAttribute(VALIDATION_TABLE_NAME, sValidationTableName);
}
if (nResType != null) {
String sResType = nResType.getNodeValue();
jdbcConnPool.setAttribute(RES_TYPE, sResType);
}
if (nTransIsolationLevel != null) {
String sTransIsolationLevel = nTransIsolationLevel.getNodeValue();
jdbcConnPool.setAttribute(TRANS_ISOLATION_LEVEL, sTransIsolationLevel);
}
if (nIsIsolationLevelQuaranteed != null) {
String sIsIsolationLevelQuaranteed = nIsIsolationLevelQuaranteed.getNodeValue();
jdbcConnPool.setAttribute(IS_ISOLATION_LEVEL_GUARANTEED, sIsIsolationLevelQuaranteed);
}
if (nonTransactionalConnectionsNode != null) {
jdbcConnPool.setAttribute(NON_TRANSACTIONAL_CONNECTIONS, nonTransactionalConnectionsNode.getNodeValue());
}
if (allowNonComponentCallersNode != null) {
jdbcConnPool.setAttribute(ALLOW_NON_COMPONENT_CALLERS, allowNonComponentCallersNode.getNodeValue());
}
if (validateAtmostOncePeriodNode != null) {
jdbcConnPool.setAttribute(VALIDATE_ATMOST_ONCE_PERIOD_IN_SECONDS, validateAtmostOncePeriodNode.getNodeValue());
}
if (connectionLeakTimeoutNode != null) {
jdbcConnPool.setAttribute(CONNECTION_LEAK_TIMEOUT_IN_SECONDS, connectionLeakTimeoutNode.getNodeValue());
}
if (connectionLeakReclaimNode != null) {
jdbcConnPool.setAttribute(CONNECTION_LEAK_RECLAIM, connectionLeakReclaimNode.getNodeValue());
}
if (connectionCreationRetryAttemptsNode != null) {
jdbcConnPool.setAttribute(CONNECTION_CREATION_RETRY_ATTEMPTS, connectionCreationRetryAttemptsNode.getNodeValue());
}
if (connectionCreationRetryIntervalNode != null) {
jdbcConnPool.setAttribute(CONNECTION_CREATION_RETRY_INTERVAL_IN_SECONDS, connectionCreationRetryIntervalNode.getNodeValue());
}
if (statementTimeoutNode != null) {
jdbcConnPool.setAttribute(STATEMENT_TIMEOUT_IN_SECONDS, statementTimeoutNode.getNodeValue());
}
if (lazyConnectionEnlistmentNode != null) {
jdbcConnPool.setAttribute(LAZY_CONNECTION_ENLISTMENT, lazyConnectionEnlistmentNode.getNodeValue());
}
if (lazyConnectionAssociationNode != null) {
jdbcConnPool.setAttribute(LAZY_CONNECTION_ASSOCIATION, lazyConnectionAssociationNode.getNodeValue());
}
if (associateWithThreadNode != null) {
jdbcConnPool.setAttribute(ASSOCIATE_WITH_THREAD, associateWithThreadNode.getNodeValue());
}
if (matchConnectionsNode != null) {
jdbcConnPool.setAttribute(MATCH_CONNECTIONS, matchConnectionsNode.getNodeValue());
}
if (maxConnectionUsageCountNode != null) {
jdbcConnPool.setAttribute(MAX_CONNECTION_USAGE_COUNT, maxConnectionUsageCountNode.getNodeValue());
}
if (wrapJDBCObjectsNode != null) {
jdbcConnPool.setAttribute(WRAP_JDBC_OBJECTS, wrapJDBCObjectsNode.getNodeValue());
}
if (poolingNode != null) {
String pooling = poolingNode.getNodeValue();
jdbcConnPool.setAttribute(POOLING, pooling);
}
if (pingNode != null) {
String ping = pingNode.getNodeValue();
jdbcConnPool.setAttribute(PING, ping);
}
if (initSqlNode != null) {
String initSQL = initSqlNode.getNodeValue();
jdbcConnPool.setAttribute(INIT_SQL, initSQL);
}
if (sqlTraceListenersNode != null) {
String sqlTraceListeners = sqlTraceListenersNode.getNodeValue();
jdbcConnPool.setAttribute(SQL_TRACE_LISTENERS, sqlTraceListeners);
}
if (customValidationNode != null) {
String customValidation = customValidationNode.getNodeValue();
jdbcConnPool.setAttribute(CUSTOM_VALIDATION, customValidation);
}
if (driverClassNameNode != null) {
String driverClassName = driverClassNameNode.getNodeValue();
jdbcConnPool.setAttribute(DRIVER_CLASSNAME, driverClassName);
}
if (statementCacheSizeNode != null) {
String statementCacheSize = statementCacheSizeNode.getNodeValue();
jdbcConnPool.setAttribute(STATEMENT_CACHE_SIZE, statementCacheSize);
}
if (statementLeakTimeoutNode != null) {
jdbcConnPool.setAttribute(STATEMENT_LEAK_TIMEOUT_IN_SECONDS, statementLeakTimeoutNode.getNodeValue());
}
if (statementLeakReclaimNode != null) {
jdbcConnPool.setAttribute(STATEMENT_LEAK_RECLAIM, statementLeakReclaimNode.getNodeValue());
}
NodeList children = nextKid.getChildNodes();
generatePropertyElement(jdbcConnPool, children);
vResources.add(jdbcConnPool);
resourceMap.put(jdbcConnPool, nextKid);
// debug strings
printResourceElements(jdbcConnPool);
}
Aggregations