Skip to content

Commit efdd270

Browse files
committed
Fix #365: Remove unnecessary ForageConnectionFactory wrapper
The ForageConnectionFactory wrapper was serving as unnecessary indirection in the JMS module. It was a simple record that wrapped ConnectionFactory, which was immediately unwrapped at every usage point.
1 parent 44cb9c7 commit efdd270

2 files changed

Lines changed: 7 additions & 16 deletions

File tree

library/jms/forage-jms-common/src/main/java/io/kaoto/forage/jms/common/ForageConnectionFactory.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

library/jms/forage-jms/src/main/java/io/kaoto/forage/jms/ConnectionFactoryBeanFactory.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import io.kaoto.forage.core.util.config.ConfigStore;
2626
import io.kaoto.forage.jms.common.ConnectionFactoryCommonExportHelper;
2727
import io.kaoto.forage.jms.common.ConnectionFactoryConfig;
28-
import io.kaoto.forage.jms.common.ForageConnectionFactory;
2928

3029
@ForageFactory(
3130
value = "JMS Connection",
@@ -130,8 +129,8 @@ public void configure() {
130129
for (String name : prefixes) {
131130
if (camelContext.getRegistry().lookupByNameAndType(name, ConnectionFactory.class) == null) {
132131
ConnectionFactoryConfig cfConfig = new ConnectionFactoryConfig(name);
133-
ForageConnectionFactory forageConnectionFactory = newConnectionFactory(cfConfig, name);
134-
camelContext.getRegistry().bind(name, forageConnectionFactory.connectionFactory());
132+
ConnectionFactory connectionFactory = newConnectionFactory(cfConfig, name);
133+
camelContext.getRegistry().bind(name, connectionFactory);
135134
}
136135
}
137136
} else {
@@ -141,11 +140,8 @@ public void configure() {
141140
final List<ServiceLoader.Provider<ConnectionFactoryProvider>> providers =
142141
findProviders(ConnectionFactoryProvider.class);
143142
if (providers.size() == 1) {
144-
ForageConnectionFactory forageConnectionFactory =
145-
doCreateConnectionFactory(providers.get(0), null);
146-
camelContext
147-
.getRegistry()
148-
.bind(DEFAULT_CONNECTION_FACTORY, forageConnectionFactory.connectionFactory());
143+
ConnectionFactory connectionFactory = doCreateConnectionFactory(providers.get(0), null);
144+
camelContext.getRegistry().bind(DEFAULT_CONNECTION_FACTORY, connectionFactory);
149145
} else {
150146
throw new IllegalArgumentException(
151147
"No ConnectionFactory implementation is present in the classpath");
@@ -157,7 +153,7 @@ public void configure() {
157153
}
158154
}
159155

160-
private synchronized ForageConnectionFactory newConnectionFactory(
156+
private synchronized ConnectionFactory newConnectionFactory(
161157
ConnectionFactoryConfig connectionFactoryConfig, String name) {
162158
final String connectionFactoryProviderClass =
163159
ConnectionFactoryCommonExportHelper.transformJmsKindIntoProviderClass(
@@ -178,10 +174,10 @@ private synchronized ForageConnectionFactory newConnectionFactory(
178174
return doCreateConnectionFactory(connectionFactoryProvider, name);
179175
}
180176

181-
private ForageConnectionFactory doCreateConnectionFactory(
177+
private ConnectionFactory doCreateConnectionFactory(
182178
ServiceLoader.Provider<ConnectionFactoryProvider> provider, String name) {
183179
final ConnectionFactoryProvider connectionFactoryProvider = provider.get();
184-
return new ForageConnectionFactory(connectionFactoryProvider.create(name));
180+
return connectionFactoryProvider.create(name);
185181
}
186182

187183
@Override

0 commit comments

Comments
 (0)