You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Raul Raja Martinez <do...@estudiowebs.com> on 2005/12/28 07:53:33 UTC

Way to Reload ASO registry?

Hi I have some problems reloading ASO's, Here is what I'm doing:

I have a webapp that loads its menu once from the database at 
application startup and stores it in a ASO. Even though I'm using the 
DeferSessionClose in hiveutils wich allows me to not have lazy 
initializations exceptions and works just fine in any other case, there 
is a case where I get the lazyInitializationException. If a reload the 
menu from the database from a Tapestry Engineservice and I overwrite the 
reference of the ASO using ApplicationStateManager.store(String,Object) 
when I go back to the frontpage I get again the lazyinitializationexception.
Setting lazy to false is not an option for me.

I would just like to know if there is a better way of reloading ASO's 
without having to use ApplicationStateManager.store(String,Object) or 
having to rebuild the whole Hivemind registry.

Any help is appreciated.

Thanks

Raul Raja

(Below is the code that I'm using)



****** ASO *********************************************************

public class GlobalMenu implements StateObjectFactory {

  private static final long serialVersionUID = 1L;
	
  public GlobalMenu() {
  }

  public Object createStateObject() {
		
   return entityService.load(Category.class, new Integer(1));
		
  }

}



****** Service that Reloads ASO **************************************


public class FrontpageReloader implements IEngineService {

  public void service(IRequestCycle cycle) throws IOException {
	
   Category cat = (Category) (service.load(Category.class,1));
   service.merge(cat);
			
   appStateMgr.store("globalMenu", cat2);

  }

  private ApplicationStateManager appStateMgr;

  public void setAppStateMgr(ApplicationStateManager asm) {
   this.appStateMgr = asm;
  }

}


****** hivemodule.xml ************************************************

<contribution configuration-id="tapestry.state.ApplicationObjects">
  <state-object name="globalMenu" scope="application">
   <invoke-factory object="object:GlobalMenu" />
  </state-object>
</contribution>

<contribution configuration-id="tapestry.services.ApplicationServices">
  <service name="frontpageReloader" 
object="service:CMS.FrontpageReloader" />
</contribution>

<service-point id="FrontpageReloader" 
interface="org.apache.tapestry.engine.IEngineService">
  <invoke-factory model="singleton">
   <construct class="com.estudiowebs.CMS.webservices.FrontpageReloader" />
    </invoke-factory>
</service-point>

<contribution configuration-id="hiveutils.ObjectBuilderObjects">
  <object name="GlobalMenu" cached="true" 
class="com.estudiowebs.CMS.DAO.GlobalMenu">
   <inject name="entityService" object="service:EntityService" />
  </object>
</contribution>

<contribution configuration-id="hivemind.ApplicationDefaults">
  <default symbol="hivetranse.hibernate3.DeferSessionClose" value="true" />
</contribution>


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


Re: Way to Reload ASO registry?

Posted by Raul Raja Martinez <do...@estudiowebs.com>.
Hi Joachim, thanks for the response,

What I really need is to reload the ASO registry at runtime without 
having to reload the whole hivemind registry. When you say dummy object 
, do you mean something like a List or Set where I can add and remove 
children?

Thanks

Raul.

Joachim (PROGS) wrote:
> Raul Raja Martinez wrote:
>> Hi I have some problems reloading ASO's, Here is what I'm doing:
>>
>> I have a webapp that loads its menu once from the database at 
>> application startup and stores it in a ASO. Even though I'm using the 
>> DeferSessionClose in hiveutils wich allows me to not have lazy 
>> initializations exceptions and works just fine in any other case, 
>> there is a case where I get the lazyInitializationException. If a 
>> reload the menu from the database from a Tapestry Engineservice and I 
>> overwrite the reference of the ASO using 
>> ApplicationStateManager.store(String,Object) when I go back to the 
>> frontpage I get again the lazyinitializationexception.
>> Setting lazy to false is not an option for me.
>>
>> I would just like to know if there is a better way of reloading ASO's 
>> without having to use ApplicationStateManager.store(String,Object) or 
>> having to rebuild the whole Hivemind registry.
> 
> If I understand correctly, you want to swap the active ASO object during 
> page processing. I don't think this is directly supported. Can you not 
> have a dummy object as aso, which contains the real aso. The dummy is 
> then immutable during page processing, and you could easily swap the 
> "real" aso object in the dummy.
> 
> Kind regards,
> Joachim
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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


Re: Way to Reload ASO registry?

Posted by "Joachim (PROGS)" <jo...@progs.be>.
Raul Raja Martinez wrote:
> Hi I have some problems reloading ASO's, Here is what I'm doing:
> 
> I have a webapp that loads its menu once from the database at 
> application startup and stores it in a ASO. Even though I'm using the 
> DeferSessionClose in hiveutils wich allows me to not have lazy 
> initializations exceptions and works just fine in any other case, there 
> is a case where I get the lazyInitializationException. If a reload the 
> menu from the database from a Tapestry Engineservice and I overwrite the 
> reference of the ASO using ApplicationStateManager.store(String,Object) 
> when I go back to the frontpage I get again the 
> lazyinitializationexception.
> Setting lazy to false is not an option for me.
> 
> I would just like to know if there is a better way of reloading ASO's 
> without having to use ApplicationStateManager.store(String,Object) or 
> having to rebuild the whole Hivemind registry.

If I understand correctly, you want to swap the active ASO object during 
page processing. I don't think this is directly supported. Can you not 
have a dummy object as aso, which contains the real aso. The dummy is 
then immutable during page processing, and you could easily swap the 
"real" aso object in the dummy.

Kind regards,
Joachim


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