Top Description Inners Fields Constructors Methods
org.hibernate.internal

public Class SessionFactoryRegistry

extends Object
Class Inheritance
Imports
java.util.Hashtable, java.util.concurrent.ConcurrentHashMap, javax.naming.Context, .Name, .Reference, javax.naming.event.NamespaceChangeListener, .NamingEvent, .NamingExceptionEvent, javax.naming.spi.ObjectFactory, org.hibernate.SessionFactory, org.hibernate.engine.jndi.JndiException, .JndiNameException, org.hibernate.engine.jndi.spi.JndiService, org.hibernate.internal.util.StringHelper

A registry of all SessionFactory instances for the same classloader as this class.

This registry is used for serialization/deserialization as well as JNDI binding.

Author
Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
public static final SessionFactoryRegistry
INSTANCE

Singleton access

private final NamespaceChangeListener
listener

Implementation of JNDI javax.naming.event.NamespaceChangeListener contract to listener for context events and react accordingly if necessary

private static final CoreMessageLogger
private final ConcurrentHashMap<String, String>
nameUuidXref

A cross-reference for mapping a SessionFactory name to its UUID.

private final ConcurrentHashMap<String, SessionFactory>
sessionFactoryMap

A map for mapping the UUID of a SessionFactory to the corresponding SessionFactory instance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
addSessionFactory(String
The uuid under which to register the SessionFactory
uuid
,
String
The optional name under which to register the SessionFactory
name
,
boolean
Is name, if provided, also a JNDI name?
isNameAlsoJndiName
,
SessionFactory
The SessionFactory instance
instance
,
JndiService
The JNDI service, so we can register a listener if name is a JNDI name
jndiService
)

Deprecated as a consequence of SessionFactory being deprecated.
Adds a SessionFactory to the registry
public void
public SessionFactory
findSessionFactory(String uuid, String name)

Deprecated as a consequence of SessionFactory being deprecated.
public SessionFactory

Returns:

The SessionFactory
getNamedSessionFactory
(String
The name
name
)

Deprecated as a consequence of SessionFactory being deprecated.
Get a registered SessionFactory by name
public SessionFactory
getSessionFactory(String uuid)

Deprecated as a consequence of SessionFactory being deprecated.
public boolean

Returns:

true/false
hasRegistrations
()

Does this registry currently contain registrations?

public void
removeSessionFactory(String
The uuid
uuid
,
String
The optional name
name
,
boolean
Is name, if provided, also a JNDI name?
isNameAlsoJndiName
,
JndiService
The JNDI service
jndiService
)

Remove a previously added SessionFactory

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final SessionFactoryRegistry INSTANCE

Singleton access

listenerback to summary
private final NamespaceChangeListener listener

Implementation of JNDI javax.naming.event.NamespaceChangeListener contract to listener for context events and react accordingly if necessary

LOGback to summary
private static final CoreMessageLogger LOG
nameUuidXrefback to summary
private final ConcurrentHashMap<String, String> nameUuidXref

A cross-reference for mapping a SessionFactory name to its UUID. Not all SessionFactories get named,

sessionFactoryMapback to summary
private final ConcurrentHashMap<String, SessionFactory> sessionFactoryMap

A map for mapping the UUID of a SessionFactory to the corresponding SessionFactory instance

Constructor Detail

SessionFactoryRegistryback to summary
private SessionFactoryRegistry()

Method Detail

addSessionFactoryback to summary
public void addSessionFactory(String uuid, String name, boolean isNameAlsoJndiName, SessionFactory instance, JndiService jndiService)

Deprecated

as a consequence of SessionFactory being deprecated. See corresponding docs for further information.

Adds a SessionFactory to the registry

Parameters
uuid:String

The uuid under which to register the SessionFactory

name:String

The optional name under which to register the SessionFactory

isNameAlsoJndiName:boolean

Is name, if provided, also a JNDI name?

instance:SessionFactory

The SessionFactory instance

jndiService:JndiService

The JNDI service, so we can register a listener if name is a JNDI name

clearRegistrationsback to summary
public void clearRegistrations()
findSessionFactoryback to summary
public SessionFactory findSessionFactory(String uuid, String name)

Deprecated

as a consequence of SessionFactory being deprecated. See corresponding docs for further information.

getNamedSessionFactoryback to summary
public SessionFactory getNamedSessionFactory(String name)

Deprecated

as a consequence of SessionFactory being deprecated. See corresponding docs for further information.

Get a registered SessionFactory by name

Parameters
name:String

The name

Returns:SessionFactory

The SessionFactory

getSessionFactoryback to summary
public SessionFactory getSessionFactory(String uuid)

Deprecated

as a consequence of SessionFactory being deprecated. See corresponding docs for further information.

