Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
suuft (valeriy) committed Feb 21, 2023
0 parents commit d93f2f4
Show file tree
Hide file tree
Showing 35 changed files with 733 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/DEPEND.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## | `Lithe DI - Add as depend:`
Here is how to add this framework depending on your project.
### | `Gradle`:
If you use Gradle with Groovy, then here is an example of adding dependencies:
```groovy
repositories {
// other repositories
maven {
name = "clojars.org"
url = uri("https://repo.clojars.org")
}
}
dependencies {
// other depends
implementation 'works.naifu:lithe:2.1.1'
}
```

### | `Maven`:

Repository:

```xml
<repository>
<id>clojars.org</id>
<url>https://repo.clojars.org</url>
</repository>
```

Depend:

```xml

<dependency>
<groupId>works.naifu</groupId>
<artifactId>lithe</artifactId>
<version>2.1.1</version>
</dependency>
```
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: suuft
custom: https://www.buymeacoffee.com/suuft
63 changes: 63 additions & 0 deletions .github/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## | `Lithe DI - Usage:`
*You can found full example-code in:* [LINK](https://github.com/suuft/Lithe/tree/master/src/test/java/net/lithe/test)

First, lets create an application class that ll run the JVM. E.i. - Main:
```java
public class Main {

public static void main(String[] args) {
}
}
```
Lets create an abstract class (an interface, but you can create abstract class or a simple class) that ll have abstract methods for working with some data. I have this as metric, so this class ll count the number of sessions:
```java
public interface SessionCounter {
int getSessions();
void incrementSessions();
}
```
Okay come write it s implementation:
```java
public class MySessionCounter implements SessionCounter {

private int sessions;

@Override
public int getSessions() {
return sessions;
}

@Override
public void incrementSessions() {
sessions++;
}
}
```
Good job! You should write a class that register dependencies, for further using - Adept, it will extends from `SimpleAdept`:
```java
public class CounterAdept extends SimpleAdept {
@Override
public void install() {
register(SessionCounter.class, MySessionCounter.class);
}
}
```
Done! So you can create an injector through the `Lithe` class and use the registered dependencies. I wrote an example in the Main class.
```java
public class Main {

public static void main(String[] args) {
Injector injector = Lithe.createInjector(new CounterAdept());
System.out.println("Current sessions: " + injector.getInstance(SessionCounter.class).getSessions());

System.out.println("Try increment #1");
injector.getInstance(SessionCounter.class).incrementSessions();

System.out.println("Try increment #2");
injector.getInstance(SessionCounter.class).incrementSessions();

System.out.println("Current sessions: " + injector.getInstance(SessionCounter.class).getSessions());
}
}
```
The final output will show us the number 2. So you did everything right. Cool!
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions LEARN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## | `Lithe DI - Learn project`
Hi! This is a learn project, if you have idea or know how to refactor the code, be sure to send me pull requests, issues. Im not adequate criticism.
### | `Road-Map`:
1) Add Automatic-Generation adept.
2) Add Auto-Injection Depends.
3) Refactor all.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Valeriy Shushpanov (suuft)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## | `Lithe DI`
A small & fast but convenient framework for working with dependencies. I'll add dependency injection soon.

### | `Links`:
* [About this learn project](https://github.com/suuft/Lithe/blob/master/LEARN.md)
* [Add as Depend](https://github.com/suuft/Lithe/blob/master/.github/DEPEND.md)
* [Usage Example](https://github.com/suuft/Lithe/blob/master/.github/USAGE.md)
19 changes: 19 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java'
}

group 'net.wonsi'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
useJUnitPlatform()
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit d93f2f4

Please sign in to comment.