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