01.05.07
Posted in code at 12:16 am by Andrew Kuklewicz
Jon Tirsen and friends created a great product, ActiveMessaging, to incorporate into Rails the ability to send and receive Stomp messages - specifically, this seems to mostly be used with ActiveMQ and its Stomp protocol support, and depends on the Ruby Stomp client courtesy Brian McCallister.
Since I am using a13g quite actively at prx, Jon has been kind enough to let me help maintain this product, and hopefully even add some to it. There is now a google code site, and a mailing list, thanks Jon.
First up are some bug fixes and quick enhancements - I sent a few in to Brian McCallister that will hopefully show up in a 1.0.3 release of the Ruby Stomp client. I also have a few fixes and minor enhancements to make to a13g that should show up soon, and I will also be working on any issues logged on the new google code site.
But what to do after that? I have some examples I want to throw out there for doing synchronous messaging between a rails and a java app, and I want to add even more documentation to the wiki so folks can get going with this easier - what else do people want? Get on the mailing list and let’s talk about it.
Permalink
09.19.06
Posted in code at 8:55 pm by Andrew Kuklewicz
Playing around with FeedTools and FeedUpdater.
Fun stuff.
Had a few lessons learned I wanted to share:
1) load the rails app feed config file
To get FeedUpdater to find my ‘feed_updater.yml’ file, I had to make a small change to some of the file loading logic. It kept loading the example/default comfig - so I changed the list of paths to look for my file first, by climbing out of the vendor directory, and getting the file in the regular rails app config directory.
config_file = FileStalker.hunt([
"./feed_updater.yml",
"../config/feed_updater.yml"
])
to:
config_file = FileStalker.hunt([
"../../../config/feed_updater.yml",
"./feed_updater.yml",
"../config/feed_updater.yml"])
2) Use the rails app model objects in the custom updater script.
This took some experimentation to figure out.
As the rails wiki says, you need to require the environment script to be able to use the rails app goodies in a standalone script. But where, pray-tell, should you put this require?
Use the on_begin method of the custom script.
So if you have in your ‘feed_updater.yml’:
load_script: lib/my_feed_updater.rb
Then in this file, you need something like the following:
class MyFeedUpdater < FeedTools::FeedUpdater
on_begin do
#load all thing needed to use rails app stuff
require File.dirname(__FILE__) + '/../config/environment'
#use your model like its going out of style
end
on_update do |feed, seconds|
self.logger.info("Loaded '#{feed.href}'. Updated (#{feed.title}) in #{seconds} seconds.")
end
on_error do |href, error|
self.logger.info("Error updating '#{href}':")
self.logger.info(error)
end
on_complete do |updated_feed_hrefs|
end
end
Hope someone else gets some fun out of this.
Permalink
12.14.05
Posted in code at 4:02 am by Andrew Kuklewicz
I miss my monkeypatch.
If you have done a decent amount of python code, you’ve probably run into monkey patching - if you haven’t, you’re missing out. But in java, where I use an ever increasing number of open source libraries, I missed this lovely feature I was able to use to good effect in Plone. But no more, now there is AspectJ to the rescue.
First off, the problem I had was to extend the code generation capabilities in Axis 1.3 to generate java code from a WSDL (which is better than the other way around). But WSDL2Java extension is limited, and I don’t feel like downloading all the Axis source and changing it and recompiling it myself. All I wanted to do was to make the java code that was created include a unique ID to make the objects easier to persist in hibernate (and just to be a show-off, yes I am using Spring too, but not for code generation - it’s not good for everything :).
So how to do it? Easy enough, use the cuckoo’s egg design pattern to replace Axis’s current java class generator with an instance of my own when the constructor is called:
import java.util.Vector;
import org.apache.axis.wsdl.symbolTable.TypeEntry;
import org.apache.axis.wsdl.toJava.Emitter;
import org.apache.axis.wsdl.toJava.JavaBeanWriter;
import org.apache.axis.wsdl.toJava.JavaWriter;
import org.kookster.PersistentJavaBeanWriter;
/**
* Use this to change the behaviour of the WSDL2Java axis code gen
*
* @author kookster
*/
public aspect ReplaceJavaBeanWriterAspect {
//here's a pointcut to get the public constructor of Axis JavaBeanWriter
public pointcut javaBeanWriterConstructor( Emitter emitter,
TypeEntry type,
Vector elements,
TypeEntry extendType,
Vector attributes,
JavaWriter helper ):
call( JavaBeanWriter.new( Emitter,TypeEntry,Vector,TypeEntry,Vector,JavaWriter )) &&
args( emitter,type,elements,extendType,attributes,helper );
//here is the advice which calls the constructor for my object instead
JavaBeanWriter around( Emitter emitter,
TypeEntry type,
Vector elements,
TypeEntry extendType,
Vector attributes,
JavaWriter helper) :
javaBeanWriterConstructor( emitter,type,elements,extendType,attributes,helper )
{
return new PersistentJavaBeanWriter(emitter,type,elements,extendType,attributes,helper);
}
}
Permalink
07.24.05
Posted in code at 3:46 pm by Andrew Kuklewicz
I’ve been having some fun of late with BEA’s WLST tools. I’m using 8.1 so the fun is that there are 2 versions, one online (while connected to a running admin server or instance), and one offline for doing configuration and creation of instances much as you would through the configuration wizard application.
So here’s the fun - it’s jython based, but the tools start their own interpreter by default, but if you want to, you can create an ini file so you can import WLST as a module into a regular jython script.
But, for whatever reason, the offline version does not work for this…you always have to run the wlst offline class as the interpreter. I am testing a workaround, which since it is not particularly well documented, I am not quite ready to release into the world, but I am hopeful :)
Permalink
· Next entries »