public class ComponentContainer extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ComponentContainer.Scope
The visibility of a Jira component as an OSGi service (for consumption by plugins).
|
Constructor and Description |
---|
ComponentContainer(boolean eagerInitialization)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
component(ComponentContainer.Scope scope,
org.picocontainer.ComponentAdapter componentAdapter)
Adds the given component adapter to this container, with the given scope.
|
org.picocontainer.ComponentAdapter |
getComponentAdapter(Class<?> key)
Returns the component adapter with the given key.
|
<T> T |
getComponentInstance(Class<T> key)
Returns the component whose key is the given class.
|
com.atlassian.plugin.osgi.hostcomponents.HostComponentProvider |
getHostComponentProvider() |
org.picocontainer.MutablePicoContainer |
getPicoContainer() |
<T> void |
implementation(ComponentContainer.Scope scope,
Class<? super T> key,
Class<T> implementation) |
<T> void |
implementation(ComponentContainer.Scope scope,
Class<? super T> key,
Class<T> implementation,
Object... parameterKeys)
Registers the interface with a concrete implementation class using the given variable number of arguments as the
keys Pico will use to look up during instantiation.
|
<T> void |
implementation(ComponentContainer.Scope scope,
Class<? super T> key,
Class<T> implementation,
org.picocontainer.Parameter[] parameters) |
<T> void |
implementationUseDefaultConstructor(ComponentContainer.Scope scope,
Class<T> key,
Class<? extends T> implementation)
Registers the default constructor, to work around PICO-201.
|
<T,S extends T> |
instance(ComponentContainer.Scope scope,
Class<T> key,
S instance)
Adds the given component to this container.
|
void |
internalInstance(Object instance)
Adds the given internal component (not published to OSGi), using the object's class as the key.
|
void |
internalInstance(String key,
Object instance)
Adds the given internal component (not published to OSGi), using the given key.
|
void |
internalInstanceOf(Class<?> componentClass)
Adds an internal (non-OSGi) instance of the given class to this container.
|
<T> void |
provideViaFactory(Class<? super T> serviceInterface,
Class<? extends <any>> osgiFactoryClass)
Provide a service via an OSGI factory from PICO container.
|
public ComponentContainer(boolean eagerInitialization)
eagerInitialization
- whether this container should initialize its components during startuppublic org.picocontainer.MutablePicoContainer getPicoContainer()
public org.picocontainer.ComponentAdapter getComponentAdapter(Class<?> key)
key
- the key to look upPicoContainer.getComponentAdapter(Object)
@Nullable public <T> T getComponentInstance(Class<T> key)
T
- the type of keykey
- the component key, typically an interface or implementationnull
if there is no component with that keypublic com.atlassian.plugin.osgi.hostcomponents.HostComponentProvider getHostComponentProvider()
public void internalInstance(Object instance)
instance
- the instance to addpublic void internalInstance(String key, Object instance)
key
- the key under which to add the componentinstance
- the component instance to addpublic <T,S extends T> void instance(ComponentContainer.Scope scope, Class<T> key, S instance)
T
- the interface being implementedS
- the class that implements itscope
- the visibility of the component to OSGikey
- the component's key in the container, usually the interface being implementedinstance
- the component instance to addpublic void internalInstanceOf(Class<?> componentClass)
componentClass
- the class that implements the componentpublic <T> void implementation(ComponentContainer.Scope scope, Class<? super T> key, Class<T> implementation)
public <T> void implementation(ComponentContainer.Scope scope, Class<? super T> key, Class<T> implementation, Object... parameterKeys)
Parameter
.scope
- the container scopekey
- the interface to registerimplementation
- the concrete implementation of interfaceClassparameterKeys
- the variable number of parameterspublic <T> void implementation(ComponentContainer.Scope scope, Class<? super T> key, Class<T> implementation, org.picocontainer.Parameter[] parameters)
public <T> void implementationUseDefaultConstructor(ComponentContainer.Scope scope, Class<T> key, Class<? extends T> implementation)
T
- the type of componentscope
- the scope of the componentkey
- the component keyimplementation
- the class that implements the componentpublic <T> void provideViaFactory(Class<? super T> serviceInterface, Class<? extends <any>> osgiFactoryClass)
There are two ways to provide a service to OSGI - expose it as a singleton object that
implements the service interface, or as a ServiceFactory
able to create instances
of the service tailored to its consumer. This does the latter.
serviceInterface
- the interface of an OSGI serviceosgiFactoryClass
- OSGI ServiceFactory class. The factory implementation will be created and injected from
the Pico container, but will not be registered in the container.public void component(ComponentContainer.Scope scope, org.picocontainer.ComponentAdapter componentAdapter)
scope
- the scope of the componentcomponentAdapter
- the adapter to addCopyright © 2002-2019 Atlassian. All Rights Reserved.