Re: Using plexus to inject custom objects (and inject their parameters)?

2006-09-04 Thread Jason van Zyl


On 3 Sep 06, at 9:46 PM 3 Sep 06, Jason Dillon wrote:

Thanks, but I can wait until this is rolled up into a release.  I  
think having this will really make it easier to create more  
powerful mojos... and to share commonly used configuration and  
logic objects w/o needing to sub-class.




Yes, it would be generally useful for plexus components in general.


--jason


On Sep 3, 2006, at 6:12 PM, Jason van Zyl wrote:



On 3 Sep 06, at 8:57 PM 3 Sep 06, Jason Dillon wrote:

Hi, I asked about this in #maven a while ago, but I forgot what  
the answer was.


How can I configure plexus to inject custom objects into my mojo,  
and have plexus inject parameters into that object?


For example, say I have:


public class ConntectionConfig
{
/**
 * The port number to connect to the server..
 *
 * @parameter expression="${port}" default-value="1099"
 */
public int port = -1;

/**
 * The username to authenticate with.
 *
 * @parameter expression="${username}" default-value="system"
 */
public String username = null;

/**
 * The password to authenticate with.
 *
 * @parameter expression="${password}" default-value="manager"
 */
public String password = null;
}


And a mojo like:


/**
 * @goal test
 */
public class TestMojo
 extends ...
{
/**
 * Connection configuration
 *
 * @parameter
 */
protected ConntectionConfig connection = null;
}


I'd like to be able to:

mvn whatever:test -Dusername=foo

Which will create a new ConnectionConfig, inject username from $ 
{username} and then initialize the other fields to to their  
default-values.


I tried briefly, using @plexus.component for ConnectionConfig,  
and then @component for the connection parameter... but it did  
not inject anything into the ConnectionConfig object.  If I  
specify something like:




 foo



Then username does get set to foo, but the others are left as nulls.

I really need a better way to share configuration and logic among  
mojo's... inheritance is not cutting it, as some mojos end up  
with more than they really need, and I'm forced to create a bunch  
of intermediate abstract classes to organize which mojos need what.


Is this possible?  And if so, can someone point me at a simple  
example?




The configuration model for a mojo is not inspected for  
annotations what what you have above for the ConnectionConfig is  
not going to processed. I've added:


http://jira.codehaus.org/browse/PLX-266

As this would be generally useful. There are some issues related  
to the component descriptor creator (CDC) for default  
configuration values as well. So, short answer right now with  
2.0.4 it's not possible. If you're using trunk and you're  
desperate I can do something.



Thanks,

--jason

 
-

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Jason van Zyl
[EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Jason van Zyl
[EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using plexus to inject custom objects (and inject their parameters)?

2006-09-03 Thread Jason Dillon
Thanks, but I can wait until this is rolled up into a release.  I  
think having this will really make it easier to create more powerful  
mojos... and to share commonly used configuration and logic objects w/ 
o needing to sub-class.


--jason


On Sep 3, 2006, at 6:12 PM, Jason van Zyl wrote:



On 3 Sep 06, at 8:57 PM 3 Sep 06, Jason Dillon wrote:

Hi, I asked about this in #maven a while ago, but I forgot what  
the answer was.


How can I configure plexus to inject custom objects into my mojo,  
and have plexus inject parameters into that object?


For example, say I have:


public class ConntectionConfig
{
/**
 * The port number to connect to the server..
 *
 * @parameter expression="${port}" default-value="1099"
 */
public int port = -1;

/**
 * The username to authenticate with.
 *
 * @parameter expression="${username}" default-value="system"
 */
public String username = null;

/**
 * The password to authenticate with.
 *
 * @parameter expression="${password}" default-value="manager"
 */
public String password = null;
}


And a mojo like:


/**
 * @goal test
 */
public class TestMojo
 extends ...
{
/**
 * Connection configuration
 *
 * @parameter
 */
protected ConntectionConfig connection = null;
}


I'd like to be able to:

mvn whatever:test -Dusername=foo

Which will create a new ConnectionConfig, inject username from $ 
{username} and then initialize the other fields to to their  
default-values.


I tried briefly, using @plexus.component for ConnectionConfig, and  
then @component for the connection parameter... but it did not  
inject anything into the ConnectionConfig object.  If I specify  
something like:




 foo



Then username does get set to foo, but the others are left as nulls.

I really need a better way to share configuration and logic among  
mojo's... inheritance is not cutting it, as some mojos end up with  
more than they really need, and I'm forced to create a bunch of  
intermediate abstract classes to organize which mojos need what.


Is this possible?  And if so, can someone point me at a simple  
example?




The configuration model for a mojo is not inspected for annotations  
what what you have above for the ConnectionConfig is not going to  
processed. I've added:


http://jira.codehaus.org/browse/PLX-266

As this would be generally useful. There are some issues related to  
the component descriptor creator (CDC) for default configuration  
values as well. So, short answer right now with 2.0.4 it's not  
possible. If you're using trunk and you're desperate I can do  
something.



Thanks,

--jason

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Jason van Zyl
[EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using plexus to inject custom objects (and inject their parameters)?

2006-09-03 Thread Jason van Zyl


On 3 Sep 06, at 8:57 PM 3 Sep 06, Jason Dillon wrote:

Hi, I asked about this in #maven a while ago, but I forgot what the  
answer was.


How can I configure plexus to inject custom objects into my mojo,  
and have plexus inject parameters into that object?


For example, say I have:


public class ConntectionConfig
{
/**
 * The port number to connect to the server..
 *
 * @parameter expression="${port}" default-value="1099"
 */
public int port = -1;

/**
 * The username to authenticate with.
 *
 * @parameter expression="${username}" default-value="system"
 */
public String username = null;

/**
 * The password to authenticate with.
 *
 * @parameter expression="${password}" default-value="manager"
 */
public String password = null;
}


And a mojo like:


/**
 * @goal test
 */
public class TestMojo
 extends ...
{
/**
 * Connection configuration
 *
 * @parameter
 */
protected ConntectionConfig connection = null;
}


I'd like to be able to:

mvn whatever:test -Dusername=foo

Which will create a new ConnectionConfig, inject username from $ 
{username} and then initialize the other fields to to their default- 
values.


I tried briefly, using @plexus.component for ConnectionConfig, and  
then @component for the connection parameter... but it did not  
inject anything into the ConnectionConfig object.  If I specify  
something like:




 foo



Then username does get set to foo, but the others are left as nulls.

I really need a better way to share configuration and logic among  
mojo's... inheritance is not cutting it, as some mojos end up with  
more than they really need, and I'm forced to create a bunch of  
intermediate abstract classes to organize which mojos need what.


Is this possible?  And if so, can someone point me at a simple  
example?




The configuration model for a mojo is not inspected for annotations  
what what you have above for the ConnectionConfig is not going to  
processed. I've added:


http://jira.codehaus.org/browse/PLX-266

As this would be generally useful. There are some issues related to  
the component descriptor creator (CDC) for default configuration  
values as well. So, short answer right now with 2.0.4 it's not  
possible. If you're using trunk and you're desperate I can do something.



Thanks,

--jason

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Jason van Zyl
[EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Using plexus to inject custom objects (and inject their parameters)?

2006-09-03 Thread Jason Dillon
Hi, I asked about this in #maven a while ago, but I forgot what the  
answer was.


How can I configure plexus to inject custom objects into my mojo, and  
have plexus inject parameters into that object?


For example, say I have:


public class ConntectionConfig
{
/**
 * The port number to connect to the server..
 *
 * @parameter expression="${port}" default-value="1099"
 */
public int port = -1;

/**
 * The username to authenticate with.
 *
 * @parameter expression="${username}" default-value="system"
 */
public String username = null;

/**
 * The password to authenticate with.
 *
 * @parameter expression="${password}" default-value="manager"
 */
public String password = null;
}


And a mojo like:


/**
 * @goal test
 */
public class TestMojo
 extends ...
{
/**
 * Connection configuration
 *
 * @parameter
 */
protected ConntectionConfig connection = null;
}


I'd like to be able to:

mvn whatever:test -Dusername=foo

Which will create a new ConnectionConfig, inject username from $ 
{username} and then initialize the other fields to to their default- 
values.


I tried briefly, using @plexus.component for ConnectionConfig, and  
then @component for the connection parameter... but it did not inject  
anything into the ConnectionConfig object.  If I specify something like:




 foo



Then username does get set to foo, but the others are left as nulls.

I really need a better way to share configuration and logic among  
mojo's... inheritance is not cutting it, as some mojos end up with  
more than they really need, and I'm forced to create a bunch of  
intermediate abstract classes to organize which mojos need what.


Is this possible?  And if so, can someone point me at a simple example?

Thanks,

--jason

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]