Package org.restlet

Examples of org.restlet.Context


  }

  @Override
  protected Application createApplication(Context context)
  {
    Context childContext = context.createChildContext();
    childContext.getAttributes().put(IApplicationProvider.SERVLET_CONFIG_ATTRIBUTE, servletConfig);
    childContext.getAttributes().put(IApplicationProvider.SERVLET_CONTEXT_ATTRIBUTE, getServletContext());
    return applicationProvider.createApplication(childContext);
  }
View Full Code Here


        new StringRepresentation("Error"),
        Status.CLIENT_ERROR_BAD_REQUEST);
  }
 
  public void testExceptionHandling(){
    Context con = new Context();
    Request req = new Request();
    Response resp = new Response(req);
   
    myResource.init(con, req, resp);
    myResource.handleGet();
View Full Code Here

    public RestletProducer(RestletEndpoint endpoint) throws Exception {
        super(endpoint);
        this.throwException = endpoint.isThrowExceptionOnFailure();
        client = new Client(endpoint.getProtocol());
        client.setContext(new Context());
    }
View Full Code Here

    public void testRequestUri() throws Exception {
        Engine.register(false);
        Engine.getInstance().getRegisteredServers()
                .add(new HttpServerHelper(null));
        Server server = new Server(new Context(), Protocol.HTTP, 0);
        server.start();

        HttpServerHelper hsh = (HttpServerHelper) server.getContext()
                .getAttributes().get("org.restlet.engine.helper");
        Connection<Server> c = hsh.getConnectionPool().checkout();
View Full Code Here

     *            the RoleChecer to use.
     * @return
     */
    protected JaxRsApplication createApplication(Application appConfig,
            ChallengeScheme challengeScheme) {
        final JaxRsApplication application = new JaxRsApplication(new Context());
        application.add(appConfig);
        modifyApplication(application);
        return application;
    }
View Full Code Here

        originComponent.start();
        proxyComponent.start();
        clientComponent.start();

        // Tests
        final Context context = clientComponent.getContext();
        String uri = "http://localhost:" + TEST_PORT + "/?foo=bar";
        testCall(context, Method.GET, uri);
        testCall(context, Method.DELETE, uri);

        uri = "http://localhost:" + TEST_PORT
View Full Code Here

                                for (final String protocol : protocols) {
                                    protocolsList.add(getProtocol(protocol));
                                }

                                client = new Client(new Context(),
                                        protocolsList);
                            }
                        } else {
                            client = new Client(new Context(),
                                    getProtocol(item.getNodeValue()));
                        }

                        if (client != null) {
                            getComponent().getClients().add(client);

                            // Look for Restlet's attributes
                            parseRestlet(client, childNode);

                            // Look for parameters
                            for (int j = 0; j < childNode.getChildNodes()
                                    .getLength(); j++) {
                                final Node childNode2 = childNode
                                        .getChildNodes().item(j);

                                if (isParameter(childNode2)) {
                                    Parameter p = parseParameter(childNode2);
                                    if (p != null) {
                                        client.getContext().getParameters()
                                                .add(p);
                                    }
                                }
                            }
                        }
                    } else if ("server".equals(childNode.getNodeName())) {
                        Node item = childNode.getAttributes().getNamedItem(
                                "protocol");
                        final Node portNode = childNode.getAttributes()
                                .getNamedItem("port");
                        final Node addressNode = childNode.getAttributes()
                                .getNamedItem("address");
                        Server server = null;

                        if (item == null) {
                            item = childNode.getAttributes().getNamedItem(
                                    "protocols");

                            if (item != null) {
                                final String[] protocols = item.getNodeValue()
                                        .split(" ");
                                final List<Protocol> protocolsList = new ArrayList<Protocol>();

                                for (final String protocol : protocols) {
                                    protocolsList.add(getProtocol(protocol));
                                }

                                final int port = getInt(portNode,
                                        Protocol.UNKNOWN_PORT);

                                if (port == Protocol.UNKNOWN_PORT) {
                                    getLogger()
                                            .warning(
                                                    "Please specify a port when defining a list of protocols.");
                                } else {
                                    server = new Server(new Context(),
                                            protocolsList, getInt(portNode,
                                                    Protocol.UNKNOWN_PORT),
                                            getComponent().getServers()
                                                    .getNext());
                                }
                            }
                        } else {
                            final Protocol protocol = getProtocol(item
                                    .getNodeValue());
                            server = new Server(
                                    new Context(),
                                    protocol,
                                    getInt(portNode, protocol.getDefaultPort()),
                                    getComponent().getServers().getNext());
                        }
View Full Code Here

    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
        Application app = new Application(new Context());
        Application.setCurrent(app);
        this.tunnelFilter = new TunnelFilter(app.getContext());
        this.tunnelFilter.getApplication().getTunnelService()
                .setExtensionsTunnel(true);
    }
View Full Code Here

            }

            public void execute(final Runnable runnable) {
                // Save the thread local variables
                final Application currentApplication = Application.getCurrent();
                final Context currentContext = Context.getCurrent();
                final Integer currentVirtualHost = VirtualHost.getCurrent();
                final Response currentResponse = Response.getCurrent();

                executorService.execute(new Runnable() {
                    public void run() {
View Full Code Here

     * Test POST, PUT and GET using the Client class
     *
     * @throws Exception
     */
    public void testIntegration() throws Exception {
        Client client = new Client(new Context(), Arrays.asList(Protocol.HTTP));
        Request request = new Request(Method.POST, uri);
        request.setEntity(new JaxbRepresentation<Sample>(new Sample(IN_STRING)));

        Response response = client.handle(request);

View Full Code Here

TOP

Related Classes of org.restlet.Context

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.