Package java.io

Examples of java.io.ObjectInputStream$CallbackContext


      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(lock);
      oos.close();
      baos.close();
      ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
      OwnableReentrantLock l2 = (OwnableReentrantLock) ois.readObject();

      assert !l2.isLocked();
      assert l2.getOwner() == null;
   }
View Full Code Here


      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(object);
      oos.close();
      baos.close();

      ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
      Object retval = ois.readObject();
      ois.close();
      return (T) retval;
   }
View Full Code Here

      CacheMarshaller200 cm200 = new CacheMarshaller200();
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      ObjectOutputStream out = new ObjectOutputStream(bout);
      cm200.objectToObjectStream(l, out);
      out.close();
      ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bout.toByteArray()));
      List<Broken> l2 = (List<Broken>) cm200.objectFromObjectStream(in);

      assert l2.size() == 2;
      assert l2.get(0).name.equals("o1");
      assert l2.get(1).name.equals("o2");
View Full Code Here

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      cm200.objectToObjectStream("Hello World", oos, Fqn.fromString("/hello"));
      oos.close();

      ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));

      // test that the first thing on the stream is the fqn!
      byte magic = ois.readByte();
      short ref = ois.readShort();
      assert magic == CacheMarshaller200.MAGICNUMBER_FQN;

      // now the chunks of an Fqn
      Fqn f = cm200.unmarshallFqn(ois, new UnmarshalledReferences());
View Full Code Here

  }

  private DayProgramScheme[] loadDayProgramSchemes() {
    String home = Plugin.getPluginManager().getTvBrowserSettings().getTvBrowserUserHome();
    File schemeFile = new File(home,SCHEME_FILE_DAYPROGRAM);
    ObjectInputStream in=null;
    try {
      in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(schemeFile), 0x4000));
      DayProgramScheme[] schemes = readDayProgramSchemesFromStream(in);
      in.close();
      return schemes;
    }catch(Exception e) {
      if (in != null) {
        try { in.close(); } catch(IOException exc) {}
      }
      DayProgramScheme scheme = new DayProgramScheme(mLocalizer.msg("defaultScheme","DefaultScheme"));
      scheme.setSettings(new DayProgramPrinterSettings(
              new Date(),
              3,
View Full Code Here

  public Serializable getObject() throws Exception {
    // TODO (AF): May be, we should verify that it is an Object message!!
    if (body == null) return null;

    ByteArrayInputStream bais = null;
    ObjectInputStream ois = null;
    Object obj = null;
   
    try {
      try {
        bais = new ByteArrayInputStream(body);
        ois = new ObjectInputStream(bais);
        obj = ois.readObject();
      } catch (ClassNotFoundException cnfexc) {
        // Could not build serialized object: reason could be linked to
        // class loaders hierarchy in an application server.
        class Specialized_OIS extends ObjectInputStream {
          Specialized_OIS(InputStream is) throws IOException {
            super(is);
          }

          protected Class resolveClass(ObjectStreamClass osc) throws IOException, ClassNotFoundException {
            String n = osc.getName();
            return Class.forName(n, false, Thread.currentThread().getContextClassLoader());
          }
        }

        bais = new ByteArrayInputStream(body);
        ois = new Specialized_OIS(bais);
        obj = ois.readObject();
      }
    } catch (Exception exc) {
      if (logger.isLoggable(BasicLevel.ERROR))
        logger.log(BasicLevel.ERROR, "ERROR: getObject()", exc);
      // Don't forget to rethrow the Exception
      throw exc;
    } finally {
      try {
        ois.close();
      } catch (Exception e) {}
      try {
        bais.close();
      } catch (Exception e) {}
    }
View Full Code Here

          throw new IOException(
              "Invalid format for a session entry: " + s);
        String aname = s.substring(0, cp);
        // if (lazyRestore)
        // result.put(aname, s.substring(cp+1));
        ObjectInputStream ois = new ObjectInputStream(
            new ByteArrayInputStream(Utils.decode64(s
                .substring(cp + 1))));
        Throwable restoreError;
        try {
          Object so;
          result.put(aname, so = ois.readObject());
          restoreError = null;
          if (so instanceof HttpSessionActivationListener)
            ((HttpSessionActivationListener) so)
                .sessionDidActivate(new HttpSessionEvent(result));
View Full Code Here

    int bodySize = msgReceived.getBodySize();
    byte[] message = new byte[bodySize];
    msgReceived.getBodyBuffer().readBytes(message);
    ByteArrayInputStream bais = new ByteArrayInputStream(message);
    try {
      ObjectInputStream ois = new ObjectInputStream(bais);
      return ois.readObject();
    } catch (IOException e) {
      throw new IOException("Error reading message");
    } catch (ClassNotFoundException e) {
      throw new IOException("Error creating message");
    }
View Full Code Here

      }
     
    @SuppressWarnings("unchecked")
    public void execute(Content content) {
      ByteArrayInputStream bis = new ByteArrayInputStream(content.getContent());
      ObjectInputStream in;
      try {
        in = new ObjectInputStream(bis);
        Object result = in.readObject();
        in.close();
        results.put("Result", result);
        if (result instanceof Map) {
          Map<?, ?> map = (Map) result;
          for (Map.Entry<?, ?> entry: map.entrySet()) {
            if (entry.getKey() instanceof String) {
View Full Code Here

  private Object readMessage(ClientMessage serverMessage) throws IOException, ClassNotFoundException {
    int bodySize = serverMessage.getBodySize();
    byte[] message = new byte[bodySize];
    serverMessage.getBodyBuffer().readBytes(message);
    ByteArrayInputStream bais = new ByteArrayInputStream(message);
    ObjectInputStream ois = new ObjectInputStream(bais);
    return ois.readObject();
  }
View Full Code Here

TOP

Related Classes of java.io.ObjectInputStream$CallbackContext

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.