java.net.ContentHandler#org.osgi.service.http.HttpService源码实例Demo

下面列出了java.net.ContentHandler#org.osgi.service.http.HttpService 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: neoscada   文件: Activator.java
@Override
public void serviceChange ( final ServiceReference<HttpService> reference, final HttpService service )
{
    if ( Activator.this.httpService != null )
    {
        Activator.this.httpService.unregister ( SERVLET_PATH );
        Activator.this.httpService.unregister ( "/media" );
        Activator.this.httpService = null;
    }
    Activator.this.httpService = service;
    try
    {
        Activator.this.httpService.registerServlet ( SERVLET_PATH, Activator.this.jsonServlet, null, null );
        Activator.this.httpService.registerResources ( SERVLET_PATH + "/ui", "/ui", null );
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to handle http service change", e );
    }
}
 
源代码2 项目: neoscada   文件: Activator.java
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.context = context;

    // start servlet
    this.httpServiceTracker = new SingleServiceTracker<HttpService> ( context, HttpService.class, this.httpServiceListener );
    this.httpServiceTracker.open ();

    this.exporterServiceTracker = new SingleServiceTracker<HttpExporter> ( context, HttpExporter.class, this.exporterServiceListener );
    this.exporterServiceTracker.open ();

    this.localHdServerServiceTracker = new SingleServiceTracker<Service> ( context, Service.class, this.localHdServerServiceListener );
    this.localHdServerServiceTracker.open ();

    // try to start local exporter
    registerRemoteExporter ( context );
}
 
源代码3 项目: knopflerfish.org   文件: Activator.java
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.");
  return http;
}
 
源代码4 项目: knopflerfish.org   文件: RMICodeBaseService.java
/**
 * Creates a new RMICodeBaseService object.
 *
 * @param mountpoint DOCUMENT ME!
 *
 * @throws Exception DOCUMENT ME!
 */
private RMICodeBaseService(String mountpoint) throws Exception {
    this.mountpoint = mountpoint;

    ServiceReference ref = Activator.bc.getServiceReference(
            "org.osgi.service.http.HttpService");
    httpService = (HttpService) Activator.bc.getService(ref);

    if (setCodeBase(prepareCodeBase(ref, httpService, mountpoint))) {
        bundleHttpContext = new BundleHttpContext();

        try {
            httpService.registerResources(mountpoint, "", bundleHttpContext);
        } catch (Exception ex) {
            Debug.printDebugInfo(10,
                "Could not register mointpount " + mountpoint);
            throw new Exception("Mountpoint already in use");
        }
    } else {
        Debug.printDebugInfo(10,
            "Could not set " + RMI_SERVER_CODEBASE + " property");
        throw new Exception("Unable to set " + RMI_SERVER_CODEBASE +
            " property");
    }
}
 
源代码5 项目: JaxRSProviders   文件: JaxRSServerContainer.java
protected void removeRegistration(RSARemoteServiceRegistration registration) {
	final HttpService httpService = getHttpService();
	if (httpService != null) {
		final String servletAlias = getServletAlias(registration);
		if (servletAlias != null) {
			synchronized (this.registrations) {
				this.registrations.remove(servletAlias);
				SafeRunner.run(new ISafeRunnable() {
					@Override
					public void run() throws Exception {
						httpService.unregister(servletAlias);
					}
				});
			}
		}
	}
}
 
源代码6 项目: carbon-identity   文件: OAuthUIServiceComponent.java
@SuppressWarnings("unchecked")
protected void activate(ComponentContext context) {
    log.debug("Activating Identity OAuth UI bundle.");

    HttpService httpService = OAuthUIServiceComponentHolder.getInstance().getHttpService();

    try {

        // Register OAuth 1.a servlet
        Servlet oauth1aServlet = new ContextPathServletAdaptor(new OAuthServlet(), OAUTH_URL);
        httpService.registerServlet(OAUTH_URL, oauth1aServlet, null, null);
        log.debug("Successfully registered an instance of OAuthServlet");

    } catch (Exception e) {
        String errMsg = "Error when registering an OAuth endpoint via the HttpService.";
        log.error(errMsg, e);
        throw new RuntimeException(errMsg, e);
    }

    log.debug("Successfully activated Identity OAuth UI bundle.");

}
 
源代码7 项目: micro-integrator   文件: CarbonCoreDataHolder.java
public  HttpService getHttpService() throws Exception {
    if (httpService == null) {
        String msg = "Before activating Carbon Core bundle, an instance of "
                + HttpService.class.getName() + " should be in existance";
        log.error(msg);
        throw new Exception(msg);
    }
    return httpService;
}
 
源代码8 项目: cxf   文件: HTTPTransportActivator.java
public void start(final BundleContext context) throws Exception {

        ConfigAdminHttpConduitConfigurer conduitConfigurer = new ConfigAdminHttpConduitConfigurer();

        registerService(context, ManagedServiceFactory.class, conduitConfigurer,
                        ConfigAdminHttpConduitConfigurer.FACTORY_PID);
        registerService(context, HTTPConduitConfigurer.class, conduitConfigurer,
                        "org.apache.cxf.http.conduit-configurer");

        if (PropertyUtils.isTrue(context.getProperty(DISABLE_DEFAULT_HTTP_TRANSPORT))) {
            //TODO: Review if it also makes sense to support "http.transport.disable"
            //      directly in the CXF_CONFIG_SCOPE properties file
            return;
        }

        DestinationRegistry destinationRegistry = new DestinationRegistryImpl();
        HTTPTransportFactory transportFactory = new HTTPTransportFactory(destinationRegistry);

        HttpServiceTrackerCust customizer = new HttpServiceTrackerCust(destinationRegistry, context);
        httpServiceTracker = new ServiceTracker<>(context, HttpService.class, customizer);
        httpServiceTracker.open();

        context.registerService(DestinationRegistry.class.getName(), destinationRegistry, null);
        context.registerService(HTTPTransportFactory.class.getName(), transportFactory, null);

        BlueprintNameSpaceHandlerFactory factory = new BlueprintNameSpaceHandlerFactory() {

            @Override
            public Object createNamespaceHandler() {
                return new HttpBPHandler();
            }
        };
        NamespaceHandlerRegisterer.register(context, factory,
                                            "http://cxf.apache.org/transports/http/configuration");
    }
 
源代码9 项目: attic-stratos   文件: CarbonUIServiceComponent.java
public static HttpService getHttpService() {
    if (httpServiceInstance == null) {
        String msg = "Before activating Carbon UI bundle, an instance of "
                     + HttpService.class.getName() + " should be in existence";
        log.error(msg);
        throw new RuntimeException(msg);
    }
    return httpServiceInstance;
}
 
源代码10 项目: neoscada   文件: Activator.java
@Override
public void start ( final BundleContext context ) throws Exception
{
    this.context = context;
    addService ( context.getServiceReference ( HttpService.class ) );
    context.addServiceListener ( this, String.format ( "(%s=%s)", Constants.OBJECTCLASS, HttpService.class.getName () ) );
}
 
源代码11 项目: neoscada   文件: Activator.java
private void addService ( final ServiceReference<?> serviceReference )
{
    if ( serviceReference == null )
    {
        return;
    }
    this.service = (HttpService)this.context.getService ( serviceReference );
    this.serviceReference = serviceReference;
    if ( this.service != null )
    {
        configureService ();
    }
}
 
源代码12 项目: neoscada   文件: Activator.java
@Override
public void start ( final BundleContext context ) throws Exception
{
    this.context = context;

    this.injector = new EventInjectorQueue ( context );

    this.httpServiceTracker = new ServiceTracker<HttpService, HttpService> ( context, HttpService.class, createHttpServiceTrackerCustomizer () );
    this.httpServiceTracker.open ();
}
 
源代码13 项目: orion.server   文件: FormAuthenticationService.java
public void unsetHttpService(HttpService httpService) {
	if (httpService != null) {
		httpService.unregister("/mixlogin/manageoauth"); //$NON-NLS-1$
		httpService.unregister("/login"); //$NON-NLS-1$
		httpService.unregister("/logout"); //$NON-NLS-1$
		httpService = null;
	}
}
 
源代码14 项目: orion.server   文件: ServerTestsActivator.java
public void start(BundleContext context) throws Exception {
	bundleContext = context;
	httpServiceTracker = new ServiceTracker<HttpService, HttpService>(context, HttpService.class, null);
	httpServiceTracker.open();

	packageAdminTracker = new ServiceTracker<PackageAdmin, PackageAdmin>(context, PackageAdmin.class.getName(), null);
	packageAdminTracker.open();
}
 
protected void unsetHttpService(HttpService httpService) {

        if (log.isDebugEnabled()) {
            log.debug("HTTP Service is unset in the Application Authentication Framework bundle");
        }

        this.httpService = null;
    }
 
@Reference(
         name = "http.service", 
         service = org.osgi.service.http.HttpService.class, 
         cardinality = ReferenceCardinality.MANDATORY, 
         policy = ReferencePolicy.DYNAMIC, 
         unbind = "unsetHttpService")
protected void setHttpService(HttpService httpService) {
    setHttpServiceInstance(httpService);
}
 
源代码17 项目: openhab-core   文件: IconForwarder.java
@Reference
protected void setHttpService(HttpService httpService) {
    try {
        httpService.registerServlet(IMAGES_ALIAS, this, null, httpService.createDefaultHttpContext());
    } catch (Exception e) {
        logger.error("Could not register icon forwarder servlet: {}", e.getMessage());
    }
}
 
源代码18 项目: knopflerfish.org   文件: Activator.java
protected void unregister(HttpService http) {
  log.info("Unregistering from removed HttpService");

  http.unregister(ALIAS_ROOT);
  http.unregister(ALIAS_SERVLET);
  http.unregister(ALIAS_DOCS);

  log.info("Unregistration done.");
}
 
源代码19 项目: knopflerfish.org   文件: HttpTestSuite.java
public void runTest() throws Throwable {
  out.println("HttpTestSuite:SETUP starting");
  httpSR = bc.getServiceReference(HttpServiceClass);
  assertNotNull("Setup: no http service ref available", httpSR);
  httpService = (HttpService) bc.getService(httpSR);
  assertNotNull("Setup: no http service object available", httpService);

  Object hostObj = httpSR.getProperty("host");
  if(hostObj != null) {
    String s = hostObj.toString();
    if(s.length() > 0) {
      hostname = s;
    }
  }

  // Now let's get on with the port...
  obj = httpSR.getProperty("port.http");
  if(obj == null) {
    obj = httpSR.getProperty("openPort");
  }
  if (obj != null) {
    port = obj.toString();
  } else {
    out.println("Ooops - failed to find the port property!!!");

    // Dump the properties as known by the http service
    String[] keys = httpSR.getPropertyKeys();
    System.out.println("--- Propetry keys ---");
    for (int i=0; i<keys.length; i++) {
      out.println(i +": " +keys[i] +" --> " +httpSR.getProperty(keys[i]));
    }
  }
  out.println("HttpTestSuite:SETUP using service with URL=" +getUrl("/"));
}
 
源代码20 项目: packagedrone   文件: JspBundle.java
public JspBundle ( final Bundle bundle, final HttpService service, final HttpContext context ) throws ServletException, NamespaceException
{
    this.service = service;

    this.alias = String.format ( "/bundle/%s/WEB-INF", bundle.getBundleId () );
    this.servlet = new JspServlet ( bundle, "/WEB-INF", this.alias );

    logger.info ( "Registering JSP servlet - resources: /WEB-INF, alias: {}, bundle: {}", this.alias, bundle.getSymbolicName () );

    final Dictionary<String, String> initparams = new Hashtable<> ( 2 );
    initparams.put ( "compilerSourceVM", "1.8" );
    initparams.put ( "compilerTargetVM", "1.8" );

    this.service.registerServlet ( this.alias, this.servlet, initparams, context );
}
 
源代码21 项目: packagedrone   文件: HttpTrigger.java
public HttpTrigger ( final SitePrefixService prefixService, final HttpService httpService, final HttpTriggerConfiguration configuration, final ChannelService channelService )
{
    this.prefixService = prefixService;
    this.httpService = httpService;
    this.configuration = configuration;
    this.channelService = channelService;
}
 
源代码22 项目: cxf   文件: HttpServiceTrackerCust.java
@Override
public HttpService addingService(ServiceReference<HttpService> reference) {
    HttpService httpService = context.getService(reference);
    Servlet servlet = new CXFNonSpringServlet(destinationRegistry, false);
    servletExporter = new ServletExporter(servlet, httpService);
    servletPublisherReg = context.registerService(ManagedService.class,
                                                  servletExporter,
                                                  CollectionUtils.singletonDictionary(Constants.SERVICE_PID,
                                                                                      CXF_CONFIG_PID));
    return httpService;
}
 
源代码23 项目: JaxRSProviders   文件: JaxRSServerContainer.java
@Override
protected Map<String, Object> exportRemoteService(RSARemoteServiceRegistration reg) {
	// Create Servlet
	Servlet servlet = createServlet(reg);
	if (servlet == null)
		throw new NullPointerException(
				"Servlet is null.  It cannot be null to export Jax RS servlet.   See subclass implementation of JaxRSServerContainer.createServlet()");
	// Create servletProps
	@SuppressWarnings("rawtypes")
	Dictionary servletProperties = createServletProperties(reg);
	// Create HttpContext
	HttpContext servletContext = createServletContext(reg);
	// Get servlet alias
	String servletAlias = getServletAlias(reg);
	// Get HttpService instance
	HttpService httpService = getHttpService();
	if (httpService == null)
		throw new NullPointerException("HttpService cannot cannot be null");
	synchronized (this.registrations) {
		try {
			httpService.registerServlet(servletAlias, servlet, servletProperties, servletContext);
		} catch (ServletException | NamespaceException e) {
			throw new RuntimeException("Cannot register servlet with alias=" + servletAlias, e);
		}
		this.registrations.put(servletAlias, reg);
	}
	return createExtraExportProperties(servletAlias, reg);
}
 
源代码24 项目: osgi.iot.contest.sdk   文件: PictureResources.java
@Reference
void setHttpService(HttpService http){
	try {
		http.registerResources("/osgi.enroute.trains/pictures", "pictures", null);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
protected void setHttpService(HttpService httpService) {
    if (log.isDebugEnabled()) {
        log.debug("HTTP Service is set in the Application Authentication Framework bundle");
    }

    this.httpService = httpService;
}
 
protected void unsetHttpService(HttpService httpService) {
    if (log.isDebugEnabled()) {
        log.debug("HTTP Service is unset in the Application Authentication Framework bundle");
    }

    this.httpService = null;
}
 
源代码27 项目: cxf   文件: HttpServiceTrackerCust.java
@Override
public void removedService(ServiceReference<HttpService> reference, HttpService service) {
    servletPublisherReg.unregister();
    try {
        servletExporter.updated(null);
    } catch (ConfigurationException e) {
        // Ignore
    }
}
 
源代码28 项目: smarthome   文件: Activator.java
@SuppressWarnings("unchecked")
@Override
public void start(BundleContext context) throws Exception {
    this.context = context;
    httpTracker = new ServiceTracker(context, HttpService.class.getName(), this);
    httpTracker.open();
}
 
源代码29 项目: smarthome   文件: Activator.java
@Override
public Object addingService(ServiceReference reference) {
    @SuppressWarnings("unchecked")
    HttpService httpService = (HttpService) context.getService(reference);
    if (httpService != null) {
        try {
            httpService.registerResources(ALIAS, "/res", this);
        } catch (NamespaceException e) {
            logger.warn("Failed registering resource {}", ALIAS, e);
        }
    }
    return httpService;
}
 
源代码30 项目: fuchsia   文件: JAXWSExporterWithHttpServiceTest.java
@Override
protected void prepareMockInterceptors() {
    super.prepareMockInterceptors();

    //Add httpservice mock
    field("http").ofType(HttpService.class).in(exporter).set(httpServiceMock);
}