ResolverDefault.java revision 608:7e06bf1dcb09
1/*
2 * Copyright (c) 2002, 2003, 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
26package com.sun.corba.se.spi.resolver ;
27
28import java.io.File ;
29
30import com.sun.corba.se.impl.resolver.LocalResolverImpl ;
31import com.sun.corba.se.impl.resolver.ORBInitRefResolverImpl ;
32import com.sun.corba.se.impl.resolver.ORBDefaultInitRefResolverImpl ;
33import com.sun.corba.se.impl.resolver.BootstrapResolverImpl ;
34import com.sun.corba.se.impl.resolver.CompositeResolverImpl ;
35import com.sun.corba.se.impl.resolver.INSURLOperationImpl ;
36import com.sun.corba.se.impl.resolver.SplitLocalResolverImpl ;
37import com.sun.corba.se.impl.resolver.FileResolverImpl ;
38
39import com.sun.corba.se.spi.orb.ORB ;
40import com.sun.corba.se.spi.orb.Operation ;
41import com.sun.corba.se.spi.orb.StringPair ;
42
43/** Utility class that provides factory methods for all of the
44 * standard resolvers that we provide.
45 */
46public class ResolverDefault {
47    /** Return a local resolver that simply stores bindings in a map.
48    */
49    public static LocalResolver makeLocalResolver( )
50    {
51        return new LocalResolverImpl() ;
52    }
53
54    /** Return a resolver that relies on configured values of ORBInitRef for data.
55    */
56    public static Resolver makeORBInitRefResolver( Operation urlOperation,
57        StringPair[] initRefs )
58    {
59        return new ORBInitRefResolverImpl( urlOperation, initRefs ) ;
60    }
61
62    public static Resolver makeORBDefaultInitRefResolver( Operation urlOperation,
63        String defaultInitRef )
64    {
65        return new ORBDefaultInitRefResolverImpl( urlOperation,
66            defaultInitRef ) ;
67    }
68
69    /** Return a resolver that uses the proprietary bootstrap protocol
70    * to implement a resolver.  Obtains the necessary host and port
71    * information from the ORB.
72    */
73    public static Resolver makeBootstrapResolver( ORB orb, String host, int port )
74    {
75        return new BootstrapResolverImpl( orb, host, port ) ;
76    }
77
78    /** Return a resolver composed of the two given resolvers.  result.list() is the
79    * union of first.list() and second.list().  result.resolve( name ) returns
80    * first.resolve( name ) if that is not null, otherwise returns the result of
81    * second.resolve( name ).
82    */
83    public static Resolver makeCompositeResolver( Resolver first, Resolver second )
84    {
85        return new CompositeResolverImpl( first, second ) ;
86    }
87
88    public static Operation makeINSURLOperation( ORB orb, Resolver bootstrapResolver )
89    {
90        return new INSURLOperationImpl(
91            (com.sun.corba.se.spi.orb.ORB)orb, bootstrapResolver ) ;
92    }
93
94    public static LocalResolver makeSplitLocalResolver( Resolver resolver,
95        LocalResolver localResolver )
96    {
97        return new SplitLocalResolverImpl( resolver, localResolver ) ;
98    }
99
100    public static Resolver makeFileResolver( ORB orb, File file )
101    {
102        return new FileResolverImpl( orb, file ) ;
103    }
104}
105