org.apache.tuscany.sca.implementation.osgi.runtime
Class OSGiImplementationProvider

java.lang.Object
  extended by org.apache.tuscany.sca.implementation.osgi.runtime.OSGiImplementationProvider
All Implemented Interfaces:
ScopedImplementationProvider, ImplementationProvider

public class OSGiImplementationProvider
extends java.lang.Object
implements ScopedImplementationProvider

The runtime instantiation of OSGi component implementations


Constructor Summary
OSGiImplementationProvider(RuntimeComponent definition, OSGiImplementation impl, DataBindingExtensionPoint dataBindingRegistry, JavaPropertyValueObjectFactory propertyValueFactory, ProxyFactory proxyFactory, ScopeRegistry scopeRegistry, RequestContextFactory requestContextFactory, MessageFactory messageFactory, InterfaceContractMapper mapper)
           
 
Method Summary
 void bundleChanged(BundleEvent event)
           
 InstanceWrapper<?> createInstanceWrapper()
          Create a wrapper for the component instance for the scope management
 Invoker createInvoker(RuntimeComponentService service, Operation operation)
          Create an invoker for the component implementation in the invocation chain.
 Invoker createTargetInvoker(RuntimeComponentService service, Operation operation)
           
 void frameworkEvent(FrameworkEvent event)
           
protected  OSGiImplementationImpl getImplementation()
           
 long getMaxAge()
           
 long getMaxIdleTime()
           
protected  org.osgi.framework.ServiceReference getOSGiServiceReference(ComponentService service)
           
protected  org.osgi.framework.ServiceReference getOSGiServiceReference(EndpointReference from, Interface callbackInterface)
           
protected  RuntimeComponent getRuntimeComponent()
           
 Scope getScope()
          Get the scope for the component implementation
protected  ScopeContainer<?> getScopeContainer()
           
protected  Bundle installDummyBundleWithoutFragments(java.lang.Class<?> interfaceClass)
           
 boolean isEagerInit()
          Indicate if the component needs to be eagerly initialized
 boolean isOptimizable()
           
 void processAnnotations(boolean doWait)
           
 void start()
          This method will be invoked when the component implementation is activated.
protected  Bundle startBundle(boolean doWait)
           
 void stop()
          This method will be invoked when the component implementation is deactivated.
 boolean supportsOneWayInvocation()
          For bindings that invoke one-way callback operations asynchronously, there is no need to perform a thread switch before calling the invoker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSGiImplementationProvider

public OSGiImplementationProvider(RuntimeComponent definition,
                                  OSGiImplementation impl,
                                  DataBindingExtensionPoint dataBindingRegistry,
                                  JavaPropertyValueObjectFactory propertyValueFactory,
                                  ProxyFactory proxyFactory,
                                  ScopeRegistry scopeRegistry,
                                  RequestContextFactory requestContextFactory,
                                  MessageFactory messageFactory,
                                  InterfaceContractMapper mapper)
                           throws BundleException
Throws:
BundleException
Method Detail

getRuntimeComponent

protected RuntimeComponent getRuntimeComponent()

getImplementation

protected OSGiImplementationImpl getImplementation()

startBundle

protected Bundle startBundle(boolean doWait)
                      throws ObjectCreationException
Throws:
ObjectCreationException

getOSGiServiceReference

protected org.osgi.framework.ServiceReference getOSGiServiceReference(ComponentService service)
                                                               throws ObjectCreationException
Throws:
ObjectCreationException

getOSGiServiceReference

protected org.osgi.framework.ServiceReference getOSGiServiceReference(EndpointReference from,
                                                                      Interface callbackInterface)
                                                               throws ObjectCreationException
Throws:
ObjectCreationException

installDummyBundleWithoutFragments

protected Bundle installDummyBundleWithoutFragments(java.lang.Class<?> interfaceClass)
                                             throws java.lang.Exception
Throws:
java.lang.Exception

createInstanceWrapper

public InstanceWrapper<?> createInstanceWrapper()
                                         throws ObjectCreationException
Description copied from interface: ScopedImplementationProvider
Create a wrapper for the component instance for the scope management

Specified by:
createInstanceWrapper in interface ScopedImplementationProvider
Returns:
A wrapper for the component instance
Throws:
ObjectCreationException

isOptimizable

public boolean isOptimizable()

getScope

public Scope getScope()
Description copied from interface: ScopedImplementationProvider
Get the scope for the component implementation

Specified by:
getScope in interface ScopedImplementationProvider
Returns:
The scope for the component implementation, if null is returned, STATELESS will be used

isEagerInit

public boolean isEagerInit()
Description copied from interface: ScopedImplementationProvider
Indicate if the component needs to be eagerly initialized

Specified by:
isEagerInit in interface ScopedImplementationProvider
Returns:
true if the component is marked to be eagerly initialized, false otherwise

getMaxAge

public long getMaxAge()
Specified by:
getMaxAge in interface ScopedImplementationProvider
Returns:
the maxAge

getMaxIdleTime

public long getMaxIdleTime()
Specified by:
getMaxIdleTime in interface ScopedImplementationProvider
Returns:
the maxIdleTime

getScopeContainer

protected ScopeContainer<?> getScopeContainer()

createTargetInvoker

public Invoker createTargetInvoker(RuntimeComponentService service,
                                   Operation operation)

createInvoker

public Invoker createInvoker(RuntimeComponentService service,
                             Operation operation)
Description copied from interface: ImplementationProvider
Create an invoker for the component implementation in the invocation chain. The invoker will be responsible for calling the implementation logic for the given component.

Specified by:
createInvoker in interface ImplementationProvider
Parameters:
service - The component service
operation - The operation that the interceptor will handle
Returns:
An invoker that handles the invocation logic, null should be returned if no invoker is required

supportsOneWayInvocation

public boolean supportsOneWayInvocation()
Description copied from interface: ImplementationProvider
For bindings that invoke one-way callback operations asynchronously, there is no need to perform a thread switch before calling the invoker. This method indicates whether the binding has this capability.

Specified by:
supportsOneWayInvocation in interface ImplementationProvider
Returns:
true if the callback invoker is able to invoke one-way operations asynchronously, false if all invocations are synchronous

start

public void start()
Description copied from interface: ImplementationProvider
This method will be invoked when the component implementation is activated.

Specified by:
start in interface ImplementationProvider

processAnnotations

public void processAnnotations(boolean doWait)
                        throws IntrospectionException
Throws:
IntrospectionException

stop

public void stop()
Description copied from interface: ImplementationProvider
This method will be invoked when the component implementation is deactivated.

Specified by:
stop in interface ImplementationProvider

frameworkEvent

public void frameworkEvent(FrameworkEvent event)

bundleChanged

public void bundleChanged(BundleEvent event)