amwebarsentitlementservice.protocol
Class AMWebARSProtocol

java.lang.Object
  |
  +--amwebarsentitlementservice.protocol.AMWebARSProtocol
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BrowserBasedProtocol, FixedProviderProtocol

public abstract class AMWebARSProtocol
extends java.lang.Object
implements java.lang.Cloneable

The AMWebARSProtocol is the superclass of all protocols. It provides the infrastructure to do the Single Instance by ID pattern. The Protocol allows cloning. Together with the ProtocolTable it implements the Prototype pattern. The ProtocolTable stores the prototypes of the AMWebARSProtocols.

See Also:
ProtocolTable

Field Summary
protected  boolean _initialized
           
static java.lang.String CLASS_NAME_XML_NAME
           
static java.lang.String PROTOCOL_ID_XML_NAME
           
static java.lang.String PROTOCOL_XML_NAME
           
 
Method Summary
 java.lang.Object clone()
          Clones (copies) this AMWebARSProtocol.
 boolean equals(java.lang.Object other_object)
          Tests whether this AMWebARSProtocol is equal to another.
abstract  AMWebARSProtocolMemento generateMemento()
           
 AMWebARSClient getClient()
          Gets the client.
static AMWebARSProtocol getInstance(java.lang.String protocol_id)
           
abstract  ProtocolSpecificClientFactory getPreferedFactory()
          Returns the factory this protocol prefers.
 java.lang.String getProtocolID()
          retruns the protocol_id of this protocol.
abstract  ProtocolInitStatus initialize()
          Initializes the protocol.
 boolean isInitialized()
          Tests whether the initialize method run successfully.
abstract  ProtocolRunStatus run()
          Runs the protocol.
 void setClient(AMWebARSClient client)
          Sets the client.
abstract  void setMemento(AMWebARSProtocolMemento memento)
           
abstract  ProtocolShutdownStatus shutdown()
           
 java.lang.String toString()
           
 org.jdom.Element toXML()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROTOCOL_XML_NAME

public static final java.lang.String PROTOCOL_XML_NAME

PROTOCOL_ID_XML_NAME

public static final java.lang.String PROTOCOL_ID_XML_NAME

CLASS_NAME_XML_NAME

public static final java.lang.String CLASS_NAME_XML_NAME

_initialized

protected boolean _initialized
Method Detail

getInstance

public static AMWebARSProtocol getInstance(java.lang.String protocol_id)
                                    throws java.lang.CloneNotSupportedException

clone

public java.lang.Object clone()
Clones (copies) this AMWebARSProtocol. It's used to implement the Prototype pattern. The cloning is invoked by the ProtocolTable.
Overrides:
clone in class java.lang.Object

getClient

public AMWebARSClient getClient()
Gets the client.
Returns:
Returns a AMWebARSClient

setClient

public void setClient(AMWebARSClient client)
Sets the client.
Parameters:
client - The client to set

getPreferedFactory

public abstract ProtocolSpecificClientFactory getPreferedFactory()
Returns the factory this protocol prefers.

initialize

public abstract ProtocolInitStatus initialize()
Initializes the protocol. This has to be done before the protocol runs.

run

public abstract ProtocolRunStatus run()
Runs the protocol. A protocol's run method has to do the following steps:
  1. Test whether the protocol is initialized. If not, return a new ProtocolRunException with containing an UnsupportedOperationException.
  2. Get the container descriptors to retrieve from the client: getClient().elements();
  3. Retrieve the containers. If one is found remove the corresponding descriptor from the client's descriptor iterator and add the container to the client:
    getClient().addContainer(retrieved_container);
    container_descriptors.remove();
  4. return PROTOCOL_RUN_SUCCESS; if any exception occurs return a new ProtocolRunException.

shutdown

public abstract ProtocolShutdownStatus shutdown()

generateMemento

public abstract AMWebARSProtocolMemento generateMemento()

setMemento

public abstract void setMemento(AMWebARSProtocolMemento memento)

isInitialized

public boolean isInitialized()
Tests whether the initialize method run successfully.

getProtocolID

public java.lang.String getProtocolID()
retruns the protocol_id of this protocol.

toXML

public org.jdom.Element toXML()

equals

public boolean equals(java.lang.Object other_object)
Tests whether this AMWebARSProtocol is equal to another.
Overrides:
equals in class java.lang.Object
Returns:
boolean true if both obj are the same.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object