private void setUpDynamicGBean(String adapterClassName, GBeanInfoBuilder infoBuilder, Set<String> ignore, Bundle bundle, boolean decapitalize) throws DeploymentException { //add all javabean properties that have both getter and setter. Ignore the "required" flag from the dd. Map<String, String> getters = new HashMap<String, String>(); Set<String> setters = new HashSet<String>(); Method[] methods; try { Class activationSpecClass = bundle.loadClass(adapterClassName); methods = activationSpecClass.getMethods(); } catch (ClassNotFoundException e) { throw new DeploymentException("Can not load adapter class in classloader " + bundle, e); } catch (NoClassDefFoundError e) { throw new DeploymentException("Can not load adapter class in classloader " + bundle, e); } for (Method method : methods) { String methodName = method.getName(); if ((methodName.startsWith("get") || methodName.startsWith("is")) && method.getParameterTypes().length == 0) { String attributeName = (methodName.startsWith("get")) ? methodName.substring(3) : methodName.substring(2); getters.put(setCase(attributeName, decapitalize), method.getReturnType().getName()); } else if (methodName.startsWith("set") && method.getParameterTypes().length == 1) { setters.add(setCase(methodName.substring(3), decapitalize)); } } getters.keySet().retainAll(setters); getters.keySet().removeAll(ignore); for (Map.Entry<String, String> entry : getters.entrySet()) { infoBuilder.addAttribute(new DynamicGAttributeInfo(entry.getKey(), entry.getValue(), true, true, true, true)); } }
private void setUpDynamicGBean(String adapterClassName, GBeanInfoBuilder infoBuilder, Set<String> ignore, ClassLoader cl, boolean decapitalize) throws DeploymentException { //add all javabean properties that have both getter and setter. Ignore the "required" flag from the dd. Map<String, String> getters = new HashMap<String, String>(); Set<String> setters = new HashSet<String>(); Method[] methods; try { Class activationSpecClass = cl.loadClass(adapterClassName); methods = activationSpecClass.getMethods(); } catch (ClassNotFoundException e) { throw new DeploymentException("Can not load adapter class in classloader " + cl, e); } catch (NoClassDefFoundError e) { throw new DeploymentException("Can not load adapter class in classloader " + cl, e); } for (Method method : methods) { String methodName = method.getName(); if ((methodName.startsWith("get") || methodName.startsWith("is")) && method.getParameterTypes().length == 0) { String attributeName = (methodName.startsWith("get")) ? methodName.substring(3) : methodName.substring(2); getters.put(setCase(attributeName, decapitalize), method.getReturnType().getName()); } else if (methodName.startsWith("set") && method.getParameterTypes().length == 1) { setters.add(setCase(methodName.substring(3), decapitalize)); } } getters.keySet().retainAll(setters); getters.keySet().removeAll(ignore); for (Map.Entry<String, String> entry : getters.entrySet()) { infoBuilder.addAttribute(new DynamicGAttributeInfo(entry.getKey(), entry.getValue(), true, true, true, true)); } }