File tree Expand file tree Collapse file tree 4 files changed +71
-0
lines changed
components/sbm-recipes-boot-upgrade/src/main
java/org/springframework/sbm/boot/upgrade_27_30 Expand file tree Collapse file tree 4 files changed +71
-0
lines changed Original file line number Diff line number Diff line change
1
+ package org .springframework .sbm .boot .upgrade_27_30 .actions ;
2
+
3
+ import org .springframework .sbm .boot .properties .finder .SpringBootDefaultPropertiesFinder ;
4
+ import org .springframework .sbm .engine .context .ProjectContext ;
5
+ import org .springframework .sbm .engine .recipe .AbstractAction ;
6
+
7
+ import java .util .Optional ;
8
+
9
+ public class Boot_27_30_JmxEndpointExposureAction extends AbstractAction {
10
+
11
+ public static final String JMX_ENDPOINT = "management.endpoints.jmx.exposure.include" ;
12
+
13
+ @ Override
14
+ public void apply (ProjectContext context ) {
15
+ SpringBootDefaultPropertiesFinder springBootDefaultPropertiesFinder = new SpringBootDefaultPropertiesFinder ();
16
+
17
+ context .getApplicationModules ()
18
+ .getTopmostApplicationModules ()
19
+ .stream ()
20
+ .map (m -> m .searchMainResources (springBootDefaultPropertiesFinder ))
21
+ .filter (Optional ::isPresent )
22
+ .map (Optional ::get )
23
+ .forEach (p -> {
24
+ if (!p .getProperty (JMX_ENDPOINT ).isPresent ()) {
25
+ p .setProperty (JMX_ENDPOINT , "*" );
26
+ }
27
+ });
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ package org .springframework .sbm .boot .upgrade_27_30 .conditions ;
2
+
3
+ import org .springframework .sbm .boot .upgrade_27_30 .filter .JmxEndpointExposureFinder ;
4
+ import org .springframework .sbm .engine .context .ProjectContext ;
5
+ import org .springframework .sbm .engine .recipe .Condition ;
6
+
7
+ public class JmxEndpointExposureCondition implements Condition {
8
+ @ Override
9
+ public String getDescription () {
10
+ return "Check if 'management.endpoints.jmx.exposure.include' is declared." ;
11
+ }
12
+
13
+ @ Override
14
+ public boolean evaluate (ProjectContext context ) {
15
+ return context .search (new JmxEndpointExposureFinder ()).isEmpty ();
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ package org .springframework .sbm .boot .upgrade_27_30 .filter ;
2
+
3
+ import org .springframework .sbm .boot .properties .api .SpringBootApplicationProperties ;
4
+ import org .springframework .sbm .boot .properties .search .SpringBootApplicationPropertiesResourceListFilter ;
5
+ import org .springframework .sbm .project .resource .ProjectResourceSet ;
6
+ import org .springframework .sbm .project .resource .filter .ProjectResourceFinder ;
7
+ import org .springframework .sbm .properties .api .PropertiesSource ;
8
+
9
+ import java .util .List ;
10
+
11
+ public class JmxEndpointExposureFinder implements ProjectResourceFinder <List <? extends PropertiesSource >> {
12
+ public static final String JMX_ENDPOINT_KEY = "management.endpoints.jmx.exposure.include" ;
13
+
14
+ @ Override
15
+ public List <? extends PropertiesSource > apply (ProjectResourceSet projectResourceSet ) {
16
+ List <SpringBootApplicationProperties > springBootApplicationProperties = new SpringBootApplicationPropertiesResourceListFilter ().apply (projectResourceSet );
17
+ return springBootApplicationProperties .stream ()
18
+ .filter (find -> find .getProperty (JMX_ENDPOINT_KEY ).isPresent ())
19
+ .toList ();
20
+ }
21
+ }
Original file line number Diff line number Diff line change 17
17
description : " Sets logging date format to yyyy-MM-dd HH:mm:ss.SSS"
18
18
condition :
19
19
type : org.springframework.sbm.boot.upgrade_27_30.conditions.LoggingDateFormatCondition
20
+ - type : org.springframework.sbm.boot.upgrade_27_30.actions.Boot_27_30_JmxEndpointExposureAction
21
+ description : " Sets JMX endpoint exposure include to *"
22
+ condition :
23
+ type : rg.springframework.sbm.boot.upgrade_27_30.conditions.JmxEndpointExposureCondition
You can’t perform that action at this time.
0 commit comments