net.m2technologies.open_arm.transport.transaction
Class AbstractTransactionMediatorImpl

java.lang.Object
  extended bynet.m2technologies.open_arm.transport.transaction.AbstractTransactionMediatorImpl
All Implemented Interfaces:
ArmInterface, ArmTransaction, ArmTransactionWithMetrics, TransactionMediator, TransportMediator
Direct Known Subclasses:
DatastoreMediator, JmxMediator, LoggingMediator, MessagingMediator, SnmpMediator

public abstract class AbstractTransactionMediatorImpl
extends java.lang.Object
implements TransactionMediator

Copyright 2005 Mark Masterson

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Description: This class implements the core functionality for all TransactionTransportMediators..

Version:
0.009
Author:
Mark Masterson

Constructor Summary
protected AbstractTransactionMediatorImpl(java.lang.Object transactionDelegate)
          Creates an instance of this class.
 
Method Summary
 int bindThread()
          Deprecated. We may not ever implement this method!
 long blocked()
          Obtains the next locking handle from the transaction delegate, calls the hook method #doBlocked, and returns the handle.
protected abstract  void doBlocked(long tmpHandle)
          Concrete implementations implement this method to persist/record/transmit the event.
protected abstract  void doStop(long elapsedTime, long totalElapsedTime, int status, java.lang.String diagnosticDetail)
          Concrete implementations implement this method to persist/record/transmit the event.
protected abstract  void doUnblocked(long blockHandle)
          Concrete implementations implement this method to persist/record/transmit the event.
protected abstract  void doUpdate(long runningTime, long totalRunningTime)
          Concrete implementations implement this method to persist/record/transmit the event.
 ArmApplication getApplication()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
protected  java.lang.String getBlockedMessage(long tmpHandle)
           
 java.lang.String getContextURIValue()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 java.lang.String getContextValue(int index)
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 ArmCorrelator getCorrelator()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
protected  ArmTransactionFactory getCreatingFactory()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 ArmTransactionDefinition getDefinition()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
protected  ArmTransaction getDelegate()
           
 int getErrorCode()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 java.lang.String getErrorMessage(int errorCode)
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 ArmMetricGroup getMetricGroup()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 ArmCorrelator getParentCorrelator()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 int getStatus()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
protected  java.lang.String getStopMessage(long elapsedTime, long totalElapsedTime, int status, java.lang.String diagnosticDetail)
           
 ArmTransactionWithMetricsDefinition getTransactionWithMetricsDefinition()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
protected  java.lang.String getUnblockedMessage(long blockHandle)
           
protected  java.lang.String getUpdateMessage(long runningTime, long totalRunningTime)
           
 ArmUser getUser()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 boolean isTraceRequested()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 int reset()
          Resets all of the transaction delimited attributes of the delegate object.
 int setArrivalTime()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 int setContextURIValue(java.lang.String value)
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 int setContextValue(int index, java.lang.String value)
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 int setErrorCode(int errorCode)
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 int setTraceRequested(boolean traceState)
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 void setTransactionalDelegate(java.lang.Object transactionDelegate)
          This class has an association with an instance of ArmTransaction -- the caller must either provide that instance here, or pass it to the constructor.
 int setUser(ArmUser user)
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.
 int start()
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given, and sets the start time to System.currentTimeMillis().
 int start(ArmCorrelator parentCorr)
          Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given, sets the start time to System.currentTimeMillis(), and the parent correlator to the value of the parameter passed to this method.
 int start(byte[] parentCorr)
          See start(ArmCorrelator parentCorr)
 int start(byte[] parentCorr, int offset)
          Deprecated. We may never implement this method!
 int stop(int status)
          See stop(int status, String diagnosticDetail)
 int stop(int status, java.lang.String diagnosticDetail)
          This method obtains the stop time via System.currentTimeMillis(), calculates the elapsed time by subtracting the start time recorded in the transactional delegates' instance from this value, calculates the total elapsed time (if needed) by subtracting the transactional delegates' instance of the arrival time from the stop time, and calls the protected hook method #doStop to allow concrete implementations to record/persist the event.
 int unbindThread()
          Deprecated. We may never implement this method!
 int unblocked(long blockHandle)
          Calls the #doUnblocked hook method.
 int update()
          Obtains the update timestamp via System.currentTimeMillis().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.m2technologies.open_arm.transport.TransportMediator
setConfiguration
 

