You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jason Wang <ja...@bulletin.net> on 2009/07/28 01:55:39 UTC

will there be a performance gain to use singleton to remove references to the service object in models?

Hi all,

Although I am using spring-wicket to prevent the whole spring being 
serialized, It still brothers me to  see the  references in the model 
object, for example:

Instead of using this:

public class MyViewObjectProvider extends SortableDataProvider{
   
   @SpringBean("daoService")
     private  DAOServices daoService;

     private String objectID;

     public Iterator iterator(final int first, final int count){
          .....
       return daoService.load(objectId).subList(first, 
first+count).iterator();
    }

}



I always write a singleton helper class for the service to be used, so I 
can have the model this way:

public class MyViewObjectProvider extends SortableDataProvider{
   
   //so no reference to the dao service object

     private String objectID;
   
    public Iterator iterator(final int first, final int count){
          .....
    //here the DAOServiceHelper.get() returns a instance that managed by 
spring(with the actual service object injected.)
       return DAOServiceHelper.get().load(objectId).subList(first, 
first+count).iterator();
    }

   
}

So my question is, will there be a noticeable  performance gain to do it 
the 2nd way?
The reason to ask is that the static kind of singleton usage is indeed 
anti-spring, and makes
my eyes bleed....

If no one has done a performance comparison, I might have to do one 
myself. Just being lazzzzzy...


Thanks,

Jason Wang




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: will there be a performance gain to use singleton to remove references to the service object in models?

Posted by Marat Radchenko <sl...@gmail.com>.
Don't guess, profile it.

2009/7/28 Jason Wang <ja...@bulletin.net>:
> Hi all,
>
> Although I am using spring-wicket to prevent the whole spring being
> serialized, It still brothers me to  see the  references in the model
> object, for example:
>
> Instead of using this:
>
> public class MyViewObjectProvider extends SortableDataProvider{
>    @SpringBean("daoService")
>    private  DAOServices daoService;
>
>    private String objectID;
>
>    public Iterator iterator(final int first, final int count){
>         .....
>      return daoService.load(objectId).subList(first,
> first+count).iterator();
>   }
>
> }
>
>
>
> I always write a singleton helper class for the service to be used, so I can
> have the model this way:
>
> public class MyViewObjectProvider extends SortableDataProvider{
>    //so no reference to the dao service object
>
>    private String objectID;
>     public Iterator iterator(final int first, final int count){
>         .....
>   //here the DAOServiceHelper.get() returns a instance that managed by
> spring(with the actual service object injected.)
>      return DAOServiceHelper.get().load(objectId).subList(first,
> first+count).iterator();
>   }
>
>  }
>
> So my question is, will there be a noticeable  performance gain to do it the
> 2nd way?
> The reason to ask is that the static kind of singleton usage is indeed
> anti-spring, and makes
> my eyes bleed....
>
> If no one has done a performance comparison, I might have to do one myself.
> Just being lazzzzzy...
>
>
> Thanks,
>
> Jason Wang
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: will there be a performance gain to use singleton to remove references to the service object in models?

Posted by Wilko Hische <w....@dotmachine.nl>.
Hi Jason,

You could have a look at http://code.google.com/p/salve/
By making use of some byte code instrumentation it will replace your
dependency injections by static lookups, i.e. the best of both worlds. I
wouldn't know about the performance of each approach however.

Regards,

Wilko


Jason Wang-2 wrote:
> 
> Hi all,
> 
> Although I am using spring-wicket to prevent the whole spring being 
> serialized, It still brothers me to  see the  references in the model 
> object, for example:
> 
> Instead of using this:
> 
> public class MyViewObjectProvider extends SortableDataProvider{
>    
>    @SpringBean("daoService")
>      private  DAOServices daoService;
> 
>      private String objectID;
> 
>      public Iterator iterator(final int first, final int count){
>           .....
>        return daoService.load(objectId).subList(first, 
> first+count).iterator();
>     }
> 
> }
> 
> 
> 
> I always write a singleton helper class for the service to be used, so I 
> can have the model this way:
> 
> public class MyViewObjectProvider extends SortableDataProvider{
>    
>    //so no reference to the dao service object
> 
>      private String objectID;
>    
>     public Iterator iterator(final int first, final int count){
>           .....
>     //here the DAOServiceHelper.get() returns a instance that managed by 
> spring(with the actual service object injected.)
>        return DAOServiceHelper.get().load(objectId).subList(first, 
> first+count).iterator();
>     }
> 
>    
> }
> 
> So my question is, will there be a noticeable  performance gain to do it 
> the 2nd way?
> The reason to ask is that the static kind of singleton usage is indeed 
> anti-spring, and makes
> my eyes bleed....
> 
> If no one has done a performance comparison, I might have to do one 
> myself. Just being lazzzzzy...
> 
> 
> Thanks,
> 
> Jason Wang
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/will-there-be-a-performance-gain-to-use-singleton-to-remove-references-to-the-service-object-in-models--tp24690276p24694064.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: will there be a performance gain to use singleton to remove references to the service object in models?

Posted by Jason Wang <ja...@bulletin.net>.
Hi Martijin,

Thats a very good point. I definitely overlooked that risk before. Thank 
you for pointing it out!

Thanks,

Jason Wang

Martijn Dashorst wrote:
> There's the risk of keeping the retrieved service as a reference
> somewhere, e.g. by declaring it final and using it inside an anon
> inner class, negating any and all gains you've done by using the
> static lookup. The @SpringBean annotated references are safe to pass
> around (as they are implemented as proxies to your services)
>
> Martijn
>
> On Tue, Jul 28, 2009 at 9:50 AM, Eelco
> Hillenius<ee...@gmail.com> wrote:
>   
>> Actually, thinking about it, if you're very tight on memory, it will
>> save you a reference, particularly when the page gets serialized. So
>> if you are worrying about efficiency *and* are ok with this code
>> style, it's an option. :-)
>>
>> Eelco
>>
>> On Tue, Jul 28, 2009 at 12:47 AM, Eelco
>> Hillenius<ee...@gmail.com> wrote:
>>     
>>> It might give you a very slight edge to use a singleton as you (or the
>>> annotation processor in this case) don't have to introspect and work
>>> through a proxy. If you're not bothered by singletons (I, for one
>>> typically are): go for it. However, keep that famous 'premature
>>> optimization is the root of all evil' in mind; 99.9% chance you're
>>> optimizing something that will never ever become a bottleneck.
>>>
>>> Eelco
>>>
>>> 2009/7/27 Murat Yücel <ko...@gmail.com>:
>>>       
>>>> Hi Jason
>>>>
>>>> I dont have a performance comparison, but i cannot see why you should
>>>> gain better performance.
>>>> All spring beans are as default singleton, so you will just forward a
>>>> singleton using a singleton.
>>>>
>>>> /Murat
>>>>
>>>> 2009/7/28 Jason Wang <ja...@bulletin.net>:
>>>>         
>>>>> Hi all,
>>>>>
>>>>> Although I am using spring-wicket to prevent the whole spring being
>>>>> serialized, It still brothers me to  see the  references in the model
>>>>> object, for example:
>>>>>
>>>>> Instead of using this:
>>>>>
>>>>> public class MyViewObjectProvider extends SortableDataProvider{
>>>>>    @SpringBean("daoService")
>>>>>    private  DAOServices daoService;
>>>>>
>>>>>    private String objectID;
>>>>>
>>>>>    public Iterator iterator(final int first, final int count){
>>>>>         .....
>>>>>      return daoService.load(objectId).subList(first,
>>>>> first+count).iterator();
>>>>>   }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> I always write a singleton helper class for the service to be used, so I can
>>>>> have the model this way:
>>>>>
>>>>> public class MyViewObjectProvider extends SortableDataProvider{
>>>>>    //so no reference to the dao service object
>>>>>
>>>>>    private String objectID;
>>>>>     public Iterator iterator(final int first, final int count){
>>>>>         .....
>>>>>   //here the DAOServiceHelper.get() returns a instance that managed by
>>>>> spring(with the actual service object injected.)
>>>>>      return DAOServiceHelper.get().load(objectId).subList(first,
>>>>> first+count).iterator();
>>>>>   }
>>>>>
>>>>>  }
>>>>>
>>>>> So my question is, will there be a noticeable  performance gain to do it the
>>>>> 2nd way?
>>>>> The reason to ask is that the static kind of singleton usage is indeed
>>>>> anti-spring, and makes
>>>>> my eyes bleed....
>>>>>
>>>>> If no one has done a performance comparison, I might have to do one myself.
>>>>> Just being lazzzzzy...
>>>>>
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Jason Wang
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>           
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>         
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: will there be a performance gain to use singleton to remove references to the service object in models?

Posted by Igor Vaynberg <ig...@gmail.com>.
also safe to do with salve because it removes the field and rewrites
field reads with lookups.

wicket-spring and salve were created for a reason - to make it easy to
work with services in an environment where objects are often
serialized.

salve doesnt have the memory overhead of wicket's @SpringBean, but
@SpringBean doesnt have the complexity of a bytecode instrumentation
step.

-igor

On Tue, Jul 28, 2009 at 1:03 AM, Martijn
Dashorst<ma...@gmail.com> wrote:
> There's the risk of keeping the retrieved service as a reference
> somewhere, e.g. by declaring it final and using it inside an anon
> inner class, negating any and all gains you've done by using the
> static lookup. The @SpringBean annotated references are safe to pass
> around (as they are implemented as proxies to your services)
>
> Martijn
>
> On Tue, Jul 28, 2009 at 9:50 AM, Eelco
> Hillenius<ee...@gmail.com> wrote:
>> Actually, thinking about it, if you're very tight on memory, it will
>> save you a reference, particularly when the page gets serialized. So
>> if you are worrying about efficiency *and* are ok with this code
>> style, it's an option. :-)
>>
>> Eelco
>>
>> On Tue, Jul 28, 2009 at 12:47 AM, Eelco
>> Hillenius<ee...@gmail.com> wrote:
>>> It might give you a very slight edge to use a singleton as you (or the
>>> annotation processor in this case) don't have to introspect and work
>>> through a proxy. If you're not bothered by singletons (I, for one
>>> typically are): go for it. However, keep that famous 'premature
>>> optimization is the root of all evil' in mind; 99.9% chance you're
>>> optimizing something that will never ever become a bottleneck.
>>>
>>> Eelco
>>>
>>> 2009/7/27 Murat Yücel <ko...@gmail.com>:
>>>> Hi Jason
>>>>
>>>> I dont have a performance comparison, but i cannot see why you should
>>>> gain better performance.
>>>> All spring beans are as default singleton, so you will just forward a
>>>> singleton using a singleton.
>>>>
>>>> /Murat
>>>>
>>>> 2009/7/28 Jason Wang <ja...@bulletin.net>:
>>>>> Hi all,
>>>>>
>>>>> Although I am using spring-wicket to prevent the whole spring being
>>>>> serialized, It still brothers me to  see the  references in the model
>>>>> object, for example:
>>>>>
>>>>> Instead of using this:
>>>>>
>>>>> public class MyViewObjectProvider extends SortableDataProvider{
>>>>>    @SpringBean("daoService")
>>>>>    private  DAOServices daoService;
>>>>>
>>>>>    private String objectID;
>>>>>
>>>>>    public Iterator iterator(final int first, final int count){
>>>>>         .....
>>>>>      return daoService.load(objectId).subList(first,
>>>>> first+count).iterator();
>>>>>   }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> I always write a singleton helper class for the service to be used, so I can
>>>>> have the model this way:
>>>>>
>>>>> public class MyViewObjectProvider extends SortableDataProvider{
>>>>>    //so no reference to the dao service object
>>>>>
>>>>>    private String objectID;
>>>>>     public Iterator iterator(final int first, final int count){
>>>>>         .....
>>>>>   //here the DAOServiceHelper.get() returns a instance that managed by
>>>>> spring(with the actual service object injected.)
>>>>>      return DAOServiceHelper.get().load(objectId).subList(first,
>>>>> first+count).iterator();
>>>>>   }
>>>>>
>>>>>  }
>>>>>
>>>>> So my question is, will there be a noticeable  performance gain to do it the
>>>>> 2nd way?
>>>>> The reason to ask is that the static kind of singleton usage is indeed
>>>>> anti-spring, and makes
>>>>> my eyes bleed....
>>>>>
>>>>> If no one has done a performance comparison, I might have to do one myself.
>>>>> Just being lazzzzzy...
>>>>>
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Jason Wang
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
>
> --
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.3.5 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: will there be a performance gain to use singleton to remove references to the service object in models?

Posted by Martijn Dashorst <ma...@gmail.com>.
There's the risk of keeping the retrieved service as a reference
somewhere, e.g. by declaring it final and using it inside an anon
inner class, negating any and all gains you've done by using the
static lookup. The @SpringBean annotated references are safe to pass
around (as they are implemented as proxies to your services)

Martijn

On Tue, Jul 28, 2009 at 9:50 AM, Eelco
Hillenius<ee...@gmail.com> wrote:
> Actually, thinking about it, if you're very tight on memory, it will
> save you a reference, particularly when the page gets serialized. So
> if you are worrying about efficiency *and* are ok with this code
> style, it's an option. :-)
>
> Eelco
>
> On Tue, Jul 28, 2009 at 12:47 AM, Eelco
> Hillenius<ee...@gmail.com> wrote:
>> It might give you a very slight edge to use a singleton as you (or the
>> annotation processor in this case) don't have to introspect and work
>> through a proxy. If you're not bothered by singletons (I, for one
>> typically are): go for it. However, keep that famous 'premature
>> optimization is the root of all evil' in mind; 99.9% chance you're
>> optimizing something that will never ever become a bottleneck.
>>
>> Eelco
>>
>> 2009/7/27 Murat Yücel <ko...@gmail.com>:
>>> Hi Jason
>>>
>>> I dont have a performance comparison, but i cannot see why you should
>>> gain better performance.
>>> All spring beans are as default singleton, so you will just forward a
>>> singleton using a singleton.
>>>
>>> /Murat
>>>
>>> 2009/7/28 Jason Wang <ja...@bulletin.net>:
>>>> Hi all,
>>>>
>>>> Although I am using spring-wicket to prevent the whole spring being
>>>> serialized, It still brothers me to  see the  references in the model
>>>> object, for example:
>>>>
>>>> Instead of using this:
>>>>
>>>> public class MyViewObjectProvider extends SortableDataProvider{
>>>>    @SpringBean("daoService")
>>>>    private  DAOServices daoService;
>>>>
>>>>    private String objectID;
>>>>
>>>>    public Iterator iterator(final int first, final int count){
>>>>         .....
>>>>      return daoService.load(objectId).subList(first,
>>>> first+count).iterator();
>>>>   }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> I always write a singleton helper class for the service to be used, so I can
>>>> have the model this way:
>>>>
>>>> public class MyViewObjectProvider extends SortableDataProvider{
>>>>    //so no reference to the dao service object
>>>>
>>>>    private String objectID;
>>>>     public Iterator iterator(final int first, final int count){
>>>>         .....
>>>>   //here the DAOServiceHelper.get() returns a instance that managed by
>>>> spring(with the actual service object injected.)
>>>>      return DAOServiceHelper.get().load(objectId).subList(first,
>>>> first+count).iterator();
>>>>   }
>>>>
>>>>  }
>>>>
>>>> So my question is, will there be a noticeable  performance gain to do it the
>>>> 2nd way?
>>>> The reason to ask is that the static kind of singleton usage is indeed
>>>> anti-spring, and makes
>>>> my eyes bleed....
>>>>
>>>> If no one has done a performance comparison, I might have to do one myself.
>>>> Just being lazzzzzy...
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Jason Wang
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: will there be a performance gain to use singleton to remove references to the service object in models?

Posted by Eelco Hillenius <ee...@gmail.com>.
Actually, thinking about it, if you're very tight on memory, it will
save you a reference, particularly when the page gets serialized. So
if you are worrying about efficiency *and* are ok with this code
style, it's an option. :-)

Eelco

On Tue, Jul 28, 2009 at 12:47 AM, Eelco
Hillenius<ee...@gmail.com> wrote:
> It might give you a very slight edge to use a singleton as you (or the
> annotation processor in this case) don't have to introspect and work
> through a proxy. If you're not bothered by singletons (I, for one
> typically are): go for it. However, keep that famous 'premature
> optimization is the root of all evil' in mind; 99.9% chance you're
> optimizing something that will never ever become a bottleneck.
>
> Eelco
>
> 2009/7/27 Murat Yücel <ko...@gmail.com>:
>> Hi Jason
>>
>> I dont have a performance comparison, but i cannot see why you should
>> gain better performance.
>> All spring beans are as default singleton, so you will just forward a
>> singleton using a singleton.
>>
>> /Murat
>>
>> 2009/7/28 Jason Wang <ja...@bulletin.net>:
>>> Hi all,
>>>
>>> Although I am using spring-wicket to prevent the whole spring being
>>> serialized, It still brothers me to  see the  references in the model
>>> object, for example:
>>>
>>> Instead of using this:
>>>
>>> public class MyViewObjectProvider extends SortableDataProvider{
>>>    @SpringBean("daoService")
>>>    private  DAOServices daoService;
>>>
>>>    private String objectID;
>>>
>>>    public Iterator iterator(final int first, final int count){
>>>         .....
>>>      return daoService.load(objectId).subList(first,
>>> first+count).iterator();
>>>   }
>>>
>>> }
>>>
>>>
>>>
>>> I always write a singleton helper class for the service to be used, so I can
>>> have the model this way:
>>>
>>> public class MyViewObjectProvider extends SortableDataProvider{
>>>    //so no reference to the dao service object
>>>
>>>    private String objectID;
>>>     public Iterator iterator(final int first, final int count){
>>>         .....
>>>   //here the DAOServiceHelper.get() returns a instance that managed by
>>> spring(with the actual service object injected.)
>>>      return DAOServiceHelper.get().load(objectId).subList(first,
>>> first+count).iterator();
>>>   }
>>>
>>>  }
>>>
>>> So my question is, will there be a noticeable  performance gain to do it the
>>> 2nd way?
>>> The reason to ask is that the static kind of singleton usage is indeed
>>> anti-spring, and makes
>>> my eyes bleed....
>>>
>>> If no one has done a performance comparison, I might have to do one myself.
>>> Just being lazzzzzy...
>>>
>>>
>>> Thanks,
>>>
>>> Jason Wang
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: will there be a performance gain to use singleton to remove references to the service object in models?

