[jboss-cvs] JBossCache/old/tests/functional/org/jboss/cache/aop/test ...
Ben Wang
bwang at jboss.com
Tue Oct 31 03:01:14 EST 2006
User: bwang
Date: 06/10/31 03:01:14
Added: old/tests/functional/org/jboss/cache/aop/test
NetworkAdmin.java Address.java ValueObject.java
IdObject.java Link.java NetworkNode.java
SpecialSerializedAddress.java CacheObject.java
Person.java NonSerializableObject.java
NodeManager.java SerializedAddress.java
Student.java TestNode.java NetworkDomain.java
NetworkElement.java
Log:
Deprecated files moved to old dir.
Revision Changes Path
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/NetworkAdmin.java
Index: NetworkAdmin.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
/**
* Sample object that contains administration details.
* <p>This object is used to illustrate the pojo cache capability of JBossCache. Note the absence of <code>Serializable</code>
* interface.</p>
*
* @author <a href="mailto:ben.wang at jboss.com">Ben Wang</a>
*
* @@org.jboss.cache.aop.AopMarker
*/
public class NetworkAdmin
{
String id_;
public String getId()
{
return id_;
}
public void setId(String id)
{
id_ = id;
}
public String toString()
{
StringBuffer sb=new StringBuffer();
sb.append(" id = ").append(getId());
return sb.toString();
}
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/Address.java
Index: Address.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
import java.util.Collection;
import java.util.Vector;
import java.util.Iterator;
/**
* Test class for TreeCacheAOP.
*
* @version $Revision: 1.1 $
* <p>Below is the annotation that signifies this class is "prepared" under JBossAop. This is used in
* conjunction with a special jboss-aop.xml (supplied by JBossCache). In addition, this is JDK1.4 style,
* so a annoc Ant build target is needed to pre-compile it.</p>
* <p>To use this approach, just apply this line to your pojo and run annoc (and possibly aopc).</p>
* @@org.jboss.cache.aop.AopMarker
*/
public class Address
{
String street = null;
String city = null;
int zip = 0;
public String getStreet()
{
return street;
}
public void setStreet(String street)
{
this.street = street;
}
public String getCity()
{
return city;
}
public void setCity(String city)
{
this.city = city;
}
public int getZip()
{
return zip;
}
public void setZip(int zip)
{
this.zip = zip;
}
public String toString()
{
return "street=" + getStreet() + ", city=" + getCity() + ", zip=" + getZip();
}
// public Object writeReplace() {
// return this;
// }
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/ValueObject.java
Index: ValueObject.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
/**
* Object to test non-primitive key.
* @@org.jboss.cache.aop.InstanceOfAopMarker
*/
public class ValueObject {
private IdObject idObj;
private float value;
public ValueObject() {
} // ValueObject
public ValueObject(IdObject aIdObj, float aValue) {
idObj = aIdObj;
value = aValue;
} // ValueObject
public IdObject getIdObj() {
return idObj;
}
public float getValue() {
return value;
}
public String toString() {
return idObj + ": " + value;
} // toString
public boolean equals(Object aObject) {
boolean result = false;
if ((aObject != null) &&
(aObject.getClass().getName().equals( this.getClass().getName()))) {
result = idObj.equals(((ValueObject)aObject).idObj);
} // if
return result;
} // equals
public int hashCode() {
return idObj.hashCode();
} // hashCode
} // class ValueObject
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/IdObject.java
Index: IdObject.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
/**
* Key object that overrides the hashCode that can cause problem for aop.
* @@org.jboss.cache.aop.InstanceOfAopMarker
*/
public class IdObject{
private String id;
public IdObject() {
} // IdObject
public IdObject(String aId) {
id = aId;
} // IdObject
public String toString() {
return id;
} // toString
public boolean equals(Object aObject) {
boolean result = false;
if ((aObject != null) &&
(aObject.getClass().getName().equals( this.getClass().getName()))) {
if (id.equals(((IdObject)aObject).id)) {
result = true;
} // if
} // if
return result;
} // equals
public int hashCode() {
return id.hashCode();
} // hashCode
} // class IdObject
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/Link.java
Index: Link.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
/**
* Test class for TreeCacheAOP for circular references.
* Link is a POJO that will be instrumentet with CacheInterceptor
*
* @version $Revision: 1.1 $
* <p>Below is the annotation that signifies this class is "prepared" under JBossAop. This is used in
* conjunction with a special jboss-aop.xml (supplied by JBossCache). In addition, this is JDK1.4 style,
* so a annoc Ant build target is needed to pre-compile it.</p>
* <p>To use this approach, just apply this line to your pojo and run annoc (and possibly aopc).</p>
* @@org.jboss.cache.aop.AopMarker
*/
public class Link
{
Link link_;
String name_;
public Link()
{
}
public Link(String name)
{
name_ = name;
}
public void setName(String linkName)
{
name_ = linkName;
}
public String getName()
{
return name_;
}
public void setLink(Link link)
{
link_ = link;
}
public Link getLink()
{
return link_;
}
public String toString()
{
StringBuffer buf = new StringBuffer();
buf.append("Link: name " + name_);
return buf.toString();
}
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/NetworkNode.java
Index: NetworkNode.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
import java.util.List;
import java.util.ArrayList;
/**
* Usually corresponds to the physical machine that comparises of various devices.
* <p>This object is used to illustrate the pojo cache capability of JBossCache. Note the absence of <code>Serializable</code>
* interface.</p>
*
* @author <a href="mailto:ben.wang at jboss.com">Ben Wang</a>
*
* @@org.jboss.cache.aop.InstanceOfAopMarker
*/
public class NetworkNode
{
String name_;
List elements_;
String ipAddress_;
public String getName()
{
return name_;
}
public void setName(String name)
{
name_ = name;
}
public List getElements()
{
return elements_;
}
protected void setElements(List elements)
{
elements_ = elements;
}
public void addElement(NetworkElement element)
{
if(elements_ == null)
elements_ = new ArrayList();
elements_.add(element);
element.setParentNode(this);
}
public String getIpAddress()
{
return ipAddress_;
}
public void setIpAddress(String ipAddress)
{
ipAddress_ = ipAddress;
}
public String toString()
{
StringBuffer sb=new StringBuffer();
sb.append(" name= ").append(getName()).append(" ipAddress= ").append(getIpAddress());
sb.append(" elements=").append(getElements());
return sb.toString();
}
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/SpecialSerializedAddress.java
Index: SpecialSerializedAddress.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
/**
* Test class for TreeCacheAOP.
*
* @version $Revision: 1.1 $
* <p>Below is the annotation that signifies this class is "prepared" under JBossAop. This is used in
* conjunction with a special jboss-aop.xml (supplied by JBossCache). In addition, this is JDK1.4 style,
* so a annoc Ant build target is needed to pre-compile it.</p>
* <p>To use this approach, just apply this line to your pojo and run annoc (and possibly aopc).</p>
* @@org.jboss.cache.aop.AopMarker
*/
public class SpecialSerializedAddress implements Serializable
{
String street = null;
String city = null;
int zip = 0;
List residents = new ArrayList();
public List getResidents() {
return residents;
}
public void setResidents(List residents) {
this.residents = residents;
}
public void addResidents(String name)
{
residents.add(name);
}
public String getStreet()
{
return street;
}
public void setStreet(String street)
{
this.street = street;
}
public String getCity()
{
return city;
}
public void setCity(String city)
{
this.city = city;
}
public int getZip()
{
return zip;
}
public void setZip(int zip)
{
this.zip = zip;
}
public String toString()
{
return "street=" + getStreet() + ", city=" + getCity() + ", zip=" + getZip();
}
// public Object writeReplace() {
// return this;
// }
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/CacheObject.java
Index: CacheObject.java
===================================================================
package org.jboss.cache.aop.test;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
/**
* Object to bind in cache
*/
public class CacheObject implements Serializable
{
private String id;
private Set identities;
public CacheObject(String id)
{
this.id = id;
this.identities = new HashSet();
}
public String getId()
{
return id;
}
public Set getIdentities()
{
return identities;
}
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/Person.java
Index: Person.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
import java.util.*;
/**
* Test class for TreeCacheAOP.
* Person is a POJO that will be instrumented with CacheInterceptor
*
* @version $Revision: 1.1 $
* <p>Below is the annotation that signifies this class is "prepared" under JBossAop. This is used in
* conjunction with a special jboss-aop.xml (supplied by JBossCache). In addition, this is JDK1.4 style,
* so a annoc Ant build target is needed to pre-compile it.</p>
* <p>To use this approach, just apply this line to your pojo and run annoc (and possibly aopc).</p>
* @@org.jboss.cache.aop.InstanceOfAopMarker
*/
public class Person
{
String name = null;
int age = 0;
Map hobbies = null;
Address address = null;
Set skills;
List languages;
// Test for transient field non-replication
transient String currentStatus = "Active";
// Test swapping out the Collection ref with proxy one
// medication will be different when age limit is exceeded.
List medication = null;
static final int AGE1 = 50;
static final int AGE2 = 60;
public Person() {
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public void setCurrentStatus(String status) {
currentStatus = status;
}
public String getCurrentStatus() {
return currentStatus;
}
public void setName(Object obj)
{
this.name = (String)obj;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
// This will swap out the reference dynamically
if(age < AGE1) {
if(medication != null) {
medication.clear();
medication=null;
}
}
else {
if( age >= AGE1 ) {
addMedication("Lipitor");
}
if (age >= AGE2) {
addMedication("Vioxx");
}
}
}
void addMedication(String name) {
if( medication == null )
medication = new ArrayList();
if(!medication.contains(name))
medication.add(name);
}
public Map getHobbies()
{
return hobbies;
}
public void setHobbies(Map hobbies)
{
this.hobbies = hobbies;
}
public Address getAddress()
{
return address;
}
public void setAddress(Address address)
{
this.address = address;
}
public Set getSkills()
{
return skills;
}
public void setSkills(Set skills)
{
this.skills = skills;
}
public List getMedication()
{
return medication;
}
public void setMedication(List medication)
{
this.medication = medication;
}
public List getLanguages()
{
return languages;
}
public void setLanguages(List languages)
{
this.languages = languages;
}
public String toString()
{
StringBuffer sb=new StringBuffer();
sb.append("name=").append(getName()).append(", age=").append(getAge()).append(", hobbies=")
.append(print(getHobbies())).append(", address=").append(getAddress()).append(", skills=")
.append(skills).append(", languages=").append(languages).toString();
if(medication != null)
sb.append(", medication=" + medication);
return sb.toString();
}
public String print(Map m)
{
StringBuffer sb = new StringBuffer();
Map.Entry entry;
if (m != null) {
for (Iterator it = m.entrySet().iterator(); it.hasNext();) {
entry = (Map.Entry) it.next();
sb.append(entry.getKey()).append(": ").append(entry.getValue());
sb.append("\n");
}
}
return sb.toString();
}
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/NonSerializableObject.java
Index: NonSerializableObject.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
/**
* A non-serializable object
*/
public class NonSerializableObject {
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public NonSerializableObject() {
}
public NonSerializableObject(String aId) {
id = aId;
}
public String toString() {
return id;
}
public boolean equals(Object aObject) {
boolean result = false;
if ((aObject != null) &&
(aObject.getClass().getName().equals( this.getClass().getName()))) {
if (id.equals(((NonSerializableObject)aObject).id)) {
result = true;
} // if
} // if
return result;
} // equals
public int hashCode() {
return id.hashCode();
} // hashCode
} // class IdObject
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/NodeManager.java
Index: NodeManager.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
/**
* Test class for TreeCacheAOP for circular references.
* Link is a POJO that will be instrumentet with CacheInterceptor
*
* @version $Revision: 1.1 $
* <p>Below is the annotation that signifies this class is "prepared" under JBossAop. This is used in
* conjunction with a special jboss-aop.xml (supplied by JBossCache). In addition, this is JDK1.4 style,
* so a annoc Ant build target is needed to pre-compile it.</p>
* <p>To use this approach, just apply this line to your pojo and run annoc (and possibly aopc).</p>
* @@org.jboss.cache.aop.AopMarker
*/
public class NodeManager
{
private TestNode rootNode_;
private Map nodeMap_ = new HashMap();
public NodeManager()
{
}
public void setRootNode(String rdn)
{
this.rootNode_ = new TestNode();
rootNode_.setNodeFDN(rdn);
rootNode_.setNodeRDN(rdn);
registMap(rootNode_);
}
public void addNode(String parentFdn, String rdn)
{
TestNode parent = findNode(parentFdn);
if (parent != null)
{
TestNode node = new TestNode();
node.setNodeFDN(parentFdn + "." + rdn);
node.setNodeRDN(rdn);
node.setParentNode(parent);
parent.addChildNode(node);
registMap(node);
}
}
public TestNode findNode(String fdn)
{
return (TestNode) nodeMap_.get(fdn);
}
private void registMap(TestNode node)
{
this.nodeMap_.put(node.getNodeFDN(), node);
}
public void printNodes()
{
printNode(rootNode_, "");
}
private void printNode(TestNode node, String prefix)
{
System.out.println(prefix + node.getNodeRDN());
String childPrefix = prefix + " + ";
List children = node.getChildren();
int size = children.size();
for (int idx = 0; idx < size; idx++)
{
TestNode child = (TestNode) children.get(idx);
printNode(child, childPrefix);
}
}
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/SerializedAddress.java
Index: SerializedAddress.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
import java.io.Serializable;
/**
* Test class for TreeCacheAOP.
*
* @version $Revision: 1.1 $
*/
public class SerializedAddress implements Serializable
{
String street = null;
String city = null;
int zip = 0;
public String getStreet()
{
return street;
}
public void setStreet(String street)
{
this.street = street;
}
public String getCity()
{
return city;
}
public void setCity(String city)
{
this.city = city;
}
public int getZip()
{
return zip;
}
public void setZip(int zip)
{
this.zip = zip;
}
public String toString()
{
return "street=" + getStreet() + ", city=" + getCity() + ", zip=" + getZip();
}
// public Object writeReplace() {
// return this;
// }
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/Student.java
Index: Student.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
/**
* Test class for TreeCacheAOP.
* Student is a POJO that will be instrumentet with CacheInterceptor
*
* @version $Revision: 1.1 $
* No need to declare annotation here since Person is an instanceof already.
*/
public class Student extends Person
{
private String year;
// co is Serializable not Advised
private CacheObject co1;
private CacheObject co2;
public String getYear() { return year; }
public void setYear(String year) { this.year = year; }
public CacheObject getCO1()
{
return co1;
}
public void setCO1(CacheObject co)
{
this.co1 = co;
}
public CacheObject getCO2()
{
return co2;
}
public void setCO2(CacheObject co)
{
this.co2 = co;
}
public String toString()
{
return "year=" + getYear() + " " + super.toString();
}
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/TestNode.java
Index: TestNode.java
===================================================================
package org.jboss.cache.aop.test;
import java.util.List;
import java.util.ArrayList;
/**
*
* @@org.jboss.cache.aop.AopMarker
*/
public class TestNode
{
private String rdn_;
private String fdn_;
private List childNodes_ = new ArrayList();
private TestNode parentNode_;
public TestNode()
{
}
public void setNodeRDN(String rdn)
{
this.rdn_ = rdn;
}
public String getNodeRDN()
{
return this.rdn_;
}
public void setNodeFDN(String fdn)
{
this.fdn_ = fdn;
}
public String getNodeFDN()
{
return this.fdn_;
}
public void addChildNode(TestNode child)
{
childNodes_.add(child);
}
public List getChildren()
{
return childNodes_;
}
public void setParentNode(TestNode parent)
{
parentNode_ = parent;
}
public TestNode getParentNode()
{
return this.parentNode_;
}
public String toString()
{
return getNodeFDN();
}
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/NetworkDomain.java
Index: NetworkDomain.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
import java.util.List;
import java.util.ArrayList;
/**
* <p>Top level sample Pojo for a sample network management software. It is a logical object that can be presented to
* the user. Example of domain is like temperature or vibration sensor domains.</p>
* <p>This object is used to illustrate the pojo cache capability of JBossCache. Note the absence of <code>Serializable</code>
* interface.</p>
*
* @author <a href="mailto:ben.wang at jboss.com">Ben Wang</a>
*
* @@org.jboss.cache.aop.InstanceOfAopMarker
*/
public class NetworkDomain
{
String name_;
// The associated nodes from the elements
List nodes_;
// All the elements to be managed in this domain
List elements_;
// Adminstration such id, pass
NetworkAdmin admin_;
static final int TEMP_SENSOR = 0;
static final int VIBRATION_SENSOR = 1;
public String getName()
{
return name_;
}
public void setName(String name)
{
name_ = name;
}
public List getNodes()
{
return nodes_;
}
protected void setNodes(List nodes)
{
nodes_ = nodes;
}
public List getElements()
{
return nodes_;
}
protected void addNode(NetworkNode node)
{
if(nodes_ == null)
nodes_ = new ArrayList();
nodes_.add(node);
}
public void addElement(NetworkElement element)
{
if(elements_ == null)
elements_ = new ArrayList();
elements_.add(element);
if(element.getParentNode() == null)
throw new RuntimeException("NetworkDomain.addElement(): parent node of element is null: " +element);
addNode(element.getParentNode());
}
public NetworkAdmin getAdmin()
{
return admin_;
}
public void setAdmin(NetworkAdmin admin)
{
admin_ = admin;
}
public String toString()
{
StringBuffer sb=new StringBuffer();
sb.append("* Damain * name= ").append(getName()).append(" + admin +: ").append(getAdmin());
sb.append(" + nodes +: ").append(getNodes());
return sb.toString();
}
}
1.1 date: 2006/10/31 08:01:14; author: bwang; state: Exp;JBossCache/old/tests/functional/org/jboss/cache/aop/test/NetworkElement.java
Index: NetworkElement.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.aop.test;
import java.util.*;
/**
* Can represent both software or devices (e.g., sensor).
* <p>This object is used to illustrate the pojo cache capability of JBossCache. Note the absence of <code>Serializable</code>
* interface.</p>
*
* @author <a href="mailto:ben.wang at jboss.com">Ben Wang</a>
*
* @@org.jboss.cache.aop.InstanceOfAopMarker
*/
public class NetworkElement
{
// Unique id
int id_;
// Element type
int type_;
String name_;
int status_;
Date startDate_;
NetworkNode parentNode_;
public int getId() { return id_;}
public void setId(int id) { id_ = id; }
public int getType() { return type_; }
public void setType(int type) { type_ = type; }
public String getName()
{
return name_;
}
public void setName(String name)
{
name_ = name;
}
public int getStatus()
{
return status_;
}
public void setStatus(int status)
{
status_ = status;
}
public Date getStartDate()
{
return startDate_;
}
public void setStartDate(Date startDate)
{
startDate_ = startDate;
}
public NetworkNode getParentNode()
{
return parentNode_;
}
public void setParentNode(NetworkNode parentNode)
{
parentNode_ = parentNode;
}
public String toString()
{
StringBuffer sb=new StringBuffer();
sb.append(" name= ").append(getName()).append(" status= ").append(getStatus());
sb.append(" parentNode= ").append(getParentNode().getName());
return sb.toString();
}
}
More information about the jboss-cvs-commits
mailing list