geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dondi Imperial <dimper...@exist.com>
Subject Re: [jira] Commented: (GERONIMO-680) New users "buy-in" hampered by inability to automatically rebuild sub-assemblies at runtime
Date Tue, 21 Jun 2005 01:49:14 GMT
Sing Li (JIRA) wrote:

>    [ http://issues.apache.org/jira/browse/GERONIMO-680?page=comments#action_12314022
] 
>
>Sing Li commented on GERONIMO-680:
>----------------------------------
>
>Thanks for the patch. The thought of being able to 
>eventually write GBeans entirely in a scripting 
>language is eerie; just picturing a REXX
>script with an EJB fascade right now... hmmm...
>  
>
I was thinking more along the lines of creating a property file like 
syntax for configuring GBeans, at startup (sort of), via a scripting 
engine. Here is one way this could work. A 'scripting' GBean is added to 
geronimo. This GBean takes a Properties (or a List if possible) object 
as an attribute. This object contains a list of all the files that are 
to be executed by the embedded interpreted on startup. Now say that the 
scripting language that is used supports operator overloading and that 
the GBean also takes a 'library' file that is to be 'included' in all 
the startup scripts. Say this script contains an object named 'getGBean' 
that takes a GBean name as its argument and overloads the 'dot' operator 
so that it calls kernel.setAttribute(...) on the gbean and it's 
property.  In Jython those files would look something like this (note 
that this does not yet handle the case where the GBean we want to 
configure is not running/loaded):

-------- header.py - Library (magic header fle)  ---------
sys.add_package("org.apache.geronimo.kernel")
sys.add_package("org.apache.geronimo.gbean")
sys.add_package("javax.management")
from org.apache.geronimo.kernel import KernelRegistry
from javax.management import ObjectName

class getGBean:
    def __init__(self, gbname):
        self.gBeanName = ObjectName(gbname)
    def __setattr__(self,name,value):
        if name != 'gBeanName':
            kernel = KernelRegistry.getSingleKernel()
            kernel.setAttribute(self.gBeanName,name,value)
        else:
            self.__dict__[name]=value
-----------------------------------------------


-------- Configuration file possibly one (or more)  for each 
configurable module (header.py is injected into this file by the 
interpreter GBean) ----
obj = getGBean('complete gbean name here'')
obj.someNumericAttribute = 10
obj.someStringAttribute = 'value'
....
-------------------------------------------------------------------------------------------------------------

The only difference from a regular properties file is the line with the 
getGBean call..

I'll admit that this is indeed kludgy because it sets the attributes of 
the GBean after they have been started where ideally you would want the 
GBeans to start with their configured attributes. Add to that the fact 
that there are some attributes that might require that the GBean be 
re-started in order to have the desired effect (ie. the JettyConnector 
and its port attribute). On the other hand, if module developers provide 
'config files' in this format and add them to the list attribute of the 
scripting gbean these can be packaged with the binary distribuition. 
Users can then modify these files as they wish, restart geronimo and 
have the changes take effect. No source download or compilation and no 
need to look and edit at XML files.

HTH,

-- 
Dondi Imperial
Software Engineer
Exist Software Labs
Penthouse I, Prestige Tower,
F. Ortigas Jr. Ave. (formerly Emerald Ave.),
Ortigas Center, Pasig City 1605
Philippines 
+632.687.7653
www.exist.com


Mime
View raw message