geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r505432 [8/11] - in /geronimo/server/trunk: applications/magicGball/magicGball-ear/src/main/plan/ configs/client-corba-yoko/src/plan/ configs/j2ee-corba-yoko/src/plan/ configs/openejb-corba-deployer/src/plan/ modules/ modules/geronimo-corba...
Date Fri, 09 Feb 2007 19:24:39 GMT
Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NoDTxServerTransactionPolicies.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NoDTxServerTransactionPolicies.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NoDTxServerTransactionPolicies.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NoDTxServerTransactionPolicies.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.transaction.nodistributedtransactions;
+
+import org.apache.geronimo.corba.transaction.OperationTxPolicy;
+import org.apache.openejb.DeploymentInfo;
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class NoDTxServerTransactionPolicies {
+    private static final OperationTxPolicy[] policies = new OperationTxPolicy[DeploymentInfo.TX_MAX];
+    static {
+        policies[DeploymentInfo.TX_MANDITORY] = Required.INSTANCE;
+        policies[DeploymentInfo.TX_NEVER] = NotRequired.INSTANCE;
+        policies[DeploymentInfo.TX_NOT_SUPPORTED] = Ignore.INSTANCE;
+        policies[DeploymentInfo.TX_REQUIRED] = NotRequired.INSTANCE;
+        policies[DeploymentInfo.TX_REQUIRES_NEW] = Ignore.INSTANCE;
+        policies[DeploymentInfo.TX_SUPPORTS] = NotRequired.INSTANCE;
+    }
+
+    public static OperationTxPolicy getContainerTransactionPolicy(byte transactionAttribute) {
+        return policies[transactionAttribute];
+    }
+    public static OperationTxPolicy getBeanTransactionPolicy() {
+        return Ignore.INSTANCE;
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NotRequired.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NotRequired.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NotRequired.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NotRequired.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.transaction.nodistributedtransactions;
+
+import java.io.Serializable;
+
+import org.apache.geronimo.corba.transaction.OperationTxPolicy;
+import org.omg.CORBA.INVALID_TRANSACTION;
+import org.omg.CosTransactions.PropagationContext;
+
+/**
+ * Use for:
+ * Required
+ * Never
+ * Supports
+ *
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class NotRequired implements OperationTxPolicy, Serializable {
+    public static final OperationTxPolicy INSTANCE = new NotRequired();
+
+    public void importTransaction(PropagationContext propagationContext) {
+        if (propagationContext != null) {
+            throw new INVALID_TRANSACTION("Transactions cannot be imported, and might also be not allowed for this method");
+        }
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/Required.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/Required.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/Required.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/Required.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.transaction.nodistributedtransactions;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.INVALID_TRANSACTION;
+import org.omg.CORBA.TRANSACTION_REQUIRED;
+import org.omg.CosTransactions.PropagationContext;
+import org.apache.geronimo.corba.transaction.OperationTxPolicy;
+
+/**
+ * Use for:
+ * Mandatory
+ *
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class Required implements OperationTxPolicy, Serializable {
+
+    public static final OperationTxPolicy INSTANCE = new Required();
+
+    public void importTransaction(PropagationContext propagationContext) {
+        if (propagationContext == null) {
+            throw new TRANSACTION_REQUIRED("Transaction required");
+        }
+        throw new INVALID_TRANSACTION("Transaction cannot be imported");
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/ClientContextHolderStub.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/ClientContextHolderStub.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/ClientContextHolderStub.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/ClientContextHolderStub.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.rmi.CORBA.Stub;
+import javax.ejb.EJBHome;
+
+import org.omg.CORBA.ORB;
+import org.apache.geronimo.corba.CORBAEJBMemento;
+
+/**
+ * @version $Revision: 502310 $ $Date: 2007-02-01 10:34:57 -0800 (Thu, 01 Feb 2007) $
+ */
+public abstract class ClientContextHolderStub extends Stub {
+
+    protected ClientContextHolderStub() {
+    }
+
+    public final Object writeReplace() {
+        String ior = getOrb().object_to_string(this);
+        return new CORBAEJBMemento(ior, this instanceof EJBHome);
+    }
+
+    private static ORB getOrb() {
+        try {
+            Context context = new InitialContext();
+            ORB orb = (ORB) context.lookup("java:comp/ORB");
+            return orb;
+        } catch (Throwable e) {
+            throw new org.omg.CORBA.MARSHAL("Could not find ORB in jndi at java:comp/ORB", 0, org.omg.CORBA.CompletionStatus.COMPLETED_YES);
+        }
+    }
+}
+
+

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/DynamicStubClassLoader.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/DynamicStubClassLoader.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/DynamicStubClassLoader.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/DynamicStubClassLoader.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,185 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 net.sf.cglib.core.NamingPolicy;
+import net.sf.cglib.core.Predicate;
+import net.sf.cglib.proxy.Callback;
+import net.sf.cglib.proxy.CallbackFilter;
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.FixedValue;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.NoOp;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class DynamicStubClassLoader extends ClassLoader implements GBeanLifecycle {
+    private final static Log log = LogFactory.getLog(DynamicStubClassLoader.class);
+    private final static String PACKAGE_PREFIX = "org.omg.stub.";
+
+    private boolean stopped = true;
+
+    public synchronized Class loadClass(final String name) throws ClassNotFoundException {
+        if (stopped) {
+            throw new ClassNotFoundException("DynamicStubClassLoader is stopped");
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("Load class " + name);
+        }
+
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+        // check if the stub already exists first
+        try {
+            return classLoader.loadClass(name);
+        } catch (ClassNotFoundException e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Unable to load class from the context class loader");
+            }
+        }
+
+        // if this is not a class from the org.omb.stub name space don't attempt to generate
+        if (!name.startsWith(PACKAGE_PREFIX)) {
+            if (log.isDebugEnabled()) {
+                log.debug("Could not load class: " + name);
+            }
+            throw new ClassNotFoundException("Could not load class: " + name);
+        }
+
+        // load the interfaces class we are attempting to create a stub for
+        Class iface = loadStubInterfaceClass(name, classLoader);
+
+        // create the stub builder
+        try {
+            Enhancer enhancer = new Enhancer();
+            enhancer.setSuperclass(ClientContextHolderStub.class);
+            enhancer.setInterfaces(new Class[]{iface});
+            enhancer.setCallbackFilter(FILTER);
+            enhancer.setCallbackTypes(new Class[]{NoOp.class, MethodInterceptor.class, FixedValue.class});
+            enhancer.setUseFactory(false);
+            enhancer.setClassLoader(classLoader);
+            enhancer.setNamingPolicy(new NamingPolicy() {
+                public String getClassName(String s, String s1, Object o, Predicate predicate) {
+                    return name;
+                }
+            });
+
+            // generate the class
+            Class result = enhancer.createClass();
+            assert result != null;
+
+            StubMethodInterceptor interceptor = new StubMethodInterceptor(iface);
+            Ids ids = new Ids(iface);
+            Enhancer.registerStaticCallbacks(result, new Callback[]{NoOp.INSTANCE, interceptor, ids});
+
+            if (log.isDebugEnabled()) {
+                log.debug("result: " + result.getName());
+            }
+            return result;
+        } catch (RuntimeException e) {
+            log.error("Unable to generate stub: " + name, e);
+            throw e;
+        } catch (Error e) {
+            log.error("Unable to generate stub: " + name, e);
+            throw e;
+        }
+    }
+
+    private Class loadStubInterfaceClass(String name, ClassLoader classLoader) throws ClassNotFoundException {
+        try {
+            int begin = name.lastIndexOf('.') + 1;
+            String iPackage = name.substring(13, begin);
+            String iName = iPackage + name.substring(begin + 1, name.length() - 5);
+
+            return classLoader.loadClass(iName);
+        } catch (ClassNotFoundException e) {
+            // don't log exceptions from CosNaming because it attempts to load every
+            // class bound into the name server
+            boolean shouldLog = true;
+            StackTraceElement[] stackTrace = e.getStackTrace();
+            for (int i = 0; i < stackTrace.length; i++) {
+                StackTraceElement stackTraceElement = stackTrace[i];
+                if (stackTraceElement.getClassName().equals("org.omg.CosNaming.NamingContextExtPOA") &&
+                        stackTraceElement.getMethodName().equals("_invoke")) {
+                    shouldLog = false;
+                    break;
+                }
+            }
+            if (shouldLog) {
+                log.error("Unable to generate stub", e);
+            }
+
+            throw new ClassNotFoundException("Unable to generate stub", e);
+        }
+    }
+
+    private static final CallbackFilter FILTER = new CallbackFilter() {
+        public int accept(Method method) {
+            // we don't intercept non-public methods like finalize
+            if (!Modifier.isPublic(method.getModifiers())) {
+                return 0;
+            }
+
+            if (method.getReturnType().equals(String[].class) && method.getParameterTypes().length == 0 && method.getName().equals("_ids")) {
+                return 2;
+            }
+
+            if (Modifier.isAbstract(method.getModifiers())) {
+                return 1;
+            }
+
+            return 0;
+        }
+    };
+
+    private static final class Ids implements FixedValue {
+        private final String[] typeIds;
+
+        public Ids(Class type) {
+            typeIds = Util.createCorbaIds(type);
+        }
+
+        public Object loadObject() throws Exception {
+            return typeIds;
+        }
+    }
+
+    public synchronized void doStart() throws Exception {
+        UtilDelegateImpl.setClassLoader(this);
+        stopped = false;
+    }
+
+    public synchronized void doStop() throws Exception {
+        stopped = true;
+        log.debug("Stopped");
+    }
+
+    public synchronized void doFail() {
+        stopped = true;
+        log.warn("Failed");
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/DynamicStubClassLoaderGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/DynamicStubClassLoaderGBean.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/DynamicStubClassLoaderGBean.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/DynamicStubClassLoaderGBean.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public final class DynamicStubClassLoaderGBean {
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(DynamicStubClassLoaderGBean.class, DynamicStubClassLoader.class, NameFactory.CORBA_SERVICE);
+        infoFactory.addOperation("loadClass", new Class[]{String.class});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/OpenORBUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/OpenORBUtil.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/OpenORBUtil.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/OpenORBUtil.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.corba.CORBABean;
+
+
+/**
+ * OpenORB specific startup GBean
+ *
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class OpenORBUtil implements GBeanLifecycle {
+
+    private final Log log = LogFactory.getLog(OpenORBUtil.class);
+
+    private final CORBABean server;
+
+    public OpenORBUtil() {
+        server = null;
+    }
+
+    public OpenORBUtil(CORBABean server) {
+        this.server = server;
+    }
+
+    public CORBABean getServer() {
+        return server;
+    }
+
+    public void doStart() throws Exception {
+
+//        DefaultORB.setORB(server.getORB());
+
+        log.debug("Started OpenORBUtil");
+    }
+
+    public void doStop() throws Exception {
+        log.debug("Stopped OpenORBUtil");
+    }
+
+    public void doFail() {
+        log.warn("Failed OpenORBUtil");
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/OpenORBUtilGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/OpenORBUtilGBean.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/OpenORBUtilGBean.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/OpenORBUtilGBean.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.corba.CORBABean;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public final class OpenORBUtilGBean {
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(OpenORBUtilGBean.class, OpenORBUtil.class, NameFactory.CORBA_SERVICE);
+
+        infoFactory.addReference("Server", CORBABean.class, NameFactory.CORBA_SERVICE);
+        infoFactory.setConstructor(new String[]{"Server"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/StubMethodInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/StubMethodInterceptor.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/StubMethodInterceptor.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/StubMethodInterceptor.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,150 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.ejb.EJBObject;
+import javax.rmi.CORBA.Util;
+
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CORBA.portable.ServantObject;
+import org.omg.CORBA_2_3.portable.InputStream;
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+/**
+ * @version $Revision: 502310 $ $Date: 2007-02-01 10:34:57 -0800 (Thu, 01 Feb 2007) $
+ */
+public class StubMethodInterceptor implements MethodInterceptor {
+    private static final Method ISIDENTICAL;
+
+    static {
+        try {
+            ISIDENTICAL = EJBObject.class.getMethod("isIdentical", new Class[]{EJBObject.class});
+        } catch (NoSuchMethodException e) {
+            throw new ExceptionInInitializerError(e);
+        }
+    }
+
+    private final Class type;
+    private final Map operations;
+
+    public StubMethodInterceptor(Class type) {
+        this.type = type;
+        this.operations = Collections.unmodifiableMap(org.apache.geronimo.corba.util.Util.mapMethodToOperation(type));
+    }
+
+    public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
+        ClientContextHolderStub stub = (ClientContextHolderStub) proxy;
+
+        // handle is identical in stub to avoid unnecessary round trip
+        if (method.equals(ISIDENTICAL)) {
+            org.omg.CORBA.Object otherObject = (org.omg.CORBA.Object) args[0];
+            return new Boolean(stub._is_equivalent(otherObject));
+        }
+
+        // get the operation name object
+        String operationName = (String) operations.get(method);
+        if (operationName == null) {
+            throw new IllegalStateException("Unknown method: " + method);
+        }
+
+        while (true) {
+            // if this is a stub to a remote object we invoke over the wire
+            if (!Util.isLocal(stub)) {
+
+                InputStream in = null;
+                try {
+                    // create the request output stream
+                    OutputStream out = (OutputStream) stub._request(operationName, true);
+
+                    // write the arguments
+                    Class[] parameterTypes = method.getParameterTypes();
+                    for (int i = 0; i < parameterTypes.length; i++) {
+                        Class parameterType = parameterTypes[i];
+                        org.apache.geronimo.corba.util.Util.writeObject(parameterType, args[i], out);
+                    }
+
+                    // send the invocation
+                    in = (InputStream) stub._invoke(out);
+
+                    // read the result
+                    Object result = org.apache.geronimo.corba.util.Util.readObject(method.getReturnType(), in);
+                    return result;
+                } catch (RemarshalException exception) {
+                    continue;
+                } catch (ApplicationException exception) {
+                    org.apache.geronimo.corba.util.Util.throwException(method, (InputStream) exception.getInputStream());
+                } catch (SystemException e) {
+                    throw Util.mapSystemException(e);
+                } finally {
+                    stub._releaseReply(in);
+                }
+            } else {
+                // get the servant
+                ServantObject servantObject = stub._servant_preinvoke(operationName, type);
+                if (servantObject == null) {
+                    continue;
+                }
+
+                try {
+                    // copy the arguments
+                    Object[] argsCopy = Util.copyObjects(args, stub._orb());
+
+                    // invoke the servant
+                    Object result = null;
+                    try {
+                        result = method.invoke(servantObject.servant, argsCopy);
+                    } catch (InvocationTargetException e) {
+                        if (e.getCause() != null) {
+                            throw e.getCause();
+                        }
+                        throw e;
+                    }
+
+                    // copy the result
+                    result = Util.copyObject(result, stub._orb());
+
+                    return result;
+                } catch (Throwable throwable) {
+                    // copy the exception
+                    Throwable throwableCopy = (Throwable) Util.copyObject(throwable, stub._orb());
+
+                    // if it is one of my exception rethrow it
+                    Class[] exceptionTypes = method.getExceptionTypes();
+                    for (int i = 0; i < exceptionTypes.length; i++) {
+                        Class exceptionType = exceptionTypes[i];
+                        if (exceptionType.isInstance(throwableCopy)) {
+                            throw throwableCopy;
+                        }
+                    }
+
+                    throw Util.wrapException(throwableCopy);
+                } finally {
+                    stub._servant_postinvoke(servantObject);
+                }
+            }
+        }
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/TypeCode.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/TypeCode.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/TypeCode.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/util/TypeCode.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,798 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.TypeCodePackage.Bounds;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+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";
+        }
+    }
+
+    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());
+        }
+    }
+
+    public boolean equivalent
+        (org.omg.CORBA.TypeCode tc)
+    {
+        throw new org.omg.CORBA.NO_IMPLEMENT();
+    }
+
+    public org.omg.CORBA.TypeCode get_compact_typecode()
+    {
+        throw new org.omg.CORBA.NO_IMPLEMENT();
+    }
+
+    private boolean equalIfNotEmpty(String a, String b)
+    {
+        if (a.length() == 0 || b.length() == 0)
+        {
+            return true;
+        }
+        else
+        {
+            return a.equals(b);
+        }
+    }
+
+    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
+    // -----------------------------------------------------------------------
+    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();
+    }
+}



Mime
View raw message