org.apache.aries.blueprint.container
Class AbstractServiceReferenceRecipe

java.lang.Object
  extended by org.apache.aries.blueprint.di.AbstractRecipe
      extended by org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe
All Implemented Interfaces:
EventListener, SatisfiableRecipe, Recipe, org.osgi.framework.ServiceListener
Direct Known Subclasses:
ReferenceListRecipe, ReferenceRecipe

public abstract class AbstractServiceReferenceRecipe
extends AbstractRecipe
implements org.osgi.framework.ServiceListener, SatisfiableRecipe

Abstract class for service reference recipes. TODO: if we have a single interface (which is the standard behavior), then we should be able to get rid of the proxyClassloader and just use this interface classloader to define the proxy TODO: it is allowed to have no interface defined at all, which should result in an empty proxy

Version:
$Rev: 1182345 $, $Date: 2011-10-12 14:03:02 +0100 (Wed, 12 Oct 2011) $

Nested Class Summary
static class AbstractServiceReferenceRecipe.Listener
           
 
Nested classes/interfaces inherited from interface org.apache.aries.blueprint.container.SatisfiableRecipe
SatisfiableRecipe.SatisfactionListener
 
Field Summary
protected  ExtendedBlueprintContainer blueprintContainer
           
protected  List<Recipe> explicitDependencies
           
protected  String filter
          The OSGi filter for tracking references
protected  List<AbstractServiceReferenceRecipe.Listener> listeners
          The list of listeners for this reference.
protected  CollectionRecipe listenersRecipe
           
protected  org.osgi.service.blueprint.reflect.ServiceReferenceMetadata metadata
           
protected  boolean optional
           
 
Fields inherited from class org.apache.aries.blueprint.di.AbstractRecipe
name, prototype
 
Constructor Summary
protected AbstractServiceReferenceRecipe(String name, ExtendedBlueprintContainer blueprintContainer, org.osgi.service.blueprint.reflect.ServiceReferenceMetadata metadata, CollectionRecipe listenersRecipe, List<Recipe> explicitDependencies)
           
 
Method Summary
protected  void bind(org.osgi.framework.ServiceReference reference, Object service)
           
protected  void createListeners()
           
protected  Object createProxy(Callable<Object> dispatcher, Set<Class<?>> interfaces)
           
protected  void doStop()
           
 org.osgi.framework.ServiceReference getBestServiceReference()
           
protected  org.osgi.framework.BundleContext getBundleContextForServiceLookup()
           
 List<Recipe> getConstructorDependencies()
          Get the list of constructor dependencies, i.e.
 List<Recipe> getDependencies()
          Get the list of nested recipes, i.e.
protected  Class getInterfaceClass()
           
 CollectionRecipe getListenersRecipe()
           
 String getOsgiFilter()
           
protected static Class getRuntimeClass(org.osgi.service.blueprint.reflect.ServiceReferenceMetadata metadata)
           
 List<org.osgi.framework.ServiceReference> getServiceReferences()
           
 boolean isSatisfied()
           
protected  boolean isStarted()
           
protected  List<Class<?>> loadAllClasses(Iterable<String> interfaceNames)
           
protected  org.osgi.service.blueprint.container.ReifiedType loadType(String typeName, ClassLoader fromClassLoader)
           
protected abstract  void retrack()
           
 void serviceChanged(org.osgi.framework.ServiceEvent event)
           
protected  void setSatisfied(boolean s)
           
 void start(SatisfiableRecipe.SatisfactionListener listener)
           
 void stop()
           
protected abstract  void track(org.osgi.framework.ServiceReference reference)
           
protected  void unbind(org.osgi.framework.ServiceReference reference, Object service)
           
protected abstract  void untrack(org.osgi.framework.ServiceReference reference)
           
