You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2007/10/16 06:39:10 UTC
svn commit: r585036 [2/7] - in /openejb/trunk/openejb3: ./
assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/
container/openejb-core/src/main/java/org/apache/openejb/assembler/
container/openejb-core/src/main/java/org/apache/openejb/assem...
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=585036&r1=585035&r2=585036&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 Mon Oct 15 21:38:53 2007
@@ -27,11 +27,15 @@
import org.apache.openejb.jee.ApplicationClient;
import org.apache.openejb.jee.Connector;
import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.jee.JspConfig;
+import org.apache.openejb.jee.Taglib;
+import org.apache.openejb.jee.TldTaglib;
import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;
import org.apache.openejb.util.Messages;
import org.apache.xbean.finder.ClassFinder;
import org.apache.xbean.finder.ResourceFinder;
+import org.apache.xbean.finder.UrlSet;
import org.xml.sax.SAXException;
import javax.ejb.Stateful;
@@ -42,13 +46,22 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Iterator;
+import java.util.TreeMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+import java.util.Arrays;
+import java.util.LinkedList;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
/**
* @version $Revision$ $Date$
@@ -282,18 +295,7 @@
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"));
- }
-
- ConnectorModule connectorModule = new ConnectorModule(connector, appClassLoader, rarFile.getAbsolutePath(), moduleName);
-
- connectorModule.getAltDDs().putAll(descriptors);
+ ConnectorModule connectorModule = createConnectorModule(rarUrl.getPath(), appClassLoader, moduleName);
appModule.getResourceModules().add(connectorModule);
} catch (OpenEJBException e) {
@@ -305,44 +307,7 @@
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);
+ WebModule webModule = createWebModule(warUrl.getPath(), appClassLoader, webContextRoots.get(moduleName), moduleName);
appModule.getWebModules().add(webModule);
} catch (OpenEJBException e) {
@@ -381,100 +346,290 @@
return appModule;
} else if (ConnectorModule.class.equals(moduleClass)) {
+ ConnectorModule connectorModule = createConnectorModule(baseUrl.getPath(), OpenEJB.class.getClassLoader(), null);
+
+ // Wrap the resource module with an Application Module
+ AppModule appModule = new AppModule(classLoader, connectorModule.getJarLocation());
+ appModule.getResourceModules().add(connectorModule);
+
+ return appModule;
+ } else if (WebModule.class.equals(moduleClass)) {
// unpack the rar file
- File rarFile = new File(baseUrl.getPath());
- rarFile = unpack(rarFile);
- baseUrl = getFileUrl(rarFile);
+ String moduleId = new File(baseUrl.getPath()).getName();
+ WebModule webModule = createWebModule(baseUrl.getPath(), OpenEJB.class.getClassLoader(), null, moduleId);
- // 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"));
+ // Wrap the resource module with an Application Module
+ AppModule appModule = new AppModule(classLoader, webModule.getJarLocation());
+ appModule.getWebModules().add(webModule);
+
+ // Persistence Units
+ addPersistenceUnits(appModule, classLoader);
+
+ return appModule;
+ } else {
+ throw new UnsupportedModuleTypeException("Unsupported module type: "+moduleClass.getSimpleName());
+ }
+ }
+
+ private WebModule createWebModule(String warPath, ClassLoader parentClassLoader, String contextRoot, String moduleName) throws OpenEJBException {
+ File warFile = new File(warPath);
+ warFile = unpack(warFile);
+
+ // read web.xml file
+ Map<String, URL> descriptors = null;
+ try {
+ descriptors = getWebDescriptors(warFile);
+ } catch (IOException e) {
+ throw new OpenEJBException("Unable to determine descriptors in jar.", e);
+ }
+
+ WebApp webApp = null;
+ if (descriptors.containsKey("web.xml")){
+ webApp = ReadDescriptors.readWebApp(descriptors.get("web.xml"));
+ }
+
+ // if this is a standalone module (no-context root), and webApp.getId is set then that is the module name
+ if (contextRoot == null && webApp != null && webApp.getId() != null) {
+ moduleName = webApp.getId();
+ }
+
+ // 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);
+ }
+ }
}
+ }
- // 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
+ URL[] webUrls = webClassPath.toArray(new URL[]{});
+ ClassLoader warClassLoader = new TemporaryClassLoader(webUrls, parentClassLoader);
+
+ // create web module
+ WebModule webModule = new WebModule(webApp, contextRoot, warClassLoader, warFile.getAbsolutePath(), moduleName);
+ webModule.getAltDDs().putAll(descriptors);
+
+ // find all tag libs
+ addTagLibraries(webModule);
+
+ return webModule;
+ }
+
+ private void addTagLibraries(WebModule webModule) throws OpenEJBException {
+ Set<URL> tldLocations = new HashSet<URL>();
+
+ // web.xml contains tag lib locations in nested jsp config elements
+ File warFile = new File(webModule.getJarLocation());
+ WebApp webApp = webModule.getWebApp();
+ if (webApp != null) {
+ for (JspConfig jspConfig : webApp.getJspConfig()) {
+ for (Taglib taglib : jspConfig.getTaglib()) {
+ String location = taglib.getTaglibLocation();
+ if (!location.startsWith("/")) {
+ // this reproduces a tomcat bug
+ location = "/WEB-INF/" + location;
+ }
+ try {
+ File file = new File(warFile, location).getCanonicalFile().getAbsoluteFile();
+ if (location.endsWith(".jar")) {
+ URL url = file.toURL();
+ tldLocations.add(url);
+ } else {
+ Set<URL> urls = scanJarForTagLibs(file);
+ tldLocations.addAll(urls);
+ }
+ } catch (IOException e) {
+ logger.warning("JSP tag library location bad: " + location, e);
+ }
+ }
}
+ }
- // 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
- ConnectorModule connectorModule = new ConnectorModule(connector, appClassLoader, jarFile.getAbsolutePath(), null);
- connectorModule.getAltDDs().putAll(descriptors);
+ // WEB-INF/**/*.tld except in WEB-INF/classes and WEB-INF/lib
+ Set<URL> urls = scanWarForTagLibs(warFile);
+ tldLocations.addAll(urls);
+
+ // Search all libs
+ ClassLoader parentClassLoader = webModule.getClassLoader().getParent();
+ urls = scanClassLoaderForTagLibs(parentClassLoader);
+ tldLocations.addAll(urls);
+
+ // load the tld files
+ for (URL location : tldLocations) {
+ TldTaglib taglib = ReadDescriptors.readTldTaglib(location);
+ webModule.getTaglibs().add(taglib);
+ }
+ }
- // Wrap the resource module with an Application Module
- AppModule appModule = new AppModule(classLoader, connectorModule.getJarLocation());
- appModule.getResourceModules().add(connectorModule);
+ private Set<URL> scanClassLoaderForTagLibs(ClassLoader parentClassLoader) throws OpenEJBException {
+ Set<URL> urls = new HashSet<URL>();
+ if (parentClassLoader == null) return urls;
- // Persistence Units
- addPersistenceUnits(appModule, classLoader, baseUrl);
+ UrlSet urlSet = null;
+ try {
+ urlSet = new UrlSet(parentClassLoader);
+ urlSet = urlSet.excludeJavaEndorsedDirs();
+ urlSet = urlSet.excludeJavaExtDirs();
+ urlSet = urlSet.excludeJavaHome();
+ urlSet = urlSet.exclude(ClassLoader.getSystemClassLoader());
+ } catch (IOException e) {
+ logger.warning("Error scanning class loader for JSP tag libraries", e);
+ }
- return appModule;
- } else if (WebModule.class.equals(moduleClass)) {
- // unpack the rar file
- File warFile = new File(baseUrl.getPath());
- warFile = unpack(warFile);
- baseUrl = getFileUrl(warFile);
+ for (URL url : urlSet.getUrls()) {
+ if (url.getProtocol().equals("jar")) {
+ try {
+ String path = url.getPath();
+ if (path.endsWith("!/")) {
+ path = path.substring(0, path.length() - 2);
+ }
+ url = new URL(path);
+ } catch (MalformedURLException e) {
+ logger.warning("JSP tag library location bad: " + url.toExternalForm(), e);
+ continue;
+ }
+ }
- // 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"));
+ if (!url.getProtocol().equals("file")) {
+ continue;
}
- // determine war class path
- List<URL> classPath = new ArrayList<URL>();
- File webInfDir = new File(warFile, "WEB-INF");
+ File file;
try {
- classPath.add(new File(webInfDir, "classes").toURL());
- } catch (MalformedURLException e) {
- logger.warning("War path bad: " + new File(webInfDir, "classes"), e);
+ file = new File(url.toURI());
+ } catch (URISyntaxException e) {
+ // Ignore, probably an unencoded char
+ file = new File(url.getFile());
+ }
+ try {
+ file = file.getCanonicalFile().getAbsoluteFile();
+ } catch (IOException e) {
+ logger.warning("JSP tag library location bad: " + file.getAbsolutePath(), e);
+ continue;
}
- 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);
- }
- }
+ urls.addAll(scanJarForTagLibs(file));
+ }
+ return urls;
+ }
+
+ private static Set<URL> scanWarForTagLibs(File war) {
+ Set<URL> urls = new HashSet<URL>();
+
+ File webInfDir = new File(war, "WEB-INF");
+ if (!webInfDir.isDirectory()) return urls;
+
+
+ // skip the lib and classes dir in WEB-INF
+ LinkedList<File> files = new LinkedList<File>();
+ for (File file : webInfDir.listFiles()) {
+ if ("lib".equals(file.getName()) || "classes".equals(file.getName())) {
+ continue;
+ }
+ files.add(file);
+ }
+
+ if (files.isEmpty()) return urls;
+
+ // recursively scan the directories
+ while(!files.isEmpty()) {
+ File file = files.removeFirst();
+ if (file.isDirectory()) {
+ files.addAll(Arrays.asList(file.listFiles()));
+ } else if (file.getName().endsWith(".tld")) {
+ try {
+ file = file.getCanonicalFile().getAbsoluteFile();
+ urls.add(file.toURL());
+ } catch (IOException e) {
+ logger.warning("JSP tag library location bad: " + file.getAbsolutePath(), 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);
+ return urls;
+ }
- // Wrap the resource module with an Application Module
- AppModule appModule = new AppModule(classLoader, webModule.getJarLocation());
- appModule.getWebModules().add(webModule);
+ private static Set<URL> scanJarForTagLibs(File file) {
+ Set<URL> urls = new HashSet<URL>();
- // Persistence Units
- addPersistenceUnits(appModule, classLoader, baseUrl);
+ if (!file.isFile()) return urls;
- return appModule;
- } else {
- throw new UnsupportedModuleTypeException("Unsupported module type: "+moduleClass.getSimpleName());
+ JarFile jarFile = null;
+ try {
+ jarFile = new JarFile(file);
+
+ URL jarFileUrl = new URL("jar", "", -1, file.toURL().toExternalForm() + "!/");
+ for (JarEntry entry : Collections.list(jarFile.entries())) {
+ String name = entry.getName();
+ if (!name.startsWith("META-INF/") || !name.endsWith(".tld")) {
+ continue;
+ }
+ URL url = new URL(jarFileUrl, name);
+ urls.add(url);
+ }
+ } catch (IOException e) {
+ logger.warning("Error scanning jar for JSP tag libraries: " + file.getAbsolutePath(), e);
+ } finally {
+ if (jarFile != null) {
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ }
+ }
}
+
+ return urls;
+ }
+
+ private ConnectorModule createConnectorModule(String rarPath, ClassLoader parentClassLoader, String moduleId) throws OpenEJBException {
+ URL baseUrl;// unpack the rar file
+ File rarFile = new File(rarPath);
+ 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")) {
+ 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, parentClassLoader);
+
+ // create the Resource Module
+ ConnectorModule connectorModule = new ConnectorModule(connector, appClassLoader, rarPath, moduleId);
+ connectorModule.getAltDDs().putAll(descriptors);
+ connectorModule.getLibraries().addAll(classPath);
+ return connectorModule;
}
private void addPersistenceUnits(AppModule appModule, ClassLoader classLoader, URL... urls) {
@@ -498,6 +653,62 @@
}
}
+ private static Map<String, URL> getWebDescriptors(File warFile) throws IOException {
+ Map<String, URL> descriptors = new TreeMap<String,URL>();
+
+ // xbean resource finder has a bug when you use any uri but "META-INF"
+ // and the jar file does not contain a directory entry for the uri
+
+ if (warFile.isFile()) {
+ URL jarURL = new URL("jar", "", -1, warFile.toURL() + "!/");
+ try {
+ JarFile jarFile = new JarFile(warFile);
+ for (JarEntry entry : Collections.list(jarFile.entries())) {
+ String entryName = entry.getName();
+ if (!entry.isDirectory() && entryName.startsWith("WEB-INF/") && entryName.indexOf('/', "WEB-INF/".length()) > 0) {
+ descriptors.put(entryName, new URL(jarURL, entry.getName()));
+ }
+ }
+ } catch (IOException e) {
+ // most likely an invalid jar file
+ }
+ } else if (warFile.isDirectory()) {
+ File webInfDir = new File(warFile, "WEB-INF");
+ if (webInfDir.isDirectory()) {
+ for (File file : webInfDir.listFiles()) {
+ if (!file.isDirectory()) {
+ descriptors.put(file.getName(), file.toURL());
+ }
+ }
+ }
+ }
+
+ return descriptors;
+ }
+
+ private static File getFile(URL warUrl) {
+ if ("jar".equals(warUrl.getProtocol())) {
+ String pathname = warUrl.getPath();
+
+ // we only support file based jar urls
+ if (!pathname .startsWith("file:")) {
+ return null;
+ }
+
+ // strip off "file:"
+ pathname = pathname.substring("file:".length());
+
+ // file path has trailing !/ that must be stripped off
+ pathname = pathname.substring(0, pathname.lastIndexOf('!'));
+ return new File(pathname);
+ } else if ("file".equals(warUrl.getProtocol())) {
+ String pathname = warUrl.getPath();
+ return new File(pathname);
+ } else {
+ return null;
+ }
+ }
+
@SuppressWarnings({"unchecked"})
public static <T>T unmarshal(Class<T> type, String descriptor, URL url) throws OpenEJBException {
try {
@@ -546,10 +757,15 @@
return ClientModule.class;
}
- if (descriptors.containsKey("ra.xml")) {
+ if (descriptors.containsKey("ra.xml") || baseUrl.getPath().endsWith(".rar")) {
return ConnectorModule.class;
}
+ Map<String, URL> webDescriptors = getWebDescriptors(getFile(baseUrl));
+ if (webDescriptors.containsKey("web.xml") || baseUrl.getPath().endsWith(".war")) {
+ return WebModule.class;
+ }
+
URL manifestUrl = descriptors.get("MANIFEST.MF");
if (manifestUrl != null) {
InputStream is = manifestUrl.openStream();
@@ -579,15 +795,14 @@
}
String name = jarFile.getName();
- if (name.endsWith(".jar") || name.endsWith(".ear") || name.endsWith(".zip")) {
+ if (name.endsWith(".jar") || name.endsWith(".ear") || name.endsWith(".zip") || name.endsWith(".war") || name.endsWith(".rar")) {
name = name.replaceFirst("....$", "");
} else {
- name += "_app";
+ name += ".unpacked";
}
try {
- URL jarUrl = new URL("jar", "", jarFile.toURL().toExternalForm() + "!/");
- return JarExtractor.extract(jarUrl, name, jarFile);
+ return JarExtractor.extract(jarFile, name);
} catch (IOException e) {
throw new OpenEJBException("Unable to extract jar. " + e.getMessage(), e);
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java Mon Oct 15 21:38:53 2007
@@ -97,7 +97,7 @@
////////////////////////////////
boolean hasNestedArchives = false;
for (File file : dir.listFiles()) {
- if (file.getName().endsWith(".jar") || file.getName().endsWith(".ear")) {
+ if (file.getName().endsWith(".jar") || file.getName().endsWith(".war")|| file.getName().endsWith(".rar")|| file.getName().endsWith(".ear")) {
if (jarList.contains(file.getAbsolutePath())) continue;
jarList.add(file.getAbsolutePath());
hasNestedArchives = true;
@@ -174,10 +174,8 @@
*/
private static void loadFromClasspath(FileUtils base, List<String> jarList, ClassLoader classLoader) {
- Deployments deployment = null;
String include = null;
String exclude = null;
- String path = null;
include = SystemInstance.get().getProperty(CLASSPATH_INCLUDE, "");
exclude = SystemInstance.get().getProperty(CLASSPATH_EXCLUDE, ".*");
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EnvEntriesPropertiesDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EnvEntriesPropertiesDeployer.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EnvEntriesPropertiesDeployer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EnvEntriesPropertiesDeployer.java Mon Oct 15 21:38:53 2007
@@ -51,10 +51,10 @@
}
}
-// // WebModule META-INF/env-entries.properties
-// for (WebModule webModule : appModule.getWebModules()) {
-// deploy(webModule);
-// }
+ // WebModule META-INF/env-entries.properties
+ for (WebModule webModule : appModule.getWebModules()) {
+ deploy(webModule);
+ }
// Resource Adapters do not have an ENC
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JarExtractor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JarExtractor.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JarExtractor.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JarExtractor.java Mon Oct 15 21:38:53 2007
@@ -16,21 +16,16 @@
*/
package org.apache.openejb.config;
-import org.apache.openejb.loader.FileUtils;
-import org.apache.openejb.loader.SystemInstance;
-
+import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.BufferedOutputStream;
-import java.net.URL;
-import java.net.JarURLConnection;
-import java.util.jar.JarFile;
-import java.util.jar.JarEntry;
-import java.util.Enumeration;
+import java.io.IOException;
+import java.io.InputStream;
import java.nio.channels.FileChannel;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
/**
* @version $Rev$ $Date$
@@ -38,19 +33,17 @@
public class JarExtractor {
/**
- * Extract the WAR file found at the specified URL into an unpacked
+ * Extract the Jar file into an unpacked
* directory structure, and return the absolute pathname to the extracted
* directory.
*
- * @param jar URL of the web application archive to be extracted
- * (must start with "jar:")
+ * @param file Jar file to unpack
* @param pathname Context path name for web application
- * @param file
* @throws IllegalArgumentException if this is not a "jar:" URL
* @throws java.io.IOException if an input/output error was encountered
* during expansion
*/
- public static File extract(URL jar, String pathname, File file)
+ public static File extract(File file, String pathname)
throws IOException {
File docBase = new File(file.getParentFile(), pathname);
@@ -65,12 +58,10 @@
docBase.mkdir();
// Extract the JAR into the new directory
- JarURLConnection jarURLConnection = (JarURLConnection) jar.openConnection();
- jarURLConnection.setUseCaches(false);
JarFile jarFile = null;
InputStream input = null;
try {
- jarFile = jarURLConnection.getJarFile();
+ jarFile = new JarFile(file);
Enumeration jarEntries = jarFile.entries();
while (jarEntries.hasMoreElements()) {
JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
@@ -105,7 +96,6 @@
try {
input.close();
} catch (Throwable t) {
- ;
}
input = null;
}
@@ -113,7 +103,6 @@
try {
jarFile.close();
} catch (Throwable t) {
- ;
}
jarFile = null;
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java Mon Oct 15 21:38:53 2007
@@ -204,9 +204,6 @@
/* Build Environment entries *****************/
jndi.envEntries.addAll(buildEnvEntryInfos(jndiConsumer));
- // URLs resource references become env entried
- jndi.envEntries.addAll(buildUrlRefInfos(jndiConsumer));
-
/* Build Resource References *****************/
jndi.resourceRefs.addAll(buildResourceRefInfos(jndiConsumer));
@@ -410,11 +407,6 @@
private List<ResourceReferenceInfo> buildResourceRefInfos(JndiConsumer item) {
List<ResourceReferenceInfo> infos = new ArrayList<ResourceReferenceInfo>();
for (ResourceRef res : item.getResourceRef()) {
- // skip URLs which are converted to env entries
- if (res.getResType().equals("java.net.URL")) {
- continue;
- }
-
ResourceReferenceInfo info = new ResourceReferenceInfo();
if (res.getResAuth() != null) {
@@ -470,31 +462,6 @@
info.value = env.getEnvEntryValue();
info.location = buildLocationInfo(env);
info.targets.addAll(buildInjectionInfos(env));
- infos.add(info);
- }
- return infos;
- }
-
- private List<EnvEntryInfo> buildUrlRefInfos(JndiConsumer item) {
- List<EnvEntryInfo> infos = new ArrayList<EnvEntryInfo>();
- for (ResourceRef res : item.getResourceRef()) {
- // only process URLs
- if (!res.getResType().equals("java.net.URL")) {
- continue;
- }
-
- // ignore env entries without a mapped name
- if (res.getMappedName() == null) {
- continue;
- }
-
- EnvEntryInfo info = new EnvEntryInfo();
-
- info.name = res.getResRefName();
- info.type = res.getResType();
- info.value = res.getMappedName();
- info.location = buildLocationInfo(res);
- info.targets.addAll(buildInjectionInfos(res));
infos.add(info);
}
return infos;
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=585036&r1=585035&r2=585036&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 Mon Oct 15 21:38:53 2007
@@ -22,6 +22,7 @@
import org.apache.openejb.jee.JaxbJavaee;
import org.apache.openejb.jee.WebApp;
import org.apache.openejb.jee.Connector;
+import org.apache.openejb.jee.TldTaglib;
import org.apache.openejb.jee.jpa.unit.JaxbPersistenceFactory;
import org.apache.openejb.jee.jpa.unit.Persistence;
import org.apache.openejb.jee.oejb2.EnterpriseBean;
@@ -370,6 +371,22 @@
throw new OpenEJBException("Encountered unknown error parsing the web.xml file: " + url.toExternalForm(), e);
}
return webApp;
+ }
+
+ public static TldTaglib readTldTaglib(URL url) throws OpenEJBException {
+ TldTaglib tldTaglib = null;
+ try {
+ tldTaglib = (TldTaglib) JaxbJavaee.unmarshal(TldTaglib.class, url.openStream());
+ } catch (SAXException e) {
+ throw new OpenEJBException("Cannot parse the JSP tag library definition file: " + url.toExternalForm(), e);
+ } catch (JAXBException e) {
+ throw new OpenEJBException("Cannot unmarshall the JSP tag library definition file: " + url.toExternalForm(), e);
+ } catch (IOException e) {
+ throw new OpenEJBException("Cannot read the JSP tag library definition file: " + url.toExternalForm(), e);
+ } catch (Exception e) {
+ throw new OpenEJBException("Encountered unknown error parsing the JSP tag library definition file: " + url.toExternalForm(), e);
+ }
+ return tldTaglib;
}
private Source getSource(Object o) {
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java Mon Oct 15 21:38:53 2007
@@ -116,6 +116,7 @@
if (!TOMCAT) {
if (DEBUG) {
args = new String[]{"java",
+ "-XX:+HeapDumpOnOutOfMemoryError",
"-Xdebug",
"-Xnoagent",
"-Djava.compiler=NONE",
@@ -127,6 +128,7 @@
};
} else {
args = new String[]{"java",
+ "-XX:+HeapDumpOnOutOfMemoryError",
"-javaagent:" + javaagentJar.getAbsolutePath(),
"-jar", openejbJar.getAbsolutePath(), "start"
};
@@ -144,6 +146,7 @@
if (DEBUG) {
args = new String[] { "java",
+ "-XX:+HeapDumpOnOutOfMemoryError",
"-Xdebug",
"-Xnoagent",
"-Djava.compiler=NONE",
@@ -168,6 +171,7 @@
};
} else {
args = new String[] { "java",
+ "-XX:+HeapDumpOnOutOfMemoryError",
"-javaagent:" + javaagentJar.getAbsolutePath(),
"-Dcom.sun.management.jmxremote",
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/SunConversion.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/SunConversion.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/SunConversion.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/SunConversion.java Mon Oct 15 21:38:53 2007
@@ -35,6 +35,7 @@
import org.apache.openejb.jee.PersistenceType;
import org.apache.openejb.jee.ApplicationClient;
import org.apache.openejb.jee.JndiReference;
+import org.apache.openejb.jee.WebApp;
import org.apache.openejb.jee.jpa.Attributes;
import org.apache.openejb.jee.jpa.Basic;
import org.apache.openejb.jee.jpa.Column;
@@ -75,6 +76,7 @@
import org.apache.openejb.jee.sun.ResourceEnvRef;
import org.apache.openejb.jee.sun.MessageDestinationRef;
import org.apache.openejb.jee.sun.ResourceRef;
+import org.apache.openejb.jee.sun.SunWebApp;
//
// Note to developer: the best doc on what the sun-cmp-mappings element mean can be foudn here
@@ -90,6 +92,9 @@
for (ClientModule clientModule : appModule.getClientModules()) {
convertModule(clientModule);
}
+ for (WebModule webModule : appModule.getWebModules()) {
+ convertModule(webModule);
+ }
return appModule;
}
@@ -115,6 +120,29 @@
return null;
}
+ private SunWebApp getSunWebApp(WebModule webModule) {
+ Object altDD = webModule.getAltDDs().get("sun-web.xml");
+ if (altDD instanceof String) {
+ try {
+ altDD = JaxbSun.unmarshal(SunWebApp.class, new ByteArrayInputStream(((String)altDD).getBytes()));
+ } catch (Exception e) {
+ // todo warn about not being able to parse sun descriptor
+ }
+ }
+ if (altDD instanceof URL) {
+ try {
+ altDD = JaxbSun.unmarshal(SunWebApp.class, ((URL)altDD).openStream());
+ } catch (Exception e) {
+ e.printStackTrace();
+ // todo warn about not being able to parse sun descriptor
+ }
+ }
+ if (altDD instanceof SunWebApp) {
+ return (SunWebApp) altDD;
+ }
+ return null;
+ }
+
private SunEjbJar getSunEjbJar(EjbModule ejbModule) {
Object altDD = ejbModule.getAltDDs().get("sun-ejb-jar.xml");
if (altDD instanceof String) {
@@ -128,6 +156,7 @@
try {
altDD = JaxbSun.unmarshal(SunEjbJar.class, ((URL)altDD).openStream());
} catch (Exception e) {
+ e.printStackTrace();
// todo warn about not being able to parse sun descriptor
}
}
@@ -226,6 +255,75 @@
}
}
+ public void convertModule(WebModule webModule) {
+ if (webModule == null) {
+ return;
+ }
+
+ WebApp webApp = webModule.getWebApp();
+ if (webApp == null) {
+ return;
+ }
+ SunWebApp sunWebApp = getSunWebApp(webModule);
+ if (sunWebApp == null) {
+ return;
+ }
+
+ // map ejb-refs
+ Map<String,org.apache.openejb.jee.JndiReference> refMap = new TreeMap<String,org.apache.openejb.jee.JndiReference>();
+ refMap.putAll(webApp.getEjbRefMap());
+ refMap.putAll(webApp.getEjbLocalRefMap());
+
+ // map ejb-ref jndi name declaration to deploymentId
+ for (EjbRef ref : sunWebApp.getEjbRef()) {
+ if (ref.getJndiName() != null) {
+ String refName = ref.getEjbRefName();
+ org.apache.openejb.jee.JndiReference ejbRef = refMap.get(refName);
+ if (ejbRef == null) {
+ ejbRef = new org.apache.openejb.jee.EjbRef();
+ ejbRef.setName(refName);
+ refMap.put(refName, ejbRef);
+ webApp.getEjbRef().add((org.apache.openejb.jee.EjbRef) ejbRef);
+ }
+ ejbRef.setMappedName(ref.getJndiName());
+ }
+ }
+
+ // map resource-env-refs and message-destination-refs
+ Map<String,JndiReference> resEnvMap = new TreeMap<String,JndiReference>();
+ resEnvMap.putAll(webApp.getResourceRefMap());
+ resEnvMap.putAll(webApp.getResourceEnvRefMap());
+ resEnvMap.putAll(webApp.getMessageDestinationRefMap());
+
+ for (ResourceRef ref : sunWebApp.getResourceRef()) {
+ if (ref.getJndiName() != null) {
+ String refName = ref.getResRefName();
+ JndiReference resEnvRef = resEnvMap.get(refName);
+ if (resEnvRef != null) {
+ resEnvRef.setMappedName(ref.getJndiName());
+ }
+ }
+ }
+ for (ResourceEnvRef ref : sunWebApp.getResourceEnvRef()) {
+ if (ref.getJndiName() != null) {
+ String refName = ref.getResourceEnvRefName();
+ JndiReference resEnvRef = resEnvMap.get(refName);
+ if (resEnvRef != null) {
+ resEnvRef.setMappedName(ref.getJndiName());
+ }
+ }
+ }
+ for (MessageDestinationRef ref : sunWebApp.getMessageDestinationRef()) {
+ if (ref.getJndiName() != null) {
+ String refName = ref.getMessageDestinationRefName();
+ JndiReference resEnvRef = resEnvMap.get(refName);
+ if (resEnvRef != null) {
+ resEnvRef.setMappedName(ref.getJndiName());
+ }
+ }
+ }
+ }
+
public void convertModule(EjbModule ejbModule, EntityMappings entityMappings) {
Map<String, EntityData> entities = new TreeMap<String, EntityData>();
for (Entity entity : entityMappings.getEntity()) {
@@ -320,6 +418,12 @@
}
link.setResId(ref.getJndiName());
}
+ }
+
+ if (ejb.getMdbResourceAdapter() != null) {
+ // resource adapter id is the MDB container ID
+ String resourceAdapterId = ejb.getMdbResourceAdapter().getResourceAdapterMid();
+ deployment.setContainerId(resourceAdapterId);
}
}
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java Mon Oct 15 21:38:53 2007
@@ -161,48 +161,58 @@
List<InfoObject> infos = new ArrayList<InfoObject>();
infos.addAll(appInfo.clients);
infos.addAll(appInfo.ejbJars);
+ infos.addAll(appInfo.webApps);
+ infos.addAll(appInfo.connectors);
// if the module id is the same as the appInfo, then it is a standalone module
if (infos.size() == 1) {
InfoObject infoObject = infos.get(0);
if (infoObject instanceof ClientInfo) {
- // are client modules allowed
- if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.CAR)) {
- return null;
- }
ClientInfo clientInfo = (ClientInfo) infoObject;
- if (clientInfo.moduleId == appInfo.jarPath) {
- return new TargetModuleIDImpl(DEFAULT_TARGET, clientInfo.moduleId);
+ if (appInfo.jarPath.equals(clientInfo.codebase)) {
+ // are client modules allowed
+ if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.CAR)) {
+ return null;
+ }
+ if (clientInfo.moduleId == appInfo.jarPath) {
+ return new TargetModuleIDImpl(DEFAULT_TARGET, clientInfo.moduleId);
+ }
}
}
if (infoObject instanceof EjbJarInfo) {
- // are ejb modules allowed
- if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.EJB)) {
- return null;
- }
EjbJarInfo ejbJarInfo = (EjbJarInfo) infoObject;
- if (ejbJarInfo.moduleId == appInfo.jarPath) {
- return new TargetModuleIDImpl(DEFAULT_TARGET, ejbJarInfo.moduleId);
+ if (appInfo.jarPath.equals(ejbJarInfo.jarPath)) {
+ // are ejb modules allowed
+ if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.EJB)) {
+ return null;
+ }
+ if (ejbJarInfo.moduleId == appInfo.jarPath) {
+ return new TargetModuleIDImpl(DEFAULT_TARGET, ejbJarInfo.moduleId);
+ }
}
}
if (infoObject instanceof ConnectorInfo) {
- // are connector modules allowed
- if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.RAR)) {
- return null;
- }
ConnectorInfo connectorInfo = (ConnectorInfo) infoObject;
- if (connectorInfo.moduleId == appInfo.jarPath) {
- return new TargetModuleIDImpl(DEFAULT_TARGET, connectorInfo.moduleId);
+ if (appInfo.jarPath.equals(connectorInfo.codebase)) {
+ // are connector modules allowed
+ if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.RAR)) {
+ return null;
+ }
+ if (connectorInfo.moduleId == appInfo.jarPath) {
+ return new TargetModuleIDImpl(DEFAULT_TARGET, connectorInfo.moduleId);
+ }
}
}
if (infoObject instanceof WebAppInfo) {
- // are web app modules allowed
- if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.WAR)) {
- return null;
- }
WebAppInfo webAppInfo = (WebAppInfo) infoObject;
- if (webAppInfo.moduleId == appInfo.jarPath) {
- return new TargetModuleIDImpl(DEFAULT_TARGET, webAppInfo.moduleId);
+ if (appInfo.jarPath.equals(webAppInfo.codebase)) {
+ // are web app modules allowed
+ if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.WAR)) {
+ return null;
+ }
+ if (webAppInfo.moduleId == appInfo.jarPath) {
+ return new TargetModuleIDImpl(DEFAULT_TARGET, webAppInfo.moduleId); //todo web module
+ }
}
}
}
@@ -496,6 +506,7 @@
if (moduleId == null) throw new NullPointerException("moduleId is null");
this.target = target;
this.moduleId = moduleId;
+ if (webUrl != null && !webUrl.startsWith("http:")) webUrl = "http://localhost:8080/" + webUrl;
this.webUrl = webUrl;
}
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=585036&r1=585035&r2=585036&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 Mon Oct 15 21:38:53 2007
@@ -17,9 +17,12 @@
package org.apache.openejb.config;
import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.jee.TldTaglib;
import java.util.Map;
import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
import java.io.File;
/**
@@ -30,13 +33,25 @@
private final Map<String,Object> altDDs = new HashMap<String,Object>();
private WebApp webApp;
+ private String host;
private String contextRoot;
private ClassLoader classLoader;
private String jarLocation;
private final String moduleId;
+ private final List<TldTaglib> taglibs = new ArrayList<TldTaglib>();
public WebModule(WebApp webApp, String contextRoot, ClassLoader classLoader, String jarLocation, String moduleId) {
this.webApp = webApp;
+ if (contextRoot == null) {
+ contextRoot = jarLocation.substring(jarLocation.lastIndexOf('/'));
+ if (contextRoot.endsWith(".unpacked")) {
+ contextRoot = contextRoot.substring(0, contextRoot.length() - ".unpacked".length());
+ }
+ if (contextRoot.endsWith(".war")) {
+ contextRoot = contextRoot.substring(0, contextRoot.length() - ".war".length());
+ }
+ }
+ if (contextRoot.startsWith("/")) contextRoot = contextRoot.substring(1);
this.contextRoot = contextRoot;
this.classLoader = classLoader;
this.jarLocation = jarLocation;
@@ -47,6 +62,9 @@
} else {
File file = new File(jarLocation);
moduleId = file.getName();
+ if (moduleId.endsWith(".unpacked")) {
+ moduleId = moduleId.substring(0, moduleId.length() - ".unpacked".length());
+ }
}
}
@@ -96,5 +114,19 @@
public void setContextRoot(String contextRoot) {
this.contextRoot = contextRoot;
+ }
+
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+
+ public List<TldTaglib> getTaglibs() {
+ return taglibs;
}
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/PropertiesAdapter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/PropertiesAdapter.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/PropertiesAdapter.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/PropertiesAdapter.java Mon Oct 15 21:38:53 2007
@@ -17,17 +17,11 @@
*/
package org.apache.openejb.config.sys;
-import static org.apache.openejb.util.Join.join;
import org.apache.activemq.util.ByteArrayOutputStream;
-import org.apache.openejb.util.Join;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.io.ByteArrayInputStream;
import java.util.Properties;
-import java.util.List;
-import java.util.Collections;
-import java.util.Arrays;
-import java.util.ArrayList;
/**
* Converts a java.util.Properties object to a String in the XML file.
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ConnectorReference.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ConnectorReference.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ConnectorReference.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ConnectorReference.java Mon Oct 15 21:38:53 2007
@@ -16,11 +16,11 @@
*/
package org.apache.openejb.core;
+import org.apache.openejb.core.ivm.naming.Reference;
+
import javax.naming.NamingException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ManagedConnectionFactory;
-
-import org.apache.openejb.core.ivm.naming.Reference;
/*
This reference object is used for wrappering ManagedConnectionFactory objects that
manufacture resource specific connection factories. When the getObject( ) method is
@@ -45,10 +45,10 @@
public Object getObject() throws NamingException {
try {
- return mngedConFactory.createConnectionFactory(conMngr);
+ Object connection = mngedConFactory.createConnectionFactory(conMngr);
+ return connection;
} catch (javax.resource.ResourceException re) {
- throw (javax.naming.NamingException)(new javax.naming.NamingException("Could not create ConnectionFactory from " + mngedConFactory.getClass()).initCause(re));
+ throw (javax.naming.NamingException) (new javax.naming.NamingException("Could not create ConnectionFactory from " + mngedConFactory.getClass()).initCause(re));
}
-
}
}
Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/URLReference.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/URLReference.java?rev=585036&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/URLReference.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/URLReference.java Mon Oct 15 21:38:53 2007
@@ -0,0 +1,39 @@
+/**
+ *
+ * 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.openejb.core.ivm.naming;
+
+import javax.naming.NamingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class URLReference extends Reference {
+
+ private String url;
+
+ public URLReference(String url) {
+ this.url = url;
+ }
+
+ public Object getObject() throws NamingException {
+ try {
+ return new URL(url);
+ } catch (MalformedURLException e) {
+ throw new NamingException("Invalid URL: " + url);
+ }
+ }
+}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointFactory.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointFactory.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointFactory.java Mon Oct 15 21:38:53 2007
@@ -41,8 +41,8 @@
this.container = container;
this.deploymentInfo = deploymentInfo;
this.instanceFactory = instanceFactory;
- classLoader = deploymentInfo.getClassLoader();
- interfaces = new Class[]{deploymentInfo.getMdbInterface(), MessageEndpoint.class};
+ classLoader = container.getMessageListenerInterface().getClassLoader();
+ interfaces = new Class[]{container.getMessageListenerInterface(), MessageEndpoint.class};
}
public ActivationSpec getActivationSpec() {
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java Mon Oct 15 21:38:53 2007
@@ -96,6 +96,18 @@
return containerID;
}
+ public ResourceAdapter getResourceAdapter() {
+ return resourceAdapter;
+ }
+
+ public Class getMessageListenerInterface() {
+ return messageListenerInterface;
+ }
+
+ public Class getActivationSpecClass() {
+ return activationSpecClass;
+ }
+
public void deploy(DeploymentInfo info) throws OpenEJBException {
CoreDeploymentInfo deploymentInfo = (CoreDeploymentInfo) info;
Object deploymentId = deploymentInfo.getDeploymentID();
@@ -150,7 +162,7 @@
}
// create the activationSpec
- ActivationSpec activationSpec = (ActivationSpec) objectRecipe.create(deploymentInfo.getClassLoader());
+ ActivationSpec activationSpec = (ActivationSpec) objectRecipe.create(activationSpecClass.getClassLoader());
// verify all properties except "destination" and "destinationType" were consumed
Set<String> unusedProperties = new TreeSet<String>(objectRecipe.getUnsetProperties().keySet());
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulInstanceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulInstanceManager.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulInstanceManager.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulInstanceManager.java Mon Oct 15 21:38:53 2007
@@ -21,7 +21,6 @@
import org.apache.openejb.InvalidateReferenceException;
import org.apache.openejb.OpenEJBException;
import org.apache.openejb.SystemException;
-import org.apache.openejb.DeploymentInfo;
import org.apache.openejb.core.BaseContext;
import org.apache.openejb.core.CoreDeploymentInfo;
import org.apache.openejb.core.CoreUserTransaction;
@@ -383,6 +382,9 @@
}
public void poolInstance(ThreadContext callContext, Object bean) throws OpenEJBException {
+ // Don't pool if the bean has been undeployed
+ if (callContext.getDeploymentInfo().isDestroyed()) return;
+
Object primaryKey = callContext.getPrimaryKey();
if (primaryKey == null || bean == null) {
throw new SystemException("Invalid arguments");
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/MdbConfigTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/MdbConfigTest.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/MdbConfigTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/MdbConfigTest.java Mon Oct 15 21:38:53 2007
@@ -27,6 +27,17 @@
import org.apache.openejb.test.mdb.BasicMdbBean;
import javax.jms.MessageListener;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.InvalidPropertyException;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.ResourceException;
+import javax.transaction.xa.XAResource;
+import java.util.Properties;
/**
* @version $Rev$ $Date$
@@ -44,21 +55,31 @@
// JMS
assembler.createResource(config.configureService("Default JMS Resource Adapter", ResourceInfo.class));
- // containers
+ // JMS Container
MdbContainerInfo mdbContainerInfo = config.configureService(MdbContainerInfo.class);
assembler.createContainer(mdbContainerInfo);
- // add fake mdb container
+ // FakeRA
+ ResourceInfo resourceInfo = new ResourceInfo();
+ resourceInfo.service = "Resource";
+ resourceInfo.className = FakeRA.class.getName();
+ resourceInfo.id = "FakeRA";
+ resourceInfo.properties = new Properties();
+ assembler.createResource(resourceInfo);
+
+ // FakeRA container
ContainerInfo containerInfo = config.configureService(MdbContainerInfo.class);
containerInfo.id = "FakeContainer";
containerInfo.displayName = "Fake Container";
- containerInfo.properties.setProperty("MessageListenerInterface", "java.lang.Runnable");
+ containerInfo.properties.setProperty("ResourceAdapter", "FakeRA");
+ containerInfo.properties.setProperty("MessageListenerInterface", FakeMessageListener.class.getName());
+ containerInfo.properties.setProperty("ActivationSpecClass", FakeActivationSpec.class.getName());
assembler.createContainer(containerInfo);
// generate ejb jar application
EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(createJaxbMdb("JmsMdb", BasicMdbBean.class.getName(), MessageListener.class.getName()));
- ejbJar.addEnterpriseBean(createJaxbMdb("FakeMdb", FakeMdb.class.getName(), Runnable.class.getName()));
+ ejbJar.addEnterpriseBean(createJaxbMdb("FakeMdb", FakeMdb.class.getName(), FakeMessageListener.class.getName()));
EjbModule ejbModule = new EjbModule(getClass().getClassLoader(), "FakeEjbJar", "fake.jar", ejbJar, null);
// configure and deploy it
@@ -66,8 +87,71 @@
assembler.createEjbJar(info);
}
- public static class FakeMdb implements Runnable {
- public void run() {
+ public static class FakeMdb implements FakeMessageListener {
+ public void doIt(Properties properties) {
+ }
+ }
+
+ public static interface FakeMessageListener {
+ public void doIt(Properties properties);
+ }
+
+ public static class FakeRA implements ResourceAdapter {
+ public boolean started;
+ public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
+ assertFalse("Already started", started);
+ assertNotNull("bootstrapContext is null", bootstrapContext);
+ assertNotNull("bootstrapContext.getWorkManager() is null", bootstrapContext.getWorkManager());
+ assertNotNull("bootstrapContext.getXATerminator() is null", bootstrapContext.getXATerminator());
+ try {
+ assertNotNull("bootstrapContext.createTimer() is null", bootstrapContext.createTimer());
+ } catch (UnavailableException e) {
+ throw new ResourceAdapterInternalException("bootstrapContext.createTimer() threw an exception", e);
+ }
+ }
+
+ public void stop() {
+ assertTrue("RA was not started", started);
+ }
+
+ public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException {
+ assertNotNull("messageEndpointFactory is null", messageEndpointFactory);
+ assertNotNull("activationSpec is null", activationSpec);
+ assertTrue("activationSpec should be an instance of FakeActivationSpec", activationSpec instanceof FakeActivationSpec);
+
+ MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
+ assertNotNull("endpoint is null", endpoint);
+ assertTrue("endpoint should be an instance of FakeMessageListener", endpoint instanceof FakeMessageListener);
+ }
+
+ public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
+ assertNotNull("messageEndpointFactory is null", messageEndpointFactory);
+ assertNotNull("activationSpec is null", activationSpec);
+ assertTrue("activationSpec should be an instance of FakeActivationSpec", activationSpec instanceof FakeActivationSpec);
+ }
+
+ public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException {
+ return new XAResource[0];
+ }
+ }
+
+ public static class FakeActivationSpec implements ActivationSpec {
+ private FakeRA fakeRA;
+ protected boolean validated;
+
+ public void validate() throws InvalidPropertyException {
+ validated = true;
+ }
+
+ public FakeRA getResourceAdapter() {
+ return fakeRA;
+ }
+
+ public void setResourceAdapter(ResourceAdapter resourceAdapter) {
+ assertNotNull("resourceAdapter is null", resourceAdapter);
+ assertTrue("resourceAdapter should be an instance of FakeRA", resourceAdapter instanceof FakeRA);
+ this.fakeRA = (FakeRA)resourceAdapter;
+ assertTrue("ActivationSpec has not been validated", validated);
}
}
Added: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/BodyContent.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/BodyContent.java?rev=585036&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/BodyContent.java (added)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/BodyContent.java Mon Oct 15 21:38:53 2007
@@ -0,0 +1,49 @@
+/**
+ * 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.openejb.jee;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlEnumValue;
+
+@XmlEnum
+public enum BodyContent {
+ @XmlEnumValue("tagdependent")
+ TAGDEPENDENT("tagdependent"),
+ JSP("JSP"),
+ @XmlEnumValue("empty")
+ EMPTY("empty"),
+ @XmlEnumValue("scriptless")
+ SCRIPTLESS("scriptless");
+ private final String value;
+
+ BodyContent(String v) {
+ value = v;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ public static BodyContent fromValue(String v) {
+ for (BodyContent c : values()) {
+ if (c.value.equals(v)) {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException(v.toString());
+ }
+}
Added: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Function.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Function.java?rev=585036&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Function.java (added)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Function.java Mon Oct 15 21:38:53 2007
@@ -0,0 +1,185 @@
+/**
+ * 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.openejb.jee;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The function element is used to provide information on each
+ * function in the tag library that is to be exposed to the EL.
+ * <p/>
+ * The function element may have several subelements defining:
+ * <p/>
+ * description Optional tag-specific information
+ * <p/>
+ * display-name A short name that is intended to be displayed
+ * by tools
+ * <p/>
+ * icon Optional icon element that can be used by tools
+ * <p/>
+ * name A unique name for this function
+ * <p/>
+ * function-class Provides the name of the Java class that
+ * implements the function
+ * <p/>
+ * function-signature Provides the signature, as in the Java Language
+ * Specification, of the Java method that is to be
+ * used to implement the function.
+ * <p/>
+ * example Optional informal description of an
+ * example of a use of this function
+ * <p/>
+ * function-extension Zero or more extensions that provide extra
+ * information about this function, for tool
+ * consumption
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "functionType", propOrder = {
+ "descriptions",
+ "displayNames",
+ "icon",
+ "name",
+ "functionClass",
+ "functionSignature",
+ "example",
+ "functionExtension"
+})
+public class Function {
+ @XmlTransient
+ protected TextMap description = new TextMap();
+ @XmlTransient
+ protected TextMap displayName = new TextMap();
+ @XmlElement(name = "icon", required = true)
+ protected LocalCollection<Icon> icon = new LocalCollection<Icon>();
+
+ @XmlElement(required = true)
+ protected String name;
+ @XmlElement(name = "function-class", required = true)
+ protected String functionClass;
+ @XmlElement(name = "function-signature", required = true)
+ protected String functionSignature;
+ protected String example;
+ @XmlElement(name = "function-extension")
+ protected List<TldExtension> functionExtension;
+ @XmlAttribute
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ protected String id;
+
+ @XmlElement(name = "description", required = true)
+ public Text[] getDescriptions() {
+ return description.toArray();
+ }
+
+ public void setDescriptions(Text[] text) {
+ description.set(text);
+ }
+
+ public String getDescription() {
+ return description.get();
+ }
+
+ @XmlElement(name = "display-name", required = true)
+ public Text[] getDisplayNames() {
+ return displayName.toArray();
+ }
+
+ public void setDisplayNames(Text[] text) {
+ displayName.set(text);
+ }
+
+ public String getDisplayName() {
+ return displayName.get();
+ }
+
+ public Collection<Icon> getIcons() {
+ if (icon == null) {
+ icon = new LocalCollection<Icon>();
+ }
+ return icon;
+ }
+
+ public Map<String, Icon> getIconMap() {
+ if (icon == null) {
+ icon = new LocalCollection<Icon>();
+ }
+ return icon.toMap();
+ }
+
+ public Icon getIcon() {
+ return icon.getLocal();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ public String getFunctionClass() {
+ return functionClass;
+ }
+
+ public void setFunctionClass(String value) {
+ this.functionClass = value;
+ }
+
+ public String getFunctionSignature() {
+ return functionSignature;
+ }
+
+ public void setFunctionSignature(String value) {
+ this.functionSignature = value;
+ }
+
+ public String getExample() {
+ return example;
+ }
+
+ public void setExample(String value) {
+ this.example = value;
+ }
+
+ public List<TldExtension> getFunctionExtension() {
+ if (functionExtension == null) {
+ functionExtension = new ArrayList<TldExtension>();
+ }
+ return this.functionExtension;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String value) {
+ this.id = value;
+ }
+}
Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java Mon Oct 15 21:38:53 2007
@@ -36,6 +36,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
+import java.io.ByteArrayInputStream;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
@@ -107,6 +108,7 @@
}
public static class NamespaceFilter extends XMLFilterImpl {
+ private static final InputSource EMPTY_INPUT_SOURCE = new InputSource(new ByteArrayInputStream(new byte[0]));
public NamespaceFilter(XMLReader xmlReader) {
super(xmlReader);
@@ -117,7 +119,7 @@
if (publicIds != null) {
publicIds.add(publicId);
}
- return super.resolveEntity(publicId, systemId);
+ return EMPTY_INPUT_SOURCE;
}
public void startElement(String uri, String localName, String qname, Attributes atts) throws SAXException {
Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ObjectFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ObjectFactory.java?rev=585036&r1=585035&r2=585036&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ObjectFactory.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ObjectFactory.java Mon Oct 15 21:38:53 2007
@@ -47,7 +47,8 @@
private final static QName _EjbRelationTypeEjbRelationshipRole_QNAME = new QName("http://java.sun.com/xml/ns/javaee", "ejb-relationship-role");
private final static QName _EjbRelationTypeDescription_QNAME = new QName("http://java.sun.com/xml/ns/javaee", "description");
private final static QName _WebResourceCollectionTypeHttpMethod_QNAME = new QName("http://java.sun.com/xml/ns/javaee", "http-method");
- private final static QName _WebApp_QNAME = new QName("http://java.sun.com/xml/ns/javaee", "web-app");
+ private final static QName _TldTaglib_QNAME = new QName("http://java.sun.com/xml/ns/javaee", "web-app");
+ private final static QName _WebApp_QNAME = new QName("http://java.sun.com/xml/ns/javaee", "taglib");
private final static QName _Connector_QNAME = new QName("http://java.sun.com/xml/ns/j2ee", "connector");
/**
@@ -105,6 +106,15 @@
@XmlElementDecl(namespace = "http://java.sun.com/xml/ns/javaee", name = "web-app")
public JAXBElement<WebApp> createWebApp(WebApp value) {
return new JAXBElement<WebApp>(_WebApp_QNAME, WebApp.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link TldTaglib }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://java.sun.com/xml/ns/javaee", name = "taglib")
+ public JAXBElement<TldTaglib> createTldTaglib(TldTaglib value) {
+ return new JAXBElement<TldTaglib>(_TldTaglib_QNAME, TldTaglib.class, null, value);
}
/**
Added: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Tag.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Tag.java?rev=585036&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Tag.java (added)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Tag.java Mon Oct 15 21:38:53 2007
@@ -0,0 +1,238 @@
+/**
+ * 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.openejb.jee;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The tag defines a unique tag in this tag library. It has one
+ * attribute, id.
+ * <p/>
+ * The tag element may have several subelements defining:
+ * <p/>
+ * description Optional tag-specific information
+ * <p/>
+ * display-name A short name that is intended to be
+ * displayed by tools
+ * <p/>
+ * icon Optional icon element that can be used
+ * by tools
+ * <p/>
+ * name The unique action name
+ * <p/>
+ * tag-class The tag handler class implementing
+ * javax.servlet.jsp.tagext.JspTag
+ * <p/>
+ * tei-class An optional subclass of
+ * javax.servlet.jsp.tagext.TagExtraInfo
+ * <p/>
+ * body-content The body content type
+ * <p/>
+ * variable Optional scripting variable information
+ * <p/>
+ * attribute All attributes of this action that are
+ * evaluated prior to invocation.
+ * <p/>
+ * dynamic-attributes Whether this tag supports additional
+ * attributes with dynamic names. If
+ * true, the tag-class must implement the
+ * javax.servlet.jsp.tagext.DynamicAttributes
+ * interface. Defaults to false.
+ * <p/>
+ * example Optional informal description of an
+ * example of a use of this tag
+ * <p/>
+ * tag-extension Zero or more extensions that provide extra
+ * information about this tag, for tool
+ * consumption
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "tagType", propOrder = {
+ "descriptions",
+ "displayNames",
+ "icon",
+ "name",
+ "tagClass",
+ "teiClass",
+ "bodyContent",
+ "variable",
+ "attribute",
+ "dynamicAttributes",
+ "example",
+ "tagExtension"
+})
+public class Tag {
+ @XmlTransient
+ protected TextMap description = new TextMap();
+ @XmlTransient
+ protected TextMap displayName = new TextMap();
+ @XmlElement(name = "icon", required = true)
+ protected LocalCollection<Icon> icon = new LocalCollection<Icon>();
+
+ @XmlElement(required = true)
+ protected String name;
+ @XmlElement(name = "tag-class", required = true)
+ protected String tagClass;
+ @XmlElement(name = "tei-class")
+ protected String teiClass;
+ @XmlElement(name = "body-content", required = true)
+ protected BodyContent bodyContent;
+ protected List<Variable> variable;
+ protected List<TldAttribute> attribute;
+ @XmlElement(name = "dynamic-attributes")
+ protected String dynamicAttributes;
+ protected String example;
+ @XmlElement(name = "tag-extension")
+ protected List<TldExtension> tagExtension;
+ @XmlAttribute
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ protected String id;
+
+ @XmlElement(name = "description", required = true)
+ public Text[] getDescriptions() {
+ return description.toArray();
+ }
+
+ public void setDescriptions(Text[] text) {
+ description.set(text);
+ }
+
+ public String getDescription() {
+ return description.get();
+ }
+
+ @XmlElement(name = "display-name", required = true)
+ public Text[] getDisplayNames() {
+ return displayName.toArray();
+ }
+
+ public void setDisplayNames(Text[] text) {
+ displayName.set(text);
+ }
+
+ public String getDisplayName() {
+ return displayName.get();
+ }
+
+ public Collection<Icon> getIcons() {
+ if (icon == null) {
+ icon = new LocalCollection<Icon>();
+ }
+ return icon;
+ }
+
+ public Map<String, Icon> getIconMap() {
+ if (icon == null) {
+ icon = new LocalCollection<Icon>();
+ }
+ return icon.toMap();
+ }
+
+ public Icon getIcon() {
+ return icon.getLocal();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ public String getTagClass() {
+ return tagClass;
+ }
+
+ public void setTagClass(String value) {
+ this.tagClass = value;
+ }
+
+ public String getTeiClass() {
+ return teiClass;
+ }
+
+ public void setTeiClass(String value) {
+ this.teiClass = value;
+ }
+
+ public BodyContent getBodyContent() {
+ return bodyContent;
+ }
+
+ public void setBodyContent(BodyContent value) {
+ this.bodyContent = value;
+ }
+
+ public List<Variable> getVariable() {
+ if (variable == null) {
+ variable = new ArrayList<Variable>();
+ }
+ return this.variable;
+ }
+
+ public List<TldAttribute> getAttribute() {
+ if (attribute == null) {
+ attribute = new ArrayList<TldAttribute>();
+ }
+ return this.attribute;
+ }
+
+ public String getDynamicAttributes() {
+ return dynamicAttributes;
+ }
+
+ public void setDynamicAttributes(String value) {
+ this.dynamicAttributes = value;
+ }
+
+ public String getExample() {
+ return example;
+ }
+
+ public void setExample(String value) {
+ this.example = value;
+ }
+
+ public List<TldExtension> getTagExtension() {
+ if (tagExtension == null) {
+ tagExtension = new ArrayList<TldExtension>();
+ }
+ return this.tagExtension;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String value) {
+ this.id = value;
+ }
+}