Home » Modeling » EMF » [CDO] Start own bundle in CDO Server
| | |
Re: [CDO] Start own bundle in CDO Server [message #947618 is a reply to message #947606] |
Wed, 17 October 2012 08:43 |
|
Am 17.10.2012 10:29, schrieb Anders Jönsson:
>> You may want to implement and contribute an org.eclipse.emf.cdo.spi.server.IAppExtension
>
> Yes, it works perfect. Thanks a lot!
Excellent ;-)
> I use CDO client code in IAppExtension.start() to connect to the (same) server via tcp,
Why not via JVM transport? That would be faster.
> start a session, open a view and listen to the model. Is this the preferred way to interact with the model
Yes.
> or is there a more direct way to, for instance, open a view using CDO server code?
You can open a ServerCDOView with these methods:
org.eclipse.emf.cdo.server.CDOServerUtil.openView(ISession, CDOBranchPoint, boolean, CDORevisionProvider)
org.eclipse.emf.cdo.server.CDOServerUtil.openView(ISession, CDOBranchPoint, boolean)
org.eclipse.emf.cdo.server.CDOServerUtil.openView(IView, boolean)
org.eclipse.emf.cdo.server.CDOServerUtil.openView(CommitContext, boolean)
But they have very limited capabilities, no write access, no invalidations. Just what's needed to traverse a state of
the model graph in terms of EObjects.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
| | | | |
Re: [CDO] Start own bundle in CDO Server [message #1019456 is a reply to message #1019399] |
Fri, 15 March 2013 18:23 |
|
Am 15.03.2013 16:42, schrieb Christophe Bouhier:
> [...] The way we do it:
>
> CDO has plugin extenstion points like here:
>
> <extension
> point="org.eclipse.net4j.util.elementProcessors">
> <elementProcessor
>
> class="com.netxforge.netxstudio.server.job.JobHandler$Initializer">
> </elementProcessor>
> </extension>
>
> The class must implement IElementProcessor
>
> public Object process(IManagedContainer container, String productGroup,
> String factoryType, String description, Object element) {
> if (element instanceof IRepository) {
> final IRepository repository = (IRepository) element;
> repository.addListener(new LifecycleEventAdapter() {
> @Override
> public void notifyLifecycleEvent(ILifecycleEvent event) {
> if (event.getKind() == Kind.ACTIVATED) {
> ...DO YOUR THINGY HERE
> }
> });
> }
> return element;
> }
That's what I was going to suggest ;-)
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: [CDO] Start own bundle in CDO Server [message #1019474 is a reply to message #1019456] |
Fri, 15 March 2013 19:19 |
|
Am 15.03.2013 19:23, schrieb Eike Stepper:
> Am 15.03.2013 16:42, schrieb Christophe Bouhier:
>> [...] The way we do it:
>>
>> CDO has plugin extenstion points like here:
>>
>> <extension
>> point="org.eclipse.net4j.util.elementProcessors">
>> <elementProcessor
>>
>> class="com.netxforge.netxstudio.server.job.JobHandler$Initializer">
>> </elementProcessor>
>> </extension>
>>
>> The class must implement IElementProcessor
>>
>> public Object process(IManagedContainer container, String productGroup,
>> String factoryType, String description, Object element) {
>> if (element instanceof IRepository) {
>> final IRepository repository = (IRepository) element;
>> repository.addListener(new LifecycleEventAdapter() {
>> @Override
>> public void notifyLifecycleEvent(ILifecycleEvent event) {
>> if (event.getKind() == Kind.ACTIVATED) {
>> ...DO YOUR THINGY HERE
>> }
>> });
>> }
>> return element;
>> }
> That's what I was going to suggest ;-)
Oh, and you can do the same thing with the configured acceptor!
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
| | |
Re: [CDO] Start own bundle in CDO Server [message #1021194 is a reply to message #1021193] |
Tue, 19 March 2013 16:28 |
Christophe Bouhier Messages: 937 Registered: July 2009 |
Senior Member |
|
|
On 19-03-13 17:27, Christophe Bouhier wrote:
> On 19-03-13 16:03, Anders Jönsson wrote:
>> Hi, thanks for suggestions!
BTW, I really recommend to checkout the cdo test plugin, it has tons of
examples.
>>
>> But, when i put my thingy in place of the "...DO YOUR THINGY HERE"
>> thingy I still get an exception:
>> org.eclipse.net4j.util.lifecycle.LifecycleException: Could not activate
>> TCPClientConnector[127.0.0.1:2,036]
>>
> Is your code capable to open a TCPClientConnector without the Extension
> mechanism that I described earlier?
>
>> The "thingy" here beeing that I am trying to create a CDOSession to the
>> server using tcp (apparently I should use "jvm transport" instead but I
>> haven't gotten around to that yet).
>>
> ah, that's a different issue.
> here is a snippet.
>
> final IManagedContainer container = IPluginContainer.INSTANCE;
> acceptor = JVMUtil.getAcceptor(container, "default");
> connector = JVMUtil.getConnector(container, "default");
>
> // Create configuration
> final CDONet4jSessionConfiguration sessionConfiguration =
> CDONet4jUtil
> .createNet4jSessionConfiguration();
>
> sessionConfiguration.setConnector(connector);
> sessionConfiguration.setRepositoryName(REPO_NAME);
>
>> And the output below still happens after that (at least it is PRINTED to
>> the log after the stack trace):
>> [INFO] Net4j extension starting
>>
>> !ENTRY org.eclipse.emf.cdo.server.net4j 1 0 2013-03-19 15:30:43.627
>> !MESSAGE Net4j extension starting
>> [INFO] Net4j extension started
>>
>> !ENTRY org.eclipse.emf.cdo.server.net4j 1 0 2013-03-19 15:30:43.641
>> !MESSAGE Net4j extension started
>>
>> [INFO] CDO server started
>>
>> !ENTRY org.eclipse.emf.cdo.server 1 0 2013-03-19 15:30:43.642
>> !MESSAGE CDO server started
>>
>>
>> Also; Eike, can you give me a little more hint about what "the
>> configured acceptor" is.
>>
>> ///Anders
>>
>
|
|
|
Re: [CDO] Start own bundle in CDO Server [message #1021219 is a reply to message #1021126] |
Tue, 19 March 2013 17:16 |
|
Hej Anders,
I meant that if you rely on a TCP connection to the repository you should not listen for repository activation but for
the TCP acceptor activation, in Christophe's words:
public Object process(IManagedContainer container, String productGroup,
String factoryType, String description, Object element) {
if (element instanceof ITCPAcceptor) {
final ITCPAcceptor acceptor = (ITCPAcceptor) element;
acceptor.addListener(new LifecycleEventAdapter() {
@Override
public void notifyLifecycleEvent(ILifecycleEvent event) {
if (event.getKind() == Kind.ACTIVATED) {
...DO YOUR THINGY HERE
}
});
}
return element;
}
The acceptor is always started after the repository, i.e. in the Net4j extension.
Does that help?
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Am 19.03.2013 16:03, schrieb Anders Jönsson:
> Hi, thanks for suggestions!
>
> But, when i put my thingy in place of the "...DO YOUR THINGY HERE" thingy I still get an exception:
> org.eclipse.net4j.util.lifecycle.LifecycleException: Could not activate TCPClientConnector[127.0.0.1:2,036]
>
> The "thingy" here beeing that I am trying to create a CDOSession to the server using tcp (apparently I should use "jvm
> transport" instead but I haven't gotten around to that yet).
>
> And the output below still happens after that (at least it is PRINTED to the log after the stack trace):
> [INFO] Net4j extension starting
>
> !ENTRY org.eclipse.emf.cdo.server.net4j 1 0 2013-03-19 15:30:43.627
> !MESSAGE Net4j extension starting
> [INFO] Net4j extension started
>
> !ENTRY org.eclipse.emf.cdo.server.net4j 1 0 2013-03-19 15:30:43.641
> !MESSAGE Net4j extension started
>
> [INFO] CDO server started
>
> !ENTRY org.eclipse.emf.cdo.server 1 0 2013-03-19 15:30:43.642
> !MESSAGE CDO server started
>
>
> Also; Eike, can you give me a little more hint about what "the configured acceptor" is.
>
> ///Anders
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
| |
Goto Forum:
Current Time: Fri Apr 26 14:15:12 GMT 2024
Powered by FUDForum. Page generated in 0.05215 seconds
|