List of usage examples for org.apache.commons.lang ClassUtils getClass
public static Class<?> getClass(String className) throws ClassNotFoundException
className
using the current thread's context class loader. From source file:net.shopxx.service.impl.DaemonServiceImpl.java
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) { try {/*from ww w . j a va2 s . c om*/ ClassUtils.getClass(StringUtils .remove("ne?t.?sh?op?xx?.e?xc?ep?ti?on?.I?nc?or?re?ct?Li?ce?ns?eE?xc?ep?ti?on", "?")); ClassUtils.getClass(StringUtils.remove("or?g.?ap?ac?he?.s?hi?ro?.r?ea?lm?.A?ut?hR?ea?lm", "?")); } catch (ClassNotFoundException e) { System.exit(0); } }
From source file:eu.esdihumboldt.hale.common.schema.model.constraint.factory.DefaultClassResolver.java
@Override public Class<?> loadClass(String className) { Class<?> result = null; try {/* www . j a va 2 s. co m*/ // loading via ClassUtils also supports primitive type classes // which Class.forName is not able to restore result = ClassUtils.getClass(className); } catch (ClassNotFoundException e) { log.debug("Could not find class " + className, e); } return result; }
From source file:com.custardsource.maven.plugins.jmx.SetAttribute.java
@Override public Object execute(MBeanServerConnection connection) throws Exception { ObjectName name = new ObjectName(objectName); ConvertUtilsBean converter = new ConvertUtilsBean(); Object attributeValue = converter.convert(value, ClassUtils.getClass(type)); connection.setAttribute(name, new Attribute(attributeName, attributeValue)); return connection.getAttribute(name, attributeName); }
From source file:com.dianping.avatar.cache.client.MemcachedClientConfigurationParser.java
@SuppressWarnings("unchecked") @Override// w w w . j a v a 2 s .c om public CacheClientConfiguration parse(CacheConfigDetailDTO detail) { assert detail instanceof MemcachedConfigDetailDTO; MemcachedClientConfiguration config = new MemcachedClientConfiguration(); MemcachedConfigDetailDTO memcachedDetail = (MemcachedConfigDetailDTO) detail; String transcoderClass = memcachedDetail.getTranscoderClazz(); if (transcoderClass != null && !transcoderClass.trim().isEmpty()) { try { Class<?> cz = ClassUtils.getClass(transcoderClass.trim()); Transcoder<Object> transcoder = (Transcoder<Object>) cz.newInstance(); config.setTranscoder(transcoder); } catch (Exception ex) { throw new RuntimeException("Failed to set memcached's transcoder.", ex); } } List<String> serverList = memcachedDetail.getServerList(); if (serverList == null || serverList.size() == 0) { throw new RuntimeException("Memcached config's server list must not be empty."); } config.setServers(serverList); return config; }
From source file:com.dianping.squirrel.client.impl.memcached.MemcachedClientConfigParser.java
@Override public StoreClientConfig parse(CacheConfigurationDTO detail) { MemcachedClientConfig config = new MemcachedClientConfig(); config.setCacheConfigurationListener(CacheMessageManager.getInstance()); String transcoderClass = ConfigManagerLoader.getConfigManager().getStringValue( "avatar-cache.memcached.transcoder.class", "com.dianping.squirrel.client.impl.memcached.MemcachedTranscoder"); if (transcoderClass != null && !transcoderClass.trim().isEmpty()) { try {/*from www.java2s . c o m*/ Class<?> cz = ClassUtils.getClass(transcoderClass.trim()); config.setTranscoderClass(cz); } catch (Exception ex) { throw new RuntimeException("Failed to set memcached's transcoder.", ex); } } List<String> serverList = detail.getServerList(); if (serverList == null || serverList.size() == 0) { throw new RuntimeException("Memcached config's server list must not be empty."); } config.setServerList(serverList); config.setClientClazz(detail.getClientClazz()); return config; }
From source file:com.yahoo.flowetl.core.util.KlassUtils.java
/** * Gets the class for a given string name * //from w ww .ja v a2 s. co m * @param <T> * the generic type to that is this class. * * @param fullyQualifiedName * the fully qualified java name of that class * * @return the class for that fully qualified name * * @throws ClassNotFoundException * the class not found exception if the name can not be found */ @SuppressWarnings("unchecked") public static <T> Class<T> getClassForName(String fullyQualifiedName) throws ClassNotFoundException { Class<?> klass = ClassUtils.getClass(fullyQualifiedName); return (Class<T>) klass; }
From source file:com.custardsource.maven.plugins.jmx.Invoke.java
@Override public Object execute(MBeanServerConnection connection) throws Exception { ObjectName name = new ObjectName(objectName); int len = parameters == null ? 0 : parameters.length; String[] signature = new String[len]; Object[] arguments = new Object[len]; ConvertUtilsBean converter = new ConvertUtilsBean(); for (int i = 0; i < len; i++) { signature[i] = parameters[i].getType(); arguments[i] = converter.convert(parameters[i].getValue(), ClassUtils.getClass(parameters[i].getType())); if (signature[i].equals("java.lang.String") && arguments[i] == null) { arguments[i] = ""; }//from w ww . j av a 2s . c om } return connection.invoke(name, operation, arguments, signature); }
From source file:it.com.pyxis.jira.selenium.WebDriverFactory.java
@SuppressWarnings("unchecked") private WebDriver newCustomDriver() { String driverClassName = properties.driverClass(FirefoxDriver.class.getName()); try {// ww w. j a v a 2s. c o m Class<WebDriver> driverClass = ClassUtils.getClass(driverClassName); WebDriver driver = driverClass.newInstance(); setDriverSpeed(driver); setTimeout(driver); return driver; } catch (Exception ex) { throw new RuntimeException(String.format("Cannot instanciate driver class '%s'!", driverClassName), ex); } }
From source file:com.agimatec.validation.jsr303.resolver.DefaultTraversableResolver.java
/** Tries to load detect and load JPA. */ private void initJpa() { try {// ww w . j a va2 s . c o m ClassUtils.getClass(PERSISTENCE_UTIL_CLASSNAME); if (log.isDebugEnabled()) log.debug("Found " + PERSISTENCE_UTIL_CLASSNAME + " on classpath."); } catch (Exception e) { if (log.isDebugEnabled()) log.debug("Cannot find " + PERSISTENCE_UTIL_CLASSNAME + " on classpath. All properties will per default be traversable."); return; } try { Class<? extends TraversableResolver> jpaAwareResolverClass = (Class<? extends TraversableResolver>) ClassUtils .getClass(JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME); jpaTR = SecureActions.newInstance(jpaAwareResolverClass); if (log.isDebugEnabled()) log.debug("Instantiated an instance of " + JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME + "."); } catch (Exception e) { log.warn("Unable to load or instanciate JPA aware resolver " + JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME + ". All properties will per default be traversable.", e); } }
From source file:fr.paris.lutece.plugins.mylutece.modules.oauth.authentication.OAuthAuthenticationFactory.java
/** * * @param strOAuthProtocolVersion the protocol version * @return the new OAuthAuthentication instance *///from www . java 2 s . c om public OAuthAuthentication newAuthentication(String strOAuthProtocolVersion) { String strClassName = _mapClasses.get(strOAuthProtocolVersion); if (strClassName != null) { Class<OAuthAuthentication> clazz; try { clazz = ClassUtils.getClass(strClassName); return clazz.newInstance(); } catch (ClassNotFoundException e) { AppLogService.error(e.getMessage(), e); } catch (InstantiationException e) { AppLogService.error(e.getMessage(), e); } catch (IllegalAccessException e) { AppLogService.error(e.getMessage(), e); } } throw new AppException("Unsupported protocol version for " + strOAuthProtocolVersion); }