|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.proactive.Service
public class Service
Service is a utility class that provides many useful methods to serve requests. It is usually instantiated once at the begining of the runActivity() method of an active object in order to be used for serving requests. For instance :
public void runActivity(org.objectweb.proactive.Body body) { org.objectweb.proactive.Service service = new org.objectweb.proactive.Service(body); ... }For intance the live method of the bounded buffer example :
public void runActivity(org.objectweb.proactive.Body body) { org.objectweb.proactive.Service service = new org.objectweb.proactive.Service(body); while (body.isActive()) { if (count == 0) { // if the buffer is empty service.blockingServeOldest("put"); // Serve the first buffer.put call } else if (count == size) { // if the buffer is full service.blockingServeOldest("get"); // Serve the first buffer.get call } else { // if the buffer is neither empty nor full service.blockingServeOldest(); // Serve the first buffer.xxx call } } }
RunActive
Nested Class Summary | |
---|---|
protected class |
Service.AcceptAllRequestFilter
AcceptAllRequestFilter is a RequestFilter that matches any request |
protected class |
Service.FlushingServeOldestRequestProcessor
FlushingServeOldestRequestProcessor is a RequestProcessor that serves only the oldest request accepted by the given RequestFilter and removes all other requests accepted by that same Filter |
protected class |
Service.FlushingServeYoungestRequestProcessor
FlushingServeYoungestRequestProcessor is a RequestProcessor that serves only the youngest request accepted by the given RequestFilter and removes all other requests accepted by that same Filter |
protected class |
Service.RequestFilterOnMethodName
RequestFilterOnMethodName is a RequestFilter that matches only request of a given method name. |
protected class |
Service.ServingRequestProcessor
ServingRequestProcessor is a simple RequestProcessor that serves and removes all requests accepted by a given RequestFilter |
Field Summary | |
---|---|
protected Body |
body
|
protected LifeCycleController |
lifeCycleController
|
protected BlockingRequestQueue |
requestQueue
|
Constructor Summary | |
---|---|
Service(Body body)
Creates a new intance of Service based on the given body. |
Method Summary | |
---|---|
Request |
blockingGetOldest()
Returns the oldest request from the queue If no request is available the method block until one request can be returned The request queue is unchanged by this call |
Request |
blockingGetYoungest()
Returns the youngest request from the queue If no request is available the method block until one request can be returned The request queue is unchanged by this call |
Request |
blockingRemoveOldest()
Blocks the calling thread until there is a request available Returns immediately if there is already one. |
Request |
blockingRemoveOldest(long timeout)
Blocks the calling thread until there is a request available but try to limit the time the thread is blocked to timeout. |
Request |
blockingRemoveOldest(RequestFilter requestFilter)
Blocks the calling thread until there is a request that can be accepted be the given RequestFilter. |
Request |
blockingRemoveOldest(RequestFilter requestFilter,
long timeout)
Blocks the calling thread until there is a request that can be accepted be the given RequestFilter, but tries to limit the time the thread is blocked to timeout. |
Request |
blockingRemoveOldest(java.lang.String methodName)
Blocks the calling thread until there is a request of name methodName Returns immediately if there is already one. |
Request |
blockingRemoveYoungest()
Blocks the calling thread until there is a request available Returns immediately if there is already one. |
Request |
blockingRemoveYoungest(long timeout)
Blocks the calling thread until there is a request available but try to limit the time the thread is blocked to timeout. |
Request |
blockingRemoveYoungest(RequestFilter requestFilter)
Blocks the calling thread until there is a request that can be accepted be the given RequestFilter. |
Request |
blockingRemoveYoungest(RequestFilter requestFilter,
long timeout)
Blocks the calling thread until there is a request that can be accepted be the given RequestFilter, but tries to limit the time the thread is blocked to the timeout. |
Request |
blockingRemoveYoungest(java.lang.String methodName)
Blocks the calling thread until there is a request of name methodName Returns immediately if there is already one. |
void |
blockingServeOldest()
Serves the oldest request in the request queue. |
void |
blockingServeOldest(long timeout)
Serves the oldest request in request queue. |
void |
blockingServeOldest(RequestFilter requestFilter)
Serves the oldest request matching the criteria given be the filter. |
void |
blockingServeOldest(RequestFilter requestFilter,
long timeout)
Serves the oldest request matching the criteria given be the filter. |
void |
blockingServeOldest(java.lang.String methodName)
Serves the oldest request for a method of name methodName . |
void |
blockingServeYoungest()
Serves the youngest request in the request queue. |
void |
blockingServeYoungest(long timeout)
Serves the youngest request in request queue. |
void |
blockingServeYoungest(RequestFilter requestFilter)
Serves the youngest request matching the criteria given be the filter. |
void |
blockingServeYoungest(RequestFilter requestFilter,
long timeout)
Serves the youngest request matching the criteria given be the filter. |
void |
blockingServeYoungest(java.lang.String methodName)
Serves the youngest request for a method of name methodName . |
void |
fifoServing()
Invoke the default FIFO policy to pick up the requests from the request queue. |
void |
flushAll()
Removes all request from the queue. |
void |
flushingServeOldest()
Serves the oldest request and discard all other requests. |
void |
flushingServeOldest(RequestFilter requestFilter)
Serves the oldest request accepted by the given filter and discards all the other requests also accepted by this sasme filter. |
void |
flushingServeOldest(java.lang.String methodName)
Serves the oldest request for the method named methodName
and discards all the other requests of the same name. |
void |
flushingServeYoungest()
Serves the youngest request and discard all other requests. |
void |
flushingServeYoungest(RequestFilter requestFilter)
Serves the most recent request (youngest) accepted by the given filter and discards all the other requests also accepted by this sasme filter. |
void |
flushingServeYoungest(java.lang.String methodName)
Serves the most recent request (youngest) for the method named methodName
and discards all the other requests of the same name. |
Request |
getOldest()
Returns the oldest request from the queue or null if the queue is empty The request queue is unchanged by this call |
Request |
getOldest(RequestFilter requestFilter)
Returns the oldest request that matches the criteria defined by the given filter The request queue is unchanged by this call |
Request |
getOldest(java.lang.String methodName)
Returns the oldest request whose method name is s or null if no match The request queue is unchanged by this call |
int |
getRequestCount()
Returns the number of request(s) in the queue |
Request |
getYoungest()
Returns the youngest request from the queue or null if the queue is empty The request queue is unchanged by this call |
Request |
getYoungest(RequestFilter requestFilter)
Returns the youngest request that matches the criteria defined by the given filter The request queue is unchanged by this call |
Request |
getYoungest(java.lang.String methodName)
Returns the youngest request whose method name is s or null if no match The request queue is unchanged by this call |
boolean |
hasRequestToServe()
true if and only if at least one request is available |
boolean |
hasRequestToServe(java.lang.String methodName)
true if and only if at least one request with the given name is available |
void |
lifoServing()
Invoke the LIFO policy to pick up the requests from the request queue. |
void |
serve(Request request)
Serves the request given in parameter |
void |
serveAll(RequestFilter requestFilter)
Serves all requests accepted by the given filter. |
void |
serveAll(java.lang.String methodName)
Serves all requests for the method named methodName . |
void |
serveOldest()
Serves the oldest request in the request queue. |
void |
serveOldest(RequestFilter requestFilter)
Serves the oldest request matching the criteria given be the filter. |
void |
serveOldest(java.lang.String methodName)
Serves the oldest request for a method of name methodName. |
void |
serveYoungest()
Serves the youngest request in the request queue. |
void |
serveYoungest(RequestFilter requestFilter)
Serves the youngest request matching the criteria given be the filter. |
void |
serveYoungest(java.lang.String methodName)
Serves the youngest request for a method of name methodName. |
java.lang.String |
toString()
|
void |
waitForRequest()
blocks until a request is available or until the body terminate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Body body
protected BlockingRequestQueue requestQueue
protected LifeCycleController lifeCycleController
Constructor Detail |
---|
public Service(Body body)
body
- the body that helper service is for.Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public void serve(Request request)
request
- the request to be servedpublic void fifoServing()
public void lifoServing()
public void blockingServeOldest()
public void blockingServeOldest(long timeout)
timeout
- how long the thread can be blocked for.public void blockingServeOldest(RequestFilter requestFilter, long timeout)
requestFilter
- The request filter accepting the requesttimeout
- the timeout in mspublic void blockingServeOldest(java.lang.String methodName)
methodName
.
The method blocks if there is no matching request until one
matching request is received or until the body terminates.
methodName
- The name of the request to servepublic void blockingServeOldest(RequestFilter requestFilter)
requestFilter
- The request filter accepting the requestpublic void serveOldest()
public void serveOldest(java.lang.String methodName)
methodName
- The name of the request to servepublic void serveOldest(RequestFilter requestFilter)
requestFilter
- The request filter accepting the requestpublic void blockingServeYoungest()
public void blockingServeYoungest(long timeout)
timeout
- : for how long the thread can be blocked.public void blockingServeYoungest(java.lang.String methodName)
methodName
.
The method blocks if there is no matching request until one
matching request is received or until the body terminates.
methodName
- The name of the request to servepublic void blockingServeYoungest(RequestFilter requestFilter)
requestFilter
- The request filter accepting the requestpublic void blockingServeYoungest(RequestFilter requestFilter, long timeout)
requestFilter
- The request filter accepting the requesttimeout
- : for how long the thread can be blocked.public void serveYoungest()
public void serveYoungest(java.lang.String methodName)
methodName
- The name of the request to servepublic void serveYoungest(RequestFilter requestFilter)
requestFilter
- The request filter accepting the requestpublic void serveAll(java.lang.String methodName)
methodName
.
If there is no request matching the method name,
no request is served.
All served requests are removed from the RequestQueue.
methodName
- The name of the request to servepublic void serveAll(RequestFilter requestFilter)
requestFilter
- The request filter accepting the requestpublic void flushingServeYoungest()
public void flushingServeYoungest(java.lang.String methodName)
methodName
and discards all the other requests of the same name. The most recent
request is the one served.
If there is no match, no request is served or removed.
All requests of method name methodName
are removed from the
request queue.
methodName
- The name of the request to serve and flushpublic void flushingServeYoungest(RequestFilter requestFilter)
requestFilter
- The request filter accepting requestspublic void flushingServeOldest()
public void flushingServeOldest(java.lang.String methodName)
methodName
and discards all the other requests of the same name. The oldest
request is the one served.
If there is no match, no request is served or removed.
All requests of method name methodName
are removed from the
request queue.
methodName
- The name of the request to serve and flushpublic void flushingServeOldest(RequestFilter requestFilter)
requestFilter
- The request filter accepting requestspublic void waitForRequest()
public boolean hasRequestToServe()
public boolean hasRequestToServe(java.lang.String methodName)
public int getRequestCount()
public void flushAll()
public Request getOldest()
public Request getOldest(java.lang.String methodName)
methodName
- the name of the method to look for
public Request getOldest(RequestFilter requestFilter)
requestFilter
- the filter accepting request on a given criteria
public Request blockingGetOldest()
public Request getYoungest()
public Request getYoungest(java.lang.String methodName)
methodName
- the name of the method to look for
public Request getYoungest(RequestFilter requestFilter)
requestFilter
- the filter accepting request on a given criteria
public Request blockingGetYoungest()
public Request blockingRemoveOldest(RequestFilter requestFilter)
requestFilter
- the request filter that select the request to be returned
public Request blockingRemoveOldest(RequestFilter requestFilter, long timeout)
requestFilter
- the request filter that select the request to be returnedtimeout
- : for how long the thread can be blocked.
public Request blockingRemoveOldest(java.lang.String methodName)
methodName
- the name of the method to wait for
public Request blockingRemoveOldest()
public Request blockingRemoveOldest(long timeout)
timeout
- : for how long the thread can be blocked.
public Request blockingRemoveYoungest(RequestFilter requestFilter)
requestFilter
- the request filter that select the request to be returned
public Request blockingRemoveYoungest(RequestFilter requestFilter, long timeout)
requestFilter
- the request filter that select the request to be returnedtimeout
- : for how long the thread can be blocked.
public Request blockingRemoveYoungest(java.lang.String methodName)
methodName
- the name of the method to wait for
public Request blockingRemoveYoungest()
public Request blockingRemoveYoungest(long timeout)
timeout
- : for how long the thread can be blocked.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |