You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Weisu <we...@gmail.com> on 2007/03/14 03:24:45 UTC

[T5]Question on ASO configuration

Hi, I am following the User Guide on ASO, what is
"ApplicationStateConfiguration"? Do I have to create this interface, the
online example code is:
public void contributeApplicationStateManager(MappedConfiguration<Class,
ApplicationStateConfiguration> configuration)
  {
    ApplicationStateCreator<MyState> creator = new
ApplicationStateCreator<MyState>()
    {
      public MyState create()
      {
        return new MyState(new Date());
      }
    };
  
    configuration.add(MyState.class, new
ApplicationStateContribution("session", creator));
  }
-- 
View this message in context: http://www.nabble.com/-T5-Question-on-ASO-configuration-tf3399851.html#a9467437
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [T5]Question on ASO configuration

Posted by Peter Beshai <pe...@gmail.com>.
Thanks a lot that works great :-)

On 3/16/07, D&J Gredler <dj...@gmail.com> wrote:
>
> I haven't looked into this stuff yet, but if I were dealing with it I'd
> probably just make a new ApplicationState class with a user property that
> I
> could set at will, and let Tapestry instantiate the ApplicationState
> whenever it wants to. Of course, once T5 supports ASO flags, you'd want to
> start using those in order to prevent unnecessary session creation.
>
> On 3/16/07, Peter Beshai <pe...@gmail.com> wrote:
> >
> > I am trying to store a user as an ASO. I am able to set the user, but
> when
> > I
> > want to log out, I figured the right way to do it was to just set the
> user
> > ASO to null. I believe this works fine, just that now when I chcek to
> see
> > if
> > the user is null or not, as expected, the application state manager will
> > attempt to create a new instance of it. I figured this wouldn't be a
> > problem, since I could just override the configuration to have something
> > like:
> > public void contributeApplicationStateManager(MappedConfiguration<Class,
> > ApplicationStateContribution> configuration)
> >     {
> > ApplicationStateCreator<User> creator = new
> > ApplicationStateCreator<User>()
> >       {
> >         public User create()
> >         {
> >           return null;
> >         }
> >       };
> >
> >       configuration.add(User.class, new
> > ApplicationStateContribution("session", creator));
> > }
> >
> > however this didn't seem to make any difference. I still get a
> > java.lang.InstantiationException. Is there something I am missing?
> >
> > --
> > Peter Beshai
> >
> > Pure Mathematics/Computer Science Student
> > University of Waterloo
> >
>



-- 
Peter Beshai

Pure Mathematics/Computer Science Student
University of Waterloo

Re: [T5]Question on ASO configuration

Posted by D&J Gredler <dj...@gmail.com>.
I haven't looked into this stuff yet, but if I were dealing with it I'd
probably just make a new ApplicationState class with a user property that I
could set at will, and let Tapestry instantiate the ApplicationState
whenever it wants to. Of course, once T5 supports ASO flags, you'd want to
start using those in order to prevent unnecessary session creation.

On 3/16/07, Peter Beshai <pe...@gmail.com> wrote:
>
> I am trying to store a user as an ASO. I am able to set the user, but when
> I
> want to log out, I figured the right way to do it was to just set the user
> ASO to null. I believe this works fine, just that now when I chcek to see
> if
> the user is null or not, as expected, the application state manager will
> attempt to create a new instance of it. I figured this wouldn't be a
> problem, since I could just override the configuration to have something
> like:
> public void contributeApplicationStateManager(MappedConfiguration<Class,
> ApplicationStateContribution> configuration)
>     {
> ApplicationStateCreator<User> creator = new
> ApplicationStateCreator<User>()
>       {
>         public User create()
>         {
>           return null;
>         }
>       };
>
>       configuration.add(User.class, new
> ApplicationStateContribution("session", creator));
> }
>
> however this didn't seem to make any difference. I still get a
> java.lang.InstantiationException. Is there something I am missing?
>
> --
> Peter Beshai
>
> Pure Mathematics/Computer Science Student
> University of Waterloo
>

Re: [T5]Question on ASO configuration

