Package com.wombat.mama
Class MamaSourceGroup
- java.lang.Object
-
- com.wombat.mama.MamaSourceGroup
-
- All Implemented Interfaces:
MamaSourceGroupListener
public class MamaSourceGroup extends java.lang.Object implements MamaSourceGroupListener
-
-
Constructor Summary
Constructors Constructor Description MamaSourceGroup(java.lang.String name)
Create a mamaSourceGroup object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSource(MamaSource source, long weight)
Add a mamaSource to the specified group with the specified weighting.void
addSourceWithName(MamaSource source, java.lang.String sourceName, long weight)
Add a mamaSource to the specified group with the specified weighting and string name identifier.void
disableLogging()
void
enableLogging(java.util.logging.Level level)
MamaSource
findSource(java.lang.String sourceName)
Find a source with the given name in the group.java.lang.String
getName()
Return the name string identifier for the specified source group.MamaSource
getTopWeightSource()
Return the top weighted source for this source groupboolean
reevaluate()
Re-evaluate the group by checking all of the relative weights and changing the state of each MamaSource in the group as appropriate.void
registerStateChangeListener(MamaSourceStateChangeListener event)
Applications interested in event notifications can register for events.void
setSourceWeight(java.lang.String sourceName, long weight)
Set the weight for an existing mamaSource in the specified group.java.util.Iterator
sourceIterator()
void
unregisterStateChangeListener(MamaSourceStateChangeListener event)
Applications interested in event notifications can unregister for events.
-
-
-
Method Detail
-
enableLogging
public void enableLogging(java.util.logging.Level level)
-
disableLogging
public void disableLogging()
-
getName
public java.lang.String getName()
Return the name string identifier for the specified source group.- Returns:
- The group name
-
findSource
public MamaSource findSource(java.lang.String sourceName)
Find a source with the given name in the group.- Parameters:
sourceName
- The name identifier for the source being located.- Returns:
- MamaSource
-
addSource
public void addSource(MamaSource source, long weight)
Add a mamaSource to the specified group with the specified weighting. The source id will be used by the group to uniquely identify the source.- Parameters:
source
- The mamaSource being added to the mamaSourceGroup.weight
- The weighing to apply to the source being added.
-
addSourceWithName
public void addSourceWithName(MamaSource source, java.lang.String sourceName, long weight)
Add a mamaSource to the specified group with the specified weighting and string name identifier.- Parameters:
source
- The mamaSource being added to the mamaSourceGroup.sourceName
- The unique identifier for this source in this group.weight
- The weighing to apply to the source being added.
-
setSourceWeight
public void setSourceWeight(java.lang.String sourceName, long weight)
Set the weight for an existing mamaSource in the specified group.- Parameters:
sourceName
- The name of the source whose weight is being updated.weight
- The new weight value for the specified source.
-
reevaluate
public boolean reevaluate()
Re-evaluate the group by checking all of the relative weights and changing the state of each MamaSource in the group as appropriate. Returns true if any states were changed; otherwise false.- Returns:
- boolean Whether any states were changed as a result of the call. false indicates none were changed. true indicates that the state of one or more sources has changed.
-
getTopWeightSource
public MamaSource getTopWeightSource()
Return the top weighted source for this source group
-
registerStateChangeListener
public void registerStateChangeListener(MamaSourceStateChangeListener event)
Applications interested in event notifications can register for events.- Specified by:
registerStateChangeListener
in interfaceMamaSourceGroupListener
- Parameters:
event
- to register
-
unregisterStateChangeListener
public void unregisterStateChangeListener(MamaSourceStateChangeListener event)
Applications interested in event notifications can unregister for events.- Specified by:
unregisterStateChangeListener
in interfaceMamaSourceGroupListener
- Parameters:
event
- to unregister
-
sourceIterator
public java.util.Iterator sourceIterator()
-
-