AwsEventWrapperFactory depends on EventWrapperMapping instance.
Its behaviors are changed by the AwsEventWrapperFactoryConfigurer instance that configures an EventWrapperMapping instance.
This means AwsEventWrapperFactory relies on dynamic dependencies. However it has two static factory methods, one of which creates a AwsEventWrapper, the other creates a customized AwsEventWrapperFactory. This is why it has a strange interface for creating customized instances.
var eventWapper = AwsEventWrapperFactory.getWrapper(snsEvent);
var customFactory = AwsEventWrapperFactory.create(configurer);
var eventWrapper2 = customFactory.getWrapper(snsEvent);
Line 1 and 3 create AwsEventWrappers.
Besides, Line 2 creates AwsEventWrapperFactory.
This is not a comprehensive interface.
To-be:
Add a static factory method to create the default AwsEventWrapperFactory instance: getDefault().
Add a static factory method to create custom AwsEventWrapperFactory instances: newInstance().
Add a private constructor: AwsEventWrapperFactory(AwsEventWrapperFactoryConfigurer).
Remove the static getWrapper() method. Make it non-static.
As-is:
AwsEventWrapperFactory
depends onEventWrapperMapping
instance.AwsEventWrapperFactoryConfigurer
instance that configures anEventWrapperMapping
instance.AwsEventWrapperFactory
relies on dynamic dependencies. However it has two static factory methods, one of which creates aAwsEventWrapper
, the other creates a customizedAwsEventWrapperFactory
. This is why it has a strange interface for creating customized instances.AwsEventWrapper
s.AwsEventWrapperFactory
.To-be:
AwsEventWrapperFactory
instance:getDefault()
.AwsEventWrapperFactory
instances:newInstance()
.AwsEventWrapperFactory(AwsEventWrapperFactoryConfigurer)
.getWrapper()
method. Make it non-static.