-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for mp health properties
Signed-off-by: Ryan Zegray <ryan.zegray@ibm.com>
- Loading branch information
1 parent
2839950
commit 7901de7
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...in/java/org/eclipse/lsp4mp/jdt/internal/health/properties/MicroProfileHealthProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.lsp4mp.jdt.internal.health.properties; | ||
|
||
import static org.eclipse.lsp4mp.jdt.internal.health.MicroProfileHealthConstants.LIVENESS_ANNOTATION; | ||
|
||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.jdt.core.IJavaProject; | ||
import org.eclipse.lsp4mp.jdt.core.AbstractStaticPropertiesProvider; | ||
import org.eclipse.lsp4mp.jdt.core.MicroProfileCorePlugin; | ||
import org.eclipse.lsp4mp.jdt.core.SearchContext; | ||
import org.eclipse.lsp4mp.jdt.core.utils.JDTTypeUtils; | ||
|
||
/** | ||
* Properties provider that provides static MicroProfile Health properties | ||
* | ||
* @author Ryan Zegray | ||
* | ||
* @see https://github.com/eclipse/microprofile-health/blob/master/spec/src/main/asciidoc/protocol-wireformat.adoc | ||
* | ||
*/ | ||
public class MicroProfileHealthProvider extends AbstractStaticPropertiesProvider { | ||
public MicroProfileHealthProvider() { | ||
super(MicroProfileCorePlugin.PLUGIN_ID, "/static-properties/mp-health-metadata.json"); | ||
} | ||
|
||
@Override | ||
protected boolean isAdaptedFor(SearchContext context, IProgressMonitor monitor) { | ||
// Check if MicroProfile health exists in classpath | ||
IJavaProject javaProject = context.getJavaProject(); | ||
return (JDTTypeUtils.findType(javaProject, LIVENESS_ANNOTATION) != null); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
microprofile.jdt/org.eclipse.lsp4mp.jdt.core/static-properties/mp-health-metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"properties": [ | ||
{ | ||
"type": "boolean", | ||
"extensionName": "microprofile-health-api", | ||
"required": false, | ||
"name": "mp.health.disable-default-procedures", | ||
"description": "Disable all default vendor procedures and display only the user-defined health check procedures." | ||
} | ||
] | ||
} |
50 changes: 50 additions & 0 deletions
50
...4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/core/health/MicroProfileHealthTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.lsp4mp.jdt.core.health; | ||
|
||
import static org.eclipse.lsp4mp.jdt.internal.core.MicroProfileAssert.assertProperties; | ||
import static org.eclipse.lsp4mp.jdt.internal.core.MicroProfileAssert.assertPropertiesDuplicate; | ||
import static org.eclipse.lsp4mp.jdt.internal.core.MicroProfileAssert.p; | ||
|
||
import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; | ||
import org.eclipse.lsp4mp.commons.MicroProfilePropertiesScope; | ||
import org.eclipse.lsp4mp.jdt.core.BasePropertiesManagerTest; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test the availability of the MicroProfile Health properties | ||
* | ||
* @author Ryan Zegray | ||
* | ||
*/ | ||
public class MicroProfileHealthTest extends BasePropertiesManagerTest { | ||
|
||
@Test | ||
public void microprofileContextPropagationPropertiesTest() throws Exception { | ||
|
||
MicroProfileProjectInfo infoFromClasspath = getMicroProfileProjectInfoFromMavenProject( | ||
MavenProjectName.microprofile_health_quickstart, MicroProfilePropertiesScope.SOURCES_AND_DEPENDENCIES); | ||
|
||
assertProperties(infoFromClasspath, | ||
|
||
p("microprofile-health-api", "mp.health.disable-default-procedures", "boolean", | ||
"Disable all default vendor procedures and display only the user-defined health check procedures.", true, | ||
null, null, null, 0, null) | ||
); | ||
|
||
assertPropertiesDuplicate(infoFromClasspath); | ||
} | ||
|
||
} |