org.jboss.jbossts.star.util
Class TxSupport

java.lang.Object
  extended by org.jboss.jbossts.star.util.TxSupport

public class TxSupport
extends Object

Various utilities for sending HTTP messages


Field Summary
static String ABORT_ONLY
           
static String ABORTED
           
static String ABORTING
           
static String BASE_URL
           
static String BIND_ADDRESS
           
static String COMMITTED
           
static String COMMITTING
           
static String DEF_TX_URL
           
static String DO_ABORT
           
static String DO_COMMIT
           
static String H_COMMIT
           
static String H_HAZARD
           
static String H_MIXED
           
static String H_ROLLBACK
           
static String LOCATION_LINK
           
protected static org.jboss.logging.Logger log
           
static String PARTICIPANT_LINK
           
static String PLAIN_MEDIA_TYPE
           
static int PORT
           
static String POST_MEDIA_TYPE
           
static String PREPARED
           
static String PREPARING
           
static String RC_SEGMENT
           
static String READONLY
           
static String RUNNING
           
static String STATUS_MEDIA_TYPE
           
static String STATUS_PROPERTY
           
static String TERMINATOR_LINK
           
static String TIMEOUT_PROPERTY
           
static String TX_ABORTED
           
static String TX_ACTIVE
           
static String TX_COMMITTED
           
static String TX_CONTEXT
           
static String TX_H_MIXED
           
static String TX_H_ROLLBACK
           
static String TX_PATH
          The REST path prefix for the transaction and recovery coordinator URLS
static String TX_PREPARED
           
static String TX_SEGMENT
          The REST path for the transaction coordinator.
static String TXN_MGR_URL
           
static String URI_SEPARATOR
           
 
Constructor Summary
TxSupport()
           
TxSupport(String txnMgr)
           
 
Method Summary
static void addLinkHeader(javax.ws.rs.core.Response.ResponseBuilder response, javax.ws.rs.core.UriInfo info, String title, String name, String... pathComponents)
           
static String buildURI(javax.ws.rs.core.UriBuilder builder, String... pathComponents)
           
 String commitTx()
           
 String enlist(String pUrl)
           
 String enlistUrl()
           
 String getBody()
           
static int getIntValue(String content, String name, int defValue)
           
static String getParticipantUrls(String terminatorUrl, String participantUrl)
           
 int getStatus()
           
static String getStatus(String statusContent)
           
static String getStringValue(String content, String name)
           
 Collection<String> getTransactions()
           
static URI getUri(javax.ws.rs.core.UriInfo info, int npaths, String... paths)
           
static javax.ws.rs.core.UriBuilder getUriBuilder(javax.ws.rs.core.UriInfo info, int npaths, String... paths)
           
 String httpRequest(int[] expect, String url, String method, String mediaType, String content, Map<String,String> linkHeaders)
           
static boolean isAbort(String status)
           
static boolean isActive(String status)
           
static boolean isCommit(String status)
           
static boolean isComplete(String status)
           
static boolean isHeuristic(String status)
           
static boolean isPrepare(String status)
           
static boolean isReadOnly(String status)
           
static void matchNames(Map<String,String> pairs, String content, String splitChars)
          Parse a string for name=value pairs TODO java.util.Scanner might be more efficient
 void refreshLinkHeaders(Map<String,String> linkHeaders)
           
 String rollbackTx()
           
static void setLinkHeader(javax.ws.rs.core.Response.ResponseBuilder builder, org.jboss.resteasy.spi.Link link)
           
static void setLinkHeader(javax.ws.rs.core.Response.ResponseBuilder builder, String title, String rel, String href, String type)
           
static void setTxnMgrUrl(String txnMgrUrl)
           
 TxSupport startTx()
           
 TxSupport startTx(long milliseconds)
           
static String toContent(String property, String status)
           
static String toStatusContent(String status)
           
 int txCount()
           
 String txStatus()
           
 String txTerminatorUrl()
           
 String txUrl()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.jboss.logging.Logger log

PORT

public static int PORT

BIND_ADDRESS

public static String BIND_ADDRESS

BASE_URL

public static String BASE_URL

TX_CONTEXT

public static final String TX_CONTEXT

TX_PATH

public static final String TX_PATH
The REST path prefix for the transaction and recovery coordinator URLS

See Also:
Constant Field Values

TX_SEGMENT

public static final String TX_SEGMENT
The REST path for the transaction coordinator. Thus the full path for the coordinator is + TX_PATH + TX_SEGMENT

See Also:
Constant Field Values

RC_SEGMENT

public static final String RC_SEGMENT
See Also:
Constant Field Values

DEF_TX_URL

public static final String DEF_TX_URL

TXN_MGR_URL

public static String TXN_MGR_URL

URI_SEPARATOR

public static final String URI_SEPARATOR
See Also:
Constant Field Values

ABORT_ONLY

public static final String ABORT_ONLY
See Also:
Constant Field Values

ABORTING

public static final String ABORTING
See Also:
Constant Field Values

ABORTED

public static final String ABORTED
See Also:
Constant Field Values

COMMITTING

public static final String COMMITTING
See Also:
Constant Field Values

COMMITTED

public static final String COMMITTED
See Also:
Constant Field Values

H_ROLLBACK

public static final String H_ROLLBACK
See Also:
Constant Field Values

H_COMMIT

public static final String H_COMMIT
See Also:
Constant Field Values

H_HAZARD

