Skip to content

Commit cb4bb15

Browse files
committed
Removed Injector
1 parent 8b2c13e commit cb4bb15

File tree

4 files changed

+0
-42
lines changed

4 files changed

+0
-42
lines changed

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
<artifactId>HTTP-Server</artifactId>
2727
<version>1.0-SNAPSHOT</version>
2828
</dependency>
29-
<dependency>
30-
<groupId>com.google.code.gson</groupId>
31-
<artifactId>gson</artifactId>
32-
<version>2.8.6</version>
33-
</dependency>
3429
<dependency>
3530
<groupId>com.github.javafaker</groupId>
3631
<artifactId>javafaker</artifactId>

src/main/java/org/javawebstack/framework/WebApplication.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public abstract class WebApplication {
2727
private Logger logger = Logger.getLogger("WebApp");
2828
private SQL sql;
2929
private final HTTPServer server;
30-
private final Injector injector;
3130
private final Faker faker = new Faker();
3231
private final Config config = new Config();
3332
private final Crypt crypt;
@@ -38,20 +37,12 @@ public abstract class WebApplication {
3837
private SQLDriverFactory sqlDriverFactory;
3938

4039
public WebApplication() {
41-
injector = new SimpleInjector();
42-
injector.setInstance(Injector.class, injector);
43-
injector.setInstance(Faker.class, faker);
44-
injector.setInstance(Config.class, config);
45-
injector.setInstance((Class<WebApplication>) getClass(), this);
46-
injector.setInstance(WebApplication.class, this);
47-
injector.setInstance(I18N.class, translation);
4840

4941
setupModules();
5042
modules.forEach(m -> m.beforeSetupConfig(this, config));
5143
setupConfig(config);
5244

5345
crypt = new Crypt(config.has("crypt.key") ? config.get("crypt.key") : Crypt.generateKey());
54-
injector.setInstance(Crypt.class, crypt);
5546

5647
modules.forEach(m -> m.setupConfig(this, config));
5748
sqlDriverFactory = new SQLDriverFactory(new HashMap<String, String>() {{
@@ -79,15 +70,8 @@ public WebApplication() {
7970
}
8071
modelBindParamTransformer = new ModelBindParamTransformer();
8172

82-
modules.forEach(m -> m.beforeSetupInjection(this, injector));
83-
setupInjection(injector);
84-
modules.forEach(m -> m.setupInjection(this, injector));
85-
8673
server = new HTTPServer()
8774
.port(config.getInt("http.server.port", 80));
88-
injector.setInstance(HTTPServer.class, server);
89-
server.injector(injector);
90-
injector.inject(this);
9175
server.beforeInterceptor(new CORSPolicy(config.get("http.server.cors", "*")));
9276
server.beforeInterceptor(new MultipartPolicy(config.get("http.server.tmp", null)));
9377
if (config.isEnabled("http.server.autoserialization", true))
@@ -143,8 +127,6 @@ public WebApplication setAccessorAttribName(String name) {
143127
public void addSeeder(String name, Seeder... seeder) {
144128
if (seeder.length == 0)
145129
return;
146-
for (Seeder seed : seeder)
147-
injector.inject(seed);
148130
if (seeder.length > 1) {
149131
addSeeder(name, new MergedSeeder(seeder));
150132
return;
@@ -168,10 +150,6 @@ public HTTPServer getServer() {
168150
return server;
169151
}
170152

171-
public Injector getInjector() {
172-
return injector;
173-
}
174-
175153
public Faker getFaker() {
176154
return faker;
177155
}
@@ -193,9 +171,6 @@ protected void setupModules() {
193171

194172
protected abstract void setupConfig(Config config);
195173

196-
protected void setupInjection(Injector injector) {
197-
}
198-
199174
protected void setupSeeding() {
200175
}
201176

src/main/java/org/javawebstack/framework/module/Module.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ public interface Module {
1313
default void beforeSetupConfig(WebApplication application, Config config) {
1414
}
1515

16-
default void beforeSetupInjection(WebApplication application, Injector injector) {
17-
}
18-
1916
default void beforeSetupModels(WebApplication application, SQL sql) throws ORMConfigurationException {
2017
}
2118

@@ -28,9 +25,6 @@ default void beforeSetupSeeding(WebApplication application) {
2825
default void setupConfig(WebApplication application, Config config) {
2926
}
3027

31-
default void setupInjection(WebApplication application, Injector injector) {
32-
}
33-
3428
default void setupDriverFactory(WebApplication application, SQLDriverFactory driverFactory) {
3529
}
3630

src/main/java/org/javawebstack/framework/testing/WebFrameworkTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
import org.javawebstack.framework.WebApplication;
44
import org.javawebstack.framework.config.Config;
55
import org.javawebstack.httpserver.test.HTTPTest;
6-
import org.javawebstack.injector.Injector;
76

87
public abstract class WebFrameworkTest extends HTTPTest {
98

109
private WebApplication webApplication;
1110

1211
public WebFrameworkTest(WebApplication webApplication){
1312
super(webApplication.getServer());
14-
webApplication.getInjector().inject(this);
1513

1614
this.webApplication = webApplication;
1715
}
@@ -20,10 +18,6 @@ public WebApplication getApplication() {
2018
return webApplication;
2119
}
2220

23-
public Injector getInjector(){
24-
return webApplication.getInjector();
25-
}
26-
2721
public void seed(String name){
2822
webApplication.getSeeder(name).seed();
2923
}

0 commit comments

Comments
 (0)