public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException { // TODO the servlet spec is not clear about searching in superclass?? // May be only check non private fields and methods Method[] methods = instance.getClass().getDeclaredMethods(); Method preDestroy = null; for (Method method : methods) { if (method.isAnnotationPresent(PreDestroy.class)) { // must not throw any checked expections // the method must not be static // must not throw any checked expections // the return value must be void // the method may be public, protected, package private or private if ((preDestroy != null) || (method.getParameterTypes().length != 0) || (Modifier.isStatic(method.getModifiers())) || (method.getExceptionTypes().length > 0) || (!method.getReturnType().getName().equals("void"))) { throw new IllegalArgumentException("Invalid PreDestroy annotation"); } preDestroy = method; } } invokeAnnotatedMethod(preDestroy, instance); }
public Object newInstance(String className) throws InstantiationException, IllegalAccessException, NamingException, InvocationTargetException, ClassNotFoundException { Class clazz = ClassUtils.classForName(className); Object object = clazz.newInstance(); processAnnotations(object); postConstruct(object); return object; }
private static Map<Class,Method[]> getDeclaredMethodBeansMap() { ClassLoader cl = ClassUtils.getContextClassLoader(); Map<Class,Method[]> metadata = (Map<Class,Method[]>) declaredMethodBeans.get(cl); if (metadata == null) { // Ensure thread-safe put over _metadata, and only create one map // per classloader to hold metadata. synchronized (declaredMethodBeans) { metadata = createDeclaredMethodBeansMap(cl, metadata); } } return metadata; }
Method[] methods = getDeclaredMethods(clazz); Method preDestroy = null; for (int i = 0; i < methods.length; i++) invokeAnnotatedMethod(preDestroy, instance);
Method[] methods = getDeclaredMethods(clazz); if (methods == null) Map<Class,Method[]> declaredMethodBeansMap = getDeclaredMethodBeansMap(); synchronized(declaredMethodBeansMap) invokeAnnotatedMethod(postConstruct, instance);
return new NoInjectionAnnotationLifecycleProvider(); return new NoInjectionAnnotationLifecycleProvider();
public Object newInstance(String className) throws InstantiationException, IllegalAccessException, NamingException, InvocationTargetException, ClassNotFoundException { Class clazz = ClassUtils.classForName(className); Object object = clazz.newInstance(); processAnnotations(object); //postConstruct(object); return object; }
Method[] getDeclaredMethods(Class clazz) { Map<Class,Method[]> declaredMethodBeansMap = getDeclaredMethodBeansMap(); Method[] methods = declaredMethodBeansMap.get(clazz); if (methods == null) { methods = clazz.getDeclaredMethods(); synchronized(declaredMethodBeansMap) { declaredMethodBeansMap.put(clazz, methods); } } return methods; }
LIFECYCLE_PROVIDER_INSTANCE = new NoInjectionAnnotationLifecycleProvider(); log.error("No InitialContext found. Using NoInjectionAnnotationProcessor.", e);
public Object newInstance(String className) throws InstantiationException, IllegalAccessException, NamingException, InvocationTargetException, ClassNotFoundException { Class clazz = ClassUtils.classForName(className); Object object = clazz.newInstance(); processAnnotations(object); //postConstruct(object); return object; }
invokeAnnotatedMethod(postConstruct, instance);
return new NoInjectionAnnotationLifecycleProvider();
public Object newInstance(String className) throws InstantiationException, IllegalAccessException, NamingException, InvocationTargetException, ClassNotFoundException { Class clazz = ClassUtils.classForName(className); Object object = clazz.newInstance(); processAnnotations(object); //postConstruct(object); return object; }
public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException { // TODO the servlet spec is not clear about searching in superclass?? // May be only check non private fields and methods Method[] methods = instance.getClass().getDeclaredMethods(); Method preDestroy = null; for (Method method : methods) { if (method.isAnnotationPresent(PreDestroy.class)) { // must not throw any checked expections // the method must not be static // must not throw any checked expections // the return value must be void // the method may be public, protected, package private or private if ((preDestroy != null) || (method.getParameterTypes().length != 0) || (Modifier.isStatic(method.getModifiers())) || (method.getExceptionTypes().length > 0) || (!method.getReturnType().getName().equals("void"))) { throw new IllegalArgumentException("Invalid PreDestroy annotation"); } preDestroy = method; } } invokeAnnotatedMethod(preDestroy, instance); }
return new NoInjectionAnnotationLifecycleProvider();
public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException { // TODO the servlet spec is not clear about searching in superclass?? // May be only check non private fields and methods Method[] methods = instance.getClass().getDeclaredMethods(); Method preDestroy = null; for (Method method : methods) { if (method.isAnnotationPresent(PreDestroy.class)) { // must not throw any checked expections // the method must not be static // must not throw any checked expections // the return value must be void // the method may be public, protected, package private or private if ((preDestroy != null) || (method.getParameterTypes().length != 0) || (Modifier.isStatic(method.getModifiers())) || (method.getExceptionTypes().length > 0) || (!method.getReturnType().getName().equals("void"))) { throw new IllegalArgumentException("Invalid PreDestroy annotation"); } preDestroy = method; } } invokeAnnotatedMethod(preDestroy, instance); }
invokeAnnotatedMethod(postConstruct, instance);
invokeAnnotatedMethod(postConstruct, instance);