Examples of DependencyService


Examples of org.apache.felix.dm.DependencyService

            m_resourceProperties.add(resourceProperties);
          counter = m_resources.size();
          services = m_services.toArray();
        }
            for (int i = 0; i < services.length; i++) {
                DependencyService ds = (DependencyService) services[i];
                if (counter == 1) {
                    ds.dependencyAvailable(this);
                    if (!isRequired()) {
                        invokeAdded(ds, resource, resourceProperties);
                    }
                }
                else {
                    ds.dependencyChanged(this);
                    invokeAdded(ds, resource, resourceProperties);
                }
            }
      }
  }
View Full Code Here

Examples of org.apache.felix.dm.DependencyService

              // change the resource properties for the resource
              m_resourceProperties.set(m_resources.indexOf(resource), resourceProperties);
                services = m_services.toArray();
            }
            for (int i = 0; i < services.length; i++) {
                DependencyService ds = (DependencyService) services[i];
                invokeChanged(ds, resource, resourceProperties);
            }
        }
  }
View Full Code Here

Examples of org.apache.felix.dm.DependencyService

            m_resources.remove(resource);
          counter = m_resources.size();
          services = m_services.toArray();
        }
            for (int i = 0; i < services.length; i++) {
                DependencyService ds = (DependencyService) services[i];
                if (counter == 0) {
                    ds.dependencyUnavailable(this);
                    if (!isRequired()) {
                        invokeRemoved(ds, resource, resourceProperties);
                    }
                }
                else {
                    ds.dependencyChanged(this);
                    invokeRemoved(ds, resource, resourceProperties);
                }
            }
        }
  }
View Full Code Here

Examples of org.apache.felix.dm.DependencyService

        if (makeAvailable) {
            m_serviceInstance = Proxy.newProxyInstance(m_trackedServiceName.getClassLoader(), new Class[] { m_trackedServiceName }, this);
        }
        Object[] services = m_services.toArray();
        for (int i = 0; i < services.length; i++) {
            DependencyService ds = (DependencyService) services[i];
            if (makeAvailable) {
                ds.dependencyAvailable(this);
            }
        }
        if (!makeAvailable) {
            notifyAll();
        }
View Full Code Here

Examples of org.apache.felix.dm.DependencyService

          return;
      }

      Object[] services = m_services.toArray();
        for (int i = 0; i < services.length; i++) {
            DependencyService ds = (DependencyService) services[i];
            // if non-null settings come in, we have to instantiate the service and
            // apply these settings
            ds.initService();
            Object service = ds.getService();

            if (service != null) {
                invokeUpdate(ds, service, settings);
            }
            else {
                m_logger.log(Logger.LOG_ERROR, "Service " + ds + " with configuration dependency " + this + " could not be instantiated.");
                return;
            }
        }

    synchronized (this) {
      m_settings = settings;
    }
   
        for (int i = 0; i < services.length; i++) {
            DependencyService ds = (DependencyService) services[i];
            // If these settings did not cause a configuration exception, we determine if they have
            // caused the dependency state to change
            if ((oldSettings == null) && (settings != null)) {
                ds.dependencyAvailable(this);
            }
            if ((oldSettings != null) && (settings == null)) {
                ds.dependencyUnavailable(this);
            }
            if ((oldSettings != null) && (settings != null)) {
                ds.dependencyChanged(this);
            }
        }
  }
View Full Code Here

Examples of org.apache.felix.dm.DependencyService

 
  public void addedBundle(Bundle bundle, BundleEvent event, Object object) {
      boolean makeAvailable = makeAvailable();
      Object[] services = m_services.toArray();
      for (int i = 0; i < services.length; i++) {
          DependencyService ds = (DependencyService) services[i];
          if (makeAvailable) {
              ds.dependencyAvailable(this);
              if (!isRequired()) {
                  invokeAdded(ds, bundle);
              }
          }
          else {
              ds.dependencyChanged(this);
              invokeAdded(ds, bundle);
          }
      }
  }
View Full Code Here

Examples of org.apache.felix.dm.DependencyService

  }

  public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
    Object[] services = m_services.toArray();
        for (int i = 0; i < services.length; i++) {
            DependencyService ds = (DependencyService) services[i];
            ds.dependencyChanged(this);
            if (ds.isInstantiated()) {
                invokeChanged(ds, bundle);
            }
        }
  }
