KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > spi > copyobject > CopyobjectDefaults


1 /*
2  * @(#)CopyobjectDefaults.java 1.9 04/06/21
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.spi.copyobject ;
9
10 import com.sun.corba.se.spi.orb.ORB ;
11
12 import com.sun.corba.se.impl.copyobject.ReferenceObjectCopierImpl ;
13 import com.sun.corba.se.impl.copyobject.FallbackObjectCopierImpl ;
14 import com.sun.corba.se.impl.copyobject.ORBStreamObjectCopierImpl ;
15 import com.sun.corba.se.impl.copyobject.JavaStreamObjectCopierImpl ;
16
17 public abstract class CopyobjectDefaults
18 {
19     private CopyobjectDefaults() { }
20
21     /** Obtain the ORB stream copier factory. Note that this version behaves differently
22      * than the others: each ObjectCopier produced by the factory only preserves aliasing
23      * within a single call to copy. The others copiers all preserve aliasing across
24      * all calls to copy (on the same ObjectCopier instance).
25      */

26     public static ObjectCopierFactory makeORBStreamObjectCopierFactory( final ORB orb )
27     {
28     return new ObjectCopierFactory() {
29         public ObjectCopier make( )
30         {
31         return new ORBStreamObjectCopierImpl( orb ) ;
32         }
33     } ;
34     }
35
36     public static ObjectCopierFactory makeJavaStreamObjectCopierFactory( final ORB orb )
37     {
38     return new ObjectCopierFactory() {
39         public ObjectCopier make( )
40         {
41         return new JavaStreamObjectCopierImpl( orb ) ;
42         }
43     } ;
44     }
45
46     private static final ObjectCopier referenceObjectCopier = new ReferenceObjectCopierImpl() ;
47
48     private static ObjectCopierFactory referenceObjectCopierFactory =
49     new ObjectCopierFactory() {
50         public ObjectCopier make()
51         {
52         return referenceObjectCopier ;
53         }
54     } ;
55
56     /** Obtain the reference object "copier". This does no copies: it just
57      * returns whatever is passed to it.
58      */

59     public static ObjectCopierFactory getReferenceObjectCopierFactory()
60     {
61     return referenceObjectCopierFactory ;
62     }
63
64     /** Create a fallback copier factory from the two ObjectCopierFactory
65      * arguments. This copier makes an ObjectCopierFactory that creates
66      * instances of a fallback copier that first tries an ObjectCopier
67      * created from f1, then tries one created from f2, if the first
68      * throws a ReflectiveCopyException.
69      */

70     public static ObjectCopierFactory makeFallbackObjectCopierFactory(
71     final ObjectCopierFactory f1, final ObjectCopierFactory f2 )
72     {
73     return new ObjectCopierFactory() {
74         public ObjectCopier make()
75         {
76         ObjectCopier c1 = f1.make() ;
77         ObjectCopier c2 = f2.make() ;
78         return new FallbackObjectCopierImpl( c1, c2 ) ;
79         }
80     } ;
81     }
82 }
83
Popular Tags