/
IntegratorServiceImpl.java
54 lines (44 loc) · 1.79 KB
/
IntegratorServiceImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.integrator.internal;
import java.util.LinkedHashSet;
import org.hibernate.boot.beanvalidation.BeanValidationIntegrator;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.cache.internal.CollectionCacheInvalidator;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.integrator.spi.IntegratorService;
import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
public class IntegratorServiceImpl implements IntegratorService {
private static final Logger LOG = Logger.getLogger( IntegratorServiceImpl.class.getName() );
private final LinkedHashSet<Integrator> integrators = new LinkedHashSet<>();
public IntegratorServiceImpl(LinkedHashSet<Integrator> providedIntegrators, ClassLoaderService classLoaderService) {
// register standard integrators. Envers and JPA, for example, need to be handled by discovery because in
// separate project/jars.
addIntegrator( new BeanValidationIntegrator() );
addIntegrator( new CollectionCacheInvalidator() );
// register provided integrators
for ( Integrator integrator : providedIntegrators ) {
addIntegrator( integrator );
}
for ( Integrator integrator : classLoaderService.loadJavaServices( Integrator.class ) ) {
addIntegrator( integrator );
}
}
private void addIntegrator(Integrator integrator) {
if ( LOG.isDebugEnabled() ) {
LOG.debugf( "Adding Integrator [%s].", integrator.getClass().getName() );
}
integrators.add( integrator );
}
@Override
public Iterable<Integrator> getIntegrators() {
return integrators;
}
}