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/23 00:00:48 UTC
tomee git commit: TOMEE-1556 basic @ApplicationComposer + arquillian
1.1.8.Final + small fix to support java:global in persistence units
Repository: tomee
Updated Branches:
refs/heads/master 777a5792e -> cc463c3cb
TOMEE-1556 basic @ApplicationComposer + arquillian 1.1.8.Final + small fix to support java:global in persistence units
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/cc463c3c
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/cc463c3c
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/cc463c3c
Branch: refs/heads/master
Commit: cc463c3cb56d3bff120c091fb7368e213a434781
Parents: 777a579
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Thu Apr 23 00:00:32 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Thu Apr 23 00:00:32 2015 +0200
----------------------------------------------------------------------
.../appcomposer/AppComposerConfiguration.java | 31 +++
.../tests/appcomposer/AppComposerTest.java | 51 +++++
.../arquillian/tests/appcomposer/Bean1.java | 29 +++
.../arquillian/tests/appcomposer/Bean2.java | 20 ++
.../arquillian/tests/appcomposer/Endpoint.java | 38 ++++
arquillian/arquillian-tomee-tests/pom.xml | 24 +-
.../api/configuration/ApplicationComposer.java | 28 +++
.../openejb/config/AnnotationDeployer.java | 2 +-
.../config/ApplicationComposerDeployer.java | 226 +++++++++++++++++++
.../org/apache/openejb/config/AutoConfig.java | 10 +-
.../openejb/config/ConfigurationFactory.java | 2 +
.../apache/openejb/testing/JaxrsProviders.java | 6 +-
pom.xml | 2 +-
13 files changed, 455 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/AppComposerConfiguration.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/AppComposerConfiguration.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/AppComposerConfiguration.java
new file mode 100644
index 0000000..39a1872
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/AppComposerConfiguration.java
@@ -0,0 +1,31 @@
+/**
+ * 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.arquillian.tests.appcomposer;
+
+import org.apache.openejb.api.configuration.ApplicationComposer;
+import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.Module;
+
+@ApplicationComposer
+@Classes(cdi = true, value = { Endpoint.class, Bean1.class })
+public class AppComposerConfiguration {
+ @Module
+ public static PersistenceUnit unit() {
+ return new PersistenceUnit("jpa");
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/AppComposerTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/AppComposerTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/AppComposerTest.java
new file mode 100644
index 0000000..31434ea
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/AppComposerTest.java
@@ -0,0 +1,51 @@
+/**
+ * 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.arquillian.tests.appcomposer;
+
+import org.apache.openejb.arquillian.common.IO;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class AppComposerTest {
+ @Deployment(testable = false)
+ public static Archive<?> war() {
+ return ShrinkWrap.create(WebArchive.class, "AppComposerTest.war")
+ .addClasses(AppComposerConfiguration.class, Bean1.class, Bean2.class, Endpoint.class);
+ }
+
+ @ArquillianResource
+ private URL url;
+
+ @Test
+ public void get() throws IOException {
+ assertEquals(
+ "org.apache.openejb.arquillian.tests.appcomposer.Bean1_true_org.apache.openejb.persistence.JtaEntityManager",
+ IO.slurp(new URL(url.toExternalForm() + "endpoint")));
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Bean1.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Bean1.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Bean1.java
new file mode 100644
index 0000000..789936e
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Bean1.java
@@ -0,0 +1,29 @@
+/**
+ * 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.arquillian.tests.appcomposer;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+public class Bean1 {
+ @PersistenceContext
+ private EntityManager em;
+
+ public EntityManager getEm() {
+ return em;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Bean2.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Bean2.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Bean2.java
new file mode 100644
index 0000000..c3daf49
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Bean2.java
@@ -0,0 +1,20 @@
+/**
+ * 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.arquillian.tests.appcomposer;
+
+public class Bean2 {
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Endpoint.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Endpoint.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Endpoint.java
new file mode 100644
index 0000000..ce08172
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/appcomposer/Endpoint.java
@@ -0,0 +1,38 @@
+/**
+ * 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.arquillian.tests.appcomposer;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("endpoint")
+@ApplicationScoped
+public class Endpoint {
+ @Inject
+ private Bean1 bean1;
+
+ @Inject
+ private Instance<Bean2> bean2;
+
+ @GET
+ public String get() {
+ return bean1.getClass().getName() + "_" + bean2.isUnsatisfied() + "_" + bean1.getEm().getClass().getName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/arquillian/arquillian-tomee-tests/pom.xml
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/pom.xml b/arquillian/arquillian-tomee-tests/pom.xml
index 5394a56..d136e61 100644
--- a/arquillian/arquillian-tomee-tests/pom.xml
+++ b/arquillian/arquillian-tomee-tests/pom.xml
@@ -279,34 +279,37 @@
</configuration>
</execution>
<execution>
- <id>test-tomee-remote-plus</id>
+ <id>test-tomee-remote-plume</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
- <skip>${skip.remote.plus}</skip>
+ <skip>${skip.remote.plume}</skip>
<systemPropertyVariables>
<openejb.arquillian.debug>true</openejb.arquillian.debug>
<tomee.version>${tomee.version}</tomee.version>
- <tomee.classifier>plus</tomee.classifier>
+ <tomee.classifier>plume</tomee.classifier>
<arquillian.launch>tomee-remote</arquillian.launch>
<openejb.arquillian.adapter>tomee-remote</openejb.arquillian.adapter>
</systemPropertyVariables>
+ <excludes>
+ <exclude>**/AppComposerTest.java</exclude>
+ </excludes>
</configuration>
</execution>
<execution>
- <id>test-tomee-remote-plume</id>
+ <id>test-tomee-remote-plus</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
- <skip>${skip.remote.plume}</skip>
+ <skip>${skip.remote.plus}</skip>
<systemPropertyVariables>
<openejb.arquillian.debug>true</openejb.arquillian.debug>
<tomee.version>${tomee.version}</tomee.version>
- <tomee.classifier>plume</tomee.classifier>
+ <tomee.classifier>plus</tomee.classifier>
<arquillian.launch>tomee-remote</arquillian.launch>
<openejb.arquillian.adapter>tomee-remote</openejb.arquillian.adapter>
</systemPropertyVariables>
@@ -361,6 +364,9 @@
<arquillian.launch>tomee-webapp</arquillian.launch>
<openejb.arquillian.adapter>tomee-webapp</openejb.arquillian.adapter>
</systemPropertyVariables>
+ <excludes>
+ <exclude>**/AppComposerTest.java</exclude>
+ </excludes>
</configuration>
</execution>
</executions>
@@ -518,6 +524,9 @@
<arquillian.launch>tomee-remote</arquillian.launch>
<openejb.arquillian.adapter>tomee-remote</openejb.arquillian.adapter>
</systemPropertyVariables>
+ <excludes>
+ <exclude>**/AppComposerTest.java</exclude>
+ </excludes>
</configuration>
</execution>
@@ -572,6 +581,9 @@
<arquillian.launch>tomee-webapp</arquillian.launch>
<openejb.arquillian.adapter>tomee-webapp</openejb.arquillian.adapter>
</systemPropertyVariables>
+ <excludes>
+ <exclude>**/AppComposerTest.java</exclude>
+ </excludes>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/ApplicationComposer.java
----------------------------------------------------------------------
diff --git a/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/ApplicationComposer.java b/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/ApplicationComposer.java
new file mode 100644
index 0000000..f5e1011
--- /dev/null
+++ b/container/openejb-api/src/main/java/org/apache/openejb/api/configuration/ApplicationComposer.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 ApplicationComposer {
+ boolean metadataComplete() default false;
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
index 32e3179..b87ed1e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
@@ -5529,7 +5529,7 @@ public class AnnotationDeployer implements DynamicDeployer {
return 0;
}
- private static Collection<String> findRestClasses(final WebModule webModule, final IAnnotationFinder finder) {
+ public static Collection<String> findRestClasses(final WebModule webModule, final IAnnotationFinder finder) {
final Collection<String> classes = new HashSet<String>();
// annotations on classes
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/container/openejb-core/src/main/java/org/apache/openejb/config/ApplicationComposerDeployer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ApplicationComposerDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ApplicationComposerDeployer.java
new file mode 100644
index 0000000..80f3cdc
--- /dev/null
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ApplicationComposerDeployer.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.config;
+
+import org.apache.openejb.BeanContext;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.api.configuration.ApplicationComposer;
+import org.apache.openejb.jee.Beans;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.TransactionType;
+import org.apache.openejb.jee.jpa.unit.Persistence;
+import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.Descriptor;
+import org.apache.openejb.testing.Descriptors;
+import org.apache.openejb.testing.JaxrsProviders;
+import org.apache.xbean.finder.AnnotationFinder;
+import org.apache.xbean.finder.archive.Archive;
+import org.apache.xbean.finder.archive.ClassesArchive;
+import org.apache.xbean.finder.archive.CompositeArchive;
+import org.apache.xbean.finder.archive.FilteredArchive;
+import org.apache.xbean.finder.filter.Filters;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Properties;
+
+// use temp classloader so be careful with the decorated class
+//
+// dont reuse ApplicationComposers to control what we support here + cleanup what we don't want to support (XModule -> test only)
+public class ApplicationComposerDeployer implements DynamicDeployer {
+ @Override
+ public AppModule deploy(final AppModule appModule) throws OpenEJBException {
+ if (!appModule.isStandaloneModule()) {
+ return appModule;
+ }
+
+ for (final EjbModule ejbModule : appModule.getEjbModules()) {
+ if (ejbModule.getFinder() == null) {
+ continue;
+ }
+ WebModule webModule = null;
+ for (final WebModule web : appModule.getWebModules()) {
+ if (!web.getModuleId().equals(ejbModule.getModuleId())) {
+ continue;
+ }
+ webModule = web;
+ break;
+ }
+ if (webModule == null) {
+ continue;
+ }
+
+ for (final Class<?> clazz : ejbModule.getFinder().findAnnotatedClasses(ApplicationComposer.class)) {
+ final ApplicationComposer applicationComposer = clazz.getAnnotation(ApplicationComposer.class);
+
+ final Descriptor descriptor = clazz.getAnnotation(Descriptor.class);
+ if (descriptor != null) {
+ configureDescriptor(appModule, descriptor);
+ }
+ final Descriptors descriptors = clazz.getAnnotation(Descriptors.class);
+ if (descriptors != null) {
+ for (final Descriptor d : descriptors.value()) {
+ configureDescriptor(appModule, descriptor);
+ }
+ }
+
+ final Classes classes = clazz.getAnnotation(Classes.class);
+ if (classes != null) {
+ configureClasses(webModule, ejbModule, applicationComposer, classes);
+ }
+
+ Object instance = null;
+ final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(org.apache.openejb.util.Classes.ancestors(clazz)));
+ for (final Method m : finder.findAnnotatedMethods(org.apache.openejb.testing.Module.class)) {
+ instance = configureModule(appModule, ejbModule, clazz, instance, m);
+ }
+ for (final Method m : finder.findAnnotatedMethods(Configuration.class)) {
+ instance = configureConfiguration(appModule, clazz, instance, m);
+ }
+
+ final JaxrsProviders jaxrsProviders = clazz.getAnnotation(JaxrsProviders.class);
+ if (jaxrsProviders != null) {
+ for (final Class<?> c : jaxrsProviders.value()) {
+ webModule.getJaxrsProviders().add(c.getName());
+ }
+ }
+ }
+ }
+ return appModule;
+ }
+
+ private Object configureConfiguration(final AppModule appModule, final Class<?> clazz, Object instance, final Method m) {
+ final int modifiers = m.getModifiers();
+ if (!Modifier.isPublic(modifiers)) {
+ throw new IllegalArgumentException("@Configuration should be public");
+ }
+ final boolean isStatic = Modifier.isStatic(modifiers);
+ if (!isStatic) {
+ try {
+ instance = clazz.newInstance();
+ } catch (final Exception e) {
+ // no-op
+ }
+ }
+ try {
+ final Object result = m.invoke(isStatic ? null : instance);
+ if (Properties.class.isInstance(result)) {
+ appModule.getProperties().putAll(Properties.class.cast(result));
+ } else {
+ throw new IllegalArgumentException(result + " not yet supported (" + m + ")");
+ }
+ } catch (final IllegalAccessException | InvocationTargetException e) {
+ throw new IllegalStateException(e);
+ }
+ return instance;
+ }
+
+ private Object configureModule(final AppModule appModule, final EjbModule ejbModule, final Class<?> clazz, Object instance, final Method m) {
+ final int modifiers = m.getModifiers();
+ if (!Modifier.isPublic(modifiers)) {
+ throw new IllegalArgumentException("@Module should be public");
+ }
+ final boolean isStatic = Modifier.isStatic(modifiers);
+ if (!isStatic) {
+ try {
+ instance = clazz.newInstance();
+ } catch (final Exception e) {
+ // no-op
+ }
+ }
+ try {
+ final Object result = m.invoke(isStatic ? null : instance);
+ if (EjbJar.class.isInstance(result)) {
+ ejbModule.setEjbJar(EjbJar.class.cast(result));
+ } else if (Persistence.class.isInstance(result)) {
+ final Persistence persistence = Persistence.class.cast(result);
+ if (!persistence.getPersistenceUnit().isEmpty()) {
+ appModule.getPersistenceModules().add(new PersistenceModule(persistence.getPersistenceUnit().iterator().next().getName(), persistence));
+ }
+ } else if (PersistenceUnit.class.isInstance(result)) {
+ final PersistenceUnit unit = PersistenceUnit.class.cast(result);
+ appModule.addPersistenceModule(new PersistenceModule(unit.getName(), new Persistence(unit)));
+ } else if (Beans.class.isInstance(result)) {
+ final Beans beans = Beans.class.cast(result);
+ ejbModule.setBeans(beans);
+ } else {
+ throw new IllegalArgumentException(result + " not yet supported (" + m + ")");
+ }
+ } catch (final IllegalAccessException | InvocationTargetException e) {
+ throw new IllegalStateException(e);
+ }
+ return instance;
+ }
+
+ private void configureClasses(final WebModule web, final EjbModule ejbModule,
+ final ApplicationComposer applicationComposer, final Classes classes) {
+ ejbModule.getEjbJar().setMetadataComplete(applicationComposer.metadataComplete());
+
+ final Collection<Archive> archives = new LinkedList<>();
+ if (classes.value().length > 0) {
+ archives.add(new ClassesArchive(classes.value()));
+ }
+ if (classes.cdi()) {
+ final Beans beans = new Beans();
+ for (final Class<?> c : classes.cdiAlternatives()) {
+ beans.addAlternativeClass(c);
+ }
+ for (final Class<?> c : classes.cdiDecorators()) {
+ beans.addDecorator(c);
+ }
+ for (final Class<?> c : classes.cdiInterceptors()) {
+ beans.addInterceptor(c);
+ }
+ ejbModule.setBeans(beans);
+
+ if (applicationComposer.metadataComplete()) {
+ for (final Class<?> c : classes.value()) {
+ beans.addManagedClass(null, c.getName());
+ }
+
+ final String name = BeanContext.Comp.openejbCompName(web.getModuleId());
+ final org.apache.openejb.jee.ManagedBean managedBean = new CompManagedBean(name, BeanContext.Comp.class);
+ managedBean.setTransactionType(TransactionType.BEAN);
+ ejbModule.getEjbJar().addEnterpriseBean(managedBean);
+ }
+ }
+
+ final CompositeArchive archive = new CompositeArchive(archives);
+ final Archive finalArchive = classes.excludes().length > 0 ? new FilteredArchive(archive, Filters.invert(Filters.prefixes(classes.excludes()))) : archive;
+ ejbModule.setFinder(new FinderFactory.OpenEJBAnnotationFinder(finalArchive).link());
+
+ web.setFinder(ejbModule.getFinder());
+ web.getWebApp().setMetadataComplete(ejbModule.getEjbJar().isMetadataComplete());
+ }
+
+ private void configureDescriptor(final AppModule appModule, final Descriptor descriptor) {
+ URL resource = appModule.getClassLoader().getResource(descriptor.path());
+ try {
+ appModule.getAltDDs().put(descriptor.name(), resource == null ? new File(descriptor.path()).toURI().toURL() : resource);
+ } catch (final MalformedURLException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
index 472eb26..b896367 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
@@ -1340,8 +1340,10 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
logger.debug("raw <jta-data-source>" + unit.getJtaDataSource() + "</jta-datasource>");
logger.debug("raw <non-jta-data-source>" + unit.getNonJtaDataSource() + "</non-jta-datasource>");
- unit.setJtaDataSource(normalizeResourceId(unit.getJtaDataSource()));
- unit.setNonJtaDataSource(normalizeResourceId(unit.getNonJtaDataSource()));
+ final String originalJtaDataSource = unit.getJtaDataSource(); // keep it can start with java:global for instance
+ unit.setJtaDataSource(normalizeResourceId(originalJtaDataSource));
+ final String originalNonJtaDataSource = unit.getNonJtaDataSource();
+ unit.setNonJtaDataSource(normalizeResourceId(originalNonJtaDataSource));
logger.debug("normalized <jta-data-source>" + unit.getJtaDataSource() + "</jta-datasource>");
logger.debug("normalized <non-jta-data-source>" + unit.getNonJtaDataSource() + "</non-jta-datasource>");
@@ -1381,7 +1383,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
// first try exact matching without JtaManaged which is not mandatory actually (custom DS + JTADataSourceWrapperFactory)
final String jtaWithJavaAndSlash = replaceJavaAndSlash(unit.getJtaDataSource());
- for (final String potentialName : asList(prefix + jtaWithJavaAndSlash, jtaWithJavaAndSlash)) {
+ for (final String potentialName : asList(prefix + jtaWithJavaAndSlash, originalJtaDataSource, jtaWithJavaAndSlash)) {
if(potentialName == null) {
// If unit.getJtaDataSource() is null, one of the potentialName is also null.
continue;
@@ -1399,7 +1401,7 @@ public class AutoConfig implements DynamicDeployer, JndiConstants {
}
final String nonJtaWithJavaAndSlash = replaceJavaAndSlash(unit.getNonJtaDataSource());
- for (final String potentialName : asList(prefix + nonJtaWithJavaAndSlash, nonJtaWithJavaAndSlash)) {
+ for (final String potentialName : asList(prefix + nonJtaWithJavaAndSlash, originalNonJtaDataSource, nonJtaWithJavaAndSlash)) {
if(potentialName == null) {
// If unit.getNonJtaDataSource() is null, one of the potentialName is also null.
continue;
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
index e35f430..6f6c787 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
@@ -215,6 +215,8 @@ public class ConfigurationFactory implements OpenEjbConfigurationFactory {
chain.add(new GeneratedClientModules.Add());
+ chain.add(new ApplicationComposerDeployer()); // before read descriptors and moreover AnnotationDeploer
+
chain.add(new ReadDescriptors());
chain.add(appContextConfigDeployer);
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/container/openejb-core/src/main/java/org/apache/openejb/testing/JaxrsProviders.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/JaxrsProviders.java b/container/openejb-core/src/main/java/org/apache/openejb/testing/JaxrsProviders.java
index d04e250..0e0487e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/testing/JaxrsProviders.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/JaxrsProviders.java
@@ -17,12 +17,14 @@
package org.apache.openejb.testing;
-import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-@Target(ElementType.METHOD)
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+
+@Target({ METHOD, TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface JaxrsProviders {
Class<?>[] value() default {};
http://git-wip-us.apache.org/repos/asf/tomee/blob/cc463c3c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d92015b..7c0602e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -122,7 +122,7 @@
<!-- to change easily the javaee api version -->
<javaee-api.version>7.0-SNAPSHOT</javaee-api.version>
- <version.arquillian>1.1.7.Final</version.arquillian>
+ <version.arquillian>1.1.8.Final</version.arquillian>
<version.shrinkwrap.descriptor>2.0.0-alpha-7</version.shrinkwrap.descriptor>
<version.shrinkwrap.shrinkwrap>1.2.2</version.shrinkwrap.shrinkwrap>