Search in sources :

Example 1 with X_C_TYPE

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_C_TYPE in project narayana by jbosstm.

the class TPCallXCTypeService method tpservice.

public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException, ConfigurationException {
    log.info("test_tpcall_x_c_type_service");
    boolean ok = false;
    X_C_TYPE aptr = (X_C_TYPE) svcinfo.getBuffer();
    byte[] receivedName = new byte[3];
    byte[] charArray = aptr.getByteArray("name");
    System.arraycopy(charArray, 0, receivedName, 0, 3);
    byte[] expectedName = "TOM".getBytes();
    long accountNumber = aptr.getLong("acct_no");
    float fooOne = aptr.getFloatArray("foo")[0];
    float fooTwo = aptr.getFloatArray("foo")[1];
    double balanceOne = aptr.getDoubleArray("balances")[0];
    double balanceTwo = aptr.getDoubleArray("balances")[1];
    if (accountNumber == 12345678 && Arrays.equals(receivedName, expectedName) && fooOne == 1.1F && fooTwo == 2.2F && balanceOne == 1.1 && balanceTwo == 2.2) {
        ok = true;
    }
    int len = 60;
    X_OCTET toReturn = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET", null);
    if (ok) {
        toReturn.setByteArray("tpcall_x_c_type".getBytes());
    } else {
        toReturn.setByteArray("fail".getBytes());
    }
    return new Response(Connection.TPSUCCESS, 23, toReturn, 0);
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_OCTET(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET) X_C_TYPE(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_C_TYPE)

Example 2 with X_C_TYPE

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_C_TYPE in project narayana by jbosstm.

the class SpecQuickstartOneService method tpservice.

public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException {
    log.info("debit_credit_svc");
    short rval;
    /* extract request typed buffer */
    X_C_TYPE dc_ptr = (X_C_TYPE) svcinfo.getBuffer();
    /*
         * Depending on service name used to invoke this routine, perform either debit or credit work.
         */
    if (!svcinfo.getName().equals("DEBIT")) {
    /*
             * Parse input data and perform debit as part of global transaction.
             */
    } else {
    /*
             * Parse input data and perform credit as part of global transaction.
             */
    }
    // TODO MAKE TWO TESTS
    if (dc_ptr.getInt("failTest") == 0) {
        rval = Connection.TPSUCCESS;
        dc_ptr.setInt("output", TestSpecQuickstartOne.OK);
    } else {
        rval = Connection.TPFAIL;
        /* global transaction will not commit */
        dc_ptr.setInt("output", TestSpecQuickstartOne.NOT_OK);
    }
    /* send reply and return from service routine */
    return new Response(rval, 0, dc_ptr, 0);
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_C_TYPE(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_C_TYPE)

Example 3 with X_C_TYPE

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_C_TYPE in project narayana by jbosstm.

the class SpecQuickstartTwoService method tpservice.

public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException {
    log.info("inquiry_svc");
    short rval;
    /* extract initial typed buffer sent as part of tpconnect() */
    X_C_TYPE ptr = (X_C_TYPE) svcinfo.getBuffer();
    /*
         * Parse input string, ptr->input, and retrieve records. Return 10 records at a time to client. Records are placed in
         * ptr->output, an array of account records.
         */
    for (int i = 0; i < 5; i++) {
        /* gather from DBMS next 10 records into ptr->output array */
        svcinfo.getSession().tpsend(ptr, Connection.TPSIGRSTRT);
    }
    // TODO DO OK AND FAIL
    if (ptr.getInt("failTest") == 0) {
        rval = Connection.TPSUCCESS;
    } else {
        rval = Connection.TPFAIL;
    /* global transaction will not commit */
    }
    /* terminate connection */
    return new Response(rval, 0, null, 0);
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_C_TYPE(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_C_TYPE)

Aggregations

Response (org.jboss.narayana.blacktie.jatmibroker.xatmi.Response)3 X_C_TYPE (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_C_TYPE)3 X_OCTET (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)1