Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: Smooks v1.4.2
-
Fix Version/s: None
-
Component/s: Smooks Core
-
Labels:None
-
Environment:Windows
Description
if you call Smooks.filterSource with a source that is a JavaBean, the beanmap that is passed in the execution context will contain the beans in the source. StandaloneBeanContextFactory.createBeanMap does the copy.
But if you add beans the execution context before calling filterSource, this does not occur because when you call
executionContext.getBeanContext(), there is no source set so nothing is copied into it.
Then when you execute the filter, the source bean is not available.
Example - This will have the bean
InputStream config = new FileInputStream(mappingConfigFile);
Smooks smooks = new Smooks(config);
ExecutionContext execContext = smooks.createExecutionContext();
Map<String,Object> mySource = new HashMap<String,Object>();
mySource.put("A", "123");
PayloadProcessor payloadProcessor = new PayloadProcessor( smooks, ResultType.STRING );
Object result = payloadProcessor.process(mySource, execContext);
This way it will not
InputStream config = new FileInputStream(mappingConfigFile);
Smooks smooks = new Smooks(config);
ExecutionContext execContext = smooks.createExecutionContext();
Map<String,Object> mySource = new HashMap<String,Object>();
mySource.put("A", "123");
// Executing this line caused the bean context to be created without the source
execContext.getBeanContext().addBean("AnotherBean", "234");
PayloadProcessor payloadProcessor = new PayloadProcessor( smooks, ResultType.STRING );
Object result = payloadProcessor.process(mySource, execContext);