Package net.aifusion.metamodel
Class PersistentCache
java.lang.Object
net.aifusion.metamodel.InMemoryCache
net.aifusion.metamodel.PersistentCache
- All Implemented Interfaces:
Repository
Class to implement a persistent repository that supports multiple name spaces
- Author:
- Sharad Singhal
-
Constructor Summary
ConstructorDescriptionPersistentCache
(String repositoryLocation) Create a persistent repository using the file system -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(ObjectPath path) Check if a named element exists in the repositoryboolean
delete
(ObjectPath path) Delete a named element from the repositoryget
(ObjectPath path) Get a named element from the repositorygetElements
(String elementTypes, String localNameSpaces, String elementNames, boolean locateSubTypes) Get elements from this repository.Get a list of all name spaces known to this repository.boolean
put
(NamedElement element) Put a named element into the repositoryMethods inherited from class net.aifusion.metamodel.InMemoryCache
filter, shutdown
-
Constructor Details
-
PersistentCache
Create a persistent repository using the file system- Parameters:
repositoryLocation
- - file system root of the repository i.e., /user/repository
-
-
Method Details
-
getNameSpaces
Description copied from interface:Repository
Get a list of all name spaces known to this repository. Note that because implementations can add or remove name spaces as elements are added or deleted, this list may not be complete, and depends on the repository implementation- Specified by:
getNameSpaces
in interfaceRepository
- Overrides:
getNameSpaces
in classInMemoryCache
- Returns:
- - list of name spaces
-
put
Description copied from interface:Repository
Put a named element into the repository- Specified by:
put
in interfaceRepository
- Overrides:
put
in classInMemoryCache
- Parameters:
element
- - element to be added- Returns:
- - true if successfully added, false otherwise
-
get
Description copied from interface:Repository
Get a named element from the repository- Specified by:
get
in interfaceRepository
- Overrides:
get
in classInMemoryCache
- Parameters:
path
- - object path corresponding to the named element- Returns:
- - Named Element corresponding to the element. Null returned if no such element exists in the repository
-
contains
Description copied from interface:Repository
Check if a named element exists in the repository- Specified by:
contains
in interfaceRepository
- Overrides:
contains
in classInMemoryCache
- Parameters:
path
- - object path corresponding to the named element- Returns:
- - true if the path exists in the repository, false otherwise
-
delete
Description copied from interface:Repository
Delete a named element from the repository- Specified by:
delete
in interfaceRepository
- Overrides:
delete
in classInMemoryCache
- Parameters:
path
- - object path corresponding to the named element- Returns:
- - true if deletion succeeded, false otherwise
-
getElements
public List<NamedElement> getElements(String elementTypes, String localNameSpaces, String elementNames, boolean locateSubTypes) Get elements from this repository. Note that depending on the size of the repository, this method can be very expensive in time and/or memory. This method directly accesses the persistent store, and does not cache the results in the in-memory cache- Specified by:
getElements
in interfaceRepository
- Overrides:
getElements
in classInMemoryCache
- Parameters:
elementTypes
- - Optional comma separated list of element types to retrieve. Must be a NamedElement (Instance, Class, QualifierType, Structure, structurevalue, Interface or enumeration). Null will select all element types.localNameSpaces
- - Optional comma separated list of local namespaces to search. A null will retrieve elements from all namespaceselementNames
- - Optional comma-separated list of element names to retrieve. A null will retrieve all elements of the given typelocateSubTypes
- - if true, also retrieve subtypes of the requested element types- Returns:
- list of elements that match the given criteria. An empty list is returned if no matching elements are found
- See Also:
-