blob: 2ecabb9a23061590220106b4270fd53ffc143771 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.tuscany.sca.contribution.jee;
import java.util.Map;
import org.apache.openejb.config.AppModule;
import org.apache.openejb.config.EjbModule;
import org.apache.openejb.jee.EnterpriseBean;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.contribution.service.ContributionException;
/**
* @version $Rev$ $Date$
*/
public class JavaEEApplicationProcessor {
private AppModule appModule;
private ComponentType componentType;
private AssemblyHelper helper;
public JavaEEApplicationProcessor(AppModule appModule, AssemblyHelper helper) {
super();
this.appModule = appModule;
this.helper = helper;
}
public JavaEEApplicationProcessor(AppModule module) {
appModule = module;
helper = new AssemblyHelper();
}
public ComponentType getJavaEEAppComponentType() throws ContributionException {
if (componentType != null) {
return componentType;
}
componentType = helper.createComponentType();
// Process all EJB modules
for(EjbModule ejbModule : appModule.getEjbModules()) {
EJBModuleProcessor emp = new EJBModuleProcessor(ejbModule, helper);
Map<String, ComponentType> ejbComponentTypes = emp.getEjbComponentTypes();
for(Map.Entry<String, ComponentType> entry : ejbComponentTypes.entrySet()) {
String beanName = entry.getKey();
ComponentType ct = entry.getValue();
EnterpriseBean bean = ejbModule.getEjbJar().getEnterpriseBeansByEjbName().get(beanName);
String mappedName = bean.getMappedName() != null ? bean.getMappedName() : beanName;
String mappedName2 = mappedName.replace("/", "_");
// Add all services from the bean
for(Service service : ct.getServices()) {
Service service2 = helper.createComponentService();
String serviceName = mappedName2 + "_"+service.getName();
service2.setName(serviceName);
service2.setInterfaceContract(service.getInterfaceContract());
componentType.getServices().add(service2);
}
String beanName2 = beanName.replace("/", "_");
// Add all references
for(Reference reference : ct.getReferences()) {
Reference reference2 = helper.createComponentReference();
String referenceName = beanName2+"_"+reference.getName();
reference2.setName(referenceName);
reference2.setInterfaceContract(reference.getInterfaceContract());
reference2.getRequiredIntents().addAll(reference.getRequiredIntents());
componentType.getReferences().add(reference2);
}
}
emp.getEjbAppComponentType();
}
// Process web modules (?)
// FIXME: SCA JEE Spec 1.0 - Sec 7.1.3 says nothing about web modules
return componentType;
}
}
|