001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tctest.spring.bean;
005:
006: import org.springframework.beans.factory.BeanNameAware;
007:
008: import com.tc.aspectwerkz.proxy.Uuid;
009:
010: public class SimpleBean implements ISimpleBean, BeanNameAware {
011: private transient long id = System.identityHashCode(this )
012: + Uuid.newUuid();
013:
014: private transient long timeStamp = System.currentTimeMillis();
015: private long sharedId = 0;
016:
017: private static int instanceCnt = 0;
018:
019: private static String staticField = null;
020: private transient String transientField = null;
021: private String field = null;
022: private String dsoTransientField = null;
023:
024: private ISimpleBean sharedRef = null;
025: private transient ISimpleBean transientRef = null;
026: private transient ISimpleBean dsoTransientRef = null;
027:
028: private transient String beanName;
029:
030: public SimpleBean() {
031: synchronized (SimpleBean.class) {
032: instanceCnt++; // this should have the number of instance in one CL, assuming constructor is invoked
033: sharedId = timeStamp;
034: }
035: }
036:
037: public int getInstanceCnt() {
038: synchronized (SimpleBean.class) {
039: return instanceCnt;
040: }
041: }
042:
043: synchronized public String getStaticField() {
044: return staticField;
045: }
046:
047: synchronized public void setStaticField(String staticField) {
048: SimpleBean.staticField = staticField;
049: }
050:
051: synchronized public String getDsoTransientField() {
052: return dsoTransientField;
053: }
054:
055: synchronized public void setDsoTransientField(
056: String dsoTransientField) {
057: this .dsoTransientField = dsoTransientField;
058: }
059:
060: synchronized public String getField() {
061: return field;
062: }
063:
064: synchronized public void setField(String field) {
065: this .field = field;
066: }
067:
068: synchronized public ISimpleBean getTransientRef() {
069: return transientRef;
070: }
071:
072: synchronized public void setTransientRef(ISimpleBean transientChild) {
073: this .transientRef = transientChild;
074: }
075:
076: synchronized public String getTransientField() {
077: return transientField;
078: }
079:
080: synchronized public void setTransientField(String transientField) {
081: this .transientField = transientField;
082: }
083:
084: public int getHashCode() {
085: return hashCode();
086: }
087:
088: synchronized public long getId() {
089: return id;
090: }
091:
092: synchronized public long getSharedId() {
093: return sharedId;
094: }
095:
096: synchronized public void setSharedId(long sharedId) {
097: this .sharedId = sharedId;
098: }
099:
100: synchronized public ISimpleBean getDsoTransientRef() {
101: return dsoTransientRef;
102: }
103:
104: synchronized public void setDsoTransientRef(
105: ISimpleBean dsoTransientRef) {
106: this .dsoTransientRef = dsoTransientRef;
107: }
108:
109: synchronized public long getSharedRefId() {
110: return this .sharedRef == null ? -1 : sharedRef.getId();
111: }
112:
113: synchronized public ISimpleBean getSharedRef() {
114: return sharedRef;
115: }
116:
117: synchronized public void setSharedRef(ISimpleBean sharedRef) {
118: this .sharedRef = sharedRef;
119: }
120:
121: public long getTimeStamp() {
122: return timeStamp;
123: }
124:
125: public static class SBParent extends SimpleBean {
126: static private int myInstanceCnt = 0;
127:
128: public SBParent() {
129: synchronized (SimpleBean.class) {
130: myInstanceCnt++; // this should have the number of instance of this subtype in one CL, assuming constructor is invoked
131: }
132: }
133:
134: public int getInstanceCnt() {
135: synchronized (SimpleBean.class) {
136: return myInstanceCnt;
137: }
138: }
139: }
140:
141: public String getBeanName() {
142: return beanName;
143: }
144:
145: public void setBeanName(String beanName) {
146: this.beanName = beanName;
147: }
148: }
|