1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.exolab.castor.xml.util.resolvers;
17
18 import java.util.Map;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22 import org.exolab.castor.mapping.ClassDescriptor;
23 import org.exolab.castor.xml.ResolverException;
24 import org.exolab.castor.xml.util.ResolverPackageCommand;
25 import org.exolab.castor.xml.util.ResolverStrategy;
26
27
28
29
30
31
32
33
34
35
36 public abstract class AbstractResolverPackageCommand implements ResolverPackageCommand {
37
38 private static final Log LOG = LogFactory.getLog(AbstractResolverPackageCommand.class);
39
40
41
42
43 public final Map<String, ClassDescriptor> resolve(final String packageName, final Map properties)
44 throws ResolverException {
45 String pName;
46 if ((packageName == null) || ("".equals(packageName))) {
47 LOG.debug("Package name is empty! Anyhow, giving it a try...");
48 pName = "";
49 } else {
50 pName = packageName;
51 }
52
53 if (LOG.isDebugEnabled()) {
54 LOG.debug("Now in resolve method: " + this.getClass().getName()
55 + " resolving: " + packageName);
56 }
57
58 ClassLoader classLoader = (ClassLoader) properties.get(
59 ResolverStrategy.PROPERTY_CLASS_LOADER);
60 if (classLoader == null) {
61 LOG.debug("No domain class loader set, taking it from class.getClassLoader().");
62 classLoader = this.getClass().getClassLoader();
63 }
64 return internalResolve(pName, classLoader, properties);
65 }
66
67
68
69
70
71
72
73 protected final boolean isEmptyPackageName(final String packageName) {
74 return ((packageName == null) || (packageName.length() == 0) || ("".equals(packageName)));
75 }
76
77
78
79
80
81
82
83
84
85
86
87
88 protected abstract Map<String, ClassDescriptor> internalResolve(String packageName, ClassLoader classLoader, Map props)
89 throws ResolverException;
90 }