You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Tobias Gierke <to...@code-sourcery.de> on 2010/10/20 22:30:19 UTC

Substitute for PlexusContainer#getLoggerManager() ?

Hi,

I just noticed that PlexusContainer#getLoggerManager() has been removed
(because of http://jira.codehaus.org/browse/MNG-4162). I have a plexus
component that is dynamically looked up from the container (from inside
a plugin) and some implementations of this component need a logger.

I made these components implement Contextualizable and just did

    public void contextualize( Context context )
        throws ContextException
    {
        final PlexusContainer container = (PlexusContainer) context.get(
PlexusConstants.PLEXUS_KEY );
        this.log = container.getLoggerManager().getLoggerForComponent(
Mojo.ROLE );
    }

inside the component...but this obviously no longer works.

Is there a way to get a Logger injected directly into the component 
(without to resorting to a marker interface / reflection tricks like
looking for a suitable setLog method) ?

Thanks in advance,

Tobias

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Substitute for PlexusContainer#getLoggerManager() ?

Posted by Igor Fedorenko <ig...@ifedorenko.com>.
In maven 3.0, you can use @Requirement to have logger injected like any
other component.

--
Regards,
Igor

On 10-10-21 06:23 AM, Tobi wrote:
>
>> Tobias Gierke wrote:
>>
>>> Is there a way to get a Logger injected directly into the component
>>
>> The usual pattern is to have the component extend AbstractLogEnabled.
> Since I already need to inherit from a different class , this won't work
> ... would implementing only the LogEnabled interface do the trick as well ?
>
>
> - Tobias
>
>
>>
>>
>> Benjamin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Substitute for PlexusContainer#getLoggerManager() ?

Posted by Tobias Gierke <to...@code-sourcery.de>.
Benjamin Bentmann wrote:
> Tobi wrote:
>
>> ... would implementing only the LogEnabled interface do the trick as
>> well ?
>
> Yes
Thanks for your help, it's working :-)

>
>
> Benjamin


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Substitute for PlexusContainer#getLoggerManager() ?

Posted by Benjamin Bentmann <be...@udo.edu>.
Tobi wrote:

> ... would implementing only the LogEnabled interface do the trick as well ?

Yes


Benjamin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Substitute for PlexusContainer#getLoggerManager() ?

Posted by Tobi <to...@code-sourcery.de>.
> Tobias Gierke wrote:
>
>> Is there a way to get a Logger injected directly into the component
>
> The usual pattern is to have the component extend AbstractLogEnabled.
Since I already need to inherit from a different class , this won't work 
... would implementing only the LogEnabled interface do the trick as well ?


- Tobias


>
>
> Benjamin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Substitute for PlexusContainer#getLoggerManager() ?

Posted by Benjamin Bentmann <be...@udo.edu>.
Tobias Gierke wrote:

> Is there a way to get a Logger injected directly into the component

The usual pattern is to have the component extend AbstractLogEnabled.


Benjamin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org