use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project cxf by apache.
the class NettyServerEngineFactoryParser method parse.
public Metadata parse(Element element, ParserContext context) {
// Endpoint definition
MutableBeanMetadata ef = context.createMetadata(MutableBeanMetadata.class);
if (!StringUtils.isEmpty(getIdOrName(element))) {
ef.setId(getIdOrName(element));
} else {
ef.setId("netty.engine.factory-holder-" + UUID.randomUUID().toString());
}
ef.setRuntimeClass(NettyHttpServerEngineFactoryHolder.class);
try {
// Print the DOM node
String xmlString = StaxUtils.toString(element);
ef.addProperty("parsedElement", createValue(context, xmlString));
ef.setInitMethod("init");
ef.setActivation(ComponentMetadata.ACTIVATION_EAGER);
ef.setDestroyMethod("destroy");
return ef;
} catch (Exception e) {
throw new RuntimeException("Could not process configuration.", e);
}
}
use of org.apache.aries.blueprint.mutable.MutableBeanMetadata 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);
}
}
use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project cxf by apache.
the class EndpointDefinitionParser method parse.
public Metadata parse(Element element, ParserContext context) {
// Endpoint definition
MutableBeanMetadata cxfBean = context.createMetadata(MutableBeanMetadata.class);
if (!StringUtils.isEmpty(getIdOrName(element))) {
cxfBean.setId(getIdOrName(element));
} else {
cxfBean.setId("cxf.endpoint." + UUID.randomUUID().toString());
}
cxfBean.setRuntimeClass(EP_CLASS);
boolean isAbstract = false;
boolean publish = true;
NamedNodeMap atts = element.getAttributes();
String bus = null;
Metadata impl = 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 ("createdFromAPI".equals(name) || "abstract".equals(name)) {
cxfBean.setScope(BeanMetadata.SCOPE_PROTOTYPE);
isAbstract = true;
} else if ("publish".equals(name)) {
publish = Boolean.parseBoolean(val);
} else if ("bus".equals(name)) {
bus = val;
} else if (isAttribute(pre, name)) {
if ("endpointName".equals(name) || "serviceName".equals(name)) {
QName q = parseQName(element, val);
cxfBean.addProperty(name, createValue(context, q));
} else if ("depends-on".equals(name)) {
cxfBean.addDependsOn(val);
} else if ("implementor".equals(name)) {
if (val.startsWith("#")) {
impl = createRef(context, val.substring(1));
} else {
impl = createObjectOfClass(context, val);
}
} else if (!"name".equals(name)) {
cxfBean.addProperty(name, createValue(context, val));
}
}
}
Element elem = DOMUtils.getFirstElement(element);
while (elem != null) {
String name = elem.getLocalName();
if ("properties".equals(name)) {
Metadata map = parseMapData(context, cxfBean, elem);
cxfBean.addProperty(name, map);
} else if ("binding".equals(name)) {
setFirstChildAsProperty(elem, context, cxfBean, "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, cxfBean, elem);
cxfBean.addProperty(name, list);
} else if ("implementor".equals(name)) {
impl = context.parseElement(Metadata.class, cxfBean, elem);
} else {
setFirstChildAsProperty(elem, context, cxfBean, name);
}
elem = DOMUtils.getNextElement(elem);
}
if (StringUtils.isEmpty(bus)) {
bus = "cxf";
}
cxfBean.addArgument(this.getBusRef(context, bus), Bus.class.getName(), 0);
cxfBean.addArgument(impl, Object.class.getName(), 1);
if (!isAbstract) {
if (publish) {
cxfBean.setInitMethod("publish");
}
cxfBean.setDestroyMethod("stop");
}
// We don't want to delay the registration of our Server
cxfBean.setActivation(ComponentMetadata.ACTIVATION_EAGER);
return cxfBean;
}
use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project cxf by apache.
the class BusDefinitionParser method parse.
public Metadata parse(Element element, ParserContext context) {
String bname = element.hasAttribute("bus") ? element.getAttribute("bus") : "cxf";
String id = element.hasAttribute("id") ? element.getAttribute("id") : null;
MutableBeanMetadata cxfBean = getBus(context, bname);
parseAttributes(element, context, cxfBean);
parseChildElements(element, context, cxfBean);
context.getComponentDefinitionRegistry().removeComponentDefinition(bname);
if (!StringUtils.isEmpty(id)) {
cxfBean.addProperty("id", createValue(context, id));
}
return cxfBean;
}
use of org.apache.aries.blueprint.mutable.MutableBeanMetadata 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);
}
Aggregations