I have a web app, in the startup a servlet creates various instances of the same 'Product', Gateway, with different configuration settings defined. Here is a small description.

Gateway: abstract class defines different types of gateways.

MessageParser: Interface, Every type of Gateway has its own parsers, process and returns a specific Message.

Mesage: an interface which has a method returning String getMessage(), all beans implement this message, and is serializable.

Listener: each type of gateway will register a listener of its own to process the incoming data.

GatewaySettings: all info the gateway needs how, when and where to connect, port etc.

GatewayBuilder produces the gateway product using the settings, Gateway buildGateway(), setting all appropriate implementations of its properties? what methods go into this, should it have setters for making it immutable?

Do the builder patter do the work or any other pattern? if builder pattern can be used where do the director of the pattern comes in this situation?

Post me if more info required!

Thanks, V.

有帮助吗?

解决方案

This stackoverflow discussion may be a really valuable resource. The appropriate use case for Builder pattern is when we need to construct an immutable instance of class throughout its life, so the Builder class creates the immutable instance. Builder itself is mutable and use & discard kind of an object.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top