public void callback (Object instance) throws SecurityException, IllegalArgumentException, NoSuchMethodException, ClassNotFoundException, IllegalAccessException, InvocationTargetException { super.callback(instance); }
@Override public boolean equals(Object o) { if (super.equals(o) && (o instanceof PreDestroyCallback)) return true; return false; } }
@Override public boolean equals (Object o) { if (o==null) return false; if (!(o instanceof LifeCycleCallback)) return false; LifeCycleCallback callback = (LifeCycleCallback)o; if (callback.getTargetClass()==null) { if (getTargetClass() != null) return false; } else if(!callback.getTargetClass().equals(getTargetClass())) return false; if (callback.getTarget()==null) { if (getTarget() != null) return false; } else if (!callback.getTarget().equals(getTarget())) return false; return true; }
/** * Add a Callback to the list of callbacks. * * @param callback the callback */ public void add (LifeCycleCallback callback) { if ((callback==null) || (callback.getTargetClassName()==null)) return; if (LOG.isDebugEnabled()) LOG.debug("Adding callback for class="+callback.getTargetClass()+ " on "+callback.getTarget()); Map<String, List<LifeCycleCallback>> map = null; if (callback instanceof PreDestroyCallback) map = preDestroyCallbacksMap; if (callback instanceof PostConstructCallback) map = postConstructCallbacksMap; if (map == null) throw new IllegalArgumentException ("Unsupported lifecycle callback type: "+callback); List<LifeCycleCallback> callbacks = map.get(callback.getTargetClassName()); if (callbacks==null) { callbacks = new ArrayList<LifeCycleCallback>(); map.put(callback.getTargetClassName(), callbacks); } //don't add another callback for exactly the same method if (!callbacks.contains(callback)) callbacks.add(callback); }
callback.setTarget(clazz, methodName); ((LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION)).add(callback); callback.setTarget(clazz, methodName); ((LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION)).add(callback); callback.setTarget(clazz, methodName); ((LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION)).add(callback);
public void setTarget (Class<?> clazz, String methodName) { try { Method method = IntrospectionUtil.findMethod(clazz, methodName, null, true, true); validate(clazz, method); _target = method; _targetClass = clazz; _className = clazz.getCanonicalName(); _methodName = methodName; } catch (NoSuchMethodException e) { throw new IllegalArgumentException ("Method "+methodName+" not found on class "+clazz.getName()); } }
public void callback (Object instance) throws SecurityException, NoSuchMethodException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (_target == null) { if (_targetClass == null) _targetClass = Loader.loadClass(null, _className); _target = _targetClass.getDeclaredMethod(_methodName, new Class[]{}); //TODO } if (_target != null) { boolean accessibility = getTarget().isAccessible(); getTarget().setAccessible(true); getTarget().invoke(instance, __EMPTY_ARGS); getTarget().setAccessible(accessibility); } }
return method; else return findMethod(clazz.getPackage(), clazz.getSuperclass(), methodName, true); return findMethod(clazz.getPackage(), clazz.getSuperclass(), methodName, true);
out.tag("lifecycle-callback-class", c.getTargetClassName()); out.tag("lifecycle-callback-method", c.getMethodName()); out.closeTag(); out.tag("lifecycle-callback-class", c.getTargetClassName()); out.tag("lifecycle-callback-method", c.getMethodName()); out.closeTag();
/** * Add a Callback to the list of callbacks. * * @param callback */ public void add (LifeCycleCallback callback) { if ((callback==null) || (callback.getTargetClassName()==null)) return; if (LOG.isDebugEnabled()) LOG.debug("Adding callback for class="+callback.getTargetClass()+ " on "+callback.getTarget()); Map<String, List<LifeCycleCallback>> map = null; if (callback instanceof PreDestroyCallback) map = preDestroyCallbacksMap; if (callback instanceof PostConstructCallback) map = postConstructCallbacksMap; if (map == null) throw new IllegalArgumentException ("Unsupported lifecycle callback type: "+callback); List<LifeCycleCallback> callbacks = map.get(callback.getTargetClassName()); if (callbacks==null) { callbacks = new ArrayList<LifeCycleCallback>(); map.put(callback.getTargetClassName(), callbacks); } //don't add another callback for exactly the same method if (!callbacks.contains(callback)) callbacks.add(callback); }
callback.setTarget(clazz, methodName); ((LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION)).add(callback); callback.setTarget(clazz, methodName); ((LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION)).add(callback); callback.setTarget(clazz, methodName); ((LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION)).add(callback);
public void setTarget (Class<?> clazz, String methodName) { try { Method method = IntrospectionUtil.findMethod(clazz, methodName, null, true, true); validate(clazz, method); _target = method; _targetClass = clazz; _className = clazz.getCanonicalName(); _methodName = methodName; } catch (NoSuchMethodException e) { throw new IllegalArgumentException ("Method "+methodName+" not found on class "+clazz.getName()); } }
public void callback (Object instance) throws SecurityException, NoSuchMethodException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (_target == null) { if (_targetClass == null) _targetClass = Loader.loadClass(null, _className); _target = _targetClass.getDeclaredMethod(_methodName, TypeUtil.NO_ARGS); } if (_target != null) { boolean accessibility = getTarget().isAccessible(); getTarget().setAccessible(true); getTarget().invoke(instance, __EMPTY_ARGS); getTarget().setAccessible(accessibility); } }
return method; else return findMethod(clazz.getPackage(), clazz.getSuperclass(), methodName, true); return findMethod(clazz.getPackage(), clazz.getSuperclass(), methodName, true);
/** * Add a Callback to the list of callbacks. * * @param callback */ public void add (LifeCycleCallback callback) { if ((callback==null) || (callback.getTargetClassName()==null)) return; if (LOG.isDebugEnabled()) LOG.debug("Adding callback for class="+callback.getTargetClass()+ " on "+callback.getTarget()); Map<String, List<LifeCycleCallback>> map = null; if (callback instanceof PreDestroyCallback) map = preDestroyCallbacksMap; if (callback instanceof PostConstructCallback) map = postConstructCallbacksMap; if (map == null) throw new IllegalArgumentException ("Unsupported lifecycle callback type: "+callback); List<LifeCycleCallback> callbacks = map.get(callback.getTargetClassName()); if (callbacks==null) { callbacks = new ArrayList<LifeCycleCallback>(); map.put(callback.getTargetClassName(), callbacks); } //don't add another callback for exactly the same method if (!callbacks.contains(callback)) callbacks.add(callback); }
public void callback (Object instance) throws SecurityException, IllegalArgumentException, NoSuchMethodException, ClassNotFoundException, IllegalAccessException, InvocationTargetException { super.callback(instance); }
public boolean equals (Object o) { if (o==null) return false; if (!(o instanceof LifeCycleCallback)) return false; LifeCycleCallback callback = (LifeCycleCallback)o; if (callback.getTargetClass()==null) { if (getTargetClass() != null) return false; } else if(!callback.getTargetClass().equals(getTargetClass())) return false; if (callback.getTarget()==null) { if (getTarget() != null) return false; } else if (!callback.getTarget().equals(getTarget())) return false; return true; }
public boolean equals (Object o) { if (super.equals(o) && (o instanceof PostConstructCallback)) return true; return false; } }
callback.setTarget(clazz, methodName); ((LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION)).add(callback); callback.setTarget(clazz, methodName); ((LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION)).add(callback); callback.setTarget(clazz, methodName); ((LifeCycleCallbackCollection)context.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION)).add(callback);
public void setTarget (Class<?> clazz, String methodName) { try { Method method = IntrospectionUtil.findMethod(clazz, methodName, null, true, true); validate(clazz, method); _target = method; _targetClass = clazz; _className = clazz.getCanonicalName(); _methodName = methodName; } catch (NoSuchMethodException e) { throw new IllegalArgumentException ("Method "+methodName+" not found on class "+clazz.getName()); } }