private void fixNullOutputsForSOAP(CrownCounselIndexGetList_Properties fromClient) { // Transform null to "null" Class c = fromClient.getClass(); java.beans.BeanInfo beanInfo = null; try { beanInfo = java.beans.Introspector.getBeanInfo(c); } catch (Exception e) { } java.beans.PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors(); for (int i = 0; i < properties.length; i++) { java.beans.PropertyDescriptor property = properties[i]; java.lang.reflect.Method readMethod = property.getReadMethod(); java.lang.reflect.Method writeMethod = property.getWriteMethod(); if ((readMethod != null) && (writeMethod != null)) { String currentvalue = new String(""); if (readMethod.getReturnType() == currentvalue.getClass()) { try { currentvalue = (String) (readMethod.invoke(fromClient, null)); } catch (java.lang.reflect.InvocationTargetException a1) // Null argument { try { Object[] args1 = new Object[1]; args1[0] = new String("null"); writeMethod.invoke(fromClient, args1); } catch (Exception e2) { } } catch (Exception e1) { } } else { } } } }
public ComponentDomainClass(Class type) { super(type, ""); PropertyDescriptor[] descriptors; try { descriptors = java.beans.Introspector.getBeanInfo(type).getPropertyDescriptors(); } catch (IntrospectionException e) { throw new GrailsDomainException( "Failed to use class [" + type + "] as a component. Cannot introspect! " + e.getMessage()); } List tmp = (List) getPropertyOrStaticPropertyOrFieldValue( GrailsDomainClassProperty.TRANSIENT, List.class); if (tmp != null) this.transients = tmp; this.properties = createDomainClassProperties(this, descriptors); try { this.constraints = GrailsDomainConfigurationUtil.evaluateConstraints( getReference().getWrappedInstance(), properties); } catch (IntrospectionException e) { LOG.error( "Error reading embedded component [" + getClazz() + "] constraints: " + e.getMessage(), e); } }
/** * Define an attribute on the managed object. The meta data is defined by looking for standard * getter and setter methods. Descriptions are obtained with a call to findDescription with the * attribute name. * * @param name The name of the attribute. Normal java bean capitlization is enforced on this name. * @param writable If false, do not look for a setter. * @param onMBean . */ public synchronized void defineAttribute(String name, boolean writable, boolean onMBean) { _dirty = true; String uName = name.substring(0, 1).toUpperCase() + name.substring(1); name = java.beans.Introspector.decapitalize(name); Class oClass = onMBean ? this.getClass() : _object.getClass(); Class type = null; Method getter = null; Method setter = null; Method[] methods = oClass.getMethods(); for (int m = 0; m < methods.length; m++) { if ((methods[m].getModifiers() & Modifier.PUBLIC) == 0) continue; // Look for a getter if (methods[m].getName().equals("get" + uName) && methods[m].getParameterTypes().length == 0) { if (getter != null) throw new IllegalArgumentException("Multiple getters for attr " + name); getter = methods[m]; if (type != null && !type.equals(methods[m].getReturnType())) throw new IllegalArgumentException("Type conflict for attr " + name); type = methods[m].getReturnType(); } // Look for an is getter if (methods[m].getName().equals("is" + uName) && methods[m].getParameterTypes().length == 0) { if (getter != null) throw new IllegalArgumentException("Multiple getters for attr " + name); getter = methods[m]; if (type != null && !type.equals(methods[m].getReturnType())) throw new IllegalArgumentException("Type conflict for attr " + name); type = methods[m].getReturnType(); } // look for a setter if (writable && methods[m].getName().equals("set" + uName) && methods[m].getParameterTypes().length == 1) { if (setter != null) throw new IllegalArgumentException("Multiple setters for attr " + name); setter = methods[m]; if (type != null && !type.equals(methods[m].getParameterTypes()[0])) throw new IllegalArgumentException("Type conflict for attr " + name); type = methods[m].getParameterTypes()[0]; } } if (getter == null && setter == null) throw new IllegalArgumentException("No getter or setters found for " + name); try { // Remember the methods _getter.put(name, getter); _setter.put(name, setter); // create and add the info _attributes.add(new ModelMBeanAttributeInfo(name, findDescription(name), getter, setter)); } catch (Exception e) { log.warn(LogSupport.EXCEPTION, e); throw new IllegalArgumentException(e.toString()); } }
private void fixNullInputsForSOAP(CrownCounselIndexGetList_Properties fromClient) { // Transform "null" to null // Set hPubStartPoolName and hPubLinkKey to null if string < 1 Class c = fromClient.getClass(); java.beans.BeanInfo beanInfo = null; try { beanInfo = java.beans.Introspector.getBeanInfo(c); } catch (Exception e) { } java.beans.PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors(); for (int i = 0; i < properties.length; i++) { java.beans.PropertyDescriptor property = properties[i]; java.lang.reflect.Method readMethod = property.getReadMethod(); java.lang.reflect.Method writeMethod = property.getWriteMethod(); if ((readMethod != null) && (writeMethod != null)) { String currentvalue = new String(""); if (readMethod.getReturnType() == currentvalue.getClass()) { try { currentvalue = (String) readMethod.invoke(fromClient, null); } catch (Exception e1) { } if (currentvalue != null) { if (currentvalue.equals("null")) { try { Object[] args1 = new Object[1]; args1[0] = null; writeMethod.invoke(fromClient, args1); } catch (Exception e2) { } } if ((currentvalue.length() < 1 || currentvalue.endsWith("/null")) && (writeMethod.getName().indexOf("PubStartPoolName") > -1)) { try { Object[] args1 = new Object[1]; args1[0] = "ICONEJB/null"; writeMethod.invoke(fromClient, args1); } catch (Exception e2) { } } if ((currentvalue.length() < 1) && (writeMethod.getName().indexOf("PubLinkKey") > -1)) { try { Object[] args1 = new Object[1]; args1[0] = null; writeMethod.invoke(fromClient, args1); } catch (Exception e2) { } } } } else { } } } }