Java 类org.hibernate.service.spi.InjectService 实例源码

项目:lams    文件:AbstractServiceRegistryImpl.java   
private <R extends Service> void applyInjections(R service) {
    try {
        for ( Method method : service.getClass().getMethods() ) {
            InjectService injectService = method.getAnnotation( InjectService.class );
            if ( injectService == null ) {
                continue;
            }

            processInjection( service, method, injectService );
        }
    }
    catch (NullPointerException e) {
           log.error( "NPE injecting service deps : " + service.getClass().getName() );
    }
}
项目:lams    文件:AbstractServiceRegistryImpl.java   
@SuppressWarnings({ "unchecked" })
private <T extends Service> void processInjection(T service, Method injectionMethod, InjectService injectService) {
    if ( injectionMethod.getParameterTypes() == null || injectionMethod.getParameterTypes().length != 1 ) {
        throw new ServiceDependencyException(
                "Encountered @InjectService on method with unexpected number of parameters"
        );
    }

    Class dependentServiceRole = injectService.serviceRole();
    if ( dependentServiceRole == null || dependentServiceRole.equals( Void.class ) ) {
        dependentServiceRole = injectionMethod.getParameterTypes()[0];
    }

    // todo : because of the use of proxies, this is no longer returning null here...

    final Service dependantService = getService( dependentServiceRole );
    if ( dependantService == null ) {
        if ( injectService.required() ) {
            throw new ServiceDependencyException(
                    "Dependency [" + dependentServiceRole + "] declared by service [" + service + "] not found"
            );
        }
    }
    else {
        try {
            injectionMethod.invoke( service, dependantService );
        }
        catch ( Exception e ) {
            throw new ServiceDependencyException( "Cannot inject dependency service", e );
        }
    }
}
项目:lams    文件:DatasourceConnectionProviderImpl.java   
@InjectService( required = false )
@SuppressWarnings("UnusedDeclaration")
public void setJndiService(JndiService jndiService) {
    this.jndiService = jndiService;
}
项目:lams    文件:StandardRefCursorSupport.java   
/**
 * Hook for service registry to be able to inject JdbcServices
 *
 * @param jdbcServices The JdbcServices service
 */
@InjectService
@SuppressWarnings("UnusedDeclaration")
public void injectJdbcServices(JdbcServices jdbcServices) {
    this.jdbcServices = jdbcServices;
}
项目:sdcct    文件:DbMetadataServiceImpl.java   
@InjectService
@Override
public void setEntityManagerFactory(EntityManagerFactoryRef entityManagerFactoryRef) {
    this.entityManagerFactory = entityManagerFactoryRef.getEntityManagerFactory();
}
项目:sdcct    文件:DbMetadataServiceImpl.java   
@InjectService
@Override
public void setMetadata(MetadataRef metadataRef) {
    this.metadata = metadataRef.getMetadata();
}
项目:sdcct    文件:DbMetadataServiceImpl.java   
@InjectService
@Override
public void setSearchIntegrator(SearchFactoryReference searchFactoryRef) {
    this.searchIntegrator = searchFactoryRef.getSearchIntegrator();
}