View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.core.net;
15  
16  import java.io.IOException;
17  import java.io.ObjectOutputStream;
18  import java.io.OutputStream;
19  
20  import ch.qos.logback.core.CoreConstants;
21  
22  /**
23   * Factory for {@link ch.qos.logback.core.net.ObjectWriter} instances.
24   *
25   * @author Sebastian Gröbler
26   */
27  public class ObjectWriterFactory {
28  
29      /**
30       * Creates a new {@link ch.qos.logback.core.net.AutoFlushingObjectWriter} instance.
31       *
32       * @param outputStream the underlying {@link java.io.OutputStream} to write to
33       * @return a new {@link ch.qos.logback.core.net.AutoFlushingObjectWriter} instance
34       * @throws IOException if an I/O error occurs while writing stream header
35       */
36      public AutoFlushingObjectWriter newAutoFlushingObjectWriter(OutputStream outputStream) throws IOException {
37          return new AutoFlushingObjectWriter(new ObjectOutputStream(outputStream), CoreConstants.OOS_RESET_FREQUENCY);
38      }
39  }