Java 类org.osgi.framework.ServiceObjects 实例源码

项目:aries-jax-rs-whiteboard    文件:Utils.java   
public static <T> ResourceProvider getResourceProvider(
    ServiceObjects<T> serviceObjects) {

    CachingServiceReference<T> serviceReference =
        new CachingServiceReference<>(
            serviceObjects.getServiceReference());

    return new ServiceReferenceResourceProvider(
        serviceReference, serviceObjects);
}
项目:aries-jax-rs-whiteboard    文件:Utils.java   
public static <T> OSGi<ServiceTuple<T>> onlyGettables(
    OSGi<CachingServiceReference<T>> program,
    Consumer<CachingServiceReference<T>> whenAddedNotGettable,
    Consumer<CachingServiceReference<T>> whenLeavingNotGettable) {

    return bundleContext().flatMap(bundleContext ->
        program.recoverWith(
            (serviceReference, e) ->
                notGettableResult(
                    whenAddedNotGettable, whenLeavingNotGettable,
                    serviceReference)
        ).flatMap(serviceReference -> {
            ServiceObjects<T> serviceObjects =
                bundleContext.getServiceObjects(
                    serviceReference.getServiceReference());
            T service = serviceObjects.getService();

            if (service == null) {
                return notGettableResult(
                    whenAddedNotGettable, whenLeavingNotGettable,
                    serviceReference);
            }

            return
                onClose(
                    () -> serviceObjects.ungetService(service)
                ).then(
                    just(new ServiceTuple<>(
                        serviceReference, serviceObjects, service))
                );
        }));
}
项目:aries-jax-rs-whiteboard    文件:Utils.java   
public static <T> OSGi<ServiceObjects<T>> serviceObjects(
    CachingServiceReference<T> immutableServiceReference) {

    return
        bundleContext().flatMap(bundleContext ->
        just(bundleContext.getServiceObjects(
            immutableServiceReference.getServiceReference()))
    );
}
项目:aries-jax-rs-whiteboard    文件:Utils.java   
ServiceReferenceResourceProvider(
    CachingServiceReference<?> serviceReference,
    ServiceObjects<?> serviceObjects) {
    _serviceReference = serviceReference;

    _serviceObjects = serviceObjects;
}
项目:aries-jax-rs-whiteboard    文件:Utils.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Class<?> getResourceClass() {
    Object service = _serviceObjects.getService();

    try {
        return service.getClass();
    }
    finally {
        ((ServiceObjects)_serviceObjects).ungetService(service);
    }
}
项目:aries-jax-rs-whiteboard    文件:Utils.java   
ServiceTuple(
    CachingServiceReference<T> a, ServiceObjects<T> serviceObjects,
    T service) {

    _serviceReference = a;

    _serviceObjects = serviceObjects;
    _service = service;
}
项目:aries-jax-rs-whiteboard    文件:Utils.java   
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void releaseInstance(Message m, Object o) {
    ((ServiceObjects)_serviceObjects).ungetService(o);
}
项目:aries-jax-rs-whiteboard    文件:Utils.java   
public ServiceObjects<T> getServiceObjects() {
    return _serviceObjects;
}
项目:musicTreePrograms    文件:MyBundleContext.java   
@Override
public <S> ServiceObjects<S> getServiceObjects(ServiceReference<S> reference) {
  return null;
}
项目:musicTreePrograms    文件:MyBundleContext.java   
@Override
public <S> ServiceObjects<S> getServiceObjects(ServiceReference<S> reference) {
  return null;
}