Adding a component implementation programmatically

View: New views
7 Messages — Rating Filter:   Alert me  

Adding a component implementation programmatically

by Anton Makeev :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Could anyone help me on the following issue?
I have a library that uses the plexus container (namely, Maven2) and I want to configure it with my own component implementation.
Moreover I need to pass some arbitrary parameters to my implementation, that are known and available in the place of configuration only.

How can I do this?
I skimmed through PlexusContainer and ComponentDescriptor interfaces but didn't find anythig suitable - all the methods (i.e setImplementation) accepts String as parameters.

Thanks beforehand,
Anton Makeev

Re: Adding a component implementation programmatically

by Jason van Zyl-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For Maven specifically you should look at the netbeans integration,  
and the eclipse integration. Both use the ContainerCustomizer in the  
Maven Embedder package to wire in their own instances of components  
for IDE use.

On 20-Mar-08, at 2:53 AM, Anton Makeev wrote:

> Hi,
>
> Could anyone help me on the following issue?
> I have a library that uses the plexus container (namely, Maven2) and  
> I want to configure it with my own component implementation.
> Moreover I need to pass some arbitrary parameters to my  
> implementation, that are known and available in the place of  
> configuration only.
>
> How can I do this?
> I skimmed through PlexusContainer and ComponentDescriptor interfaces  
> but didn't find anythig suitable - all the methods (i.e  
> setImplementation) accepts String as parameters.
>
> Thanks beforehand,
> Anton Makeev

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------

believe nothing, no matter where you read it,
or who has said it,
not even if i have said it,
unless it agrees with your own reason
and your own common sense.

-- Buddha




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Adding a component implementation programmatically

by Anton Makeev :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for your answer.
Let me accurate the question, though.

I have the PlexusContainer instance (taken via ContainerCustomizer) and want to change an ArifactResolver implementation.
I have to pass some specific information to the instance of my implementation.
Having the following code:

new ContainerCustomizer() {
  public void customize(PlexusContainer c) {
    ComponentRequirement r = new ComponentRequirement();
    ComponentDescriptor resolverDescriptor = c.getComponentDescriptor(ArtifactResolver.ROLE);

    // not only do I want to set the implementation class, but also to pass the parameter
    resolverDescriptor.setImplementation(ProjectArtifactResolver.class.getName());
  }
}

I need something like
resolverDescriptor.setImplementation(new ProjectArtifactResolver(myParameters));

Is that possible?

Thanks,
Anton Makeev

On 3/20/08, Jason van Zyl <jason@...> wrote:
For Maven specifically you should look at the netbeans integration,
and the eclipse integration. Both use the ContainerCustomizer in the
Maven Embedder package to wire in their own instances of components
for IDE use.


On 20-Mar-08, at 2:53 AM, Anton Makeev wrote:

> Hi,
>
> Could anyone help me on the following issue?
> I have a library that uses the plexus container (namely, Maven2) and
> I want to configure it with my own component implementation.
> Moreover I need to pass some arbitrary parameters to my
> implementation, that are known and available in the place of
> configuration only.
>
> How can I do this?
> I skimmed through PlexusContainer and ComponentDescriptor interfaces
> but didn't find anythig suitable - all the methods (i.e
> setImplementation) accepts String as parameters.
>
> Thanks beforehand,
> Anton Makeev


Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------

believe nothing, no matter where you read it,
or who has said it,
not even if i have said it,
unless it agrees with your own reason
and your own common sense.

-- Buddha




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




Re: Adding a component implementation programmatically

by Jason van Zyl-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The artifact resolver is exactly what the two other IDE integrations  
do insofar as replacing components. So you'll have full examples  
looking at the Netbeans or Eclipse integration. Replacing the artifact  
resolver is, in fact, possible.

On 21-Mar-08, at 1:48 AM, Anton Makeev wrote:

> Thanks for your answer.
> Let me accurate the question, though.
>
> I have the PlexusContainer instance (taken via ContainerCustomizer)  
> and want to change an ArifactResolver implementation.
> I have to pass some specific information to the instance of my  
> implementation.
> Having the following code:
>
> new ContainerCustomizer() {
>   public void customize(PlexusContainer c) {
>     ComponentRequirement r = new ComponentRequirement();
>     ComponentDescriptor resolverDescriptor =  
> c.getComponentDescriptor(ArtifactResolver.ROLE);
>
>     // not only do I want to set the implementation class, but also  
> to pass the parameter
>      
> resolverDescriptor
> .setImplementation(ProjectArtifactResolver.class.getName());
>   }
> }
>
> I need something like
> resolverDescriptor.setImplementation(new  
> ProjectArtifactResolver(myParameters));
>
> Is that possible?
>
> Thanks,
> Anton Makeev
>
> On 3/20/08, Jason van Zyl <jason@...> wrote: For Maven  
> specifically you should look at the netbeans integration,
> and the eclipse integration. Both use the ContainerCustomizer in the
> Maven Embedder package to wire in their own instances of components
> for IDE use.
>
>
> On 20-Mar-08, at 2:53 AM, Anton Makeev wrote:
>
> > Hi,
> >
> > Could anyone help me on the following issue?
> > I have a library that uses the plexus container (namely, Maven2) and
> > I want to configure it with my own component implementation.
> > Moreover I need to pass some arbitrary parameters to my
> > implementation, that are known and available in the place of
> > configuration only.
> >
> > How can I do this?
> > I skimmed through PlexusContainer and ComponentDescriptor interfaces
> > but didn't find anythig suitable - all the methods (i.e
> > setImplementation) accepts String as parameters.
> >
> > Thanks beforehand,
> > Anton Makeev
>
>
> Thanks,
>
> Jason
>
> ----------------------------------------------------------
> Jason van Zyl
> Founder,  Apache Maven
> jason at sonatype dot com
> ----------------------------------------------------------
>
> believe nothing, no matter where you read it,
> or who has said it,
> not even if i have said it,
> unless it agrees with your own reason
> and your own common sense.
>
> -- Buddha
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------

believe nothing, no matter where you read it,
or who has said it,
not even if i have said it,
unless it agrees with your own reason
and your own common sense.

-- Buddha




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Adding a component implementation programmatically

by Anton Makeev :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Probably I don't quite understand your point.

The question is not whether I can replace ArtifactResolver. What I need is to pass a parameter to my implementation of ArtifactResolver.

I, apparently, can pass the paramater somehow - for example by retrieving and casting the artifact resolver from the container after creation of the MavenEmbedder - but is is not a good way, I reckon.

I have examined both eclipse and netbeans before asking the question - they do not pass any parameters to components.
These are the extracts:

//netbeans
new ContainerCustomizer() {
public void customize(PlexusContainer plexusContainer) {
  ComponentDescriptor desc = new ComponentDescriptor();
  desc.setRole(TransferListener.class.getName());
  plexusContainer.addComponentDescriptor(desc);
  desc.setImplementation("org.codehaus.mevenide.netbeans.embedder.exec.ProgressTransferListener"); //NOI18N
  desc = plexusContainer.getComponentDescriptor(WagonManager.ROLE);
  ComponentRequirement requirement = new ComponentRequirement();
  requirement.setRole(TransferListener.class.getName());
  desc.addRequirement(requirement);
}
}

//eclipse
new ContainerCustomizer() {
public void customize(PlexusContainer container) {
  ComponentDescriptor resolverDescriptor = container.getComponentDescriptor(ArtifactResolver.ROLE);
  resolverDescriptor.setImplementation(EclipseArtifactResolver.class.getName());
}
}

Thanks,

On 3/21/08, Jason van Zyl <jason@...> wrote:
The artifact resolver is exactly what the two other IDE integrations
do insofar as replacing components. So you'll have full examples
looking at the Netbeans or Eclipse integration. Replacing the artifact
resolver is, in fact, possible.


On 21-Mar-08, at 1:48 AM, Anton Makeev wrote:

> Thanks for your answer.
> Let me accurate the question, though.
>
> I have the PlexusContainer instance (taken via ContainerCustomizer)
> and want to change an ArifactResolver implementation.
> I have to pass some specific information to the instance of my
> implementation.
> Having the following code:
>
> new ContainerCustomizer() {
>   public void customize(PlexusContainer c) {
>     ComponentRequirement r = new ComponentRequirement();
>     ComponentDescriptor resolverDescriptor =
> c.getComponentDescriptor(ArtifactResolver.ROLE);
>
>     // not only do I want to set the implementation class, but also
> to pass the parameter
>
> resolverDescriptor
> .setImplementation(ProjectArtifactResolver.class.getName());
>   }
> }
>
> I need something like
> resolverDescriptor.setImplementation(new
> ProjectArtifactResolver(myParameters));
>
> Is that possible?
>
> Thanks,
> Anton Makeev
>
> On 3/20/08, Jason van Zyl <jason@...> wrote: For Maven
> specifically you should look at the netbeans integration,
> and the eclipse integration. Both use the ContainerCustomizer in the
> Maven Embedder package to wire in their own instances of components
> for IDE use.
>
>
> On 20-Mar-08, at 2:53 AM, Anton Makeev wrote:
>
> > Hi,
> >
> > Could anyone help me on the following issue?
> > I have a library that uses the plexus container (namely, Maven2) and
> > I want to configure it with my own component implementation.
> > Moreover I need to pass some arbitrary parameters to my
> > implementation, that are known and available in the place of
> > configuration only.
> >
> > How can I do this?
> > I skimmed through PlexusContainer and ComponentDescriptor interfaces
> > but didn't find anythig suitable - all the methods (i.e
> > setImplementation) accepts String as parameters.
> >
> > Thanks beforehand,
> > Anton Makeev
>
>
> Thanks,
>
> Jason
>
> ----------------------------------------------------------
> Jason van Zyl
> Founder,  Apache Maven
> jason at sonatype dot com
> ----------------------------------------------------------
>
> believe nothing, no matter where you read it,
> or who has said it,
> not even if i have said it,
> unless it agrees with your own reason
> and your own common sense.
>
> -- Buddha
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------

believe nothing, no matter where you read it,
or who has said it,
not even if i have said it,
unless it agrees with your own reason
and your own common sense.

-- Buddha




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




Re: Adding a component implementation programmatically

by Jason van Zyl-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 21-Mar-08, at 7:28 AM, Anton Makeev wrote:

> Probably I don't quite understand your point.
>
> The question is not whether I can replace ArtifactResolver. What I  
> need is to pass a parameter to my implementation of ArtifactResolver.
>

What parameter do you need to pass in? This is just more curiosity as  
Milos and Eugene don't do that.

It might also be good to talk with Eugene and Milos as you guys are  
reproducing almost exactly the same things. All of you need some form  
of workspace resolution, a better event mechanism and graceful  
failover. I would definitely not like to see three sets of different  
behaviors in each of the IDEs as that would be completely confusing to  
Maven users.

I will make you an example of adding a configuration to a component  
descriptor. The configuration is then applied to the component when  
you look it up.

> I, apparently, can pass the paramater somehow - for example by  
> retrieving and casting the artifact resolver from the container  
> after creation of the MavenEmbedder - but is is not a good way, I  
> reckon.
>
> I have examined both eclipse and netbeans before asking the question  
> - they do not pass any parameters to components.
> These are the extracts:
>
> //netbeans
> new ContainerCustomizer() {
> public void customize(PlexusContainer plexusContainer) {
>   ComponentDescriptor desc = new ComponentDescriptor();
>   desc.setRole(TransferListener.class.getName());
>   plexusContainer.addComponentDescriptor(desc);
>    
> desc
> .setImplementation
> ("org
> .codehaus
> .mevenide.netbeans.embedder.exec.ProgressTransferListener"); //NOI18N
>   desc = plexusContainer.getComponentDescriptor(WagonManager.ROLE);
>   ComponentRequirement requirement = new ComponentRequirement();
>   requirement.setRole(TransferListener.class.getName());
>   desc.addRequirement(requirement);
> }
> }
>
> //eclipse
> new ContainerCustomizer() {
> public void customize(PlexusContainer container) {
>   ComponentDescriptor resolverDescriptor =  
> container.getComponentDescriptor(ArtifactResolver.ROLE);
>    
> resolverDescriptor
> .setImplementation(EclipseArtifactResolver.class.getName());
> }
> }
>
> Thanks,
>
> On 3/21/08, Jason van Zyl <jason@...> wrote: The artifact  
> resolver is exactly what the two other IDE integrations
> do insofar as replacing components. So you'll have full examples
> looking at the Netbeans or Eclipse integration. Replacing the artifact
> resolver is, in fact, possible.
>
>
> On 21-Mar-08, at 1:48 AM, Anton Makeev wrote:
>
> > Thanks for your answer.
> > Let me accurate the question, though.
> >
> > I have the PlexusContainer instance (taken via ContainerCustomizer)
> > and want to change an ArifactResolver implementation.
> > I have to pass some specific information to the instance of my
> > implementation.
> > Having the following code:
> >
> > new ContainerCustomizer() {
> >   public void customize(PlexusContainer c) {
> >     ComponentRequirement r = new ComponentRequirement();
> >     ComponentDescriptor resolverDescriptor =
> > c.getComponentDescriptor(ArtifactResolver.ROLE);
> >
> >     // not only do I want to set the implementation class, but also
> > to pass the parameter
> >
> > resolverDescriptor
> > .setImplementation(ProjectArtifactResolver.class.getName());
> >   }
> > }
> >
> > I need something like
> > resolverDescriptor.setImplementation(new
> > ProjectArtifactResolver(myParameters));
> >
> > Is that possible?
> >
> > Thanks,
> > Anton Makeev
> >
> > On 3/20/08, Jason van Zyl <jason@...> wrote: For Maven
> > specifically you should look at the netbeans integration,
> > and the eclipse integration. Both use the ContainerCustomizer in the
> > Maven Embedder package to wire in their own instances of components
> > for IDE use.
> >
> >
> > On 20-Mar-08, at 2:53 AM, Anton Makeev wrote:
> >
> > > Hi,
> > >
> > > Could anyone help me on the following issue?
> > > I have a library that uses the plexus container (namely, Maven2)  
> and
> > > I want to configure it with my own component implementation.
> > > Moreover I need to pass some arbitrary parameters to my
> > > implementation, that are known and available in the place of
> > > configuration only.
> > >
> > > How can I do this?
> > > I skimmed through PlexusContainer and ComponentDescriptor  
> interfaces
> > > but didn't find anythig suitable - all the methods (i.e
> > > setImplementation) accepts String as parameters.
> > >
> > > Thanks beforehand,
> > > Anton Makeev
> >
> >
> > Thanks,
> >
> > Jason
> >
> > ----------------------------------------------------------
> > Jason van Zyl
> > Founder,  Apache Maven
> > jason at sonatype dot com
> > ----------------------------------------------------------
> >
> > believe nothing, no matter where you read it,
> > or who has said it,
> > not even if i have said it,
> > unless it agrees with your own reason
> > and your own common sense.
> >
> > -- Buddha
> >
> >
> >
> >
> >  
> ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
> >
>
> Thanks,
>
> Jason
>
> ----------------------------------------------------------
> Jason van Zyl
> Founder,  Apache Maven
> jason at sonatype dot com
> ----------------------------------------------------------
>
> believe nothing, no matter where you read it,
> or who has said it,
> not even if i have said it,
> unless it agrees with your own reason
> and your own common sense.
>
> -- Buddha
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------

Simplex sigillum veri. (Simplicity is the seal of truth.)




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Adding a component implementation programmatically

by Anton Makeev :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

They probably do not need to pass any parameters since these IDEs have a one-workspace model.
IDEA has a notion of multiple open project (multi-workspace). Therefore the particular resolver should know about the particular project (workspace) in order to resolve dependencies - I can not use static name space.

On 3/21/08, Jason van Zyl <jason@...> wrote:

On 21-Mar-08, at 7:28 AM, Anton Makeev wrote:

> Probably I don't quite understand your point.
>
> The question is not whether I can replace ArtifactResolver. What I
> need is to pass a parameter to my implementation of ArtifactResolver.
>


What parameter do you need to pass in? This is just more curiosity as
Milos and Eugene don't do that.

It might also be good to talk with Eugene and Milos as you guys are
reproducing almost exactly the same things. All of you need some form
of workspace resolution, a better event mechanism and graceful
failover. I would definitely not like to see three sets of different
behaviors in each of the IDEs as that would be completely confusing to
Maven users.

I will make you an example of adding a configuration to a component
descriptor. The configuration is then applied to the component when
you look it up.


> I, apparently, can pass the paramater somehow - for example by
> retrieving and casting the artifact resolver from the container
> after creation of the MavenEmbedder - but is is not a good way, I
> reckon.
>
> I have examined both eclipse and netbeans before asking the question
> - they do not pass any parameters to components.
> These are the extracts:
>
> //netbeans
> new ContainerCustomizer() {
> public void customize(PlexusContainer plexusContainer) {
>   ComponentDescriptor desc = new ComponentDescriptor();
>   desc.setRole(TransferListener.class.getName());
>   plexusContainer.addComponentDescriptor(desc);
>
> desc
> .setImplementation
> ("org
> .codehaus
> .mevenide.netbeans.embedder.exec.ProgressTransferListener"); //NOI18N
>   desc = plexusContainer.getComponentDescriptor(WagonManager.ROLE);
>   ComponentRequirement requirement = new ComponentRequirement();
>   requirement.setRole(TransferListener.class.getName());
>   desc.addRequirement(requirement);
> }
> }
>
> //eclipse
> new ContainerCustomizer() {
> public void customize(PlexusContainer container) {
>   ComponentDescriptor resolverDescriptor =
> container.getComponentDescriptor(ArtifactResolver.ROLE);
>
> resolverDescriptor
> .setImplementation(EclipseArtifactResolver.class.getName());
> }
> }
>
> Thanks,
>
> On 3/21/08, Jason van Zyl <jason@...> wrote: The artifact
> resolver is exactly what the two other IDE integrations
> do insofar as replacing components. So you'll have full examples
> looking at the Netbeans or Eclipse integration. Replacing the artifact
> resolver is, in fact, possible.
>
>
> On 21-Mar-08, at 1:48 AM, Anton Makeev wrote:
>
> > Thanks for your answer.
> > Let me accurate the question, though.
> >
> > I have the PlexusContainer instance (taken via ContainerCustomizer)
> > and want to change an ArifactResolver implementation.
> > I have to pass some specific information to the instance of my
> > implementation.
> > Having the following code:
> >
> > new ContainerCustomizer() {
> >   public void customize(PlexusContainer c) {
> >     ComponentRequirement r = new ComponentRequirement();
> >     ComponentDescriptor resolverDescriptor =
> > c.getComponentDescriptor(ArtifactResolver.ROLE);
> >
> >     // not only do I want to set the implementation class, but also
> > to pass the parameter
> >
> > resolverDescriptor
> > .setImplementation(ProjectArtifactResolver.class.getName());
> >   }
> > }
> >
> > I need something like
> > resolverDescriptor.setImplementation(new
> > ProjectArtifactResolver(myParameters));
> >
> > Is that possible?
> >
> > Thanks,
> > Anton Makeev
> >
> > On 3/20/08, Jason van Zyl <jason@...> wrote: For Maven
> > specifically you should look at the netbeans integration,
> > and the eclipse integration. Both use the ContainerCustomizer in the
> > Maven Embedder package to wire in their own instances of components
> > for IDE use.
> >
> >
> > On 20-Mar-08, at 2:53 AM, Anton Makeev wrote:
> >
> > > Hi,
> > >
> > > Could anyone help me on the following issue?
> > > I have a library that uses the plexus container (namely, Maven2)
> and
> > > I want to configure it with my own component implementation.
> > > Moreover I need to pass some arbitrary parameters to my
> > > implementation, that are known and available in the place of
> > > configuration only.
> > >
> > > How can I do this?
> > > I skimmed through PlexusContainer and ComponentDescriptor
> interfaces
> > > but didn't find anythig suitable - all the methods (i.e
> > > setImplementation) accepts String as parameters.
> > >
> > > Thanks beforehand,
> > > Anton Makeev
> >
> >
> > Thanks,
> >
> > Jason
> >
> > ----------------------------------------------------------
> > Jason van Zyl
> > Founder,  Apache Maven
> > jason at sonatype dot com
> > ----------------------------------------------------------
> >
> > believe nothing, no matter where you read it,
> > or who has said it,
> > not even if i have said it,
> > unless it agrees with your own reason
> > and your own common sense.
> >
> > -- Buddha
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
> >
>
> Thanks,
>
> Jason
>
> ----------------------------------------------------------
> Jason van Zyl
> Founder,  Apache Maven
> jason at sonatype dot com
> ----------------------------------------------------------
>
> believe nothing, no matter where you read it,
> or who has said it,
> not even if i have said it,
> unless it agrees with your own reason
> and your own common sense.
>
> -- Buddha
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------


Simplex sigillum veri. (Simplicity is the seal of truth.)





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email