Class DeploymentDescriptorModel
java.lang.Object
com.sun.jdo.api.persistence.model.Model
com.sun.jdo.api.persistence.model.RuntimeModel
com.sun.jdo.spi.persistence.support.ejb.model.DeploymentDescriptorModel
public class DeploymentDescriptorModel
extends com.sun.jdo.api.persistence.model.RuntimeModel
This is a subclass of RuntimeModel which uses the deployment descriptor
to augment the java metadata for a non-existent persistence-capable
java/class file. It is primarily used at ejbc time, though it could be
used at any time as long as sufficient mapping and deployment descriptor
information is available. See the javadoc for individual methods below
for differences and translations between persistence-capable and ejb
names and behavior. There are different answers to methods depending
on whether they are called on the persistence-capable or the ejb. These
are primarily for the handling of serializable, non-primitive, non-wrapper
type fields: isByteArray, getFieldType (returning byte array),
isPersistentTypeAllowed and isPersistentAllowed (returning true) which
return answers about the byte array when called on the persistence-capable
and return answers about the serializable type when called on the ejb.
- Author:
- Rochelle Raccah 2001
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSignature with CVS keyword substitution for identifying the generated codeFields inherited from class com.sun.jdo.api.persistence.model.Model
ENHANCER, messageBase, NO_ARGS, RUNTIME -
Constructor Summary
ConstructorsConstructorDescriptionDeploymentDescriptorModel(NameMapper nameMapper, ClassLoader classLoader) Creates a new instance of DeploymentDescriptorModel -
Method Summary
Modifier and TypeMethodDescriptionprotected BufferedOutputStreamcreateFile(String className, String baseFileName, String extension) Creates a file with the given base file name and extension parallel to the supplied class (if it does not yet exist).protected voiddeleteFile(String className, String fileName) Deletes the file with the given file name which is parallel to the supplied class.protected ClassLoaderfindClassLoader(String className, ClassLoader classLoader) This method returns the class loader used to find mapping information for the specified className.protected StringfindPenultimateSuperclass(String className) Returns the name of the second to top (top excluding java.lang.Object) superclass for the given class name.getAllFields(String className) Returns a list of names of all the field elements in the class with the specified name.getClass(String className, ClassLoader classLoader) Returns the class element with the specified className.getConstructor(String className, String[] argTypeNames) Returns a wrapped constructor element for the specified argument types in the class with the specified name.getDeclaringClass(Object memberElement) Returns the string representation of declaring class of the specified member element.Returns a wrapped field element for the specified fieldName in the class with the specified className.Returns a list of names of all the declared field elements in the class with the specified name.getFieldType(String className, String fieldName) Returns the field type for the specified fieldName in the class with the specified className.getInheritedMethod(String className, String methodName, String[] argTypeNames) Returns the inherited method element for the specified method name and argument types in the class with the specified name.protected BufferedInputStreamgetInputStreamForResource(String className, ClassLoader classLoader, String resourceName) Returns a wrapped method element for the specified method name and argument types in the class with the specified name.intgetModifiers(Object memberElement) Returns the modifier mask for the specified member element.intgetModifiersForClass(String className) Returns the modifier mask for the specified className.protected StringgetSuperclass(String className) Returns the name of the superclass for the given class name.protected ClassgetTypeObject(Object element) Returns the Class type of the specified element.booleanisValidKeyType(String className, String fieldName) Determines if the specified className and fieldName pair represent a field which has a type which is valid for key fields.Methods inherited from class com.sun.jdo.api.persistence.model.RuntimeModel
getClassLoaderCache, getFile, getMappingClass, getType, hasConstructor, implementsInterface, isArray, isInterface, isSerializable, removeResourcesFromCachesMethods inherited from class com.sun.jdo.api.persistence.model.Model
addFieldElement, convertDefaultFields, convertFields, convertToPersistenceCapable, convertToPersistenceCapable, getClass, getDefaultCollectionClass, getEqualsArgs, getFileName, getFileNameWithExtension, getInheritedField, getMappingCache, getMappingClass, getMessages, getModifiers, getPersistenceClass, getPersistenceClass, getPersistenceClass, getPersistenceField, getPersistenceFieldInternal, getReadObjectArgs, getRelatedClass, getResourceName, getResourceNameWithExtension, getSupportedCollectionClasses, getWriteObjectArgs, hasClass, hasClass, hasField, hasPersistentSuperclass, isByteArray, isByteArray, isCollection, isDefaultFetchGroup, isKey, isMutableSecondClassObject, isPersistenceCapableAllowed, isPersistent, isPersistent, isPersistent, isPersistentAllowed, isPersistentAllowed, isPersistentTypeAllowed, isPrimitive, isPrimitive, isSecondClassObject, lockFile, NewModel, parse, removeFieldElement, removeFromCache, removeResourcesFromCaches, shouldBePersistent, storeMappingClass, storeMappingClass, storeMappingClass, unlockFile, unlockFile, updateKeyForClass, validate, validate
-
Field Details
-
SIGNATURE
Signature with CVS keyword substitution for identifying the generated code- See Also:
-
-
Constructor Details
-
DeploymentDescriptorModel
Creates a new instance of DeploymentDescriptorModel- Parameters:
nameMapper- the name mapper to be used as a helper for translation between persistence class and ejb names.classLoader- the class loader object which is used for the application.
-
-
Method Details
-
getInputStreamForResource
protected BufferedInputStream getInputStreamForResource(String className, ClassLoader classLoader, String resourceName) - Overrides:
getInputStreamForResourcein classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
classLoader- ignored parameter, using CL provided in constructor instead
-
findPenultimateSuperclass
Returns the name of the second to top (top excluding java.lang.Object) superclass for the given class name. This method overrides the one in RuntimeModel in order to return the supplied className if it represents a persistence-capable class. This is because the persistence-capable classes don't mirror the inheritance hierarchy of the ejbs.- Overrides:
findPenultimateSuperclassin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the top non-Object superclass for className,
classNameif an error occurs or none exists
-
getSuperclass
Returns the name of the superclass for the given class name. This method overrides the one in RuntimeModel in order to return java.lang.Object if the supplied className represents a persistence-capable class. This is because the persistence-capable classes don't mirror the inheritance hierarchy of the ejbs.- Overrides:
getSuperclassin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the superclass for className,
nullif an error occurs or none exists
-
createFile
protected BufferedOutputStream createFile(String className, String baseFileName, String extension) throws IOException Creates a file with the given base file name and extension parallel to the supplied class (if it does not yet exist). This method overrides the one in RuntimeModel and throws UnsupportedOperationException in the case where the file doesn't yet exist. If the file exists (even if it has just been "touched"), this method will return that output stream, but it is not capable of using the supplied class as a sibling location.- Overrides:
createFilein classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
className- the fully qualified name of the classbaseFileName- the name of the base fileextension- the file extension- Returns:
- the output stream for the specified resource,
nullif an error occurs or none exists - Throws:
IOException- if there is some error creating the file
-
deleteFile
Deletes the file with the given file name which is parallel to the supplied class. This method overrides the one in RuntimeModel and throws UnsupportedOperationException.- Overrides:
deleteFilein classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
className- the fully qualified name of the classfileName- the name of the file- Throws:
IOException- if there is some error deleting the file
-
getClass
Returns the class element with the specified className. If the specified className represents a persistence-capable class, the abstract bean class for the corresponding ejb is always returned (even if there is a Class object available for the persistence-capable). If there is an ejb name and an abstract bean class with the same name, the abstract bean class which is associated with the ejb will be returned, not the abstract bean class which corresponds to the supplied name (directly). If the specified className represents a persistence-capable key class name, the corresponding bean's key class is returned.- Overrides:
getClassin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
className- the fully qualified name of the class to be checkedclassLoader- the class loader used to find mapping information- Returns:
- the class element for the specified className
-
getConstructor
Returns a wrapped constructor element for the specified argument types in the class with the specified name. If the specified class name is a persistence-capable key class name which corresponds to a bean with an unknown primary key class a dummy constructor will also be returned. Types are specified as type names for primitive type such as int, float or as fully qualified class names.- Overrides:
getConstructorin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
className- the name of the class which contains the constructor to be checkedargTypeNames- the fully qualified names of the argument types- Returns:
- the constructor element
- See Also:
-
getMethod
Returns a wrapped method element for the specified method name and argument types in the class with the specified name. If the specified className represents a persistence-capable class and the requested methodName is readObject or writeObject, a dummy method will be returned. Similarly, if the specified class name is a persistence-capable key class name which corresponds to a bean with an unknown primary key class or a primary key field (in both cases there is no user defined primary key class) and the requested method is equals or hashCode, a dummy method will also be returned. Types are specified as type names for primitive type such as int, float or as fully qualified class names. Note, the method does not return inherited methods.- Overrides:
getMethodin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
className- the name of the class which contains the method to be checkedmethodName- the name of the method to be checkedargTypeNames- the fully qualified names of the argument types- Returns:
- the method element
- See Also:
-
getInheritedMethod
Returns the inherited method element for the specified method name and argument types in the class with the specified name. Types are specified as type names for primitive type such as int, float or as fully qualified class names. Note that the class with the specified className is not checked for this method, only superclasses are checked. This method overrides the one in Model in order to do special handling for a persistence-capable key class name which corresponds to a bean with a primary key field. In that case, we don't want to climb the inheritance of the primary key field type.- Overrides:
getInheritedMethodin classcom.sun.jdo.api.persistence.model.Model- Parameters:
className- the name of the class which contains the method to be checkedmethodName- the name of the method to be checkedargTypeNames- the fully qualified names of the argument types- Returns:
- the method element
- See Also:
-
getFields
Returns a list of names of all the declared field elements in the class with the specified name. If the specified className represents a persistence-capable class, the list of field names from the corresponding ejb is returned (even if there is a Class object available for the persistence-capable).- Overrides:
getFieldsin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the names of the field elements for the specified class
-
getAllFields
Returns a list of names of all the field elements in the class with the specified name. This list includes the inherited fields. If the specified className represents a persistence-capable class, the list of field names from the corresponding ejb is returned (even if there is a Class object available for the persistence-capable). This method overrides the one in Model in order to do special handling for a persistence-capable key class name which corresponds to a bean with a primary key field. In that case, we don't want to climb the inheritance hierarchy of the primary key field type.- Overrides:
getAllFieldsin classcom.sun.jdo.api.persistence.model.Model- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the names of the field elements for the specified class
-
getField
Returns a wrapped field element for the specified fieldName in the class with the specified className. If the specified className represents a persistence-capable class, a field representing the field in the abstract bean class for the corresponding ejb is always returned (even if there is a Field object available for the persistence-capable). If there is an ejb name and an abstract bean class with the same name, the abstract bean class which is associated with the ejb will be used, not the abstract bean class which corresponds to the supplied name (directly).- Overrides:
getFieldin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
- the wrapped field element for the specified fieldName
-
getFieldType
Returns the field type for the specified fieldName in the class with the specified className. This method is overrides the one in Model in order to do special handling for non-collection relationship fields. If it's a generated relationship that case, the returned MemberWrapper from getField contains a type of the abstract bean and it's impossible to convert that into the persistence capable class name, so here that case is detected, and if found, the ejb name is extracted and used to find the corresponding persistence capable class. For a relationship which is of type of the local interface, we do the conversion from local interface to persistence-capable class. In the case of a collection relationship (generated or not), the superclass' implementation which provides the java type is sufficient.- Overrides:
getFieldTypein classcom.sun.jdo.api.persistence.model.Model- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
- the field type for the specified fieldName
-
getDeclaringClass
Returns the string representation of declaring class of the specified member element. Note, the member element is either a class element as returned by getClass, a field element as returned by getField, a constructor element as returned by getConstructor, or a method element as returned by getMethod executed on the same model instance. This implementation expects the member element to be a reflection instance or a wrapped member instance.- Overrides:
getDeclaringClassin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
memberElement- the member element to be checked- Returns:
- the string representation of the declaring class of the specified memberElement
- See Also:
-
getModifiers
Returns the modifier mask for the specified member element. Note, the member element is either a class element as returned by getClass, a member wrapper element as returned by getField or getMethod, a constructor element as returned by getConstructor executed on the same model instance. This implementation expects the member element being a reflection instance or a wrapped member instance.- Overrides:
getModifiersin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
memberElement- the member element to be checked- Returns:
- the modifier mask for the specified memberElement
- See Also:
-
getModifiersForClass
Returns the modifier mask for the specified className. This method overrides the one in Model to strip out the abstract modifier when the persistence capable class is represented by the abstract bean. It also adds the static modifier when the specified class represents the persistence capable key class which will be generated.- Overrides:
getModifiersForClassin classcom.sun.jdo.api.persistence.model.Model- Parameters:
className- the fully qualified name of the class to be checked- Returns:
- the modifier mask for the specified class
- See Also:
-
isValidKeyType
Determines if the specified className and fieldName pair represent a field which has a type which is valid for key fields. Valid key field types include non-collection SCOs (wrappers, Date, Time, etc.) and primitives for user defined key classes. This method overrides the one in Model in order to do special handling for a persistence-capable key class name which corresponds to a bean with a primary key field. In that case, we want to restrict the list of allowable types not to include primitives.- Overrides:
isValidKeyTypein classcom.sun.jdo.api.persistence.model.Model- Parameters:
className- the fully qualified name of the class which contains the field to be checkedfieldName- the name of the field to be checked- Returns:
trueif this field name represents a field with a valid type for a key field;falseotherwise.
-
getTypeObject
Returns the Class type of the specified element. If element denotes a field, it returns the type of the field. If element denotes a method, it returns the return type of the method. Note, element is either a field element as returned by getField, or a method element as returned by getMethod executed on the same model instance.- Overrides:
getTypeObjectin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
element- the element to be checked- Returns:
- the Class type of the element
- See Also:
-
getField(java.lang.String, java.lang.String)RuntimeModel.getMethod(java.lang.String, java.lang.String, java.lang.String[])
-
findClassLoader
This method returns the class loader used to find mapping information for the specified className. This implementation overrides the one in RuntimeModel so that it always returns the ClassLoader provided at construction time.- Overrides:
findClassLoaderin classcom.sun.jdo.api.persistence.model.RuntimeModel- Parameters:
className- the fully qualified name of the class to be checkedclassLoader- the class loader used to find mapping information- Returns:
- the class loader used to find mapping information for the specified className
-