Re: After/before creation or serialization

2012-11-25 Thread Martin Grigorov
The proxy does effectively the same as your code - it uses a transient bean
and if it is not available then it looks it up in the bean repository.

I'm not sure what performance loss you experience.


On Sun, Nov 25, 2012 at 11:15 PM, Oscar Besga Arcauz wrote:

> Hi Martin
>
>
> Yes, I've tried @SpringBean but I don't like it because I noticed a (not
> very big) performace loss when using it; because the dynamicly-created
> serializable proxy.
> Or at least that seems to me.
>
> IMHO, the proxy is an overwhelming solution, I prefer a combination of
> transients and 'if (dao==null) dao = (
> ((MyApplicattion)getApplication()).getDao());'
>
> Simply if this can be done in another way.
>
> Thanks
>
>
>
>
> > > > Oscar Besga Arcauz  < < <
>
> -Martin Grigorov  escribió: -
> Para: users@wicket.apache.org
> De: Martin Grigorov 
> Fecha: 25/11/2012  15:57
> Asunto: Re: After/before creation or serialization
>
> Hi,
>
> onInitialize is called just once for any Component. As its javadoc says it
> is called some time before the first call of #onConfigure.
> #onDetach() is called before passing the Page to serialization but it can
> be called at any time and several times per request cycle, so it is not
> good idea to do your task there too.
>
> The solution you are looking for is wicket-ioc module. It is the base for
> @SpringBean and @Inject support in Wicket. It injects serializable proxy
> instead of your real DAO/Service/... So it is very cheap for serialization
> and doesn't require your real dao/service to be Serializable itself.
>
>
> On Sun, Nov 25, 2012 at 2:22 PM, Oscar Besga Arcauz  >wrote:
>
> >  Thanks
> >
> > Yes, I can use both methos onInitialize + onRead and onDetach + onSave
> >
> > Perhaps I should ask if onInitialize and onDetach are used when component
> > is serialized /deserialized on wicket 6
> >
> > My plan is to do avoid this
> >
> > MyPanel(String id){
> > super(id)
> > ((MyApplicattion)getApplication()).getDao().getData();
> >}
> >
> > and turn into this
> >
> >
> > MyPanel(String id){
> > super(id)
> > }
> >
> > private transient Dao dao;
> >
> > void onCreateOrRead(){
> > dao = ((MyApplicattion)getApplication()).getDao();
> > }
> >
> >
> >void onCreateOrRead(){
> > dao = null; // Not necessary
> >}
> >
> >
> > > > > Oscar Besga Arcauz  < < <
> >
> > -Cedric Gatay  escribió: -
> > Para: users@wicket.apache.org
> > De: Cedric Gatay 
> > Fecha: 25/11/2012  13:36
> > Asunto: Re: After/before creation or serialization
> >
> > Hi,
> > I don't know if there is a special Wicket thing, but you can use the
> > standard Java way like this :
> > private void writeObject(ObjectOutputStream out) throws IOException {
> > //provide your own logic
> > }
> >
> > private void readObject(ObjectInputStream in) throws IOException,
> > ClassNotFoundException {
> > //provide your own logic
> > }
> >
> > Regards,
> >
> > __
> > Cedric Gatay
> > http://www.bloggure.info | http://cedric.gatay.fr |
> > @Cedric_Gatay<http://twitter.com/Cedric_Gatay>
> >
> >
> >
> > On Sun, Nov 25, 2012 at 1:28 PM, Oscar Besga Arcauz  > >wrote:
> >
> > >
> > >
> > > Hi wickers !
> > >
> > > Is there a method on Wicket components that is called before
> > > creation/load(f.e. from disk, deserialization) and another method
> called
> > > before destroy/save(to disk, serialization)
> > >
> > > Would it be methods onInitialize()   and onDetach()  of
> > > org.apache.wicket.Component ?
> > >
> > > Thanks !
> > >
> > >
> > > > > > Oscar Besga Arcauz  < < <
> > > -
> > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > For additional commands, e-mail: users-h...@wicket.apache.org
> > >
> > >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>


Re: After/before creation or serialization

2012-11-25 Thread Oscar Besga Arcauz
Hi Martin 

 
Yes, I've tried @SpringBean but I don't like it because I noticed a (not very 
big) performace loss when using it; because the dynamicly-created serializable 
proxy. 
Or at least that seems to me.

IMHO, the proxy is an overwhelming solution, I prefer a combination of 
transients and 'if (dao==null) dao = (
((MyApplicattion)getApplication()).getDao());'

Simply if this can be done in another way.

Thanks 




> > > Oscar Besga Arcauz  < < < 

-Martin Grigorov  escribió: -
Para: users@wicket.apache.org
De: Martin Grigorov 
Fecha: 25/11/2012  15:57
Asunto: Re: After/before creation or serialization

Hi,

onInitialize is called just once for any Component. As its javadoc says it
is called some time before the first call of #onConfigure.
#onDetach() is called before passing the Page to serialization but it can
be called at any time and several times per request cycle, so it is not
good idea to do your task there too.

The solution you are looking for is wicket-ioc module. It is the base for
@SpringBean and @Inject support in Wicket. It injects serializable proxy
instead of your real DAO/Service/... So it is very cheap for serialization
and doesn't require your real dao/service to be Serializable itself.


On Sun, Nov 25, 2012 at 2:22 PM, Oscar Besga Arcauz wrote:

>  Thanks
>
> Yes, I can use both methos onInitialize + onRead and onDetach + onSave
>
> Perhaps I should ask if onInitialize and onDetach are used when component
> is serialized /deserialized on wicket 6
>
> My plan is to do avoid this
>
>     MyPanel(String id){
>         super(id)
>         ((MyApplicattion)getApplication()).getDao().getData();
>    }
>
> and turn into this
>
>
>     MyPanel(String id){
>         super(id)
>     }
>
>     private transient Dao dao;
>
>     void onCreateOrRead(){
>         dao = ((MyApplicattion)getApplication()).getDao();
>     }
>
>
>    void onCreateOrRead(){
>         dao = null; // Not necessary
>    }
>
>
>     > > > Oscar Besga Arcauz  < < <
>
> -Cedric Gatay  escribió: -
> Para: users@wicket.apache.org
> De: Cedric Gatay 
> Fecha: 25/11/2012  13:36
> Asunto: Re: After/before creation or serialization
>
> Hi,
> I don't know if there is a special Wicket thing, but you can use the
> standard Java way like this :
>     private void writeObject(ObjectOutputStream out) throws IOException {
>         //provide your own logic
>     }
>
>     private void readObject(ObjectInputStream in) throws IOException,
> ClassNotFoundException {
>         //provide your own logic
>     }
>
> Regards,
>
> __
> Cedric Gatay
> http://www.bloggure.info | http://cedric.gatay.fr |
> @Cedric_Gatay<http://twitter.com/Cedric_Gatay>
>
>
>
> On Sun, Nov 25, 2012 at 1:28 PM, Oscar Besga Arcauz  >wrote:
>
> >
> >
> > Hi wickers !
> >
> > Is there a method on Wicket components that is called before
> > creation/load(f.e. from disk, deserialization) and another method called
> > before destroy/save(to disk, serialization)
> >
> > Would it be methods onInitialize()   and onDetach()  of
> > org.apache.wicket.Component ?
> >
> > Thanks !
> >
> >
> >     > > > Oscar Besga Arcauz  < < <
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

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



Re: After/before creation or serialization

2012-11-25 Thread Martin Grigorov
Hi,

onInitialize is called just once for any Component. As its javadoc says it
is called some time before the first call of #onConfigure.
#onDetach() is called before passing the Page to serialization but it can
be called at any time and several times per request cycle, so it is not
good idea to do your task there too.

The solution you are looking for is wicket-ioc module. It is the base for
@SpringBean and @Inject support in Wicket. It injects serializable proxy
instead of your real DAO/Service/... So it is very cheap for serialization
and doesn't require your real dao/service to be Serializable itself.


On Sun, Nov 25, 2012 at 2:22 PM, Oscar Besga Arcauz wrote:

>  Thanks
>
> Yes, I can use both methos onInitialize + onRead and onDetach + onSave
>
> Perhaps I should ask if onInitialize and onDetach are used when component
> is serialized /deserialized on wicket 6
>
> My plan is to do avoid this
>
> MyPanel(String id){
> super(id)
> ((MyApplicattion)getApplication()).getDao().getData();
>}
>
> and turn into this
>
>
> MyPanel(String id){
> super(id)
> }
>
> private transient Dao dao;
>
> void onCreateOrRead(){
> dao = ((MyApplicattion)getApplication()).getDao();
> }
>
>
>void onCreateOrRead(){
> dao = null; // Not necessary
>}
>
>
> > > > Oscar Besga Arcauz  < < <
>
> -----Cedric Gatay  escribió: -
> Para: users@wicket.apache.org
> De: Cedric Gatay 
> Fecha: 25/11/2012  13:36
> Asunto: Re: After/before creation or serialization
>
> Hi,
> I don't know if there is a special Wicket thing, but you can use the
> standard Java way like this :
> private void writeObject(ObjectOutputStream out) throws IOException {
> //provide your own logic
> }
>
> private void readObject(ObjectInputStream in) throws IOException,
> ClassNotFoundException {
> //provide your own logic
> }
>
> Regards,
>
> __
> Cedric Gatay
> http://www.bloggure.info | http://cedric.gatay.fr |
> @Cedric_Gatay<http://twitter.com/Cedric_Gatay>
>
>
>
> On Sun, Nov 25, 2012 at 1:28 PM, Oscar Besga Arcauz  >wrote:
>
> >
> >
> > Hi wickers !
> >
> > Is there a method on Wicket components that is called before
> > creation/load(f.e. from disk, deserialization) and another method called
> > before destroy/save(to disk, serialization)
> >
> > Would it be methods onInitialize()   and onDetach()  of
> > org.apache.wicket.Component ?
> >
> > Thanks !
> >
> >
> > > > > Oscar Besga Arcauz  < < <
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>


Re: After/before creation or serialization

2012-11-25 Thread Oscar Besga Arcauz
 Thanks

Yes, I can use both methos onInitialize + onRead and onDetach + onSave

Perhaps I should ask if onInitialize and onDetach are used when component is 
serialized /deserialized on wicket 6

My plan is to do avoid this

    MyPanel(String id){
    super(id)
        ((MyApplicattion)getApplication()).getDao().getData();
   }

and turn into this


    MyPanel(String id){
    super(id)
    }

    private transient Dao dao;

    void onCreateOrRead(){
    dao = ((MyApplicattion)getApplication()).getDao();
    }


   void onCreateOrRead(){
    dao = null; // Not necessary
   }


> > > Oscar Besga Arcauz  < < < 

-Cedric Gatay  escribió: -
Para: users@wicket.apache.org
De: Cedric Gatay 
Fecha: 25/11/2012  13:36
Asunto: Re: After/before creation or serialization

Hi,
I don't know if there is a special Wicket thing, but you can use the
standard Java way like this :
    private void writeObject(ObjectOutputStream out) throws IOException {
        //provide your own logic
    }

    private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
        //provide your own logic
    }

Regards,

__
Cedric Gatay
http://www.bloggure.info | http://cedric.gatay.fr |
@Cedric_Gatay<http://twitter.com/Cedric_Gatay>



On Sun, Nov 25, 2012 at 1:28 PM, Oscar Besga Arcauz wrote:

>
>
> Hi wickers !
>
> Is there a method on Wicket components that is called before
> creation/load(f.e. from disk, deserialization) and another method called
> before destroy/save(to disk, serialization)
>
> Would it be methods onInitialize()   and onDetach()  of
> org.apache.wicket.Component ?
>
> Thanks !
>
>
>     > > > Oscar Besga Arcauz  < < <
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

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



Re: After/before creation or serialization

2012-11-25 Thread Cedric Gatay
Hi,
I don't know if there is a special Wicket thing, but you can use the
standard Java way like this :
private void writeObject(ObjectOutputStream out) throws IOException {
//provide your own logic
}

private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
//provide your own logic
}

Regards,

__
Cedric Gatay
http://www.bloggure.info | http://cedric.gatay.fr |
@Cedric_Gatay



On Sun, Nov 25, 2012 at 1:28 PM, Oscar Besga Arcauz wrote:

>
>
> Hi wickers !
>
> Is there a method on Wicket components that is called before
> creation/load(f.e. from disk, deserialization) and another method called
> before destroy/save(to disk, serialization)
>
> Would it be methods onInitialize()   and onDetach()  of
> org.apache.wicket.Component ?
>
> Thanks !
>
>
> > > > Oscar Besga Arcauz  < < <
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>