/** * Method called when a method of the class is visited. * * @param access Access for the method * @param name Name of the method * @param desc Descriptor * @param signature Signature * @param exceptions Exceptions that this method is declared to throw * @return Visitor to visit this (or null if not wanting to visit it) */ public MethodVisitor visitMethod( int access, String name, String desc, String signature, String[] exceptions) { if (name.equals("<init>") && desc != null && desc.equals("()V")) { // Check for default constructor hasDefaultConstructor = true; } if (name.equals("writeObject") && desc != null && desc.equals("(Ljava/io/ObjectOutputStream;)V")) { // Has writeObject() for use in serialisation hasWriteObject = true; } if (name.equals("<clinit>") && desc != null && desc.equals("()V")) { hasStaticInitialisation = true; } MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions); if (mv == null) { return null; } if (name.equals("jdoPreClear") || name.equals("jdoPostLoad")) { // jdoPreClear/jdoPostLoad should not be enhanced (JDO2 spec [10.1, 10.3] return mv; } else if (name.equals("readObject") && (desc.equals("(Ljava/io/ObjectOutputStream;)V") || desc.equals("(Ljava/io/ObjectInputStream;)V"))) { // readObject(ObjectInputStream), readObject(ObjectOutputStream) should not be enhanced (JDO2 // spec [21.6]) return mv; } String propGetterName = ClassUtils.getFieldNameForJavaBeanGetter(name); String propSetterName = ClassUtils.getFieldNameForJavaBeanSetter(name); if (propGetterName != null) { AbstractMemberMetaData mmd = enhancer.getClassMetaData().getMetaDataForMember(propGetterName); if (mmd != null && mmd instanceof PropertyMetaData && mmd.getPersistenceModifier() != FieldPersistenceModifier.NONE) { // Property getter method "getXXX" - generated dnGetXXX return new EnhancerPropertyGetterAdapter(mv, enhancer, name, desc, mmd, cv); } } else if (propSetterName != null) { AbstractMemberMetaData mmd = enhancer.getClassMetaData().getMetaDataForMember(propSetterName); if (mmd != null && mmd instanceof PropertyMetaData && mmd.getPersistenceModifier() != FieldPersistenceModifier.NONE) { // Property setter method "setXXX" - generates dnSetXXX return new EnhancerPropertySetterAdapter(mv, enhancer, name, desc, mmd, cv); } } // normal method, so just enhance it return new EnhancerMethodAdapter(mv, enhancer, name, desc); }
/** * Constructor, using the ObjectProvider of the "owner" and the field name. * * @param op The owner ObjectProvider * @param mmd Metadata for the member */ public Map(ObjectProvider op, AbstractMemberMetaData mmd) { super(op, mmd); // Set up our "delegate" this.delegate = new java.util.HashMap(); ExecutionContext ec = ownerOP.getExecutionContext(); allowNulls = SCOUtils.allowNullsInContainer(allowNulls, mmd); useCache = SCOUtils.useContainerCache(ownerOP, mmd); if (!SCOUtils.mapHasSerialisedKeysAndValues(mmd) && mmd.getPersistenceModifier() == FieldPersistenceModifier.PERSISTENT) { ClassLoaderResolver clr = ec.getClassLoaderResolver(); this.backingStore = (MapStore) ((BackedSCOStoreManager) ownerOP.getStoreManager()) .getBackingStoreForField(clr, mmd, java.util.Map.class); } if (NucleusLogger.PERSISTENCE.isDebugEnabled()) { NucleusLogger.PERSISTENCE.debug( SCOUtils.getContainerInfoMessage( ownerOP, ownerMmd.getName(), this, useCache, allowNulls, SCOUtils.useCachedLazyLoading(ownerOP, ownerMmd))); } }
/** * Constructor, using the ObjectProvider of the "owner" and the field name. * * @param op The owner ObjectProvider * @param mmd Metadata for the member */ public ArrayList(ObjectProvider op, AbstractMemberMetaData mmd) { super(op, mmd); // Set up our delegate this.delegate = new java.util.ArrayList(); ExecutionContext ec = op.getExecutionContext(); allowNulls = SCOUtils.allowNullsInContainer(allowNulls, mmd); queued = ec.isDelayDatastoreOperationsEnabled(); useCache = SCOUtils.useContainerCache(op, mmd); if (!SCOUtils.collectionHasSerialisedElements(mmd) && mmd.getPersistenceModifier() == FieldPersistenceModifier.PERSISTENT) { ClassLoaderResolver clr = ec.getClassLoaderResolver(); this.backingStore = (ListStore) ((BackedSCOStoreManager) op.getStoreManager()) .getBackingStoreForField(clr, mmd, java.util.ArrayList.class); } if (NucleusLogger.PERSISTENCE.isDebugEnabled()) { NucleusLogger.PERSISTENCE.debug( SCOUtils.getContainerInfoMessage( op, ownerMmd.getName(), this, useCache, queued, allowNulls, SCOUtils.useCachedLazyLoading(op, ownerMmd))); } }
/** * Constructor. * * @param tableName The Table SQL identifier * @param mmd Member meta data for the owner field/property * @param storeMgr Manager for the datastore. */ protected JoinTable( DatastoreIdentifier tableName, AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr) { super(tableName, storeMgr); this.mmd = mmd; this.ownerType = mmd.getClassName(true); if (mmd.getPersistenceModifier() == FieldPersistenceModifier.NONE) { throw new NucleusException(Localiser.msg("057006", mmd.getName())).setFatal(); } }