Class PCRegistry


  • public class PCRegistry
    extends java.lang.Object
    Tracks registered persistence-capable classes.
    Since:
    0.4.0
    Author:
    Abe White
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  PCRegistry.RegisterClassListener
      Listener for persistent class registration events.
    • Constructor Summary

      Constructors 
      Constructor Description
      PCRegistry()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addRegisterClassListener​(PCRegistry.RegisterClassListener rcl)
      static void copyKeyFieldsFromObjectId​(java.lang.Class<?> pcClass, FieldConsumer fm, java.lang.Object oid)
      Copy fields to an outside source from the key fields in the identity object.
      static void copyKeyFieldsToObjectId​(java.lang.Class<?> pcClass, FieldSupplier fm, java.lang.Object oid)
      Copy fields from an outside source to the key fields in the identity object.
      static void deRegister​(java.lang.ClassLoader cl)
      De-Register all metadata associated with the given ClassLoader.
      static java.lang.String[] getFieldNames​(java.lang.Class<?> pcClass)
      Get the field names for a PersistenceCapable class.
      static java.lang.Class<?>[] getFieldTypes​(java.lang.Class<?> pcClass)
      Get the field types for a PersistenceCapable class.
      static java.lang.Class<?> getPCType​(java.lang.Class<?> type)
      Return the persistence-capable type for type.
      static java.lang.Class<?> getPersistentSuperclass​(java.lang.Class<?> pcClass)
      Return the persistent superclass for a PersistenceCapable class, or null if none.
      static java.util.Collection<java.lang.Class<?>> getRegisteredTypes()
      Returns a collection of class objects of the registered persistence-capable classes.
      static java.lang.String getTypeAlias​(java.lang.Class<?> pcClass)
      Return the alias for the given type.
      static boolean isRegistered​(java.lang.Class<?> cls)
      Returns true if the given class is already registered.
      static PersistenceCapable newInstance​(java.lang.Class<?> pcClass, StateManager sm, boolean clear)
      Create a new instance of the class and assign its state manager.
      static PersistenceCapable newInstance​(java.lang.Class<?> pcClass, StateManager sm, java.lang.Object oid, boolean clear)
      Create a new instance of the class and assign its state manager and oid.
      static java.lang.Object newObjectId​(java.lang.Class<?> pcClass)
      Create a new identity object for the given PersistenceCapable class.
      static java.lang.Object newObjectId​(java.lang.Class<?> pcClass, java.lang.String str)
      Create a new identity object for the given PersistenceCapable class, using the String form of the constructor.
      static void register​(java.lang.Class<?> pcClass, java.lang.String[] fieldNames, java.lang.Class<?>[] fieldTypes, byte[] fieldFlags, java.lang.Class<?> sup, java.lang.String alias, PersistenceCapable pc)
      Register metadata by class.
      static boolean removeRegisterClassListener​(PCRegistry.RegisterClassListener rcl)
      • Methods inherited from class java.lang.Object

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

      • PCRegistry

        public PCRegistry()
    • Method Detail

      • getFieldNames

        public static java.lang.String[] getFieldNames​(java.lang.Class<?> pcClass)
        Get the field names for a PersistenceCapable class.
      • getFieldTypes

        public static java.lang.Class<?>[] getFieldTypes​(java.lang.Class<?> pcClass)
        Get the field types for a PersistenceCapable class.
      • getPersistentSuperclass

        public static java.lang.Class<?> getPersistentSuperclass​(java.lang.Class<?> pcClass)
        Return the persistent superclass for a PersistenceCapable class, or null if none. The superclass may or may not implement PersistenceCapable, depending on the access type of the class.
      • newInstance

        public static PersistenceCapable newInstance​(java.lang.Class<?> pcClass,
                                                     StateManager sm,
                                                     boolean clear)
        Create a new instance of the class and assign its state manager. The new instance has its flags set to LOAD_REQUIRED.
      • newInstance

        public static PersistenceCapable newInstance​(java.lang.Class<?> pcClass,
                                                     StateManager sm,
                                                     java.lang.Object oid,
                                                     boolean clear)
        Create a new instance of the class and assign its state manager and oid. The new instance has its flags set to LOAD_REQUIRED.
      • getPCType

        public static java.lang.Class<?> getPCType​(java.lang.Class<?> type)
        Return the persistence-capable type for type. This might be a generated subclass of type.
        Since:
        1.1.0
      • newObjectId

        public static java.lang.Object newObjectId​(java.lang.Class<?> pcClass)
        Create a new identity object for the given PersistenceCapable class.
      • newObjectId

        public static java.lang.Object newObjectId​(java.lang.Class<?> pcClass,
                                                   java.lang.String str)
        Create a new identity object for the given PersistenceCapable class, using the String form of the constructor.
      • getTypeAlias

        public static java.lang.String getTypeAlias​(java.lang.Class<?> pcClass)
        Return the alias for the given type.
      • copyKeyFieldsToObjectId

        public static void copyKeyFieldsToObjectId​(java.lang.Class<?> pcClass,
                                                   FieldSupplier fm,
                                                   java.lang.Object oid)
        Copy fields from an outside source to the key fields in the identity object.
      • copyKeyFieldsFromObjectId

        public static void copyKeyFieldsFromObjectId​(java.lang.Class<?> pcClass,
                                                     FieldConsumer fm,
                                                     java.lang.Object oid)
        Copy fields to an outside source from the key fields in the identity object.
      • register

        public static void register​(java.lang.Class<?> pcClass,
                                    java.lang.String[] fieldNames,
                                    java.lang.Class<?>[] fieldTypes,
                                    byte[] fieldFlags,
                                    java.lang.Class<?> sup,
                                    java.lang.String alias,
                                    PersistenceCapable pc)
        Register metadata by class.
        Parameters:
        fieldTypes - managed field types
        fieldFlags - managed field flags
        sup - the most immediate persistent superclass
        pcClass - the PersistenceCapable class
        fieldNames - managed field names
        alias - the class alias
        pc - an instance of the class, if not abstract
      • deRegister

        public static void deRegister​(java.lang.ClassLoader cl)
        De-Register all metadata associated with the given ClassLoader. Allows ClassLoaders to be garbage collected.
        Parameters:
        cl - the ClassLoader
      • getRegisteredTypes

        public static java.util.Collection<java.lang.Class<?>> getRegisteredTypes()
        Returns a collection of class objects of the registered persistence-capable classes.
      • isRegistered

        public static boolean isRegistered​(java.lang.Class<?> cls)
        Returns true if the given class is already registered.