private static String[] extractEmails(MailMessage message, String headerField) {
   String[] adresses = StringHelper.split(message.getFirstHeaderValue(headerField), ",");
   if (adresses != null) {
     for (int i = 0; i < adresses.length; i++) {
       adresses[i] = adresses[i].trim();
     }
   }
   return adresses;
 }
  /*
   * (non-Javadoc)
   * @see org.kaleidofoundry.core.context.Provider#_provides(org.kaleidofoundry.core.context.RuntimeContext)
   */
  @Override
  public MyServiceInterface _provides(final RuntimeContext<MyServiceInterface> context)
      throws ProviderException {

    final Set<Plugin<MyServiceInterface>> pluginImpls =
        PluginFactory.getImplementationRegistry().findByInterface(MyServiceInterface.class);
    final String contextPluginCode = context.getString("pluginCode");

    if (StringHelper.isEmpty(contextPluginCode)) {
      throw new EmptyContextParameterException("pluginCode", context);
    }

    // scan each @Declare MyServiceInterface implementation, to get one which match the context
    // plugin code
    for (final Plugin<MyServiceInterface> pi : pluginImpls) {
      final Class<? extends MyServiceInterface> impl = pi.getAnnotatedClass();
      try {
        final Declare declarePlugin = impl.getAnnotation(Declare.class);
        if (declarePlugin.value().equalsIgnoreCase(contextPluginCode)) {
          final Constructor<? extends MyServiceInterface> constructor = impl.getConstructor();
          return constructor.newInstance();
        }
      } catch (final NoSuchMethodException e) {
        throw new ProviderException(
            "context.provider.error.NoSuchConstructorException", impl.getName(), "");
      } catch (final InstantiationException e) {
        throw new ProviderException(
            "context.provider.error.InstantiationException", impl.getName(), e.getMessage());
      } catch (final IllegalAccessException e) {
        throw new ProviderException(
            "context.provider.error.IllegalAccessException", impl.getName(), "");
      } catch (final InvocationTargetException e) {
        throw new ProviderException(
            "context.provider.error.InvocationTargetException",
            impl.getName(),
            "",
            e.getCause().getClass().getName(),
            e.getMessage());
      }
    }

    throw new IllegalStateException(
        "can't found a declare plugin with plugin code : " + contextPluginCode);
  }
  @Produces
  public Configuration getConfiguration(final InjectionPoint injectionPoint) {

    Context context;
    String defaultName;

    // try CDI bean name
    defaultName = injectionPoint.getBean() != null ? injectionPoint.getBean().getName() : null;

    // try field / method name
    if (StringHelper.isEmpty(defaultName)) {
      defaultName = injectionPoint.getMember().getName();
    }

    // context needed annotation
    context = injectionPoint.getAnnotated().getAnnotation(Context.class);

    // if no @Context annotation is present, create a default one with no name
    if (context == null) {
      context = ContextHelper.createContext(defaultName);
    }

    return provides(context, defaultName, Configuration.class);
  }