Jshorten is an url shortener made purely in Java 11. This project is supposed to be an easily-extendable url shortener to make the job as fast as You need it. It needs unit testing.
- SparkJava - lightweight web framework
- Thymeleaf - frontend template engine
- org.json - json library
- org.slf4j - logging library
- Gradle - build tool
Requirements:
- Java 11
- Gradle
In order to start app simply clone it, enter the directory of cloned project and execute in terminal:
gradle jar
java -jar build/libs/UrlShortener-1.0-SNAPSHOT.jar
The app is ready to be deployed to Heroku. It uses either environment variable PORT
(as Heroku requires) whenever possible, otherwise default Spark
port: 4567
In order to create your own version of this project you have to create class which would extend Url
abstract class. You can use default implementation UrlPojo
.
Server
class uses default implementations or objects passed using methods as repository(arg), service(arg), ...
.
Class | Default implementation | Arguments |
---|---|---|
Url | UrlPojo | String url, OffsetDateTime expirationTime |
UrlRepository | InMemoryUrlRepository | DuplicateHandler |
DuplicateHandler | DefaultDuplicateHandlerImpl | X |
UrlFactory | DefaultUrlFactory | ShortingAlgorithm algorithm, UrlCreator creator |
UrlService | DefaultUrlServiceImpl | UrlRepository repository, UrlFactory factory, UrlValidator validator |
UrlValidator | DefaultUrlValidator | X |
The default version (available here).