On Apr 2, 9:24 am, Chas Emerick <cemer...@snowtide.com> wrote: > But: invoking clojure.main.main programmatically? Ouch. :-) > > - Chas
Yeah, I know it's shady, and I know that with more time and effort I can avoid doing it, but should I bother? It's given me a command shell with access to my JPA layer that's been working for a few days without trouble. What bugs me is that it smells bad. Is it bad? The build process uses maven, but deployment does not; we needed more unix-level process control in production than we were willing to ask maven to manage/avoid, so the last mile of invoking the actual java process(es) is done by bespoke scripts that directly invoke java. I guess I'll probably end up spring-injecting (a thin wrapper around) swank-clojure or, if my non-emacs-enabled colleagues object, the Enclojure library (of which I had not been aware; thanks!). Cheers. --josh > > On Mar 31, 2010, at 11:18 PM, Josh Daghlian wrote: > > > > > I greatly appreciate the excellent recent spate of “getting started” > > discussions/docs, and I’ve had no trouble at all in bootstrapping new > > Clojure projects. But I wonder if there is (yet? anymore?) a canonical > > way of embedding Clojure into my existing codebase without refactoring > > my existing deployment model. Everything I’ve seen on the web on the > > subject is at least a year old. > > > A repl is a great debugging and diagnostic tool (and it gives me an > > excuse to use Clojure at work), but the embedding feels shadier than > > I’m comfortable with. Here’s a cartoon: > > > public class ExampleMain { > > private static ApplicationContext staticCtx; > > public static void main(String[] args) { > > // About 30 man-years of effort is embodied in the following line, > > including > > // lots of o-r mappings, database credentials, and many scattered > > properties. > > staticCtx = loadSpringContext(“enormous-spring-file.xml”); > > > if (args[0].equals(“shell-mode”)) { > > clojure.main.main(new String[]{}); // starts up more or less > > instantly > > } else { > > doNormalWork(); // runs for many minutes before hitting > > breakpoint > > } > > System.exit(0); > > } > > } > > > so then, thanks to having a static Spring context bean, I can then do > > things like: > > > (def get-bean [beanname] (.getBean com.example.ExampleMain/staticCtx > > beanname)) > > (def dao (get-bean “readOnlyJpaDao”)) > > ;; now I can interrogate my big Oracle database... > > > (def customer-to-debug (.getCustomer dao “customerID4200000213”)) > > ;; picked out a single Customer object; probably initialized a bunch > > of JPA stuff, too > > > (map #(.getVisitTime %) (.getVisits customer-to-debug)) > > (count (filter #(> .getVisitTime % *last-week*) #(.getVisits customer- > > to-debug))) > > ;; etc. > > > It's a vanilla repl (though running it in a shell in emacs helps). > > What I’d *really* like to do is start up swank-clojure, pass locals > > (like the Spring context, some timing information, etc.) into the > > clojure environment, and so forth. > > > Apologies if I’m missing something obvious (although I suppose that’s > > what “getting started” docs are for:). > > > Thanks. > > --josh > > > -- > > 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 > > > To unsubscribe, reply using "remove me" as the subject. -- 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