public class MetadataSources extends Object
Constructor and Description |
---|
MetadataSources(ServiceRegistry serviceRegistry) |
MetadataSources(ServiceRegistry serviceRegistry,
EntityResolver entityResolver,
NamingStrategy namingStrategy) |
Modifier and Type | Method and Description |
---|---|
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()
Short-hand form of calling
getMetadataBuilder() and using its
MetadataBuilder.build() method in cases where the application wants
to accept the defaults. |
Metadata |
buildMetadata(StandardServiceRegistry serviceRegistry) |
Iterable<Class<?>> |
getAnnotatedClasses() |
Iterable<String> |
getAnnotatedPackages() |
List<JaxbRoot> |
getJaxbRootList() |
MetadataBuilder |
getMetadataBuilder()
Get a builder for metadata where non-default options can be specified.
|
MetadataBuilder |
getMetadataBuilder(StandardServiceRegistry serviceRegistry)
Get a builder for metadata where non-default options can be specified.
|
NamingStrategy |
getNamingStrategy() |
ServiceRegistry |
getServiceRegistry() |
protected static boolean |
isExpectedServiceRegistryType(ServiceRegistry serviceRegistry) |
public MetadataSources(ServiceRegistry serviceRegistry)
public MetadataSources(ServiceRegistry serviceRegistry, EntityResolver entityResolver, NamingStrategy namingStrategy)
protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRegistry)
public ServiceRegistry getServiceRegistry()
public NamingStrategy getNamingStrategy()
public MetadataBuilder getMetadataBuilder()
public MetadataBuilder getMetadataBuilder(StandardServiceRegistry serviceRegistry)
public Metadata buildMetadata()
getMetadataBuilder()
and using its
MetadataBuilder.build()
method in cases where the application wants
to accept the defaults.public Metadata buildMetadata(StandardServiceRegistry serviceRegistry)
public MetadataSources addAnnotatedClass(Class annotatedClass)
annotatedClass
- The class containing annotationspublic MetadataSources addPackage(String packageName)
packageName
- java package name without trailing '.', cannot be null
public MetadataSources addResource(String name)
name
- The resource namepublic MetadataSources addClass(Class entityClass)
foo.bar.Foo
is
mapped by a file named foo/bar/Foo.hbm.xml
which can be resolved as a classpath resource.entityClass
- The mapped class. Cannot be null
null.public MetadataSources addFile(String path)
path
- The path to a file. Expected to be resolvable by File.File(String)
addFile(java.io.File)
public MetadataSources addFile(File file)
file
- The reference to the XML filepublic MetadataSources addCacheableFile(String path)
addCacheableFile(java.io.File)
for descriptionpath
- The path to a file. Expected to be resolvable by File.File(String)
addCacheableFile(java.io.File)
public MetadataSources addCacheableFile(File file)
{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.file
- The cacheable mapping file to be added, {xmlFile}
in above discussion.public MetadataSources addInputStream(InputStream xmlInputStream)
InputStream
.xmlInputStream
- The input stream containing a DOM.public MetadataSources addURL(URL url)
URL
url
- The url for the mapping document to be read.public MetadataSources addDocument(Document document)
Document
document
- The DOM documentpublic MetadataSources addJar(File jar)
jar
- a jar filepublic MetadataSources addDirectory(File dir)
dir
- The directoryMappingException
- Indicates problems reading the jar file or
processing the contained mapping documents.Copyright © 2001-2015 Red Hat, Inc. All Rights Reserved.