Skip to content

Commit efc335e

Browse files
committed
Remove remaining Kotlin "translations" of Java APIs in the reference manual
1 parent 1e57e57 commit efc335e

File tree

5 files changed

+33
-427
lines changed

5 files changed

+33
-427
lines changed

src/docs/asciidoc/core/core-aop-api.adoc

+8-96
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,13 @@ target different advice with the same pointcut.
2525
The `org.springframework.aop.Pointcut` interface is the central interface, used to
2626
target advices to particular classes and methods. The complete interface follows:
2727

28-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
29-
.Java
28+
[source,java,indent=0,subs="verbatim,quotes"]
3029
----
3130
public interface Pointcut {
3231
3332
ClassFilter getClassFilter();
3433
3534
MethodMatcher getMethodMatcher();
36-
37-
}
38-
----
39-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
40-
.Kotlin
41-
----
42-
interface Pointcut {
43-
44-
fun getClassFilter(): ClassFilter
45-
46-
fun getMethodMatcher(): MethodMatcher
47-
4835
}
4936
----
5037

@@ -56,27 +43,17 @@ The `ClassFilter` interface is used to restrict the pointcut to a given set of t
5643
classes. If the `matches()` method always returns true, all target classes are
5744
matched. The following listing shows the `ClassFilter` interface definition:
5845

59-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
60-
.Java
46+
[source,java,indent=0,subs="verbatim,quotes"]
6147
----
6248
public interface ClassFilter {
6349
6450
boolean matches(Class clazz);
6551
}
6652
----
67-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
68-
.Kotlin
69-
----
70-
interface ClassFilter {
71-
72-
fun matches(clazz: Class<*>): Boolean
73-
}
74-
----
7553

7654
The `MethodMatcher` interface is normally more important. The complete interface follows:
7755

78-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
79-
.Java
56+
[source,java,indent=0,subs="verbatim,quotes"]
8057
----
8158
public interface MethodMatcher {
8259
@@ -87,18 +64,6 @@ The `MethodMatcher` interface is normally more important. The complete interface
8764
boolean matches(Method m, Class targetClass, Object[] args);
8865
}
8966
----
90-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
91-
.Kotlin
92-
----
93-
interface MethodMatcher {
94-
95-
val isRuntime: Boolean
96-
97-
fun matches(m: Method, targetClass: Class<*>): Boolean
98-
99-
fun matches(m: Method, targetClass: Class<*>, args: Array<Any>): Boolean
100-
}
101-
----
10267

10368
The `matches(Method, Class)` method is used to test whether this pointcut ever
10469
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
335300
interception. Classes that implement `MethodInterceptor` and that implement around advice should also implement the
336301
following interface:
337302

338-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
339-
.Java
303+
[source,java,indent=0,subs="verbatim,quotes"]
340304
----
341305
public interface MethodInterceptor extends Interceptor {
342306
343307
Object invoke(MethodInvocation invocation) throws Throwable;
344308
}
345309
----
346-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
347-
.Kotlin
348-
----
349-
interface MethodInterceptor : Interceptor {
350-
351-
fun invoke(invocation: MethodInvocation) : Any
352-
}
353-
----
354310

355311
The `MethodInvocation` argument to the `invoke()` method exposes the method being
356312
invoked, the target join point, the AOP proxy, and the arguments to the method. The
@@ -413,22 +369,13 @@ interceptor chain.
413369

414370
The following listing shows the `MethodBeforeAdvice` interface:
415371

416-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
417-
.Java
372+
[source,java,indent=0,subs="verbatim,quotes"]
418373
----
419374
public interface MethodBeforeAdvice extends BeforeAdvice {
420375
421376
void before(Method m, Object[] args, Object target) throws Throwable;
422377
}
423378
----
424-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
425-
.Kotlin
426-
----
427-
interface MethodBeforeAdvice : BeforeAdvice {
428-
429-
fun before(m: Method, args: Array<Any>, target: Any)
430-
}
431-
----
432379

