Co-existence
From APIDesign
(→Object level) |
(→Class level) |
||
Line 10: | Line 10: | ||
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 [[singleton]]s. | 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 [[singleton]]s. | ||
+ | |||
+ | The [[NetBeans Runtime Container]] falls into this category ([[NetBeans]] [[API]]s 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 == | == Call level == |
Revision as of 09:04, 25 January 2010
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.
TBD.
Contents |
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, netbeains.org) is often possible only with duplicating all its network.