-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.objectstyle.dagger</groupId> | ||
<artifactId>dagger-sandbox</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>cayennedi</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<main.class>org.objectstyle.cayenne.Main</main.class> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.objectstyle.dagger</groupId> | ||
<artifactId>common</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cayenne</groupId> | ||
<artifactId>cayenne-di</artifactId> | ||
<version>${cayenne.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.objectstyle.cayenne; | ||
|
||
import org.apache.cayenne.di.DIBootstrap; | ||
import org.objectstyle.dagger.service.Service; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
Service s = DIBootstrap.createInjector(new MainModule()).getInstance(Service.class); | ||
System.out.println(s.doIt()); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
cayennedi/src/main/java/org/objectstyle/cayenne/MainModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.objectstyle.cayenne; | ||
|
||
import org.apache.cayenne.di.Binder; | ||
import org.apache.cayenne.di.Module; | ||
import org.objectstyle.dagger.service.Service; | ||
import org.objectstyle.dagger.service.SubService; | ||
import org.objectstyle.dagger.service.SubServiceImpl; | ||
|
||
public class MainModule implements Module { | ||
|
||
@Override | ||
public void configure(Binder binder) { | ||
binder.bind(Service.class).toProvider(SubServiceProvider.class); | ||
binder.bind(SubService.class).to(SubServiceImpl.class); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
cayennedi/src/main/java/org/objectstyle/cayenne/SubServiceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.objectstyle.cayenne; | ||
|
||
import org.apache.cayenne.di.DIRuntimeException; | ||
import org.apache.cayenne.di.Inject; | ||
import org.apache.cayenne.di.Provider; | ||
import org.objectstyle.dagger.service.Service; | ||
import org.objectstyle.dagger.service.ServiceImpl; | ||
import org.objectstyle.dagger.service.SubService; | ||
|
||
public class SubServiceProvider implements Provider<Service> { | ||
|
||
@Inject | ||
private SubService subService; | ||
|
||
@Override | ||
public Service get() throws DIRuntimeException { | ||
return new ServiceImpl(subService); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters