Skip to content

Commit e6db48c

Browse files
Merge pull request #23 from ChillyCheesy/feat/controller
Feat/controller
2 parents 7119cc0 + dcb2546 commit e6db48c

File tree

68 files changed

+33
-2005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+33
-2005
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
modulo_modulename=ModuloServer
2-
modulo_version=BINKS-0.3.1
2+
modulo_version=BINKS-0.4.0

modulo-api/src/main/java/com/chillycheesy/modulo/ModuloAPI.java

-28
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import com.chillycheesy.modulo.controllers.ControllerContainer;
44
import com.chillycheesy.modulo.events.EventContainer;
55
import com.chillycheesy.modulo.modules.ModuleContainer;
6-
import com.chillycheesy.modulo.pages.PageContainer;
7-
import com.chillycheesy.modulo.signals.SignalContainer;
86
import com.chillycheesy.modulo.utils.Logger;
97

108
/**
@@ -23,14 +21,6 @@ public class ModuloAPI {
2321
* Event section.
2422
*/
2523
private static EventContainer event;
26-
/**
27-
* Signal section.
28-
*/
29-
private static SignalContainer signal;
30-
/**
31-
* Page manager.
32-
*/
33-
private static PageContainer page;
3424
/**
3525
* Controller container.
3626
*/
@@ -58,24 +48,6 @@ public static EventContainer getEvent() {
5848
return event = event == null ? new EventContainer() : event;
5949
}
6050

