#Toothpick (a.k.a T.P. like a teepee)
|
|
Visit TP wiki ! |
What is Toothpick ?
Toothpick is a scope tree based Dependency Injection (DI) library for Java.
It is a full-featured, runtime based, but reflection free, implementation of JSR 330.
What does Toothpick offer ?
//a typical Toothpick scope tree during the execution of an Android app.
@ApplicationSingleton
/ | \
/ | \
/ | \
@PresenterSingleton | Service 2
/ |
/ Service 1
/
Activity 1
/ \
/ Fragment 2
/
Fragment 1
Toothpick is :
- pure java
- fast, it doesn't use reflection but annotation processing
- simple, flexible, extensible & powerful, robust & tested
- thread safe
- documented & Open Source
- scope safe : it enforces leak free apps
- test oriented : it makes tests easier
- it works very well with Android or any other context based framework (such as web containers)
Hey, Android Devs, you can use TP to create MVP apps so easily !
Examples
Currently Toothpick has 2 sets of examples :
- one in pure Java
- one for Android
Setup
For Android :
#android setup using apt
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
dependencies {
compile 'com.github.stephanenicolas.toothpick:toothpick-runtime:x.y.z')
//or 'com.github.stephanenicolas.toothpick:smoothie:x.y.z'
apt 'com.github.stephanenicolas.toothpick:toothpick-compiler:x.y.z')
//highly recommended
testCompile 'com.github.stephanenicolas.toothpick:toothpick-testing:x.y.z')
testCompile 'mockito or easymock'
}
For java:
<!--java setup with maven -->
<dependencies>
<dependency>
<groupId>com.github.stephanenicolas.toothpick</groupId>
<artifactId>toothpick-compiler</artifactId>
<version>x.y.z</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.stephanenicolas.toothpick</groupId>
<artifactId>toothpick-runtime</artifactId>
<version>x.y.z</version>
<scope>compile</scope>
</dependency>
<!-- highly recommended-->
<dependency>
<groupId>com.github.stephanenicolas.toothpick</groupId>
<artifactId>toothpick-testing</artifactId>
<version>x.y.z</version>
<scope>test</scope>
</dependency>
<dependency>
<easymock or mockito>
</dependency>
</dependencies>
Wanna know more ?
Visit Toothpick's wiki !