Package org.restlet.service

Examples of org.restlet.service.ConnectorService


                writeResponseHead(response);
                final Representation entity = response.getEntity();

                if (entity != null) {
                    // Get the connector service to callback
                    final ConnectorService connectorService = getConnectorService(response
                            .getRequest());
                    if (connectorService != null) {
                        connectorService.beforeSend(entity);
                    }

                    final WritableByteChannel responseEntityChannel = getResponseEntityChannel();
                    final OutputStream responseEntityStream = getResponseEntityStream();
                    writeResponseBody(entity, responseEntityChannel,
                            responseEntityStream);

                    if (connectorService != null) {
                        connectorService.afterSend(entity);
                    }

                    if (responseEntityStream != null) {
                        try {
                            responseEntityStream.flush();
View Full Code Here


                writeResponseHead(response);
                final Representation entity = response.getEntity();

                if (entity != null) {
                    // Get the connector service to callback
                    final ConnectorService connectorService = getConnectorService(response
                            .getRequest());
                    if (connectorService != null) {
                        connectorService.beforeSend(entity);
                    }

                    final WritableByteChannel responseEntityChannel = getResponseEntityChannel();
                    final OutputStream responseEntityStream = getResponseEntityStream();
                    writeResponseBody(entity, responseEntityChannel,
                            responseEntityStream);

                    if (connectorService != null) {
                        connectorService.afterSend(entity);
                    }

                    if (responseEntityStream != null) {
                        try {
                            responseEntityStream.flush();
View Full Code Here

     * @param request
     *            The request to lookup.
     * @return The connector service associated to a request.
     */
    public ConnectorService getConnectorService(Request request) {
        ConnectorService result = null;
        final Application application = Application.getCurrent();

        if (application != null) {
            result = application.getConnectorService();
        } else {
            result = new ConnectorService();
        }

        return result;
    }
View Full Code Here

        final Representation entity = request.isEntityAvailable() ? request
                .getEntity() : null;
        try {
            if (entity != null) {
                // Get the connector service to callback
                final ConnectorService connectorService = getConnectorService(request);
                if (connectorService != null) {
                    connectorService.beforeSend(entity);
                }

                // In order to workaround bug #6472250
                // (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6472250),
                // it is very important to reuse that exact same "rs" reference
                // when manipulating the request stream, otherwise "insufficient
                // data sent" exceptions will occur in "fixedLengthMode"
                final OutputStream rs = getRequestEntityStream();
                final WritableByteChannel wbc = getRequestEntityChannel();

                if (wbc != null) {
                    entity.write(wbc);
                } else if (rs != null) {
                    entity.write(rs);
                    rs.flush();
                }

                // Call-back after writing
                if (connectorService != null) {
                    connectorService.afterSend(entity);
                }

                if (rs != null) {
                    rs.close();
                } else if (wbc != null) {
View Full Code Here

                    && !response.getRequest().getMethod().equals(Method.HEAD)
                    && !response.getStatus().equals(Status.SUCCESS_NO_CONTENT)
                    && !response.getStatus().equals(
                            Status.SUCCESS_RESET_CONTENT)) {
                // Get the connector service to callback
                ConnectorService connectorService = getConnectorService(response
                        .getRequest());
                if (connectorService != null)
                    connectorService.beforeSend(entity);

                writeResponseBody(entity);

                if (connectorService != null)
                    connectorService.afterSend(entity);
            }

            if (getResponseStream() != null) {
                try {
                    getResponseStream().flush();
View Full Code Here

     * @param request
     *            The request to lookup.
     * @return The connector service associated to a request.
     */
    public ConnectorService getConnectorService(Request request) {
        ConnectorService result = null;
        Application application = (Application) request.getAttributes().get(
                Application.KEY);

        if (application != null) {
            result = application.getConnectorService();
        } else {
            result = new ConnectorService();
        }

        return result;
    }
View Full Code Here

TOP

Related Classes of org.restlet.service.ConnectorService

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.