001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.cmp2.lob;
023:
024: import javax.ejb.EntityBean;
025: import javax.ejb.EntityContext;
026: import javax.ejb.CreateException;
027: import javax.ejb.RemoveException;
028: import java.util.Map;
029: import java.util.List;
030: import java.util.Set;
031: import java.util.HashMap;
032: import java.util.ArrayList;
033: import java.util.HashSet;
034:
035: /**
036: * Implementaton of a CMP2 entity bean that is intended to demonstrate the
037: * storage of large text and binary objects.
038: *
039: * @see javax.ejb.EntityBean
040: *
041: * @version <tt>$Revision: 57211 $</tt>
042: * @author <a href="mailto:steve@resolvesw.com">Steve Coy</a>
043: * @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
044: */
045: public abstract class LOBBean implements EntityBean {
046: private EntityContext mEntityContext;
047:
048: /**
049: * Returns the primary key
050: * @return Integer
051: */
052: public abstract Integer getId();
053:
054: /**
055: * Sets the primary key.
056: * @param id
057: */
058: public abstract void setId(Integer id);
059:
060: /**
061: * Returns the large string attribute.
062: * @return String
063: */
064: public abstract String getBigString();
065:
066: /**
067: * Sets the value of the large string attribute.
068: * The idea here is to store it in a CLOB object in associated database table
069: * so that we can check the container's LOB functionality properly.
070: * @param s
071: */
072: public abstract void setBigString(String s);
073:
074: /**
075: * Returns the content of the large binary object.
076: * @return byte[]
077: */
078: public abstract byte[] getBinaryData();
079:
080: /**
081: * Sets the content of the large binary object.
082: * The idea here is to store it in a BLOB object in the associated database
083: * table so that we check the container's LOB functionality properly.
084: * @param data
085: */
086: public abstract void setBinaryData(byte[] data);
087:
088: public abstract Object getObjectField();
089:
090: public abstract void setObjectField(Object obj);
091:
092: public abstract Map getMapField();
093:
094: public abstract void setMapField(Map map);
095:
096: public abstract List getListField();
097:
098: public abstract void setListField(List list);
099:
100: public abstract Set getSetField();
101:
102: public abstract void setSetField(Set set);
103:
104: public abstract ValueHolder getValueHolder();
105:
106: public abstract void setValueHolder(ValueHolder valueHolder);
107:
108: public abstract ValueHolder getCleanGetValueHolder();
109:
110: public abstract void setCleanGetValueHolder(ValueHolder valueHolder);
111:
112: public abstract ValueHolder getStateFactoryValueHolder();
113:
114: public abstract void setStateFactoryValueHolder(
115: ValueHolder valueHolder);
116:
117: // EntityBean implementation
118:
119: public Integer ejbCreate(Integer id) throws CreateException {
120: setId(id);
121: setMapField(new HashMap());
122: setListField(new ArrayList());
123: setSetField(new HashSet());
124: setValueHolder(new ValueHolder(null));
125: setCleanGetValueHolder(new ValueHolder(null));
126: setStateFactoryValueHolder(new ValueHolder(null));
127: return null;
128: }
129:
130: public void ejbPostCreate(Integer id) {
131: }
132:
133: public void ejbActivate() {
134: }
135:
136: public void ejbLoad() {
137: }
138:
139: public void ejbPassivate() {
140: }
141:
142: public void ejbRemove() throws RemoveException {
143: }
144:
145: public void ejbStore() {
146: }
147:
148: public void setEntityContext(EntityContext ctx) {
149: mEntityContext = ctx;
150: }
151:
152: public void unsetEntityContext() {
153: mEntityContext = null;
154: }
155: }
|