blob: 765f594e33aeb625a1d693b96a75e00b2773fb48 [file] [log] [blame]
Richard S. Hallfbd735b2009-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 */
19package org.osgi.service.threadio;
20
21import java.io.*;
22
23/**
24 * Enable multiplexing of the standard IO streams for input, output, and error.
25 *
26 * This service guards the central resource of IO streams. The standard streams
27 * are singletons. This service replaces the singletons with special versions that
28 * can find a unique stream for each thread. If no stream is associated with a
29 * thread, it will use the standard input/output that was originally set.
30 *
31 * @author aqute
32 *
33 */
34public interface ThreadIO {
35 /**
36 * Associate this streams with the current thread.
37 *
38 * Ensure that when output is performed on System.in, System.out, System.err it
39 * will happen on the given streams.
40 *
41 * The streams will automatically be canceled when the bundle that has gotten
42 * this service is stopped or returns this service.
43 *
44 * @param in InputStream to use for the current thread when System.in is used
45 * @param out PrintStream to use for the current thread when System.out is used
46 * @param err PrintStream to use for the current thread when System.err is used
47 */
48 void setStreams(InputStream in, PrintStream out, PrintStream err);
49
50 /**
51 * Cancel the streams associated with the current thread.
52 *
53 * This method will not do anything when no streams are associated.
54 */
55 void close();
56}