blob: 98e78e8316abdbf8045c7b35cdf69b5a0a8a8236 [file] [log] [blame]
Richard S. Hallaf656a02009-06-11 16:07:20 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Richard S. Hall27d70122010-05-28 15:39:06 +000019package org.apache.felix.service.threadio;
Richard S. Hallaf656a02009-06-11 16:07:20 +000020
Guillaume Nodetc35dd9e2009-06-22 22:27:13 +000021import java.io.InputStream;
22import java.io.PrintStream;
Richard S. Hallaf656a02009-06-11 16:07:20 +000023
24/**
25 * Enable multiplexing of the standard IO streams for input, output, and error.
Guillaume Nodetc35dd9e2009-06-22 22:27:13 +000026 * <p/>
Richard S. Hallaf656a02009-06-11 16:07:20 +000027 * This service guards the central resource of IO streams. The standard streams
28 * are singletons. This service replaces the singletons with special versions that
29 * can find a unique stream for each thread. If no stream is associated with a
30 * thread, it will use the standard input/output that was originally set.
Richard S. Hallaf656a02009-06-11 16:07:20 +000031 *
Guillaume Nodetc35dd9e2009-06-22 22:27:13 +000032 * @author aqute
Richard S. Hallaf656a02009-06-11 16:07:20 +000033 */
Guillaume Nodetc35dd9e2009-06-22 22:27:13 +000034public interface ThreadIO
35{
36 /**
37 * Associate this streams with the current thread.
38 * <p/>
39 * Ensure that when output is performed on System.in, System.out, System.err it
40 * will happen on the given streams.
41 * <p/>
42 * The streams will automatically be canceled when the bundle that has gotten
43 * this service is stopped or returns this service.
44 *
45 * @param in InputStream to use for the current thread when System.in is used
46 * @param out PrintStream to use for the current thread when System.out is used
47 * @param err PrintStream to use for the current thread when System.err is used
48 */
49 void setStreams(InputStream in, PrintStream out, PrintStream err);
Richard S. Hallaf656a02009-06-11 16:07:20 +000050
Guillaume Nodetc35dd9e2009-06-22 22:27:13 +000051 /**
52 * Cancel the streams associated with the current thread.
53 * <p/>
54 * This method will not do anything when no streams are associated.
55 */
Derek Baum137d3402009-12-20 11:12:13 +000056 void close();
Richard S. Hallaf656a02009-06-11 16:07:20 +000057}