KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > corba > runtime > RegistrationServiceImpl


1 // ====================================================================
2
//
3
// ECM: The Extensible Container Model
4
// Copyright (C) 2004 THALES
5
// Contact: openccm-ecm@objectweb.org
6
//
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Lesser General Public
9
// License as published by the Free Software Foundation; either
10
// version 2.1 of the License, or any later version.
11
//
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// Lesser General Public License for more details.
16
//
17
// You should have received a copy of the GNU Lesser General Public
18
// License along with this library; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
// USA
21
//
22
// Initial developer(s): Mathieu Vadet.
23
// Initial Funding: IST COACH European project (IST-2001-34445)
24
// http://www.ist-coach.org
25
//
26
// ====================================================================
27

28
29
30 package org.objectweb.corba.runtime;
31
32 /**
33  ** <p>Default implementation of the <tt>RegistrationService</tt> system service.</p>
34  **/

35 public class RegistrationServiceImpl
36 extends org.omg.CORBA.LocalObject JavaDoc
37 implements RegistrationService
38 {
39     // registration service
40
static final private String JavaDoc _class_name = "RegistrationServiceImpl";
41     static final private String JavaDoc _service_id = RegistrationService.SERVICE_ID;
42     private java.util.HashMap JavaDoc _schemes;
43
44     // default constructor
45
protected
46     RegistrationServiceImpl()
47     {
48         // registration service
49
_schemes = null;
50     }
51
52     //
53
// entry point
54
//
55

56     static public SystemService
57     create_service()
58     {
59         return new RegistrationServiceImpl();
60     }
61
62     //
63
// IDL:objectweb.org/corba/runtime/SystemComponent:1.0
64
//
65

66     final public void
67     system_configuration_complete(SystemConfiguration cfg)
68     {
69         _schemes = new java.util.HashMap JavaDoc();
70
71         // add default schemes: FileRegistrationScheme and INSRegistrationScheme
72
_schemes.put(FileRegistrationScheme.SCHEME_ID, new FileRegistrationSchemeImpl());
73         _schemes.put(INSRegistrationScheme.SCHEME_ID, new INSRegistrationSchemeImpl());
74     }
75
76     final public void
77     destroy()
78     {
79         _schemes.clear();
80     }
81
82     //
83
// IDL:objectweb.org/corba/runtime/SystemService:1.0
84
//
85

86     final public String JavaDoc
87     service_id()
88     {
89         return _service_id;
90     }
91
92     //
93
// IDL:objectweb.org/corba/runtime/RegistrationService:1.0
94
//
95

96     final public void
97     add_scheme(String JavaDoc location, String JavaDoc entrypt)
98     {
99         // check if location is set
100
if (location!=null) {
101             // add archive location to class loader
102
TheClassLoader.addResource(location);
103         }
104
105         // create the scheme
106
RegistrationScheme scheme = (RegistrationScheme)TheClassLoader.newInstance(entrypt);
107
108         // check if created
109
if (scheme==null) {
110             // NOTE: TODO: should be reported as an exception
111
final String JavaDoc opname = "add_scheme";
112             final String JavaDoc msg = "IGNORE (scheme not created)";
113             TheLogger.debug(_class_name, opname, msg);
114         }
115
116         // add
117
_schemes.put(scheme.scheme_id(), scheme);
118     }
119
120
121     final public RegistrationScheme
122     get_scheme(String JavaDoc scheme_id)
123     {
124         return (RegistrationScheme)_schemes.get(scheme_id);
125     }
126 }
127
Popular Tags