org.apache.cxf.transport.servlet.ServletController Java Examples

The following examples show how to use org.apache.cxf.transport.servlet.ServletController. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BulkReadResourceImpl.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
@PostConstruct
private void init() {
    final DestinationRegistry registry = cxf.getRegistry();
    controller = new ServletController(registry,
            new SimpleServletConfig(servletContext, "Talend Component Kit Bulk Transport"),
            new ServiceListGeneratorServlet(registry, bus));
}
 
Example #2
Source File: KSBDispatcherServlet.java    From rice with Educational Community License v2.0 5 votes vote down vote up
@Override
protected void initFrameworkServlet() throws ServletException, BeansException {
	this.httpInvokerHandler = new KSBHttpInvokerHandler();
	
       Bus bus = KSBServiceLocator.getCXFBus();

       List<Interceptor<? extends Message>> inInterceptors = KSBServiceLocator.getInInterceptors();
       if(inInterceptors != null) {
       	List<Interceptor<? extends Message>> busInInterceptors = bus.getInInterceptors();
       	busInInterceptors.addAll(inInterceptors);
       }
      
       List<Interceptor<? extends Message>> outInterceptors = KSBServiceLocator.getOutInterceptors();
       if(outInterceptors != null) {
       	List<Interceptor<? extends Message>> busOutInterceptors = bus.getOutInterceptors();
       	busOutInterceptors.addAll(outInterceptors);
       }


	HTTPTransportFactory transportFactory = bus.getExtension(HTTPTransportFactory.class);
       if (transportFactory == null) {
           throw new IllegalStateException("Failed to locate HTTPTransportFactory extension on Apache CXF Bus");
       }

       DestinationRegistry destinationRegistry = transportFactory.getRegistry();


	this.cxfServletController = new ServletController(destinationRegistry, getCXFServletConfig(
               this.getServletConfig()), new ServiceListGeneratorServlet(destinationRegistry, bus));

	this.setPublishEvents(false);
}
 
Example #3
Source File: CXFServletControllerAdapter.java    From rice with Educational Community License v2.0 4 votes vote down vote up
public void setController(ServletController controller){
	this.controller = controller;
}
 
Example #4
Source File: ServiceListGeneratorServlet.java    From cxf with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void service(HttpServletRequest request,
                    HttpServletResponse response) throws ServletException, IOException {
    Object obj = request.getAttribute(ServletController.AUTH_SERVICE_LIST);
    boolean isAuthServiceList = false;
    if (obj != null) {
        isAuthServiceList = Boolean.valueOf(obj.toString());
    }
    if (isAuthServiceList) {
        String authServiceListRealm = (String)request.getAttribute(ServletController.AUTH_SERVICE_LIST_REALM);
        ServiceListJAASAuthenticator authenticator = new ServiceListJAASAuthenticator();
        authenticator.setRealm(authServiceListRealm);
        if (!authenticator.authenticate(request, response)) {
            return;
        }
        request.removeAttribute(ServletController.AUTH_SERVICE_LIST);
        request.removeAttribute(ServletController.AUTH_SERVICE_LIST_REALM);
    }
    AbstractDestination[] destinations = destinationRegistry.getSortedDestinations();
    if (request.getParameter("stylesheet") != null) {
        renderStyleSheet(request, response);
        return;
    }
    List<String> privateEndpoints;
    if (bus == null) {
        bus = BusFactory.getDefaultBus(false);
    }
    if (bus != null) {
        privateEndpoints = (List<String>)bus.getProperty("org.apache.cxf.private.endpoints");
    } else {
        privateEndpoints = new ArrayList<>();
    }

    AbstractDestination[] soapEndpoints = getSOAPEndpoints(destinations, privateEndpoints);
    AbstractDestination[] restEndpoints = getRestEndpoints(destinations, privateEndpoints);
    ServiceListWriter serviceListWriter;
    if ("false".equals(request.getParameter("formatted"))) {
        boolean renderWsdlList = "true".equals(request.getParameter("wsdlList"));
        serviceListWriter = new UnformattedServiceListWriter(renderWsdlList, bus);
    } else {
        String styleSheetPath;
        if (serviceListStyleSheet != null) {
            styleSheetPath = request.getContextPath() + "/" + serviceListStyleSheet;
        } else {
            styleSheetPath = "";
            String contextPath = request.getContextPath();
            if (contextPath != null) {
                styleSheetPath += contextPath;
            }
            String servletPath = request.getServletPath();
            if (servletPath != null) {
                styleSheetPath += servletPath;
            }
            String pathInfo = request.getPathInfo();
            if (pathInfo != null) {
                styleSheetPath += pathInfo;
            }

            if (!styleSheetPath.endsWith("/")) {
                styleSheetPath += "/";
            }
            styleSheetPath += "?stylesheet=1";
        }
        serviceListWriter =
            new FormattedServiceListWriter(styleSheetPath, title, showForeignContexts, bus);

    }
    response.setContentType(serviceListWriter.getContentType());
    Object basePath = request.getAttribute(Message.BASE_PATH);
    serviceListWriter.writeServiceList(response.getWriter(),
                                       basePath == null ? null : basePath.toString(),
                                       soapEndpoints, restEndpoints);
}
 
Example #5
Source File: GenericWebServiceServlet.java    From BIMserver with GNU Affero General Public License v3.0 4 votes vote down vote up
private ServletController createServletController(ServletConfig servletConfig) {
	HttpServlet serviceListGeneratorServlet = new ServiceListGeneratorServlet(destinationRegistry, bus);
	ServletController newController = new ServletController(destinationRegistry, servletConfig, serviceListGeneratorServlet);
	return newController;
}