public static Method findPreDestroyMethod(Class<?> c) { return findPreDestroyMethod(c, null); }
public static Method findPreDestroyMethod(Class<?> c) { return findPreDestroyMethod(c, null); }
public static Method findPreDestroyMethod(Class<?> c, String name) { if (Object.class == c || null == c) { return null; } for (Method m : c.getDeclaredMethods()) { if (name != null) { if (m.getName().equals(name)) { return m; } } else if (m.getAnnotation(PreDestroy.class) != null) { return m; } } Method m = findPreDestroyMethod(c.getSuperclass(), name); if (m != null) { return m; } for (Class<?> i : c.getInterfaces()) { m = findPreDestroyMethod(i, name); if (m != null) { return m; } } return null; }
public PerRequestResourceProvider(Class<?> clazz) { c = ResourceUtils.findResourceConstructor(clazz, true); if (c == null) { throw new RuntimeException("Resource class " + clazz + " has no valid constructor"); } params = c.getParameterTypes(); anns = c.getParameterAnnotations(); genericTypes = c.getGenericParameterTypes(); postConstructMethod = ResourceUtils.findPostConstructMethod(clazz); preDestroyMethod = ResourceUtils.findPreDestroyMethod(clazz); }
public static Method findPreDestroyMethod(Class<?> c, String name) { if (Object.class == c || null == c) { return null; } for (Method m : getDeclaredMethods(c)) { if (name != null) { if (m.getName().equals(name)) { return m; } } else if (m.getAnnotation(PreDestroy.class) != null) { return m; } } Method m = findPreDestroyMethod(c.getSuperclass(), name); if (m != null) { return m; } for (Class<?> i : c.getInterfaces()) { m = findPreDestroyMethod(i, name); if (m != null) { return m; } } return null; }
public PerRequestResourceProvider(Class<?> clazz) { c = ResourceUtils.findResourceConstructor(clazz, true); if (c == null) { throw new RuntimeException("Resource class " + clazz + " has no valid constructor"); } postConstructMethod = ResourceUtils.findPostConstructMethod(clazz); preDestroyMethod = ResourceUtils.findPreDestroyMethod(clazz); }
private void init() { Class<?> type = ClassHelper.getRealClassFromClass(ac.getType(beanId)); if (Proxy.isProxyClass(type)) { type = ClassHelper.getRealClass(ac.getBean(beanId)); } c = ResourceUtils.findResourceConstructor(type, !isSingleton()); if (c == null) { throw new RuntimeException("Resource class " + type + " has no valid constructor"); } postConstructMethod = ResourceUtils.findPostConstructMethod(type, postConstructMethodName); preDestroyMethod = ResourceUtils.findPreDestroyMethod(type, preDestroyMethodName); isSingleton = ac.isSingleton(beanId); if (!isSingleton) { isPrototype = ac.isPrototype(beanId); } }
private void init() { type = ClassHelper.getRealClassFromClass(ac.getType(beanId)); if (Proxy.isProxyClass(type)) { type = ClassHelper.getRealClass(ac.getBean(beanId)); } isSingleton = ac.isSingleton(beanId); postConstructMethod = ResourceUtils.findPostConstructMethod(type, postConstructMethodName); preDestroyMethod = ResourceUtils.findPreDestroyMethod(type, preDestroyMethodName); if (isSingleton()) { try { singletonInstance = ac.getBean(beanId); } catch (BeansException ex) { // ignore for now, try resolving resource constructor later } if (singletonInstance != null) { return; } } else { isPrototype = ac.isPrototype(beanId); } c = ResourceUtils.findResourceConstructor(type, !isSingleton()); if (c == null) { throw new RuntimeException("Resource class " + type + " has no valid constructor"); } }
private void init() { Class<?> type = ClassHelper.getRealClassFromClass(blueprintContainer.getComponentInstance(beanId) .getClass()); if (Proxy.isProxyClass(type)) { type = ClassHelper.getRealClass(blueprintContainer.getComponentInstance(beanId)); } c = ResourceUtils.findResourceConstructor(type, !isSingleton()); if (c == null) { throw new RuntimeException("Resource class " + type + " has no valid constructor"); } postConstructMethod = ResourceUtils.findPostConstructMethod(type); preDestroyMethod = ResourceUtils.findPreDestroyMethod(type); Object component = blueprintContainer.getComponentMetadata(beanId); if (component instanceof BeanMetadata) { BeanMetadata local = (BeanMetadata) component; isSingleton = BeanMetadata.SCOPE_SINGLETON.equals(local.getScope()) || (local.getScope() == null && local.getId() != null); } }
private void init() { Class<?> type = ClassHelper.getRealClassFromClass(blueprintContainer.getComponentInstance(beanId) .getClass()); if (Proxy.isProxyClass(type)) { type = ClassHelper.getRealClass(blueprintContainer.getComponentInstance(beanId)); } c = ResourceUtils.findResourceConstructor(type, !isSingleton()); if (c == null) { throw new RuntimeException("Resource class " + type + " has no valid constructor"); } postConstructMethod = ResourceUtils.findPostConstructMethod(type); preDestroyMethod = ResourceUtils.findPreDestroyMethod(type); Object component = blueprintContainer.getComponentMetadata(beanId); if (component instanceof BeanMetadata) { BeanMetadata local = (BeanMetadata) component; isSingleton = BeanMetadata.SCOPE_SINGLETON.equals(local.getScope()) || (local.getScope() == null && local.getId() != null); } }
preDestroyMethod = ResourceUtils.findPreDestroyMethod(clazz);