com.atlassian.plugin.osgi.spring
Class DefaultSpringContainerAccessor

java.lang.Object
  extended by com.atlassian.plugin.osgi.spring.DefaultSpringContainerAccessor
All Implemented Interfaces:
ContainerAccessor, SpringContainerAccessor

public class DefaultSpringContainerAccessor
extends java.lang.Object
implements SpringContainerAccessor

Manages spring context access, including autowiring.

Since:
2.2.0

Constructor Summary
DefaultSpringContainerAccessor(java.lang.Object applicationContext)
           
 
Method Summary
 void autowireBean(java.lang.Object instance, AutowireCapablePlugin.AutowireStrategy autowireStrategy)
          'Autowires' a given object - injects all dependencies defined in the constructor.
<T> T
createBean(java.lang.Class<T> clazz)
          Will ask the container to instantiate a bean of the given class and does inject all constructor defined dependencies.
 java.lang.Object getBean(java.lang.String id)
          Retrieves a spring bean from the spring bean factory.
<T> java.util.Collection<T>
getBeansOfType(java.lang.Class<T> interfaceClass)
          Gets all the beans that implement a given interface
<T> T
injectBean(T bean)
          Injects an existing bean instance with any dependencies via setters or private field injection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSpringContainerAccessor

public DefaultSpringContainerAccessor(java.lang.Object applicationContext)
Method Detail

createBean

public <T> T createBean(java.lang.Class<T> clazz)
Description copied from interface: ContainerAccessor
Will ask the container to instantiate a bean of the given class and does inject all constructor defined dependencies. Currently we have only spring as a container that will autowire this bean.

Specified by:
createBean in interface ContainerAccessor
Parameters:
clazz - the Class to instantiate. Cannot be null.
Returns:
an instantiated bean.

injectBean

public <T> T injectBean(T bean)
Description copied from interface: ContainerAccessor
Injects an existing bean instance with any dependencies via setters or private field injection

Specified by:
injectBean in interface ContainerAccessor
Type Parameters:
T - The bean type
Parameters:
bean - The instantiated bean to inject

getBeansOfType

public <T> java.util.Collection<T> getBeansOfType(java.lang.Class<T> interfaceClass)
Description copied from interface: ContainerAccessor
Gets all the beans that implement a given interface

Specified by:
getBeansOfType in interface ContainerAccessor
Type Parameters:
T - The target interface type
Parameters:
interfaceClass - The interface class
Returns:
A collection of implementations from the plugin's container

autowireBean

public void autowireBean(java.lang.Object instance,
                         AutowireCapablePlugin.AutowireStrategy autowireStrategy)
Description copied from interface: SpringContainerAccessor
'Autowires' a given object - injects all dependencies defined in the constructor.

Specified by:
autowireBean in interface SpringContainerAccessor
Parameters:
instance - the object instance to autowire
autowireStrategy - the autowire strategy

getBean

public java.lang.Object getBean(java.lang.String id)
Description copied from interface: SpringContainerAccessor
Retrieves a spring bean from the spring bean factory.

Specified by:
getBean in interface ContainerAccessor
Specified by:
getBean in interface SpringContainerAccessor
Parameters:
id - the id of the spring bean, cannot be null
Returns:
the spring bean object


Copyright © 2012 Atlassian. All Rights Reserved.