hasRegistrationsback to summary
public boolean hasRegistrations()

Does this registry currently contain registrations?

Returns:boolean

true/false

removeSessionFactoryback to summary
public void removeSessionFactory(String uuid, String name, boolean isNameAlsoJndiName, JndiService jndiService)

Remove a previously added SessionFactory

Parameters
uuid:String

The uuid

name:String

The optional name

isNameAlsoJndiName:boolean

Is name, if provided, also a JNDI name?

jndiService:JndiService

The JNDI service

org.hibernate.internal back to summary

public Class SessionFactoryRegistry.ObjectFactoryImpl

extends Object
implements ObjectFactory
Class Inheritance
  • java.lang.Object
  • org.hibernate.internal.SessionFactoryRegistry.ObjectFactoryImpl
All Implemented Interfaces
javax.naming.spi.ObjectFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
getObjectInstance(Object
The possibly null object containing location or reference information that can be used in creating an object.
reference
,
Name
The name of this object relative to nameCtx, or null if no name is specified.
name
,
Context
The context relative to which the name parameter is specified, or null if name is relative to the default initial context.
nameCtx
,
Hashtable<?, ?>
The possibly null environment that is used in creating the object.
environment
)

Implements javax.naming.spi.ObjectFactory.getObjectInstance.

Creates an object using the location or reference information specified.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ObjectFactoryImplback to summary
public ObjectFactoryImpl()

Method Detail

getObjectInstanceback to summary
public Object getObjectInstance(Object reference, Name name, Context nameCtx, Hashtable<?, ?> environment)

Implements javax.naming.spi.ObjectFactory.getObjectInstance.

Doc from javax.naming.spi.ObjectFactory.getObjectInstance.

Creates an object using the location or reference information specified.

Special requirements of this object are supplied using environment. An example of such an environment property is user identity information.

NamingManager.getObjectInstance() successively loads in object factories and invokes this method on them until one produces a non-null answer. When an exception is thrown by an object factory, the exception is passed on to the caller of NamingManager.getObjectInstance() (and no search is made for other factories that may produce a non-null answer). An object factory should only throw an exception if it is sure that it is the only intended factory and that no other object factories should be tried. If this factory cannot create an object using the arguments supplied, it should return null.

A URL context factory is a special ObjectFactory that creates contexts for resolving URLs or objects whose locations are specified by URLs. The getObjectInstance() method of a URL context factory will obey the following rules.

  1. If obj is null, create a context for resolving URLs of the scheme associated with this factory. The resulting context is not tied to a specific URL: it is able to handle arbitrary URLs with this factory's scheme id. For example, invoking getObjectInstance() with obj set to null on an LDAP URL context factory would return a context that can resolve LDAP URLs such as "ldap://ldap.wiz.com/o=wiz,c=us" and "ldap://ldap.umich.edu/o=umich,c=us".
  2. If obj is a URL string, create an object (typically a context) identified by the URL. For example, suppose this is an LDAP URL context factory. If obj is "ldap://ldap.wiz.com/o=wiz,c=us", getObjectInstance() would return the context named by the distinguished name "o=wiz, c=us" at the LDAP server ldap.wiz.com. This context can then be used to resolve LDAP names (such as "cn=George") relative to that context.
  3. If obj is an array of URL strings, the assumption is that the URLs are equivalent in terms of the context to which they refer. Verification of whether the URLs are, or need to be, equivalent is up to the context factory. The order of the URLs in the array is not significant. The object returned by getObjectInstance() is like that of the single URL case. It is the object named by the URLs.
  4. If obj is of any other type, the behavior of getObjectInstance() is determined by the context factory implementation.

The name and environment parameters are owned by the caller. The implementation will not modify these objects or keep references to them, although it may keep references to clones or copies.

Name and Context Parameters.     The name and nameCtx parameters may optionally be used to specify the name of the object being created. name is the name of the object, relative to context nameCtx. If there are several possible contexts from which the object could be named -- as will often be the case -- it is up to the caller to select one. A good rule of thumb is to select the "deepest" context available. If nameCtx is null, name is relative to the default initial context. If no name is being specified, the name parameter should be null. If a factory uses nameCtx it should synchronize its use against concurrent access, since context implementations are not guaranteed to be thread-safe.

Parameters
reference:Object

The possibly null object containing location or reference information that can be used in creating an object.

name:Name

The name of this object relative to nameCtx, or null if no name is specified.

nameCtx:Context

The context relative to which the name parameter is specified, or null if name is relative to the default initial context.

environment:Hashtable<?, ?>

The possibly null environment that is used in creating the object.

Returns:Object

The object created; null if an object cannot be created.

Annotations
@Override