Code example for LinkRef

0
        final InitialContext context = new InitialContext();
 
        final Context javaContext = (Context) context.lookup("java:");
 
        javaContext.bind("java:TransactionManager", new JndiUrlReference("java:comp/TransactionManager"));
        javaContext.bind("java:TransactionManagerLink", new LinkRef("java:comp/TransactionManager"));
 
        assertTrue(context.lookup("java:TransactionManager") instanceof TransactionManager);
        assertTrue(context.lookup("java:TransactionManagerLink") instanceof TransactionManager);
 
        new InitialContext().bind("java:foo", new LinkRef("java:comp/TransactionManager"));
 
        assertTrue(context.lookup("java:foo") instanceof TransactionManager);
 
 
    } 
 
} 
Experience pair programming with AI  Get Codota for Java