All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.tsl2.nano.h5.plugin.INanoPlugin Maven / Gradle / Ivy

Go to download

TSL2 Framework Html5 Extensions (WebServer, Html5Presentation, RuleCover, BeanConfigurator, LogicTable-Sheet, Expression-Descriptors for Actions, Rules, URLs, Queries)

There is a newer version: 2.5.2
Show newest version
package de.tsl2.nano.h5.plugin;

import java.nio.ByteBuffer;
import java.util.Map;
import java.util.SortedMap;

import org.java_websocket.WebSocket;

import de.tsl2.nano.action.IAction;
import de.tsl2.nano.bean.def.BeanDefinition;
import de.tsl2.nano.bean.def.IPageBuilder;
import de.tsl2.nano.h5.NanoH5Session;
import de.tsl2.nano.h5.NanoHTTPD.Method;
import de.tsl2.nano.h5.NanoHTTPD.Response;
import de.tsl2.nano.h5.navigation.IBeanNavigator;
import de.tsl2.nano.persistence.Persistence;
import de.tsl2.nano.plugin.Plugin;
import de.tsl2.nano.serviceaccess.IAuthorization;

/**
 * NanoH5 Plugin interface to define an own NanoH5 Application through callbacks invoked on most important entry
 * points. All classpath-implmenetations of this interface will be found by the framework and will be invoked on the
 * instruction points.
 * 

* At least one implementation should have a main function calling * *

 * Main.startApplication(NanoH5.class, null, args);
 * 
* * Each method will be called with parameters, pre-filled and provided by the framework. *

* To enhance the the Html-Output, see {@link IDOMDecorator}. * * @author Tom, Thomas Schneider * @version $Revision$ */ public interface INanoPlugin extends Plugin { /** * change the default properties of the application. see 'environment.xml' for a list of all keys and their defaults */ void configuration(SortedMap properties, Map, Object> services); /** do some inspections on authentication. The auth object is pre-filled */ void onAuthentication(IAuthorization auth); /** * before an authentication, the properties for the jpa persistence.xml will be defined. You can change these * settings before a new session will be started */ void definePersistence(Persistence persistence); /** do some initializings on the database. the connection-info is inside the persistence object */ void databaseGenerated(Persistence persistence); /** do some initializings on the jar-file. the jar-file-name is inside the persistence object */ void beansGenerated(Persistence persistence); /** * The Html page-builder defines the creation of each response. you must return an instance of pageBuilder (null * will result in errors)! */ > T definePresentationType(T pageBuilder); /** * for each bean type (belonging to an entity class) the default handling can be changed. the output can be found at * the presentation directory */ void defineBeanDefinition(BeanDefinition beanDef); /** before running the requested user interaction, you can inspect the action that will be called */ void actionBeforeHandler(IAction action); /** after running the requested user interaction, you can inspect the action that was called */ default void actionAfterHandler(IAction action) {} /** * on creating a new session, the workflow / navigation stack is defined by loading from 'workflow.xml' or if not * found by providing all entity beans in a list. This workflow can be changed by your inspector. */ void workflowHandler(IBeanNavigator workflow); void exceptionHandler(Exception ex); /** on each new http request, you can inspect and change the header, parameters and files */ void requestHandler(String uri, Method m, Map header, Map parms, Map files); /** on each html response you are able to manipulate the dom transformed html response string */ default String manipulateHtmlResponse(String html) { return html; } /** lets you change the response object - perhaps adding header values etc. */ default Response handleResponse(Response response) { return response; } /** do anything on receiving a new message from a websocket client */ default void handleWebSocketMessage(WebSocket conn, String msg) {} /** do anything on receiving a new message from a websocket client */ default void handleWebSocketMessage(WebSocket conn, ByteBuffer message) {} /** the request has entered the session to work on. all request values were transferred to the workflow bean */ default void handleSessionRequest(NanoH5Session nanoH5Session, Map parms) {} }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy