Package org.jboss.marshalling

Examples of org.jboss.marshalling.Marshaller


    public Marshaller create(final MarshallingConfiguration config, final ByteOutput target) throws IOException {
        if (version != -1) {
            config.setVersion(version);
        }
        final Marshaller marshaller = marshallerFactory.createMarshaller(config);
        marshaller.start(target);
        return marshaller;
    }
View Full Code Here


        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);
        marshaller.finish();
        final byte[] bytes = baos.toByteArray();

        final MarshallingConfiguration writeConfiguration = configuration.clone();
        readWriteTest.configureWrite(writeConfiguration);
View Full Code Here

      baseCfg.setClassResolver(
            new DefaultContextClassResolver(this.getClass().getClassLoader()));
   }

   protected Marshaller getMarshaller(boolean isReentrant) throws IOException {
      Marshaller marshaller = isReentrant ?
            factory.createMarshaller(baseCfg) : marshallerTL.get();

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

                if (locator instanceof EJBHomeLocator) {
                    return (org.omg.CORBA.Object) ejbHome;
                } else if (locator instanceof StatelessEJBLocator) {
                    return beanReferenceFactory.createReference(beanRepositoryIds[0]);
                } else if (locator instanceof StatefulEJBLocator) {
                    final Marshaller marshaller = factory.createMarshaller(configuration);
                    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    marshaller.start(new OutputStreamByteOutput(stream));
                    marshaller.writeObject(((StatefulEJBLocator) locator).getSessionId());
                    marshaller.finish();
                    return beanReferenceFactory.createReferenceWithId(stream.toByteArray(), beanRepositoryIds[0]);
                } else if (locator instanceof EntityEJBLocator) {
                    final Marshaller marshaller = factory.createMarshaller(configuration);
                    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    marshaller.start(new OutputStreamByteOutput(stream));
                    marshaller.writeObject(((EntityEJBLocator) locator).getPrimaryKey());
                    marshaller.finish();
                    return beanReferenceFactory.createReferenceWithId(stream.toByteArray(), beanRepositoryIds[0]);
                }
                throw EjbLogger.EJB3_LOGGER.unknownEJBLocatorType(locator);
            } else {
                throw EjbLogger.EJB3_LOGGER.incorrectEJBLocatorForBean(locator, ejbComponent.getComponentName());
View Full Code Here

                outputStream = FOSAction.open(file);
                SimpleDataOutput output = new SimpleDataOutput(Marshalling.createByteOutput(outputStream));
                int version = this.passivationManager.getCurrentMarshallingVersion();
                output.writeInt(version);
                MarshallingConfiguration config = this.passivationManager.getMarshallingConfiguration(version);
                Marshaller marshaller = this.marshallerFactory.createMarshaller(config);
                marshaller.start(output);
                try {
                    marshaller.writeObject(obj);
                    marshaller.finish();
                } finally {
                    marshaller.close();
                }
            } finally {
                safeClose(outputStream);
            }
        } catch (IOException e) {
View Full Code Here

      baseCfg.setClassResolver(
            new DefaultContextClassResolver(this.getClass().getClassLoader()));
   }

   protected Marshaller getMarshaller(boolean isReentrant) throws IOException {
      Marshaller marshaller = isReentrant ?
            factory.createMarshaller(baseCfg) : marshallerTL.get();

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

        if (this.object == null) return null;
        int version = this.context.getCurrentVersion();
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        SimpleDataOutput data = new SimpleDataOutput(Marshalling.createByteOutput(output));
        data.writeInt(version);
        Marshaller marshaller = this.context.createMarshaller(version);
        try {
            marshaller.start(data);

            // Workaround for AS7-2496
            ClassLoader currentLoader = null;
            ClassLoader contextLoader = context.getContextClassLoader(version);
            if (contextLoader != null) {
                currentLoader = getCurrentThreadContextClassLoader();
                setCurrentThreadContextClassLoader(contextLoader);
            }
            try {
                marshaller.writeObject(this.object);
            } finally {
                if (contextLoader != null) {
                    setCurrentThreadContextClassLoader(currentLoader);
                }
            }
            marshaller.finish();
            return output.toByteArray();
        } finally {
            marshaller.close();
        }
    }
View Full Code Here

                for (Map.Entry<String, StateTransferProvider> entry: stateProviders.entrySet()) {
                    String serviceName = entry.getKey();
                    out.writeUTF(serviceName);
                    StateTransferProvider provider = entry.getValue();

                    Marshaller marshaller = marshallerFactory.createMarshaller(new MarshallingConfiguration());
                    ByteArrayOutputStream output = new ByteArrayOutputStream();
                    marshaller.start(Marshalling.createByteOutput(output));
                    marshaller.writeObject(provider.getCurrentState());
                    marshaller.close();
                    byte[] bytes = output.toByteArray();
                    out.writeInt(bytes.length);
                    out.write(bytes);
                }
            } catch (IOException e) {
View Full Code Here

    /**
     * Serializes an object into a byte buffer. The object has to implement interface Serializable or Externalizable
     */
    byte[] objectToByteBufferInternal(Object object) throws Exception {
        Marshaller marshaller = marshallerFactory.createMarshaller(new MarshallingConfiguration());
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        marshaller.start(Marshalling.createByteOutput(output));
        marshaller.writeObject(object);
        marshaller.close();
        return output.toByteArray();
    }
View Full Code Here

    byte[] objectToByteBufferResponseInternal(Object obj) throws Exception {
        if (obj == null) {
            return new byte[] { NULL_VALUE };
        }

        Marshaller marshaller = marshallerFactory.createMarshaller(new MarshallingConfiguration());
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        marshaller.start(Marshalling.createByteOutput(output));
        // write a marker to stream to distinguish from null value stream
        marshaller.write(SERIALIZABLE_VALUE);
        marshaller.writeObject(obj);
        marshaller.close();
        return output.toByteArray();
    }
View Full Code Here

TOP

Related Classes of org.jboss.marshalling.Marshaller

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.