Class XMLClassDescriptorResolverImpl

    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addClass​(java.lang.Class<?> clazz)
      Loads the class descriptor for the class instance specified.
      void addClass​(java.lang.String className)
      Loads the class descriptor for the class instance specified.
      void addClasses​(java.lang.Class<?>[] clazzes)
      Loads the class descriptors for the class instances specified.
      void addClasses​(java.lang.String[] classNames)
      Loads the class descriptors for the class instances specified.
      void addPackage​(java.lang.String packageName)
      Loads class descriptors from the package specified.
      void addPackages​(java.lang.String[] packageNames)
      Loads class descriptors from the packages specified.
      void cleanDescriptorCache()
      Cleans the descriptor cache.
      MappingLoader getMappingLoader()
      Note: This method will be removed soon (kv).
      void loadClassDescriptors​(java.lang.String packageName)
      Deprecated. 
      ClassDescriptor resolve​(java.lang.Class<?> type)
      Returns the ClassDescriptor for the given class.
      XMLClassDescriptor resolve​(java.lang.String className)
      Returns the XMLClassDescriptor for the given class name.
      XMLClassDescriptor resolve​(java.lang.String className, java.lang.ClassLoader loader)
      Returns the XMLClassDescriptor for the given class name.
      java.util.Iterator<ClassDescriptor> resolveAllByXMLName​(java.lang.String xmlName, java.lang.String namespaceURI, java.lang.ClassLoader loader)
      Returns an enumeration of XMLClassDescriptor objects that match the given xml name.
      XMLClassDescriptor resolveByXMLName​(java.lang.String xmlName, java.lang.String namespaceURI, java.lang.ClassLoader loader)
      Returns the first XMLClassDescriptor that matches the given XML name and namespaceURI.
      void setClassLoader​(java.lang.ClassLoader loader)
      Sets the ClassLoader to use when loading class descriptors.
      void setInternalContext​(InternalContext internalContext)
      To set the XMLContext to be used.
      void setIntrospector​(Introspector introspector)
      To set the Introspector to be used.
      void setLoadPackageMappings​(boolean loadPackageMappings)
      Sets whether or not to look for and load package specific mapping files (".castor.xml").
      void setMappingLoader​(MappingLoader mappingLoader)
      Sets the mapping loader for this ClassDescriptorResolver.
      void setResolverStrategy​(ResolverStrategy resolverStrategy)
      The resolver strategy to use for class and package resolving.
      void setUseIntrospection​(boolean enable)
      Enables or disables introspection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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 Detail

      • setInternalContext

        public void setInternalContext​(InternalContext internalContext)
        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:
        setInternalContext in interface XMLClassDescriptorResolver
        Parameters:
        internalContext - the XMLContext to be used
      • setClassLoader

        public void setClassLoader​(java.lang.ClassLoader loader)
        Sets the ClassLoader to use when loading class descriptors.
        Specified by:
        setClassLoader in interface XMLClassDescriptorResolver
        Parameters:
        loader - the ClassLoader to use
      • setUseIntrospection

        public void setUseIntrospection​(boolean enable)
        Enables or disables introspection. Introspection is enabled by default.
        Specified by:
        setUseIntrospection in interface XMLClassDescriptorResolver
        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:
        setLoadPackageMappings in interface XMLClassDescriptorResolver
        Parameters:
        loadPackageMappings - a boolean that enables or disables the loading of package specific mapping files
      • setIntrospector

        public void setIntrospector​(Introspector introspector)
        To set the Introspector to be used. It is stored as attribute of resolver and set as property into the current strategy.
        Specified by:
        setIntrospector in interface XMLClassDescriptorResolver
        Parameters:
        introspector - the Introspector to use
      • setResolverStrategy

        public void setResolverStrategy​(ResolverStrategy resolverStrategy)
        The resolver strategy to use for class and package resolving. Will set the current attributes into the new strategy.
        Specified by:
        setResolverStrategy in interface XMLClassDescriptorResolver
        Parameters:
        resolverStrategy - the ResolverStrategy to use for resolve calls
      • resolve

        public XMLClassDescriptor resolve​(java.lang.String className)
                                   throws ResolverException
        Returns the XMLClassDescriptor for the given class name.
        Specified by:
        resolve in interface XMLClassDescriptorResolver
        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

        public XMLClassDescriptor resolve​(java.lang.String className,
                                          java.lang.ClassLoader loader)
                                   throws ResolverException
        Returns the XMLClassDescriptor for the given class name.
        Specified by:
        resolve in interface XMLClassDescriptorResolver
        Parameters:
        className - the class name to find the XMLClassDescriptor for
        loader - the ClassLoader to use
        Returns:
        the XMLClassDescriptor for the given class name
        Throws:
        ResolverException - in case that resolving fails unrecoverable
      • resolveByXMLName

        public XMLClassDescriptor resolveByXMLName​(java.lang.String xmlName,
                                                   java.lang.String namespaceURI,
                                                   java.lang.ClassLoader loader)
        Returns the first XMLClassDescriptor that matches the given XML name and namespaceURI. Null is returned if no descriptor can be found.
        Specified by:
        resolveByXMLName in interface XMLClassDescriptorResolver
        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 java.util.Iterator<ClassDescriptor> resolveAllByXMLName​(java.lang.String xmlName,
                                                                       java.lang.String namespaceURI,
                                                                       java.lang.ClassLoader loader)
        Returns an enumeration of XMLClassDescriptor objects that match the given xml name.
        Specified by:
        resolveAllByXMLName in interface XMLClassDescriptorResolver
        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

        public void addClass​(java.lang.String className)
                      throws ResolverException
        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:
        addClass in interface XMLClassDescriptorResolver
        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

        public void addClasses​(java.lang.String[] classNames)
                        throws ResolverException
        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:
        addClasses in interface XMLClassDescriptorResolver
        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

        public void addClass​(java.lang.Class<?> clazz)
                      throws ResolverException
        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:
        addClass in interface XMLClassDescriptorResolver
        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

        public void addClasses​(java.lang.Class<?>[] clazzes)
                        throws ResolverException
        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:
        addClasses in interface XMLClassDescriptorResolver
        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

        public void addPackage​(java.lang.String packageName)
                        throws ResolverException
        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:
        addPackage in interface XMLClassDescriptorResolver
        Parameters:
        packageName - The package name for the (descriptor) classes
        Throws:
        ResolverException - If there's a problem loading class descriptors for the given package.
      • addPackages

        public void addPackages​(java.lang.String[] packageNames)
                         throws ResolverException
        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:
        addPackages in interface XMLClassDescriptorResolver
        Parameters:
        packageNames - The package names for the (descriptor) classes
        Throws:
        ResolverException - If there's a problem loading class descriptors for the given package.
      • loadClassDescriptors

        public void loadClassDescriptors​(java.lang.String packageName)
                                  throws ResolverException
        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:
        loadClassDescriptors in interface XMLClassDescriptorResolver
        Parameters:
        packageName - The package name for the (descriptor) classes
        Throws:
        ResolverException - If there's a problem loading class descriptors for the given package.