Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] 3.0 Standalone server
[CDO] 3.0 Standalone server [message #507005] Mon, 11 January 2010 16:41 Go to next message
Assen Sharlandjiev is currently offline Assen SharlandjievFriend
Messages: 17
Registered: January 2010
Location: Sofia, Bulgaria
Junior Member

Hi,

Can anyone give me a snippet that instantiates a standalone (outside of OSGI) CDO 3.0 server.
I want to use Spring Context to wire the CDO server instance in a J2EE Web application.

I'm also taking advantage of the container lifecycle and using default init and destroy methods for the spring beans:

default-init-method="activate"
default-destroy-method="deactivate"

I've faced problems when trying to move these into the IoC container:

IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(true);

IStore store = CDODBUtil.createStore(mappingStrategy, dbAdapter, dbConnectionProvider);

the implementation of createStore() changes the state of the mappingStrategy, and sets the store property of the strategy.


Thanks in advance,
Assen.
Re: [CDO] 3.0 Standalone server [message #507029 is a reply to message #507005] Mon, 11 January 2010 17:33 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Assen,

Comments below...


Assen Sharlandjiev schrieb:
> Hi,
>
> Can anyone give me a snippet that instantiates a standalone (outside
> of OSGI) CDO 3.0 server.
There might be examples at
http://wiki.eclipse.org/User_Contributed_CDO_Documentation

> I want to use Spring Context to wire the CDO server instance in a J2EE
> Web application.
That should generally be possible. A (possibly outdated) example is in
the Wiki, see above.

>
> I'm also taking advantage of the container lifecycle and using default
> init and destroy methods for the spring beans:
>
> default-init-method="activate"
> default-destroy-method="deactivate"
I think you must be careful. Some components are implicitely activated
when they are "contained" in other components. For a repository for
example it should only be necessary to explicitely activate the
repository component itself.

>
> I've faced problems when trying to move these into the IoC container:
>
> IMappingStrategy mappingStrategy =
> CDODBUtil.createHorizontalMappingStrategy(true);
>
> IStore store = CDODBUtil.createStore(mappingStrategy, dbAdapter,
> dbConnectionProvider);
>
> the implementation of createStore() changes the state of the
> mappingStrategy, and sets the store property of the strategy.
What exactly is the problem? How can I help?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] 3.0 Standalone server [message #507035 is a reply to message #507029] Mon, 11 January 2010 18:06 Go to previous messageGo to next message
Assen Sharlandjiev is currently offline Assen SharlandjievFriend
Messages: 17
Registered: January 2010
Location: Sofia, Bulgaria
Junior Member

Hi Eike,
the examples from the wiki are CDO 2.0 and outdated.
I'll contribute my updated examples of using standalone spring wired CDO server and client, once I get all the things running. I already have a working client.

I realized that I can't use the Spring's container's default bean activation methods for the CDO server.

Suppose I already have activated a repository, how can I start the configure a container correctly?

I'm using the code below, but I do get an exception when the client opens a session


// Spring wired beans
Map<String, String> props = (Map<String, String>) applicationContext.getBean("props");
IDBAdapter dbAdapter = (IDBAdapter) applicationContext.getBean("dbAdapter");
IDBConnectionProvider dbConnectionProvider = (IDBConnectionProvider) applicationContext.getBean("dbConnectionProvider");

// Repository
IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(true);
IStore store = CDODBUtil.createStore(mappingStrategy, dbAdapter, dbConnectionProvider);
final IRepository repository = CDOServerUtil.createRepository("repo1", store, props);
((Repository) repository).activate();

// Further I create the container:

IManagedContainer container = ContainerUtil.createContainer();
Net4jUtil.prepareContainer(container);
TCPUtil.prepareContainer(container);
container.activate();

IAcceptor acceptor = (IAcceptor) container.getElement("org.eclipse.net4j.acceptors", "tcp", null);
((Repository) repository).activate();

while (System.in.read()==-1) {
Thread.sleep(500);
}
((Repository) repository).deactivate();
container.deactivate();

...

When I run the client, I get the following exception:

[ERROR] Factory not found: org.eclipse.net4j.serverProtocols[cdo]
org.eclipse.net4j.util.container.FactoryNotFoundException: Factory not found: org.eclipse.net4j.serverProtocols[cdo]
at org.eclipse.net4j.util.container.ManagedContainer.getFactory (ManagedContainer.java:193)

How can I register this factory manually with the container?

Assen.
Re: [CDO] 3.0 Standalone server [message #507039 is a reply to message #507035] Mon, 11 January 2010 18:39 Go to previous message
Assen Sharlandjiev is currently offline Assen SharlandjievFriend
Messages: 17
Registered: January 2010
Location: Sofia, Bulgaria
Junior Member

Ok, I resolved it, but adding a dependency jar which I have missed, and

container.registerFactory(new CDOServerProtocolFactory(
new IRepositoryProvider() {
@Override
public IRepository getRepository(String name) {
return repository;
}
}));

Further goal is to skip the use of IManagedContainer and use the Spring bean container instead.

Assen.
Previous Topic:CDO authentication
Next Topic:Re: GMF & TENEO
Goto Forum:
  


Current Time: Thu Apr 18 11:10:10 GMT 2024

Powered by FUDForum. Page generated in 0.02150 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top