jdk/src/java.management/share/classes/sun/management/jdp/JdpPacket.java
changeset 43592 14c12a5689d3
parent 43591 62824732af55
parent 43562 0cdf61c416d4
child 43593 06bce0388880
equal deleted inserted replaced
43591:62824732af55 43592:14c12a5689d3
     1 /*
       
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 package sun.management.jdp;
       
    26 
       
    27 import java.io.IOException;
       
    28 
       
    29 /**
       
    30  * Packet to broadcast
       
    31  *
       
    32  * <p>Each packet have to contain MAGIC and PROTOCOL_VERSION in order to be
       
    33  * recognized as a valid JDP packet.</p>
       
    34  *
       
    35  * <p>Default implementation build packet as a set of UTF-8 encoded Key/Value pairs
       
    36  * are stored as an ordered list of values, and are sent to the server
       
    37  * in that order.</p>
       
    38  *
       
    39  * <p>
       
    40  * Packet structure:
       
    41  *
       
    42  * 4 bytes JDP magic (0xC0FFE42)
       
    43  * 2 bytes JDP protocol version (01)
       
    44  *
       
    45  * 2 bytes size of key
       
    46  * x bytes key (UTF-8 encoded)
       
    47  * 2 bytes size of value
       
    48  * x bytes value (UTF-8 encoded)
       
    49  *
       
    50  * repeat as many times as necessary ...
       
    51  * </p>
       
    52   */
       
    53 public interface JdpPacket {
       
    54 
       
    55     /**
       
    56      * This method responsible to assemble packet and return a byte array
       
    57      * ready to be sent across a Net.
       
    58      *
       
    59      * @return assembled packet as an array of bytes
       
    60      * @throws IOException
       
    61      */
       
    62     public byte[] getPacketData() throws IOException;
       
    63 
       
    64 }