public static final String H_HAZARD
See Also:
Constant Field Values

H_MIXED

public static final String H_MIXED
See Also:
Constant Field Values

PREPARING

public static final String PREPARING
See Also:
Constant Field Values

PREPARED

public static final String PREPARED
See Also:
Constant Field Values

RUNNING

public static final String RUNNING
See Also:
Constant Field Values

READONLY

public static final String READONLY
See Also:
Constant Field Values

TX_ACTIVE

public static final String TX_ACTIVE

TX_PREPARED

public static final String TX_PREPARED

TX_COMMITTED

public static final String TX_COMMITTED

TX_ABORTED

public static final String TX_ABORTED

TX_H_MIXED

public static final String TX_H_MIXED

TX_H_ROLLBACK

public static final String TX_H_ROLLBACK

DO_COMMIT

public static final String DO_COMMIT

DO_ABORT

public static final String DO_ABORT

STATUS_MEDIA_TYPE

public static final String STATUS_MEDIA_TYPE
See Also:
Constant Field Values

POST_MEDIA_TYPE

public static final String POST_MEDIA_TYPE
See Also:
Constant Field Values

PLAIN_MEDIA_TYPE

public static final String PLAIN_MEDIA_TYPE
See Also:
Constant Field Values

LOCATION_LINK

public static final String LOCATION_LINK
See Also:
Constant Field Values

TERMINATOR_LINK

public static final String TERMINATOR_LINK
See Also:
Constant Field Values

PARTICIPANT_LINK

public static final String PARTICIPANT_LINK
See Also:
Constant Field Values

TIMEOUT_PROPERTY

public static final String TIMEOUT_PROPERTY
See Also:
Constant Field Values

STATUS_PROPERTY

public static final String STATUS_PROPERTY
See Also:
Constant Field Values
Constructor Detail

TxSupport

public TxSupport(String txnMgr)

TxSupport

public TxSupport()
Method Detail

setTxnMgrUrl

public static void setTxnMgrUrl(String txnMgrUrl)

addLinkHeader

public static void addLinkHeader(javax.ws.rs.core.Response.ResponseBuilder response,
                                 javax.ws.rs.core.UriInfo info,
                                 String title,
                                 String name,
                                 String... pathComponents)

setLinkHeader

public static void setLinkHeader(javax.ws.rs.core.Response.ResponseBuilder builder,
                                 String title,
                                 String rel,
                                 String href,
                                 String type)

setLinkHeader

public static void setLinkHeader(javax.ws.rs.core.Response.ResponseBuilder builder,
                                 org.jboss.resteasy.spi.Link link)

getTransactions

public Collection<String> getTransactions()
                                   throws HttpResponseException
Throws:
HttpResponseException

txCount

public int txCount()
            throws HttpResponseException
Throws:
HttpResponseException

startTx

public TxSupport startTx()
                  throws HttpResponseException
Throws:
HttpResponseException

startTx

public TxSupport startTx(long milliseconds)
                  throws HttpResponseException
Throws:
HttpResponseException

commitTx

public String commitTx()
                throws HttpResponseException
Throws:
HttpResponseException

rollbackTx

public String rollbackTx()
                  throws HttpResponseException
Throws:
HttpResponseException

txStatus

public String txStatus()
                throws HttpResponseException
Throws:
HttpResponseException

txUrl

public String txUrl()

txTerminatorUrl

public String txTerminatorUrl()

enlistUrl

public String enlistUrl()

getBody

public String getBody()

getStatus

public int getStatus()

refreshLinkHeaders

public void refreshLinkHeaders(Map<String,String> linkHeaders)
                        throws HttpResponseException
Throws:
HttpResponseException

enlist

public String enlist(String pUrl)
              throws HttpResponseException
Throws:
HttpResponseException

httpRequest

public String httpRequest(int[] expect,
                          String url,
                          String method,
                          String mediaType,
                          String content,
                          Map<String,String> linkHeaders)
                   throws HttpResponseException
Throws:
HttpResponseException

getParticipantUrls

public static String getParticipantUrls(String terminatorUrl,
                                        String participantUrl)

getStringValue

public static String getStringValue(String content,
                                    String name)

getIntValue

public static int getIntValue(String content,
                              String name,
                              int defValue)

matchNames

public static void matchNames(Map<String,String> pairs,
                              String content,
                              String splitChars)
Parse a string for name=value pairs TODO java.util.Scanner might be more efficient

Parameters:
pairs - the name value pairs contained in content
content - a string containing name=value substrings

getUriBuilder

public static javax.ws.rs.core.UriBuilder getUriBuilder(javax.ws.rs.core.UriInfo info,
                                                        int npaths,
                                                        String... paths)

getUri

public static URI getUri(javax.ws.rs.core.UriInfo info,
                         int npaths,
                         String... paths)

buildURI

public static String buildURI(javax.ws.rs.core.UriBuilder builder,
                              String... pathComponents)

getStatus

public static String getStatus(String statusContent)

toContent

public static String toContent(String property,
                               String status)

toStatusContent

public static String toStatusContent(String status)

isPrepare

public static boolean isPrepare(String status)

isCommit

public static boolean isCommit(String status)

isAbort

public static boolean isAbort(String status)

isReadOnly

public static boolean isReadOnly(String status)

isHeuristic

public static boolean isHeuristic(String status)

isComplete

public static boolean isComplete(String status)

isActive

public static boolean isActive(String status)


Copyright © 2011. All Rights Reserved.