Compare commits
8 Commits
1.0.1-BETA
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| a9bcdb42bf | |||
|
|
7fa378c236 | ||
|
|
8ffc5fb5ec | ||
| 1a7a4617be | |||
| 14e2af25d6 | |||
| 0a821fc8e5 | |||
|
|
2d63489b86 | ||
| 93df6ac904 |
@@ -23,5 +23,3 @@ Download all license here: https://open-autonomous-connection.org/assets/license
|
||||
# In progress
|
||||
|
||||
# TODO
|
||||
|
||||
everything
|
||||
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>org.openautonomousconnection</groupId>
|
||||
<artifactId>WebServer</artifactId>
|
||||
<version>1.0.1-BETA.0.4</version>
|
||||
<version>1.0.1-BETA.0.5</version>
|
||||
<organization>
|
||||
<name>Open Autonomous Connection</name>
|
||||
<url>https://open-autonomous-connection.org/</url>
|
||||
|
||||
@@ -1,13 +1,54 @@
|
||||
package org.openautonomousconnection.webserver.api;
|
||||
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket;
|
||||
import org.openautonomousconnection.webserver.Main;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.html.HTMLBodyElement;
|
||||
import org.w3c.dom.html.HTMLHeadElement;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
/**
|
||||
* Server-side Java page (v1.0.1-BETA).
|
||||
*
|
||||
* <p>Every .java page must implement this interface.</p>
|
||||
* <p>Every .java page must extend this class.</p>
|
||||
*/
|
||||
public interface WebPage {
|
||||
public abstract class WebPage {
|
||||
|
||||
private static final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
|
||||
private static final DocumentBuilder documentBuilder;
|
||||
|
||||
static {
|
||||
DocumentBuilder temp = null;
|
||||
try {
|
||||
temp = factory.newDocumentBuilder();
|
||||
} catch (ParserConfigurationException e) {
|
||||
Main.getValues().logger.exception("Failed to create document builder", e);
|
||||
temp = null;
|
||||
}
|
||||
|
||||
documentBuilder = temp;
|
||||
}
|
||||
|
||||
protected final Document document;
|
||||
protected final HTMLHeadElement head;
|
||||
protected final HTMLBodyElement body;
|
||||
|
||||
/**
|
||||
* Default constructor that creates a new Document instance
|
||||
*/
|
||||
public WebPage() {
|
||||
this.document = documentBuilder.newDocument();
|
||||
|
||||
this.head = (HTMLHeadElement) this.document.createElement("head");
|
||||
this.body = (HTMLBodyElement) this.document.createElement("body");
|
||||
|
||||
this.document.appendChild(this.head);
|
||||
this.document.appendChild(this.body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a web request.
|
||||
@@ -16,5 +57,5 @@ public interface WebPage {
|
||||
* @return resource response packet
|
||||
* @throws Exception on unexpected failures
|
||||
*/
|
||||
WebResourceResponsePacket handle(WebPageContext ctx) throws Exception;
|
||||
public abstract WebResourceResponsePacket handle(WebPageContext ctx) throws Exception;
|
||||
}
|
||||
Reference in New Issue
Block a user