|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GraphPool
A GraphPool
manages graphs which are stored in the same data
source.
A graph pool always is in one of two states: opened or closed. Most methods will only work if the pool is opened!
All implementations of GraphPool must provide a public constructor accepting
a DataSourceURL
as the only parameter. The
GraphPoolFactory
will not be able to instantiate
them otherwise.
Method Summary | |
---|---|
void |
clear(boolean alsoClearSchema)
Removes every graph entity from this graph pool, and possibly every class declaration from the schema. |
void |
close()
Closes the graph pool and frees all temporary resources used by it. |
Graph |
createTopLevelGraph(java.lang.String name,
GraphClass type)
Creates a new (top-level) graph with the given name. |
boolean |
existsTopLevelGraph(java.lang.String name)
Returns true if a graph identified by the name is stored
in the pool and false otherwise. |
java.util.Collection<? extends GraphEntity> |
getAllInstances(GraphEntityClass id)
Returns all instances of a GraphEntityClass contained in the pool. |
java.util.Collection<? extends Graph> |
getAllTopLevelGraphs()
Returns all top-level graphs (those which have no parent graph) stored in this graph pool. |
DataSourceURL |
getDataSourceURL()
Returns the URL to the data source of this graph pool. |
boolean |
getForceExistenceCheckOnRead()
Tells wether the existence of any entity or entity class is checked before performing a reading operation. |
GraphEntity |
getGraphEntityByInternalIdentifier(java.io.Serializable identifier)
Retrieves a GraphEntity by its internal identifier. |
DefaultGraphPoolChecker |
getGraphPoolChecker()
Returns the GraphPoolChecker used by the GraphPool, which will always be an instance of DefaultGraphPoolChecker. |
Schema |
getSchema()
Returns the schema used for all elements in this graph pool. |
Graph |
getTopLevelGraphByName(java.lang.String name)
Returns the top-level graph identified by the specified name. |
GraphPool |
getWrappedGraphPool()
Returns the wrapped graph pool, null if none. |
Wrapper |
getWrapper()
Returns the Wrapper currently used by the GraphPool. |
void |
init()
Initializes a graph pool. |
void |
open()
Prepares the graph pool for normal operation. |
void |
removeAllAttributeInstances(Attribute attribute)
Removes every instance of an attribute from the pool. |
void |
removeAllInstances(GraphEntityClass id)
Removes every instance of a GraphEntityClass from the pool. |
void |
removeTopLevelGraph(Graph graph)
Deletes a top-level graph. |
void |
reorganizePool()
Reorganizes the entire graph pool. |
void |
setForceExistenceCheckOnRead(boolean b)
Sets wether the existence of any entity or entity class is checked before performing a reading operation. |
void |
setWrapper(Wrapper w)
Sets the Wrapper to be used by the GraphPool. |
Methods inherited from interface i3.dragos.gm.core.schema.MetaAttributable |
---|
getAllMetaAttributes, getMetaAttribute, isMetaAttributeKeyReserved, isMetaAttributeSet, setMetaAttribute, unsetMetaAttribute |
Method Detail |
---|
DataSourceURL getDataSourceURL()
null
.
This method must work even when the GraphPool is closed.
Schema getSchema() throws DragosException
This method must work even when the GraphPool is closed.
DragosException
- if something went wrong.Graph createTopLevelGraph(java.lang.String name, GraphClass type) throws EntityNotFoundException, DragosException, java.lang.IllegalArgumentException, EntityAlreadyExistsException, GraphEntityInstantiationException
name
- The name of the graph.type
- The graphs type.
EntityNotFoundException
- if the type could not be found.
java.lang.IllegalArgumentException
- if name or type are null
.
EntityAlreadyExistsException
- if a graph with this name already
exists.
GraphEntityInstantiationException
- if type is declared as an abstract class.
DragosException
- if something went wrong.boolean existsTopLevelGraph(java.lang.String name) throws DragosException
true
if a graph identified by the name is stored
in the pool and false
otherwise.
name
- The name of the graph.
true
if a graph identified by the name is stored
in the pool and false
otherwise.
DragosException
- if something went wrong.void removeTopLevelGraph(Graph graph) throws EntityNotFoundException, DragosException
See Graph.removeGraphEntity(GraphEntity)
for a detailed
description on the deletion process.
Any non-top-level graphs should be deleted by calling
Graph.removeGraphEntity(GraphEntity)
on their parent graph instead.
graph
- The graph.
EntityNotFoundException
- if the graph is not a top-level graph in
this GraphPool.
DragosException
- if something went wrong.java.util.Collection<? extends Graph> getAllTopLevelGraphs() throws DragosException
Graph
.
DragosException
- in case of internal errors.Graph getTopLevelGraphByName(java.lang.String name) throws EntityNotFoundException, DragosException
name
- The name of the graph.
EntityNotFoundException
- if the graph does not exist.
DragosException
- if something else went wrong.GraphEntity getGraphEntityByInternalIdentifier(java.io.Serializable identifier) throws EntityNotFoundException, DragosException
identifier
- The internal identifier.
EntityNotFoundException
- if the graph entity does not exist.
DragosException
- if something else went wrong.void clear(boolean alsoClearSchema) throws DragosException
GraphPoolEvent
is required.
alsoClearSchema
- Whether Schema.clear()
should be called
after successful removal of all entities in the pool.
DragosException
- if something went wrong.java.util.Collection<? extends GraphEntity> getAllInstances(GraphEntityClass id) throws EntityNotFoundException, DragosException
id
- The class whose instances are to be returned.
EntityNotFoundException
- if the class was not found in the schema.
DragosException
- if something went wrong.void removeAllInstances(GraphEntityClass id) throws EntityNotFoundException, DragosException
Deletion must follow the general procedure for deletion of
graph entities, described at Graph.removeGraphEntity(GraphEntity)
.
The easiest way to ensure this is to proceed as follows for every graph entity in this pool:
removeTopLevelGraph(Graph)
.Graph.removeGraphEntity(GraphEntity)
on their parent graph.Implementation notice: Some instances might already be deleted due to cascading removal of entities processed before, so take care when iterating through the instances.
id
- The class whose instances are to be deleted.
EntityNotFoundException
- if the class was not found in the schema.
DragosException
- if something went wrong.void removeAllAttributeInstances(Attribute attribute) throws EntityNotFoundException, DragosException
attribute
- The attribute whose instances are to be deleted.
EntityNotFoundException
- if the attribute definition was not found
in the schema.
DragosException
- if something went wrong.void reorganizePool() throws EntityInUseException, DragosException
Any information that is used by applications to access any kind of information externally visible (like internal identifiers) will not be modified.
Caution: This method should only be used by privileged application modules because exclusive access to the graph pool is required in general.
EntityInUseException
- if the graph use by some other component.
DragosException
- if something went wrong.void close() throws GraphPoolException
This method must work even when the GraphPool is closed.
GraphPoolException
- if something went wrong.open()
void open() throws GraphPoolException
This method must work even when the GraphPool is closed.
GraphPoolException
- if something went wrong.close()
void init() throws GraphPoolException
init
method must be called first
DataSource
and accessible via the TransactionManagerFactory
open()
GraphPoolException
- if something went wrong.void setForceExistenceCheckOnRead(boolean b)
b
- The new value of the flag.boolean getForceExistenceCheckOnRead()
Wrapper getWrapper()
NullWrapper
upon creation, and
setWrapper(Wrapper)
does not allow a null
argument, the returned value is guaranteed not to be null
.
The Wrapper itself must not be modified after it has been set,
the wrapping mechanism should be immutable! Rationale: We want
to allow the caching of wrapped entities, and changes directly to
the Wrapper will not be noticed by the GraphPool, meaning entities
wrapped according to the old rules may remain in the caches and still be
returned!
To change the Wrapper, e.g. add a new layer to a MultiWrapper
,
create a completely new Wrapper and set it using this method. The
GraphPool will take this as a sign to discard not only the old Wrapper,
but also any caches associated with it!
This method must work even when the GraphPool is closed.
Wrapper
void setWrapper(Wrapper w) throws DragosException
NullWrapper
(which is the
default Wrapper set upon GraphPool creation)
This method must work even when the GraphPool is closed.
w
- the Wrapper to be used by the GraphPool (must not be
null
).
DragosException
- if something went wrong.Wrapper
GraphPool getWrappedGraphPool()
null
if none.
If there is more than one instance of any sub-interface or implementing class in the wrapper chain, partial unwrapping (needed mostly to access newly defined methods) may not work as expected. It is up to the application to ensure that no wrapper is included more than once.
This method must work even when the GraphPool is closed.
null
if none.GraphPoolFactory.unwrapGraphPoolTill(GraphPool, ExtensionDescriptor)
DefaultGraphPoolChecker getGraphPoolChecker()
DefaultGraphPoolChecker.addCustomGraphPoolChecker(GraphPoolChecker)
to add additional, custom checks that will be performed after the
default tests have passed. The default checker can not be deactivated
without modifying the source code. This makes sense because the default
checker simply enforces assumptions also made by implementations, so
loosening its restrictions would result in unpredictable behaviour and
errors. If you change the whole graph model implementation to deal with
different assumptions anyway, deactivating the default checker should be
easy.
This method must work even when the GraphPool is closed.
null
).GraphPoolChecker
,
DefaultGraphPoolChecker
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |