Upgrade to Boot 3.x
- For now port spring-native to framework config. - 3rd party configs should go somewhere else. - Fix changes from javax to jakarta. - Change java settings as we now require jdk 17. - Fixes #385
This commit is contained in:
@@ -21,6 +21,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.aot.hint.annotation.Reflective;
|
||||
import org.springframework.shell.context.InteractionMode;
|
||||
|
||||
/**
|
||||
@@ -32,6 +33,7 @@ import org.springframework.shell.context.InteractionMode;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
@Documented
|
||||
@Reflective
|
||||
public @interface ShellMethod {
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,6 +75,7 @@ public class StandardMethodTargetRegistrar implements MethodTargetRegistrar, App
|
||||
@Override
|
||||
public void register(CommandCatalog registry) {
|
||||
Map<String, Object> commandBeans = applicationContext.getBeansWithAnnotation(ShellComponent.class);
|
||||
log.debug("Found commandBeans to register {}", commandBeans);
|
||||
for (Object bean : commandBeans.values()) {
|
||||
Class<?> clazz = bean.getClass();
|
||||
ReflectionUtils.doWithMethods(clazz, method -> {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.shell.standard;
|
||||
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
|
||||
/**
|
||||
* {@link RuntimeHintsRegistrar} for Shell Standard resources.
|
||||
*
|
||||
* @author Janne Valkealahti
|
||||
*/
|
||||
class StandardResourcesRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.resources().registerPattern("org/springframework/shell/component/*.stg");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.shell.standard.completion;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.ReflectionHints;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.aot.hint.TypeReference;
|
||||
|
||||
/**
|
||||
* {@link RuntimeHintsRegistrar} for Shell Standard completion temlate model classes.
|
||||
*
|
||||
* @author Janne Valkealahti
|
||||
*/
|
||||
class StandardCompletionModelsRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
ReflectionHints reflection = hints.reflection();
|
||||
registerForDeclaredMethodsInvocation(reflection, AbstractCompletions.DefaultCommandModel.class,
|
||||
AbstractCompletions.DefaultCommandModelCommand.class,
|
||||
AbstractCompletions.DefaultCommandModelOption.class);
|
||||
}
|
||||
|
||||
private void registerForDeclaredMethodsInvocation(ReflectionHints reflection, Class<?>... classes) {
|
||||
reflection.registerTypes(typeReferences(classes),
|
||||
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS));
|
||||
}
|
||||
|
||||
private Iterable<TypeReference> typeReferences(Class<?>... classes) {
|
||||
return Stream.of(classes).map(TypeReference::of).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "org.springframework.shell.standard.completion.AbstractCompletions$DefaultCommandModel",
|
||||
"allDeclaredMethods": true
|
||||
},
|
||||
{
|
||||
"name": "org.springframework.shell.standard.completion.AbstractCompletions$DefaultCommandModelCommand",
|
||||
"allDeclaredMethods": true
|
||||
}
|
||||
]
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"resources": {
|
||||
"includes": [
|
||||
{
|
||||
"pattern": "completion/.*"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
org.springframework.aot.hint.RuntimeHintsRegistrar=\
|
||||
org.springframework.shell.standard.StandardResourcesRuntimeHints,\
|
||||
org.springframework.shell.standard.completion.StandardCompletionModelsRuntimeHints
|
||||
Reference in New Issue
Block a user