001: /*
002: * Created on Jul 10, 2003
003: *
004: * JtestInteraction.java is used to test the J2EE Connector
005: * as implemented by JOnAS. This class implements the Interaction and InteractionSpec
006: * (cci) classes.
007: *
008: */
009: package fictional.resourceadapter;
010:
011: import javax.resource.ResourceException;
012: import javax.resource.NotSupportedException;
013: import javax.resource.cci.*;
014: import javax.resource.spi.*; // logger imports
015: import org.objectweb.jonas.common.Log;
016: import org.objectweb.util.monolog.api.Logger;
017: import org.objectweb.util.monolog.api.BasicLevel;
018:
019: /**
020: * @author Bob Kruse
021: *
022: * Jtest Resource Adapter
023: *
024: * used to test the J2EE Connector as implemented by JOnAS.
025: *
026: */
027: public class JtestInteraction implements Interaction, InteractionSpec,
028: java.io.Serializable {
029:
030: private Record output;
031: private boolean closed = false;
032: private Connection con;
033: private ManagedConnection mcon;
034: private Logger logger = null;
035: String cName = "";
036:
037: public JtestInteraction(Connection c) {
038: cName = "Interaction";
039: if (logger == null) {
040: logger = Log.getLogger("fictional.resourceadapter");
041: }
042: logger.log(BasicLevel.DEBUG, cName + ".constructor");
043: con = c;
044: }
045:
046: public JtestInteraction(Connection c, ManagedConnection mc) {
047: cName = "Interaction";
048: if (logger == null) {
049: logger = Log.getLogger("fictional.resourceadapter");
050: }
051: logger.log(BasicLevel.DEBUG, cName + ".constructor");
052: con = c;
053: mcon = mc;
054: }
055:
056: private String impl(Object obj) {
057: if (obj instanceof Interaction) {
058: return "Interaction";
059: } else if (obj instanceof InteractionSpec) {
060: return "InteractionSpec";
061: } else
062: return "InteractionSpec. Is this an error";
063: }
064:
065: /****************************
066: * Interaction methods
067: ****************************/
068: public boolean execute(InteractionSpec ispec, Record input,
069: Record output) throws ResourceException {
070: cName = "Interaction";
071: logger.log(BasicLevel.DEBUG, cName + ".execute");
072: this .output = input;
073: return (true);
074: }
075:
076: public Record execute(InteractionSpec ispec, Record input)
077: throws ResourceException {
078: cName = "Interaction";
079: logger.log(BasicLevel.DEBUG, cName + ".execute");
080: return (output);
081: }
082:
083: public void close() throws ResourceException {
084: cName = "Interaction";
085: logger.log(BasicLevel.DEBUG, cName + ".close");
086: closed = true;
087: }
088:
089: public Connection getConnection() {
090: cName = "Interaction";
091: logger.log(BasicLevel.DEBUG, cName + ".getConnection");
092: return con;
093: }
094:
095: public ResourceWarning getWarnings() throws ResourceException {
096: cName = "Interaction";
097: logger.log(BasicLevel.DEBUG, cName + ".getWarnings");
098: NotSupportedException nse = new NotSupportedException(
099: "Interaction.getWarnings is not currently supported");
100: throw nse;
101: }
102:
103: public void clearWarnings() throws ResourceException {
104: cName = "Interaction";
105: logger.log(BasicLevel.DEBUG, cName + ".clearWarnings");
106: NotSupportedException nse = new NotSupportedException(
107: "Interaction.clearWarnings is not currently supported");
108: throw nse;
109: }
110:
111: /****************************
112: * InteractionSpec methods
113: ****************************/
114: // standard properties
115: private int interactionVerb;
116: // SYNC_SEND =0 These interactionVerb values are from
117: // SYNC_SEND_RECEIVE =1 Constant Field Values of J2EE API
118: // SYNC_RECEIVE =2
119:
120: private String FunctionName;
121: private int ExecutionTimeout;
122: private int FetchSize;
123: private int FetchDirection;
124: private int MaxFieldSize;
125: private int ResultSetType;
126: private int ResultSetConcurrency;
127:
128: public JtestInteraction() {
129: cName = "InteractionSpec";
130: if (logger == null) {
131: logger = Log.getLogger("fictional.resourceadapter");
132: }
133: logger.log(BasicLevel.DEBUG, cName + ".constructor");
134: interactionVerb = SYNC_SEND_RECEIVE;
135: FunctionName = "";
136: FetchDirection = 0;
137: ExecutionTimeout = 2000;
138: FetchSize = 30;
139: MaxFieldSize = 444;
140: ResultSetType = 5;
141: ResultSetConcurrency = 6;
142: }
143:
144: public void setFunctionName(String n) {
145: FunctionName = n;
146: }
147:
148: public String getFunctionName() {
149: return (FunctionName);
150: }
151:
152: public void setInteractionVerb(int verb) {
153: interactionVerb = verb;
154: }
155:
156: public int getInteractionVerb() {
157: return (interactionVerb);
158: }
159:
160: public void setExecutionTimeout(int verb) {
161: ExecutionTimeout = verb;
162: }
163:
164: public int getExecutionTimeout() {
165: return (ExecutionTimeout);
166: }
167:
168: public void setFetchSize(int x) {
169: FetchSize = x;
170: ;
171: }
172:
173: public int getFetchSize() {
174: return (FetchSize);
175: }
176:
177: public void setFetchDirection(int x) {
178: FetchDirection = x;
179: ;
180: }
181:
182: public int getFetchDirection() {
183: return (FetchDirection);
184: }
185:
186: public void setMaxFieldSize(int x) {
187: MaxFieldSize = x;
188: ;
189: }
190:
191: public int getMaxFieldSize() {
192: return (MaxFieldSize);
193: }
194:
195: public void setResultSetType(int x) {
196: ResultSetType = x;
197: }
198:
199: public int getResultSetType() {
200: return (ResultSetType);
201: }
202:
203: public void setResultSetConcurrency(int x) {
204: ResultSetConcurrency = x;
205: ;
206: }
207:
208: public int getResultSetConcurrency() {
209: return (ResultSetConcurrency);
210: }
211: }
|