edu.cmu.aura.service
Class PrimitiveServiceStub

java.lang.Object
  |
  +--edu.cmu.aura.service.rpc.GenericStub
        |
        +--edu.cmu.aura.service.PrimitiveServiceStub
All Implemented Interfaces:
PrimitiveService, java.rmi.Remote

public class PrimitiveServiceStub
extends edu.cmu.aura.service.rpc.GenericStub
implements PrimitiveService

PrimitiveServiceStub is used by clients send requests to services. There are three general ways that this class may be used: 1 - specifying all query arguments, 2 - passing in an object that represents a query or trigger, 3 - calling one of the simple attribute retrieval methods.

The attribute retrieval methods are shortcuts to performing a query of the form: select attribName where keyName = keyVal. Note that the use of the name key here merely signifies that the attribute is acting as a key for this query and is not necessarily what the service would consider a key (though it probably is most of the time).


Field Summary
 
Fields inherited from interface edu.cmu.aura.service.PrimitiveService
ALL_ATTRIBS, ANY_CHANGE, DEFAULT_EXEC_INTERVAL, DEFAULT_SERVICE, DEFAULT_SERVICE_NAME, NO_REQS, NO_TIME_LIMIT, RELATION_ATTRIB, SELECT_ALL
 
Constructor Summary
PrimitiveServiceStub(edu.cmu.aura.service.rpc.RemoteReference dest)
          Creates a PrimitiveServiceStub.
PrimitiveServiceStub(java.lang.String hostName, int port)
          Creates a PrimitiveServiceStub.
 
Method Summary
 boolean getBoolean(java.lang.String attribName, java.lang.String keyName, java.lang.Object keyVal)
          Retrieve an attribute of type boolean from a service by specifying a lookup key name and value.
 char getChar(java.lang.String attribName, java.lang.String keyName, java.lang.Object keyVal)
          Retrieve an attribute of type char from a service by specifying a lookup key name and value.
 double getDouble(java.lang.String attribName, java.lang.String keyName, java.lang.Object keyVal)
          Retrieve an attribute of type double from a service by specifying a lookup key name and value.
 float getFloat(java.lang.String attribName, java.lang.String keyName, java.lang.Object keyVal)
          Retrieve an attribute of type float from a service by specifying a lookup key name and value.
 int getInt(java.lang.String attribName, java.lang.String keyName, java.lang.Object keyVal)
          Retrieve an attribute of type int from a service by specifying a lookup key name and value.
 long getLong(java.lang.String attribName, java.lang.String keyName, java.lang.Object keyVal)
          Retrieve an attribute of type long from a service by specifying a lookup key name and value.
 short getShort(java.lang.String attribName, java.lang.String keyName, java.lang.Object keyVal)
          Retrieve an attribute of type short from a service by specifying a lookup key name and value.
 java.lang.String getString(java.lang.String attribName, java.lang.String keyName, java.lang.Object keyVal)
          Retrieve an attribute of type string from a service by specifying a lookup key name and value.
 int postCondTrigger(java.util.ArrayList selectedAttribs, java.util.ArrayList serviceNames, ExpressionNode expression, java.util.ArrayList attribReqs, long timeLimit, long execInterval, ExpressionNode triggerExpression, edu.cmu.aura.service.rpc.RemoteReference queryClient)
          Post a trigger that is to execute when a particular condition is met.
 int postCondTrigger(CondTrigger condTrigger)
          Post a trigger that is to execute when a particular condition is met.
 int postModTrigger(java.util.ArrayList selectedAttribs, java.util.ArrayList serviceNames, ExpressionNode expression, java.util.ArrayList attribReqs, long timeLimit, long execInterval, java.util.ArrayList triggerAttribs, java.util.ArrayList triggerDeltas, edu.cmu.aura.service.rpc.RemoteReference queryClient)
          Post a trigger that is to execute when any one of a given set of attributes changes by a specified amount.
 int postModTrigger(ModTrigger modTrigger)
          Post a trigger that is to execute when any one of a given set of attributes changes by a specified amount.
 int postQuery(java.util.ArrayList selectedAttributes, java.util.ArrayList fromServices, ExpressionNode expression, java.util.ArrayList attribReqs, long timeLimit, long execInterval, edu.cmu.aura.service.rpc.RemoteReference queryClient)
          Query a service repeatedly at a regular interval.
 int postQuery(PostedQuery postedQuery)
          Query a service repeatedly at a regular interval.
 QueryResult query(java.util.ArrayList selectedAttributes, java.util.ArrayList fromServices, ExpressionNode expression, java.util.ArrayList attribReqs, long timeLimit)
          Query a service.
 QueryResult query(Query query)
          Query a service.
 void removeQuery(java.lang.String serviceName, int queryID)
          Remove a recurrent query.
 void removeTrigger(java.lang.String serviceName, int queryID)
          Remove a trigger.
 
