Package org.sblim.cimclient.discovery
Class AdvertisementCatalog
- java.lang.Object
-
- org.sblim.cimclient.discovery.AdvertisementCatalog
-
public class AdvertisementCatalog extends java.lang.Object
Class AdvertisementCatalog implements a catalog for WBEM service advertisements. In practice we usually have multiple advertisements for a single service, because the DMTF mandates an advertisement per remote service access point (e.g. http, https, rmi). This class tries to ease the management of this by indexing services by the unique service id and therefore surfacing which advertisements belong to the same service. The application might then choose it's preferred communication mechanism.- Since:
- 2.0.2
- Threading considerations:
- No thread synchronization provided, this is the responsibility of the caller.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AdvertisementCatalog.EventListener
Interface EventListener specifies listener that are called when an advertisement is added to or removed from the catalog, expires or is renewed.
-
Field Summary
Fields Modifier and Type Field Description static int
EVENT_ADD
Event code when advertisement is addedstatic int
EVENT_EXPIRE
Event code when advertisement expiresstatic int
EVENT_REMOVE
Event code when advertisement is removedstatic int
EVENT_RENEW
Event code when advertisement is renewed
-
Constructor Summary
Constructors Constructor Description AdvertisementCatalog()
Ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAdvertisements(WBEMServiceAdvertisement[] pAdvertisements)
Adds new advertisements to the catalog.void
addEventListener(AdvertisementCatalog.EventListener pListener)
Adds a listener for "add" events.WBEMServiceAdvertisement
getAdvertisement(java.lang.String pId, WBEMProtocol[] pProtocols)
Returns the advertisement from the catalog corresponding to a given id and with the protocol preferred most.WBEMServiceAdvertisement[]
getAdvertisementsByDirectory(java.lang.String pDirectory)
Returns the advertisements from the catalog corresponding to a given directoryWBEMServiceAdvertisement[]
getAdvertisementsById(java.lang.String pId)
Returns the advertisements from the catalog corresponding to a given idjava.lang.String[]
getKnownIds()
Returns an array of service ids known by this catalogvoid
refreshAdvertisements(java.lang.String[] pDirectory, WBEMServiceAdvertisement[] pAdvertisements)
Refreshes the advertisements from a given directory.void
removeEventListener(AdvertisementCatalog.EventListener pListener)
Removes a listenervoid
removeExpired(java.lang.String pDirectory)
Removes the expired advertisements from the catalog.java.lang.String
toString()
-
-
-
Field Detail
-
EVENT_ADD
public static int EVENT_ADD
Event code when advertisement is added
-
EVENT_REMOVE
public static int EVENT_REMOVE
Event code when advertisement is removed
-
EVENT_EXPIRE
public static int EVENT_EXPIRE
Event code when advertisement expires
-
EVENT_RENEW
public static int EVENT_RENEW
Event code when advertisement is renewed
-
-
Method Detail
-
addEventListener
public void addEventListener(AdvertisementCatalog.EventListener pListener)
Adds a listener for "add" events. The listener will be called whenever a advertisement is added to the catalog.- Parameters:
pListener
- The listener
-
addAdvertisements
public void addAdvertisements(WBEMServiceAdvertisement[] pAdvertisements)
Adds new advertisements to the catalog. Existing advertisements sharing concrete type, url and directory are replaced.- Parameters:
pAdvertisements
- The new advertisements
-
getAdvertisement
public WBEMServiceAdvertisement getAdvertisement(java.lang.String pId, WBEMProtocol[] pProtocols)
Returns the advertisement from the catalog corresponding to a given id and with the protocol preferred most.- Parameters:
pId
- The service idpProtocols
- An array containing the desired protocols in order of preference. If a service doesn't advertise any of the given protocols this service returns null.- Returns:
- The corresponding advertisement
-
getAdvertisementsByDirectory
public WBEMServiceAdvertisement[] getAdvertisementsByDirectory(java.lang.String pDirectory)
Returns the advertisements from the catalog corresponding to a given directory- Parameters:
pDirectory
- The directory service- Returns:
- The corresponding advertisements
-
getAdvertisementsById
public WBEMServiceAdvertisement[] getAdvertisementsById(java.lang.String pId)
Returns the advertisements from the catalog corresponding to a given id- Parameters:
pId
- The service id- Returns:
- The corresponding advertisements
-
getKnownIds
public java.lang.String[] getKnownIds()
Returns an array of service ids known by this catalog- Returns:
- The service ids
-
refreshAdvertisements
public void refreshAdvertisements(java.lang.String[] pDirectory, WBEMServiceAdvertisement[] pAdvertisements)
Refreshes the advertisements from a given directory. All existing advertisements from this directory are deleted first before the new ones are added.- Parameters:
pDirectory
- The directory services we got the advertisements frompAdvertisements
- The advertisements
-
removeEventListener
public void removeEventListener(AdvertisementCatalog.EventListener pListener)
Removes a listener- Parameters:
pListener
- The listener to remove
-
removeExpired
public void removeExpired(java.lang.String pDirectory)
Removes the expired advertisements from the catalog.- Parameters:
pDirectory
- Whennot null
only the expired advertisements of the given directory are removed. Otherwise all expired advertisements are removed.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-