本文整理匯總了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());
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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");
}
示例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);
}
}
}
示例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;
}
示例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;
}
}
示例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;
}