-
Notifications
You must be signed in to change notification settings - Fork 3
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
bs
committed
Apr 30, 2019
1 parent
413a796
commit 033fc52
Showing
162 changed files
with
1,640 additions
and
341 deletions.
There are no files selected for viewing
File renamed without changes.
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,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.3.11.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.11.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.11.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.11.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.11.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.11.RELEASE" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.8" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.10" level="project" /> | ||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" /> | ||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.11" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> | ||
</component> | ||
</module> |
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,55 @@ | ||
<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/maven-v4_0_0.xsd"> | ||
<parent> | ||
<groupId>io.drift</groupId> | ||
<artifactId>drift-core</artifactId> | ||
<version>0.0.2-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>drift-core-domain</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Drift :: Core :: Domain</name> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.giffing.wicket.spring.boot.starter</groupId> | ||
<artifactId>wicket-spring-boot-starter</artifactId> | ||
<version>1.0.10</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context-support</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.8.8</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.2.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
...re/drift-core-domain/src/main/java/io/drift/core/config/DriftAnnotationPostProcessor.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,31 @@ | ||
package io.drift.core.config; | ||
|
||
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.config.BeanPostProcessor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class DriftAnnotationPostProcessor implements BeanPostProcessor { | ||
|
||
private final DriftEngine driftEngine; | ||
|
||
public DriftAnnotationPostProcessor(DriftEngine driftEngine) { | ||
this.driftEngine = driftEngine; | ||
} | ||
|
||
|
||
@Override | ||
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { | ||
return bean; | ||
} | ||
|
||
@Override | ||
public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { | ||
if (bean instanceof EnginePlugin) { | ||
EnginePlugin plugin = (EnginePlugin) bean; | ||
driftEngine.registerPlugin(plugin); | ||
} | ||
|
||
return bean; | ||
} | ||
} |
11 changes: 2 additions & 9 deletions
11
...io/drift/core/config/DriftCoreConfig.java → ...io/drift/core/config/DriftCoreConfig.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
5 changes: 2 additions & 3 deletions
5
...ava/io/drift/core/config/DriftEngine.java → ...ava/io/drift/core/config/DriftEngine.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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
drift-core/drift-core-domain/src/main/java/io/drift/core/lifecycle/AbstractScope.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,25 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
abstract public class AbstractScope implements Scope { | ||
|
||
private Map<Class, Object> objects = new HashMap<>(); | ||
|
||
protected Object getOrCreate(BeanDescriptor descriptor) { | ||
Object object = objects.get(descriptor.getBeanClass()); | ||
if (object == null) { | ||
object = create(descriptor); | ||
objects.put(descriptor.getBeanClass(), object); | ||
} | ||
return object; | ||
|
||
} | ||
|
||
protected Object create(BeanDescriptor descriptor) { | ||
return descriptor.getConstructor().create(); | ||
} | ||
|
||
|
||
} |
6 changes: 6 additions & 0 deletions
6
drift-core/drift-core-domain/src/main/java/io/drift/core/lifecycle/BeanConstructor.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,6 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
@FunctionalInterface | ||
public interface BeanConstructor { | ||
Object create(); | ||
} |
27 changes: 27 additions & 0 deletions
27
drift-core/drift-core-domain/src/main/java/io/drift/core/lifecycle/BeanContainer.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,27 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class BeanContainer { | ||
|
||
private Map<Class, BeanDescriptor> descriptors = new HashMap<>(); | ||
|
||
private List<Scope> scopes = new ArrayList<>(); | ||
|
||
public Object getBean(Class _class) { | ||
BeanDescriptor descriptor = descriptors.get(_class); | ||
return descriptor.getScope().getBean(descriptor); | ||
} | ||
|
||
public void registerModule(Module module) { | ||
module.registerTo(this); | ||
} | ||
|
||
public void registerBean(BeanDescriptor descriptor) { | ||
descriptors.put(descriptor.getBeanClass(), descriptor); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
drift-core/drift-core-domain/src/main/java/io/drift/core/lifecycle/BeanDescriptor.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,29 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
public class BeanDescriptor { | ||
|
||
private BeanConstructor constructor; | ||
|
||
private Scope scope; | ||
|
||
private Class beanClass; | ||
|
||
public BeanDescriptor(Class beanClass, Scope scope, BeanConstructor constructor) { | ||
this.constructor = constructor; | ||
this.scope = scope; | ||
this.beanClass = beanClass; | ||
} | ||
|
||
public BeanConstructor getConstructor() { | ||
return constructor; | ||
} | ||
|
||
public Class getBeanClass() { | ||
return beanClass; | ||
} | ||
|
||
public Scope getScope() { | ||
return scope; | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
drift-core/drift-core-domain/src/main/java/io/drift/core/lifecycle/FlowScope.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,8 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
public class FlowScope extends AbstractScope implements Scope { | ||
@Override | ||
public Object getBean(BeanDescriptor descriptor) { | ||
return create(descriptor); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
drift-core/drift-core-domain/src/main/java/io/drift/core/lifecycle/Module.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,5 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
public interface Module { | ||
void registerTo(BeanContainer beanContainer); | ||
} |
8 changes: 8 additions & 0 deletions
8
drift-core/drift-core-domain/src/main/java/io/drift/core/lifecycle/RequestScope.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,8 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
public class RequestScope extends AbstractScope implements Scope { | ||
@Override | ||
public Object getBean(BeanDescriptor descriptor) { | ||
return create(descriptor); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
drift-core/drift-core-domain/src/main/java/io/drift/core/lifecycle/Scope.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,5 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
public interface Scope { | ||
Object getBean(BeanDescriptor descriptor); | ||
} |
10 changes: 10 additions & 0 deletions
10
drift-core/drift-core-domain/src/main/java/io/drift/core/lifecycle/SingletonScope.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,10 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
public class SingletonScope extends AbstractScope implements Scope { | ||
|
||
@Override | ||
public Object getBean(BeanDescriptor descriptor) { | ||
return getOrCreate(descriptor); | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,7 @@ | ||
<project name="drift-core"> | ||
<skin> | ||
<groupId>org.apache.maven.skins</groupId> | ||
<artifactId>maven-fluido-skin</artifactId> | ||
<version>1.7</version> | ||
</skin> | ||
</project> |
4 changes: 4 additions & 0 deletions
4
drift-core/drift-core-domain/src/test/java/io/drift/core/lifecycle/ConfigBean.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,4 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
public class ConfigBean { | ||
} |
18 changes: 18 additions & 0 deletions
18
drift-core/drift-core-domain/src/test/java/io/drift/core/lifecycle/FlowScopedBean.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,18 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
public class FlowScopedBean { | ||
|
||
private SingletonScopedBean singletonScopedBean; | ||
|
||
public FlowScopedBean(SingletonScopedBean singletonScopedBean) { | ||
this.singletonScopedBean = singletonScopedBean; | ||
} | ||
|
||
public void doSomething() { | ||
singletonScopedBean.doSomething(); | ||
} | ||
|
||
public SingletonScopedBean getSingletonScopedBean() { | ||
return singletonScopedBean; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
drift-core/drift-core-domain/src/test/java/io/drift/core/lifecycle/LifeCycleTest.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,55 @@ | ||
package io.drift.core.lifecycle; | ||
|
||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
public class LifeCycleTest extends TestCase { | ||
|
||
private BeanContainer beanContainer; | ||
|
||
protected void setUp() { | ||
beanContainer = new BeanContainer(); | ||
beanContainer.registerModule(new Module1()); | ||
} | ||
|
||
public void testBeanCreation() { | ||
|
||
SingletonScopedBean singletonScopedBean = (SingletonScopedBean) beanContainer.getBean(SingletonScopedBean.class); | ||
Assert.assertNotNull(singletonScopedBean); | ||
|
||
FlowScopedBean flowScopedBean = (FlowScopedBean) beanContainer.getBean(FlowScopedBean.class); | ||
Assert.assertNotNull(flowScopedBean); | ||
Assert.assertNotNull(flowScopedBean.getSingletonScopedBean()); | ||
|
||
RequestScopedBean requestScopedBean = (RequestScopedBean) beanContainer.getBean(RequestScopedBean.class); | ||
Assert.assertNotNull(requestScopedBean.getFlowScopedBean()); | ||
Assert.assertNotNull(requestScopedBean.getFlowScopedBean().getSingletonScopedBean()); | ||
|
||
} | ||
|
||
public void testSingletonScope() { | ||
SingletonScopedBean singletonScopedBean = (SingletonScopedBean) beanContainer.getBean(SingletonScopedBean.class); | ||
SingletonScopedBean singletonScopedBean2 = (SingletonScopedBean) beanContainer.getBean(SingletonScopedBean.class); | ||
Assert.assertEquals(singletonScopedBean, singletonScopedBean2); | ||
|
||
FlowScopedBean flowScopedBean = (FlowScopedBean) beanContainer.getBean(FlowScopedBean.class); | ||
FlowScopedBean flowScopedBean2 = (FlowScopedBean) beanContainer.getBean(FlowScopedBean.class); | ||
Assert.assertNotEquals(flowScopedBean, flowScopedBean2); | ||
Assert.assertEquals(singletonScopedBean, flowScopedBean.getSingletonScopedBean()); | ||
|
||
RequestScopedBean requestScopedBean = (RequestScopedBean) beanContainer.getBean(RequestScopedBean.class); | ||
RequestScopedBean requestScopedBean2 = (RequestScopedBean) beanContainer.getBean(RequestScopedBean.class); | ||
Assert.assertNotEquals(requestScopedBean, requestScopedBean2); | ||
Assert.assertEquals(singletonScopedBean, requestScopedBean.getFlowScopedBean().getSingletonScopedBean()); | ||
|
||
|
||
|
||
} | ||
|
||
public void testStoreBackedBean() { | ||
|
||
|
||
|
||
} | ||
|
||
} |
Oops, something went wrong.