use of org.apache.openejb.jee.sun.SunWebApp 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<>();
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<>();
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<>();
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);
}
}
}
}
Aggregations