I found another solution which suits me, writing here for others who might be facing the same problem.
Assume I want to plug in the new component named TestExtractorFactory
. Then we need to write two classes, one with an annotation @Configuration
and the component being a simple POJO (not a spring component).
Below are the two classes:
package com.test.extractor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class TestConfig {
@Bean(name="testExtractorFactory")
public TestExtractorFactory testExtractorFactory(){
return new TestExtractorFactory();
}
}
and here is the actual component:
package com.test.extractor;
public class TestExtractorFactory extends ExtractorFactory{
public TestExtractorFactory() {
super("TESTEX");
}
// write other methods you want and your framework requires.
}
Need not worry about what an ExtractorFactory
is. The new component is extended from an ExtractorFactory
How to make it enable for a @ComponentScan
we just need to add it in our web.xml
as below:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.framework.config.WebConfig,
com.test.extractor.TestConfig
</param-value>
</context-param>