Package org.exolab.castor.xml.util
Class XMLClassDescriptorResolverImpl
java.lang.Object
org.exolab.castor.xml.util.XMLClassDescriptorResolverImpl
- All Implemented Interfaces:
ClassDescriptorResolver,XMLClassDescriptorResolver
The default implementation of the ClassDescriptorResolver interface.
- Version:
- $Revision: 8691 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
- Author:
- Keith Visco
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidLoads the class descriptor for the class instance specified.voidLoads the class descriptor for the class instance specified.voidaddClasses(Class<?>[] clazzes) Loads the class descriptors for the class instances specified.voidaddClasses(String[] classNames) Loads the class descriptors for the class instances specified.voidaddPackage(String packageName) Loads class descriptors from the package specified.voidaddPackages(String[] packageNames) Loads class descriptors from the packages specified.voidCleans the descriptor cache.Note: This method will be removed soon (kv).voidloadClassDescriptors(String packageName) Deprecated.Returns the ClassDescriptor for the given class.Returns the XMLClassDescriptor for the given class name.resolve(String className, ClassLoader loader) Returns the XMLClassDescriptor for the given class name.resolveAllByXMLName(String xmlName, String namespaceURI, ClassLoader loader) Returns an enumeration of XMLClassDescriptor objects that match the given xml name.resolveByXMLName(String xmlName, String namespaceURI, ClassLoader loader) Returns the first XMLClassDescriptor that matches the given XML name and namespaceURI.voidsetClassLoader(ClassLoader loader) Sets the ClassLoader to use when loading class descriptors.voidsetInternalContext(InternalContext internalContext) To set the XMLContext to be used.voidsetIntrospector(Introspector introspector) To set the Introspector to be used.voidsetLoadPackageMappings(boolean loadPackageMappings) Sets whether or not to look for and load package specific mapping files (".castor.xml").voidsetMappingLoader(MappingLoader mappingLoader) Sets the mapping loader for this ClassDescriptorResolver.voidsetResolverStrategy(ResolverStrategy resolverStrategy) The resolver strategy to use for class and package resolving.voidsetUseIntrospection(boolean enable) Enables or disables introspection.
-
Constructor Details
-
XMLClassDescriptorResolverImpl
public XMLClassDescriptorResolverImpl()Creates a new ClassDescriptorResolverImpl. It is left empty to avoid cycles at construction. To guarantee backward compatibility the backwardInit method will do all required initialization if it hadn't happened before.
-
-
Method Details
-
setInternalContext
To set the XMLContext to be used. The InternalContext itself is not stored! But all values of interest are read and stored in local attributes.- Specified by:
setInternalContextin interfaceXMLClassDescriptorResolver- Parameters:
internalContext- the XMLContext to be used
-
getMappingLoader
Note: This method will be removed soon (kv).- Specified by:
getMappingLoaderin interfaceClassDescriptorResolver
-
setClassLoader
Sets the ClassLoader to use when loading class descriptors.- Specified by:
setClassLoaderin interfaceXMLClassDescriptorResolver- Parameters:
loader- the ClassLoader to use
-
setUseIntrospection
public void setUseIntrospection(boolean enable) Enables or disables introspection. Introspection is enabled by default.- Specified by:
setUseIntrospectionin interfaceXMLClassDescriptorResolver- Parameters:
enable- a flag to indicate whether or not introspection is allowed.
-
setLoadPackageMappings
public void setLoadPackageMappings(boolean loadPackageMappings) Sets whether or not to look for and load package specific mapping files (".castor.xml").- Specified by:
setLoadPackageMappingsin interfaceXMLClassDescriptorResolver- Parameters:
loadPackageMappings- a boolean that enables or disables the loading of package specific mapping files
-
setMappingLoader
Sets the mapping loader for this ClassDescriptorResolver. Note: This method will be removed soon (kv).- Specified by:
setMappingLoaderin interfaceClassDescriptorResolver
-
setIntrospector
To set the Introspector to be used. It is stored as attribute of resolver and set as property into the current strategy.- Specified by:
setIntrospectorin interfaceXMLClassDescriptorResolver- Parameters:
introspector- the Introspector to use
-
setResolverStrategy
The resolver strategy to use for class and package resolving. Will set the current attributes into the new strategy.- Specified by:
setResolverStrategyin interfaceXMLClassDescriptorResolver- Parameters:
resolverStrategy- the ResolverStrategy to use for resolve calls
-
resolve
Returns the ClassDescriptor for the given class.- Specified by:
resolvein interfaceClassDescriptorResolver- Parameters:
type- the Class to find the ClassDescriptor for- Returns:
- the ClassDescriptor for the given class
- Throws:
ResolverException
-
resolve
Returns the XMLClassDescriptor for the given class name.- Specified by:
resolvein interfaceXMLClassDescriptorResolver- Parameters:
className- the class name to find the XMLClassDescriptor for- Returns:
- the XMLClassDescriptor for the given class name
- Throws:
ResolverException- in case that resolving fails unrecoverable
-
resolve
Returns the XMLClassDescriptor for the given class name.- Specified by:
resolvein interfaceXMLClassDescriptorResolver- Parameters:
className- the class name to find the XMLClassDescriptor forloader- the ClassLoader to use- Returns:
- the XMLClassDescriptor for the given class name
- Throws:
ResolverException- in case that resolving fails unrecoverable
-
resolveByXMLName
Returns the first XMLClassDescriptor that matches the given XML name and namespaceURI. Null is returned if no descriptor can be found.- Specified by:
resolveByXMLNamein interfaceXMLClassDescriptorResolver- Parameters:
xmlName- The class name to find the XMLClassDescriptor for.namespaceURI- The namespace URI to identify the XMLClassDescriptor.loader- The ClassLoader to use.- Returns:
- The XMLClassDescriptor for the given XML name.
-
resolveAllByXMLName
public Iterator<ClassDescriptor> resolveAllByXMLName(String xmlName, String namespaceURI, ClassLoader loader) Returns an enumeration of XMLClassDescriptor objects that match the given xml name.- Specified by:
resolveAllByXMLNamein interfaceXMLClassDescriptorResolver- Parameters:
xmlName- The class name to find the XMLClassDescriptor for.namespaceURI- The namespace URI to identify the XMLClassDescriptor.loader- The ClassLoader to use.- Returns:
- An Iterator of XMLClassDescriptor objects.
-
addClass
Loads the class descriptor for the class instance specified. The use of this method is useful when no mapping is used, as happens when the domain classes hase been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).- Specified by:
addClassin interfaceXMLClassDescriptorResolver- Parameters:
className- Name of the class for which the associated descriptor should be loaded.- Throws:
ResolverException- If there's an unrecoverable problem with resolving a certain class.
-
addClasses
Loads the class descriptors for the class instances specified. The use of this method is useful when no mapping is used, as happens when the domain classes hase been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).- Specified by:
addClassesin interfaceXMLClassDescriptorResolver- Parameters:
classNames- Names of the classes for which the associated descriptors should be loaded.- Throws:
ResolverException- If there's an unrecoverable problem with resolving a certain class.
-
addClass
Loads the class descriptor for the class instance specified. The use of this method is useful when no mapping is used, as happens when the domain classes have been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).- Specified by:
addClassin interfaceXMLClassDescriptorResolver- Parameters:
clazz- Class for which the associated descriptor should be loaded.- Throws:
ResolverException- If there's an unrecoverable problem with resolving a certain class.
-
addClasses
Loads the class descriptors for the class instances specified. The use of this method is useful when no mapping is used, as happens when the domain classes hase been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).- Specified by:
addClassesin interfaceXMLClassDescriptorResolver- Parameters:
clazzes- Classes for which the associated descriptors should be loaded.- Throws:
ResolverException- If there's an unrecoverable problem with resolving a certain class.
-
addPackage
Loads class descriptors from the package specified. The use of this method is useful when no mapping is used, as happens when the domain classes hase been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).Please note that this functionality will work only if you provide the .castor.cdr file with your generated classes (as generated by the XML code generator).
- Specified by:
addPackagein interfaceXMLClassDescriptorResolver- Parameters:
packageName- The package name for the (descriptor) classes- Throws:
ResolverException- If there's a problem loading class descriptors for the given package.
-
addPackages
Loads class descriptors from the packages specified. The use of this method is useful when no mapping is used, as happens when the domain classes hase been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).Please note that this functionality will work only if you provide the .castor.cdr files with your generated classes (as generated by the XML code generator).
- Specified by:
addPackagesin interfaceXMLClassDescriptorResolver- Parameters:
packageNames- The package names for the (descriptor) classes- Throws:
ResolverException- If there's a problem loading class descriptors for the given package.
-
loadClassDescriptors
Deprecated.Loads class descriptors from the package specified. The use of this method is useful when no mapping is used, as happens when the domain classes hase been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).Please note that this functionality will work only if you provide the .castor.cdr file with your generated classes (as generated by the XML code generator).
- Specified by:
loadClassDescriptorsin interfaceXMLClassDescriptorResolver- Parameters:
packageName- The package name for the (descriptor) classes- Throws:
ResolverException- If there's a problem loading class descriptors for the given package.
-
cleanDescriptorCache
public void cleanDescriptorCache()Cleans the descriptor cache.- Specified by:
cleanDescriptorCachein interfaceXMLClassDescriptorResolver- See Also:
-