1
package com.eucalyptus.component;
3
import java.util.NoSuchElementException;
4
import org.apache.log4j.Logger;
5
import com.eucalyptus.util.Committor;
6
import com.eucalyptus.util.Transition;
13
public class Lifecycles {
14
private static Logger LOG = Logger.getLogger( Lifecycles.class );
17
* The states possible in a component's lifecycle <br/>
18
* TODO:TODO:TODO:TODO:TODO:TODO:TODO: <br/>
19
* Valid transitions are: <br/>
20
* - UNLOADED -> INITIALIZED <br/>
21
* - INITIALIZED -> LOADED <br/>
22
* - LOADED -> STARTED <br/>
23
* - STARTED <-> STOPPED <br/>
24
* - STOPPED -> UNLOADED (not implemented at this time) <br/>
29
DISABLED, PRIMORDIAL, INITIALIZED, LOADED, STARTED, STOPPED, PAUSED;
31
public <A> Transition<A, Lifecycles.State> to( final Lifecycles.State s, final Committor<A> c ) throws Exception {
32
return ( Transition<A, Lifecycles.State> ) Transition.anonymous( this, s, new Committor<A>( ) {
34
public void commit( A object ) throws Exception {
36
if ( object instanceof Component ) {
37
( ( Component ) object ).getLifecycle( ).setState( s );
43
public <A> Transition<A, Lifecycles.State> to( final Lifecycles.State s ) throws Exception {
44
return ( Transition<A, Lifecycles.State> ) Transition.anonymous( this, s, new Committor<A>( ) {
46
public void commit( A object ) throws Exception {
47
if ( object instanceof Component ) {
48
( ( Component ) object ).getLifecycle( ).setState( s );
56
public static Lifecycle lookup( String componentName ) throws NoSuchElementException {
57
return Components.lookup( Lifecycle.class, componentName );
60
public static Lifecycle lookup( com.eucalyptus.bootstrap.Component component ) throws NoSuchElementException {
61
return Components.lookup( Lifecycle.class, component.name( ) );
64
public static boolean contains( String componentName ) {
65
return Components.contains( Lifecycle.class, componentName );
68
public static boolean contains( com.eucalyptus.bootstrap.Component component ) {
69
return Components.contains( Lifecycle.class, component.name( ) );