| /******************************************************************************* |
| * Copyright (c) 2012, 2014 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Florian Pirchner - initial API and implementation |
| * |
| *******************************************************************************/ |
| package org.eclipse.osbp.vaaclipse.addons.app.webapp; |
| |
| import java.util.Dictionary; |
| import java.util.HashMap; |
| import java.util.Map; |
| import java.util.Set; |
| |
| import org.eclipse.osbp.vaaclipse.addons.app.common.Constants; |
| import org.eclipse.osbp.vaaclipse.addons.app.common.OSGiUIProvider; |
| import org.osgi.framework.Bundle; |
| import org.osgi.framework.BundleContext; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| /** |
| * The Class VaadinWebApplication. |
| */ |
| public class VaadinWebApplication { |
| |
| /** The logger. */ |
| private static Logger logger = LoggerFactory |
| .getLogger(VaadinWebApplication.class); |
| |
| /** The bundle context. */ |
| private BundleContext bundleContext; |
| |
| /** The id. */ |
| private final String id; |
| |
| /** The alias. */ |
| private String alias = ""; |
| |
| /** The port. */ |
| private int port; |
| |
| /** The theme id. */ |
| private String themeId; |
| |
| /** The widgetset name. */ |
| private String widgetsetName; |
| |
| /** The header icon uri. */ |
| private String headerIconURI; |
| |
| /** The production mode. */ |
| private boolean productionMode; |
| |
| /** The context path. */ |
| private String contextPath; |
| |
| /** The init properties. */ |
| private Map<String, String> initProperties = new HashMap<>(); |
| |
| /** The tracker. */ |
| private HttpServiceTracker tracker; |
| |
| /** |
| * Instantiates a new vaadin web application. |
| * |
| * @param bundle |
| * the bundle |
| */ |
| public VaadinWebApplication(Bundle bundle) { |
| this.bundleContext = bundle.getBundleContext(); |
| id = bundle.getSymbolicName(); |
| } |
| |
| /** |
| * Activate. |
| */ |
| public void activate() { |
| tracker = new HttpServiceTracker(bundleContext, this); |
| logger.debug("The alias that will be tracked is:\"" + alias); |
| tracker.open(); |
| } |
| |
| /** |
| * Deactivate. |
| */ |
| public void deactivate() { |
| logger.debug("Tracker for alias" + tracker.getAlias() + " was removed."); |
| if (tracker != null) { |
| tracker.close(); |
| tracker = null; |
| } |
| } |
| |
| /** |
| * Gets the id. |
| * |
| * @return the id |
| */ |
| public String getId() { |
| return id; |
| } |
| |
| /** |
| * Gets the alias. |
| * |
| * @return the alias |
| */ |
| public String getAlias() { |
| return alias; |
| } |
| |
| /** |
| * Sets the alias. |
| * |
| * @param alias |
| * the alias to set |
| */ |
| public void setAlias(String alias) { |
| this.alias = alias; |
| } |
| |
| /** |
| * Gets the port. |
| * |
| * @return the port |
| */ |
| public int getPort() { |
| return port; |
| } |
| |
| /** |
| * Sets the port. |
| * |
| * @param port |
| * the port to set |
| */ |
| public void setPort(int port) { |
| this.port = port; |
| } |
| |
| /** |
| * Gets the widgetset name. |
| * |
| * @return the widgetsetName |
| */ |
| public String getWidgetsetName() { |
| return widgetsetName; |
| } |
| |
| /** |
| * Sets the widgetset name. |
| * |
| * @param widgetsetName |
| * the widgetsetName to set |
| */ |
| public void setWidgetsetName(String widgetsetName) { |
| this.widgetsetName = widgetsetName; |
| } |
| |
| /** |
| * Checks if is production mode. |
| * |
| * @return the productionMode |
| */ |
| public boolean isProductionMode() { |
| return productionMode; |
| } |
| |
| /** |
| * Sets the production mode. |
| * |
| * @param productionMode |
| * the productionMode to set |
| */ |
| public void setProductionMode(boolean productionMode) { |
| this.productionMode = productionMode; |
| } |
| |
| /** |
| * Gets the inits the property. |
| * |
| * @param propName |
| * the prop name |
| * @return the inits the property |
| */ |
| public String getInitProperty(String propName) { |
| return this.initProperties.get(propName); |
| } |
| |
| /** |
| * Sets the init property. |
| * |
| * @param propName |
| * the prop name |
| * @param propValue |
| * the prop value |
| */ |
| public void setInitProperty(String propName, String propValue) { |
| this.initProperties.put(propName, propValue); |
| } |
| |
| /** |
| * Gets the inits the properties. |
| * |
| * @return the inits the properties |
| */ |
| public Set<String> getInitProperties() { |
| return this.initProperties.keySet(); |
| } |
| |
| /** |
| * Gets the header icon uri. |
| * |
| * @return the headerIcon |
| */ |
| public String getHeaderIconURI() { |
| return headerIconURI; |
| } |
| |
| /** |
| * Sets the header icon uri. |
| * |
| * @param headerIconURI |
| * the headerIconURI to set |
| */ |
| public void setHeaderIconURI(String headerIconURI) { |
| this.headerIconURI = headerIconURI; |
| } |
| |
| /** |
| * Gets the theme id. |
| * |
| * @return the themeId |
| */ |
| public String getThemeId() { |
| return themeId; |
| } |
| |
| /** |
| * Sets the theme id. |
| * |
| * @param themeId |
| * the themeId to set |
| */ |
| public void setThemeId(String themeId) { |
| this.themeId = themeId; |
| } |
| |
| /** |
| * Gets the context path. |
| * |
| * @return the context path |
| */ |
| public String getContextPath() { |
| return contextPath; |
| } |
| |
| /** |
| * Sets the context path. |
| * |
| * @param contextPath |
| * the new context path |
| */ |
| public void setContextPath(String contextPath) { |
| this.contextPath = contextPath; |
| } |
| |
| /** |
| * Updated. |
| * |
| * @param properties |
| * the properties |
| */ |
| @SuppressWarnings("rawtypes") |
| public void updated(Dictionary properties) { |
| if (properties.get(Constants.PROP_WIDGETSET) != null) { |
| widgetsetName = (String) properties.get(Constants.PROP_WIDGETSET); |
| } |
| } |
| |
| /** |
| * Gets the ui provider. |
| * |
| * @return the ui provider |
| */ |
| public OSGiUIProvider getUiProvider() { |
| return new OSGiUIProvider(); |
| } |
| |
| } |