use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class WebBundleDescriptorImpl method combineEjbReferenceDescriptors.
@Override
protected void combineEjbReferenceDescriptors(JndiNameEnvironment env) {
for (Object oejbRef : env.getEjbReferenceDescriptors()) {
EjbReference ejbRef = (EjbReference) oejbRef;
EjbReferenceDescriptor ejbRefDesc = (EjbReferenceDescriptor) _getEjbReference(ejbRef.getName());
if (ejbRefDesc != null) {
combineInjectionTargets(ejbRefDesc, (EnvironmentProperty) ejbRef);
} else {
if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictEjbReference()) {
throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionconflictejbref", "There are more than one ejb references defined in web fragments with the same name, but not overrided in web.xml"));
} else {
addEjbReferenceDescriptor(ejbRef);
}
}
}
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class WebBundleDescriptorImpl method combineServiceReferenceDescriptors.
@Override
protected void combineServiceReferenceDescriptors(JndiNameEnvironment env) {
for (Object oserviceRef : env.getServiceReferenceDescriptors()) {
ServiceReferenceDescriptor serviceRef = (ServiceReferenceDescriptor) oserviceRef;
ServiceReferenceDescriptor sr = _getServiceReferenceByName(serviceRef.getName());
if (sr != null) {
combineInjectionTargets(sr, serviceRef);
} else {
if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictServiceReference()) {
throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionconflictserviceref", "There are more than one service references defined in web fragments with the same name, but not overrided in web.xml"));
} else {
addServiceReferenceDescriptor(serviceRef);
}
}
}
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class WebBundleDescriptorImpl method combineMessageDestinationReferenceDescriptors.
@Override
protected void combineMessageDestinationReferenceDescriptors(JndiNameEnvironment env) {
for (Object omdRef : env.getMessageDestinationReferenceDescriptors()) {
MessageDestinationReferenceDescriptor mdRef = (MessageDestinationReferenceDescriptor) omdRef;
MessageDestinationReferenceDescriptor mdr = _getMessageDestinationReferenceByName(mdRef.getName());
if (mdr != null) {
combineInjectionTargets(mdr, mdRef);
} else {
if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictMessageDestinationReference()) {
throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionconflictmessagedestinationref", "There are more than one message destination references defined in web fragments with the same name, but not overrided in web.xml"));
} else {
addMessageDestinationReferenceDescriptor(mdRef);
}
}
}
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class ServletMappingNode method setElementValue.
/**
* receives notiification of the value for a particular tag
*
* @param element the xml element
* @param value it's associated value
*/
public void setElementValue(XMLElement element, String value) {
if (WebTagNames.SERVLET_NAME.equals(element.getQName())) {
servletName = value;
}
if (WebTagNames.URL_PATTERN.equals(element.getQName())) {
if (!URLPattern.isValid(value)) {
// try trimming url (in case DD uses extra
// whitespace for aligning)
String trimmedUrl = value.trim();
if ("\"\"".equals(trimmedUrl)) {
trimmedUrl = "";
}
// If URL Pattern does not start with "/" then
// prepend it (for Servlet2.2 Web apps)
Object parent = getParentNode().getDescriptor();
if (parent instanceof WebBundleDescriptor && ((WebBundleDescriptor) parent).getSpecVersion().equals("2.2")) {
if (!trimmedUrl.startsWith("/") && !trimmedUrl.startsWith("*.")) {
trimmedUrl = "/" + trimmedUrl;
}
}
if (URLPattern.isValid(trimmedUrl)) {
// warn user if url included \r or \n
if (URLPattern.containsCRorLF(value)) {
DOLUtils.getDefaultLogger().log(Level.WARNING, "enterprise.deployment.backend.urlcontainscrlf", new Object[] { value });
}
value = trimmedUrl;
} else {
throw new IllegalArgumentException(MessageFormat.format(rb.getString(LogFacade.ENTERPRISE_DEPLOYMENT_INVALID_URL_PATTERN), value));
}
}
urlPattern = value;
XMLNode parentNode = getParentNode();
if (parentNode instanceof WebCommonNode) {
((WebCommonNode) parentNode).addServletMapping(servletName, urlPattern);
} else {
DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure", new Object[] { getXMLRootTag(), "servlet-mapping" });
}
}
}
use of com.sun.enterprise.deployment.WebBundleDescriptor 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);
}
}
Aggregations