usr/src/java/rad/org/opensolaris/os/rad/UnixTransport.java
author Stephen Talley <stephen.talley@oracle.com>
Thu, 03 Feb 2011 14:10:29 -0500
changeset 647 ddbb04508ea4
parent 433 e629b84699e3
child 710 beb915128edf
permissions -rw-r--r--
17819 nit roundup
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
433
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
     1
/*
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
     2
 * CDDL HEADER START
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
     3
 *
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
     7
 *
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    11
 * and limitations under the License.
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    12
 *
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    18
 *
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    19
 * CDDL HEADER END
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    20
 */
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    21
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    22
/*
647
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    23
 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
433
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    24
 */
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    25
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    26
package org.opensolaris.os.rad;
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    27
647
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    28
import java.io.*;
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    29
import org.opensolaris.os.uds.*;
433
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    30
647
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    31
public class UnixTransport implements Transport {
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    32
    //
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    33
    // Instance data
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    34
    //
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    35
433
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    36
    private UDSocket socket_;
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    37
647
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    38
    //
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    39
    // Constructors
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    40
    //
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    41
433
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    42
    public UnixTransport(File path) throws IOException {
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    43
	socket_ = UnixDomainSocket.connect(path);
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    44
    }
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    45
647
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    46
    //
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    47
    // Closeable methods
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    48
    //
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    49
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    50
    @Override
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    51
    public void close() throws IOException {
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    52
	socket_.close();
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    53
    }
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    54
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    55
    //
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    56
    // Transport methods
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    57
    //
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    58
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    59
    @Override
433
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    60
    public InputStream getInputStream() {
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    61
	return socket_.getInputStream();
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    62
    }
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    63
647
ddbb04508ea4 17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents: 433
diff changeset
    64
    @Override
433
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    65
    public OutputStream getOutputStream() {
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    66
	return socket_.getOutputStream();
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    67
    }
e629b84699e3 14567 JMX connector needs more precise failure handling
David Powell <David.Powell@sun.com>
parents:
diff changeset
    68
}