use of javax.jws.WebMethod in project quickstart by wildfly.
the class SetServiceBAImpl method addValueToSet.
/**
* Add an item to a set and enroll a Participant if necessary then pass the call through to the business logic.
*
* @param value the value to add to the set.
* @throws AlreadyInSetException if value is already in the set
* @throws SetServiceException if an error occurred when attempting to add the item to the set.
*/
@WebMethod
public void addValueToSet(String value) throws AlreadyInSetException, SetServiceException {
System.out.println("[SERVICE] invoked addValueToSet('" + value + "')");
BusinessActivityManager activityManager = BusinessActivityManagerFactory.businessActivityManager();
/*
* get the transaction context of this thread:
*/
String transactionId;
try {
transactionId = activityManager.currentTransaction().toString();
} catch (SystemException e) {
throw new SetServiceException("Unable to lookup existing BusinesActivity", e);
}
/*
* Lookup existing participant or register new participant
*/
SetParticipantBA participantBA = SetParticipantBA.getParticipant(transactionId);
if (participantBA == null) {
try {
// enlist the Participant for this service:
SetParticipantBA participant = new SetParticipantBA(transactionId, value);
SetParticipantBA.recordParticipant(transactionId, participant);
System.out.println("[SERVICE] Enlisting a participant into the BA");
activityManager.enlistForBusinessAgreementWithCoordinatorCompletion(participant, "SetServiceBAImpl:" + UUID.randomUUID());
} catch (Exception e) {
System.err.println("Participant enlistment failed");
throw new SetServiceException("Error enlisting participant", e);
}
} else {
System.out.println("[SERVICE] Re-using the existing participant, already registered for this BA");
participantBA.addValue(value);
}
// invoke the back-end business logic
System.out.println("[SERVICE] Invoking the back-end business logic");
MockSetManager.add(value);
}
use of javax.jws.WebMethod in project quickstarts by jboss-switchyard.
the class AirportService method getFLTID.
/**
* Get flight identifier for the parameters.
* @param from place (city)
* @param to place (city)
* @param date of flight
* @return format [from/to/month/day]
*/
@WebMethod
@WebResult(name = "fltid")
public String getFLTID(@WebParam(name = "from") String from, @WebParam(name = "to") String to, @WebParam(name = "date") Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return from + "/" + to + "/" + String.valueOf(c.get(Calendar.MONTH) + 1) + "/" + String.valueOf(c.get(Calendar.DAY_OF_MONTH));
}
use of javax.jws.WebMethod in project quickstarts by jboss-switchyard.
the class AirportService method order.
/**
* Order flight ticket defined by fltid for a user identified by name.
* @param name username
* @param fltid flight identifier
*/
@WebMethod
public void order(@WebParam(name = "name") String name, @WebParam(name = "fltid") String fltid) {
log.info("AirportService:order");
UserTransaction transactionId = UserTransactionFactory.userTransaction();
if (transactionId != null) {
log.info("Transaction ID = " + transactionId.toString());
if (transactionId.toString().compareTo("Unknown") == 0) {
log.info("JBoss AS is badly configured. (Enable XTS)");
return;
}
// Create order participant (fly ticket)
OrderParticipant op = new OrderParticipant(transactionId.toString(), fltid);
try {
// Enlist order participant to the transaction
TransactionManagerFactory.transactionManager().enlistForDurableTwoPhase(op, "org.switchyard.quickstarts.bpel.xts.wsat.ws:AirportService:" + name + ":" + fltid);
} catch (Exception e) {
log.log(Level.SEVERE, e.getMessage());
e.printStackTrace();
}
}
}
use of javax.jws.WebMethod in project quickstarts by jboss-switchyard.
the class AirportService method order.
/**
* Order flight ticket defined by fltid for a user identified by name.
* @param name username
* @param fltid flight identifier
*/
@WebMethod
public void order(@WebParam(name = "name") String name, @WebParam(name = "fltid") String fltid) {
log.info("AirportService:order");
UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
if (uba != null) {
log.info("Transaction ID = " + uba.toString());
if (uba.toString().compareTo("Unknown") == 0) {
log.info("JBoss AS is badly configured. (Enable XTS)");
return;
}
// Create order participant (fly ticket)
OrderParticipant op = new OrderParticipant(uba.toString(), fltid);
try {
// Enlist order participant to the transaction
BusinessActivityManager.getBusinessActivityManager().enlistForBusinessAgreementWithCoordinatorCompletion(op, "org.switchyard.quickstarts.bpel.xts.wsba.ws:AirportService:" + name + ":" + fltid);
} catch (Exception e) {
log.log(Level.SEVERE, e.getMessage());
e.printStackTrace();
}
}
}
use of javax.jws.WebMethod in project quickstarts by jboss-switchyard.
the class AirportService method getFLTID.
/**
* Get flight identifier for the parameters.
* @param from place (city)
* @param to place (city)
* @param date of flight
* @return format [from/to/month/day]
*/
@WebMethod
@WebResult(name = "fltid")
public String getFLTID(@WebParam(name = "from") String from, @WebParam(name = "to") String to, @WebParam(name = "date") Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return from + "/" + to + "/" + String.valueOf(c.get(Calendar.MONTH) + 1) + "/" + String.valueOf(c.get(Calendar.DAY_OF_MONTH));
}
Aggregations