[jboss-cvs] JBossCache/examples/PojoCache/passivation/src/examples ...

Ben Wang bwang at jboss.com
Mon Nov 6 23:26:51 EST 2006


  User: bwang   
  Date: 06/11/06 23:26:51

  Added:       examples/PojoCache/passivation/src/examples     Address.java
                        Course.java Person.java Student.java
  Log:
  passivation example.
  
  Revision  Changes    Path
  1.1      date: 2006/11/07 04:26:51;  author: bwang;  state: Exp;JBossCache/examples/PojoCache/passivation/src/examples/Address.java
  
  Index: Address.java
  ===================================================================
  package examples;
  
  /**
   * @author Ben Wang
   */
  @org.jboss.cache.pojo.annotation.PojoCacheable
  public class Address {
     protected String city;
     protected int zip;
     protected String street;
  
     public void setCity(String city)
     {
        this.city = city;
     }
  
     public String getCity()
     {
        return this.city;
     }
  
     public void setZip(int zip)
     {
        this.zip = zip;
     }
  
     public int getZip()
     {
        return zip;
     }
  
     public void setStreet(String street)
     {
        this.street = street;
     }
  
     public String getStreet()
     {
        return this.street;
     }
  
     public String getSimpleAddress()
     {
        StringBuffer buf = new StringBuffer(street);
        buf.append(" "  + city);
        if (zip > 0)
           buf.append("  " + zip);
  
        return buf.toString();
     }
  
     public String toString()
     {
        StringBuffer buf = new StringBuffer();
        buf.append("{City = " +city).append(" ,zip = " +zip).append(" ,street = " +street + "}\n");
  
        return buf.toString();
     }
  }
  
  
  
  1.1      date: 2006/11/07 04:26:51;  author: bwang;  state: Exp;JBossCache/examples/PojoCache/passivation/src/examples/Course.java
  
  Index: Course.java
  ===================================================================
  package examples;
  
  /**
   * @author Brian Stansberry
   */
  @org.jboss.cache.pojo.annotation.PojoCacheable
  public class Course {
     protected String title;
     protected String instructor;
     protected String room;
  
     public void setTitle(String title)
     {
        this.title = title;
     }
  
     public String getTitle()
     {
        return this.title;
     }
  
     public void setRoom(String room)
     {
        this.room = room;
     }
  
     public String getRoom()
     {
        return this.room;
     }
  
     public void setInstructor(String instructor)
     {
        this.instructor = instructor;
     }
  
     public String getInstructor()
     {
        return instructor;
     }
  
     public String toString()
     {
        StringBuffer buf = new StringBuffer();
        buf.append("{Title = " +title).append(", Instructor = " + instructor).append(", Room = " +room + "}\n");
  
        return buf.toString();
     }
  
     public boolean equals(Object other)
     {
        if (this == other)
           return true;
  
        if (other instanceof Course) {
           String otherTitle = ((Course) other).getTitle();
           return (title == otherTitle || (title != null && title.equals(otherTitle)));
        }
  
        return false;
     }
  
     public int hashCode()
     {
        return title == null ? 0 : title.hashCode();
     }
  }
  
  
  
  1.1      date: 2006/11/07 04:26:51;  author: bwang;  state: Exp;JBossCache/examples/PojoCache/passivation/src/examples/Person.java
  
  Index: Person.java
  ===================================================================
  package examples;
  
  import java.util.List;
  
  /**
   * @author Ben Wang
   */
  @org.jboss.cache.pojo.annotation.InstanceOfPojoCacheable
  public class Person {
     protected String name;
     protected Address address;
  
     public void setName(String name)
     {
        this.name = name;
     }
  
     public String getName()
     {
        return this.name;
     }
  
     public void setAddress(Address address)
     {
        this.address = address;
     }
  
     public Address getAddress()
     {
        return this.address;
     }
  
     public String toString()
     {
        StringBuffer buf = new StringBuffer();
        buf.append("{Name = " +name);
        if (address != null)
           buf.append(", Address = " + address.getSimpleAddress());
        buf.append("}\n");
  
        return buf.toString();
     }
  
  }
  
  
  
  1.1      date: 2006/11/07 04:26:51;  author: bwang;  state: Exp;JBossCache/examples/PojoCache/passivation/src/examples/Student.java
  
  Index: Student.java
  ===================================================================
  package examples;
  
  import java.util.Collections;
  import java.util.Iterator;
  import java.util.LinkedHashSet;
  import java.util.Set;
  
  
  /**
   * @author Ben Wang
   * No need for annotation here since Person has been annotated already.
   */
  public class Student extends Person 
  {
     protected String school;
     protected Set   courses = new LinkedHashSet();
  
     public void setSchool(String school)
     {
        this.school = school;
     }
  
     public String getSchool()
     {
        return this.school;
     }
     
     public void addCourse(Course course)
     {
        courses.add(course);
     }
     
     public void removeCourse(Course course)
     {
        courses.remove(course);
     }
     
     public Set getCourses()
     {
        return Collections.unmodifiableSet(courses);
     }
  
     public String toString()
     {
        StringBuffer buf = new StringBuffer();
        buf.append("{Name = " +name).append(", School = " +school);
        if (address != null)
           buf.append(", Address = " + address.getSimpleAddress());
        buf.append("}\n");
        buf.append("Courses:\n");
        for (Iterator iter = getCourses().iterator(); iter.hasNext(); )
           buf.append(iter.next());
  
        return buf.toString();
     }
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list