Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Communications Framework (ECF) » Using the JmDNS provider (newbie questions)
Using the JmDNS provider (newbie questions) [message #603516] Sat, 29 April 2006 17:17 Go to next message
Ronald Pomeroy is currently offline Ronald Pomeroy
Messages: 3
Registered: July 2009
Junior Member
Ok, I'm just getting started with the ECF. Actually, I'm trying to use
it because I spotted the JmDNS stuff. Awhile back I started to write my
own set of (wrapper) plugins to provide an Eclipse-centric (IAdaptable
and extension based) API for service discovery. Once I found the ECF I
decided I should avoid re-inventing the wheel.

So I'm trying to write the SWT equivalent of the Swing-based service
browser buried in the JmDNS jar. My local environment (G5 with multiple
Airport Extremes and Airport Express') has many Bonjour enabled
services advertised (The Swing service browser shows a fairly healthy
number of services). I'm using the following code just to get some of
the mechanics down but I'm not seeing any events firing

public void start(BundleContext context) throws Exception {
super.start(context);
System.out.println("Starting...");
container =
ContainerFactory.getDefault().createContainer("ecf.discovery.jmdns ");
IDiscoveryContainer discoveryContainer =
(IDiscoveryContainer)container.getAdapter(IDiscoveryContaine r.class);
Namespace namespace =
IDFactory.getDefault().getNamespaceByName("zeroconf.jmdns");
ID id = IDFactory.getDefault().createID(namespace, "_http._tcp");
IServiceTypeListener listener = new ServiceTypeListener();
discoveryContainer.addServiceTypeListener(listener);
System.out.print("About to connect...");
((IContainer)discoveryContainer).connect(null, null);
System.out.println("connected");
System.out.println("Getting services...");
IServiceInfo[] services = discoveryContainer.getServices((ServiceID) id);
for (int i = 0; i < services.length; i++) {
IServiceInfo info = services[i];
System.out.println(info.getServiceURI());
}
System.out.println("Finished getting services");
}

Other notes:
• The ServiceTypeListener just logs events to System.out. It never gets
an event.
• I get the plugin to start by opening a view associated with the
plugin (this code IS run).
• I've tried connect(null, null) as well as connect(id, null) to no avail
• I'm guessing a bit on the "_http._tcp" bit - the docs are pretty thin
on how to do service browsing JmDNS style

Any pointers are greatly appreciated.

--
Thanks,

Ron
rpomeroy at mac.com
Re: Using the JmDNS provider (newbie questions) [message #603521 is a reply to message #603516] Sat, 29 April 2006 19:48 Go to previous message
Scott Lewis is currently offline Scott Lewis
Messages: 971
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000000060508040801090407
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi Ronald,

My apologies for the dearth of examples. As it turns out I was working
on some example discovery code this very day. Attached to this posting
is a Discovery class that you can use that puts its output on System.out.

I've also checked in this class to the org.eclipse.ecf.example.collab
plugin in the org.eclipse.ecf.example.start package.

Thanks,

Scott


Ronald Pomeroy wrote:
> Ok, I'm just getting started with the ECF. Actually, I'm trying to
> use it because I spotted the JmDNS stuff. Awhile back I started to
> write my own set of (wrapper) plugins to provide an Eclipse-centric
> (IAdaptable and extension based) API for service discovery. Once I
> found the ECF I decided I should avoid re-inventing the wheel.
>
> So I'm trying to write the SWT equivalent of the Swing-based service
> browser buried in the JmDNS jar. My local environment (G5 with
> multiple Airport Extremes and Airport Express') has many Bonjour
> enabled services advertised (The Swing service browser shows a fairly
> healthy number of services). I'm using the following code just to get
> some of the mechanics down but I'm not seeing any events firing
>
> public void start(BundleContext context) throws Exception {
> super.start(context); System.out.println("Starting..."); container =
>
> ContainerFactory.getDefault().createContainer("ecf.discovery.jmdns ");
> IDiscoveryContainer discoveryContainer =
> (IDiscoveryContainer)container.getAdapter(IDiscoveryContaine r.class);
> Namespace namespace =
> IDFactory.getDefault().getNamespaceByName("zeroconf.jmdns"); ID id =
> IDFactory.getDefault().createID(namespace, "_http._tcp");
> IServiceTypeListener listener = new ServiceTypeListener();
> discoveryContainer.addServiceTypeListener(listener);
> System.out.print("About to connect...");
> ((IContainer)discoveryContainer).connect(null, null);
> System.out.println("connected"); System.out.println("Getting
> services..."); IServiceInfo[] services =
> discoveryContainer.getServices((ServiceID) id); for (int i = 0; i <
> services.length; i++) { IServiceInfo info = services[i];
> System.out.println(info.getServiceURI()); }
> System.out.println("Finished getting services"); }
>
> Other notes: • The ServiceTypeListener just logs events to
> System.out. It never gets an event. • I get the plugin to start by
> opening a view associated with the plugin (this code IS run). • I've
> tried connect(null, null) as well as connect(id, null) to no avail •
> I'm guessing a bit on the "_http._tcp" bit - the docs are pretty thin
> on how to do service browsing JmDNS style
>
> Any pointers are greatly appreciated.
>


--------------000000060508040801090407
Content-Type: text/plain;
name="Discovery.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="Discovery.java"

cGFja2FnZSBvcmcuZWNsaXBzZS5lY2YuZXhhbXBsZS5jb2xsYWIuc3RhcnQ7 DQoNCmltcG9y
dCBvcmcuZWNsaXBzZS5lY2YuY29yZS5Db250YWluZXJGYWN0b3J5Ow0KaW1w b3J0IG9yZy5l
Y2xpcHNlLmVjZi5jb3JlLklDb250YWluZXI7DQppbXBvcnQgb3JnLmVjbGlw c2UuZWNmLmNv
cmUuaWRlbnRpdHkuU2VydmljZUlEOw0KaW1wb3J0IG9yZy5lY2xpcHNlLmVj Zi5kaXNjb3Zl
cnkuSURpc2NvdmVyeUNvbnRhaW5lcjsNCmltcG9ydCBvcmcuZWNsaXBzZS5l Y2YuZGlzY292
ZXJ5LklTZXJ2aWNlRXZlbnQ7DQppbXBvcnQgb3JnLmVjbGlwc2UuZWNmLmRp c2NvdmVyeS5J
U2VydmljZUxpc3RlbmVyOw0KaW1wb3J0IG9yZy5lY2xpcHNlLmVjZi5kaXNj b3ZlcnkuSVNl
cnZpY2VUeXBlTGlzdGVuZXI7DQoNCnB1YmxpYyBjbGFzcyBEaXNjb3Zlcnkg ew0KCQ0KCUlD
b250YWluZXIgY29udGFpbmVyID0gbnVsbDsNCglJRGlzY292ZXJ5Q29udGFp bmVyIGRpc2Nv
dmVyeUNvbnRhaW5lciA9IG51bGw7DQoJDQoJcHVibGljIERpc2NvdmVyeSgp IHRocm93cyBF
eGNlcHRpb24gew0KCQlzdGFydERpc2NvdmVyeSgpOw0KCX0NCglwcml2YXRl IHZvaWQgc3Rh
cnREaXNjb3ZlcnkoKSB0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ENvbGxhYlNlcnZp Y2VMaXN0ZW5l
ciBpbXBsZW1lbnRzIElTZXJ2aWNlTGlzdGVuZXIgew0KCQlwdWJsaWMgdm9p ZCBzZXJ2aWNl
QWRkZWQoSVNlcnZpY2VFdmVudCBldmVudCkgew0KCQkJU3lzdGVtLm91dC5w cmludGxuKCJz
ZXJ2aWNlQWRkZWQoIiArIGV2ZW50ICsgIikiKTsNCgkJCWRpc2NvdmVyeUNv bnRhaW5lci5y
ZXF1ZXN0U2VydmljZUluZm8oZXZlbnQuZ2V0U2VydmljZUluZm8oKQ0KCQkJ CQkuZ2V0U2Vy
dmljZUlEKCksIDMwMDApOw0KCQl9DQoJCXB1YmxpYyB2b2lkIHNlcnZpY2VS ZW1vdmVkKElT
ZXJ2aWNlRXZlbnQgZXZlbnQpIHsNCgkJCVN5c3RlbS5vdXQucHJpbnRsbigi c2VydmljZVJl
bW92ZWQoIiArIGV2ZW50ICsgIikiKTsNCgkJfQ0KCQlwdWJsaWMgdm9pZCBz ZXJ2aWNlUmVz
b2x2ZWQoSVNlcnZpY2VFdmVudCBldmVudCkgew0KCQkJU3lzdGVtLm91dC5w cmludGxuKCJz
ZXJ2aWNlUmVzb2x2ZWQoIiArIGV2ZW50ICsgIikiKTsNCgkJfQ0KCX0NCn0N Cg==
--------------000000060508040801090407--
Previous Topic:RCP Application with ECF
Next Topic:ECF 0.8.0 Stable Released
Goto Forum:
  


Current Time: Thu Oct 23 19:25:55 GMT 2014

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

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