把ComponentMetadata转换成具体的对象

org.osgi.service.blueprint.reflect.ComponentMetadata 只是一个组件的引用,如何转换成具体的对象呢?

代码如下


import org.apache.aries.blueprint.ParserContext;
import org.apache.aries.blueprint.PassThroughMetadata;
import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.reflect.ComponentMetadata;

public class Test
{
	private ExtendedBlueprintContainer getBlueprintContainer(final ParserContext context)
	{
		ComponentMetadata cm = context.getComponentDefinitionRegistry().getComponentDefinition("blueprintContainer");
		
		PassThroughMetadata ptm = (PassThroughMetadata)cm;
		
		return (ExtendedBlueprintContainer)ptm.getObject();
	}
	
	public static void main(String[] args)
	{
		BlueprintContainer blueprintContainer = new Test().getBlueprintContainer(null);
		///
	}
}


你可能感兴趣的:(osgi,aries)