|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object context.arch.BaseObject context.arch.widget.Widget context.arch.discoverer.Discoverer
This class allows to add a discovery system to the context toolkit.
The discoverer is found by context components thanks to multicast communications. The discoverer allow them to register to it (to send their complete description), to query to it (to retrieve the description of components that fit several characteristics), to subscribe to notification (the subscriber wants to be notified when the discoverer registers a new component that fit some characteristics), to lease it (when a component registers to the discoverer, it registers for a given period that is identified by a lease), to unregister (when the component lease ends or when the components wants).
When a context component is created, it does not know the other components. And it can subscribes to another component only if it knows the component's name, port and hostname. The discoverer registers all context components when they are created, it stores for each of them their description. So that a component is able to do a request to the discoverer to get one or more context components that fit some characteristics (for example : I want all widgets that has information about Anind in the CRB)
context.arch.discoverer.SearchEngine
,
ComponentDescription
,
DiscovererDescription
,
context.arch.discoverer.query.Query
,
Lease
,
LeasesWatcher
Field Summary | |
static java.lang.String |
ALL_RESULTS
Type of query reply : returns no query id and all results (with a maximum set by |
static java.lang.String |
APPLICATION
Component type : for application |
static java.lang.String |
CALLER
Tag used in LOOKUP_DISCOVERER to contain the description of the caller component |
static java.lang.String |
CALLER_ID
Tag used in LOOKUP_DISCOVERER inside CALLER tags for the component id Also used in LOOKUP_DISCOVERER_REPLY by discoverers |
static java.lang.String |
CASE_SENSITIVE
Type of matching for the query |
static java.lang.String |
CLASSNAME
Classname tag |
static java.lang.String |
COMPONENT_CLASSNAME
Tag used in DISCOVERER_REGISTRATION for component classname Tag also used in DISCOVERER_QUERY |
static java.lang.String |
COMPONENT_ID
Tag used in DISCOVERER_QUERY_REPLY to give the resulting component id |
static java.lang.String |
CONSTANT_ATTRIBUTE_NAME
Tag used in QueryElement to query the discoverer. |
static java.lang.String |
CONSTANT_ATTRIBUTE_NAME_VALUES
Tag used in DISCOVERER_REGISTRATION to contain the constant attributes of the component Tag also used in DISCOVERER_QUERY This tag is also used in QueryElement to query the discoverer. |
static java.lang.String |
CONSTANT_ATTRIBUTE_VALUE
Tag used in QueryElement to query the discoverer. |
static boolean |
DEBUG
Debug flag. |
static int |
DEFAULT_MAX_RESULTS
Default number of responses sent in replyt to a DISOVERER_QUERY message with a ALL_RESULTS type |
static int |
DEFAULT_PORT
Default port for discoverer to use |
static java.lang.String |
DISCOVERER
Tag used in LOOKUP_DISCOVERER_REPLY to contain the discoverer description |
static java.lang.String |
DISCOVERER_DESCRIPTION_FULL_RESPONSE
Tag used to determine level of detail of component description in response to subscribers |
static java.lang.String |
DISCOVERER_ID
Tag used in LOOKUP_DISCOVERER_REPLY for the discoverer id Also used in DISCOVERER_REGISTRATION |
static java.lang.String |
DISCOVERER_QUERY
Tag used for query messages to the discoverer |
static java.lang.String |
DISCOVERER_QUERY_CONTENT
Tag used in DISCOVERER_QUERY messages to the discoverer |
static java.lang.String |
DISCOVERER_QUERY_REPLY
Tag used for query reply messages to the discoverer |
static java.lang.String |
DISCOVERER_QUERY_REPLY_CONTENT
Tag used in DISCOVERER_QUERY_REPLY_CONTENTS messages |
static java.lang.String |
DISCOVERER_QUERY_REPLY_CONTENTS
Tag used in DISCOVERER_QUERY_REPLY messages to the discoverer |
static java.lang.String |
DISCOVERER_QUERY_TYPE
Tag used in DISCOVERER_QUERY_CONTENT to indicate the type of query reply |
static java.lang.String |
DISCOVERER_REGISTRATION
Message tag used by components to send to the discoverer their description |
static java.lang.String |
DISCOVERER_SUBSCRIBE
Message tag used by components to send to the discoverer a subscription |
static java.lang.String |
DISCOVERER_TYPE
|
static java.lang.String |
DISCOVERER_UNREGISTRATION
Message tag used by components to unregister from the discoverer |
static java.lang.String |
DISCOVERER_UNREGISTRATION_REPLY
Message tag used by the discoverer to reply to a DISCOVERER_UNREGISTRATION message |
static java.lang.String |
DISCOVERER_UPDATE
Message tag used by components to send to the discoverer an update |
static java.lang.String |
ERROR_EMPTY_QUERY
This tag is used when there is no response to the received query |
static java.lang.String |
ERROR_QUERY_NOT_FOUND
This tag is used when a NEXT_RESULT query is received and the queryId is not reckognized |
static java.lang.String |
ERROR_REGISTRATION_NOT_FOUND
This tag is used in error object for DISCOVERER_UNREGISTRATION_REPLY messages when the context component that want to be unregistered is not found. |
static java.lang.String |
FIELD_SEPARATOR
Separator used to separate fields (as for constant attribute name and value) |
static java.lang.String |
FIRST_RESULT
Type of query reply : returns the first element |
static java.lang.String |
HOSTADDRESS
Tag used in LOOKUP_DISCOVERER inside CALLER tags for the component IP address |
static java.lang.String |
HOSTNAME
Tag used in LOOKUP_DISCOVERER inside CALLER tags for the component hostname Also used in LOOKUP_DISCOVERER_REPLY, DISCOVERER_REGISTRATION |
static java.lang.String |
IGNORE_CASE
Type of matching for the query |
static java.lang.String |
INCOMING_ATTRIBUTE_NAME_VALUES
Tag used in DISCOVERER_REGISTRATION to contain the incoming attribute name values Tag also used in DISCOVERER_QUERY |
static java.lang.String |
INTERPRETER
Component type : for interpreter |
static java.lang.String |
LOCATION_ADDRESS
Tag used in DISOCVERER_REGISTRATION for the component location address Tag also used in DISCOVERER_QUERY |
static java.lang.String |
LOOKUP_DISCOVERER
Message tag used by components to send a multicast message to lookup a discoverer |
static java.lang.String |
LOOKUP_DISCOVERER_OK
Message tag used by discoverers to reply to a lookup message |
static java.lang.String |
LOOKUP_DISCOVERER_REPLY
Message tag used by discoverers to reply to a lookup message |
static java.lang.String |
MAXIMUM_RESULTS
Tag used if DISCOVERER_QUERY to set the maximum number of responses wanted |
protected DiscovererMediator |
mediator
|
static java.lang.String |
NEW_COMPONENT
This tag is the callback name used to notify subscriber of a new component |
static java.lang.String |
NEXT_RESULT
Type of query reply : returns the next result |
static java.lang.String |
NON_CONSTANT_ATTRIBUTE_NAME
Tag used in QueryElement to query the discoverer. |
static java.lang.String |
NON_CONSTANT_ATTRIBUTE_NAME_VALUES
Tag used in DISCOVERER_REGISTRATION to contain the non constant attributes of the component Tag also used in DISCOVERER_QUERY |
static java.lang.String |
OUTGOING_ATTRIBUTE_NAME_VALUES
Tag used in DISCOVERER_REGISTRATION to contain the outgoing attribute name values Tag also used in DISCOVERER_QUERY |
static java.lang.String |
PORT
Tag used in LOOKUP_DISCOVERER inside CALLER tags for the component port Also used in LOOKUP_DISCOVERER_REPLY, DISCOVERER_REGISTRATION |
static java.lang.String |
PRIORITY
Attribute tag used in the DISCOVERER_QUERY_CONTENT |
static int |
PRIORITY_1
First or weakest priority for the query element |
static int |
PRIORITY_2
Second or middle priority for the query element |
static int |
PRIORITY_3
Last or stronger priority for the query element |
static java.lang.String |
QUERY_ID
Tag used in the DISCOVERER_QUERY_REPLY_CONTENT to give the query id |
static java.lang.String |
QUERY_ORDER
Tag used inside the DISCOVERER_QUERY_REPLY_CONTENT to give the order of the response |
static java.lang.String |
QUERY_TOTAL_ANSWERS
Tag used inside the DISCOVERER_QUERY_REPLY_CONTENT to give the total number of answers to the query |
static java.lang.String |
REGISTERER
Tag used in DISCOVERER_REGISTRATION to contain the description of the component registring |
static java.lang.String |
REGISTERER_ID
Tag used in DISCOVERER_REGISTRATION for the component id |
static java.lang.String |
SERVER
Component type : for servers |
static java.lang.String |
SERVER_CALLBACKS
Tag used in DISCOVERER_REGISTRATION to contain the server callback names |
static java.lang.String |
SERVER_CONSTANT_ATTRIBUTES
Tag used in DISCOVERER_REGISTRATION to contain the server constant attributes of the component |
static java.lang.String |
SERVER_NON_CONSTANT_ATTRIBUTES
Tag used in DISCOVERER_REGISTRATION to contain the server non constant attributes of the component |
static java.lang.String |
SERVER_SERVICES
Tag used in DISCOVERER_REGISTRATION to contain the server service names |
static java.lang.String |
TEMP_DEST
Tag used by communicationsObject to retrieve the destination address |
static java.lang.String |
TYPE
Tag used in LOOKUP_DISCOVERER inside CALLER tags for the component type (baseobject(applications), widget, server, interpreter) |
static java.lang.String |
UPDATE_ADD_TYPE
Tag used in UPDATE_TYPE message to specify the method used to update information. |
static java.lang.String |
UPDATE_REPLACE_TYPE
Tag used in UPDATE_TYPE message to specify the method used to update information Replace type is used to remove old information before adding new one. |
static java.lang.String |
UPDATE_TYPE
Message tag used by components to specify the update's type |
static java.lang.String |
WIDGET
Component type : for widget |
static java.lang.String |
WIDGET_CALLBACKS
Tag used in DISCOVERER_REGISTRATION to contain the widget callback names Tag also used in DISCOVERER_QUERY |
static java.lang.String |
WIDGET_SERVICES
Tag used in DISCOVERER_REGISTRATION to contain the widget service names Tag also used in DISCOVERER_QUERY |
Fields inherited from class context.arch.BaseObject |
BASEOBJECT_TYPE, communications, DISABLE_PORT, discoverer, EXIT_OK, gFrame, handlers, ID, parser, PING, PING_REPLY, QUERY_DESCRIPTION, QUERY_DESCRIPTION_REPLY, serviceHandlers |
Constructor Summary | |
Discoverer()
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services. |
|
Discoverer(int port)
Constructor that sets up internal variables for maintaining the list of discoverer attributes, callbacks and services. |
|
Discoverer(int port,
boolean storageFlag)
Constructor that sets up internal variables for maintaining the list of discoverer attributes, callbacks and services. |
|
Discoverer(java.lang.String id,
boolean storageFlag)
Constructor that sets up internal variables for maintaining the list of discoverer attributes, callbacks and services. |
|
Discoverer(java.lang.String clientClass,
java.lang.String serverClass,
int serverPort,
java.lang.String encoderClass,
java.lang.String decoderClass,
boolean storageFlag)
Constructor that sets up internal variables for maintaining the list of discoverer attributes, callbacks, and services and setting up the BaseObject info. |
|
Discoverer(java.lang.String clientClass,
java.lang.String serverClass,
int serverPort,
java.lang.String encoderClass,
java.lang.String decoderClass,
java.lang.String storageClass)
Constructor that sets up internal variables for maintaining the list of discoverer attributes, callbacks, and services and setting up the BaseObject info. |
Method Summary | |
int |
checkSubscribers(Callback callback,
ComponentDescription comp)
This method allows to send a message to all subscribers whose interests are for the new registered component. |
protected DataObject |
componentRegistration(DataObject data)
This method handles a DISCOVERER_REGISTRATION message. |
DataObject |
componentSubscription(DataObject dataObject)
This method is handling the subscription of a context component that wants to subscribe to be notified of the registration of context components of its interest. |
protected DataObject |
componentUnregistration(DataObject dataObject)
This method is used to unregister a context component from the discoverer. |
DataObject |
componentUpdate(DataObject dataObject)
This method handles the UPDATE_DISCOVERER messages. |
DataObject |
getDiscovererDescription(DataObject data)
?? TO DO : add errors control This method returns the DataObject replying to the LOOKUP_DISCOVERER message from a component. |
java.lang.String |
getSearchEngineContent()
Returns the content of the search engine |
java.lang.String |
getType()
Returns the type of the object This method should be overridden |
void |
handleIndependentReply(IndependentCommunication independentCommunication)
This method is called after the independentUserRequest has been called. |
DataObject |
handleQuery(DataObject data)
Handles a DISCOVERER_QUUERY message from components and returns a DataObject containing the identification of the response and the first response. |
protected Attributes |
initAttributes()
Sets the attributes for the discoverer: they specify the information the discoverer is storing about the registered context components. |
protected Callbacks |
initCallbacks()
Sets the callbacks for the discoverer |
protected Attributes |
initConstantAttributes()
Sets the constant attributes for the discoverer |
protected Services |
initServices()
Sets the services for the discoverer |
static void |
main(java.lang.String[] argv)
Main method to create a discoverer with location and port specified by command line arguments |
protected Attributes |
queryGenerator()
This abstract method is called when the discoverer wants to get the latest generator info. |
protected void |
removeComponentDescription(java.lang.Integer componentToRemoveIndex)
This method allows to remove a ComponentDescription from the discoverer |
protected DataObject |
runDiscovererMethod(DataObject dataObject,
java.lang.String error)
This method should be overriden by inheriting classes to handle other messages. |
protected DataObject |
runWidgetMethod(DataObject dataObject,
java.lang.String error)
This method is meant to handle any internal methods that the baseObject doesn't handle. |
void |
sendLeaseEndNotificationTo(java.util.ArrayList listOfComponents)
This method allows to send a lease end notification to each component whose lease ends. |
protected boolean |
sendLeaseEndNotificationTo(IndependentCommunication comm)
This method allows to send the Lease.LEASE_END_NOTIFICATION to a context component. |
java.lang.String |
subscribersToString()
Returns a printable version of the list of discoverer subscribers |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final boolean DEBUG
public static final int DEFAULT_PORT
public static final java.lang.String CLASSNAME
public static final java.lang.String LOOKUP_DISCOVERER
public static final java.lang.String CALLER
public static final java.lang.String CALLER_ID
public static final java.lang.String TYPE
public static final java.lang.String HOSTNAME
public static final java.lang.String HOSTADDRESS
public static final java.lang.String PORT
public static final java.lang.String LOOKUP_DISCOVERER_REPLY
public static final java.lang.String DISCOVERER
public static final java.lang.String DISCOVERER_TYPE
public static final java.lang.String DISCOVERER_ID
public static final java.lang.String COMPONENT_ID
public static final java.lang.String LOOKUP_DISCOVERER_OK
public static final java.lang.String DISCOVERER_REGISTRATION
public static final java.lang.String DISCOVERER_UNREGISTRATION
public static final java.lang.String DISCOVERER_UNREGISTRATION_REPLY
public static final java.lang.String DISCOVERER_UPDATE
public static final java.lang.String DISCOVERER_SUBSCRIBE
public static final java.lang.String UPDATE_TYPE
public static final java.lang.String UPDATE_ADD_TYPE
public static final java.lang.String UPDATE_REPLACE_TYPE
public static final java.lang.String REGISTERER
public static final java.lang.String REGISTERER_ID
public static final java.lang.String COMPONENT_CLASSNAME
public static final java.lang.String LOCATION_ADDRESS
public static final java.lang.String CONSTANT_ATTRIBUTE_NAME_VALUES
context.arch.discoverer.query.QueryElement
,
context.arch.discoverer.query.Query
,
Constant Field Valuespublic static final java.lang.String NON_CONSTANT_ATTRIBUTE_NAME_VALUES
public static final java.lang.String CONSTANT_ATTRIBUTE_NAME
context.arch.discoverer.query.QueryElement
,
context.arch.discoverer.query.Query
,
Constant Field Valuespublic static final java.lang.String NON_CONSTANT_ATTRIBUTE_NAME
context.arch.discoverer.query.QueryElement
,
context.arch.discoverer.query.Query
,
Constant Field Valuespublic static final java.lang.String CONSTANT_ATTRIBUTE_VALUE
context.arch.discoverer.query.QueryElement
,
context.arch.discoverer.query.Query
,
Constant Field Valuespublic static final java.lang.String SERVER_CONSTANT_ATTRIBUTES
public static final java.lang.String SERVER_NON_CONSTANT_ATTRIBUTES
public static final java.lang.String INCOMING_ATTRIBUTE_NAME_VALUES
public static final java.lang.String OUTGOING_ATTRIBUTE_NAME_VALUES
public static final java.lang.String WIDGET_CALLBACKS
public static final java.lang.String SERVER_CALLBACKS
public static final java.lang.String WIDGET_SERVICES
public static final java.lang.String SERVER_SERVICES
public static final java.lang.String TEMP_DEST
public static final java.lang.String DISCOVERER_QUERY
public static final java.lang.String DISCOVERER_QUERY_CONTENT
public static final java.lang.String DISCOVERER_DESCRIPTION_FULL_RESPONSE
public static final java.lang.String DISCOVERER_QUERY_REPLY
public static final java.lang.String DISCOVERER_QUERY_REPLY_CONTENTS
public static final java.lang.String DISCOVERER_QUERY_REPLY_CONTENT
public static final java.lang.String DISCOVERER_QUERY_TYPE
public static final java.lang.String QUERY_ID
public static final java.lang.String QUERY_ORDER
public static final java.lang.String QUERY_TOTAL_ANSWERS
public static final java.lang.String FIRST_RESULT
public static final java.lang.String ALL_RESULTS
public static final int DEFAULT_MAX_RESULTS
public static final java.lang.String NEXT_RESULT
public static final java.lang.String MAXIMUM_RESULTS
public static final java.lang.String IGNORE_CASE
public static final java.lang.String CASE_SENSITIVE
public static final java.lang.String PRIORITY
public static final int PRIORITY_1
public static final int PRIORITY_2
public static final int PRIORITY_3
public static final java.lang.String APPLICATION
public static final java.lang.String WIDGET
public static final java.lang.String SERVER
public static final java.lang.String INTERPRETER
public static final java.lang.String FIELD_SEPARATOR
public static final java.lang.String ERROR_REGISTRATION_NOT_FOUND
public static final java.lang.String ERROR_QUERY_NOT_FOUND
public static final java.lang.String ERROR_EMPTY_QUERY
public static final java.lang.String NEW_COMPONENT
protected DiscovererMediator mediator
Constructor Detail |
public Discoverer(java.lang.String clientClass, java.lang.String serverClass, int serverPort, java.lang.String encoderClass, java.lang.String decoderClass, java.lang.String storageClass)
clientClass
- Class to use for client communicationsserverClass
- Class to use for server communicationsserverPort
- Port to use for server communicationsencoderClass
- Class to use for communications encodingdecoderClass
- Class to use for communications decodingstorageClass
- Class to use for storageStorageObject
public Discoverer(java.lang.String clientClass, java.lang.String serverClass, int serverPort, java.lang.String encoderClass, java.lang.String decoderClass, boolean storageFlag)
clientClass
- Class to use for client communicationsserverClass
- Class to use for server communicationsserverPort
- Port to use for server communicationsencoderClass
- Class to use for communications encodingdecoderClass
- Class to use for communications decodingstorageFlag
- Flag to determine whether storage should be used or notStorageObject
public Discoverer(int port, boolean storageFlag)
port
- Port to listen to for incoming messagesstorageFlag
- Boolean flag to indicate whether storage should be turned onpublic Discoverer(int port)
port
- Port to listen to for incoming messagespublic Discoverer(java.lang.String id, boolean storageFlag)
id
- Discoverer idstorageFlag
- Boolean flag to indicate whether storage should be turned onpublic Discoverer()
Method Detail |
protected Attributes initAttributes()
initAttributes
in class Widget
protected Attributes initConstantAttributes()
initConstantAttributes
in class Widget
protected Callbacks initCallbacks()
initCallbacks
in class Widget
protected Services initServices()
initServices
in class Widget
protected Attributes queryGenerator()
queryGenerator
in class Widget
protected DataObject runWidgetMethod(DataObject dataObject, java.lang.String error)
runWidgetMethod
in class Widget
dataObject
- DataObject containing the method to run and parameterserror
- Error object
LOOKUP_DISCOVERER
,
DISCOVERER_REGISTRATION
,
DISCOVERER_UNREGISTRATION
,
DISCOVERER_UPDATE
,
DISCOVERER_QUERY
,
DISCOVERER_SUBSCRIBE
protected DataObject runDiscovererMethod(DataObject dataObject, java.lang.String error)
dataObject
- The data object containing the messageerror
- The Error object
public DataObject getDiscovererDescription(DataObject data)
data
- The DataObject containing the identification of the caller component
DiscovererDescription
protected DataObject componentRegistration(DataObject data)
data
- The DataObject containing the description on the caller component
ComponentDescription
public int checkSubscribers(Callback callback, ComponentDescription comp)
comp
- The component newly registered
protected DataObject componentUnregistration(DataObject dataObject)
dataObject
- The content of the DISCOVERER_UNREGISTRATION message
DISCOVERER_UNREGISTRATION
,
#ERROR_COMPONENT_NOT_FOUND
protected void removeComponentDescription(java.lang.Integer componentToRemoveIndex)
componentToRemoveIndex
- The index of the component to removepublic DataObject componentUpdate(DataObject dataObject)
ComponentDescription
public DataObject componentSubscription(DataObject dataObject)
public DataObject handleQuery(DataObject data)
data
- The DataObject containing the query
context.arch.discoverer.Query
,
context.arch.discoverer.QueryElement
,
context.arch.discoverer.Response
,
context.arch.discoverer.ResponseElement
,
context.arch.discoverer.SearchEngine
public java.lang.String getSearchEngineContent()
public void sendLeaseEndNotificationTo(java.util.ArrayList listOfComponents)
listOfComponents
- The components indexprotected boolean sendLeaseEndNotificationTo(IndependentCommunication comm)
public void handleIndependentReply(IndependentCommunication independentCommunication)
handleIndependentReply
in interface MessageHandler
handleIndependentReply
in class Widget
independentCommunication
- The object sent back by the threadClientsPool
,
Client
,
context.arch.util.RequestObject
,
DataObject
public java.lang.String getType()
Widget
getType
in class Widget
public java.lang.String subscribersToString()
public static void main(java.lang.String[] argv)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |