polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject Re: Discuss; SLF4J in Core
Date Tue, 31 Mar 2015 09:15:39 GMT
On Tue, Mar 31, 2015 at 11:18 AM, James Carman <james@carmanconsulting.com>
wrote:

> What do you do when there is no logger?  Use
> a default no-op implementation or something?


Some basic training for our new friends;

If I have

public interface Abc
{
    int doSomething();
    void somethingElse();
      :
}

I can during bootstrap do;

public void assemble( ModuleAssembly module ) // you implement, called by
Qi4j
    throws AssemblyException
{
    module.services( Abc.class ).withMixins( NoopMixin.class );
}

And I have a Noop implementation of the Abc service. Nothing else is
needed. ;-)

or, I can do;

public void assemble( ModuleAssembly module ) // you implement, called by
Qi4j
    throws AssemblyException
{
    if( Boolean.getBoolean( "enableAbcAll" ) )
        module.services( Abc.class ).withMixins( DoSomethingMixin.class,
SomethingElseMixin.class );
    if( Boolean.getBoolean( "enableAbcDoSomething" ) )
        module.services( Abc.class ).withMixins( DoSomethingMixin.class );
    if( Boolean.getBoolean( "enableAbcSomethingElse" ) )
        module.services( Abc.class ).withMixins( SomethingElseMixin.class );
    module.services( Abc.class ).withMixins( NoopMixin.class );
}

If I want to allow each method to be enable individually with an
implementation. The last NoopMixin registration basically says; "And for
everything else use Noop".

For extensions working straight on Core itself, it is not as sweet, but it
has been done with Metrics. Possibly, the design for this will get an
upgrade at the same time....


Hope you find that intriguing...


Cheers
-- 
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message