1 /*
2 * Copyright (c) 2005, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
107 name_length_max = 16, // maximum length of name
108 arg_length_max = 1024, // maximum length of argument
109 arg_count_max = 3 // maximum number of arguments
110 };
111
112 // name of special operation that can be enqueued when all
113 // clients detach
114 static char* detachall_operation_name() { return (char*)"detachall"; }
115
116 private:
117 char _name[name_length_max+1];
118 char _arg[arg_count_max][arg_length_max+1];
119
120 public:
121 const char* name() const { return _name; }
122
123 // set the operation name
124 void set_name(char* name) {
125 size_t len = strlen(name);
126 assert(len <= name_length_max, "exceeds maximum name length");
127 memcpy(_name, name, MIN2(len + 1, (size_t)name_length_max));
128 }
129
130 // get an argument value
131 const char* arg(int i) const {
132 assert(i>=0 && i<arg_count_max, "invalid argument index");
133 return _arg[i];
134 }
135
136 // set an argument value
137 void set_arg(int i, char* arg) {
138 assert(i>=0 && i<arg_count_max, "invalid argument index");
139 if (arg == NULL) {
140 _arg[i][0] = '\0';
141 } else {
142 size_t len = strlen(arg);
143 assert(len <= arg_length_max, "exceeds maximum argument length");
144 memcpy(_arg[i], arg, MIN2(len + 1, (size_t)arg_length_max));
145 }
146 }
147
148 // create an operation of a given name
149 AttachOperation(char* name) {
150 set_name(name);
151 for (int i=0; i<arg_count_max; i++) {
152 set_arg(i, NULL);
153 }
154 }
155
156 // complete operation by sending result code and any result data to the client
157 virtual void complete(jint result, bufferedStream* result_stream) = 0;
158 };
159 #endif // INCLUDE_SERVICES
160
161 #endif // SHARE_VM_SERVICES_ATTACHLISTENER_HPP
|
1 /*
2 * Copyright (c) 2005, 2018, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
107 name_length_max = 16, // maximum length of name
108 arg_length_max = 1024, // maximum length of argument
109 arg_count_max = 3 // maximum number of arguments
110 };
111
112 // name of special operation that can be enqueued when all
113 // clients detach
114 static char* detachall_operation_name() { return (char*)"detachall"; }
115
116 private:
117 char _name[name_length_max+1];
118 char _arg[arg_count_max][arg_length_max+1];
119
120 public:
121 const char* name() const { return _name; }
122
123 // set the operation name
124 void set_name(char* name) {
125 size_t len = strlen(name);
126 assert(len <= name_length_max, "exceeds maximum name length");
127 len = MIN2(len, (size_t)name_length_max);
128 memcpy(_name, name, len);
129 _name[len] = '\0';
130 }
131
132 // get an argument value
133 const char* arg(int i) const {
134 assert(i>=0 && i<arg_count_max, "invalid argument index");
135 return _arg[i];
136 }
137
138 // set an argument value
139 void set_arg(int i, char* arg) {
140 assert(i>=0 && i<arg_count_max, "invalid argument index");
141 if (arg == NULL) {
142 _arg[i][0] = '\0';
143 } else {
144 size_t len = strlen(arg);
145 assert(len <= arg_length_max, "exceeds maximum argument length");
146 len = MIN2(len, (size_t)arg_length_max);
147 memcpy(_arg[i], arg, len);
148 _arg[i][len] = '\0';
149 }
150 }
151
152 // create an operation of a given name
153 AttachOperation(char* name) {
154 set_name(name);
155 for (int i=0; i<arg_count_max; i++) {
156 set_arg(i, NULL);
157 }
158 }
159
160 // complete operation by sending result code and any result data to the client
161 virtual void complete(jint result, bufferedStream* result_stream) = 0;
162 };
163 #endif // INCLUDE_SERVICES
164
165 #endif // SHARE_VM_SERVICES_ATTACHLISTENER_HPP
|