net.ubisoa.push
Class PushRouter
java.lang.Object
org.restlet.Restlet
org.restlet.routing.Router
net.ubisoa.common.BaseRouter
net.ubisoa.push.PushRouter
- All Implemented Interfaces:
- Uniform
public class PushRouter
- extends BaseRouter
A router for Restlet applications that handles the resources and methods needed to implement
a hub service subscriber. Contains a method to send subscription requests that will later
be verified by the callback resource. After the subscription is verified, the push messages
will be received by the callback resource and notified to the Restlet application.
Applications using this router must implement the PushApplication
interface or a
RuntimeException
will be thrown when running the constructor.
Example: Creating a push router for a Restful application where
the main resource is handled by the SubscriberResource
class.
public Restlet createInboundRoot() {
return new PushRouter(getContext(), SubscriberResource.class);
}
- Author:
- Edgardo Avilés-López
- See Also:
PushApplication
,
BaseRouter
Fields inherited from class org.restlet.routing.Router |
BEST, CUSTOM, FIRST, LAST, MODE_BEST_MATCH, MODE_CUSTOM, MODE_FIRST_MATCH, MODE_LAST_MATCH, MODE_NEXT_MATCH, MODE_RANDOM_MATCH, NEXT, RANDOM |
Methods inherited from class org.restlet.routing.Router |
attach, attach, attach, attach, attach, attach, attachDefault, attachDefault, createFinder, createRoute, createRoute, detach, detach, doHandle, getCustom, getDefaultMatchingMode, getDefaultMatchingQuery, getDefaultMatchQuery, getDefaultRoute, getFinderClass, getMatchingMode, getMaxAttempts, getNext, getRequiredScore, getRetryDelay, getRoutes, getRoutingMode, handle, logRoute, setDefaultMatchingMode, setDefaultMatchingQuery, setDefaultMatchQuery, setDefaultRoute, setFinderClass, setMaxAttempts, setRequiredScore, setRetryDelay, setRoutes, setRoutingMode, start, stop |
Methods inherited from class org.restlet.Restlet |
finalize, getApplication, getAuthor, getContext, getDescription, getLogger, getName, getOwner, isStarted, isStopped, setAuthor, setContext, setDescription, setName, setOwner |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PushRouter
public PushRouter(Context context,
java.lang.Class<SubscriberResource> defaultResource)
- Creates a Restlet router with the specified resource attached to
/
and the
CallbackResource
attached to /callback
.
If the Restlet application from where this router is created does not implements the
PushApplication
interface this constructor will throw an RuntimeException
.
- Parameters:
context
- Restlet application context.defaultResource
- The resource to attach to "/".
sendSubscriptionRequest
public void sendSubscriptionRequest()
- Sends a subscription request to a hub server.
The topic to subscribe to, hub service URL, verify token, and other parameters are
obtained from the
PushInfo
instance retrieved from the
PushApplication.getPushInfo()
method of the Restlet application using this router.