Commons

Commons is a package that contains shared constants, objects and classes among the microservices. The reason of the usage of this dependency package is to avaoid code duplication and improve code reusabilty.

Annotations


Constants

  • This package contains shared constant variables by microservices. For instance, service and header names.

Entity

  • This package contains two different entity class. The reason of this package is to provide a common entity structure in the project. For instance, mete data usage.
    • AbstractEntity.java: Abstraction of an entity class. Contains meta informations. (createdAt, createdBy, uodatedAt, updatedBy)
    • ResourceEntity.java: Extends AbstractEntity.java and inherits resourceId field to the classes who extends this class.

Exception

  • This package contains a customized RunTimeException. Multiple ErrorMessages can be added to throw multiple errors at the same time.
  • In the constants package, an enumurated needs to be defined that contains title and error code. So that error body can be initialized easily.

Helper

  • TokenHelper.java
    • Generated JWT Tokens and checks whether a token is expired or not.

Mapper

  • Abstraction of mappers. This class needs to be extended by all of the mappers so that, thanks to Mapstruct, creating a java class will be enought to generate mapper implementations.

Rest

- Model - Request models that are consumed by controllers. - Rest - This package contains a http request client to be able to send rest request easily. It is used to send a REST request from a microservice to the another microservice.


Response

    • This is a common return type of all methods in the constructors. Thanks to Builder Pattern an instance of this object can be generated.
    • This response object is for the responses that are parsed by HttpRestClient. On the other word, this response object uses for the internal request results.

Util

  • Contains utility classes for complex type Java objects.

Validator

  • This package contains abstraction of a validator and the validation facade. Facade Patternis being used for validations.
  • MandatoryCheckValidator is a common validation class. This is a singleton classs. Instead of most of the validators in Scrumier, it is not a spring bean.

Contribution

  • Git flow

    • In order to be able to contribute this package, you need to fork this repository and clone it into your local.
    • Create a feature branch from master.
    • Push your changes to your feature branch on your fork.
    • Create a pull request from the feature branch on your fork to the master branch on this repository
  • Building Artifact

    • Add your authentication information to ~/.m2/settings.xml so that the github site-maven-plugin can push to GitHub
    <settings>
      <servers>
        <server>
          <id>github</id>
          <username>YOUR-USERNAME</username>
          <password>YOUR-PASSWORD</password>
       </server>
      </servers>
    </settings>
    mvn clean deploy