01: /*
02: * Created on Feb 12, 2004
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.xdev.base.xssl.manage;
08:
09: import java.io.BufferedWriter;
10: import java.io.OutputStream;
11: import java.io.OutputStreamWriter;
12: import java.io.Writer;
13: import java.util.HashMap;
14:
15: import org.xdev.base.xssl.XSSLAction;
16: import org.xdev.base.xssl.XSSLActionIterator;
17: import org.xdev.base.xssl.XSSLReturn;
18:
19: /**
20: * @author AYegorov
21: *
22: * To change the template for this generated type comment go to
23: * Window>Preferences>Java>Code Generation>Code and Comments
24: */
25: public class TransactionWriter extends XSSLActionIterator implements
26: ITransactionFinalizable {
27: protected Writer writer = null;
28:
29: /**
30: * @param id
31: */
32: public TransactionWriter(String id) {
33: super (id);
34: // XXX Auto-generated constructor stub
35: }
36:
37: /**
38: * @param id
39: * @param properties
40: */
41: public TransactionWriter(String id, HashMap properties) {
42: super (id, properties);
43: // XXX Auto-generated constructor stub
44: }
45:
46: /* (non-Javadoc)
47: * @see org.xdev.base.xssl.XSSLActionIterator#invoke(org.xdev.base.xssl.XSSLAction)
48: */
49: protected void invoke(XSSLAction component) throws Exception {
50:
51: if (component instanceof XSSLReturn) {
52:
53: Object obj = ((XSSLReturn) component).getObjectValue();
54:
55: if (obj != null) {
56: writer.write(obj.toString());
57: }
58: }
59:
60: }
61:
62: /* (non-Javadoc)
63: * @see org.xdev.base.xssl.XSSLAction#set()
64: */
65: protected void set() throws Exception {
66:
67: Object obj = this .getEvaluatedReference();
68:
69: if (obj instanceof OutputStream) {
70: this .writer = new BufferedWriter(new OutputStreamWriter(
71: (OutputStream) obj));
72: } else {
73: this .writer = (Writer) obj;
74: }
75: }
76:
77: public void doFinalize() throws Exception {
78: this.writer.flush();
79: this.writer.close();
80: }
81: }
|