View Javadoc
1   package org.codehaus.classworlds;
2   
3   /*
4    * Copyright 2001-2010 Codehaus Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.io.InputStream;
20  import java.io.IOException;
21  import java.net.MalformedURLException;
22  
23  /**
24   * Created by IntelliJ IDEA.
25   *
26   * @uthor: Andrew Williams
27   * @since: Nov 25, 2006
28   */
29  @Deprecated
30  public class ConfiguratorAdapter
31      extends Configurator
32  {
33  
34      public static ConfiguratorAdapter getInstance( org.codehaus.plexus.classworlds.launcher.Configurator newConfig,
35                                                     Launcher launcher )
36      {
37          ConfiguratorAdapter adapter = new ConfiguratorAdapter( newConfig, launcher );
38  
39          return adapter;
40      }
41  
42      public static ConfiguratorAdapter getInstance( org.codehaus.plexus.classworlds.launcher.Configurator newConfig,
43                                                     ClassWorld world )
44      {
45          ConfiguratorAdapter adapter = new ConfiguratorAdapter( newConfig, world );
46  
47          return adapter;
48      }
49  
50      private org.codehaus.plexus.classworlds.launcher.Configurator config;
51  
52      private ConfiguratorAdapter( org.codehaus.plexus.classworlds.launcher.Configurator config, Launcher launcher )
53      {
54          super( launcher );
55          this.config = config;
56      }
57  
58      private ConfiguratorAdapter( org.codehaus.plexus.classworlds.launcher.Configurator config, ClassWorld world )
59      {
60          super( world );
61          this.config = config;
62      }
63  
64      public void associateRealms()
65      {
66          config.associateRealms();
67      }
68  
69      public void configureAdapter( InputStream is )
70          throws IOException, MalformedURLException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
71      {
72          try
73          {
74              config.configure( is );
75          }
76          catch ( org.codehaus.plexus.classworlds.launcher.ConfigurationException e )
77          {
78              throw new ConfigurationException( e.getMessage() );
79          }
80          catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e )
81          {
82              throw new DuplicateRealmException( ClassWorldAdapter.getInstance( e.getWorld() ), e.getId() );
83          }
84          catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e )
85          {
86              throw new NoSuchRealmException( ClassWorldAdapter.getInstance( e.getWorld() ), e.getId() );
87          }
88      }
89  
90  }