use of javax.ejb.TransactionAttribute in project eap-additional-testsuite by jboss-set.
the class SFSB method setupConfig.
@TransactionAttribute(TransactionAttributeType.NEVER)
public void setupConfig() {
// static {
try {
// prepare the configuration
Configuration configuration = new Configuration().setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
configuration.getProperties().put(AvailableSettings.JTA_PLATFORM, JBossAppServerJtaPlatform.class);
configuration.getProperties().put(AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta");
configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS");
// fetch the properties
Properties properties = new Properties();
configuration = configuration.configure("hibernate.cfg.xml");
properties.putAll(configuration.getProperties());
Environment.verifyProperties(properties);
ConfigurationHelper.resolvePlaceHolders(properties);
sessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
ex.printStackTrace();
throw new ExceptionInInitializerError(ex);
}
}
use of javax.ejb.TransactionAttribute in project Payara by payara.
the class TransactionAttributeHandler method postProcessAnnotation.
/**
* Set the default value (from class type annotation) on all
* methods that don't have a value.
*/
public void postProcessAnnotation(AnnotationInfo ainfo, EjbContext ejbContext) throws AnnotationProcessorException {
EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
TransactionAttribute taAn = (TransactionAttribute) ainfo.getAnnotation();
ContainerTransaction containerTransaction = getContainerTransaction(taAn.value());
Class classAn = (Class) ainfo.getAnnotatedElement();
Set txBusMethods = ejbDesc.getTxBusinessMethodDescriptors();
for (Object mdObj : txBusMethods) {
MethodDescriptor md = (MethodDescriptor) mdObj;
// override by xml
if (classAn.equals(ejbContext.getDeclaringClass(md)) && ejbDesc.getContainerTransactionFor(md) == null) {
ejbDesc.setContainerTransactionFor(md, containerTransaction);
}
}
}
use of javax.ejb.TransactionAttribute in project quickstart by wildfly.
the class CustomerManagerEJB method createCustomer.
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void createCustomer(String name) throws RemoteException, JMSException {
logMessageManager.logCreateCustomer(name);
Customer c1 = new Customer();
c1.setName(name);
entityManager.persist(c1);
invoiceManager.createInvoice(name);
// after the fact but before the transaction is committed.
if (!nameIsValid(name)) {
throw new EJBException("Invalid name: customer names should only contain letters & '-'");
}
}
use of javax.ejb.TransactionAttribute in project UVMS-ActivityModule-APP by UnionVMS.
the class MovementModuleServiceBean method getMovement.
/**
* {@inheritDoc}
*/
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public List<MovementType> getMovement(List<String> vesselIds, Date startDate, Date endDate) throws ServiceException {
try {
MovementQuery movementQuery = new MovementQuery();
addListCriteria(vesselIds, movementQuery);
addRangeCriteria(startDate, endDate, movementQuery);
movementQuery.setExcludeFirstAndLastSegment(true);
String request = MovementModuleRequestMapper.mapToGetMovementMapByQueryRequest(movementQuery);
String moduleMessage = movementProducer.sendModuleMessage(request, activityConsumer.getDestination());
TextMessage response = activityConsumer.getMessage(moduleMessage, TextMessage.class);
if (response != null && !isUserFault(response)) {
List<MovementMapResponseType> mapResponseTypes = MovementModuleResponseMapper.mapToMovementMapResponse(response);
List<MovementType> movements = new ArrayList<>();
for (MovementMapResponseType movementMap : mapResponseTypes) {
movements.addAll(movementMap.getMovements());
}
return movements;
} else {
throw new ServiceException("FAILED TO GET DATA FROM MOVEMENT");
}
} catch (MovementDuplicateException | MovementFaultException | ServiceException | MessageException | JMSException | ModelMapperException e) {
log.error("Exception in communication with movements", e);
throw new ServiceException(e.getMessage(), e);
}
}
use of javax.ejb.TransactionAttribute in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityMessageConsumerBean method onMessage.
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void onMessage(Message message) {
TextMessage textMessage = null;
try {
textMessage = (TextMessage) message;
MappedDiagnosticContext.addMessagePropertiesToThreadMappedDiagnosticContext(textMessage);
ActivityModuleRequest request;
request = JAXBMarshaller.unmarshallTextMessage(textMessage, ActivityModuleRequest.class);
LOG.debug("Message unmarshalled successfully in activity");
if (request == null) {
LOG.error("[ Request is null ]");
return;
}
ActivityModuleMethod method = request.getMethod();
if (method == null) {
LOG.error("[ Request method is null ]");
return;
}
switch(method) {
case GET_FLUX_FA_REPORT:
case GET_FLUX_FA_QUERY:
receiveFishingActivityEvent.fire(new EventMessage(textMessage, method));
break;
case MAP_TO_SUBSCRIPTION_REQUEST:
mapToSubscriptionRequest.fire(new EventMessage(textMessage));
break;
case GET_FISHING_TRIPS:
getFishingTripListEvent.fire(new EventMessage(textMessage));
break;
case GET_FA_CATCH_SUMMARY_REPORT:
getFACatchSummaryReportEvent.fire(new EventMessage(textMessage));
break;
case GET_NON_UNIQUE_IDS:
getNonUniqueIdsRequest.fire(new EventMessage(textMessage));
break;
case GET_FISHING_ACTIVITY_FOR_TRIPS:
getFishingActivityForTrips.fire(new EventMessage(textMessage));
break;
default:
LOG.error("[ Request method {} is not implemented ]", method.name());
errorEvent.fire(new EventMessage(textMessage, ActivityModuleResponseMapper.createFaultMessage(FaultCode.ACTIVITY_MESSAGE, "[ Request method " + method.name() + " is not implemented ]")));
}
} catch (ActivityModelMarshallException | ClassCastException e) {
LOG.error("[ Error when receiving message in activity: ] {}", e);
errorEvent.fire(new EventMessage(textMessage, ActivityModuleResponseMapper.createFaultMessage(FaultCode.ACTIVITY_MESSAGE, "Error when receiving message")));
}
}
Aggregations