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:
java.util.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: 1030761 $, $Date: 2010-11-03 23:48:47 +0000 (Wed, 03 Nov 2010) $

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  java.util.List<Recipe> explicitDependencies
           
protected  java.lang.String filter
          The OSGi filter for tracking references
protected  java.util.List<AbstractServiceReferenceRecipe.Listener> listeners
          The list of listeners for this reference.
protected  CollectionRecipe listenersRecipe
           
protected  ServiceReferenceMetadata metadata
           
protected  boolean optional
           
 
Fields inherited from class org.apache.aries.blueprint.di.AbstractRecipe
name, prototype
 
Constructor Summary
protected AbstractServiceReferenceRecipe(java.lang.String name, ExtendedBlueprintContainer blueprintContainer, ServiceReferenceMetadata metadata, CollectionRecipe listenersRecipe, java.util.List<Recipe> explicitDependencies)
           
 
Method Summary
protected  void bind(org.osgi.framework.ServiceReference reference, java.lang.Object service)
           
protected  void createListeners()
           
protected  java.lang.Object createProxy(java.util.concurrent.Callable<java.lang.Object> dispatcher, java.util.Set<java.lang.Class<?>> interfaces)
           
protected  void doStop()
           
 org.osgi.framework.ServiceReference getBestServiceReference()
           
 java.util.List<Recipe> getConstructorDependencies()
          Get the list of constructor dependencies, i.e.
 java.util.List<Recipe> getDependencies()
          Get the list of nested recipes, i.e.
protected  java.lang.Class getInterfaceClass()
           
 CollectionRecipe getListenersRecipe()
           
 java.lang.String getOsgiFilter()
           
protected static java.lang.Class getRuntimeClass(ServiceReferenceMetadata metadata)
           
 java.util.List<org.osgi.framework.ServiceReference> getServiceReferences()
           
 boolean isSatisfied()
           
protected  boolean isStarted()
           
protected  java.util.List<java.lang.Class<?>> loadAllClasses(java.lang.Iterable<java.lang.String> interfaceNames)
           
protected  ReifiedType loadType(java.lang.String typeName, java.lang.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, java.lang.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 ServiceReferenceMetadata metadata

listenersRecipe

protected final CollectionRecipe listenersRecipe

explicitDependencies

protected final java.util.List<Recipe> explicitDependencies

optional

protected final boolean optional

filter

protected final java.lang.String filter
The OSGi filter for tracking references


listeners

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

Constructor Detail

AbstractServiceReferenceRecipe

protected AbstractServiceReferenceRecipe(java.lang.String name,
                                         ExtendedBlueprintContainer blueprintContainer,
                                         ServiceReferenceMetadata metadata,
                                         CollectionRecipe listenersRecipe,
                                         java.util.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 java.util.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 java.util.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 java.lang.String getOsgiFilter()
Specified by:
getOsgiFilter in interface SatisfiableRecipe

createListeners

protected void createListeners()

loadAllClasses

protected java.util.List<java.lang.Class<?>> loadAllClasses(java.lang.Iterable<java.lang.String> interfaceNames)

loadType

protected ReifiedType loadType(java.lang.String typeName,
                               java.lang.ClassLoader fromClassLoader)
Overrides:
loadType in class AbstractRecipe

createProxy

protected java.lang.Object createProxy(java.util.concurrent.Callable<java.lang.Object> dispatcher,
                                       java.util.Set<java.lang.Class<?>> interfaces)
                                throws java.lang.Exception
Throws:
java.lang.Exception

serviceChanged

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

getInterfaceClass

protected java.lang.Class getInterfaceClass()

getRuntimeClass

protected static java.lang.Class getRuntimeClass(ServiceReferenceMetadata metadata)

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,
                    java.lang.Object service)

unbind

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

getServiceReferences

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

getBestServiceReference

public org.osgi.framework.ServiceReference getBestServiceReference()


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