Menu

Flyweight Syntax

Developers
uptown
2006-10-06
2013-04-19
  • uptown

    uptown - 2006-10-06

    So the original XML Structure in the code (which we can just use from a starting point)

    <object-profile name="patternSample" metaphor="testPatternSample">    
    <design-pattern>singleton</design-pattern>
    <classes>            <class>com.wideplay.Singleton</class>
    </classes>
    </object-profile>

     
    • uptown

      uptown - 2006-10-06

      Then i suggested something similar to (i know this doesn't have any context to the flyweight yet)

      <object-profile name="patternSample" metaphor="testPatternSample"> 
      <singleton>
      <class>test.Singleton</class> 
      <!-- Allow changes to which method gets an instance --> 
      <instanceOf>getInstance</instanceOf> 
      </singleton> 
      </object-profile>

       
    • uptown

      uptown - 2006-10-06

      Another suggestion was something similar to how spring handles properties of objects...

      <object-profile name="patternSample" metaphor="testPatternSample"> 
      <singleton class="test.Singleton"> 
      <property name="instanceOf">getInstance</property> 
      </singleton> 
      </object-profile>

      I know you had suggested a namespace in your previous examples that can of course be added simply.

      so finally for the flyweight we would be looking at something similar to this in my mind (this of course needs refining probably)....

      <object-profile name="patternSample" metaphor="testPatternSample"> 
      <flyweight class="test.FlyWeight"> 
      <property name="equalityComparator">equals</property> 
      </flyweight> 
      </object-profile>

       
    • deje

      deje - 2006-10-17

      yea that looks good. I would say we dont need to be explicit about the equality comparator so that can be optional (default to Object.equals()). And if we want to make it explicit--it could even be an ognl expression, example: "ognl:#this.hashCode() == java.lang.System@identityHashCode()"

      but that's a perfect start for us for the flyweight. What are your thoughts on using an xml parsing framework like dom4j? It's a bit tedious to do everything with dom (though makes JO lightweight and more portable).

       
    • uptown

      uptown - 2006-10-28

      Dom4j is fine. I have no real preference. Its good because it is contained in one jar with few other dependencies.

       
    • deje

      deje - 2006-10-28

      ok I will keep the dom4j conversion on the back burner, while we get pattern support going (atleast in junit tests).

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.