Annotation Type WebServerRegistration


  • @Retention(RUNTIME)
    public @interface WebServerRegistration
    This annotation is required for the SimpleWebsiteInterface and the AdvancedWebsiteInterface. Please place this annotation above the function which should be registered in the web server. If some feature that provides values is disabled it will provide NULL.
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String[] context
      The path you want to register.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean acceptDelete
      This is only required on the SimpleWebsiteInterface.
      boolean acceptDelete_GET_VALUES
      If this is enabled get values in the url will be provided.
      boolean acceptGet
      This is only required on the SimpleWebsiteInterface.
      boolean acceptGet_GET_VALUES
      If this is enabled get values in the url will be provided.
      boolean acceptPatch
      This is only required on the SimpleWebsiteInterface.
      boolean acceptPatch_FILE
      Only one data type can be enabled at once! If this is enabled files can be uploaded to the webserver.
      boolean acceptPatch_JSON
      Only one data type can be enabled at once! If this is enabled json can be passed to the server.
      boolean acceptPatch_RAW_STRING
      Only one data type can be enabled at once! If this is enabled the raw string value in the post request will be provided.
      boolean acceptPatch_X_WWW_FORM_URLENCODED
      Only one data type can be enabled at once! If this is enabled X_WWW_FORM_URLENCODED values in the post request will be provided.
      boolean acceptPathValues
      If you use the path values feature please set this to true.
      boolean acceptPost
      This is only required on the SimpleWebsiteInterface.
      boolean acceptPost_FILE
      Only one data type can be enabled at once! If this is enabled files can be uploaded to the webserver.
      boolean acceptPost_JSON
      Only one data type can be enabled at once! If this is enabled json can be passed to the server.
      boolean acceptPost_RAW_STRING
      Only one data type can be enabled at once! If this is enabled the raw string value in the post request will be provided.
      boolean acceptPost_X_WWW_FORM_URLENCODED
      Only one data type can be enabled at once! If this is enabled X_WWW_FORM_URLENCODED values in the post request will be provided.
      boolean acceptPut
      This is only required on the SimpleWebsiteInterface.
      boolean acceptPut_FILE
      Only one data type can be enabled at once! If this is enabled files can be uploaded to the webserver.
      boolean acceptPut_JSON
      Only one data type can be enabled at once! If this is enabled json can be passed to the server.
      boolean acceptPut_RAW_STRING
      Only one data type can be enabled at once! If this is enabled the raw string value in the post request will be provided.
      boolean acceptPut_X_WWW_FORM_URLENCODED
      Only one data type can be enabled at once! If this is enabled X_WWW_FORM_URLENCODED values in the post request will be provided.
      java.lang.String apiDescription
      An simple API description.
      java.lang.String[] errorMessages
      An array list of error messages with their short codes separated by a ' - '.
      java.lang.String exampleRequest
      An example request path.
      java.lang.String exampleResponse
      An example response.
      boolean isAPI
      If you want to generate an map for your webserver set this to true if you are registering an API.
      java.lang.Class<?> jsonObject
      If json should be automatically managed by the webserver set here the class of the json object.
      int maxFileSizeInMb
      CURRENTLY NOT IN USE! WIP! Max file size in MB if file upload is enabled in this registrations.
      int usageWeight
      Each call of this site will add to not whitelisted IPs the specified usage weight.
      SpecialWebsite website
      If you want to replace the default pages like the 404 page you can define here the page.
    • Element Detail

      • context

        java.lang.String[] context
         The path you want to register.
         You can specify values like an id with a '~' between two '/'.
         With an '?' after an '/' can you specify that the url CAN
         end here. This is multiple times possible. With a double '~~'
         can you define that after that point every string will be
         stored after an slash. Also its possible to set multiple static
         paths with '|'. The used static path will then be stored in
         the path values.
        
         ---------------------------------------------------------------------
        
         Example: /user/~
         With this path would you get following values on the following calls:
        
         Call: /user
         Return: 404 not found error!
        
         Call: /user/123
         Return: [0] = 123
        
         Call: /user/123/123
         Return: 404 not found error!
        
         ---------------------------------------------------------------------
        
         Example: /search/~/?lowToHigh|highToLow/?modifiers/~
         With this path would you get following values on the following calls:
        
         Call: /search
         Return: 404 not found error!
        
         Call: /search/Im%20a%20Test%20Search
         Return: [0] = Im a Test Search
        
         Call: /search/Im%20a%20Test%20Search/lowToHigh
         Return: [0] = Im a Test Search
                 [1] = lowToHigh
        
         Call: /search/Im%20a%20Test%20Search/someThingElse
         Return: 404 not found error!
        
         Call: /search/Im%20a%20Test%20Search/highToLow/modifiers/reverse
         Return: [0] = Im a Test Search
                 [1] = highToLow
                 [2] = reverse
        
         ---------------------------------------------------------------------
        
         Example: /settings/?category/~/?view
         With this path would you get following values on the following calls:
        
         Call: /settings
         Return: [EMPTY]
        
         Call: /settings/category/1
         Return: [0] = 1
        
         Call: /settings/category/1/view
         Return: [0] = 1
                 [1] = view
        
         ---------------------------------------------------------------------
        
         Example: /download/~~
         With this path would you get following values on the following calls:
        
         Call: /download
         Return: 404 not found error!
        
         Call: /download/id123
         Return: [0] = id123
        
         Call: /download/id123/id456/id789
         Return: [0] = id123
                 [1] = id456
                 [2] = id789
        
         ---------------------------------------------------------------------
        
         If you want more examples look in the WebServerTest class.
        Returns:
        The path for the registration
      • acceptPathValues

        boolean acceptPathValues
        If you use the path values feature please set this to true. Its on default false to save resources.
        Returns:
        Should path values be checked?
        Default:
        false
      • acceptGet

        boolean acceptGet
        This is only required on the SimpleWebsiteInterface. In the AdvancedWebsiteInterface will this setting be ignored.
        Returns:
        Should get be accepted?
        Default:
        true
      • acceptGet_GET_VALUES

        boolean acceptGet_GET_VALUES
        If this is enabled get values in the url will be provided.
        Returns:
        Should the get values be provided by the web server?
        Default:
        false
      • acceptPost

        boolean acceptPost
        This is only required on the SimpleWebsiteInterface. In the AdvancedWebsiteInterface will this setting be ignored.
        Returns:
        Should post be accepted?
        Default:
        false
      • acceptPost_X_WWW_FORM_URLENCODED

        boolean acceptPost_X_WWW_FORM_URLENCODED
        Only one data type can be enabled at once! If this is enabled X_WWW_FORM_URLENCODED values in the post request will be provided. Please be aware that any request that does not provide the "content-type" header with the value "application/x-www-form-urlencoded" will be rejected!
        Returns:
        Should the post values be provided by the web server?
        Default:
        true
      • acceptPost_RAW_STRING

        boolean acceptPost_RAW_STRING
        Only one data type can be enabled at once! If this is enabled the raw string value in the post request will be provided.
        Returns:
        Should the post value be provided by the web server?
        Default:
        false
      • acceptPost_FILE

        boolean acceptPost_FILE
        Only one data type can be enabled at once! If this is enabled files can be uploaded to the webserver.
        Returns:
        Should the web server enable file uploads?
        Default:
        false
      • acceptPost_JSON

        boolean acceptPost_JSON
        Only one data type can be enabled at once! If this is enabled json can be passed to the server. Please be aware that any request that does not provide the "content-type" header with the value "application/json" will be rejected!
        Returns:
        Should the web server read the body and parse it to your json object?
        Default:
        false
      • acceptPut

        boolean acceptPut
        This is only required on the SimpleWebsiteInterface. In the AdvancedWebsiteInterface will this setting be ignored.
        Returns:
        Should put be accepted?
        Default:
        false
      • acceptPut_X_WWW_FORM_URLENCODED

        boolean acceptPut_X_WWW_FORM_URLENCODED
        Only one data type can be enabled at once! If this is enabled X_WWW_FORM_URLENCODED values in the post request will be provided.
        Returns:
        Should the post values be provided by the web server?
        Default:
        true
      • acceptPut_RAW_STRING

        boolean acceptPut_RAW_STRING
        Only one data type can be enabled at once! If this is enabled the raw string value in the post request will be provided.
        Returns:
        Should the post value be provided by the web server?
        Default:
        false
      • acceptPut_FILE

        boolean acceptPut_FILE
        Only one data type can be enabled at once! If this is enabled files can be uploaded to the webserver.
        Returns:
        Should the web server enable file uploads?
        Default:
        false
      • acceptPut_JSON

        boolean acceptPut_JSON
        Only one data type can be enabled at once! If this is enabled json can be passed to the server. Please be aware that any request that does not provide the "content-type" header with the value "application/json" will be rejected!
        Returns:
        Should the web server read the body and parse it to your json object?
        Default:
        false
      • acceptPatch

        boolean acceptPatch
        This is only required on the SimpleWebsiteInterface. In the AdvancedWebsiteInterface will this setting be ignored.
        Returns:
        Should patch be accepted?
        Default:
        false
      • acceptPatch_X_WWW_FORM_URLENCODED

        boolean acceptPatch_X_WWW_FORM_URLENCODED
        Only one data type can be enabled at once! If this is enabled X_WWW_FORM_URLENCODED values in the post request will be provided.
        Returns:
        Should the post values be provided by the web server?
        Default:
        true
      • acceptPatch_RAW_STRING

        boolean acceptPatch_RAW_STRING
        Only one data type can be enabled at once! If this is enabled the raw string value in the post request will be provided.
        Returns:
        Should the post value be provided by the web server?
        Default:
        false
      • acceptPatch_FILE

        boolean acceptPatch_FILE
        Only one data type can be enabled at once! If this is enabled files can be uploaded to the webserver.
        Returns:
        Should the web server enable file uploads?
        Default:
        false
      • acceptPatch_JSON

        boolean acceptPatch_JSON
        Only one data type can be enabled at once! If this is enabled json can be passed to the server. Please be aware that any request that does not provide the "content-type" header with the value "application/json" will be rejected!
        Returns:
        Should the web server read the body and parse it to your json object?
        Default:
        false
      • acceptDelete

        boolean acceptDelete
        This is only required on the SimpleWebsiteInterface. In the AdvancedWebsiteInterface will this setting be ignored.
        Returns:
        Should patch be accepted?
        Default:
        false
      • acceptDelete_GET_VALUES

        boolean acceptDelete_GET_VALUES
        If this is enabled get values in the url will be provided.
        Returns:
        Should the get values be provided by the web server?
        Default:
        false
      • website

        SpecialWebsite website
        If you want to replace the default pages like the 404 page you can define here the page. Should you use this feature its not required for the special page to have a valid context because its ignored if this is set. Special pages cant have passed any values by the webserver except for the HttpExchange object. Can only be used on SimpleWebsiteInterface!
        Returns:
        ENUM which special page should be defined!
        Default:
        me.scolastico.tools.web.enums.SpecialWebsite.NORMAL_PAGE
      • jsonObject

        java.lang.Class<?> jsonObject
        If json should be automatically managed by the webserver set here the class of the json object.
        Returns:
        The class of the json object which should be automatically parsed.
        Default:
        void.class
      • isAPI

        boolean isAPI
        If you want to generate an map for your webserver set this to true if you are registering an API. In normal cases every time true if you use an AdvancedWebsiteInterface.
        Returns:
        Is this is an API registration?
        Default:
        false
      • maxFileSizeInMb

        int maxFileSizeInMb
        CURRENTLY NOT IN USE! WIP! Max file size in MB if file upload is enabled in this registrations. Default is 256MB. On larger files its recommended to use a synchronized function because the file is until you save it in your function completely in the system ram.
        Returns:
        Max file size for uploads in MB.
        Default:
        256
      • usageWeight

        int usageWeight
        Each call of this site will add to not whitelisted IPs the specified usage weight. If the usage weight exceeds the configured max weight per use of the web server the user gets an 429 error and the LIMIT_REACHED_PAGE will be shown. If the weight is 0 the user can open this page even if he is at max weight. The default max weight is 60000. An user loses every second 100 weight until he is back on 0.
        Returns:
        The weight for each usage.
        Default:
        0
      • apiDescription

        java.lang.String apiDescription
        An simple API description.
        Returns:
        An simple API description.
        Default:
        ""
      • exampleRequest

        java.lang.String exampleRequest
        An example request path. The domain will be added automatically.
        Returns:
        An example request path.
        Default:
        ""
      • exampleResponse

        java.lang.String exampleResponse
        An example response.
        Returns:
        An example response.
        Default:
        ""
      • errorMessages

        java.lang.String[] errorMessages
        An array list of error messages with their short codes separated by a ' - '. Example: 'not found - The resource could not be found.'
        Returns:
        An array list of error messages with their short codes.
        Default:
        {}