Methods inherited from class edu.cmu.aura.service.rpc.GenericStub
setDest
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrimitiveServiceStub

public PrimitiveServiceStub(java.lang.String hostName,
                            int port)
Creates a PrimitiveServiceStub.

Parameters:
hostName - the hostName where the service resides
port - the port on which the service is listening

PrimitiveServiceStub

public PrimitiveServiceStub(edu.cmu.aura.service.rpc.RemoteReference dest)
Creates a PrimitiveServiceStub.

Parameters:
dest - the RemoteReference of this service
Method Detail

query

public QueryResult query(Query query)
                  throws java.rmi.RemoteException,
                         ServiceException
Query a service.

Parameters:
query - the query to perform
Returns:
the QueryResult of the query
java.rmi.RemoteException
ServiceException

query

public QueryResult query(java.util.ArrayList selectedAttributes,
                         java.util.ArrayList fromServices,
                         ExpressionNode expression,
                         java.util.ArrayList attribReqs,
                         long timeLimit)
                  throws java.rmi.RemoteException,
                         ServiceException
Query a service.

Specified by:
query in interface PrimitiveService
Parameters:
expression - expression selecting which entities or relations in the service should be returned. PrimitiveService.SELECT_ALL indicates all entities are to be selected.
attribReqs - requirements on dynamic attributes. PrimitiveService.NO_REQS indicates there are no requirements in effect.
timeLimit - this is used by clients to inform the service on when they need the results by. This may also be viewed as a suggestion on how hard to work to retrieve the results. PrimitiveService.NO_TIME_LIMIT indicates that the client has no hard limit on how long the query should take; though a client will likely still desire reasonably fast execution.
selectedAttributes - attribsutes to select. ALL_ATTRIBS indicates that all attributes are to be selected.
fromServices - names of services to retrieve attributes from. DEFAULT_SERVICE may be used if there is only one service listening on a given port.
Returns:
the QueryResult of the query.
java.rmi.RemoteException
ServiceException

postQuery

public int postQuery(PostedQuery postedQuery)
              throws java.rmi.RemoteException,
                     ServiceException
Query a service repeatedly at a regular interval.

Returns:
the id of the posted query.
java.rmi.RemoteException
ServiceException

postQuery

public int postQuery(java.util.ArrayList selectedAttributes,
                     java.util.ArrayList fromServices,
                     ExpressionNode expression,
                     java.util.ArrayList attribReqs,
                     long timeLimit,
                     long execInterval,
                     edu.cmu.aura.service.rpc.RemoteReference queryClient)
              throws java.rmi.RemoteException,
                     ServiceException
Query a service repeatedly at a regular interval.

Specified by:
postQuery in interface PrimitiveService
Parameters:
expression - expression selecting which entities or relations in the service should be returned. PrimitiveService.SELECT_ALL indicates all entities are to be selected.
attribReqs - requirements on dynamic attributes. PrimitiveService.NO_REQS indicates there are no requirements in effect.
timeLimit - this is used by clients to inform the service on when they need the results by. This may also be viewed as a suggestion on how hard to work to retrieve the results. PrimitiveService.NO_TIME_LIMIT indicates that the client has no hard limit on how long the query should take; though a client will likely still desire reasonably fast execution.
execInterval - interval at which to execute the query. PrimitiveService.DEFAULT_EXEC_INTERVAL may be specified if they service is to select the interval at which the query should execute.
queryClient - the client that should be informed when this query executes.
selectedAttributes - attribsutes to select. ALL_ATTRIBS indicates that all attributes are to be selected.
fromServices - names of services to retrieve attributes from. DEFAULT_SERVICE may be used if there is only one service listening on a given port.
Returns:
the id of the posted query.
java.rmi.RemoteException
ServiceException

removeQuery

public void removeQuery(java.lang.String serviceName,
                        int queryID)
                 throws java.rmi.RemoteException
Remove a recurrent query.

Specified by:
removeQuery in interface PrimitiveService
Parameters:
serviceName - name of the service to remove the query from
queryID - the ID of the query to remove
java.rmi.RemoteException

postCondTrigger

public int postCondTrigger(CondTrigger condTrigger)
                    throws java.rmi.RemoteException,
                           ServiceException
Post a trigger that is to execute when a particular condition is met. Note that a trigger may be regarded as a posted query that executes at a particular interval. A client may request that a service check constantly by specifying an execInterval of PrimitiveService.DEFAULT_EXEC_INTERVAL, but a service is free to decide what interval to check at if it has no easy mechanism for checking constantly.

