当前位置: 首页>>代码示例>>Java>>正文


Java ClassUtils.getClass方法代码示例

本文整理汇总了Java中org.apache.commons.lang.ClassUtils.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java ClassUtils.getClass方法的具体用法?Java ClassUtils.getClass怎么用?Java ClassUtils.getClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.ClassUtils的用法示例。


在下文中一共展示了ClassUtils.getClass方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
@Override
public Object call(Context context, List args) throws FunctionCallException {
    try {
        String clazzName = (String) (args.get(0));
        String methodName = (String) (args.get(1));
        LOGGER.info("XEditor extension function calling {} {}", clazzName, methodName);

        Class[] argTypes = new Class[args.size() - 2];
        Object[] params = new Object[args.size() - 2];
        for (int i = 0; i < argTypes.length; i++) {
            argTypes[i] = args.get(i + 2).getClass();
            params[i] = args.get(i + 2);
        }

        Class clazz = ClassUtils.getClass(clazzName);
        Method method = MethodUtils.getMatchingAccessibleMethod(clazz, methodName, argTypes);
        return method.invoke(null, params);
    } catch (Exception ex) {
        LOGGER.warn("Exception in call to external java method", ex);
        return ex.getMessage();
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:23,代码来源:MCRFunctionCallJava.java

示例2: read

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
@Override
public Object read(Kryo kryo, Input input, Class type) {
    try {
        ObjectMap graphContext = kryo.getGraphContext();
        ObjectInputStream objectStream = (ObjectInputStream) graphContext.get(this);
        if (objectStream == null) {
            objectStream = new ObjectInputStream(input) {
                @Override
                protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
                    return ClassUtils.getClass(KryoSerialization.class.getClassLoader(), desc.getName());
                }
            };
            graphContext.put(this, objectStream);
        }
        return objectStream.readObject();
    } catch (Exception ex) {
        throw new KryoException("Error during Java deserialization.", ex);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:KryoSerialization.java

示例3: findMethod

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
private Method findMethod(Class<?> argType) {
    try {
        Class<?> clazz = ClassUtils.getClass(className);
        Class<?>[] argTypes = { argType };
        return MethodUtils.getMatchingAccessibleMethod(clazz, methodName, argTypes);
    } catch (ClassNotFoundException ex) {
        throw new MCRConfigurationException("class configured for external validation not found: " + className);
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:10,代码来源:MCRExternalValidator.java

示例4: completeValidation

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
@Override
public void completeValidation(Class rootObjectClass, Class otherObjectClass, ValidationTrace tracer) {
	super.completeValidation(rootObjectClass, otherObjectClass,tracer);
	if ( StringUtils.isNotBlank(lookupBoClass) ) {
       	try {
       		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);
       	}
       }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:13,代码来源:KimAttributeDefinition.java

示例5: getClass

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
public static Class<?> getClass(String className) {
	if (StringUtils.isEmpty(className)) {
		return null;
	}
	try {
		return ClassUtils.getClass(getDefaultClassLoader(), className);
	} catch (ClassNotFoundException e) {
		throw new RiceRuntimeException(e);
	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:11,代码来源:ClassLoaderUtils.java

示例6: getClass

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
/**
 * Loads the <code>Class</code> with the given name from the given <code>ClassLoader</code>.
 * 
 * @param className the name of the <code>Class</code>
 * @param classLoader the <code>ClassLoader</code> with which to load it
 * @return the <code>Class</code> with the given name loaded from the given <code>ClassLoader</code>
 * @throws TransloaderException if the <code>Class</code> cannot be found in the given <code>ClassLoader</code>
 */
public static Class getClass(String className, ClassLoader classLoader) {
	Assert.areNotNull(className, classLoader);
	try {
		return ClassUtils.getClass(classLoader, className, false);
	} catch (ClassNotFoundException e) {
		// TODO test ClassNotFoundException
		throw new TransloaderException(
				"Unable to load Class '" + className + "' from ClassLoader '" + classLoader + "'.", e);
	}
}
 
开发者ID:fmunch,项目名称:transloader,代码行数:19,代码来源:ClassWrapper.java

示例7: getObjectInstance

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
public T getObjectInstance() throws ImplementationClassLoadException {			
	
	String configurationKey = this.getConfigurationKey();
    String className =
        configuration.getString(configurationKey, null);

    if (className == null) {
        throw new ImplementationClassLoadException(
            String.format("Missing property key on configuration file: %s",
                configurationKey)
        );
    }

    logger.info("Creating instance for configured class {}",
        className);

    T instance = null;

    try {
        Class<?> clazz = ClassUtils.getClass(className);			
        instance = instantiate(clazz);

    } catch (Exception e) {
        throw new ImplementationClassLoadException(
            String.format("Exception trying to make the instance: %s",
                ExceptionUtils.getStackTrace(e))
        );
    }            

    logger.info("Instance created successful :)");
    return instance;
}
 
开发者ID:jmg,项目名称:jcaching,代码行数:33,代码来源:BaseFactory.java

示例8: getClassFrom

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
/**
 * Loads the <code>Class</code> with the given name from the given <code>ClassLoader</code>.
 *
 * @param classLoader the <code>ClassLoader</code> with which to load it
 * @param className   the name of the <code>Class</code>
 * @return the <code>Class</code> with the given name loaded from the given <code>ClassLoader</code>
 * @throws net.datenwerke.transloader.except.TransloaderException
 *          if the <code>Class</code> cannot be found in the given <code>ClassLoader</code>
 */
public static Class getClassFrom(ClassLoader classLoader, String className) {
    Assert.areNotNull(classLoader, className);
    try {
        return ClassUtils.getClass(classLoader, className, false);
    } catch (ClassNotFoundException e) {
        // TODO test ClassNotFoundException
        throw new TransloaderException(
                "Unable to load Class '" + className + "' from ClassLoader '" + classLoader + "'.", e);
    }
}
 
开发者ID:csm,项目名称:java-sandbox,代码行数:20,代码来源:ClassWrapper.java

示例9: completeValidation

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void completeValidation(Class rootObjectClass, Class otherObjectClass) {
	if (lookupBoClass != null) {
       	try {
       		Class lookupBoClassObject = ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(), getLookupBoClass());
       		if (!BusinessObject.class.isAssignableFrom(lookupBoClassObject)) {
       			throw new ClassValidationException("lookupBoClass is not a valid instance of " + BusinessObject.class.getName() + " instead was: " + lookupBoClassObject.getName());
       		}
       	} catch (ClassNotFoundException e) {
       		throw new ClassValidationException("lookupBoClass could not be found: " + getLookupBoClass(), e);
       	}
       }
	super.completeValidation(rootObjectClass, otherObjectClass);
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:16,代码来源:KimAttributeDefinition.java

示例10: registerTreeGeneratorClass

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
/**
 * Registers a tree-generator if it does not throw an exception while preparing it.
 * @param loader    The generator.
 * @param classname The name of the class.
 */
private void registerTreeGeneratorClass(ConfigurationHandler loader, String classname) {
    try {
        Class<?> cls = ClassUtils.getClass(this.getClass().getClassLoader(), classname);
        loader.addTreeGenerator((NodeTreeGenerator) cls.newInstance());
    } catch (Throwable e) {
        // Do a catchall, that's easier.
        loader.getLoggingInterface().debug("Not installing: " + loader);
        loader.getLoggingInterface().debugException(e);
    }
}
 
开发者ID:StuxSoftware,项目名称:SimpleDev,代码行数:16,代码来源:BaseConstructor.java

示例11: invoke

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
@Override
public LocalServiceInvocationResult invoke(LocalServiceInvocation invocation) {
    if (invocation == null) {
        throw new IllegalArgumentException("Invocation is null");
    }

    LocalServiceInvocationResult result = new LocalServiceInvocationResult();
    ClassLoader clientClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        ClassLoader classLoader = target.getClass().getClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);

        String[] parameterTypeNames = invocation.getParameterTypeNames();
        Class[] parameterTypes = new Class[parameterTypeNames.length];
        for (int i = 0; i < parameterTypeNames.length; i++) {
            Class<?> paramClass = ClassUtils.getClass(classLoader, parameterTypeNames[i]);
            parameterTypes[i] = paramClass;
        }

        byte[][] argumentsData = invocation.getArgumentsData();
        Object[] notSerializableArguments = invocation.getNotSerializableArguments();
        Object[] arguments;
        if (argumentsData == null) {
            arguments = null;
        } else {
            arguments = new Object[argumentsData.length];
            for (int i = 0; i < argumentsData.length; i++) {
                if (argumentsData[i] == null) {
                    if (notSerializableArguments[i] == null) {
                        arguments[i] = null;
                    } else {
                        arguments[i] = notSerializableArguments[i];
                    }
                } else {
                    arguments[i] = SerializationSupport.deserialize(argumentsData[i]);
                }
            }
        }

        SecurityContext targetSecurityContext = null;
        if (invocation.getSessionId() != null) {
            targetSecurityContext = new SecurityContext(invocation.getSessionId());
        }
        AppContext.setSecurityContext(targetSecurityContext);

        if (invocation.getLocale() != null) {
            Locale locale = Locale.forLanguageTag(invocation.getLocale());
            UserInvocationContext.setRequestScopeInfo(invocation.getSessionId(), locale, invocation.getTimeZone(),
                    invocation.getAddress(), invocation.getClientInfo());
        }

        Method method = target.getClass().getMethod(invocation.getMethodName(), parameterTypes);
        Object data = method.invoke(target, arguments);

        if (invocation.canResultBypassSerialization()) {
            result.setNotSerializableData(data);
        } else {
            result.setData(SerializationSupport.serialize(data));
        }
        return result;
    } catch (Throwable t) {
        if (t instanceof InvocationTargetException)
            t = ((InvocationTargetException) t).getTargetException();
        result.setException(SerializationSupport.serialize(t));
        return result;
    } finally {
        Thread.currentThread().setContextClassLoader(clientClassLoader);
        AppContext.setSecurityContext(null);
        UserInvocationContext.clearRequestScopeInfo();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:72,代码来源:LocalServiceInvokerImpl.java

示例12: loadKeys

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
@Override
protected void loadKeys() {
    if (config.getConfigurationSection("Hostile") != null) {
        backup();
        return;
    }

    for (String entityName : config.getKeys(false)) {
        Class<?> clazz = null;
        String className = config.getString(entityName + ".Class", "");

        try {
            clazz = ClassUtils.getClass(className);
        }
        catch (ClassNotFoundException e) {
            plugin.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
            plugin.getLogger().warning("This custom entity may not function properly.");
        }

        String entityTypeName = entityName.replace("_", ".");
        double xpMultiplier = config.getDouble(entityName + ".XP_Multiplier", 1.0D);

        boolean canBeTamed = config.getBoolean(entityName + ".Tameable");
        int tamingXp = config.getInt(entityName + ".Taming_XP");

        boolean canBeSummoned = config.getBoolean(entityName + ".CanBeSummoned");
        Material callOfTheWildMaterial = Material.matchMaterial(config.getString(entityName + ".COTW_Material", ""));
        byte callOfTheWildData = (byte) config.getInt(entityName + ".COTW_Material_Data");
        int callOfTheWildAmount = config.getInt(entityName + ".COTW_Material_Amount");

        if (canBeSummoned && (callOfTheWildMaterial == null || callOfTheWildAmount == 0)) {
            plugin.getLogger().warning("Incomplete Call of the Wild information. This entity will not be able to be summoned by Call of the Wild.");
            canBeSummoned = false;
        }

        CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new MaterialData(callOfTheWildMaterial, callOfTheWildData).toItemStack(1) : null), callOfTheWildAmount);

        customEntityTypeMap.put(entityTypeName, entity);
        customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:42,代码来源:CustomEntityConfig.java

示例13: completeValidation

import org.apache.commons.lang.ClassUtils; //导入方法依赖的package包/类
/**
 * Directly validate simple fields, call completeValidation on Definition
 * fields.
 *
 * @see org.kuali.rice.krad.datadictionary.DataDictionaryEntry#completeValidation()
 */
@Override
@Deprecated
public void completeValidation(Class<?> rootObjectClass, Class<?> otherObjectClass) {
    try {
        if (!DataDictionary.isPropertyOf(rootObjectClass, getName())) {
            throw new AttributeValidationException("property '"
                    + getName()
                    + "' is not a property of class '"
                    + rootObjectClass.getName()
                    + "' ("
                    + ""
                    + ")");
        }

        //TODO currently requiring a control or controlField, but this should not be case (AttrField should probably do the check)
        if (getControl() == null && getControlField() == null) {
            throw new AttributeValidationException("property '"
                    + getName()
                    + "' in class '"
                    + rootObjectClass.getName()
                    + " does not have a control defined");
        }

        if (getControl() != null) {
            getControl().completeValidation(rootObjectClass, otherObjectClass);
        }

        if (attributeSecurity != null) {
            attributeSecurity.completeValidation(rootObjectClass, otherObjectClass);
        }

        if (validationPattern != null) {
            validationPattern.completeValidation();
        }

        if (formatterClass != null) {
            try {
                Class formatterClassObject = ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(),
                        getFormatterClass());
                if (!Formatter.class.isAssignableFrom(formatterClassObject)) {
                    throw new ClassValidationException("formatterClass is not a valid instance of "
                            + Formatter.class.getName()
                            + " instead was: "
                            + formatterClassObject.getName());
                }
            } catch (ClassNotFoundException e) {
                throw new ClassValidationException("formatterClass could not be found: " + getFormatterClass(), e);
            }
        }
    } catch (RuntimeException ex) {
        Logger.getLogger(getClass()).error(
                "Unable to validate attribute " + rootObjectClass + "." + getName() + ": " + ex.getMessage(), ex);
        throw ex;
    }
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:62,代码来源:AttributeDefinition.java


注:本文中的org.apache.commons.lang.ClassUtils.getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。