JdpPacket.java revision 16594:7bd7a7ffa84b
133965Sjdp/*
233965Sjdp * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
333965Sjdp * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
433965Sjdp *
533965Sjdp * This code is free software; you can redistribute it and/or modify it
638889Sjdp * under the terms of the GNU General Public License version 2 only, as
7218822Sdim * published by the Free Software Foundation.  Oracle designates this
833965Sjdp * particular file as subject to the "Classpath" exception as provided
933965Sjdp * by Oracle in the LICENSE file that accompanied this code.
1094536Sobrien *
1133965Sjdp * This code is distributed in the hope that it will be useful, but WITHOUT
1294536Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1333965Sjdp * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14130561Sobrien * version 2 for more details (a copy is included in the LICENSE file that
1533965Sjdp * accompanied this code).
1633965Sjdp *
1733965Sjdp * You should have received a copy of the GNU General Public License version
1833965Sjdp * 2 along with this work; if not, write to the Free Software Foundation,
1933965Sjdp * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2033965Sjdp *
2133965Sjdp * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2233965Sjdp * or visit www.oracle.com if you need additional information or have any
2333965Sjdp * questions.
2433965Sjdp */
25package sun.management.jdp;
26
27import 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  */
53public 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}
65