use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class AbstractEjbHandler method doTimedObjectProcessing.
/**
* Process TimedObject and @Timeout annotation. It's better to do it
* when processing the initial bean type since Timeout method is a
* business method that should be included in any tx processing defaulting
* that takes place.
*/
private void doTimedObjectProcessing(Class ejbClass, EjbDescriptor ejbDesc) {
// Timeout methods can be declared on the bean class or any
// super-class and can be public, protected, private, or
// package access. There can be at most one timeout method for
// the entire bean class hierarchy, so we start from the bean
// class and go up, stopping when we find the first one.
MethodDescriptor timeoutMethodDesc = null;
Class nextClass = ejbClass;
while ((nextClass != Object.class) && (nextClass != null) && (timeoutMethodDesc == null)) {
Method[] methods = nextClass.getDeclaredMethods();
for (Method m : methods) {
if ((m.getAnnotation(Timeout.class) != null)) {
timeoutMethodDesc = new MethodDescriptor(m, MethodDescriptor.TIMER_METHOD);
break;
}
}
nextClass = nextClass.getSuperclass();
}
if ((timeoutMethodDesc == null) && javax.ejb.TimedObject.class.isAssignableFrom(ejbClass)) {
// If the class implements the TimedObject interface, it must
// be ejbTimeout.
timeoutMethodDesc = new MethodDescriptor("ejbTimeout", "@Timeout method", new String[] { "javax.ejb.Timer" }, MethodDescriptor.TIMER_METHOD);
}
if (timeoutMethodDesc != null) {
ejbDesc.setEjbTimeoutMethod(timeoutMethodDesc);
}
return;
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class EJBTimerService method createSchedules.
/**
* Create automatic timers defined by the @Schedule annotation on the EJB bean.
*
* XXX???
* If this method is called on a deploy in a clustered deployment, only persistent schedule
* based timers will be created. And no timers will be scheduled.
* If it is called from deploy on a non-clustered instance, both
* persistent and non-persistent timers will be created.
* Otherwise only non-persistent timers are created by this method.
*/
protected void createSchedules(long containerId, long applicationId, Map<?, List<ScheduledTimerDescriptor>> schedules, Map<TimerPrimaryKey, Method> result, String server_name, boolean startTimers, boolean deploy) throws Exception {
for (Map.Entry<?, List<ScheduledTimerDescriptor>> entry : schedules.entrySet()) {
Object key = entry.getKey();
String mname = null;
int args_length = 0;
if (key instanceof Method) {
mname = ((Method) key).getName();
args_length = ((Method) key).getParameterTypes().length;
} else {
mname = ((MethodDescriptor) key).getName();
args_length = ((MethodDescriptor) key).getJavaParameterClassNames().length;
}
for (ScheduledTimerDescriptor sch : entry.getValue()) {
boolean persistent = sch.getPersistent();
if ((persistent && !deploy) || (!persistent && !startTimers)) {
// non-persistent timers on a clustered deploy
continue;
}
EJBTimerSchedule ts = new EJBTimerSchedule(sch, mname, args_length);
TimerConfig tc = new TimerConfig();
String info = sch.getInfo();
if (info != null && !info.equals("")) {
tc.setInfo(info);
}
tc.setPersistent(persistent);
TimerPrimaryKey tpk = createTimer(containerId, applicationId, ts, tc, server_name);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "@@@ CREATED new schedule: " + ts.getScheduleAsString() + " FOR method: " + key);
}
if (startTimers && result != null) {
result.put(tpk, (Method) key);
}
}
}
}
Aggregations