Author: gawor
Date: Thu Jun 3 05:09:29 2010
New Revision: 950878
URL: http://svn.apache.org/viewvc?rev=950878&view=rev
Log:
GERONIMO-5205: On Equinox use ClassLoadingHook to add necessary JPA provider imports to the
persistence bundle.
Added:
geronimo/server/trunk/framework/modules/geronimo-hook/
geronimo/server/trunk/framework/modules/geronimo-hook/pom.xml (with props)
geronimo/server/trunk/framework/modules/geronimo-hook/src/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/bundle/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/bundle/equinox/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/equinox/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/equinox/classloader/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleExtender.java
(with props)
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleHelper.java
(with props)
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/ClassLoaderHook.java
(with props)
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoHookConfigurator.java
(with props)
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/resources/
geronimo/server/trunk/framework/modules/geronimo-hook/src/main/resources/hookconfigurators.properties
(with props)
geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceBundleHelper.java
(contents, props changed)
- copied, changed from r950759, geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java
Removed:
geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java
Modified:
geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java
geronimo/server/trunk/framework/configs/karaf-framework/pom.xml
geronimo/server/trunk/framework/configs/karaf-framework/src/main/filtered-resources/etc/config.properties
geronimo/server/trunk/framework/modules/pom.xml
geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml
geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java
Modified: geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java?rev=950878&r1=950877&r2=950878&view=diff
==============================================================================
--- geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java
(original)
+++ geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java
Thu Jun 3 05:09:29 2010
@@ -844,6 +844,7 @@ public abstract class AbstractCarMojo
"org.apache.geronimo.system.threads," +
"org.apache.geronimo.system.util," +
"org.apache.geronimo.transformer," +
+ "org.apache.geronimo.hook," +
"org.apache.geronimo.mavenplugins.car," +
"org.apache.felix.karaf.jaas.boot;version=\"1.6.0\"," +
"org.apache.yoko," +
Modified: geronimo/server/trunk/framework/configs/karaf-framework/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/karaf-framework/pom.xml?rev=950878&r1=950877&r2=950878&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/karaf-framework/pom.xml (original)
+++ geronimo/server/trunk/framework/configs/karaf-framework/pom.xml Thu Jun 3 05:09:29 2010
@@ -124,6 +124,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.geronimo.framework</groupId>
+ <artifactId>geronimo-hook</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.felix.karaf.shell</groupId>
<artifactId>org.apache.felix.karaf.shell.log</artifactId>
<version>${felix.karaf.version}</version>
@@ -541,6 +547,12 @@
</artifactItem>
<artifactItem>
<groupId>org.apache.geronimo.framework</groupId>
+ <artifactId>geronimo-hook</artifactId>
+ <outputDirectory>target/dependencies/lib</outputDirectory>
+ <destFileName>geronimo-hook.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.geronimo.framework</groupId>
<artifactId>geronimo-deploy-jsr88-full</artifactId>
<outputDirectory>target/dependencies/jsr88</outputDirectory>
<destFileName>geronimo-deploy-jsr88-full.jar</destFileName>
Modified: geronimo/server/trunk/framework/configs/karaf-framework/src/main/filtered-resources/etc/config.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/karaf-framework/src/main/filtered-resources/etc/config.properties?rev=950878&r1=950877&r2=950878&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/karaf-framework/src/main/filtered-resources/etc/config.properties
(original)
+++ geronimo/server/trunk/framework/configs/karaf-framework/src/main/filtered-resources/etc/config.properties
Thu Jun 3 05:09:29 2010
@@ -50,7 +50,8 @@ org.osgi.framework.system.packages.extra
org.apache.geronimo.cli.client, \
org.apache.geronimo.cli.shutdown, \
org.apache.geronimo.cli.deployer, \
- org.apache.geronimo.transformer
+ org.apache.geronimo.transformer, \
+ org.apache.geronimo.hook
# javax.transaction is needed to avoid class loader constraint violation when using javax.sql
org.osgi.framework.bootdelegation=sun.*,com.sun.*,javax.transaction,javax.transaction.*
Added: geronimo/server/trunk/framework/modules/geronimo-hook/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-hook/pom.xml?rev=950878&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-hook/pom.xml (added)
+++ geronimo/server/trunk/framework/modules/geronimo-hook/pom.xml Thu Jun 3 05:09:29 2010
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.geronimo.framework</groupId>
+ <artifactId>modules</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>geronimo-hook</artifactId>
+ <packaging>bundle</packaging>
+ <name>Geronimo Framework, Modules :: OSGi Framework Hook</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
+
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleExtender.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleExtender.java?rev=950878&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleExtender.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleExtender.java
Thu Jun 3 05:09:29 2010
@@ -0,0 +1,25 @@
+/**
+ * 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.geronimo.hook;
+
+public interface BundleExtender {
+
+ void addDynamicImportPackage(long bundleId, String packages);
+
+ void removeDynamicImportPackage(long bundleId);
+
+}
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleExtender.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleExtender.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleExtender.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleHelper.java?rev=950878&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleHelper.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleHelper.java
Thu Jun 3 05:09:29 2010
@@ -0,0 +1,45 @@
+/**
+ * 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.geronimo.hook;
+
+public class BundleHelper {
+
+ private static BundleExtender extender;
+
+ public static void setBundleExtender(BundleExtender newExtender) {
+ extender = newExtender;
+ }
+
+ public static boolean isBundleExtenderSet() {
+ return (extender != null);
+ }
+
+ public static void addDynamicImportPackage(long bundleId, String packages) {
+ if (extender == null) {
+ return;
+ }
+ extender.addDynamicImportPackage(bundleId, packages);
+ }
+
+ public static void removeDynamicImportPackage(long bundleId) {
+ if (extender == null) {
+ return;
+ }
+ extender.removeDynamicImportPackage(bundleId);
+ }
+
+}
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleHelper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/BundleHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/ClassLoaderHook.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/ClassLoaderHook.java?rev=950878&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/ClassLoaderHook.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/ClassLoaderHook.java
Thu Jun 3 05:09:29 2010
@@ -0,0 +1,96 @@
+/**
+ * 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.geronimo.hook.equinox;
+
+import java.security.ProtectionDomain;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.geronimo.hook.BundleExtender;
+import org.eclipse.osgi.baseadaptor.BaseData;
+import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
+import org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook;
+import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader;
+import org.eclipse.osgi.baseadaptor.loader.ClasspathEntry;
+import org.eclipse.osgi.baseadaptor.loader.ClasspathManager;
+import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain;
+import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
+import org.eclipse.osgi.framework.internal.core.Constants;
+import org.eclipse.osgi.internal.loader.BundleLoader;
+import org.eclipse.osgi.util.ManifestElement;
+import org.osgi.framework.BundleException;
+
+public class ClassLoaderHook implements ClassLoadingHook, BundleExtender {
+
+ private final Map<Long, String> dynamicPackages =
+ Collections.synchronizedMap(new HashMap<Long, String>());
+
+ public void addDynamicImportPackage(long bundleId, String packages) {
+ dynamicPackages.put(bundleId, packages);
+ }
+
+ public void removeDynamicImportPackage(long bundleId) {
+ dynamicPackages.remove(bundleId);
+ }
+
+ public boolean addClassPathEntry(ArrayList arg0,
+ String arg1,
+ ClasspathManager arg2,
+ BaseData arg3,
+ ProtectionDomain arg4) {
+ return false;
+ }
+
+ public BaseClassLoader createClassLoader(ClassLoader parent,
+ ClassLoaderDelegate delegate,
+ BundleProtectionDomain domain,
+ BaseData data,
+ String[] classpath) {
+ BundleLoader loader = (BundleLoader) delegate;
+ String packages = dynamicPackages.get(loader.getBundle().getBundleId());
+ if (packages != null) {
+ try {
+ loader.addDynamicImportPackage(ManifestElement.parseHeader(Constants.DYNAMICIMPORT_PACKAGE,
packages));
+ } catch (BundleException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return null;
+ }
+
+ public String findLibrary(BaseData arg0, String arg1) {
+ return null;
+ }
+
+ public ClassLoader getBundleClassLoaderParent() {
+ return null;
+ }
+
+ public void initializedClassLoader(BaseClassLoader arg0, BaseData arg1) {
+ }
+
+ public byte[] processClass(String arg0,
+ byte[] arg1,
+ ClasspathEntry arg2,
+ BundleEntry arg3,
+ ClasspathManager arg4) {
+ return null;
+ }
+
+}
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/ClassLoaderHook.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/ClassLoaderHook.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/ClassLoaderHook.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoHookConfigurator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoHookConfigurator.java?rev=950878&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoHookConfigurator.java
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoHookConfigurator.java
Thu Jun 3 05:09:29 2010
@@ -0,0 +1,32 @@
+/**
+ * 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.geronimo.hook.equinox;
+
+import org.apache.geronimo.hook.BundleHelper;
+import org.eclipse.osgi.baseadaptor.HookConfigurator;
+import org.eclipse.osgi.baseadaptor.HookRegistry;
+
+public class GeronimoHookConfigurator implements HookConfigurator {
+
+ public void addHooks(HookRegistry registry) {
+ ClassLoaderHook classLoaderHook = new ClassLoaderHook();
+ registry.addClassLoadingHook(classLoaderHook);
+
+ BundleHelper.setBundleExtender(classLoaderHook);
+ }
+
+}
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoHookConfigurator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoHookConfigurator.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoHookConfigurator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/resources/hookconfigurators.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-hook/src/main/resources/hookconfigurators.properties?rev=950878&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-hook/src/main/resources/hookconfigurators.properties
(added)
+++ geronimo/server/trunk/framework/modules/geronimo-hook/src/main/resources/hookconfigurators.properties
Thu Jun 3 05:09:29 2010
@@ -0,0 +1,4 @@
+hook.configurators=org.apache.geronimo.hook.equinox.GeronimoHookConfigurator
+
+
+
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/resources/hookconfigurators.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/resources/hookconfigurators.properties
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/resources/hookconfigurators.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/framework/modules/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/pom.xml?rev=950878&r1=950877&r2=950878&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/pom.xml (original)
+++ geronimo/server/trunk/framework/modules/pom.xml Thu Jun 3 05:09:29 2010
@@ -90,6 +90,7 @@
<module>geronimo-management</module>
<module>geronimo-naming</module>
<module>geronimo-security</module>
+ <module>geronimo-hook</module>
</modules>
</profile>
<profile>
Modified: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml?rev=950878&r1=950877&r2=950878&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml (original)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml Thu Jun 3 05:09:29
2010
@@ -52,6 +52,13 @@
</dependency>
<dependency>
+ <groupId>org.apache.geronimo.framework</groupId>
+ <artifactId>geronimo-hook</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.aries</groupId>
<artifactId>org.apache.aries.util</artifactId>
<scope>provided</scope>
Modified: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java?rev=950878&r1=950877&r2=950878&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java
(original)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java
Thu Jun 3 05:09:29 2010
@@ -34,7 +34,7 @@ import org.osgi.framework.ServiceReferen
public class GeronimoManagedPersistenceUnitInfoFactory extends ManagedPersistenceUnitInfoFactoryImpl
{
- private PersistenceUnitFragmentGenerator generator = new PersistenceUnitFragmentGenerator();
+ private PersistenceBundleHelper helper = new PersistenceBundleHelper();
private Map<Bundle, Collection<ManagedPersistenceUnitInfo>> map =
Collections.synchronizedMap(new HashMap<Bundle, Collection<ManagedPersistenceUnitInfo>>());
@@ -51,7 +51,7 @@ public class GeronimoManagedPersistenceU
managedUnits.add(new GeronimoManagedPersistenceUnitInfo(persistenceBundle, unit,
providerReference));
}
- generator.persistenceUnitMetadataCreated(containerContext, persistenceBundle, providerReference,
managedUnits);
+ helper.addProviderImports(containerContext, persistenceBundle, providerReference);
map.put(persistenceBundle, managedUnits);
@@ -65,7 +65,7 @@ public class GeronimoManagedPersistenceU
for (ManagedPersistenceUnitInfo unit : managedUnits) {
((GeronimoManagedPersistenceUnitInfo) unit).destroy();
}
- generator.persistenceBundleDestroyed(containerContext, persistenceBundle);
+ helper.removeProviderImports(containerContext, persistenceBundle);
}
}
Copied: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceBundleHelper.java
(from r950759, geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceBundleHelper.java?p2=geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceBundleHelper.java&p1=geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java&r1=950759&r2=950878&rev=950878&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java
(original)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceBundleHelper.java
Thu Jun 3 05:09:29 2010
@@ -19,13 +19,13 @@
package org.apache.geronimo.aries.jpa;
import java.io.IOException;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
-import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
import org.apache.aries.util.FragmentBuilder;
+import org.apache.geronimo.hook.BundleHelper;
import org.apache.xbean.osgi.bundle.util.BundleDescription;
import org.apache.xbean.osgi.bundle.util.BundleDescription.ExportPackage;
import org.apache.xbean.osgi.bundle.util.BundleDescription.HeaderEntry;
@@ -33,63 +33,88 @@ import org.apache.xbean.osgi.bundle.util
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * An implementation of {@link ManagedPersistenceUnitInfoFactoryListener} that generates
and installs
- * a fragment bundle that attaches to the persistence bundle. The generated fragment bundle
imports
- * every package exported by the JPA provider bundle.
- */
-public class PersistenceUnitFragmentGenerator {
+public class PersistenceBundleHelper {
- private static final Logger LOG = LoggerFactory.getLogger(PersistenceUnitFragmentGenerator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(PersistenceBundleHelper.class);
private Map<Bundle, Bundle> fragmentMap = Collections.synchronizedMap(new HashMap<Bundle,
Bundle>());
- public void persistenceUnitMetadataCreated(BundleContext containerContext,
- Bundle persistenceBundle,
- ServiceReference providerReference,
- Collection<ManagedPersistenceUnitInfo>
managedUnits) {
- if (persistenceBundle.getState() == Bundle.INSTALLED
- && providerReference != null
- && needsFragment(persistenceBundle, providerReference.getBundle())) {
-
- LOG.debug("Generating JPA fragment for persistence bundle {}", persistenceBundle.getSymbolicName());
-
- FragmentBuilder builder = new FragmentBuilder(persistenceBundle, ".jpa.fragment",
"JPA Fragment");
- builder.addImportsFromExports(providerReference.getBundle());
- Bundle fragment;
- try {
- fragment = builder.install(containerContext);
- } catch (IOException e) {
- throw new RuntimeException("Error installing JPA fragment bundle", e);
- } catch (BundleException e) {
- throw new RuntimeException("Error installing JPA fragment bundle", e);
+ public void addProviderImports(BundleContext containerContext,
+ Bundle persistenceBundle,
+ ServiceReference providerReference) {
+ if (persistenceBundle.getState() == Bundle.INSTALLED && providerReference
!= null) {
+ Bundle providerBundle = providerReference.getBundle();
+ BundleDescription providerDescription = new BundleDescription(providerBundle.getHeaders());
+ if (needsProviderImports(persistenceBundle, providerDescription)) {
+
+ StringBuffer providerConstraint = new StringBuffer();
+ providerConstraint.append(";");
+ providerConstraint.append(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
+ providerConstraint.append("=\"").append(providerBundle.getSymbolicName()).append("\"");
+ providerConstraint.append(";");
+ providerConstraint.append(Constants.BUNDLE_VERSION_ATTRIBUTE);
+ String exportVersion = providerBundle.getVersion().toString();
+ providerConstraint.append("=\"[").append(exportVersion).append(",").append(exportVersion).append("]\"");
+
+ if (BundleHelper.isBundleExtenderSet()) {
+ LOG.debug("Adding DynamicImport-Package for persistence bundle {}", persistenceBundle.getSymbolicName());
+
+ StringBuffer packageList = new StringBuffer();
+ Iterator<ExportPackage> iterator = providerDescription.getExportPackage().iterator();
+ while (iterator.hasNext()) {
+ ExportPackage exportPackage = iterator.next();
+ packageList.append(exportPackage.getName()).append(providerConstraint);
+ if (iterator.hasNext()) {
+ packageList.append(",");
+ }
+ }
+
+ BundleHelper.addDynamicImportPackage(persistenceBundle.getBundleId(),
packageList.toString());
+ } else {
+ LOG.debug("Generating JPA fragment for persistence bundle {}", persistenceBundle.getSymbolicName());
+
+ FragmentBuilder builder = new FragmentBuilder(persistenceBundle, ".jpa.fragment",
"JPA Fragment");
+ for (ExportPackage exportPackage : providerDescription.getExportPackage())
{
+ builder.addImports(exportPackage.getName() + providerConstraint);
+ }
+
+ Bundle fragment;
+ try {
+ fragment = builder.install(containerContext);
+ } catch (IOException e) {
+ throw new RuntimeException("Error installing JPA fragment bundle",
e);
+ } catch (BundleException e) {
+ throw new RuntimeException("Error installing JPA fragment bundle",
e);
+ }
+
+ fragmentMap.put(persistenceBundle, fragment);
+ }
}
-
- fragmentMap.put(persistenceBundle, fragment);
}
}
+
- private boolean needsFragment(Bundle persistenceBundle, Bundle providerBundle) {
+ private boolean needsProviderImports(Bundle persistenceBundle, BundleDescription providerDescription)
{
BundleDescription description = new BundleDescription(persistenceBundle.getHeaders());
for (HeaderEntry importPackage : description.getDynamicImportPackage()) {
if ("*".equals(importPackage.getName())) {
- LOG.debug("JPA fragment will not be generated: Persistence bundle {} can
load any class.",
+ LOG.debug("Persistence bundle {} can load any class.",
persistenceBundle.getSymbolicName());
return false;
}
}
- BundleDescription providerDescription = new BundleDescription(providerBundle.getHeaders());
for (ImportPackage importPackage : description.getImportPackage()) {
for (ExportPackage exportPackage : providerDescription.getExportPackage()) {
if (importPackage.getName().equals(exportPackage.getName())
&& importPackage.getVersionRange().isInRange(exportPackage.getVersion()))
{
- LOG.debug("JPA fragment will not be generated: Persistence bundle {}
already imports at least one package from JPA provider bundle.",
+ LOG.debug("Persistence bundle {} already imports at least one package
from JPA provider bundle.",
persistenceBundle.getSymbolicName());
return false;
}
@@ -99,16 +124,24 @@ public class PersistenceUnitFragmentGene
return true;
}
- public void persistenceBundleDestroyed(BundleContext containerContext, Bundle persistenceBundle)
{
+ public void removeProviderImports(BundleContext containerContext, Bundle persistenceBundle)
{
if (persistenceBundle.getState() == Bundle.UNINSTALLED) {
- LOG.debug("Persistence bundle {} was uninstalled. Uninstalling the corresponding
JPA fragment bundle",
- persistenceBundle.getSymbolicName());
- Bundle fragment = fragmentMap.remove(persistenceBundle);
- if (fragment != null) {
- try {
- fragment.uninstall();
- } catch (BundleException e) {
- // ignore
+ if (BundleHelper.isBundleExtenderSet()) {
+ LOG.debug("Persistence bundle {} was uninstalled. Removing DynamicImport-Package
from persistence bundle",
+ persistenceBundle.getSymbolicName());
+
+ BundleHelper.removeDynamicImportPackage(persistenceBundle.getBundleId());
+ } else {
+ LOG.debug("Persistence bundle {} was uninstalled. Uninstalling the corresponding
JPA fragment bundle",
+ persistenceBundle.getSymbolicName());
+
+ Bundle fragment = fragmentMap.remove(persistenceBundle);
+ if (fragment != null) {
+ try {
+ fragment.uninstall();
+ } catch (BundleException e) {
+ // ignore
+ }
}
}
}
Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceBundleHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceBundleHelper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceBundleHelper.java
------------------------------------------------------------------------------
svn:mergeinfo =
Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceBundleHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
|