1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package de.bea.domingo.proxy;
23
24 import lotus.domino.Log;
25 import lotus.domino.NotesException;
26 import de.bea.domingo.DBase;
27 import de.bea.domingo.DLog;
28 import de.bea.domingo.DNotesMonitor;
29 import de.bea.domingo.DSession;
30
31 /***
32 * A notes Log.
33 *
34 * @author <a href="mailto:kriede@users.sourceforge.net">Kurt Riede</a>
35 */
36 public final class LogProxy extends BaseProxy implements DLog {
37
38 /*** serial version ID for serialization. */
39 private static final long serialVersionUID = 3762817086526863668L;
40
41 /***
42 * Constructor.
43 *
44 * @param theFactory the controlling factory
45 * @param parent the parent object
46 * @param log the Notes log object
47 * @param monitor the monitor
48 */
49 private LogProxy(final NotesProxyFactory theFactory, final DBase parent,
50 final Log log, final DNotesMonitor monitor) {
51 super(theFactory, parent, log, monitor);
52 getFactory().preprocessMethod();
53 }
54
55 /***
56 * Creates an notes log.
57 *
58 * @param theFactory the controlling factory
59 * @param session the Notes Session
60 * @param theLog the Notes Log
61 * @param monitor the monitor
62 * @return a log object
63 */
64 static DLog getInstance(final NotesProxyFactory theFactory, final DSession session,
65 final Log theLog, final DNotesMonitor monitor) {
66 if (theLog == null) {
67 return null;
68 }
69 LogProxy logProxy = (LogProxy) theFactory.getBaseCache().get(theLog);
70 if (logProxy == null) {
71 logProxy = new LogProxy(theFactory, session, theLog, monitor);
72 theFactory.getBaseCache().put(theLog, logProxy);
73 }
74 return logProxy;
75 }
76
77 /***
78 * Returns the notes log object.
79 *
80 * @return the notes log object
81 */
82 private Log getLog() {
83 return (Log) getNotesObject();
84 }
85
86 /***
87 * {@inheritDoc}
88 * @see de.bea.domingo.DLog#logAction(java.lang.String)
89 */
90 public void logAction(final String text) {
91 getFactory().preprocessMethod();
92 try {
93 getLog().logAction(text);
94 } catch (NotesException e) {
95 throw newRuntimeException("Cannot log action", e);
96 }
97 }
98
99 /***
100 * {@inheritDoc}
101 * @see de.bea.domingo.DLog#logError(int, java.lang.String)
102 */
103 public void logError(final int code, final String text) {
104 getFactory().preprocessMethod();
105 try {
106 getLog().logError(code, text);
107 } catch (NotesException e) {
108 throw newRuntimeException("Cannot log error", e);
109 }
110 }
111
112 /***
113 * @see java.lang.Object#toString()
114 * @return a string representation of the object.
115 */
116 public String toString() {
117 return super.toStringIntern(this);
118 }
119
120 /***
121 * {@inheritDoc}
122 * @see de.bea.domingo.DLog#openNotesLog(java.lang.String, java.lang.String)
123 */
124 public void openNotesLog(final String server, final String database) {
125 getFactory().preprocessMethod();
126 try {
127 getLog().openNotesLog(server, database);
128 } catch (NotesException e) {
129 throw newRuntimeException("Cannot open notes log " + server + "!!" + database, e);
130 }
131 }
132 }