AggregatedClassLoader.
| Modifier and Type | Class and Description |
|---|---|
| private static class | AggregatedServiceLoader.ClassPathAndModulePathAggregatedServiceLoader<
The type of loaded services. S>An |
| Modifier and Type | Field and Description |
|---|---|
| private static final CoreMessageLogger |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public abstract void | |
| pack-priv static <S> AggregatedServiceLoader | |
| public abstract Collection |
| log | back to summary |
|---|---|
| private static final CoreMessageLogger log | |
| AggregatedServiceLoader | back to summary |
|---|---|
| pack-priv AggregatedServiceLoader() | |
| close | back to summary |
|---|---|
| public abstract void close() Release all resources. | |
| create | back to summary |
|---|---|
| pack-priv static <S> AggregatedServiceLoader | |
| getAll | back to summary |
|---|---|
public abstract Collection
| |
AggregatedServiceLoader that will detect services defined in the class path or in the module path.
This implementation only works when running Hibernate ORM on Java 9 and above.
When retrieving services from providers in the module path, the service loader internally uses a map from classloader to service catalog. Since the aggregated class loader is artificial and unknown from the service loader, it will never match any service from the module path.
To work around this problem, we try to get services from a service loader bound to the aggregated class loader first, then we try a service loader bound to each individual class loader.
This could result in duplicates, so we take specific care to avoid using the same service provider twice.
See getAll().
Note that, in the worst case, the service retrieved from each individual class loader could load duplicate versions of classes already loaded from another class loader. For example in an aggregated class loader made up of individual class loader A, B, C: it is possible that class C1 was already loaded from A, but then we load service S1 from B, and this service will also need class C1 but won't find it in class loader B, so it will load its own version of that class.
We assume that this situation will never occur in practice because class loaders are structure in a hierarchy that prevents one class to be loaded twice.
| Modifier and Type | Field and Description |
|---|---|
| private final ServiceLoader | |
| private Collection | |
| private final List | |
| private final Class |
| Access | Constructor and Description |
|---|---|
| private | ClassPathAndModulePathAggregatedServiceLoader(AggregatedClassLoader aggregatedClassLoader, Class<S> serviceContract)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements abstract org. |
| private void | collectServiceIfNotDuplicate(Set<S> result, Set<String> alreadyEncountered, ServiceLoader.
|
| public Collection | getAll()
Implements abstract org. |
| private boolean | |
| private Collection |
| aggregatedClassLoaderServiceLoader | back to summary |
|---|---|
| private final ServiceLoader<S> aggregatedClassLoaderServiceLoader | |
| cache | back to summary |
|---|---|
| private Collection<S> cache | |
| delegates | back to summary |
|---|---|
| private final List<ServiceLoader<S>> delegates | |
| serviceContract | back to summary |
|---|---|
| private final Class<S> serviceContract | |
| ClassPathAndModulePathAggregatedServiceLoader | back to summary |
|---|---|
| private ClassPathAndModulePathAggregatedServiceLoader(AggregatedClassLoader aggregatedClassLoader, Class<S> serviceContract) | |
| close | back to summary |
|---|---|
| public void close() Implements abstract org. Doc from org. Release all resources.
| |
| collectServiceIfNotDuplicate | back to summary |
|---|---|
| private void collectServiceIfNotDuplicate(Set<S> result, Set<String> alreadyEncountered, ServiceLoader. | |
| getAll | back to summary |
|---|---|
| public Collection Implements abstract org.
| |
| hasNextIgnoringServiceConfigurationError | back to summary |
|---|---|
| private boolean hasNextIgnoringServiceConfigurationError(Iterator<?> iterator) | |
| loadAll | back to summary |
|---|---|
| private Collection | |