Package gov.usgs.earthquake.distribution
Interface ProductStorage
-
- All Superinterfaces:
Configurable
- All Known Implementing Classes:
DYFILegacyStorage
,FileProductStorage
,HashFileProductStorage
,JsonProductStorage
,URLProductStorage
public interface ProductStorage extends Configurable
Stores and retrieves Products. This is typically used by a NotificationReceiver to store downloaded products.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addStorageListener(StorageListener listener)
Adds aStorageListener
to be notified when a change occurs in thisProductStorage
.Product
getProduct(ProductId id)
Retrieve a stored product.ProductSource
getProductSource(ProductId id)
Retrieve a ProductSource for a stored product.boolean
hasProduct(ProductId id)
A method to check whether a product is already in storage.void
notifyListeners(StorageEvent event)
NotifiesStorageListener
s of the change to theProductStorage
.void
removeProduct(ProductId id)
Remove a Product from storage, if it exists.void
removeStorageListener(StorageListener listener)
Removes aStorageListener
from being notified when a change occurs in thisProductStorage
.ProductId
storeProduct(Product product)
Store a product.ProductId
storeProductSource(ProductSource input)
Store a ProductSource.
-
-
-
Method Detail
-
hasProduct
boolean hasProduct(ProductId id) throws java.lang.Exception
A method to check whether a product is already in storage. Implementers should define this method as more than "getProduct(id) != null" when it is significantly less expensive to check whether a product exists, compared to loading a product from storage.- Parameters:
id
- the product to check.- Returns:
- true if the product is in this storage, false otherwise.
- Throws:
java.lang.Exception
- if an error occurs while checking.
-
getProduct
Product getProduct(ProductId id) throws java.lang.Exception
Retrieve a stored product. May be implemented asreturn ObjectProductHandler.getProduct(getProductInput(id));
- Parameters:
id
- which product to retrieve.- Returns:
- the retrieved product, or null if the product isn't in storage.
- Throws:
java.lang.Exception
- if errors occur while retrieving product.
-
storeProduct
ProductId storeProduct(Product product) throws java.lang.Exception
Store a product. May be implemented asreturn storeProductSource(new ObjectProductInput(product));
- Parameters:
product
- the product to store.- Returns:
- the stored product's id.
- Throws:
java.lang.Exception
- if errors occur while storing product.
-
getProductSource
ProductSource getProductSource(ProductId id) throws java.lang.Exception
Retrieve a ProductSource for a stored product.- Parameters:
id
- which product to retrieve.- Returns:
- a ProductInput for the stored product, or null if not in storage.
- Throws:
java.lang.Exception
- if any errors occur while getting the ProductInput.
-
storeProductSource
ProductId storeProductSource(ProductSource input) throws java.lang.Exception
Store a ProductSource.- Parameters:
input
- the product to store.- Returns:
- the stored product's id.
- Throws:
java.lang.Exception
- if errors occur while storing product.
-
removeProduct
void removeProduct(ProductId id) throws java.lang.Exception
Remove a Product from storage, if it exists.- Parameters:
id
- which product to remove.- Throws:
java.lang.Exception
- if errors occur while removing product.
-
notifyListeners
void notifyListeners(StorageEvent event)
NotifiesStorageListener
s of the change to theProductStorage
.- Parameters:
event
- StorageEvent
-
addStorageListener
void addStorageListener(StorageListener listener)
Adds aStorageListener
to be notified when a change occurs in thisProductStorage
.- Parameters:
listener
- The listener to notify of changes.
-
removeStorageListener
void removeStorageListener(StorageListener listener)
Removes aStorageListener
from being notified when a change occurs in thisProductStorage
.- Parameters:
listener
- The listener to remove
-
-