Package org.springframework.osgi.extender.internal.util.concurrent

Examples of org.springframework.osgi.extender.internal.util.concurrent.Counter


  protected void waitOnContextCreation(BundleContext context, String forBundleWithSymbolicName, long timeout) {
    // translate from seconds to milliseconds
    long time = timeout * SECOND;

    // use the counter to make sure the threads block
    final Counter counter = new Counter("waitForContext on bnd=" + forBundleWithSymbolicName);

    counter.increment();

    String filter = "(org.springframework.context.service.name=" + forBundleWithSymbolicName + ")";

    ServiceListener listener = new ServiceListener() {

      public void serviceChanged(ServiceEvent event) {
        if (event.getType() == ServiceEvent.REGISTERED)
          counter.decrement();
      }
    };

    OsgiListenerUtils.addServiceListener(context, listener, filter);

    if (logger.isDebugEnabled())
      logger.debug("Start waiting for Spring/OSGi bundle=" + forBundleWithSymbolicName);

    try {
      if (counter.waitForZero(time)) {
        waitingFailed(forBundleWithSymbolicName);
      }
      else if (logger.isDebugEnabled()) {
        logger.debug("Found applicationContext for bundle=" + forBundleWithSymbolicName);
      }
View Full Code Here


  protected void waitOnContextCreation(BundleContext context, String forBundleWithSymbolicName, long timeout) {
    // translate from seconds to milliseconds
    long time = timeout * SECOND;

    // use the counter to make sure the threads block
    final Counter counter = new Counter("waitForContext on bnd=" + forBundleWithSymbolicName);

    counter.increment();

    String filter = "(org.springframework.context.service.name=" + forBundleWithSymbolicName + ")";

    ServiceListener listener = new ServiceListener() {

      public void serviceChanged(ServiceEvent event) {
        if (event.getType() == ServiceEvent.REGISTERED)
          counter.decrement();
      }
    };

    OsgiListenerUtils.addServiceListener(context, listener, filter);

    if (logger.isDebugEnabled())
      logger.debug("Start waiting for Spring/OSGi bundle=" + forBundleWithSymbolicName);

    try {
      if (counter.waitForZero(time)) {
        waitingFailed(forBundleWithSymbolicName);
      }
      else if (logger.isDebugEnabled()) {
        logger.debug("Found applicationContext for bundle=" + forBundleWithSymbolicName);
      }
View Full Code Here

TOP

Related Classes of org.springframework.osgi.extender.internal.util.concurrent.Counter

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.