public class MetadataSources extends Object implements Serializable
buildMetadata()
, or use getMetadataBuilder()
to customize
how sources are processed (naming strategies, etc).Constructor and Description |
---|
MetadataSources() |
MetadataSources(ServiceRegistry serviceRegistry)
Create a metadata sources using the specified service registry.
|
Modifier and Type | Method and Description |
---|---|
MetadataSources |
addAnnotatedClass(Class annotatedClass)
Read metadata from the annotations attached to the given class.
|
MetadataSources |
addAnnotatedClassName(String annotatedClassName)
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 |
addCacheableFileStrictly(File file)
INTENDED FOR TESTSUITE USE ONLY!
Much like
addCacheableFile(java.io.File) except that here we will fail immediately if
the cache version cannot be found or used for whatever reason |
MetadataSources |
addClass(Class entityClass)
Deprecated.
hbm.xml is a legacy mapping format now considered deprecated.
|
MetadataSources |
addDirectory(File dir)
Read all mapping documents from a directory tree.
|
MetadataSources |
addDocument(Document document)
Deprecated.
since 5.0. Use one of the other methods for passing mapping source(s).
|
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 |
addInputStream(InputStreamAccess xmlInputStreamAccess)
Read metadata from an
InputStream access |
MetadataSources |
addJar(File jar)
Read all mappings from a jar file.
|
MetadataSources |
addPackage(Package packageRef)
Read package-level metadata.
|
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) |
Collection<Class<?>> |
getAnnotatedClasses() |
Collection<String> |
getAnnotatedClassNames() |
Collection<String> |
getAnnotatedPackages() |
MetadataBuilder |
getMetadataBuilder()
Get a builder for metadata where non-default options can be specified.
|
MetadataBuilder |
getMetadataBuilder(StandardServiceRegistry serviceRegistry)
Deprecated.
Use
getMetadataBuilder() instead |
ServiceRegistry |
getServiceRegistry() |
List<Binding> |
getXmlBindings() |
XmlMappingBinderAccess |
getXmlMappingBinderAccess() |
protected static boolean |
isExpectedServiceRegistryType(ServiceRegistry serviceRegistry) |
public MetadataSources()
public MetadataSources(ServiceRegistry serviceRegistry)
serviceRegistry
- The service registry to use.protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRegistry)
public XmlMappingBinderAccess getXmlMappingBinderAccess()
public Collection<String> getAnnotatedPackages()
public Collection<Class<?>> getAnnotatedClasses()
public Collection<String> getAnnotatedClassNames()
public ServiceRegistry getServiceRegistry()
public MetadataBuilder getMetadataBuilder()
@Deprecated public MetadataBuilder getMetadataBuilder(StandardServiceRegistry serviceRegistry)
getMetadataBuilder()
insteadpublic 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 addAnnotatedClassName(String annotatedClassName)
Class
will not be accessed until later
which is important for on-the-fly bytecode-enhancementannotatedClassName
- The name of a class containing annotationspublic MetadataSources addPackage(String packageName)
packageName
- java package name without trailing '.', cannot be null
public MetadataSources addPackage(Package packageRef)
packageRef
- Java Package reference@Deprecated public 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 addResource(String name)
name
- The resource namepublic 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 addCacheableFileStrictly(File file) throws SerializationException, FileNotFoundException
addCacheableFile(java.io.File)
except that here we will fail immediately if
the cache version cannot be found or used for whatever reasonfile
- The xml file, not the bin!SerializationException
- Indicates a problem deserializing the cached dom treeFileNotFoundException
- Indicates that the cached file was not found or was not usable.public MetadataSources addInputStream(InputStreamAccess xmlInputStreamAccess)
InputStream
accessxmlInputStreamAccess
- Access to an input stream containing a DOM.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.@Deprecated 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 © 2019 JBoss by Red Hat. All rights reserved.