On Jan 18, 2007, at 4:23 PM, Alan D. Cabrera wrote:
Really? You have to grok those nested case statements and
construct the states of allowable operations in your head.
switch (currentOperation) {
case SET_CONTEXT:
case UNSET_CONTEXT:
switch(methodCategory){
case getCallerPrincipal:
case getRollbackOnly:
case isCallerInRole:
case setRollbackOnly:
case getEJBObject:
case getPrimaryKey:
case getUserTransaction:
throw new IllegalStateException
(methodCategory + "cannot be called in " + currentOperation);
}
What's to grock? For the setContext and unsetContext operations only
the listed methods can be called. Looks straight forward to me.
You really like that check method better?
Yes. Once you get the switch right, the code never changes (until
sun releases a new ejb spec), and it is very concise and readable.
-dain