Search in sources :

Example 26 with WebMethod

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);
}
Also used : SystemException(com.arjuna.wst.SystemException) BusinessActivityManager(com.arjuna.mw.wst11.BusinessActivityManager) SystemException(com.arjuna.wst.SystemException) WebMethod(javax.jws.WebMethod)

Example 27 with WebMethod

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));
}
Also used : Calendar(java.util.Calendar) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Example 28 with WebMethod

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();
        }
    }
}
Also used : UserTransaction(com.arjuna.mw.wst11.UserTransaction) WebMethod(javax.jws.WebMethod)

Example 29 with WebMethod

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();
        }
    }
}
Also used : UserBusinessActivity(com.arjuna.mw.wst11.UserBusinessActivity) WebMethod(javax.jws.WebMethod)

Example 30 with WebMethod

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));
}
Also used : Calendar(java.util.Calendar) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Aggregations

WebMethod (javax.jws.WebMethod)48 Method (java.lang.reflect.Method)13 WebResult (javax.jws.WebResult)12 Test (org.junit.Test)7 File (java.io.File)6 IOException (java.io.IOException)6 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)6 ActionExecutionException (com.axway.ats.agent.core.exceptions.ActionExecutionException)5 AgentException (com.axway.ats.agent.core.exceptions.AgentException)5 InternalComponentException (com.axway.ats.agent.core.exceptions.InternalComponentException)5 NoCompatibleMethodFoundException (com.axway.ats.agent.core.exceptions.NoCompatibleMethodFoundException)5 NoSuchActionException (com.axway.ats.agent.core.exceptions.NoSuchActionException)5 NoSuchComponentException (com.axway.ats.agent.core.exceptions.NoSuchComponentException)5 Path (javax.ws.rs.Path)5 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)4 QName (javax.xml.namespace.QName)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 ArrayList (java.util.ArrayList)3 GET (javax.ws.rs.GET)3