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


Java ClassUtils.getClass方法代码示例

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


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

示例1: newCredentialSelectionPredicate

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * Gets credential selection predicate.
 *
 * @param selectionCriteria the selection criteria
 * @return the credential selection predicate
 */
public static Predicate<org.apereo.cas.authentication.Credential> newCredentialSelectionPredicate(final String selectionCriteria) {
    try {
        if (StringUtils.isBlank(selectionCriteria)) {
            return credential -> true;
        }

        if (selectionCriteria.endsWith(".groovy")) {
            final ResourceLoader loader = new DefaultResourceLoader();
            final Resource resource = loader.getResource(selectionCriteria);
            if (resource != null) {
                final String script = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8);
                final GroovyClassLoader classLoader = new GroovyClassLoader(Beans.class.getClassLoader(),
                        new CompilerConfiguration(), true);
                final Class<Predicate> clz = classLoader.parseClass(script);
                return clz.newInstance();
            }
        }

        final Class predicateClazz = ClassUtils.getClass(selectionCriteria);
        return (Predicate<org.apereo.cas.authentication.Credential>) predicateClazz.newInstance();
    } catch (final Exception e) {
        final Predicate<String> predicate = Pattern.compile(selectionCriteria).asPredicate();
        return credential -> predicate.test(credential.getId());
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:32,代码来源:Beans.java

示例2: handleUnknownTypeId

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
@Override
public JavaType handleUnknownTypeId(final DeserializationContext ctxt, final JavaType baseType,
                                    final String subTypeId, final TypeIdResolver idResolver,
                                    final String failureMsg) throws IOException {

    try {
        if (subTypeId.contains("org.jasig.")) {
            final String newTypeName = subTypeId.replaceAll("jasig", "apereo");
            LOGGER.warn("Found legacy CAS JSON definition type identified as [{}]. "
                            + "While CAS will attempt to convert the legacy definition to [{}] for the time being, "
                            + "the definition SHOULD manually be upgraded to the new supported syntax",
                    subTypeId, newTypeName);
            final Class newType = ClassUtils.getClass(newTypeName);
            return SimpleType.construct(newType);
        }
        return null;
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:JasigRegisteredServiceDeserializationProblemHandler.java

示例3: construct

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * Call a class constructor with an integer parameter
 * @param className name of the class to be constructed
 * @param parameter the value to be used in the constructor
 * @return an instance of the class
 * @throws JMeterException if class cannot be created
 */
public static Object construct(String className, int parameter) throws JMeterException
{
    Object instance = null;
    try {
        Class<?> clazz = ClassUtils.getClass(className);
        Constructor<?> constructor = clazz.getConstructor(Integer.TYPE);
        instance = constructor.newInstance(Integer.valueOf(parameter));
    } catch (ClassNotFoundException | InvocationTargetException
            | IllegalArgumentException | NoSuchMethodException
            | SecurityException | IllegalAccessException
            | InstantiationException e) {
        throw new JMeterException(e);
    }
    return instance;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:23,代码来源:ClassTools.java

示例4: getPropertyType

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 *
 *
 * @param className .
 * @param property .
 *
 * @return .
 */
@Override
public String getPropertyType(String className, String property) {
    Class<?> clazz;

    try {
        clazz = ClassUtils.getClass(className);

        BeanWrapper bw = new BeanWrapperImpl(clazz);

        return bw.getPropertyType(property).getName();
    } catch (ClassNotFoundException e) {
        LOG.error("Oops", e);
    }

    return null;
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:25,代码来源:SimpleInstanceFactory.java

示例5: getValue

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public T getValue() {
    Object value = storedValue;
    if (propertyValueEvaluator != null) {
        value = propertyValueEvaluator.evaluate(this, storedValue);
    } // else not evaluator so return the storedValue
      // try to convert the String to the enum
    if (value instanceof String) {
        try {
            Class<T> enumClass = (Class<T>) ClassUtils.getClass(getType());
            return Enum.valueOf(enumClass, (String) value);
        } catch (ClassNotFoundException e) {
            TalendRuntimeException.unexpectedException(e);
        }
    }
    return (T) value;
}
 
开发者ID:Talend,项目名称:daikon,代码行数:19,代码来源:EnumProperty.java

示例6: parserPool

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
@Bean(name = "shibboleth.ParserPool", initMethod = "initialize")
public BasicParserPool parserPool() {
    final BasicParserPool pool = new BasicParserPool();
    pool.setMaxPoolSize(POOL_SIZE);
    pool.setCoalescing(true);
    pool.setIgnoreComments(true);
    pool.setXincludeAware(false);
    pool.setExpandEntityReferences(false);
    pool.setIgnoreComments(true);
    pool.setNamespaceAware(true);

    final Map<String, Object> attributes = new HashMap<>();
    try {
        final Class clazz = ClassUtils.getClass(casProperties.getSamlCore().getSecurityManager());
        attributes.put("http://apache.org/xml/properties/security-manager", clazz.newInstance());
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
    pool.setBuilderAttributes(attributes);

    final Map<String, Boolean> features = new HashMap<>();
    features.put("http://apache.org/xml/features/disallow-doctype-decl", Boolean.TRUE);
    features.put("http://apache.org/xml/features/validation/schema/normalized-value",
            Boolean.FALSE);
    features.put("http://javax.xml.XMLConstants/feature/secure-processing",
            Boolean.TRUE);
    features.put("http://xml.org/sax/features/external-general-entities",
            Boolean.FALSE);
    features.put("http://xml.org/sax/features/external-parameter-entities",
            Boolean.FALSE);
    pool.setBuilderFeatures(features);
    return pool;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:34,代码来源:CoreSamlConfiguration.java

示例7: newLdaptiveConnectionFactory

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * New connection factory connection factory.
 *
 * @param l the l
 * @return the connection factory
 */
public static DefaultConnectionFactory newLdaptiveConnectionFactory(final AbstractLdapProperties l) {
    LOGGER.debug("Creating LDAP connection factory for [{}]", l.getLdapUrl());
    final ConnectionConfig cc = newLdaptiveConnectionConfig(l);
    final DefaultConnectionFactory bindCf = new DefaultConnectionFactory(cc);
    if (l.getProviderClass() != null) {
        try {
            final Class clazz = ClassUtils.getClass(l.getProviderClass());
            bindCf.setProvider(Provider.class.cast(clazz.newInstance()));
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
    return bindCf;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:Beans.java

示例8: getClass

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
public static Class getClass(String name) {
    try {
        return ClassUtils.getClass(Synthesizer.classLoader, name);
    } catch (ClassNotFoundException e) {
        System.out.println(name);
        throw new SynthesisException(SynthesisException.ClassNotFoundInLoader);
    }
}
 
开发者ID:capergroup,项目名称:bayou,代码行数:9,代码来源:Environment.java

示例9: loadClass

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * 加载指定名称的类,并指定是否执行静态初始代码块
 *
 * @param className 类名
 * @param initial   true表示执行初始代码块,otherwise 不执行初始代码块
 * @return 执行类名的Class对象
 */
public static Class<?> loadClass(String className, boolean initial) {

    try {
        Class<?> aClass = ClassUtils.getClass(className, initial);
        return aClass;
    } catch (ClassNotFoundException e) {
        LOGGER.error(e.getMessage(), e);
        return null;
    }

}
 
开发者ID:151376liujie,项目名称:wechat-core,代码行数:19,代码来源:ClassPathUtils.java

示例10: channelRead0

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
	ByteBuf buf = msg.content();
	int id = buf.readInt();
	String clazzName = readString(buf);
	Class<?> clazz = ClassUtils.getClass(clazzName);
	Object val;
	if(ByteBuf.class.isAssignableFrom(clazz)) {
		val = buf.copy();
	} else {
		String json = readString(buf);
		val = gson.fromJson(json, clazz);
	}
	manager.returnValueCallback(id, val);
}
 
开发者ID:thilokru,项目名称:Controller-Support,代码行数:16,代码来源:ClientNetworkHandler.java

示例11: getClassFileStream

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/** Utility method to get an input stream to a class file */
public static InputStream getClassFileStream(String className) throws ClassNotFoundException {
    Class<?> c = ClassUtils.getClass(className);
    ClassLoader loader = c.getClassLoader();
    if (loader == null) {
        loader = ClassLoader.getSystemClassLoader();
        while (loader != null && loader.getParent() != null) {
            loader = loader.getParent();
        }
    }
    if (loader == null) {
        return null;
    }
    return loader.getResourceAsStream(c.getName().replace(".", "/") + ".class");
}
 
开发者ID:brownsys,项目名称:tracing-framework,代码行数:16,代码来源:Agent.java

示例12: Transformer

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
public Transformer(Map<String, byte[]> modifiedClassFiles) {
    for (String className : modifiedClassFiles.keySet()) {
        try {
            Class<?> actualClass = ClassUtils.getClass(className);
            classdata.put(actualClass, modifiedClassFiles.get(className));
        } catch (ClassNotFoundException e) {
            // If the class can't be found, just ignore it
            log.warn("Unable to reload class " + className, e);
        }
    }
}
 
开发者ID:brownsys,项目名称:tracing-framework,代码行数:12,代码来源:JVMAgent.java

示例13: loadClass

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
@Override
public Class<?> loadClass(String className) {
    LOG.debug("Loading class from classloader: {}.", Thread.currentThread().getContextClassLoader());
    Class<?> result = null;
    try {
        // try to resolve the class from the thread context classloader
        result = ClassUtils.getClass(Thread.currentThread().getContextClassLoader(), className);
    } catch (ClassNotFoundException e) {
        MappingUtils.throwMappingException(e);
    }
    return result;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:DozerThreadContextClassLoader.java

示例14: apply

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
@Override
public boolean apply(@Nullable String s) {
    if (s==null) return false;
    if (preregisteredAutoType.containsKey(s)) return true;
    try {
        Class clazz = ClassUtils.getClass(s);
        return DefaultSchemaMaker.class.isAssignableFrom(clazz);
    } catch (ClassNotFoundException e) {
        return false;
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:12,代码来源:GraphDatabaseConfiguration.java

示例15: getClassType

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 *
 *
 * @param <T> .
 * @param type .
 *
 * @return .
 */
@SuppressWarnings("unchecked")
@Override
public <T> Class<T> getClassType(String type) {
    try {
        return (Class<T>) ClassUtils.getClass(type);
    } catch (ClassNotFoundException e) {
        LOG.error("Oops", e);
    }

    return null;
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:20,代码来源:SimpleInstanceFactory.java


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