You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by jd...@apache.org on 2025/07/12 03:21:23 UTC
(grails-core) 07/09: removal: remove old, deprecated class `BaseApiProvider`
This is an automated email from the ASF dual-hosted git repository.
jdaugherty pushed a commit to branch deprecationRemovals
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 1718f9a3ca5c78c696a5166eadc182ac9c4298c3
Author: James Daugherty <jd...@jdresources.net>
AuthorDate: Fri Jul 11 23:13:00 2025 -0400
removal: remove old, deprecated class `BaseApiProvider`
---
.../org/grails/core/metaclass/BaseApiProvider.java | 152 ---------------------
.../src/en/guide/upgrading/upgrading60x.adoc | 14 +-
2 files changed, 9 insertions(+), 157 deletions(-)
diff --git a/grails-core/src/main/groovy/org/grails/core/metaclass/BaseApiProvider.java b/grails-core/src/main/groovy/org/grails/core/metaclass/BaseApiProvider.java
deleted file mode 100644
index c1c624710f..0000000000
--- a/grails-core/src/main/groovy/org/grails/core/metaclass/BaseApiProvider.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.grails.core.metaclass;
-
-import grails.util.GrailsNameUtils;
-import groovy.lang.GString;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import grails.util.GrailsArrayUtils;
-import grails.util.GrailsClassUtils;
-import org.codehaus.groovy.reflection.CachedClass;
-import org.codehaus.groovy.reflection.CachedMethod;
-import org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod;
-
-/**
- * @author Graeme Rocher
- * @since 2.0
- * @deprecated Use traits instead
- */
-@Deprecated
-public abstract class BaseApiProvider {
-
- private static List<String> EXCLUDED_METHODS = Arrays.asList("setMetaClass", "getMetaClass", "setProperties", "getProperties");
-
- public static final String CONSTRUCTOR_METHOD = "initialize";
- public static final String CTOR_GROOVY_METHOD = "<ctor>";
-
- @SuppressWarnings("rawtypes")
- protected List instanceMethods = new ArrayList();
- protected List<Method> staticMethods = new ArrayList<Method>();
- protected List<Method> constructors = new ArrayList<Method>();
-
- @SuppressWarnings("unchecked")
- public void addApi(final Object apiInstance) {
- if (apiInstance == null) {
- return;
- }
-
- Class<?> currentClass = apiInstance.getClass();
- while (currentClass != Object.class) {
- final Method[] declaredMethods = currentClass.getDeclaredMethods();
-
- for (final Method javaMethod : declaredMethods) {
- final int modifiers = javaMethod.getModifiers();
- if (!isNotExcluded(javaMethod, modifiers)) {
- continue;
- }
-
- if (Modifier.isStatic(modifiers)) {
- if (isConstructorCallMethod(javaMethod)) {
- constructors.add(javaMethod);
- }
- else {
- staticMethods.add(javaMethod);
- }
- }
- else {
- instanceMethods.add(new ReflectionMetaMethod(new CachedMethod(javaMethod)) {
- {
- CachedClass[] paramTypes = super.getParameterTypes();
- if(paramTypes.length > 0) {
- setParametersTypes((CachedClass[]) GrailsArrayUtils.subarray(paramTypes, 1, paramTypes.length));
- }
- }
-
- @Override
- public String getName() {
- String methodName = super.getName();
- if (isConstructorCallMethod(javaMethod)) {
- return CTOR_GROOVY_METHOD;
- }
- return methodName;
- }
-
- @Override
- public Object invoke(Object object, Object[] arguments) {
- if (arguments.length == 0) {
- return super.invoke(apiInstance, new Object[]{object});
- }
- return super.invoke(apiInstance, (Object[])GrailsArrayUtils.add(checkForGStrings(arguments), 0, object));
- }
-
- private Object[] checkForGStrings(Object[] arguments) {
- for (int i = 0; i < arguments.length; i++) {
- if (arguments[i] instanceof GString) {
- arguments[i] = arguments[i].toString();
- }
- }
- return arguments;
- }
-
- @Override
- public CachedClass[] getParameterTypes() {
- final CachedClass[] paramTypes = method.getParameterTypes();
- if (paramTypes.length > 0) {
- return (CachedClass[]) GrailsArrayUtils.subarray(paramTypes, 1, paramTypes.length);
- }
- return paramTypes;
- }
- });
- }
- }
- currentClass = currentClass.getSuperclass();
- }
- }
-
- private boolean isConstructorCallMethod(Method method) {
- return method != null && Modifier.isStatic(method.getModifiers()) && Modifier.isPublic(method.getModifiers()) && method.getName().equals(CONSTRUCTOR_METHOD) && method.getParameterTypes().length>0;
- }
-
- private boolean isNotExcluded(Method method, final int modifiers) {
- final String name = method.getName();
-
- if (EXCLUDED_METHODS.contains(name)) return false;
-
- boolean isStatic = Modifier.isStatic(modifiers);
-
- // skip plain setters/getters by default for instance methods (non-static)
- if (!isStatic && (GrailsClassUtils.isSetter(name, method.getParameterTypes()) || GrailsNameUtils.isGetter(name, method.getReturnType(), method.getParameterTypes()))) {
- return false;
- }
-
- int minParameters = isStatic ? 0 : 1;
-
- return Modifier.isPublic(modifiers) &&
- !(method.isSynthetic() || method.isBridge()) &&
- !Modifier.isAbstract(modifiers) &&
- !name.contains("$") &&
- (method.getParameterTypes().length >= minParameters);
- }
-}
diff --git a/grails-doc/src/en/guide/upgrading/upgrading60x.adoc b/grails-doc/src/en/guide/upgrading/upgrading60x.adoc
index 70eaadde55..419a6a465f 100644
--- a/grails-doc/src/en/guide/upgrading/upgrading60x.adoc
+++ b/grails-doc/src/en/guide/upgrading/upgrading60x.adoc
@@ -235,11 +235,15 @@ jakartaeeMigration {
===== 12.3 Removed libraries/classes
- The `grails-web-fileupload` library, including its sole class `ContentLengthAwareCommonsMultipartResolver`, has been removed. This change was necessitated by the removal of the superclass `CommonsMultipartResolver` in Spring 6. The `ContentLengthAwareCommonsMultipartResolver` was originally introduced to address a bug in Safari back in 2007, but it is likely no longer needed. Spring has transitioned away from `CommonsMultipartResolver` and now recommends using the built-in support for [...]
-- `org.grails.spring.beans.factory.OptimizedAutowireCapableBeanFactory` was previously deprecated and is now removed.
-- the `checkForChangesExpected` on GrailsPlugin was previously deprecated and is now removed.
-- `GrailsClassUtils#isGetter(String, Class[])` was previously deprecated and is now removed. Use `isGetter(String, Class, Class[])` instead.
-- `GrailsClassUtils#getPropertyForGetter(String)` was previously deprecated and is now removed. Use `getPropertyForGetter(String, Class)` instead.
-- `AbstractGrailsClass#getPropertyDescriptors` was previously deprecated and is now removed. Use `getMetaProperties` instead.
+- Removed deprecations:
+
+1. `org.grails.spring.beans.factory.OptimizedAutowireCapableBeanFactory`
+2. `GrailsPlugin#checkForChangesExpected`
+3. `GrailsClassUtils#isGetter(String, Class[])` - use `isGetter(String, Class, Class[])` instead.
+4. `GrailsClassUtils#getPropertyForGetter(String)` - use `getPropertyForGetter(String, Class)` instead.
+5. `AbstractGrailsClass#getPropertyDescriptors` - use `getMetaProperties` instead.
+6. `org.grails.core.metaclass.BaseApiProvider` - use traits instead.
+
- The following deprecated classes were removed, please use the suggested replacement:
1. `grails.core.GrailsTagLibClass` -> `grails.core.gsp.GrailsTagLibClass`