org.apache.geronimo.blueprint.container
Class AbstractServiceReferenceRecipe

java.lang.Object
  extended by org.apache.geronimo.blueprint.di.AbstractRecipe
      extended by org.apache.geronimo.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: 760378 $, $Date: 2009-03-31 11:31:38 +0200 (Tue, 31 Mar 2009) $
Author:
Apache Geronimo Project

Nested Class Summary
static class AbstractServiceReferenceRecipe.CgLibProxyFactory
           
static class AbstractServiceReferenceRecipe.JdkProxyFactory
           
static class AbstractServiceReferenceRecipe.Listener
           
static interface AbstractServiceReferenceRecipe.ProxyFactory
           
 
Nested classes/interfaces inherited from interface org.apache.geronimo.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  ServiceReferenceMetadata metadata
           
protected  boolean optional
           
protected  ClassLoader proxyClassLoader
           
 
Fields inherited from class org.apache.geronimo.blueprint.di.AbstractRecipe
name, prototype
 
Constructor Summary
protected AbstractServiceReferenceRecipe(String name, ExtendedBlueprintContainer blueprintContainer, 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, Iterable<String> interfaces)
           
protected  void doStop()
           
 org.osgi.framework.ServiceReference getBestServiceReference()
           
 List<Recipe> getConstructorDependencies()
          Get the list of constructor dependencies, i.e.
 List<Recipe> getDependencies()
          Get the list of nested recipes, i.e.
 CollectionRecipe getListenersRecipe()
           
 String getOsgiFilter()
           
protected  AbstractServiceReferenceRecipe.ProxyFactory getProxyFactory()
           
 List<org.osgi.framework.ServiceReference> getServiceReferences()
           
 boolean isSatisfied()
           
protected  boolean isStarted()
           
protected  List<Class> loadAllClasses(Iterable<String> interfaceNames)
           
protected  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.geronimo.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.geronimo.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 List<Recipe> explicitDependencies

proxyClassLoader

protected final ClassLoader proxyClassLoader

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,
                                         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)
                              throws ClassNotFoundException
Throws:
ClassNotFoundException

loadType

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

createProxy

protected Object createProxy(Callable<Object> dispatcher,
                             Iterable<String> interfaces)
                      throws Exception
Throws:
Exception

getProxyFactory

protected AbstractServiceReferenceRecipe.ProxyFactory getProxyFactory()
                                                               throws ClassNotFoundException
Throws:
ClassNotFoundException

serviceChanged

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

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 © 2003-2009 The Apache Software Foundation. All Rights Reserved.