From efc335e19894bda8aa149840bb8dec053dbede4c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 16 Feb 2021 11:16:14 +0100 Subject: [PATCH] Remove remaining Kotlin "translations" of Java APIs in the reference manual --- src/docs/asciidoc/core/core-aop-api.adoc | 104 +----------- src/docs/asciidoc/core/core-beans.adoc | 92 +---------- src/docs/asciidoc/core/core-resources.adoc | 5 - src/docs/asciidoc/core/core-validation.adoc | 168 ++------------------ src/docs/asciidoc/data-access.adoc | 91 +---------- 5 files changed, 33 insertions(+), 427 deletions(-) diff --git a/src/docs/asciidoc/core/core-aop-api.adoc b/src/docs/asciidoc/core/core-aop-api.adoc index cbfbab9e0bc6..4b7a21573fc2 100644 --- a/src/docs/asciidoc/core/core-aop-api.adoc +++ b/src/docs/asciidoc/core/core-aop-api.adoc @@ -25,26 +25,13 @@ target different advice with the same pointcut. The `org.springframework.aop.Pointcut` interface is the central interface, used to target advices to particular classes and methods. The complete interface follows: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface Pointcut { ClassFilter getClassFilter(); MethodMatcher getMethodMatcher(); - - } ----- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface Pointcut { - - fun getClassFilter(): ClassFilter - - fun getMethodMatcher(): MethodMatcher - } ---- @@ -56,27 +43,17 @@ The `ClassFilter` interface is used to restrict the pointcut to a given set of t classes. If the `matches()` method always returns true, all target classes are matched. The following listing shows the `ClassFilter` interface definition: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface ClassFilter { boolean matches(Class clazz); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface ClassFilter { - - fun matches(clazz: Class<*>): Boolean - } ----- The `MethodMatcher` interface is normally more important. The complete interface follows: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface MethodMatcher { @@ -87,18 +64,6 @@ The `MethodMatcher` interface is normally more important. The complete interface boolean matches(Method m, Class targetClass, Object[] args); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface MethodMatcher { - - val isRuntime: Boolean - - fun matches(m: Method, targetClass: Class<*>): Boolean - - fun matches(m: Method, targetClass: Class<*>, args: Array): Boolean - } ----- The `matches(Method, Class)` method is used to test whether this pointcut ever matches a given method on a target class. This evaluation can be performed when an AOP @@ -335,22 +300,13 @@ Spring is compliant with the AOP `Alliance` interface for around advice that use interception. Classes that implement `MethodInterceptor` and that implement around advice should also implement the following interface: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface MethodInterceptor extends Interceptor { Object invoke(MethodInvocation invocation) throws Throwable; } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface MethodInterceptor : Interceptor { - - fun invoke(invocation: MethodInvocation) : Any - } ----- The `MethodInvocation` argument to the `invoke()` method exposes the method being invoked, the target join point, the AOP proxy, and the arguments to the method. The @@ -413,22 +369,13 @@ interceptor chain. The following listing shows the `MethodBeforeAdvice` interface: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface MethodBeforeAdvice extends BeforeAdvice { void before(Method m, Object[] args, Object target) throws Throwable; } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- -interface MethodBeforeAdvice : BeforeAdvice { - - fun before(m: Method, args: Array, target: Any) -} ----- (Spring's API design would allow for field before advice, although the usual objects apply to field interception and it is @@ -591,8 +538,7 @@ TIP: Throws advice can be used with any pointcut. An after returning advice in Spring must implement the `org.springframework.aop.AfterReturningAdvice` interface, which the following listing shows: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface AfterReturningAdvice extends Advice { @@ -600,14 +546,6 @@ An after returning advice in Spring must implement the throws Throwable; } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface AfterReturningAdvice : Advice { - - fun afterReturning(returnValue: Any, m: Method, args: Array, target: Any) - } ----- An after returning advice has access to the return value (which it cannot modify), the invoked method, the method's arguments, and the target. @@ -660,22 +598,13 @@ Spring treats introduction advice as a special kind of interception advice. Introduction requires an `IntroductionAdvisor` and an `IntroductionInterceptor` that implement the following interface: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface IntroductionInterceptor extends MethodInterceptor { boolean implementsInterface(Class intf); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface IntroductionInterceptor : MethodInterceptor { - - fun implementsInterface(intf: Class<*>): Boolean - } ----- The `invoke()` method inherited from the AOP Alliance `MethodInterceptor` interface must implement the introduction. That is, if the invoked method is on an introduced @@ -686,8 +615,7 @@ Introduction advice cannot be used with any pointcut, as it applies only at the rather than the method, level. You can only use introduction advice with the `IntroductionAdvisor`, which has the following methods: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface IntroductionAdvisor extends Advisor, IntroductionInfo { @@ -701,22 +629,6 @@ rather than the method, level. You can only use introduction advice with the Class[] getInterfaces(); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface IntroductionAdvisor : Advisor, IntroductionInfo { - - val classFilter: ClassFilter - - @Throws(IllegalArgumentException::class) - fun validateInterfaces() - } - - interface IntroductionInfo { - - val interfaces: Array> - } ----- There is no `MethodMatcher` and, hence, no `Pointcut` associated with introduction advice. Only class filtering is logical. diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index 6aa1d45a1578..258082f2f0ee 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -3406,16 +3406,10 @@ The `org.springframework.beans.factory.InitializingBean` interface lets a bean perform initialization work after the container has set all necessary properties on the bean. The `InitializingBean` interface specifies a single method: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- void afterPropertiesSet() throws Exception; ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - fun afterPropertiesSet() ----- We recommend that you do not use the `InitializingBean` interface, because it unnecessarily couples the code to Spring. Alternatively, we suggest using @@ -3491,16 +3485,10 @@ Implementing the `org.springframework.beans.factory.DisposableBean` interface le bean get a callback when the container that contains it is destroyed. The `DisposableBean` interface specifies a single method: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- void destroy() throws Exception; ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - fun destroy() ----- We recommend that you do not use the `DisposableBean` callback interface, because it unnecessarily couples the code to Spring. Alternatively, we suggest using @@ -3711,8 +3699,7 @@ Destroy methods are called in the same order: The `Lifecycle` interface defines the essential methods for any object that has its own lifecycle requirements (such as starting and stopping some background process): -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface Lifecycle { @@ -3723,18 +3710,6 @@ lifecycle requirements (such as starting and stopping some background process): boolean isRunning(); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface Lifecycle { - - fun start() - - fun stop() - - val isRunning: Boolean - } ----- Any Spring-managed object may implement the `Lifecycle` interface. Then, when the `ApplicationContext` itself receives start and stop signals (for example, for a stop/restart @@ -3742,8 +3717,7 @@ scenario at runtime), it cascades those calls to all `Lifecycle` implementations defined within that context. It does this by delegating to a `LifecycleProcessor`, shown in the following listing: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface LifecycleProcessor extends Lifecycle { @@ -3752,16 +3726,6 @@ in the following listing: void onClose(); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface LifecycleProcessor : Lifecycle { - - fun onRefresh() - - fun onClose() - } ----- Notice that the `LifecycleProcessor` is itself an extension of the `Lifecycle` interface. It also adds two other methods for reacting to the context being refreshed @@ -3788,27 +3752,17 @@ prior to objects of another type. In those cases, the `SmartLifecycle` interface another option, namely the `getPhase()` method as defined on its super-interface, `Phased`. The following listing shows the definition of the `Phased` interface: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface Phased { int getPhase(); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface Phased { - - val phase: Int - } ----- The following listing shows the definition of the `SmartLifecycle` interface: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface SmartLifecycle extends Lifecycle, Phased { @@ -3817,16 +3771,6 @@ The following listing shows the definition of the `SmartLifecycle` interface: void stop(Runnable callback); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface SmartLifecycle : Lifecycle, Phased { - - val isAutoStartup: Boolean - - fun stop(callback: Runnable) - } ----- When starting, the objects with the lowest phase start first. When stopping, the reverse order is followed. Therefore, an object that implements `SmartLifecycle` and @@ -3938,23 +3882,13 @@ When an `ApplicationContext` creates an object instance that implements the with a reference to that `ApplicationContext`. The following listing shows the definition of the `ApplicationContextAware` interface: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface ApplicationContextAware { void setApplicationContext(ApplicationContext applicationContext) throws BeansException; } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface ApplicationContextAware { - - @Throws(BeansException::class) - fun setApplicationContext(applicationContext: ApplicationContext) - } ----- Thus, beans can programmatically manipulate the `ApplicationContext` that created them, through the `ApplicationContext` interface or by casting the reference to a known @@ -3983,23 +3917,13 @@ When an `ApplicationContext` creates a class that implements the a reference to the name defined in its associated object definition. The following listing shows the definition of the BeanNameAware interface: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface BeanNameAware { void setBeanName(String name) throws BeansException; } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface BeanNameAware { - - @Throws(BeansException::class) - fun setBeanName(name: String) - } ----- The callback is invoked after population of normal bean properties but before an initialization callback such as `InitializingBean`, `afterPropertiesSet`, or a custom diff --git a/src/docs/asciidoc/core/core-resources.adoc b/src/docs/asciidoc/core/core-resources.adoc index 155410b125fe..812b8163b65c 100644 --- a/src/docs/asciidoc/core/core-resources.adoc +++ b/src/docs/asciidoc/core/core-resources.adoc @@ -41,7 +41,6 @@ following listing provides an overview of the `Resource` interface. See the [source,java,indent=0,subs="verbatim,quotes"] -.Java ---- public interface Resource extends InputStreamSource { @@ -78,7 +77,6 @@ interface. The following listing shows the definition of the `InputStreamSource` interface: [source,java,indent=0,subs="verbatim,quotes"] -.Java ---- public interface InputStreamSource { @@ -261,7 +259,6 @@ The `ResourceLoader` interface is meant to be implemented by objects that can re interface definition: [source,java,indent=0,subs="verbatim,quotes"] -.Java ---- public interface ResourceLoader { @@ -374,7 +371,6 @@ which defines a strategy for resolving a location pattern (for example, an Ant-s pattern) into `Resource` objects. [source,java,indent=0,subs="verbatim,quotes"] -.Java ---- public interface ResourcePatternResolver extends ResourceLoader { @@ -426,7 +422,6 @@ components that expect to be provided a `ResourceLoader` reference. The followin shows the definition of the `ResourceLoaderAware` interface: [source,java,indent=0,subs="verbatim,quotes"] -.Java ---- public interface ResourceLoaderAware { diff --git a/src/docs/asciidoc/core/core-validation.adoc b/src/docs/asciidoc/core/core-validation.adoc index dc8287172453..db0c054ffb84 100644 --- a/src/docs/asciidoc/core/core-validation.adoc +++ b/src/docs/asciidoc/core/core-validation.adoc @@ -874,8 +874,7 @@ application where type conversion is needed. The SPI to implement type conversion logic is simple and strongly typed, as the following interface definition shows: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- package org.springframework.core.convert.converter; @@ -884,16 +883,6 @@ interface definition shows: T convert(S source); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - package org.springframework.core.convert.converter - - interface Converter { - - fun convert(source: S): T - } ----- To create your own converter, implement the `Converter` interface and parameterize `S` as the type you are converting from and `T` as the type you are converting to. You can also transparently apply such a @@ -910,8 +899,7 @@ Several converter implementations are provided in the `core.convert.support` pac a convenience. These include converters from strings to numbers and other common types. The following listing shows the `StringToInteger` class, which is a typical `Converter` implementation: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- package org.springframework.core.convert.support; @@ -922,20 +910,6 @@ The following listing shows the `StringToInteger` class, which is a typical `Con } } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - package org.springframework.core.convert.support - - import org.springframework.core.convert.converter.Converter - - internal class StringToInteger : Converter { - - override fun convert(source: String): Int? { - return Integer.valueOf(source) - } - } ----- @@ -946,8 +920,7 @@ When you need to centralize the conversion logic for an entire class hierarchy (for example, when converting from `String` to `Enum` objects), you can implement `ConverterFactory`, as the following example shows: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- package org.springframework.core.convert.converter; @@ -956,16 +929,6 @@ When you need to centralize the conversion logic for an entire class hierarchy Converter getConverter(Class targetType); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - package org.springframework.core.convert.converter - - interface ConverterFactory { - - fun getConverter(targetType: Class): Converter - } ----- Parameterize S to be the type you are converting from and R to be the base type defining the __range__ of classes you can convert to. Then implement `getConverter(Class)`, @@ -974,7 +937,6 @@ where T is a subclass of R. Consider the `StringToEnumConverterFactory` as an example: [source,java,indent=0,subs="verbatim,quotes"] -.Java ---- package org.springframework.core.convert.support; @@ -1011,8 +973,7 @@ context that you can use when you implement your conversion logic. Such context type conversion be driven by a field annotation or by generic information declared on a field signature. The following listing shows the interface definition of `GenericConverter`: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- package org.springframework.core.convert.converter; @@ -1023,18 +984,6 @@ field signature. The following listing shows the interface definition of `Generi Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - package org.springframework.core.convert.converter - - interface GenericConverter { - - fun getConvertibleTypes(): Set? - - fun convert(@Nullable source: Any?, sourceType: TypeDescriptor, targetType: TypeDescriptor): Any? - } ----- To implement a `GenericConverter`, have `getConvertibleTypes()` return the supported source->target type pairs. Then implement `convert(Object, TypeDescriptor, @@ -1063,8 +1012,7 @@ on the target field, or you might want to run a `Converter` only if a specific m `ConditionalGenericConverter` is the union of the `GenericConverter` and `ConditionalConverter` interfaces that lets you define such custom matching criteria: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface ConditionalConverter { @@ -1074,16 +1022,6 @@ on the target field, or you might want to run a `Converter` only if a specific m public interface ConditionalGenericConverter extends GenericConverter, ConditionalConverter { } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface ConditionalConverter { - - fun matches(sourceType: TypeDescriptor, targetType: TypeDescriptor): Boolean - } - - interface ConditionalGenericConverter : GenericConverter, ConditionalConverter ----- A good example of a `ConditionalGenericConverter` is an `EntityConverter` that converts between a persistent entity identifier and an entity reference. Such an `EntityConverter` @@ -1099,8 +1037,7 @@ might match only if the target entity type declares a static finder method (for `ConversionService` defines a unified API for executing type conversion logic at runtime. Converters are often run behind the following facade interface: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- package org.springframework.core.convert; @@ -1113,24 +1050,6 @@ runtime. Converters are often run behind the following facade interface: boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType); Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType); - - } ----- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - package org.springframework.core.convert - - interface ConversionService { - - fun canConvert(sourceType: Class<*>, targetType: Class<*>): Boolean - - fun convert(source: Any, targetType: Class): T - - fun canConvert(sourceType: TypeDescriptor, targetType: TypeDescriptor): Boolean - - fun convert(source: Any, sourceType: TypeDescriptor, targetType: TypeDescriptor): Any - } ---- @@ -1301,8 +1220,7 @@ provides a unified type conversion API for both SPIs. The `Formatter` SPI to implement field formatting logic is simple and strongly typed. The following listing shows the `Formatter` interface definition: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- package org.springframework.format; @@ -1313,25 +1231,15 @@ following listing shows the `Formatter` interface definition: `Formatter` extends from the `Printer` and `Parser` building-block interfaces. The following listing shows the definitions of those two interfaces: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface Printer { String print(T fieldValue, Locale locale); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface Printer { - - fun print(fieldValue: T, locale: Locale): String - } ----- -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- import java.text.ParseException; @@ -1340,15 +1248,6 @@ following listing shows the definitions of those two interfaces: T parse(String clientValue, Locale locale) throws ParseException; } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface Parser { - - @Throws(ParseException::class) - fun parse(clientValue: String, locale: Locale): T - } ----- To create your own `Formatter`, implement the `Formatter` interface shown earlier. Parameterize `T` to be the type of object you wish to format -- for example, @@ -1432,8 +1331,7 @@ Field formatting can be configured by field type or annotation. To bind an annotation to a `Formatter`, implement `AnnotationFormatterFactory`. The following listing shows the definition of the `AnnotationFormatterFactory` interface: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- package org.springframework.format; @@ -1446,20 +1344,6 @@ listing shows the definition of the `AnnotationFormatterFactory` interface: Parser getParser(A annotation, Class fieldType); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - package org.springframework.format - - interface AnnotationFormatterFactory { - - val fieldTypes: Set> - - fun getPrinter(annotation: A, fieldType: Class<*>): Printer<*> - - fun getParser(annotation: A, fieldType: Class<*>): Parser<*> - } ----- To create an implementation: . Parameterize A to be the field `annotationType` with which you wish to associate @@ -1602,8 +1486,7 @@ for use with Spring's `DataBinder` and the Spring Expression Language (SpEL). The following listing shows the `FormatterRegistry` SPI: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- package org.springframework.format; @@ -1618,22 +1501,6 @@ The following listing shows the `FormatterRegistry` SPI: void addFormatterForAnnotation(AnnotationFormatterFactory factory); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - package org.springframework.format - - interface FormatterRegistry : ConverterRegistry { - - fun addFormatterForFieldType(fieldType: Class<*>, printer: Printer<*>, parser: Parser<*>) - - fun addFormatterForFieldType(fieldType: Class<*>, formatter: Formatter<*>) - - fun addFormatterForFieldType(formatter: Formatter<*>) - - fun addFormatterForAnnotation(factory: AnnotationFormatterFactory<*>) - } ----- As shown in the preceding listing, you can register formatters by field type or by annotation. @@ -1651,8 +1518,7 @@ these rules once, and they are applied whenever formatting is needed. `FormatterRegistrar` is an SPI for registering formatters and converters through the FormatterRegistry. The following listing shows its interface definition: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- package org.springframework.format; @@ -1661,16 +1527,6 @@ FormatterRegistry. The following listing shows its interface definition: void registerFormatters(FormatterRegistry registry); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - package org.springframework.format - - interface FormatterRegistrar { - - fun registerFormatters(registry: FormatterRegistry) - } ----- A `FormatterRegistrar` is useful when registering multiple related converters and formatters for a given formatting category, such as date formatting. It can also be diff --git a/src/docs/asciidoc/data-access.adoc b/src/docs/asciidoc/data-access.adoc index aa4685a79a9e..0dc692dad161 100644 --- a/src/docs/asciidoc/data-access.adoc +++ b/src/docs/asciidoc/data-access.adoc @@ -158,8 +158,7 @@ transaction management and the transaction management. The following listing shows the definition of the `PlatformTransactionManager` API: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface PlatformTransactionManager extends TransactionManager { @@ -170,21 +169,6 @@ transaction management. The following listing shows the definition of the void rollback(TransactionStatus status) throws TransactionException; } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface PlatformTransactionManager : TransactionManager { - - @Throws(TransactionException::class) - fun getTransaction(definition: TransactionDefinition): TransactionStatus - - @Throws(TransactionException::class) - fun commit(status: TransactionStatus) - - @Throws(TransactionException::class) - fun rollback(status: TransactionStatus) - } ----- This is primarily a service provider interface (SPI), although you can use it <> from your application code. Because @@ -215,8 +199,7 @@ reactive applications that make use of reactive types or Kotlin Coroutines. The listing shows the transaction strategy defined by `org.springframework.transaction.ReactiveTransactionManager`: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface ReactiveTransactionManager extends TransactionManager { @@ -227,21 +210,6 @@ listing shows the transaction strategy defined by Mono rollback(ReactiveTransaction status) throws TransactionException; } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface ReactiveTransactionManager : TransactionManager { - - @Throws(TransactionException::class) - fun getReactiveTransaction(definition: TransactionDefinition): Mono - - @Throws(TransactionException::class) - fun commit(status: ReactiveTransaction): Mono - - @Throws(TransactionException::class) - fun rollback(status: ReactiveTransaction): Mono - } ----- The reactive transaction manager is primarily a service provider interface (SPI), although you can use it <> from your @@ -276,8 +244,7 @@ control transaction execution and query transaction status. The concepts should familiar, as they are common to all transaction APIs. The following listing shows the `TransactionStatus` interface: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface TransactionStatus extends TransactionExecution, SavepointManager, Flushable { @@ -298,24 +265,6 @@ familiar, as they are common to all transaction APIs. The following listing show boolean isCompleted(); } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface TransactionStatus : TransactionExecution, SavepointManager, Flushable { - - override fun isNewTransaction(): Boolean - - fun hasSavepoint(): Boolean - - override fun setRollbackOnly() - - override fun isRollbackOnly(): Boolean - - fun flush() - - override fun isCompleted(): Boolean - } ----- Regardless of whether you opt for declarative or programmatic transaction management in Spring, defining the correct `TransactionManager` implementation is absolutely essential. @@ -8565,8 +8514,7 @@ the two Spring interfaces used for this purpose. Spring abstracts all marshalling operations behind the `org.springframework.oxm.Marshaller` interface, the main method of which follows: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface Marshaller { @@ -8576,22 +8524,6 @@ Spring abstracts all marshalling operations behind the void marshal(Object graph, Result result) throws XmlMappingException, IOException; } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface Marshaller { - - /** - * Marshal the object graph with the given root into the provided Result. - */ - @Throws(XmlMappingException::class, IOException::class) - fun marshal( - graph: Any, - result: Result - ) - } ----- - The `Marshaller` interface has one main method, which marshals the given object to a given `javax.xml.transform.Result`. The result is a tagging interface that basically @@ -8625,8 +8557,7 @@ to determine how your O-X technology manages this. Similar to the `Marshaller`, we have the `org.springframework.oxm.Unmarshaller` interface, which the following listing shows: -[source,java,indent=0,subs="verbatim,quotes",role="primary"] -.Java +[source,java,indent=0,subs="verbatim,quotes"] ---- public interface Unmarshaller { @@ -8636,18 +8567,6 @@ interface, which the following listing shows: Object unmarshal(Source source) throws XmlMappingException, IOException; } ---- -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] -.Kotlin ----- - interface Unmarshaller { - - /** - * Unmarshal the given provided Source into an object graph. - */ - @Throws(XmlMappingException::class, IOException::class) - fun unmarshal(source: Source): Any - } ----- This interface also has one method, which reads from the given `javax.xml.transform.Source` (an XML input abstraction) and returns the object read. As