org.osgi.service.blueprint.reflect.ComponentMetadata Java Examples
The following examples show how to use
org.osgi.service.blueprint.reflect.ComponentMetadata.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JettyServerEngineFactoryParser.java From cxf with Apache License 2.0 | 6 votes |
protected Metadata parseEngineHandlers(List<Element> engines, ComponentMetadata enclosingComponent, ParserContext context) { MutableMapMetadata map = context.createMetadata(MutableMapMetadata.class); map.setKeyType("java.lang.String"); map.setValueType("java.util.List"); for (Element engine : engines) { String port = engine.getAttribute("port"); ValueMetadata keyValue = createValue(context, port); Element handlers = DOMUtils .getFirstChildWithName(engine, HTTPJettyTransportNamespaceHandler.JETTY_TRANSPORT, "handlers"); if (handlers != null) { Metadata valValue = parseListData(context, enclosingComponent, handlers); map.addEntry(keyValue, valValue); } } return map; }
Example #2
Source File: ConfigurerImpl.java From cxf with Apache License 2.0 | 6 votes |
public synchronized void configureBean(String bn, Object beanInstance, boolean checkWildcards) { if (null == bn) { bn = getBeanName(beanInstance); } if (null == bn) { return; } if (checkWildcards) { configureWithWildCard(bn, beanInstance); } if (container instanceof ExtendedBlueprintContainer) { ComponentMetadata cm = null; try { cm = container.getComponentMetadata(bn); } catch (NoSuchComponentException nsce) { cm = null; } if (cm instanceof BeanMetadata) { ((ExtendedBlueprintContainer)container).injectBeanInstance((BeanMetadata)cm, beanInstance); } } }
Example #3
Source File: ConfigurerImpl.java From cxf with Apache License 2.0 | 6 votes |
private void initializeWildcardMap() { for (String s : container.getComponentIds()) { if (isWildcardBeanName(s)) { ComponentMetadata cmd = container.getComponentMetadata(s); Class<?> cls = BlueprintBeanLocator.getClassForMetaData(container, cmd); if (cls != null) { final String cid = s.charAt(0) != '*' ? s : "." + s.replaceAll("\\.", "\\."); //old wildcard Matcher matcher = Pattern.compile(cid).matcher(""); List<MatcherHolder> m = wildCardBeanDefinitions.get(cls.getName()); if (m == null) { m = new ArrayList<>(); wildCardBeanDefinitions.put(cls.getName(), m); } MatcherHolder holder = new MatcherHolder(s, matcher); m.add(holder); } } } }
Example #4
Source File: BlueprintBeanLocator.java From cxf with Apache License 2.0 | 6 votes |
static Class<?> getClassForMetaData(BlueprintContainer container, ComponentMetadata cmd) { Class<?> cls = null; if (cmd instanceof BeanMetadata) { BeanMetadata bm = (BeanMetadata)cmd; if (bm instanceof ExtendedBeanMetadata) { cls = ((ExtendedBeanMetadata)bm).getRuntimeClass(); } if (cls == null && container instanceof ExtendedBlueprintContainer && bm.getClassName() != null) { try { cls = ((ExtendedBlueprintContainer)container).loadClass(bm.getClassName()); } catch (ClassNotFoundException cnfe) { //ignore } } } return cls; }
Example #5
Source File: NettyServerEngineFactoryParser.java From cxf with Apache License 2.0 | 6 votes |
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); } }
Example #6
Source File: UndertowServerEngineFactoryParser.java From cxf with Apache License 2.0 | 6 votes |
protected Metadata parseEngineHandlers(List<Element> engines, ComponentMetadata enclosingComponent, ParserContext context) { MutableMapMetadata map = context.createMetadata(MutableMapMetadata.class); map.setKeyType("java.lang.String"); map.setValueType("java.util.List"); for (Element engine : engines) { String port = engine.getAttribute("port"); ValueMetadata keyValue = createValue(context, port); Element handlers = DOMUtils .getFirstChildWithName(engine, HTTPUndertowTransportNamespaceHandler.UNDERTOW_TRANSPORT, "handlers"); if (handlers != null) { Metadata valValue = parseListData(context, enclosingComponent, handlers); map.addEntry(keyValue, valValue); } } return map; }
Example #7
Source File: JettyServerEngineFactoryParser.java From cxf with Apache License 2.0 | 6 votes |
protected Metadata parseEngineConnector(List<Element> engines, ComponentMetadata enclosingComponent, ParserContext context) { MutableMapMetadata map = context.createMetadata(MutableMapMetadata.class); map.setKeyType("java.lang.String"); map.setValueType("org.eclipse.jetty.server.Connector"); for (Element engine : engines) { String port = engine.getAttribute("port"); ValueMetadata keyValue = createValue(context, port); Element connector = DOMUtils .getFirstChildWithName(engine, HTTPJettyTransportNamespaceHandler.JETTY_TRANSPORT, "connector"); if (connector != null) { Element first = DOMUtils.getFirstElement(connector); Metadata valValue = context.parseElement(Metadata.class, enclosingComponent, first); map.addEntry(keyValue, valValue); } } return map; }
Example #8
Source File: ServerFactoryBeanDefinitionParser.java From cxf with Apache License 2.0 | 5 votes |
@Override public Metadata parse(Element element, ParserContext context) { MutableBeanMetadata bean = (MutableBeanMetadata)super.parse(element, context); bean.setInitMethod("init"); bean.setDestroyMethod("destroy"); // We don't really want to delay the registration of our Server bean.setActivation(ComponentMetadata.ACTIVATION_EAGER); return bean; }
Example #9
Source File: AbstractBPBeanDefinitionParser.java From cxf with Apache License 2.0 | 5 votes |
protected Metadata parseListData(ParserContext context, ComponentMetadata enclosingComponent, Element element) { MutableCollectionMetadata m = (MutableCollectionMetadata) context.parseElement(CollectionMetadata.class, enclosingComponent, element); m.setCollectionClass(List.class); return m; }
Example #10
Source File: UndertowServerEngineFactoryParser.java From cxf with Apache License 2.0 | 5 votes |
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("undertow.engine.factory-holder-" + UUID.randomUUID().toString()); } ef.setRuntimeClass(UndertowHTTPServerEngineFactoryHolder.class); // setup the HandlersMap property for the UndertowHTTPServerEngineFactoryHolder 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"); // setup the EngineConnector List<Element> engines = DOMUtils .getChildrenWithName(element, HTTPUndertowTransportNamespaceHandler.UNDERTOW_TRANSPORT, "engine"); ef.addProperty("handlersMap", parseEngineHandlers(engines, ef, context)); return ef; } catch (Exception e) { throw new RuntimeException("Could not process configuration.", e); } }
Example #11
Source File: AbstractBPBeanDefinitionParser.java From cxf with Apache License 2.0 | 5 votes |
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); }
Example #12
Source File: AuthorizationNsHandler.java From peer-os with Apache License 2.0 | 5 votes |
@Override public ComponentMetadata decorate( Node node, ComponentMetadata cm, ParserContext pc ) { if ( node instanceof Element ) { parseElement( ( Element ) node, pc ); } return cm; }
Example #13
Source File: JettyServerEngineFactoryParser.java From cxf with Apache License 2.0 | 5 votes |
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("jetty.engine.factory-holder-" + UUID.randomUUID().toString()); } ef.setRuntimeClass(JettyHTTPServerEngineFactoryHolder.class); // setup the ConnectorMap and HandlersMap property for the JettyHTTPServerEngineFactoryHolder 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"); // setup the EngineConnector List<Element> engines = DOMUtils .getChildrenWithName(element, HTTPJettyTransportNamespaceHandler.JETTY_TRANSPORT, "engine"); ef.addProperty("connectorMap", parseEngineConnector(engines, ef, context)); ef.addProperty("handlersMap", parseEngineHandlers(engines, ef, context)); return ef; } catch (Exception e) { throw new RuntimeException("Could not process configuration.", e); } }
Example #14
Source File: BlueprintBeanLocator.java From cxf with Apache License 2.0 | 5 votes |
private ComponentMetadata getComponentMetadata(String id) { try { return container.getComponentMetadata(id); } catch (NoSuchComponentException nsce) { return null; } }
Example #15
Source File: BlueprintBeanLocator.java From cxf with Apache License 2.0 | 5 votes |
public <T> T getBeanOfType(String name, Class<T> type) { ComponentMetadata cmd = getComponentMetadata(name); Class<?> cls = getClassForMetaData(cmd); if (cls != null && type.isAssignableFrom(cls)) { return type.cast(container.getComponentInstance(name)); } return orig.getBeanOfType(name, type); }
Example #16
Source File: BlueprintBeanLocator.java From cxf with Apache License 2.0 | 5 votes |
/** {@inheritDoc}*/ public List<String> getBeanNamesOfType(Class<?> type) { Set<String> names = new LinkedHashSet<>(); for (String s : container.getComponentIds()) { ComponentMetadata cmd = container.getComponentMetadata(s); Class<?> cls = getClassForMetaData(cmd); if (cls != null && type.isAssignableFrom(cls)) { names.add(s); } } names.addAll(orig.getBeanNamesOfType(type)); return new ArrayList<>(names); }
Example #17
Source File: BlueprintBeanLocator.java From cxf with Apache License 2.0 | 5 votes |
/** {@inheritDoc}*/ public <T> Collection<? extends T> getBeansOfType(Class<T> type) { List<T> list = new ArrayList<>(); for (String s : container.getComponentIds()) { ComponentMetadata cmd = container.getComponentMetadata(s); Class<?> cls = getClassForMetaData(cmd); if (cls != null && type.isAssignableFrom(cls)) { list.add(type.cast(container.getComponentInstance(s))); } } if (list.isEmpty() && context != null) { try { ServiceReference<?>[] refs = context.getServiceReferences(type.getName(), null); if (refs != null) { for (ServiceReference<?> r : refs) { list.add(type.cast(context.getService(r))); } } } catch (Exception ex) { //ignore, just don't support the OSGi services LOG.info("Try to find the Bean with type:" + type + " from OSGi services and get error: " + ex); } } list.addAll(orig.getBeansOfType(type)); return list; }
Example #18
Source File: BlueprintBeanLocator.java From cxf with Apache License 2.0 | 5 votes |
public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String value) { ComponentMetadata cmd = getComponentMetadata(beanName); if (cmd instanceof BeanMetadata) { BeanMetadata br = (BeanMetadata)cmd; for (BeanProperty s : br.getProperties()) { if (propertyName.equals(s.getName())) { return true; } } return false; } return orig.hasConfiguredPropertyValue(beanName, propertyName, value); }
Example #19
Source File: BlueprintBeanLocator.java From cxf with Apache License 2.0 | 5 votes |
public boolean hasBeanOfName(String name) { ComponentMetadata cmd = getComponentMetadata(name); if (cmd instanceof BeanMetadata) { return true; } return orig.hasBeanOfName(name); }
Example #20
Source File: JAXRSServerFactoryBeanDefinitionParser.java From cxf with Apache License 2.0 | 5 votes |
@Override public Metadata parse(Element element, ParserContext context) { MutableBeanMetadata bean = (MutableBeanMetadata)super.parse(element, context); bean.setInitMethod("init"); bean.setDestroyMethod("destroy"); // We don't really want to delay the registration of our Server bean.setActivation(ComponentMetadata.ACTIVATION_EAGER); return bean; }
Example #21
Source File: BlueprintBeanLocator.java From cxf with Apache License 2.0 | 4 votes |
private Class<?> getClassForMetaData(ComponentMetadata cmd) { return getClassForMetaData(container, cmd); }
Example #22
Source File: AuthorizationInterceptor.java From peer-os with Apache License 2.0 | 4 votes |
@Override public Object preCall( ComponentMetadata cm, Method method, Object... parameters ) throws Throwable { Annotation ann = new SecurityAnnotationParser().getEffectiveAnnotation( beanClass, method ); if ( ann == null ) { return null; } if ( ann instanceof PermitAll ) { return null; } String[] rolesAr = new String[] {}; // Also applies for @DenyAll if ( ann instanceof RolesAllowed ) { rolesAr = ( ( RolesAllowed ) ann ).value(); } if ( ann instanceof RelationCredibility ) { return null; } Set<String> roles = new HashSet<>( Arrays.asList( rolesAr ) ); AccessControlContext acc = AccessController.getContext(); Subject subject = Subject.getSubject( acc ); if ( subject == null ) { throw new AccessControlException( "Method call " + method.getDeclaringClass() + "." + method.getName() + " denied. No JAAS login present" ); } Set<Principal> principals = subject.getPrincipals(); for ( Principal principal : principals ) { if ( roles.contains( principal.getName() ) ) { logger.debug( "Granting access to Method: {} for {}.", method, principal ); return null; } } String msg = String.format( "Method call %s.%s denied. Roles allowed are %s. Your principals are %s.", method.getDeclaringClass(), method.getName(), roles, getNames( principals ) ); throw new AccessControlException( msg ); }
Example #23
Source File: SimpleBPNamespaceHandler.java From cxf with Apache License 2.0 | 4 votes |
public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) { return null; }
Example #24
Source File: AbstractBPBeanDefinitionParser.java From cxf with Apache License 2.0 | 4 votes |
protected Metadata parseMapData(ParserContext context, ComponentMetadata enclosingComponent, Element element) { return context.parseElement(MapMetadata.class, enclosingComponent, element); }
Example #25
Source File: AuthorizationInterceptor.java From peer-os with Apache License 2.0 | 4 votes |
@Override public void postCallWithReturn( ComponentMetadata cm, Method method, Object returnType, Object preCallToken ) throws Exception { }
Example #26
Source File: CXFAPINamespaceHandler.java From cxf with Apache License 2.0 | 4 votes |
public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) { return null; }
Example #27
Source File: HttpNettyTransportNamespaceHandler.java From cxf with Apache License 2.0 | 4 votes |
public ComponentMetadata decorate(Node node, ComponentMetadata componentMetadata, ParserContext parserContext) { LOG.info("Decorating node " + node + " " + componentMetadata); return componentMetadata; }
Example #28
Source File: HTTPUndertowTransportNamespaceHandler.java From cxf with Apache License 2.0 | 4 votes |
public ComponentMetadata decorate(Node node, ComponentMetadata componentMetadata, ParserContext parserContext) { LOG.info("Decorating node " + node + " " + componentMetadata); return componentMetadata; }
Example #29
Source File: HTTPJettyTransportNamespaceHandler.java From cxf with Apache License 2.0 | 4 votes |
public ComponentMetadata decorate(Node node, ComponentMetadata componentMetadata, ParserContext parserContext) { LOG.info("Decorating node " + node + " " + componentMetadata); return componentMetadata; }
Example #30
Source File: AuthorizationInterceptor.java From peer-os with Apache License 2.0 | 4 votes |
@Override public void postCallWithException( ComponentMetadata cm, Method m, Throwable ex, Object preCallToken ) { }