Re: Using constructors with arguments

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

Re: Using constructors with arguments

by Niall Gallagher-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

With release 2.1 constructor injection is now supported. Examples of constructor injection can be found in the test cases as well as the tutorial.

http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#immutable

Regards,
Niall

--- On Tue, 1/20/09, Kevin Day <kevin@...> wrote:

> From: Kevin Day <kevin@...>
> Subject: [Simple-support] Using constructors with arguments
> To: "Simple" <simple-support@...>
> Date: Tuesday, January 20, 2009, 4:28 PM
>
>
> #yiv386076557 P, #yiv386076557 UL,
> #yiv386076557 OL, #yiv386076557 DL, #yiv386076557 DIR,
> #yiv386076557 MENU, #yiv386076557 PRE {margin:0
> auto;}
>
>  
>
> For starters, I really like what I see in this
> project (just started reviewing it this afternoon). 
> I'm hoping that I can get some pointers on a specific
> use-case.
>  
>  
> I would like to use Simple in conjunction with a
> dependency injection system (probably Guice) and List
> implementations from the GlazedLists project.
>  
> We have to use a constructor on our list
> implementations that contains arguments (some of the
> arguments provided by Guice, some from element or attribute
> data in the XML).
>  
> What is the best way to approach this with
> Simple?
>  
>
> It seems that some sort of Strategy mixed with a
> custom Type is in order, but I'm not entirely clear on
> the best approach.  The architecture of the framework
> looks powerful enough to do what we need, but
> I can't see where to get started just yet.
>  
>  
> To give a pseudo-code example of what we are trying to
> do (in real life, we'll be injecting SomeInjectedObject
> using Guice or a factory/service provider call):
>  
> class SpecialList<E>{
>   public SpecialList(SomeInjectedObject injected,
> String valueFromAttribute, SomeObject
> valueFromElement){
>   ...
>   }
> }
>  
>  
> class MyObject{
>
>   @ElementList
>   SpecialList<ElementObject> list = new
> SpecialList<ElementObject>(SomeInjectedObject.defaultInstance,
> "test", new SomeObject());
>  
> }
>  
>  
> When we serialize this with Simple, we'd like to
> see something approximately like the following:
>  
> <myObject
> valueFromAttribute="test">
>
>   <someObject> ...
> </someObject>  <list>
>     <elementObject> ... whatever
> goes into this ... </elementObject>
>
>     <elementObject> ... whatever
> goes into this ... </elementObject>
>     ...  </list>
> </myObject>
>  
>  
> Note that:
>  
> 1.  The <list> element doesn't have a
> class attribute
> 2.  When we construct the list during
> deserialization, we need to be able to pull the
> 'valueFromAttribute' and 'someObject' values
> to use during construction of the SpecialList object
> 3.  The SpecialList object needs to have the 3
> argument constructor called (not a zero-arg
> constructor).  And it is not possible to call a zero
> arg constructor, then modify the object afterwards to get
> the same result.
>  
>  
> Any pointers?  I may be pushing the framework too
> hard (some of the above requirements can be relaxed - if it
> isn't possible to obtain valueFromAttribute or
> someObject at construction time, we can find workarounds -
> but we have to be able to create the SpecialList instance
> using values from a factory/Guice/etc...).  For what
> it's worth, we have this type of behavior working in
> Betwixt using custom BeanCreator implementations.
>  
> Thanks much,
>  
> - Kevin
>
>
> -----Inline Attachment Follows-----
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Simple-support@...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>


     

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

Re: Using constructors with arguments

by Quirino Zagarese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Niall,
this is a great feature! Simple is used in my framework, you can see it at http://eu4ria.googlecode.com
Anyway I have to use version 1.7.3 cause I'm still facing with the well known issue concerning J2EE classloading.
Right now I'm studying Tomcat source-code to understand where are annotations processed.
I'll keep you informed.
Bests

2009/7/12 Niall Gallagher <gallagher_niall@...>

Hi,

With release 2.1 constructor injection is now supported. Examples of constructor injection can be found in the test cases as well as the tutorial.

http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#immutable

Regards,
Niall

--- On Tue, 1/20/09, Kevin Day <kevin@...> wrote:

> From: Kevin Day <kevin@...>
> Subject: [Simple-support] Using constructors with arguments
> To: "Simple" <simple-support@...>
> Date: Tuesday, January 20, 2009, 4:28 PM
>
>
> #yiv386076557 P, #yiv386076557 UL,
> #yiv386076557 OL, #yiv386076557 DL, #yiv386076557 DIR,
> #yiv386076557 MENU, #yiv386076557 PRE {margin:0
> auto;}
>
>
>
> For starters, I really like what I see in this
> project (just started reviewing it this afternoon). 
> I'm hoping that I can get some pointers on a specific
> use-case.
>  
>  
> I would like to use Simple in conjunction with a
> dependency injection system (probably Guice) and List
> implementations from the GlazedLists project.
>  
> We have to use a constructor on our list
> implementations that contains arguments (some of the
> arguments provided by Guice, some from element or attribute
> data in the XML).
>  
> What is the best way to approach this with
> Simple?
>  
>
> It seems that some sort of Strategy mixed with a
> custom Type is in order, but I'm not entirely clear on
> the best approach.  The architecture of the framework
> looks powerful enough to do what we need, but
> I can't see where to get started just yet.
>  
>  
> To give a pseudo-code example of what we are trying to
> do (in real life, we'll be injecting SomeInjectedObject
> using Guice or a factory/service provider call):
>  
> class SpecialList<E>{
>   public SpecialList(SomeInjectedObject injected,
> String valueFromAttribute, SomeObject
> valueFromElement){
>   ...
>   }
> }
>  
>  
> class MyObject{
>
>   @ElementList
>   SpecialList<ElementObject> list = new
> SpecialList<ElementObject>(SomeInjectedObject.defaultInstance,
> "test", new SomeObject());
>  
> }
>  
>  
> When we serialize this with Simple, we'd like to
> see something approximately like the following:
>  
> <myObject
> valueFromAttribute="test">
>
>   <someObject> ...
> </someObject>  <list>
>     <elementObject> ... whatever
> goes into this ... </elementObject>
>
>     <elementObject> ... whatever
> goes into this ... </elementObject>
>     ...  </list>
> </myObject>
>  
>  
> Note that:
>  
> 1.  The <list> element doesn't have a
> class attribute
> 2.  When we construct the list during
> deserialization, we need to be able to pull the
> 'valueFromAttribute' and 'someObject' values
> to use during construction of the SpecialList object
> 3.  The SpecialList object needs to have the 3
> argument constructor called (not a zero-arg
> constructor).  And it is not possible to call a zero
> arg constructor, then modify the object afterwards to get
> the same result.
>  
>  
> Any pointers?  I may be pushing the framework too
> hard (some of the above requirements can be relaxed - if it
> isn't possible to obtain valueFromAttribute or
> someObject at construction time, we can find workarounds -
> but we have to be able to create the SpecialList instance
> using values from a factory/Guice/etc...).  For what
> it's worth, we have this type of behavior working in
> Betwixt using custom BeanCreator implementations.
>  
> Thanks much,
>  
> - Kevin
>
>
> -----Inline Attachment Follows-----
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Simple-support@...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>




------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support



--
Quirino Zagarese

Italian OpenLaszlo Community  - www.laszloitalia.org



------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support