Пример #1
0
 private BindingProcessor getBindingProcessor(final Class<Object> implementationClass) {
   for (final BindingProcessor processor : processors) {
     if (processor.handles(implementationClass)) {
       return processor;
     }
   }
   return null;
 }
Пример #2
0
 private void registerFunction(final BeanEntry<Annotation, Object> beanEntry) {
   final Class<Object> implementationClass = beanEntry.getImplementationClass();
   final BindingProcessor processor = getBindingProcessor(implementationClass);
   if (processor != null) {
     final FunctionDescriptor descriptor = processor.process(beanEntry);
     final Properties commandProperties = new Properties();
     commandProperties.setProperty("osgi.command.scope", descriptor.getScope());
     commandProperties.setProperty("osgi.command.function", descriptor.getName());
     commandProperties.setProperty("implementationClass", implementationClass.getName());
     final BundleContext commandBundleContext = bundleContextOfCommand(implementationClass);
     if (commandBundleContext != null) {
       final ServiceRegistration serviceRegistration =
           commandBundleContext.registerService(
               new String[] {Function.class.getName(), CompletableFunction.class.getName()},
               descriptor.getFunction(),
               commandProperties);
       commands.put(
           beanEntry,
           new Holder(descriptor.getScope(), descriptor.getName(), serviceRegistration));
     }
     logger.debug(
         "Registered command '{}' in scope '{}'", descriptor.getName(), descriptor.getScope());
   }
 }