Skip navigation


Using the Hermes Class Loader

If you want to access your own code from within a Jython extension then package your code up into a jar and create a new class path group for it:

You can access the regular Java class loader as follows - its parent class loader is the application class loader.

browser = HermesBrowser.getBrowser()
classLoader = browser.getLoader().getClassLoaderManager().getClassLoader("My Custom Code")

So now you've got the class loader you can load you your custom code right inside Hermes as in this example renderer.

class CustomRenderer (MessageRenderer):
	def __init__(self):
                browser = HermesBrowser.getBrowser()
                classLoader = browser.getLoader().getClassLoaderManager().getClassLoader("My Custom Code")
		self.__config = CustomRendererConfig() 
                self.__renderer = classLoader.loadClass("com.acme.MyRenderer").newInstance()                
		
	def canRender(self, message):
		return 1 

	def getConfigPanel(self, dialogProxy):
		return None

	def getDisplayName(self):
		return 'CustomRenderer'

	def setConfig(self, config):
		self.__config = config 

	def getConfig(self):
		return self.__config

	def createConfig(self):
		return CustomRendererConfig() 

	def render(self, message):
		return self.__renderer.render(message)

Read more about Python and HermesJMS.

Adaptavist Theme Builder Powered by Atlassian Confluence