Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sisu-users] Should I be able to use @PostConstruct on an abstract class?

On 15 February 2014 02:23, Benson Margulies <benson@xxxxxxxxxxxxx> wrote:

Correct, at the moment the new LifecycleModule is not installed by default in InjectedTest(Case). Similarly it's not installed by default in the other launch-related classes. I wanted to give people a chance to install it and try it out first before enabling it everywhere, and even then we should give people a way to disable it so they can use alternative @PostConstruct/@PreDestroy lifecycle extensions such as the one from Apache/Onami.

Btw, InjectedTest(Case) has a configure(Binder) method that lets you install modules or add bindings:

    @Override
    public void configure( Binder binder )
    {
        binder.install( new LifecycleModule() );
    }

Note you're currently responsible for deciding when to call the unmanage method of the BeanManager which kicks off the @PreDestroy cycle:

    public void tearDown()
        throws Exception
    {
        lookup( BeanManager.class ).unmanage();
    }

This is so you can tie this to other shutdown hooks that you might already have in your launcher, but I'm also looking at alternative ways to trigger this.
 
M3?

0.2.0 passed its release review, so unless there's a blocker this weekend the next release will be 0.2.0 - soon to be followed by the first 0.3.0 milestone.
 
Can anyone tell me how to make IntelliJ and the sisu source get along?

Get along in what way?
 
On Fri, Feb 14, 2014 at 9:01 PM, Benson Margulies <benson@xxxxxxxxxxxxx> wrote:
The PostConstruct is not called. I'm using 0.2.M2

@Named
public abstract class AbstractWsBusComponent implements WsBusComponent {
    @Inject
    protected MetricRegistry metrics;
    private Timer requests;

    @PostConstruct
    public void postConstruct() {
        requests = metrics.timer(name(getClass(), "requests"));
    }


    @Override
    public final Text process(WsBusComponentInput input) {
        Timer.Context context = requests.time();
        try {
            return processImplementation(input);
        } finally {
            context.stop();
        }
    }

    protected abstract Text processImplementation(WsBusComponentInput input);
}

--
Cheers, Stuart

Back to the top