public void reloadEvent(String typename, Class<?> aClass, String encodedTimestamp) { CachedIntrospectionResults.clearClassLoader(aClass.getClassLoader()); ClassPropertyFetcher.clearClassPropertyFetcherCache(); if (GrailsProjectWatcher.isActive()) { GrailsProjectWatcher.firePendingClassChangeEvents(aClass); } }
@SuppressWarnings("unchecked") @Override protected Object createNode(Object name, Map attributes) { // we do this so that missing property exception is throw if it doesn't exist try { String property = (String) name; ConstrainedProperty cp; if (constrainedProperties.containsKey(property)) { cp = constrainedProperties.get(property); } else { cp = new ConstrainedProperty( targetClass, property, classPropertyFetcher.getPropertyType(property)); cp.setOrder(order++); constrainedProperties.put(property, cp); } if (cp.getPropertyType() == null) { GrailsUtil.warn( "Property [" + cp.getPropertyName() + "] not found in domain class " + targetClass.getName() + "; cannot apply constraints: " + attributes); return cp; } for (Object o : attributes.keySet()) { String constraintName = (String) o; final Object value = attributes.get(constraintName); if (SHARED_CONSTRAINT.equals(constraintName)) { if (value != null) { sharedConstraints.put(property, value.toString()); } continue; } if (cp.supportsContraint(constraintName)) { cp.applyConstraint(constraintName, value); } else { if (ConstrainedProperty.hasRegisteredConstraint(constraintName)) { // constraint is registered but doesn't support this property's type GrailsUtil.warn( "Property [" + cp.getPropertyName() + "] of domain class " + targetClass.getName() + " has type [" + cp.getPropertyType().getName() + "] and doesn't support constraint [" + constraintName + "]. This constraint will not be checked during validation."); } else { // in the case where the constraint is not supported we still retain meta data // about the constraint in case its needed for other things cp.addMetaConstraint(constraintName, value); } } } return cp; } catch (InvalidPropertyException ipe) { throw new MissingMethodException((String) name, targetClass, new Object[] {attributes}); } }
public ConstrainedPropertyBuilder(Class<?> targetClass) { this.targetClass = targetClass; classPropertyFetcher = ClassPropertyFetcher.forClass(targetClass); }