use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method generateJNDIResource.
/**
* Generate the JNDI resource
*/
private void generateJNDIResource(Node nextKid, String scope) throws Exception {
NamedNodeMap attributes = nextKid.getAttributes();
if (attributes == null)
return;
Node jndiNameNode = attributes.getNamedItem(JNDI_NAME);
String jndiName = getScopedName(jndiNameNode.getNodeValue(), scope);
Node jndiLookupNode = attributes.getNamedItem(JNDI_LOOKUP);
String jndiLookup = jndiLookupNode.getNodeValue();
Node resTypeNode = attributes.getNamedItem(RES_TYPE);
String resType = resTypeNode.getNodeValue();
Node factoryClassNode = attributes.getNamedItem(FACTORY_CLASS);
String factoryClass = factoryClassNode.getNodeValue();
Node enabledNode = attributes.getNamedItem(ENABLED);
org.glassfish.resources.api.Resource jndiResource = new Resource(Resource.EXTERNAL_JNDI_RESOURCE);
jndiResource.setAttribute(JNDI_NAME, jndiName);
jndiResource.setAttribute(JNDI_LOOKUP, jndiLookup);
jndiResource.setAttribute(RES_TYPE, resType);
jndiResource.setAttribute(FACTORY_CLASS, factoryClass);
if (enabledNode != null) {
String sEnabled = enabledNode.getNodeValue();
jndiResource.setAttribute(ENABLED, sEnabled);
}
NodeList children = nextKid.getChildNodes();
generatePropertyElement(jndiResource, children);
vResources.add(jndiResource);
resourceMap.put(jndiResource, nextKid);
// debug strings
printResourceElements(jndiResource);
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method generateJDBCResource.
/**
* Generate the JDBC resource
*/
private void generateJDBCResource(Node nextKid, String scope) throws Exception {
NamedNodeMap attributes = nextKid.getAttributes();
if (attributes == null)
return;
Node jndiNameNode = attributes.getNamedItem(JNDI_NAME);
String jndiName = getScopedName(jndiNameNode.getNodeValue(), scope);
Node poolNameNode = attributes.getNamedItem(POOL_NAME);
String poolName = getScopedName(poolNameNode.getNodeValue(), scope);
Node enabledNode = attributes.getNamedItem(ENABLED);
Resource jdbcResource = new org.glassfish.resources.api.Resource(org.glassfish.resources.api.Resource.JDBC_RESOURCE);
jdbcResource.setAttribute(JNDI_NAME, jndiName);
jdbcResource.setAttribute(POOL_NAME, poolName);
if (enabledNode != null) {
String enabledName = enabledNode.getNodeValue();
jdbcResource.setAttribute(ENABLED, enabledName);
}
NodeList children = nextKid.getChildNodes();
// get description
if (children != null) {
for (int ii = 0; ii < children.getLength(); ii++) {
if (children.item(ii).getNodeName().equals("description")) {
if (children.item(ii).getFirstChild() != null) {
jdbcResource.setDescription(children.item(ii).getFirstChild().getNodeValue());
}
}
}
}
vResources.add(jdbcResource);
resourceMap.put(jdbcResource, nextKid);
// debug strings
printResourceElements(jdbcResource);
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method generatePersistenceResource.
private void generatePersistenceResource(Node nextKid) throws Exception {
NamedNodeMap attributes = nextKid.getAttributes();
if (attributes == null)
return;
Node jndiNameNode = attributes.getNamedItem(JNDI_NAME);
String jndiName = jndiNameNode.getNodeValue();
Node factoryClassNode = attributes.getNamedItem(FACTORY_CLASS);
Node poolNameNode = attributes.getNamedItem(JDBC_RESOURCE_JNDI_NAME);
Node enabledNode = attributes.getNamedItem(ENABLED);
Resource persistenceResource = new org.glassfish.resources.api.Resource(org.glassfish.resources.api.Resource.PERSISTENCE_MANAGER_FACTORY_RESOURCE);
persistenceResource.setAttribute(JNDI_NAME, jndiName);
if (factoryClassNode != null) {
String factoryClass = factoryClassNode.getNodeValue();
persistenceResource.setAttribute(FACTORY_CLASS, factoryClass);
}
if (poolNameNode != null) {
String poolName = poolNameNode.getNodeValue();
persistenceResource.setAttribute(JDBC_RESOURCE_JNDI_NAME, poolName);
}
if (enabledNode != null) {
String sEnabled = enabledNode.getNodeValue();
persistenceResource.setAttribute(ENABLED, sEnabled);
}
NodeList children = nextKid.getChildNodes();
generatePropertyElement(persistenceResource, children);
vResources.add(persistenceResource);
resourceMap.put(persistenceResource, nextKid);
// debug strings
printResourceElements(persistenceResource);
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesDeployer method getResources.
/**
* Retrieve connector and non-connector resources from the archive.
*
* @param archive Archieve from which the resources to be retrieved.
* @param appName Name of the application
* @param connectorResources Connector resources will be added to this list.
* @param nonConnectorResources Non connector resources will be added to this list.
* @param resourceXmlParsers Resource xml parsers corresponding to both connector and non connector resources will be stored in this.
*/
public void getResources(ReadableArchive archive, String appName, List<org.glassfish.resources.api.Resource> connectorResources, List<org.glassfish.resources.api.Resource> nonConnectorResources, Map<org.glassfish.resources.api.Resource, ResourcesXMLParser> resourceXmlParsers) {
try {
if (ResourceUtil.hasResourcesXML(archive, locator)) {
Map<String, Map<String, List>> appScopedResources = new HashMap<String, Map<String, List>>();
Map<String, String> fileNames = new HashMap<String, String>();
// using appName as it is possible that "deploy --name=APPNAME" will
// be different than the archive name.
retrieveAllResourcesXMLs(fileNames, archive, appName);
for (Map.Entry<String, String> entry : fileNames.entrySet()) {
String moduleName = entry.getKey();
String fileName = entry.getValue();
debug("GlassFish Resources XML : " + fileName);
moduleName = org.glassfish.resourcebase.resources.util.ResourceUtil.getActualModuleNameWithExtension(moduleName);
String scope;
if (appName.equals(moduleName)) {
scope = JAVA_APP_SCOPE_PREFIX;
} else {
scope = JAVA_MODULE_SCOPE_PREFIX;
}
File file = new File(fileName);
ResourcesXMLParser parser = new ResourcesXMLParser(file, scope);
validateResourcesXML(file, parser);
List<org.glassfish.resources.api.Resource> resources = parser.getResourcesList();
if (nonConnectorResources != null) {
nonConnectorResources.addAll(ResourcesXMLParser.getNonConnectorResourcesList(resources, false, true));
}
if (connectorResources != null) {
connectorResources.addAll(ResourcesXMLParser.getConnectorResourcesList(resources, false, true));
}
if (resourceXmlParsers != null) {
for (org.glassfish.resources.api.Resource res : resources) {
resourceXmlParsers.put(res, parser);
}
}
}
}
} catch (Exception e) {
// in the event notification infrastructure
throw new DeploymentException("Failue while processing glassfish-resources.xml(s) in the archive ", e);
}
}
Aggregations