use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method generateCustomResource.
/*
* Generate the Custom resource
*/
private void generateCustomResource(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 resTypeNode = attributes.getNamedItem(RES_TYPE);
String resType = resTypeNode.getNodeValue();
Node factoryClassNode = attributes.getNamedItem(FACTORY_CLASS);
String factoryClass = factoryClassNode.getNodeValue();
Node enabledNode = attributes.getNamedItem(ENABLED);
Resource customResource = new Resource(Resource.CUSTOM_RESOURCE);
customResource.setAttribute(JNDI_NAME, jndiName);
customResource.setAttribute(RES_TYPE, resType);
customResource.setAttribute(FACTORY_CLASS, factoryClass);
if (enabledNode != null) {
String sEnabled = enabledNode.getNodeValue();
customResource.setAttribute(ENABLED, sEnabled);
}
NodeList children = nextKid.getChildNodes();
generatePropertyElement(customResource, children);
vResources.add(customResource);
resourceMap.put(customResource, nextKid);
// debug strings
printResourceElements(customResource);
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method generateConnectorResource.
/**
* Generate the Connector resource
*/
private void generateConnectorResource(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 resTypeNode = attributes.getNamedItem(RESOURCE_TYPE);
Node enabledNode = attributes.getNamedItem(ENABLED);
org.glassfish.resources.api.Resource connectorResource = new Resource(org.glassfish.resources.api.Resource.CONNECTOR_RESOURCE);
connectorResource.setAttribute(JNDI_NAME, jndiName);
connectorResource.setAttribute(POOL_NAME, poolName);
if (resTypeNode != null) {
String resType = resTypeNode.getNodeValue();
connectorResource.setAttribute(RESOURCE_TYPE, resType);
}
if (enabledNode != null) {
String sEnabled = enabledNode.getNodeValue();
connectorResource.setAttribute(ENABLED, sEnabled);
}
NodeList children = nextKid.getChildNodes();
generatePropertyElement(connectorResource, children);
vResources.add(connectorResource);
resourceMap.put(connectorResource, nextKid);
// debug strings
printResourceElements(connectorResource);
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesDeployer method deployResources.
public void deployResources(String applicationName, String moduleName, Collection<com.sun.enterprise.config.serverbeans.Resource> resources, boolean postDeployPhase) throws Exception {
for (Resource resource : resources) {
if (resource instanceof BindableResource) {
BindableResource bindableResource = (BindableResource) resource;
ResourceInfo resourceInfo = new ResourceInfo(bindableResource.getJndiName(), applicationName, moduleName);
if (getResourceDeployer(bindableResource).canDeploy(postDeployPhase, resources, bindableResource)) {
resourcesBinder.deployResource(resourceInfo, bindableResource);
}
} else {
if (getResourceDeployer(resource).canDeploy(postDeployPhase, resources, resource)) {
getResourceDeployer(resource).deployResource(resource, applicationName, moduleName);
}
}
}
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourceUtilities method getResourceConflictsWithDomainXML.
/**
* Checks if any of the Resource in the given set has a conflict with
* resource definitions in the domain.xml. A <b> conflict </b> is defined
* based on the type of the resource. For example, a JDBC Resource has "jndi-name"
* that is the identifying key where as for a JDBC Connection Pool, it is
* the "name" that must be unique.
*
* @param resList a Set of Resource elements.
* @param resources all resources from domain.xml
*
* @throws org.glassfish.resources.api.ResourceConflictException an exception is thrown when an archive is found to
* have two or more resources that conflict with resources already present in domain.xml.
*/
public static void getResourceConflictsWithDomainXML(final List<Resource> resList, final Resources resources) throws ResourceConflictException {
if (resList != null) {
Iterator<org.glassfish.resources.api.Resource> iterRes = resList.iterator();
StringBuffer conflictingResources = new StringBuffer();
while (iterRes.hasNext()) {
org.glassfish.resources.api.Resource res = iterRes.next();
final String id = getIdToCompare(res);
if (resources.getResourceByName(res.getClass(), id) != null) {
conflictingResources.append("\n");
String message = localStrings.getString("conflict.resource.with.domain.xml", getIdToCompare(res));
conflictingResources.append(message);
_logger.warning(message);
if (_logger.isLoggable(Level.FINE))
logAttributes(res);
}
}
if (conflictingResources.toString().length() > 0) {
throw new ResourceConflictException(conflictingResources.toString());
}
}
}
use of org.glassfish.resources.api.Resource in project Payara by payara.
the class ResourcesXMLParser method getResourcesOfType.
/**
* Sorts the resources defined in the resources configuration xml file into
* two buckets
* a) list of resources that needs to be created prior to
* module deployment. This includes all non-Connector resources
* and resource-adapter-config
* b) includes all connector resources in the order in which the resources needs
* to be created
* and returns the requested resources bucker to the caller.
*
* @param resources Resources list as defined in sun-resources.xml
* @param type Specified either ResourcesXMLParser.CONNECTOR or
* ResourcesXMLParser.NONCONNECTOR to indicate the type of
* resources are needed by the client of the ResourcesXMLParser
* @param isResourceCreation During the resource Creation Phase, RA configs are
* added to the nonConnector resources list so that they can be created in the
* <code>PreResCreationPhase</code>. When the isResourceCreation is false, the
* RA config resuorces are added to the Connector Resources list, so that they
* can be deleted as all other connector resources in the
* <code>PreResDeletionPhase</code>
*/
private static List<org.glassfish.resources.api.Resource> getResourcesOfType(List<Resource> resources, int type, boolean isResourceCreation, boolean ignoreDuplicates) {
List<Resource> nonConnectorResources = new ArrayList<org.glassfish.resources.api.Resource>();
List<org.glassfish.resources.api.Resource> connectorResources = new ArrayList<org.glassfish.resources.api.Resource>();
for (Resource res : resources) {
if (isConnectorResource(res)) {
if (res.getType().equals(Resource.RESOURCE_ADAPTER_CONFIG)) {
if (isResourceCreation) {
// RA config is considered as a nonConnector Resource,
// during sun-resources.xml resource-creation phase, so that
// it could be created before the RAR is deployed.
addToList(nonConnectorResources, res, ignoreDuplicates);
} else {
addToList(connectorResources, res, ignoreDuplicates);
}
} else {
addToList(connectorResources, res, ignoreDuplicates);
}
} else {
addToList(nonConnectorResources, res, ignoreDuplicates);
}
}
List<org.glassfish.resources.api.Resource> finalSortedConnectorList = sortConnectorResources(connectorResources);
List<org.glassfish.resources.api.Resource> finalSortedNonConnectorList = sortNonConnectorResources(nonConnectorResources);
if (type == CONNECTOR) {
return finalSortedConnectorList;
} else {
return finalSortedNonConnectorList;
}
}
Aggregations