Pico 2.4 Collections....

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

Pico 2.4 Collections....

by Michael Rimov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

Ok, so 2.4 had a lot of collection work done.  Wonderful :)


But.... uhhh... how do you handle the backwards compatible case of:

--------------------------------------------------------------------------------
----
The Model:
--------------------------------------------------------------------------------
----

class Something {
        List<String> searchPath;

        public Something(List<String> searchPath) {
                /* Assignments here */
        }
       
        //Example usage.  Only shows why this kind of thing is required.
        public String locateExecutable(String binaryName) {
                //Searches search path
                for (String eachPath : searchPath) {
                        //Search and return routine.
                }
        }
}

--------------------------------------------------------------------------------
----
The Assembly:
--------------------------------------------------------------------------------
----

List<String> searchPath = new ArrayList<String>();
searchPath.add("/usr/bin");
seachPath.add("/usr/local/bin");
/* And so on */

/* Assemble via Pico */
MutablePicoContainer mpc = new
PicoBuilder().withCaching().withLifecycle().build();
mpc.addComponent("SearchPath", searchPath);
mpc.addComponent(Something.class, Something.class, new
ComponentParameter("SearchPath");

Something searcher = mpc.getComponent(Something.class);

//Example usage.  Only shows why this kind of thing is required.
searcher.locatExecutable("ls");


I was integrating Pico 2.4 throughout my libraries.  (Last time I did it was
right before Pico-Script release), and hit this wall in a couple of my
libraries.

Thanks,
                                                                        -Mike

P.S Note, I tried:
mpc.addComponent(Something.class, Something.class, new
ConstantParameter(mpc.getComponent("SearchPath"));

But not only is it ugly, my container was still throwing Unsatisfiable
dependencies.





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

    http://xircles.codehaus.org/manage_email



Re: Pico 2.4 Collections....

by Paul Hammant-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mike,

Could you not do the following ?

    mpc.addComponent(Something.class);

The impl that will go out in Pico 2.5 is supposed to collect suitable  
types and inject them without specifying parameters manually.

If I'm missing something, can you help with a failing testcase ?

Regards,

- Paul

On Jul 15, 2008, at 7:07 AM, Michael Rimov wrote:

> Hi All,
>
> Ok, so 2.4 had a lot of collection work done.  Wonderful :)
>
>
> But.... uhhh... how do you handle the backwards compatible case of:
>
> --------------------------------------------------------------------------------
> ----
> The Model:
> --------------------------------------------------------------------------------
> ----
>
> class Something {
> List<String> searchPath;
>
> public Something(List<String> searchPath) {
> /* Assignments here */
> }
>
> //Example usage.  Only shows why this kind of thing is required.
> public String locateExecutable(String binaryName) {
> //Searches search path
> for (String eachPath : searchPath) {
> //Search and return routine.
> }
> }
> }
>
> --------------------------------------------------------------------------------
> ----
> The Assembly:
> --------------------------------------------------------------------------------
> ----
>
> List<String> searchPath = new ArrayList<String>();
> searchPath.add("/usr/bin");
> seachPath.add("/usr/local/bin");
> /* And so on */
>
> /* Assemble via Pico */
> MutablePicoContainer mpc = new
> PicoBuilder().withCaching().withLifecycle().build();
> mpc.addComponent("SearchPath", searchPath);
> mpc.addComponent(Something.class, Something.class, new
> ComponentParameter("SearchPath");
>
> Something searcher = mpc.getComponent(Something.class);
>
> //Example usage.  Only shows why this kind of thing is required.
> searcher.locatExecutable("ls");
>
>
> I was integrating Pico 2.4 throughout my libraries.  (Last time I  
> did it was
> right before Pico-Script release), and hit this wall in a couple of my
> libraries.
>
> Thanks,
> -Mike
>
> P.S Note, I tried:
> mpc.addComponent(Something.class, Something.class, new
> ConstantParameter(mpc.getComponent("SearchPath"));
>
> But not only is it ugly, my container was still throwing Unsatisfiable
> dependencies.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


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

    http://xircles.codehaus.org/manage_email



RE: Pico 2.4 Collections....

by Michael Rimov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Mike,
>
> Could you not do the following ?
>
>     mpc.addComponent(Something.class);

Tried what you suggested no go.

>
> The impl that will go out in Pico 2.5 is supposed to collect suitable
> types and inject them without specifying parameters manually.
>
> If I'm missing something, can you help with a failing testcase ?

Test case here:

http://jira.codehaus.org/browse/PICO-322

Thanks for looking at it,
       
-Mike


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

    http://xircles.codehaus.org/manage_email


LightInTheBox - Buy quality products at wholesale price