KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > jvmai > Provider


1 //
2
// This file is part of the prose package.
3
//
4
// The contents of this file are subject to the Mozilla Public License
5
// Version 1.1 (the "License"); you may not use this file except in
6
// compliance with the License. You may obtain a copy of the License at
7
// http://www.mozilla.org/MPL/
8
//
9
// Software distributed under the License is distributed on an "AS IS" basis,
10
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
// for the specific language governing rights and limitations under the
12
// License.
13
//
14
// The Original Code is prose.
15
//
16
// The Initial Developer of the Original Code is Andrei Popovici. Portions
17
// created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
18
// All Rights Reserved.
19
//
20
// Contributor(s):
21
// $Id: Provider.java,v 1.1.1.1 2003/07/02 15:30:50 apopovic Exp $
22
// =====================================================================
23
//
24
// (history at end)
25
//
26

27 package ch.ethz.jvmai;
28
29 // used packages/classes
30
import ch.ethz.jvmai.JVMAspectInterface;
31
32 /**
33  * Class Provider builds the connection between the
34  * jvmai-system and the user-application. Every virtual
35  * machine (better: every jvmai-implementation) implements
36  * a provider. Method <code>getProvider</code> is used to
37  * get an instace of a provider specified by a classname.
38  * This provider connects to the jvmai-implementation and
39  * tries to get references to the aspect- and
40  * info-interface. Applications can then retrieve this
41  * references by calling <code>getAspectInterface()</code>
42  * and <code>getInfoInterface()</code>.
43  *
44  * @version $Revision: 1.1.1.1 $
45  * @author Stephan Markwalder
46  */

47 public abstract class Provider {
48
49     protected Provider() {
50     }
51
52     /**
53      * Gets an implementation of a provider specified by the
54      * providers classname.
55      * This method may fail for many different reasons.
56      * First, the class may not be found. If the class can
57      * be found and linked without errors, an instance of
58      * this provider is created. Depending on the kind of
59      * jvmai-implementation, providers try to connect to
60      * this implementation or the virtual machine itself.
61      * If the specified provider (parameter
62      * <code>classname</code>) is not able to establish this
63      * connection, it will throw a JVMAIRuntimeException.
64      *
65      * @param classname Name of the provider-class
66      * (with package-name).
67      * @return An instance of a provider.
68      * @exception JVMAIRuntimeException Use <code>JVMAIRuntimeException.getMessage()</code>
69      * to retrieve a description.
70      */

71     public static final Provider getProvider(String JavaDoc classname)
72     {
73         Provider provider = null;
74         try
75         {
76             Class JavaDoc providerClass = Class.forName(classname);
77             provider = (Provider)providerClass.newInstance();
78         }
79         catch(Exception JavaDoc e)
80         {
81             throw new JVMAIRuntimeException(e.toString());
82         }
83         return provider;
84     }
85
86     /**
87      * Returns the apect-interface of the jvmai-system
88      * supported by this provider.
89      */

90     public abstract JVMAspectInterface getAspectInterface();
91 }
92
93 //======================================================================
94
//
95
// $Log: Provider.java,v $
96
// Revision 1.1.1.1 2003/07/02 15:30:50 apopovic
97
// Imported from ETH Zurich
98
//
99
// Revision 1.1 2003/05/05 14:02:25 popovici
100
// renaming from runes to prose
101
//
102
// Revision 1.6 2003/03/04 11:27:10 popovici
103
// Important refactorization step (march):
104
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
105
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
106
// structures
107
//
108
// Revision 1.5 2002/03/28 13:48:31 popovici
109
// Mozilla-ified
110
//
111
// Revision 1.4 2002/02/13 12:25:11 smarkwal
112
// spaces/tabs alignment corrected
113
//
114
// Revision 1.3 2002/02/04 13:11:12 smarkwal
115
// method getProvider(...) declared final
116
//
117
// Revision 1.2 2002/01/24 12:52:14 smarkwal
118
// Constructor is now 'protected'. Comments added.
119
//
120
// Revision 1.1 2001/12/14 15:01:19 smarkwal
121
// Initial Revision
122
//
123
Popular Tags