Constructor Detail

AbstractTransactionMediatorImpl

protected AbstractTransactionMediatorImpl(java.lang.Object transactionDelegate)
Creates an instance of this class. This class has an association with an instance of ArmTransaction -- the caller of this constructor must either provide that instance here, or provide it later with a call to #setTransactionalDelegate.

Parameters:
transactionDelegate -
Method Detail

setTransactionalDelegate

public final void setTransactionalDelegate(java.lang.Object transactionDelegate)
This class has an association with an instance of ArmTransaction -- the caller must either provide that instance here, or pass it to the constructor.

Specified by:
setTransactionalDelegate in interface TransportMediator
Parameters:
transactionDelegate -

getCreatingFactory

protected ArmTransactionFactory getCreatingFactory()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Returns:
an instance of the creating ArmTransactionFactory

bindThread

public int bindThread()
Deprecated. We may not ever implement this method!

This method is not currently supported.

Specified by:
bindThread in interface ArmTransaction
Returns:
UnsupportedOperationException

blocked

public long blocked()
Obtains the next locking handle from the transaction delegate, calls the hook method #doBlocked, and returns the handle.

Specified by:
blocked in interface ArmTransaction
Returns:
the next locking handle -- locking handles are just an incremented counter, and they are not guaranteed to be uniquie across VM's or invocations of the same VM.

doBlocked

protected abstract void doBlocked(long tmpHandle)
Concrete implementations implement this method to persist/record/transmit the event.

Parameters:
tmpHandle -

getApplication

public ArmApplication getApplication()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
getApplication in interface ArmTransaction
Returns:
the delegates' instance of ArmApplication

getContextURIValue

public java.lang.String getContextURIValue()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
getContextURIValue in interface ArmTransaction
Returns:
the context URI, if set

getContextValue

public java.lang.String getContextValue(int index)
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
getContextValue in interface ArmTransaction
Parameters:
index - of the desired context value
Returns:
the context value at the given index

getCorrelator

public ArmCorrelator getCorrelator()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
getCorrelator in interface ArmTransaction
Returns:
the delegates' instance of ArmCorrelator, if set

getParentCorrelator

public ArmCorrelator getParentCorrelator()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
getParentCorrelator in interface ArmTransaction
Returns:
the delegates' instance of the parent ArmCorrelator, if set

getStatus

public int getStatus()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
getStatus in interface ArmTransaction
Returns:
the completion status of the last iteration of this transaction.

getDefinition

public ArmTransactionDefinition getDefinition()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
getDefinition in interface ArmTransaction
Returns:
the delegates' instance of ArmTransactionDefinition

getUser

public ArmUser getUser()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
getUser in interface ArmTransaction
Returns:
the delegates' instance of ArmUser

isTraceRequested

public boolean isTraceRequested()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
isTraceRequested in interface ArmTransaction
Returns:
true if the trace flag is set on the delegate, otherwise false.

reset

public int reset()
Resets all of the transaction delimited attributes of the delegate object.

Specified by:
reset in interface ArmTransaction
Returns:
Zero. Always. No kidding!

setArrivalTime

public int setArrivalTime()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
setArrivalTime in interface ArmTransaction
Returns:
the delegates' instance of arrival time

setContextURIValue

public int setContextURIValue(java.lang.String value)
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
setContextURIValue in interface ArmTransaction
Parameters:
value -
Returns:
The ARM error code. Zero means 'No problem!'

setContextValue

public int setContextValue(int index,
                           java.lang.String value)
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
setContextValue in interface ArmTransaction
Parameters:
index -
value -
Returns:
The ARM error code. Zero means 'No problem!'

setTraceRequested

public int setTraceRequested(boolean traceState)
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
setTraceRequested in interface ArmTransaction
Parameters:
traceState -
Returns:
The ARM error code. Zero means 'No problem!'

setUser

public int setUser(ArmUser user)
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
setUser in interface ArmTransaction
Parameters:
user -
Returns:
The ARM error code. Zero means 'No problem!'

start

public int start()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given, and sets the start time to System.currentTimeMillis().

Specified by:
start in interface ArmTransaction
Returns:
Zero. Always. No kidding.

start

public int start(byte[] parentCorr)
See start(ArmCorrelator parentCorr)

Specified by:
start in interface ArmTransaction
Parameters:
parentCorr -
Returns:
the parent correlator

start