Parameters:
condTrigger - the trigger to post
Returns:
the id of the posted trigger
java.rmi.RemoteException
ServiceException

postCondTrigger

public int postCondTrigger(java.util.ArrayList selectedAttribs,
                           java.util.ArrayList serviceNames,
                           ExpressionNode expression,
                           java.util.ArrayList attribReqs,
                           long timeLimit,
                           long execInterval,
                           ExpressionNode triggerExpression,
                           edu.cmu.aura.service.rpc.RemoteReference queryClient)
                    throws java.rmi.RemoteException,
                           ServiceException
Post a trigger that is to execute when a particular condition is met. Note that a trigger may be regarded as a posted query that executes at a particular interval. A client may request that a service check constantly by specifying an execInterval of PrimitiveService.DEFAULT_EXEC_INTERVAL, but a service is free to decide what interval to check at if it has no easy mechanism for checking constantly.

Specified by:
postCondTrigger in interface PrimitiveService
Parameters:
serviceNames - names of services to retrieve attributes from. PrimitiveService.DEFAULT_SERVICE may be used if there is only one service listening on a given port.
expression - expression selecting which entities or relations in the service should be returned. PrimitiveService.SELECT_ALL indicates all entities are to be selected.
attribReqs - requirements on dynamic attributes. PrimitiveService.NO_REQS indicates there are no requirements in effect.
timeLimit - this is used by clients to inform the service on when they need the results by. This may also be viewed as a suggestion on how hard to work to retrieve the results. PrimitiveService.NO_TIME_LIMIT indicates that the client has no hard limit on how long the processing should take; though a client will likely still desire reasonably fast execution.
execInterval - interval at which to check the trigger.
triggerExpression - condition indicating when to fire the trigger.
queryClient - the client that should be informed when this trigger executes.
selectedAttribs - attribsutes to select. ALL_ATTRIBS indicates that all attributes are to be selected.
Returns:
the id of the posted trigger.
java.rmi.RemoteException
ServiceException

postModTrigger

public int postModTrigger(ModTrigger modTrigger)
                   throws java.rmi.RemoteException,
                          ServiceException
Post a trigger that is to execute when any one of a given set of attributes changes by a specified amount. Note that a trigger may be regarded as a posted query that executes at a particular interval. A client may request that a service check constantly by specifying an execInterval of DEFAULT_EXEC_INTERVAL, but a service is free to decide what interval to check at if it has no easy mechanism for checking constantly.

Parameters:
modTrigger - the trigger to post
Returns:
the id of the posted trigger
java.rmi.RemoteException
ServiceException

postModTrigger

public int postModTrigger(java.util.ArrayList selectedAttribs,
                          java.util.ArrayList serviceNames,
                          ExpressionNode expression,
                          java.util.ArrayList attribReqs,
                          long timeLimit,
                          long execInterval,
                          java.util.ArrayList triggerAttribs,
                          java.util.ArrayList triggerDeltas,
                          edu.cmu.aura.service.rpc.RemoteReference queryClient)
                   throws java.rmi.RemoteException,
                          ServiceException
Post a trigger that is to execute when any one of a given set of attributes changes by a specified amount. Note that a trigger may be regarded as a posted query that executes at a particular interval. A client may request that a service check constantly by specifying an execInterval of DEFAULT_EXEC_INTERVAL, but a service is free to decide what interval to check at if it has no easy mechanism for checking constantly.

Specified by:
postModTrigger in interface PrimitiveService
Parameters:
serviceNames - names of services to retrieve attributes from. DEFAULT_SERVICE may be used if there is only one service listening on a given port.
expression - expression selecting which entities or relations in the service should be returned. SELECT_ALL indicates all entities are to be selected.
attribReqs - requirements on dynamic attributes. NO_REQS indicates there are no requirements in effect.
timeLimit - this is used by clients to inform the service on when they need the results by. This may also be viewed as a suggestion on how hard to work to retrieve the results. NO_TIME_LIMIT indicates that the client has no hard limit on how long the processing should take; though a client will likely still desire reasonably fast execution.
execInterval - interval at which to check the trigger.
triggerAttribs - attributes to watch for changes. PrimitiveService.ANY_CHANGE may be specified if any change to any attribute should cause the trigger to fire. In this case triggerDeltas should be specified as PrimitiveService.ANY_CHANGE as well.
triggerDeltas - amount of change that will cause the trigger to fire for the corresponding attribute. PrimitiveService.ANY_CHANGE may be specified if for any of the specified attributes, any amount of change should cause the trigger to fire.
queryClient - the client that should be informed when this trigger executes.
selectedAttribs - attribsutes to select. ALL_ATTRIBS indicates that all attributes are to be selected.
Returns:
the id of the posted trigger.
java.rmi.RemoteException
ServiceException

