diff --git a/examples/hawkbit-device-simulator/cf/manifest.yml b/examples/hawkbit-device-simulator/cf/manifest.yml new file mode 100644 index 000000000..8a65690fe --- /dev/null +++ b/examples/hawkbit-device-simulator/cf/manifest.yml @@ -0,0 +1,21 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# 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 +# +--- +applications: +- name: hawkbit-simulator + memory: 512M + instances: 1 + buildpack: https://github.com/cloudfoundry/java-buildpack + path: hawkbit-example-app-0.2.0-SNAPSHOT.jar + services: + - dmf-rabbit + env: + SPRING_PROFILES_ACTIVE: cloudsandbox,amqp + CF_STAGING_TIMEOUT: 15 + CF_STARTUP_TIMEOUT: 15 diff --git a/examples/hawkbit-device-simulator/pom.xml b/examples/hawkbit-device-simulator/pom.xml index a2575e9db..5ee781e34 100644 --- a/examples/hawkbit-device-simulator/pom.xml +++ b/examples/hawkbit-device-simulator/pom.xml @@ -42,6 +42,16 @@ + + + cf + true + ${project.build.directory} + + manifest.yml + + + diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java index b8b5011aa..afc3a2569 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java @@ -14,6 +14,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice.Protocol; import org.eclipse.hawkbit.simulator.amqp.SpSenderService; import org.eclipse.hawkbit.simulator.event.InitUpdate; import org.eclipse.hawkbit.simulator.event.ProgressUpdate; @@ -34,6 +35,9 @@ public class DeviceSimulatorUpdater { @Autowired private SpSenderService spSenderService; + @Autowired + private SimulatedDeviceFactory deviceFactory; + @Autowired private EventBus eventbus; @@ -58,7 +62,13 @@ public class DeviceSimulatorUpdater { */ public void startUpdate(final String tenant, final String id, final long actionId, final String swVersion, final UpdaterCallback callback) { - final AbstractSimulatedDevice device = repository.get(tenant, id); + AbstractSimulatedDevice device = repository.get(tenant, id); + + // plug and play - non existing device will be auto created + if (device == null) { + device = repository.add(deviceFactory.createSimulatedDevice(id, tenant, Protocol.DMF_AMQP, -1, null, null)); + } + device.setProgress(0.0); device.setSwversion(swVersion); eventbus.post(new InitUpdate(device)); diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java index 492bb3857..bf5d723a8 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java @@ -59,7 +59,8 @@ public class AmqpConfiguration { } /** - * Create the receiver queue from sp. Receive messages from sp. + * Creates the receiver queue from update server for receiving message from + * update server. * * @return the queue */ @@ -70,7 +71,7 @@ public class AmqpConfiguration { } /** - * Create the recevier exchange. Sp send messages to this exchange. + * Creates the receiver exchange for sending messages to update server. * * @return the exchange */ diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java index 1c314d56f..9f7e4d9ca 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java @@ -26,9 +26,7 @@ import org.springframework.messaging.handler.annotation.Header; import org.springframework.stereotype.Component; /** - * Handle all incoming Messages from SP. - * - * + * Handle all incoming Messages from hawkBit update server. * */ @Component @@ -44,17 +42,6 @@ public class SpReceiverService extends ReceiverService { /** * Constructor. - * - * @param rabbitTemplate - * the rabbit template - * @param amqpProperties - * the amqp properties - * @param lwm2mSenderService - * the lwm2mSenderService - * @param spSenderService - * the spSenderService - * @param deviceUpdater - * the updater service to simulate update process */ @Autowired public SpReceiverService(final RabbitTemplate rabbitTemplate, final AmqpProperties amqpProperties, @@ -62,12 +49,11 @@ public class SpReceiverService extends ReceiverService { super(rabbitTemplate, amqpProperties); this.spSenderService = spSenderService; this.deviceUpdater = deviceUpdater; - } /** * Handle the incoming Message from Queue with the property - * (com.bosch.sp.lwm2m.connector.amqp.receiverConnectorQueueFromSp). + * (hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp). * * @param message * the incoming message diff --git a/examples/hawkbit-device-simulator/src/main/resources/application.properties b/examples/hawkbit-device-simulator/src/main/resources/application.properties index 56d0190a7..cdc72ba28 100644 --- a/examples/hawkbit-device-simulator/src/main/resources/application.properties +++ b/examples/hawkbit-device-simulator/src/main/resources/application.properties @@ -7,11 +7,7 @@ # http://www.eclipse.org/legal/epl-v10.html # - -######################################################################################### -# PUBLIC configuration, i.e. can be changed by users at runtime (defaults provided here) -######################################################################################### -## Configuration for RabbitMQ communication +## Configuration for DMF communication hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=simulator_receiver hawkbit.device.simulator.amqp.deadLetterQueue=simulator_deadletter hawkbit.device.simulator.amqp.deadLetterExchange=simulator.deadletter diff --git a/examples/hawkbit-example-app/README.md b/examples/hawkbit-example-app/README.md index eaf30f306..4efbdb8ed 100644 --- a/examples/hawkbit-example-app/README.md +++ b/examples/hawkbit-example-app/README.md @@ -1,7 +1,15 @@ # hawkBit Example Application -The hawkBit example application is a standalone spring-boot application with an embedded servlet container to start the hawkBit. +The hawkBit example application is a standalone spring-boot application with an embedded servlet container to host the hawkBit Update Server. -## Run +We have have described several options for you to get access to the example. + +## Try out the example application in our hawkBit sandbox on Bluemix +- try out Management UI https://hawkbit.eu-gb.mybluemix.net/UI +- try out Management API https://hawkbit.eu-gb.mybluemix.net/rest/v1/targets (don't forget basic auth header) +- try out DDI API https://hawkbit.eu-gb.mybluemix.net/DEFAULT/controller/v1/MYTESTDEVICE + +## On your own workstation +### Run ``` java -jar examples/hawkbit-example-app/target/hawkbit-example-app-*-SNAPSHOT.jar ``` @@ -10,6 +18,13 @@ Or: run org eclipse.hawkbit.app.Start ``` -## Usage -The UI can be accessed via _http://localhost:8080/UI_. -The REST API can be accessed via _http://localhost:8080/rest/v1_. +### Usage +The Management UI can be accessed via http://localhost:8080/UI +The Management API can be accessed via http://localhost:8080/rest/v1 + +## Deploy example app to Cloud Foundry + +- Go to ```cf``` subfolder. +- Select one of the two manifests + - **manifest-simple.yml** for a standalone hawkBit installation with embedded H2. + - **manifest.yml** for a standalone hawkBit installation with embedded H2 and RabbitMQ service binding for DMF integration (note: this manifest is used for the sandbox above). diff --git a/examples/hawkbit-example-app/cf/manifest-simple.yml b/examples/hawkbit-example-app/cf/manifest-simple.yml new file mode 100644 index 000000000..4d4a798ef --- /dev/null +++ b/examples/hawkbit-example-app/cf/manifest-simple.yml @@ -0,0 +1,19 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# 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 +# +--- +applications: +- name: hawkbit-simple + memory: 1024M + instances: 1 + buildpack: https://github.com/cloudfoundry/java-buildpack + path: ${project.build.finalName}.jar + env: + SPRING_PROFILES_ACTIVE: cloudsandbox + CF_STAGING_TIMEOUT: 15 + CF_STARTUP_TIMEOUT: 15 diff --git a/examples/hawkbit-example-app/cf/manifest.yml b/examples/hawkbit-example-app/cf/manifest.yml new file mode 100644 index 000000000..278f43681 --- /dev/null +++ b/examples/hawkbit-example-app/cf/manifest.yml @@ -0,0 +1,21 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# 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 +# +--- +applications: +- name: hawkbit + memory: 1024M + instances: 1 + buildpack: https://github.com/cloudfoundry/java-buildpack + path: ${project.build.finalName}.jar + services: + - dmf-rabbit + env: + SPRING_PROFILES_ACTIVE: cloudsandbox,amqp + CF_STAGING_TIMEOUT: 15 + CF_STARTUP_TIMEOUT: 15 diff --git a/examples/hawkbit-example-app/pom.xml b/examples/hawkbit-example-app/pom.xml index 33624ffd7..e9f57ad54 100644 --- a/examples/hawkbit-example-app/pom.xml +++ b/examples/hawkbit-example-app/pom.xml @@ -39,6 +39,17 @@ + + + cf + true + ${project.build.directory} + + manifest.yml + manifest-simple.yml + + + diff --git a/examples/hawkbit-example-app/src/main/resources/application-cloudsandbox.properties b/examples/hawkbit-example-app/src/main/resources/application-cloudsandbox.properties new file mode 100644 index 000000000..d54e1d6a2 --- /dev/null +++ b/examples/hawkbit-example-app/src/main/resources/application-cloudsandbox.properties @@ -0,0 +1,11 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# 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 +# + +spring.profiles.active= +vaadin.servlet.productionMode=true