if (sunEjbJar == null) return;
if (sunEjbJar.getEnterpriseBeans() == null) return;
Map<String,Map<String, WebserviceEndpoint>> endpointMap = new HashMap<String,Map<String, WebserviceEndpoint>>();
for (Ejb ejb : sunEjbJar.getEnterpriseBeans().getEjb()) {
EjbDeployment deployment = openejbJar.getDeploymentsByEjbName().get(ejb.getEjbName());
if (deployment == null) {
// warn no matching deployment
continue;
}
// ejb jndi name is the deploymentId
if (ejb.getJndiName() != null) {
deployment.setDeploymentId(ejb.getJndiName());
}
// map ejb-ref jndi name declaration to deploymentId
Map<String, EjbLink> linksMap = deployment.getEjbLinksMap();
for (EjbRef ref : ejb.getEjbRef()) {
if (ref.getJndiName() != null) {
String refName = ref.getEjbRefName();
refName = normalize(refName);
EjbLink link = linksMap.get(refName);
if (link == null) {
link = new EjbLink();
link.setEjbRefName(refName);
linksMap.put(refName, link);
deployment.getEjbLink().add(link);
}
link.setDeployentId(ref.getJndiName());
}
}
Map<String, ResourceLink> resourceLinksMap = deployment.getResourceLinksMap();
for (ResourceRef ref : ejb.getResourceRef()) {
if (ref.getJndiName() != null) {
String refName = ref.getResRefName();
refName = normalize(refName);
ResourceLink link = resourceLinksMap.get(refName);
if (link == null) {
link = new ResourceLink();
link.setResRefName(refName);
resourceLinksMap.put(refName, link);
deployment.getResourceLink().add(link);
}
link.setResId(ref.getJndiName());
}
}
for (ResourceEnvRef ref : ejb.getResourceEnvRef()) {
if (ref.getJndiName() != null) {
String refName = ref.getResourceEnvRefName();
refName = normalize(refName);
ResourceLink link = resourceLinksMap.get(refName);
if (link == null) {
link = new ResourceLink();
link.setResRefName(refName);
resourceLinksMap.put(refName, link);
deployment.getResourceLink().add(link);
}
link.setResId(ref.getJndiName());
}
}
for (MessageDestinationRef ref : ejb.getMessageDestinationRef()) {
if (ref.getJndiName() != null) {
String refName = ref.getMessageDestinationRefName();
refName = normalize(refName);
ResourceLink link = resourceLinksMap.get(refName);
if (link == null) {
link = new ResourceLink();
link.setResRefName(refName);
resourceLinksMap.put(refName, link);
deployment.getResourceLink().add(link);
}
link.setResId(ref.getJndiName());
}
}
EnterpriseBean bean = ejbJar.getEnterpriseBeansByEjbName().get(ejb.getEjbName());
if (bean != null) {
Map<String, ServiceRef> serviceRefMap = bean.getServiceRefMap();
for (org.apache.openejb.jee.sun.ServiceRef ref : ejb.getServiceRef()) {
String refName = ref.getServiceRefName();
refName = normalize(refName);
ServiceRef serviceRef = serviceRefMap.get(refName);
if (serviceRef != null) {
Map<String,PortComponentRef> ports = new TreeMap<String,PortComponentRef>();
for (PortComponentRef portComponentRef : serviceRef.getPortComponentRef()) {
ports.put(portComponentRef.getServiceEndpointInterface(), portComponentRef);
}
for (PortInfo portInfo : ref.getPortInfo()) {
PortComponentRef portComponentRef = ports.get(portInfo.getServiceEndpointInterface());
if (portComponentRef != null) {
WsdlPort wsdlPort = portInfo.getWsdlPort();
if (wsdlPort != null) {
QName qname = new QName(wsdlPort.getNamespaceURI(), wsdlPort.getLocalpart());
portComponentRef.setQName(qname);
}
for (StubProperty stubProperty : portInfo.getStubProperty()) {
String name = stubProperty.getName();
String value = stubProperty.getValue();
portComponentRef.getProperties().setProperty(name, value);
}
}
}
String wsdlOverride = ref.getWsdlOverride();
if (wsdlOverride != null && wsdlOverride.length() > 0) {
String serviceId = extractServiceId(wsdlOverride);
serviceRef.setMappedName(serviceId);
}
}
}
}
if (ejb.getMdbResourceAdapter() != null) {
// resource adapter id is the MDB container ID
String resourceAdapterId = ejb.getMdbResourceAdapter().getResourceAdapterMid();
deployment.setContainerId(resourceAdapterId);
}
endpointMap.put(ejb.getEjbName(), ejb.getWebserviceEndpointMap());
}