Commit d892cbab authored by Sefa Eyeoglu's avatar Sefa Eyeoglu

Code cleanup, pom.xml changes, Added examples and maven dependency example

parent 3cf3583b
# Created by .ignore support plugin (hsz.mobi)
### Java template
# Compiled class file
*.class
# Log file
# Log files
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Windows template
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
......@@ -42,7 +23,7 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
......@@ -55,16 +36,16 @@ buildNumber.properties
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.idea
*.iml
## File-based project format:
# File-based project format:
*.iws
## Plugin-specific files:
# Plugin-specific files:
# IntelliJ
/out/
......@@ -79,4 +60,4 @@ atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
\ No newline at end of file
fabric.properties
# Implify
A Java HTTP server.
## Download
You can find Implify in the Maven Central Repository:
```
<dependency>
<groupId>net.scrumplex</groupId>
<assemblyId>implify</assemblyId>
<version>0.0.1</version>
</dependency>
```
## Usage
You can find examples [here](https://github.com/Scrumplex/Implify/tree/master/examples) and for further documentation refer to the [wiki](https://github.com/Scrumplex/Implify/wiki).
## License
This project is licensed under the Apache License 2.0. You can find more information in the *NOTICE* file
\ No newline at end of file
package net.scrumplex.implify;
import net.scrumplex.implify.core.ImplifyServer;
import net.scrumplex.implify.core.exchange.handler.FileSystemHTTPHandler;
import net.scrumplex.implify.exceptions.ImplifyException;
import java.io.File;
import java.util.logging.Level;
public class FileSystemHandler {
public static void main(String[] args) {
ImplifyServer implifyServer = new ImplifyServer(8080, "default");
implifyServer.setLogLevel(Level.ALL);
implifyServer.setHttpHandler(new FileSystemHTTPHandler(new File("").getAbsoluteFile(), "index.html"));
try {
//Will not pause thread
implifyServer.start();
} catch (ImplifyException e) {
e.printStackTrace();
}
}
}
package net.scrumplex.implify;
import net.scrumplex.implify.core.ImplifyServer;
import net.scrumplex.implify.exceptions.ImplifyException;
import java.io.File;
import java.util.logging.Level;
public class StartingWithoutConfiguration {
public static void main(String[] args) {
ImplifyServer implifyServer = new ImplifyServer(8080, "default");
implifyServer.setLogLevel(Level.ALL);
try {
//Will not pause thread
implifyServer.start();
} catch (ImplifyException e) {
e.printStackTrace();
}
}
}
......@@ -7,6 +7,7 @@
<groupId>net.scrumplex</groupId>
<artifactId>implify</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>Implify Core</name>
<description>Implify HTTP Server.</description>
......@@ -47,6 +48,17 @@
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
......@@ -74,16 +86,29 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<show>public</show>
</configuration>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......@@ -99,6 +124,17 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -7,7 +7,7 @@ import java.util.concurrent.ThreadFactory;
public class ImplifyThreadFactory implements ThreadFactory {
private ImplifyServer serverInstance;
private final ImplifyServer serverInstance;
public ImplifyThreadFactory(ImplifyServer serverInstance) {
this.serverInstance = serverInstance;
......
......@@ -73,7 +73,7 @@ public class ImplifyServer {
@Override
public void publish(LogRecord record) {
StringBuilder sb = new StringBuilder();
sb.append("[" + record.getLevel().getName() + "] ");
sb.append("[").append(record.getLevel().getName()).append("] ");
sb.append(record.getMessage()).append('\n');
if (record.getLevel() == Level.WARNING || record.getLevel() == Level.SEVERE) {
System.err.println(sb.toString());
......
......@@ -46,7 +46,7 @@ public class HTTPRequest {
/**
* Getter method for method.
*
* @return method as {@link java.lang.String}
* @return method as {@link Method}
*/
public Method getMethod() {
return method;
......@@ -171,7 +171,7 @@ public class HTTPRequest {
GET("GET"),
POST("POST");
private String method;
private final String method;
Method(String method) {
this.method = method;
......
......@@ -12,7 +12,7 @@ import java.io.IOException;
public class FileSystemHTTPHandler implements HTTPHandler {
private final File parentDirectory;
private String[] indexFiles;
private final String[] indexFiles;
public FileSystemHTTPHandler(File parentDirectory, String... indexFiles) {
this.parentDirectory = parentDirectory;
......
......@@ -17,7 +17,7 @@ public class DefaultSocketHandler implements SocketHandler {
private final Pattern httpPattern;
public DefaultSocketHandler() {
this.httpPattern = Pattern.compile("(GET|POST)\\s(.*?)(?:\\?(.*))?\\sHTTP\\/(\\d\\.\\d)");
this.httpPattern = Pattern.compile("(GET|POST)\\s(.*?)(?:\\?(.*))?\\sHTTP/(\\d\\.\\d)");
}
@Override
......
package net.scrumplex.implify.exceptions;
import org.jetbrains.annotations.NotNull;
public interface ExceptionHandler extends Thread.UncaughtExceptionHandler {
void caughtException(Throwable e, String context);
......
Markdown is supported
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