Skip to content

Commit

Permalink
added basic implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mcupak committed Mar 29, 2016
1 parent ccc498c commit 483cab6
Show file tree
Hide file tree
Showing 28 changed files with 2,002 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,31 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# IntelliJ
*.iml
.idea

# Eclipse
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# NetBeans
nb-configuration.xml
nbactions*.xml

# Maven
*target*
*.class
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#Java Beacon

##Contents

* [What it is](#what-it-is)
* [System requirements](#system-requirements)
* [How to run it](#how-to-run-it)
* [How it works](#how-it-works)
* [Technologies](#technologies)

##What it is
This project contains BDK (beacon development kit) for Java (EE) developers. It provides a skeleton of a simple beacon allowing the developers to plug in their own data/functionality. The API makes sure the response produced is compatible with what the Beacon of Beacons can consume.

##System requirements
All you need to build this project is Java 7.0 (Java SDK 1.7) or later, Maven 3.0 or later. Since the project is Java EE based, an application server with support for Java EE 6 is needed to deploy the application (e.g. JBoss EAP or WildFly).

##How to run it
Start the JBoss server:

For Linux/Unix: JBOSS_HOME/bin/standalone.sh
For Windows: JBOSS_HOME\bin\standalone.bat

Build and deploy the archive:

mvn clean install jboss-as:deploy

The application should now be running on <http://localhost:8080/beacon-java>.

In order to run the tests in a managed (remote) container, use the test-managed (test-remote) Maven profile. Example:

mvn clean test -Ptest-managed

##How it works
The project provides the following:
- API for beacons
- sample beacon implementation
- conversion of parameters to a normalized form (the same way Beacon of Beacons does)
- sample navigation webpage
- sample testsuite

In order to create your own beacon, we suggest you do the following:
- implement BeaconService interface (replace the sample implementation provided in the SampleBeaconService class, you shouldn't need to touch any other classes in this project)
- modify index.jsp to provide a landing page for your beacon (optional)
- provide query with a YES and NO response in BeaconResourceTest class to make sure your beacon works (optional)

The API takes care of the rest and provides the following endpoints upon deployment of your beacon:

http://localhost:8080/beacon-java/info - information about your beacon
http://localhost:8080/beacon-java/query - access to query service

##Technologies
Java EE. CDI, JAX-RS, JAXB. Tested with Arquillian/ShrinkWrap.
218 changes: 218 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>

<groupId>com.dnastack</groupId>
<artifactId>beacon-java</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>beacon-java</name>

<scm>
<url>https://github.com/mcupak/beacon-java</url>
<connection>scm:git:git://github.com/mcupak/beacon-java.git</connection>
<developerConnection>scm:git:[email protected]:mcupak/beacon-java.git</developerConnection>
</scm>

<developers>
<developer>
<id>mcupak</id>
<name>Miro</name>
<email>[email protected]</email>
<url>https://github.com/mcupak</url>
</developer>
</developers>

<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>


<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.jboss.spec.javaee.7.0>8.2.1.Final</version.jboss.spec.javaee.7.0>
<version.shrinkwrap.resolver.bom>2.1.1</version.shrinkwrap.resolver.bom>
<version.arquillian.bom>1.1.8.Final</version.arquillian.bom>
<version.eclipselink>2.6.0</version.eclipselink>
<version.junit>4.12</version.junit>
<version.surefire.plugin>2.17</version.surefire.plugin>
<version.compiler.plugin>2.3.2</version.compiler.plugin>
<version.jaxb.plugin>2.1</version.jaxb.plugin>
<version.war.plugin>2.3</version.war.plugin>
<version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-all</artifactId>
<version>${version.jboss.spec.javaee.7.0}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-bom</artifactId>
<version>${version.shrinkwrap.resolver.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.arquillian.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>${version.eclipselink}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<scope>test</scope>
<type>pom</type>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire.plugin}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>test-managed</id>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>test-remote</id>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
62 changes: 62 additions & 0 deletions src/main/java/com/dnastack/beacon/entity/Allele.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* The MIT License
*
* Copyright 2014 Miroslav Cupak ([email protected]).
*
* 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.
*/
package com.dnastack.beacon.entity;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "allele")
public class Allele {

private String allele;
private Double frequency;

public Allele() {
// needed for JAXB
}

/*
* Required field(s): allele
* frequency is a double between 0 & 1
*/
public Allele(String allele, Double frequency) {
this.allele = allele;
this.frequency = frequency;
}

public String getAllele() {
return allele;
}

public void setAllele(String allele) {
this.allele = allele;
}

public Double getFrequency() {
return frequency;
}

public void setFrequency(Double frequency) {
this.frequency = frequency;
}
}
Loading

0 comments on commit 483cab6

Please sign in to comment.