本文整理汇总了Java中org.osgi.service.blueprint.container.ComponentDefinitionException类的典型用法代码示例。如果您正苦于以下问题:Java ComponentDefinitionException类的具体用法?Java ComponentDefinitionException怎么用?Java ComponentDefinitionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComponentDefinitionException类属于org.osgi.service.blueprint.container包,在下文中一共展示了ComponentDefinitionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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());
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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());
}
}
示例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);
}