org.hibernate.metamodel
Class MetadataSources

java.lang.Object
  extended by org.hibernate.metamodel.MetadataSources

public class MetadataSources
extends Object


Constructor Summary
MetadataSources(ServiceRegistry serviceRegistry)
           
MetadataSources(ServiceRegistry serviceRegistry, EntityResolver entityResolver, NamingStrategy namingStrategy)
           
 
Method Summary
 MetadataSources addAnnotatedClass(Class annotatedClass)
          Read metadata from the annotations attached to the given class.
 MetadataSources addCacheableFile(File file)
          Add a cached mapping file.
 MetadataSources addCacheableFile(String path)
          See addCacheableFile(java.io.File) for description
 MetadataSources addClass(Class entityClass)
          Read a mapping as an application resource using the convention that a class named foo.bar.Foo is mapped by a file named foo/bar/Foo.hbm.xml which can be resolved as a classpath resource.
 MetadataSources addDirectory(File dir)
          Read all mapping documents from a directory tree.
 MetadataSources addDocument(Document document)
          Read mappings from a DOM Document
 MetadataSources addFile(File file)
          Read mappings from a particular XML file
 MetadataSources addFile(String path)
          Read mappings from a particular XML file
 MetadataSources addInputStream(InputStream xmlInputStream)
          Read metadata from an InputStream.
 MetadataSources addJar(File jar)
          Read all mappings from a jar file.
 MetadataSources addPackage(String packageName)
          Read package-level metadata.
 MetadataSources addResource(String name)
          Read mappings as a application resourceName (i.e.
 MetadataSources addURL(URL url)
          Read mappings from a URL
 Metadata buildMetadata()
           
 Iterable<Class<?>> getAnnotatedClasses()
           
 Iterable<String> getAnnotatedPackages()
           
 List<JaxbRoot> getJaxbRootList()
           
 MetadataBuilder getMetadataBuilder()
           
 NamingStrategy getNamingStrategy()
           
 ServiceRegistry getServiceRegistry()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetadataSources

public MetadataSources(ServiceRegistry serviceRegistry)

MetadataSources

public MetadataSources(ServiceRegistry serviceRegistry,
                       EntityResolver entityResolver,
                       NamingStrategy namingStrategy)
Method Detail

getJaxbRootList

public List<JaxbRoot> getJaxbRootList()

getAnnotatedPackages

public Iterable<String> getAnnotatedPackages()

getAnnotatedClasses

public Iterable<Class<?>> getAnnotatedClasses()

getServiceRegistry

public ServiceRegistry getServiceRegistry()

getNamingStrategy

public NamingStrategy getNamingStrategy()

getMetadataBuilder

public MetadataBuilder getMetadataBuilder()

buildMetadata

public Metadata buildMetadata()

addAnnotatedClass

public MetadataSources addAnnotatedClass(Class annotatedClass)
Read metadata from the annotations attached to the given class.

Parameters:
annotatedClass - The class containing annotations
Returns:
this (for method chaining)

addPackage

public MetadataSources addPackage(String packageName)
Read package-level metadata.

Parameters:
packageName - java package name without trailing '.', cannot be null
Returns:
this (for method chaining)

addResource

public MetadataSources addResource(String name)
Read mappings as a application resourceName (i.e. classpath lookup).

Parameters:
name - The resource name
Returns:
this (for method chaining purposes)

addClass

public MetadataSources addClass(Class entityClass)
Read a mapping as an application resource using the convention that a class named foo.bar.Foo is mapped by a file named foo/bar/Foo.hbm.xml which can be resolved as a classpath resource.

Parameters:
entityClass - The mapped class. Cannot be null null.
Returns:
this (for method chaining purposes)

addFile

public MetadataSources addFile(String path)
Read mappings from a particular XML file

Parameters:
path - The path to a file. Expected to be resolvable by File.File(String)
Returns:
this (for method chaining purposes)
See Also:
addFile(java.io.File)

addFile

public MetadataSources addFile(File file)
Read mappings from a particular XML file

Parameters:
file - The reference to the XML file
Returns:
this (for method chaining purposes)

addCacheableFile

public MetadataSources addCacheableFile(String path)
See addCacheableFile(java.io.File) for description

Parameters:
path - The path to a file. Expected to be resolvable by File.File(String)
Returns:
this (for method chaining purposes)
See Also:
addCacheableFile(java.io.File)

addCacheableFile

public MetadataSources addCacheableFile(File file)
Add a cached mapping file. A cached file is a serialized representation of the DOM structure of a particular mapping. It is saved from a previous call as a file with the name {xmlFile}.bin where {xmlFile} is the name of the original mapping file.

If a cached {xmlFile}.bin exists and is newer than {xmlFile}, the {xmlFile}.bin file will be read directly. Otherwise {xmlFile} is read and then serialized to {xmlFile}.bin for use the next time.

Parameters:
file - The cacheable mapping file to be added, {xmlFile} in above discussion.
Returns:
this (for method chaining purposes)

addInputStream

public MetadataSources addInputStream(InputStream xmlInputStream)
Read metadata from an InputStream.

Parameters:
xmlInputStream - The input stream containing a DOM.
Returns:
this (for method chaining purposes)

addURL

public MetadataSources addURL(URL url)
Read mappings from a URL

Parameters:
url - The url for the mapping document to be read.
Returns:
this (for method chaining purposes)

addDocument

public MetadataSources addDocument(Document document)
Read mappings from a DOM Document

Parameters:
document - The DOM document
Returns:
this (for method chaining purposes)

addJar

public MetadataSources addJar(File jar)
Read all mappings from a jar file.

Assumes that any file named *.hbm.xml is a mapping document.

Parameters:
jar - a jar file
Returns:
this (for method chaining purposes)

addDirectory

public MetadataSources addDirectory(File dir)
Read all mapping documents from a directory tree.

Assumes that any file named *.hbm.xml is a mapping document.

Parameters:
dir - The directory
Returns:
this (for method chaining purposes)
Throws:
MappingException - Indicates problems reading the jar file or processing the contained mapping documents.


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.