I need to load an ejb container from a task to perform some work. This is the code I have
class TalkTask extends DefaultTask {
@TaskAction
def greet(){
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
properties.put("openejb.validation.output.level", "VERBOSE");
properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
Context ctx;
try
{
ctx = new InitialContext(properties);
Talk talk = (Talk) ctx.lookup("TalkImplLocal");
talk.hello();
}catch (NamingException e) {
e.printStackTrace();
}
}
}
public interface Talk{
public void hello();
}
@Stateless
public class TalkImpl implements Talk {
public void hello(){
System.out.println("This is hello from the implmentation");
}
}
task sayHello(type: TalkTask)
The problem is Talk and TalkImpl must be in the classpath for the container to load them.
How can I add these classes and the current project dynamically to the task classpath ??