hivemind-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eli Doran <eli.do...@gmail.com>
Subject some 'how to' questions
Date Tue, 05 Jul 2005 19:25:51 GMT
Hello, I thought it may be more appropriate to send this to the hivemind 
list because it seems to relate more to hivemind. Please, correct me if 
i'm wrong.  
Below I wrote a few classes representing a simple trio: an object 
(*Member*), a service supplying the object from a key (*Members*), a 
holder of that object for serialization (*MemberHolder*) that only 
serializes the key necessary to restore its *Member* reference.

*Brief:*
    Can you have hivemind reinsert a service into a deserialized state 
object that it previously stored into the session? (reconfigure upon 
deserializing)
    How do you check for or get rid of a state object from Java code?

*Verbose: *

How do I get the *Members* service restored into *MemberHolder* when it 
is deserialized from the session?

I can check if the holder object has been created using 
"state:MemberHolder". But there is no ognl equivalent expression so can 
you not check the existence of state objects from java code without 
forcing creation? Would a call to getMemberHolder (injected property) 
cause the creation of the MemberHolder state object and the session to 
store it in?

Upon logout how do you null the member holder so it's no longer stored 
into the session? I can inject *MemberHolder* into the pages that need 
it but would *setMemberHolder(null)* remove the state object from the 
session?


thank you,
eli

class Member
{
  Integer id;
  String name;
  //obvious get/sets
}

class MemberHolder implements java.io.Serializable
{
  Integer id;
  transient Member member;
  transient Members members;

  // get/sets for member and members
  // if member is null then getMember would
  //use the Integer to get member from Members
}

class Members
{
   Member getMember( Integer id )
}


<service-point id="Members" interface="com.elidoran.member.Members">
  <create-instance class="com.elidoran.member.MembersMap"/>
</service-point>
 
This creates the MemberHolder using a builder service because the 
state-object schema requires the object reference in invoke-factory so 
you can't use hivemind.BuilderFactory. The only reason to not use 
create-instance is to set the Members service into the MemberHolder upon 
creation. So, instead I created a builder service for it and set the 
Members service into that which uses it for newly created MemberHolders.

<contribution configuration-id="tapestry.state.ApplicationObjects">
  <state-object name="MemberHolder" scope="session">
    <invoke-factory object="service:MemberHolderBuilder"/>
  </state-object>
</contribution>
 
<service-point id="MemberHolderBuilder" 
interface="org.apache.tapestry.engine.state.StateObjectFactory">
  <invoke-factory>
    <construct class="com.elidoran.member.MemberHolderBuilder">
       <set-object property="members" value="service:Members"/>
    </construct>
  </invoke-factory>
</service-point>


Mime
View raw message