Posted by Eelco Hillenius <ee...@gmail.com>.
It might give you a very slight edge to use a singleton as you (or the
annotation processor in this case) don't have to introspect and work
through a proxy. If you're not bothered by singletons (I, for one
typically are): go for it. However, keep that famous 'premature
optimization is the root of all evil' in mind; 99.9% chance you're
optimizing something that will never ever become a bottleneck.

Eelco

2009/7/27 Murat Yücel <ko...@gmail.com>:
> Hi Jason
>
> I dont have a performance comparison, but i cannot see why you should
> gain better performance.
> All spring beans are as default singleton, so you will just forward a
> singleton using a singleton.
>
> /Murat
>
> 2009/7/28 Jason Wang <ja...@bulletin.net>:
>> Hi all,
>>
>> Although I am using spring-wicket to prevent the whole spring being
>> serialized, It still brothers me to  see the  references in the model
>> object, for example:
>>
>> Instead of using this:
>>
>> public class MyViewObjectProvider extends SortableDataProvider{
>>    @SpringBean("daoService")
>>    private  DAOServices daoService;
>>
>>    private String objectID;
>>
>>    public Iterator iterator(final int first, final int count){
>>         .....
>>      return daoService.load(objectId).subList(first,
>> first+count).iterator();
>>   }
>>
>> }
>>
>>
>>
>> I always write a singleton helper class for the service to be used, so I can
>> have the model this way:
>>
>> public class MyViewObjectProvider extends SortableDataProvider{
>>    //so no reference to the dao service object
>>
>>    private String objectID;
>>     public Iterator iterator(final int first, final int count){
>>         .....
>>   //here the DAOServiceHelper.get() returns a instance that managed by
>> spring(with the actual service object injected.)
>>      return DAOServiceHelper.get().load(objectId).subList(first,
>> first+count).iterator();
>>   }
>>
>>  }
>>
>> So my question is, will there be a noticeable  performance gain to do it the
>> 2nd way?
>> The reason to ask is that the static kind of singleton usage is indeed
>> anti-spring, and makes
>> my eyes bleed....
>>
>> If no one has done a performance comparison, I might have to do one myself.
>> Just being lazzzzzy...
>>
>>
>> Thanks,
>>
>> Jason Wang
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: will there be a performance gain to use singleton to remove references to the service object in models?

