Package net.anotheria.anodoc.service
Class ModuleServiceImpl
- java.lang.Object
-
- net.anotheria.anodoc.service.ModuleServiceImpl
-
- All Implemented Interfaces:
IModuleService,IModuleListener
public class ModuleServiceImpl extends java.lang.Object implements IModuleService, IModuleListener
An implementation of IModuleService for local usage, which supports local cache and synchronization over network.- Version:
- $Id: $Id
- Author:
- another
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_COPY_IDConstant used for 'copy' if none is specified.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddModuleListener(java.lang.String moduleId, java.lang.String ownerId, IModuleListener aModuleListeners)Adds listener for module.voidattachModuleFactory(java.lang.String moduleId, IModuleFactory factory)Attaches a factory for a given moduleId.voidattachModuleStorage(java.lang.String moduleId, IModuleStorage storage)Attaches a storage for a given moduleId.voiddeleteModule(java.lang.String ownerId, java.lang.String moduleId)Deletes the module identified by the tuple (ownerId | moduleId) from the appropriate storage.voiddeleteModule(java.lang.String ownerId, java.lang.String moduleId, java.lang.String copyId)Deletes the module identified by the tuple (ownerId | moduleId | copyId) from the appropriate storage.voiddeleteModule(Module module)Deletes the given module from the appropriate storage.protected static ModuleServiceImplgetInstance()Returns the current (singleton) instance of this implementation.ModulegetModule(java.lang.String ownerId, java.lang.String moduleId)getModule.ModulegetModule(java.lang.String ownerId, java.lang.String moduleId, boolean create)Same as getModule(ownerId, moduleId, default_copy_id, create?)ModulegetModule(java.lang.String ownerId, java.lang.String moduleId, java.lang.String copyId)Same as return getModule(ownerId, moduleId, copyId, false); in current implementation.ModulegetModule(java.lang.String ownerId, java.lang.String moduleId, java.lang.String copyId, boolean create)This function retrieves the appropriate Module from the storage and returns it.voidmoduleLoaded(Module module)Called if module changed.voidnotifyConfigurationFinished()notifyConfigurationFinished.voidremoveModuleListener(java.lang.String moduleId, java.lang.String ownerId)Removes listener for module.voidstoreModule(Module module)Stores the given module in the appropriate storage.
-
-
-
Field Detail
-
DEFAULT_COPY_ID
public static final java.lang.String DEFAULT_COPY_ID
Constant used for 'copy' if none is specified.- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
protected static ModuleServiceImpl getInstance()
Returns the current (singleton) instance of this implementation.- Returns:
- a
ModuleServiceImplobject.
-
attachModuleFactory
public void attachModuleFactory(java.lang.String moduleId, IModuleFactory factory)Attaches a factory for a given moduleId. Attaches a factory for given module id.- Specified by:
attachModuleFactoryin interfaceIModuleService- Parameters:
moduleId- aStringobject.factory- aIModuleFactoryobject.
-
attachModuleStorage
public void attachModuleStorage(java.lang.String moduleId, IModuleStorage storage)Attaches a storage for a given moduleId. Attaches a storage for given module id.- Specified by:
attachModuleStoragein interfaceIModuleService- Parameters:
moduleId- aStringobject.storage- aIModuleStorageobject.
-
getModule
public Module getModule(java.lang.String ownerId, java.lang.String moduleId, java.lang.String copyId) throws NoStorageForModuleException, NoFactoryForModuleException, NoStoredModuleEntityException, StorageFailureException
Same as return getModule(ownerId, moduleId, copyId, false); in current implementation. Same as getModule(ownerId, moduleId, copyId, false)- Specified by:
getModulein interfaceIModuleService- Parameters:
ownerId- aStringobject.moduleId- aStringobject.copyId- aStringobject.- Returns:
- a
Moduleobject. - Throws:
NoStorageForModuleException- if any.NoFactoryForModuleException- if any.NoStoredModuleEntityException- if any.StorageFailureException- if any.
-
getModule
public Module getModule(java.lang.String ownerId, java.lang.String moduleId) throws NoStorageForModuleException, NoFactoryForModuleException, NoStoredModuleEntityException, StorageFailureException
getModule.
Same as getModule(ownerId, moduleId, default_copy_id, false)- Specified by:
getModulein interfaceIModuleService- Parameters:
ownerId- aStringobject.moduleId- aStringobject.- Returns:
- a
Moduleobject. - Throws:
NoStorageForModuleException- if any.NoFactoryForModuleException- if any.NoStoredModuleEntityException- if any.StorageFailureException- if any.
-
getModule
public Module getModule(java.lang.String ownerId, java.lang.String moduleId, boolean create) throws NoStorageForModuleException, NoFactoryForModuleException, NoStoredModuleEntityException, StorageFailureException
Same as getModule(ownerId, moduleId, default_copy_id, create?)- Specified by:
getModulein interfaceIModuleService- Parameters:
ownerId- aStringobject.moduleId- aStringobject.create- a boolean.- Returns:
- a
Moduleobject. - Throws:
NoStorageForModuleException- if any.NoFactoryForModuleException- if any.NoStoredModuleEntityException- if any.StorageFailureException- if any.
-
getModule
public Module getModule(java.lang.String ownerId, java.lang.String moduleId, java.lang.String copyId, boolean create) throws NoStorageForModuleException, NoFactoryForModuleException, NoStoredModuleEntityException, StorageFailureException
This function retrieves the appropriate Module from the storage and returns it. If the create flag is set, and no module instance is available (NoStoredModuleEntityException) a new Module instance will be created by the previously attached Factory and returned.- Specified by:
getModulein interfaceIModuleService- Parameters:
ownerId- the id of the owner of this module.moduleId- the id of the modulecopyId- the copy id.create- if true and the module doesn't exists yet, it will be created.- Returns:
- retrieved Module
- Throws:
NoStorageForModuleException- if any.NoFactoryForModuleException- if any.NoStoredModuleEntityException- if any.StorageFailureException- if any.
-
storeModule
public void storeModule(Module module) throws NoStorageForModuleException, StorageFailureException
Stores the given module in the appropriate storage.- Specified by:
storeModulein interfaceIModuleService- Parameters:
module- the module to store.- Throws:
NoStorageForModuleException- thrown if no storage for this moduleId is attached.StorageFailureException- thrown if the storage failed.
-
deleteModule
public void deleteModule(Module module) throws NoStorageForModuleException, StorageFailureException
Deletes the given module from the appropriate storage.- Specified by:
deleteModulein interfaceIModuleService- Parameters:
module- aModuleobject.- Throws:
NoStorageForModuleException- if any.StorageFailureException- if any.
-
deleteModule
public void deleteModule(java.lang.String ownerId, java.lang.String moduleId, java.lang.String copyId) throws NoStorageForModuleException, StorageFailureExceptionDeletes the module identified by the tuple (ownerId | moduleId | copyId) from the appropriate storage.- Specified by:
deleteModulein interfaceIModuleService- Parameters:
ownerId- aStringobject.moduleId- aStringobject.copyId- aStringobject.- Throws:
NoStorageForModuleException- if any.StorageFailureException- if any.
-
deleteModule
public void deleteModule(java.lang.String ownerId, java.lang.String moduleId) throws NoStorageForModuleException, StorageFailureExceptionDeletes the module identified by the tuple (ownerId | moduleId) from the appropriate storage. The copy id is assumed to be the standart copyId.- Specified by:
deleteModulein interfaceIModuleService- Parameters:
ownerId- aStringobject.moduleId- aStringobject.- Throws:
NoStorageForModuleException- if any.StorageFailureException- if any.
-
moduleLoaded
public void moduleLoaded(Module module)
Called if module changed. Removes changed module from cache and fires moduleLoaded event of registered listener.- Specified by:
moduleLoadedin interfaceIModuleListener- Parameters:
module- changed module.
-
addModuleListener
public void addModuleListener(java.lang.String moduleId, java.lang.String ownerId, IModuleListener aModuleListeners)Adds listener for module.- Specified by:
addModuleListenerin interfaceIModuleService- Parameters:
moduleId- module id of module.ownerId- owner id of module.aModuleListeners- listener to add.
-
removeModuleListener
public void removeModuleListener(java.lang.String moduleId, java.lang.String ownerId)Removes listener for module. Removes listener for module.- Specified by:
removeModuleListenerin interfaceIModuleService- Parameters:
moduleId- id of module.ownerId- owner id for module.
-
notifyConfigurationFinished
public void notifyConfigurationFinished()
notifyConfigurationFinished.
-
-