Skip to content
Snippets Groups Projects
Commit cbbc1a86 authored by jez04's avatar jez04
Browse files

feat: :tada: initial commit

parent fc343158
No related merge requests found
Pipeline #2241 failed with stages
in 0 seconds
Showing
with 456 additions and 0 deletions
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
*.db
rebel.xml
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
#Directories
target/
build/
tmp/
bin/
logs/
GitDirectory/
#Windows
Thumbs.db
Desktop.ini
#Eclipse
*.pydevproject
.project
.metadata
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
#IntelliJ IDEA
*.iml
\.idea/
#Sonar-Scanner
\.scannerwork/
# Thumbnails
._*
*# Testing environment specific
derby.log
<?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>
<artifactId>vis-java</artifactId>
<groupId>cz.jezek</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>common</artifactId>
<name>common</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
</properties>
<dependencies>
</dependencies>
</project>
package cz.common;
public class Person {
private String name;
private long id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Person(long id, String name) {
super();
this.id = id;
this.name = name;
}
@Override
public String toString() {
return "Person [id=" + id + ", name=" + name + "]";
}
}
module common {
exports cz.common;
}
\ No newline at end of file
package cz.common;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Test;
/**
* Unit test for simple App.
*/
public class PersonTest {
/**
* Rigorous Test :-)
*/
@Test
public void toStringTest() {
assertNotNull(new Person(1, "Test").toString());
}
}
<?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>
<artifactId>vis-java</artifactId>
<groupId>cz.jezek</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>dataLayerDB</artifactId>
<name>dataLayerDB</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>cz.jezek</groupId>
<artifactId>dataLayerInterfaces</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
package cz.dataLayerDB;
import java.util.Arrays;
import java.util.List;
import cz.common.Person;
import cz.dataLayerInterfaces.PersonDataMapperInterface;
public class PersonDM implements PersonDataMapperInterface{
@Override
public List<Person> getAllPersons() {
return Arrays.asList(new Person(1, "SQL Modul"));
}
}
import cz.dataLayerDB.PersonDM;
import cz.dataLayerInterfaces.PersonDataMapperInterface;
module dataLayerDB {
exports cz.dataLayerDB;
requires transitive common;
requires dataLayerInterfaces;
provides PersonDataMapperInterface with PersonDM;
}
\ No newline at end of file
package cz.dataLayerDB;
import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
/**
* Unit test for simple App.
*/
public class PersonDMTest
{
/**
* Rigorous Test :-)
*/
@Test
public void getAllPersonsTest()
{
assertFalse(new PersonDM().getAllPersons().isEmpty());
}
}
<?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>
<artifactId>vis-java</artifactId>
<groupId>cz.jezek</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>dataLayerInterfaces</artifactId>
<name>dataLayerInterfaces</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>cz.jezek</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.12</version>
</dependency>
</dependencies>
</project>
package cz.dataLayerInterfaces;
import java.util.List;
import java.util.ServiceLoader;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
import cz.common.Person;
public interface PersonDataMapperInterface {
public List<Person> getAllPersons();
public static PersonDataMapperInterface newInstance() {
ServiceLoader<PersonDataMapperInterface> service = ServiceLoader.load(PersonDataMapperInterface.class);
for (PersonDataMapperInterface personDataMapperInterface : service) {
System.out.println("Implementation of PersonDataMapperInterface found: "
+ personDataMapperInterface.getClass().getCanonicalName());
}
for (PersonDataMapperInterface inter : service) {
return inter;
}
/*
* try find implementation using reflection, due running without module support
* to run spring
*/
return findImplementationByReflection();
}
public static PersonDataMapperInterface findImplementationByReflection() {
String packageNameForSearch = "cz";
Reflections reflections = new Reflections(packageNameForSearch, new SubTypesScanner());
Class<?> clazz = reflections.getSubTypesOf(PersonDataMapperInterface.class).stream().findAny().orElse(null);
if (clazz == null) {
return null;
}
try {
return (PersonDataMapperInterface) clazz.getConstructor(null).newInstance(null);
} catch (Exception e) {
System.out.println(e.getMessage());
}
return null;
}
}
import cz.dataLayerInterfaces.PersonDataMapperInterface;
module dataLayerInterfaces {
exports cz.dataLayerInterfaces;
requires transitive common;
requires reflections;
uses PersonDataMapperInterface;
}
\ No newline at end of file
<?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>
<artifactId>vis-java</artifactId>
<groupId>cz.jezek</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>dataLayerOther</artifactId>
<name>dataLayerOther</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>cz.jezek</groupId>
<artifactId>dataLayerInterfaces</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
package cz.dataLayerOther;
import java.util.Arrays;
import java.util.List;
import cz.common.Person;
import cz.dataLayerInterfaces.PersonDataMapperInterface;
public class PersonOtherDM implements PersonDataMapperInterface{
@Override
public List<Person> getAllPersons() {
return Arrays.asList(new Person(1, "Other storage Modul"));
}
}
import cz.dataLayerInterfaces.PersonDataMapperInterface;
import cz.dataLayerOther.PersonOtherDM;
module dataLayerOther {
exports cz.dataLayerOther;
requires transitive common;
requires dataLayerInterfaces;
provides PersonDataMapperInterface with PersonOtherDM;
}
\ No newline at end of file
package cz.dataLayerOther;
import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
/**
* Unit test for simple App.
*/
public class PersonOtherDMTest
{
/**
* Rigorous Test :-)
*/
@Test
public void getAllPersonsTest()
{
assertFalse(new PersonOtherDM().getAllPersons().isEmpty());
}
}
<?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>
<artifactId>vis-java</artifactId>
<groupId>cz.jezek</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>domainLayer</artifactId>
<name>domainLayer</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>cz.jezek</groupId>
<artifactId>dataLayerInterfaces</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
package cz.domainLayer;
import java.util.List;
import cz.common.Person;
import cz.dataLayerInterfaces.PersonDataMapperInterface;
public class PersonTransactionScript {
private PersonDataMapperInterface personDM;
public PersonTransactionScript() {
personDM = PersonDataMapperInterface.newInstance();
}
public List<Person> getAllPersons(){
System.out.println("personDM="+personDM);
/*very complicated domain logic :-) */
return personDM.getAllPersons();
}
}
module domainLayer {
exports cz.domainLayer;
requires transitive common ;
requires dataLayerInterfaces;
}
\ No newline at end of file
package cz.domainLayer;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* Unit test for simple App.
*/
public class PersonTransactionScriptTest {
/**
* Rigorous Test :-)
*/
@Test
public void getAllPersonsTest() {
assertTrue(true);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment