Skip to content

Commit 4c625cc

Browse files
committed
Remove BeanScope start() method as it can and should be internal
1 parent 5786de1 commit 4c625cc

File tree

4 files changed

+15
-27
lines changed

4 files changed

+15
-27
lines changed

inject/src/main/java/io/avaje/inject/BeanScope.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,6 @@ default <T> List<T> getBeansByPriority(Class<T> interfaceType, Class<? extends A
220220
*/
221221
<T> RequestScopeMatch<T> requestProvider(Class<T> type, String name);
222222

223-
/**
224-
* Start the context firing any <code>@PostConstruct</code> methods.
225-
*/
226-
void start();
227-
228223
/**
229224
* Close the context firing any <code>@PreDestroy</code> methods.
230225
*/

inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ public BeanScope build() {
118118
}
119119

120120
BeanScope beanScope = builder.build();
121-
// entire graph built, fire postConstruct
122-
beanScope.start();
123121
if (shutdownHook) {
124122
return new ShutdownAwareBeanScope(beanScope);
125123
}
@@ -162,59 +160,54 @@ public void run() {
162160
private static class ShutdownAwareBeanScope implements BeanScope {
163161

164162
private final ReentrantLock lock = new ReentrantLock();
165-
private final BeanScope context;
163+
private final BeanScope beanScope;
166164
private final Hook hook;
167165
private boolean shutdown;
168166

169-
ShutdownAwareBeanScope(BeanScope context) {
170-
this.context = context;
167+
ShutdownAwareBeanScope(BeanScope beanScope) {
168+
this.beanScope = beanScope;
171169
this.hook = new Hook(this);
172170
Runtime.getRuntime().addShutdownHook(hook);
173171
}
174172

175173
@Override
176174
public RequestScopeBuilder newRequestScope() {
177-
return context.newRequestScope();
175+
return beanScope.newRequestScope();
178176
}
179177

180178
@Override
181179
public <T> RequestScopeMatch<T> requestProvider(Class<T> type, String name) {
182-
return context.requestProvider(type, name);
180+
return beanScope.requestProvider(type, name);
183181
}
184182

185183
@Override
186184
public <T> T get(Class<T> beanClass) {
187-
return context.get(beanClass);
185+
return beanScope.get(beanClass);
188186
}
189187

190188
@Override
191189
public <T> T get(Class<T> beanClass, String name) {
192-
return context.get(beanClass, name);
190+
return beanScope.get(beanClass, name);
193191
}
194192

195193
@Override
196194
public List<Object> listByAnnotation(Class<?> annotation) {
197-
return context.listByAnnotation(annotation);
195+
return beanScope.listByAnnotation(annotation);
198196
}
199197

200198
@Override
201199
public <T> List<T> list(Class<T> interfaceType) {
202-
return context.list(interfaceType);
200+
return beanScope.list(interfaceType);
203201
}
204202

205203
@Override
206204
public <T> List<T> listByPriority(Class<T> interfaceType) {
207-
return context.listByPriority(interfaceType);
205+
return beanScope.listByPriority(interfaceType);
208206
}
209207

210208
@Override
211209
public <T> List<T> listByPriority(Class<T> interfaceType, Class<? extends Annotation> priority) {
212-
return context.listByPriority(interfaceType, priority);
213-
}
214-
215-
@Override
216-
public void start() {
217-
context.start();
210+
return beanScope.listByPriority(interfaceType, priority);
218211
}
219212

220213
@Override
@@ -224,7 +217,7 @@ public void close() {
224217
if (!shutdown) {
225218
Runtime.getRuntime().removeShutdownHook(hook);
226219
}
227-
context.close();
220+
beanScope.close();
228221
} finally {
229222
lock.unlock();
230223
}

inject/src/main/java/io/avaje/inject/spi/DBeanScope.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ public List<Object> listByAnnotation(Class<?> annotation) {
9696
return beans.all(annotation);
9797
}
9898

99-
@Override
100-
public void start() {
99+
DBeanScope start() {
101100
lock.lock();
102101
try {
103102
log.trace("firing postConstruct");
@@ -107,6 +106,7 @@ public void start() {
107106
} finally {
108107
lock.unlock();
109108
}
109+
return this;
110110
}
111111

112112
@Override

inject/src/main/java/io/avaje/inject/spi/DBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,6 @@ private void runInjectors() {
197197

198198
public BeanScope build() {
199199
runInjectors();
200-
return new DBeanScope(lifecycleList, beanMap, reqScopeProviders);
200+
return new DBeanScope(lifecycleList, beanMap, reqScopeProviders).start();
201201
}
202202
}

0 commit comments

Comments
 (0)