KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ejb > base > io > IOUtilsCallerImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * IOUtilsCallerImpl.java
26  *
27  * Created on October 13, 2003, 11:40 AM
28  */

29
30 package com.sun.ejb.base.io;
31
32 import java.io.InputStream JavaDoc;
33 import java.io.OutputStream JavaDoc;
34 import java.io.ObjectInputStream JavaDoc;
35 import java.io.ObjectOutputStream JavaDoc;
36 import java.io.IOException JavaDoc;
37 import com.sun.ejb.spi.io.NonSerializableObjectHandler;
38 import org.apache.catalina.session.IOUtilsCaller;
39 import org.apache.catalina.util.CustomObjectInputStream;
40
41 /**
42  * This class is used by the web tier to obtain equivalent
43  * object stream service as the ejb tier obtains from directly
44  * using classes like IOUtils
45  * @author Administrator
46  */

47 public class IOUtilsCallerImpl implements IOUtilsCaller{
48     
49     /** Creates a new instance of IOUtilsCallerImpl */
50     public IOUtilsCallerImpl() {
51     }
52     
53     public ObjectInputStream JavaDoc createObjectInputStream(
54             final InputStream JavaDoc is,
55             final boolean resolveObject,
56             final ClassLoader JavaDoc loader)
57         throws Exception JavaDoc {
58         ObjectInputStream JavaDoc strm = null;
59         try {
60             strm = IOUtils.createObjectInputStream(is, resolveObject, loader);
61         } catch (Exception JavaDoc ex) {}
62         if (strm == null) {
63             strm = new CustomObjectInputStream(is, loader);
64         }
65         return strm;
66     }
67     
68     public ObjectOutputStream JavaDoc createObjectOutputStream(
69         final OutputStream JavaDoc os,
70         final boolean replaceObject) throws IOException JavaDoc {
71         return IOUtils.createObjectOutputStream(os, replaceObject,
72             new NonSerializableObjectHandler() {
73                 public Object JavaDoc handleNonSerializableObject(Object JavaDoc obj) {
74                     return obj;
75                 }
76             }
77         );
78     }
79     
80     public ObjectOutputStream JavaDoc createObjectOutputStream(
81         final OutputStream JavaDoc os,
82         final boolean replaceObject,
83         final NonSerializableObjectHandler handler) throws IOException JavaDoc {
84         return IOUtils.createObjectOutputStream(os, replaceObject, handler);
85     }
86     
87 }
88
Popular Tags