|
From: Thomas R. <tho...@tr...> - 2004-04-04 20:34:59
|
I have bee experimenting a bit with Jython. I have not used it for a
while, so I'm a bit rusty, but I did load an application context and
used a data source been that was defined in it.
I think that the different types of bean factories are going to have
different feature sets - property files are less feature rich than the
xml files. With jython and groovy, we will have similar issues where
some features just does not fit naturally.
Here is my context (applicationContext.py):
from org.springframework.jdbc.datasource import DriverManagerDataSource
from org.springframework.jdbc.core import JdbcTemplate
dataSource = DriverManagerDataSource()
dataSource.driverClassName="org.hsqldb.jdbcDriver"
dataSource.url="jdbc:hsqldb:hsql://localhost"
dataSource.username="sa"
dataSource.password=""
db = JdbcTemplate(dataSource)
Here is my code (LoadPyContext.java:
import java.util.List;
import org.python.core.PySystemState;
import org.python.util.PythonInterpreter;
import org.springframework.jdbc.core.JdbcTemplate;
public class LoadPyContext {
public static void main(String[] args) {
System.out.println("Start");
PySystemState.initialize();
PythonInterpreter pyInterp = new PythonInterpreter();
pyInterp.execfile("applicationContext.py");
JdbcTemplate db = (JdbcTemplate) pyInterp.get("db",
JdbcTemplate.class);
List l = db.queryForList("select brand, price from beer");
System.out.println(l);
}
}
I guess the next step is to actually create a PythonBeanFactory.
Thomas
Alef Arendsen wrote:
>Err,
>
>Been able to get a beanfactory up-and-running, however, not in a way as
>elegant as I wanted it to be, but that's something that's probably going to
>take some more time and thinking. It's something like this, and I don't like
>it ;-)
>
>test = new BeanDef (age:8,name:'susan')
>test.singleton = true
>test.dependencyCheck = PRIMITIVES
>
>est = new BeanDef (age:10)
>est.name='jim'
>est.spouse=test
>est.singleton = false
>
>I'm not entirely sure how to go about the dependencies and properties of a
>bean versus the behavioral stuff (singleton, dependency checking, etcetera).
>For sure we need some extra stuff here (i.e. some kind of wrapper around the
>BeanDefinition class--the BeanDef class in the script above), I don't think
>dealing with MutablePropertyValue objects in a Groovy script directly is the
>way to go. But maybe you noticed the problem in the script above already:
>you can't have dependencies named 'singleton' or 'dependencyCheck' here. So
>maybe including some kind of metadata object might be an option.
>
>By the way, from my point of view, there's a difference between reading in
>and modifying a applicationcontext and its beandefinition and actually
>approaching/using it at runtime. Currently I'm only thinking about the
>former... Using it from Groovy scripts however could be quite something as
>well!
>
>Regards,
>Alef
>
>
>
>
>
>
>>-----Original Message-----
>>From: spr...@li...
>>[mailto:spr...@li...] On Behalf
>>Of Darren Davison
>>Sent: Saturday, April 03, 2004 1:01 PM
>>To: spr...@li...
>>Subject: [Springframework-developer] Groovy / Jython (was: Road map)
>>
>>On Saturday 03 April 2004 09:47, Alef Arendsen wrote:
>>
>>
>>
>>>It would be nice to have something in the sandbox indeed. I'm currently
>>>experimenting with a GroovyBeanDefinitionReader and it seems it's not
>>>going to be all that tough to get it running!
>>>
>>>
>>snap!
>>
>>I started looking at something similar in both Groovy and Jython (partly
>>to
>>see which of those two was 'best'). Thought it may be very useful for
>>writing tests or certain deployment scripts.
>>
>>How far have you got with it?
>>
>>--
>>
>>Darren Davison
>>Public Key: http://www.davison.uk.net/key.jsp
>>
>>
>>-------------------------------------------------------
>>This SF.Net email is sponsored by: IBM Linux Tutorials
>>Free Linux tutorial presented by Daniel Robbins, President and CEO of
>>GenToo technologies. Learn everything from fundamentals to system
>>administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
>>_______________________________________________
>>Springframework-developer mailing list
>>Spr...@li...
>>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>>
>>
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: IBM Linux Tutorials
>Free Linux tutorial presented by Daniel Robbins, President and CEO of
>GenToo technologies. Learn everything from fundamentals to system
>administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
>_______________________________________________
>Springframework-developer mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
>
>
>
|