Example usage for org.apache.commons.lang ClassUtils getClass

List of usage examples for org.apache.commons.lang ClassUtils getClass

Introduction

In this page you can find the example usage for org.apache.commons.lang ClassUtils getClass.

Prototype

public static Class<?> getClass(String className) throws ClassNotFoundException 

Source Link

Document

Returns the (initialized) class represented by className using the current thread's context class loader.

Usage

From source file:de.hybris.platform.addonsupport.config.SpelBeanFactory.java

@Override
public void onApplicationEvent(final ContextRefreshedEvent event) {
    final ExpressionParser parser = new SpelExpressionParser();
    final StandardEvaluationContext context = new StandardEvaluationContext();
    context.setBeanResolver(new BeanFactoryResolver(applicationContext));

    final String[] beanNames = applicationContext.getBeanNamesForType(AbstractConverter.class);
    for (final String beanName : beanNames) {
        final BeanDefinition def = beanFactory.getBeanDefinition(beanName);
        final PropertyValue pv = def.getPropertyValues().getPropertyValue("targetClass");
        if (pv != null) {

            if (pv.getValue() instanceof TypedStringValue) {

                String expr = StringUtils.strip(((TypedStringValue) pv.getValue()).getValue());
                if (expr.startsWith("#{")) {
                    expr = StringUtils.replaceOnce(expr, "#{", "@");
                    expr = StringUtils.stripEnd(expr, "}");
                    final Object result = parser.parseExpression(expr).getValue(context);
                    if (result != null) {

                        try {
                            applicationContext.getBean(beanName, AbstractConverter.class)
                                    .setTargetClass(ClassUtils.getClass(result.toString()));
                        } catch (final ClassNotFoundException e) {
                            LOG.error(beanName + " target class instantiation failed", e);
                        }/*from  w  ww . ja  v  a2 s  . c  om*/
                    }
                }
            }
        }
    }
}

From source file:com.agimatec.validation.xml.XMLMetaElement.java

public void mergeInto(MetaProperty prop) throws ClassNotFoundException {
    mergeFeaturesInto(prop);/*from   ww w .j  a  v  a2s . c o m*/
    if (getType() != null && getType().length() > 0) {
        prop.setType(ClassUtils.getClass(getType())); // enhancement: or use getGenericType() ?
    }
    if (getHidden() != null) {
        prop.putFeature(HIDDEN, getHidden().booleanValue());
    }
    if (getMandatory() != null) {
        prop.putFeature(MANDATORY, getMandatory().equals("true"));
    }
    if (getMaxLength() != null) {
        prop.putFeature(MAX_LENGTH, getMaxLength());
    }
    if (getMinLength() != null) {
        prop.putFeature(MIN_LENGTH, getMinLength());
    }
    if (getReadonly() != null) {
        prop.putFeature(READONLY, getReadonly());
    }
    if (getDenied() != null) {
        prop.putFeature(DENIED, getDenied());
    }
}

From source file:com.agimatec.validation.xml.XMLMetaBeanInfos.java

private void initValidationLookup() throws Exception {
    validationLookup = new FastHashMap();
    for (XMLMetaValidator xv : validators) {
        if (xv.getJava() != null) {
            Validation validation = (Validation) ClassUtils.getClass(xv.getJava()).newInstance();
            xv.setValidation(validation);
            validationLookup.put(xv.getId(), xv);
        }//from w w w  .j  av  a  2s. c  om
    }
    ((FastHashMap) validationLookup).setFast(true);
}

From source file:com.liferay.alloy.util.TypeUtil.java

private Class<?> _getClass(String className) {
    Class<?> clazz = null;//from  www  .  j  a  va 2s  .c  o  m

    try {
        clazz = ClassUtils.getClass(className);
    } catch (ClassNotFoundException cnfe) {
        if (_isJavaClass(className)) {
            String genericsType = _getGenericsType(className);

            if (Validator.isNotNull(genericsType)) {
                className = _removeGenericsType(className);

                return _getClass(className);
            }
        } else {
            _log.debug(cnfe);
        }
    }

    return clazz;
}

From source file:com.asual.summer.core.RequestFilter.java

protected void initFilterBean() throws ServletException {
    if (multipartResolver == null) {
        try {// w  ww.  j  av  a 2 s .co  m
            ClassUtils.getClass("org.apache.commons.fileupload.FileItemFactory");
            RequestMultipartResolver requestMultipartResolver = new RequestMultipartResolver();
            Object maxInMemorySize = ResourceUtils.getProperty("app.maxInMemorySize");
            if (maxInMemorySize != null) {
                requestMultipartResolver.setMaxInMemorySize((Integer) maxInMemorySize);
            }
            Object maxUploadSize = ResourceUtils.getProperty("app.maxUploadSize");
            if (maxUploadSize != null) {
                requestMultipartResolver.setMaxUploadSize((Integer) maxUploadSize);
            }
            multipartResolver = requestMultipartResolver;
        } catch (ClassNotFoundException e) {
        }
    }
}

From source file:com.agimatec.validation.jsr303.AgimatecValidatorFactory.java

/**
 * Return an object of the specified type to allow access to the
 * provider-specific API.  If the Bean Validation provider
 * implementation does not support the specified class, the
 * ValidationException is thrown./*from   w  w w .  ja va2 s. c  om*/
 *
 * @param type the class of the object to be returned.
 * @return an instance of the specified class
 * @throws ValidationException if the provider does not
 *                             support the call.
 */
public <T> T unwrap(Class<T> type) {
    if (type.isAssignableFrom(getClass())) {
        return (T) this;
    } else if (!type.isInterface()) {
        return SecureActions.newInstance(type);
    } else {
        try {
            Class<T> cls = ClassUtils.getClass(type.getName() + "Impl");
            return SecureActions.newInstance(cls);
        } catch (ClassNotFoundException e) {
            throw new ValidationException("Type " + type + " not supported");
        }
    }
}

From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.DBLoginDialog.java

/**
 * db widget? .//from   ww  w  . j ava2  s  .  c  om
 */
private void initDBWidget() {
    if (loginComposite != null)
        loginComposite.dispose();

    DBDefine dbDefine = (DBDefine) comboDBList.getData(comboDBList.getText());

    if (dbDefine == DBDefine.ALTIBASE_DEFAULT | dbDefine == DBDefine.CUBRID_DEFAULT
            | dbDefine == DBDefine.MYSQL_DEFAULT | dbDefine == DBDefine.MARIADB_DEFAULT
            | dbDefine == DBDefine.MSSQL_DEFAULT | dbDefine == DBDefine.MONGODB_DEFAULT
            | dbDefine == DBDefine.ORACLE_DEFAULT | dbDefine == DBDefine.SQLite_DEFAULT
            | dbDefine == DBDefine.TIBERO_DEFAULT | dbDefine == DBDefine.POSTGRE_DEFAULT) {
        try {
            ClassUtils.getClass(dbDefine.getDriverClass());
        } catch (ClassNotFoundException e) {

            if (MessageDialog.openConfirm(null, Messages.get().DriverNotFound,
                    Messages.get().DriverNotFoundMSG)) {
                JDBCDriverManageDialog dialog = new JDBCDriverManageDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
                if (Dialog.OK == dialog.open()) {
                    if (dialog.isUploaded()) {
                        MessageDialog.openInformation(null, Messages.get().Information,
                                Messages.get().jdbcdriver);
                    }
                }
            }
        }
    }

    createDBWidget(null);
    compositeBody.layout();
    container.layout();

    // google analytic
    AnalyticCaller.track("DBLoginDialog"); //$NON-NLS-1$
}

From source file:com.agimatec.validation.MetaBeanBuilder.java

protected Class findLocalClass(String className) {
    if (className != null) {
        try {//from   w  ww.  ja v a2  s  .  c o  m
            return ClassUtils.getClass(className);
        } catch (ClassNotFoundException e) {
            log.warn("class not found: " + className, e);
        }
    }
    return null;
}

From source file:com.agimatec.validation.jsr303.ClassValidator.java

/**
 * Return an object of the specified type to allow access to the
 * provider-specific API.  If the Bean Validation provider
 * implementation does not support the specified class, the
 * ValidationException is thrown.//from   w  w w.  ja va 2  s .  co m
 *
 * @param type the class of the object to be returned.
 * @return an instance of the specified class
 * @throws ValidationException if the provider does not
 *                             support the call.
 */
public <T> T unwrap(Class<T> type) {
    if (type.isAssignableFrom(getClass())) {
        return (T) this;
    } else if (!type.isInterface()) {
        return SecureActions.newInstance(type, new Class[] { AgimatecFactoryContext.class },
                new Object[] { factoryContext });
    } else {
        try {
            Class<T> cls = ClassUtils.getClass(type.getName() + "Impl");
            return SecureActions.newInstance(cls, new Class[] { AgimatecFactoryContext.class },
                    new Object[] { factoryContext });
        } catch (ClassNotFoundException e) {
            throw new ValidationException("Type " + type + " not supported");
        }
    }
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksEx.java

/**
 * ??[?\bhn?NXz?B/*  w  w w  .ja v a 2 s  . com*/
 * 
 * <b>?\bhANVtH?[? tH?[O?Ap?s???B</b>
 * 
 * @param va
 *            Strutsp<code>ValidatorAction</code>
 * @return ?NXz
 */
protected static Class[] getParamClass(ValidatorAction va) {

    String methodParams = va.getMethodParams();
    if (methodParams == null) {
        return null;
    }

    StringTokenizer st = new StringTokenizer(methodParams, ",");
    Class[] paramClass = new Class[st.countTokens()];

    for (int i = 0; st.hasMoreTokens(); i++) {
        try {
            String key = st.nextToken().trim();
            paramClass[i] = ClassUtils.getClass(key);
        } catch (ClassNotFoundException e) {
            log.error("", e);
            return null;
        }
    }
    return paramClass;
}