protected Application initObjLinkage(){ Context cx = this.getContext(); Client cli = cx.getClientDispatcher(); Application app = cli.getApplication() ; return app; }
/** * Returns a request dispatcher to available client connectors. When you ask * the dispatcher to handle a request, it will automatically select the best * client connector for your request, based on the request.protocol property * or on the resource URI's scheme. This call is blocking and will return an * updated response object. * * @return A request dispatcher to virtual hosts of the local component. * @deprecated Use getClientDispatcher() instead. */ @Deprecated public Uniform getDispatcher() { return getClientDispatcher(); }
/** * Sets the context. * * @param context * The context. */ public void setContext(Context context) { if (context != null) { setOutboundNext(context.getClientDispatcher()); } }
/** * Constructor. * * @param context * The context from which the client dispatcher will be * retrieved. * @param serviceUri * The service URI. * @throws IOException */ public Service(Context context, String serviceUri) throws IOException { this(context.getClientDispatcher(), serviceUri, context .getClientDispatcher().get(serviceUri).getEntity()); }
public Context getContext() { // Get the context from the parent Context context = super.getContext(); // Wrapper the context's client dispatcher in an object that will force it to use the OSGi bundle classloader // rather than the classloader that created the dispatcher. Also, the same Context object may run through // this many times so we have to make sure we don't wrapper multiple times -- otherwise evil hilarity will ensue // (i.e stack overflows) if (!(context.getClientDispatcher() instanceof CLAPCustomClassLoaderDispatcher)) { context.setClientDispatcher(new CLAPCustomClassLoaderDispatcher(context.getClientDispatcher(), bundleClassloader)); } return context; } }
/** * Constructor. * * @param context * The context from which the client dispatcher will be * retrieved. * @param serviceUri * The service URI. * @throws IOException */ public Service(Context context, String serviceUri) throws IOException { this(context.getClientDispatcher(), serviceUri, context .getClientDispatcher() .handle(new Request(Method.GET, serviceUri)).getEntity()); }
/** * Constructor. * * @param context * The context from which the client dispatcher will be * retrieved. * @param serviceUri * The service URI. * @throws IOException */ public Service(Context context, String serviceUri) throws IOException { this(context.getClientDispatcher(), serviceUri, context .getClientDispatcher() .handle(new Request(Method.GET, serviceUri)).getEntity()); }
/** * Constructor. * * @param servlet * The parent Servlet. * @param parentContext * The parent context. */ public ServletContextAdapter(Servlet servlet, Context parentContext) { super(new ServletLogger(servlet.getServletConfig().getServletContext())); this.servletContext = servlet.getServletConfig().getServletContext(); this.clientDispatcher = (parentContext != null) ? parentContext .getClientDispatcher() : null; this.serverDispatcher = (parentContext != null) ? parentContext .getServerDispatcher() : null; }
/** * Constructor. * * @param context * The context from which the client dispatcher will be * retrieved. * @param feedUri * The feed URI. * @throws IOException */ public Feed(Context context, String feedUri) throws IOException { this(context.getClientDispatcher() .handle(new Request(Method.GET, feedUri)).getEntity()); }
/** * Constructor. * * @param context * The context from which the client dispatcher will be * retrieved. * @param entryUri * The entry URI. * @throws IOException */ public Entry(Context context, String entryUri) throws IOException { this(context.getClientDispatcher().handle( new Request(Method.GET, entryUri)).getEntity()); }
/** * Constructor. * * @param context * The context from which the client dispatcher will be * retrieved. * @param categoriesUri * The feed URI. * @throws IOException */ public Categories(Context context, String categoriesUri) throws IOException { this(context.getClientDispatcher() .handle(new Request(Method.GET, categoriesUri)).getEntity()); }
/** * Constructor. * * @param context * The context from which the client dispatcher will be * retrieved. * @param categoriesUri * The feed URI. * @throws IOException */ public Categories(Context context, String categoriesUri) throws IOException { this(context.getClientDispatcher().handle( new Request(Method.GET, categoriesUri)).getEntity()); }
/** * Constructor. * * @param context * The context from which the client dispatcher will be * retrieved. * @param entryUri * The entry URI. * @throws IOException */ public Entry(Context context, String entryUri) throws IOException { this(context.getClientDispatcher() .handle(new Request(Method.GET, entryUri)).getEntity()); }
/** * Constructor. * * @param context * The context from which the client dispatcher will be * retrieved. * @param feedUri * The feed URI. * @throws IOException */ public Feed(Context context, String feedUri) throws IOException { this(context.getClientDispatcher() .handle(new Request(Method.GET, feedUri)).getEntity()); }
/** * Asks to the parent component to handle the call. * * @param request * The request to handle. * @param response * The response to update. */ private void parentHandle(Request request, Response response) { if (getChildContext() != null) { if (getChildContext().getParentContext() != null) { if (getChildContext().getParentContext().getClientDispatcher() != null) { getChildContext().getParentContext().getClientDispatcher() .handle(request, response); } else { getLogger() .warning( "The parent context doesn't have a client dispatcher available. Unable to handle call."); } } else { getLogger() .warning( "Your Restlet doesn't have a parent context available."); } } else { getLogger().warning( "Your Restlet doesn't have a context available."); } }
/** * Finds the object that acts as the source of the template with the given * name. * * @param name * The template name. * @return The template source {@link Representation}. */ public Object findTemplateSource(String name) throws IOException { String fullUri; if (getBaseUri().endsWith("/")) { fullUri = getBaseUri() + name; } else { fullUri = getBaseUri() + "/" + name; } return (getContext() == null) ? null : getContext() .getClientDispatcher().handle(new Request(Method.GET, fullUri)) .getEntity(); }
Response response = this.context.getClientDispatcher().handle( new Request(Method.GET, targetUri));
/** * Redirects a given call to a target reference. In the default * implementation, the request HTTP headers, stored in the request's * attributes, are removed before dispatching. After dispatching, the * response HTTP headers are also removed to prevent conflicts with the main * call. * * @param targetRef * The target reference with URI variables resolved. * @param request * The request to handle. * @param response * The response to update. */ protected void outboundServerRedirect(Reference targetRef, Request request, Response response) { Restlet next = (getApplication() == null) ? null : getApplication() .getOutboundRoot(); if (next == null) { next = getContext().getClientDispatcher(); } serverRedirect(next, targetRef, request, response); if (response.getEntity() != null && !request.getResourceRef().getScheme() .equalsIgnoreCase(targetRef.getScheme())) { // Distinct protocol, this data cannot be exposed. response.getEntity().setLocationRef((Reference) null); } }
/** * Creates a next Restlet is no one is set. By default, it creates a new * {@link Client} based on the protocol of the resource's URI reference. * * @return The created next Restlet or null. */ protected Uniform createNext() { Uniform result = null; // Prefer the outbound root result = getApplication().getOutboundRoot(); if ((result == null) && (getContext() != null)) { // Try using directly the client dispatcher result = getContext().getClientDispatcher(); } if (result == null) { // As a final option, try creating a client connector Protocol rProtocol = getProtocol(); Reference rReference = getReference(); Protocol protocol = (rProtocol != null) ? rProtocol : (rReference != null) ? rReference.getSchemeProtocol() : null; if (protocol != null) { org.restlet.engine.util.TemplateDispatcher dispatcher = new org.restlet.engine.util.TemplateDispatcher(); dispatcher.setContext(getContext()); dispatcher.setNext(new Client(protocol)); result = dispatcher; } } return result; }
/** * Attaches an application created from a WADL description document * available at a given URI reference. * * @param wadlRef * The URI reference to the WADL description document. * @return The created WADL application. */ public WadlApplication attach(Reference wadlRef) { WadlApplication result = null; // Adds some common client connectors to load the WADL documents if (!getClients().contains(wadlRef.getSchemeProtocol())) { getClients().add(wadlRef.getSchemeProtocol()); } // Get the WADL document final Response response = getContext().getClientDispatcher().handle( new Request(Method.GET, wadlRef)); if (response.getStatus().isSuccess() && response.isEntityAvailable()) { result = attach(response.getEntity()); } return result; }