Methods Summary |
---|
public void | cancel()
checkCallPermission();
try {
timerService_.cancelTimer(timerId_);
} catch(FinderException fe) {
throw new NoSuchObjectLocalException("timer no longer exists", fe);
} catch(Exception e) {
throw new EJBException(e);
}
|
private static void | checkCallPermission()Verify that Timer method access is allowed from this context.
This method is static so that TimerHandle can call it even
before it has created a TimerWrapper instance.
boolean allowed = false;
ContainerFactoryImpl cf = (ContainerFactoryImpl)
Switch.getSwitch().getContainerFactory();
EJBTimerService timerService = cf.getEJBTimerService();
if( timerService == null ) {
throw new IllegalStateException
("EJBTimerService is not available");
}
try {
InvocationManager invManager =
Switch.getSwitch().getInvocationManager();
ComponentInvocation inv = invManager.getCurrentInvocation();
if (inv == null)
throw new IllegalStateException
("Invocation cannot be null");
int invType = inv.getInvocationType();
if( invType == ComponentInvocation.EJB_INVOCATION ) {
if ( inv instanceof Invocation ) {
ComponentContext context = ((Invocation) inv).context;
// Delegate check to EJB context. Let any
// IllegalStateException bubble up.
context.checkTimerServiceMethodAccess();
allowed = true;
} else {
// NOTE : There shouldn't be any cases where an EJB
// container uses com.sun.enterprise.ComponentInvocation
// instead of com.sun.ejb.Invocation and timer method
// access is allowed. No EJBContextImpl is available
// to perform checks.
allowed = false;
}
} else if( invType == ComponentInvocation.SERVLET_INVOCATION ) {
throw new IllegalStateException
("Web tier access to EJB timers through local " +
"interfaces is not portable");
}
} catch(InvocationException ie) {
IllegalStateException ise = new IllegalStateException
("Operation not allowed");
ise.initCause(ie);
throw ise;
}
if( !allowed ) {
throw new IllegalStateException("Operation not allowed");
}
|
public boolean | equals(java.lang.Object o)
boolean equal = false;
if(o instanceof TimerWrapper) {
TimerWrapper other = (TimerWrapper) o;
equal = other.timerId_.equals(this.timerId_);
}
return equal;
|
public javax.ejb.TimerHandle | getHandle()
checkCallPermission();
if( !timerService_.timerExists(timerId_) ) {
throw new NoSuchObjectLocalException("timer no longer exists");
}
return new TimerHandleImpl(timerId_);
|
public java.io.Serializable | getInfo()
checkCallPermission();
Serializable info;
try {
info = timerService_.getInfo(timerId_);
} catch(FinderException fe) {
throw new NoSuchObjectLocalException("timer no longer exists", fe);
}
return info;
|
public java.util.Date | getNextTimeout()
checkCallPermission();
Date nextTimeout;
try {
nextTimeout = timerService_.getNextTimeout(timerId_);
} catch(FinderException fe) {
throw new NoSuchObjectLocalException("timer no longer exists", fe);
}
return nextTimeout;
|
public com.sun.ejb.spi.io.SerializableObjectFactory | getSerializableObjectFactory()
return new SerializedTimerWrapper(timerId_);
|
public long | getTimeRemaining()
Date nextTimeout = getNextTimeout();
Date now = new Date();
long timeRemaining = nextTimeout.getTime() - now.getTime();
return (timeRemaining > 0) ? timeRemaining : 0;
|
public int | hashCode()
return timerId_.hashCode();
|
public java.lang.String | toString()
return "Timer " + timerId_;
|