/** * @param pw * @param provides */ void provides(PrintWriter pw, String provides, boolean servicefactory) { if (provides != null) { if (!servicefactory) pw.println(" <service>"); else pw.println(" <service servicefactory='true'>"); StringTokenizer st = new StringTokenizer(provides, ","); while (st.hasMoreTokens()) { String interfaceName = st.nextToken(); pw.println(" <provide interface='" + interfaceName + "'/>"); if (!analyzer.checkClass(interfaceName)) error("Component definition provides a class that is neither imported nor contained: " + interfaceName); } pw.println(" </service>"); } }
/** * Check if the given class or interface name is contained in the jar. * * @param interfaceName * @return */ public boolean checkClass(String interfaceName) { String path = Clazz.fqnToPath(interfaceName); if (classspace.containsKey(path)) return true; if (interfaceName.startsWith("java.")) return true; if (imports != null && !imports.isEmpty()) { String pack = interfaceName; int n = pack.lastIndexOf('.'); if (n > 0) pack = pack.substring(0, n); else pack = "."; if (imports.containsKey(pack)) return true; } int n = interfaceName.lastIndexOf('.'); if (n > 0 && n + 1 < interfaceName.length() && Character.isUpperCase(interfaceName.charAt(n + 1))) { return checkClass(interfaceName.substring(0, n) + '$' + interfaceName.substring(n + 1)); } return false; }
if (!analyzer.checkClass(interfaceName)) error("Component definition refers to a class that is neither imported nor contained: " + interfaceName);
impl = info.get(COMPONENT_IMPLEMENTATION); if (!analyzer.checkClass(impl)) { error("Not found Service-Component header: " + name); } else {