maguro 2005/03/26 21:04:42
Modified: modules/core/src/java/org/openejb/corba/util
OpenORBUtil.java Util.java UtilDelegateImpl.java
UtilInitializer.java
Added: modules/core/src/java/org/openejb/corba/util TypeCode.java
Log:
Updated to use the default Sun ORB.
Revision Changes Path
1.5 +4 -4
openejb/modules/core/src/java/org/openejb/corba/util/OpenORBUtil.java
Index: OpenORBUtil.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/util/OpenORBUtil.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- OpenORBUtil.java 18 Mar 2005 08:26:10 -0000 1.4
+++ OpenORBUtil.java 27 Mar 2005 02:04:42 -0000 1.5
@@ -46,7 +46,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.openorb.orb.rmi.DefaultORB;
+//import org.openorb.orb.rmi.DefaultORB;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
@@ -81,7 +81,7 @@
public void doStart() throws Exception {
- DefaultORB.setORB(server.getORB());
+// DefaultORB.setORB(server.getORB());
log.info("Started OpenORBUtil");
}
1.4 +9 -5
openejb/modules/core/src/java/org/openejb/corba/util/Util.java
Index: Util.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/util/Util.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Util.java 20 Mar 2005 23:13:32 -0000 1.3
+++ Util.java 27 Mar 2005 02:04:42 -0000 1.4
@@ -62,15 +62,16 @@
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.UserException;
-import org.omg.GSSUP.GSSUPMechOID;
-import org.omg.GSSUP.InitialContextToken;
-import org.omg.GSSUP.InitialContextTokenHelper;
import org.omg.IOP.Codec;
import org.omg.IOP.CodecFactory;
import org.omg.IOP.ENCODING_CDR_ENCAPS;
import org.omg.IOP.Encoding;
import org.openorb.util.HexPrintStream;
+import org.apache.geronimo.interop.GSSUP.GSSUPMechOID;
+import org.apache.geronimo.interop.GSSUP.InitialContextToken;
+import org.apache.geronimo.interop.GSSUP.InitialContextTokenHelper;
+
/**
* Various utility functions.
@@ -95,7 +96,7 @@
return orb;
}
- static void setORB(ORB orb) throws UserException {
+ public static void setORB(ORB orb) throws UserException {
Util.orb = orb;
CodecFactory factory = (CodecFactory)
Util.orb.resolve_initial_references("CodecFactory");
codec = factory.create_codec(new Encoding(ENCODING_CDR_ENCAPS.value,
(byte) 1, (byte) 2));
@@ -303,9 +304,12 @@
// create and encode a GSSUP initial context token
InitialContextToken init_token = new InitialContextToken();
init_token.username = user.getBytes();
+
String password = new String(pwd);
init_token.password = password.getBytes();
+
init_token.target_name =
encodeGSSExportName(GSSUPMechOID.value.substring(4), target);
+
Any a = orb.create_any();
InitialContextTokenHelper.insert(a, init_token);
byte[] init_ctx_token = codec.encode_value(a);
1.8 +3 -3
openejb/modules/core/src/java/org/openejb/corba/util/UtilDelegateImpl.java
Index: UtilDelegateImpl.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/util/UtilDelegateImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- UtilDelegateImpl.java 23 Mar 2005 05:20:07 -0000 1.7
+++ UtilDelegateImpl.java 27 Mar 2005 02:04:42 -0000 1.8
@@ -210,7 +210,7 @@
try {
result = classLoader.loadClass(className);
} catch (ClassNotFoundException e) {
- if (log.isDebugEnabled()) log.debug("Unable to load " +
className + " from the static class loader", e);
+ if (log.isDebugEnabled()) log.debug("Unable to load " +
className + " from the static class loader");
throw e;
}
1.2 +3 -10
openejb/modules/core/src/java/org/openejb/corba/util/UtilInitializer.java
Index: UtilInitializer.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/util/UtilInitializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UtilInitializer.java 2 Mar 2005 23:48:14 -0000 1.1
+++ UtilInitializer.java 27 Mar 2005 02:04:42 -0000 1.2
@@ -48,6 +48,7 @@
import org.apache.commons.logging.LogFactory;
import org.omg.CORBA.LocalObject;
import org.omg.CORBA.UserException;
+import org.omg.CORBA.ORB;
import org.omg.PortableInterceptor.ORBInitInfo;
import org.omg.PortableInterceptor.ORBInitializer;
@@ -95,13 +96,5 @@
* operations by which Interceptors can be registered.
*/
public void post_init(ORBInitInfo info) {
- try {
- LocalObject current = (LocalObject)
info.resolve_initial_references("PICurrent");
- Util.setORB(current._orb());
-
- log.trace("Registered ORB w/ Util");
- } catch (UserException e) {
- log.error("Unable to register ORB w/ Util");
- }
}
}
1.1
openejb/modules/core/src/java/org/openejb/corba/util/TypeCode.java
Index: TypeCode.java
===================================================================
/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "OpenEJB" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of The OpenEJB Group. For written permission,
* please contact [EMAIL PROTECTED]
*
* 4. Products derived from this Software may not be called "OpenEJB"
* nor may "OpenEJB" appear in their names without prior written
* permission of The OpenEJB Group. OpenEJB is a registered
* trademark of The OpenEJB Group.
*
* 5. Due credit should be given to the OpenEJB Project
* (http://openejb.sf.net/).
*
* THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.
*
* $Id: TypeCode.java,v 1.1 2005/03/27 02:04:42 maguro Exp $
*/
package org.openejb.corba.util;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.TypeCodePackage.Bounds;
/**
* @version $Revision: 1.1 $ $Date: 2005/03/27 02:04:42 $
*/
public class TypeCode extends org.omg.CORBA.TypeCode
{
// -----------------------------------------------------------------------
// public data
// -----------------------------------------------------------------------
public static final TypeCode NULL = new TypeCode(TCKind.tk_null);
public static final TypeCode VOID = new TypeCode(TCKind.tk_void);
public static final TypeCode ANY = new TypeCode(TCKind.tk_any);
public static final TypeCode BOOLEAN = new TypeCode(TCKind.tk_boolean);
public static final TypeCode CHAR = new TypeCode(TCKind.tk_char);
public static final TypeCode WCHAR = new TypeCode(TCKind.tk_wchar);
public static final TypeCode OCTET = new TypeCode(TCKind.tk_octet);
public static final TypeCode SHORT = new TypeCode(TCKind.tk_short);
public static final TypeCode USHORT = new TypeCode(TCKind.tk_ushort);
public static final TypeCode LONG = new TypeCode(TCKind.tk_long);
public static final TypeCode ULONG = new TypeCode(TCKind.tk_ulong);
public static final TypeCode LONGLONG = new TypeCode(TCKind.tk_longlong);
public static final TypeCode ULONGLONG = new
TypeCode(TCKind.tk_ulonglong);
public static final TypeCode FLOAT = new TypeCode(TCKind.tk_float);
public static final TypeCode DOUBLE = new TypeCode(TCKind.tk_double);
public static final TypeCode LONGDOUBLE = new TypeCode(
TCKind.tk_longdouble);
public static final TypeCode STRING = new TypeCode(TCKind.tk_string);
public static final TypeCode WSTRING = new TypeCode(TCKind.tk_wstring);
public static final TypeCode OBJREF = new TypeCode(TCKind.tk_objref);
public static final TypeCode TYPECODE = new TypeCode(TCKind.tk_TypeCode);
// -----------------------------------------------------------------------
// private data
// -----------------------------------------------------------------------
private TCKind _kind;
private String _name;
private String _type;
private String _id;
private String _label;
// content type, discriminator type, concrete base type,
// or other TypeCode for indirection.
private org.omg.CORBA.TypeCode _ref;
private String[] _member_name;
private org.omg.CORBA.TypeCode[] _member_type;
private org.omg.CORBA.Any[] _member_label;
private short[] _member_visibility;
private int _default;
private int _length;
private short _digits;
private short _scale;
private short _type_modifier;
private boolean _indirection;
// -----------------------------------------------------------------------
// public methods
// -----------------------------------------------------------------------
/**
* @param kind
*/
public TypeCode(TCKind kind)
{
_kind = kind;
_default = -1;
if (kind.value() == TCKind._tk_objref)
{
_type = "Object";
}
}
/**
* @param tc
* @return
*/
public boolean equal(org.omg.CORBA.TypeCode tc)
{
if (_indirection)
{
return _ref.equal(tc);
}
try
{
int tk = _kind.value();
if (tk != tc.kind().value())
{
return false;
}
// TODO: compare id()
if (_member_name != null)
{
int n = _member_name.length;
if (n != tc.member_count())
{
return false;
}
for (int i = 0; i < n; i++)
{
if (!equalIfNotEmpty(member_name(i), tc.member_name(i)))
{
return false;
}
if (!member_type(i).equal(tc.member_type(i)))
{
return false;
}
}
}
if (tk == TCKind._tk_union)
{
if (!discriminator_type().equal(tc.discriminator_type()))
{
return false;
}
int n = _member_name.length;
for (int i = 0; i < n; i++)
{
if (!member_label(i).equal(tc.member_label(i)))
{
return false;
}
}
}
if (tk == TCKind._tk_array
||
tk == TCKind._tk_sequence
||
tk == TCKind._tk_string
|| tk == TCKind._tk_wstring)
{
if (length() != tc.length())
{
return false;
}
}
if (tk == TCKind._tk_alias
||
tk == TCKind._tk_array
|| tk == TCKind._tk_sequence)
{
if (!content_type().equal(tc.content_type()))
{
return false;
}
}
return true;
}
catch (org.omg.CORBA.TypeCodePackage.BadKind ex)
{
throw new org.omg.CORBA.UNKNOWN(ex.toString());
}
catch (org.omg.CORBA.TypeCodePackage.Bounds ex)
{
throw new org.omg.CORBA.UNKNOWN(ex.toString());
}
}
/**
* @param tc
* @return
*/
public boolean equivalent
(org.omg.CORBA.TypeCode tc)
{
throw new org.omg.CORBA.NO_IMPLEMENT();
}
/**
* @return
*/
public org.omg.CORBA.TypeCode get_compact_typecode()
{
throw new org.omg.CORBA.NO_IMPLEMENT();
}
/**
* @param a
* @param b
* @return
*/
private boolean equalIfNotEmpty(String a, String b)
{
if (a.length() == 0 || b.length() == 0)
{
return true;
}
else
{
return a.equals(b);
}
}
/**
* @return
*/
public TCKind kind()
{
if (_indirection)
{
return _ref.kind();
}
return _kind;
}
/**
* @return
* @throws BadKind
*/
public String id()
throws BadKind
{
if (_indirection)
{
return _ref.id();
}
if (_id != null)
{
return _id;
}
if (_type != null && _type.equals("Object"))
{
return "";
}
return default_id();
}
// Sybase-internal
/**
* @param id
*/
public void id(String id)
{
if (!id.equals(""))
{
_id = id;
if (id.startsWith("IDL:") && id.endsWith(":1.0"))
{
// Infer _type field from standard IDL format _id
id = id.substring(4, id.length() - 4);
if (id.startsWith("omg.org/"))
{
id = id.substring(8);
}
_type = "";
for (; ;)
{
int slash = id.indexOf('/');
if (slash == -1)
{
break;
}
_type = _type + id.substring(0, slash) + "::";
id = id.substring(slash + 1);
}
_type = _type + id;
}
}
}
/**
* @return
* @throws BadKind
*/
public String name()
throws BadKind
{
if (_indirection)
{
return _ref.name();
}
/* TODO?
if (_name == null)
{
_name = (String)_names.get(new Integer(_kind.value()));
}
*/
if (_name == null)
{
throw new BadKind();
}
return _name;
}
// Sybase-internal
/**
* @param name
*/
public void name(String name)
{
_name = name;
}
/**
* @return
* @throws BadKind
*/
public int member_count()
throws BadKind
{
if (_indirection)
{
return _ref.member_count();
}
if (_member_name == null)
{
throw new BadKind();
}
return _member_name.length;
}
// Sybase-internal
/**
* @param count
*/
public void member_count(int count)
{
_member_name = new String[count];
_member_type = new org.omg.CORBA.TypeCode[count];
if (_kind.value() == TCKind._tk_union)
{
_member_label = new org.omg.CORBA.Any[count];
}
if (_kind.value() == TCKind._tk_value)
{
_member_visibility = new short[count];
}
}
/**
* @param index
* @return
* @throws BadKind
* @throws Bounds
*/
public String member_name(int index)
throws BadKind, Bounds
{
if (_indirection)
{
return _ref.member_name(index);
}
if (_member_name == null)
{
throw new BadKind();
}
if (index < 0 || index >= _member_name.length)
{
throw new Bounds();
}
return _member_name[index];
}
// Sybase-internal
/**
* @param index
* @param name
*/
public void member_name(int index, String name)
{
_member_name[index] = name;
}
/**
* @param index
* @return
* @throws BadKind
* @throws Bounds
*/
public org.omg.CORBA.TypeCode member_type(int index)
throws BadKind, Bounds
{
if (_indirection)
{
return _ref.member_type(index);
}
if (_member_type == null)
{
throw new BadKind();
}
if (index < 0 || index >= _member_type.length)
{
throw new Bounds();
}
return _member_type[index];
}
// Sybase-internal
/**
* @param index
* @param type
*/
public void member_type(int index, org.omg.CORBA.TypeCode type)
{
_member_type[index] = type;
}
/**
* @param index
* @return
* @throws BadKind
* @throws Bounds
*/
public org.omg.CORBA.Any member_label(int index)
throws BadKind, Bounds
{
if (_indirection)
{
return _ref.member_label(index);
}
if (_member_label == null)
{
throw new BadKind();
}
if (index < 0 || index >= _member_label.length)
{
throw new Bounds();
}
return _member_label[index];
}
// Sybase-internal
/**
* @param index
* @param label
*/
public void member_label(int index, org.omg.CORBA.Any label)
{
_member_label[index] = label;
}
/**
* @return
* @throws BadKind
*/
public org.omg.CORBA.TypeCode discriminator_type()
throws BadKind
{
if (_indirection)
{
return _ref.discriminator_type();
}
if (_ref == null
|| _kind.value() != TCKind._tk_union)
{
throw new BadKind();
}
return _ref;
}
// Sybase-internal
/**
* @param disc
*/
public void discriminator_type(org.omg.CORBA.TypeCode disc)
{
_ref = disc;
}
/**
* @return
* @throws BadKind
*/
public int default_index()
throws BadKind
{
if (_indirection)
{
return _ref.default_index();
}
if (_kind.value() != TCKind._tk_union)
{
throw new BadKind();
}
return _default;
}
/**
* @return
* @throws BadKind
*/
public int length()
throws BadKind
{
if (_indirection)
{
return _ref.length();
}
int tk = _kind.value();
if (tk != TCKind._tk_string &&
tk != TCKind._tk_wstring
&& tk != TCKind._tk_sequence && tk != TCKind._tk_array)
{
throw new BadKind();
}
return _length;
}
// Sybase-internal
/**
* @param length
*/
public void length(int length)
{
_length = length;
}
/**
* @return
* @throws BadKind
*/
public org.omg.CORBA.TypeCode content_type()
throws BadKind
{
if (_indirection)
{
return _ref.content_type();
}
int tk = _kind.value();
if (_ref == null
|| (tk != TCKind._tk_alias
&&
tk != TCKind._tk_array
&&
tk != TCKind._tk_sequence
&& tk != TCKind._tk_value_box))
{
throw new BadKind();
}
return _ref;
}
// Sybase-internal
/**
* @param type
*/
public void content_type(org.omg.CORBA.TypeCode type)
{
_ref = type;
}
/**
* @return
* @throws BadKind
*/
public short fixed_digits()
throws BadKind
{
if (_indirection)
{
return _ref.fixed_digits();
}
int tk = _kind.value();
if (tk != TCKind._tk_fixed)
{
throw new BadKind();
}
return _digits;
}
// Sybase-internal
/**
* @param digits
*/
public void fixed_digits(short digits)
{
_digits = digits;
}
/**
* @return
* @throws BadKind
*/
public short fixed_scale()
throws BadKind
{
if (_indirection)
{
return _ref.fixed_scale();
}
int tk = _kind.value();
if (tk != TCKind._tk_fixed)
{
throw new BadKind();
}
return _scale;
}
// Sybase-internal
/**
* @param scale
*/
public void fixed_scale(short scale)
{
_scale = scale;
}
/**
* @param index
* @return
* @throws BadKind
* @throws Bounds
*/
public short member_visibility
(int index)
throws BadKind, Bounds
{
if (_indirection)
{
return _ref.member_visibility(index);
}
if (_member_type == null)
{
throw new BadKind();
}
if (index < 0 || index >= _member_visibility.length)
{
throw new Bounds();
}
return _member_visibility[index];
}
// Sybase-internal
/**
* @param index
* @param visibility
*/
public void member_visibility(int index, short visibility)
{
_member_visibility[index] = visibility;
}
/**
* @return
* @throws BadKind
*/
public short type_modifier()
throws BadKind
{
if (_indirection)
{
return _ref.type_modifier();
}
int tk = _kind.value();
if (tk != TCKind._tk_value)
{
throw new BadKind();
}
return _type_modifier;
}
// Sybase-internal
/**
* @param modifier
*/
public void type_modifier(short modifier)
{
_type_modifier = modifier;
}
/**
* @return
* @throws BadKind
*/
public org.omg.CORBA.TypeCode concrete_base_type()
throws BadKind
{
if (_indirection)
{
return _ref.concrete_base_type();
}
int tk = _kind.value();
if (tk != TCKind._tk_value)
{
throw new BadKind();
}
return _ref;
}
// Sybase-internal
/**
* @param base
*/
public void concrete_base_type(org.omg.CORBA.TypeCode base)
{
_ref = base;
}
// Sybase-internal
/**
* @param ref
*/
public void indirection(org.omg.CORBA.TypeCode ref)
{
_ref = ref;
_indirection = true;
}
// Sybase-internal
/**
* @param id
*/
public void recursive(String id)
{
_id = id;
_ref = null;
_indirection = true;
}
// Sybase-internal
/**
*
*/
public void fix_recursive_members()
{
String id = _id == null ? default_id() : _id;
int n = _member_type.length;
for (int i = 0; i < n; i++)
{
TypeCode mt = (TypeCode) _member_type[i];
if (mt._kind.value() == TCKind._tk_sequence)
{
TypeCode ct = (TypeCode) mt._ref;
if (ct._indirection
&&
ct._ref == null
&& ct._id.equals(id))
{
ct._ref = this;
}
}
}
}
// -----------------------------------------------------------------------
// private methods
// -----------------------------------------------------------------------
/**
* @return
*/
private String default_id()
{
// Take _type, and generate _id, e.g.
// if _type = "SessionManager::Manager",
// then _id = "IDL:SessionManager/Manager:1.0".
if (_type == null)
{
return "";
}
StringBuffer id = new StringBuffer(_type.length() + 10);
id.append("IDL:");
int n = _type.length();
for (int i = 0; i < n; i++)
{
char c = _type.charAt(i);
if (c == ':' && i + 1 < n && _type.charAt(i + 1) == ':')
{
i++;
}
id.append(c == ':' ? '/' : c);
}
id.append(":1.0");
return id.toString();
}
}