You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by si...@apache.org on 2008/09/16 17:33:33 UTC
svn commit: r695939 - in /labs/magma/trunk/database-openjpa: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/magma/ src/main/java/org/apache/magma/database/
src/main/java/org/apache/magma/database/...
Author: simoneg
Date: Tue Sep 16 08:33:32 2008
New Revision: 695939
URL: http://svn.apache.org/viewvc?rev=695939&view=rev
Log:
Initial import.
Added:
labs/magma/trunk/database-openjpa/pom.xml
labs/magma/trunk/database-openjpa/src/
labs/magma/trunk/database-openjpa/src/main/
labs/magma/trunk/database-openjpa/src/main/java/
labs/magma/trunk/database-openjpa/src/main/java/org/
labs/magma/trunk/database-openjpa/src/main/java/org/apache/
labs/magma/trunk/database-openjpa/src/main/java/org/apache/magma/
labs/magma/trunk/database-openjpa/src/main/java/org/apache/magma/database/
labs/magma/trunk/database-openjpa/src/main/java/org/apache/magma/database/openjpa/
labs/magma/trunk/database-openjpa/src/main/java/org/apache/magma/database/openjpa/SupportTransformer.java
labs/magma/trunk/database-openjpa/src/main/resources/
labs/magma/trunk/database-openjpa/src/main/resources/META-INF/
labs/magma/trunk/database-openjpa/src/main/resources/META-INF/magma.devel.default.properties
Added: labs/magma/trunk/database-openjpa/pom.xml
URL: http://svn.apache.org/viewvc/labs/magma/trunk/database-openjpa/pom.xml?rev=695939&view=auto
==============================================================================
--- labs/magma/trunk/database-openjpa/pom.xml (added)
+++ labs/magma/trunk/database-openjpa/pom.xml Tue Sep 16 08:33:32 2008
@@ -0,0 +1,54 @@
+<?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.
+-->
+<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">
+ <parent>
+ <artifactId>magma-parent</artifactId>
+ <groupId>org.apache.magma</groupId>
+ <version>1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>database-openjpa</artifactId>
+ <name>OpenJPA database</name>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>magma</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.magma.tools</groupId>
+ <artifactId>maven-magma-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+ <description />
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.magma</groupId>
+ <artifactId>database-jpa</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ </dependencies>
+</project>
Added: labs/magma/trunk/database-openjpa/src/main/java/org/apache/magma/database/openjpa/SupportTransformer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/database-openjpa/src/main/java/org/apache/magma/database/openjpa/SupportTransformer.java?rev=695939&view=auto
==============================================================================
--- labs/magma/trunk/database-openjpa/src/main/java/org/apache/magma/database/openjpa/SupportTransformer.java (added)
+++ labs/magma/trunk/database-openjpa/src/main/java/org/apache/magma/database/openjpa/SupportTransformer.java Tue Sep 16 08:33:32 2008
@@ -0,0 +1,73 @@
+/*
+ * 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.magma.database.openjpa;
+
+import org.apache.magma.settings.ManageSettings;
+import org.apache.magma.settings.Settings;
+import org.apache.magma.settings.SettingsHolder;
+
+import java.security.AccessController;
+import java.util.Map;
+
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
+import org.apache.openjpa.enhance.PCClassFileTransformer;
+import org.apache.openjpa.lib.conf.Configuration;
+import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
+import org.apache.openjpa.lib.util.Options;
+import org.apache.openjpa.util.ClassResolver;
+
+public class SupportTransformer {
+
+ public static PCClassFileTransformer getTransformer(String paths) {
+ OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
+ Options opts = new Options();
+ ManageSettings.getHolder().override("openjpa.MetaDataFactory", "jpa(URLs=" + paths + ")");
+ Map<String, String> all = Settings.getAll();
+ for (Map.Entry<String, String> entry : all.entrySet()) {
+ opts.setProperty(entry.getKey(), entry.getValue());
+ }
+ //Configurations.populateConfiguration(conf, opts);
+ conf.fromProperties(opts);
+ // don't allow connections
+ conf.setConnectionUserName(null);
+ conf.setConnectionPassword(null);
+ conf.setConnectionURL(null);
+ conf.setConnectionDriverName(null);
+ conf.setConnectionFactoryName(null);
+
+ // set single class resolver
+ final ClassLoader tmpLoader = (ClassLoader) AccessController
+ .doPrivileged(J2DoPrivHelper
+ .newTemporaryClassLoaderAction((ClassLoader) AccessController
+ .doPrivileged(J2DoPrivHelper
+ .getContextClassLoaderAction())));
+ conf.setClassResolver(new ClassResolver() {
+ public ClassLoader getClassLoader(Class context, ClassLoader env) {
+ return tmpLoader;
+ }
+ });
+ conf.setReadOnly(Configuration.INIT_STATE_FREEZING);
+ conf.instantiateAll(); // avoid threading issues
+
+ PCClassFileTransformer transformer = new PCClassFileTransformer(conf
+ .newMetaDataRepositoryInstance(), opts, tmpLoader);
+ return transformer;
+ }
+
+}
Added: labs/magma/trunk/database-openjpa/src/main/resources/META-INF/magma.devel.default.properties
URL: http://svn.apache.org/viewvc/labs/magma/trunk/database-openjpa/src/main/resources/META-INF/magma.devel.default.properties?rev=695939&view=auto
==============================================================================
--- labs/magma/trunk/database-openjpa/src/main/resources/META-INF/magma.devel.default.properties (added)
+++ labs/magma/trunk/database-openjpa/src/main/resources/META-INF/magma.devel.default.properties Tue Sep 16 08:33:32 2008
@@ -0,0 +1,15 @@
+#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.
+openjpa.jdbc.SynchronizeMappings=buildSchema(ForeignKeys=true)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org