MongoEMF outside OSGI

140 views
Skip to first unread message

Xavier S.

unread,
May 28, 2012, 7:44:27 AM5/28/12
to mong...@googlegroups.com
Hello,
Is there any way to use MongoEMF without OSGI?

I digged in the examples, and couldn't find if this is possible.

I would like to know how to instanciate the MongoResourceSetFactory. And also, what are the minimal sets of jars that mongo-emf needs to run in a standalone way.

Regards,

Xavier

Bryan Hunt

unread,
May 28, 2012, 5:15:35 PM5/28/12
to mong...@googlegroups.com
Hi Xavier,

Yes, it should be possible to use MongoEMF without OSGi - it just won't be trivial.  To create a new resource set factory, simply:

IResourceSetFactory resourceSetFactory = new MongoResourceSetFactory().

That will allow you to create instances of MongoResourceSetImpl, but it won't be configured for MongoEMF.  To do that, you can add the MongoURIHandlerImpl() yourself, or bind the configurators.  The minimal set of jars is the same as for an OSGi environment.  Please see the User Guide.

Bryan

Xavier S.

unread,
May 28, 2012, 6:07:21 PM5/28/12
to mong...@googlegroups.com
Hello,

Thanks for your answer, there was a weird access restriction on the org.eclipselabs.mongo.emf.ext_0.7.0.201205201640.jar : **/*

I presume this is done because OSGI handles itself the configuration of mongo-emf.

I removed it and now, I'm trying to add the MongoURIHandlerImpl to the list of handlers.

But I'm puzzled about how to do that since I cannot rely on the ConfigurationAdmin.

For now here is what I've done : https://gist.github.com/2821402

But I need to pass some args to the MongoURIHandlerImpl constructor, and I cannot see what to do?

I think I'm missing the configuration of my mongodb credentials too.

Is there any example? Or maybe could you give me some help.

Best regards,

Xavier

Bryan Hunt

unread,
May 28, 2012, 8:44:10 PM5/28/12
to mong...@googlegroups.com
Hi Xavier,

For now, I'm going to have to refer you to the source code.  I intend on creating an extender guide that will help with what you want to do, but unfortunately I have other priorities right now.  Pay attention to the constructors with arguments and to any bind*() functions - they will give you some guidance.  This diagram may help understand better how the services interconnect.  You basically have to connect the services manually outside of an OSGi environment.

Bryan

Xavier S.

unread,
May 29, 2012, 4:30:17 AM5/29/12
to mong...@googlegroups.com
Hi Bryan,

Thanks to your hints, I think I'm not that far of solving it.

I tried to configure the services and to interconnect them. I relied on the default implementation of each, so i had to configure some exported packages in the bundles MANIFESTs.

But still, I end up with a null resource when I call the following :
 
Resource resource = resourceSet.createResource(URI.createURI("mongodb://ds033087.mongolab.com:33087/mongo-emf/test/1"));

Maybe I'm missing something?

You can find an updated version of the code there : https://gist.github.com/2821402

Best regards,

Xavier 


2012/5/29 Bryan Hunt <bh...@mac.com>

Guillaume Hillairet

unread,
May 30, 2012, 10:49:45 AM5/30/12
to mong...@googlegroups.com
Hi Xavier,

I haven't try the latest version of mongo-emf but have you register XMIResourceFactoryImpl has the default ResourceFactory, so the ResourceSet will know what kind of Resource to create. You'll need also of course to have the xmi jars on the classpath.


On Tuesday, 29 May 2012 10:30:17 UTC+2, Xavier S. wrote:
Hi Bryan,

Thanks to your hints, I think I'm not that far of solving it.

I tried to configure the services and to interconnect them. I relied on the default implementation of each, so i had to configure some exported packages in the bundles MANIFESTs.

But still, I end up with a null resource when I call the following :
 
Resource resource = resourceSet.createResource(URI.createURI("mongodb://ds033087.mongolab.com:33087/mongo-emf/test/1"));

Maybe I'm missing something?

You can find an updated version of the code there : https://gist.github.com/2821402

Best regards,

Xavier 

Xavier S.

unread,
May 30, 2012, 12:01:13 PM5/30/12
to mong...@googlegroups.com
Hello Guillaume,

Thanks for your answer.

You mean I should add the following?

IResourceSetFactory resourceSetFactory = new MongoResourceSetFactory();
ResourceSet resourceSet = resourceSetFactory.createResourceSet();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());

I tried it, but with no luck.

Best regards,

Xavier

Guillaume Hillairet

unread,
May 30, 2012, 12:43:25 PM5/30/12
to mong...@googlegroups.com

Yes, but since your URI has no extension, you have to use the wildcard like this:

resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());

or if you want to be specific you can specify the protocol:

resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("mongodb", new XMIResourceFactoryImpl());

Xavier S.

unread,
May 30, 2012, 1:36:47 PM5/30/12
to mong...@googlegroups.com
Hi again Guillaume,

Thanks! With your advises i was able to run mongo-emf outside OSGI.

Here is the final code : https://gist.github.com/2821402

I'll now be able to put more pressure to  colleagues to use mongo-emf :)

Thanks to Bryan and you.

I've got one question to Bryan.

Is there any reason not to export implementation packages? I had to export them in order to call some constructors.
If it doesn't introduces any limitations about exporting these packages, I would like to send a small pull request.

Best regards to both of you,

Xavier

Bryan Hunt

unread,
May 30, 2012, 2:14:47 PM5/30/12
to mong...@googlegroups.com
Hi Xavier,

I'm pretty sure the export package headers are ignored outside of an OSGi container.  Exporting private (implementation) packages in OSGi is very bad practice.  We need to better understand the root cause of your problem.

Bryan

Xavier S.

unread,
May 31, 2012, 3:36:21 AM5/31/12
to mong...@googlegroups.com
Hello Bryan,

You're right, I was using the dependency mechanism of eclipse4 for testing purpose, now I mavenized the deps and I have no problems.

Thanks again!

Regards,

Xavier

Bryan Hunt

unread,
May 31, 2012, 8:25:01 AM5/31/12
to mong...@googlegroups.com
HI Xavier,

That's great to hear.  Any chance you would like to contribute a wiki page that details the steps to get everything configured?

Bryan

Xavier S.

unread,
May 31, 2012, 8:41:28 AM5/31/12
to mong...@googlegroups.com
Hello Bryan,

Sure.

After the help (and obviously the work you're doing on mongo-emf) it's the least I can do.

I pulled your last changes, and it seems the authentication mechanism has changed, so I'll have to dig to provide an up-to-date wiki page.

Regards,

Xavier

Antonio Salvi

unread,
Feb 27, 2015, 8:45:13 AM2/27/15
to mong...@googlegroups.com, xavier....@gmail.com
Hello to all,
I am vary interesting in MongoEMF outside OSGi and I found this
So I downloaded it but I have problems with maven dependencies, please Xavier can you help me?

Thank you!
Reply all
Reply to author
Forward
0 new messages