61-
/**
62-
* Getter for Signal logic section.
63-
*
64-
* @return The Signal section.
65-
*/
66-
public static SignalContainer getSignal() {
67-
return signal = signal == null ? new SignalContainer() : signal;
68-
}
69-
70-
/**
71-
* Getter for Signal logic section.
72-
*
73-
* @return The Signal section.
74-
*/
75-
public static PageContainer getPage() {
76-
return page = page == null ? new PageContainer() : page;
77-
}
78-
7951
/**
8052
* Getter for Logger logic section.
8153
*

modulo-api/src/main/java/com/chillycheesy/modulo/controllers/HttpPathVariableController.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,22 @@ private boolean match(List<String> requestPathList, List<String> pathVariableSpl
9999
final String requestPath = requestPathIterator.next();
100100
final String pathVariable = pathVariableIterator.next();
101101
if (argMatch(requestPath, pathVariable, configuration)) {
102-
if (pathVariable.equals("**")) {
103-
final StringBuilder additionalPath = new StringBuilder(requestPath);
104-
requestPathIterator.forEachRemaining(value -> additionalPath.append("/").append(value));
105-
configuration.set("additional-path", additionalPath.toString());
102+
if (isAdditionalPath(requestPathIterator, requestPath, pathVariable, configuration))
106103
return true;
107-
}
108-
} else {
109-
return false;
110-
}
104+
} else return false;
111105
}
112-
return true;
106+
if (!requestPathIterator.hasNext() && !pathVariableIterator.hasNext()) return true;
107+
else return pathVariableIterator.hasNext() && isAdditionalPath(requestPathIterator, "", pathVariableIterator.next(), configuration);
108+
}
109+
110+
private boolean isAdditionalPath(Iterator<String> requestPathIterator, String base, String pathVariable, Configuration configuration) {
111+
if (pathVariable.equals("**")) {
112+
final StringBuilder additionalPath = new StringBuilder(base);
113+
requestPathIterator.forEachRemaining(value -> additionalPath.append("/").append(value));
114+
configuration.set("additional-path", additionalPath.toString());
115+
return true;
116+
}
117+
return false;
113118
}
114119

115120
/**

modulo-api/src/main/java/com/chillycheesy/modulo/controllers/MethodController.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.chillycheesy.modulo.controllers;
22

33
import com.chillycheesy.modulo.config.Configuration;
4-
import com.chillycheesy.modulo.controllers.annotations.HttpParamMethodControllerParameterAnnotationApplier;
5-
import com.chillycheesy.modulo.controllers.annotations.MethodControllerParameterAnnotationApplier;
6-
import com.chillycheesy.modulo.controllers.annotations.PathVariableMethodControllerParameterAnnotationApplier;
7-
import com.chillycheesy.modulo.controllers.annotations.RequestBodyMethodControllerParameterAnnotationApplier;
4+
import com.chillycheesy.modulo.controllers.methodcontroller.HttpParamMethodControllerParameterAnnotationApplier;
5+
import com.chillycheesy.modulo.controllers.methodcontroller.MethodControllerParameterAnnotationApplier;
6+
import com.chillycheesy.modulo.controllers.methodcontroller.PathVariableMethodControllerParameterAnnotationApplier;
7+
import com.chillycheesy.modulo.controllers.methodcontroller.RequestBodyMethodControllerParameterAnnotationApplier;
88

99
import javax.servlet.http.HttpServletRequest;
1010
import javax.servlet.http.HttpServletResponse;

modulo-api/src/main/java/com/chillycheesy/modulo/controllers/annotations/HttpParam.java renamed to modulo-api/src/main/java/com/chillycheesy/modulo/controllers/methodcontroller/HttpParam.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.chillycheesy.modulo.controllers.annotations;
1+
package com.chillycheesy.modulo.controllers.methodcontroller;
22

33
import java.lang.annotation.*;
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.chillycheesy.modulo.controllers.annotations;
1+
package com.chillycheesy.modulo.controllers.methodcontroller;
22

33
import com.chillycheesy.modulo.config.Configuration;
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.chillycheesy.modulo.controllers.annotations;
1+
package com.chillycheesy.modulo.controllers.methodcontroller;
22

33
import com.chillycheesy.modulo.config.Configuration;
44

modulo-api/src/main/java/com/chillycheesy/modulo/controllers/annotations/PathVariable.java renamed to modulo-api/src/main/java/com/chillycheesy/modulo/controllers/methodcontroller/PathVariable.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.chillycheesy.modulo.controllers.annotations;
1+
package com.chillycheesy.modulo.controllers.methodcontroller;
22

33
import java.lang.annotation.*;
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.chillycheesy.modulo.controllers.annotations;
1+
package com.chillycheesy.modulo.controllers.methodcontroller;
22

33

44
import com.chillycheesy.modulo.config.Configuration;

modulo-api/src/main/java/com/chillycheesy/modulo/controllers/annotations/RequestBody.java renamed to modulo-api/src/main/java/com/chillycheesy/modulo/controllers/methodcontroller/RequestBody.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.chillycheesy.modulo.controllers.annotations;
1+
package com.chillycheesy.modulo.controllers.methodcontroller;
22

33
import java.lang.annotation.*;
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.chillycheesy.modulo.controllers.annotations;
1+
package com.chillycheesy.modulo.controllers.methodcontroller;
22

33
import com.chillycheesy.modulo.config.Configuration;
44
import com.fasterxml.jackson.databind.ObjectMapper;

modulo-api/src/main/java/com/chillycheesy/modulo/event/SendPageEvent.java

-54
This file was deleted.

modulo-api/src/main/java/com/chillycheesy/modulo/listener/Listener.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.chillycheesy.modulo.events.Event;
44
import com.chillycheesy.modulo.events.EventHandler;
55
import com.chillycheesy.modulo.modules.Module;
6-
import com.chillycheesy.modulo.signals.SignalHandler;
76

87
/**
98
* The class that implement Listener, will be called to catch {@link Event} emit by a {@link Module}.
@@ -12,7 +11,7 @@
1211
* with one parameter of {@link Event} type.
1312
* If the method was annotated by the {@link EventHandler} Annotation,
1413
* it will be invoked automatically when the unique parameter {@link Event}
15-
* is the same type than the emitted {@link Event}.
14+
* is the same type as the emitted {@link Event}.
1615
*
1716
*/
1817
public interface Listener {

modulo-api/src/main/java/com/chillycheesy/modulo/modules/ModuleManager.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.chillycheesy.modulo.modules;
22

3-
import com.chillycheesy.modulo.signals.SignalManager;
43
import com.chillycheesy.modulo.ModuloAPI;
54
import com.chillycheesy.modulo.events.EventManager;
65
import com.chillycheesy.modulo.utils.exception.HTModuleNotFoundException;
@@ -150,14 +149,11 @@ public void stopModules(List<Module> modules){
150149
}
151150

152151
/**
153-
* It stops a module, removes it from the {@link SignalManager} and the {@link EventManager} and the {@link ModuleManager}
152+
* It stops a module, removes it from the {@link ModuleManager}
154153
* @param module module you want to stop
155154
*/
156155
public void stopModule(Module module){
157156
module.stop();
158-
ModuloAPI.getSignal().getSignalManager().removeAllItems(module);
159-
ModuloAPI.getEvent().getEventManager().removeAllItems(module);
160-
ModuloAPI.getPage().getPageManager().removeAllItems(module);
161157
removeModule(module);
162158
}
163159

modulo-api/src/main/java/com/chillycheesy/modulo/pages/Page.java

-108
This file was deleted.

modulo-api/src/main/java/com/chillycheesy/modulo/pages/PageContainer.java

-11
This file was deleted.

0 commit comments

Comments
 (0)