Skip to content

Commit 56f2047

Browse files
ekcaseysabbey37
authored andcommitted
Move tomcat_version from config to a constructor param
Signed-off-by: Emily Casey <[email protected]> (cherry picked from commit 1a9733e)
1 parent 411241d commit 56f2047

File tree

8 files changed

+28
-15
lines changed

8 files changed

+28
-15
lines changed

config/open_jdk_jre.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jvmkill_agent:
2525
memory_calculator:
2626
version: 3.+
2727
repository_root: "{default.repository.root}/memory-calculator/{platform}/{architecture}"
28-
class_count:
29-
headroom:
28+
class_count:
29+
headroom:
3030
stack_threads: 250

lib/java_buildpack/container/tomcat.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ def command
5454
def sub_components(context)
5555
instance = TomcatInstance.new(sub_configuration_context(context, 'tomcat'))
5656
# pass Tomcat major version to geode_store so we can verify compatibility.
57-
@configuration['geode_store']['tomcat_version'] = instance.instance_variable_get(:@version)[0]
57+
tomcat_version = instance.instance_variable_get(:@version)[0]
5858

5959
components = [
6060
instance,
6161
TomcatAccessLoggingSupport.new(sub_configuration_context(context, 'access_logging_support')),
62-
TomcatGeodeStore.new(sub_configuration_context(context, 'geode_store')),
62+
TomcatGeodeStore.new(sub_configuration_context(context, 'geode_store'), tomcat_version),
6363
TomcatInsightSupport.new(context),
6464
TomcatLifecycleSupport.new(sub_configuration_context(context, 'lifecycle_support')),
6565
TomcatLoggingSupport.new(sub_configuration_context(context, 'logging_support')),

lib/java_buildpack/container/tomcat/tomcat_geode_store.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ module Container
2727
class TomcatGeodeStore < JavaBuildpack::Component::VersionedDependencyComponent
2828
include JavaBuildpack::Container
2929

30+
# Creates an instance. In addition to the functionality inherited from +VersionedDependencyComponent+
31+
# +@tomcat_version+ instance variable is exposed.
32+
#
33+
# @param [Hash] context a collection of utilities used by components
34+
# @param [String] tomcat_version is the major version of tomcat
35+
def initialize(context, tomcat_version)
36+
super(context)
37+
@tomcat_version = tomcat_version
38+
end
39+
3040
# (see JavaBuildpack::Component::BaseComponent#compile)
3141
def compile
3242
return unless supports?
@@ -144,16 +154,15 @@ def detect_geode_tomcat_version
144154
'Please verify your geode_store tar contains a geode-modules-tomcat jar.')
145155
end
146156

147-
tomcat_version = @configuration['tomcat_version']
157+
puts " Detected Geode Tomcat #{geode_tomcat_version} module"
148158

149159
# leave possibility for generic jar/session manager class that is compatible with all tomcat versions
150-
if !geode_tomcat_version.empty? && geode_tomcat_version != tomcat_version
151-
puts " WARNING: Tomcat version #{tomcat_version} " \
160+
if !geode_tomcat_version.empty? && geode_tomcat_version != @tomcat_version
161+
puts " WARNING: Tomcat version #{@tomcat_version} " \
152162
"does not match Geode Tomcat #{geode_tomcat_version} module. " \
153163
'If you encounter compatibility issues, please make sure these versions match.'
154164
end
155165

156-
puts " Detected Geode Tomcat #{geode_tomcat_version} module"
157166
@session_manager_classname =
158167
"org.apache.geode.modules.session.catalina.Tomcat#{geode_tomcat_version}DeltaSessionManager"
159168
end

spec/fixtures/container_no_tomcat_version_geode_store_context_after.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<!--
33
~ Cloud Foundry Java Buildpack
4-
~ Copyright 2013-2021 the original author or authors.
4+
~ Copyright 2013-2020 the original author or authors.
55
~
66
~ Licensed under the Apache License, Version 2.0 (the "License");
77
~ you may not use this file except in compliance with the License.

spec/fixtures/container_tomcat8_geode_store_context_after.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<!--
33
~ Cloud Foundry Java Buildpack
4-
~ Copyright 2013-2021 the original author or authors.
4+
~ Copyright 2013-2020 the original author or authors.
55
~
66
~ Licensed under the Apache License, Version 2.0 (the "License");
77
~ you may not use this file except in compliance with the License.

spec/fixtures/container_tomcat_geode_store_context_after.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<!--
33
~ Cloud Foundry Java Buildpack
4-
~ Copyright 2013-2021 the original author or authors.
4+
~ Copyright 2013-2020 the original author or authors.
55
~
66
~ Licensed under the Apache License, Version 2.0 (the "License");
77
~ you may not use this file except in compliance with the License.

spec/java_buildpack/container/tomcat/tomcat_geode_store_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
describe JavaBuildpack::Container::TomcatGeodeStore do
2323
include_context 'with component help'
2424

25+
let(:component) { described_class.new(context, '9') }
26+
2527
let(:component_id) { 'tomcat' }
2628

2729
let(:configuration) do
@@ -83,9 +85,11 @@
8385
app_fixture: 'container_tomcat_geode_store',
8486
cache_fixture: 'stub-geode-store.tar' do
8587

88+
component = described_class.new(context, '8')
89+
8690
expect { component.compile }.to output(
8791
# rubocop:disable Layout/LineLength
88-
/WARNING: Tomcat version does not match Geode Tomcat 9 module\. If you encounter compatibility issues, please make sure these versions match\./
92+
/WARNING: Tomcat version 8 does not match Geode Tomcat 9 module\. If you encounter compatibility issues, please make sure these versions match\./
8993
# rubocop:enable Layout/LineLength
9094
).to_stdout
9195
end

spec/java_buildpack/container/tomcat_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
let(:lifecycle_support_configuration) { instance_double('lifecycle-support-configuration') }
4848

4949
let(:logging_support_configuration) { instance_double('logging-support-configuration') }
50-
# pass empty hash, so tomcat_version can be added in `sub_components` method
51-
let(:geode_store_configuration) { {} }
50+
51+
let(:geode_store_configuration) { instance_double('geode_store_configuration') }
5252

5353
let(:redis_store_configuration) { instance_double('redis-store-configuration') }
5454

@@ -84,7 +84,7 @@
8484
allow(JavaBuildpack::Container::TomcatAccessLoggingSupport)
8585
.to receive(:new).with(sub_configuration_context(access_logging_support_configuration))
8686
allow(JavaBuildpack::Container::TomcatGeodeStore)
87-
.to receive(:new).with(sub_configuration_context(geode_store_configuration))
87+
.to receive(:new).with(sub_configuration_context(geode_store_configuration), '9')
8888
allow(JavaBuildpack::Container::TomcatInsightSupport).to receive(:new).with(context)
8989
allow(JavaBuildpack::Container::TomcatLifecycleSupport)
9090
.to receive(:new).with(sub_configuration_context(lifecycle_support_configuration))

0 commit comments

Comments
 (0)