Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
titleAnnotations
@Component
public class Dependency {

    @Requires
    public FooService fs;
    
    @Unbind
    public void unbind(BazService bz) {
        //...
    }
    
    @Bind
    public void bind(BazService bz) {
        // ...
    }

  //...
}
Center

Reacting to lifecycle state changes

Immediate components

  • A POJO object (implementation object) is created as soons as the instance becomes valid
  • Instances that don't provide services becomes automatically immediate
    Code Block
    xml
    xml
    titleXML
    
    <component classname="my.service.implementation" name="my-service-impl" immediate="true">
       <provides/>
    </component>
    
    Code Block
    java
    java
    titleAnnotations
    
    @Component(immediate=true)
    @Provides
    public class Implementation implements FooService {
       ...
    }
    
    Center

Lifecycle callbacks

Code Block
xml
xml
titleXML

<component classname="my.implementation" name="my-impl">
    <callback transition="validate" method="start" />
    <callback transition="invalidate" method="stop" />
</component>
Code Block
java
java
titleAnnotations

@Component
public class Implementation {
    
    @Validate
    public void start() {
        
    }
    
    @Invalidate
    public void stop() {
        
    }
}