本文整理汇总了Java中org.osgi.service.blueprint.container.ComponentDefinitionException类的典型用法代码示例。如果您正苦于以下问题:Java ComponentDefinitionException类的具体用法?Java ComponentDefinitionException怎么用?Java ComponentDefinitionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComponentDefinitionException类属于org.osgi.service.blueprint.container包,在下文中一共展示了ComponentDefinitionException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
public static BindingContext create(final String logName, final Class<? extends DataObject> klass,
final String appConfigListKeyValue) {
if (Identifiable.class.isAssignableFrom(klass)) {
// The binding class corresponds to a yang list.
if (Strings.isNullOrEmpty(appConfigListKeyValue)) {
throw new ComponentDefinitionException(String.format(
"%s: App config binding class %s represents a yang list therefore \"%s\" must be specified",
logName, klass.getName(), DataStoreAppConfigMetadata.LIST_KEY_VALUE));
}
try {
return ListBindingContext.newInstance(klass, appConfigListKeyValue);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new ComponentDefinitionException(String.format(
"%s: Error initializing for app config list binding class %s",
logName, klass.getName()), e);
}
} else {
return new ContainerBindingContext(klass);
}
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:BindingContext.java
示例2: init
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void init(final ExtendedBlueprintContainer container) {
super.init(container);
Class<DataObject> appConfigBindingClass;
try {
Class<?> bindingClass = container.getBundleContext().getBundle().loadClass(appConfigBindingClassName);
if (!DataObject.class.isAssignableFrom(bindingClass)) {
throw new ComponentDefinitionException(String.format(
"%s: Specified app config binding class %s does not extend %s",
logName(), appConfigBindingClassName, DataObject.class.getName()));
}
appConfigBindingClass = (Class<DataObject>) bindingClass;
} catch (final ClassNotFoundException e) {
throw new ComponentDefinitionException(String.format("%s: Error loading app config binding class %s",
logName(), appConfigBindingClassName), e);
}
bindingContext = BindingContext.create(logName(), appConfigBindingClass, appConfigListKeyValue);
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:DataStoreAppConfigMetadata.java
示例3: init
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
@SuppressWarnings({ "checkstyle:IllegalCatch", "unchecked" })
@Override
public final void init(final ExtendedBlueprintContainer container) {
super.init(container);
final Class<?> interfaceClass;
try {
interfaceClass = container().getBundleContext().getBundle().loadClass(interfaceName);
} catch (final Exception e) {
throw new ComponentDefinitionException(String.format("%s: Error obtaining interface class %s",
logName(), interfaceName), e);
}
if (!RpcService.class.isAssignableFrom(interfaceClass)) {
throw new ComponentDefinitionException(String.format(
"%s: The specified interface %s is not an RpcService", logName(), interfaceName));
}
rpcInterface = (Class<RpcService>)interfaceClass;
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:AbstractInvokableServiceMetadata.java
示例4: create
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public final Object create() throws ComponentDefinitionException {
log.debug("{}: In create: interfaceName: {}", logName(), interfaceName);
super.onCreate();
try {
RpcService rpcService = rpcRegistry.getRpcService(rpcInterface);
log.debug("{}: create returning service {}", logName(), rpcService);
return rpcService;
} catch (final RuntimeException e) {
throw new ComponentDefinitionException("Error getting RPC service for " + interfaceName, e);
}
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:AbstractInvokableServiceMetadata.java
示例5: getRpcClass
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Class<RpcService> getRpcClass() {
final Class<?> iface;
try {
iface = bundle.loadClass(interfaceName);
} catch (final ClassNotFoundException e) {
throw new ComponentDefinitionException(String.format(
"The specified \"interface\" for %s \"%s\" does not refer to an available class", interfaceName,
ACTION_PROVIDER), e);
}
if (!RpcService.class.isAssignableFrom(iface)) {
throw new ComponentDefinitionException(String.format(
"The specified \"interface\" %s for \"%s\" is not an RpcService", interfaceName, ACTION_PROVIDER));
}
return (Class<RpcService>) iface;
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:ActionProviderBean.java
示例6: parse
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
@Override
public Metadata parse(final Element element, final ParserContext context) {
LOG.debug("In parse for {}", element);
if (nodeNameEquals(element, RpcImplementationBean.RPC_IMPLEMENTATION)) {
return parseRpcImplementation(element, context);
} else if (nodeNameEquals(element, RoutedRpcMetadata.ROUTED_RPC_IMPLEMENTATION)) {
return parseRoutedRpcImplementation(element, context);
} else if (nodeNameEquals(element, RPC_SERVICE)) {
return parseRpcService(element, context);
} else if (nodeNameEquals(element, NotificationListenerBean.NOTIFICATION_LISTENER)) {
return parseNotificationListener(element, context);
} else if (nodeNameEquals(element, CLUSTERED_APP_CONFIG)) {
return parseClusteredAppConfig(element, context);
} else if (nodeNameEquals(element, SPECIFIC_SERVICE_REF_LIST)) {
return parseSpecificReferenceList(element, context);
} else if (nodeNameEquals(element, STATIC_REFERENCE)) {
return parseStaticReference(element, context);
} else if (nodeNameEquals(element, ACTION_SERVICE)) {
return parseActionService(element, context);
} else if (nodeNameEquals(element, ActionProviderBean.ACTION_PROVIDER)) {
return parseActionProvider(element, context);
}
throw new ComponentDefinitionException("Unsupported standalone element: " + element.getNodeName());
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:27,代码来源:OpendaylightNamespaceHandler.java
示例7: decorate
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的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
示例8: enableComponentProcessorProperty
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的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
示例9: getComponentInstance
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
public Object getComponentInstance(String name) throws NoSuchComponentException {
if (getBeanFactory().containsBean(name)) {
try {
return getBeanFactory().getBean(name);
} catch (RuntimeException ex) {
throw new ComponentDefinitionException("Cannot get component instance " + name, ex);
}
} else {
throw new NoSuchComponentException(name);
}
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:12,代码来源:SpringBlueprintContainer.java
示例10: create
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
@Override
public Object create() throws ComponentDefinitionException {
super.onCreate();
LOG.debug("{}: create returning service {}", logName(), retrievedService);
return retrievedService;
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:9,代码来源:StaticReferenceMetadata.java
示例11: create
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
@Override
public Object create() throws ComponentDefinitionException {
LOG.debug("{}: In create: interfaceName: {}", logName(), interfaceName);
super.onCreate();
LOG.debug("{}: create returning service list {}", logName(), retrievedServices);
synchronized (retrievedServices) {
return ImmutableList.copyOf(retrievedServices);
}
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:13,代码来源:SpecificReferenceListMetadata.java
示例12: create
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
@Override
public Object create() throws ComponentDefinitionException {
LOG.debug("{}: In create - currentAppConfig: {}", logName(), currentAppConfig);
super.onCreate();
return currentAppConfig;
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:9,代码来源:DataStoreAppConfigMetadata.java
示例13: getImplementedRpcServiceInterfaces
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static List<Class<RpcService>> getImplementedRpcServiceInterfaces(final String interfaceName,
final Class<?> implementationClass, final Bundle bundle, final String logName)
throws ClassNotFoundException {
if (!Strings.isNullOrEmpty(interfaceName)) {
Class<?> rpcInterface = bundle.loadClass(interfaceName);
if (!rpcInterface.isAssignableFrom(implementationClass)) {
throw new ComponentDefinitionException(String.format(
"The specified \"interface\" %s for \"%s\" is not implemented by RpcService \"ref\" %s",
interfaceName, logName, implementationClass));
}
return Collections.singletonList((Class<RpcService>)rpcInterface);
}
List<Class<RpcService>> rpcInterfaces = new ArrayList<>();
for (Class<?> intface : implementationClass.getInterfaces()) {
if (RpcService.class.isAssignableFrom(intface)) {
rpcInterfaces.add((Class<RpcService>) intface);
}
}
if (rpcInterfaces.isEmpty()) {
throw new ComponentDefinitionException(String.format(
"The \"ref\" instance %s for \"%s\" does not implemented any RpcService interfaces",
implementationClass, logName));
}
return rpcInterfaces;
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:32,代码来源:RpcImplementationBean.java
示例14: onCreate
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
protected void onCreate() throws ComponentDefinitionException {
if (failureMessage != null) {
throw new ComponentDefinitionException(failureMessage, failureCause);
}
// The following code is a bit odd so requires some explanation. A little background... If a bean
// is a prototype then the corresponding Recipe create method does not register the bean as created
// with the BlueprintRepository and thus the destroy method isn't called on container destroy. We
// rely on destroy being called to close our DTCL registration. Unfortunately the default setting
// for the prototype flag in AbstractRecipe is true and the DependentComponentFactoryRecipe, which
// is created for DependentComponentFactoryMetadata types of which we are one, doesn't have a way for
// us to indicate the prototype state via our metadata.
//
// The ExecutionContext is actually backed by the BlueprintRepository so we access it here to call
// the removePartialObject method which removes any partially created instance, which does not apply
// in our case, and also has the side effect of registering our bean as created as if it wasn't a
// prototype. We also obtain our corresponding Recipe instance and clear the prototype flag. This
// doesn't look to be necessary but is done so for completeness. Better late than never. Note we have
// to do this here rather than in startTracking b/c the ExecutionContext is not available yet at that
// point.
//
// Now the stopTracking method is called on container destroy but startTracking/stopTracking can also
// be called multiple times during the container creation process for Satisfiable recipes as bean
// processors may modify the metadata which could affect how dependencies are satisfied. An example of
// this is with service references where the OSGi filter metadata can be modified by bean processors
// after the initial service dependency is satisfied. However we don't have any metadata that could
// be modified by a bean processor and we don't want to register/unregister our DTCL multiple times
// so we only process startTracking once and close the DTCL registration once on container destroy.
ExecutionContext executionContext = ExecutionContext.Holder.getContext();
executionContext.removePartialObject(id);
Recipe myRecipe = executionContext.getRecipe(id);
if (myRecipe instanceof AbstractRecipe) {
log.debug("{}: setPrototype to false", logName());
((AbstractRecipe)myRecipe).setPrototype(false);
} else {
log.warn("{}: Recipe is null or not an AbstractRecipe", logName());
}
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:40,代码来源:AbstractDependentComponentFactoryMetadata.java
示例15: registerImplementation
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
private void registerImplementation(final Class<RpcService> interfaceClass) {
if (!interfaceClass.isInstance(implementation)) {
throw new ComponentDefinitionException(String.format(
"The specified \"interface\" %s for \"%s\" is not implemented by RpcService \"ref\" %s",
interfaceName, ACTION_PROVIDER, implementation.getClass()));
}
reg = rpcRegistry.addRpcImplementation(interfaceClass, implementation);
LOG.debug("Registered implementation {} for {}", implementation, interfaceName);
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:ActionProviderBean.java
示例16: decorateServiceType
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
private static ComponentMetadata decorateServiceType(final Attr attr, final ComponentMetadata component,
final ParserContext context) {
if (!(component instanceof MutableServiceMetadata)) {
throw new ComponentDefinitionException("Expected an instanceof MutableServiceMetadata");
}
MutableServiceMetadata service = (MutableServiceMetadata)component;
LOG.debug("decorateServiceType for {} - adding type property {}", service.getId(), attr.getValue());
service.addServiceProperty(createValue(context, TYPE_ATTR), createValue(context, attr.getValue()));
return component;
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:OpendaylightNamespaceHandler.java
示例17: decorateServiceReferenceType
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
private static ComponentMetadata decorateServiceReferenceType(final Attr attr, final ComponentMetadata component,
final ParserContext context) {
if (!(component instanceof MutableServiceReferenceMetadata)) {
throw new ComponentDefinitionException("Expected an instanceof MutableServiceReferenceMetadata");
}
// We don't actually need the ComponentProcessor for augmenting the OSGi filter here but we create it
// to workaround an issue in Aries where it doesn't use the extended filter unless there's a
// Processor or ComponentDefinitionRegistryProcessor registered. This may actually be working as
// designed in Aries b/c the extended filter was really added to allow the OSGi filter to be
// substituted by a variable via the "cm:property-placeholder" processor. If so, it's a bit funky
// but as long as there's at least one processor registered, it correctly uses the extended filter.
registerComponentProcessor(context);
MutableServiceReferenceMetadata serviceRef = (MutableServiceReferenceMetadata)component;
String oldFilter = serviceRef.getExtendedFilter() == null ? null :
serviceRef.getExtendedFilter().getStringValue();
String filter;
if (Strings.isNullOrEmpty(oldFilter)) {
filter = String.format("(type=%s)", attr.getValue());
} else {
filter = String.format("(&(%s)(type=%s))", oldFilter, attr.getValue());
}
LOG.debug("decorateServiceReferenceType for {} with type {}, old filter: {}, new filter: {}",
serviceRef.getId(), attr.getValue(), oldFilter, filter);
serviceRef.setExtendedFilter(createValue(context, filter));
return component;
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:32,代码来源:OpendaylightNamespaceHandler.java
示例18: parseXML
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
private static Element parseXML(final String name, final String xml) {
try {
return UntrustedXML.newDocumentBuilder().parse(new InputSource(new StringReader(xml))).getDocumentElement();
} catch (SAXException | IOException e) {
throw new ComponentDefinitionException(String.format("Error %s parsing XML: %s", name, xml), e);
}
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:OpendaylightNamespaceHandler.java
示例19: parseRestContextNode
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
private Metadata parseRestContextNode(Element element, ParserContext context) {
LOG.trace("Parsing RestContext {}", element);
// now parse the rests with JAXB
Binder<Node> binder;
try {
binder = getJaxbContext().createBinder();
} catch (JAXBException e) {
throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
}
Object value = parseUsingJaxb(element, context, binder);
if (!(value instanceof CamelRestContextFactoryBean)) {
throw new ComponentDefinitionException("Expected an instance of " + CamelRestContextFactoryBean.class);
}
CamelRestContextFactoryBean rcfb = (CamelRestContextFactoryBean) value;
String id = rcfb.getId();
MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
factory.setId(".camelBlueprint.passThrough." + id);
factory.setObject(new PassThroughCallable<Object>(rcfb));
MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
factory2.setId(".camelBlueprint.factory." + id);
factory2.setFactoryComponent(factory);
factory2.setFactoryMethod("call");
MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
ctx.setId(id);
ctx.setRuntimeClass(List.class);
ctx.setFactoryComponent(factory2);
ctx.setFactoryMethod("getRests");
// must be lazy as we want CamelContext to be activated first
ctx.setActivation(ACTIVATION_LAZY);
// lets inject the namespaces into any namespace aware POJOs
injectNamespaces(element, binder);
LOG.trace("Parsing RestContext done, returning {}", element, ctx);
return ctx;
}
开发者ID:HydAu,项目名称:Camel,代码行数:41,代码来源:CamelNamespaceHandler.java
示例20: parseEndpointNode
import org.osgi.service.blueprint.container.ComponentDefinitionException; //导入依赖的package包/类
private Metadata parseEndpointNode(Element element, ParserContext context) {
LOG.trace("Parsing Endpoint {}", element);
// now parse the rests with JAXB
Binder<Node> binder;
try {
binder = getJaxbContext().createBinder();
} catch (JAXBException e) {
throw new ComponentDefinitionException("Failed to create the JAXB binder : " + e, e);
}
Object value = parseUsingJaxb(element, context, binder);
if (!(value instanceof CamelEndpointFactoryBean)) {
throw new ComponentDefinitionException("Expected an instance of " + CamelEndpointFactoryBean.class);
}
CamelEndpointFactoryBean rcfb = (CamelEndpointFactoryBean) value;
String id = rcfb.getId();
MutablePassThroughMetadata factory = context.createMetadata(MutablePassThroughMetadata.class);
factory.setId(".camelBlueprint.passThrough." + id);
factory.setObject(new PassThroughCallable<Object>(rcfb));
MutableBeanMetadata factory2 = context.createMetadata(MutableBeanMetadata.class);
factory2.setId(".camelBlueprint.factory." + id);
factory2.setFactoryComponent(factory);
factory2.setFactoryMethod("call");
factory2.setInitMethod("afterPropertiesSet");
factory2.setDestroyMethod("destroy");
factory2.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
MutableBeanMetadata ctx = context.createMetadata(MutableBeanMetadata.class);
ctx.setId(id);
ctx.setRuntimeClass(Endpoint.class);
ctx.setFactoryComponent(factory2);
ctx.setFactoryMethod("getObject");
// must be lazy as we want CamelContext to be activated first
ctx.setActivation(ACTIVATION_LAZY);
LOG.trace("Parsing endpoint done, returning {}", element, ctx);
return ctx;
}
开发者ID:HydAu,项目名称:Camel,代码行数:41,代码来源:CamelNamespaceHandler.java
注:本文中的org.osgi.service.blueprint.container.ComponentDefinitionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论