removeTrigger

public void removeTrigger(java.lang.String serviceName,
                          int queryID)
                   throws java.rmi.RemoteException
Remove a trigger.

Specified by:
removeTrigger in interface PrimitiveService
Parameters:
serviceName - name of the service to remove the trigger from
queryID - the ID of the trigger to remove
java.rmi.RemoteException

getDouble

public double getDouble(java.lang.String attribName,
                        java.lang.String keyName,
                        java.lang.Object keyVal)
                 throws java.rmi.RemoteException,
                        ServiceException
Retrieve an attribute of type double from a service by specifying a lookup key name and value. Note that in some cases the lookup "key" attribute may be different from what the service considers a key attribute.

Parameters:
attribName - name of attribute to retrieve
keyName - name of attribute to use as a lookup key
keyVal - value of key attribute
java.rmi.RemoteException
ServiceException

getFloat

public float getFloat(java.lang.String attribName,
                      java.lang.String keyName,
                      java.lang.Object keyVal)
               throws java.rmi.RemoteException,
                      ServiceException
Retrieve an attribute of type float from a service by specifying a lookup key name and value. Note that in some cases the lookup "key" attribute may be different from what the service considers a key attribute.

Parameters:
attribName - name of attribute to retrieve
keyName - name of attribute to use as a lookup key
keyVal - value of key attribute
java.rmi.RemoteException
ServiceException

getLong

public long getLong(java.lang.String attribName,
                    java.lang.String keyName,
                    java.lang.Object keyVal)
             throws java.rmi.RemoteException,
                    ServiceException
Retrieve an attribute of type long from a service by specifying a lookup key name and value. Note that in some cases the lookup "key" attribute may be different from what the service considers a key attribute.

Parameters:
attribName - name of attribute to retrieve
keyName - name of attribute to use as a lookup key
keyVal - value of key attribute
java.rmi.RemoteException
ServiceException

getInt

public int getInt(java.lang.String attribName,
                  java.lang.String keyName,
                  java.lang.Object keyVal)
           throws java.rmi.RemoteException,
                  ServiceException
Retrieve an attribute of type int from a service by specifying a lookup key name and value. Note that in some cases the lookup "key" attribute may be different from what the service considers a key attribute.

Parameters:
attribName - name of attribute to retrieve
keyName - name of attribute to use as a lookup key
keyVal - value of key attribute
java.rmi.RemoteException
ServiceException

getShort

public short getShort(java.lang.String attribName,
                      java.lang.String keyName,
                      java.lang.Object keyVal)
               throws java.rmi.RemoteException,
                      ServiceException
Retrieve an attribute of type short from a service by specifying a lookup key name and value. Note that in some cases the lookup "key" attribute may be different from what the service considers a key attribute.

Parameters:
attribName - name of attribute to retrieve
keyName - name of attribute to use as a lookup key
keyVal - value of key attribute
java.rmi.RemoteException
ServiceException

getChar

public char getChar(java.lang.String attribName,
                    java.lang.String keyName,
                    java.lang.Object keyVal)
             throws java.rmi.RemoteException,
                    ServiceException
Retrieve an attribute of type char from a service by specifying a lookup key name and value. Note that in some cases the lookup "key" attribute may be different from what the service considers a key attribute.

Parameters:
attribName - name of attribute to retrieve
keyName - name of attribute to use as a lookup key
keyVal - value of key attribute
java.rmi.RemoteException
ServiceException

getBoolean

public boolean getBoolean(java.lang.String attribName,
                          java.lang.String keyName,
                          java.lang.Object keyVal)
                   throws java.rmi.RemoteException,
                          ServiceException
Retrieve an attribute of type boolean from a service by specifying a lookup key name and value. Note that in some cases the lookup "key" attribute may be different from what the service considers a key attribute.

Parameters:
attribName - name of attribute to retrieve
keyName - name of attribute to use as a lookup key
keyVal - value of key attribute
java.rmi.RemoteException
ServiceException

getString

public java.lang.String getString(java.lang.String attribName,
                                  java.lang.String keyName,
                                  java.lang.Object keyVal)
                           throws java.rmi.RemoteException,
                                  ServiceException
Retrieve an attribute of type string from a service by specifying a lookup key name and value. Note that in some cases the lookup "key" attribute may be different from what the service considers a key attribute.

Parameters:
attribName - name of attribute to retrieve
keyName - name of attribute to use as a lookup key
keyVal - value of key attribute
java.rmi.RemoteException
ServiceException