Amaya is a fairly lightweight web framework for Java, which guarantees speed, ease of creating plugins/addons, flexibility and ease of use.
The main goals pursued during the creation were the avoidance of redundant abstractions, modularity, simplification of the creation of REST services and sufficient freedom for user configuration and modification. The server part is built on the basis of a repackaged sun server.
The core of the Amaya framework, which is an independent dependency. I.e. it is enough to install only it to create a simple server. The kernel is built in such a way as not to force users to install unnecessary dependencies. In case you need any missing functionality, it will be enough to deliver the necessary dependency. The only possible inconvenience is the need to specify classindex in dependencies, but this is the fee for the launch speed: other similar libraries are incomparably slow.
To install it, you will need:
- java 8+
- classindex
- some implementation of slf4j
- Maven/Gradle
dependencies {
annotationProcessor group: 'org.atteo.classindex', name: 'classindex', version: '3.11'
implementation group: 'io.github.amayaframework', name: 'amaya-core', version: '1+'
implementation group: 'io.github.amayaframework', name: 'amaya-sun', version: 'LATEST'
}
<dependency>
<groupId>io.github.amayaframework</groupId>
<artifactId>amaya-core</artifactId>
<version>1+</version>
</dependency>
<dependency>
<groupId>io.github.amayaframework</groupId>
<artifactId>amaya-sun</artifactId>
<version>LATEST</version>
</dependency>
To support getting method parameter names, add to your build.gradle the following
compileJava {
options.compilerArgs << '-parameters'
}
public class Server {
public static void main(String[] args) throws Throwable {
Amaya<HttpServer> amaya = new SunBuilder().
bind(8080).
build();
amaya.start();
}
}
@Endpoint
public class ExampleController {
@Get("/hello/{count:int}")
public HttpResponse get(HttpRequest request, @Path Integer count) {
String helloWorld = "Hello, world!";
StringBuilder response = new StringBuilder();
for (int i = 0; i < count; ++i) {
response.append(helloWorld).append('\n');
}
return Responses.ok(response);
}
}
Let's look at the controller code in more detail.
- The Endpoint annotation instructs the framework to add a controller to the server at the specified path.
- Inheritance from AbstractController ensures that the contents of your controller will be properly processed.
- The Get annotation indicates to the framework that you want to register the corresponding method located along the passed sub-path relative to the controller path.
- The Path annotation shows the framework that you want to put the value of the path variable "count" in the specified argument.
There is nothing complicated or requiring a long study in this construction. However, the user is provided with a convenient tool that allows you to quickly and easily create an api without thinking about unnecessary things.
To learn more about the core capabilities, check this
- Gradle - Dependency management
- classindex - Annotation scanning
- slf4j - Logging facade
- javax.servlet - Servlets
- amaya-core - Basic framework utilities
- sun-http-server - Server part
- RomanQed - Main work - RomanQed
- max0000402 - Technical advices and ideas for features - max0000402
See also the list of contributors who participated in this project.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details
Thanks to all the sun developers who participated in the creation of this server.
Thanks to max0000402 for good advices and great suggestions.
Thanks to IntelliJ IDEA creators - this is a really great IDE that saved me a couple of hundred hours.