com.github.marschall.jakartajmsadapter.JakartaConnectionFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jakarta-jms-adapter Show documentation
Show all versions of jakarta-jms-adapter Show documentation
Adapts a javax.jms JMS provider to a jakarta.jms JMS provider.
The newest version!
package com.github.marschall.jakartajmsadapter;
import java.util.Objects;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.JMSContext;
import jakarta.jms.JMSException;
/**
* Adapts a {@link javax.jms.ConnectionFactory} to a {@link jakarta.jms.ConnectionFactory}
*/
public sealed class JakartaConnectionFactory implements ConnectionFactory
permits JakartaQueueConnectionFactory, JakartaTopicConnectionFactory {
private final javax.jms.ConnectionFactory javaxConnectionFactory;
/**
* Constructs a new {@link JakartaConnectionFactory}
*
* @param javaxConnectionFactory the javax connection factory to adapt, not {@code null}
* @throws NullPointerException if {@code javaxConnectionFactory} is {@code null}
*/
public JakartaConnectionFactory(javax.jms.ConnectionFactory javaxConnectionFactory) {
Objects.requireNonNull(javaxConnectionFactory);
this.javaxConnectionFactory = javaxConnectionFactory;
}
@Override
public Connection createConnection() throws JMSException {
try {
return new JakartaConnection(this.javaxConnectionFactory.createConnection());
} catch (javax.jms.JMSException e) {
throw JMSExceptionUtil.adaptException(e);
}
}
@Override
public Connection createConnection(String userName, String password) throws JMSException {
try {
return new JakartaConnection(this.javaxConnectionFactory.createConnection(userName, password));
} catch (javax.jms.JMSException e) {
throw JMSExceptionUtil.adaptException(e);
}
}
@Override
public JMSContext createContext() {
try {
return new JakartaJMSContext(this.javaxConnectionFactory.createContext());
} catch (javax.jms.JMSRuntimeException e) {
throw JMSRuntimeExceptionUtil.adaptException(e);
}
}
@Override
public JMSContext createContext(String userName, String password) {
try {
return new JakartaJMSContext(this.javaxConnectionFactory.createContext(userName, password));
} catch (javax.jms.JMSRuntimeException e) {
throw JMSRuntimeExceptionUtil.adaptException(e);
}
}
@Override
public JMSContext createContext(String userName, String password, int sessionMode) {
try {
return new JakartaJMSContext(this.javaxConnectionFactory.createContext(userName, password, sessionMode));
} catch (javax.jms.JMSRuntimeException e) {
throw JMSRuntimeExceptionUtil.adaptException(e);
}
}
@Override
public JMSContext createContext(int sessionMode) {
try {
return new JakartaJMSContext(this.javaxConnectionFactory.createContext(sessionMode));
} catch (javax.jms.JMSRuntimeException e) {
throw JMSRuntimeExceptionUtil.adaptException(e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy