/** * Computes required handlers. This method does not manipulate any non-immutable fields, so does * not need to be synchronized. * * @return the required handler list. */ public List getRequiredHandlerList() { List list = new ArrayList(); Element[] elems = m_componentMetadata.getElements(); for (int i = 0; i < elems.length; i++) { Element current = elems[i]; if (!"manipulation".equals(current.getName())) { RequiredHandler req = new RequiredHandler(current.getName(), current.getNameSpace()); if (!list.contains(req)) { list.add(req); } } } // Add architecture if architecture != 'false' String arch = m_componentMetadata.getAttribute("architecture"); if (arch == null || arch.equalsIgnoreCase("true")) { list.add(new RequiredHandler("architecture", null)); } // Determine if the component must be immediate. // A component becomes immediate if it doesn't provide a service, // and does not specified that the component is not immediate. if (m_componentMetadata.getElements("provides") == null) { String imm = m_componentMetadata.getAttribute("immediate"); if (imm == null) { // immediate not specified, set the immediate attribute to true getLogger() .log(Logger.INFO, "The component type " + getFactoryName() + " becomes immediate"); m_componentMetadata.addAttribute(new Attribute("immediate", "true")); } } // Add lifecycle callback if immediate = true RequiredHandler reqCallback = new RequiredHandler("callback", null); String imm = m_componentMetadata.getAttribute("immediate"); if (!list.contains(reqCallback) && imm != null && imm.equalsIgnoreCase("true")) { list.add(reqCallback); } return list; }
/** * Computes required handlers. This method does not manipulate any non-immutable fields, so does * not need to be synchronized. This method checks the {@link * ComponentFactory#HANDLER_AUTO_PRIMITIVE} system property to add the listed handlers to the * required handler set. * * @return the required handler list. */ public List<RequiredHandler> getRequiredHandlerList() { List<RequiredHandler> list = new ArrayList<RequiredHandler>(); Element[] elems = m_componentMetadata.getElements(); for (Element current : elems) { if (!"manipulation".equals(current.getName())) { // Remove the manipulation element RequiredHandler req = new RequiredHandler(current.getName(), current.getNameSpace()); if (!list.contains(req)) { list.add(req); } } } // Add architecture if architecture != 'false' String arch = m_componentMetadata.getAttribute("architecture"); if (arch == null || arch.equalsIgnoreCase("true")) { list.add(new RequiredHandler("architecture", null)); } // Determine if the component must be immediate. // A component becomes immediate if it doesn't provide a service, // and does not specified that the component is not immediate. if (m_componentMetadata.getElements("provides") == null) { String imm = m_componentMetadata.getAttribute("immediate"); if (imm == null) { // immediate not specified, set the immediate attribute to true getLogger() .log(Logger.INFO, "The component type " + getFactoryName() + " becomes immediate"); m_componentMetadata.addAttribute(new Attribute("immediate", "true")); } } // Add lifecycle callback if immediate = true RequiredHandler reqCallback = new RequiredHandler("callback", null); String imm = m_componentMetadata.getAttribute("immediate"); if (!list.contains(reqCallback) && imm != null && imm.equalsIgnoreCase("true")) { list.add(reqCallback); } // Manage auto attached handler. String v = System.getProperty(HANDLER_AUTO_PRIMITIVE); if (v != null && v.length() != 0) { String[] hs = ParseUtils.split(v, ","); for (String h1 : hs) { String h = h1.trim(); String[] segments = ParseUtils.split(h, ":"); RequiredHandler rq = null; if (segments.length == 2) { // External handler rq = new RequiredHandler(segments[1], segments[0]); } else if (segments.length == 1) { // Core handler rq = new RequiredHandler(segments[1], null); } // Others case are ignored. if (rq != null) { // Check it's not already contained if (!list.contains(rq)) { list.add(rq); } } } } return list; }