use of org.osgi.service.blueprint.reflect.Metadata in project karaf by apache.
the class NamespaceHandler method parseCompleters.
private Metadata parseCompleters(ParserContext context, ComponentMetadata enclosingComponent, Element element) {
MutableCollectionMetadata collection = context.createMetadata(MutableCollectionMetadata.class);
collection.setCollectionClass(List.class);
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child instanceof Element) {
Metadata metadata;
if (nodeNameEquals(child, REF)) {
metadata = context.parseElement(RefMetadata.class, context.getEnclosingComponent(), (Element) child);
} else if (nodeNameEquals(child, NULL)) {
metadata = context.parseElement(NullMetadata.class, context.getEnclosingComponent(), (Element) child);
} else if (nodeNameEquals(child, BEAN)) {
metadata = context.parseElement(BeanMetadata.class, enclosingComponent, (Element) child);
} else {
throw new IllegalStateException("Unexpected element " + child.getNodeName());
}
collection.addValue(metadata);
}
}
return collection;
}
use of org.osgi.service.blueprint.reflect.Metadata in project camel by apache.
the class EndpointDefinitionParser method parse.
public Metadata parse(Element element, ParserContext context) {
MutableBeanMetadata endpointConfig = createBeanMetadata(element, context, CxfBlueprintEndpoint.class);
NamedNodeMap atts = element.getAttributes();
String bus = null;
String address = 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 ("address".equals(name)) {
address = val;
} else if (isAttribute(pre, name)) {
if ("endpointName".equals(name) || "serviceName".equals(name)) {
if (isPlaceHolder(val)) {
endpointConfig.addProperty(name + "String", createValue(context, val));
} else {
QName q = parseQName(element, val);
endpointConfig.addProperty(name, createValue(context, q));
}
} else if ("depends-on".equals(name)) {
endpointConfig.addDependsOn(val);
} else if (!"name".equals(name)) {
endpointConfig.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, endpointConfig, elem);
endpointConfig.addProperty(name, map);
} else if ("binding".equals(name)) {
setFirstChildAsProperty(elem, context, endpointConfig, "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, endpointConfig, elem);
endpointConfig.addProperty(name, list);
} else {
setFirstChildAsProperty(elem, context, endpointConfig, name);
}
elem = DOMUtils.getNextElement(elem);
}
if (StringUtils.isEmpty(bus)) {
bus = "cxf";
}
//Will create a bus if needed...
endpointConfig.addProperty("bus", getBusRef(context, bus));
endpointConfig.setDestroyMethod("destroy");
endpointConfig.addArgument(createValue(context, address), String.class.getName(), 0);
endpointConfig.addArgument(createRef(context, "blueprintBundleContext"), BundleContext.class.getName(), 1);
return endpointConfig;
}
use of org.osgi.service.blueprint.reflect.Metadata in project fabric8 by jboss-fuse.
the class DirectoryNamespaceHandler method parse.
@Override
public Metadata parse(Element element, ParserContext parserContext) {
if (parserContext.getComponentDefinitionRegistry().getComponentDefinition("." + MyConverter.class.getName()) == null) {
MutableBeanMetadata converter = parserContext.createMetadata(MutableBeanMetadata.class);
converter.setId("." + MyConverter.class.getName());
converter.setRuntimeClass(MyConverter.class);
parserContext.getComponentDefinitionRegistry().registerTypeConverter(converter);
}
Metadata metadata = super.parse(element, parserContext);
if (metadata instanceof MutableBeanMetadata) {
MutableBeanMetadata bean = (MutableBeanMetadata) metadata;
if (bean.getRuntimeClass() == ApacheDS.class) {
bean.setInitMethod("startup");
bean.setDestroyMethod("shutdown");
}
}
return metadata;
}
use of org.osgi.service.blueprint.reflect.Metadata in project aries by apache.
the class BlueprintContainerImpl method getMetadata.
private <T extends ComponentMetadata> void getMetadata(Class<T> clazz, Metadata component, Collection<T> metadatas) {
if (component == null) {
return;
}
if (clazz.isInstance(component)) {
metadatas.add(clazz.cast(component));
}
if (component instanceof BeanMetadata) {
getMetadata(clazz, ((BeanMetadata) component).getFactoryComponent(), metadatas);
for (BeanArgument arg : ((BeanMetadata) component).getArguments()) {
getMetadata(clazz, arg.getValue(), metadatas);
}
for (BeanProperty prop : ((BeanMetadata) component).getProperties()) {
getMetadata(clazz, prop.getValue(), metadatas);
}
}
if (component instanceof CollectionMetadata) {
for (Metadata m : ((CollectionMetadata) component).getValues()) {
getMetadata(clazz, m, metadatas);
}
}
if (component instanceof MapMetadata) {
for (MapEntry m : ((MapMetadata) component).getEntries()) {
getMetadata(clazz, m.getKey(), metadatas);
getMetadata(clazz, m.getValue(), metadatas);
}
}
if (component instanceof PropsMetadata) {
for (MapEntry m : ((PropsMetadata) component).getEntries()) {
getMetadata(clazz, m.getKey(), metadatas);
getMetadata(clazz, m.getValue(), metadatas);
}
}
if (component instanceof ServiceReferenceMetadata) {
for (ReferenceListener l : ((ServiceReferenceMetadata) component).getReferenceListeners()) {
getMetadata(clazz, l.getListenerComponent(), metadatas);
}
}
if (component instanceof ServiceMetadata) {
getMetadata(clazz, ((ServiceMetadata) component).getServiceComponent(), metadatas);
for (MapEntry m : ((ServiceMetadata) component).getServiceProperties()) {
getMetadata(clazz, m.getKey(), metadatas);
getMetadata(clazz, m.getValue(), metadatas);
}
for (RegistrationListener l : ((ServiceMetadata) component).getRegistrationListeners()) {
getMetadata(clazz, l.getListenerComponent(), metadatas);
}
}
}
use of org.osgi.service.blueprint.reflect.Metadata in project aries by apache.
the class NSHandlerFour method parse.
// process elements
public Metadata parse(Element element, ParserContext context) {
Metadata retval = null;
if (element.getLocalName().equals(ELT_NAME)) {
final String id = element.getAttributeNS(NSURI, ATTRIB_ID);
MutableBeanMetadata bm = context.createMetadata(MutableBeanMetadata.class);
bm.setId(id);
bm.setScope("PROTOTYPE");
bm.setClassName(TestBean.class.getName());
retval = bm;
}
return retval;
}
Aggregations