import io.voodoo.framework.core.Application;
import io.voodoo.framework.web.WebServer;
import io.voodoo.framework.web.router.Router;
import io.voodoo.framework.web.router.Route;
public class WebApplication extends Application {
public static void main(String[] args) {
WebServer webServer = new WebServer();
Router router = webServer.getRouter();
router.addRoute(new Route("/home", HomeHandler.class));
router.addRoute(new Route("/about", AboutHandler.class));
webServer.start();
}
}
public class HomeHandler {
public void handle(Request request, Response response) {
response.send("Welcome to the home page!");
}
}
public class AboutHandler {
public void handle(Request request, Response response) {
response.send("This is the about page.");
}
}
import io.voodoo.framework.db.Database;
import io.voodoo.framework.db.ConnectionPool;
import io.voodoo.framework.db.Query;
public class DatabaseApplication extends Application {
public static void main(String[] args) {
ConnectionPool connectionPool = new ConnectionPool("jdbc:mysql://localhost:3306/mydb", "username", "password");
Database database = connectionPool.getConnection();
Query query = database.createQuery("SELECT * FROM users");
query.execute();
while (query.next()) {
String username = query.getString("username");
int age = query.getInt("age");
System.out.println("Username: " + username + ", Age: " + age);
}
connectionPool.releaseConnection(database);
}
}
import io.voodoo.framework.remote.RemoteService;
import io.voodoo.framework.remote.RemoteServiceHandler;
import io.voodoo.framework.remote.RemoteServiceRegistry;
public class RemoteServiceApplication extends Application {
public static void main(String[] args) {
RemoteServiceRegistry serviceRegistry = new RemoteServiceRegistry();
serviceRegistry.registerService("CalculatorService", new CalculatorServiceImpl());
RemoteServiceHandler serviceHandler = new RemoteServiceHandler(serviceRegistry);
serviceHandler.start();
CalculatorService calculatorService = RemoteService.createClient(CalculatorService.class, "http://localhost:8080/api");
int result = calculatorService.add(5, 3);
System.out.println("Result: " + result);
serviceHandler.stop();
}
}
public interface CalculatorService {
int add(int a, int b);
}
public class CalculatorServiceImpl implements CalculatorService {
public int add(int a, int b) {
return a + b;
}
}