Skip to main content
summaryrefslogtreecommitdiffstats
blob: 80a999297db1b825c97ced38963da3504053c0d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*******************************************************************************
 * Copyright (c) 2001, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.wst.wsdl.validation.internal.resolver;


/**
 * A delegate to hold information about an extension URI resolver.
 */
public class URIResolverDelegate
{
  private String classname;
  private ClassLoader classloader;
  private IExtensibleURIResolver resolver = null;
  
  
  /**
   * Constructor.
   * 
   * @param classname The class name of the URI resolver.
   * @param classloader The class loader to use to load the URI resolver.
   */
  public URIResolverDelegate(String classname, ClassLoader classloader)
  {
    this.classname = classname;
    this.classloader = classloader;
  }
  
  /**
   * Get the URI resolver described by this delegate.
   * 
   * @return The URI resolver described by this delegate.
   */
  public IExtensibleURIResolver getURIResolver()
  {
    if(resolver == null)
    {
      try
      {
        resolver = (IExtensibleURIResolver)classloader.loadClass(classname).newInstance();
      }
      catch(Exception e)
      {
        try
        {
          resolver = (IExtensibleURIResolver)getClass().getClassLoader().loadClass(classname).newInstance();
        }
        catch(Exception e2)
        {
        }
      }
    }
    return resolver;
  }
}

Back to the top