Package org.example.utils.vaadinbridge.internal

Source Code of org.example.utils.vaadinbridge.internal.HttpServiceTracker

package org.example.utils.vaadinbridge.internal;

import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpService;
import org.osgi.service.http.NamespaceException;
import org.osgi.util.tracker.ServiceTracker;


class HttpServiceTracker extends ServiceTracker {
 
  HttpServiceTracker(BundleContext context) {
    super(context, HttpService.class.getName(), null);
  }
 
  @Override
  public Object addingService(ServiceReference reference) {
    HttpService httpService = (HttpService) context.getService(reference);
    try {
      httpService.registerResources("/VAADIN", "/VAADIN", new TargetBundleHttpContext(context, "com.vaadin"));
    } catch (NamespaceException e) {
      e.printStackTrace();
    }
    ApplicationFactoryTracker bridge = new ApplicationFactoryTracker(httpService, context);
    bridge.open();
    return bridge;
  }
  @Override
  public void removedService(ServiceReference reference, Object service) {
    ApplicationFactoryTracker bridge = (ApplicationFactoryTracker) service;
    bridge.close();
    context.ungetService(reference);
  }
}
TOP

Related Classes of org.example.utils.vaadinbridge.internal.HttpServiceTracker

TOP
Copyright © 2018 www.massapi.com. 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.