View Full Code Here

Examples of org.apache.felix.dm.DependencyService

        Object[] services;
        synchronized (this) {
            services = m_services.toArray();
        }
        for (int i = 0; i < services.length; i++) {
            DependencyService ds = (DependencyService) services[i];
            if (makeAvailable) {
                if (ds.isInstantiated() && isInstanceBound() && isRequired()) {
                    if (m_debug) {
                        m_logger.log(Logger.LOG_DEBUG, "[" + m_debugKey + "] invoke added: " + ref);      
                    }
                    invokeAdded(ds, ref, service);
                }
                // The dependency callback will be deferred until all required dependency are available.
                if (m_debug) {
                    m_logger.log(Logger.LOG_DEBUG, "[" + m_debugKey + "] dependency available: " + ref);
                }
                ds.dependencyAvailable(this); //**
                if (!isRequired()) {
                    // For optional dependency, we always invoke callback, because at this point, we know
                    // that the service has been started, and the service start method has been called.
                    // (See the ServiceImpl.bindService method, which will activate optional dependencies using
                    // startTrackingOptional() method).
                    if (m_debug) {
                        m_logger.log(Logger.LOG_DEBUG, "[" + m_debugKey + "] invoke added: " + ref);
                    }
                    invokeAdded(ds, ref, service);
                }
            } else {
                if (m_debug) {
                    m_logger.log(Logger.LOG_DEBUG, "[" + m_debugKey + "] dependency added (was available): " + ref);
                }
                // First, inject the added service in autoconfig field, if any.
                ds.autoConfig(this);
               
                // At this point, either the dependency is optional (meaning that the service has been started,
                // because if not, then our dependency would not be active); or the dependency is required,
                // meaning that either the service is not yet started, or already started.
                // In all cases, we have to inject the required dependency.
                // we only try to invoke the method here if we are really already instantiated
                if (ds.isInstantiated() && ds.getCompositionInstances().length > 0) {
                    if (m_debug) {
                        m_logger.log(Logger.LOG_DEBUG, "[" + m_debugKey + "] invoke added: " + ref);
                    }
                    if (invokeAdded(ds, ref, service)) {
                  // Propagate (if needed) all "setPropagate" dependencies to the dependency service.
                  ds.propagate(this);
                    }
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.felix.dm.DependencyService

        Object[] services;
        synchronized (this) {
            services = m_services.toArray();
        }
        for (int i = 0; i < services.length; i++) {
            DependencyService ds = (DependencyService) services[i];
            ds.autoConfig(this);
            if (ds.isInstantiated()) {
                if (invokeChanged(ds, ref, service)) {
                    // The "change" or "swap" callback has been invoked (if not it means that the modified service
                    // is for a lower ranked aspect to which we are not interested in).
                    // Now, propagate (if needed) changed properties to dependency service properties.
                    ds.propagate(this);
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.felix.dm.DependencyService

        synchronized (this) {
            services = m_services.toArray();
        }

        for (int i = 0; i < services.length; i++) {
            DependencyService ds = (DependencyService) services[i];
            if (makeUnavailable) {
                ds.dependencyUnavailable(this);
                // when the dependency is optional or the dependency is instance bound and the component is instantiated (and the dependency is required)
                // then remove is invoked. In other cases the removed has been when the component was unconfigured.
                if (!isRequired() || (ds.isInstantiated() && isInstanceBound())) {
                    invokeRemoved(ds, ref, service);
                }
            } else {
                // Some dependencies are still available: first inject the remaining highest ranked dependency
                // in component class field, if the dependency is configured in autoconfig mode.
                ds.autoConfig(this);
                // Next, invoke "removed" callback. If the dependency is aspect aware, we only invoke removed cb
                // if the removed service is the highest ranked service. Note that if the cb is not called, we don't
                // propagate the remaining dependency properties.
                if (invokeRemoved(ds, ref, service)) {
                    // Finally, since we have lost one dependency, we have to possibly propagate the highest ranked
                    // dependency available.
                    ds.propagate(this);
                }
            }
        }
        // unget what we got in addingService (see ServiceTracker 701.4.1)
        m_context.ungetService(ref);
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.