Skip to content

Commit

Permalink
Remove PooledJmsDecorator (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhfeng authored Sep 11, 2023
1 parent 7b2e6dc commit 611d159
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.quarkiverse.messaginghub.pooled.jms.deployment;

import jakarta.inject.Singleton;

import org.jboss.jandex.DotName;

import io.quarkiverse.messaginghub.pooled.jms.PooledJmsDecorator;
import io.quarkiverse.messaginghub.pooled.jms.PooledJmsRecorder;
import io.quarkiverse.messaginghub.pooled.jms.PooledJmsWrapper;
import io.quarkiverse.messaginghub.pooled.jms.transaction.XATransactionSupport;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.arc.deployment.UnremovableBeanBuildItem;
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.deployment.Capabilities;
Expand All @@ -28,19 +30,24 @@ FeatureBuildItem feature() {
}

@BuildStep
void build(BuildProducer<AdditionalBeanBuildItem> additionalBeans,
BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
additionalBeans.produce(new AdditionalBeanBuildItem(PooledJmsDecorator.class));

void build(BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
reflectiveClasses.produce(
ReflectiveClassBuildItem.builder("org.apache.commons.pool2.impl.DefaultEvictionPolicy")
.methods(true).fields(false).build());
}

@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
ConnectionFactoryWrapperBuildItem wrap(Capabilities capabilities, PooledJmsRecorder recorder) {
return new ConnectionFactoryWrapperBuildItem(recorder.getWrapper(capabilities.isPresent(Capability.TRANSACTIONS)));
void wrap(Capabilities capabilities, PooledJmsRecorder recorder,
BuildProducer<ConnectionFactoryWrapperBuildItem> wrapper,
BuildProducer<SyntheticBeanBuildItem> syntheticBeans) {
wrapper.produce(
new ConnectionFactoryWrapperBuildItem(recorder.getWrapper(capabilities.isPresent(Capability.TRANSACTIONS))));
syntheticBeans.produce(SyntheticBeanBuildItem.configure(PooledJmsWrapper.class)
.scope(Singleton.class)
.runtimeValue(recorder.getPooledJmsWrapper(capabilities.isPresent(Capability.TRANSACTIONS)))
.defaultBean().setRuntimeInit()
.done());
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package io.quarkiverse.messaginghub.pooled.jms.it;

import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.jms.ConnectionFactory;

import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.eclipse.microprofile.config.ConfigProvider;

import io.quarkiverse.messaginghub.pooled.jms.PooledJmsWrapper;
import io.quarkus.arc.properties.UnlessBuildProperty;

@Dependent
@UnlessBuildProperty(name = "quarkus.artemis.enabled", stringValue = "true")
public class CustomConnectionFactory extends ActiveMQConnectionFactory {
public CustomConnectionFactory() {
super(ConfigProvider.getConfig().getValue("artemis.custom.url", String.class));
public class CustomConnectionFactory {

@Produces
@UnlessBuildProperty(name = "quarkus.artemis.enabled", stringValue = "true")
@ApplicationScoped
public ConnectionFactory createConnectionFactory(PooledJmsWrapper wrapper) {
String url = ConfigProvider.getConfig().getValue("artemis.custom.url", String.class);
return wrapper.wrapConnectionFactory(new ActiveMQConnectionFactory(url));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@QuarkusTest
@TestProfile(JmsArtemisDisabled.class)
public class PooledDecoratorTest extends BasePooledJmsTest {
public class PooledCustomerConnectionFactoryTest extends BasePooledJmsTest {
@Override
boolean isTransacted() {
return true;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import jakarta.jms.ConnectionFactory;

import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;

@Recorder
Expand All @@ -20,4 +21,8 @@ public Function<ConnectionFactory, Object> getWrapper(boolean transaction) {
return wrapper.wrapConnectionFactory(cf);
};
}

public RuntimeValue<PooledJmsWrapper> getPooledJmsWrapper(boolean transaction) {
return new RuntimeValue<>(new PooledJmsWrapper(transaction, pooledJmsRuntimeConfig));
}
}

0 comments on commit 611d159

Please sign in to comment.