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

de.tsl2.nano.h5.NanoH5UnitPlugin 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;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.SortedMap;

import de.tsl2.nano.action.IAction;
import de.tsl2.nano.bean.def.BeanDefinition;
import de.tsl2.nano.bean.def.IPageBuilder;
import de.tsl2.nano.core.ManagedException;
import de.tsl2.nano.core.util.ENVTestPreparation;
import de.tsl2.nano.core.util.FileUtil;
import de.tsl2.nano.h5.NanoHTTPD.Method;
import de.tsl2.nano.h5.navigation.IBeanNavigator;
import de.tsl2.nano.h5.plugin.INanoPlugin;
import de.tsl2.nano.persistence.Persistence;
import de.tsl2.nano.serviceaccess.IAuthorization;

/**
 * Tries to prepare some unit-test specific environments on NanoH5
 * 
 * @author Tom, Thomas Schneider
 * @version $Revision$
 */
public class NanoH5UnitPlugin implements INanoPlugin, ENVTestPreparation {

    private static boolean enabled;

    @Override
    public void configuration(SortedMap properties, Map, Object> services) {
    }

    @Override
    public void onAuthentication(IAuthorization auth) {
    }

    @Override
    public void definePersistence(Persistence persistence) {
    }


    @Override
    public void databaseGenerated(Persistence persistence) {
        //copy the jarfile to the workspace classpath
//        FileUtil.copy(persistence.jarFileInEnvironment(), TARGET_DIR + "classes/" + persistence.jarFileInEnvironment());
    }

    @Override
    public void beansGenerated(Persistence persistence) {
        //copy META-INF/persistence.xml to the workspace classpath
        //and set jarfile from origin user.dir
        String persistenceXML = null;
        try {
            persistence.setJarFile(Persistence.FIX_PATH + new File(persistence.jarFileInEnvironment()).getAbsolutePath());
            persistenceXML = persistence.save();
        } catch (IOException e) {
            ManagedException.forward(e);
        }
        FileUtil.writeBytes(persistenceXML.getBytes(), "classes/" + Persistence.FILE_PERSISTENCE_XML, false);
    }

    @Override
    public > T definePresentationType(T pageBuilder) {
        return pageBuilder;
    }

    @Override
    public void defineBeanDefinition(BeanDefinition beanDef) {
    }

    @Override
    public void actionBeforeHandler(IAction action) {
    }

    @Override
    public void actionAfterHandler(IAction action) {
    }

    @Override
    public void workflowHandler(IBeanNavigator workflow) {
    }

    @Override
    public void exceptionHandler(Exception ex) {
    }

    @Override
    public void requestHandler(String uri,
            Method m,
            Map header,
            Map parms,
            Map files) {
    }
    
    @Override
    public boolean isEnabled() {
        return enabled;
    }
    
    public static void setEnabled(boolean e) {
        enabled = e;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy