當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassUtils類代碼示例

本文整理匯總了Java中org.springframework.util.ClassUtils的典型用法代碼示例。如果您正苦於以下問題:Java ClassUtils類的具體用法?Java ClassUtils怎麽用?Java ClassUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClassUtils類屬於org.springframework.util包,在下文中一共展示了ClassUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: commaSeparatedStringToThrowablesCollection

import org.springframework.util.ClassUtils; //導入依賴的package包/類
@ConfigurationPropertiesBinding
@Bean
public Converter<String, List<Class<? extends Throwable>>> commaSeparatedStringToThrowablesCollection() {
    return new Converter<String, List<Class<? extends Throwable>>>() {
        @Override
        public List<Class<? extends Throwable>> convert(final String source) {
            try {
                final List<Class<? extends Throwable>> classes = new ArrayList<>();
                for (final String className : StringUtils.commaDelimitedListToStringArray(source)) {
                    classes.add((Class<? extends Throwable>) ClassUtils.forName(className.trim(), getClass().getClassLoader()));
                }
                return classes;
            } catch (final Exception e) {
                throw new IllegalStateException(e);
            }
        }
    };
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:19,代碼來源:CasCoreBootstrapStandaloneConfiguration.java

示例2: forMethod

import org.springframework.util.ClassUtils; //導入依賴的package包/類
/**
 * Creates a {@link PublicationTargetIdentifier} for the given {@link Method}.
 * 
 * @param method must not be {@literal null}.
 * @return
 */
public static PublicationTargetIdentifier forMethod(Method method) {

	String typeName = ClassUtils.getUserClass(method.getDeclaringClass()).getName();
	String methodName = method.getName();
	String parameterTypes = StringUtils.arrayToDelimitedString(method.getParameterTypes(), ", ");

	return PublicationTargetIdentifier.of(String.format("%s.%s(%s)", typeName, methodName, parameterTypes));
}
 
開發者ID:olivergierke,項目名稱:spring-domain-events,代碼行數:15,代碼來源:PublicationTargetIdentifier.java

示例3: getSingletonInstance

import org.springframework.util.ClassUtils; //導入依賴的package包/類
/**
 * Return the singleton instance of this class's proxy object,
 * lazily creating it if it hasn't been created already.
 * @return the shared singleton proxy
 */
private synchronized Object getSingletonInstance() {
	if (this.singletonInstance == null) {
		this.targetSource = freshTargetSource();
		if (this.autodetectInterfaces && getProxiedInterfaces().length == 0 && !isProxyTargetClass()) {
			// Rely on AOP infrastructure to tell us what interfaces to proxy.
			Class<?> targetClass = getTargetClass();
			if (targetClass == null) {
				throw new FactoryBeanNotInitializedException("Cannot determine target class for proxy");
			}
			setInterfaces(ClassUtils.getAllInterfacesForClass(targetClass, this.proxyClassLoader));
		}
		// Initialize the shared singleton instance.
		super.setFrozen(this.freezeProxy);
		this.singletonInstance = getProxy(createAopProxy());
	}
	return this.singletonInstance;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:ProxyFactoryBean.java

示例4: getNumberConversionMethodName

import org.springframework.util.ClassUtils; //導入依賴的package包/類
private static String getNumberConversionMethodName(Class<?> objectClass) {
    objectClass = ClassUtils.resolvePrimitiveIfNecessary(objectClass);
    if (Integer.class.isAssignableFrom(objectClass)) {
        return INT_VALUE;
    }
    if (Long.class.isAssignableFrom(objectClass)) {
        return LONG_VALUE;
    }
    if (Float.class.isAssignableFrom(objectClass)) {
        return FLOAT_VALUE;
    }
    if (Double.class.isAssignableFrom(objectClass)) {
        return DOUBLE_VALUE;
    }
    throw new IllegalArgumentException(
            "Cannot get conversion number for class " + objectClass);
}
 
開發者ID:rubasace,項目名稱:spring-data-jdbc,代碼行數:18,代碼來源:GeneratedValueUtil.java

示例5: parseTargetMapping

import org.springframework.util.ClassUtils; //導入依賴的package包/類
private static FlowExecutor.TargetMappingExecutor parseTargetMapping(Method method) {
    logger.debug("解析目標對象映射方法:{}", method);
    // 校驗方法類型
    if (!Modifier.isPublic(method.getModifiers())) {
        throw new IllegalArgumentException("目標對象映射方法" + ClassUtils.getQualifiedMethodName(method) + "必須是public類型");
    }
    // 校驗入參
    Class[] parameterTypes = method.getParameterTypes();
    if (parameterTypes.length != 1) {
        throw new IllegalArgumentException("目標對象映射方法" + ClassUtils.getQualifiedMethodName(method) + "必須隻能有一個入參");
    }
    // 校驗返回參數
    if (method.getReturnType() != String.class) {
        throw new IllegalArgumentException("目標對象映射方法" + ClassUtils.getQualifiedMethodName(method) + "返回參數必須是String類型");
    }

    return new FlowExecutor.TargetMappingExecutor(method, parameterTypes[0]);
}
 
開發者ID:zhongxunking,項目名稱:bekit,代碼行數:19,代碼來源:FlowParser.java

示例6: newPrototypeInstance

import org.springframework.util.ClassUtils; //導入依賴的package包/類
/**
 * Create a new prototype instance of this class's created proxy object,
 * backed by an independent AdvisedSupport configuration.
 * @return a totally independent proxy, whose advice we may manipulate in isolation
 */
private synchronized Object newPrototypeInstance() {
	// In the case of a prototype, we need to give the proxy
	// an independent instance of the configuration.
	// In this case, no proxy will have an instance of this object's configuration,
	// but will have an independent copy.
	if (logger.isTraceEnabled()) {
		logger.trace("Creating copy of prototype ProxyFactoryBean config: " + this);
	}

	ProxyCreatorSupport copy = new ProxyCreatorSupport(getAopProxyFactory());
	// The copy needs a fresh advisor chain, and a fresh TargetSource.
	TargetSource targetSource = freshTargetSource();
	copy.copyConfigurationFrom(this, targetSource, freshAdvisorChain());
	if (this.autodetectInterfaces && getProxiedInterfaces().length == 0 && !isProxyTargetClass()) {
		// Rely on AOP infrastructure to tell us what interfaces to proxy.
		copy.setInterfaces(
				ClassUtils.getAllInterfacesForClass(targetSource.getTargetClass(), this.proxyClassLoader));
	}
	copy.setFrozen(this.freezeProxy);

	if (logger.isTraceEnabled()) {
		logger.trace("Using ProxyCreatorSupport copy: " + copy);
	}
	return getProxy(copy.createAopProxy());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:ProxyFactoryBean.java

示例7: getBeanName

import org.springframework.util.ClassUtils; //導入依賴的package包/類
private static String getBeanName(AnnotationMetadata annotationMetadata, Map<String, Object> attributes) {
    // name & value are aliases
    String beanName = (String) attributes.get("value");
    if (!StringUtils.isEmpty(beanName)) {
        return beanName;
    } else {
        // generate bean name from class name
        String shortName = ClassUtils.getShortName(annotationMetadata.getClassName());
        return StringUtils.uncapitalize(shortName);
    }
}
 
開發者ID:xm-online,項目名稱:xm-commons,代碼行數:12,代碼來源:LepServicesRegistrar.java

示例8: createProxy

import org.springframework.util.ClassUtils; //導入依賴的package包/類
/**
 * Actually create the EntityManager proxy.
 * @param rawEm raw EntityManager
 * @param emIfc the (potentially vendor-specific) EntityManager
 * interface to proxy, or {@code null} for default detection of all interfaces
 * @param cl the ClassLoader to use for proxy creation (maybe {@code null})
 * @param exceptionTranslator the PersistenceException translator to use
 * @param jta whether to create a JTA-aware EntityManager
 * (or {@code null} if not known in advance)
 * @param containerManaged whether to follow container-managed EntityManager
 * or application-managed EntityManager semantics
 * @param synchronizedWithTransaction whether to automatically join ongoing
 * transactions (according to the JPA 2.1 SynchronizationType rules)
 * @return the EntityManager proxy
 */
private static EntityManager createProxy(
		EntityManager rawEm, Class<? extends EntityManager> emIfc, ClassLoader cl,
		PersistenceExceptionTranslator exceptionTranslator, Boolean jta,
		boolean containerManaged, boolean synchronizedWithTransaction) {

	Assert.notNull(rawEm, "EntityManager must not be null");
	Set<Class<?>> ifcs = new LinkedHashSet<Class<?>>();
	if (emIfc != null) {
		ifcs.add(emIfc);
	}
	else {
		ifcs.addAll(ClassUtils.getAllInterfacesForClassAsSet(rawEm.getClass(), cl));
	}
	ifcs.add(EntityManagerProxy.class);
	return (EntityManager) Proxy.newProxyInstance(
			(cl != null ? cl : ExtendedEntityManagerCreator.class.getClassLoader()),
			ifcs.toArray(new Class<?>[ifcs.size()]),
			new ExtendedEntityManagerInvocationHandler(
					rawEm, exceptionTranslator, jta, containerManaged, synchronizedWithTransaction));
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:36,代碼來源:ExtendedEntityManagerCreator.java

示例9: scanForEntities

import org.springframework.util.ClassUtils; //導入依賴的package包/類
protected Set<Class<?>> scanForEntities(String basePackage) throws ClassNotFoundException {
    if (!StringUtils.hasText(basePackage)) {
        return Collections.emptySet();
    }

    final Set<Class<?>> initialEntitySet = new HashSet<Class<?>>();

    if (StringUtils.hasText(basePackage)) {
        final ClassPathScanningCandidateComponentProvider componentProvider =
                new ClassPathScanningCandidateComponentProvider(false);
        componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));

        for (final BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {

            initialEntitySet
                    .add(ClassUtils.forName(candidate.getBeanClassName(),
                            DocumentDbConfigurationSupport.class.getClassLoader()));
        }
    }

    return initialEntitySet;
}
 
開發者ID:Microsoft,項目名稱:spring-data-documentdb,代碼行數:23,代碼來源:DocumentDbConfigurationSupport.java

示例10: HandlerMethodService

import org.springframework.util.ClassUtils; //導入依賴的package包/類
public HandlerMethodService(ConversionService conversionService,
		List<HandlerMethodArgumentResolver> customArgumentResolvers,
		ObjectMapper objectMapper, ApplicationContext applicationContext) {
	this.conversionService = conversionService;
	this.parameterNameDiscoverer = new DefaultParameterNameDiscoverer();

	this.argumentResolvers = new HandlerMethodArgumentResolverComposite();

	ConfigurableBeanFactory beanFactory = ClassUtils.isAssignableValue(
			ConfigurableApplicationContext.class, applicationContext)
					? ((ConfigurableApplicationContext) applicationContext)
							.getBeanFactory()
					: null;

	this.argumentResolvers.addResolver(
			new HeaderMethodArgumentResolver(this.conversionService, beanFactory));
	this.argumentResolvers.addResolver(new HeadersMethodArgumentResolver());
	this.argumentResolvers.addResolver(new WampMessageMethodArgumentResolver());
	this.argumentResolvers.addResolver(new PrincipalMethodArgumentResolver());
	this.argumentResolvers.addResolver(new WampSessionIdMethodArgumentResolver());
	this.argumentResolvers.addResolvers(customArgumentResolvers);

	this.objectMapper = objectMapper;
}
 
開發者ID:ralscha,項目名稱:wamp2spring,代碼行數:25,代碼來源:HandlerMethodService.java

示例11: invoke

import org.springframework.util.ClassUtils; //導入依賴的package包/類
/**
 * Invoke the method after resolving its argument values in the context of the given
 * message.
 * <p>
 * Argument values are commonly resolved through
 * {@link HandlerMethodArgumentResolver}s. The {@code providedArgs} parameter however
 * may supply argument values to be used directly, i.e. without argument resolution.
 * @param message the current message being processed
 * @param arguments
 * @param argumentsKw
 * @return the raw value returned by the invoked method
 * @exception Exception raised if no suitable argument resolver can be found, or if
 * the method raised an exception
 */
@Nullable
public Object invoke(WampMessage message, List<Object> arguments,
		Map<String, Object> argumentsKw) throws Exception {
	Object[] args = getMethodArgumentValues(message, arguments, argumentsKw);
	if (this.logger.isTraceEnabled()) {
		this.logger.trace("Invoking '"
				+ ClassUtils.getQualifiedMethodName(getMethod(), getBeanType())
				+ "' with arguments " + Arrays.toString(args));
	}
	Object returnValue = doInvoke(args);
	if (this.logger.isTraceEnabled()) {
		this.logger.trace("Method ["
				+ ClassUtils.getQualifiedMethodName(getMethod(), getBeanType())
				+ "] returned [" + returnValue + "]");
	}
	return returnValue;
}
 
開發者ID:ralscha,項目名稱:wamp2spring,代碼行數:32,代碼來源:InvocableHandlerMethod.java

示例12: getSpecificmethod

import org.springframework.util.ClassUtils; //導入依賴的package包/類
private Method getSpecificmethod(ProceedingJoinPoint pjp) {
	MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
	Method method = methodSignature.getMethod();
	// The method may be on an interface, but we need attributes from the
	// target class. If the target class is null, the method will be
	// unchanged.
	Class<?> targetClass = AopProxyUtils.ultimateTargetClass(pjp.getTarget());
	if (targetClass == null && pjp.getTarget() != null) {
		targetClass = pjp.getTarget().getClass();
	}
	Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
	// If we are dealing with method with generic parameters, find the
	// original method.
	specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
	return specificMethod;
}
 
開發者ID:ziwenxie,項目名稱:leafer,代碼行數:17,代碼來源:CachingAnnotationsAspect.java

示例13: equals

import org.springframework.util.ClassUtils; //導入依賴的package包/類
@Override
public boolean equals(Object obj) {

    if (null == obj) {
        return false;
    }

    if (this == obj) {
        return true;
    }

    if (!getClass().equals(ClassUtils.getUserClass(obj))) {
        return false;
    }

    AbstractPersistable<?> that = (AbstractPersistable<?>) obj;

    return null != this.getId() && this.getId().equals(that.getId());
}
 
開發者ID:geeker-lait,項目名稱:tasfe-framework,代碼行數:20,代碼來源:BaseEntity.java

示例14: getEmbeddedServletContainer

import org.springframework.util.ClassUtils; //導入依賴的package包/類
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers) {
    ClassLoader parentClassLoader = resourceLoader != null ? resourceLoader.getClassLoader() : ClassUtils.getDefaultClassLoader();
    Package nettyPackage = Bootstrap.class.getPackage();
    String title = nettyPackage.getImplementationTitle();
    String version = nettyPackage.getImplementationVersion();
    logger.info("Running with " + title + " " + version);
    NettyEmbeddedContext context = new NettyEmbeddedContext(getContextPath(), new URLClassLoader(new URL[]{}, parentClassLoader), SERVER_INFO);
    if (isRegisterDefaultServlet()) {
        logger.warn("This container does not support a default servlet");
    }
    /*if (isRegisterJspServlet()) {
        logger.warn("This container does not support a JSP servlet");
    }*/
    for (ServletContextInitializer initializer : initializers) {
        try {
            initializer.onStartup(context);
        } catch (ServletException e) {
            throw new RuntimeException(e);
        }
    }
    int port = getPort() > 0 ? getPort() : new Random().nextInt(65535 - 1024) + 1024;
    InetSocketAddress address = new InetSocketAddress(port);
    logger.info("Server initialized with port: " + port);
    return new NettyEmbeddedServletContainer(address, context);
}
 
開發者ID:geeker-lait,項目名稱:tasfe-framework,代碼行數:27,代碼來源:NettyEmbeddedServletContainerFactory.java

示例15: getURL

import org.springframework.util.ClassUtils; //導入依賴的package包/類
public static URL getURL(String resourceLocation)
        throws FileNotFoundException {
    Assert.notNull(resourceLocation, "Resource location must not be null");
    if (resourceLocation.startsWith("classpath:")) {
        String path = resourceLocation.substring("classpath:".length());
        ClassLoader cl = ClassUtils.getDefaultClassLoader();
        URL url = cl != null ? cl.getResource(path) : ClassLoader.getSystemResource(path);
        if (url == null) {
            String description = "class path resource [" + path + "]";
            throw new FileNotFoundException(description + " cannot be resolved to URL because it does not exist");
        }

        return url;
    }
    try {
        return new URL(resourceLocation);
    } catch (MalformedURLException ex) {
        try {
            return new File(resourceLocation).toURI().toURL();
        } catch (MalformedURLException ex2) {
        }
    }
    throw new FileNotFoundException("Resource location [" + resourceLocation + "] is neither a URL not a well-formed file path");
}
 
開發者ID:geeker-lait,項目名稱:tasfe-framework,代碼行數:25,代碼來源:ResourcesUtil.java


注:本文中的org.springframework.util.ClassUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。