public AuditManager(Auditor auditor) { super(); if (auditor == null) { throw new NullPointerException("null auditor"); } setPreFlush(false); _auditor = auditor; _allTypes = new HashSet<Class<?>>(); _newTypes = new HashSet<Class<?>>(); _updateTypes = new HashSet<Class<?>>(); _deleteTypes = new HashSet<Class<?>>(); _saved = new ConcurrentHashMap<Broker, AuditCallback>(); PCRegistry.addRegisterClassListener(this); }
/** * Get the field types for a <code>PersistenceCapable</code> class. */ public static Class<?>[] getFieldTypes(Class<?> pcClass) { Meta meta = getMeta(pcClass); return meta.fieldTypes; }
/** * Return true if the given class is the least-derived persistent * implementor of the given interface, false otherwise. */ private boolean isLeastDerivedImpl(Class inter, Class cls) { Class parent = PCRegistry.getPersistentSuperclass(cls); while (parent != null) { if (Arrays.asList(parent.getInterfaces()).contains(inter)) return false; parent = PCRegistry.getPersistentSuperclass(parent); } return true; }
if (!PCRegistry.isRegistered(cls)) return false; try { String[] fieldNames = PCRegistry.getFieldNames(cls); Class<?>[] fieldTypes = PCRegistry.getFieldTypes(cls); Member member; FieldMetaData fmd;
Object oid = PCRegistry.newObjectId(meta.getDescribedType()); PrimaryKeyFieldManager producer = new PrimaryKeyFieldManager(); producer.setStore(pks); if (convert) producer.setMetaData(meta); PCRegistry.copyKeyFieldsToObjectId(meta.getDescribedType(), producer, oid); return ApplicationIds.wrap(meta, oid);
synchronized (this) { ClassMetaData meta; for (Class<?> anc = cls; (anc = PCRegistry.getPersistentSuperclass(anc)) != null;) { addToCollection(_subs, anc, cls, true); meta = (ClassMetaData) _metas.get(anc); oid = PCRegistry.newObjectId(cls); } catch (InternalException ie) { while (PCRegistry.getPersistentSuperclass(sup) != null) sup = PCRegistry.getPersistentSuperclass(sup);
ClassMetaData meta; for (Class anc = cls; (anc = PCRegistry.getPersistentSuperclass(anc)) != null;) { addToCollection(_subs, anc, cls, true); meta = (ClassMetaData) _metas.get(anc); oid = PCRegistry.newObjectId(cls); } catch (InternalException ie) { while (PCRegistry.getPersistentSuperclass(sup) != null) sup = PCRegistry.getPersistentSuperclass(sup); String alias = PCRegistry.getTypeAlias(cls); if (alias != null) { synchronized (_aliases) {
oid = new Id(attrs.getValue("oid"), _conf, null); else oid = PCRegistry.newObjectId(meta.getDescribedType(), attrs.getValue("oid"));
/** * If this is a generated subclass, look up the corresponding Class * object via metadata. */ private Class<?> lookupClass(String className) throws ClassNotFoundException { try { return Class.forName(className); } catch (ClassNotFoundException e) { if (PCEnhancer.isPCSubclassName(className)) { String superName = PCEnhancer.toManagedTypeName(className); ClassMetaData[] metas = conf.getMetaDataRepositoryInstance() .getMetaDatas(); for (int i = 0; i < metas.length; i++) { if (superName.equals( metas[i].getDescribedType().getName())) { return PCRegistry.getPCType( metas[i].getDescribedType()); } } // if it's not found, try to look for it anyways return Class.forName(className); } else { throw e; } } } }
PCRegistry.copyKeyFieldsFromObjectId(meta.getDescribedType(), consumer, oid); return consumer.getStore();
/** * Register the given class to the list of known aliases. * The alias is registered only if the class has been enhanced. * */ void registerAlias(Class<?> cls) { registerAlias(PCRegistry.getTypeAlias(cls), cls); }
if (!PCRegistry.isRegistered(cls)) return false; try { String[] fieldNames = PCRegistry.getFieldNames(cls); Class<?>[] fieldTypes = PCRegistry.getFieldTypes(cls); Member member; FieldMetaData fmd;
Object oid = PCRegistry.newObjectId(meta.getDescribedType()); PrimaryKeyFieldManager producer = new PrimaryKeyFieldManager(); producer.setStore(pks); if (convert) producer.setMetaData(meta); PCRegistry.copyKeyFieldsToObjectId(meta.getDescribedType(), producer, oid); return ApplicationIds.wrap(meta, oid);
synchronized (this) { ClassMetaData meta; for (Class<?> anc = cls; (anc = PCRegistry.getPersistentSuperclass(anc)) != null;) { addToCollection(_subs, anc, cls, true); meta = (ClassMetaData) _metas.get(anc); oid = PCRegistry.newObjectId(cls); } catch (InternalException ie) { while (PCRegistry.getPersistentSuperclass(sup) != null) sup = PCRegistry.getPersistentSuperclass(sup);
oid = new Id(attrs.getValue("oid"), _conf, null); else oid = PCRegistry.newObjectId(meta.getDescribedType(), attrs.getValue("oid"));
/** * If this is a generated subclass, look up the corresponding Class * object via metadata. */ private Class<?> lookupClass(String className) throws ClassNotFoundException { try { return Class.forName(className); } catch (ClassNotFoundException e) { if (PCEnhancer.isPCSubclassName(className)) { String superName = PCEnhancer.toManagedTypeName(className); ClassMetaData[] metas = conf.getMetaDataRepositoryInstance() .getMetaDatas(); for (int i = 0; i < metas.length; i++) { if (superName.equals( metas[i].getDescribedType().getName())) { return PCRegistry.getPCType( metas[i].getDescribedType()); } } // if it's not found, try to look for it anyways return Class.forName(className); } else { throw e; } } } }
consumer.setStore(pks); oid = wrap(meta, oid); PCRegistry.copyKeyFieldsFromObjectId(meta.getDescribedType(), consumer, oid); return consumer.getStore();
/** * Register the given class to the list of known aliases. * The alias is registered only if the class has been enhanced. * */ void registerAlias(Class<?> cls) { registerAlias(PCRegistry.getTypeAlias(cls), cls); }
if (!PCRegistry.isRegistered(cls)) return false; try { String[] fieldNames = PCRegistry.getFieldNames(cls); Class<?>[] fieldTypes = PCRegistry.getFieldTypes(cls); Member member; FieldMetaData fmd;
/** * Return the persistent superclass for a <code>PersistenceCapable</code> * class, or null if none. The superclass may or may not implement * {@link PersistenceCapable}, depending on the access type of the class. */ public static Class<?> getPersistentSuperclass(Class<?> pcClass) { Meta meta = getMeta(pcClass); return meta.pcSuper; }