Skip to content

Commit 78b17d7

Browse files
committed
Remove Initializable iface
1 parent 5a41033 commit 78b17d7

File tree

5 files changed

+1
-46
lines changed

5 files changed

+1
-46
lines changed

src/main/java/com/coditory/quark/context/BeanInitializer.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ private BeanInitializer() {
1717
}
1818

1919
static void initializeBean(Object bean, BeanDescriptor<?> descriptor, ResolutionContext context) {
20-
if (bean instanceof Initializable) {
21-
initializeBean((Initializable) bean, descriptor);
22-
}
2320
for (Method method : bean.getClass().getDeclaredMethods()) {
2421
if (method.isAnnotationPresent(Init.class)) {
2522
method.setAccessible(true);
@@ -38,14 +35,4 @@ private static void initializeBean(Object bean, BeanDescriptor<?> descriptor, Me
3835
}
3936
log.debug("Initialized bean {} using method {} in {}", descriptor.toShortString(), simplifyMethodName(method), timer.measureAndFormat());
4037
}
41-
42-
private static void initializeBean(Initializable bean, BeanDescriptor<?> descriptor) {
43-
Timer timer = Timer.start();
44-
try {
45-
bean.init();
46-
} catch (Exception e) {
47-
throw new BeanInitializationException("Could not initialize bean: " + descriptor.toShortString(), e);
48-
}
49-
log.debug("Initialized bean {} in {}", descriptor.toShortString(), timer.measureAndFormat());
50-
}
5138
}

src/main/java/com/coditory/quark/context/BeanPostInitializer.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ private BeanPostInitializer() {
1717
}
1818

1919
static void postInitializeBean(Object bean, BeanDescriptor<?> descriptor, ResolutionContext context) {
20-
if (bean instanceof PostInitializable) {
21-
postInitializeBean((PostInitializable) bean, descriptor);
22-
}
2320
for (Method method : bean.getClass().getDeclaredMethods()) {
2421
if (method.isAnnotationPresent(PostInit.class)) {
2522
method.setAccessible(true);
@@ -38,14 +35,4 @@ private static void postInitializeBean(Object bean, BeanDescriptor<?> descriptor
3835
}
3936
log.debug("Post initialized bean {} using method {} in {}", descriptor.toShortString(), simplifyMethodName(method), timer.measureAndFormat());
4037
}
41-
42-
private static void postInitializeBean(PostInitializable bean, BeanDescriptor<?> descriptor) {
43-
Timer timer = Timer.start();
44-
try {
45-
bean.postInit();
46-
} catch (Exception e) {
47-
throw new BeanInitializationException("Could not post initialize bean: " + descriptor.toShortString(), e);
48-
}
49-
log.debug("Post initialized bean {} in {}", descriptor.toShortString(), timer.measureAndFormat());
50-
}
5138
}

src/main/java/com/coditory/quark/context/Initializable.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/main/java/com/coditory/quark/context/PostInitializable.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/test/groovy/com/coditory/quark/context/BeanLifecycleSpec.groovy

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class BeanLifecycleSpec extends Specification {
2222
when:
2323
LifecycleImplemented lifecycleImplemented = context.get(LifecycleImplemented)
2424
then:
25-
lifecycleImplemented.initialized
2625
!lifecycleImplemented.finalized
2726
}
2827

@@ -57,7 +56,6 @@ class BeanLifecycleSpec extends Specification {
5756
context.close()
5857
then:
5958
lifecycleAnnotated.initialized
60-
lifecycleImplemented.initialized
6159
}
6260

6361
def "should not initialize lazy beans that were not retrieved from the context"() {
@@ -73,7 +71,6 @@ class BeanLifecycleSpec extends Specification {
7371
context.close()
7472
then:
7573
!lifecycleAnnotated.initialized
76-
!lifecycleImplemented.initialized
7774
}
7875

7976
def "should inject dependencies to lifecycle annotated methods"() {
@@ -146,15 +143,9 @@ class BeanLifecycleSpec extends Specification {
146143
}
147144
}
148145

149-
static class LifecycleImplemented implements Initializable, Closeable {
150-
boolean initialized = false
146+
static class LifecycleImplemented implements Closeable {
151147
boolean finalized = false
152148

153-
@Override
154-
void init() {
155-
initialized = true
156-
}
157-
158149
@Override
159150
void close() {
160151
finalized = true

0 commit comments

Comments
 (0)