433380
(Spring's API design would allow for
434381
field before advice, although the usual objects apply to field interception and it is
@@ -591,23 +538,14 @@ TIP: Throws advice can be used with any pointcut.
591538
An after returning advice in Spring must implement the
592539
`org.springframework.aop.AfterReturningAdvice` interface, which the following listing shows:
593540

594-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
595-
.Java
541+
[source,java,indent=0,subs="verbatim,quotes"]
596542
----
597543
public interface AfterReturningAdvice extends Advice {
598544
599545
void afterReturning(Object returnValue, Method m, Object[] args, Object target)
600546
throws Throwable;
601547
}
602548
----
603-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
604-
.Kotlin
605-
----
606-
interface AfterReturningAdvice : Advice {
607-
608-
fun afterReturning(returnValue: Any, m: Method, args: Array<Any>, target: Any)
609-
}
610-
----
611549

612550
An after returning advice has access to the return value (which it cannot modify),
613551
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.
660598
Introduction requires an `IntroductionAdvisor` and an `IntroductionInterceptor` that
661599
implement the following interface:
662600

663-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
664-
.Java
601+
[source,java,indent=0,subs="verbatim,quotes"]
665602
----
666603
public interface IntroductionInterceptor extends MethodInterceptor {
667604
668605
boolean implementsInterface(Class intf);
669606
}
670607
----
671-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
672-
.Kotlin
673-
----
674-
interface IntroductionInterceptor : MethodInterceptor {
675-
676-
fun implementsInterface(intf: Class<*>): Boolean
677-
}
678-
----
679608

680609
The `invoke()` method inherited from the AOP Alliance `MethodInterceptor` interface must
681610
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
686615
rather than the method, level. You can only use introduction advice with the
687616
`IntroductionAdvisor`, which has the following methods:
688617

689-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
690-
.Java
618+
[source,java,indent=0,subs="verbatim,quotes"]
691619
----
692620
public interface IntroductionAdvisor extends Advisor, IntroductionInfo {
693621
@@ -701,22 +629,6 @@ rather than the method, level. You can only use introduction advice with the
701629
Class<?>[] getInterfaces();
702630
}
703631
----
704-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
705-
.Kotlin
706-
----
707-
interface IntroductionAdvisor : Advisor, IntroductionInfo {
708-
709-
val classFilter: ClassFilter
710-
711-
@Throws(IllegalArgumentException::class)
712-
fun validateInterfaces()
713-
}
714-
715-
interface IntroductionInfo {
716-
717-
val interfaces: Array<Class<*>>
718-
}
719-
----
720632

721633
There is no `MethodMatcher` and, hence, no `Pointcut` associated with introduction
722634
advice. Only class filtering is logical.

src/docs/asciidoc/core/core-beans.adoc

+8-84
Original file line numberDiff line numberDiff line change
@@ -3406,16 +3406,10 @@ The `org.springframework.beans.factory.InitializingBean` interface lets a bean
34063406
perform initialization work after the container has set all necessary properties on the
34073407
bean. The `InitializingBean` interface specifies a single method:
34083408

3409-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
3410-
.Java
3409+
[source,java,indent=0,subs="verbatim,quotes"]
34113410
----
34123411
void afterPropertiesSet() throws Exception;
34133412
----
3414-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
3415-
.Kotlin
3416-
----
3417-
fun afterPropertiesSet()
3418-
----
34193413

34203414
We recommend that you do not use the `InitializingBean` interface, because it
34213415
unnecessarily couples the code to Spring. Alternatively, we suggest using
@@ -3491,16 +3485,10 @@ Implementing the `org.springframework.beans.factory.DisposableBean` interface le
34913485
bean get a callback when the container that contains it is destroyed. The
34923486
`DisposableBean` interface specifies a single method:
34933487

3494-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
3495-
.Java
3488+
[source,java,indent=0,subs="verbatim,quotes"]
34963489
----
34973490
void destroy() throws Exception;
34983491
----
3499-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
3500-
.Kotlin
3501-
----
3502-
fun destroy()
3503-
----
35043492

35053493
We recommend that you do not use the `DisposableBean` callback interface, because it
35063494
unnecessarily couples the code to Spring. Alternatively, we suggest using
@@ -3711,8 +3699,7 @@ Destroy methods are called in the same order:
37113699
The `Lifecycle` interface defines the essential methods for any object that has its own
37123700
lifecycle requirements (such as starting and stopping some background process):
37133701

3714-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
3715-
.Java
3702+
[source,java,indent=0,subs="verbatim,quotes"]
37163703
----
37173704
public interface Lifecycle {
37183705
@@ -3723,27 +3710,14 @@ lifecycle requirements (such as starting and stopping some background process):
37233710
boolean isRunning();
37243711
}
37253712
----
3726-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
3727-
.Kotlin
3728-
----
3729-
interface Lifecycle {
3730-
3731-
fun start()
3732-
3733-
fun stop()
3734-
3735-
val isRunning: Boolean
3736-
}
3737-
----
37383713

37393714
Any Spring-managed object may implement the `Lifecycle` interface. Then, when the
37403715
`ApplicationContext` itself receives start and stop signals (for example, for a stop/restart
37413716
scenario at runtime), it cascades those calls to all `Lifecycle` implementations
37423717
defined within that context. It does this by delegating to a `LifecycleProcessor`, shown
37433718
in the following listing:
37443719

3745-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
3746-
.Java
3720+
[source,java,indent=0,subs="verbatim,quotes"]
37473721
----
37483722
public interface LifecycleProcessor extends Lifecycle {
37493723
@@ -3752,16 +3726,6 @@ in the following listing:
37523726
void onClose();
37533727
}
37543728
----
3755-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
3756-
.Kotlin
3757-
----
3758-
interface LifecycleProcessor : Lifecycle {
3759-
3760-
fun onRefresh()
3761-
3762-
fun onClose()
3763-
}
3764-
----
37653729

37663730
Notice that the `LifecycleProcessor` is itself an extension of the `Lifecycle`
37673731
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
37883752
another option, namely the `getPhase()` method as defined on its super-interface,
37893753
`Phased`. The following listing shows the definition of the `Phased` interface:
37903754

3791-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
3792-
.Java
3755+
[source,java,indent=0,subs="verbatim,quotes"]
37933756
----
37943757
public interface Phased {
37953758
37963759
int getPhase();
37973760
}
37983761
----
3799-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
3800-
.Kotlin
3801-
----
3802-
interface Phased {
3803-
3804-
val phase: Int
3805-
}
3806-
----
38073762

38083763
The following listing shows the definition of the `SmartLifecycle` interface:
38093764

3810-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
3811-
.Java
3765+
[source,java,indent=0,subs="verbatim,quotes"]
38123766
----
38133767
public interface SmartLifecycle extends Lifecycle, Phased {
38143768
@@ -3817,16 +3771,6 @@ The following listing shows the definition of the `SmartLifecycle` interface:
38173771
void stop(Runnable callback);
38183772
}
38193773
----
3820-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
3821-
.Kotlin
3822-
----
3823-
interface SmartLifecycle : Lifecycle, Phased {
3824-
3825-
val isAutoStartup: Boolean
3826-
3827-
fun stop(callback: Runnable)
3828-
}
3829-
----
38303774

38313775
When starting, the objects with the lowest phase start first. When stopping, the
38323776
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
39383882
with a reference to that `ApplicationContext`. The following listing shows the definition
39393883
of the `ApplicationContextAware` interface:
39403884

3941-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
3942-
.Java
3885+
[source,java,indent=0,subs="verbatim,quotes"]
39433886
----
39443887
public interface ApplicationContextAware {
39453888
39463889
void setApplicationContext(ApplicationContext applicationContext) throws BeansException;
39473890
}
39483891
----
3949-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
3950-
.Kotlin
3951-
----
3952-
interface ApplicationContextAware {
3953-
3954-
@Throws(BeansException::class)
3955-
fun setApplicationContext(applicationContext: ApplicationContext)
3956-
}
3957-
----
39583892

39593893
Thus, beans can programmatically manipulate the `ApplicationContext` that created them,
39603894
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
39833917
a reference to the name defined in its associated object definition. The following listing
39843918
shows the definition of the BeanNameAware interface:
39853919

3986-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
3987-
.Java
3920+
[source,java,indent=0,subs="verbatim,quotes"]
39883921
----
39893922
public interface BeanNameAware {
39903923
39913924
void setBeanName(String name) throws BeansException;
39923925
}
39933926
----
3994-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
3995-
.Kotlin
3996-
----
3997-
interface BeanNameAware {
3998-
3999-
@Throws(BeansException::class)
4000-
fun setBeanName(name: String)
4001-
}
4002-
----
40033927

40043928
The callback is invoked after population of normal bean properties but before an
40053929
initialization callback such as `InitializingBean`, `afterPropertiesSet`, or a custom

0 commit comments

Comments
 (0)