use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class JMXHandlerDescription method getHandlerInfo.
/**
* Gets handler information.
*
* @return the handler information.
*/
public Element getHandlerInfo() {
Element elem = super.getHandlerInfo();
elem.addAttribute(new Attribute("registered", Boolean.toString(m_handler.isRegistered())));
elem.addAttribute(new Attribute("objectName", m_handler.getUsedObjectName()));
if (m_handler.isUsesMOSGi()) {
String foundStr = null;
if (m_handler.isMOSGiExists()) {
foundStr = "found";
} else {
foundStr = "not_found";
}
elem.addAttribute(new Attribute("mosgi", foundStr));
}
return elem;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class TestDeclarationBuilderService method manipulation.
private Element manipulation() {
Element manipulation = new Element("manipulation", null);
manipulation.addAttribute(new Attribute("classname", "org.apache.felix.ipojo.runtime.core.test.components.GermanHelloService"));
manipulation.addAttribute(new Attribute("super", "java.lang.Object"));
Element itf = new Element("interface", null);
itf.addAttribute(new Attribute("name", "org.apache.felix.ipojo.runtime.core.test.services.HelloService"));
manipulation.addElement(itf);
Element method = new Element("method", null);
method.addAttribute(new Attribute("name", "hello"));
method.addAttribute(new Attribute("return", "java.lang.String"));
method.addAttribute(new Attribute("arguments", "{java.lang.String}"));
method.addAttribute(new Attribute("names", "{name}"));
manipulation.addElement(method);
return manipulation;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class CheckServiceHandlerDescription method getHandlerInfo.
public Element getHandlerInfo() {
Element elem = super.getHandlerInfo();
elem.addAttribute(new Attribute("isValid", isValid() + ""));
return elem;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class ComponentFactory method getRequiredHandlerList.
/**
* 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));
}
// 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);
}
if (rq != null) {
// Check it's not already contained
if (!list.contains(rq)) {
list.add(rq);
}
}
}
}
return list;
}
use of org.apache.felix.ipojo.metadata.Attribute in project felix by apache.
the class PrimitiveTypeDescription method getDescription.
/**
* Adds the "implementation-class" attribute to the type description.
*
* @return the component type description.
* @see org.apache.felix.ipojo.architecture.ComponentTypeDescription#getDescription()
*/
public Element getDescription() {
Element elem = super.getDescription();
elem.addAttribute(new Attribute("Implementation-Class", m_factory.getClassName()));
/* Adding interfaces and super-classes of component into description */
Element inheritance = new Element("Inherited", "");
inheritance.addAttribute(new Attribute("Interfaces", m_interfaces.toString()));
inheritance.addAttribute(new Attribute("SuperClasses", m_superClasses.toString()));
elem.addElement(inheritance);
return elem;
}
Aggregations