context.getComponentDefinitionRegistry().registerTypeConverter(cnv);
}
}
private void parseCommand(Element element, ParserContext context) {
MutableBeanMetadata command = context.createMetadata(MutableBeanMetadata.class);
command.setRuntimeClass(BlueprintCommand.class);
command.addProperty(BLUEPRINT_CONTAINER, createRef(context, BLUEPRINT_CONTAINER));
command.addProperty(BLUEPRINT_CONVERTER, createRef(context, BLUEPRINT_CONVERTER));
NodeList children = element.getChildNodes();
MutableBeanMetadata action = null;
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child instanceof Element) {
Element childElement = (Element) child;
if (nodeNameEquals(childElement, ACTION)) {
action = parseAction(context, command, childElement);
action.setId(getName());
context.getComponentDefinitionRegistry().registerComponentDefinition(action);
command.addProperty(ACTION_ID, createIdRef(context, action.getId()));
} else if (nodeNameEquals(childElement, COMPLETERS)) {
command.addProperty(COMPLETERS, parseCompleters(context, command, childElement));
} else if (nodeNameEquals(childElement, OPTIONAL_COMPLETERS)) {
command.addProperty(OPTIONAL_COMPLETERS_PROPERTY, parseOptionalCompleters(context, command, childElement));
}
else {
throw new ComponentDefinitionException("Bad xml syntax: unknown element '" + childElement.getNodeName() + "'");
}
}
}
MutableServiceMetadata commandService = context.createMetadata(MutableServiceMetadata.class);
commandService.setActivation(MutableServiceMetadata.ACTIVATION_LAZY);
commandService.setId(getName());
commandService.setAutoExport(ServiceMetadata.AUTO_EXPORT_ALL_CLASSES);
commandService.setServiceComponent(command);
String scope = null;
if (SHELL_NAMESPACE_1_0_0.equals(element.getNamespaceURI())) {
String location = element.getAttribute(NAME);
location = location.replace('/', ':');
String function;
if (location.lastIndexOf(':') >= 0) {
scope = location.substring(0, location.lastIndexOf(':'));
function = location.substring(location.lastIndexOf(':') + 1);
} else {
scope = "";
function = location;
}
commandService.addServiceProperty(createStringValue(context, "osgi.command.scope"),
createStringValue(context, scope));
commandService.addServiceProperty(createStringValue(context, "osgi.command.function"),
createStringValue(context, function));
} else {
commandService.addServiceProperty(createStringValue(context, "osgi.command.scope"),
getInvocationValue(context, "getScope", action.getClassName()));
commandService.addServiceProperty(createStringValue(context, "osgi.command.function"),
getInvocationValue(context, "getName", action.getClassName()));
}
context.getComponentDefinitionRegistry().registerComponentDefinition(commandService);
String subShellName = null;