use of javax.resource.ResourceException in project wildfly by wildfly.
the class EJBUtilities method createActivationSpecs.
public ActivationSpec createActivationSpecs(final String resourceAdapterName, final Class<?> messageListenerInterface, final Properties activationConfigProperties, final ClassLoader classLoader) {
try {
// first get the ra "identifier" (with which it is registered in the resource adapter repository) for the
// ra name
final String raIdentifier = ConnectorServices.getRegisteredResourceAdapterIdentifier(resourceAdapterName);
if (raIdentifier == null) {
throw EjbLogger.ROOT_LOGGER.unknownResourceAdapter(resourceAdapterName);
}
final ResourceAdapterRepository resourceAdapterRepository = getResourceAdapterRepository();
if (resourceAdapterRepository == null) {
throw EjbLogger.ROOT_LOGGER.resourceAdapterRepositoryUnAvailable();
}
// now get the message listeners for this specific ra identifier
final List<MessageListener> messageListeners = resourceAdapterRepository.getMessageListeners(raIdentifier);
if (messageListeners == null || messageListeners.isEmpty()) {
throw EjbLogger.ROOT_LOGGER.unknownMessageListenerType(messageListenerInterface.getName(), resourceAdapterName);
}
MessageListener requiredMessageListener = null;
// now find the expected message listener from the list of message listeners for this resource adapter
for (final MessageListener messageListener : messageListeners) {
if (messageListenerInterface.equals(messageListener.getType())) {
requiredMessageListener = messageListener;
break;
}
}
if (requiredMessageListener == null) {
throw EjbLogger.ROOT_LOGGER.unknownMessageListenerType(messageListenerInterface.getName(), resourceAdapterName);
}
// found the message listener, now finally create the activation spec
final Activation activation = requiredMessageListener.getActivation();
// filter out the activation config properties, specified on the MDB, which aren't accepted by the resource
// adaptor
final Properties validActivationConfigProps = this.filterUnknownActivationConfigProperties(resourceAdapterName, activation, activationConfigProperties);
// now set the activation config properties on the ActivationSpec
final ActivationSpec activationSpec = activation.createInstance();
BeanUtils.mapJavaBeanProperties(activationSpec, validActivationConfigProps);
return activationSpec;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (ResourceException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (NotFoundException e) {
throw new RuntimeException(e);
} catch (IntrospectionException e) {
throw new RuntimeException(e);
}
}
use of javax.resource.ResourceException in project geode by apache.
the class JCALocalTransaction method commit.
@Override
public void commit() throws ResourceException {
LogWriter logger = this.cache.getLogger();
if (logger.fineEnabled()) {
logger.fine("JCALocalTransaction:invoked commit");
}
TXStateProxy tsp = this.gfTxMgr.getTXState();
if (tsp != null && this.tid != tsp.getTransactionId()) {
throw new IllegalStateException("Local Transaction associated with Tid = " + this.tid + " attempting to commit a different transaction");
}
try {
this.gfTxMgr.commit();
this.tid = null;
} catch (Exception e) {
// TODO: consider wrapping the cause
throw new LocalTransactionException(e.toString());
}
}
use of javax.resource.ResourceException in project geode by apache.
the class JCALocalTransaction method rollback.
@Override
public void rollback() throws ResourceException {
TXStateProxy tsp = this.gfTxMgr.getTXState();
if (tsp != null && this.tid != tsp.getTransactionId()) {
throw new IllegalStateException("Local Transaction associated with Tid = " + this.tid + " attempting to commit a different transaction");
}
LogWriter logger = this.cache.getLogger();
if (logger.fineEnabled()) {
logger.fine("JCALocalTransaction:invoked rollback");
}
try {
this.gfTxMgr.rollback();
} catch (IllegalStateException ise) {
// It is possible that the GFE transaction has already been rolled back.
if (ise.getMessage().equals(LocalizedStrings.TXManagerImpl_THREAD_DOES_NOT_HAVE_AN_ACTIVE_TRANSACTION.toLocalizedString())) {
// ignore
} else {
throw new ResourceException(ise);
}
} catch (RuntimeException e) {
throw new ResourceException(e);
} finally {
this.tid = null;
}
}
use of javax.resource.ResourceException in project spring-framework by spring-projects.
the class CciLocalTransactionManager method doCommit.
@Override
protected void doCommit(DefaultTransactionStatus status) {
CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
Connection con = txObject.getConnectionHolder().getConnection();
if (status.isDebug()) {
logger.debug("Committing CCI local transaction on Connection [" + con + "]");
}
try {
con.getLocalTransaction().commit();
} catch (LocalTransactionException ex) {
throw new TransactionSystemException("Could not commit CCI local transaction", ex);
} catch (ResourceException ex) {
throw new TransactionSystemException("Unexpected failure on commit of CCI local transaction", ex);
}
}
use of javax.resource.ResourceException in project spring-framework by spring-projects.
the class CciLocalTransactionManager method doRollback.
@Override
protected void doRollback(DefaultTransactionStatus status) {
CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
Connection con = txObject.getConnectionHolder().getConnection();
if (status.isDebug()) {
logger.debug("Rolling back CCI local transaction on Connection [" + con + "]");
}
try {
con.getLocalTransaction().rollback();
} catch (LocalTransactionException ex) {
throw new TransactionSystemException("Could not roll back CCI local transaction", ex);
} catch (ResourceException ex) {
throw new TransactionSystemException("Unexpected failure on rollback of CCI local transaction", ex);
}
}
Aggregations