com.ados.hestia.utils.io
Class StoreRepository

java.lang.Object
  extended by com.ados.hestia.utils.io.StoreRepository
Direct Known Subclasses:
DBStoreRepository, FileStoreRepository

public abstract class StoreRepository
extends Object

History. Nov 16, 2004. Refactored. Add dependence from folder. Converted from factory to repository. Nov 17, 2004. Clear temp folder on start. Apr 22, 2005. Did this class as base for all other repository type. Implements storing of temporary data at fs. Apr 25, 2005. Add restoreFromRemoteReceiving/prepareForRemoteSending.

Version:
$Revision: 1765 $ $Date: 2006-04-10 07:08:59 +0900 $

Field Summary
protected  File m_tempFolder
           
 
Constructor Summary
StoreRepository(String tempfolder)
           
 
Method Summary
protected static void closeStreamSafe(Object stream)
           
 IStore createStore()
          Allocate store at repository.
 IStore createStore(InputStream stream)
          Allocate and return store.
abstract  IStore createStore(String storeID)
          Allocate store at repository with required id.
 IStore createStore(String storeid, InputStream stream)
          Allocate and return store.
 IStore createTempStore()
          Create and return temporary store.
 IStore createTempStore(InputStream stream)
          Create and return temporary store.
 void delete(IStore store)
          Delete store from repository.
abstract  String getID()
          Returns uid for repository.
 IStore getStore(String storeID)
          Returns existing store with specific ID.
abstract  IStore getStoreSafe(String storeID)
          Returns existing store with specific ID.
 IStore prepareForRemoteSending(IRMIStoreAccess rmi, IStore store)
          Create at remote side equvalent for store.
 IStore restoreFromRemoteReceiving(IRMIStoreAccess rmi, IStore store)
          Restore store after receiving it from remote side.
abstract  void setReferenceID(IStore store, String referenceID)
          Set reference id to requested store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_tempFolder

protected File m_tempFolder
Constructor Detail

StoreRepository

public StoreRepository(String tempfolder)
Method Detail

setReferenceID

public abstract void setReferenceID(IStore store,
                                    String referenceID)
                             throws IOException
Set reference id to requested store.

Parameters:
store - store to process.
referenceID - reference to set.
Throws:
IOException - if impossible to set.

createTempStore

public IStore createTempStore()
Create and return temporary store. The data at this store will be removed automatically when object will be destroyed or virtual machine restarted.

Returns:
created temporary store

createTempStore

public IStore createTempStore(InputStream stream)
                       throws IOException
Create and return temporary store. The data at this store will be removed automatically when object will be destroyed or virtual machine restarted. The content of store will be automatically filled from provided InputStream.

Parameters:
stream - stream to fill content of store
Returns:
created temporary filled by provided stream store
Throws:
IOException

getStore

public IStore getStore(String storeID)
                throws IOException
Returns existing store with specific ID. Existing store must not be temporary.

Parameters:
storeID - id of store.
Returns:
existing store with specific ID. Existing store must not be temporary
Throws:
IOException - if store can not be found;

getStoreSafe

public abstract IStore getStoreSafe(String storeID)
Returns existing store with specific ID. Existing store must not be temporary.

Parameters:
storeID - id of store.
Returns:
existing store with specific ID. Existing store must not be temporary

createStore

public IStore createStore()
Allocate store at repository. ID will be generated automatically.

Returns:
allocated at repository store. ID will be generated automatically

createStore

public abstract IStore createStore(String storeID)
Allocate store at repository with required id.

Parameters:
storeID - required store id
Returns:
allocated store.

createStore

public IStore createStore(InputStream stream)
                   throws IOException
Allocate and return store. The data at this store The content of store will be automatically filled from provided InputStream.

Parameters:
stream - stream to fill content of store
Returns:
created temporary filled by provided stream store
Throws:
IOException

createStore

public IStore createStore(String storeid,
                          InputStream stream)
                   throws IOException
Allocate and return store. The data at this store The content of store will be automatically filled from provided InputStream.

Parameters:
storeid - -id of created store
stream - stream to fill content of store
Returns:
created temporary filled by provided stream store
Throws:
IOException

delete

public void delete(IStore store)
Delete store from repository.

Parameters:
store - store to delete;

closeStreamSafe

protected static void closeStreamSafe(Object stream)

prepareForRemoteSending

public IStore prepareForRemoteSending(IRMIStoreAccess rmi,
                                      IStore store)
                               throws IOException
Create at remote side equvalent for store.

Parameters:
rmi - remote access interface
store - store to send to remote side
Returns:
store which is at remote side
Throws:
IOException - if data cannot be allocated, read or wrote

restoreFromRemoteReceiving

public IStore restoreFromRemoteReceiving(IRMIStoreAccess rmi,
                                         IStore store)
                                  throws IOException
Restore store after receiving it from remote side.

Parameters:
rmi - remote access interface
store - store wich was received
Returns:
store at cuurent repository which is equvalent of remote repository
Throws:
IOException - if data cannot be allocated, read or wrote

getID

public abstract String getID()
Returns uid for repository.

Returns:
uid for repository


Copyright © 2005-2006 ADOS Co.,Ltd.. All Rights Reserved.