use of com.sun.enterprise.deployment.ResourceReferenceDescriptor in project Payara by payara.
the class ResourceDescriptionNode method writeDescriptors.
/**
* write all occurrences of the descriptor corresponding to the current
* node from the parent descriptor to an JAXP DOM node and return it
*
* This API will be invoked by the parent node when the parent node
* writes out a mix of statically and dynamically registered sub nodes.
*
* This method should be overriden by the sub classes if it
* needs to be called by the parent node.
*
* @param parent node in the DOM tree
* @param nodeName the name of the node
* @param parentDesc parent descriptor of the descriptor to be written
* @return the JAXP DOM node
*/
@Override
public Node writeDescriptors(Node parent, String nodeName, Descriptor parentDesc) {
if (parentDesc instanceof ResourceReferenceContainer) {
ResourceReferenceContainer resourceReferenceContainer = (ResourceReferenceContainer) parentDesc;
// resource-reference-description*
Set<ResourceReferenceDescriptor> resourceReferenceDescriptors = resourceReferenceContainer.getResourceReferenceDescriptors();
for (ResourceReferenceDescriptor resourceReferenceDescriptor : resourceReferenceDescriptors) {
writeDescriptor(parent, nodeName, resourceReferenceDescriptor);
}
}
return parent;
}
use of com.sun.enterprise.deployment.ResourceReferenceDescriptor in project Payara by payara.
the class EnvEntriesValidator method validateEnvEntry.
private void validateEnvEntry(JndiNameEnvironment env, Object curEntry, String name) {
String logicalJndiName = getLogicalJNDIName(name, env);
Map namespace = getNamespace(logicalJndiName, env);
Object preObject = namespace.get(logicalJndiName);
if (preObject != null) {
if (preObject instanceof SimpleEnvEntry && curEntry instanceof SimpleEnvEntry) {
SimpleEnvEntry preEnvEntry = (SimpleEnvEntry) preObject;
SimpleEnvEntry curEnvEntry = (SimpleEnvEntry) curEntry;
if (areConflicting(preEnvEntry.getType(), curEnvEntry.getType()) || areConflicting(preEnvEntry.getValue(), curEnvEntry.getValue())) {
throwConflictException(name, namespace.toString());
}
} else if (preObject instanceof EjbReference && curEntry instanceof EjbReference) {
EjbReference preRef = (EjbReference) preObject;
EjbReference curRef = (EjbReference) curEntry;
if (areConflicting(preRef.getType(), curRef.getType()) || areConflicting(preRef.getEjbHomeInterface(), curRef.getEjbHomeInterface()) || areConflicting(preRef.getEjbInterface(), curRef.getEjbInterface()) || // link name is optional. compare only when they are both not null.
((preRef.getLinkName() != null && curRef.getLinkName() != null && !preRef.getLinkName().equals(curRef.getLinkName()))) || (preRef.isLocal() != curRef.isLocal()) || areConflicting(preRef.getLookupName(), curRef.getLookupName())) {
throwConflictException(name, namespace.toString());
}
} else if (preObject instanceof ResourceReferenceDescriptor && curEntry instanceof ResourceReferenceDescriptor) {
ResourceReferenceDescriptor preRef = (ResourceReferenceDescriptor) preObject;
ResourceReferenceDescriptor curRef = (ResourceReferenceDescriptor) curEntry;
if (areConflicting(preRef.getType(), curRef.getType()) || areConflicting(preRef.getAuthorization(), curRef.getAuthorization()) || areConflicting(preRef.getSharingScope(), curRef.getSharingScope()) || areConflicting(preRef.getMappedName(), curRef.getMappedName()) || areConflicting(preRef.getLookupName(), curRef.getLookupName())) {
throwConflictException(name, namespace.toString());
}
} else if (preObject instanceof ResourceEnvReferenceDescriptor && curEntry instanceof ResourceEnvReferenceDescriptor) {
ResourceEnvReferenceDescriptor preRef = (ResourceEnvReferenceDescriptor) preObject;
ResourceEnvReferenceDescriptor curRef = (ResourceEnvReferenceDescriptor) curEntry;
if (areConflicting(preRef.getType(), curRef.getType()) || areConflicting(preRef.getRefType(), curRef.getRefType()) || areConflicting(preRef.getMappedName(), curRef.getMappedName()) || areConflicting(preRef.getLookupName(), curRef.getLookupName())) {
throwConflictException(name, namespace.toString());
}
} else {
throwConflictException(name, namespace.toString());
}
} else {
namespace.put(logicalJndiName, curEntry);
}
}
use of com.sun.enterprise.deployment.ResourceReferenceDescriptor in project Payara by payara.
the class WebBundleRuntimeNode method writeDescriptor.
/**
* write the descriptor class to a DOM tree and return it
*
* @param parent node for the DOM tree
* @param bundleDescriptor the descriptor to write
* @return the DOM tree top node
*/
@Override
public Node writeDescriptor(Node parent, WebBundleDescriptorImpl bundleDescriptor) {
Element web = (Element) super.writeDescriptor(parent, bundleDescriptor);
SunWebAppImpl sunWebApp = (SunWebAppImpl) bundleDescriptor.getSunDescriptor();
// context-root?
appendTextChild(web, RuntimeTagNames.CONTEXT_ROOT, bundleDescriptor.getContextRoot());
// security-role-mapping
SecurityRoleMapping[] roleMappings = sunWebApp.getSecurityRoleMapping();
if (roleMappings != null && roleMappings.length > 0) {
SecurityRoleMappingNode srmn = new SecurityRoleMappingNode();
for (SecurityRoleMapping roleMapping : roleMappings) {
srmn.writeDescriptor(web, RuntimeTagNames.SECURITY_ROLE_MAPPING, roleMapping);
}
}
// servlet
Set servlets = bundleDescriptor.getServletDescriptors();
org.glassfish.web.deployment.node.runtime.gf.ServletNode servletNode = new org.glassfish.web.deployment.node.runtime.gf.ServletNode();
for (Iterator itr = servlets.iterator(); itr.hasNext(); ) {
WebComponentDescriptor servlet = (WebComponentDescriptor) itr.next();
servletNode.writeDescriptor(web, RuntimeTagNames.SERVLET, servlet);
}
// idempotent-url-pattern
IdempotentUrlPattern[] patterns = sunWebApp.getIdempotentUrlPatterns();
if (patterns != null && patterns.length > 0) {
IdempotentUrlPatternNode node = new IdempotentUrlPatternNode();
for (IdempotentUrlPattern pattern : patterns) {
node.writeDescriptor(web, RuntimeTagNames.IDEMPOTENT_URL_PATTERN, pattern);
}
}
// session-config?
if (sunWebApp.getSessionConfig() != null) {
SessionConfigNode scn = new SessionConfigNode();
scn.writeDescriptor(web, RuntimeTagNames.SESSION_CONFIG, sunWebApp.getSessionConfig());
}
// ejb-ref*
Set<EjbReference> ejbRefs = bundleDescriptor.getEjbReferenceDescriptors();
if (ejbRefs.size() > 0) {
EjbRefNode node = new EjbRefNode();
for (EjbReference ejbRef : ejbRefs) {
node.writeDescriptor(web, RuntimeTagNames.EJB_REF, ejbRef);
}
}
// resource-ref*
Set<ResourceReferenceDescriptor> resourceRefs = bundleDescriptor.getResourceReferenceDescriptors();
if (resourceRefs.size() > 0) {
ResourceRefNode node = new ResourceRefNode();
for (ResourceReferenceDescriptor resourceRef : resourceRefs) {
node.writeDescriptor(web, RuntimeTagNames.RESOURCE_REF, resourceRef);
}
}
// resource-env-ref*
Set<ResourceEnvReferenceDescriptor> resourceEnvRefs = bundleDescriptor.getResourceEnvReferenceDescriptors();
if (resourceEnvRefs.size() > 0) {
ResourceEnvRefNode node = new ResourceEnvRefNode();
for (ResourceEnvReferenceDescriptor resourceEnvRef : resourceEnvRefs) {
node.writeDescriptor(web, RuntimeTagNames.RESOURCE_ENV_REF, resourceEnvRef);
}
}
// service-ref*
if (bundleDescriptor.hasServiceReferenceDescriptors()) {
ServiceRefNode serviceNode = new ServiceRefNode();
for (ServiceReferenceDescriptor next : bundleDescriptor.getServiceReferenceDescriptors()) {
serviceNode.writeDescriptor(web, WebServicesTagNames.SERVICE_REF, next);
}
}
// message-destination-ref*
MessageDestinationRefNode.writeMessageDestinationReferences(web, bundleDescriptor);
// cache?
Cache cache = sunWebApp.getCache();
if (cache != null) {
CacheNode cn = new CacheNode();
cn.writeDescriptor(web, RuntimeTagNames.CACHE, cache);
}
// class-loader?
ClassLoader classLoader = sunWebApp.getClassLoader();
if (classLoader != null) {
ClassLoaderNode cln = new ClassLoaderNode();
cln.writeDescriptor(web, RuntimeTagNames.CLASS_LOADER, classLoader);
}
// jsp-config?
if (sunWebApp.getJspConfig() != null) {
WebPropertyNode propertyNode = new WebPropertyNode();
Node jspConfig = appendChild(web, RuntimeTagNames.JSP_CONFIG);
propertyNode.writeDescriptor(jspConfig, RuntimeTagNames.PROPERTY, sunWebApp.getJspConfig().getWebProperty());
}
// locale-charset-info?
if (sunWebApp.getLocaleCharsetInfo() != null) {
LocaleCharsetInfoNode localeNode = new LocaleCharsetInfoNode();
localeNode.writeDescriptor(web, RuntimeTagNames.LOCALE_CHARSET_INFO, sunWebApp.getLocaleCharsetInfo());
}
// parameter-encoding?
if (sunWebApp.isParameterEncoding()) {
Element parameter = appendChild(web, RuntimeTagNames.PARAMETER_ENCODING);
if (sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.FORM_HINT_FIELD) != null) {
setAttribute(parameter, RuntimeTagNames.FORM_HINT_FIELD, sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.FORM_HINT_FIELD));
}
if (sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.DEFAULT_CHARSET) != null) {
setAttribute(parameter, RuntimeTagNames.DEFAULT_CHARSET, sunWebApp.getAttributeValue(SunWebApp.PARAMETER_ENCODING, SunWebApp.DEFAULT_CHARSET));
}
}
// property*
WebPropertyNode props = new WebPropertyNode();
props.writeDescriptor(web, RuntimeTagNames.PROPERTY, sunWebApp.getWebProperty());
// valve*
if (sunWebApp.getValve() != null) {
ValveNode valve = new ValveNode();
valve.writeDescriptor(web, RuntimeTagNames.VALVE, sunWebApp.getValve());
}
// message-destination*
RuntimeDescriptorNode.writeMessageDestinationInfo(web, bundleDescriptor);
// webservice-description*
WebServiceRuntimeNode webServiceNode = new WebServiceRuntimeNode();
webServiceNode.writeWebServiceRuntimeInfo(web, bundleDescriptor);
// error-url
if (sunWebApp.getAttributeValue(SunWebApp.ERROR_URL) != null) {
setAttribute(web, RuntimeTagNames.ERROR_URL, sunWebApp.getAttributeValue(SunWebApp.ERROR_URL));
}
// httpservlet-security-provider
if (sunWebApp.getAttributeValue(SunWebApp.HTTPSERVLET_SECURITY_PROVIDER) != null) {
setAttribute(web, RuntimeTagNames.HTTPSERVLET_SECURITY_PROVIDER, sunWebApp.getAttributeValue(SunWebApp.HTTPSERVLET_SECURITY_PROVIDER));
}
// keep-state
appendTextChild(web, RuntimeTagNames.KEEP_STATE, String.valueOf(bundleDescriptor.getKeepState()));
return web;
}
use of com.sun.enterprise.deployment.ResourceReferenceDescriptor in project Payara by payara.
the class ResourceInjectorImpl method inject.
public void inject(WSWebServiceContext context, Object instance) throws WebServiceException {
try {
// Set proper component context
invMgr.preInvoke(inv);
// Injection first
InjectionManager injManager = WebServiceContractImpl.getInstance().getInjectionManager();
injManager.injectInstance(instance);
// Set webservice context here
// If the endpoint has a WebServiceContext with @Resource then
// that has to be used
WebServiceContextImpl wsc = null;
WebBundleDescriptor bundle = (WebBundleDescriptor) endpoint.getBundleDescriptor();
Iterator<ResourceReferenceDescriptor> it = bundle.getResourceReferenceDescriptors().iterator();
while (it.hasNext()) {
ResourceReferenceDescriptor r = it.next();
if (r.isWebServiceContext()) {
Iterator<InjectionTarget> iter = r.getInjectionTargets().iterator();
boolean matchingClassFound = false;
while (iter.hasNext()) {
InjectionTarget target = iter.next();
if (endpoint.getServletImplClass().equals(target.getClassName())) {
matchingClassFound = true;
break;
}
}
if (!matchingClassFound) {
continue;
}
try {
javax.naming.InitialContext ic = new javax.naming.InitialContext();
wsc = (WebServiceContextImpl) ic.lookup("java:comp/env/" + r.getName());
} catch (Throwable t) {
// Do something here
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, LogUtils.EXCEPTION_THROWN, t);
}
}
if (wsc != null) {
wsc.setContextDelegate(context);
// needed to support isUserInRole() on WSC;
wsc.setServletName(bundle.getWebComponentDescriptors());
}
}
}
} catch (InjectionException ie) {
throw new WebServiceException(ie);
} finally {
invMgr.postInvoke(inv);
}
}
use of com.sun.enterprise.deployment.ResourceReferenceDescriptor in project Payara by payara.
the class AppSpecificConnectorClassLoaderUtil method processDescriptorForRAReferences.
private void processDescriptorForRAReferences(com.sun.enterprise.deployment.Application app, String moduleName, JndiNameEnvironment jndiEnv) {
// resource-ref
for (Object resourceRef : jndiEnv.getResourceReferenceDescriptors()) {
ResourceReferenceDescriptor resRefDesc = (ResourceReferenceDescriptor) resourceRef;
String jndiName = resRefDesc.getJndiName();
// ignore refs where jndi-name is not available
if (jndiName != null) {
detectResourceInRA(app, moduleName, jndiName);
}
}
// resource-env-ref
for (Object resourceEnvRef : jndiEnv.getResourceEnvReferenceDescriptors()) {
ResourceEnvReferenceDescriptor resourceEnvRefDesc = (ResourceEnvReferenceDescriptor) resourceEnvRef;
String jndiName = resourceEnvRefDesc.getJndiName();
// ignore refs where jndi-name is not available
if (jndiName != null) {
detectResourceInRA(app, moduleName, jndiName);
}
}
}
Aggregations