public interface MathService { int add(int a, int b); } public class MathServiceImpl implements MathService { public int add(int a, int b) { return a + b; } } <openejb> <Container id="default" ctype="STATELESS"> <Bean id="MathServiceBean" class="com.example.MathServiceImpl" /> </Container> </openejb> import javax.naming.Context; import javax.naming.InitialContext; public class Main { public static void main(String[] args) { try { Context context = new InitialContext(); MathService mathService = (MathService) context.lookup("MathServiceBean"); int result = mathService.add(2, 3); System.out.println("Result: " + result); } catch (Exception e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文