private void createSubShell(ParserContext context, String scope, String subShellName) {
if (context.getComponentDefinitionRegistry().containsComponentDefinition(subShellName)) {
return;
}
MutableBeanMetadata subShellAction = context.createMetadata(MutableBeanMetadata.class);
subShellAction.setRuntimeClass(SubShellAction.class);
subShellAction.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);
subShellAction.setScope(MutableBeanMetadata.SCOPE_PROTOTYPE);
subShellAction.setId(getName());
subShellAction.addProperty("subShell", createStringValue(context, scope));
context.getComponentDefinitionRegistry().registerComponentDefinition(subShellAction);
MutableBeanMetadata subShellCommand = context.createMetadata(MutableBeanMetadata.class);
subShellCommand.setId(getName());
subShellCommand.setRuntimeClass(BlueprintCommand.class);
subShellCommand.addProperty(BLUEPRINT_CONTAINER, createRef(context, BLUEPRINT_CONTAINER));
subShellCommand.addProperty(BLUEPRINT_CONVERTER, createRef(context, BLUEPRINT_CONVERTER));
subShellCommand.addProperty(ACTION_ID, createIdRef(context, subShellAction.getId()));
context.getComponentDefinitionRegistry().registerComponentDefinition(subShellCommand);
MutableServiceMetadata subShellCommandService = context.createMetadata(MutableServiceMetadata.class);
subShellCommandService.setActivation(MutableServiceMetadata.ACTIVATION_LAZY);
subShellCommandService.setId(subShellName);
subShellCommandService.setAutoExport(ServiceMetadata.AUTO_EXPORT_INTERFACES);
subShellCommandService.setServiceComponent(subShellCommand);
subShellCommandService.addServiceProperty(createStringValue(context, "osgi.command.scope"), createStringValue(context, "*"));
subShellCommandService.addServiceProperty(createStringValue(context, "osgi.command.function"), createStringValue(context, scope));
context.getComponentDefinitionRegistry().registerComponentDefinition(subShellCommandService);
}