Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse Communications Framework (ECF) » Questions about ECF
Questions about ECF [message #587370] Thu, 08 September 2005 10:11 Go to next message
Eclipse UserFriend
Originally posted by: aiko.ituniv.se

Hello,
I'm from IT University of Göteborg, and currently I'm trying to
understand how does ECF works.

Regarding to ECF, I can understand the theory, but I'm having some
practical issues.

For instance, we have installed the ECF plug-in al already joined an ECF
group in the local machine (piece of cake, of course), but regarding to
the task of running the sample codes (for instance the code of
org.eclipse.ecf.example.hello_0.4.0), I've got some troubles, by the
fact that I really can't understand how to run a plug-in (which by the
way is not essential for understanding how does ECF works).

So, I was trying to create a main method in a Main class inside the
project, in order to run it as a normal Java application, the file was
created inside org.eclipse.ecf.example.hello package (just for testing
purposes, for debugging and get to understand the code flow), and it
looks like this:

package org.eclipse.ecf.example.hello;

import org.eclipse.ecf.core.identity.IDFactory;

public class Main {

public static void main(String[] args){
HelloClient client = new HelloClient();
try {
client.createAndConnect(IDFactory.getDefault().makeStringID( "ecftcp://localhost:3282/server"));
System.out.println("Hello Client, ECF Hello World attempt finished");
} catch (Exception e) {
System.out.println("ECF Hello World server not currently running");
}
}
}

And I tried to run it, but it generates the next error:

org.eclipse.ecf.core.ContainerInstantiationException:
ContainerDescription named 'org.eclipse.ecf.provider.generic.Client' not
found at
org.eclipse.ecf.core.ContainerFactory.getDescriptionByName(C ontainerFactory.java:126)
at
org.eclipse.ecf.core.SharedObjectContainerFactory.makeShared ObjectContainer(SharedObjectContainerFactory.java:86)
at
org.eclipse.ecf.example.hello.HelloClient.createAndConnect(H elloClient.java:34)
at org.eclipse.ecf.example.hello.Main.main(Main.java:10)

The server is running because when I run the "Join Group" option, it works.
Also, I have included on the libraries of the project, the next jar files:
ecf.jar,
org.eclipse.ecf.provider_0.4.0.jar,
org.eclipse.ecf.test,
org.eclipse.ecf.test.provider and
org.eclipse.test.ui

The code is not giving any compilation errors.
If you have an idea of what's going on, I would appreciate greatly if
you could help me.
Re: Questions about ECF [message #587383 is a reply to message #587370] Fri, 09 September 2005 05:52 Go to previous messageGo to next message
Scott Lewis is currently offline Scott LewisFriend
Messages: 1038
Registered: July 2009
Senior Member
Hi Aiko,

Aiko Fallas Yamashita wrote:
> Hello,
> I'm from IT University of Göteborg, and currently I'm trying to
> understand how does ECF works.
>
> Regarding to ECF, I can understand the theory, but I'm having some
> practical issues.
>
> For instance, we have installed the ECF plug-in al already joined an ECF
> group in the local machine (piece of cake, of course), but regarding to
> the task of running the sample codes (for instance the code of
> org.eclipse.ecf.example.hello_0.4.0), I've got some troubles, by the
> fact that I really can't understand how to run a plug-in (which by the
> way is not essential for understanding how does ECF works).
>
> So, I was trying to create a main method in a Main class inside the
> project, in order to run it as a normal Java application, the file was
> created inside org.eclipse.ecf.example.hello package (just for testing
> purposes, for debugging and get to understand the code flow), and it
> looks like this:
>
> package org.eclipse.ecf.example.hello;
>
> import org.eclipse.ecf.core.identity.IDFactory;
>
> public class Main {
>
> public static void main(String[] args){
> HelloClient client = new HelloClient();
> try {
> client.createAndConnect(IDFactory.getDefault().makeStringID( "ecftcp://localhost:3282/server"));
>
> System.out.println("Hello Client, ECF Hello World attempt finished");
> } catch (Exception e) {
> System.out.println("ECF Hello World server not currently running");
> }
> }
> }
>
> And I tried to run it, but it generates the next error:
>
> org.eclipse.ecf.core.ContainerInstantiationException:
> ContainerDescription named 'org.eclipse.ecf.provider.generic.Client' not
> found at
> org.eclipse.ecf.core.ContainerFactory.getDescriptionByName(C ontainerFactory.java:126)
>
> at
> org.eclipse.ecf.core.SharedObjectContainerFactory.makeShared ObjectContainer(SharedObjectContainerFactory.java:86)
>
> at
> org.eclipse.ecf.example.hello.HelloClient.createAndConnect(H elloClient.java:34)
>
> at org.eclipse.ecf.example.hello.Main.main(Main.java:10)
>
> The server is running because when I run the "Join Group" option, it works.
> Also, I have included on the libraries of the project, the next jar files:
> ecf.jar,
> org.eclipse.ecf.provider_0.4.0.jar,
> org.eclipse.ecf.test,
> org.eclipse.ecf.test.provider and
> org.eclipse.test.ui
>
> The code is not giving any compilation errors.
> If you have an idea of what's going on, I would appreciate greatly if
> you could help me.

Sure. The reason you are getting this exception is because as a mere
java application the ECF ContainerFactory not get populated
appropriately. In Eclipse, the ECF container factory gets populated
upon plugin startup with any/all plugin-defined extensions of the ECF
containerFactory extension point.

So to create a 'typical' ECF client your code must be run as an Eclipse
plugin. An easy way to do this (create a plugin) is to use the Project
Wizard: New->Project...->Plugin Development->Plugin Project. After the
plugin project is created, open the new plugin.xml file for the project
in the PDE editor (by just double clicking the plugin.xml file), and add
org.eclipse.ecf to the dependencies tab. Then you can create classes
and such that implement the code you have above.

The org.eclipse.ecf.example.hello plugin is just such an example. It
only has a few classes, but it is a complete plugin that is dependent
upon the ECF API. It also has an action class that is connected to the
UI by an extension...this puts a menu item in the Eclipse main menu 'ECF
Hello World', which calls the run method of the HelloAction class (see
org.eclipse.ecf.example.hello.actions.HelloAction). This run method
then does something very similar to what you are trying to do above.

NOW, if you really want to run an ECF-based client *outside* of Eclipse
(i.e. not as a plugin) it is possible to do so...but what must happen is
that

a) all of the needed packages/classes must be on the application's
classpath (i.e. all needed ECF code...e.g. org.eclipse.ecf,
org.eclipse.ecf.provider at least)
b) you need to populate the ECF ContainerFactory manually, as it is
usually done as part of Eclipse initialization with the extension
registry. To populate the ContainerFactory yourself, you can do
something like this:

// Create IContainerInstantiator manually
IContainerInstantiator instantiator = new
org.eclipse.ecf.provider.generic.ContainerInstantiator();
// Create a containerdescription that associates the
// appropriate name with the instantiator
ContainerDescription cd = new
ContainerDescription("org.eclipse.ecf.provider.generic.Client ",instantiator,"");
// Add this new description to ContainerFactory
IContainerFactory factory = ContainerFactory.getDefault();
factory.addDescription(cd);

// Now you should be able to create instances of the given named type
IContainer container =
ContainerFactory.getDefault().makeContainer("org.eclipse.ecf.provider.generic.Client ");
// do stuff with container...connect, etc.

Does this help? The above code is not really intended to be run
directly, and all of the above is done automatically by Eclipse and ECF
via the extension registry...but it can be done to create ECF clients
that do not require Eclipse in order to run. Note that again you will
have to make sure that all the necessary classes are available on the
application classpath (at least org.eclipse.ecf,
org.eclipse.ecf.provider, and possibly others).

Thanks,

Scott


>
>
Re: Questions about ECF [message #587439 is a reply to message #587383] Sat, 10 September 2005 01:23 Go to previous messageGo to next message
Scott Lewis is currently offline Scott LewisFriend
Messages: 1038
Registered: July 2009
Senior Member
HI Aiko,

Scott Lewis wrote:
> <stuff deleted>

> a) all of the needed packages/classes must be on the application's
> classpath (i.e. all needed ECF code...e.g. org.eclipse.ecf,
> org.eclipse.ecf.provider at least)
> b) you need to populate the ECF ContainerFactory manually, as it is
> usually done as part of Eclipse initialization with the extension
> registry. To populate the ContainerFactory yourself, you can do
> something like this:
>
> // Create IContainerInstantiator manually
> IContainerInstantiator instantiator = new
> org.eclipse.ecf.provider.generic.ContainerInstantiator();
> // Create a containerdescription that associates the
> // appropriate name with the instantiator
> ContainerDescription cd = new
>
ContainerDescription("org.eclipse.ecf.provider.generic.Client ",instantiator,"");

>
> // Add this new description to ContainerFactory
> IContainerFactory factory = ContainerFactory.getDefault();
> factory.addDescription(cd);
>
> // Now you should be able to create instances of the given named type
> IContainer container =
>
ContainerFactory.getDefault().makeContainer("org.eclipse.ecf.provider.generic.Client ");

>

Some more info on this...

in addition to the ECF dependencies listed in 'a' above, you will also
need to have access (on classpath) to the org.eclipse.core.runtime
classes and the org.eclipse.osgi classes (this because org.eclipse.ecf
has some dependencies on classes in these two plugins). Note that you
can just put the jars from these respective plugins in your classpath
and the classes will be loaded fine...Eclipse itself will not be needed.

Scott



> // do stuff with container...connect, etc.
>
> Does this help? The above code is not really intended to be run
> directly, and all of the above is done automatically by Eclipse and ECF
> via the extension registry...but it can be done to create ECF clients
> that do not require Eclipse in order to run. Note that again you will
> have to make sure that all the necessary classes are available on the
> application classpath (at least org.eclipse.ecf,
> org.eclipse.ecf.provider, and possibly others).
>
> Thanks,
>
> Scott
>
>
>>
>>
Re: Questions about ECF [message #587469 is a reply to message #587439] Sun, 11 September 2005 19:02 Go to previous message
Eclipse UserFriend
Originally posted by: aiko.ituniv.se

Scott,
Thank you very much for this info.
It really helped me a lot.

best,

Aiko

Scott Lewis wrote:
> HI Aiko,
>
> Scott Lewis wrote:
>
>> <stuff deleted>
>
>
> > a) all of the needed packages/classes must be on the application's
> > classpath (i.e. all needed ECF code...e.g. org.eclipse.ecf,
> > org.eclipse.ecf.provider at least)
> > b) you need to populate the ECF ContainerFactory manually, as it is
> > usually done as part of Eclipse initialization with the extension
> > registry. To populate the ContainerFactory yourself, you can do
> > something like this:
> >
> > // Create IContainerInstantiator manually
> > IContainerInstantiator instantiator = new
> > org.eclipse.ecf.provider.generic.ContainerInstantiator();
> > // Create a containerdescription that associates the
> > // appropriate name with the instantiator
> > ContainerDescription cd = new
> >
> ContainerDescription("org.eclipse.ecf.provider.generic.Client ",instantiator,"");
>
> >
> > // Add this new description to ContainerFactory
> > IContainerFactory factory = ContainerFactory.getDefault();
> > factory.addDescription(cd);
> >
> > // Now you should be able to create instances of the given named type
> > IContainer container =
> >
> ContainerFactory.getDefault().makeContainer("org.eclipse.ecf.provider.generic.Client ");
>
> >
>
> Some more info on this...
>
> in addition to the ECF dependencies listed in 'a' above, you will also
> need to have access (on classpath) to the org.eclipse.core.runtime
> classes and the org.eclipse.osgi classes (this because org.eclipse.ecf
> has some dependencies on classes in these two plugins). Note that you
> can just put the jars from these respective plugins in your classpath
> and the classes will be loaded fine...Eclipse itself will not be needed.
>
> Scott
>
>
>
>> // do stuff with container...connect, etc.
>>
>> Does this help? The above code is not really intended to be run
>> directly, and all of the above is done automatically by Eclipse and
>> ECF via the extension registry...but it can be done to create ECF
>> clients that do not require Eclipse in order to run. Note that again
>> you will have to make sure that all the necessary classes are
>> available on the application classpath (at least org.eclipse.ecf,
>> org.eclipse.ecf.provider, and possibly others).
>>
>> Thanks,
>>
>> Scott
>>
>>
>>>
>>>
Previous Topic:Looking for nice implementation task
Next Topic:JMS Provider?
Goto Forum:
  


Current Time: Fri Apr 26 18:30:27 GMT 2024

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

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

Back to the top