Hi Neil:

Thanks for the answer. I do have the event bundle active, I added a plug-in
project from an existing JAR file (event1.0.100.jar or something like that),
and the bundle is active (Event 1.0.0) . when I put the SS command. I
downloaded the JAR from here:
http://www.jarvana.com/jarvana/browse/org/eclipse/equinox/event/

I also added to the dependencies in both generator and listener's MANIFEST
file.

The EventPoster is ACTIVE, but it has nothing in the tracker yet. The
listener is still "RESOLVED" and gives me exceptions when I try to run it.

Thanks in advance,

Asier

2009/11/9 <[email protected]>

> Send osgi-dev mailing list submissions to
>        [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        https://mail.osgi.org/mailman/listinfo/osgi-dev
> or, via email, send a message with subject or body 'help' to
>        [email protected]
>
> You can reach the person managing the list at
>        [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of osgi-dev digest..."
>
>
> Today's Topics:
>
>   1. orkut - cato kato wants you to join orkut! (cato kato)
>   2. Problems with OSGi PostEvent (Asier Aranbarri Beldarrain)
>   3. Re: Problems with OSGi PostEvent (Neil Bartlett)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 09 Nov 2009 06:07:29 +0000
> From: cato kato <[email protected]>
> Subject: [osgi-dev] orkut - cato kato wants you to join orkut!
> To: [email protected]
> Message-ID:
>        <
> 1257746849.22.14755993692388951536.4.17305302649282842...@mail.orkut.com>
>
> Content-Type: text/plain; charset="iso-8859-1"
>
> cato kato wants you to join orkut.
>
> Join now!
> http://www.orkut.com/Join.aspx?id=4AF74F254DB924DF&mt=22
>
>  * * *
>
> What you can do on orkut:
>  - CONNECT with friends and family using scraps and instant messaging
>  - DISCOVER new people through friends of friends and communities
>  - SHARE your videos, pictures and passions all in one place
>
> Help Centre: http://help.orkut.com/support/
>
>
>
>
> * * *
>
> Flooded inbox? Block all orkut users from sending you email by going to:
> http://www.orkut.com/Block.aspx?mt=22
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mail.osgi.org/pipermail/osgi-dev/attachments/20091109/30ef48c9/attachment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Mon, 9 Nov 2009 13:01:42 +0100
> From: Asier Aranbarri Beldarrain <[email protected]>
> Subject: [osgi-dev] Problems with OSGi PostEvent
> To: [email protected]
> Message-ID:
>        <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello everyone!
> I am having troubles with OSGi, using Eclipse's Equinox. My problem is that
> I want to create two bundles, one to POST(asynch.) events, and another one
> to LISTEN to them. My most frecuent error is that EventAdmin is null and
> cannot post any event, but I really do not know what is happening. I post
> you my codes for the Event Poster and Event Listener, which I took from
> here:
> http://kenai.com/projects/posteventvssendevent/sources/subversion/show.
> The author of it is *Slim Ouertani:*
> *
> *
> *
> *
>
> *_____________________________________________________________________________________________________________
> *
>
> *
> *
> *
> *
> * Event Poster * [CODE]package posteventos; import java.util.logging.Level;
> import java.util.logging.Logger; import org.osgi.framework.BundleActivator;
> import org.osgi.framework.BundleContext; import java.util.Date; import
> java.util.Dictionary; import java.util.Properties; import
> org.osgi.service.event.Event; import org.osgi.service.event.EventAdmin;
> import org.osgi.util.tracker.ServiceTracker; public class Activator
> implements BundleActivator { private EventAdmin eventAdmin; private
> ServiceTracker eventAdminTracker; private static final String
> POST_EVENT_QUEUE = "An Event"; private void postEvent() { Dictionary props
> =
> new Properties(); int i = 0; while (true) { Date d = new Date();
> props.put("property", "" + i++ + " : " + d); System.out.println("before
> post
> : " + d); Event event = new Event(POST_EVENT_QUEUE, props);
> eventAdmin.postEvent(event); System.out.println("after post : " + d); try {
> Thread.sleep(10 * 1000); } catch (InterruptedException ex) {
> Logger.getLogger(Activator.class.getName()).log(Level.SEVERE, null, ex); }
> }
> } @Override public void start(BundleContext bundleContext) throws Exception
> { eventAdminTracker = new ServiceTracker(bundleContext,
> EventAdmin.class.getName(), null); eventAdminTracker.open(); eventAdmin =
> (EventAdmin) eventAdminTracker.getService(); if (eventAdmin != null) { new
> Thread() { @Override public void run() { postEvent(); } }.start(); } else {
> System.out.println("eventAdmin is null"); //this one to see if it's NULL }
> }
> @Override public void stop(BundleContext bundleContext) throws Exception {
> eventAdminTracker.close(); } } [/CODE]
>
> _____________________________________________________________________________________________________________
> *Event Listener * [CODE]package listenereventos; import
> java.util.Dictionary; import java.util.Hashtable; import
> java.util.Properties; import java.util.logging.Level; import
> java.util.logging.Logger; import org.osgi.framework.BundleActivator; import
> org.osgi.framework.BundleContext; import org.osgi.service.event.Event;
> import org.osgi.service.event.EventConstants; import
> org.osgi.service.event.EventHandler; /** * Hello world! * */ public class
> Activator implements BundleActivator { private static final String
> POST_EVENT_QUEUE = "Hola"; @Override public void start(BundleContext
> context) throws Exception { Dictionary dp = new Hashtable();
> dp.put(EventConstants.EVENT_TOPIC, POST_EVENT_QUEUE); for (int i = 0; i <
> 50000; i++) { context.registerService(EventHandler.class.getName(), new
> [B]PostEventHandler[/B](), dp); //code for this behind } } @Override public
> void stop(BundleContext context) throws Exception { } } [/CODE]
> ____________________________________ *PostEventHandler*: [CODE]package
> listenereventos; import java.util.logging.Level; import
> java.util.logging.Logger; import org.osgi.service.event.Event; import
> org.osgi.service.event.EventHandler; public class PostEventHandler { public
> void handleEvent(Event event) { String value =
> event.getProperty("property").toString(); try { Thread.sleep(30 * 1000); }
> catch (InterruptedException ex) {
> Logger.getLogger(Activator.class.getName()).log(Level.SEVERE, null, ex); }
> System.out.println("---------------->Post value : " + value); } } [/CODE] I
> really don't know what's happening since it's my first time using OSGi
> events, and I would really thank any help from you. Regards, Asier[/QUOTE]
>
>
>
> _____________________________________________________________________________________________________________
>
>
>
>
> I noticed that the EventTracker size is 0 :
> System.out.println(eventAdminTracker.size())
>
> Could it be the problem? Thank you very much,
>
>
> Asier
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mail.osgi.org/pipermail/osgi-dev/attachments/20091109/f0ca58d4/attachment-0001.html
>
> ------------------------------
>
> Message: 3
> Date: Mon, 9 Nov 2009 12:15:07 +0000
> From: Neil Bartlett <[email protected]>
> Subject: Re: [osgi-dev] Problems with OSGi PostEvent
> To: OSGi Developer Mail List <[email protected]>
> Message-ID:
>        <[email protected]>
> Content-Type: text/plain; charset=UTF-8
>
> Asier,
>
> Do you have an event admin bundle installed and active? The Equinox
> implementation is called org.eclipse.equinox.event.
>
> Without that bundle active you will of course always get null when
> trying to obtain the EventAdmin service.
>
> Regards,
> Neil
>
> On Mon, Nov 9, 2009 at 12:01 PM, Asier Aranbarri Beldarrain
> <[email protected]> wrote:
> > Hello everyone!
> > I am having troubles with OSGi, using Eclipse's Equinox. My problem is
> that
> > I want to create two bundles, one to POST(asynch.) events, and another
> one
> > to LISTEN to them. My most frecuent error is that EventAdmin is null and
> > cannot post any event, but I really do not know what is happening. I post
> > you my codes for the Event Poster and Event Listener, which I took from
> > here:
> > http://kenai.com/projects/posteventvssendevent/sources/subversion/show.
> The
> > author of it is Slim Ouertani:
> >
> >
> _____________________________________________________________________________________________________________
> >
> >
> > Event Poster [CODE]package posteventos; import java.util.logging.Level;
> > import java.util.logging.Logger; import
> org.osgi.framework.BundleActivator;
> > import org.osgi.framework.BundleContext; import java.util.Date; import
> > java.util.Dictionary; import java.util.Properties; import
> > org.osgi.service.event.Event; import org.osgi.service.event.EventAdmin;
> > import org.osgi.util.tracker.ServiceTracker; public class Activator
> > implements BundleActivator { private EventAdmin eventAdmin; private
> > ServiceTracker eventAdminTracker; private static final String
> > POST_EVENT_QUEUE = "An Event"; private void postEvent() { Dictionary
> props =
> > new Properties(); int i = 0; while (true) { Date d = new Date();
> > props.put("property", "" + i++ + " : " + d); System.out.println("before
> post
> > : " + d); Event event = new Event(POST_EVENT_QUEUE, props);
> > eventAdmin.postEvent(event); System.out.println("after post : " + d); try
> {
> > Thread.sleep(10 * 1000); } catch (InterruptedException ex) {
> > Logger.getLogger(Activator.class.getName()).log(Level.SEVERE, null, ex);
> } }
> > } @Override public void start(BundleContext bundleContext) throws
> Exception
> > { eventAdminTracker = new ServiceTracker(bundleContext,
> > EventAdmin.class.getName(), null); eventAdminTracker.open(); eventAdmin =
> > (EventAdmin) eventAdminTracker.getService(); if (eventAdmin != null) {
> new
> > Thread() { @Override public void run() { postEvent(); } }.start(); } else
> {
> > System.out.println("eventAdmin is null"); //this one to see if it's NULL
> } }
> > @Override public void stop(BundleContext bundleContext) throws Exception
> {
> > eventAdminTracker.close(); } } [/CODE]
> >
> _____________________________________________________________________________________________________________
> > Event Listener [CODE]package listenereventos; import
> java.util.Dictionary;
> > import java.util.Hashtable; import java.util.Properties; import
> > java.util.logging.Level; import java.util.logging.Logger; import
> > org.osgi.framework.BundleActivator; import
> org.osgi.framework.BundleContext;
> > import org.osgi.service.event.Event; import
> > org.osgi.service.event.EventConstants; import
> > org.osgi.service.event.EventHandler; /** * Hello world! * */ public class
> > Activator implements BundleActivator { private static final String
> > POST_EVENT_QUEUE = "Hola"; @Override public void start(BundleContext
> > context) throws Exception { Dictionary dp = new Hashtable();
> > dp.put(EventConstants.EVENT_TOPIC, POST_EVENT_QUEUE); for (int i = 0; i <
> > 50000; i++) { context.registerService(EventHandler.class.getName(), new
> > [B]PostEventHandler[/B](), dp); //code for this behind } } @Override
> public
> > void stop(BundleContext context) throws Exception { } } [/CODE]
> > ____________________________________ PostEventHandler: [CODE]package
> > listenereventos; import java.util.logging.Level; import
> > java.util.logging.Logger; import org.osgi.service.event.Event; import
> > org.osgi.service.event.EventHandler; public class PostEventHandler {
> public
> > void handleEvent(Event event) { String value =
> > event.getProperty("property").toString(); try { Thread.sleep(30 * 1000);
> }
> > catch (InterruptedException ex) {
> > Logger.getLogger(Activator.class.getName()).log(Level.SEVERE, null, ex);
> }
> > System.out.println("---------------->Post value : " + value); } } [/CODE]
> I
> > really don't know what's happening since it's my first time using OSGi
> > events, and I would really thank any help from you. Regards,
> Asier[/QUOTE]
> >
> >
> _____________________________________________________________________________________________________________
> >
> >
> > I noticed that the EventTracker size is 0 :
> > System.out.println(eventAdminTracker.size())
> >
> > Could it be the problem? Thank you very much,
> >
> > Asier
> >
> >
> > _______________________________________________
> > OSGi Developer Mail List
> > [email protected]
> > https://mail.osgi.org/mailman/listinfo/osgi-dev
> >
>
>
> ------------------------------
>
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
> End of osgi-dev Digest, Vol 37, Issue 4
> ***************************************
>
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to