hivemind-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Achim Hügen <achim.hue...@gmx.de>
Subject Re: Working with classes
Date Sun, 04 Dec 2005 10:34:43 GMT
I assume that the map access doesn't work because
it uses different keys for storing and retrieval.
Hivemind doesn't hand in instances of the Apple and Banana
class in the constructor, but proxies that are descendants of
the original classes.
That means, that apple.getClass() is not equivalant to Apple.class.

Try to verify this by adding a

System.out.println(apple.getClass().getName()) to the constructor.

and solve it by using:

bowl.put(Apple.class, apple);
bowl.put(Banana.class, banana);


Hope this helps
Achim


Am Sun, 04 Dec 2005 10:47:57 +0100 schrieb Massimo Lusetti  
<mlusetti@gmail.com>:

> How should DI from hivemind work when dealing with classes and not
> interfaces for service point?
>
> I've to work with classes so refactoring is not an option.
>
> I got a FruitBowl class which has this constructors:
>    public FruitBowl()
>     {
>     }
>
>     public FruitBowl(Fruit fruit[])
>     {
>         for (int i = 0; i < fruit.length; i++) {
>             bowl.put(fruit[i].getClass(), fruit[i]);
>         }
>     }
>
>     public FruitBowl(Apple apple, Banana banana)
>     {
>         bowl.put(apple.getClass(), apple);
>         bowl.put(banana.getClass(), banana);
>     }
>
> And this getters/setters methods:
>    public boolean hasApple()
>     {
>         return bowl.get(Apple.class) != null;
>     }
>
>     public boolean hasBanana()
>     {
>         return bowl.get(Banana.class) != null;
>     }
>
>     public Apple getApple()
>     {
>         return (Apple) bowl.get(Apple.class);
>     }
>
>     public void setApple(Apple apple)
>     {
>         bowl.put(apple.getClass(), apple);
>     }
>
>     public Banana getBanana()
>     {
>         return (Banana) bowl.get(Banana.class);
>     }
>
>     public void setBanana(Banana banana)
>     {
>         bowl.put(banana.getClass(), banana);
>     }
>
>
> Have Apple and Banana classes without a constructor and a hivemodule  
> like this:
> <module id="tck" version="1.0.0" package="org.mule.tck.testmodels.fruit">
>     <service-point id="Apple" interface="Apple">
>      <invoke-factory>
>       <construct class="Apple"/>
>      </invoke-factory>
>     </service-point>
>     <service-point id="Banana" interface="Banana">
>      <invoke-factory>
>       <construct class="Banana"/>
>      </invoke-factory>
>     </service-point>
>     <service-point id="FruitBowl" interface="FruitBowl">
>       <invoke-factory>
>         <construct class="FruitBowl">
>          <service>Apple</service>
>          <service>Banana</service>
>         </construct>
>       </invoke-factory>
>     </service-point>
> </module>
>
> I've already tried different ways of injecting deps like construct
> based with service and object nested element of <construct> without
> any luck
>
> As you can see this is a test case to make pass the Mule ESB test
> suite to add support for HiveMind container context (to use HiveMind
> services within Mule descriptors)
> Inside the test it fails when assertTrue(fruitBowl.hasApple()).
>
> The code is there, just need help to pass this test.
>
> Regards
> --
> Massimo
> http://meridio.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Mime
View raw message