Example usage for org.springframework.data.repository.core.support RepositoryFactoryInformation getRepositoryInformation

List of usage examples for org.springframework.data.repository.core.support RepositoryFactoryInformation getRepositoryInformation

Introduction

In this page you can find the example usage for org.springframework.data.repository.core.support RepositoryFactoryInformation getRepositoryInformation.

Prototype

RepositoryInformation getRepositoryInformation();

Source Link

Document

Returns the RepositoryInformation to determine meta-information about the repository being used.

Usage

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));
    }/* w  ww.  jav a2s  .  co m*/
    return repositoryBeanNames;
}

From source file:org.lightadmin.core.config.bootstrap.RepositoriesFactoryBean.java

@SuppressWarnings("unchecked")
private Map<Class<?>, RepositoryFactoryInformation<Object, Serializable>> repositoryFactoryInfos(
        ListableBeanFactory beanFactory) {
    Map<Class<?>, RepositoryFactoryInformation<Object, Serializable>> repositoryFactoryInfos = newHashMap();
    for (String name : beanFactory.getBeanNamesForType(RepositoryFactoryInformation.class, false, false)) {
        RepositoryFactoryInformation repositoryFactoryInformation = beanFactory.getBean(name,
                RepositoryFactoryInformation.class);
        Class<?> userDomainType = ClassUtils
                .getUserClass(repositoryFactoryInformation.getRepositoryInformation().getDomainType());
        repositoryFactoryInfos.put(userDomainType, repositoryFactoryInformation);
    }//w w w  . j ava  2 s.  c om
    return repositoryFactoryInfos;
}

From source file:net.daum.clix.springframework.data.rest.client.repository.RestRepositories.java

/**
 * Returns the {@link EntityInformation} for the given domain class.
 * //from   w w w  .jav  a 2  s  .  c om
 * @param domainClass
 *            must not be {@literal null}.
 * @return the {@link EntityInformation} for the given domain class or
 *         {@literal null} if no repository registered for this domain
 *         class.
 */
public RepositoryInformation getRepositoryInformationFor(Class<?> domainClass) {

    RepositoryFactoryInformation<Object, Serializable> information = getRepoInfoFor(domainClass);
    return information == null ? null : information.getRepositoryInformation();
}

From source file:net.daum.clix.springframework.data.rest.client.repository.RestRepositories.java

/**
 * Creates a new {@link RestRepositories} instance by looking up the
 * repository instances and meta information from the given
 * {@link ListableBeanFactory}./*w w w  .  j ava  2 s.c o m*/
 * 
 * @param factory
 *            must not be {@literal null}.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public RestRepositories(ListableBeanFactory factory) {

    Assert.notNull(factory);

    Collection<RestRepositoryFactoryBean> providers = BeanFactoryUtils
            .beansOfTypeIncludingAncestors(factory, RestRepositoryFactoryBean.class, true, false).values();

    for (RepositoryFactoryInformation<Object, Serializable> info : providers) {

        RepositoryInformation information = info.getRepositoryInformation();
        Class repositoryInterface = information.getRepositoryInterface();

        if (CrudRepository.class.isAssignableFrom(repositoryInterface)) {
            Class<CrudRepository<Object, Serializable>> objectType = repositoryInterface;
            CrudRepository<Object, Serializable> repository = BeanFactoryUtils
                    .beanOfTypeIncludingAncestors(factory, objectType);

            this.domainClassToBeanName.put(information.getDomainType(), info);
            this.resourcePathToBeanName.put(getResourcePath(repositoryInterface), info);
            this.repositories.put(info, repository);

        }
    }
}

From source file:net.daum.clix.springframework.data.rest.client.repository.RestRepositories.java

/**
 * Returns the {@link EntityInformation} for the given resource path.
 * //from   w ww  .j a va  2s .  c  o m
 * @param resourcePath
 *            must not be {@literal null}.
 * @return the {@link EntityInformation} for the given resource path or
 *         {@literal null} if no repository registered for this domain
 *         class.
 */
public RepositoryInformation findRepositoryInformationFor(String resourcePath) {
    RepositoryFactoryInformation<Object, Serializable> repositoryFactoryInformation = this.resourcePathToBeanName
            .get(resourcePath);
    return repositoryFactoryInformation == null ? null
            : repositoryFactoryInformation.getRepositoryInformation();
}