[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [ecf-dev] OSGi Container bundles for Eclipse Remote Service tutorial
|
Hi Wim,
Thanks for the reply. The OSGI DS bundle therefore must be included in
the bundles that must be started before the service. What should be
the priority for this bundle?
Also note that In order to start my service, I do it manually in the
osgi console after i execute the product as an Eclipse application.
Thanks.
Quoting Wim Jongman <wim.jongman@xxxxxxxxx>:
Hi Nicollas,
The service relies on OSGi DS. This means that by just activating the
bundle, the service registry is done automatically instead of manually. For
that the contents in the file in the OSGI-INF directory must be correct, and
the manifest must point to this file. Also the osgi DS bundle must be added
to the family and be started before your service bundle is activated.
Alternatively, you can register your service manually as explained
here
[1]<http://wiki.eclipse.org/Getting_Started_with_ECF's_OSGi_Remote_Services_Implementation#Service_Host:_Registering_the_Remote_Service>
Regards,
Wim
[1]
http://wiki.eclipse.org/Getting_Started_with_ECF's_OSGi_Remote_Services_Implementation#Service_Host:_Registering_the_Remote_Service
<http://wiki.eclipse.org/Getting_Started_with_ECF's_OSGi_Remote_Services_Implementation#Service_Host:_Registering_the_Remote_Service>
On Tue, Aug 24, 2010 at 8:55 PM, Nicholas Loulloudes <
loulloudes.n@xxxxxxxxxxxx> wrote:
Hi Wim, Scott and All,
I used the code provided by Wim in the Activator and run and Quotes
consumer with the Quotes host running. All went well and in the Remote
Services output i could see the following string: $Proxy1
Then i went and created my own host bundles, very similar to the Quotes
host. One service interface, and one service implementation. I made sure
that the OSGI configuration for the service implementation had the same
parameters as the Quotes configuration, but reflecting to my services. Then
i run the quotes consumer and in the remote services i got nothing. Keep in
mind that i kept the
Activator.getContext().getAllServiceReferences(null, null); method with
null parameters in order to get all the ServiceReferences.
What do you think might be going wrong? What i have to check in the host?
Regards,
Nicholas.
Quoting Scott Lewis <slewis@xxxxxxxxxxxxx>:
Hi Wim and All,
One thing to note about the ECF implementation WRT the
'service.imported' OSGi service property...
For ECF's impl the following code
Object o = serviceReference.getProperty("service.imported");
will result in Object o being of type 'IRemoteService'...see javadocs here
http://www.eclipse.org/ecf/org.eclipse.ecf.docs/api/org/eclipse/ecf/remoteservice/IRemoteService.html
So code like this can be written (if desired...Wim's code below will
work just fine as well):
IRemoteService rs = (IRemoteService)
serviceReference.getProperty("service.imported");
// use rs if non-null
if (rs != null) {
rs.callAsync(remoteCall,listener);
}
I just mention this because this is a feature unique to ECF...as the
OSGi remote services spec only defines that a remote service will have
a non-null value for "service.imported" service property...but does not
say what type that value will be (and IRemoteService allows easy access
to...e.g. asynchronous/non-blocking remote invocation).
Scott
Wim Jongman wrote:
Hi Nicholas,
There are a few ways to deal with discovered services but here is one
that uses the OSGi framework.
Please take a look at the modified Activator.start method of the
o.e.e.examples.remoteservices.quotes.consumer bundle . Replace the start
method with this code and then connect to the yazafatutu.com <
http://yazafatutu.com> server. The code will extract all services in
the framework every 10 seconds and will print a list of all
services and a
list with remote services.
It extracts the services from the framework with
/Activator.getContext().getAllServiceReferences(null, null);/
the null, null can be replaced by your specific class and filter
requirements.
It then extracts the actual service from the service reference
(/Activator.getContext().getService(serviceReference)/) and prints the
class name.
The next loop only prints services with the property "service.imported"
not equal to null. This indicates that the service is a remote
property. Is
it useful to know if the service is a remote service? In one
way, yes. You
have to adapt your programming style to be "remote aware" and
realize that
calls can be delayed. On the other hand, there is no difference in remote
and local services from an OSGi point of view. With the discovery in
place, services are "just there" to be used.
Best regards,
Wim
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
Runnable runner = new Runnable() {
public void run() {
try {
ServiceReference[] services =
Activator.getContext().getAllServiceReferences(null, null);
System.out.println("All Services");
System.out.println("------------");
for (ServiceReference serviceReference : services) {
Object obj = Activator.getContext().getService(serviceReference);
System.out.println(obj.getClass().getSimpleName());
}
services = Activator.getContext().getAllServiceReferences(null, null);
System.out.println();
System.out.println("Remote Services");
System.out.println("------------");
for (ServiceReference serviceReference : services) {
if (serviceReference.getProperty("service.imported") != null) {
Object obj = Activator.getContext().getService(serviceReference);
System.out.println(obj.getClass().getSimpleName());
}
}
} catch (InvalidSyntaxException e) {
e.printStackTrace();
}
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
}
new Thread(this).start();
}
};
new Thread(runner).start();
}
On Tue, Aug 17, 2010 at 11:27 AM, Nicholas Loulloudes <
loulloudes.n@xxxxxxxxxxxx <mailto:loulloudes.n@xxxxxxxxxxxx>> wrote:
Hi Wim,
The listener in the consumer example you have provided me, as far
as i understand tracks for services changes and based on
the event (i.e Registration) it shows some service details. In my
case, how can i first get a list of all the available services?
Thanks.
Wim Jongman wrote:
Hi,
The service will already be available/published as a local
service. Why not get a list of all services and display that to
the user. You can also filter all remote services by specifying
the remote service property in the filter.
Look at the listener code in [1] to see an approach on publications.
Best regards,
Wim [1]
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ecf/examples/bundles/org.eclipse.ecf.examples.remoteservices.quotes.consumer/src/org/eclipse/ecf/examples/remoteservices/quotes/consumer/Application.java?view=markup&root=RT_Project
<
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ecf/examples/bundles/org.eclipse.ecf.examples.remoteservices.quotes.consumer/src/org/eclipse/ecf/examples/remoteservices/quotes/consumer/Application.java?view=markup&root=RT_Project
>
On Tue, Aug 17, 2010 at 8:01 AM, Markus Alexander Kuppe
<ecf-dev_eclipse.org <http://ecf-dev_eclipse.org>@lemmster.de
<http://lemmster.de>> wrote:
On 08/17/2010 07:58 AM, Nicholas Loulloudes wrote:
> Hi Markus,
>
> I am experimenting with the Zookeeper code rom Wim's
tutorial, and one
> of the things i would like to do is to obtain a list of the
services
> provided by a host.
> I tried to use the IDiscoveryLocator interface as suggested
in the
> Zoodiscovery wiki, but when calling the getServices()
method, an empty
> array is returned.
>
> Could the discovery part in OSGi assist me in getting a
list of the
> published services? If yes, could you direct me on how to
achieve this?
Question is, what is supposed to happen with the list of
services once
retrieved. Do you want your distribution provider to create
endpoints
and connect to each of to invoke services? Or do you just want to
display the results and e.g. let a user choose a service
manually?
Markus
_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx <mailto:ecf-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/ecf-dev
------------------------------------------------------------------------
_______________________________________________ ecf-dev mailing
list ecf-dev@xxxxxxxxxxx <mailto:ecf-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/ecf-dev
-- ________________________________________________________
Nicholas Loulloudes
PhD Candidate,
High Performance Computing Systems Laboratory (HPCL)
University of Cyprus,
Nicosia, Cyprus
Tel: +357-22892663
Email: loulloudes.n[at]cs.ucy.ac.cy <http://cs.ucy.ac.cy>
Web: www.cs.ucy.ac.cy/~nickl <http://www.cs.ucy.ac.cy/%7Enickl>
________________________________________________________
_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx <mailto:ecf-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/ecf-dev
------------------------------------------------------------------------
_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev
_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev
_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev