activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject activemq-artemis git commit: ARTEMIS-1020 Fixing CDI client
Date Mon, 06 Mar 2017 19:58:21 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master d12330f15 -> ffb7c5654


ARTEMIS-1020 Fixing CDI client

Observe process bean when finding eligible bean classes to allow producer methods.

This closes #1066


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/ffb7c565
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/ffb7c565
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/ffb7c565

Branch: refs/heads/master
Commit: ffb7c5654a7614813e94d7f6e7934e37dce82139
Parents: d12330f
Author: John D. Ament <johndament@apache.org>
Authored: Mon Mar 6 13:34:50 2017 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Mon Mar 6 14:54:22 2017 -0500

----------------------------------------------------------------------
 .../client/cdi/extension/ArtemisExtension.java  | 18 +++---
 .../client/cdi/logger/ActiveMQCDILogger.java    |  6 +-
 .../cdi/bootstrap/CDIBootstrapProducerTest.java | 61 ++++++++++++++++++++
 .../artemis/cdi/bootstrap/CDIProducers.java     | 35 +++++++++++
 4 files changed, 110 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ffb7c565/artemis-cdi-client/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisExtension.java
----------------------------------------------------------------------
diff --git a/artemis-cdi-client/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisExtension.java
b/artemis-cdi-client/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisExtension.java
index d9a0d54..6f28bc2 100644
--- a/artemis-cdi-client/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisExtension.java
+++ b/artemis-cdi-client/src/main/java/org/apache/artemis/client/cdi/extension/ArtemisExtension.java
@@ -22,7 +22,7 @@ package org.apache.artemis.client.cdi.extension;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.inject.spi.ProcessBean;
 
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.artemis.client.cdi.configuration.ArtemisClientConfiguration;
@@ -33,14 +33,18 @@ public class ArtemisExtension implements Extension {
    private boolean foundEmbeddedConfig = false;
    private boolean foundConfiguration = false;
 
-   <T extends ArtemisClientConfiguration> void foundClientConfig(@Observes ProcessAnnotatedType<T>
pat) {
-      ActiveMQCDILogger.LOGGER.discoveredConfiguration(pat);
-      foundConfiguration = true;
+   void foundClientConfig(@Observes ProcessBean<?> processBean) {
+      if (processBean.getBean().getTypes().contains(ArtemisClientConfiguration.class)) {
+         ActiveMQCDILogger.LOGGER.discoveredConfiguration(processBean);
+         foundConfiguration = true;
+      }
    }
 
-   <T extends Configuration> void foundEmbeddedConfig(@Observes ProcessAnnotatedType<T>
pat) {
-      ActiveMQCDILogger.LOGGER.discoveredClientConfiguration(pat);
-      foundEmbeddedConfig = true;
+   void foundEmbeddedConfig(@Observes ProcessBean<?> processBean) {
+      if (processBean.getBean().getTypes().contains(Configuration.class)) {
+         ActiveMQCDILogger.LOGGER.discoveredClientConfiguration(processBean);
+         foundEmbeddedConfig = true;
+      }
    }
 
    void afterBeanDiscovery(@Observes AfterBeanDiscovery afterBeanDiscovery) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ffb7c565/artemis-cdi-client/src/main/java/org/apache/artemis/client/cdi/logger/ActiveMQCDILogger.java
----------------------------------------------------------------------
diff --git a/artemis-cdi-client/src/main/java/org/apache/artemis/client/cdi/logger/ActiveMQCDILogger.java
b/artemis-cdi-client/src/main/java/org/apache/artemis/client/cdi/logger/ActiveMQCDILogger.java
index fd2f7e7..f02d51b 100644
--- a/artemis-cdi-client/src/main/java/org/apache/artemis/client/cdi/logger/ActiveMQCDILogger.java
+++ b/artemis-cdi-client/src/main/java/org/apache/artemis/client/cdi/logger/ActiveMQCDILogger.java
@@ -19,7 +19,7 @@
 
 package org.apache.artemis.client.cdi.logger;
 
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.inject.spi.ProcessBean;
 
 import org.jboss.logging.BasicLogger;
 import org.jboss.logging.Logger;
@@ -48,11 +48,11 @@ public interface ActiveMQCDILogger extends BasicLogger {
 
    @LogMessage
    @Message(id = 571000, value = "Discovered configuration class {0}", format = Message.Format.MESSAGE_FORMAT)
-   void discoveredConfiguration(ProcessAnnotatedType<?> pat);
+   void discoveredConfiguration(ProcessBean<?> pb);
 
    @LogMessage
    @Message(id = 571001, value = "Discovered client configuration class {0}", format = Message.Format.MESSAGE_FORMAT)
-   void discoveredClientConfiguration(ProcessAnnotatedType<?> pat);
+   void discoveredClientConfiguration(ProcessBean<?> pb);
 
    @LogMessage(level = Logger.Level.DEBUG)
    @Message(id = 573000, value = "Configuration found, not using built in configuration")

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ffb7c565/artemis-cdi-client/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIBootstrapProducerTest.java
----------------------------------------------------------------------
diff --git a/artemis-cdi-client/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIBootstrapProducerTest.java
b/artemis-cdi-client/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIBootstrapProducerTest.java
new file mode 100644
index 0000000..c999226
--- /dev/null
+++ b/artemis-cdi-client/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIBootstrapProducerTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.activemq.artemis.cdi.bootstrap;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+import org.apache.artemis.client.cdi.configuration.ArtemisClientConfiguration;
+import org.apache.artemis.client.cdi.extension.ArtemisExtension;
+import org.apache.artemis.client.cdi.factory.ConnectionFactoryProvider;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class CDIBootstrapProducerTest {
+   @Deployment
+   public static Archive<?> createArchive() {
+      return ShrinkWrap.create(JavaArchive.class)
+         .addAsServiceProviderAndClasses(Extension.class, ArtemisExtension.class)
+         .addClasses(ConnectionFactoryProvider.class, CDIProducers.class)
+         .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+   }
+
+   @Inject
+   private Instance<ArtemisClientConfiguration> artemisClientConfigurations;
+
+   @Test
+   public void shouldStartJMS() throws Exception {
+      assertFalse(artemisClientConfigurations.isAmbiguous());
+      assertFalse(artemisClientConfigurations.isUnsatisfied());
+      assertTrue(artemisClientConfigurations.iterator().hasNext());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ffb7c565/artemis-cdi-client/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIProducers.java
----------------------------------------------------------------------
diff --git a/artemis-cdi-client/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIProducers.java
b/artemis-cdi-client/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIProducers.java
new file mode 100644
index 0000000..625268c
--- /dev/null
+++ b/artemis-cdi-client/src/test/java/org/apache/activemq/artemis/cdi/bootstrap/CDIProducers.java
@@ -0,0 +1,35 @@
+/*
+ * 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.activemq.artemis.cdi.bootstrap;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+
+import org.apache.artemis.client.cdi.configuration.ArtemisClientConfiguration;
+import org.apache.artemis.client.cdi.configuration.DefaultArtemisClientConfigurationImpl;
+
+@ApplicationScoped
+public class CDIProducers {
+   @Produces
+   @ApplicationScoped
+   public ArtemisClientConfiguration createConfig() {
+      return new DefaultArtemisClientConfigurationImpl();
+   }
+}


Mime
View raw message