当前位置: 首页>>代码示例>>Java>>正文


Java Response类代码示例

本文整理汇总了Java中org.apache.tapestry5.services.Response的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Response类属于org.apache.tapestry5.services包,在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildTimingFilter

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
public RequestFilter buildTimingFilter(final Logger log) {
    return new RequestFilter() {

        public boolean service(Request request, Response response, RequestHandler handler) throws IOException {
            long startTime = System.currentTimeMillis();

            try {
                return handler.service(request, response);
            } finally {
                long elapsed = System.currentTimeMillis() - startTime;

                log.info(String.format("Request time: %d ms, %s", elapsed, request.getPath()));
            }
        }
    };
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:17,代码来源:AppModule.java

示例2: handleRetrieveAlerts

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
protected void handleRetrieveAlerts(final Request request, final Response response) throws IOException {
  // See TAP5-1941
  if (!request.isXHR()) {
    response.sendError(400, "Expecting XMLHttpRequest");
  }
  JSONObject result = new JSONObject();
  AlertStorage storage = applicationStateManager.getIfExists(AlertStorage.class);
  if (storage != null) {

    for (Alert alert : storage.getAlerts()) {
      result.append("alerts", alert.toJSON());
    }
    storage.dismissNonPersistent();
  }
  try (PrintWriter printWriter = response.getPrintWriter("application/json")) {
    printWriter.write(result.toString(productionMode));
  }
}
 
开发者ID:eddyson-de,项目名称:tapestry-react,代码行数:19,代码来源:ReactAPIFilter.java

示例3: handleDismissAlerts

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
protected void handleDismissAlerts(final Request request, final Response response) throws IOException {
  AlertStorage storage = applicationStateManager.getIfExists(AlertStorage.class);
  if (storage != null) {
    String id = request.getParameter("id");
    if (id != null) {
      storage.dismiss(Long.parseLong(id));
    } else {
      storage.dismissAll();
    }
  }
  if (request.isXHR()) {
    try (PrintWriter printWriter = response.getPrintWriter("application/json")) {
      printWriter.write("{}");
    }
  }
}
 
开发者ID:eddyson-de,项目名称:tapestry-react,代码行数:17,代码来源:ReactAPIFilter.java

示例4: buildTimingFilter

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
/**
 * This is a service definition, the service will be named "TimingFilter".
 * The interface, RequestFilter, is used within the RequestHandler service
 * pipeline, which is built from the RequestHandler service configuration.
 * Tapestry IoC is responsible for passing in an appropriate Logger
 * instance. Requests for static resources are handled at a higher level, so
 * this filter will only be invoked for Tapestry related requests.
 * <p/>
 * <p/>
 * Service builder methods are useful when the implementation is inline as
 * an inner class (as here) or require some other kind of special
 * initialization. In most cases, use the static bind() method instead.
 * <p/>
 * <p/>
 * If this method was named "build", then the service id would be taken from
 * the service interface and would be "RequestFilter". Since Tapestry
 * already defines a service named "RequestFilter" we use an explicit
 * service id that we can reference inside the contribution method.
 */
public RequestFilter buildTimingFilter(final Logger log) {
    return new RequestFilter() {
        public boolean service(Request request, Response response, RequestHandler handler) throws IOException {
            long startTime = System.currentTimeMillis();

            try {
                // The responsibility of a filter is to invoke the
                // corresponding method
                // in the handler. When you chain multiple filters together,
                // each filter
                // received a handler that is a bridge to the next filter.

                return handler.service(request, response);
            } finally {
                long elapsed = System.currentTimeMillis() - startTime;

                log.info(String.format("Request time: %d ms", elapsed));
            }
        }
    };
}
 
开发者ID:beargiles,项目名称:project-student,代码行数:41,代码来源:AppModule.java

示例5: buildTimingFilter

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
/**
 * This is a service definition, the service will be named "TimingFilter". The interface,
 * RequestFilter, is used within the RequestHandler service pipeline, which is built from the
 * RequestHandler service configuration. Tapestry IoC is responsible for passing in an
 * appropriate Logger instance. Requests for static resources are handled at a higher level, so
 * this filter will only be invoked for Tapestry related requests.
 * <p/>
 * <p/>
 * Service builder methods are useful when the implementation is inline as an inner class
 * (as here) or require some other kind of special initialization. In most cases,
 * use the static bind() method instead.
 * <p/>
 * <p/>
 * If this method was named "build", then the service id would be taken from the
 * service interface and would be "RequestFilter".  Since Tapestry already defines
 * a service named "RequestFilter" we use an explicit service id that we can reference
 * inside the contribution method.
 */
public RequestFilter buildTimingFilter(final Logger log)
{
    return new RequestFilter()
    {
        public boolean service(Request request, Response response, RequestHandler handler)
                throws IOException
        {
            long startTime = System.currentTimeMillis();

            try
            {
                // The responsibility of a filter is to invoke the corresponding method
                // in the handler. When you chain multiple filters together, each filter
                // received a handler that is a bridge to the next filter.

                return handler.service(request, response);
            } finally
            {
                long elapsed = System.currentTimeMillis() - startTime;

                log.info(String.format("Request time: %d ms", elapsed));
            }
        }
    };
}
 
开发者ID:wso2as-developer,项目名称:tapestry-samples,代码行数:44,代码来源:AppModule.java

示例6: decorateRequestGlobals

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
public static RequestGlobals decorateRequestGlobals(final RequestGlobals originalRequestGlobals)
{
    HttpServletRequest httpServletRequest = createNiceMock(HttpServletRequest.class);
    RequestGlobals requestGlobals = createNiceMock(RequestGlobals.class);

    requestGlobals.storeRequestResponse(anyObject(Request.class), anyObject(Response.class));
    expectLastCall().andDelegateTo(originalRequestGlobals);

    requestGlobals.storeActivePageName(anyObject(String.class));
    expectLastCall().andDelegateTo(originalRequestGlobals);

    expect(requestGlobals.getRequest()).andDelegateTo(originalRequestGlobals);
    expect(requestGlobals.getResponse()).andDelegateTo(originalRequestGlobals);
    expect(requestGlobals.getHTTPServletRequest()).andReturn(httpServletRequest);

    replay(requestGlobals, httpServletRequest);

    return requestGlobals;
}
 
开发者ID:porscheinformatik,项目名称:tapestry-csrf-protection,代码行数:20,代码来源:PageTesterUtils.java

示例7: qrDownStreamResponse

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
private
StreamResponse qrDownStreamResponse()
{
    return new StreamResponse()
    {
        public String getContentType()
        {
            return "image/png";
        }

        public InputStream getStream() throws IOException
        {
            return qrDownImage.getResource().openStream();
        }

        public void prepareResponse(Response response)
        {
            //You might think that we could ask them to cache it a while... but it won't help b/c the url changes constantly (it includes "x").
        }
    };
}
 
开发者ID:Allogy,项目名称:isqrl-server,代码行数:22,代码来源:QR.java

示例8: onActivate

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
public StreamResponse onActivate() {
    return new StreamResponse() {

        InputStream inputStream;

        @Override
        public void prepareResponse(Response response) {
            try {
                response.setHeader("Content-Disposition", "attachment; filename=" + streamFilename);
                inputStream = new ByteArrayInputStream(streamContent.getBytes("UTF-8"));    
                response.setHeader("Content-Length", "" + inputStream.available());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public String getContentType() {
            return streamType;
        }

        @Override
        public InputStream getStream() throws IOException {
            return inputStream;
        }
    };
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:28,代码来源:StreamResponsePage.java

示例9: buildUtf8Filter

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
public RequestFilter buildUtf8Filter(@InjectService("RequestGlobals") final RequestGlobals requestGlobals,
        final Logger log) {
    return new RequestFilter() {

        public boolean service(Request request, Response response, RequestHandler handler) throws IOException {
            requestGlobals.getHTTPServletRequest().setCharacterEncoding("UTF-8");
            return handler.service(request, response);
        }
    };
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:11,代码来源:AppModule.java

示例10: createEpgImage

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
@OnEvent(value = "epgImage")
public StreamResponse createEpgImage(String key) {
    return new StreamResponse() {

        InputStream inputStream;

        @Override
        public void prepareResponse(Response response) {
            try {
                byte[] file = epgImageService.getEpgImage(key);
                inputStream = new ByteArrayInputStream(file);
                response.setHeader("Content-Length", "" + inputStream.available());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public String getContentType() {
            return "text/png";
        }

        @Override
        public InputStream getStream() throws IOException {
            return inputStream;
        }
    };
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:29,代码来源:EpgImage.java

示例11: createMovieMediaImage

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
@OnEvent(value = "movieMediaImage")
public StreamResponse createMovieMediaImage(long movieId, long actorId, int mediaType) {
    return new StreamResponse() {

        InputStream inputStream;

        @Override
        public void prepareResponse(Response response) {
            try {
                byte[] file = epgImageService.getMovieMediaImage(movieId, mediaType, actorId);
                inputStream = new ByteArrayInputStream(file);
                response.setHeader("Content-Length", "" + inputStream.available());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public String getContentType() {
            return "text/png";
        }

        @Override
        public InputStream getStream() throws IOException {
            return inputStream;
        }
    };
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:29,代码来源:EpgImage.java

示例12: createSeriesMediaImage

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
@OnEvent(value = "seriesMediaImage")
public StreamResponse createSeriesMediaImage(long seriesId, long seasonNumber, long episodeId, long actorId,
        int mediaType) {
    return new StreamResponse() {

        InputStream inputStream;

        @Override
        public void prepareResponse(Response response) {
            try {
                byte[] file = epgImageService.getSeriesMediaImage(seriesId, seasonNumber, episodeId, mediaType,
                        actorId);
                inputStream = new ByteArrayInputStream(file);
                response.setHeader("Content-Length", "" + inputStream.available());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public String getContentType() {
            return "text/png";
        }

        @Override
        public InputStream getStream() throws IOException {
            return inputStream;
        }
    };
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:31,代码来源:EpgImage.java

示例13: onDownload

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
public StreamResponse onDownload() {
    return new StreamResponse() {

        InputStream inputStream;

        @Override
        public void prepareResponse(Response response) {
            try {
                response.setHeader("Content-Disposition", "attachment; filename=channelmap.conf");

                String mapping = channelMapService.createEpgdMapping(currentVdrView.getChannelVdr().get());
                inputStream = new ByteArrayInputStream(mapping.getBytes("UTF-8"));

                response.setHeader("Content-Length", "" + inputStream.available());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public String getContentType() {
            return "text/plain";
        }

        @Override
        public InputStream getStream() throws IOException {
            return inputStream;
        }
    };
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:31,代码来源:ChannelMap.java

示例14: createChannelImage

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
@OnEvent(value = "channelImage")
public StreamResponse createChannelImage(String channel) {
    return new StreamResponse() {

        InputStream inputStream;

        @Override
        public void prepareResponse(Response response) {
            try {
                // inputStream = getResourceAsStream(channel);
                inputStream = logoCache.getResource(channel);

                if (inputStream == null) {
                    inputStream = emptyChannel.getResource().openStream();
                }

                response.setHeader("Content-Length", "" + inputStream.available());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public String getContentType() {
            return "text/png";
        }

        @Override
        public InputStream getStream() throws IOException {
            return inputStream;
        }
    };
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:34,代码来源:ChannelImage.java

示例15: onCreateChannelsConf

import org.apache.tapestry5.services.Response; //导入依赖的package包/类
public StreamResponse onCreateChannelsConf() {
    return new StreamResponse() {

        InputStream inputStream;

        @Override
        public void prepareResponse(Response response) {
            try {
                response.setHeader("Content-Disposition", "attachment; filename=channels.conf");

                // generate channels.conf
                StringBuilder builder = new StringBuilder();
                channelGroups.stream() //
                    .filter(f -> !parkingGroup.equals(f)) //
                    .forEach(g -> {
                        builder.append(":").append(g).append("\n");
                        if ((channelsInGroup.get(g) != null) && (channelsInGroup.get(g).size() > 1)) {
                            channelsInGroup.get(g).stream().forEach(c -> builder.append(c.getChannelLine()).append("\n"));
                        }
                    });
                
                inputStream = new ByteArrayInputStream(builder.toString().getBytes("UTF-8"));

                response.setHeader("Content-Length", "" + inputStream.available());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public String getContentType() {
            return "text/plain";
        }

        @Override
        public InputStream getStream() throws IOException {
            return inputStream;
        }
    };
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:41,代码来源:ChannelConfig.java


注:本文中的org.apache.tapestry5.services.Response类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。