01: package org.objectweb.celtix.bus.resource;
02:
03: import java.util.logging.Level;
04: import java.util.logging.Logger;
05: import org.objectweb.celtix.Bus;
06: import org.objectweb.celtix.BusException;
07: import org.objectweb.celtix.common.logging.LogUtils;
08: import org.objectweb.celtix.configuration.Configuration;
09: import org.objectweb.celtix.configuration.types.StringListType;
10: import org.objectweb.celtix.resource.DefaultResourceManager;
11: import org.objectweb.celtix.resource.ResourceResolver;
12:
13: public class ResourceManagerImpl extends DefaultResourceManager {
14:
15: private static final Logger LOG = LogUtils
16: .getL7dLogger(ResourceManagerImpl.class);
17:
18: public ResourceManagerImpl() {
19: super ();
20: }
21:
22: public ResourceManagerImpl(Bus bus) throws BusException {
23: super ();
24: resolvers.clear();
25:
26: Configuration conf = bus.getConfiguration();
27: assert null != conf;
28: Object obj = conf.getObject("resourceResolvers");
29: assert null != obj;
30:
31: try {
32: for (String className : ((StringListType) obj).getItem()) {
33: if (LOG.isLoggable(Level.FINE)) {
34: LOG.finest("attempting to load resolver "
35: + className);
36: }
37:
38: Class<? extends ResourceResolver> clz = getClass()
39: .getClassLoader().loadClass(className)
40: .asSubclass(ResourceResolver.class);
41:
42: ResourceResolver rr = clz.newInstance();
43: resolvers.add(rr);
44: }
45: } catch (Exception ex) {
46: throw new BusException(ex);
47: }
48: }
49:
50: }
|