geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r950759 - in /geronimo/server/trunk/plugins/openjpa2: ./ geronimo-aries-jpa/ geronimo-aries-jpa/src/ geronimo-aries-jpa/src/main/ geronimo-aries-jpa/src/main/java/ geronimo-aries-jpa/src/main/java/org/ geronimo-aries-jpa/src/main/java/org/a...
Date Wed, 02 Jun 2010 21:06:15 GMT
Author: gawor
Date: Wed Jun  2 21:06:14 2010
New Revision: 950759

URL: http://svn.apache.org/viewvc?rev=950759&view=rev
Log:
GERONIMO-5205: Support runtime JPA entity enhancement for OSGi JPA applications (using java
agent approach and PU fragment bundles)

Added:
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml   (with props)
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfo.java
  (with props)
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java
  (with props)
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoPersistenceUnitInfo.java
  (with props)
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java
  (with props)
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/TransformerWrapper.java
  (with props)
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/resources/
    geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/resources/org.apache.aries.jpa.container.properties
  (with props)
Modified:
    geronimo/server/trunk/plugins/openjpa2/openjpa2/pom.xml
    geronimo/server/trunk/plugins/openjpa2/openjpa2/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/openjpa2/pom.xml

Added: 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=950759&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml (added)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml Wed Jun  2 21:06:14
2010
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.plugins</groupId>
+        <artifactId>openjpa2</artifactId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    
+    <groupId>org.apache.geronimo.modules</groupId>
+    <artifactId>geronimo-aries-jpa</artifactId>
+    <packaging>bundle</packaging>
+    <name>Geronimo Plugins, OpenJPA2 :: Aries JPA</name>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_2.0_spec</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.container</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.framework</groupId>
+            <artifactId>geronimo-transformer</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.aries</groupId>
+            <artifactId>org.apache.aries.util</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                            org.apache.geronimo.aries.jpa
+                        </Export-Package>
+                        <Import-Package>
+                            !org.apache.aries.jpa*,
+                            *
+                        </Import-Package>
+                        <Fragment-Host> 
+                            org.apache.aries.jpa.container
+                        </Fragment-Host>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfo.java?rev=950759&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfo.java
(added)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfo.java
Wed Jun  2 21:06:14 2010
@@ -0,0 +1,53 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa;
+
+import java.util.Collections;
+import java.util.Map;
+
+import javax.persistence.spi.PersistenceUnitInfo;
+
+import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
+import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+public class GeronimoManagedPersistenceUnitInfo implements ManagedPersistenceUnitInfo {
+
+    private final GeronimoPersistenceUnitInfo info;
+
+    public GeronimoManagedPersistenceUnitInfo(Bundle persistenceBundle,
+                                              ParsedPersistenceUnit unit,
+                                              ServiceReference providerRef) {
+        info = new GeronimoPersistenceUnitInfo(persistenceBundle, unit, providerRef);
+    }
+
+    public Map<String, Object> getContainerProperties() {
+        return Collections.emptyMap();
+    }
+
+    public PersistenceUnitInfo getPersistenceUnitInfo() {
+        return info;
+    }
+
+    public void destroy() {
+        info.destroy();
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=950759&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java
(added)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java
Wed Jun  2 21:06:14 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.aries.jpa;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
+import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
+import org.apache.aries.jpa.container.unit.impl.ManagedPersistenceUnitInfoFactoryImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public class GeronimoManagedPersistenceUnitInfoFactory extends ManagedPersistenceUnitInfoFactoryImpl
{
+    
+    private PersistenceUnitFragmentGenerator generator = new PersistenceUnitFragmentGenerator();
+    
+    private Map<Bundle, Collection<ManagedPersistenceUnitInfo>> map = 
+        Collections.synchronizedMap(new HashMap<Bundle, Collection<ManagedPersistenceUnitInfo>>());
+    
+    @Override
+    public Collection<ManagedPersistenceUnitInfo> createManagedPersistenceUnitMetadata(
+            BundleContext containerContext, 
+            Bundle persistenceBundle,
+            ServiceReference providerReference,
+            Collection<ParsedPersistenceUnit> persistenceMetadata) {
+        
+        Collection<ManagedPersistenceUnitInfo> managedUnits = new ArrayList<ManagedPersistenceUnitInfo>();
   
+        for (ParsedPersistenceUnit unit : persistenceMetadata) {
+            managedUnits.add(new GeronimoManagedPersistenceUnitInfo(persistenceBundle, unit,
providerReference));
+        }
+     
+        generator.persistenceUnitMetadataCreated(containerContext, persistenceBundle, providerReference,
managedUnits);
+        
+        map.put(persistenceBundle, managedUnits);
+        
+        return managedUnits;
+    }
+    
+    @Override
+    public void destroyPersistenceBundle(BundleContext containerContext, Bundle persistenceBundle)
{
+        Collection<ManagedPersistenceUnitInfo> managedUnits = map.remove(persistenceBundle);
+        if (managedUnits != null) {
+            for (ManagedPersistenceUnitInfo unit : managedUnits) {
+                ((GeronimoManagedPersistenceUnitInfo) unit).destroy();
+            }
+            generator.persistenceBundleDestroyed(containerContext, persistenceBundle);
+        }
+    }
+    
+}

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoManagedPersistenceUnitInfoFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoPersistenceUnitInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoPersistenceUnitInfo.java?rev=950759&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoPersistenceUnitInfo.java
(added)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoPersistenceUnitInfo.java
Wed Jun  2 21:06:14 2010
@@ -0,0 +1,57 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.spi.ClassTransformer;
+
+import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
+import org.apache.aries.jpa.container.unit.impl.PersistenceUnitInfoImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+public class GeronimoPersistenceUnitInfo extends PersistenceUnitInfoImpl {
+
+    private final List<TransformerWrapper> transformers;
+    private final Bundle bundle;
+    
+    public GeronimoPersistenceUnitInfo(Bundle bundle,
+                                       ParsedPersistenceUnit parsedData,
+                                       ServiceReference providerRef) {
+        super(bundle, parsedData, providerRef);
+        this.bundle = bundle;
+        this.transformers = new ArrayList<TransformerWrapper>();
+    }
+
+    @Override
+    public void addTransformer(ClassTransformer classTransformer) {
+        TransformerWrapper transformer = new TransformerWrapper(classTransformer, bundle);
+        org.apache.geronimo.transformer.TransformerAgent.addTransformer(transformer);
+        transformers.add(transformer);
+    }
+
+    public void destroy() {
+        for (TransformerWrapper transformer : transformers) {
+            org.apache.geronimo.transformer.TransformerAgent.removeTransformer(transformer);
+        }
+        transformers.clear();
+    }
+}

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoPersistenceUnitInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoPersistenceUnitInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/GeronimoPersistenceUnitInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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/PersistenceUnitFragmentGenerator.java?rev=950759&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java
(added)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java
Wed Jun  2 21:06:14 2010
@@ -0,0 +1,117 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
+import org.apache.aries.util.FragmentBuilder;
+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;
+import org.apache.xbean.osgi.bundle.util.BundleDescription.ImportPackage;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+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 {
+
+    private static final Logger LOG = LoggerFactory.getLogger(PersistenceUnitFragmentGenerator.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);
+            }
+            
+            fragmentMap.put(persistenceBundle, fragment);
+        }
+    }
+
+    private boolean needsFragment(Bundle persistenceBundle, Bundle providerBundle) {
+        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.", 
+                          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.",
+                              persistenceBundle.getSymbolicName());
+                    return false;
+                }
+            }
+        }
+        
+        return true;
+    }
+    
+    public void persistenceBundleDestroyed(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
+                }
+            }
+        }
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/PersistenceUnitFragmentGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/TransformerWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/TransformerWrapper.java?rev=950759&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/TransformerWrapper.java
(added)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/TransformerWrapper.java
Wed Jun  2 21:06:14 2010
@@ -0,0 +1,53 @@
+/**
+ *  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.aries.jpa;
+
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
+import java.security.ProtectionDomain;
+
+import javax.persistence.spi.ClassTransformer;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransformerWrapper implements ClassFileTransformer {
+
+    private final ClassTransformer classTransformer;
+    private final Bundle bundle;
+
+    public TransformerWrapper(ClassTransformer classTransformer, Bundle bundle) {
+        this.classTransformer = classTransformer;
+        this.bundle = bundle;
+    }
+
+    public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException
{
+        if (loader instanceof BundleReference && ((BundleReference) loader).getBundle()
== bundle) {
+            try {
+                return classTransformer.transform(loader, className, classBeingRedefined,
protectionDomain, classfileBuffer);
+            } catch (IllegalClassFormatException e) {
+                throw e;
+            } catch (RuntimeException e) {
+                return null;
+            }
+        }
+        return null;
+
+    }
+}

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/TransformerWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/TransformerWrapper.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/java/org/apache/geronimo/aries/jpa/TransformerWrapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/resources/org.apache.aries.jpa.container.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/resources/org.apache.aries.jpa.container.properties?rev=950759&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/resources/org.apache.aries.jpa.container.properties
(added)
+++ geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/resources/org.apache.aries.jpa.container.properties
Wed Jun  2 21:06:14 2010
@@ -0,0 +1 @@
+org.apache.aries.jpa.container.ManagedPersistenceUnitInfoFactory=org.apache.geronimo.aries.jpa.GeronimoManagedPersistenceUnitInfoFactory

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/resources/org.apache.aries.jpa.container.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/resources/org.apache.aries.jpa.container.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/openjpa2/geronimo-aries-jpa/src/main/resources/org.apache.aries.jpa.container.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/openjpa2/openjpa2/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/openjpa2/pom.xml?rev=950759&r1=950758&r2=950759&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/openjpa2/pom.xml (original)
+++ geronimo/server/trunk/plugins/openjpa2/openjpa2/pom.xml Wed Jun  2 21:06:14 2010
@@ -74,7 +74,13 @@
             <type>car</type>
         </dependency>
 
-       <dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-aries-jpa</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.aries.jpa</groupId>
             <artifactId>org.apache.aries.jpa.api</artifactId>
         </dependency>

Modified: geronimo/server/trunk/plugins/openjpa2/openjpa2/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/openjpa2/src/main/history/dependencies.xml?rev=950759&r1=950758&r2=950759&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/openjpa2/src/main/history/dependencies.xml (original)
+++ geronimo/server/trunk/plugins/openjpa2/openjpa2/src/main/history/dependencies.xml Wed
Jun  2 21:06:14 2010
@@ -58,6 +58,11 @@
     </dependency>
     <dependency>
         <groupId>org.apache.geronimo.modules</groupId>
+        <artifactId>geronimo-aries-jpa</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.modules</groupId>
         <artifactId>geronimo-openjpa2</artifactId>
         <type>jar</type>
     </dependency>

Modified: geronimo/server/trunk/plugins/openjpa2/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openjpa2/pom.xml?rev=950759&r1=950758&r2=950759&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openjpa2/pom.xml (original)
+++ geronimo/server/trunk/plugins/openjpa2/pom.xml Wed Jun  2 21:06:14 2010
@@ -125,6 +125,7 @@
 -->
 
     <modules>
+        <module>geronimo-aries-jpa</module>
         <module>geronimo-openjpa2</module>
         <module>geronimo-persistence-jpa20</module>
         <module>geronimo-persistence-jpa20-builder</module>



Mime
View raw message