Package org.eclipse.sisu.peaberry

Examples of org.eclipse.sisu.peaberry.ServiceRegistry


    @SuppressWarnings("unchecked")
    final Iterable<Import<T>>[] lazyIterables = new Iterable[registries.length];

    // support lazy lookup from multiple registries
    for (int i = 0; i < registries.length; i++) {
      final ServiceRegistry reg = registries[i];
      lazyIterables[i] = new Iterable<Import<T>>() { // NOPMD
            private volatile Iterable<Import<T>> iterable;

            // delay lookup until absolutely necessary
            public Iterator<Import<T>> iterator() {
              if (null == iterable) {
                synchronized (this) {
                  if (null == iterable) {
                    iterable = reg.lookup(clazz, filter);
                  }
                }
              }
              return iterable.iterator();
            }
View Full Code Here


    }
    return attributeFilter;
  }

  Iterable<Import<T>> getImports(final Injector injector, final boolean isConcurrent) {
    final ServiceRegistry serviceRegistry = registry.get(injector);
    final AttributeFilter attributeFilter = getFilter(injector);

    final Iterable<Import<T>> imports = serviceRegistry.lookup(clazz, attributeFilter);

    // enable outjection, but only if it's going to a different watcher
    ServiceWatcher<? super T> serviceWatcher = watcher.get(injector);
    if (null != serviceWatcher && serviceRegistry != serviceWatcher) { // NOPMD

      final ImportDecorator<? super T> watcherDecorator = decorator.get(injector);
      if (null != watcherDecorator) {
        // decorate the watcher if necessary, to support decorated watching
        serviceWatcher = new DecoratedServiceWatcher<T>(watcherDecorator, serviceWatcher);
      }

      if (isConcurrent) {
        // now apply concurrent behaviour when watching single services
        serviceWatcher = new ConcurrentServiceWatcher<T>(imports, serviceWatcher);
      }

      serviceRegistry.watch(clazz, attributeFilter, serviceWatcher);
    }

    return imports;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.sisu.peaberry.ServiceRegistry

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.