Skip to content

Commit

Permalink
CDITCK-94 Added SPI implementation for serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
drallen authored and pmuir committed Aug 11, 2010
1 parent 8b37e63 commit 39ac5b1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions porting-package/src/main/java/org/jboss/weld/tck/BeansImpl.java
Expand Up @@ -16,6 +16,12 @@
*/
package org.jboss.weld.tck;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import org.jboss.jsr299.tck.spi.Beans;

/**
Expand All @@ -34,4 +40,18 @@ public boolean isProxy(Object instance)
return instance.getClass().getName().indexOf("_$$_Weld") > 0;
}

public byte[] serialize(Object instance) throws IOException
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bytes);
out.writeObject(instance);
return bytes.toByteArray();
}

public Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException
{
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
return in.readObject();
}

}

0 comments on commit 39ac5b1

Please sign in to comment.