
org.kantega.respiro.ui.UiPlugin Maven / Gradle / Ivy
/*
* Copyright 2015 Kantega AS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kantega.respiro.ui;
import org.kantega.respiro.api.ApplicationBuilder;
import org.kantega.respiro.ui.resources.UserModulesResource;
import org.kantega.respiro.ui.resources.UserProfileResource;
import org.kantega.reststop.api.Config;
import org.kantega.reststop.api.Export;
import org.kantega.reststop.api.Plugin;
import org.kantega.reststop.api.ServletBuilder;
import javax.servlet.Filter;
import javax.ws.rs.core.Application;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
/**
*
*/
@Plugin
public class UiPlugin {
@Export final Collection filters = new ArrayList<>();
@Export final Application uiApp;
public UiPlugin(@Config(defaultValue = "/respiro") String respiroPath,
Collection uiModules,
ServletBuilder servletBuilder,
ApplicationBuilder applicationBuilder) throws IOException {
uiApp = applicationBuilder.application()
.singleton(new UserModulesResource(uiModules))
.singleton(new UserProfileResource())
.build();
String respiroDir = respiroPath + "/";
filters.add(servletBuilder.redirectServlet(respiroPath, respiroDir));
filters.add(servletBuilder.resourceServlet(respiroDir +"respiro.js", getClass().getResource("/ui/respiro.js")));
filters.add(servletBuilder.resourceServlet(respiroDir, getClass().getResource("/ui/index.html")));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy