Awhile back I had a plain Java app that included EOF. In eclipse it's just a Java project with the following jars and a WO framework in the class path:
public class EOFSetup
{
private
static EOFSetup
setupHandler;
protected NSArray
modelNames;
protected Properties
props;
public
static void initSharedHandler(Properties props, NSArray modelNames)
{
setupHandler =
new EOFSetup(props, modelNames);
}
public
static EOFSetup getSetupHandler()
{
return
setupHandler;
}
public EOFSetup(Properties props, NSArray modelNames)
{
this.modelNames = modelNames;
this.props = props;
createDbContextStacks();
}
/**
* Overrides connection dictionary of this database context's adaptor
* to the one specified in defaults if applicable.
*/
protected
void createDbContextStacks()
{
EOEditingContext ec = EOSharedEditingContext.defaultSharedEditingContext();
EOObjectStoreCoordinator storeCoord =
EOObjectStoreCoordinator.defaultCoordinator();
EOModelGroup mg =
EOModelGroup.defaultGroup();
// see if we have custom connection dictionary
//NSDictionary altConnectInfo = props.eofAltConnection();
NSMutableDictionary altConnectInfo =
new NSMutableDictionary();
String[] connectionPorops =
new String[]
{
"URL", "password",
"username"
};
for (int i = 0; i < connectionPorops.length; i++)
{
// Allow command line override of connection properties
if (null != System.getProperty(connectionPorops[i]))
{
altConnectInfo.setObjectForKey(System.getProperty(connectionPorops[i]),
connectionPorops[i]);
Log.logI("Connection property '" + connectionPorops[i] +
"' changed to '" + System.getProperty(connectionPorops[i]) +
"'");
}
}
if (altConnectInfo !=
null)
{
Log.logI("Using alt. connection info.");
}
for (int i = 0, iMax =
modelNames.count(); i < iMax; i++)
{
try {
mg.addModelWithPathURL(new File(modelNames.objectAtIndex(i) +
".eomodeld").toURI().toURL());
}
catch (MalformedURLException x) {
Log.logX(x);
System.exit(-1);
}
EOModel aModel = mg.modelNamed((String)modelNames.objectAtIndex(i));
if (null == aModel) {
Log.logE("Model '" +
modelNames.objectAtIndex(i) +
"' not found!");
System.exit(-1);
}
Log.logI("Initializing model: " +
modelNames.objectAtIndex(i));
// merge model connection dictionary with
alt dictionary
// this way, only certain keys can be
overriden in
alt.
NSMutableDictionary dict =
null;
if (null != altConnectInfo &&
null != aModel)
{
dict =
new NSMutableDictionary(aModel.connectionDictionary());
dict.addEntriesFromDictionary(altConnectInfo);
}
// create EOF stack with new connection
dict...
EODatabaseContext dbContext =
EODatabaseContext.forceConnectionWithModel(
aModel,
dict,
new EOEditingContext(storeCoord));
storeCoord.addCooperatingObjectStore(dbContext);
// this line is important !!!
// this will force shared editing contexts to be fetched...
EODatabaseContext.registeredDatabaseContextForModel(aModel, ec);
}
}
}
Sounds like what would have been a “Command Line App” in the old Project Builder days…
I’d start with a Wonder app and strip out all the frameworks that you don’t want - maybe even start with the JavaClient project template and just delete all the client-side stuff, or the ERRest application and yank out the ERRest framework.
If you have the original install disks for WO 5.2 then you could probably find the project builder setup script and look at what it used for a command-line project… but I’ve dug around and I don’t seem to have it anymore.
Dave
On Apr 25, 2014, at 10:43 AM, John Pollard <
email@hidden> wrote:
Hi List,
What is the sensible way to create a new application in Eclipse that uses EOF and a model, plus draws on Wonder bits and bobs, but isn't a web app i.e. has no web front end? I think Eclipse once had an EOF Application type, or I may have mis-remembered
that.
I can create a new Wonder app in eclipse and just not have any request / responses and launch my code from Application(), but that feels a bit wrong. I don't want it to talk to wotaskd or be started from JavaMonitor.
Thanks in advance.
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Help/Unsubscribe/Update your Subscription:
—————————————————————————————
WebObjects - so easy that even Dave Avendasora can do it!™
—————————————————————————————
David Avendasora
Senior Software Abuser
Nekesto, Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Help/Unsubscribe/Update your Subscription: