org.apache.openjpa.persistence
Class PersistenceMetaDataDefaults

java.lang.Object
  extended by org.apache.openjpa.meta.AbstractMetaDataDefaults
      extended by org.apache.openjpa.persistence.PersistenceMetaDataDefaults
All Implemented Interfaces:
CallbackModes, MetaDataDefaults

public class PersistenceMetaDataDefaults
extends AbstractMetaDataDefaults

JPA-based metadata defaults.

Author:
Patrick Linskey, Abe White, Pinaki Poddar

Nested Class Summary
(package private) static class PersistenceMetaDataDefaults.AccessFilter
          Selects elements which is annotated with @Access annotation and that annotation has the given AccessType value.
(package private) static class PersistenceMetaDataDefaults.AnnotatedFilter
          Selects all element annotated with javax.persistence.* or org.apache.openjpa.* annotation except the annotations marked to be ignored.
(package private) static class PersistenceMetaDataDefaults.GetterFilter
          Selects getter method.
(package private) static class PersistenceMetaDataDefaults.MemberFilter
          Selects elements which is annotated with @Access annotation and that annotation has the given AccessType value.
(package private) static class PersistenceMetaDataDefaults.SetterFilter
          Selects setter method.
(package private) static class PersistenceMetaDataDefaults.TransientFilter
          Selects non-transient elements.
 
Field Summary
protected  PersistenceMetaDataDefaults.AnnotatedFilter annotatedFilter
           
protected  PersistenceMetaDataDefaults.AccessFilter fieldAccessFilter
           
protected  PersistenceMetaDataDefaults.MemberFilter fieldFilter
           
protected  PersistenceMetaDataDefaults.GetterFilter getterFilter
           
protected  PersistenceMetaDataDefaults.MemberFilter methodFilter
           
protected  PersistenceMetaDataDefaults.TransientFilter nonTransientFilter
           
protected  PersistenceMetaDataDefaults.AccessFilter propertyAccessFilter
          Set of Inclusion Filters based on member type, access type or transient annotations.
protected  PersistenceMetaDataDefaults.SetterFilter setterFilter
           
 
Fields inherited from interface org.apache.openjpa.event.CallbackModes
CALLBACK_FAIL_FAST, CALLBACK_IGNORE, CALLBACK_LOG, CALLBACK_RETHROW, CALLBACK_ROLLBACK
 
Constructor Summary
PersistenceMetaDataDefaults()
           
 
Method Summary
(package private)  void assertNoDuplicate(List<Field> fields, List<Method> getters)
           
(package private)  void error(ClassMetaData meta, Localizer.Message message)
           
(package private)
<T extends AnnotatedElement>
List<T>
filter(List<T> list, org.apache.openjpa.persistence.PersistenceMetaDataDefaults.InclusiveFilter... filters)
           
(package private)
<T extends AnnotatedElement>
List<T>
filter(T[] array, org.apache.openjpa.persistence.PersistenceMetaDataDefaults.InclusiveFilter... filters)
          Filter the given collection with the conjunction of filters.
(package private)  ClassMetaData getCachedSuperclassMetaData(ClassMetaData meta)
           
protected  List<String> getFieldAccessNames(ClassMetaData meta)
          Return the list of fields in meta that use field access, or null if a list of fields is unobtainable.
 Member getMemberByProperty(ClassMetaData meta, String property, int access, boolean applyDefaultRule)
          Gets either the instance field or the getter method depending upon the access style of the given meta-data.
static PersistenceStrategy getPersistenceStrategy(FieldMetaData fmd, Member member)
          Return the code for the strategy of the given member.
static PersistenceStrategy getPersistenceStrategy(FieldMetaData fmd, Member member, boolean ignoreTransient)
          Return the code for the strategy of the given member.
(package private)  List<Field> getPersistentFields(ClassMetaData meta, boolean ignoreTransient)
          Gets the fields that are possible candidate for being persisted.
 List<Member> getPersistentMembers(ClassMetaData meta, boolean ignoreTransient)
          Gets the members that are backing members for attributes being persisted.
(package private)  List<Method> getPersistentMethods(ClassMetaData meta, boolean ignoreTransient)
          Gets the methods that are possible candidate for being persisted.
protected  List<String> getPropertyAccessNames(ClassMetaData meta)
          Return the list of methods in meta that use property access, or null if a list of methods is unobtainable.
 boolean isAbstractMappingUniDirectional(OpenJPAConfiguration conf)
          Whether the relationship in MappedSuper class must be uni-directional.
protected  boolean isDefaultPersistent(ClassMetaData meta, Member member, String name)
           
protected  boolean isDefaultPersistent(ClassMetaData meta, Member member, String name, boolean ignoreTransient)
          Return true if the given member is persistent by default.
 boolean isNonDefaultMappingAllowed(OpenJPAConfiguration conf)
          Whether non-default mapping is allowed.
 void populate(ClassMetaData meta, int access)
          Populates the given class metadata.
 void populate(ClassMetaData meta, int access, boolean ignoreTransient)
          Populates the given class metadata.
protected  void populate(FieldMetaData fmd)
           
 void setAbstractMappingUniDirectional(OpenJPAConfiguration conf)
           
(package private) static void setCascadeNone(ValueMetaData vmd)
          Turns off auto cascading of persist, refresh, attach, detach.
 void setDefaultAccessType(String type)
          Auto-configuration method for the default access type of base classes with ACCESS_UNKNOWN
 void setNonDefaultMappingAllowed(OpenJPAConfiguration conf)
           
(package private)  String toFieldNames(List<Field> fields)
           
(package private)  String toMethodNames(List<Method> methods)
           
(package private)  void trace(ClassMetaData meta, Localizer.Message message)
           
(package private)  void warn(ClassMetaData meta, Localizer.Message message)
           
 
Methods inherited from class org.apache.openjpa.meta.AbstractMetaDataDefaults
getBackingMember, getCallbackMode, getCallbacksBeforeListeners, getDefaultAccessType, getDefaultIdentityType, getFieldName, getIgnoreNonPersistent, getUnimplementedExceptionType, getUsePCRegistry, isBoolean, isBooleanGetter, isDataStoreObjectIdFieldUnwrapped, isDeclaredInterfacePersistent, isGetter, isNormalGetter, isReservedFieldName, isUserDefined, setCallbackMode, setCallbackMode, setDataStoreObjectIdFieldUnwrapped, setDeclaredInterfacePersistent, setDefaultAccessType, setDefaultIdentityType, setIgnoreNonPersistent, setUsePCRegistry, startsWith, toNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyAccessFilter

protected PersistenceMetaDataDefaults.AccessFilter propertyAccessFilter
Set of Inclusion Filters based on member type, access type or transient annotations. Used to determine the persistent field/methods.


fieldAccessFilter

protected PersistenceMetaDataDefaults.AccessFilter fieldAccessFilter

fieldFilter

protected PersistenceMetaDataDefaults.MemberFilter fieldFilter

methodFilter

protected PersistenceMetaDataDefaults.MemberFilter methodFilter

nonTransientFilter

protected PersistenceMetaDataDefaults.TransientFilter nonTransientFilter

annotatedFilter

protected PersistenceMetaDataDefaults.AnnotatedFilter annotatedFilter

getterFilter

protected PersistenceMetaDataDefaults.GetterFilter getterFilter

setterFilter

protected PersistenceMetaDataDefaults.SetterFilter setterFilter
Constructor Detail

PersistenceMetaDataDefaults

public PersistenceMetaDataDefaults()
Method Detail

getPersistenceStrategy

public static PersistenceStrategy getPersistenceStrategy(FieldMetaData fmd,
                                                         Member member)
Return the code for the strategy of the given member. Return null if no strategy.


getPersistenceStrategy

public static PersistenceStrategy getPersistenceStrategy(FieldMetaData fmd,
                                                         Member member,
                                                         boolean ignoreTransient)
Return the code for the strategy of the given member. Return null if no strategy.


setDefaultAccessType

public void setDefaultAccessType(String type)
Auto-configuration method for the default access type of base classes with ACCESS_UNKNOWN


populate

public void populate(ClassMetaData meta,
                     int access)
Populates the given class metadata. The access style determines which field and/or getter method will contribute as the persistent property of the given class. If the given access is unknown, then the access type is to be determined at first.

Specified by:
populate in interface MetaDataDefaults
Overrides:
populate in class AbstractMetaDataDefaults
access - access type constant from ClassMetaData
See Also:
determineAccessType(ClassMetaData)

populate

public void populate(ClassMetaData meta,
                     int access,
                     boolean ignoreTransient)
Populates the given class metadata. The access style determines which field and/or getter method will contribute as the persistent property of the given class. If the given access is unknown, then the access type is to be determined at first.

Specified by:
populate in interface MetaDataDefaults
Overrides:
populate in class AbstractMetaDataDefaults
access - access type constant from ClassMetaData
See Also:
determineAccessType(ClassMetaData)

populate

protected void populate(FieldMetaData fmd)
Overrides:
populate in class AbstractMetaDataDefaults

setCascadeNone

static void setCascadeNone(ValueMetaData vmd)
Turns off auto cascading of persist, refresh, attach, detach.


getCachedSuperclassMetaData

ClassMetaData getCachedSuperclassMetaData(ClassMetaData meta)

getPersistentFields

List<Field> getPersistentFields(ClassMetaData meta,
                                boolean ignoreTransient)
Gets the fields that are possible candidate for being persisted. The result depends on the current access style of the given class.


getPersistentMethods

List<Method> getPersistentMethods(ClassMetaData meta,
                                  boolean ignoreTransient)
Gets the methods that are possible candidate for being persisted. The result depends on the current access style of the given class.


getPersistentMembers

public List<Member> getPersistentMembers(ClassMetaData meta,
                                         boolean ignoreTransient)
Gets the members that are backing members for attributes being persisted. Unlike #getPersistentFields(ClassMetaData) and #getPersistentMethods(ClassMetaData) which returns possible candidates, the result of this method is definite. Side-effect of this method is if the given class metadata has no access type set, this method will set it.

Specified by:
getPersistentMembers in class AbstractMetaDataDefaults

assertNoDuplicate

void assertNoDuplicate(List<Field> fields,
                       List<Method> getters)

error

void error(ClassMetaData meta,
           Localizer.Message message)

warn

void warn(ClassMetaData meta,
          Localizer.Message message)

trace

void trace(ClassMetaData meta,
           Localizer.Message message)

getFieldAccessNames

protected List<String> getFieldAccessNames(ClassMetaData meta)
Description copied from class: AbstractMetaDataDefaults
Return the list of fields in meta that use field access, or null if a list of fields is unobtainable. An empty list should be returned if the list of fields is obtainable, but there happens to be no field access in meta. This is used for error reporting purposes only, so need not be efficient. This implementation returns null.

Overrides:
getFieldAccessNames in class AbstractMetaDataDefaults

getPropertyAccessNames

protected List<String> getPropertyAccessNames(ClassMetaData meta)
Description copied from class: AbstractMetaDataDefaults
Return the list of methods in meta that use property access, or null if a list of methods is unobtainable. An empty list should be returned if the list of methods is obtainable, but there happens to be no property access in meta. This is used for error reporting purposes only, so need not be efficient. This implementation returns null.

Overrides:
getPropertyAccessNames in class AbstractMetaDataDefaults

isDefaultPersistent

protected boolean isDefaultPersistent(ClassMetaData meta,
                                      Member member,
                                      String name)

isDefaultPersistent

protected boolean isDefaultPersistent(ClassMetaData meta,
                                      Member member,
                                      String name,
                                      boolean ignoreTransient)
Description copied from class: AbstractMetaDataDefaults
Return true if the given member is persistent by default. This will only be invoked on members of the right type (field vs. method). Returns false if member is static or final by default.

Specified by:
isDefaultPersistent in class AbstractMetaDataDefaults
name - the field name from AbstractMetaDataDefaults.getFieldName(java.lang.reflect.Member)

getMemberByProperty

public Member getMemberByProperty(ClassMetaData meta,
                                  String property,
                                  int access,
                                  boolean applyDefaultRule)
Gets either the instance field or the getter method depending upon the access style of the given meta-data.

Parameters:
meta - is the declaring class
property - name of the logical attribute
access - whether to look for the field of getter method. If unknown, then field or property is chosen based on the access type used by the given class.
applyDefaultRule - if true and access is unknown then scans the annotation on the member to determine access.

filter

<T extends AnnotatedElement> List<T> filter(T[] array,
                                            org.apache.openjpa.persistence.PersistenceMetaDataDefaults.InclusiveFilter... filters)
Filter the given collection with the conjunction of filters. The given collection itself is not modified.


filter

<T extends AnnotatedElement> List<T> filter(List<T> list,
                                            org.apache.openjpa.persistence.PersistenceMetaDataDefaults.InclusiveFilter... filters)

toFieldNames

String toFieldNames(List<Field> fields)

toMethodNames

String toMethodNames(List<Method> methods)

isAbstractMappingUniDirectional

public boolean isAbstractMappingUniDirectional(OpenJPAConfiguration conf)
Description copied from interface: MetaDataDefaults
Whether the relationship in MappedSuper class must be uni-directional.


setAbstractMappingUniDirectional

public void setAbstractMappingUniDirectional(OpenJPAConfiguration conf)

isNonDefaultMappingAllowed

public boolean isNonDefaultMappingAllowed(OpenJPAConfiguration conf)
Description copied from interface: MetaDataDefaults
Whether non-default mapping is allowed.


setNonDefaultMappingAllowed

public void setNonDefaultMappingAllowed(OpenJPAConfiguration conf)


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.