org.objectweb.jorm.api

Interface PMapper

All Superinterfaces:
PMappingStructuresManager
Known Subinterfaces:
PMappingCallback

public interface PMapper
extends PMappingStructuresManager

The PMapper interface defines a JORM mapper as an object that mainly maintains the set of JORM classes that it maps on a particular DS. It relies on JCA as a means to access a DS. It enables to access to the meta-information associated to JORM classes at runtime. Before being able to request the load of meta-information at mapping time, the mapper should have been assigned a mapping name, a meta-information manager, as well as a parser.

Author:
P. Dechamboux

Field Summary

static String
JORMPROPFILE
static String
PBINDINGAPPENDER
static String
PCLASSMAPPINGAPPENDER

Method Summary

void
addMapperEventListener(PMapperListener listener)
Adds the given mapper listener to this mapper.
void
closeConnection(Object conn)
Closes the given connection which has been allocated previously using getConnection.
String
cn2mn(String cn)
Constructs a "mapped name" starting from a JORM class name.
PClassMapping
createGenClassMapping()
Creates a new PClassMapping for a gen class.
Object
getConnection()
Allocates a connection for accessing the underlying DS.
Object
getConnection(Object ctxt)
Allocates a connection for accessing the underlying DS knowing additional context information.
Object
getConnection(Object connectionContext, Object user)
Allocates a connection for accessing the underlying DS knowing additional context information.
Object
getConnectionFactory()
Returns the connection factory associated to this mapper.
String
getMapperName()
The name yielded by this method defines what kind of PMapper is used on a particular DS.
Manager
getMetaInfoManager()
It retrieves a meta-information Manager that may used by a parser in order to load the meta-information associated to JORM classes mapped within this PMapper.
PMappingStructuresManager
getPMappingStructuresManager()
Retrieves the PMappingStructuresManager associated with this mapper.
PTypeSpace
getPTypeSpace()
It returns a PTypeSpace that may be used to create PType associated to JORM classes mapped within this PMapper.
PrefetchCache
getPrefetchCache()
Returns the prefetch cache associated to this mapper.
PClassMapping
lookup(String classname)
It looks for the PClassMapping object associated to a JORM class within this PMapper.
void
map(Object conn, PClassMapping pcm)
It registers a PClassMapping associated to a particular JORM class within this PMapper.
void
map(Object conn, PClassMapping pcm, boolean loadmeta)
It registers a PClassMapping associated to a particular JORM class within this PMapper.
void
map(PClassMapping pcm)
It registers a PClassMapping associated to a particular JORM class within this PMapper.
void
removeMapperEventListener(PMapperListener listener)
Removes the given mapper listener from this mapper.
void
setConnectionFactory(Object cf)
Assigns a connection factory to this mapper.
void
setMapperName(String mappername)
It assigns the name of the mapper that is instanciated.
void
setPrefetchCache(PrefetchCache pc)
Assigns a prefetch cache to this mapper.
void
start()
Starts this mapper.
void
stop()
Stops this mapper.
void
unmap(String classname)
It unmaps a particular JORM class within this PMapper.

Methods inherited from interface org.objectweb.jorm.api.PMappingStructuresManager

addDependency, classDefined, declareClass, getPMapCluster, getPMapClusters, setLogger, setPMapper

Field Details

JORMPROPFILE

public static final String JORMPROPFILE


PBINDINGAPPENDER

public static final String PBINDINGAPPENDER


PCLASSMAPPINGAPPENDER

public static final String PCLASSMAPPINGAPPENDER

Method Details

addMapperEventListener

public void addMapperEventListener(PMapperListener listener)
Adds the given mapper listener to this mapper. If it already exists, does nothing.

Parameters:
listener - The corresponding listener.


closeConnection

public void closeConnection(Object conn)
            throws PException
Closes the given connection which has been allocated previously using getConnection.

Parameters:
conn - The concerned connection.


cn2mn

public String cn2mn(String cn)
Constructs a "mapped name" starting from a JORM class name. For example, "foo" class name produces ".foo", while "p1.p2.foo" produces "p1.p2..foo".

Parameters:
cn - The JORM class name.


createGenClassMapping

