01: /*
02: * JFox - The most lightweight Java EE Application Server!
03: * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
04: *
05: * JFox is licenced and re-distributable under GNU LGPL.
06: */
07: package org.jfox.util;
08:
09: import java.rmi.MarshalledObject;
10:
11: /**
12: * @author <a href="mailto:jfox.young@gmail.com">Young Yang</a>
13: */
14:
15: public class MarshallUtils {
16: public static MarshalledObject marshall(Object obj) {
17: if (obj == null) {
18: return null;
19: } else if (obj instanceof MarshalledObject) {
20: return (MarshalledObject) obj;
21: } else {
22: try {
23: return new MarshalledObject(obj);
24: } catch (Exception e) {
25: e.printStackTrace();
26: return null;
27: }
28: }
29: }
30:
31: public static Object unmarshall(Object obj) {
32: if (obj == null) {
33: return null;
34: } else if (obj instanceof MarshalledObject) {
35: try {
36: return ((MarshalledObject) obj).get();
37: } catch (Exception e) {
38: e.printStackTrace();
39: return null;
40: }
41: } else {
42: return obj;
43: }
44: }
45:
46: public static void main(String[] args) {
47:
48: }
49: }
|