Package rocket.serialization.client

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


    final long start = System.currentTimeMillis();
    String serializedForm = null;

    for (int i = 0; i < iterations; i++) {
      final ObjectOutputStream objectOutputStream = factory.createObjectOutputStream();
      objectOutputStream.writeObject(tree);
      serializedForm = objectOutputStream.getText();
    }
    final long end = System.currentTimeMillis();

    log(ROCKET, "End of timing.");
    logBenchmark(ROCKET, SERIALIZATION, iterations, start, end);
View Full Code Here

    final SerializationFactory factory = this.getSerializationFactory();
    Object instance = this.getObject();

    log(ROCKET, "About to capture serialized instance for later deserialization.");

    final ObjectOutputStream objectOutputStream = factory.createObjectOutputStream();
    objectOutputStream.writeObject(instance);
    final String stream = objectOutputStream.getText();
    this.setRocketStream(stream);

    log(ROCKET, "Saved serialized instance [" + stream + "]");
  }
View Full Code Here

    final long start = System.currentTimeMillis();

    log(ROCKET, "Starting of timing.");

    for (int i = 0; i < iterations; i++) {
      final ObjectOutputStream objectOutputStream = factory.createObjectOutputStream();
      objectOutputStream.writeObject(instance);
      serializedForm = objectOutputStream.getText();
    }
    final long end = System.currentTimeMillis();

    log(ROCKET, "End of timing.");
    logBenchmark(ROCKET, SERIALIZATION, iterations, start, end);
View Full Code Here

  }

  protected void commitParameterTypes() {
    final List<String> parameterTypes = this.getParameterTypes();

    final ObjectOutputStream outputStream = this.getObjectOutputStream();
    outputStream.writeInt(parameterTypes.size());

    final Iterator<String> iterator = parameterTypes.iterator();
    while (iterator.hasNext()) {
      outputStream.writeObject(iterator.next());
    }
  }
View Full Code Here

TOP

Related Classes of rocket.serialization.client.ObjectOutputStream

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.