Skip to content

Commit a781a98

Browse files
author
Glyn Normington
committed
Code climate improvements to Spring Insight framework
[#59478422]
1 parent 6ebc7b6 commit a781a98

4 files changed

Lines changed: 54 additions & 30 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/All_Tests.xml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java-buildpack.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<module type="RUBY_MODULE" version="4">
3-
<component name="NewModuleRootManager" inherit-compiler-output="false">
3+
<component name="NewModuleRootManager">
44
<content url="file://$MODULE_DIR$">
55
<sourceFolder url="file://$MODULE_DIR$/lib/java_buildpack" isTestSource="false" />
66
<sourceFolder url="file://$MODULE_DIR$/bin" isTestSource="false" />

lib/java_buildpack/framework/spring_insight.rb

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,13 @@ def compile
4040
end
4141

4242
def release
43-
weaver_jar = @application.relative_path_to(Pathname.new Dir[File.join(insight_home, 'weaver', 'insight-weaver-*.jar')][0])
44-
45-
@java_opts << "-javaagent:#{weaver_jar}"
43+
# Spring Insight depends on the following options being in a particular order.
44+
add_agent_weaver_option
4645
@java_opts << "-Dinsight.base=#{File.join INSIGHT_HOME, 'insight'}"
4746
@java_opts << "-Dinsight.logs=#{File.join INSIGHT_HOME, 'insight', 'logs'}"
4847
@java_opts << '-Daspectj.overweaving=true'
4948
@java_opts << '-Dorg.aspectj.tracing.factory=default'
50-
@java_opts << '-Dagent.http.protocol=http'
51-
@java_opts << "-Dagent.http.host=#{URI(@uri).host}"
52-
@java_opts << '-Dagent.http.port=80'
53-
@java_opts << '-Dagent.http.context.path=insight'
54-
@java_opts << '-Dagent.http.username=spring'
55-
@java_opts << '-Dagent.http.password=insight'
56-
@java_opts << '-Dagent.http.send.json=false'
57-
@java_opts << '-Dagent.http.use.proxy=false'
58-
@java_opts << '-Dinsight.transport.type=HTTP'
49+
add_agent_http_options
5950
@java_opts << "-Dagent.name.override=#{@vcap_application[NAME_KEY]}"
6051
end
6152

@@ -112,25 +103,42 @@ def unpack_agent_installer(root, file)
112103
end
113104

114105
def install_insight(agent_dir)
115-
weaver_directory = File.join insight_home, 'weaver'
116-
insight_directory = File.join insight_home, 'insight'
117-
insight_analyser_directory = File.join extra_applications_directory, 'insight-agent'
118106
uber_agent_directory = File.join agent_dir, 'springsource-insight-uber-agent-*'
119-
120107
FileUtils.rm_rf insight_home
121-
FileUtils.rm_rf insight_analyser_directory
122-
FileUtils.mkdir_p container_libs_directory
123-
FileUtils.mkdir_p extra_applications_directory
108+
109+
initialise_weaver_directory uber_agent_directory
110+
add_container_libs uber_agent_directory
111+
initialise_insight_directory uber_agent_directory
112+
initialise_insight_analyser_directory uber_agent_directory
113+
end
114+
115+
def initialise_weaver_directory(uber_agent_directory)
116+
weaver_directory = File.join insight_home, 'weaver'
117+
FileUtils.rm_rf weaver_directory
124118
FileUtils.mkdir_p weaver_directory
119+
shell "mv #{File.join uber_agent_directory, 'agents', 'common', 'insight-weaver-*.jar'} #{weaver_directory}"
120+
end
121+
122+
def add_container_libs(uber_agent_directory)
123+
FileUtils.mkdir_p container_libs_directory
124+
shell "mv #{File.join uber_agent_directory, 'agents', 'common', 'insight-bootstrap-generic-*.jar'} #{container_libs_directory}"
125+
shell "mv #{File.join uber_agent_directory, 'agents', 'tomcat', '7', 'lib', 'insight-bootstrap-tomcat-common-*.jar'} #{container_libs_directory}"
126+
end
127+
128+
def initialise_insight_directory(uber_agent_directory)
129+
insight_directory = File.join insight_home, 'insight'
130+
FileUtils.rm_rf insight_directory
125131
FileUtils.mkdir_p insight_directory
132+
shell "mv #{File.join uber_agent_directory, 'insight', 'collection-plugins'} #{insight_directory}"
133+
shell "mv #{File.join uber_agent_directory, 'insight', 'conf'} #{insight_directory}"
134+
end
126135

127-
FileUtils.mv Dir[File.join(uber_agent_directory, 'agents', 'common', 'insight-weaver-*.jar')][0], weaver_directory
128-
FileUtils.mv Dir[File.join(uber_agent_directory, 'agents', 'common', 'insight-bootstrap-generic-*.jar')][0], container_libs_directory
129-
FileUtils.mv Dir[File.join(uber_agent_directory, 'agents', 'tomcat', '7', 'lib', 'insight-bootstrap-tomcat-common-*.jar')][0], container_libs_directory
130-
FileUtils.mv Dir[File.join(uber_agent_directory, 'insight', 'collection-plugins')][0], insight_directory
131-
FileUtils.mv Dir[File.join(uber_agent_directory, 'insight', 'conf')][0], insight_directory
132-
FileUtils.mv Dir[File.join(uber_agent_directory, 'insight-agent')][0], insight_analyser_directory
133-
FileUtils.mv Dir[File.join(uber_agent_directory, 'transport', 'http', 'insight-agent-http-*.jar')][0], File.join(insight_analyser_directory, 'WEB-INF', 'lib')
136+
def initialise_insight_analyser_directory(uber_agent_directory)
137+
insight_analyser_directory = File.join extra_applications_directory, 'insight-agent'
138+
FileUtils.rm_rf insight_analyser_directory
139+
FileUtils.mkdir_p extra_applications_directory
140+
shell "mv #{File.join uber_agent_directory, 'insight-agent'} #{insight_analyser_directory}"
141+
shell "mv #{File.join uber_agent_directory, 'transport', 'http', 'insight-agent-http-*.jar'} #{File.join insight_analyser_directory, 'WEB-INF', 'lib'} "
134142
end
135143

136144
def container_libs_directory
@@ -159,6 +167,23 @@ def insight_home
159167
File.join @app_dir, INSIGHT_HOME
160168
end
161169

170+
def add_agent_weaver_option
171+
weaver_jar = @application.relative_path_to(Pathname.new Dir[File.join(insight_home, 'weaver', 'insight-weaver-*.jar')][0])
172+
@java_opts << "-javaagent:#{weaver_jar}"
173+
end
174+
175+
def add_agent_http_options
176+
@java_opts << '-Dagent.http.protocol=http'
177+
@java_opts << "-Dagent.http.host=#{URI(@uri).host}"
178+
@java_opts << '-Dagent.http.port=80'
179+
@java_opts << '-Dagent.http.context.path=insight'
180+
@java_opts << '-Dagent.http.username=spring'
181+
@java_opts << '-Dagent.http.password=insight'
182+
@java_opts << '-Dagent.http.send.json=false'
183+
@java_opts << '-Dagent.http.use.proxy=false'
184+
@java_opts << '-Dinsight.transport.type=HTTP'
185+
end
186+
162187
end
163188

164189
end

0 commit comments

Comments
 (0)