summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEExtensionImpl.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEExtensionImpl.java90
1 files changed, 73 insertions, 17 deletions
diff --git a/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEExtensionImpl.java b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEExtensionImpl.java
index 8d8d0f4c35..c4e180bf82 100644
--- a/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEExtensionImpl.java
+++ b/branches/sca-java-1.x/modules/contribution-jee/src/main/java/org/apache/tuscany/sca/contribution/jee/impl/JavaEEExtensionImpl.java
@@ -23,9 +23,14 @@ import java.util.Map;
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.jee.EJBImplementationGenerated;
import org.apache.tuscany.sca.contribution.jee.EjbInfo;
import org.apache.tuscany.sca.contribution.jee.EjbModuleInfo;
import org.apache.tuscany.sca.contribution.jee.JavaEEApplicationInfo;
@@ -97,14 +102,16 @@ public class JavaEEExtensionImpl implements JavaEEExtension {
return componentType;
}
- public ComponentType createImplementationJeeComponentType(EjbModuleInfo ejbModule) {
- ComponentType componentType = assemblyFactory.createComponentType();
-
+ public void createImplementationJeeComposite(EjbModuleInfo ejbModule, Composite composite) {
+
for(Map.Entry<String, EjbInfo> entry : ejbModule.getEjbInfos().entrySet()) {
EjbInfo ejbInfo = entry.getValue();
+
+ Component component = findComponent(composite, ejbInfo.beanName);
+
if(ejbInfo.ejbType.compareTo(EjbType.MESSAGE_DRIVEN) != 0) {
for(Class<?> intf : ejbInfo.businessRemote) {
- Service service = assemblyFactory.createComponentService();
+ ComponentService service = assemblyFactory.createComponentService();
String intfName = intf.getName();
String serviceName = intfName.lastIndexOf(".") != -1 ? intfName.substring(intfName.lastIndexOf(".") + 1) : intfName;
serviceName = ejbInfo.beanName+"_"+serviceName;
@@ -117,11 +124,12 @@ public class JavaEEExtensionImpl implements JavaEEExtension {
e.printStackTrace();
}
service.setInterfaceContract(ic);
- componentType.getServices().add(service);
+
+ addComponentService(composite, component, service);
}
for(Class<?> intf : ejbInfo.businessLocal) {
- Service service = assemblyFactory.createComponentService();
+ ComponentService service = assemblyFactory.createComponentService();
String intfName = intf.getName();
String serviceName = intfName.lastIndexOf(".") != -1 ? intfName.substring(intfName.lastIndexOf(".") + 1) : intfName;
serviceName = ejbInfo.beanName+"_"+serviceName;
@@ -136,25 +144,25 @@ public class JavaEEExtensionImpl implements JavaEEExtension {
service.setInterfaceContract(ic);
service.getRequiredIntents().add(EJB_INTENT);
- componentType.getServices().add(service);
+ addComponentService(composite, component, service);
}
}
}
-
- return componentType;
}
-
- public ComponentType createImplementationJeeComponentType(JavaEEApplicationInfo appInfo) {
- ComponentType componentType = assemblyFactory.createComponentType();
+
+ public void createImplementationJeeComposite(JavaEEApplicationInfo appInfo, Composite composite) {
for(Map.Entry<String, EjbModuleInfo> entry0 : appInfo.getEjbModuleInfos().entrySet()) {
EjbModuleInfo ejbModule = entry0.getValue();
for(Map.Entry<String, EjbInfo> entry : ejbModule.getEjbInfos().entrySet()) {
EjbInfo ejbInfo = entry.getValue();
+
+ Component component = findComponent(composite, ejbInfo.beanName);
+
if(ejbInfo.ejbType.compareTo(EjbType.MESSAGE_DRIVEN) != 0) {
for(Class<?> intf : ejbInfo.businessRemote) {
- Service service = assemblyFactory.createComponentService();
+ ComponentService service = assemblyFactory.createComponentService();
String intfName = intf.getName();
String serviceName = intfName.lastIndexOf(".") != -1 ? intfName.substring(intfName.lastIndexOf(".") + 1) : intfName;
serviceName = ejbInfo.mappedName+"_"+serviceName;
@@ -167,11 +175,12 @@ public class JavaEEExtensionImpl implements JavaEEExtension {
e.printStackTrace();
}
service.setInterfaceContract(ic);
- componentType.getServices().add(service);
+
+ addComponentService(composite, component, service);
}
for(Class<?> intf : ejbInfo.businessLocal) {
- Service service = assemblyFactory.createComponentService();
+ ComponentService service = assemblyFactory.createComponentService();
String intfName = intf.getName();
String serviceName = intfName.lastIndexOf(".") != -1 ? intfName.substring(intfName.lastIndexOf(".") + 1) : intfName;
serviceName = ejbInfo.mappedName+"_"+serviceName;
@@ -186,12 +195,59 @@ public class JavaEEExtensionImpl implements JavaEEExtension {
service.setInterfaceContract(ic);
service.getRequiredIntents().add(EJB_INTENT);
- componentType.getServices().add(service);
+ addComponentService(composite, component, service);
}
}
}
}
+ }
+
+ /**
+ * We are fluffing up the JEEImplemention composite to represented the components
+ * in the JEE archive. Given the JEEimplemenation composite find a named component
+ * it if already exists or create it if it doesn't.
+ *
+ * @param composite
+ * @param componentName
+ * @return
+ */
+ private Component findComponent(Composite composite, String componentName){
+ Component component = null;
- return componentType;
+ for (Component tmpComponent : composite.getComponents()){
+ if (tmpComponent.getName().equals(componentName)){
+ component = tmpComponent;
+ break;
+ }
+ }
+
+ if (component == null){
+ component = assemblyFactory.createComponent();
+ component.setName(componentName);
+ composite.getComponents().add(component);
+
+ EJBImplementationGenerated implementation = new EJBImplementationGeneratedImpl();
+ component.setImplementation(implementation);
+ }
+
+ return component;
+ }
+
+ /**
+ * Add a component service and fluff up a composite service to match
+ *
+ * @param composite
+ * @param component
+ * @param service
+ */
+ private void addComponentService(Composite composite, Component component, ComponentService service){
+ component.getImplementation().getServices().add(service);
+
+ CompositeService compositeService = assemblyFactory.createCompositeService();
+ composite.getServices().add(compositeService);
+
+ compositeService.setName(service.getName());
+ compositeService.setPromotedComponent(component);
+ compositeService.setPromotedService(service);
}
}