You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by va...@apache.org on 2008/12/10 15:29:18 UTC
svn commit: r725295 -
/geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java
Author: vamsic007
Date: Wed Dec 10 06:29:18 2008
New Revision: 725295
URL: http://svn.apache.org/viewvc?rev=725295&view=rev
Log:
Support for web and ejb apps packaged in a EAR file.
Modified:
geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java
Modified: geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java?rev=725295&r1=725294&r2=725295&view=diff
==============================================================================
--- geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java (original)
+++ geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java Wed Dec 10 06:29:18 2008
@@ -101,8 +101,18 @@
public void createModule(Module module, Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, Environment environment, Object moduleContextInfo, AbstractName earName, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
System.out.println("Inside TuscanyModuleBuilderExtension.createModule");
- // TODO: Merge environment only for SCA enhanced apps.
- EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+ // Merge environment only for SCA enhanced apps.
+ if(module instanceof WebModule) {
+ // TODO: Need a more general rule. For now look for web.composite
+ if(moduleFile.getEntry("WEB-INF/web.composite") != null) {
+ EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+ }
+ } else if(module instanceof EjbModule) {
+ // TODO: Need a more general rule. For now look for ejb-jar.composite
+ if(moduleFile.getEntry("META-INF/ejb-jar.composite") != null) {
+ EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+ }
+ }
}
public void installModule(JarFile earFile, EARContext earContext, Module module, Collection configurationStores, ConfigurationStore targetConfigurationStore, Collection repository) throws DeploymentException {
@@ -127,7 +137,7 @@
Naming naming = earContext.getNaming();
// Add EmbeddedRuntimeGBean to the application config.
- AbstractName moduleName = earContext.getModuleName();
+ AbstractName moduleName = module.getModuleName();
AbstractName abstractName = naming.createChildName(moduleName, "EmbeddedRuntime", "GBean");
GBeanInfo gBeanInfo = GBeanInfo.getGBeanInfo(EmbeddedRuntimeGBean.class.getName(), cl);
GBeanData data = new GBeanData(abstractName, gBeanInfo);
@@ -137,12 +147,13 @@
// FIXME: Eliminate this hack.
// HACK: Create a JAR file with web.composite and web.componentType files
// place it as META-INF/application-composite.jar to deploy to the SCA domain
- File webCompositeFile = new File(earContext.getBaseDir(), "WEB-INF/web.composite");
- File webComponentTypeFile = new File(earContext.getBaseDir(), "WEB-INF/web.componentType");
- File appCompositeJarFile = new File(earContext.getBaseDir(), "META-INF/application-composite.jar");
+ File webCompositeFile = new File(earContext.getBaseDir(), (module.isStandAlone() ? "" : module.getName()+"/")+"WEB-INF/web.composite");
+ File webComponentTypeFile = new File(earContext.getBaseDir(), (module.isStandAlone() ? "" : module.getName()+"/")+"WEB-INF/web.componentType");
+ File appCompositeJarFile = new File(earContext.getBaseDir(), "META-INF/"+(module.isStandAlone() ? "" : module.getName()+"/")+"application-composite.jar");
JarOutputStream jarOut = null;
FileInputStream fin = null;
try {
+ appCompositeJarFile.getParentFile().mkdirs();
jarOut = new JarOutputStream(new FileOutputStream(appCompositeJarFile));
if(webCompositeFile.exists()) {
fin = new FileInputStream(webCompositeFile);
@@ -170,7 +181,7 @@
IOUtil.close(jarOut);
}
- data.setAttribute("jarFileName", "META-INF/application-composite.jar");
+ data.setAttribute("jarFileName", "META-INF/"+(module.isStandAlone() ? "" : module.getName()+"/")+"application-composite.jar");
try {
earContext.addGBean(data);
} catch (GBeanAlreadyExistsException e) {
@@ -211,13 +222,14 @@
WebModule webModule = (WebModule) module;
WebAppType webApp = (WebAppType) webModule.getSpecDD();
XmlObject vendorWebApp = webModule.getVendorDD();
+ ClassLoader webClassLoader = module.getEarContext().getClassLoader();
// Find the injection points
ServletType[] servlets = webApp.getServletArray();
for(ServletType servlet:servlets) {
String servletClassName = servlet.getServletClass().getStringValue().trim();
try {
- Class servletClass = cl.loadClass(servletClassName);
+ Class servletClass = webClassLoader.loadClass(servletClassName);
processWebArtifactClass(servletClass, compContext, holder, thisComponentName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
@@ -229,7 +241,7 @@
for(FilterType filter : filters) {
String filterClassName = filter.getFilterClass().getStringValue().trim();
try {
- Class filterClass = cl.loadClass(filterClassName);
+ Class filterClass = webClassLoader.loadClass(filterClassName);
processWebArtifactClass(filterClass, compContext, holder, thisComponentName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
@@ -241,7 +253,7 @@
for(ListenerType listener : listeners) {
String listenerClassName = listener.getListenerClass().getStringValue().trim();
try {
- Class listenerClass = cl.loadClass(listenerClassName);
+ Class listenerClass = webClassLoader.loadClass(listenerClassName);
processWebArtifactClass(listenerClass, compContext, holder, thisComponentName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
@@ -258,8 +270,9 @@
}
// Add dependency so that EmbeddedRuntime starts before the WebAppContext
- ((GBeanData)earContext.getConfiguration().findGBeanDatas(Collections.singleton(new AbstractNameQuery(module.getModuleName()))).toArray()[0]).addDependency(abstractName);
-
+ // ((GBeanData)earContext.getConfiguration().findGBeanDatas(Collections.singleton(new AbstractNameQuery(module.getModuleName()))).toArray()[0]).addDependency(abstractName);
+ // module name is not good enough to query the webappcontext gbean incase of web modules in a EAR file
+ ((GBeanData)module.getEarContext().getConfiguration().findGBeanDatas(Collections.singleton(new AbstractNameQuery("org.apache.geronimo.management.geronimo.WebModule"))).toArray()[0]).addDependency(abstractName);
namingBuilders.buildNaming(webApp, vendorWebApp, webModule, buildingContext);
}
@@ -318,7 +331,7 @@
Naming naming = earContext.getNaming();
// Add EmbeddedRuntimeGBean to the application config.
- AbstractName moduleName = earContext.getModuleName();
+ AbstractName moduleName = module.getModuleName();
AbstractName abstractName = naming.createChildName(moduleName, "EmbeddedRuntime", "GBean");
GBeanInfo gBeanInfo = GBeanInfo.getGBeanInfo(EmbeddedRuntimeGBean.class.getName(), cl);
GBeanData data = new GBeanData(abstractName, gBeanInfo);
@@ -328,8 +341,8 @@
// FIXME: Eliminate this hack.
// HACK: Create a JAR file with ejb-jar.composite and other componentType files.
// Place it as META-INF/application-composite.jar to deploy to the SCA domain
- File ejbJarFile = new File(earContext.getBaseDir(), "ejb.jar");
- File appCompositeJarFile = new File(earContext.getBaseDir(), "META-INF/application-composite.jar");
+ File ejbJarFile = new File(earContext.getBaseDir(), module.isStandAlone() ? "ejb.jar" : module.getName());
+ File appCompositeJarFile = new File(earContext.getBaseDir(), "META-INF/"+(module.isStandAlone() ? "" : module.getName()+"/")+"application-composite.jar");
JarOutputStream jarOut = null;
JarInputStream jin = null;
try {
@@ -361,7 +374,7 @@
IOUtil.close(jarOut);
}
- data.setAttribute("jarFileName", "META-INF/application-composite.jar");
+ data.setAttribute("jarFileName", "META-INF/"+(module.isStandAlone() ? "" : module.getName()+"/")+"application-composite.jar");
try {
earContext.addGBean(data);
} catch (GBeanAlreadyExistsException e) {