Package org.restlet

Examples of org.restlet.Restlet


     * Returns the next Restlet in the inbound chain.
     *
     * @return The next Restlet in the inbound chain.
     */
    protected synchronized Restlet getInboundNext() {
        Restlet result = null;

        if (getLastInboundFilter() != null) {
            result = getLastInboundFilter().getNext();
        } else {
            result = this.inboundNext;
View Full Code Here


     * Returns the next Restlet in the outbound chain.
     *
     * @return The next Restlet in the outbound chain.
     */
    public synchronized Restlet getOutboundNext() {
        Restlet result = null;

        if (getLastOutboundFilter() != null) {
            result = getLastOutboundFilter().getNext();
        } else {
            result = this.outboundNext;
View Full Code Here

    private boolean checkVirtualHost(VirtualHost host) throws Exception {
        boolean result = true;

        if (host != null) {
            for (Route route : host.getRoutes()) {
                Restlet next = route.getNext();

                if (next instanceof Application) {
                    Application application = (Application) next;

                    if (application.getConnectorService() != null) {
View Full Code Here

     * @param targetClass
     *            The target class to detach.
     */
    public void detach(Class<?> targetClass) {
        for (int i = getRoutes().size() - 1; i >= 0; i--) {
            Restlet target = getRoutes().get(i).getNext();
            if (target != null
                    && Finder.class.isAssignableFrom(target.getClass())) {
                Finder finder = (Finder) target;
                if (finder.getTargetClass().equals(targetClass)) {
                    getRoutes().remove(i);
                }
            }
        }

        if (getDefaultRoute() != null) {
            Restlet target = getDefaultRoute().getNext();
            if (target != null
                    && Finder.class.isAssignableFrom(target.getClass())) {
                Finder finder = (Finder) target;
                if (finder.getTargetClass().equals(targetClass)) {
                    setDefaultRoute(null);
                }
            }
View Full Code Here

     *            The response to update.
     */
    @Override
    public void handle(Request request, Response response) {
        super.handle(request, response);
        Restlet next = getNext(request, response);

        if (next != null) {
            doHandle(next, request, response);
        } else {
            response.setStatus(Status.CLIENT_ERROR_NOT_FOUND);
View Full Code Here

            getRoutes().add(
                    new HostRoute(this, getComponent().getDefaultHost()));
        }

        // If no host matches, display and error page with a precise message
        final Restlet noHostMatched = new Restlet(getComponent().getContext()
                .createChildContext()) {
            @Override
            public void handle(Request request, Response response) {
                response.setStatus(Status.CLIENT_ERROR_NOT_FOUND,
                        "No virtual host could handle the request");
View Full Code Here

        }
    }

    @Override
    public Restlet getNext(Request request, Response response) {
        Restlet result = super.getNext(request, response);
        if (result == null) {
            getLogger()
                    .warning(
                            "The protocol used by this request is not declared in the list of client connectors. ("
                                    + request.getResourceRef()
View Full Code Here

     * @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();
        }
View Full Code Here

*
* @author Jerome Louvel
*/
public class HeadersTest {
    public static void main(String[] args) throws Exception {
        final Restlet restlet = new Restlet() {
            @SuppressWarnings("unchecked")
            @Override
            public void handle(Request request, Response response) {
                // ------------------------------
                // Getting an HTTP request header
View Full Code Here

        // Create a directory able to expose a hierarchy of files
        Directory directory = new Directory(getContext(), ROOT_URI);
        guard.setNext(directory);

        // Create the account handler
        Restlet account = new Restlet() {
            @Override
            public void handle(Request request, Response response) {
                // Print the requested URI path
                String message = "Account of user \""
                        + request.getAttributes().get("user") + "\"";
                response.setEntity(message, MediaType.TEXT_PLAIN);
            }
        };

        // Create the orders handler
        Restlet orders = new Restlet(getContext()) {
            @Override
            public void handle(Request request, Response response) {
                // Print the user name of the requested orders
                String message = "Orders of user \""
                        + request.getAttributes().get("user") + "\"";
                response.setEntity(message, MediaType.TEXT_PLAIN);
            }
        };

        // Create the order handler
        Restlet order = new Restlet(getContext()) {
            @Override
            public void handle(Request request, Response response) {
                // Print the user name of the requested orders
                String message = "Order \""
                        + request.getAttributes().get("order")
View Full Code Here

TOP

Related Classes of org.restlet.Restlet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.