Package org.osgi.service.http

Examples of org.osgi.service.http.HttpService


    }

    private void removeServlet(ServiceReference ref, String endpoint) {
        m_servlets.remove(ref);
        for (ServiceReference reference : m_httpServices) {
            HttpService httpService = (HttpService) m_context.getService(reference);
            if ((httpService != null) && (endpoint != null)) {
                try {
                    httpService.unregister(endpoint);
                }
                catch (Exception e) {
                    m_log.log(LogService.LOG_WARNING, "Servlet cannot be unregistered, maybe not registered under this endpoint", e);
                }
            }
View Full Code Here


    }

    @Override
    public synchronized void destroy(BundleContext context, DependencyManager arg1) throws Exception {
        for (ServiceReference httpRef : m_httpServices) {
            HttpService httpService = (HttpService)m_context.getService(httpRef);
            if (httpService != null) {
                unregisterEndpoints(httpService);
            }
        }
        m_httpServices.clear();
View Full Code Here

    public HttpServiceTracker(BundleContext context) {
        super(context, HttpService.class.getName(), null);
    }

    public Object addingService(ServiceReference reference) {
        final HttpService httpService = (HttpService) context.getService(reference);
        try {
            HttpContext commonContext =
                    new BundleEntryHttpContext(context.getBundle(), "/web");
            httpService.registerResources("/jsp-examples", "/",
                                          commonContext);

            Servlet adaptedJspServlet = new ContextPathServletAdaptor(
                    new JspServlet(context.getBundle(), "/web"),
                    "/jsp-examples");
            httpService.registerServlet("/jsp-examples/*.jsp", adaptedJspServlet, null,
                                        commonContext);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
View Full Code Here

        }
        return httpService;
    }

    public void removedService(ServiceReference reference, Object service) {
        final HttpService httpService = (HttpService) service;
        httpService.unregister("/jsp-examples"); //$NON-NLS-1$
        httpService.unregister("/jsp-examples/*.jsp"); //$NON-NLS-1$
        super.removedService(reference, service);
    }
View Full Code Here

    public void start(BundleContext bundleContext) throws Exception {

        ServiceReference reference = bundleContext.getServiceReference(HttpService.class.getName());
        if (reference != null) {
            final HttpService httpService = (HttpService) bundleContext.getService(reference);
            try {
                HttpContext commonContext =
                        new DefaultComponentEntryHttpContext(bundleContext.getBundle(), INTERNAL_CONTEXT);

                //register our .jsp files at the httpService
                Servlet servlet = new ContextPathServletAdaptor(
                        new JspServlet(bundleContext.getBundle(), "/web"), CONTEXT);
                httpService.registerResources(CONTEXT, "/", commonContext);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else {
View Full Code Here

    public HttpServiceTracker(BundleContext context) {
      super(context, HttpService.class.getName(), null);
    }

    public Object addingService(ServiceReference reference) {
      final HttpService httpService = (HttpService) context.getService(reference);
      try {     
        HttpContext commonContext = new BundleEntryHttpContext(context.getBundle(), "/web");
        httpService.registerResources("/struts-examples", "/", commonContext); //$NON-NLS-1$ //$NON-NLS-2$
       
        Servlet adaptedJspServlet = new ContextPathServletAdaptor(new JspServlet(context.getBundle(), "/web"), "/struts-examples"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        httpService.registerServlet("/struts-examples/*.jsp", adaptedJspServlet, null, commonContext); //$NON-NLS-1$
       
        Dictionary initparams = new Hashtable();
        initparams.put("servlet-name", "action"); //Note: requires servlet-name support in Http Service Implementation
        initparams.put("config", "/WEB-INF/struts-config.xml");
        initparams.put("config/exercise", "/WEB-INF/exercise/struts-config.xml");
        initparams.put("config/upload", "/WEB-INF/upload/struts-config.xml");
        initparams.put("config/validator", "/WEB-INF/validator/struts-config.xml");
        initparams.put("config/dispatch", "/WEB-INF/dispatch/struts-config.xml");
        initparams.put("debug", "2");
        initparams.put("detail", "2");
        Servlet adaptedActionServlet = new ContextPathServletAdaptor(new ActionServlet(), "/struts-examples");
        httpService.registerServlet("/struts-examples/*.do", adaptedActionServlet, initparams, commonContext);
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return httpService;
View Full Code Here

      }
      return httpService;
    }
   
    public void removedService(ServiceReference reference, Object service) {
      final HttpService httpService = (HttpService) service;
      httpService.unregister("/struts-examples"); //$NON-NLS-1$
      httpService.unregister("/struts-examples/*.jsp"); //$NON-NLS-1$
      httpService.unregister("/struts-examples/*.do"); //$NON-NLS-1$     
      super.removedService(reference, service);
    }
View Full Code Here

            //Deploying Web service which resides in bundles
            Axis2ServiceRegistry serviceRegistry = new Axis2ServiceRegistry(serverConfigContext);
            serviceRegistry.register(bundleContext.getBundles());
            new OSGiAxis2ServiceDeployer(serverConfigContext, bundleContext).registerBundleListener(); // This will register the OSGi bundle listener

            HttpService httpService = dataHolder.getHttpService();
            HttpContext defaultHttpContext = httpService.createDefaultHttpContext();

            registerCarbonServlet(httpService, defaultHttpContext);

            RealmService realmService = dataHolder.getRealmService();
            UserRealm teannt0Realm = realmService.getBootstrapRealm();
View Full Code Here

        Hashtable<String, String[]> properties3 = new Hashtable<String, String[]>();
        properties3.put(URLConstants.URL_CONTENT_MIMETYPE, new String[]{"text/javascript"});
        context.registerService(ContentHandler.class.getName(), new TextJavascriptHandler(),
                                properties3);

        final HttpService httpService = getHttpService();

        Dictionary<String, String> initparams = new Hashtable<String, String>();
        initparams.put("servlet-name", "TilesServlet");
        initparams.put("definitions-config", "/WEB-INF/tiles/main_defs.xml");
        initparams.put("org.apache.tiles.context.TilesContextFactory",
                       "org.apache.tiles.context.enhanced.EnhancedContextFactory");
        initparams.put("org.apache.tiles.factory.TilesContainerFactory.MUTABLE", "true");
        initparams.put("org.apache.tiles.definition.DefinitionsFactory",
                       "org.wso2.carbon.tiles.CarbonUrlDefinitionsFactory");

        String webContext = "carbon"; // The subcontext for the Carbon Mgt Console

        String serverURL = CarbonUIUtil.getServerURL(serverConfig);
        String indexPageURL = CarbonUIUtil.getIndexPageURL(serverConfig);
        if (indexPageURL == null) {
            indexPageURL = "/carbon/admin/index.jsp";
        }
        RegistryService registryService = getRegistryService();
        Registry registry = registryService.getLocalRepository();

        UIBundleDeployer uiBundleDeployer = new UIBundleDeployer();
        UIResourceRegistry uiResourceRegistry = new UIResourceRegistry();
        uiResourceRegistry.initialize(bundleContext);
        uiResourceRegistry.setDefaultUIResourceProvider(
                uiBundleDeployer.getBundleBasedUIResourcePrvider());
//        BundleResourcePathRegistry resourcePathRegistry = uiBundleDeployer.getBundleResourcePathRegistry();

        HttpContext commonContext =
                new CarbonSecuredHttpContext(context.getBundle(), "/web", uiResourceRegistry, registry);

        //Registering filedownload servlet
        Servlet fileDownloadServlet = new ContextPathServletAdaptor(new FileDownloadServlet(
                context, getConfigurationContextService()), "/filedownload");
        httpService.registerServlet("/filedownload", fileDownloadServlet, null, commonContext);
        fileDownloadServlet.getServletConfig().getServletContext().setAttribute(
                CarbonConstants.SERVER_URL, serverURL);
        fileDownloadServlet.getServletConfig().getServletContext().setAttribute(
                CarbonConstants.INDEX_PAGE_URL, indexPageURL);

        //Registering fileupload servlet
        Servlet fileUploadServlet = new ContextPathServletAdaptor(new FileUploadServlet(
                context, configContext, webContext), "/fileupload");
        httpService.registerServlet("/fileupload", fileUploadServlet, null, commonContext);
        fileUploadServlet.getServletConfig().getServletContext().setAttribute(
                CarbonConstants.SERVER_URL, serverURL);
        fileUploadServlet.getServletConfig().getServletContext().setAttribute(
                CarbonConstants.INDEX_PAGE_URL, indexPageURL);

        uiBundleDeployer.deploy(bundleContext, commonContext);
        context.addBundleListener(uiBundleDeployer);

        httpService.registerServlet("/", new org.apache.tiles.web.startup.TilesServlet(),
                                    initparams,
                                    commonContext);
        httpService.registerResources("/" + webContext, "/", commonContext);

        adaptedJspServlet = new ContextPathServletAdaptor(
                new TilesJspServlet(context.getBundle(), uiResourceRegistry), "/" + webContext);
        httpService.registerServlet("/" + webContext + "/*.jsp", adaptedJspServlet, null,
                                    commonContext);

        ServletContext jspServletContext =
                adaptedJspServlet.getServletConfig().getServletContext();
        jspServletContext.setAttribute("registry", registryService);
View Full Code Here

        public HttpServiceTracker(BundleContext context) {
            super(context, HttpService.class.getName(), null);
        }

        public Object addingService(ServiceReference reference) {
            final HttpService httpService = (HttpService) context.getService(reference);
            try {
                HttpContext commonContext =
                        new BundleEntryHttpContext(context.getBundle(), "/web"); //$NON-NLS-1$
                httpService.registerResources("/jstl-examples", "/",
                                              commonContext); //$NON-NLS-1$ //$NON-NLS-2$

                Servlet adaptedJspServlet = new ContextPathServletAdaptor(
                        new JspServlet(context.getBundle(), "/web"),
                        "/jstl-examples")//$NON-NLS-1$//$NON-NLS-2$
                httpService.registerServlet("/jstl-examples/*.jsp", adaptedJspServlet, null,
                                            commonContext); //$NON-NLS-1$
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
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.