Re: EnterpriseObjects in a regular Java application
Re: EnterpriseObjects in a regular Java application
- Subject: Re: EnterpriseObjects in a regular Java application
- From: John Lennard <email@hidden>
- Date: Tue, 31 Jan 2006 14:02:39 +1300
Hi,
I followed the stepwise article, but found that a few things in it
were no longer relevant or api's had changed.
This is how i got my editingContext etc.
<snip>
//gets a url for the model
modelUrl = new URL("file:holidaybook.eomodeld");
EOModel model = new EOModel(modelUrl);
EOModelGroup mg = EOModelGroup.defaultGroup();
mg.addModel( model );
//use lewo stuff to specify the db to connect to
LEEOHelper.setDBConnectionForNamedModel("file:holidaybook",
LEConfig.stringForKey(WTConstants.KEY_CONFIG_WT_MAIN_JDBCDRIVER),
LEConfig.stringForKey(WTConstants.KEY_CONFIG_WT_MAIN_JDBCURL),
LEConfig.stringForKey(WTConstants.KEY_CONFIG_WT_MAIN_JDBCUSERNAME),
LEConfig.stringForKey(WTConstants.KEY_CONFIG_WT_MAIN_JDBCPASSWD));
</snip>
and due to general laziness, this is how i created my editing context
as a class variable (i know, very lazy :-)
<snip>
protected static EOEditingContext ec = new EOEditingContext();
</snip>
with this, i used the lewostuff framework from http://
www.lindesay.co.nz to alter the connection properties of the model.
and this is the list of the jar files that are needed
<snip>
/System/Library/Frameworks/JavaEOControl.framework/Resources/Java/
javaeocontrol.jar
/System/Library/Frameworks/JavaFoundation.framework/Resources/Java/
javafoundation.jar
/System/Library/Frameworks/JavaEOAccess.framework/Resources/Java/
javaeoaccess.jar
/System/Library/Frameworks/JavaXML.framework/Resources/Java/javaxml.jar
/System/Library/Frameworks/JavaJDBCAdaptor.framework/Resources/Java/
javajdbcadaptor.jar
</snip>
I was then happy to run EOF stuff to my hearts content and avoid
those horrid Java collection classes too.
This example was used in a highly threaded application used to
process images and i didn't run into any problems other than those of
my own doing anyway.
The only gotchas are that you need to make sure that xcode has the
jars specified in the project in order to build, and then for
debugging/running you need to add
<snip>
-cp "EOFImageMunger.jar:/System/Library/Frameworks/
JavaEOControl.framework/Resources/Java/javaeocontrol.jar:/System/
Library/Frameworks/JavaFoundation.framework/Resources/Java/
javafoundation.jar:/System/Library/Frameworks/JavaEOAccess.framework/
Resources/Java/javaeoaccess.jar:/System/Library/Frameworks/
JavaXML.framework/Resources/Java/javaxml.jar:/Library/Frameworks/
LEWOStuff.framework/Resources/Java/lewostuff.jar:/System/Library/
Frameworks/JavaJDBCAdaptor.framework/Resources/Java/
javajdbcadaptor.jar:."
</snip>
as a run time argument to the java run target so that every thing can
be found, like wise, this needs to be specified if you are running
from a command line.
I can possibly provide a more complete example, but this should be
enough to get it all running, as it was surprisingly simple once the
class paths were correct.
regards
john.
On 30/01/2006, at 10:24 PM, Ruenagel, Frank wrote:
Hi,
there is a little bit outdated stepwise article about this issue:
http://www.stepwise.com/Articles/Technical/2001-07-01.01.html
It has helped me to create a java console app.
HTH
Frank
-----Original Message-----
From: webobjects-dev-bounces+webobjects=email@hidden
[mailto:webobjects-dev-bounces+webobjects=symposion.de@lists.a
pple.com]O
n Behalf Of John Huss
Sent: Friday, January 27, 2006 9:35 PM
To: email@hidden
Subject: EnterpriseObjects in a regular Java application
Is it possible to use my EnterpriseObjects classes and
EOModel in a regular
Java application without any web interface?
How do I get a connection to the database and get an editing context?
My ultimate goal is to write a little command-line program
that will import
text files into a database at scheduled times. If this is a
bad approach
I'm open to other ideas.
Thanks,
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40yakmoose.org.nz
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden