GithubHelp home page GithubHelp logo

bethibande / jwebapi Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 417 KB

A simple framework for easy creation of simple http servers/clients

License: Apache License 2.0

Java 100.00%
framework gson http java maven web

jwebapi's Introduction

jwebapi's People

Contributors

bethibande avatar

Stargazers

 avatar

Watchers

 avatar

jwebapi's Issues

Possible performance improvement

Store OutputHandler instances insteadof classes, removes need to create instances on the fly.
For more info, see TODO item in HttpHandler

Logger, use only one Thread

currently, every log message submits a new task to the thread-pool, this is obviously not good. Sometimes the logger also stops printing messages completely, this has not yet been debuged, but is probably caused by this. The goal of this issue is, to now only use one static thread to print all queued message of a logger

@JsonField(value) annotation

  1. If there already is a json object stored in the current context, skip step 2
  2. This annotation is supposed to read json post data, turn it into a json object, store it in the current context.
  3. Pass data of json field into parameter where jsonFieldName = @JsonField.value

URI priority

There needs to be a priority used to define which handlers get checked and subsequently executed first.
At the moment there is no way to do this. I want to be able to define a handler with the uri "/" and the type string which will act as a 404 error handler. At the moment this handler, depending on when it is registered, will prevent other handlers from being executed. In order for this handler to work as intented, it needs a priority making sure, it is always the last entry in the list of handlers.

Should look something like this

@URI(value = "/", type = URI.URIType.STRING, priority = Integer.MIN_VALUE)
public Object notFoundHandler() {

Global gson instance

Store a Gson instance in the server or context, this allows for people to customize the gson instance used by all classes

Cache parameter mappings

Cache parameter mappings for constructors and methods. This prevents having to apply all ParameterProcessors to every parameter with every request. Creating mappings of which ParameterProcessor needs to be applied to which parameter will increase performance.

Clean-up

After before the first version containing the client is built, some things have to be cleaned up. There are lots of methods and classes used by the server that are now redundant. And should be replace with classes and methods added during client development.

Dynamic URIs

Create URIObject and replace URI class in JWebServer methods HashMap

Not sure as to what this is supposed to look like or wheter it's actually needed or not

RequestParameterProcessor class

Create a RequestParameterProcessor class, which is an abstract class and implements ParameterProcessor, this class should only fire if the request is not empty and only has a server instance

Autodiscover feature

Register all classes annotated with an annotation as handlers, without having to register each class individually.
Perhaps even add a value to said annotation, and make it ignore all annotated classes that don't have a certain value.

Custom HttpServer impl as default server

By default the JWebServer class uses the com.sun.net.httpserver.HttpServer class. The experimental branch has a custom implementation of this class, that does not implement a lot of features like the HttpContext class and more, due to this, the custom server implementation is quite a bit faster than the default com.sun.net.httpserver.HttpServer class. Use this class as a default instead.
Before that, the HttpServer and HttpExchange classes have to implement a few important features like the stop method.

method for registering handlers using Function interface

Add a method for adding handlers using the Function interface, instead of implementing handlers as methods using the @uri annotation. The method should look something like this:

.registerHandler(String uri, Function<ServerContext, Object> fun);

Logging

Add a proper Logger and debug messages

Client performance issue

The ClientHandler class currently has two nested for loops, these are unnecessary and should be replace with pre calculated mappings like the ones the server uses for its parameter processors.

Register individual methods

register individual methods instead of registering all methods within a certain class

jwebserver.registerMethod(Method method);

jwebserver.registerMethod(Class class, String methodName, Class... methodSignature);

Beans

No idea what this is gonna look like, but something like this would certainly be convenient to have.

Fix logger dateformat

The logger seems to print mm:hh insead of hh:mm, minutes and hours are swapped. The format should obviously be hh:mm

Experimental branch

Create an experimental branch, for experiments, like Custom HttpServer implementations or more.

Add UpdateTimeout value into cache and cache config

Add UpdateTimeout value into cache and cache config and subsequently remove update timeouts stored in JWebServer and Session classes. Note: Make Cache.update() method return a boolean, to show whether or not the cache was updated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.