Package javax.rmi.CORBA

Examples of javax.rmi.CORBA.Stub


                    case OBJECT:
                        clazz = (Class) in.readObject();
                        obj = in.readObject();
                        if (obj instanceof Stub) {
                            final Stub stub = (Stub) obj;
                            final ORB orb = getORB();
                            stub.connect(orb);
                        }
                        break;
                    default:
                        throw new IOException("Unkown data type: " + type);
                }
View Full Code Here


                    case L:
                        clazz = (Class) in.readObject();
                        obj = in.readObject();
                        if (obj instanceof Stub) {
                            Stub stub = (Stub)obj;
                            ORB orb = getORB();
                            stub.connect(orb);
                        }
                        break;
                    default:
                        throw new IOException("Unkown data type: " + type);
                }
View Full Code Here

    private void verifyStub(final Class c) throws Exception {
        final Exception[] exception = new Exception[1];
        Runnable verify = new Runnable() {
            public void run() {
                try {
                    Stub stub = (Stub) c.newInstance();
                    String[] strings = stub._ids();
                    assertNotNull(strings);
                    assertEquals(2, strings.length);
                    List ids = Arrays.asList(strings);
                    assertTrue(ids.contains("RMI:org.apache.geronimo.corba.compiler.Simple:0000000000000000"));
                    assertTrue(ids.contains("RMI:org.apache.geronimo.corba.compiler.Special:0000000000000000"));
View Full Code Here

                    case L:
                        clazz = (Class) in.readObject();
                        obj = in.readObject();
                        if (obj instanceof Stub) {
                            Stub stub = (Stub)obj;
                            ORB orb = getORB();
                            stub.connect(orb);
                        }
                        break;
                    default:
                        throw new IOException("Unkown data type: " + type);
                }
View Full Code Here

        this.type = type;
        this.operations = Collections.unmodifiableMap(org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.mapMethodToOperation(type));
    }

    public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        Stub stub = (Stub) 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.tuscany.sca.binding.ejb.corba.Java2IDLUtil.writeObject(parameterType, args[i], out);
                    }

                    // send the invocation
                    in = (InputStream) stub._invoke(out);

                    // read the result
                    Object result = org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.readObject(method.getReturnType(), in);
                    return result;
                } catch (RemarshalException exception) {
                    continue;
                } catch (ApplicationException exception) {
                    org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.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);
                }
            }
        }
    }
View Full Code Here

        this.type = type;
        this.operations = Collections.unmodifiableMap(org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.mapMethodToOperation(type));
    }

    public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        Stub stub = (Stub) 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.tuscany.sca.binding.ejb.corba.Java2IDLUtil.writeObject(parameterType, args[i], out);
                    }

                    // send the invocation
                    in = (InputStream) stub._invoke(out);

                    // read the result
                    Object result = org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.readObject(method.getReturnType(), in);
                    return result;
                } catch (RemarshalException exception) {
                    continue;
                } catch (ApplicationException exception) {
                    org.apache.tuscany.sca.binding.ejb.corba.Java2IDLUtil.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);
                }
            }
        }
    }
View Full Code Here

                ObjectImpl objectImpl = (ObjectImpl) object;
                objectImpl._get_delegate();
            } catch (BAD_OPERATION e) {
                try {
                    // Reconnect
                    final Stub stub = (Stub) object;
                    final ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB");
                    stub.connect(orb);
                } catch (NamingException ne) {
                    throw new IOException("Unable to lookup java:comp/ORB");
                }
            }
        } else {
View Full Code Here

                    case L:
                        clazz = (Class) in.readObject();
                        obj = in.readObject();
                        if (obj instanceof Stub) {
                            Stub stub = (Stub)obj;
                            ORB orb = getORB();
                            stub.connect(orb);
                        }
                        break;
                    default:
                        throw new IOException("Unkown data type: " + type);
                }
View Full Code Here

                    case L:
                        clazz = (Class) in.readObject();
                        obj = in.readObject();
                        if (obj instanceof Stub) {
                            Stub stub = (Stub)obj;
                            ORB orb = getORB();
                            stub.connect(orb);
                        }
                        break;
                    default:
                        throw new IOException("Unkown data type: " + type);
                }
View Full Code Here

         return (EJBHome) PortableRemoteObject.narrow(obj, EJBHome.class);

      // Create the stub from the stub class
      try
      {
         Stub stub = (Stub) stubClass.newInstance();
         stub._set_delegate(((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate());
         return (EJBHome) stub;
      }
      catch (Exception e)
      {
         throw new RemoteException("Error creating stub", e);
View Full Code Here

TOP

Related Classes of javax.rmi.CORBA.Stub

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.