Examples of OsgiServiceCollection


Examples of org.springframework.osgi.service.importer.support.internal.collection.OsgiServiceCollection

   */
  Object createProxy() {
    if (log.isDebugEnabled())
      log.debug("Creating a multi-value/collection proxy");

    OsgiServiceCollection collection;
    Collection delegate;

    BundleContext bundleContext = getBundleContext();
    ClassLoader classLoader = getAopClassLoader();
    Filter filter = getUnifiedFilter();

    if (CollectionType.LIST.equals(collectionType)) {
      collection = (comparator == null ? new OsgiServiceList(filter, bundleContext, classLoader, proxyCreator)
          : new OsgiServiceSortedList(filter, bundleContext, classLoader, comparator, proxyCreator));
      delegate = Collections.unmodifiableList((List) collection);
    }
    else if (CollectionType.SET.equals(collectionType)) {
      collection = (comparator == null ? new OsgiServiceSet(filter, bundleContext, classLoader, proxyCreator)
          : new OsgiServiceSortedSet(filter, bundleContext, classLoader, comparator, proxyCreator));

      delegate = Collections.unmodifiableSet((Set) collection);
    }
    else if (CollectionType.SORTED_LIST.equals(collectionType)) {
      collection = new OsgiServiceSortedList(filter, bundleContext, classLoader, comparator, proxyCreator);

      delegate = Collections.unmodifiableList((List) collection);
    }

    else if (CollectionType.SORTED_SET.equals(collectionType)) {
      collection = new OsgiServiceSortedSet(filter, bundleContext, classLoader, comparator, proxyCreator);
      delegate = Collections.unmodifiableSortedSet((SortedSet) collection);
    }

    else {
      throw new IllegalArgumentException("Unknown collection type:" + collectionType);
    }

    collection.setRequiredAtStartup(getCardinality().isMandatory());
    collection.setListeners(getListeners());
    collection.setStateListeners(stateListeners);
    collection.setServiceImporter(this);
    collection.setServiceImporterName(getBeanName());
    collection.afterPropertiesSet();

    proxy = delegate;
    exposedProxy = collection;
    proxyDestructionCallback = new DisposableBeanRunnableAdapter(collection);

View Full Code Here

Examples of org.springframework.osgi.service.importer.support.internal.collection.OsgiServiceCollection

  }

  protected Collection createCollection() {
    BundleDelegatingClassLoader classLoader = BundleDelegatingClassLoader.createBundleClassLoaderFor(bundleContext.getBundle());

    OsgiServiceCollection collection = new OsgiServiceCollection(null, bundleContext, classLoader, null);
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    try {
      Thread.currentThread().setContextClassLoader(classLoader);
      collection.setRequiredAtStartup(false);
      // collection.setInterfaces(new Class[] { Date.class });
      collection.afterPropertiesSet();
    }
    finally {
      Thread.currentThread().setContextClassLoader(tccl);
    }
View Full Code Here

Examples of org.springframework.osgi.service.importer.support.internal.collection.OsgiServiceCollection

    super.setUp();
    iter = col.iterator();
  }

  OsgiServiceCollection createCollection() {
    return new OsgiServiceCollection(null, context, getClass().getClassLoader(), createProxyCreator(new Class[] {
      Wrapper.class, Comparable.class }));
  }
View Full Code Here
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.