KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > test > CustomActivationDepth


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10 Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11 Suite 350, San Mateo, CA 94403, USA.
12
13 db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

21 package com.db4o.test;
22
23 import com.db4o.*;
24
25 /**
26  *
27  */

28 public class CustomActivationDepth {
29     
30     int myInt;
31     String JavaDoc myString;
32     int[] ints;
33     String JavaDoc[] strings;
34     
35     CA1 ca1;
36     CA2 ca2;
37     CA3 ca3;
38     
39     CA1[] ca1s;
40     CA2[] ca2s;
41     CA3[] ca3s;
42     
43     
44     public void configure(){
45         Db4o.configure().objectClass(CA1.class).maximumActivationDepth(1);
46     }
47     
48     
49     public void storeOne(){
50         myInt = 7;
51         myString = "seven";
52         ints = new int[]{77};
53         strings = new String JavaDoc[]{"sevenseven"};
54         ca1 = new CA1("1");
55         ca2 = new CA2("2");
56         ca3 = new CA3("3");
57         
58         ca1s = new CA1[] {new CA1("1arr1"), new CA1("1arr2")};
59         ca2s = new CA2[] {new CA2("2arr1"), new CA2("2arr2")};
60         ca3s = new CA3[] {new CA3("3arr1"), new CA3("3arr2")};
61         
62         Db4o.configure().activationDepth(0);
63     }
64     
65     public void testOne(){
66         Test.objectContainer().activate(this, 10);
67         
68         Test.objectContainer().activate(this.ca1, 10);
69         
70         Db4o.configure().activationDepth(5);
71     }
72     
73     public static class CA1{
74         
75         public String JavaDoc name;
76         
77         public CA2 ca2;
78         
79         public CA1(){
80             
81         }
82         
83         public CA1(String JavaDoc name){
84             this.name = name;
85             ca2 = new CA2(name + ".2");
86         }
87         
88         
89     }
90     
91     public static class CA2{
92         
93         public String JavaDoc name;
94         
95         public CA3 ca3;
96         
97         public CA2(){
98             
99         }
100         
101         public CA2(String JavaDoc name){
102             this.name = name;
103             ca3 = new CA3(name + ".3");
104         }
105     
106     }
107     
108     
109     public static class CA3{
110         
111         public String JavaDoc name;
112         
113         public CA3(){
114             
115         }
116         
117         public CA3(String JavaDoc name){
118             this.name = name;
119         }
120     
121     }
122
123     
124     
125     
126
127 }
128
Popular Tags