Author: dain
Date: Sat Sep 15 14:42:45 2007
New Revision: 575989
URL: http://svn.apache.org/viewvc?rev=575989&view=rev
Log:
Process web.xml and ra.xml in DeploymentLoader
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ResourceModule.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=575989&r1=575988&r2=575989&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Sat Sep 15 14:42:45 2007
@@ -25,6 +25,8 @@
import org.apache.openejb.jee.JaxbJavaee;
import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.ApplicationClient;
+import org.apache.openejb.jee.Connector;
+import org.apache.openejb.jee.WebApp;
import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;
import org.apache.openejb.util.Messages;
@@ -44,6 +46,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Iterator;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@@ -51,9 +54,6 @@
* @version $Revision$ $Date$
*/
public class DeploymentLoader {
-
- private static final Map<Class<?>, JaxbUnmarshaller> unmarshallers = new
HashMap<Class<?>, JaxbUnmarshaller>();
-
public static final Logger logger =
Logger.getInstance(LogCategory.OPENEJB_STARTUP,
"org.apache.openejb.util.resources");
private static final Messages messages = new
Messages("org.apache.openejb.util.resources");
@@ -89,8 +89,15 @@
try {
+ //
+ // Find all the modules using either the application xml or by
searching for all .jar, .war and .rar files.
+ //
+
Map<String, URL> ejbModules = new HashMap<String, URL>();
Map<String, URL> clientModules = new HashMap<String, URL>();
+ Map<String, URL> resouceModules = new HashMap<String, URL>();
+ Map<String, URL> webModules = new HashMap<String, URL>();
+ Map<String, String> webContextRoots = new HashMap<String,
String>();
URL applicationXmlUrl = appDescriptors.get("application.xml");
@@ -105,6 +112,13 @@
} else if (module.getJava() != null) {
URL url = finder.find(module.getJava().trim());
clientModules.put(module.getConnector(), url);
+ } else if (module.getConnector() != null) {
+ URL url =
finder.find(module.getConnector().trim());
+ resouceModules.put(module.getConnector(), url);
+ } else if (module.getWeb() != null) {
+ URL url =
finder.find(module.getWeb().getWebUri().trim());
+ webModules.put(module.getWeb().getWebUri(),
url);
+
webContextRoots.put(module.getWeb().getWebUri(),
module.getWeb().getContextRoot());
}
} catch (IOException e) {
throw new OpenEJBException("Invalid path to module
" + e.getMessage(), e);
@@ -127,6 +141,10 @@
ejbModules.put(entry.getKey(),
entry.getValue());
} else if (ClientModule.class.equals(moduleType)) {
clientModules.put(entry.getKey(),
entry.getValue());
+ } else if
(ResourceModule.class.equals(moduleType)) {
+ resouceModules.put(entry.getKey(),
entry.getValue());
+ } else if (WebModule.class.equals(moduleType)) {
+ webModules.put(entry.getKey(),
entry.getValue());
}
} catch (UnsupportedOperationException e) {
// Ignore it as per the javaee spec EE.8.4.2
section 1.d.iiilogger.info("Ignoring unknown module type: "+entry.getKey());
@@ -136,13 +154,17 @@
}
}
+ //
+ // Create a class loader for the application
+ //
+
+ // lib/*
if (application.getLibraryDirectory() == null) {
application.setLibraryDirectory("lib/");
} else {
String dir = application.getLibraryDirectory();
if (!dir.endsWith("/"))
application.setLibraryDirectory(dir + "/");
}
-
List<URL> extraLibs = new ArrayList<URL>();
try {
Map<String, URL> libs =
finder.getResourcesMap(application.getLibraryDirectory());
@@ -151,6 +173,7 @@
logger.warning("Cannot load libs from '" +
application.getLibraryDirectory() + "' : " + e.getMessage(), e);
}
+ // APP-INF/lib/*
try {
Map<String, URL> libs =
finder.getResourcesMap("APP-INF/lib/");
extraLibs.addAll(libs.values());
@@ -158,6 +181,7 @@
logger.warning("Cannot load libs from 'APP-INF/lib/' : " +
e.getMessage(), e);
}
+ // META-INF/lib/*
try {
Map<String, URL> libs =
finder.getResourcesMap("META-INF/lib/");
extraLibs.addAll(libs.values());
@@ -165,17 +189,44 @@
logger.warning("Cannot load libs from 'META-INF/lib/' : "
+ e.getMessage(), e);
}
+ // All jars nested in the Resource Adapter
+ HashMap<String, URL> rarLibs = new HashMap<String, URL>();
+ for (Map.Entry<String, URL> entry : resouceModules.entrySet())
{
+ try {
+ // unpack the resource adapter archive
+ File rarFile = new File(entry.getValue().getPath());
+ rarFile = unpack(rarFile);
+ entry.setValue(rarFile.toURL());
+
+ scanDir(appDir, rarLibs, "");
+ } catch (MalformedURLException e) {
+ throw new OpenEJBException("Malformed URL to app. " +
e.getMessage(), e);
+ }
+ }
+ for (Iterator<Map.Entry<String, URL>> iterator =
rarLibs.entrySet().iterator(); iterator.hasNext();) {
+ // remove all non jars from the rarLibs
+ Map.Entry<String, URL> fileEntry = iterator.next();
+ if (!fileEntry.getKey().endsWith(".jar")) continue;
+ iterator.remove();
+ }
+
List<URL> classPath = new ArrayList<URL>();
classPath.addAll(ejbModules.values());
classPath.addAll(clientModules.values());
+ classPath.addAll(rarLibs.values());
classPath.addAll(extraLibs);
URL[] urls = classPath.toArray(new URL[]{});
ClassLoader appClassLoader = new TemporaryClassLoader(urls,
OpenEJB.class.getClassLoader());
+ //
+ // Create the AppModule and all nested module objects
+ //
+
AppModule appModule = new AppModule(appClassLoader,
appDir.getAbsolutePath());
appModule.getAdditionalLibraries().addAll(extraLibs);
appModule.getAltDDs().putAll(appDescriptors);
+ // EJB modules
for (String moduleName : ejbModules.keySet()) {
try {
URL ejbUrl = ejbModules.get(moduleName);
@@ -197,6 +248,8 @@
logger.error("Unable to load EJBs from EAR: " +
appDir.getAbsolutePath() + ", module: " + moduleName + ". Exception: " +
e.getMessage(), e);
}
}
+
+ // Application Client Modules
for (String moduleName : clientModules.keySet()) {
try {
URL clientUrl = clientModules.get(moduleName);
@@ -225,16 +278,81 @@
}
}
- //
- // Persistence Units
- try {
- ResourceFinder finder1 = new ResourceFinder("",
appClassLoader, urls);
- List<URL> persistenceUrls =
finder1.findAll("META-INF/persistence.xml");
- appModule.getAltDDs().put("persistence.xml",
persistenceUrls);
- } catch (IOException e1) {
- logger.warning("Cannot load persistence-units from
'META-INF/persistence.xml' : " + e1.getMessage(), e1);
+ // Resource modules
+ for (String moduleName : resouceModules.keySet()) {
+ try {
+ URL rarUrl = resouceModules.get(moduleName);
+ File rarFile = new File(rarUrl.getPath());
+
+ Map<String, URL> descriptors = getDescriptors(rarUrl);
+
+ Connector connector = null;
+ if (descriptors.containsKey("ra.xml")){
+ connector =
ReadDescriptors.readConnector(descriptors.get("ra.xml"));
+ }
+
+ ResourceModule resourceModule = new
ResourceModule(connector, appClassLoader, rarFile.getAbsolutePath(),
moduleName);
+
+ resourceModule.getAltDDs().putAll(descriptors);
+
+ appModule.getResourceModules().add(resourceModule);
+ } catch (OpenEJBException e) {
+ logger.error("Unable to load RAR: " +
appDir.getAbsolutePath() + ", module: " + moduleName + ". Exception: " +
e.getMessage(), e);
+ }
}
+ // Web modules
+ for (String moduleName : webModules.keySet()) {
+ try {
+ URL warUrl = webModules.get(moduleName);
+ File warFile = new File(warUrl.getPath());
+
+ // read web.xml file
+ Map<String, URL> descriptors = getDescriptors(warUrl);
+ WebApp webApp = null;
+ if (descriptors.containsKey("web.xml")){
+ webApp =
ReadDescriptors.readWebApp(descriptors.get("web.xml"));
+ }
+
+ // determine war class path
+ List<URL> webClassPath = new ArrayList<URL>();
+ File webInfDir = new File(warFile, "WEB-INF");
+ try {
+ webClassPath.add(new File(webInfDir,
"classes").toURL());
+ } catch (MalformedURLException e) {
+ logger.warning("War path bad: " + new
File(webInfDir, "classes"), e);
+ }
+
+ File libDir = new File(webInfDir, "lib");
+ if (libDir.exists()) {
+ for (File file : libDir.listFiles()) {
+ if (file.getName().endsWith(".jar") ||
file.getName().endsWith(".zip")) {
+ try {
+ webClassPath.add(file.toURL());
+ } catch (MalformedURLException e) {
+ logger.warning("War path bad: " +
file, e);
+ }
+ }
+ }
+ }
+
+ // create the class loader
+ URL[] webUrls = webClassPath.toArray(new URL[]{});
+ ClassLoader warClassLoader = new
TemporaryClassLoader(webUrls, appClassLoader);
+
+ // create web module
+ WebModule webModule = new WebModule(webApp,
webContextRoots.get(moduleName), warClassLoader, warFile.getAbsolutePath(),
moduleName);
+ webModule.getAltDDs().putAll(descriptors);
+
+ appModule.getWebModules().add(webModule);
+ } catch (OpenEJBException e) {
+ logger.error("Unable to load WAR: " +
appDir.getAbsolutePath() + ", module: " + moduleName + ". Exception: " +
e.getMessage(), e);
+ }
+ }
+
+ // Persistence Units
+ addPersistenceUnits(appModule, classLoader, urls);
+
return appModule;
} catch (OpenEJBException e) {
@@ -243,34 +361,129 @@
}
} else if (EjbModule.class.equals(moduleClass)) {
-
+ // read the ejb-jar.xml file
Map<String, URL> descriptors = getDescriptors(baseUrl);
-
EjbJar ejbJar = null;
if (descriptors.containsKey("ejb-jar.xml")){
ejbJar =
ReadDescriptors.readEjbJar(descriptors.get("ejb-jar.xml"));
}
+ // create the EJB Module
EjbModule ejbModule = new EjbModule(classLoader,
jarFile.getAbsolutePath(), ejbJar, null);
-
ejbModule.getAltDDs().putAll(descriptors);
+ // wrap the EJB Module with an Application Module
AppModule appModule = new AppModule(classLoader,
ejbModule.getJarLocation());
appModule.getEjbModules().add(ejbModule);
- //
// Persistence Units
+ addPersistenceUnits(appModule, classLoader, baseUrl);
+
+ return appModule;
+ } else if (ResourceModule.class.equals(moduleClass)) {
+ // unpack the rar file
+ File rarFile = new File(baseUrl.getPath());
+ rarFile = unpack(rarFile);
+ baseUrl = getFileUrl(rarFile);
+
+ // read the ra.xml file
+ Map<String, URL> descriptors = getDescriptors(baseUrl);
+ Connector connector = null;
+ if (descriptors.containsKey("ra.xml")){
+ connector =
ReadDescriptors.readConnector(descriptors.get("ra.xml"));
+ }
+
+ // find the nested jar files
+ HashMap<String, URL> rarLibs = new HashMap<String, URL>();
+ scanDir(rarFile, rarLibs, "");
+ for (Iterator<Map.Entry<String, URL>> iterator =
rarLibs.entrySet().iterator(); iterator.hasNext();) {
+ // remove all non jars from the rarLibs
+ Map.Entry<String, URL> fileEntry = iterator.next();
+ if (!fileEntry.getKey().endsWith(".jar")) continue;
+ iterator.remove();
+ }
+
+ // create the class loader
+ List<URL> classPath = new ArrayList<URL>();
+ classPath.addAll(rarLibs.values());
+ URL[] urls = classPath.toArray(new URL[]{});
+ ClassLoader appClassLoader = new TemporaryClassLoader(urls,
OpenEJB.class.getClassLoader());
+
+ // create the Resource Module
+ ResourceModule resourceModule = new ResourceModule(connector,
appClassLoader, jarFile.getAbsolutePath(), null);
+ resourceModule.getAltDDs().putAll(descriptors);
+
+ // Wrap the resource module with an Application Module
+ AppModule appModule = new AppModule(classLoader,
resourceModule.getJarLocation());
+ appModule.getResourceModules().add(resourceModule);
+
+ // Persistence Units
+ addPersistenceUnits(appModule, classLoader, baseUrl);
+
+ return appModule;
+ } else if (WebModule.class.equals(moduleClass)) {
+ // unpack the rar file
+ File warFile = new File(baseUrl.getPath());
+ warFile = unpack(warFile);
+ baseUrl = getFileUrl(warFile);
+
+ // read the web.xml file
+ Map<String, URL> descriptors = getDescriptors(baseUrl);
+ WebApp webApp = null;
+ if (descriptors.containsKey("web.xml")){
+ webApp =
ReadDescriptors.readWebApp(descriptors.get("web.xml"));
+ }
+
+ // determine war class path
+ List<URL> classPath = new ArrayList<URL>();
+ File webInfDir = new File(warFile, "WEB-INF");
try {
- ResourceFinder finder = new ResourceFinder("", classLoader,
baseUrl);
- List<URL> persistenceUrls =
finder.findAll("META-INF/persistence.xml");
- appModule.getAltDDs().put("persistence.xml", persistenceUrls);
- } catch (IOException e) {
- logger.warning("Cannot load persistence-units from
'META-INF/persistence.xml' : " + e.getMessage(), e);
+ classPath.add(new File(webInfDir, "classes").toURL());
+ } catch (MalformedURLException e) {
+ logger.warning("War path bad: " + new File(webInfDir,
"classes"), e);
}
+ File libDir = new File(webInfDir, "lib");
+ if (libDir.exists()) {
+ for (File file : libDir.listFiles()) {
+ if (file.getName().endsWith(".jar") ||
file.getName().endsWith(".zip")) {
+ try {
+ classPath.add(file.toURL());
+ } catch (MalformedURLException e) {
+ logger.warning("War path bad: " + file, e);
+ }
+ }
+ }
+ }
+
+ // create the class loader
+ URL[] urls = classPath.toArray(new URL[]{});
+ ClassLoader appClassLoader = new TemporaryClassLoader(urls,
OpenEJB.class.getClassLoader());
+
+ // create the Resource Module
+ WebModule webModule = new WebModule(webApp, null, appClassLoader,
jarFile.getAbsolutePath(), null);
+ webModule.getAltDDs().putAll(descriptors);
+
+ // Wrap the resource module with an Application Module
+ AppModule appModule = new AppModule(classLoader,
webModule.getJarLocation());
+ appModule.getWebModules().add(webModule);
+
+ // Persistence Units
+ addPersistenceUnits(appModule, classLoader, baseUrl);
+
return appModule;
} else {
throw new UnsupportedModuleTypeException("Unsupported module type:
"+moduleClass.getSimpleName());
+ }
+ }
+
+ private void addPersistenceUnits(AppModule appModule, ClassLoader
classLoader, URL... urls) {
+ try {
+ ResourceFinder finder = new ResourceFinder("", classLoader, urls);
+ List<URL> persistenceUrls =
finder.findAll("META-INF/persistence.xml");
+ appModule.getAltDDs().put("persistence.xml", persistenceUrls);
+ } catch (IOException e) {
+ logger.warning("Cannot load persistence-units from
'META-INF/persistence.xml' : " + e.getMessage(), e);
}
}
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java?rev=575989&r1=575988&r2=575989&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
Sat Sep 15 14:42:45 2007
@@ -20,9 +20,18 @@
import org.apache.openejb.jee.ApplicationClient;
import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.JaxbJavaee;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.jee.Connector;
import org.apache.openejb.jee.jpa.unit.JaxbPersistenceFactory;
import org.apache.openejb.jee.jpa.unit.Persistence;
-import org.apache.openejb.jee.oejb2.*;
+import org.apache.openejb.jee.oejb2.EnterpriseBean;
+import org.apache.openejb.jee.oejb2.GeronimoEjbJarType;
+import org.apache.openejb.jee.oejb2.JaxbOpenejbJar2;
+import org.apache.openejb.jee.oejb2.OpenejbJarType;
+import org.apache.openejb.jee.oejb2.RpcBean;
+import org.apache.openejb.jee.oejb2.SessionBeanType;
+import org.apache.openejb.jee.oejb2.TssLinkType;
+import org.apache.openejb.jee.oejb2.WebServiceBindingType;
import org.apache.openejb.jee.oejb3.JaxbOpenejbJar3;
import org.apache.openejb.jee.oejb3.OpenejbJar;
import org.xml.sax.SAXException;
@@ -61,6 +70,14 @@
readAppClient(clientModule, appModule);
}
+ for (ResourceModule resourceModule : appModule.getResourceModules()) {
+ readConnector(resourceModule, appModule);
+ }
+
+ for (WebModule webModule : appModule.getWebModules()) {
+ readWebApp(webModule, appModule);
+ }
+
List<URL> persistenceUrls = (List<URL>)
appModule.getAltDDs().get("persistence.xml");
if (persistenceUrls != null) {
for (URL url1 : persistenceUrls) {
@@ -259,6 +276,38 @@
}
}
+ private void readConnector(ResourceModule resourceModule, AppModule
appModule) throws OpenEJBException {
+ if (resourceModule.getConnector() != null) return;
+
+ Object data = resourceModule.getAltDDs().get("ra.xml");
+ if (data instanceof Connector) {
+ resourceModule.setConnector((Connector) data);
+ } else if (data instanceof URL) {
+ URL url = (URL) data;
+ Connector connector = readConnector(url);
+ resourceModule.setConnector(connector);
+ } else {
+ DeploymentLoader.logger.debug("No ra.xml found assuming annotated
beans present: " + appModule.getJarLocation() + ", module: " +
resourceModule.getModuleId());
+ resourceModule.setConnector(new Connector());
+ }
+ }
+
+ private void readWebApp(WebModule webModule, AppModule appModule) throws
OpenEJBException {
+ if (webModule.getWebApp() != null) return;
+
+ Object data = webModule.getAltDDs().get("web.xml");
+ if (data instanceof WebApp) {
+ webModule.setWebApp((WebApp) data);
+ } else if (data instanceof URL) {
+ URL url = (URL) data;
+ WebApp webApp = readWebApp(url);
+ webModule.setWebApp(webApp);
+ } else {
+ DeploymentLoader.logger.debug("No web.xml found assuming annotated
beans present: " + appModule.getJarLocation() + ", module: " +
webModule.getModuleId());
+ webModule.setWebApp(new WebApp());
+ }
+ }
+
public static ApplicationClient readApplicationClient(URL url) throws
OpenEJBException {
ApplicationClient applicationClient;
try {
@@ -289,6 +338,38 @@
throw new OpenEJBException("Encountered unknown error parsing the
ejb-jar.xml file: " + url.toExternalForm(), e);
}
return ejbJar;
+ }
+
+ public static Connector readConnector(URL url) throws OpenEJBException {
+ Connector connector = null;
+ try {
+ connector = (Connector) JaxbJavaee.unmarshal(Connector.class,
url.openStream());
+ } catch (SAXException e) {
+ throw new OpenEJBException("Cannot parse the web.xml file: " +
url.toExternalForm(), e);
+ } catch (JAXBException e) {
+ throw new OpenEJBException("Cannot unmarshall the web.xml file: "
+ url.toExternalForm(), e);
+ } catch (IOException e) {
+ throw new OpenEJBException("Cannot read the web.xml file: " +
url.toExternalForm(), e);
+ } catch (Exception e) {
+ throw new OpenEJBException("Encountered unknown error parsing the
web.xml file: " + url.toExternalForm(), e);
+ }
+ return connector;
+ }
+
+ public static WebApp readWebApp(URL url) throws OpenEJBException {
+ WebApp webApp = null;
+ try {
+ webApp = (WebApp) JaxbJavaee.unmarshal(WebApp.class,
url.openStream());
+ } catch (SAXException e) {
+ throw new OpenEJBException("Cannot parse the web.xml file: " +
url.toExternalForm(), e);
+ } catch (JAXBException e) {
+ throw new OpenEJBException("Cannot unmarshall the web.xml file: "
+ url.toExternalForm(), e);
+ } catch (IOException e) {
+ throw new OpenEJBException("Cannot read the web.xml file: " +
url.toExternalForm(), e);
+ } catch (Exception e) {
+ throw new OpenEJBException("Encountered unknown error parsing the
web.xml file: " + url.toExternalForm(), e);
+ }
+ return webApp;
}
private Source getSource(Object o) {
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ResourceModule.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ResourceModule.java?rev=575989&r1=575988&r2=575989&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ResourceModule.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ResourceModule.java
Sat Sep 15 14:42:45 2007
@@ -16,29 +16,75 @@
*/
package org.apache.openejb.config;
+import org.apache.openejb.jee.Connector;
+
+import java.io.File;
+import java.util.HashMap;
import java.util.Map;
/**
* @version $Rev$ $Date$
*/
public class ResourceModule implements DeploymentModule {
+ private final ValidationContext validation;
+ private final Map<String,Object> altDDs = new HashMap<String,Object>();
+
+ private Connector connector;
+ private ClassLoader classLoader;
+ private String jarLocation;
+ private final String moduleId;
+
+ public ResourceModule(Connector connector, ClassLoader classLoader, String
jarLocation, String moduleId) {
+ this.connector = connector;
+ this.classLoader = classLoader;
+ this.jarLocation = jarLocation;
+
+ if (moduleId == null){
+ if (connector != null && connector.getId() != null){
+ moduleId = connector.getId();
+ } else {
+ File file = new File(jarLocation);
+ moduleId = file.getName();
+ }
+ }
+
+ this.moduleId = moduleId;
+ validation = new ValidationContext(ResourceModule.class, jarLocation);
+ }
+
+ public ValidationContext getValidation() {
+ return validation;
+ }
+
public String getModuleId() {
- throw new UnsupportedOperationException();
+ return moduleId;
}
public Map<String, Object> getAltDDs() {
- throw new UnsupportedOperationException();
+ return altDDs;
+ }
+
+ public Connector getConnector() {
+ return connector;
+ }
+
+ public void setConnector(Connector connector) {
+ this.connector = connector;
}
public ClassLoader getClassLoader() {
- throw new UnsupportedOperationException();
+ return classLoader;
+ }
+
+ public void setClassLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
}
public String getJarLocation() {
- throw new UnsupportedOperationException();
+ return jarLocation;
}
- public ValidationContext getValidation() {
- throw new UnsupportedOperationException();
+ public void setJarLocation(String jarLocation) {
+ this.jarLocation = jarLocation;
}
}
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java?rev=575989&r1=575988&r2=575989&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java
Sat Sep 15 14:42:45 2007
@@ -16,29 +16,85 @@
*/
package org.apache.openejb.config;
+import org.apache.openejb.jee.WebApp;
+
import java.util.Map;
+import java.util.HashMap;
+import java.io.File;
/**
* @version $Rev$ $Date$
*/
public class WebModule implements DeploymentModule {
+ private final ValidationContext validation;
+ private final Map<String,Object> altDDs = new HashMap<String,Object>();
+
+ private WebApp webApp;
+ private String contextRoot;
+ private ClassLoader classLoader;
+ private String jarLocation;
+ private final String moduleId;
+
+ public WebModule(WebApp webApp, String contextRoot, ClassLoader
classLoader, String jarLocation, String moduleId) {
+ this.webApp = webApp;
+ this.contextRoot = contextRoot;
+ this.classLoader = classLoader;
+ this.jarLocation = jarLocation;
+
+ if (moduleId == null){
+ if (webApp != null && webApp.getId() != null){
+ moduleId = webApp.getId();
+ } else {
+ File file = new File(jarLocation);
+ moduleId = file.getName();
+ }
+ }
+
+ this.moduleId = moduleId;
+ validation = new ValidationContext(WebModule.class, jarLocation);
+ }
+
+ public ValidationContext getValidation() {
+ return validation;
+ }
+
public String getModuleId() {
- throw new UnsupportedOperationException();
+ return moduleId;
}
public Map<String, Object> getAltDDs() {
- throw new UnsupportedOperationException();
+ return altDDs;
}
+ public WebApp getWebApp() {
+ return webApp;
+ }
+
+ public void setWebApp(WebApp webApp) {
+ this.webApp = webApp;
+ }
public ClassLoader getClassLoader() {
- throw new UnsupportedOperationException();
+ return classLoader;
+ }
+
+ public void setClassLoader(ClassLoader classLoader) {
+ this.classLoader = classLoader;
}
public String getJarLocation() {
- throw new UnsupportedOperationException();
+ return jarLocation;
}
- public ValidationContext getValidation() {
- throw new UnsupportedOperationException();
+ public void setJarLocation(String jarLocation) {
+ this.jarLocation = jarLocation;
+ }
+
+
+ public String getContextRoot() {
+ return contextRoot;
+ }
+
+ public void setContextRoot(String contextRoot) {
+ this.contextRoot = contextRoot;
}
}