Hi Folks,

When going through the SynapseConfiguration class I noticed some minor
design issues in the code. For instance some of the add methods in the class
(eg: addProxyService, addStartup) do not guarantee that adding a new item
does not overwirte any existing item. Let's take the addProxyService method
for example.

public void addProxyService(String name, ProxyService proxy) {
        proxyServices.put(name, proxy);
}

If we call this method with two ProxyService objects having the same name
the second service object will overwrite the first one. It seems that
SynapseConfiguration class relies on higher layers to take care of such
issues. As a result in classes like SynapseXMLConfigurationFactory we need
to do this.

if (config.getProxyService(proxy.getName()) != null) {
        handleException("Duplicate proxy service with name : " +
proxy.getName());
}
config.addProxyService(proxy.getName(), proxy);

IMHO such validation should take place at the lowest level, ie at the
SynapseConfiguration class itself. Higher levels shouldn't have to dig into
the existing configuration before trying to add a new item. It should just
add the item and the lower level should perform the necessary validation and
throw an exception in case of an error.

Secondly I have acome across some methods that are not used anywhere in the
code.

eg:
public void addSequence(String key, Entry entry)
public void addEndpoint(String key, Entry entry)

I think it's safe to get rid of these methods and simply the API. So what do
you folks think about carrying out the necessary refactoring operations to
fix these design issues? If you all agree I can spend some time on this.

Thanks
-- 
Hiranya Jayathilaka
Software Engineer;
WSO2 Inc.;  http://wso2.org
E-mail: [email protected];  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com

Reply via email to