01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.invocation.unified.interfaces;
23:
24: /**
25: * $Id: JavaSerializationManager.java 57209 2006-09-26 12:21:57Z dimitris@jboss.org $
26: *
27: * @author <a href="mailto:tclebert.suconic@jboss.com">Clebert Suconic</a>
28: */
29: import java.io.IOException;
30:
31: import org.jboss.invocation.MarshalledValueEX;
32: import org.jboss.logging.Logger;
33: import org.jboss.remoting.serialization.IMarshalledValue;
34: import org.jboss.remoting.serialization.SerializationStreamFactory;
35:
36: /**
37: * JavaSerializationmanager from JBossRemoting doesn't use the same
38: * MarshalledValue specified by org.jboss.invocation. As
39: * org.jboss.invocation.MarshalledValue could use caching features from JBossAS,
40: * we will need to use that MarshalledValue.
41: *
42: * $Id: JavaSerializationManager.java 57209 2006-09-26 12:21:57Z dimitris@jboss.org $
43: *
44: * @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>
45: */
46: public class JavaSerializationManager
47: extends
48: org.jboss.remoting.serialization.impl.java.JavaSerializationManager {
49:
50: protected static final Logger log = Logger
51: .getLogger(JavaSerializationManager.class);
52:
53: static {
54: register();
55: }
56:
57: /** Register yourself as Java manager into SerializationStreamFactory */
58: private static void register() {
59: register("compatible");
60: register(SerializationStreamFactory.JAVA);
61:
62: try {
63: if (SerializationStreamFactory.getManagerInstance()
64: .getClass() == org.jboss.remoting.serialization.impl.java.JavaSerializationManager.class) {
65: register(SerializationStreamFactory.DEFAULT);
66: }
67: } catch (Exception e) {
68: log.error(e);
69: }
70: }
71:
72: private static void register(String provider) {
73: try {
74: SerializationStreamFactory.setManagerClassName(provider,
75: JavaSerializationManager.class.getName());
76: } catch (ClassNotFoundException e) {
77: log.error(e);
78: } catch (IllegalAccessException e) {
79: log.error(e);
80: } catch (InstantiationException e) {
81: log.error(e);
82: }
83: }
84:
85: /**
86: * Creates a MarshalledValue that does lazy serialization.
87: */
88: public IMarshalledValue createdMarshalledValue(Object source)
89: throws IOException {
90: if (source instanceof IMarshalledValue) {
91: return (IMarshalledValue) source;
92: } else {
93: return new MarshalledValueEX(source);
94: }
95: }
96:
97: }
|