View Javadoc
1   package com.guinetik.examples;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   import java.util.Scanner;
6   
7   /**
8    * Main example runner that presents a menu of examples to run
9    */
10  public class HelloWorld {
11      // List of available examples
12      private static final List<Example> EXAMPLES = new ArrayList<>();
13      
14      static {
15          // Register all examples here
16          EXAMPLES.add(new JsonTodoExample());
17          EXAMPLES.add(new FakeJsonApiExample());
18          EXAMPLES.add(new FluentApiExample());
19          EXAMPLES.add(new RocketRestFluentExample());
20          EXAMPLES.add(new RocketRestCircuitBreakerExample());
21          EXAMPLES.add(new NasaApodExample());
22          EXAMPLES.add(new PokeApiExample());
23          EXAMPLES.add(new WeatherExample());
24          EXAMPLES.add(new SapIdpExample());
25          EXAMPLES.add(new AdpApiExample());
26          System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "DEBUG");
27          // Add more examples as they are created
28      }
29      
30      public static void main(String[] args) {
31          System.out.println("=== RocketRest Examples ===");
32          System.out.println("Choose an example to run:");
33          
34          // Display all available examples
35          for (int i = 0; i < EXAMPLES.size(); i++) {
36              System.out.printf("%d. %s%n", i + 1, EXAMPLES.get(i).getName());
37          }
38          
39          System.out.print("\nEnter number (1-" + EXAMPLES.size() + "): ");
40          
41          // Read user input
42          Scanner scanner = new Scanner(System.in);
43          int choice = 0;
44          
45          try {
46              choice = Integer.parseInt(scanner.nextLine());
47              
48              if (choice < 1 || choice > EXAMPLES.size()) {
49                  System.out.println("Invalid choice. Exiting.");
50                  return;
51              }
52              
53              // Run the selected example
54              Example selectedExample = EXAMPLES.get(choice - 1);
55              System.out.println("\nRunning: " + selectedExample.getName());
56              System.out.println("===================================\n");
57              
58              selectedExample.run();
59              
60          } catch (NumberFormatException e) {
61              System.out.println("Invalid input. Please enter a number.");
62          } finally {
63              scanner.close();
64          }
65      }
66  }