Package org.jboss.marshalling

Examples of org.jboss.marshalling.ByteOutput


            @Override
            public void write(final byte[] b, final int off, final int len) throws IOException {
                dataOutput.write(b, off, len);
            }
        };
        final ByteOutput byteOutput = Marshalling.createByteOutput(outputStream);
        // start the marshaller
        marshaller.start(byteOutput);

        return marshaller;
    }
View Full Code Here


            public void write(int b) throws IOException {
                final int byteToWrite = b & 0xff;
                dataOutput.write(byteToWrite);
            }
        };
        final ByteOutput byteOutput = Marshalling.createByteOutput(outputStream);
        // start the marshaller
        marshaller.start(byteOutput);

        return marshaller;
    }
View Full Code Here

     */
    @Test
    public void testReuse() throws Throwable {
        final TestSerializable t = new TestSerializable();
        ByteArrayOutputStream baos = new ByteArrayOutputStream(10240);
        ByteOutput byteOutput = Marshalling.createByteOutput(baos);
        Marshaller marshaller = testMarshallerProvider.create(configuration.clone(), byteOutput);
        if (marshaller instanceof ObjectOutputStreamMarshaller) {
            throw new SkipException(marshaller + " doesn't support start()");
        }
        System.out.println("Marshaller = " + marshaller + " (version set to " + configuration.getVersion() + ")");
View Full Code Here

        }
        final Serializable serializable = new TestSerializable();
        final TestStreamHeader streamHeader = new TestStreamHeader();
        configuration.setStreamHeader(streamHeader);
        ByteArrayOutputStream baos = new ByteArrayOutputStream(10240);
        ByteOutput byteOutput = Marshalling.createByteOutput(baos);
        Marshaller marshaller = testMarshallerProvider.create(configuration.clone(), byteOutput);
        System.out.println("Marshaller = " + marshaller + " (version set to " + configuration.getVersion() + ")");
        marshaller.writeObject(serializable);
        marshaller.finish();
        byte[] bytes = baos.toByteArray();
View Full Code Here

            throw new SkipException("Can't use ClassExternalizerFactory in compatibility tests");
        }
        TestExternalizerFactory externalizerFactory = new TestExternalizerFactory();
        Object o = new TestExternalizableInt(7);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ByteOutput byteOutput = Marshalling.createByteOutput(baos);
        MarshallingConfiguration config = configuration.clone();
        config.setClassExternalizerFactory(externalizerFactory);
        Marshaller marshaller = testMarshallerProvider.create(config, byteOutput);
//        if (marshaller instanceof SerialMarshaller) {
//            throw new SkipException("TODO: Known issue - see JBMAR-50");
View Full Code Here

    public void runReadWriteTest(ReadWriteTest readWriteTest) throws Throwable {
        final MarshallingConfiguration readConfiguration = configuration.clone();
        readWriteTest.configureRead(readConfiguration);

        final ByteArrayOutputStream baos = new ByteArrayOutputStream(10240);
        final ByteOutput byteOutput = Marshalling.createByteOutput(baos);

        System.out.println("Read Configuration = " + readConfiguration);
        final Marshaller marshaller = testMarshallerProvider.create(readConfiguration, byteOutput);
        System.out.println("Marshaller = " + marshaller + " (version set to " + readConfiguration.getVersion() + ")");
        readWriteTest.runWrite(marshaller);
View Full Code Here

     * It will then flush the underlying byte output.
     *
     * @throws IOException
     */
    public void flush() throws IOException {
        final ByteOutput output = this.output;
        final int pos = this.position;
        if (pos > 0) {
            output.write(CHUNK_START);
            writeInt(pos);
            final byte[] buffer = this.buffer;
            output.write(buffer, 0, pos);
        }
        this.position = 0;
    }
View Full Code Here

        }
        this.position = 0;
    }

    public void writeInt(final int i) throws IOException {
        final ByteOutput output = this.output;
        byte[] bytes = new byte[4];
        bytes[0] = (byte) (i >> 24);
        bytes[1] = (byte) (i >> 16);
        bytes[2] = (byte) (i >> 8);
        bytes[3] = (byte) i;
        output.write(bytes);
    }
View Full Code Here

   public void tearDown() {
   }
  
   public void testSerObjWithRefToSerObjectWithCustomReadObj() throws Exception {
      ByteArrayOutputStream baos = new ByteArrayOutputStream(10240);
      ByteOutput byteOutput = Marshalling.createByteOutput(baos);
      marshaller.start(byteOutput);
      ObjectThatContainsACustomReadObjectMethod obj = new ObjectThatContainsACustomReadObjectMethod();
      obj.anObjectWithCustomReadObjectMethod = new CustomReadObjectMethod();
      try {
         marshaller.writeObject(obj);
View Full Code Here

     * It will then flush the underlying byte output.
     *
     * @throws IOException
     */
    public void flush() throws IOException {
        final ByteOutput output = this.output;
        final int pos = this.position;
        if (pos > 0) {
            output.write(CHUNK_START);
            writeInt(pos);
            final byte[] buffer = this.buffer;
            output.write(buffer, 0, pos);
        }
        this.position = 0;
    }
View Full Code Here

TOP

Related Classes of org.jboss.marshalling.ByteOutput

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.