geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r329036 [7/7] - in /geronimo/trunk/sandbox/freeorb: ./ geronimo-orb/ geronimo-orb/src/ geronimo-orb/src/main/ geronimo-orb/src/main/java/ geronimo-orb/src/main/java/org/ geronimo-orb/src/main/java/org/apache/ geronimo-orb/src/main/java/org/...
Date Fri, 28 Oct 2005 02:00:22 GMT
Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecureInetTransport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecureInetTransport.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecureInetTransport.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecureInetTransport.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,35 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.ior;
+
+import java.net.InetSocketAddress;
+
+import org.omg.IIOP.Version;
+
+
+public class SecureInetTransport extends IIOPTransportSpec {
+
+    private final short target_requires;
+    private final short target_supports;
+
+    SecureInetTransport(Version version, InetSocketAddress addr, short target_requires, short
target_supports, CompoundSecurityMechanism mechanism) {
+        super(version, addr, mechanism);
+        this.target_requires = target_requires;
+        this.target_supports = target_supports;
+    }
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecurityMechanismListComponent.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecurityMechanismListComponent.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecurityMechanismListComponent.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/SecurityMechanismListComponent.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,73 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.ior;
+
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CSIIOP.CompoundSecMechList;
+import org.omg.CSIIOP.CompoundSecMechListHelper;
+import org.omg.CSIIOP.TAG_CSI_SEC_MECH_LIST;
+
+import org.apache.geronimo.corba.AbstractORB;
+import org.apache.geronimo.corba.io.EncapsulationInputStream;
+
+
+public class SecurityMechanismListComponent extends Component {
+
+    private final AbstractORB orb;
+    private final CompoundSecMechList mech_list;
+    private CompoundSecurityMechanism[] mechs;
+
+    public SecurityMechanismListComponent(AbstractORB orb2, CompoundSecMechList mech_list)
{
+        this.orb = orb2;
+        this.mech_list = mech_list;
+    }
+
+    public int tag() {
+        return TAG_CSI_SEC_MECH_LIST.value;
+    }
+
+    protected void write_content(OutputStream out) {
+        CompoundSecMechListHelper.write(out, mech_list);
+    }
+
+    public int getMechanismCount() {
+        return mech_list.mechanism_list.length;
+    }
+
+    public int getTransportMechanismTag(int j) {
+        return mech_list.mechanism_list[j].transport_mech.tag;
+    }
+
+    public static Component read(AbstractORB orb, byte[] data) {
+        EncapsulationInputStream ein = new EncapsulationInputStream(orb, data);
+        CompoundSecMechList mech_list = CompoundSecMechListHelper.read(ein);
+        return new SecurityMechanismListComponent(orb, mech_list);
+    }
+
+    public CompoundSecurityMechanism getSecurityMechanism(int j) {
+        if (mechs == null) {
+            mechs = new CompoundSecurityMechanism[mech_list.mechanism_list.length];
+        }
+
+        if (mechs[j] == null) {
+            mechs[j] = new CompoundSecurityMechanism(orb, mech_list.mechanism_list[j]);
+        }
+
+        return mechs[j];
+    }
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TLSSecureTransport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TLSSecureTransport.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TLSSecureTransport.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TLSSecureTransport.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,67 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.ior;
+
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CSIIOP.TLS_SEC_TRANS;
+
+import org.apache.geronimo.corba.AbstractORB;
+import org.apache.geronimo.corba.io.EncapsulationInputStream;
+
+
+public class TLSSecureTransport extends SecureInetTransport {
+
+    public TLSSecureTransport(AbstractORB orb, TLS_SEC_TRANS trans, int idx, CompoundSecurityMechanism
mechanism)
+            throws UnknownHostException
+    {
+        super(orb.getIIOPVersion(), new InetSocketAddress(orb
+                .getAddress(trans.addresses[idx].host_name),
+                                                          trans.addresses[idx].port &
0xffff), trans.target_requires,
+                                                                                        
      trans.target_supports, mechanism);
+
+    }
+
+    public static IIOPTransportSpec[] read(AbstractORB orb, byte[] component_data, CompoundSecurityMechanism
mechanism) {
+        InputStream in = new EncapsulationInputStream(orb, component_data);
+        org.omg.CSIIOP.TLS_SEC_TRANS trans = org.omg.CSIIOP.TLS_SEC_TRANSHelper
+                .read(in);
+
+        List list = new ArrayList();
+        for (int i = 0; i < trans.addresses.length; i++) {
+            try {
+                list.add(new TLSSecureTransport(orb, trans, i, mechanism));
+            }
+            catch (UnknownHostException e) {
+                // ignore - we don't know the targe thost //
+            }
+        }
+
+        TLSSecureTransport[] result = new TLSSecureTransport[list.size()];
+        list.toArray(result);
+        return result;
+    }
+
+    public String protocol() {
+        return PROTO_TLS;
+    }
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TaggedValue.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TaggedValue.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TaggedValue.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TaggedValue.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.ior;
+
+import java.io.IOException;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.OutputStream;
+
+import org.apache.geronimo.corba.io.EncapsulationOutputStream;
+import org.apache.geronimo.corba.io.OutputStreamBase;
+
+
+public abstract class TaggedValue {
+
+    public abstract int tag();
+
+    public void write(OutputStreamBase out) {
+        out.write_long(tag());
+        write_encapsulated_content(out);
+    }
+
+    protected void write_encapsulated_content(OutputStreamBase out) {
+        EncapsulationOutputStream eo = new EncapsulationOutputStream(out.__orb());
+        write_content(eo);
+        try {
+            eo.writeTo(out);
+        }
+        catch (IOException ex) {
+            MARSHAL m = new MARSHAL();
+            m.initCause(ex);
+            throw m;
+        }
+    }
+
+    protected abstract void write_content(OutputStream eo);
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TransportSpecification.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TransportSpecification.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TransportSpecification.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/TransportSpecification.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,21 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.ior;
+
+public interface TransportSpecification {
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/UnknownComponent.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/UnknownComponent.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/UnknownComponent.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/UnknownComponent.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,44 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.ior;
+
+import org.apache.geronimo.corba.io.OutputStreamBase;
+
+
+public class UnknownComponent extends Component {
+
+    private final int tag;
+
+    private final byte[] data;
+
+    public UnknownComponent(int tag, byte[] data) {
+        this.tag = tag;
+        this.data = data;
+    }
+
+    public int tag() {
+        return tag;
+    }
+
+    protected void write_encapsulated_content(OutputStreamBase out) {
+        out.write_octet_array(data, 0, data.length);
+    }
+
+    protected void write_content(org.omg.CORBA.portable.OutputStream eo) {
+    }
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/UnknownProfile.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/UnknownProfile.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/UnknownProfile.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ior/UnknownProfile.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.ior;
+
+import org.omg.CORBA.INTERNAL;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.IOP.TaggedComponent;
+
+
+public class UnknownProfile extends Profile {
+
+    private final int tag;
+    private final byte[] data;
+
+    public UnknownProfile(int tag, byte[] data) {
+        this.tag = tag;
+        this.data = data;
+    }
+
+    public int tag() {
+        return tag;
+    }
+
+    int getComponentCount() {
+        return 0;
+    }
+
+    public int getTag(int idx) {
+        return 0;
+    }
+
+    public TaggedComponent getTaggedComponent(int idx) {
+        return null;
+    }
+
+    public Component getComponent(int idx) {
+        return null;
+    }
+
+    protected void write_encapsulated_content(OutputStream out) {
+        out.write_octet_array(data, 0, data.length);
+    }
+
+    protected void write_content(OutputStream eo) {
+        throw new INTERNAL();
+    }
+
+    protected byte[] get_encapsulation_bytes() {
+        return data;
+    }
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntIter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntIter.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntIter.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntIter.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,23 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.util;
+
+public interface IntIter {
+
+    void each(int i);
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntIterator.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntIterator.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntIterator.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntIterator.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.util;
+
+public interface IntIterator {
+
+    public int next();
+
+    public boolean hasNext();
+
+    public int size();
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntegerToObjectHashMap.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntegerToObjectHashMap.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntegerToObjectHashMap.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntegerToObjectHashMap.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,402 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.util;
+
+import java.util.NoSuchElementException;
+
+
+/**
+ * @author Kresten Krab Thorup (krab@trifork.com)
+ */
+
+public class IntegerToObjectHashMap implements IntegerToObjectMap {
+
+    public static final Object NO_VALUE = null;
+
+    protected int size;
+
+    public int size() {
+        return size;
+    }
+
+    public boolean isEmpty() {
+        return size() == 0;
+    }
+
+    protected static int keyHash(int key) {
+        return key;
+    }
+
+    protected static boolean keyEquals(int key1, int key2) {
+        return key1 == key2;
+    }
+
+    static int valueHash(Object value) {
+        return value == null ? 0 : value.hashCode();
+    }
+
+    static boolean valueEquals(Object value1, Object value2) {
+        return value1 == null ? value2 == null : value1.equals(value2);
+    }
+
+    static class Entry implements IntegerToObjectMap.Entry {
+
+        public int hashCode() {
+            return keyHash(getKey()) ^ valueHash(getValue());
+        }
+
+        public boolean equals(Object other) {
+            if (other instanceof Entry) {
+                Entry ent = (Entry) other;
+                return keyEquals(getKey(), ent.getKey())
+                       && valueEquals(getValue(), ent.getValue());
+            } else {
+                return false;
+            }
+        }
+
+        Entry next;
+
+        int key;
+        Object value;
+
+        private int hash;
+
+        Entry(int hash, int key, Object value, Entry next) {
+            this.key = key;
+            this.value = value;
+            this.next = next;
+            this.hash = hash;
+        }
+
+        public int getKey() {
+            return key;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object setValue(Object value2) {
+            Object result = this.value;
+            this.value = value2;
+            return result;
+        }
+
+        boolean sameKey(int hash, int key) {
+            return keyEquals(getKey(), key);
+        }
+
+        /**
+         * @return
+         */
+        public int getHash() {
+            return hash;
+        }
+    }
+
+    /**
+     * the hash index
+     */
+    private Entry[] table;
+
+    /**
+     * the current range for table.
+     */
+    private int range;
+
+    private float ratio;
+
+    private static final int DEFAULT_RANGE = 17;
+
+    /**
+     * translate hash code bucket to index
+     */
+    private int index(int hash) {
+        return (hash & 0x7ffffff) % range;
+    }
+
+    /**
+     * the default and only constructor
+     */
+    public IntegerToObjectHashMap() {
+        clear();
+    }
+
+    /**
+     * the default and only constructor
+     */
+    public IntegerToObjectHashMap(int size) {
+        clear(size);
+    }
+
+    public void clear() {
+        clear(DEFAULT_RANGE);
+    }
+
+    protected void clear(int initial_range) {
+        if (initial_range == 0) {
+            initial_range = 3;
+        }
+        range = initial_range;
+        size = 0;
+        ratio = 0.75F;
+        table = new Entry[range];
+    }
+
+    /**
+     * return the element with the given key
+     */
+    public Object get(int key) {
+        int hash = keyHash(key);
+        return get(hash, key);
+    }
+
+    private Object get(int hash, int key) {
+        int idx = index(hash);
+
+        for (Entry ent = table[idx]; ent != null; ent = ent.next) {
+            if (ent.sameKey(hash, key))
+                return ent.value;
+        }
+
+        return NO_VALUE;
+    }
+
+    /**
+     * return the element with the given key
+     */
+    public boolean containsKey(int key) {
+        int hash = keyHash(key);
+        return containsKey(hash, key);
+    }
+
+    private boolean containsKey(int hash, int key) {
+        int idx = index(hash);
+
+        for (Entry ent = table[idx]; ent != null; ent = ent.next) {
+            if (ent.sameKey(hash, key))
+                return true;
+        }
+
+        return false;
+    }
+
+    public Object put(int key, Object value) {
+        int hash = keyHash(key);
+        return put(hash, key, value);
+    }
+
+    private Object put(int hash, int key, Object value) {
+        int idx = index(hash);
+
+        for (Entry ent = table[idx]; ent != null; ent = ent.next) {
+            if (ent.sameKey(hash, key)) {
+                return ent.setValue(value);
+            }
+        }
+
+        if (1.0F * size / range > ratio) {
+            grow();
+            idx = index(hash);
+        }
+
+        table[idx] = new Entry(hash, key, value, table[idx]);
+
+        size += 1;
+
+        return NO_VALUE;
+    }
+
+    public Object remove(int key) {
+        int hash = keyHash(key);
+        return remove(hash, key);
+    }
+
+    private Object remove(int hash, int key) {
+        int idx = index(hash);
+
+        Entry entry = table[idx];
+        if (entry != null) {
+
+            if (entry.sameKey(hash, key)) {
+                table[idx] = entry.next;
+                size -= 1;
+                return entry.getValue();
+
+            } else {
+                Entry ahead = entry.next;
+
+                while (ahead != null) {
+                    if (ahead.sameKey(hash, key)) {
+                        entry.next = ahead.next;
+                        size -= 1;
+                        return ahead.getValue();
+                    }
+
+                    entry = ahead;
+                    ahead = ahead.next;
+                }
+            }
+        }
+
+        // it was not found at all!
+        return NO_VALUE;
+    }
+
+    public Object removeEntry(Entry ent) {
+        int hash = ent.getHash();
+        int idx = index(hash);
+
+        Entry entry = table[idx];
+        if (entry != null) {
+
+            if (entry == ent) {
+                table[idx] = entry.next;
+                size -= 1;
+                return entry.getValue();
+
+            } else {
+                Entry ahead = entry.next;
+
+                while (ahead != null) {
+                    if (ahead == ent) {
+                        entry.next = ahead.next;
+                        size -= 1;
+                        return ahead.getValue();
+                    }
+
+                    entry = ahead;
+                    ahead = ahead.next;
+                }
+            }
+        }
+
+        // it was not found at all!
+        return NO_VALUE;
+    }
+
+    private void grow() {
+        int old_range = range;
+        Entry[] old_table = table;
+
+        range = old_range * 2 + 1;
+        table = new Entry[range];
+
+        for (int i = 0; i < old_range; i++) {
+            Entry entry = old_table[i];
+
+            while (entry != null) {
+                Entry ahead = entry.next;
+                int idx = index(keyHash(entry.getKey()));
+                entry.next = table[idx];
+                table[idx] = entry;
+                entry = ahead;
+            }
+        }
+    }
+
+    final class EntryIterator implements IntegerToObjectMap.EntryIterator {
+
+        int idx;
+
+        Entry entry;
+
+        EntryIterator() {
+            idx = 0;
+            entry = table[0];
+            locateNext();
+        }
+
+        private void locateNext() {
+            // we reached the end of a list
+            while (entry == null) {
+                // goto next bucket
+                idx += 1;
+                if (idx == range) {
+                    // we reached the end
+                    return;
+                }
+
+                // entry is the first element of this bucket
+                entry = table[idx];
+            }
+        }
+
+        public boolean hasNext() {
+            return (entry != null);
+        }
+
+        public IntegerToObjectMap.Entry next() {
+            Entry result = entry;
+
+            if (result == null) {
+                throw new NoSuchElementException();
+            } else {
+                entry = entry.next;
+                locateNext();
+                return result;
+            }
+        }
+
+        public void remove() {
+            Entry remove = entry;
+
+            entry = entry.next;
+            locateNext();
+
+            IntegerToObjectHashMap.this.removeEntry(remove);
+        }
+    }
+
+    public IntegerToObjectMap.EntryIterator entryIterator() {
+        return new EntryIterator();
+    }
+
+    /**
+     * @param map
+     */
+    public void putAll(IntegerToObjectMap map) {
+        IntegerToObjectMap.EntryIterator it = map.entryIterator();
+        while (it.hasNext()) {
+            IntegerToObjectMap.Entry ent = it.next();
+            int o = ent.getKey();
+            put(o, ent.getValue());
+        }
+    }
+
+    public IntIterator keyIterator() {
+        final IntegerToObjectMap.EntryIterator iter = entryIterator();
+        return new IntIterator() {
+
+            public int next() {
+                IntegerToObjectMap.Entry ent = iter.next();
+                return ent.getKey();
+            }
+
+            public boolean hasNext() {
+                return iter.hasNext();
+            }
+
+            public int size() {
+                return IntegerToObjectHashMap.this.size();
+            }
+
+        };
+    }
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntegerToObjectMap.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntegerToObjectMap.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntegerToObjectMap.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/IntegerToObjectMap.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.util;
+
+/**
+ * @author Kresten Krab Thorup (krab@trifork.com)
+ */
+public interface IntegerToObjectMap {
+
+    Object get(int key);
+
+    Object remove(int key);
+
+    Object put(int key, Object value);
+
+    interface Entry {
+
+        int getKey();
+
+        Object getValue();
+    }
+
+    interface EntryIterator {
+
+        boolean hasNext();
+
+        Entry next();
+    }
+
+    EntryIterator entryIterator();
+
+    IntIterator keyIterator();
+
+    int size();
+
+    boolean containsKey(int target);
+
+    boolean isEmpty();
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/StringUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/StringUtil.java?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/StringUtil.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/util/StringUtil.java
Thu Oct 27 19:00:06 2005
@@ -0,0 +1,76 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.corba.util;
+
+import java.util.ArrayList;
+
+
+/**
+ * @author Jeppe Sommer (jso@eos.dk)
+ * @author Kim Harding Christensen (khc@eos.dk)
+ */
+public class StringUtil {
+
+    public static String capitalize(String str) {
+        StringBuffer sb = new StringBuffer(str);
+        sb.setCharAt(0, Character.toUpperCase(str.charAt(0)));
+        return sb.toString();
+    }
+
+    public static String join(String[] strings, String delimiter) {
+        StringBuffer sb = new StringBuffer();
+        for (int n = 0; n < strings.length; n++) {
+            sb.append(strings[n]);
+            if (n < strings.length - 1) {
+                sb.append(delimiter);
+            }
+        }
+        return sb.toString();
+    }
+
+    public static String[] split(String str, char splitChar) {
+        ArrayList al = new ArrayList(8);
+        int i = -1;
+        String s;
+        String rest = str;
+        while ((i = rest.indexOf(splitChar)) != -1) {
+            s = rest.substring(0, i);
+            al.add(s);
+            rest = rest.substring(i + 1);
+        }
+        al.add(rest);
+        String[] result = new String[al.size()];
+        al.toArray(result);
+        return result;
+    }
+
+    public static String replace(String str, String oldStr, String newStr) {
+        int prevIndex = 0, nextIndex;
+        StringBuffer result = new StringBuffer();
+
+        while ((nextIndex = str.indexOf(oldStr, prevIndex)) != -1) {
+            result.append(str.substring(prevIndex, nextIndex));
+            result.append(newStr);
+            prevIndex = nextIndex + oldStr.length();
+        }
+
+        result.append(str.substring(prevIndex));
+
+        return result.toString();
+    }
+}
+

Added: geronimo/trunk/sandbox/freeorb/pom.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/pom.xml?rev=329036&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/pom.xml (added)
+++ geronimo/trunk/sandbox/freeorb/pom.xml Thu Oct 27 19:00:06 2005
@@ -0,0 +1,156 @@
+<project>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.geronimo</groupId>
+  <artifactId>root</artifactId>
+  <name>Geronimo</name>
+  <version>1.0-SNAPSHOT</version>
+  <description>Geronimo parent</description>
+  <url>http://geronimo.apache.org</url>
+
+
+  <issueManagement>
+    <system>jira</system>
+    <url>http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10220</url>
+  </issueManagement>
+
+  <ciManagement>
+    <system>continuum</system>
+    <notifiers>
+      <notifier>
+        <type>mail</type>
+        <sendOnError/>
+        <sendOnFailure/>
+        <address>dev@geronimo.org</address>
+      </notifier>
+    </notifiers>
+  </ciManagement>
+  
+  <mailingLists>
+    <mailingList>
+      <name>Geronimo User List</name>
+      <subscribe>users-subscribe@geronimo.apache.org</subscribe>
+      <unsubscribe>users-unsubscribe@geronimo.apache.org</unsubscribe>
+      <archive>http://mail-archives.apache.org/mod_mbox/geronimo-user/</archive>
+    </mailingList>
+    <mailingList>
+      <name>Geronimo Developer List</name>
+      <subscribe>dev-subscribe@geronimo.apache.org</subscribe>
+      <unsubscribe>dev-unsubscribe@geronimo.apache.org</unsubscribe>
+      <archive>http://mail-archives.apache.org/mod_mbox/geronimo-dev/</archive>
+    </mailingList>
+    <mailingList>
+      <name>Source Control List</name>
+      <subscribe>scm-subscribe@geronimo.apache.org</subscribe>
+      <unsubscribe>scm-unsubscribe@geronimo.apache.org</unsubscribe>
+      <archive>http://mail-archives.apache.org/mod_mbox/geronimo-scm/</archive>
+    </mailingList>
+  </mailingLists>
+
+  <developers>
+    <developer>
+      <id>adc</id>
+      <name>Alan D. Cabrera</name>
+      <roles>
+        <role>Commiter</role>
+        <role>PMC</role>
+      </roles>
+      <timezone>-8</timezone>
+    </developer>
+  </developers>
+
+  <repositories>
+    <repository>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <id>codehaus</id>
+      <name>Ibiblio Repository</name>
+      <url>http://www.ibiblio.org/maven</url>
+      <layout>legacy</layout>
+    </repository>
+    <repository>
+      <id>apache</id>
+      <name>Apche Repository</name>
+      <url>http://cvs.apache.org/repository</url>
+      <layout>legacy</layout>
+    </repository>
+    <repository>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <id>central</id>
+      <name>Maven Repository Switchboard</name>
+      <url>http://repo1.maven.org/maven2</url>
+    </repository>
+  </repositories>
+   
+  <modules>
+    <module>geronimo-orb</module>
+  </modules> 
+
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+
+  <scm>
+    <connection>scm:svn:https://svn.apache.org/repos/asf/geronimo/</connection>
+    <developerConnection>scm:svn:https://${maven.username}@svn.apache.org/repos/asf/geronimo/</developerConnection>
+    <url>https://svn.apache.org/repos/asf/geronimo/</url>
+  </scm>
+
+  <organization>
+    <name>Geronimo</name>
+    <url>http://geronimo.apache.org/</url>
+  </organization>
+
+  <dependencyManagement>
+    <dependencies>
+      
+      <!-- =============================== -->
+      <!-- Required dependencies -->
+      <!-- =============================== -->
+
+      <dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+        <version>1.0.3</version>
+      </dependency>
+
+      <dependency>
+        <groupId>concurrent</groupId>
+        <artifactId>concurrent</artifactId>
+        <version>1.3.4</version>
+        <scope>runtime</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>1.2.8</version>
+        <scope>runtime</scope>
+      </dependency>
+
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+
+    <!-- =============================== -->
+    <!-- Testing dependencies -->
+    <!-- =============================== -->
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+ 
+  </dependencies>
+
+</project>



Mime
View raw message