use of org.apache.openejb.jee.oejb2.PatternType in project tomee by apache.
the class OpenEjb2Conversion method convertEjbRefs.
public final void convertEjbRefs(final EjbJar ejbJar, final OpenejbJar openejbJar, final OpenejbJarType openejbJarType) {
openejbJar.getProperties().putAll(openejbJarType.getProperties());
final Map<String, EnterpriseBean> ejbs = ejbJar.getEnterpriseBeansByEjbName();
final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
for (final org.apache.openejb.jee.oejb2.EnterpriseBean enterpriseBean : openejbJarType.getEnterpriseBeans()) {
final EnterpriseBean ejb = ejbs.get(enterpriseBean.getEjbName());
if (ejb == null) {
// todo warn no such ejb in the ejb-jar.xml
continue;
}
final Map<String, EjbRef> ejbRefs = ejb.getEjbRefMap();
final EjbDeployment deployment = deployments.get(enterpriseBean.getEjbName());
if (deployment == null) {
// todo warn no such ejb in the ejb-jar.xml
continue;
}
// Add WS Security
if (enterpriseBean instanceof SessionBeanType) {
final SessionBeanType sessionBean = (SessionBeanType) enterpriseBean;
final WebServiceSecurityType webServiceSecurityType = sessionBean.getWebServiceSecurity();
if (webServiceSecurityType != null) {
if (webServiceSecurityType.getRealmName() != null) {
deployment.addProperty("webservice.security.realm", webServiceSecurityType.getRealmName());
}
if (webServiceSecurityType.getSecurityRealmName() != null) {
deployment.addProperty("webservice.security.securityRealm", webServiceSecurityType.getSecurityRealmName());
}
if (webServiceSecurityType.getTransportGuarantee() != null) {
deployment.addProperty("webservice.security.transportGarantee", webServiceSecurityType.getTransportGuarantee().value());
} else {
deployment.addProperty("webservice.security.transportGarantee", "NONE");
}
if (webServiceSecurityType.getAuthMethod() != null) {
deployment.addProperty("webservice.security.authMethod", webServiceSecurityType.getAuthMethod().value());
} else {
deployment.addProperty("webservice.security.authMethod", "NONE");
}
deployment.getProperties().putAll(webServiceSecurityType.getProperties());
}
if (sessionBean.getWebServiceAddress() != null) {
deployment.getProperties().put("openejb.webservice.deployment.address", sessionBean.getWebServiceAddress());
}
}
deployment.getProperties().putAll(enterpriseBean.getProperties());
for (final String name : enterpriseBean.getLocalJndiName()) {
deployment.getJndi().add(new org.apache.openejb.jee.oejb3.Jndi(name, "LocalHome"));
}
for (final String name : enterpriseBean.getJndiName()) {
deployment.getJndi().add(new org.apache.openejb.jee.oejb3.Jndi(name, "RemoteHome"));
}
for (final Jndi jndi : enterpriseBean.getJndi()) {
deployment.getJndi().add(new org.apache.openejb.jee.oejb3.Jndi(jndi.getName(), jndi.getInterface()));
}
final Set<String> ejbLinks = new TreeSet<String>();
for (final EjbLink ejbLink : deployment.getEjbLink()) {
ejbLinks.add(ejbLink.getEjbRefName());
}
for (final EjbRefType refType : enterpriseBean.getEjbRef()) {
final String refName = refType.getRefName();
if (ejbLinks.contains(refName)) {
// don't overwrite refs that have been already set
continue;
}
final String nsCorbaloc = refType.getNsCorbaloc();
if (nsCorbaloc != null) {
final EjbRef ref = ejbRefs.get(refName);
if (ref != null) {
ref.setMappedName("jndi:" + nsCorbaloc);
}
} else if (refType.getEjbLink() != null) {
final EjbRef ref = ejbRefs.get(refName);
if (ref != null) {
ref.setEjbLink(refType.getEjbLink());
}
} else {
final PatternType pattern = refType.getPattern();
addEjbLink(deployment, refName, pattern);
}
}
for (final EjbLocalRefType refType : enterpriseBean.getEjbLocalRef()) {
final String refName = refType.getRefName();
if (ejbLinks.contains(refName)) {
// don't overwrite refs that have been already set
continue;
}
if (refType.getEjbLink() != null) {
final EjbRef ref = ejbRefs.get(refName);
if (ref != null) {
ref.setEjbLink(refType.getEjbLink());
}
} else {
final PatternType pattern = refType.getPattern();
addEjbLink(deployment, refName, pattern);
}
}
}
}
Aggregations