/** * Inject resources in specified method. */ protected static void lookupMethodResource(javax.naming.Context context, Object instance, Method method, String name) throws NamingException, IllegalAccessException, InvocationTargetException { if (!method.getName().startsWith("set") || method.getParameterTypes().length != 1 || !method.getReturnType().getName().equals("void")) { throw new IllegalArgumentException("Invalid method resource injection annotation"); } Object lookedupResource; if ((name != null) && (name.length() > 0)) { // TODO local or global JNDI lookedupResource = context.lookup(JAVA_COMP_ENV + name); } else { // TODO local or global JNDI lookedupResource = context.lookup(JAVA_COMP_ENV + instance.getClass().getName() + "/" + getFieldName(method)); } boolean accessibility = method.isAccessible(); method.setAccessible(true); method.invoke(instance, lookedupResource); method.setAccessible(accessibility); }
/** * Inject resources in specified method. */ protected static void lookupMethodResource(javax.naming.Context context, Object instance, Method method, String name) throws NamingException, IllegalAccessException, InvocationTargetException { if (!method.getName().startsWith("set") || method.getParameterTypes().length != 1 || !method.getReturnType().getName().equals("void")) { throw new IllegalArgumentException("Invalid method resource injection annotation"); } Object lookedupResource; if ((name != null) && (name.length() > 0)) { // TODO local or global JNDI lookedupResource = context.lookup(JAVA_COMP_ENV + name); } else { // TODO local or global JNDI lookedupResource = context.lookup(JAVA_COMP_ENV + instance.getClass().getName() + "/" + getFieldName(method)); } boolean accessibility = method.isAccessible(); method.setAccessible(true); method.invoke(instance, lookedupResource); method.setAccessible(accessibility); }
/** * Inject resources in specified method. */ protected static void lookupMethodResource(javax.naming.Context context, Object instance, Method method, String name) throws NamingException, IllegalAccessException, InvocationTargetException { if (!method.getName().startsWith("set") || method.getParameterTypes().length != 1 || !method.getReturnType().getName().equals("void")) { throw new IllegalArgumentException("Invalid method resource injection annotation"); } Object lookedupResource; if ((name != null) && (name.length() > 0)) { // TODO local or global JNDI lookedupResource = context.lookup(JAVA_COMP_ENV + name); } else { // TODO local or global JNDI lookedupResource = context.lookup(JAVA_COMP_ENV + instance.getClass().getName() + "/" + getFieldName(method)); } boolean accessibility = method.isAccessible(); method.setAccessible(true); method.invoke(instance, lookedupResource); method.setAccessible(accessibility); }