private ClassLoader makeAggregatedClassLoader ( ClassLoader globalClassLoader ) { // use an ordered set to deduplicate them Set < ClassLoader > classLoaders = new LinkedHashSet <> ( 6 ) ; // add the cache manager's CL if ( globalClassLoader != null ) { classLoaders . add ( globalClassLoader ) ; } // add Infinispan's CL classLoaders . add ( AggregatedClassLoader . class . getClassLoader ( ) ) ; // add Hibernate Search's CL classLoaders . add ( ClassLoaderService . class . getClassLoader ( ) ) ; // add this module's CL classLoaders . add ( getClass ( ) . getClassLoader ( ) ) ; // add the TCCL try { ClassLoader tccl = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( tccl != null ) { classLoaders . add ( tccl ) ; } } catch ( Exception e ) { // ignored } // add the system CL try { ClassLoader syscl = ClassLoader . getSystemClassLoader ( ) ; if ( syscl != null ) { classLoaders . add ( syscl ) ; } } catch ( Exception e ) { // ignored } return new AggregatedClassLoader ( classLoaders ) ; }
Create a class loader that delegates loading to an ordered set of class loaders .