Class ClassWorld

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    ClassWorldReverseAdapter

    public class ClassWorld
    extends java.lang.Object
    implements java.io.Closeable
    A collection of ClassRealms, indexed by id.
    Author:
    bob mcwhirter
    • Constructor Detail

      • ClassWorld

        public ClassWorld​(java.lang.String realmId,
                          java.lang.ClassLoader classLoader)
      • ClassWorld

        public ClassWorld()
    • Method Detail

      • newRealm

        public ClassRealm newRealm​(java.lang.String id,
                                   java.lang.ClassLoader classLoader,
                                   java.util.function.Predicate<java.lang.String> filter)
                            throws DuplicateRealmException
        Adds a class realm with filtering. Only resources/classes whose name matches a given predicate are exposed.
        Parameters:
        id - The identifier for this realm, must not be null.
        classLoader - The base class loader for this realm, may be null to use the bootstrap class loader.
        filter - a predicate to apply to each resource name to determine if it should be loaded through this class loader
        Returns:
        the created class realm
        Throws:
        DuplicateRealmException - in case a realm with the given id does already exist
        Since:
        2.7.0
        See Also:
        FilteredClassRealm
      • close

        public void close()
                   throws java.io.IOException
        Closes all contained class realms.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
        Since:
        2.7.0
      • getRealms

        public java.util.Collection<ClassRealm> getRealms()
      • getClassRealm

        public ClassRealm getClassRealm​(java.lang.String id)