org.jvnet.hk2.component
Class MultiThreadedInhabitantActivator

java.lang.Object
  extended by org.jvnet.hk2.component.MultiThreadedInhabitantActivator
All Implemented Interfaces:
InhabitantActivator

public class MultiThreadedInhabitantActivator
extends Object
implements InhabitantActivator

A simple multi-threaded based InhabitantActivator

Author:
Jeff Trent

Constructor Summary
MultiThreadedInhabitantActivator()
           
 
Method Summary
 void activate(Inhabitant<?> inhabitant)
          Implementations are generally expected to call Inhabitant.get() at some point.
 void awaitCompletion()
          Called after all InhabitantActivator.activate(Inhabitant) and InhabitantActivator.deactivate(Inhabitant) calls are made to wait for completion of a progression to a particular run level.
 void awaitCompletion(long timeout, TimeUnit unit)
          Called after all InhabitantActivator.activate(Inhabitant) and InhabitantActivator.deactivate(Inhabitant) calls are made to wait for completion of a progression to a particular run level.
 void deactivate(Inhabitant<?> inhabitant)
          Implementations are generally expected to call Inhabitant.release() at some point.
 void setExecutorService(Executor es)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiThreadedInhabitantActivator

public MultiThreadedInhabitantActivator()
Method Detail

setExecutorService

public void setExecutorService(Executor es)

activate

public void activate(Inhabitant<?> inhabitant)
Description copied from interface: InhabitantActivator
Implementations are generally expected to call Inhabitant.get() at some point.

The DefaultRunLevelService calls activate for all Inhabitants qualifying in the activated RunLevel regardless of whether or not they need activation.

Specified by:
activate in interface InhabitantActivator
Parameters:
inhabitant - the inhabitant to activate

deactivate

public void deactivate(Inhabitant<?> inhabitant)
Description copied from interface: InhabitantActivator
Implementations are generally expected to call Inhabitant.release() at some point.

The DefaultRunLevelService calls deactivate for all Inhabitants qualifying in the activated RunLevel regardless of whether or not they need releasing.

Specified by:
deactivate in interface InhabitantActivator
Parameters:
inhabitant - the inhabitant to release

awaitCompletion

public void awaitCompletion()
                     throws InterruptedException,
                            ExecutionException,
                            TimeoutException
Description copied from interface: InhabitantActivator
Called after all InhabitantActivator.activate(Inhabitant) and InhabitantActivator.deactivate(Inhabitant) calls are made to wait for completion of a progression to a particular run level. This is useful in the case where the implementation is asynchronous in nature.

Generally, there is one awaitCompletion() call per RunLevel being processed.

Specified by:
awaitCompletion in interface InhabitantActivator
Throws:
InterruptedException
ExecutionException
TimeoutException

awaitCompletion

public void awaitCompletion(long timeout,
                            TimeUnit unit)
                     throws ExecutionException,
                            InterruptedException,
                            TimeoutException
Description copied from interface: InhabitantActivator
Called after all InhabitantActivator.activate(Inhabitant) and InhabitantActivator.deactivate(Inhabitant) calls are made to wait for completion of a progression to a particular run level. This is useful in the case where the implementation is asynchronous in nature.

Generally, there is one awaitCompletion() call per RunLevel being processed.

Specified by:
awaitCompletion in interface InhabitantActivator
Throws:
ExecutionException
InterruptedException
TimeoutException


Copyright © 2011 Oracle Corporation. All Rights Reserved.