public int start(byte[] parentCorr,
                 int offset)
Deprecated. We may never implement this method!

This method signature is not supported.

Specified by:
start in interface ArmTransaction
Parameters:
parentCorr -
offset -
Returns:
UnsupportedOperationException

start

public int start(ArmCorrelator parentCorr)
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given, sets the start time to System.currentTimeMillis(), and the parent correlator to the value of the parameter passed to this method.

Specified by:
start in interface ArmTransaction
Parameters:
parentCorr -
Returns:
#start's error code

stop

public int stop(int status)
See stop(int status, String diagnosticDetail)

Specified by:
stop in interface ArmTransaction
Parameters:
status -
Returns:
error code

stop

public int stop(int status,
                java.lang.String diagnosticDetail)
This method obtains the stop time via System.currentTimeMillis(), calculates the elapsed time by subtracting the start time recorded in the transactional delegates' instance from this value, calculates the total elapsed time (if needed) by subtracting the transactional delegates' instance of the arrival time from the stop time, and calls the protected hook method #doStop to allow concrete implementations to record/persist the event.

Specified by:
stop in interface ArmTransaction
Parameters:
status -
diagnosticDetail -
Returns:
Zero as placeholder error code

doStop

protected abstract void doStop(long elapsedTime,
                               long totalElapsedTime,
                               int status,
                               java.lang.String diagnosticDetail)
Concrete implementations implement this method to persist/record/transmit the event.

Parameters:
elapsedTime -
totalElapsedTime -
status -
diagnosticDetail -

unbindThread

public int unbindThread()
Deprecated. We may never implement this method!

This method is not supported.

Specified by:
unbindThread in interface ArmTransaction
Returns:
UnsupportedOperationException

unblocked

public int unblocked(long blockHandle)
Calls the #doUnblocked hook method.

Specified by:
unblocked in interface ArmTransaction
Parameters:
blockHandle -
Returns:
Zero as placeholder error code

doUnblocked

protected abstract void doUnblocked(long blockHandle)
Concrete implementations implement this method to persist/record/transmit the event.

Parameters:
blockHandle -

update

public int update()
Obtains the update timestamp via System.currentTimeMillis(). Calculates running time and (if needed) total running time, by subtracting start and arrival time, respectively, from this value. Then calls the #doUpdate hook method to persist/record the event.

Specified by:
update in interface ArmTransaction
Returns:
Zero as placeholder error code

doUpdate

protected abstract void doUpdate(long runningTime,
                                 long totalRunningTime)
Concrete implementations implement this method to persist/record/transmit the event.

Parameters:
runningTime -
totalRunningTime -

getErrorCode

public int getErrorCode()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
getErrorCode in interface ArmInterface
Returns:
error code

setErrorCode

public int setErrorCode(int errorCode)
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
setErrorCode in interface ArmInterface
Parameters:
errorCode -
Returns:
error code

getErrorMessage

public java.lang.String getErrorMessage(int errorCode)
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given.

Specified by:
getErrorMessage in interface ArmInterface
Parameters:
errorCode -
Returns:
the text message that matches the error code param

getTransactionWithMetricsDefinition

public ArmTransactionWithMetricsDefinition getTransactionWithMetricsDefinition()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given. This method can throw a ClassCast Exception, if the delegate being used is not an instance of ArmTransactionWithMetrics.

Specified by:
getTransactionWithMetricsDefinition in interface ArmTransactionWithMetrics
Returns:
ArmTransactionWithMetricsDefinition

getMetricGroup

public ArmMetricGroup getMetricGroup()
Invokes the method of the same name on the delegate instance of ArmTransaction that the constructor is given. This method can throw a ClassCast Exception, if the delegate being used is not an instance of ArmTransactionWithMetrics.

Specified by:
getMetricGroup in interface ArmTransactionWithMetrics
Returns:
ArmMetricGroup

getDelegate

protected ArmTransaction getDelegate()

getBlockedMessage

protected java.lang.String getBlockedMessage(long tmpHandle)

getStopMessage

protected java.lang.String getStopMessage(long elapsedTime,
                                          long totalElapsedTime,
                                          int status,
                                          java.lang.String diagnosticDetail)

getUnblockedMessage

protected java.lang.String getUnblockedMessage(long blockHandle)

getUpdateMessage

protected java.lang.String getUpdateMessage(long runningTime,
                                            long totalRunningTime)