Package org.jboss.marshalling

Examples of org.jboss.marshalling.Unmarshaller


            this.context = context;
            if (this.bytes != null) {
                ByteArrayInputStream input = new ByteArrayInputStream(this.bytes);
                SimpleDataInput data = new SimpleDataInput(Marshalling.createByteInput(input));
                int version = data.readInt();
                Unmarshaller unmarshaller = context.createUnmarshaller(version);
                try {
                    unmarshaller.start(data);
                    // Workaround for AS7-2496
                    ClassLoader currentLoader = null;
                    ClassLoader contextLoader = context.getContextClassLoader(version);
                    if (contextLoader != null) {
                        currentLoader = getCurrentThreadContextClassLoader();
                        setCurrentThreadContextClassLoader(contextLoader);
                    }
                    try {
                        this.object = (T) unmarshaller.readObject();
                    } finally {
                        if (contextLoader != null) {
                            setCurrentThreadContextClassLoader(currentLoader);
                        }
                    }
                    unmarshaller.finish();
                    this.bytes = null; // Free up memory
                } finally {
                    unmarshaller.close();
                }
            }
        }
        return this.object;
    }
View Full Code Here


        @Override
        protected void setState(InputStream is) throws IOException, ClassNotFoundException {
            MarshallingConfiguration config = new MarshallingConfiguration();
            config.setClassResolver(new SimpleClassResolver(getStateTransferClassLoader()));
            Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(config);
            unmarshaller.start(Marshalling.createByteInput(is));
            this.state = unmarshaller.readObject(Serializable.class);
            unmarshaller.close();
        }
View Full Code Here

        config.setSerializedCreator(new SunReflectiveCreator());
        config.setExternalizerCreator(new ReflectiveCreator());
        if (resolver != null) {
            config.setClassResolver(resolver);
        }
        Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(config);
        unmarshaller.start(Marshalling.createByteInput(new ByteArrayInputStream(buffer, offset, length)));
        try {
            return unmarshaller.readObject();
        } finally {
            unmarshaller.close();
        }
    }
View Full Code Here

        config.setSerializedCreator(new SunReflectiveCreator());
        config.setExternalizerCreator(new ReflectiveCreator());
        if (resolver != null) {
            config.setClassResolver(resolver);
        }
        Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(config);
        unmarshaller.start(Marshalling.createByteInput(new ByteArrayInputStream(buffer, offset, length)));
        // read past the null/serializable byte
        unmarshaller.read();
        try {
            return unmarshaller.readObject();
        } finally {
            unmarshaller.close();
        }
    }
View Full Code Here

        if (buffer == null) return null;
        MarshallingConfiguration config = new MarshallingConfiguration();
        if (loader != null) {
            config.setClassResolver(new SimpleClassResolver(loader));
        }
        Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(config);
        unmarshaller.start(Marshalling.createByteInput(new ByteArrayInputStream(buffer, offset, length)));
        try {
            return unmarshaller.readObject();
        } finally {
            unmarshaller.close();
        }
    }
View Full Code Here

        MarshallingConfiguration config = new MarshallingConfiguration();
        if (loader != null) {
            config.setClassResolver(new SimpleClassResolver(loader));
        }
        Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(config);
        unmarshaller.start(Marshalling.createByteInput(new ByteArrayInputStream(buffer, offset, length)));
        // read past the null/serializable byte
        unmarshaller.read();
        try {
            return unmarshaller.readObject();
        } finally {
            unmarshaller.close();
        }
    }
View Full Code Here

        @Override
        protected void setState(InputStream is) throws IOException, ClassNotFoundException {
            MarshallingConfiguration config = new MarshallingConfiguration();
            config.setClassResolver(new SimpleClassResolver(getStateTransferClassLoader()));
            Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(config);
            unmarshaller.start(Marshalling.createByteInput(is));
            this.state = unmarshaller.readObject(Serializable.class);
            unmarshaller.close();
        }
View Full Code Here

   }

   @Override
   final public ObjectInput startObjectInput(final InputStream is, final boolean isReentrant) throws IOException {
      PerThreadInstanceHolder instanceHolder = marshallerTL.get();
      Unmarshaller unmarshaller = instanceHolder.getUnmarshaller();

      if (trace)
         log.tracef("Start unmarshaller after retrieving marshaller from %s",
                   isReentrant ? "factory" : "thread local");

      unmarshaller.start(Marshalling.createByteInput(is));
      return unmarshaller;
   }
View Full Code Here

      }
      return o;
   }

   public ObjectInput startObjectInput(InputStream is, boolean isReentrant) throws IOException {
      Unmarshaller unmarshaller;
      if (isReentrant) {
         unmarshaller = factory.createUnmarshaller(configuration);
      } else {
         unmarshaller = unmarshallerTL.get();
      }

      if (log.isTraceEnabled())
         log.tracef("Start unmarshaller after retrieving marshaller from %s",
                   isReentrant ? "factory" : "thread local");

      unmarshaller.start(Marshalling.createByteInput(is));
      return unmarshaller;
   }
View Full Code Here

        }
        return os.toByteArray();
    }

    protected Object unmarshall( byte[] bytes ) throws IOException, ClassNotFoundException {
        final Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
        final ByteArrayInputStream is = new ByteArrayInputStream(bytes);
        try {
            unmarshaller.start(Marshalling.createByteInput(is));
            Object result = unmarshaller.readObject();
            unmarshaller.finish();
            is.close();
            return result;
        } finally {
            // clean up stream resource
            try {
View Full Code Here

TOP

Related Classes of org.jboss.marshalling.Unmarshaller

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.