|
13 | 13 | * See the License for the specific language governing permissions and
|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 |
| -package org.culturegraph.mf.stream.pipe; |
17 |
| - |
18 |
| -import org.culturegraph.mf.framework.DefaultObjectPipe; |
19 |
| -import org.culturegraph.mf.framework.ObjectReceiver; |
20 |
| -import org.culturegraph.mf.framework.annotations.Description; |
21 |
| -import org.culturegraph.mf.framework.annotations.In; |
22 |
| -import org.culturegraph.mf.framework.annotations.Out; |
23 |
| -import org.slf4j.Logger; |
24 |
| -import org.slf4j.LoggerFactory; |
25 |
| - |
26 |
| - |
27 |
| -/** |
28 |
| - * Logs the string representation of every object. |
29 |
| - * |
30 |
| - * @param <T> object type |
31 |
| - * |
32 |
| - * @author Christoph Böhme |
33 |
| - * |
34 |
| - */ |
35 |
| -@Description("logs objects with the toString method") |
36 |
| -@In(Object.class) |
37 |
| -@Out(Object.class) |
38 |
| -public final class ObjectExceptionLogger<T> |
39 |
| - extends DefaultObjectPipe<T, ObjectReceiver<T>> { |
40 |
| - |
41 |
| - private static final Logger LOG = LoggerFactory.getLogger(ObjectExceptionLogger.class); |
42 |
| - |
43 |
| - private final String logPrefix; |
44 |
| - |
45 |
| - public ObjectExceptionLogger() { |
46 |
| - this(""); |
47 |
| - } |
48 |
| - |
49 |
| - public ObjectExceptionLogger(final String logPrefix) { |
50 |
| - super(); |
51 |
| - this.logPrefix = logPrefix; |
52 |
| - } |
53 |
| - |
54 |
| - @Override |
55 |
| - public void process(final T obj) { |
56 |
| - |
57 |
| - try{ |
58 |
| - getReceiver().process(obj); |
59 |
| - }catch(Exception e){ |
60 |
| - LOG.error(logPrefix, e); |
61 |
| - } |
62 |
| - |
63 |
| - } |
64 |
| - |
65 |
| - @Override |
66 |
| - protected void onResetStream() { |
67 |
| - LOG.debug("{}resetStream", logPrefix); |
68 |
| - } |
69 |
| - |
70 |
| - @Override |
71 |
| - protected void onCloseStream() { |
72 |
| - LOG.debug("{}closeStream", logPrefix); |
73 |
| - } |
74 |
| - |
75 |
| -} |
| 16 | +package org.culturegraph.mf.stream.pipe; |
| 17 | + |
| 18 | +import org.culturegraph.mf.framework.DefaultObjectPipe; |
| 19 | +import org.culturegraph.mf.framework.ObjectReceiver; |
| 20 | +import org.culturegraph.mf.framework.annotations.Description; |
| 21 | +import org.culturegraph.mf.framework.annotations.In; |
| 22 | +import org.culturegraph.mf.framework.annotations.Out; |
| 23 | +import org.slf4j.Logger; |
| 24 | +import org.slf4j.LoggerFactory; |
| 25 | + |
| 26 | + |
| 27 | +/** |
| 28 | + * Logs the string representation of every object. |
| 29 | + * |
| 30 | + * @param <T> object type |
| 31 | + * @deprecated use {@link ObjectExceptionLogger} instead. |
| 32 | + * @author Christoph Böhme |
| 33 | + * |
| 34 | + */ |
| 35 | +@Description("logs objects with the toString method") |
| 36 | +@In(Object.class) |
| 37 | +@Out(Object.class) |
| 38 | +@Deprecated |
| 39 | +public final class ObjectExceptionLogger<T> |
| 40 | + extends DefaultObjectPipe<T, ObjectReceiver<T>> { |
| 41 | + |
| 42 | + private static final Logger LOG = LoggerFactory.getLogger(ObjectExceptionLogger.class); |
| 43 | + |
| 44 | + private final String logPrefix; |
| 45 | + |
| 46 | + public ObjectExceptionLogger() { |
| 47 | + this(""); |
| 48 | + } |
| 49 | + |
| 50 | + public ObjectExceptionLogger(final String logPrefix) { |
| 51 | + super(); |
| 52 | + this.logPrefix = logPrefix; |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + public void process(final T obj) { |
| 57 | + |
| 58 | + try{ |
| 59 | + getReceiver().process(obj); |
| 60 | + }catch(Exception e){ |
| 61 | + LOG.error(logPrefix, e); |
| 62 | + } |
| 63 | + |
| 64 | + } |
| 65 | + |
| 66 | + @Override |
| 67 | + protected void onResetStream() { |
| 68 | + LOG.debug("{}resetStream", logPrefix); |
| 69 | + } |
| 70 | + |
| 71 | + @Override |
| 72 | + protected void onCloseStream() { |
| 73 | + LOG.debug("{}closeStream", logPrefix); |
| 74 | + } |
| 75 | + |
| 76 | +} |
0 commit comments