本文整理汇总了Java中org.osgi.service.blueprint.reflect.ComponentMetadata类的典型用法代码示例。如果您正苦于以下问题:Java ComponentMetadata类的具体用法?Java ComponentMetadata怎么用?Java ComponentMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComponentMetadata类属于org.osgi.service.blueprint.reflect包,在下文中一共展示了ComponentMetadata类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: process
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
@Override
public void process(ComponentDefinitionRegistry cdr) {
BlueprintContainer container = getComponent(cdr, "blueprintContainer");
Bundle bundle = getComponent(cdr, "blueprintBundle");
cdr.registerComponentDefinition(createServiceRef(JPA_COORDINATOR, Coordinator.class));
Set<String> components = new HashSet<String>(cdr.getComponentDefinitionNames());
for (String component : components) {
ComponentMetadata compDef = cdr.getComponentDefinition(component);
if (compDef instanceof MutableBeanMetadata && !((MutableBeanMetadata)compDef).isProcessor()) {
// Normal bean def
handleComponent((MutableBeanMetadata)compDef, bundle, cdr, container);
} else if(compDef instanceof MutableServiceMetadata) {
// Bean inlined into service def
MutableServiceMetadata sMeta = (MutableServiceMetadata)compDef;
Target target = sMeta.getServiceComponent();
if (target instanceof MutableBeanMetadata) {
handleComponent((MutableBeanMetadata)target, bundle, cdr, container);
}
}
}
}
开发者ID:apache,项目名称:aries-jpa,代码行数:24,代码来源:JpaComponentProcessor.java
示例2: preCall
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
@Override
public Object preCall(ComponentMetadata cm, Method m, Object... parameters) throws Throwable {
if (coordinator == null || em == null) {
initServices();
}
try {
LOG.debug("PreCall for bean {}, method {}", cm.getId(), m.getName());
Coordination coordination = coordinator.begin("jpa", 0);
boolean weControlTx = isResourceLocal(em) && !em.getTransaction().isActive();
if (weControlTx) {
coordination.addParticipant(new ResourceLocalTransactionParticipant(em));
}
return coordination;
} catch (Exception e) {
LOG.warn("Exception from EmSupplier.preCall", e);
throw new RuntimeException(e); // NOSONAR
}
}
开发者ID:apache,项目名称:aries-jpa,代码行数:19,代码来源:JpaInterceptor.java
示例3: buildBeanDefinitionFor
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
BeanDefinition buildBeanDefinitionFor(ComponentMetadata metadata) {
// shortcut (to avoid re-rewrapping)
if (metadata instanceof SimpleComponentMetadata) {
return ((SimpleComponentMetadata) metadata).getBeanDefinition();
}
AbstractBeanDefinition definition = buildBeanDefinition(metadata);
// add common properties
definition.setAttribute(MetadataConstants.COMPONENT_METADATA_ATTRIBUTE, metadata);
definition.setAttribute(MetadataConstants.COMPONENT_NAME, metadata.getId());
// Set<String> dependencies = metadata.;
// definition.setDependsOn(dependencies.toArray(new String[dependencies.size()]));
throw new UnsupportedOperationException("move depends on for BeanMetadata");
// return definition;
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:BeanDefinitionFactory.java
示例4: buildBeanDefinition
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
private AbstractBeanDefinition buildBeanDefinition(ComponentMetadata metadata) {
if (metadata instanceof BeanMetadata) {
return buildLocalComponent((BeanMetadata) metadata);
}
if (metadata instanceof ServiceMetadata) {
return buildExporter((ServiceMetadata) metadata);
}
if (metadata instanceof ServiceReferenceMetadata) {
if (metadata instanceof ReferenceListMetadata) {
return buildReferenceCollection((ReferenceListMetadata) metadata);
}
if (metadata instanceof ReferenceMetadata) {
return buildReferenceProxy((ReferenceMetadata) metadata);
}
}
// unknown rich metadata type, unable to perform conversion
throw new IllegalArgumentException("Unknown metadata type" + metadata.getClass());
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:23,代码来源:BeanDefinitionFactory.java
示例5: buildComponentMetadataFor
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
public static List<ComponentMetadata> buildComponentMetadataFor(ConfigurableListableBeanFactory factory) {
List<ComponentMetadata> metadata = new ArrayList<ComponentMetadata>();
String[] components = factory.getBeanDefinitionNames();
for (String beanName : components) {
BeanDefinition definition = factory.getBeanDefinition(beanName);
// filter generated definitions
if (!definition.hasAttribute(PROMOTED_REF)) {
// add metadata for top-level definitions
metadata.add(MetadataFactory.buildComponentMetadataFor(beanName, definition));
// look for nested ones
metadata.addAll(MetadataFactory.buildNestedComponentMetadataFor(definition));
}
}
return metadata;
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:19,代码来源:ComponentMetadataFactory.java
示例6: testDefaultsOnNestedBeans
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
public void testDefaultsOnNestedBeans() throws Exception {
ComponentMetadata metadata = blueprintContainer.getComponentMetadata("nested");
assertEquals(ComponentMetadata.ACTIVATION_LAZY, metadata.getActivation());
assertNull("null scope expected", ((BeanMetadata)metadata).getScope());
BeanMetadata meta = (BeanMetadata) metadata;
List<BeanProperty> props = meta.getProperties();
assertEquals(2, props.size());
BeanProperty propA = props.get(0);
ReferenceMetadata nestedRef = (ReferenceMetadata) propA.getValue();
assertEquals(ReferenceMetadata.AVAILABILITY_MANDATORY, nestedRef.getAvailability());
assertEquals(300, nestedRef.getTimeout());
BeanProperty propB = props.get(1);
ReferenceListMetadata nestedList = (ReferenceListMetadata) propB.getValue();
assertEquals(ReferenceMetadata.AVAILABILITY_OPTIONAL, nestedList.getAvailability());
assertEquals(ReferenceListMetadata.USE_SERVICE_REFERENCE, nestedList.getMemberType());
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:DefaultsTest.java
示例7: testOverallMetadata
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
public void testOverallMetadata() throws Exception {
BeanDefinition def = new GenericBeanDefinition();
assertEquals(new SimpleComponentMetadata(null, def), new SimpleComponentMetadata("foo", def));
Collection<ComponentMetadata> metadata = blueprintContainer.getMetadata(ComponentMetadata.class);
for (ComponentMetadata componentMetadata : metadata) {
if (componentMetadata instanceof ServiceReferenceMetadata) {
System.out.println(componentMetadata.getId());
}
}
// 1+1+3+4+4+5+3+1=22
assertEquals(22, metadata.size());
System.out.println(blueprintContainer.getComponentIds());
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:17,代码来源:NestedDefinitionMetadataTest.java
示例8: decorate
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
@Override
public ComponentMetadata decorate(final Node node, final ComponentMetadata component, final ParserContext context) {
if (node instanceof Attr) {
if (nodeNameEquals(node, RESTART_DEPENDENTS_ON_UPDATES)) {
return decorateRestartDependentsOnUpdates((Attr) node, component, context);
} else if (nodeNameEquals(node, USE_DEFAULT_FOR_REFERENCE_TYPES)) {
return decorateUseDefaultForReferenceTypes((Attr) node, component, context);
} else if (nodeNameEquals(node, TYPE_ATTR)) {
if (component instanceof ServiceReferenceMetadata) {
return decorateServiceReferenceType((Attr) node, component, context);
} else if (component instanceof ServiceMetadata) {
return decorateServiceType((Attr)node, component, context);
}
throw new ComponentDefinitionException("Attribute " + node.getNodeName()
+ " can only be used on a <reference>, <reference-list> or <service> element");
}
throw new ComponentDefinitionException("Unsupported attribute: " + node.getNodeName());
} else {
throw new ComponentDefinitionException("Unsupported node type: " + node);
}
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:OpendaylightNamespaceHandler.java
示例9: enableComponentProcessorProperty
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
private static ComponentMetadata enableComponentProcessorProperty(final Attr attr,
final ComponentMetadata component, final ParserContext context, final String propertyName) {
if (component != null) {
throw new ComponentDefinitionException("Attribute " + attr.getNodeName()
+ " can only be used on the root <blueprint> element");
}
LOG.debug("{}: {}", propertyName, attr.getValue());
if (!Boolean.parseBoolean(attr.getValue())) {
return component;
}
MutableBeanMetadata metadata = registerComponentProcessor(context);
metadata.addProperty(propertyName, createValue(context, "true"));
return component;
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:OpendaylightNamespaceHandler.java
示例10: lookupPropertyPlaceholderIds
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
/**
* Lookup the ids of the Blueprint property placeholder services in the
* Blueprint container.
*
* @return the ids, will be an empty array if none found.
*/
public String[] lookupPropertyPlaceholderIds() {
List<String> ids = new ArrayList<String>();
for (Object componentId : container.getComponentIds()) {
String id = (String) componentId;
ComponentMetadata meta = container.getComponentMetadata(id);
if (meta instanceof ExtendedBeanMetadata) {
Class<?> clazz = ((ExtendedBeanMetadata) meta).getRuntimeClass();
if (clazz != null && AbstractPropertyPlaceholder.class.isAssignableFrom(clazz)) {
ids.add(id);
}
}
}
return ids.toArray(new String[ids.size()]);
}
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:BlueprintPropertiesParser.java
示例11: lookupBlueprintCamelContext
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
/**
* Lookup all the {@link BlueprintCamelContext} in the {@link BlueprintContainer}.
*
* @param container the blueprint container, must be provided
* @return a set with the ids of the {@link BlueprintCamelContext}, never <tt>null</tt>, but can be empty set.
*/
public static Set<String> lookupBlueprintCamelContext(BlueprintContainer container) {
Set<String> ids = new LinkedHashSet<String>();
for (Object id : container.getComponentIds()) {
ComponentMetadata meta = container.getComponentMetadata(id.toString());
// must be extended meta, to see if its the blueprint camel context
if (meta instanceof ExtendedBeanMetadata) {
Class<?> clazz = ((ExtendedBeanMetadata) meta).getRuntimeClass();
if (clazz != null && BlueprintCamelContext.class.isAssignableFrom(clazz)) {
// okay we found a BlueprintCamelContext
ids.add(meta.getId());
}
}
}
return ids;
}
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:BlueprintCamelContextLookupHelper.java
示例12: getServiceRef
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
private MutableRefMetadata getServiceRef(ComponentDefinitionRegistry cdr, String unitName, Class<?> iface) {
ComponentMetadata serviceRef = cdr.getComponentDefinition(getId(unitName, iface));
if (serviceRef == null) {
serviceRef = createJPAServiceRef(unitName, iface);
cdr.registerComponentDefinition(serviceRef);
}
MutableRefMetadata ref = pc.createMetadata(MutableRefMetadata.class);
ref.setComponentId(serviceRef.getId());
return ref;
}
开发者ID:apache,项目名称:aries-jpa,代码行数:11,代码来源:JpaComponentProcessor.java
示例13: createServiceRef
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
private ComponentMetadata createServiceRef(String id, Class<?> iface) {
final MutableReferenceMetadata refMeta = pc.createMetadata(MutableReferenceMetadata.class);
refMeta.setActivation(getDefaultActivation(pc));
refMeta.setAvailability(ReferenceMetadata.AVAILABILITY_MANDATORY);
refMeta.setRuntimeInterface(iface);
refMeta.setTimeout(Integer.parseInt(pc.getDefaultTimeout()));
List<String> emptyList = Collections.emptyList();
refMeta.setDependsOn(emptyList);
refMeta.setId(id);
return refMeta;
}
开发者ID:apache,项目名称:aries-jpa,代码行数:12,代码来源:JpaComponentProcessor.java
示例14: createJPAServiceRef
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
private ComponentMetadata createJPAServiceRef(String unitName, Class<?> iface) {
final MutableReferenceMetadata refMeta = pc.createMetadata(MutableReferenceMetadata.class);
refMeta.setActivation(getDefaultActivation(pc));
refMeta.setAvailability(ReferenceMetadata.AVAILABILITY_MANDATORY);
refMeta.setRuntimeInterface(iface);
refMeta.setFilter(String.format("(%s=%s)", JPA_UNIT_NAME, unitName));
refMeta.setTimeout(Integer.parseInt(pc.getDefaultTimeout()));
List<String> emptyList = Collections.emptyList();
refMeta.setDependsOn(emptyList);
refMeta.setId(getId(unitName, iface));
return refMeta;
}
开发者ID:apache,项目名称:aries-jpa,代码行数:13,代码来源:JpaComponentProcessor.java
示例15: postCallWithException
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
@Override
public void postCallWithException(ComponentMetadata cm, Method m, Throwable ex, Object preCallToken) {
LOG.debug("PostCallWithException for bean {}, method {}", cm.getId(), m.getName(), ex);
if (preCallToken != null) {
((Coordination)preCallToken).fail(ex);
}
}
开发者ID:apache,项目名称:aries-jpa,代码行数:8,代码来源:JpaInterceptor.java
示例16: postCallWithReturn
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
@Override
public void postCallWithReturn(ComponentMetadata cm, Method m, Object returnType, Object preCallToken)
throws Exception {
LOG.debug("PostCallWithReturn for bean {}, method {}", cm.getId(), m.getName());
if (preCallToken != null) {
((Coordination)preCallToken).end();
}
}
开发者ID:apache,项目名称:aries-jpa,代码行数:9,代码来源:JpaInterceptor.java
示例17: decorate
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
@Override
public ComponentMetadata decorate(Node node, ComponentMetadata cm, ParserContext pc) {
if (node instanceof Element) {
parseElement((Element)node, pc);
}
return cm;
}
开发者ID:apache,项目名称:aries-jpa,代码行数:8,代码来源:JpaNsHandler.java
示例18: run
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
@Override
public void run() {
ComponentMetadata cm = new ComponentMetadata() {
@Override
public String getId() {
return "testMetadata";
}
@Override
public List<String> getDependsOn() {
return null;
}
@Override
public int getActivation() {
return 0;
}
};
Method m;
try {
m = this.getClass().getMethod("run", null);
interceptor.preCall(cm, m, null);
} catch (Throwable e) {
synchronized (result) {
result.set(false);
}
} finally {
synchronized (result) {
result.notifyAll();
}
}
}
开发者ID:apache,项目名称:aries-jpa,代码行数:34,代码来源:JpaInterceptorTest.java
示例19: buildMetadata
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
/**
* Builds a component metadata from the given bean definition.
*
* @param name bean name
* @param beanDefinition
* @return
*/
static ComponentMetadata buildMetadata(String name, BeanDefinition beanDefinition) {
// shortcut (to avoid re-re-wrapping)
Object metadata = beanDefinition.getAttribute(COMPONENT_METADATA_ATTRIBUTE);
if (metadata instanceof ComponentMetadata)
return (ComponentMetadata) metadata;
// if no name has been given, look for one
if (name == null) {
name = (String) beanDefinition.getAttribute(COMPONENT_NAME);
}
if (isServiceExporter(beanDefinition)) {
return new SimpleServiceExportComponentMetadata(name, beanDefinition);
}
if (isSingleServiceImporter(beanDefinition)) {
return new SimpleReferenceMetadata(name, beanDefinition);
}
if (isCollectionImporter(beanDefinition)) {
return new SimpleReferenceListMetadata(name, beanDefinition);
}
BeanDefinition original = unwrapImporterReference(beanDefinition);
if (original != null) {
return buildMetadata(null, original);
}
if (isEnvironmentManager(beanDefinition)) {
return new EnvironmentManagerMetadata(name);
}
return new SimpleBeanMetadata(name, beanDefinition);
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:41,代码来源:ComponentMetadataFactory.java
示例20: buildNestedMetadata
import org.osgi.service.blueprint.reflect.ComponentMetadata; //导入依赖的package包/类
static Collection<ComponentMetadata> buildNestedMetadata(BeanDefinition beanDefinition) {
List<ComponentMetadata> col = new ArrayList<ComponentMetadata>(4);
processBeanDefinition(beanDefinition, col);
// remove the first definition
col.remove(0);
return col;
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:8,代码来源:ComponentMetadataFactory.java
注:本文中的org.osgi.service.blueprint.reflect.ComponentMetadata类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论