Emerjoin / Hi-Framework-features

Java EE Framework
5 stars 1 forks source link

Map Hi-Framework exceptions to documentation topics #105

Open emjunior258 opened 7 years ago

emjunior258 commented 7 years ago

The path of the documentation base-url will be passed as a servlet configuration param and when an exception is thrown, the help url must be shown as part of the message.

The Mapping of the exception must be in a separate artifact named: hi-docs-mapping. The DispatcherSerlvet must attempt to load the mapping when its being initialized.

When the mapping file cant be found, then there wont be help links on exceptions messages.

emjunior258 commented 7 years ago

A new annotation must be introduced


@ExceptionTopicInfo("whatever-keyword")
public class WhateverException extends HiException{
    //More code comes here
}

Every Internal exception will be carrying this annotation. This annotation tells the keyword that must be used to map the exception to a documentation topic.

A new interface must be introduced in Hi-Framework jar

public interface ExceptionsMapper{
    public String getExceptionTopicPath(ExceptionTopicInfo info);
}

This interface will not be implemented directly inside Hi-Framework. This will be implemented out-side of the Hi-Framework-web. It will be implemented in Hi-Framework-docs. The documentation HTML pages will not be inside this jar. Only the implementation of that interface will be there. Internally. The Hi-Framework-docs jar Will use a mapping.properties file to do the mapping. Take this file as an example:

#Documentation of whatever-keyword
whatever-keyword=topic/path/comes/here
#Documentation of whativin-exception
whativin-exception=another/path/comes/here

A proxy class must be introduced

There must be a Service class that injects the ExceptionsMapper implementation into itself

The HiException class must be the one calling the proxy

The base class of all the exceptions in the framework must be the one calling the Proxy of the ExceptionsMapper implementation.

Base Path must be defined via web.xml

The default base-path will be https://Emerjoin.github.io/Hi-Framework but the developer might download the documentation to his computer, then they must be able to specify the path of their documentation: the base-url, via web.xml