protected  void updateListeners()
           
 
Methods inherited from class org.apache.aries.blueprint.di.AbstractRecipe
addPartialObject, convert, convert, create, destroy, getName, internalCreate, isPrototype, loadClass, loadType, setPrototype, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.aries.blueprint.di.Recipe
create, destroy, getName
 

Field Detail

blueprintContainer

protected final ExtendedBlueprintContainer blueprintContainer

metadata

protected final org.osgi.service.blueprint.reflect.ServiceReferenceMetadata metadata

listenersRecipe

protected final CollectionRecipe listenersRecipe

explicitDependencies

protected final List<Recipe> explicitDependencies

optional

protected final boolean optional

filter

protected final String filter
The OSGi filter for tracking references


listeners

protected List<AbstractServiceReferenceRecipe.Listener> listeners
The list of listeners for this reference. This list will be lazy created

Constructor Detail

AbstractServiceReferenceRecipe

protected AbstractServiceReferenceRecipe(String name,
                                         ExtendedBlueprintContainer blueprintContainer,
                                         org.osgi.service.blueprint.reflect.ServiceReferenceMetadata metadata,
                                         CollectionRecipe listenersRecipe,
                                         List<Recipe> explicitDependencies)
Method Detail

getListenersRecipe

public CollectionRecipe getListenersRecipe()

start

public void start(SatisfiableRecipe.SatisfactionListener listener)
Specified by:
start in interface SatisfiableRecipe

stop

public void stop()
Specified by:
stop in interface SatisfiableRecipe

doStop

protected void doStop()

isStarted

protected boolean isStarted()

isSatisfied

public boolean isSatisfied()
Specified by:
isSatisfied in interface SatisfiableRecipe

getConstructorDependencies

public List<Recipe> getConstructorDependencies()
Description copied from interface: Recipe
Get the list of constructor dependencies, i.e. explicit and argument dependencies. These dependencies must be satisfied before the an object can be created.

Specified by:
getConstructorDependencies in interface Recipe
Overrides:
getConstructorDependencies in class AbstractRecipe
Returns:
a list of constructor dependencies

getDependencies

public List<Recipe> getDependencies()
Description copied from interface: Recipe
Get the list of nested recipes, i.e. all dependencies including constructor dependencies.

Specified by:
getDependencies in interface Recipe
Returns:
a list of dependencies

getOsgiFilter

public String getOsgiFilter()
Specified by:
getOsgiFilter in interface SatisfiableRecipe

createListeners

protected void createListeners()

loadAllClasses

protected List<Class<?>> loadAllClasses(Iterable<String> interfaceNames)

loadType

protected org.osgi.service.blueprint.container.ReifiedType loadType(String typeName,
                                                                    ClassLoader fromClassLoader)
Overrides:
loadType in class AbstractRecipe

createProxy

protected Object createProxy(Callable<Object> dispatcher,
                             Set<Class<?>> interfaces)
                      throws Exception
Throws:
Exception

serviceChanged

public void serviceChanged(org.osgi.framework.ServiceEvent event)
Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener

getInterfaceClass

protected Class getInterfaceClass()

getRuntimeClass

protected static Class getRuntimeClass(org.osgi.service.blueprint.reflect.ServiceReferenceMetadata metadata)

getBundleContextForServiceLookup

protected org.osgi.framework.BundleContext getBundleContextForServiceLookup()

setSatisfied

protected void setSatisfied(boolean s)

track

protected abstract void track(org.osgi.framework.ServiceReference reference)

untrack

protected abstract void untrack(org.osgi.framework.ServiceReference reference)

retrack

protected abstract void retrack()

updateListeners

protected void updateListeners()

bind

protected void bind(org.osgi.framework.ServiceReference reference,
                    Object service)

unbind

protected void unbind(org.osgi.framework.ServiceReference reference,
                      Object service)

getServiceReferences

public List<org.osgi.framework.ServiceReference> getServiceReferences()

getBestServiceReference

public org.osgi.framework.ServiceReference getBestServiceReference()


Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.