|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpl.gda.pg.eti.ask.przemyslawbielicki.aeh.ejb.ExceptionControllerBean
ExceptionController
class gives methods for safe method invocation from
EJB objects. It enables to invoke methods once invokeOnce(Object, String, Object[])
,
with repeat invokeAndRepeat(Object, String, Object[], int)
,
invokeAndRepeat(Object, String, Object[], int, long)
, and invoke equal or
similar methods from different EJB objects invokeNVariant(Object[], String[], Object[][])
.
If any of invoked method throws an exception information about it is passed to
MethodInfo
class which updates information (statistics) about invoked method.
MethodInfo
,
Serialized FormField Summary | |
private static UTL.ResultLoggerLocal |
LOG
|
Constructor Summary | |
ExceptionControllerBean()
|
Method Summary | |
private Class[] |
createParameterTypes(Object[] args)
Creates parameterType array for given object list. |
void |
ejbActivate()
Activate method |
void |
ejbCreate()
Create method for EJB |
void |
ejbPassivate()
Passivate method |
void |
ejbRemove()
Remove method |
void |
initialize(String path)
|
boolean |
invokeAndCheck(Object object,
String methodName,
Object[] args,
Object expectedValue)
Invokes method methodName from object with given
arguments (args ) and checks if returnValue equals
expectedValue . |
Object |
invokeAndRepeat(Object object,
String methodName,
Object[] args,
int repeat)
Invokes method methodName from object with given
arguments (args ). |
Object |
invokeAndRepeat(Object object,
String methodName,
Object[] args,
int repeat,
long delay)
Invokes method methodName from object with given
arguments (args ). |
Object |
invokeNVariant(Object[] objects,
String[] methodNames,
Object[][] args)
Invokes method methodNames from objects with given
arguments (args ). |
Object |
invokeOnce(Object object,
String methodName,
Object[] args)
Invokes method methodName from object with given
arguments (args ). |
void |
setSessionContext(SessionContext context)
Setter method for session context |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static UTL.ResultLoggerLocal LOG
Constructor Detail |
public ExceptionControllerBean()
Method Detail |
public void ejbCreate() throws CreateException
CreateException
public void ejbActivate() throws EJBException, RemoteException
ejbActivate
in interface SessionBean
EJBException
RemoteException
public void ejbPassivate() throws EJBException, RemoteException
ejbPassivate
in interface SessionBean
EJBException
RemoteException
public void ejbRemove() throws EJBException, RemoteException
ejbRemove
in interface SessionBean
EJBException
RemoteException
public void setSessionContext(SessionContext context) throws EJBException, RemoteException
setSessionContext
in interface SessionBean
EJBException
RemoteException
public void initialize(String path)
path
- private Class[] createParameterTypes(Object[] args)
Method
object.
args
- array of arguments to convert to class list
Method.getParameterTypes()
public Object invokeOnce(Object object, String methodName, Object[] args) throws InvocationTargetException
Invokes method methodName
from object
with given
arguments (args
). Return value is stored in returnValue
argument.
Invokes given method only once. When invoking method methodName
finishes
with exception throwing method update statistics about invoking method (add exception
invocation). Also when invoked method throws an exception it (exception) is passed to
caller by putting thrown exception object into targetException
argument.
Every exception thrown during invocation operation is logged to LOG MANAGER. This is TODO logging.
object
- user wants to invoke method from this object;
TODO what if method is static???methodName
- name of the method we want to invokeargs
- arguments for invoking method
InvocationTargetException
- exception thrown during methodName
invocationpublic Object invokeAndRepeat(Object object, String methodName, Object[] args, int repeat) throws InvocationTargetException
Invokes method methodName
from object
with given
arguments (args
). Return value is stored in returnValue
argument.
Invokes given method repeat
(maximum) times. When invoking method
methodName
finishes with exception throwing method update statistics
about invoking method (add exception invocation) and method methodName
is invoked again and againg (till loop counter doesn't approach repeat
value). If method invocation doesn't throw exception method breaks loop and goes further.
It means that method invoked correctly.
Generally this method calls method invokeOnce
- maximum repeat
times.
Every exception thrown during invocation operation is logged to LOG MANAGER. This is TODO logging.
object
- user wants to invoke method from this object;
TODO what if method is static???methodName
- name of the method we want to invokeargs
- arguments for invoking methodrepeat
- how many times (maximum) try to invoke method methodName
InvocationTargetException
- exception thrown during methodName
invocationinvokeOnce(Object, String, Object[])
public Object invokeAndRepeat(Object object, String methodName, Object[] args, int repeat, long delay) throws InvocationTargetException
Invokes method methodName
from object
with given
arguments (args
). Return value is stored in returnValue
argument.
Invokes given method repeat
(maximum) times. When invoking method
finishes with exception throwing method update statistics about invoking method (add exception
invocation) and method methodName
is invoked again and againg (till loop counter
doesn't approach repeat
value). Loop stops every exceptional invocation for
delay
milliseconds. If method invocation doesn't throw exception method
breaks loop and goes further. It means that method invoked correctly.
invokeOnce
- maximum repeat
times.
Every exception thrown during invocation operation is logged to LOG MANAGER. This is TODO logging.
object
- user wants to invoke method from this object;
TODO what if method is static???methodName
- name of the method we want to invokeargs
- arguments for invoking methodrepeat
- how many times (maximum) try to invoke method methodName
delay
- time in milliseconds to wait between invocations (when invocation of
methodName
finishes with exception)
InvocationTargetException
- exception thrown during methodName
invocationinvokeOnce(Object, String, Object[])
,
invokeAndRepeat(Object, String, Object[], int)
public Object invokeNVariant(Object[] objects, String[] methodNames, Object[][] args) throws IllegalArgumentException
Invokes method methodNames
from objects
with given
arguments (args
). Return value is stored in returnValue
argument.
Invokes methods in order of objects
array. If first method from
first object throw an exception method invoke next method from objects
array. And so on. If any of these invoked methods finishes correctly method ends
and returnValue
contains return object from last invoked method.
Generally this method calls method invokeOnce
with specific arguments
for each method.
Every exception thrown during invocation operation is logged to LOG MANAGER. This is TODO logging.
objects
- array of objects that contain methods to invoke
TODO what if any of these method is static???methodNames
- array of names of the methods we want to invokeargs
- array of arguments for invoking methods
correctly and didn't throw an exception)
IllegalArgumentException
- argument arrays length mismatchinvokeOnce(Object, String, Object[])
public boolean invokeAndCheck(Object object, String methodName, Object[] args, Object expectedValue) throws InvocationTargetException
Invokes method methodName
from object
with given
arguments (args
) and checks if returnValue
equals
expectedValue
.
object
- user wants to invoke method from this object;
TODO what if method is static???methodName
- name of the method we want to invokeargs
- arguments for invoking methodexpectedValue
- expected object to be returned from invoking method
true
if method invoked correctly and value returned by this method
equals expected value; false
in other case
InvocationTargetException
- exception thrown during methodName
invocationinvokeOnce(Object, String, Object[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |