Use Spring Boot and Spring Shell to build a Hazelcast @@ -19,9 +19,9 @@ public class Application { * * @param args From command line */ - public static void main(String[] args) throws Exception { + public static void main(String[] args) { System.setProperty("hazelcast.logging.type", "slf4j"); - Bootstrap.main(args); + SpringApplication.run(Application.class, args); } } diff --git a/serialization/hazelcast-airlines/grid-node/src/main/java/com/hazelcast/samples/serialization/hazelcast/airlines/CLI.java b/serialization/hazelcast-airlines/grid-node/src/main/java/com/hazelcast/samples/serialization/hazelcast/airlines/CLI.java index 1a81a9493..f1fe8f6b2 100644 --- a/serialization/hazelcast-airlines/grid-node/src/main/java/com/hazelcast/samples/serialization/hazelcast/airlines/CLI.java +++ b/serialization/hazelcast-airlines/grid-node/src/main/java/com/hazelcast/samples/serialization/hazelcast/airlines/CLI.java @@ -7,9 +7,8 @@ import com.hazelcast.samples.serialization.hazelcast.airlines.util.Constants; import com.hazelcast.samples.serialization.hazelcast.airlines.util.FlightBuilder; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.shell.core.CommandMarker; -import org.springframework.shell.core.annotation.CliCommand; -import org.springframework.shell.core.annotation.CliOption; +import org.springframework.shell.command.annotation.Command; +import org.springframework.shell.command.annotation.Option; import org.springframework.stereotype.Component; import java.util.Arrays; @@ -28,7 +27,7 @@ *
*/ @Component -public class CLI implements CommandMarker { +public class CLI { @Autowired private HazelcastInstance hazelcastInstance; @@ -59,12 +58,12 @@ public class CLI implements CommandMarker { * @param name Who to book the seat for * @return The seat booked */ - @CliCommand(value = "BOOK", - help = "BOOK A SEAT ON A FLIGHT") + @Command(command = "BOOK", + description = "BOOK A SEAT ON A FLIGHT") public String loading( - @CliOption(key = {"CODE"}, mandatory = true, help = "THE FLIGHT TO BOOK ONTO") + @Option(label = "CODE", required = true, description = "THE FLIGHT TO BOOK ONTO") String code, - @CliOption(key = {"NAME"}, mandatory = true, help = "WHO TO BOOK ONTO THE FLIGHT") + @Option(label = "NAME", required = true, description = "WHO TO BOOK ONTO THE FLIGHT") String name ) { IMapList the stored flights, keys are {@link java.lang.Comparable} so sort before printing. *
*/ - @CliCommand(value = "KEYS", - help = "DISPLAY THE STORED FLIGHTS") + @Command(command = "KEYS", + description = "DISPLAY THE STORED FLIGHTS") public String keys() { IMapLoad test data into the cluster. *
*/ - @CliCommand(value = "TESTDATA", - help = "INJECT TEST DATA INTO THE CLUSTER") + @Command(command = "TESTDATA", + description = "INJECT TEST DATA INTO THE CLUSTER") public String testData() { IMap* Use http://localhost:8080/ * to discover what URLs are available. */ diff --git a/spring/spring-data-hazelcast-chemistry-sample/client/src/main/java/com/hazelcast/samples/spring/data/chemistry/ClientController.java b/spring/spring-data-hazelcast-chemistry-sample/client/src/main/java/com/hazelcast/samples/spring/data/chemistry/ClientController.java index d86e657d4..433dea1ca 100644 --- a/spring/spring-data-hazelcast-chemistry-sample/client/src/main/java/com/hazelcast/samples/spring/data/chemistry/ClientController.java +++ b/spring/spring-data-hazelcast-chemistry-sample/client/src/main/java/com/hazelcast/samples/spring/data/chemistry/ClientController.java @@ -2,7 +2,7 @@ import com.hazelcast.samples.spring.data.chemistry.domain.Element; import com.hazelcast.samples.spring.data.chemistry.service.ChemistryService; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -33,18 +33,19 @@ @RestController public class ClientController { - @Autowired - private ChemistryService chemistryService; + private final ChemistryService chemistryService; + + public ClientController(ChemistryService chemistryService) { + this.chemistryService = chemistryService; + } /** * Return the other URLs supported by this controller. - * + *
* HATEOAS or Swagger would be an alternative mechanism here,
* although unrelated to the purpose of the example.
- *
- * @throws MalformedURLException
*/
- @RequestMapping(value = "/", method = RequestMethod.GET)
+ @GetMapping("/")
public List
* extend this with extra commands for this example. - * + *
* Commands *
* Usage *
* Usage *
* Usage *
* Usage *