Package org.jboss.marshalling

Examples of org.jboss.marshalling.Unmarshaller


        try {
            factory = Marshalling.getMarshallerFactory("river", Module.getModuleFromDefaultLoader(ModuleIdentifier.fromString("org.jboss.marshalling.river")).getClassLoader());
        } catch (ModuleLoadException e) {
            throw new IllegalStateException("Failed to start server", e);
        }
        final Unmarshaller unmarshaller;
        final ByteInput byteInput;
        try {
            final MarshallingConfiguration configuration = new MarshallingConfiguration();
            configuration.setVersion(2);
            configuration.setClassTable(ModularClassTable.getInstance());
            unmarshaller = factory.createUnmarshaller(configuration);
            byteInput = Marshalling.createByteInput(initialInput);
            unmarshaller.start(byteInput);
            final ServerTask task = unmarshaller.readObject(ServerTask.class);
            unmarshaller.finish();
            task.run(Arrays.<ServiceActivator>asList(new ServiceActivator() {
                public void activate(final ServiceActivatorContext serviceActivatorContext) {
                    // TODO activate server manager client service
                }
            }));
        } catch (Exception e) {
            e.printStackTrace(initialError);
            System.exit(1);
            throw new IllegalStateException(); // not reached
        }
        for (;;) try {
            unmarshaller.start(byteInput);
            final InetSocketAddress socketAddress = unmarshaller.readObject(InetSocketAddress.class);
            unmarshaller.finish();
            // todo connect to the SM at socketAddress, disconnect from old
            break;
        } catch (InterruptedIOException e) {
            Thread.interrupted();
            // ignore
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

   }

   @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

    @Override
    public synchronized T get(MarshallingContext context) throws IOException, ClassNotFoundException {
        if (this.object == null) {
            this.context = context;
            if (this.bytes != null) {
                Unmarshaller unmarshaller = context.createUnmarshaller();
                try {
                    unmarshaller.start(Marshalling.createByteInput(new ByteArrayInputStream(this.bytes)));
                    this.object = (T) unmarshaller.readObject();
                    unmarshaller.finish();
                    this.bytes = null; // Free up memory
                } finally {
                    unmarshaller.close();
                }
            }
        }
        return this.object;
    }
View Full Code Here

            System.exit(1);
            throw new IllegalStateException(); // not reached
        }

        final MarshallerFactory factory = Marshalling.getMarshallerFactory("river", DomainServerMain.class.getClassLoader());
        final Unmarshaller unmarshaller;
        final ByteInput byteInput;
        final AsyncFuture<ServiceContainer> containerFuture;
        try {
            Module.registerURLStreamHandlerFactoryModule(Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.jboss.vfs")));
            final MarshallingConfiguration configuration = new MarshallingConfiguration();
            configuration.setVersion(2);
            configuration.setClassResolver(new SimpleClassResolver(DomainServerMain.class.getClassLoader()));
            unmarshaller = factory.createUnmarshaller(configuration);
            byteInput = Marshalling.createByteInput(initialInput);
            unmarshaller.start(byteInput);
            final ServerTask task = unmarshaller.readObject(ServerTask.class);
            unmarshaller.finish();
            containerFuture = task.run(Arrays.<ServiceActivator>asList(new ServiceActivator() {
                @Override
                public void activate(final ServiceActivatorContext serviceActivatorContext) {
                    // TODO activate host controller client service
                }
View Full Code Here

      finishObjectInput(unmarshaller);
      return o;
   }
  
   public ObjectInput startObjectInput(InputStream is) throws IOException {
      Unmarshaller unmarshaller = factory.createUnmarshaller(configuration);
      unmarshaller.start(Marshalling.createByteInput(is));
      return unmarshaller;
   }
View Full Code Here

                return timers;
            } else if (!file.isDirectory()) {
                ROOT_LOGGER.failToRestoreTimers(file);
                return timers;
            }
            Unmarshaller unmarshaller = factory.createUnmarshaller(configuration);
            for (File timerFile : file.listFiles()) {
                FileInputStream in = null;
                try {
                    in = new FileInputStream(timerFile);
                    unmarshaller.start(new InputStreamByteInput(in));
                    final TimerEntity entity = unmarshaller.readObject(TimerEntity.class);
                    timers.put(entity.getId(), entity);
                    unmarshaller.finish();
                } catch (Exception e) {
                    ROOT_LOGGER.failToRestoreTimersFromFile(timerFile, e);
                } finally {
                    if (in != null) {
                        try {
View Full Code Here

    private Object unmarshalIdentifier() throws IOException, ClassNotFoundException {
        final Object id;
        try {
            final byte[] idData = poaCurrent.get_object_id();
            final Unmarshaller unmarshaller = factory.createUnmarshaller(configuration);
            unmarshaller.start(new InputStreamByteInput(new ByteArrayInputStream(idData)));
            id = unmarshaller.readObject();
            unmarshaller.finish();
        } catch (NoContext noContext) {
            throw new RuntimeException(noContext);
        }
        return id;
    }
View Full Code Here

            }
            File marker = new File(file, MIGRATION_MARKER);
            if (marker.exists()) {
                return timers;
            }
            Unmarshaller unmarshaller = factory.createUnmarshaller(configuration);
            for (File timerFile : file.listFiles()) {
                if(timerFile.getName().endsWith(".xml")) {
                    continue;
                }
                FileInputStream in = null;
                try {
                    in = new FileInputStream(timerFile);
                    unmarshaller.start(new InputStreamByteInput(in));

                    final TimerEntity entity = unmarshaller.readObject(TimerEntity.class);

                    //we load the legacy timer entity class, and turn it into a timer state

                    TimerImpl.Builder builder;
                    if (entity instanceof CalendarTimerEntity) {
                        CalendarTimerEntity c = (CalendarTimerEntity) entity;
                        builder = CalendarTimer.builder()
                                .setScheduleExprSecond(c.getSecond())
                                .setScheduleExprMinute(c.getMinute())
                                .setScheduleExprHour(c.getHour())
                                .setScheduleExprDayOfWeek(c.getDayOfWeek())
                                .setScheduleExprDayOfMonth(c.getDayOfMonth())
                                .setScheduleExprMonth(c.getMonth())
                                .setScheduleExprYear(c.getYear())
                                .setScheduleExprStartDate(c.getStartDate())
                                .setScheduleExprEndDate(c.getEndDate())
                                .setScheduleExprTimezone(c.getTimezone())
                                .setAutoTimer(c.isAutoTimer())
                                .setTimeoutMethod(CalendarTimer.getTimeoutMethod(c.getTimeoutMethod(), timerService.getTimedObjectInvoker().getValue().getClassLoader()));
                    } else {
                        builder = TimerImpl.builder();
                    }
                    builder.setId(entity.getId())
                            .setTimedObjectId(entity.getTimedObjectId())
                            .setInitialDate(entity.getInitialDate())
                            .setRepeatInterval(entity.getInterval())
                            .setNextDate(entity.getNextDate())
                            .setPreviousRun(entity.getPreviousRun())
                            .setInfo(entity.getInfo())
                            .setPrimaryKey(entity.getPrimaryKey())
                            .setTimerState(entity.getTimerState())
                            .setPersistent(true);

                    timers.put(entity.getId(), builder.build(timerService));
                    unmarshaller.finish();
                } catch (Exception e) {
                    ROOT_LOGGER.failToRestoreTimersFromFile(timerFile, e);
                } finally {
                    if (in != null) {
                        try {
View Full Code Here

        if (data == null) {
            return null;
        }
        InputStream in = new ByteArrayInputStream(Base64.decode(data));
        try {
            final Unmarshaller unmarshaller = factory.createUnmarshaller(configuration);
            unmarshaller.start(new InputStreamByteInput(in));
            Object ret = unmarshaller.readObject();
            unmarshaller.finish();
            return ret;
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
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.