You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/02/21 15:06:19 UTC
svn commit: r1291791 - in /openejb/trunk/openejb:
container/openejb-core/pom.xml
container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
examples/webapps/rest-example/pom.xml
Author: rmannibucau
Date: Tue Feb 21 14:06:18 2012
New Revision: 1291791
URL: http://svn.apache.org/viewvc?rev=1291791&view=rev
Log:
using xbean-xml (in maven modules for the moment))
Modified:
openejb/trunk/openejb/container/openejb-core/pom.xml
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
openejb/trunk/openejb/examples/webapps/rest-example/pom.xml
Modified: openejb/trunk/openejb/container/openejb-core/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/pom.xml?rev=1291791&r1=1291790&r2=1291791&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/pom.xml (original)
+++ openejb/trunk/openejb/container/openejb-core/pom.xml Tue Feb 21 14:06:18 2012
@@ -516,6 +516,11 @@
<artifactId>xbean-bundleutils</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.openejb</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ <artifactId>xbean-xml</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java?rev=1291791&r1=1291790&r2=1291791&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java Tue Feb 21 14:06:18 2012
@@ -16,6 +16,7 @@
*/
package org.apache.openejb.config;
+import org.apache.openejb.xbean.xml.XMLAnnotationFinderHelper;
import org.apache.xbean.finder.AnnotationFinder;
import org.apache.xbean.finder.IAnnotationFinder;
import org.apache.openejb.util.Logger;
@@ -24,13 +25,20 @@ import org.apache.openejb.loader.SystemI
import org.apache.xbean.finder.archive.ClassesArchive;
import org.apache.xbean.finder.archive.ClasspathArchive;
+import javax.xml.bind.JAXBException;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
import java.net.URL;
public class FinderFactory {
private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB, FinderFactory.class);
+ private static final String SCAN_XML = "META-INF/org/apache/xbean/scan.xml";
+ private static final String WEB_SCAN_XML = SCAN_XML.replace("META-INF", "WEB-INF");
+
private static final FinderFactory factory = new FinderFactory();
private static FinderFactory get() {
@@ -46,12 +54,20 @@ public class FinderFactory {
if (module instanceof WebModule) {
WebModule webModule = (WebModule) module;
final ClassLoader webClassLoader = webModule.getClassLoader();
+ final IAnnotationFinder finder = xmlFinder(module, inputStream(webModule.getFile(), WEB_SCAN_XML));
+ if (finder != null) {
+ return finder;
+ }
return new AnnotationFinder(new AggregatedArchive(webClassLoader, webModule.getScannableUrls())).link();
}
if (module instanceof ConnectorModule) {
ConnectorModule connectorModule = (ConnectorModule) module;
final ClassLoader connectorClassLoader = connectorModule.getClassLoader();
+ final IAnnotationFinder finder = xmlFinder(module, connectorClassLoader.getResourceAsStream(SCAN_XML));
+ if (finder != null) {
+ return finder;
+ }
return new AnnotationFinder(new ClasspathArchive(connectorClassLoader, connectorModule.getLibraries())).link();
}
@@ -67,13 +83,47 @@ public class FinderFactory {
if (webInfClassesFolder.exists() && webInfClassesFolder.isDirectory()) {
url = webInfClassesFolder.toURI().toURL();
}
+ if (webInfClassesFolder.getParentFile().exists()) {
+ final FileInputStream fis = inputStream(webInfClassesFolder.getParentFile().getParentFile(), WEB_SCAN_XML);
+ final IAnnotationFinder finder = xmlFinder(module, fis);
+ if (finder != null) {
+ return finder;
+ }
+ }
} else {
url = new URL(location);
}
+
+ final IAnnotationFinder finder = xmlFinder(module, module.getClassLoader().getResourceAsStream(SCAN_XML));
+ if (finder != null) {
+ return finder;
+ }
+
return new AnnotationFinder(new ClasspathArchive(module.getClassLoader(), url)).link();
} else {
return new AnnotationFinder(new ClassesArchive()).link();
}
}
+ private static IAnnotationFinder xmlFinder(final DeploymentModule module, final InputStream scanIs) {
+ if (scanIs != null) {
+ try {
+ final IAnnotationFinder finder = XMLAnnotationFinderHelper.finderFromXml(scanIs, module.getClassLoader());
+ logger.info("using scan.xml for module " + module.getModuleId());
+ return finder;
+ } catch (JAXBException jaxbEx) {
+ logger.warning("can't use scan.xml for " + module.getModuleId());
+ }
+ }
+ return null;
+ }
+
+ private static FileInputStream inputStream(final File file, final String xml) throws FileNotFoundException {
+ final File scanFile = new File(file, xml);
+ if (scanFile.exists()) {
+ return new FileInputStream(scanFile);
+ }
+ return null;
+ }
+
}
Modified: openejb/trunk/openejb/examples/webapps/rest-example/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/webapps/rest-example/pom.xml?rev=1291791&r1=1291790&r2=1291791&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/webapps/rest-example/pom.xml (original)
+++ openejb/trunk/openejb/examples/webapps/rest-example/pom.xml Tue Feb 21 14:06:18 2012
@@ -92,6 +92,29 @@
</webapps>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.openejb</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ <artifactId>spi-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-scan-xml</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <outputFilename>${project.build.directory}/${project.build.finalName}/WEB-INF/org/apache/xbean/scan.xml</outputFilename>
+ </configuration>
+ <dependencies>
+ <dependency> <!-- mandatory for the scanning since we enhanced our entities -->
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.2.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
<plugin> <!-- needed otherwise it will not work at runtime -->
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>