Problem to inject a NexusAether in a custom plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem to inject a NexusAether in a custom plugin

Oscar Picasso-4
Hi,

I cannot get the injected constructor of my custom nexus plugin to be called when I try to pass a NexusAether parameter. It works fine when injecting, exactly in similar way, a constructor with, for example an EventBus as a parameter. 

What is the proper way to inject a NexusAether ? 

I have tested it against Nexus Pro 2.7.2-03 and nexus-maven-bridge-plugin was added as a provided dependency to my plugin.

Below the details.

=====================
This does not work. Nothing from the plugin constructor is logged.

@Named
@Singleton
public class DeployRecorder extends ComponentSupport implements EventSubscriber {

private final NexusAether nexusAether;

@Inject
public DeployRecorder(final NexusAether nexusAether) {
log.info("Initializing Deploy Recorder...");
this.nexusAether = checkNotNull(nexusAether);
log.info("Deploy Recorder initialized...");
}
...
}

==============================
This works properly. Everything in the constructor is properly logged.

@Named
@Singleton
public class DeployRecorder extends ComponentSupport implements EventSubscriber {

private final EventBus eventBus;

@Inject
public DeployRecorder(final EventBus eventBus) {
log.info("Initializing Deploy Recorder...");
this.eventBus = checkNotNull(eventBus);
log.info("Deploy Recorder initialized...");
}
....
}

Reply | Threaded
Open this post in threaded view
|

Re: Problem to inject a NexusAether in a custom plugin

Stuart McCulloch-2
On 24 Mar 2014, at 20:16, Oscar Picasso <[hidden email]> wrote:

Hi,

I cannot get the injected constructor of my custom nexus plugin to be called when I try to pass a NexusAether parameter. It works fine when injecting, exactly in similar way, a constructor with, for example an EventBus as a parameter. 

What is the proper way to inject a NexusAether ? 

I have tested it against Nexus Pro 2.7.2-03 and nexus-maven-bridge-plugin was added as a provided dependency to my plugin.

Does that plugin dependency have <type>nexus-plugin</type> ?   Could you paste the META-INF/nexus/plugin.xml that’s generated for your plugin?

Below the details.

=====================
This does not work. Nothing from the plugin constructor is logged.

@Named
@Singleton
public class DeployRecorder extends ComponentSupport implements EventSubscriber {

private final NexusAether nexusAether;

@Inject
public DeployRecorder(final NexusAether nexusAether) {
log.info("Initializing Deploy Recorder...");
this.nexusAether = checkNotNull(nexusAether);
log.info("Deploy Recorder initialized...");
}
...
}

==============================
This works properly. Everything in the constructor is properly logged.

@Named
@Singleton
public class DeployRecorder extends ComponentSupport implements EventSubscriber {

private final EventBus eventBus;

@Inject
public DeployRecorder(final EventBus eventBus) {
log.info("Initializing Deploy Recorder...");
this.eventBus = checkNotNull(eventBus);
log.info("Deploy Recorder initialized...");
}
....
}


Reply | Threaded
Open this post in threaded view
|

RE: Problem to inject a NexusAether in a custom plugin

mgainty
Oscar

  • org.sonatype.sisu.goodies.eventbus.EventBus
  • <type>nexus-plugin</type> 

    ..let us know..
    M-
     


    From: [hidden email]
    Date: Mon, 24 Mar 2014 20:26:55 +0000
    To: [hidden email]
    Subject: Re: [nexus-dev] Problem to inject a NexusAether in a custom plugin

    On 24 Mar 2014, at 20:16, Oscar Picasso <[hidden email]> wrote:

    Hi,

    I cannot get the injected constructor of my custom nexus plugin to be called when I try to pass a NexusAether parameter. It works fine when injecting, exactly in similar way, a constructor with, for example an EventBus as a parameter. 

    What is the proper way to inject a NexusAether ? 

    I have tested it against Nexus Pro 2.7.2-03 and nexus-maven-bridge-plugin was added as a provided dependency to my plugin.

    Does that plugin dependency have <type>nexus-plugin</type> ?   Could you paste the META-INF/nexus/plugin.xml that’s generated for your plugin?

    Below the details.

    =====================
    This does not work. Nothing from the plugin constructor is logged.

    @Named
    @Singleton
    public class DeployRecorder extends ComponentSupport implements EventSubscriber {

    private final NexusAether nexusAether;

    @Inject
    public DeployRecorder(final NexusAether nexusAether) {
    log.info("Initializing Deploy Recorder...");
    this.nexusAether = checkNotNull(nexusAether);
    log.info("Deploy Recorder initialized...");
    }
    ...
    }

    ==============================
    This works properly. Everything in the constructor is properly logged.

    @Named
    @Singleton
    public class DeployRecorder extends ComponentSupport implements EventSubscriber {

    private final EventBus eventBus;

    @Inject
    public DeployRecorder(final EventBus eventBus) {
    log.info("Initializing Deploy Recorder...");
    this.eventBus = checkNotNull(eventBus);
    log.info("Deploy Recorder initialized...");
    }
    ....
    }


    Reply | Threaded
    Open this post in threaded view
    |

    Re: Problem to inject a NexusAether in a custom plugin

    Oscar Picasso-4
    Hi Stuart, 
    Hi Martin,

    As you suspected adding <type>nexus-plugin</type> to the nexus-maven-bridge-plugin dependency solved the problem.

    Thanks for your help.

    Oscar


    On Mon, Mar 24, 2014 at 8:11 PM, Martin Gainty <[hidden email]> wrote:
    Oscar

  • org.sonatype.sisu.goodies.eventbus.EventBus
  • is injected by the sisu-injector
    what is NexusAether interface injected by?

    are you certain your pom in  implementing your nexus-plugin as Stuart asked as
    <type>nexus-plugin</type> 

    ..let us know..
    M-
     


    From: [hidden email]
    Date: Mon, 24 Mar 2014 20:26:55 +0000
    To: [hidden email]
    Subject: Re: [nexus-dev] Problem to inject a NexusAether in a custom plugin


    On 24 Mar 2014, at 20:16, Oscar Picasso <[hidden email]> wrote:

    Hi,

    I cannot get the injected constructor of my custom nexus plugin to be called when I try to pass a NexusAether parameter. It works fine when injecting, exactly in similar way, a constructor with, for example an EventBus as a parameter. 

    What is the proper way to inject a NexusAether ? 

    I have tested it against Nexus Pro 2.7.2-03 and nexus-maven-bridge-plugin was added as a provided dependency to my plugin.

    Does that plugin dependency have <type>nexus-plugin</type> ?   Could you paste the META-INF/nexus/plugin.xml that’s generated for your plugin?

    Below the details.

    =====================
    This does not work. Nothing from the plugin constructor is logged.

    @Named
    @Singleton
    public class DeployRecorder extends ComponentSupport implements EventSubscriber {

    private final NexusAether nexusAether;

    @Inject
    public DeployRecorder(final NexusAether nexusAether) {
    log.info("Initializing Deploy Recorder...");
    this.nexusAether = checkNotNull(nexusAether);
    log.info("Deploy Recorder initialized...");
    }
    ...
    }

    ==============================
    This works properly. Everything in the constructor is properly logged.

    @Named
    @Singleton
    public class DeployRecorder extends ComponentSupport implements EventSubscriber {

    private final EventBus eventBus;

    @Inject
    public DeployRecorder(final EventBus eventBus) {
    log.info("Initializing Deploy Recorder...");
    this.eventBus = checkNotNull(eventBus);
    log.info("Deploy Recorder initialized...");
    }
    ....
    }





    --
    blog: http://fp.opicasso.com
    twitter: @oscarpica