KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > impl > HivemoduleProvider


1 // Copyright 2007 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.impl;
16
17 import org.apache.commons.logging.Log;
18 import org.apache.commons.logging.LogFactory;
19 import org.apache.hivemind.ClassResolver;
20 import org.apache.hivemind.ErrorHandler;
21 import org.apache.hivemind.definition.RegistryDefinition;
22
23 /**
24  * Implementation of {@link RegistryProvider} that loads all xml modules
25  * defined in <code>META-INF/hivemodule.xml</code> files.
26  */

27 public class HivemoduleProvider implements RegistryProvider
28 {
29     private static final Log LOG = LogFactory.getLog(HivemoduleProvider.class);
30
31     /**
32      * The default path, within a JAR or the classpath, to the XML HiveMind module deployment
33      * descriptor: <code>META-INF/hivemodule.xml</code>. Use this constant with the
34      * {@link XmlModuleReader#readClassPathModules(String)} constructor.
35      */

36     public static final String JavaDoc HIVE_MODULE_XML = "META-INF/hivemodule.xml";
37
38     private ClassResolver _classResolver;
39     
40     private String JavaDoc _resourcePath;
41
42     public HivemoduleProvider()
43     {
44         this(new DefaultClassResolver(), HIVE_MODULE_XML);
45     }
46
47     public HivemoduleProvider(ClassResolver classResolver, String JavaDoc resourcePath)
48     {
49         _classResolver = classResolver;
50         _resourcePath = resourcePath;
51     }
52
53     public void process(RegistryDefinition registryDefinition, ErrorHandler errorHandler)
54     {
55         XmlModuleReader xmlModuleReader = new XmlModuleReader(registryDefinition, _classResolver,
56                 errorHandler);
57         if (LOG.isDebugEnabled())
58             LOG.debug("Processing xml modules visible to " + _classResolver);
59
60         xmlModuleReader.readClassPathModules(_resourcePath);
61     }
62
63 }
64
Popular Tags