Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=951759&r1=951758&r2=951759&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Sat Jun 5 20:31:05 2010 @@ -132,11 +132,7 @@ public class ConfigurationFactory implem chain.add(new ReadDescriptors()); - if (System.getProperty(DUCT_TAPE_PROPERTY) == null) { - chain.add(new AnnotationDeployer()); - } else { - chain.add(new BundleAnnotationDeployer()); - } + chain.add(new AnnotationDeployer()); chain.add(new GeneratedClientModules.Prune());
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java?rev=951759&r1=951758&r2=951759&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java Sat Jun 5 20:31:05 2010 @@ -98,13 +98,13 @@ public class EjbModule implements WsModu } public AbstractFinder getFinder() { - return (finder != null)? finder.get(): null; + return finder.get(); } - public AtomicReference<AbstractFinder> getFinderReference() { - return this.finder; + public void setFinder(AbstractFinder finder) { + this.finder.set(finder); } - + public ClientModule getClientModule() { return clientModule; } Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java?rev=951759&view=auto ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java (added) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java Sat Jun 5 20:31:05 2010 @@ -0,0 +1,76 @@ +/** + * 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.config; + +import org.apache.xbean.finder.AbstractFinder; +import org.apache.xbean.finder.ClassFinder; +import org.apache.openejb.util.Logger; +import org.apache.openejb.util.LogCategory; + +import java.io.File; +import java.net.URL; +import static java.util.Arrays.asList; + +public class FinderFactory { + + private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB, FinderFactory.class); + + private static final FinderFactory factory = singleton(); + + private static FinderFactory singleton() { + try { + ClassLoader loader = FinderFactory.class.getClassLoader(); + Class<?> clazz = loader.loadClass("org.apache.openejb.core.osgi.BundleFinderFactory"); + return (FinderFactory) clazz.newInstance(); + } catch (ClassNotFoundException e) { + logger.debug("Optional OSGi Bundle annotation scanning not installed"); + } catch (Exception e) { + logger.error("Failed creating BundleFinderFactory", e); + } + + return new FinderFactory(); + } + + public static AbstractFinder createFinder(DeploymentModule module) throws Exception { + return factory.create(module); + } + + public AbstractFinder create(DeploymentModule module) throws Exception { + if (module instanceof WebModule) { + WebModule webModule = (WebModule) module; + File file = new File(webModule.getJarLocation()); + URL[] urls = DeploymentLoader.getWebappUrls(file); + final ClassLoader webClassLoader = webModule.getClassLoader(); + return new ClassFinder(webClassLoader, asList(urls)); + } + + if (module.getJarLocation() != null) { + String location = module.getJarLocation(); + File file = new File(location); + + URL url; + if (file.exists()) { + url = file.toURI().toURL(); + } else { + url = new URL(location); + } + return new ClassFinder(module.getClassLoader(), url); + } else { + return new ClassFinder(module.getClassLoader()); + } + } +} Propchange: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: openejb/trunk/openejb3/container/openejb-osgi-core/pom.xml (from r951745, openejb/trunk/openejb3/container/openejb-osgi/pom.xml) URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-osgi-core/pom.xml?p2=openejb/trunk/openejb3/container/openejb-osgi-core/pom.xml&p1=openejb/trunk/openejb3/container/openejb-osgi/pom.xml&r1=951745&r2=951759&rev=951759&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-osgi/pom.xml (original) +++ openejb/trunk/openejb3/container/openejb-osgi-core/pom.xml Sat Jun 5 20:31:05 2010 @@ -25,7 +25,7 @@ <version>3.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>openejb-core-osgi</artifactId> + <artifactId>openejb-osgi-core</artifactId> <packaging>bundle</packaging> <name>OpenEJB :: Container :: Core :: OSGi</name> <dependencies> @@ -38,96 +38,6 @@ <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> </dependency> - <dependency> - <groupId>org.apache.geronimo.components</groupId> - <artifactId>geronimo-transaction</artifactId> - </dependency> </dependencies> - <build> - <resources> - <resource> - <directory>${pom.basedir}/src/main/resources</directory> - </resource> - <resource> - <directory>${pom.basedir}/src/main/filtered-resources</directory> - <filtering>true</filtering> - <includes> - <include>**/*</include> - </includes> - </resource> - </resources> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <configuration> - <instructions> - <Bundle-Activator>org.apache.openejb.core.osgi.impl.Activator</Bundle-Activator> - <Require-Bundle> - org.apache.openejb.core, - org.apache.openejb.loader, - org.apache.openejb.jee - </Require-Bundle> - <Export-Package>org.apache.openejb.core.osgi.*</Export-Package> - <Import-Package> - javax.transaction;version="[1.1,1.2)", - javax.transaction.xa;version="[1.1,1.2)", - javax.naming, - javax.jms, - org.apache.commons.logging, - org.apache.openejb.assembler.classic, - org.apache.openejb.config, - org.apache.openejb.spi, - org.apache.openejb.resource.activemq, - org.apache.openejb.client, - org.apache.activemq.ra, - org.apache.openejb;version="3.1", - org.apache.openejb.core.osgi.impl, - org.apache.openejb.loader;version="3.1", - org.apache.openejb.util;version="3.1", - org.osgi.framework;version="1.4" - </Import-Package> - <Include-Resource>${pom.basedir}/src/main/resources</Include-Resource> - </instructions> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>attach-artifacts</id> - <phase>package</phase> - <goals> - <goal>attach-artifact</goal> - </goals> - <configuration> - <artifacts> - <artifact> - <file>target/classes/features.xml</file> - <type>xml </type> - <classifier>features</classifier> - </artifact> - </artifacts> - </configuration> - </execution> - </executions> - </plugin> - - <!-- - <plugin> <groupId>org.apache.felix.karaf.tooling</groupId> - <artifactId>features-maven-plugin</artifactId> - <version>1.0.0</version> <executions> <execution> - <id>add-features-to-repo</id> <phase>generate-resources</phase> - <goals> <goal>add-features-to-repo</goal> </goals> - <configuration> <descriptors> - <descriptor>file:${basedir}/target/classes/features.xml</descriptor> - </descriptors> <features> <feature>javaee-api</feature> - <feature>openejb-core</feature> </features> - <repository>target/features-repo</repository> </configuration> - </execution> </executions> </plugin> - --> - </plugins> - </build> </project> Added: openejb/trunk/openejb3/container/openejb-osgi-core/src/main/java/org/apache/openejb/osgi/core/BundleFinderFactory.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-osgi-core/src/main/java/org/apache/openejb/osgi/core/BundleFinderFactory.java?rev=951759&view=auto ============================================================================== --- openejb/trunk/openejb3/container/openejb-osgi-core/src/main/java/org/apache/openejb/osgi/core/BundleFinderFactory.java (added) +++ openejb/trunk/openejb3/container/openejb-osgi-core/src/main/java/org/apache/openejb/osgi/core/BundleFinderFactory.java Sat Jun 5 20:31:05 2010 @@ -0,0 +1,55 @@ +/** + * 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.osgi.core; + +import org.apache.openejb.config.DeploymentModule; +import org.apache.openejb.config.FinderFactory; +import org.apache.xbean.finder.AbstractFinder; +import org.apache.xbean.finder.BundleAnnotationFinder; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleReference; +import org.osgi.framework.ServiceReference; +import org.osgi.service.packageadmin.PackageAdmin; + +/** + * @version $Rev$ $Date$ + */ +public class BundleFinderFactory extends FinderFactory { + + @Override + public AbstractFinder create(DeploymentModule module) throws Exception { + ClassLoader cl = BundleFinderFactory.class.getClassLoader(); + ClassLoader moduleCL = module.getClassLoader(); + + if (cl instanceof BundleReference && moduleCL instanceof BundleReference) { + Bundle bundle = getBundle(cl); + BundleContext bundleContext = bundle.getBundleContext(); + ServiceReference sr = bundleContext.getServiceReference(PackageAdmin.class.getName()); + PackageAdmin packageAdmin = (PackageAdmin) bundleContext.getService(sr); + + return new BundleAnnotationFinder(packageAdmin, getBundle(moduleCL)); + } + + return super.create(module); + } + + private Bundle getBundle(ClassLoader cl) { + return ((BundleReference) cl).getBundle(); + } + +} Propchange: openejb/trunk/openejb3/container/openejb-osgi-core/src/main/java/org/apache/openejb/osgi/core/BundleFinderFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: openejb/trunk/openejb3/container/pom.xml URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/pom.xml?rev=951759&r1=951758&r2=951759&view=diff ============================================================================== --- openejb/trunk/openejb3/container/pom.xml (original) +++ openejb/trunk/openejb3/container/pom.xml Sat Jun 5 20:31:05 2010 @@ -32,6 +32,7 @@ <module>openejb-javaagent</module> <module>openejb-jee</module> <module>openejb-spring</module> + <module>openejb-osgi-core</module> <module>openejb-osgi</module> <module>openejb-activemq4</module> <module>openejb-junit</module>
