Package org.osgi.service.http

Examples of org.osgi.service.http.HttpService


        return; // already done
      }
     
      log.debug("set axis servlet for " + httpSR);
     
      HttpService http = (HttpService)Activator.bc.getService(httpSR);
     
      try {
        Axis2Servlet      axisServlet  = new Axis2Servlet();
        Axis2AdminServlet adminServlet = new Axis2AdminServlet(axisServlet);

        http.registerServlet(AXIS2_SERVLET_ALIAS, axisServlet, new Hashtable(), myHttpContext);
        http.registerServlet(AXIS2ADMIN_SERVLET_ALIAS, adminServlet, new Hashtable(), myHttpContext);
       
        log.info("registered axis servlet at " + AXIS2_SERVLET_ALIAS);
        log.info("registered axis admin servlet at " + AXIS2ADMIN_SERVLET_ALIAS);
       
        servletRegistrations.put(httpSR, new Object[] {
View Full Code Here


        }
      } catch (Exception e) {
        log.warn("Failed to undeploy", e);
      }
     
      HttpService http = (HttpService)Activator.bc.getService(httpSR);
     
      if(http != null) {
        http.unregister(AXIS2_SERVLET_ALIAS);
        http.unregister(AXIS2ADMIN_SERVLET_ALIAS);
        bc.ungetService(httpSR);
      }
      servletRegistrations.remove(httpSR);
    }
  }
View Full Code Here

  private HttpService register(final ServiceReference sr)
  {
    log.info("Registering with added HttpService");

    final HttpService http = (HttpService) bc.getService(sr);

    try {
      http.registerResources(ALIAS_ROOT, RES_ROOT, new CompletingHttpContext());
      http.registerServlet(ALIAS_SERVLET, new InfoServlet(sr),
                           new Hashtable(), null);
      http.registerResources(ALIAS_DOCS, "", new DirectoryHttpContext());
    } catch (Exception e) {
      log.error("Failed to register in HttpService: " +e.getMessage(), e);
    }

    log.info("Registration done.");
View Full Code Here

      e.printStackTrace();
    }
  }
 
  void register(ServiceReference sr) {
    HttpService http = (HttpService) bc.getService(sr);
    if (http == null) {
      Activator.log.warn("http resource is null");
      return;
    }
   
    try {
      Hashtable props = new Hashtable();
      http.registerServlet(Activator.SERVLET_ALIAS, servlet, props, null);
      http.registerResources(Activator.RES_ALIAS, Activator.RES_DIR, context);
    } catch (Exception e) {
      Activator.log.error("Failed to register resource", e);
    }
  }
View Full Code Here

        PrivateAccessor.setField(servlet, "config", config);
        PrivateAccessor.setField(servlet, "clusterViewService", clusterViewService);
        PrivateAccessor.setField(servlet, "announcementRegistry", announcementRegistry);

        Mockery context = new JUnit4Mockery();
        final HttpService httpService = context.mock(HttpService.class);
        context.checking(new Expectations() {
            {
                allowing(httpService).registerServlet(with(any(String.class)),
                        with(any(Servlet.class)),
                        with(any(Dictionary.class)),
View Full Code Here

            _context,
            HttpService.class.getName(),
            new ServiceTrackerCustomizer() {
                public Object addingService(ServiceReference serviceReference) {
                    try {
                        HttpService service = (HttpService)_context.getService(serviceReference);
                        Dictionary<String, String> initParams = new Hashtable<String, String>();
                        initParams.put("javax.ws.rs.Application", SampleApplication.class.getName());
                        service.registerServlet(_path, new SampleServlet(), initParams, null);
                        return service;
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        throw new RuntimeException(ex);
                    }
                }

                public void modifiedService(ServiceReference serviceReference, Object o) {
                    // do nothing
                }

                public void removedService(ServiceReference serviceReference, Object o) {
                    HttpService service = (HttpService)_context.getService(serviceReference);
                    if (service != null) {
                        service.unregister(_path);
                    }
                }
            }
        );
        _tracker.open();
View Full Code Here

     * @throws NamespaceException
     * @throws IOException
     */
    public void testCorrectParameterCount() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        int parameterCount = 16;
        for ( int i = 0; i < parameterCount; ++i )
View Full Code Here

     * @throws ServletException
     * @throws NamespaceException
     */
    public void testParameterContents() throws IOException, ServletException, NamespaceException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        int parameterCount = 16;
        for ( int i = 0; i < parameterCount; ++i )
View Full Code Here

     * @throws ServletException
     * @throws NamespaceException
     */
    public void testCanRegisterServlet() throws ServletException, NamespaceException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        httpService.registerServlet( "/", new BasicTestingServlet(), null, null );
    }
View Full Code Here

     * @throws NamespaceException
     */
    public void testCannotRegisterSameAliasTwice() throws ServletException, NamespaceException
    {

        HttpService httpService = getHTTPService( registry.getBundleContext() );

        boolean namespaceExceptionThrown = false;
        httpService.registerServlet( "/alias", new BasicTestingServlet(), null, null );

        try
        {
            httpService.registerServlet( "/alias", new BasicTestingServlet(), null, null );
        }
        catch ( NamespaceException e )
        {
            namespaceExceptionThrown = true;
        }
View Full Code Here

TOP

Related Classes of org.osgi.service.http.HttpService

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.