Posted by Murat Yücel <ko...@gmail.com>.
Hi Jason

I dont have a performance comparison, but i cannot see why you should
gain better performance.
All spring beans are as default singleton, so you will just forward a
singleton using a singleton.

/Murat

2009/7/28 Jason Wang <ja...@bulletin.net>:
> Hi all,
>
> Although I am using spring-wicket to prevent the whole spring being
> serialized, It still brothers me to  see the  references in the model
> object, for example:
>
> Instead of using this:
>
> public class MyViewObjectProvider extends SortableDataProvider{
>    @SpringBean("daoService")
>    private  DAOServices daoService;
>
>    private String objectID;
>
>    public Iterator iterator(final int first, final int count){
>         .....
>      return daoService.load(objectId).subList(first,
> first+count).iterator();
>   }
>
> }
>
>
>
> I always write a singleton helper class for the service to be used, so I can
> have the model this way:
>
> public class MyViewObjectProvider extends SortableDataProvider{
>    //so no reference to the dao service object
>
>    private String objectID;
>     public Iterator iterator(final int first, final int count){
>         .....
>   //here the DAOServiceHelper.get() returns a instance that managed by
> spring(with the actual service object injected.)
>      return DAOServiceHelper.get().load(objectId).subList(first,
> first+count).iterator();
>   }
>
>  }
>
> So my question is, will there be a noticeable  performance gain to do it the
> 2nd way?
> The reason to ask is that the static kind of singleton usage is indeed
> anti-spring, and makes
> my eyes bleed....
>
> If no one has done a performance comparison, I might have to do one myself.
> Just being lazzzzzy...
>
>
> Thanks,
>
> Jason Wang
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org