You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2007/01/13 04:08:04 UTC
svn commit: r495829 - in
/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config:
ConfigurationFactory.java DeploymentLoader.java
Author: dblevins
Date: Fri Jan 12 19:08:03 2007
New Revision: 495829
URL: http://svn.apache.org/viewvc?view=rev&rev=495829
Log:
Small tweaks to the ConfigurationFactory/DeploymentLoader. more coming.
Modified:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/ConfigurationFactory.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentLoader.java
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/ConfigurationFactory.java?view=diff&rev=495829&r1=495828&r2=495829
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/ConfigurationFactory.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/ConfigurationFactory.java Fri Jan 12 19:08:03 2007
@@ -40,7 +40,6 @@
import org.apache.openejb.assembler.classic.FacilitiesInfo;
import org.apache.openejb.assembler.classic.IntraVmServerInfo;
import org.apache.openejb.assembler.classic.JndiContextInfo;
-import org.apache.openejb.assembler.classic.JndiEncInfo;
import org.apache.openejb.assembler.classic.ManagedConnectionFactoryInfo;
import org.apache.openejb.assembler.classic.MdbContainerInfo;
import org.apache.openejb.assembler.classic.OpenEjbConfiguration;
@@ -77,18 +76,22 @@
public static OpenEjbConfiguration sys;
private final List<ContainerInfo> containers = new ArrayList<ContainerInfo>();
- private final List<EntityContainerInfo> entityContainers = new ArrayList<EntityContainerInfo>();
- private final List<StatefulSessionContainerInfo> sfsbContainers = new ArrayList<StatefulSessionContainerInfo>();
- private final List<StatelessSessionContainerInfo> slsbContainers = new ArrayList<StatelessSessionContainerInfo>();
- private final List<MdbContainerInfo> mdbContainers = new ArrayList<MdbContainerInfo>();
private Map<String,ContainerInfo> containerTable = new HashMap<String,ContainerInfo>();
- private Properties props;
+ private Properties props = new Properties();
public EjbJarInfoBuilder ejbJarInfoBuilder = new EjbJarInfoBuilder();
+ public ConfigurationFactory() {
+ }
+
public void init(Properties props) throws OpenEJBException {
this.props = props;
+ findConfiguration(props);
+
+ }
+
+ private void findConfiguration(Properties props) throws OpenEJBException {
configLocation = props.getProperty("openejb.conf.file");
if (configLocation == null) {
@@ -99,35 +102,18 @@
if (configLocation != null){
this.props.setProperty("openejb.configuration", configLocation);
}
-
- }
-
- public static void main(String[] args) {
- try {
- ConfigurationFactory conf = new ConfigurationFactory();
- conf.configLocation = args[0];
- conf.init(null);
- OpenEjbConfiguration openejb = conf.getOpenEjbConfiguration();
-
- ConfigurationPrinter.printConf(openejb);
- } catch (Exception e) {
- System.out.println("[OpenEJB] " + e.getMessage());
- e.printStackTrace();
- }
}
public OpenEjbConfiguration getOpenEjbConfiguration() throws OpenEJBException {
Openejb openejb;
- DynamicDeployer deployer;
if (configLocation != null) {
openejb = ConfigUtils.readConfig(configLocation);
- deployer = new AutoDeployer(openejb);
} else {
openejb = new Openejb();
- deployer = new AutoConfigAndDeploy(openejb);
}
+ DynamicDeployer deployer = getDeployer(openejb);
List<Deployments> deployments = new ArrayList<Deployments>(Arrays.asList(openejb.getDeployments()));
@@ -142,7 +128,13 @@
deployments.add(deployment);
}
- List<DeploymentModule> deployedJars = new DeploymentLoader().loadDeploymentsList(deployments, deployer);
+ DeploymentLoader deploymentLoader = new DeploymentLoader();
+
+ List<DeploymentModule> deployedJars = deploymentLoader.loadModules(deployments, deployer);
+
+ for (DeploymentModule ejbModule : deployedJars) {
+ DeploymentLoader.logger.info("Loaded Module: " + ejbModule.getJarLocation());
+ }
DeploymentModule[] jars = deployedJars.toArray(new DeploymentModule[]{});
@@ -161,28 +153,6 @@
sys.containerSystem.containers.addAll(containers);
List<AppInfo> appInfos = new ArrayList<AppInfo>();
- {
- AppInfo appInfo = new AppInfo();
- for (DeploymentModule jar : jars) {
- if (!(jar instanceof EjbModule)) {
- continue;
- }
- EjbModule ejbModule = (EjbModule) jar;
- try {
- EjbJarInfo ejbJarInfo = ejbJarInfoBuilder.buildInfo(ejbModule);
- if (ejbJarInfo == null) {
- continue;
- }
- assignBeansToContainers(ejbJarInfo.enterpriseBeans, ejbModule.getOpenejbJar().getDeploymentsByEjbName());
- appInfo.ejbJars.add(ejbJarInfo);
- } catch (Exception e) {
- e.printStackTrace();
- ConfigUtils.logger.i18n.warning("conf.0004", ejbModule.getJarURI(), e.getMessage());
- }
- }
-
- appInfos.add(appInfo);
- }
for (DeploymentModule module : jars) {
if (!(module instanceof AppModule)) {
@@ -190,43 +160,7 @@
}
AppModule appModule = (AppModule) module;
- AppInfo appInfo = new AppInfo();
- for (EjbModule ejbModule : appModule.getEjbModules()) {
- try {
- EjbJarInfo ejbJarInfo = ejbJarInfoBuilder.buildInfo(ejbModule);
- if (ejbJarInfo == null) {
- continue;
- }
- assignBeansToContainers(ejbJarInfo.enterpriseBeans, ejbModule.getOpenejbJar().getDeploymentsByEjbName());
- appInfo.ejbJars.add(ejbJarInfo);
- } catch (Exception e) {
- e.printStackTrace();
- ConfigUtils.logger.i18n.warning("conf.0004", ejbModule.getJarURI(), e.getMessage());
- }
- }
-
- for (ClientModule clientModule : appModule.getClientModules()) {
-
- ApplicationClient applicationClient = clientModule.getApplicationClient();
- ClientInfo clientInfo = new ClientInfo();
- clientInfo.description = applicationClient.getDescription();
- clientInfo.displayName = applicationClient.getDisplayName();
- clientInfo.codebase = clientModule.getJarLocation();
- clientInfo.mainClass = clientModule.getMainClass();
- clientInfo.moduleId = getClientModuleId(clientModule);
-
- JndiEncInfoBuilder jndiEncInfoBuilder = new JndiEncInfoBuilder(appInfo.ejbJars);
- JndiEncInfo jndiEncInfo = jndiEncInfoBuilder.build(applicationClient, clientModule.getJarLocation());
- clientInfo.jndiEnc = jndiEncInfo;
- appInfo.clients.add(clientInfo);
- }
-
- appInfo.jarPath = appModule.getJarLocation();
- List<URL> additionalLibraries = appModule.getAdditionalLibraries();
- for (URL url : additionalLibraries) {
- File file = new File(url.getPath());
- appInfo.libs.add(file.getAbsolutePath());
- }
+ AppInfo appInfo = configureAppModule(appModule);
appInfos.add(appInfo);
}
@@ -241,6 +175,67 @@
SystemInstance.get().setComponent(OpenEjbConfiguration.class, sys);
return sys;
+ }
+
+ private DynamicDeployer getDeployer(Openejb openejb) {
+ DynamicDeployer deployer;
+ // TODO: Create some way to enable one versus the other
+ if (false){
+ deployer = new AutoDeployer(openejb);
+
+ } else {
+ deployer = new AutoConfigAndDeploy(openejb);
+ }
+
+ deployer = new AnnotationDeployer(deployer);
+
+ boolean shouldValidate = !SystemInstance.get().getProperty("openejb.validation.skip", "false").equalsIgnoreCase("true");
+ if (shouldValidate) {
+ deployer = new ValidateEjbModule(deployer);
+ } else {
+ DeploymentLoader.logger.info("Validation is disabled.");
+ }
+ return deployer;
+ }
+
+ public AppInfo configureAppModule(AppModule appModule) throws OpenEJBException {
+ AppInfo appInfo = new AppInfo();
+ for (EjbModule ejbModule : appModule.getEjbModules()) {
+ try {
+ EjbJarInfo ejbJarInfo = ejbJarInfoBuilder.buildInfo(ejbModule);
+ if (ejbJarInfo == null) {
+ continue;
+ }
+ assignBeansToContainers(ejbJarInfo.enterpriseBeans, ejbModule.getOpenejbJar().getDeploymentsByEjbName());
+ appInfo.ejbJars.add(ejbJarInfo);
+ } catch (Exception e) {
+ e.printStackTrace();
+ ConfigUtils.logger.i18n.warning("conf.0004", ejbModule.getJarURI(), e.getMessage());
+ }
+ }
+
+ for (ClientModule clientModule : appModule.getClientModules()) {
+
+ ApplicationClient applicationClient = clientModule.getApplicationClient();
+ ClientInfo clientInfo = new ClientInfo();
+ clientInfo.description = applicationClient.getDescription();
+ clientInfo.displayName = applicationClient.getDisplayName();
+ clientInfo.codebase = clientModule.getJarLocation();
+ clientInfo.mainClass = clientModule.getMainClass();
+ clientInfo.moduleId = getClientModuleId(clientModule);
+
+ JndiEncInfoBuilder jndiEncInfoBuilder = new JndiEncInfoBuilder(appInfo.ejbJars);
+ clientInfo.jndiEnc = jndiEncInfoBuilder.build(applicationClient, clientModule.getJarLocation());
+ appInfo.clients.add(clientInfo);
+ }
+
+ appInfo.jarPath = appModule.getJarLocation();
+ List<URL> additionalLibraries = appModule.getAdditionalLibraries();
+ for (URL url : additionalLibraries) {
+ File file = new File(url.getPath());
+ appInfo.libs.add(file.getAbsolutePath());
+ }
+ return appInfo;
}
private static String getClientModuleId(ClientModule clientModule) {
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentLoader.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentLoader.java?view=diff&rev=495829&r1=495828&r2=495829
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentLoader.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentLoader.java Fri Jan 12 19:08:03 2007
@@ -146,51 +146,8 @@
}
}
- public static enum Type {
- JAR, DIR, CLASSPATH
- }
-
- public List<DeploymentModule> load(Type type, Object source) throws OpenEJBException {
- Deployments deployments = new Deployments();
- switch (type) {
- case JAR:
- deployments.setJar((String) source);
- break;
- case DIR:
- deployments.setDir((String) source);
- break;
- case CLASSPATH:
- deployments.setClasspath((ClassLoader) source);
- break;
- }
-
- List<Deployments> list = new ArrayList();
- list.add(deployments);
- return loadDeploymentsList(list, null);
- }
-
- public List<DeploymentModule> loadDeploymentsList(List<Deployments> deployments, DynamicDeployer deployer) throws OpenEJBException {
-
- if (deployer == null) {
- deployer = new DynamicDeployer() {
- public EjbModule deploy(EjbModule ejbModule) throws OpenEJBException {
- return ejbModule;
- }
-
- public ClientModule deploy(ClientModule clientModule) throws OpenEJBException {
- return clientModule;
- }
- };
- }
-
- deployer = new AnnotationDeployer(deployer);
-
- if (!SystemInstance.get().getProperty("openejb.validation.skip", "false").equalsIgnoreCase("true")) {
- deployer = new ValidateEjbModule(deployer);
- } else {
- logger.info("Validation is disabled.");
- }
+ public List<DeploymentModule> loadModules(List<Deployments> deployments, DynamicDeployer deployer) {
List<DeploymentModule> deployedJars = new ArrayList();
// resolve jar locations ////////////////////////////////////// BEGIN ///////
@@ -240,22 +197,22 @@
loadAppModule(jarFile, deployer, deployedJars);
} else {
+
EjbJarUtils ejbJarUtils = new EjbJarUtils(jarFile.getAbsolutePath());
EjbModule undeployedModule = new EjbModule(classLoader, jarFile.getAbsolutePath(), ejbJarUtils.getEjbJar(), ejbJarUtils.getOpenejbJar());
+
+
EjbModule ejbModule = deployer.deploy(undeployedModule);
- /* Add it to the Vector ***************/
- deployedJars.add(ejbModule);
+ AppModule appModule = new AppModule(classLoader, null);
+ appModule.getEjbModules().add(ejbModule);
+ deployedJars.add(appModule);
}
} catch (OpenEJBException e) {
e.printStackTrace();
ConfigUtils.logger.i18n.warning("conf.0004", jarFile.getAbsolutePath(), e.getMessage());
}
- }
-
- for (DeploymentModule ejbModule : deployedJars) {
- logger.info("Loaded Module: " + ejbModule.getJarLocation());
}
return deployedJars;
}