1 package org.codehaus.classworlds;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.util.Collection;
20 import java.util.Vector;
21 import java.util.Iterator;
22
23
24
25
26
27
28 @Deprecated
29 public class ClassWorldAdapter
30 extends ClassWorld
31 {
32
33 public static ClassWorldAdapter getInstance( org.codehaus.plexus.classworlds.ClassWorld newWorld )
34 {
35 ClassWorldAdapter adapter = new ClassWorldAdapter( newWorld );
36
37 return adapter;
38 }
39
40 private org.codehaus.plexus.classworlds.ClassWorld world;
41
42 private ClassWorldAdapter( org.codehaus.plexus.classworlds.ClassWorld newWorld )
43 {
44 super( false );
45 this.world = newWorld;
46 }
47
48 public ClassRealm newRealm( String id )
49 throws DuplicateRealmException
50 {
51 try
52 {
53 return ClassRealmAdapter.getInstance( world.newRealm( id ) );
54 }
55 catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e )
56 {
57 throw new DuplicateRealmException( this, e.getId() );
58 }
59 }
60
61 public ClassRealm newRealm( String id,
62 ClassLoader classLoader )
63 throws DuplicateRealmException
64 {
65 try
66 {
67 return ClassRealmAdapter.getInstance( world.newRealm( id,
68 classLoader ) );
69 }
70 catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e )
71 {
72 throw new DuplicateRealmException( this, e.getId() );
73 }
74 }
75
76 public void disposeRealm( String id )
77 throws NoSuchRealmException
78 {
79 try
80 {
81 world.disposeRealm( id );
82 }
83 catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e )
84 {
85 throw new NoSuchRealmException( this, e.getId() );
86 }
87 }
88
89 public ClassRealm getRealm( String id )
90 throws NoSuchRealmException
91 {
92 try
93 {
94 return ClassRealmAdapter.getInstance( world.getRealm( id ) );
95 }
96 catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e )
97 {
98 throw new NoSuchRealmException( this, e.getId() );
99 }
100 }
101
102 public Collection getRealms()
103 {
104 Collection realms = world.getRealms();
105 Vector ret = new Vector();
106
107 Iterator it = realms.iterator();
108 while ( it.hasNext() )
109 {
110 org.codehaus.plexus.classworlds.realm.ClassRealm realm =
111 (org.codehaus.plexus.classworlds.realm.ClassRealm) it.next();
112 ret.add( ClassRealmAdapter.getInstance( realm ) );
113 }
114
115 return ret;
116 }
117 }