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 2015/04/22 22:06:38 UTC
tomee git commit: s/AutoJPA/PersistenceUnitDefinition/
Repository: tomee
Updated Branches:
refs/heads/master a8b111da7 -> 777a5792e
s/AutoJPA/PersistenceUnitDefinition/
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/777a5792
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/777a5792
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/777a5792
Branch: refs/heads/master
Commit: 777a5792e05c95899be0e1c23044dc2c49c820b1
Parents: a8b111d
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed Apr 22 22:06:31 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Wed Apr 22 22:06:31 2015 +0200
----------------------------------------------------------------------
.../openejb/api/configuration/AutoJPA.java | 39 ----------
.../openejb/api/configuration/AutoJPAs.java | 28 -------
.../PersistenceUnitDefinition.java | 39 ++++++++++
.../PersistenceUnitDefinitions.java | 28 +++++++
.../openejb/config/ConfigurationDeployer.java | 16 ++--
.../openejb/configuration/AutoJPATest.java | 77 --------------------
.../PersistenceUnitDefinitionTest.java | 77 ++++++++++++++++++++
7 files changed, 152 insertions(+), 152 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/777a5792/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/AutoJPA.java
----------------------------------------------------------------------
diff --git a/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/AutoJPA.java b/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/AutoJPA.java
deleted file mode 100644
index 72d9fde..0000000
--- a/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/AutoJPA.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.api.configuration;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import javax.persistence.SharedCacheMode;
-import javax.persistence.ValidationMode;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface AutoJPA {
- String unitName() default "jpa";
- String provider() default "auto";
- String jtaDataSource() default "auto";
- String nonJtaDataSource() default "auto";
- String entitiesPackage() default "auto";
- String[] properties() default {};
- boolean ddlAuto() default true;
- boolean jta() default true;
- ValidationMode validationMode() default ValidationMode.AUTO;
- SharedCacheMode cacheMode() default SharedCacheMode.UNSPECIFIED;
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/777a5792/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/AutoJPAs.java
----------------------------------------------------------------------
diff --git a/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/AutoJPAs.java b/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/AutoJPAs.java
deleted file mode 100644
index f9f01b7..0000000
--- a/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/AutoJPAs.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.api.configuration;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface AutoJPAs {
- AutoJPA[] value() default {};
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/777a5792/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/PersistenceUnitDefinition.java
----------------------------------------------------------------------
diff --git a/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/PersistenceUnitDefinition.java b/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/PersistenceUnitDefinition.java
new file mode 100644
index 0000000..31d35b9
--- /dev/null
+++ b/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/PersistenceUnitDefinition.java
@@ -0,0 +1,39 @@
+/*
+ * 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.api.configuration;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import javax.persistence.SharedCacheMode;
+import javax.persistence.ValidationMode;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PersistenceUnitDefinition {
+ String unitName() default "jpa";
+ String provider() default "auto";
+ String jtaDataSource() default "auto";
+ String nonJtaDataSource() default "auto";
+ String entitiesPackage() default "auto";
+ String[] properties() default {};
+ boolean ddlAuto() default true;
+ boolean jta() default true;
+ ValidationMode validationMode() default ValidationMode.AUTO;
+ SharedCacheMode cacheMode() default SharedCacheMode.UNSPECIFIED;
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/777a5792/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/PersistenceUnitDefinitions.java
----------------------------------------------------------------------
diff --git a/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/PersistenceUnitDefinitions.java b/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/PersistenceUnitDefinitions.java
new file mode 100644
index 0000000..cb72fa2
--- /dev/null
+++ b/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/PersistenceUnitDefinitions.java
@@ -0,0 +1,28 @@
+/*
+ * 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.api.configuration;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PersistenceUnitDefinitions {
+ PersistenceUnitDefinition[] value() default {};
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/777a5792/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java
index 22f2e01..637e1bb 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java
@@ -17,8 +17,8 @@
package org.apache.openejb.config;
import org.apache.openejb.OpenEJBException;
-import org.apache.openejb.api.configuration.AutoJPA;
-import org.apache.openejb.api.configuration.AutoJPAs;
+import org.apache.openejb.api.configuration.PersistenceUnitDefinition;
+import org.apache.openejb.api.configuration.PersistenceUnitDefinitions;
import org.apache.openejb.jee.jpa.unit.Persistence;
import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
import org.apache.openejb.jee.jpa.unit.TransactionType;
@@ -34,19 +34,19 @@ public class ConfigurationDeployer implements DynamicDeployer {
continue;
}
- for (final Class<?> configClass : module.getFinder().findAnnotatedClasses(AutoJPA.class)) {
- configureJpa(appModule, configClass.getAnnotation(AutoJPA.class));
+ for (final Class<?> configClass : module.getFinder().findAnnotatedClasses(PersistenceUnitDefinition.class)) {
+ configureJpa(appModule, configClass.getAnnotation(PersistenceUnitDefinition.class));
}
- for (final Class<?> configClass : module.getFinder().findAnnotatedClasses(AutoJPAs.class)) {
- for (final AutoJPA autoJPA : configClass.getAnnotation(AutoJPAs.class).value()) {
- configureJpa(appModule, autoJPA);
+ for (final Class<?> configClass : module.getFinder().findAnnotatedClasses(PersistenceUnitDefinitions.class)) {
+ for (final PersistenceUnitDefinition persistenceUnitDefinition : configClass.getAnnotation(PersistenceUnitDefinitions.class).value()) {
+ configureJpa(appModule, persistenceUnitDefinition);
}
}
}
return appModule;
}
- private void configureJpa(final AppModule appModule, final AutoJPA annotation) {
+ private void configureJpa(final AppModule appModule, final PersistenceUnitDefinition annotation) {
if (annotation == null) {
return;
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/777a5792/container/openejb-core/src/test/java/org/apache/openejb/configuration/AutoJPATest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/configuration/AutoJPATest.java b/container/openejb-core/src/test/java/org/apache/openejb/configuration/AutoJPATest.java
deleted file mode 100644
index be35e31..0000000
--- a/container/openejb-core/src/test/java/org/apache/openejb/configuration/AutoJPATest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.configuration;
-
-import org.apache.openejb.api.configuration.AutoJPA;
-import org.apache.openejb.api.configuration.AutoJPAs;
-import org.apache.openejb.junit.ApplicationComposer;
-import org.apache.openejb.persistence.JtaEntityManager;
-import org.apache.openejb.testing.Classes;
-import org.apache.openejb.testing.SimpleLog;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.persistence.Entity;
-import javax.persistence.EntityManager;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.PersistenceContext;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-@SimpleLog
-@Classes(innerClassesAsBean = true)
-@RunWith(ApplicationComposer.class)
-public class AutoJPATest {
- @PersistenceContext(unitName = "jpa")
- private EntityManager em1;
-
- @PersistenceContext(unitName = "jpa2")
- private EntityManager em2;
-
- @Test
- public void run() {
- assertNotNull(em1);
- assertNotNull(em2);
- assertTrue(JtaEntityManager.class.isInstance(em1));
- }
-
- @AutoJPAs({
- @AutoJPA,
- @AutoJPA(unitName = "jpa2", jta = false)
- })
- public static class MyConfig {
- }
-
- @Entity
- public static class AnEntity {
- @Id
- @GeneratedValue
- private long id;
-
- public long getId() {
- return id;
- }
-
- public void setId(final long id) {
- this.id = id;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/777a5792/container/openejb-core/src/test/java/org/apache/openejb/configuration/PersistenceUnitDefinitionTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/configuration/PersistenceUnitDefinitionTest.java b/container/openejb-core/src/test/java/org/apache/openejb/configuration/PersistenceUnitDefinitionTest.java
new file mode 100644
index 0000000..81a8041
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/configuration/PersistenceUnitDefinitionTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.configuration;
+
+import org.apache.openejb.api.configuration.PersistenceUnitDefinition;
+import org.apache.openejb.api.configuration.PersistenceUnitDefinitions;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.persistence.JtaEntityManager;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.SimpleLog;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.persistence.Entity;
+import javax.persistence.EntityManager;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.PersistenceContext;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@SimpleLog
+@Classes(innerClassesAsBean = true)
+@RunWith(ApplicationComposer.class)
+public class PersistenceUnitDefinitionTest {
+ @PersistenceContext(unitName = "jpa")
+ private EntityManager em1;
+
+ @PersistenceContext(unitName = "jpa2")
+ private EntityManager em2;
+
+ @Test
+ public void run() {
+ assertNotNull(em1);
+ assertNotNull(em2);
+ assertTrue(JtaEntityManager.class.isInstance(em1));
+ }
+
+ @PersistenceUnitDefinitions({
+ @PersistenceUnitDefinition,
+ @PersistenceUnitDefinition(unitName = "jpa2", jta = false)
+ })
+ public static class MyConfig {
+ }
+
+ @Entity
+ public static class AnEntity {
+ @Id
+ @GeneratedValue
+ private long id;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(final long id) {
+ this.id = id;
+ }
+ }
+}