KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cmp2 > lob > LOBBean


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.test.cmp2.lob;
23
24 import javax.ejb.EntityBean JavaDoc;
25 import javax.ejb.EntityContext JavaDoc;
26 import javax.ejb.CreateException JavaDoc;
27 import javax.ejb.RemoveException JavaDoc;
28 import java.util.Map JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.Set JavaDoc;
31 import java.util.HashMap JavaDoc;
32 import java.util.ArrayList JavaDoc;
33 import java.util.HashSet JavaDoc;
34
35 /**
36  * Implementaton of a CMP2 entity bean that is intended to demonstrate the
37  * storage of large text and binary objects.
38  *
39  * @see javax.ejb.EntityBean
40  *
41  * @version <tt>$Revision: 56720 $</tt>
42  * @author <a HREF="mailto:steve@resolvesw.com">Steve Coy</a>
43  * @author <a HREF="mailto:alex@jboss.org">Alexey Loubyansky</a>
44  */

45 public abstract class LOBBean implements EntityBean JavaDoc
46 {
47    private EntityContext JavaDoc mEntityContext;
48
49    /**
50     * Returns the primary key
51     * @return Integer
52     */

53    public abstract Integer JavaDoc getId();
54
55    /**
56     * Sets the primary key.
57     * @param id
58     */

59    public abstract void setId(Integer JavaDoc id);
60
61    /**
62     * Returns the large string attribute.
63     * @return String
64     */

65    public abstract String JavaDoc getBigString();
66
67     /**
68      * Sets the value of the large string attribute.
69      * The idea here is to store it in a CLOB object in associated database table
70      * so that we can check the container's LOB functionality properly.
71      * @param s
72      */

73    public abstract void setBigString(String JavaDoc s);
74
75     /**
76      * Returns the content of the large binary object.
77      * @return byte[]
78      */

79    public abstract byte[] getBinaryData();
80
81     /**
82      * Sets the content of the large binary object.
83      * The idea here is to store it in a BLOB object in the associated database
84      * table so that we check the container's LOB functionality properly.
85      * @param data
86      */

87    public abstract void setBinaryData(byte[] data);
88
89    public abstract Object JavaDoc getObjectField();
90    public abstract void setObjectField(Object JavaDoc obj);
91
92    public abstract Map JavaDoc getMapField();
93    public abstract void setMapField(Map JavaDoc map);
94
95    public abstract List JavaDoc getListField();
96    public abstract void setListField(List JavaDoc list);
97
98    public abstract Set JavaDoc getSetField();
99    public abstract void setSetField(Set JavaDoc set);
100
101    public abstract ValueHolder getValueHolder();
102    public abstract void setValueHolder(ValueHolder valueHolder);
103
104    public abstract ValueHolder getCleanGetValueHolder();
105    public abstract void setCleanGetValueHolder(ValueHolder valueHolder);
106
107    public abstract ValueHolder getStateFactoryValueHolder();
108    public abstract void setStateFactoryValueHolder(ValueHolder valueHolder);
109
110    
111    // EntityBean implementation
112

113    public Integer JavaDoc ejbCreate(Integer JavaDoc id) throws CreateException JavaDoc
114    {
115       setId(id);
116       setMapField(new HashMap JavaDoc());
117       setListField(new ArrayList JavaDoc());
118       setSetField(new HashSet JavaDoc());
119       setValueHolder(new ValueHolder(null));
120       setCleanGetValueHolder(new ValueHolder(null));
121       setStateFactoryValueHolder(new ValueHolder(null));
122       return null;
123    }
124
125    public void ejbPostCreate(Integer JavaDoc id) {}
126
127    public void ejbActivate() {}
128    public void ejbLoad() {}
129    public void ejbPassivate() {}
130    public void ejbRemove() throws RemoveException JavaDoc {}
131    public void ejbStore() {}
132
133    public void setEntityContext(EntityContext JavaDoc ctx)
134    {
135       mEntityContext = ctx;
136    }
137
138    public void unsetEntityContext()
139    {
140       mEntityContext = null;
141    }
142 }
143
Popular Tags