1 /* 2 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.corba.se.spi.copyobject ; 27 28 import com.sun.corba.se.spi.orb.ORB ; 29 30 import com.sun.corba.se.impl.copyobject.ReferenceObjectCopierImpl ; 31 import com.sun.corba.se.impl.copyobject.FallbackObjectCopierImpl ; 32 import com.sun.corba.se.impl.copyobject.ORBStreamObjectCopierImpl ; 33 import com.sun.corba.se.impl.copyobject.JavaStreamObjectCopierImpl ; 34 35 public abstract class CopyobjectDefaults 36 { 37 private CopyobjectDefaults() { } 38 39 /** Obtain the ORB stream copier factory. Note that this version behaves differently 40 * than the others: each ObjectCopier produced by the factory only preserves aliasing 41 * within a single call to copy. The others copiers all preserve aliasing across 42 * all calls to copy (on the same ObjectCopier instance). 43 */ 44 public static ObjectCopierFactory makeORBStreamObjectCopierFactory( final ORB orb ) 45 { 46 return new ObjectCopierFactory() { 47 public ObjectCopier make( ) 48 { 49 return new ORBStreamObjectCopierImpl( orb ) ; 50 } 51 } ; 52 } 53 54 public static ObjectCopierFactory makeJavaStreamObjectCopierFactory( final ORB orb ) 55 { 56 return new ObjectCopierFactory() { 57 public ObjectCopier make( ) 58 { 59 return new JavaStreamObjectCopierImpl( orb ) ; 60 } 61 } ; 62 } 63 64 private static final ObjectCopier referenceObjectCopier = new ReferenceObjectCopierImpl() ; 65 66 private static ObjectCopierFactory referenceObjectCopierFactory = 67 new ObjectCopierFactory() { 68 public ObjectCopier make() 69 { 70 return referenceObjectCopier ; 71 } 72 } ; 73 74 /** Obtain the reference object "copier". This does no copies: it just 75 * returns whatever is passed to it. 76 */ 77 public static ObjectCopierFactory getReferenceObjectCopierFactory() 78 { 79 return referenceObjectCopierFactory ; 80 } 81 82 /** Create a fallback copier factory from the two ObjectCopierFactory 83 * arguments. This copier makes an ObjectCopierFactory that creates 84 * instances of a fallback copier that first tries an ObjectCopier 85 * created from f1, then tries one created from f2, if the first 86 * throws a ReflectiveCopyException. 87 */ 88 public static ObjectCopierFactory makeFallbackObjectCopierFactory( 89 final ObjectCopierFactory f1, final ObjectCopierFactory f2 ) 90 { 91 return new ObjectCopierFactory() { 92 public ObjectCopier make() 93 { 94 ObjectCopier c1 = f1.make() ; 95 ObjectCopier c2 = f2.make() ; 96 return new FallbackObjectCopierImpl( c1, c2 ) ; 97 } 98 } ; 99 } 100 }