Thanks, I think.
I don't have experience with Spring, so this will take some time for me to
digest. I was rather hoping there was a way to register an EventListener
without rebuilding the OpenNMS.
If I am understanding correctly, beanRefContext.xml is used at build time, not
run time, so if I update that file, I need to get the source and rebuild the
system.
As far as I can tell, I can create a NotificationStrategy and register it
without access to the source code for OpenNMS. This does not seem to be true
for the path you suggested for the EventListener. Is there a non-Spring
approach to add a simple Listener, or do I need to adopt the whole Spring
Framework to add a new service. I understand why you might wish to have a
consistent structure for adding new services, so I won't try to buck the trend.
===========================
Decided to try something differently. I tried basing my entry on
<name>OpenNMS:Name=Queued</name>
<class-name>org.opennms.netmgt.queued.jmx.Queued</class-name>
<invoke at="start" pass="0" method="init"/>
<invoke at="start" pass="1" method="start"/>
<invoke at="status" pass="0" method="status"/>
<invoke at="stop" pass="0" method="stop"/>
</service>
and opennms would not start because of missing Spring Contexts (I expect that
is what the beanRefContext is for)
Then I tried
<service>
<name>OpenNMS:Name=DramaConverter</name>
<class-name>com.telcordia.ar.drama.opennms.dramabeans.jmx.DramaConverter</class-name>
</service>
and OpenNMS starts up fine. Apparently, the <invoke> elements caused a problem
with the system looking for a SpringContext.
Unfortunately, now the class does not get referenced and no methods are called.
I tried adding static initializers to instantiate a singleton and register it,
but they are not invoked. So I guess the simpler approach won't work. Time to
install Maven and build from scratch.
Gary Levin
RRC 1N345
Telcordia Technologies
> -----Original Message-----
> From: DJ Gregor [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 21, 2008 6:52 PM
> To: OpenNMS Code Development and Bugs
> Subject: Re: [opennms-devel] Fetching an Event in a
> NotificationStrategy
>
> You are on the right track. Create a daemon that will get
> instantiated
> through configuration in service-configuration.xml. Your daemon will
> work with EventIpcManager to register for events and install
> itself as a
> callback when the events come in. You probably want to use something
> that does nothing other than event processing as a base, and queued is
> probably the best thing:
>
> opennms-services/src/main/java/org/opennms/netmgt/queued
>
> In jmx/Queued.java, you only need the getLoggingPrefix() and
> getSpringContext() methods--the rest of what is in there is
> specific to
> RRD handling. The value returned from getSpringContext() refers to a
> Spring context defined in
> opennms-services/src/main/resources/beanRefContext.xml. Let
> us know if
> you have any problems figuring this out.
>
> Lastly, here is a web page that discusses some of the details of the
> Spring-loaded daemon infrastructure:
>
> http://www.opennms.org/index.php/Using_AbstractSpringContextJm
> xServiceDaemon_to_dependency_inject_a_daemon
>
> Good luck!
>
>
> - djg
>
> On Fri, 21 Nov 2008 13:14:40 -0500, "Levin, Gary Marc"
> <[EMAIL PROTECTED]> said:
> > Nothing like sending in a request to get the brain going.
> >
> > I found that I can use EventIpcManagerFactory to get an
> EventIpcManager
> > to which I can register an EventListener of my own. The
> only tricky part
> > is figuring out a good place to arrange for the class to
> register itself.
> > Is there a clean way to do it? At worst, I can have a
> > NotificationStrategy registered that instantiates the
> listener. A hack,
> > but it works.
> >
> >
> >
> > Gary Levin
> > RRC 1N345
> > Telcordia Technologies
> >
> >
> > > -----Original Message-----
> > > From: Levin, Gary Marc
> > > Sent: Friday, November 21, 2008 12:35 PM
> > > To: '[email protected]'
> > > Subject: RE: Fetching an Event in a NotificationStrategy
> > >
> > > This is a follow-up to the previous question. I found
> > > org.opennms.netmgt.xml.event.Event, and I can get the event from
> > > NotificationFactory based on the EventId in the notification.
> > > The problem
> > > is that the event retrieved is incomplete. It is missing the
> > > parameters
> > > (which are passed to the notification, because they appear in my
> > > description).
> > >
> > > * No parameters show up in the xml produced by Event.marshal().
> > > * Event.getParms() returns null
> > > (1) Is this a bug in org.opennms.netmgt.xml.event.Event?
> > > (2) Is this a bug in
> > > org.opennms.netmgt.xml.event.NotificationFactory.getEvent()?
> > > (Producing an
> > > incomplete Event)
> > > (3) Is there an alternative way to get the original event from the
> > > notification? (I thought that EventFactory would be the way
> > > to go, but that
> > > is not accessible from a NotificationStrategy.)
> > >
> > >
> > >
> > >
> > >
> > >
> > > I am trying to forward the event to another system. If
> > > necessary, I can put
> > > enough information into the notification description so that
> > > I can manually
> > > construct the event, but it seems like a fragile solution.
> > >
> > >
> > >
> > >
> > > If there is a way to capture the event *before* it gets to be a
> > > notification, that would be even better. An EventListener
> > > would be ideal.
> > > (This is where the Uses page would be very helpful.) Is
> > > there a way to
> > > register a new EventListener?
> > >
> > >
> > >
> > >
> > > Gary Levin
> > > RRC 1N345
> > > Telcordia Technologies
> > >
> > >
> > > > -----Original Message-----
> > > > From: Levin, Gary Marc [mailto:[EMAIL PROTECTED]
> > > > Sent: Friday, October 31, 2008 3:56 PM
> > > > To: [email protected]
> > > > Subject: [opennms-devel] Fetching an Event in a
> NotificationStrategy
> > > >
> > >
> > >
> > > I need to fetch the Event that triggered a Notification. I
> > > have written an
> > > implementation of NotificationStrategy, which is
> correctly invoked by
> > > notifd. The notification places the eventId into the text
> > > message, which is
> > > included in the list of arguments passed to
> > > NotificationStrategy.send(). I
> > > log this information, so I am sure it is being received correctly.
> > >
> > > My code then extracts the eventId, parses it into an integer,
> > > eid, and tries
> > > calling EventFactory.getEvent(eid). It gets to that point,
> > > but the call
> > > never returns. I catch SQLException, and that is not
> thrown either.
> > >
> > > I tried catching Throwable and found the problem to be
> > > java.lang.NoClassDefFoundError:
> > > org/opennms/web/event/EventFactory
> > > I am guessing this is caused by the EventFactory being loaded
> > > by a different
> > > classloader than my NotificationStrategy. This had me go
> > > look for another
> > > way to get the event, using the jars in lib and not web-apps.
> > >
> > >
> > >
> > > I was trying to learn more about the API and noticed that although
> > > http://www.opennms.org/documentation/java-apidocs-stable/
> > > org/opennms/netmgt/xml/event/Event.html
> > > exists, if you go to the frame view, this class and its
> > > package are not in
> > > the list of packages and classes.
> > >
> > > I found that what I needed was
> > > org.opennms.netmgt.xml.event.Event, which I
> > > can get from
> > > org.opennms.netmgt.xml.event.NotificationFactory. This would
> > > have been easier to find if the Javadoc included that
> > > package. Also,having
> > > the Uses page when I am trying to learn an API. This lets me
> > > work backwards
> > > from what I want, in this case an Event.
> > >
> >
> >
> --------------------------------------------------------------
> -----------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> > challenge
> > Build the coolest Linux based applications with Moblin SDK
> & win great
> > prizes
> > Grand prize is a trip for two to an Open Source event
> anywhere in the
> > world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________
> > Please read the OpenNMS Mailing List FAQ:
> > http://www.opennms.org/index.php/Mailing_List_FAQ
> >
> > opennms-devel mailing list
> >
> > To *unsubscribe* or change your subscription options, see
> the bottom of
> > this page:
> > https://lists.sourceforge.net/lists/listinfo/opennms-devel
>
> --------------------------------------------------------------
> -----------
> This SF.Net email is sponsored by the Moblin Your Move
> Developer's challenge
> Build the coolest Linux based applications with Moblin SDK &
> win great prizes
> Grand prize is a trip for two to an Open Source event
> anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Please read the OpenNMS Mailing List FAQ:
> http://www.opennms.org/index.php/Mailing_List_FAQ
>
> opennms-devel mailing list
>
> To *unsubscribe* or change your subscription options, see the
> bottom of this page:
> https://lists.sourceforge.net/lists/listinfo/opennms-devel
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ
opennms-devel mailing list
To *unsubscribe* or change your subscription options, see the bottom of this
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel