List of usage examples for org.apache.commons.lang ClassUtils getClass
public static Class<?> getClass(String className, boolean initialize) throws ClassNotFoundException
className
using the current thread's context class loader. From source file:org.kuali.rice.kns.kim.type.KimAttributeDefinition.java
@Override public void completeValidation(Class rootObjectClass, Class otherObjectClass, ValidationTrace tracer) { super.completeValidation(rootObjectClass, otherObjectClass, tracer); if (StringUtils.isNotBlank(lookupBoClass)) { try {//ww w. java 2 s. co m ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(), getLookupBoClass()); } catch (ClassNotFoundException e) { String currentValues[] = { "property = " + getName(), "class = " + rootObjectClass.getName(), "lookupBoClass = " + getLookupBoClass() }; tracer.createError("lookupBoClass could not be found", currentValues); } } }
From source file:org.kuali.rice.krad.datadictionary.AttributeDefinition.java
/** * Directly validate simple fields, call completeValidation on Definition * fields.//from w ww .j a v a 2 s . co m * * @see org.kuali.rice.krad.datadictionary.DataDictionaryEntry#completeValidation(org.kuali.rice.krad.datadictionary.validator.ValidationTrace) */ @Override public void completeValidation(Class rootObjectClass, Class otherObjectClass, ValidationTrace tracer) { tracer.addBean(this.getClass().getSimpleName(), "id: " + getId()); try { if (StringUtils.isBlank(getName())) { String currentValues[] = { "id = " + getId(), "class = " + rootObjectClass.getName() }; tracer.createError("AttributeDefinition missing name", currentValues); } if (!DataDictionary.isPropertyOf(rootObjectClass, getName())) { String currentValues[] = { "property = " + getName(), "class = " + rootObjectClass.getName() }; tracer.createError( "Property is not found in class. Ensure that the property is defined on the class and that there is at least a public 'getter' for it.", currentValues); } if (getControl() == null && getControlField() == null) { String currentValues[] = { "property = " + getName(), "class = " + rootObjectClass.getName() }; tracer.createError("Property does not have a control defined in the class", currentValues); } if (getAttributeSecurity() != null) { getAttributeSecurity().completeValidation(rootObjectClass, otherObjectClass, tracer.getCopy()); } // KNS Controls - do not use KRAD Validation style if (getControl() != null) { getControl().completeValidation(rootObjectClass, otherObjectClass); } if (validationPattern != null) { validationPattern.completeValidation(); } if (getFormatterClass() != null) { try { Class formatterClassObject = ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(), getFormatterClass()); if (!Formatter.class.isAssignableFrom(formatterClassObject)) { String currentValues[] = { "formatterClassObject = " + formatterClassObject.getName() }; tracer.createError("FormatterClass is not a valid instance", currentValues); } } catch (ClassNotFoundException e) { String currentValues[] = { "class = " + getFormatterClass() }; tracer.createError("FormatterClass could not be found", currentValues); } } } catch (RuntimeException ex) { String currentValues[] = { "attribute = " + rootObjectClass + "." + getName(), "Exception = " + ex.getMessage() }; tracer.createError("Unable to validate attribute", currentValues); LOG.error("Exception while validating AttributeDefinition: " + getId(), ex); } }
From source file:org.milyn.smooks.mule.core.ClassNameResultFactory.java
@SuppressWarnings("unchecked") public ClassNameResultFactory(String className) throws ClassNotFoundException { this.resultClass = ClassUtils.getClass(this.getClass().getClassLoader(), className); if (!Result.class.isAssignableFrom(resultClass)) { throw new IllegalArgumentException( "The class '" + className + "' does not implement the 'javax.xml.transform.Result' interface."); }// w w w.j a v a 2s .com }
From source file:org.milyn.smooks.mule.SmooksTransformer.java
/** * Creates a SourceResult Factory//from w w w. j a v a 2 s. co m * * @return * @throws InitialisationException */ private SourceResultFactory createSourceResultFactory() throws InitialisationException { ResultFactory resultFactory; if (!StringUtils.isBlank(resultClass)) { try { resultFactory = new ClassNameResultFactory(resultClass); } catch (ClassNotFoundException e) { final Message errorMsg = createStaticMessage( "The class '" + resultClass + "' definend in the 'resultClass' property can't be found."); throw new InitialisationException(errorMsg, e, this); } catch (IllegalArgumentException e) { final Message errorMsg = createStaticMessage(e.getMessage()); throw new InitialisationException(errorMsg, e, this); } } else if (!StringUtils.isBlank(resultFactoryClass)) { try { resultFactory = (ResultFactory) ClassUtils .getClass(this.getClass().getClassLoader(), resultFactoryClass).newInstance(); } catch (ClassNotFoundException e) { final Message errorMsg = createStaticMessage("The class '" + resultFactoryClass + "' definend in the 'resultFactoryClass' property can't be found."); throw new InitialisationException(errorMsg, e, this); } catch (InstantiationException e) { final Message errorMsg = createStaticMessage("The class '" + resultFactoryClass + "' definend in the 'resultFactoryClass' property can't be instantiated."); throw new InitialisationException(errorMsg, e, this); } catch (IllegalAccessException e) { final Message errorMsg = createStaticMessage("The class '" + resultFactoryClass + "' definend in the 'resultFactoryClass' property can't be instantiated."); throw new InitialisationException(errorMsg, e, this); } catch (ClassCastException e) { final Message errorMsg = createStaticMessage("The class '" + resultFactoryClass + "' does not implement the 'org.milyn.smooks.mule.ResultFactory' interface."); throw new InitialisationException(errorMsg, e, this); } } else { final Message errorMsg = createStaticMessage("The resultType is '" + resultType + "' but no 'resultClass' or 'resultFactoryClass' is correctly defined. On of those need to be defined."); throw new InitialisationException(errorMsg, this); } return new GenericSourceResultFactory(resultFactory); }
From source file:org.openengsb.core.services.internal.RequestHandlerImpl.java
private Class<?>[] getArgTypes(MethodCall args) { List<Class<?>> clazzes = new ArrayList<Class<?>>(); for (String clazz : args.getClasses()) { try {// w w w . j a v a 2s . c o m clazzes.add(ClassUtils.getClass(this.getClass().getClassLoader(), clazz)); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("The classes defined could not be found", e); } } return clazzes.toArray(new Class<?>[0]); }