Class: RBoss::DeployFolder

Inherits:
Object
  • Object
show all
Includes:
FileUtils, Component
Defined in:
lib/rboss/components/deploy_folder.rb,
lib/rboss/components/org/6.0/deploy_folder.rb

Overview

A class to add deploy folders to a JBoss Profile.

Note: there is a bug in JBoss (issues.jboss.org/browse/JBAS-9387) that affect this class if profile.xml needs to be changed (deploy folder outside $JBOSS_HOME/server/$PROFILE/deploy)

author: Marcelo Guimarães <[email protected]>

Instance Method Summary collapse

Methods included from Component

#initialize, #load_yaml, #new_file_processor

Instance Method Details

#configure(folder) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rboss/components/deploy_folder.rb', line 42

def configure folder
  @folder = folder.to_s

  @absolute_path = @folder.start_with? '/'
  @outside_deploy = (!@folder.start_with?('deploy') and not @absolute_path)

  @configure_vsf_and_profile = (@absolute_path or @outside_deploy)

  @path = @absolute_path ? @folder : "#{@jboss.profile}/#{@folder}"

  @folder = "${jboss.server.home.url}#{@folder}" if @outside_deploy
  @folder = "file://#{@folder}" if @absolute_path
end

#configure_profileObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rboss/components/deploy_folder.rb', line 67

def configure_profile
  @logger.info "Updating profile.xml"
  processor = new_file_processor
  processor.with "#{@jboss.profile}/conf/bootstrap/profile.xml", :xml do |action|
    action.to_process do |xml, jboss|
      element = XPath.first xml, "//property[@name='applicationURIs']"
      element = XPath.first element, "//list[@elementClass='java.net.URI']"
      deploy = Element::new "value"
      deploy.text = @folder
      element << deploy
      xml
    end
  end
  processor.process
end

#configure_vfsObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rboss/components/deploy_folder.rb', line 83

def configure_vfs
  @logger.info "Updating vfs.xml"
  processor = new_file_processor
  processor.with "#{@jboss.profile}/conf/bootstrap/vfs.xml", :xml do |action|
    action.to_process do |xml, jboss|
      map = XPath.first xml, "//map[@keyClass='java.net.URL']"
      entry = Document::new <<XML
<entry>
  <key>#{@folder}</key>
  <value><inject bean="VfsNamesExceptionHandler"/></value>
</entry>
XML
      map << entry
      xml
    end
  end
  processor.process
end

#processObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/rboss/components/deploy_folder.rb', line 56

def process
  @logger.info "Creating deploy folder: #{@path}"
  mkdir_p @path

  if @configure_vsf_and_profile
    @logger.warn "Please change your profile.xml file according to this issue <https://issues.jboss.org/browse/JBAS-9387>"
    configure_vfs
    configure_profile
  end
end