Tracks registered persistence-capable classes.
| Method from org.apache.openjpa.enhance.PCRegistry Detail: |
public static void addRegisterClassListener(PCRegistry.RegisterClassListener rcl) {
if (rcl == null)
return;
// we have to be positive that every listener gets notified for
// every class, so lots of locking
synchronized (_listeners) {
_listeners.add(rcl);
}
synchronized (_metas) {
for (Iterator itr = _metas.keySet().iterator(); itr.hasNext();)
rcl.register((Class) itr.next());
}
}
|
public static void copyKeyFieldsFromObjectId(Class pcClass,
FieldConsumer fm,
Object oid) {
Meta meta = getMeta(pcClass);
if (meta.pc == null)
throw new UserException(_loc.get("copy-no-id", pcClass));
meta.pc.pcCopyKeyFieldsFromObjectId(fm, oid);
}
Copy fields to an outside source from the key fields in the identity
object. |
public static void copyKeyFieldsToObjectId(Class pcClass,
FieldSupplier fm,
Object oid) {
Meta meta = getMeta(pcClass);
if (meta.pc == null)
throw new UserException(_loc.get("copy-no-id", pcClass));
meta.pc.pcCopyKeyFieldsToObjectId(fm, oid);
}
Copy fields from an outside source to the key fields in the identity
object. |
public static void deRegister(ClassLoader cl) {
synchronized (_metas) {
for (Iterator i = _metas.keySet().iterator(); i.hasNext();) {
Class pcClass = (Class) i.next();
if (pcClass.getClassLoader() == cl) {
_metas.remove(pcClass);
}
}
}
}
De-Register all metadata associated with the given ClassLoader.
Allows ClassLoaders to be garbage collected. |
public static String[] getFieldNames(Class pcClass) {
Meta meta = getMeta(pcClass);
return meta.fieldNames;
}
Get the field names for a PersistenceCapable class. |
public static Class[] getFieldTypes(Class pcClass) {
Meta meta = getMeta(pcClass);
return meta.fieldTypes;
}
Get the field types for a PersistenceCapable class. |
public static Class getPCType(Class type) {
Meta meta = getMeta(type);
return (meta.pc == null) ? null : meta.pc.getClass();
}
Return the persistence-capable type for type. This might
be a generated subclass of type. |
public static Class getPersistentSuperclass(Class pcClass) {
Meta meta = getMeta(pcClass);
return meta.pcSuper;
}
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. |
public static Collection getRegisteredTypes() {
return Collections.unmodifiableCollection(_metas.keySet());
}
Returns a collection of class objects of the registered
persistence-capable classes. |
public static String getTypeAlias(Class pcClass) {
return getMeta(pcClass).alias;
}
Return the alias for the given type. |
public static boolean isRegistered(Class cls) {
return _metas.containsKey(cls);
}
Returns true if cls is already registered. |
public static PersistenceCapable newInstance(Class pcClass,
StateManager sm,
boolean clear) {
Meta meta = getMeta(pcClass);
return (meta.pc == null) ? null : meta.pc.pcNewInstance(sm, clear);
}
Create a new instance of the class and assign its state manager.
The new instance has its flags set to LOAD_REQUIRED. |
public static PersistenceCapable newInstance(Class pcClass,
StateManager sm,
Object oid,
boolean clear) {
Meta meta = getMeta(pcClass);
return (meta.pc == null) ? null : meta.pc.pcNewInstance(sm, oid, 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. |
public static Object newObjectId(Class pcClass) {
Meta meta = getMeta(pcClass);
return (meta.pc == null) ? null : meta.pc.pcNewObjectIdInstance();
}
Create a new identity object for the given
PersistenceCapable class. |
public static Object newObjectId(Class pcClass,
String str) {
Meta meta = getMeta(pcClass);
return (meta.pc == null) ? null : meta.pc.pcNewObjectIdInstance(str);
}
Create a new identity object for the given
PersistenceCapable class, using the String
form of the constructor. |
public static void register(Class pcClass,
String[] fieldNames,
Class[] fieldTypes,
byte[] fieldFlags,
Class sup,
String alias,
PersistenceCapable pc) {
if (pcClass == null)
throw new NullPointerException();
// we have to be positive that every listener gets notified for
// every class, so lots of locking
Meta meta = new Meta(pc, fieldNames, fieldTypes, sup, alias);
synchronized (_metas) {
_metas.put(pcClass, meta);
}
synchronized (_listeners) {
for (Iterator i = _listeners.iterator(); i.hasNext();)
((RegisterClassListener) i.next()).register(pcClass);
}
}
Register metadata by class. |
public static void removeRegisterClassListener(PCRegistry.RegisterClassListener rcl) {
synchronized (_listeners) {
_listeners.remove(rcl);
}
}
|