當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。