public PClassMapping createGenClassMapping()
            throws PException
Creates a new PClassMapping for a gen class. It instanciates the relevant class wrt the type of mapper.

Returns:


getConnection

public Object getConnection()
            throws PException
Allocates a connection for accessing the underlying DS.


getConnection

public Object getConnection(Object ctxt)
            throws PException
Allocates a connection for accessing the underlying DS knowing additional context information.

Parameters:
ctxt - Context information used to allocate the connection.


getConnection

public Object getConnection(Object connectionContext,
                            Object user)
            throws PException
Allocates a connection for accessing the underlying DS knowing additional context information.

Parameters:
connectionContext - Context information used to allocate the connection.
user - is the identifier of the connection user (working set or transaction id).


getConnectionFactory

public Object getConnectionFactory()
Returns the connection factory associated to this mapper.


getMapperName

public String getMapperName()
The name yielded by this method defines what kind of PMapper is used on a particular DS.

Returns:
The name defining the PMapper kind.


getMetaInfoManager

public Manager getMetaInfoManager()
It retrieves a meta-information Manager that may used by a parser in order to load the meta-information associated to JORM classes mapped within this PMapper.

Returns:
The meta-information Manager assigned.


getPMappingStructuresManager

public PMappingStructuresManager getPMappingStructuresManager()
Retrieves the PMappingStructuresManager associated with this mapper.

Returns:
The associated PMappingStructuresManager.


getPTypeSpace

public PTypeSpace getPTypeSpace()
It returns a PTypeSpace that may be used to create PType associated to JORM classes mapped within this PMapper.


getPrefetchCache

public PrefetchCache getPrefetchCache()
Returns the prefetch cache associated to this mapper. It can be null.


lookup

public PClassMapping lookup(String classname)
It looks for the PClassMapping object associated to a JORM class within this PMapper.

Returns:
The PClassMapping that maps the corresponding class, or null if none exists


map

public void map(Object conn,
                PClassMapping pcm)
            throws PException
It registers a PClassMapping associated to a particular JORM class within this PMapper. It initializes the storage structures if necessary. It previously removes them if the "dsrem" flag is set. If the mapper is ready to manage the meta-information, it is loaded for this JORM class.

Parameters:
conn - The connection to access to the underlying DS.
pcm - The class mapping to add to this mapper.


map

public void map(Object conn,
                PClassMapping pcm,
                boolean loadmeta)
            throws PException
It registers a PClassMapping associated to a particular JORM class within this PMapper. It initializes the storage structures if necessary. It previously removes them if the "dsrem" flag is set. It also loads the meta-information related to this class if the "loadmeta" flag is set.

Parameters:
conn - The connection to access to the underlying DS.
pcm - The class mapping to add to this mapper.
loadmeta - It specifies that meta-information should be loaded for this class to map.


map

public void map(PClassMapping pcm)
            throws PException
It registers a PClassMapping associated to a particular JORM class within this PMapper. It initializes the storage structures if necessary. It previously removes them if the "dsrem" flag is set. If the mapper is ready to manage the meta-information, it is loaded for this JORM class.

Parameters:
pcm - The class mapping to add to this mapper.


removeMapperEventListener

public void removeMapperEventListener(PMapperListener listener)
Removes the given mapper listener from this mapper. If it is not present among this list, does nothing.

Parameters:
listener - The corresponding listener.


setConnectionFactory

public void setConnectionFactory(Object cf)
            throws PException
Assigns a connection factory to this mapper.


setMapperName

public void setMapperName(String mappername)
It assigns the name of the mapper that is instanciated. It is mandatory to assign it at mapper initialization as the load of meta-information depends on it.

Parameters:
mappername - The name of the mapper.


setPrefetchCache

public void setPrefetchCache(PrefetchCache pc)
            throws PException
Assigns a prefetch cache to this mapper. It is optional.


start

public void start()
            throws PException
Starts this mapper.

Throws:
PException -


stop

public void stop()
            throws PException
Stops this mapper.

Throws:
PException -


unmap

public void unmap(String classname)
            throws PException
It unmaps a particular JORM class within this PMapper.

Parameters:
classname - The name of the JORM class to be unmapped.