use of org.apache.openejb.jee.WebApp$JAXB in project tomee by apache.
the class MaxChildTest method app.
@Module
public AppModule app() {
final String jarLocation = "target/" + getClass().getSimpleName();
return new AppModule(Thread.currentThread().getContextClassLoader(), jarLocation, new Application(), true) {
{
getEjbModules().add(new EjbModule(new EjbJar("app"), new OpenejbJar() {
{
getPojoDeployment().add(new PojoDeployment() {
{
setClassName(SimpleContractImpl.class.getName());
getProperties().setProperty("cxf.jaxws.properties", "cxfLargeMsgSize");
}
});
}
}));
getWebModules().add(new WebModule(new WebApp().contextRoot("app").addServlet("ws", SimpleContractImpl.class.getName(), "/ws"), "app", Thread.currentThread().getContextClassLoader(), jarLocation, "app"));
getServices().add(new Service() {
{
setId("cxfLargeMsgSize");
setClassName(Properties.class.getName());
getProperties().setProperty("org.apache.cxf.stax.maxChildElements", "1");
}
});
}
};
}
use of org.apache.openejb.jee.WebApp$JAXB in project tomee by apache.
the class SunConversion method convertModule.
public void convertModule(final WebModule webModule) {
if (webModule == null) {
return;
}
final WebApp webApp = webModule.getWebApp();
if (webApp == null) {
return;
}
final SunWebApp sunWebApp = getSunWebApp(webModule);
if (sunWebApp == null) {
return;
}
if (sunWebApp.getContextRoot() != null) {
webModule.setContextRoot(sunWebApp.getContextRoot());
}
// map ejb-refs
final Map<String, JndiReference> refMap = new TreeMap<String, JndiReference>();
refMap.putAll(webApp.getEjbRefMap());
refMap.putAll(webApp.getEjbLocalRefMap());
// map ejb-ref jndi name declaration to deploymentId
for (final EjbRef ref : sunWebApp.getEjbRef()) {
if (ref.getJndiName() != null) {
final String refName = ref.getEjbRefName();
JndiReference ejbRef = refMap.get(refName);
if (ejbRef == null) {
ejbRef = new org.apache.openejb.jee.EjbRef();
ejbRef.setName(refName);
refMap.put(refName, ejbRef);
webApp.getEjbRef().add((org.apache.openejb.jee.EjbRef) ejbRef);
}
ejbRef.setMappedName(ref.getJndiName());
}
}
// map resource-env-refs and message-destination-refs
final Map<String, JndiReference> resEnvMap = new TreeMap<String, JndiReference>();
resEnvMap.putAll(webApp.getResourceRefMap());
resEnvMap.putAll(webApp.getResourceEnvRefMap());
resEnvMap.putAll(webApp.getMessageDestinationRefMap());
for (final ResourceRef ref : sunWebApp.getResourceRef()) {
if (ref.getJndiName() != null) {
String refName = ref.getResRefName();
refName = normalize(refName);
final JndiReference resEnvRef = resEnvMap.get(refName);
if (resEnvRef != null) {
resEnvRef.setMappedName(ref.getJndiName());
}
}
}
for (final ResourceEnvRef ref : sunWebApp.getResourceEnvRef()) {
if (ref.getJndiName() != null) {
String refName = ref.getResourceEnvRefName();
refName = normalize(refName);
final JndiReference resEnvRef = resEnvMap.get(refName);
if (resEnvRef != null) {
resEnvRef.setMappedName(ref.getJndiName());
}
}
}
for (final MessageDestinationRef ref : sunWebApp.getMessageDestinationRef()) {
if (ref.getJndiName() != null) {
String refName = ref.getMessageDestinationRefName();
refName = normalize(refName);
final JndiReference resEnvRef = resEnvMap.get(refName);
if (resEnvRef != null) {
resEnvRef.setMappedName(ref.getJndiName());
}
}
}
final Map<String, ServiceRef> serviceRefMap = webApp.getServiceRefMap();
for (final org.apache.openejb.jee.sun.ServiceRef ref : sunWebApp.getServiceRef()) {
String refName = ref.getServiceRefName();
refName = normalize(refName);
final ServiceRef serviceRef = serviceRefMap.get(refName);
if (serviceRef != null) {
final Map<String, PortComponentRef> ports = new TreeMap<String, PortComponentRef>();
for (final PortComponentRef portComponentRef : serviceRef.getPortComponentRef()) {
ports.put(portComponentRef.getServiceEndpointInterface(), portComponentRef);
}
for (final PortInfo portInfo : ref.getPortInfo()) {
final PortComponentRef portComponentRef = ports.get(portInfo.getServiceEndpointInterface());
if (portComponentRef != null) {
final WsdlPort wsdlPort = portInfo.getWsdlPort();
if (wsdlPort != null) {
final QName qname = new QName(wsdlPort.getNamespaceURI(), wsdlPort.getLocalpart());
portComponentRef.setQName(qname);
}
for (final StubProperty stubProperty : portInfo.getStubProperty()) {
final String name = stubProperty.getName();
final String value = stubProperty.getValue();
portComponentRef.getProperties().setProperty(name, value);
}
}
}
final String wsdlOverride = ref.getWsdlOverride();
if (wsdlOverride != null && wsdlOverride.length() > 0) {
final String serviceId = extractServiceId(wsdlOverride);
serviceRef.setMappedName(serviceId);
}
}
}
// map wsdl locations
if (webModule.getWebservices() != null) {
final Map<String, WebserviceDescription> descriptions = webModule.getWebservices().getWebserviceDescriptionMap();
for (final org.apache.openejb.jee.sun.WebserviceDescription sunDescription : sunWebApp.getWebserviceDescription()) {
final WebserviceDescription description = descriptions.get(sunDescription.getWebserviceDescriptionName());
if (description == null) {
continue;
}
final String serviceId = extractSerivceId(sunDescription.getWsdlPublishLocation(), description.getWsdlFile());
if (serviceId != null) {
description.setId(serviceId);
}
}
}
}
use of org.apache.openejb.jee.WebApp$JAXB in project tomee by apache.
the class WsDeployer method processPorts.
private void processPorts(final WebModule webModule) throws OpenEJBException {
// map existing webservice port declarations by servlet link
Webservices webservices = webModule.getWebservices();
final Map<String, PortComponent> portMap = new TreeMap<String, PortComponent>();
if (webservices != null) {
for (final WebserviceDescription webserviceDescription : webservices.getWebserviceDescription()) {
for (final PortComponent portComponent : webserviceDescription.getPortComponent()) {
final ServiceImplBean serviceImplBean = portComponent.getServiceImplBean();
if (serviceImplBean != null && serviceImplBean.getServletLink() != null) {
portMap.put(serviceImplBean.getServletLink(), portComponent);
}
}
}
}
// map existing servlet-mapping declarations
final WebApp webApp = webModule.getWebApp();
final Map<String, ServletMapping> servletMappings = new TreeMap<String, ServletMapping>();
for (final ServletMapping servletMapping : webApp.getServletMapping()) {
servletMappings.put(servletMapping.getServletName(), servletMapping);
}
// add port declarations for Pojo webservices
WebserviceDescription webserviceDescription;
for (final Servlet servlet : webApp.getServlet()) {
// the implementation class will be replaced by the WsServlet in the WsRegistry
final String className = servlet.getServletClass();
// Skip JSPs
if (className == null) {
continue;
}
try {
final Class<?> clazz = webModule.getClassLoader().loadClass(className);
if (JaxWsUtils.isWebService(clazz)) {
// add servlet mapping if not already declared
ServletMapping servletMapping = servletMappings.get(servlet.getServletName());
final String serviceName = JaxWsUtils.getServiceName(clazz);
if (servletMapping == null) {
servletMapping = new ServletMapping();
servletMapping.setServletName(servlet.getServletName());
final String location = "/" + serviceName;
servletMapping.getUrlPattern().add(location);
webApp.getServletMapping().add(servletMapping);
}
// if we don't have a webservices document yet, we're gonna need one now
if (webservices == null) {
webservices = new Webservices();
webModule.setWebservices(webservices);
}
// add web service description element (maps to service)
webserviceDescription = webservices.getWebserviceDescriptionMap().get(serviceName);
if (webserviceDescription == null) {
webserviceDescription = new WebserviceDescription();
webserviceDescription.setWebserviceDescriptionName(serviceName);
webservices.getWebserviceDescription().add(webserviceDescription);
}
// define port if not already declared
PortComponent portComponent = portMap.get(servlet.getServletName());
if (portComponent == null) {
portComponent = new PortComponent();
portComponent.setPortComponentName(clazz.getSimpleName());
final ServiceImplBean serviceImplBean = new ServiceImplBean();
serviceImplBean.setServletLink(servlet.getServletName());
portComponent.setServiceImplBean(serviceImplBean);
webserviceDescription.getPortComponent().add(portComponent);
}
// default portId == host.moduleId.servletName
if (portComponent.getId() == null) {
portComponent.setId(webModule.getHost() + "." + webModule.getModuleId() + "." + servlet.getServletName());
}
if (webserviceDescription.getId() == null) {
webserviceDescription.setId(webModule.getHost() + "." + webModule.getModuleId() + "." + servlet.getServletName());
}
// set port values from annotations if not already set
if (portComponent.getServiceEndpointInterface() == null) {
portComponent.setServiceEndpointInterface(JaxWsUtils.getServiceInterface(clazz));
}
if (portComponent.getWsdlPort() == null) {
portComponent.setWsdlPort(JaxWsUtils.getPortQName(clazz));
}
if (webserviceDescription.getWsdlFile() == null) {
webserviceDescription.setWsdlFile(JaxWsUtils.getServiceWsdlLocation(clazz, webModule.getClassLoader()));
}
if (portComponent.getWsdlService() == null) {
final Definition definition = getWsdl(webModule, webserviceDescription.getWsdlFile());
if (definition != null && definition.getServices().size() == 1) {
final QName serviceQName = (QName) definition.getServices().keySet().iterator().next();
portComponent.setWsdlService(serviceQName);
} else {
portComponent.setWsdlService(JaxWsUtils.getServiceQName(clazz));
}
}
if (portComponent.getProtocolBinding() == null) {
portComponent.setProtocolBinding(JaxWsUtils.getBindingUriFromAnn(clazz));
}
configMtomAnnotation(clazz, portComponent);
if (SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(portComponent.getProtocolBinding()) || SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(portComponent.getProtocolBinding())) {
portComponent.setEnableMtom(true);
}
// handlers
if (portComponent.getHandlerChains() == null) {
final HandlerChains handlerChains = getHandlerChains(clazz, portComponent.getServiceEndpointInterface(), webModule.getClassLoader());
portComponent.setHandlerChains(handlerChains);
}
}
} catch (final Exception e) {
throw new OpenEJBException("Unable to load servlet class: " + className, e);
}
}
}
use of org.apache.openejb.jee.WebApp$JAXB in project tomee by apache.
the class DeploymentLoader method addTagLibraries.
private void addTagLibraries(final WebModule webModule) throws OpenEJBException {
final Set<URL> tldLocations = new HashSet<URL>();
// web.xml contains tag lib locations in nested jsp config elements
final File warFile = new File(webModule.getJarLocation());
final WebApp webApp = webModule.getWebApp();
if (webApp != null) {
for (final JspConfig jspConfig : webApp.getJspConfig()) {
for (final Taglib taglib : jspConfig.getTaglib()) {
String location = taglib.getTaglibLocation();
if (!location.startsWith("/")) {
// this reproduces a tomcat bug
location = "/WEB-INF/" + location;
}
try {
final File file = new File(warFile, location).getCanonicalFile().getAbsoluteFile();
tldLocations.addAll(TldScanner.scanForTagLibs(file));
} catch (final IOException e) {
logger.warning("JSP tag library location bad: " + location, e);
}
}
}
}
// WEB-INF/**/*.tld except in WEB-INF/classes and WEB-INF/lib
Set<URL> urls = TldScanner.scanWarForTagLibs(warFile);
tldLocations.addAll(urls);
// Search all libs
final ClassLoader parentClassLoader = webModule.getClassLoader().getParent();
urls = TldScanner.scan(parentClassLoader);
tldLocations.addAll(urls);
// load the tld files
for (final URL location : tldLocations) {
final TldTaglib taglib = ReadDescriptors.readTldTaglib(location);
if (taglib != null && taglib != ReadDescriptors.SKIP_TAGLIB) {
webModule.getTaglibs().add(taglib);
if ("file".equals(location.getProtocol())) {
webModule.getWatchedResources().add(URLs.toFilePath(location));
}
}
}
// no more need + this classloader is a temp one in Servlet container so avoid mem leaks
TldScanner.quickClean(parentClassLoader);
}
use of org.apache.openejb.jee.WebApp$JAXB in project tomee by apache.
the class DeploymentLoader method fillEjbJar.
/**
* If the web.xml is metadata-complete and there is no ejb-jar.xml
* then per specification we use the web.xml metadata-complete setting
* to imply the same for EJBs.
*
* @param webModule WebModule
* @param ejbModule EjbModule
*/
private static void fillEjbJar(final WebModule webModule, final EjbModule ejbModule) {
final Object o = webModule.getAltDDs().get("ejb-jar.xml");
if (o != null) {
return;
}
if (ejbModule.getEjbJar() != null) {
return;
}
final EjbJar ejbJar = new EjbJar();
final WebApp webApp = webModule.getWebApp();
ejbJar.setMetadataComplete(webApp.isMetadataComplete());
ejbModule.setEjbJar(ejbJar);
}
Aggregations