|
| 1 | +# Encoding: utf-8 |
| 2 | +# Cloud Foundry Java Buildpack |
| 3 | +# Copyright 2013-2015 the original author or authors. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +require 'java_buildpack/component/base_component' |
| 18 | +require 'java_buildpack/framework' |
| 19 | +require 'java_buildpack/util/dash_case' |
| 20 | + |
| 21 | +module JavaBuildpack |
| 22 | + module Framework |
| 23 | + |
| 24 | + # Encapsulates the functionality for contributing Java JMX options to an application. |
| 25 | + class Jmx < JavaBuildpack::Component::BaseComponent |
| 26 | + |
| 27 | + # (see JavaBuildpack::Component::BaseComponent#detect) |
| 28 | + def detect |
| 29 | + enabled? ? "#{Jmx.to_s.dash_case}=#{port}" : nil |
| 30 | + end |
| 31 | + |
| 32 | + # (see JavaBuildpack::Component::BaseComponent#compile) |
| 33 | + def compile |
| 34 | + end |
| 35 | + |
| 36 | + # (see JavaBuildpack::Component::BaseComponent#release) |
| 37 | + def release |
| 38 | + @droplet.java_opts |
| 39 | + .add_system_property('java.rmi.server.hostname', '127.0.0.1') |
| 40 | + .add_system_property('com.sun.management.jmxremote.authenticate', false) |
| 41 | + .add_system_property('com.sun.management.jmxremote.port', port) |
| 42 | + .add_system_property('com.sun.management.jmxremote.rmi.port', port) |
| 43 | + end |
| 44 | + |
| 45 | + private |
| 46 | + |
| 47 | + def enabled? |
| 48 | + @configuration['enabled'] |
| 49 | + end |
| 50 | + |
| 51 | + def port |
| 52 | + @configuration['port'] || 5000 |
| 53 | + end |
| 54 | + |
| 55 | + end |
| 56 | + |
| 57 | + end |
| 58 | +end |
0 commit comments