Examples of ObjectOutputStream


Examples of java.io.ObjectOutputStream

    ContentData content = null;
    Object contentObject = workItem.getParameter("Content");
    if (contentObject != null) {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      ObjectOutputStream out;
      try {
        out = new ObjectOutputStream(bos);
        out.writeObject(contentObject);
        out.close();
        content = new ContentData();
        content.setContent(bos.toByteArray());
        content.setAccessType(AccessType.Inline);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
                // If the content is not set we will automatically copy all the input objects into
                // the task content
                else {
                    contentObject = workItem.getParameters();
                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
      ObjectOutputStream out;
      try {
        out = new ObjectOutputStream(bos);
        out.writeObject(contentObject);
        out.close();
        content = new ContentData();
        content.setContent(bos.toByteArray());
        content.setAccessType(AccessType.Inline);
                                content.setType("java.util.map");
      } catch (IOException e) {
View Full Code Here

Examples of java.io.ObjectOutputStream

    this.producer = producer;
  }

  public void write(Object message) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oout;
    try {
      oout = new ObjectOutputStream(baos);
      oout.writeObject(message);
      ClientMessage clientMessage = session.createMessage(true);
      clientMessage.getBodyBuffer().writeBytes(baos.toByteArray());
      producer.send(clientMessage);
    } catch (IOException e) {
      throw new IOException("Error creating message");
View Full Code Here

Examples of org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream

        ReplyHeader_1_2 reply = new ReplyHeader_1_2();
        reply.request_id = request.request_id;

        ObjectInputStream objectIn;
        ObjectOutputStream objectOut;

        if (simpleIDL || keyType == 'N' || keyType == 'J') {
            // Name Service and JMS use simple IDL interoperability.
            objectIn = org.apache.geronimo.interop.rmi.iiop.SimpleObjectInputStream.getInstance(parameters);
            objectOut = org.apache.geronimo.interop.rmi.iiop.SimpleObjectOutputStream.getInstance(results);
        } else {
            // Otherwise use RMI-IIOP interoperability.
            objectIn = org.apache.geronimo.interop.rmi.iiop.ObjectInputStream.getInstance(parameters);
            objectOut = org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream.getInstance(results);
        }

        try {
            String objectName = null;
            for (int colonPos = 0; colonPos < keyLength; colonPos++) {
                if (objectKey[colonPos] == ':') {
                    objectName = UTF8.toString(objectKey, 0, colonPos);
                    int newKeyLength = keyLength - colonPos - 1;
                    byte[] newObjectKey = new byte[newKeyLength];
                    System.arraycopy(objectKey, colonPos + 1, newObjectKey, 0, newKeyLength);
                    objectKey = newObjectKey;
                    break;
                }
            }

            if (objectName == null) {
                objectName = UTF8.toString(objectKey);
            }

            processServiceContext(request);

            Object object;
            try
            {
                object = nameService.lookup(objectName);
            }
            catch (javax.naming.NameNotFoundException notFound)
            {
                warnLookupFailed(clientInfo, notFound);
                throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
            }

            Adapter adapter = (Adapter)object;
            if (adapter != null)
            {
                adapter.invoke(request.operation, objectKey, objectIn, objectOut);

                if (objectOut.hasException()) {
                    reply.reply_status = ReplyStatusType_1_2.USER_EXCEPTION;
                } else {
                    reply.reply_status = ReplyStatusType_1_2.NO_EXCEPTION;
                }
View Full Code Here

Examples of rocket.serialization.client.ObjectOutputStream

    Checker.notNull("parameter:serviceProvider", serviceProvider);

    ServerSerializationFactory serializationFactory = createSerializationFactory();

    final ObjectInputStream inputStream = serializationFactory.createObjectInputStream(input);
    final ObjectOutputStream outputStream = serializationFactory.createObjectOutputStream();

    Object result = null;
    boolean exceptionWasThrown = false;
    Method method = null;

    // read in the interface...
    final String interfaceName = (String) inputStream.readObject();
    final Class interfacee = this.getRequestedInterface(interfaceName);

    // verify the serviceProvider actually implements $interface
    this.checkServiceProvider(interfacee, serviceProvider);

    // the method name...
    final String methodName = (String) inputStream.readObject();

    // the parameter types...
    final int parameterCount = inputStream.readInt();
    final String[] parameterTypes = new String[parameterCount];
    for (int i = 0; i < parameterTypes.length; i++) {
      parameterTypes[i] = (String) inputStream.readObject();
    }

    // attempt to find a method on the given interface that matches the
    // method signature...
    method = this.getMethod(serviceProvider.getClass(), methodName, parameterTypes);

    // deserialize parameters...
    final Object[] parameters = new Object[parameterCount];
    for (int i = 0; i < parameterCount; i++) {
      parameters[i] = inputStream.readObject();
    }

    // any exceptions that are thrown will be serialized and included in the
    // response...
    try {
      // prepare to invoke method...
      result = this.invoke(serviceProvider, method, parameters);
    } catch (final InvocationTargetException invocationTargetException) {
      final Throwable caught = invocationTargetException.getTargetException();

      // if method throws exception leave...
      boolean thrown = false;
      final Class caughtType = caught.getClass();
      final Class[] thrownExceptions = method.getExceptionTypes();
      for (int i = 0; i < thrownExceptions.length; i++) {
        final Class thrownException = thrownExceptions[i];
        if (caughtType.equals(thrownException)) {
          thrown = true;
          result = caught;
          break;
        }
      }

      if (false == thrown) {
        result = new RpcException(caught.getMessage());
      }
      exceptionWasThrown = true;

    } catch (final RuntimeException runtimeException) {
      exceptionWasThrown = true;
      result = new RpcException(runtimeException.getMessage());
    } catch (final Throwable throwable) {
      exceptionWasThrown = true;
      result = new RpcException(throwable.getMessage());
    }

    // write the result...
    outputStream.writeBoolean(exceptionWasThrown);
    outputStream.writeObject(result);

    return outputStream.getText();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.