Implement plugin provider in the core component

Introduction

The plugin framework can be extend with plugin providers which provides plugins access to different forms of data at runtime.

Overview

Follow these steps to implement a plugin provider:

  1. Define a interface for the plugin provider in the pineapple-api project. Example: com.alpha.pineapple.execution.ExecutionInfoProvider.
  2. Implement the plugin provider interface in the pineapple-core project. Example: com.alpha.pineapple.execution.ExecutionInfoProviderImpl:
    1. public class ExecutionInfoProviderImpl implements ExecutionInfoProvider {
    2. public ExecutionInfo get(ExecutionResult result) {
    3. // TODO Auto-generated method stub
    4. return null;
    5. }
    6. }
  3. Add a bean definition of the provider to the core component application context , e.g. com.alpha.pineapple.core-config.xml Example:
    1. <!-- define execution info provider -->
    2. <bean id="executionInfoProviderImpl" class="com.alpha.pineapple.execution.ExecutionInfoProviderImpl" />
  4. Define a field in the PluginInitializerImpl class with a @Resource annotation to have the provider injected to the initializer at runtime. Example:
    1. /**
    2. * Execution info provider.
    3. */
    4. @Resource
    5. ExecutionInfoProvider executionInfoProvider;
  5. Implement a new Spring bean definition in the PluginInitializerImpl.addProvidersToContext(..) method to add the provider to plugin application contexts. Example:
    1. // register execution info provider
    2. factory.registerSingleton(EXECUTION_INFO_PROVIDER_BEANID, executionInfoProvider);

    The result is that the same provider instance which is used by the core compoent is injected into all plugin contexts.