Skip to content

Commit

Permalink
Add support for mp health properties
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Zegray <ryan.zegray@ibm.com>
  • Loading branch information
rzgry authored and angelozerr committed Aug 31, 2020
1 parent 2839950 commit 7901de7
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
5 changes: 5 additions & 0 deletions microprofile.jdt/org.eclipse.lsp4mp.jdt.core/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@

<!-- Microprofile Health support -->

<extension point="org.eclipse.lsp4mp.jdt.core.propertiesProviders">
<!-- Properties provider for MicroProfile Health -->
<provider class="org.eclipse.lsp4mp.jdt.internal.health.properties.MicroProfileHealthProvider" />
</extension>

<extension point="org.eclipse.lsp4mp.jdt.core.javaFeatureParticipants">
<!-- Java diagnostics for the MicroProfile Health -->
<diagnostics class="org.eclipse.lsp4mp.jdt.internal.health.java.MicroProfileHealthDiagnosticsParticipant" />
Expand Down
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);
}
}
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."
}
]
}
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);
}

}

0 comments on commit 7901de7

Please sign in to comment.