1 /*
2 * Copyright (c) 2000, 2009, 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
143 ORB orb = (ORB)(out.orb());
144 String name = ex.getClass().getName();
145 String repID = ORBUtility.repositoryIdOf(name);
146 out.write_string(repID);
147 out.write_long(ex.minor);
148 out.write_long(ex.completed.value());
149 any.read_value(out.create_input_stream(),
150 getSystemExceptionTypeCode(orb, repID, name));
151 }
152
153 public static SystemException extractSystemException(Any any) {
154 InputStream in = any.create_input_stream();
155 ORB orb = (ORB)(in.orb());
156 if ( ! isSystemExceptionTypeCode(any.type(), orb)) {
157 throw wrapper.unknownDsiSysex(CompletionStatus.COMPLETED_MAYBE);
158 }
159 return ORBUtility.readSystemException(in);
160 }
161
162 /**
163 * Creates the correct ValueHandler for the given ORB,
164 * querying ORBVersion information. If the ORB or
165 * ORBVersion is null, gets the ValueHandler from
166 * Util.createValueHandler.
167 */
168 public static ValueHandler createValueHandler(ORB orb) {
169
170 if (orb == null)
171 return Util.createValueHandler();
172
173 ORBVersion version = orb.getORBVersion();
174
175 if (version == null)
176 return Util.createValueHandler();
177
178 if (version.equals(ORBVersionFactory.getOLD()))
179 return new ValueHandlerImpl_1_3();
180 if (version.equals(ORBVersionFactory.getNEW()))
181 return new ValueHandlerImpl_1_3_1();
182
183 return Util.createValueHandler();
184 }
185
186 /**
187 * Returns true if the given ORB could accurately be determined to be a
188 * Kestrel or earlier ORB. Note: If passed the ORBSingleton, this will return
189 * false.
190 */
191 public static boolean isLegacyORB(ORB orb)
192 {
193 try {
194 ORBVersion currentORB = orb.getORBVersion();
195 return currentORB.equals( ORBVersionFactory.getOLD() ) ;
196 } catch (SecurityException se) {
197 return false;
198 }
199 }
200
201 /**
202 * Returns true if it was accurately determined that the remote ORB is
203 * a foreign (non-JavaSoft) ORB. Note: If passed the ORBSingleton, this
204 * will return false.
205 */
206 public static boolean isForeignORB(ORB orb)
207 {
208 if (orb == null)
209 return false;
210
211 try {
212 return orb.getORBVersion().equals(ORBVersionFactory.getFOREIGN());
213 } catch (SecurityException se) {
214 return false;
215 }
216 }
217
218 /** Unmarshal a byte array to an integer.
|
1 /*
2 * Copyright (c) 2000, 2012, 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
143 ORB orb = (ORB)(out.orb());
144 String name = ex.getClass().getName();
145 String repID = ORBUtility.repositoryIdOf(name);
146 out.write_string(repID);
147 out.write_long(ex.minor);
148 out.write_long(ex.completed.value());
149 any.read_value(out.create_input_stream(),
150 getSystemExceptionTypeCode(orb, repID, name));
151 }
152
153 public static SystemException extractSystemException(Any any) {
154 InputStream in = any.create_input_stream();
155 ORB orb = (ORB)(in.orb());
156 if ( ! isSystemExceptionTypeCode(any.type(), orb)) {
157 throw wrapper.unknownDsiSysex(CompletionStatus.COMPLETED_MAYBE);
158 }
159 return ORBUtility.readSystemException(in);
160 }
161
162 /**
163 * Return default ValueHandler
164 */
165 public static ValueHandler createValueHandler() {
166 return Util.createValueHandler();
167 }
168
169 /**
170 * Returns true if it was accurately determined that the remote ORB is
171 * a foreign (non-JavaSoft) ORB. Note: If passed the ORBSingleton, this
172 * will return false.
173 */
174 public static boolean isForeignORB(ORB orb)
175 {
176 if (orb == null)
177 return false;
178
179 try {
180 return orb.getORBVersion().equals(ORBVersionFactory.getFOREIGN());
181 } catch (SecurityException se) {
182 return false;
183 }
184 }
185
186 /** Unmarshal a byte array to an integer.
|