Search in sources :

Example 1 with Processor

use of org.openksavi.sponge.Processor in project sponge by softelnet.

the class DefaultProcessorManager method createAdapter.

protected BaseProcessorAdapter createAdapter(ProcessorInstanceHolder instanceHolder, ProcessorType requiredType) {
    Processor processor = instanceHolder.getProcessor();
    Validate.isInstanceOf(ProcessorAdapterFactory.class, processor, "Processor must implement %s", ProcessorAdapterFactory.class);
    ProcessorAdapter adapter = ((ProcessorAdapterFactory) processor).createAdapter();
    Validate.isInstanceOf(BaseProcessorAdapter.class, adapter, "Processor adapter must extend %s", BaseProcessorAdapter.class);
    BaseProcessorAdapter result = (BaseProcessorAdapter) adapter;
    result.getDefinition().setJavaDefined(instanceHolder.isJavaDefined());
    result.getDefinition().setProcessorClass(processor.getClass());
    if (requiredType != null) {
        Validate.isTrue(adapter.getType() == requiredType, "% is % but should be %", adapter.getName(), adapter.getType().getDisplayName(), requiredType.getDisplayName());
    }
    return result;
}
Also used : Processor(org.openksavi.sponge.Processor) BaseProcessorAdapter(org.openksavi.sponge.core.BaseProcessorAdapter) ProcessorAdapter(org.openksavi.sponge.ProcessorAdapter) BaseProcessorAdapter(org.openksavi.sponge.core.BaseProcessorAdapter) ProcessorAdapterFactory(org.openksavi.sponge.ProcessorAdapterFactory)

Example 2 with Processor

use of org.openksavi.sponge.Processor in project sponge by softelnet.

the class DefaultProcessorManager method initializeProcessor.

protected void initializeProcessor(ProcessorInstanceHolder instanceHolder, BaseProcessorAdapter adapter) {
    Processor processor = instanceHolder.getProcessor();
    processor.onConfigure();
    // Must be verified after onConfigure, because onConfigure may change for example the name of the processor.
    Optional<Map.Entry<ProcessorType, RegistrationHandler>> alreadyRegistered = findAlreadyRegisteredByDifferentType(adapter);
    if (alreadyRegistered.isPresent()) {
        Validate.isTrue(false, "% named '%' has already been registered as % type", adapter.getType().getDisplayName(), adapter.getName(), alreadyRegistered.get().getKey().getDisplayName());
    }
    processor.getAdapter().validate();
    if (processor.getAdapter().getDefinition().isSingleton()) {
        processor.onInit();
    }
}
Also used : Processor(org.openksavi.sponge.Processor)

Aggregations

Processor (org.openksavi.sponge.Processor)2 ProcessorAdapter (org.openksavi.sponge.ProcessorAdapter)1 ProcessorAdapterFactory (org.openksavi.sponge.ProcessorAdapterFactory)1 BaseProcessorAdapter (org.openksavi.sponge.core.BaseProcessorAdapter)1