|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.jstore.Store
public class Store
This class is the facade of JStore framework. It encapsulates all the sub-components involved for the object storage.
Field Summary | |
---|---|
static boolean |
DEFAULT_HANDLER_FLAG
|
static String |
REVISION
|
Object |
storeAccessLock
|
Fields inherited from interface com.jalios.jstore.StoreConstants |
---|
ARRAY_FLAG, CLEANING_STATE, COLLECTION_FLAG, CREATE_OP, DELETE_OP, IDLE_STATE, INNER_LOGS, INNER_MILESTONE, INNER_PREFIX, INNER_SYNC, ITEM_ESCAPE_CHAR, ITEM_SEPARATOR, LOADING_STATE, MAP_ASSIGN, MAP_CHARS_TO_ESCAPE, MAP_CLASS_SEPARATOR, MAP_FLAG, NAMESPACE, SH_SUFFIX, STORING_STATE, UPDATE_OP |
Constructor Summary | |
---|---|
Store(String logFilename)
Create a new Store which does not support precompiled store handlers nor in-memory parsing. |
|
Store(String logFilename,
boolean areHandlersEnabled)
Create a new Store which does not support precompiled store handlers. |
|
Store(String logFilename,
boolean areHandlersEnabled,
String urid,
boolean useNIO)
Create a new Store |
Method Summary | |
---|---|
void |
addClassTag(String tag,
Class<?> clazz)
Binds a tag name with a Storable class. |
void |
addExtraDeleteAttribute(String attName)
Adds an attribute which will be stored when a storable is deleted. |
void |
addStoreListener(StoreListener listener,
boolean repeat)
|
void |
addStoreListener(StoreListener listener,
Class<?> clazz,
boolean repeat)
|
void |
appendAndProcessSuffix(List<? extends LogEntry> logEntryList)
Appends the given LogEntries in the store.xml file and process each of them. |
void |
appendMilestone(Map<String,String> map)
Appends a milestone in the store. |
void |
appendMilestone(String text)
Appends a milestone in the store. |
void |
appendSync(Date date)
Appends a sync tag in the store. |
boolean |
backupStore(File backupFile)
Backup the store. |
void |
close()
Close all Store resources when ending. |
void |
create(Storable storable)
Create a storable, set storable id to stamp value. |
void |
create(Storable storable,
boolean overrideId)
Create a storable, if overrideId is false and storable have an id then do not override id. |
void |
delete(Storable storable)
Delete a storable (even if references remain on it). |
void |
delete(Storable storable,
boolean force)
Delete a storable. |
int |
generateDelta(OutputStream out,
Stamp startStamp,
boolean includeStart)
Ouput in a given stream all the log operations having a stamp greater that the given one. |
void |
generateLogFromMemory(String backupFilename)
Cleans the log. |
Class<?> |
getClassFromTag(String tag)
Returns the class binded with a specified tag name If the class was not registered the class associated to the name is returned |
int |
getCreationLineNumber(String id)
Returns the line number in the store file of the creation. |
TreeSet<? extends Storable> |
getDeletedSet(Class<?> clazz)
Get the latest version of the deleted Storable for a given class. |
Set<String> |
getExtraDeleteAttributeSet()
Returns the list of attributes stored when a storable is deleted. |
LoadReport |
getLoadReport()
Return the load report |
LogCleaner |
getLogCleaner()
Returns the LogCleaner. |
String |
getLogFilename()
Return the name of the log file. |
List<InnerLogEntry> |
getMilestoneList()
Returns the list of milestones. |
Stamp |
getProgressStamp()
Return the greatest stamp of this urid |
Stamp |
getProgressStamp(String urid)
Return the greatest stamp of the given urid |
StampTable |
getProgressTable()
Return the progressTable |
int |
getSize()
Return the size of the store. |
Stamp |
getStamp()
Return a new stamp. |
int |
getStampLineNumber(Stamp stamp)
Returns the line number in the store file of the given stamp. |
int |
getState()
Return the current state of the store (see StoreConstants). |
Storable |
getStorable(String id)
Return the storable given its id |
Map<Class<?>,Set<StoreListener>> |
getStoreClassListeners(boolean repeat)
|
Set<StoreListener> |
getStoreListeners(boolean repeat)
|
SyncManager |
getSyncManager()
Return the SyncManager |
String |
getTagFromClass(Class<?> clazz)
Returns the tag name binded with a specified class |
String |
getUrid()
|
List<? extends Storable> |
getVersionList(Storable storable)
Get all the version of a given Storable |
List<? extends Storable> |
getVersionList(String id)
Get all the version of a given Storable ID |
boolean |
isReferrenced(Storable storable)
|
boolean |
isRegistered(Storable storable)
|
boolean |
isRegistered(String id)
|
Iterator<Storable> |
iterator()
Return an iterator on the storables registered in the swizzler |
void |
load()
Load and process the log |
void |
load(boolean processStorable,
boolean processInner)
Load and process the log |
void |
parseLog(LogManagerHandler handler)
Parse the store with the given handler |
boolean |
parseLog(LogManagerHandler handler,
int startLine)
Parse the store with the given handler from the given line number |
void |
parseLog(LogManagerHandler handler,
Stamp stamp)
Parse the store with the given handler from the given stamp |
void |
printMemoryToLog(OutputStream out)
Prints a cleaned version of the log. |
void |
processInnerLogEntry(InnerLogEntry logEntry)
|
void |
processLogEntry(LogEntry logEntry)
|
void |
processStorableLogEntry(StorableLogEntry storableLog)
|
void |
removeStoreListener(StoreListener listener)
|
void |
removeStoreListener(StoreListener listener,
Class<?> clazz)
|
void |
replaceSuffix(TreeSet<StorableLogEntry> newSuffix,
LogEntry startLogEntry,
boolean includeStart)
|
void |
setClassLoader(ClassLoader classLoader)
Set the classLoader |
void |
setReplaceSuffixLimit(int replaceSuffixLimit)
A store suffix replacement starting before the limit will be rejected. |
void |
setUrid(String urid)
Set the current urid value |
void |
update(Storable storable,
Map<String,String> attributes)
Update a storable. |
void |
update(Storable storable,
Storable updated)
Update a storable. |
void |
update(String id,
Map<String,String> attributes)
Update a storable. |
void |
update(String id,
Storable updated)
Update a storable. |
void |
updateStamp(Stamp stamp)
Update the current stamp value (and the progress table) |
void |
updateStamp(Stamp stamp,
boolean updatePT)
Update the current stamp value |
boolean |
verifyLastStampIndex()
Verify if the last (highest) stamp is correctly indexed. |
boolean |
verifyStampLineMap()
Verify if the stamps are correctly indexed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String REVISION
public static final boolean DEFAULT_HANDLER_FLAG
public Object storeAccessLock
Constructor Detail |
---|
public Store(String logFilename) throws IOException
logFilename
- the name of the file which contains the log
IOException
public Store(String logFilename, boolean areHandlersEnabled) throws IOException
logFilename
- the name of the file which contains the logareHandlersEnabled
- specify if the precompiled store handlers are supported.
IOException
public Store(String logFilename, boolean areHandlersEnabled, String urid, boolean useNIO) throws IOException
logFilename
- the name of the file which contains the logareHandlersEnabled
- specify if the precompiled store handlers are supported.urid
- the URIDuseNIO
- specify if the NIO must be used (faster store access)
IOException
Method Detail |
---|
public void addExtraDeleteAttribute(String attName)
attName
- the attribute namepublic Set<String> getExtraDeleteAttributeSet()
public void setClassLoader(ClassLoader classLoader)
classLoader
- the classLoader to usepublic void addClassTag(String tag, Class<?> clazz)
tag
- the nam of the tagclazz
- the classpublic String getTagFromClass(Class<?> clazz)
clazz
- the class
public Class<?> getClassFromTag(String tag) throws ClassNotFoundException
tag
- the tag name
ClassNotFoundException
public Storable getStorable(String id)
id
- the storable id
public boolean isReferrenced(Storable storable)
storable
- the storable to check
public boolean isRegistered(Storable storable)
storable
- the storable to check
public boolean isRegistered(String id)
id
- the storable id
public List<? extends Storable> getVersionList(Storable storable)
storable
- the storable
public List<? extends Storable> getVersionList(String id)
id
- the ID of storable
public TreeSet<? extends Storable> getDeletedSet(Class<?> clazz)
clazz
- the searched class
public int generateDelta(OutputStream out, Stamp startStamp, boolean includeStart) throws LogException
out
- the outputstream to use to output the operationsstartStamp
- the stamp to start the copy
LogException
public void parseLog(LogManagerHandler handler) throws LogException
handler
- the handler used to parse the store
LogException
public void parseLog(LogManagerHandler handler, Stamp stamp) throws LogException
handler
- the handler used to parse the storestamp
- the stamp to start the parsing
LogException
public boolean parseLog(LogManagerHandler handler, int startLine)
handler
- the handler used to parse the storestartLine
- the line number to start the parsing
public void replaceSuffix(TreeSet<StorableLogEntry> newSuffix, LogEntry startLogEntry, boolean includeStart) throws IOException
IOException
LogManager.replaceSuffix(java.util.TreeSet,com.jalios.jstore.LogEntry,boolean,boolean)
public void appendAndProcessSuffix(List<? extends LogEntry> logEntryList) throws IOException
logEntryList
- the list of logEntry. It assumes the logEntries are sorted according their stamps
IOException
public Iterator<Storable> iterator()
public int getSize()
public int getState()
public String getUrid()
StampManager.getUrid()
public void setUrid(String urid)
StampManager.setUrid(String)
public void updateStamp(Stamp stamp)
stamp
- the stamp to be addedupdateStamp(Stamp, boolean)
public void updateStamp(Stamp stamp, boolean updatePT)
stamp
- the stamp to be addedupdatePT
- if true use this stamp to update the progress tableStampManager.update(com.jalios.jstore.Stamp,boolean)
public Stamp getStamp()
StampManager.getStamp()
public StampTable getProgressTable()
StampManager.getProgressTable()
public Stamp getProgressStamp()
StampManager.getProgressStamp(String)
public Stamp getProgressStamp(String urid)
urid
- the urid
StampManager.getProgressStamp(String)
public SyncManager getSyncManager()
public void load() throws LogException
LogException
public void load(boolean processStorable, boolean processInner) throws LogException
processStorable
- if true the storable operations are processed. If false only the stamps information are processed.processInner
- if true the storable operations are processed. If false only the stamps information are processed.
LogException
public void processLogEntry(LogEntry logEntry)
public void processInnerLogEntry(InnerLogEntry logEntry)
public void processStorableLogEntry(StorableLogEntry storableLog)
public void create(Storable storable) throws IOException
storable
- the storable to create.
IOException
public void create(Storable storable, boolean overrideId) throws IOException
storable
- overrideId
-
IOException
public void update(String id, Map<String,String> attributes) throws IOException
id
- the id of the storable to updateattributes
- the map that contains the new attributes values
IOException
public void update(Storable storable, Map<String,String> attributes) throws IOException
storable
- the storable to updateattributes
- the map that contains the new attributes values
IOException
public void update(String id, Storable updated) throws IOException, NoUpdateException
storable
and updated
.
id
- the id of the storable to updateupdated
- the updated storable
IOException
NoUpdateException
public void update(Storable storable, Storable updated) throws IOException, NoUpdateException
storable
and updated
.
storable
- the storable to updateupdated
- the updated storable
NoUpdateException
- on error, for example when given objects are same instance
IOException
public void delete(Storable storable) throws IOException
storable
- the storable to delete
IOException
public void delete(Storable storable, boolean force) throws IOException
storable
- the storable to deleteforce
- if true the referenced storable attributes are
deleted
IOException
public List<InnerLogEntry> getMilestoneList()
public void appendMilestone(String text) throws IOException
text
- the text of the milestone.
IOException
public void appendMilestone(Map<String,String> map) throws IOException
map
- the map of attributes.
IOException
public void appendSync(Date date) throws IOException
date
- the date of the sync.
IOException
public void generateLogFromMemory(String backupFilename) throws IOException
printCleanedLog
method. If a backup filename is provided (i.e. not null
), the current log file is copy into before to
be cleaned.
backupFilename
- the name of the file to backup the current log
IOException
public void printMemoryToLog(OutputStream out) throws Exception
out
- the OutputStream in which to print the cleaned log
Exception
public LogCleaner getLogCleaner()
public String getLogFilename()
public LoadReport getLoadReport()
public int getStampLineNumber(Stamp stamp)
stamp
- the stamp to get the line number
public boolean verifyStampLineMap()
public boolean verifyLastStampIndex()
public int getCreationLineNumber(String id)
id
- the id of the storable
public boolean backupStore(File backupFile)
backupFile
- the backup file.
LogManager.backupStore(File)
public void setReplaceSuffixLimit(int replaceSuffixLimit)
replaceSuffixLimit
- the limit (in number of lines).public Set<StoreListener> getStoreListeners(boolean repeat)
public Map<Class<?>,Set<StoreListener>> getStoreClassListeners(boolean repeat)
public void addStoreListener(StoreListener listener, boolean repeat)
public void addStoreListener(StoreListener listener, Class<?> clazz, boolean repeat)
public void removeStoreListener(StoreListener listener)
public void removeStoreListener(StoreListener listener, Class<?> clazz)
public void close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |