Splitting monolith app to micro services (#1490)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.app.vv8ui;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
|
||||
import org.springframework.boot.web.servlet.error.ErrorAttributes;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* Error page controller that ensures that ocet stream does not return text in
|
||||
* case of an error.
|
||||
*/
|
||||
@Controller
|
||||
// Exception squid:S3752 - errors need handling for all methods
|
||||
@SuppressWarnings("squid:S3752")
|
||||
public class ErrorController extends BasicErrorController {
|
||||
|
||||
private static final String PATH = "path";
|
||||
|
||||
/**
|
||||
* A new {@link ErrorController}.
|
||||
*
|
||||
* @param errorAttributes
|
||||
* the error attributes
|
||||
* @param serverProperties
|
||||
* configuration properties
|
||||
*/
|
||||
public ErrorController(final ErrorAttributes errorAttributes, final ServerProperties serverProperties) {
|
||||
super(errorAttributes, serverProperties.getError());
|
||||
}
|
||||
|
||||
@RequestMapping(produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public ResponseEntity<Void> errorStream(final HttpServletRequest request, final HttpServletResponse response) {
|
||||
final HttpStatus status = getStatus(request);
|
||||
return new ResponseEntity<>(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequestMapping
|
||||
public ResponseEntity<Map<String, Object>> error(final HttpServletRequest request) {
|
||||
final HttpStatus status = getStatus(request);
|
||||
final Map<String, Object> body = getErrorAttributesWithoutPath(request);
|
||||
return new ResponseEntity<>(body, status);
|
||||
}
|
||||
|
||||
private Map<String, Object> getErrorAttributesWithoutPath(final HttpServletRequest request) {
|
||||
final Map<String, Object> body = getErrorAttributes(request, getErrorAttributeOptions(request, MediaType.ALL));
|
||||
if (body != null && body.containsKey(PATH)) {
|
||||
body.remove(PATH);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.app.vv8ui;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.MultitenancyIndicator;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.login.AbstractHawkbitLoginUI;
|
||||
import org.eclipse.hawkbit.ui.themes.HawkbitTheme;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.vaadin.spring.security.VaadinSecurity;
|
||||
|
||||
import com.vaadin.spring.annotation.SpringUI;
|
||||
|
||||
/**
|
||||
* Example hawkBit login UI implementation.
|
||||
*
|
||||
* A {@link SpringUI} annotated class must be present in the classpath for the
|
||||
* login path. The easiest way to get an hawkBit login UI running is to extend
|
||||
* the {@link AbstractHawkbitLoginUI} and to annotated it with {@link SpringUI}
|
||||
* as in this example to the defined {@link HawkbitTheme#LOGIN_UI_PATH}.
|
||||
*/
|
||||
@SpringUI(path = HawkbitTheme.LOGIN_UI_PATH)
|
||||
// Exception squid:MaximumInheritanceDepth - Most of the inheritance comes from
|
||||
// Vaadin.
|
||||
@SuppressWarnings({ "squid:MaximumInheritanceDepth" })
|
||||
public class MyLoginUI extends AbstractHawkbitLoginUI {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
MyLoginUI(final ApplicationContext context, final VaadinSecurity vaadinSecurity, final VaadinMessageSource i18n,
|
||||
final UiProperties uiProperties, final MultitenancyIndicator multiTenancyIndicator) {
|
||||
super(context, vaadinSecurity, i18n, uiProperties, multiTenancyIndicator);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.app.vv8ui;
|
||||
|
||||
import org.eclipse.hawkbit.ui.AbstractHawkbitUI;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.components.NotificationUnreadButton;
|
||||
import org.eclipse.hawkbit.ui.error.ErrorView;
|
||||
import org.eclipse.hawkbit.ui.menu.DashboardMenu;
|
||||
import org.eclipse.hawkbit.ui.push.EventPushStrategy;
|
||||
import org.eclipse.hawkbit.ui.push.UIEventProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
|
||||
import com.vaadin.annotations.Push;
|
||||
import com.vaadin.server.ErrorHandler;
|
||||
import com.vaadin.shared.communication.PushMode;
|
||||
import com.vaadin.shared.ui.ui.Transport;
|
||||
import com.vaadin.spring.annotation.SpringUI;
|
||||
import com.vaadin.spring.navigator.SpringViewProvider;
|
||||
|
||||
/**
|
||||
* Example hawkBit UI implementation.
|
||||
*
|
||||
* A {@link SpringUI} annotated class must be present in the classpath. The
|
||||
* easiest way to get an hawkBit UI running is to extend the
|
||||
* {@link AbstractHawkbitUI} and to annotated it with {@link SpringUI} as in
|
||||
* this example. WEBSOCKET_XHR transport is used instead of WEBSOCKET in order
|
||||
* to preserve Spring Security Context, that does not work using websocket
|
||||
* communication with Vaadin Shared Security.
|
||||
*
|
||||
*/
|
||||
@SpringUI
|
||||
@Push(value = PushMode.AUTOMATIC, transport = Transport.WEBSOCKET_XHR)
|
||||
// Exception squid:MaximumInheritanceDepth - Most of the inheritance comes from
|
||||
// Vaadin.
|
||||
@SuppressWarnings({ "squid:MaximumInheritanceDepth" })
|
||||
public class MyUI extends AbstractHawkbitUI {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
MyUI(final EventPushStrategy pushStrategy, final UIEventBus eventBus, final UIEventProvider eventProvider,
|
||||
final SpringViewProvider viewProvider, final ApplicationContext context, final DashboardMenu dashboardMenu,
|
||||
final ErrorView errorview, final NotificationUnreadButton notificationUnreadButton,
|
||||
final UiProperties uiProperties, final VaadinMessageSource i18n, final ErrorHandler uiErrorHandler) {
|
||||
super(pushStrategy, eventBus, eventProvider, viewProvider, context, dashboardMenu, errorview,
|
||||
notificationUnreadButton, uiProperties, i18n, uiErrorHandler);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.app.vv8ui;
|
||||
|
||||
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* A {@link SpringBootApplication} annotated class with a main method to start.
|
||||
* The minimal configuration for the stand alone hawkBit server.
|
||||
*
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableHawkbitManagedSecurityConfiguration
|
||||
public class Vaadin8UIStart {
|
||||
|
||||
/**
|
||||
* Main method to start the spring-boot application.
|
||||
*
|
||||
* @param args
|
||||
* the VM arguments.
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(Vaadin8UIStart.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2019 Bosch Software Innovations GmbH and others
|
||||
#
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
# This profile adds basic configurations for a DB2 DB usage.
|
||||
# Keep in mind that you need the DB2 driver in your classpath on compile.
|
||||
# see https://www.eclipse.org/hawkbit/guides/runhawkbit/
|
||||
|
||||
spring.jpa.database=DB2
|
||||
spring.datasource.url=jdbc:db2://localhost:50000/hawkbit
|
||||
spring.datasource.username=db2inst1
|
||||
spring.datasource.password=db2inst1-pwd
|
||||
spring.datasource.driverClassName=com.ibm.db2.jcc.DB2Driver
|
||||
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2018 Bosch Software Innovations GmbH and others
|
||||
#
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
# This profile adds basic configurations for a Microsoft SQL Server DB usage.
|
||||
# Keep in mind that you need the SQL server driver in your classpath on compile.
|
||||
# see https://www.eclipse.org/hawkbit/guides/runhawkbit/
|
||||
|
||||
spring.jpa.database=SQL_SERVER
|
||||
spring.datasource.url=jdbc:sqlserver://localhost:1433;database=hawkbit
|
||||
spring.datasource.username=SA
|
||||
spring.datasource.password=
|
||||
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
#
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
# This profile adds basic configurations for a MySQL DB usage.
|
||||
# Keep in mind that you need the MariaDB driver in your classpath on compile.
|
||||
# see https://www.eclipse.org/hawkbit/guides/runhawkbit/
|
||||
|
||||
spring.jpa.database=MYSQL
|
||||
spring.datasource.url=jdbc:mariadb://localhost:3306/hawkbit
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=
|
||||
spring.datasource.driverClassName=org.mariadb.jdbc.Driver
|
||||
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2020 Enapter Co.,Ltd
|
||||
#
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
# This profile adds basic configurations for a PostgreSQL usage.
|
||||
# Keep in mind that you need the PostgreSQL driver in your classpath on compile.
|
||||
# see https://www.eclipse.org/hawkbit/guides/runhawkbit/
|
||||
|
||||
spring.jpa.database=POSTGRESQL
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/hawkbit
|
||||
spring.datasource.username=postgres
|
||||
spring.datasource.password=admin
|
||||
spring.datasource.driverClassName=org.postgresql.Driver
|
||||
@@ -0,0 +1,77 @@
|
||||
#
|
||||
# Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
#
|
||||
# This program and the accompanying materials are made
|
||||
# available under the terms of the Eclipse Public License 2.0
|
||||
# which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
#
|
||||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
|
||||
spring.application.name=vv8-ui-server
|
||||
server.port=8082
|
||||
|
||||
# User Security
|
||||
spring.security.user.name=admin
|
||||
spring.security.user.password={noop}admin
|
||||
spring.main.allow-bean-definition-overriding=true
|
||||
|
||||
# Http Encoding
|
||||
server.servlet.encoding.charset=UTF-8
|
||||
server.servlet.encoding.enabled=true
|
||||
server.servlet.encoding.force=true
|
||||
|
||||
# DDI authentication configuration
|
||||
hawkbit.server.ddi.security.authentication.anonymous.enabled=false
|
||||
hawkbit.server.ddi.security.authentication.targettoken.enabled=false
|
||||
hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=false
|
||||
|
||||
# Optional events
|
||||
hawkbit.server.repository.publish-target-poll-event=false
|
||||
|
||||
## Configuration for DMF/RabbitMQ integration
|
||||
spring.rabbitmq.username=guest
|
||||
spring.rabbitmq.password=guest
|
||||
spring.rabbitmq.virtual-host=/
|
||||
spring.rabbitmq.host=localhost
|
||||
spring.rabbitmq.port=5672
|
||||
|
||||
# Define own users instead of default "admin" user:
|
||||
#hawkbit.server.im.users[0].username=hawkbit
|
||||
#hawkbit.server.im.users[0].password={noop}isAwesome!
|
||||
#hawkbit.server.im.users[0].firstname=Eclipse
|
||||
#hawkbit.server.im.users[0].lastname=HawkBit
|
||||
#hawkbit.server.im.users[0].permissions=ALL
|
||||
|
||||
# Enable CORS and specify the allowed origins:
|
||||
#hawkbit.server.security.cors.enabled=true
|
||||
#hawkbit.server.security.cors.allowedOrigins=http://localhost
|
||||
|
||||
## Disable swagger
|
||||
hawkbit.server.swagger.mgmt.api.group.enabled=false
|
||||
hawkbit.server.swagger.ddi.api.group.enabled=false
|
||||
|
||||
# Flyway disabled - US only
|
||||
spring.flyway.enabled=false
|
||||
## SQL Database Configuration - END
|
||||
|
||||
## No Schedulers - START
|
||||
hawkbit.autoassign.scheduler.enabled=false
|
||||
hawkbit.rollout.scheduler.enabled=false
|
||||
## No Schedulers - END
|
||||
|
||||
# Disable discovery client of spring-cloud-commons
|
||||
spring.cloud.discovery.enabled=false
|
||||
# Enable communication between services
|
||||
spring.cloud.bus.enabled=true
|
||||
spring.cloud.bus.ack.enabled=false
|
||||
spring.cloud.bus.refresh.enabled=false
|
||||
spring.cloud.bus.env.enabled=false
|
||||
endpoints.spring.cloud.bus.refresh.enabled=false
|
||||
endpoints.spring.cloud.bus.env.enabled=false
|
||||
spring.cloud.stream.bindings.springCloudBusInput.group=vv8-ui-server
|
||||
|
||||
# To use protostuff (for instance fot improved performance) you shall uncomment
|
||||
# the following two lines and add io.protostuff:protostuff-core and io.protostuff:protostuff-runtime to dependencies
|
||||
#spring.cloud.stream.bindings.springCloudBusInput.content-type=application/binary+protostuff
|
||||
#spring.cloud.stream.bindings.springCloudBusOutput.content-type=application/binary+protostuff
|
||||
18
hawkbit-runtime/hawkbit-vv8-ui/src/main/resources/banner.txt
Normal file
18
hawkbit-runtime/hawkbit-vv8-ui/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
______ _ _ _ _ ____ _ _
|
||||
| ____| | (_) | | | | | _ \(_) |
|
||||
| |__ ___| |_ _ __ ___ ___ | |__ __ ___ _| | _| |_) |_| |_
|
||||
| __| / __| | | '_ \/ __|/ _ \ | '_ \ / _` \ \ /\ / / |/ / _ <| | __|
|
||||
| |___| (__| | | |_) \__ \ __/ | | | | (_| |\ V V /| <| |_) | | |_
|
||||
|______\___|_|_| .__/|___/\___| |_| |_|\__,_| \_/\_/ |_|\_\____/|_|\__|
|
||||
__ __ | | _ _ ___ _ _ _____
|
||||
\ \ / / |_| | (_) / _ \ | | | |_ _|
|
||||
\ \ / /_ _ __ _ __| |_ _ __ __ _| (_) | | | | | | |
|
||||
\ \/ / _` |/ _` |/ _` | | '_ \ \ \ / /> _ < | | | | | |
|
||||
\ / (_| | (_| | (_| | | | | | \ V /| (_) | | |__| |_| |_
|
||||
\/ \__,_|\__,_|\__,_|_|_| |_| \_/ \___/ \____/|_____|
|
||||
|
||||
Eclipse hawkBit Vaadin v8 UI ${application.formatted-version}
|
||||
using Spring Boot ${spring-boot.formatted-version}
|
||||
|
||||
Go to https://www.eclipse.org/hawkbit for more information.
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
|
||||
This program and the accompanying materials are made
|
||||
available under the terms of the Eclipse Public License 2.0
|
||||
which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
|
||||
SPDX-License-Identifier: EPL-2.0
|
||||
|
||||
-->
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
|
||||
<logger name="org.eclipse.hawkbit.eventbus.DeadEventListener" level="WARN" />
|
||||
<Logger name="org.springframework.boot.actuate.audit.listener.AuditListener" level="WARN" />
|
||||
|
||||
<Logger name="org.hibernate.validator.internal.util.Version" level="WARN" />
|
||||
|
||||
<!-- Security Log with hints on potential attacks -->
|
||||
<logger name="server-security" level="INFO" />
|
||||
|
||||
<!-- Suppressing "More than one Servlet Mapping defined. WebSocket may not work"
|
||||
error due to the way VaadinServletConfiguration configures the endpoints mapping ("/UI" and "/UI/*").
|
||||
At the end only the first "/UI" is taken for websocket communication. -->
|
||||
<logger name="org.atmosphere.util.IOUtils" level="OFF" />
|
||||
|
||||
<Root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</Root>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user