List of usage examples for org.springframework.util ClassUtils getUserClass
public static Class<?> getUserClass(Class<?> clazz)
From source file:com.vaadin.spring.internal.Conventions.java
public static String deriveMappingForView(Class<?> beanClass, SpringView annotation) { if (annotation != null && !SpringView.USE_CONVENTIONS.equals(annotation.name())) { return annotation.name(); } else {/*from w ww . j a va 2 s .co m*/ // derive mapping from classname // do not use proxy class names Class<?> realBeanClass = ClassUtils.getUserClass(beanClass); String mapping = realBeanClass.getSimpleName().replaceFirst("View$", ""); return upperCamelToLowerHyphen(mapping); } }
From source file:com.ccc.cccframework.vaadin_spring.application.VaadinConfigurableBeanWiringInfoResolver.java
private String getDefaultBeanName(Object bean) { return ClassUtils.getUserClass(bean).getName(); }
From source file:com.denksoft.springstarter.util.security.CustomAclEntryAfterInvocationProvider.java
private Serializable getIdentity(Object object) throws IdentityUnavailableException { Assert.notNull(object, "object cannot be null"); Serializable identifier;/*from ww w . java 2s. co m*/ Class javaType = ClassUtils.getUserClass(object.getClass()); Object result; try { Method method = javaType.getMethod("getId", new Class[] {}); result = method.invoke(object, new Object[] {}); } catch (Exception e) { throw new IdentityUnavailableException("Could not extract identity from object " + object, e); } Assert.notNull(result, "getId() is required to return a non-null value"); Assert.isInstanceOf(Serializable.class, result, "Getter must provide a return value of type Serializable"); return (Serializable) result; }
From source file:com._4dconcept.springframework.data.marklogic.core.MarklogicExceptionTranslator.java
@Override public DataAccessException translateExceptionIfPossible(RuntimeException ex) { // Check for well-known MarklogicException subclasses. String exception = ClassUtils.getShortName(ClassUtils.getUserClass(ex.getClass())); if (RESOURCE_FAILURE_EXCEPTIONS.contains(exception)) { return new DataAccessResourceFailureException(ex.getMessage(), ex); }//from w w w . j a va2s . co m if (RESOURCE_USAGE_EXCEPTIONS.contains(exception)) { return new InvalidDataAccessResourceUsageException(ex.getMessage(), ex); } if (DATA_INTEGRETY_EXCEPTIONS.contains(exception)) { return new DataIntegrityViolationException(ex.getMessage(), ex); } return null; }
From source file:jetbrains.buildServer.server.rest.jersey.JerseyWebComponent.java
/** * Checks for all beans that have @Provider annotation and * registers them into Jersey ResourceConfig * @param rc config//from w ww. j av a 2 s . co m * @param springContext spring context */ private void registerResourceProfiders(ResourceConfig rc, ConfigurableApplicationContext springContext) { //TODO: restrict search to current spring context without parent for speedup for (String name : BeanFactoryUtils.beanNamesIncludingAncestors(springContext)) { final Class<?> type = ClassUtils.getUserClass(springContext.getType(name)); if (ResourceConfig.isProviderClass(type)) { LOG.info("Registering Spring bean, " + name + ", of type " + type.getName() + " as a provider class"); rc.getClasses().add(type); } else if (ResourceConfig.isRootResourceClass(type)) { LOG.info("Registering Spring bean, " + name + ", of type " + type.getName() + " as a root resource class"); rc.getClasses().add(type); } } }
From source file:example.springdata.jpa.compositions.FlushOnSaveRepositoryImpl.java
@SuppressWarnings({ "unchecked", "rawtypes" })
private <S extends T> EntityInformation<Object, S> getEntityInformation(S entity) {
Class<?> userClass = ClassUtils.getUserClass(entity.getClass());
if (entity instanceof AbstractPersistable<?>) {
return new JpaPersistableEntityInformation(userClass, entityManager.getMetamodel());
}//from w w w.java2s .c o m
return new JpaMetamodelEntityInformation(userClass, entityManager.getMetamodel());
}
From source file:ch.ralscha.extdirectspring.controller.MethodRegistrar.java
@Override public void onApplicationEvent(ContextRefreshedEvent event) { ApplicationContext context = (ApplicationContext) event.getSource(); String[] beanNames = context.getBeanNamesForType(Object.class); for (String beanName : beanNames) { Class<?> handlerType = context.getType(beanName); final Class<?> userType = ClassUtils.getUserClass(handlerType); Set<Method> methods = MethodIntrospector.selectMethods(userType, new MethodFilter() { @Override//from w w w. java 2s . c o m public boolean matches(Method method) { return AnnotationUtils.findAnnotation(method, ExtDirectMethod.class) != null; } }); for (Method method : methods) { ExtDirectMethod directMethodAnnotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class); final String beanAndMethodName = beanName + "." + method.getName(); if (directMethodAnnotation.value().isValid(beanAndMethodName, userType, method)) { this.methodInfoCache.put(beanName, handlerType, method, event.getApplicationContext()); // /CLOVER:OFF if (log.isDebugEnabled()) { String info = "Register " + beanAndMethodName + "(" + directMethodAnnotation.value(); if (StringUtils.hasText(directMethodAnnotation.group())) { info += ", " + directMethodAnnotation.group(); } info += ")"; log.debug(info); } // /CLOVER:ON } } } }
From source file:org.agatom.springatom.data.oid.creators.PersistableSOidCreator.java
@Override @SuppressWarnings("unchecked") public <S extends Persistable<?>> SOid fromObject(final S from) throws Exception { return new PersistableOid().setReference(new WeakReference<Persistable<?>>(from)) .setObjectClass((Class<Persistable<?>>) ClassUtils.getUserClass(from)) .setObjectId((Long) from.getId()).setObjectPrefix(PERSISTABLE_TYPE_PREFIX); }
From source file:org.lightadmin.core.config.bootstrap.RepositoriesFactoryBean.java
private Map<Class<?>, String> repositoryBeanNames(ListableBeanFactory beanFactory) { Map<Class<?>, String> repositoryBeanNames = newHashMap(); for (String name : beanFactory.getBeanNamesForType(RepositoryFactoryInformation.class, false, false)) { RepositoryFactoryInformation repositoryFactoryInformation = beanFactory.getBean(name, RepositoryFactoryInformation.class); Class<?> userDomainType = ClassUtils .getUserClass(repositoryFactoryInformation.getRepositoryInformation().getDomainType()); repositoryBeanNames.put(userDomainType, BeanFactoryUtils.transformedBeanName(name)); }//from ww w . j a v a 2 s .c om return repositoryBeanNames; }