Thanks for the tip on how to express a java bean -- that appears to only be part of the problem; I still have the error I posted above. But I'm going to keep flailing at it.
On Feb 2, 10:11 am, Ken Wesson <kwess...@gmail.com> wrote: > On Wed, Feb 2, 2011 at 11:15 AM, clwham...@gmail.com > > <clwham...@gmail.com> wrote: > > I am doing some prototyping with the event processing framework Esper > > (http://esper.codehaus.org/) and I'm running up against my ignorance > > of clojure/java interop. I would like to create a java bean in clojure > > that is visible to the Esper runtime; I found some sample Java code > > that I clojurized as follows: > > > (ns cepdemo.core > > (:import [com.espertech.esper.client > > Configuration UpdateListener > > EPServiceProviderManager EPRuntime])) > > > (defrecord Tick [symbol price timestamp]) > > ... > > > The error I get is: > > Property named 'symbol' is not valid in any stream [select * from > > StockTick(symbol='AAPL').win:length(2) having avg(price) > 6.0] > > > from which I conclude that defrecord may not be the way to create a > > java bean. Do I need to use gen-class? > > I'd try first to make Tick bean-ish with > > (definterface ITick > (getSymbol [this]) > (setSymbol [this y]) > (getPrice [this]) > (setPrice [this y]) > (getTimeStamp [this]) > (setTimeStamp [this y])) > > (defrecord Tick [symbol price timestamp] > ITick > (getSymbol [this] symbol) > (setSymbol [this] (throw (UnsupportedOperationException.))) > (getPrice [this] price) > (setPrice [this] (throw (UnsupportedOperationException.))) > (getTimeStamp [this] timestamp) > (setTimeStamp [this] (throw (UnsupportedOperationException.))) > > Tell the external tool that the bean properties are Symbol, Price, and > TimeStamp (rather than symbol, price, and timestamp) and unless it > tries to mutate your Ticks it ought to work. > > Of course, you might also consider making a defbean macro that wraps > defrecord and automates the above. :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en