Posted by Peter Beshai <pe...@gmail.com>.
I am trying to store a user as an ASO. I am able to set the user, but when I
want to log out, I figured the right way to do it was to just set the user
ASO to null. I believe this works fine, just that now when I chcek to see if
the user is null or not, as expected, the application state manager will
attempt to create a new instance of it. I figured this wouldn't be a
problem, since I could just override the configuration to have something
like:
 public void contributeApplicationStateManager(MappedConfiguration<Class,
ApplicationStateContribution> configuration)
    {
 ApplicationStateCreator<User> creator = new ApplicationStateCreator<User>()
      {
        public User create()
        {
          return null;
        }
      };

      configuration.add(User.class, new
ApplicationStateContribution("session", creator));
}

however this didn't seem to make any difference. I still get a
java.lang.InstantiationException. Is there something I am missing?

-- 
Peter Beshai

Pure Mathematics/Computer Science Student
University of Waterloo

Re: [T5]Question on ASO configuration

Posted by Howard Lewis Ship <hl...@gmail.com>.
Again, if you ASO is just a normal POJO (public no args constructor),
then you don't need to make a contribution to the
ApplicationStateManager service configuration.

On 3/13/07, Weisu <we...@gmail.com> wrote:
>
> Hi, I am following the User Guide on ASO, what is
> "ApplicationStateConfiguration"? Do I have to create this interface, the
> online example code is:
> public void contributeApplicationStateManager(MappedConfiguration<Class,
> ApplicationStateConfiguration> configuration)
>   {
>     ApplicationStateCreator<MyState> creator = new
> ApplicationStateCreator<MyState>()
>     {
>       public MyState create()
>       {
>         return new MyState(new Date());
>       }
>     };
>
>     configuration.add(MyState.class, new
> ApplicationStateContribution("session", creator));
>   }
> --
> View this message in context: http://www.nabble.com/-T5-Question-on-ASO-configuration-tf3399851.html#a9467437
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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


Re: [T5]Question on ASO configuration

Posted by Weisu <we...@gmail.com>.
Thanks Howard, it now working.

Howard Lewis Ship wrote:
> 
> Sorry, just a typo; the name of the class should be
> ApplicationStateContribution (not ApplicationStateConfiguration).
> 
> On 3/13/07, Weisu <we...@gmail.com> wrote:
>>
>> Hi, I am following the User Guide on ASO, what is
>> "ApplicationStateConfiguration"? Do I have to create this interface, the
>> online example code is:
>> public void contributeApplicationStateManager(MappedConfiguration<Class,
>> ApplicationStateConfiguration> configuration)
>>   {
>>     ApplicationStateCreator<MyState> creator = new
>> ApplicationStateCreator<MyState>()
>>     {
>>       public MyState create()
>>       {
>>         return new MyState(new Date());
>>       }
>>     };
>>
>>     configuration.add(MyState.class, new
>> ApplicationStateContribution("session", creator));
>>   }
>> --
>> View this message in context:
>> http://www.nabble.com/-T5-Question-on-ASO-configuration-tf3399851.html#a9467437
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> -- 
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
> 
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-T5-Question-on-ASO-configuration-tf3399851.html#a9484190
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [T5]Question on ASO configuration

Posted by Howard Lewis Ship <hl...@gmail.com>.
Sorry, just a typo; the name of the class should be
ApplicationStateContribution (not ApplicationStateConfiguration).

On 3/13/07, Weisu <we...@gmail.com> wrote:
>
> Hi, I am following the User Guide on ASO, what is
> "ApplicationStateConfiguration"? Do I have to create this interface, the
> online example code is:
> public void contributeApplicationStateManager(MappedConfiguration<Class,
> ApplicationStateConfiguration> configuration)
>   {
>     ApplicationStateCreator<MyState> creator = new
> ApplicationStateCreator<MyState>()
>     {
>       public MyState create()
>       {
>         return new MyState(new Date());
>       }
>     };
>
>     configuration.add(MyState.class, new
> ApplicationStateContribution("session", creator));
>   }
> --
> View this message in context: http://www.nabble.com/-T5-Question-on-ASO-configuration-tf3399851.html#a9467437
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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