/** * 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 inboundServerRedirect(Reference targetRef, Request request, Response response) { serverRedirect(getContext().getServerDispatcher(), targetRef, request, response); }
/** * 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; }
@Get Representation retrieve() { // Create the mail URI inside the API application String accountId = getAttribute("accountId"); String mailId = getAttribute("mailId"); String mailApiUri = "riap://component/api/accounts/" + accountId + "/mails/" + mailId; // Optimal internal call using the server dispatcher ClientResource cr = new ClientResource(mailApiUri); cr.setNext(getContext().getServerDispatcher()); MailRepresentation mail = cr.get(MailRepresentation.class); // Load the FreeMarker template Representation mailFtl = new ClientResource( LocalReference.createClapReference(getClass().getPackage()) + "/Mail.ftl").get(); // Wraps the bean with a FreeMarker representation return new TemplateRepresentation(mailFtl, mail, MediaType.TEXT_HTML); }
/** * Constructor. * * @param parentContext * The parent context. */ public ChildContext(Context parentContext) { this.child = null; this.parentContext = parentContext; setClientDispatcher(new ChildClientDispatcher(this)); setServerDispatcher((parentContext != null) ? getParentContext() .getServerDispatcher() : null); setExecutorService((parentContext != null) ? ((parentContext .getExecutorService() != null) ? new WrapperScheduledExecutorService( parentContext.getExecutorService()) : null) : null); }