public class UAAL extends Object
Not all the possible features of universAAL are accessible from it, only the most typical and straight/forward, namely:
And all of these without (virtually) having to implement extensions of universAAL classes, which may come in handy for already existing applications which just want to connect easily to universAAL. Actually some of these provided simplified features use a Listener Interface-oriented approach, for which it may be necessary to create additional classes for implementing them or do it in existing classes, although in general it is possible to create the implementation in the method calls themselves without much complication.
Notice that for allowing this, this universAAL class takes care of instantiating
and maintaining all needed universAAL wrapper classes, so for as long as you don't
call terminate()
it will keep hold of these resources. This also
means that the performance might not be as polite as it could if you handled
your own implementations of universAAL wrappers with the native API or the other
sublayers of this utilities API. The purpose of this universAAL class was never to
improve the performance but to simplify the coding.
To use the class methods, just instantiate it with a valid universAAL
ModuleContext. For instance, from an Activator:
private universAAL u;
public void start(BundleContext bcontext) throws Exception {
Activator.osgiContext = bcontext;
Activator.context = OSGiContainer.THE_CONTAINER
.registerModule(new Object[] { bcontext });
u = new universAAL(context);
...
}
Remember to release the resources when you stop your application (like in
Activator.stop()
method) by calling terminate()
.
Constructor and Description |
---|
UAAL(ModuleContext context)
This constructor just assigns the Module Context: the rest of resources
used by this class are not initialized.
|
Modifier and Type | Method and Description |
---|---|
ServiceResponse |
callS(ServiceRequest r)
Calls a Service with a Service Request.
|
void |
provideS(ServiceProfile[] p,
ISListener l)
Registers Service Profiles and specifies how the calls to these profiles
would be handled.
|
void |
requestUI(UIRequest ui,
IUIListener l)
Requests User Interaction and specifies how the response would be
handled.
|
void |
sendC(ContextEvent e)
Sends a Context Event.
|
void |
subscribeC(ContextEventPattern[] p,
ICListener l)
Subscribes for Context Events and specifies how the events would be
handled.
|
void |
terminate()
Closes all universAAL wrapper classes created by this universAAL helper until now (by
calling their
.close() method) and eliminates them. |
public UAAL(ModuleContext context)
terminate()
.
Although it is possible to have as many instances of this class as desired (no restrictions are set about it), it is recommended to maintain just a single(ton) instance of it, and make it accessible to the rest of your application code.
context
- The universAAL Module Context.public void sendC(ContextEvent e)
universAAL helper automatically creates its own internal Context Publisher if
this is the first time the method is called. If the passed event contains
ContextProvider information, it is used to instantiate the Publisher.
Otherwise the missing information is automatically generated: The
Publisher is described as either a Gauge or a Controller depending on if
you are providing Services (you called method provideS()
before). The URI of the Provider is then set to
http://ontology.universAAL.org/SimpleUAAL
.owl#ContextEventsProvider and it cannot be changed. Currently, the
pattern that describes the provided events of this provider is empty,
which means it can publish any type of event. Notice this Provider info
is set ONLY THE FIRST TIME and cannot be changed by later calls.
e
- The Context Event to send.public ServiceResponse callS(ServiceRequest r)
universAAL helper automatically creates its own internal Default Service Caller if this is the first time the method is called. The call to the service is synchronous: this method returns the response of the call straight from Service Bus. You will have to deal with it.
Remember that the simplified API in this library (
org.universAAL.utilities.api.service
packages) can assist
you in creating Service Requests and handling Service Responses.
r
- The Service Request describing the Service to call.Request
public void requestUI(UIRequest ui, IUIListener l)
universAAL helper automatically creates its own internal UI Caller if this is
the first time the method is called. An implementation of
IUIListener
must be passed that will handle the response to the
UI Request that is being sent. The response contains the user input to
the forms described in the UI Request, so the listener must be ready to
work with the fields, controls, submits and identifiers used in the
request. There can only be a single listener associated to the UI Caller
at a time, which means this method cannot be called again with a new
listener until the previous response has been received and processed by
the old listener. Another solution is using always the same instance of
the listener, which should then be ready to handle any possible UI
response to your application.
Remember that the simplified API in this library (
org.universAAL.utilities.api.ui
packages) can assist you in
creating UI Requests.
public void subscribeC(ContextEventPattern[] p, ICListener l)
universAAL helper automatically creates a new own internal Context Subscriber
each time this method is called. An implementation of ICListener
must be passed that will handle the reception of an event that matches
the passed patterns. The listener is associated to the patterns: All
events that match the patterns are received by the listener (regardless
of any other calls to this method). The listener remains active and
associated to the patterns until terminate()
is called.
Since every call to this method creates a new subscriber, you should be
careful with how many times you call this method. Usually, a limited
number of subscriptions is needed. Remember that you can combine
different patterns to be handled by a single listener.
Remember that the simplified API in this library (
org.universAAL.utilities.api.context
packages) can assist
you in creating Context Event Patterns.
p
- An array of Context Event Patterns describing the Context
Events that will be handled by the listener.l
- The listener that will handle the received event that matches
the patterns.Pattern
public void provideS(ServiceProfile[] p, ISListener l)
universAAL helper automatically creates a new own internal Service Callee each
time this method is called. An implementation of ISListener
must
be passed that will handle the call request that matches the provided
profiles. The listener is associated to the profiles: All call requests
that match the profiles are received by the listener (regardless of any
other calls to this method). The listener remains active and associated
to the profiles until terminate()
is called. Since every
call to this method creates a new callee, you should be careful with how
many times you call this method. Usually, a limited number of callees is
needed.
Remember that the simplified API in this library (
org.universAAL.utilities.api.service
packages) can assist
you in creating Service Profiles.
p
- An array of Service Profiles describing the provided services
that will be handled by the listener.l
- The listener that will handle the received call request that
matches the provided service profiles.Profile
public void terminate()
.close()
method) and eliminates them. The
reference to the Module Context is maintained, however. This allows to
perform new calls to the universAAL features methods, which will create new
universAAL wrappers in the helper.Copyright © 2018 universAAL Consortium. All rights reserved.