Package org.exoplatform.commons.serialization

Examples of org.exoplatform.commons.serialization.SerializationContext


   public void testCustomFactory() throws Exception
   {
      TypeDomain domain = new TypeDomain();
      domain.addTypeModel(A2.class);
      SerializationContext context = new SerializationContext(domain);
      context.addFactory(new A1());
      A2 a2 = new A2();
      assertSame(A1.instance, context.clone(a2));
   }
View Full Code Here


   public void testFactoryThrowsException() throws Exception
   {
      TypeDomain domain = new TypeDomain();
      domain.addTypeModel(B.class);
      SerializationContext context = new SerializationContext(domain);
      B b = new B(false);
      try
      {
         context.clone(b);
         fail();
      }
      catch (InvalidClassException e)
      {
      }
View Full Code Here

         public A1 read(A2 output) throws Exception
         {
            return new A1(output.state);
         }
      };
      SerializationContext context = new SerializationContext(domain);
      a = context.clone(a);
      assertEquals("foo", a.state);
   }
View Full Code Here

      TypeDomain domain = new TypeDomain();
      domain.addTypeModel(B1.class);
      B1 b = new B1("foo");

      //
      SerializationContext context = new SerializationContext(domain);
      b = context.clone(b);
      assertEquals("foo", b.state);
   }
View Full Code Here

         public A1 read(A2 output) throws Exception
         {
            throw new AssertionFailedError();
         }
      };
      SerializationContext context = new SerializationContext(domain);
      try
      {
         a = context.clone(a);
         fail();
      }
      catch (InvalidObjectException ioe)
      {
         assertSame(e, ioe.getCause());
View Full Code Here

         public A1 read(A2 output) throws Exception
         {
            throw new AssertionFailedError();
         }
      };
      SerializationContext context = new SerializationContext(domain);
      try
      {
         a = context.clone(a);
         fail();
      }
      catch (InvalidObjectException e)
      {
      }
View Full Code Here

         public A1 read(A2 output) throws Exception
         {
            return null;
         }
      };
      SerializationContext context = new SerializationContext(domain);
      try
      {
         a = context.clone(a);
         fail();
      }
      catch (InvalidObjectException e)
      {
      }
View Full Code Here

         public A1 read(A2 output) throws Exception
         {
            throw e;
         }
      };
      SerializationContext context = new SerializationContext(domain);
      try
      {
         a = context.clone(a);
         fail();
      }
      catch (InvalidObjectException ioe)
      {
         assertSame(e, ioe.getCause());
View Full Code Here

        return userName;
    }

    public UIApplication getApplication() throws IOException, ClassNotFoundException {
        if (serialization != null) {
            SerializationContext serializationContext = SerializationContextSingleton.getInstance();
            byte[] bytes = serialization;
            serialization = null;
            application = (UIApplication) serializationContext.read(bytes);
        }
        return application;
    }
View Full Code Here

        //
        if (application != null && application.getClass().getAnnotation(Serialized.class) != null) {
            oos.writeBoolean(true);

            //
            SerializationContext serializationContext = SerializationContextSingleton.getInstance();

            //
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            serializationContext.write(application, baos);
            baos.close();

            //
            byte[] bytes = baos.toByteArray();
            oos.writeInt(bytes.length);
View Full Code Here

TOP

Related Classes of org.exoplatform.commons.serialization.SerializationContext

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.