use of org.apache.aries.blueprint.mutable.MutablePassThroughMetadata in project camel by apache.
the class CamelNamespaceHandler method parseRouteContextNode.
private Metadata parseRouteContextNode(Element element, ParserContext context) {
LOG.trace("Parsing RouteContext {}", element);
// now parse the routes with JAXB
Binder<Node> binder;
try {
binder = getJaxbContext().createBinder();
} catch (JAXBException e) {
throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
}
Object value = parseUsingJaxb(element, context, binder);
if (!(value instanceof CamelRouteContextFactoryBean)) {
throw new ComponentDefinitionException("Expected an instance of " + CamelRouteContextFactoryBean.class);
}
CamelRouteContextFactoryBean rcfb = (CamelRouteContextFactoryBean) value;
String id = rcfb.getId();
MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
factory.setId(".camelBlueprint.passThrough." + id);
factory.setObject(new PassThroughCallable<Object>(rcfb));
MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
factory2.setId(".camelBlueprint.factory." + id);
factory2.setFactoryComponent(factory);
factory2.setFactoryMethod("call");
MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
ctx.setId(id);
ctx.setRuntimeClass(List.class);
ctx.setFactoryComponent(factory2);
ctx.setFactoryMethod("getRoutes");
// must be lazy as we want CamelContext to be activated first
ctx.setActivation(ACTIVATION_LAZY);
// lets inject the namespaces into any namespace aware POJOs
injectNamespaces(element, binder);
LOG.trace("Parsing RouteContext done, returning {}", element, ctx);
return ctx;
}
use of org.apache.aries.blueprint.mutable.MutablePassThroughMetadata in project camel by apache.
the class RsClientDefinitionParser method parse.
public Metadata parse(Element element, ParserContext context) {
MutableBeanMetadata beanMetadata = createBeanMetadata(element, context, RsClientBlueprintBean.class);
NamedNodeMap atts = element.getAttributes();
String bus = null;
for (int i = 0; i < atts.getLength(); i++) {
Attr node = (Attr) atts.item(i);
String val = node.getValue();
String pre = node.getPrefix();
String name = node.getLocalName();
if ("bus".equals(name)) {
bus = val;
} else if (isAttribute(pre, name)) {
if ("depends-on".equals(name)) {
beanMetadata.addDependsOn(val);
} else if (!"name".equals(name)) {
beanMetadata.addProperty(name, AbstractBPBeanDefinitionParser.createValue(context, val));
}
}
}
for (Element elem = DOMUtils.getFirstElement(element); elem != null; elem = DOMUtils.getNextElement(elem)) {
String name = elem.getLocalName();
if ("properties".equals(name) || "headers".equals(name)) {
Metadata map = parseMapData(context, beanMetadata, elem);
beanMetadata.addProperty(name, map);
} else if ("binding".equals(name)) {
setFirstChildAsProperty(elem, context, beanMetadata, "bindingConfig");
} else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
Metadata list = parseListData(context, beanMetadata, elem);
beanMetadata.addProperty(name, list);
} else if ("features".equals(name) || "providers".equals(name) || "schemaLocations".equals(name) || "modelBeans".equals(name)) {
Metadata list = parseListData(context, beanMetadata, elem);
beanMetadata.addProperty(name, list);
} else if ("model".equals(name)) {
List<UserResource> resources = ResourceUtils.getResourcesFromElement(elem);
MutablePassThroughMetadata value = context.createMetadata(MutablePassThroughMetadata.class);
value.setObject(resources);
beanMetadata.addProperty(name, value);
} else {
setFirstChildAsProperty(elem, context, beanMetadata, name);
}
}
if (StringUtils.isEmpty(bus)) {
bus = "cxf";
}
//Will create a bus if needed...
beanMetadata.addProperty("bus", getBusRef(context, bus));
return beanMetadata;
}
use of org.apache.aries.blueprint.mutable.MutablePassThroughMetadata in project camel by apache.
the class RsServerDefinitionParser method parse.
public Metadata parse(Element element, ParserContext context) {
MutableBeanMetadata beanMetadata = createBeanMetadata(element, context, RsServerBlueprintBean.class);
NamedNodeMap atts = element.getAttributes();
String bus = null;
for (int i = 0; i < atts.getLength(); i++) {
Attr node = (Attr) atts.item(i);
String val = node.getValue();
String pre = node.getPrefix();
String name = node.getLocalName();
if ("bus".equals(name)) {
bus = val;
} else if (isAttribute(pre, name)) {
if ("depends-on".equals(name)) {
beanMetadata.addDependsOn(val);
} else if (!"name".equals(name)) {
beanMetadata.addProperty(name, AbstractBPBeanDefinitionParser.createValue(context, val));
}
}
}
for (Element elem = DOMUtils.getFirstElement(element); elem != null; elem = DOMUtils.getNextElement(elem)) {
String name = elem.getLocalName();
if ("properties".equals(name) || "extensionMappings".equals(name) || "languageMappings".equals(name)) {
Metadata map = parseMapData(context, beanMetadata, elem);
beanMetadata.addProperty(name, map);
} else if ("binding".equals(name)) {
setFirstChildAsProperty(elem, context, beanMetadata, "bindingConfig");
} else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
Metadata list = parseListData(context, beanMetadata, elem);
beanMetadata.addProperty(name, list);
} else if ("features".equals(name) || "providers".equals(name) || "schemaLocations".equals(name) || "modelBeans".equals(name) || "serviceBeans".equals(name)) {
Metadata list = parseListData(context, beanMetadata, elem);
beanMetadata.addProperty(name, list);
} else if ("model".equals(name)) {
List<UserResource> resources = ResourceUtils.getResourcesFromElement(elem);
MutablePassThroughMetadata value = context.createMetadata(MutablePassThroughMetadata.class);
value.setObject(resources);
beanMetadata.addProperty(name, value);
} else {
setFirstChildAsProperty(elem, context, beanMetadata, name);
}
}
if (StringUtils.isEmpty(bus)) {
bus = "cxf";
}
//Will create a bus if needed...
beanMetadata.addProperty("bus", getBusRef(context, bus));
return beanMetadata;
}
use of org.apache.aries.blueprint.mutable.MutablePassThroughMetadata in project cxf by apache.
the class AbstractBPBeanDefinitionParser method getBus.
protected MutableBeanMetadata getBus(ParserContext context, String name) {
ComponentDefinitionRegistry cdr = context.getComponentDefinitionRegistry();
ComponentMetadata meta = cdr.getComponentDefinition("blueprintBundle");
if (!cdr.containsComponentDefinition(InterceptorTypeConverter.class.getName())) {
MutablePassThroughMetadata md = context.createMetadata(MutablePassThroughMetadata.class);
md.setObject(new InterceptorTypeConverter());
md.setId(InterceptorTypeConverter.class.getName());
context.getComponentDefinitionRegistry().registerTypeConverter(md);
}
if (!cdr.containsComponentDefinition(name)) {
// Create a bus
MutableBeanMetadata bus = context.createMetadata(MutableBeanMetadata.class);
bus.setId(name);
bus.setRuntimeClass(BlueprintBus.class);
if (meta != null) {
// blueprint-no-osgi does not provide a bundleContext
bus.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
}
bus.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
bus.setDestroyMethod("shutdown");
bus.setInitMethod("initialize");
context.getComponentDefinitionRegistry().registerComponentDefinition(bus);
return bus;
}
return (MutableBeanMetadata) cdr.getComponentDefinition(name);
}
use of org.apache.aries.blueprint.mutable.MutablePassThroughMetadata in project cxf by apache.
the class JAXRSServerFactoryBeanDefinitionParser method mapElement.
@Override
protected void mapElement(ParserContext ctx, MutableBeanMetadata bean, Element el, String name) {
if ("properties".equals(name) || "extensionMappings".equals(name) || "languageMappings".equals(name)) {
bean.addProperty(name, this.parseMapData(ctx, bean, el));
} else if ("executor".equals(name)) {
setFirstChildAsProperty(el, ctx, bean, "serviceFactory.executor");
} else if ("invoker".equals(name)) {
setFirstChildAsProperty(el, ctx, bean, "serviceFactory.invoker");
} else if ("binding".equals(name)) {
setFirstChildAsProperty(el, ctx, bean, "bindingConfig");
} else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name)) {
bean.addProperty(name, this.parseListData(ctx, bean, el));
} else if ("features".equals(name) || "schemaLocations".equals(name) || "providers".equals(name) || "serviceBeans".equals(name) || "modelBeans".equals(name)) {
bean.addProperty(name, this.parseListData(ctx, bean, el));
} else if ("serviceFactories".equals(name)) {
bean.addProperty("resourceProviders", this.parseListData(ctx, bean, el));
} else if ("resourceClasses".equals(name)) {
List<String> resources = getResourceClassesFromElement(el);
MutableCollectionMetadata list = ctx.createMetadata(MutableCollectionMetadata.class);
list.setCollectionClass(List.class);
for (String res : resources) {
MutableBeanMetadata objectOfClass = createObjectOfClass(ctx, res);
list.addValue(objectOfClass);
}
bean.addProperty("serviceBeans", list);
} else if ("model".equals(name)) {
List<UserResource> resources = ResourceUtils.getResourcesFromElement(el);
MutableCollectionMetadata list = ctx.createMetadata(MutableCollectionMetadata.class);
list.setCollectionClass(List.class);
for (UserResource res : resources) {
MutablePassThroughMetadata factory = ctx.createMetadata(MutablePassThroughMetadata.class);
factory.setObject(new PassThroughCallable<Object>(res));
MutableBeanMetadata resourceBean = ctx.createMetadata(MutableBeanMetadata.class);
resourceBean.setFactoryComponent(factory);
resourceBean.setFactoryMethod("call");
list.addValue(resourceBean);
}
bean.addProperty("modelBeans", list);
} else {
setFirstChildAsProperty(el, ctx, bean, name);
}
}
Aggregations