1 /*
2 * Copyright (c) 2003, 2004, 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
92 protected GenericListeningConnector(TransportService ts) {
93 this(ts, false);
94 }
95
96 /**
97 * Create an instance of this Connector. The resulting ListeningConnector will
98 * have "address" and "timeout" connector arguments.
99 */
100 public static GenericListeningConnector create(TransportService ts) {
101 return new GenericListeningConnector(ts, true);
102 }
103
104 public String startListening(String address, Map<String,? extends Connector.Argument> args)
105 throws IOException, IllegalConnectorArgumentsException
106 {
107 TransportService.ListenKey listener = listenMap.get(args);
108 if (listener != null) {
109 throw new IllegalConnectorArgumentsException("Already listening",
110 new ArrayList<String>(args.keySet()));
111 }
112
113 listener = transportService.startListening(address);
114 listenMap.put(args, listener);
115 return listener.address();
116 }
117
118 public String
119 startListening(Map<String,? extends Connector.Argument> args)
120 throws IOException, IllegalConnectorArgumentsException
121 {
122 String address = argument(ARG_ADDRESS, args).value();
123 return startListening(address, args);
124 }
125
126 public void stopListening(Map<String,? extends Connector.Argument> args)
127 throws IOException, IllegalConnectorArgumentsException
128 {
129 TransportService.ListenKey listener = listenMap.get(args);
130 if (listener == null) {
131 throw new IllegalConnectorArgumentsException("Not listening",
132 new ArrayList<String>(args.keySet()));
133 }
161 connection = transportService.accept(listener, timeout, 0);
162 stopListening(args);
163 }
164 return Bootstrap.virtualMachineManager().createVirtualMachine(connection);
165 }
166
167 public boolean supportsMultipleConnections() {
168 return transportService.capabilities().supportsMultipleConnections();
169 }
170
171 public String name() {
172 return transport.name() + "Listen";
173 }
174
175 public String description() {
176 return transportService.description();
177 }
178
179 public Transport transport() {
180 return transport;
181 }
182
183 }
|
1 /*
2 * Copyright (c) 2003, 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. 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
92 protected GenericListeningConnector(TransportService ts) {
93 this(ts, false);
94 }
95
96 /**
97 * Create an instance of this Connector. The resulting ListeningConnector will
98 * have "address" and "timeout" connector arguments.
99 */
100 public static GenericListeningConnector create(TransportService ts) {
101 return new GenericListeningConnector(ts, true);
102 }
103
104 public String startListening(String address, Map<String,? extends Connector.Argument> args)
105 throws IOException, IllegalConnectorArgumentsException
106 {
107 TransportService.ListenKey listener = listenMap.get(args);
108 if (listener != null) {
109 throw new IllegalConnectorArgumentsException("Already listening",
110 new ArrayList<String>(args.keySet()));
111 }
112 listener = transportService.startListening(address);
113 updateArgumentMapIfRequired(args, listener);
114 listenMap.put(args, listener);
115 return listener.address();
116 }
117
118 public String
119 startListening(Map<String,? extends Connector.Argument> args)
120 throws IOException, IllegalConnectorArgumentsException
121 {
122 String address = argument(ARG_ADDRESS, args).value();
123 return startListening(address, args);
124 }
125
126 public void stopListening(Map<String,? extends Connector.Argument> args)
127 throws IOException, IllegalConnectorArgumentsException
128 {
129 TransportService.ListenKey listener = listenMap.get(args);
130 if (listener == null) {
131 throw new IllegalConnectorArgumentsException("Not listening",
132 new ArrayList<String>(args.keySet()));
133 }
161 connection = transportService.accept(listener, timeout, 0);
162 stopListening(args);
163 }
164 return Bootstrap.virtualMachineManager().createVirtualMachine(connection);
165 }
166
167 public boolean supportsMultipleConnections() {
168 return transportService.capabilities().supportsMultipleConnections();
169 }
170
171 public String name() {
172 return transport.name() + "Listen";
173 }
174
175 public String description() {
176 return transportService.description();
177 }
178
179 public Transport transport() {
180 return transport;
181 }
182
183 protected void updateArgumentMapIfRequired(
184 Map<String, ? extends Connector.Argument> args, TransportService.ListenKey listener) {
185 }
186
187 }
|