Coverage Report - org.codehaus.classworlds.ClassWorldReverseAdapter
 
Classes in this File Line Coverage Branch Coverage Complexity
ClassWorldReverseAdapter
0 %
0/31
0 %
0/4
3
 
 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.util.HashMap;
 20  
 import java.util.Collection;
 21  
 import java.util.Vector;
 22  
 import java.util.Iterator;
 23  
 
 24  
 /**
 25  
  * A reverse adapter for ClassWorlds
 26  
  *
 27  
  * @author Andrew Williams
 28  
  */
 29  
 @Deprecated
 30  
 public class ClassWorldReverseAdapter
 31  
     extends org.codehaus.plexus.classworlds.ClassWorld
 32  
 {
 33  0
     private static HashMap instances = new HashMap();
 34  
 
 35  
     public static ClassWorldReverseAdapter getInstance( ClassWorld oldWorld )
 36  
     {
 37  0
         if ( instances.containsKey( oldWorld ) )
 38  0
             return (ClassWorldReverseAdapter) instances.get( oldWorld );
 39  
 
 40  0
         ClassWorldReverseAdapter adapter = new ClassWorldReverseAdapter( oldWorld );
 41  0
         instances.put( oldWorld, adapter );
 42  
 
 43  0
         return adapter;
 44  
     }
 45  
 
 46  
     private ClassWorld world;
 47  
 
 48  
     private ClassWorldReverseAdapter( ClassWorld newWorld )
 49  
     {
 50  0
         super();
 51  0
         this.world = newWorld;
 52  0
     }
 53  
 
 54  
     public org.codehaus.plexus.classworlds.realm.ClassRealm newRealm( String id )
 55  
         throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException
 56  
     {
 57  
         try
 58  
         {
 59  0
             return ClassRealmReverseAdapter.getInstance( world.newRealm( id ) );
 60  
         }
 61  0
         catch ( DuplicateRealmException e )
 62  
         {
 63  0
             throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( this, e.getId() );
 64  
         }
 65  
     }
 66  
 
 67  
     public org.codehaus.plexus.classworlds.realm.ClassRealm newRealm( String id,
 68  
                                 ClassLoader classLoader )
 69  
         throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException
 70  
     {
 71  
         try
 72  
         {
 73  0
             return ClassRealmReverseAdapter.getInstance( world.newRealm( id,
 74  
                                                                   classLoader ) );
 75  
         }
 76  0
         catch ( DuplicateRealmException e )
 77  
         {
 78  0
             throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( this, e.getId() );
 79  
         }
 80  
     }
 81  
 
 82  
     public void disposeRealm( String id )
 83  
         throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException
 84  
     {
 85  
         try
 86  
         {
 87  0
             world.disposeRealm( id );
 88  
         }
 89  0
         catch ( NoSuchRealmException e )
 90  
         {
 91  0
             throw new org.codehaus.plexus.classworlds.realm.NoSuchRealmException( this, e.getId() );
 92  0
         }
 93  0
     }
 94  
 
 95  
     public org.codehaus.plexus.classworlds.realm.ClassRealm getRealm( String id )
 96  
         throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException
 97  
     {
 98  
         try
 99  
         {
 100  0
             return ClassRealmReverseAdapter.getInstance( world.getRealm( id ) );
 101  
         }
 102  0
         catch ( NoSuchRealmException e )
 103  
         {
 104  0
             throw new org.codehaus.plexus.classworlds.realm.NoSuchRealmException( this, e.getId() );
 105  
         }
 106  
     }
 107  
 
 108  
     public Collection getRealms()
 109  
     {
 110  0
         Collection realms = world.getRealms();
 111  0
         Vector ret = new Vector();
 112  
 
 113  0
         Iterator it = realms.iterator();
 114  0
         while ( it.hasNext() )
 115  
         {
 116  0
             ClassRealm realm = (ClassRealm) it.next();
 117  0
             ret.add( ClassRealmReverseAdapter.getInstance( realm ) );
 118  0
         }
 119  
 
 120  0
         return ret;
 121  
     }
 122  
 }