'. '


From APIDesign

Jump to: navigation, search

Often one needs to provide similar, yet slightly different AlternativeBehaviors of the system. This page describes various levels on which such co-existence can take place.



Object level

One can configure two objects to have the same type (external interface), but slightly different behavior. The OSGi falls into this category. It is possible to have two running OSGi containers in the same virtual machine quite easily (as the API doesn't have any static getters).

Class level

The behavior is associated with class - e.g. in Java one needs to load the class by two different ClassLoaders to get different behavior. This way one can get multiple singletons.

The NetBeans Runtime Container falls into this category (NetBeans APIs expose a lot of static getters). This was an intentional decision. We never wanted to have more than one GUI application in the process.

Call level

Is it? Would be behavior that inspects stacktraces. Probably Java's security policy falls into the category.

Process level

The behavior is the same throughout the process. System.getProperty("...") or various singletons in core Java libraries (SecurityManager) are example of such APIs. One needs to start new virtual machine to get different behavior.

Computer level

Running two different HTTP servers on port 80 is possible only with two computers (ignore case of virtual hosts).

Cloud level

To achieve parallel behavior of a complex system (kenai.com, netbeans.org) is often possible only with duplicating all its network.

Personal tools