Return to Snippet

Revision: 4802
at January 21, 2008 19:28 by narkisr


Initial Code
require 'fileutils'

Def='server/default/deploy/jms/'
Conf='server/default/conf/'

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}]

class String
    def uncomment_end
        self.gsub(/\s*-->/, '')
    end

    def comment_end
        self.gsub(/\n/, '-->\0')
    end
end


class JMSNullPerPerformer

    def get_user_input
        puts 'enter your jboss folder path:'
        @dest=gets.chomp!+'/'
        puts 'enter you jboss examples (under doc) folder path:'
        puts 'default ['+@dest+'docs/]'
        if (@source=gets.chomp!).empty? then @source=@dest+'/docs/examples/jms/' end
        puts 'starting to apply JMS null persistency onto selected jboss'
    end

    def apply_additions
        {'null-persistence-service.xml'=>Def, 'file-state-service.xml'=>Def, 'conf/jbossmq-state.xml'=>Conf}.each{|file, d| FileUtils.cp(@source+file, @dest+d)}
    end

    def apply_deletions
        ['hsqldb-jdbc2-service.xml', 'hsqldb-jdbc-state-service.xml'].each{|file|
            if File.exist?(@dest+Def+file) then FileUtils.rm(@dest+Def+file)end
        }
    end

    def apply_new_security
        res=''
        loginConf = @dest+Conf+'login-config.xml'
        IO.readlines(loginConf).each{|line|
            if !Markers.empty? && line.include?(Markers.first.keys.first)
                line=line.send(Markers.shift.values.first)
            end
            res << line
            File.open(loginConf, 'w'){|file| file.puts res}
        }
    end
end

performer = JMSNullPerPerformer.new
performer.get_user_input
puts '* adding files'
performer.apply_additions
puts '* deleting files'
performer.apply_deletions
puts '* applying new security'
performer.apply_new_security

Initial URL

                                

Initial Description
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.

Initial Title
JBoss Null JMS Persistency setup script

Initial Tags
ruby

Initial Language
Ruby