Class JCasRegistry


  • public class JCasRegistry
    extends java.lang.Object
    Maintains a registry of JCas cover classes that have been loaded in order to be able to assign a unique low-value positive int index to each loaded JCas class. Note that the same JCas class loaded under two different class loaders may get two different numbers. The internals maintain a weak reference to the loaded class in order to allow the index value to be reused if the associated JCas class is garbaged collected. This could happen if the JCas classes are loaded under a class loader which is a child of the class loader of this framework class, and that child classloader later gets GC'd. The register method is called from JCas cover class static initialization and returns the unique index value for this class. The associated int index is used in a lookup on a jcas registry array associated with a particular type system, to get the associated Type. This supports the use cases of - different type systems being used with the same loaded JCas classes, either -- sequentially by a single instance of UIMA or -- multiple instances of pipelines running in one JVM each with different type systems
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  JCasRegistry.WeakRefInt<T>
      A WeakReference class holding - a ref to a JCas class - an assigned int for that class
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.ArrayList<JCasRegistry.WeakRefInt<java.lang.Class<? extends TOP>>> loadedJCasClasses
      The argument say the type is a class, which extends TOP
      private static java.lang.ref.ReferenceQueue<java.lang.Class<? extends TOP>> releasedQueue  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private JCasRegistry()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Class<? extends TOP> getClassForIndex​(int aIndex)
      Used for error message: When a particular loaded type system is missing the type that corresponds to a loaded JCas class (perhaps that class was loaded when another type system was being used, or it was just referred to in Java code (which causes it to be loaded) then the error message uses this to get the class to be able to print the class name Gets the JCas cover class for a given index.
      static boolean getFeatOkTst​(java.lang.String fullyQualTypeName)
      For a particular type, return true if that type should have run-time checking for use of fields defined in the JCas Model which are not present in the CAS.
      static int getNumberOfRegisteredClasses()
      NOT CURRENTLY USED Gets the number of cover classes that have been registered.
      static int register​(java.lang.Class<? extends TOP> aJCasCoverClass)
      Registers a JCas cover class with this registry.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • loadedJCasClasses

        private static final java.util.ArrayList<JCasRegistry.WeakRefInt<java.lang.Class<? extends TOP>>> loadedJCasClasses
        The argument say the type is a class, which extends TOP
      • releasedQueue

        private static final java.lang.ref.ReferenceQueue<java.lang.Class<? extends TOP>> releasedQueue
    • Constructor Detail

      • JCasRegistry

        private JCasRegistry()
    • Method Detail

      • register

        public static int register​(java.lang.Class<? extends TOP> aJCasCoverClass)
        Registers a JCas cover class with this registry. The registry will assign it a unique index, which is then used by the cover-class to identify itself to the JCas implementation. Before adding the class to the array list, see if there are any "free" slots in the array list
        Parameters:
        aJCasCoverClass - the class to register
        Returns:
        the unique index value for this class.
      • getFeatOkTst

        public static boolean getFeatOkTst​(java.lang.String fullyQualTypeName)
        For a particular type, return true if that type should have run-time checking for use of fields defined in the JCas Model which are not present in the CAS. If false, all fields in the JCas must be in the CAS type system at instantiation time, or an exception is thrown; this allows the runtime to skip this test.

        This is reserved for future use; it currently always returns true.

        Parameters:
        fullyQualTypeName - fully qualified type name
        Returns:
        true if that type should have run-time checking for use of fields defined in the JCas Model which are not present in the CAS. If false, all fields in the JCas must be in the CAS type system at instantiation time, or an exception is thrown; this allows the runtime to skip this test.
      • getNumberOfRegisteredClasses

        public static int getNumberOfRegisteredClasses()
        NOT CURRENTLY USED Gets the number of cover classes that have been registered.
        Returns:
        the number of registered JCas cover classes
      • getClassForIndex

        public static java.lang.Class<? extends TOP> getClassForIndex​(int aIndex)
        Used for error message: When a particular loaded type system is missing the type that corresponds to a loaded JCas class (perhaps that class was loaded when another type system was being used, or it was just referred to in Java code (which causes it to be loaded) then the error message uses this to get the class to be able to print the class name Gets the JCas cover class for a given index.
        Parameters:
        aIndex - the index
        Returns:
        the JCas cover class that was assigned the value aIndex during its registration, null if none.