Package com.ibm.sbt.service.basic

Examples of com.ibm.sbt.service.basic.ProxyEndpointService


    public ConnectionsProxyHandler() {
    }
   
    public void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
        ProxyEndpointService p = new ProxyEndpointService() {
            @Override
            protected String getProxyUrlPath() {
                return URL_PATH;
            }
            @Override
            protected boolean isMethodAllowed(String method) {
                if(method.equalsIgnoreCase("get")) {
                    return true;
                }
                return false;
            }
        };
        p.service(request, response);
    }   
View Full Code Here


    fileProxyMap.put("connections", "com.ibm.sbt.service.basic.ConnectionsFileProxyService");   
  }

  @Override
  public ProxyEndpointService createProxyEndpointService(String serviceType) {
    ProxyEndpointService proxyEndpointService = null;
    try {
      proxyEndpointService = (ProxyEndpointService) Class.forName(fileProxyMap.get(serviceType)).newInstance();
    } catch (InstantiationException e) {
      logger.log(Level.SEVERE, e.getMessage(), e);     
    } catch (IllegalAccessException e) {
View Full Code Here


  @Override
  public void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {

    ProxyEndpointService proxyEndpointService = null;
    // /files/<<endpointName>>/<<serviceType>>/fileName?args
    String pathinfo = request.getPathInfo().substring(request.getPathInfo().indexOf("/files"));
    String[] pathTokens = pathinfo.split("/");   
    if (pathTokens.length > 4) {
      String serviceType = pathTokens[3];
      Application application = Application.get();
      // ProxyEndpointServiceProvider.PROXY_SERVICE_TYPE is the extension ID
      List<Object> proxyServiceProviders = application.findServices(ProxyEndpointServiceProvider.PROXY_SERVICE_TYPE);
      if(proxyServiceProviders != null && !proxyServiceProviders.isEmpty()){
        for(Object o : proxyServiceProviders){
          ProxyEndpointServiceProvider pvdr = (ProxyEndpointServiceProvider)o;
          proxyEndpointService = pvdr.createProxyEndpointService(serviceType);
          if(proxyEndpointService != null){
            break;
          }
        }
      }
      else {
        DefaultProxyEndpointServiceProvider proxyEndpointServiceProvider = new DefaultProxyEndpointServiceProvider();
        proxyEndpointService = proxyEndpointServiceProvider.createProxyEndpointService(serviceType);
      }
    }
    if(proxyEndpointService != null){
      proxyEndpointService.service(request, response);
    }
    else{
      logger.log(Level.SEVERE, "ProxyEndpoint Service could not be retrieved for PathInfo {0}", pathinfo);
      ProxyService.writeErrorResponse(HttpServletResponse.SC_BAD_REQUEST, "ProxyEndpoint Service could not be retrieved", new String[] {}, new String[] {}, response, request);     
    }
View Full Code Here

    public static final String URL_PATH = "proxy";
 
    @Override
  public void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
        ProxyEndpointService p = new ProxyEndpointService() {
            @Override
            protected String getProxyUrlPath() {
                return URL_PATH;
            }
            @Override
            protected boolean isMethodAllowed(String method) {
                if(method.equalsIgnoreCase("get")|| method.equalsIgnoreCase("put")||method.equalsIgnoreCase("post")||method.equalsIgnoreCase("delete") ||
                        method.equalsIgnoreCase("OPTIONS") || method.equalsIgnoreCase("HEAD")) {
                    return true;
                }
                return false;
            }
        };
        p.service(request, response);
    }   
View Full Code Here

    public ConnectionsProxyHandler() {
    }
   
    @Override
  public void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
        ProxyEndpointService p = new ProxyEndpointService() {
            @Override
            protected String getProxyUrlPath() {
                return URL_PATH;
            }
            @Override
            protected boolean isMethodAllowed(String method) {
                if(method.equalsIgnoreCase("get")) {
                    return true;
                }
                return false;
            }
        };
        p.service(request, response);
    }   
View Full Code Here

TOP

Related Classes of com.ibm.sbt.service.basic.ProxyEndpointService

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.