JBoss Null JMS Persistency setup script


/ Published in: Ruby
Save to your folder(s)

This script will setup JBoss 4.2.2 to use null persistence (no DB, see http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigJBossMQNullPersistence) when handling JMS messages.


Copy this code and paste it in your HTML
  1. require 'fileutils'
  2.  
  3. Def='server/default/deploy/jms/'
  4. Conf='server/default/conf/'
  5.  
  6. Markers=[{'<!-- Security domain for JBossMQ -->'=>:uncomment_end }, {'</application-policy>'=>:comment_end}, {'<!-- Security domain for JBossMQ when using file-state-service.xml'=>:comment_end}, {'-->'=>:uncomment_end}]
  7.  
  8. class String
  9. def uncomment_end
  10. self.gsub(/\s*-->/, '')
  11. end
  12.  
  13. def comment_end
  14. self.gsub(/\n/, '-->\0')
  15. end
  16. end
  17.  
  18.  
  19. class JMSNullPerPerformer
  20.  
  21. def get_user_input
  22. puts 'enter your jboss folder path:'
  23. @dest=gets.chomp!+'/'
  24. puts 'enter you jboss examples (under doc) folder path:'
  25. puts 'default ['+@dest+'docs/]'
  26. if (@source=gets.chomp!).empty? then @source=@dest+'/docs/examples/jms/' end
  27. puts 'starting to apply JMS null persistency onto selected jboss'
  28. end
  29.  
  30. def apply_additions
  31. {'null-persistence-service.xml'=>Def, 'file-state-service.xml'=>Def, 'conf/jbossmq-state.xml'=>Conf}.each{|file, d| FileUtils.cp(@source+file, @dest+d)}
  32. end
  33.  
  34. def apply_deletions
  35. ['hsqldb-jdbc2-service.xml', 'hsqldb-jdbc-state-service.xml'].each{|file|
  36. if File.exist?(@dest+Def+file) then FileUtils.rm(@dest+Def+file)end
  37. }
  38. end
  39.  
  40. def apply_new_security
  41. res=''
  42. loginConf = @dest+Conf+'login-config.xml'
  43. IO.readlines(loginConf).each{|line|
  44. if !Markers.empty? && line.include?(Markers.first.keys.first)
  45. line=line.send(Markers.shift.values.first)
  46. end
  47. res << line
  48. File.open(loginConf, 'w'){|file| file.puts res}
  49. }
  50. end
  51. end
  52.  
  53. performer = JMSNullPerPerformer.new
  54. performer.get_user_input
  55. puts '* adding files'
  56. performer.apply_additions
  57. puts '* deleting files'
  58. performer.apply_deletions
  59. puts '* applying new security'
  60. performer.apply_new_security

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.