Skip to content

Instantly share code, notes, and snippets.

@rmannibucau
Created September 21, 2012 11:12
Show Gist options
  • Save rmannibucau/3760928 to your computer and use it in GitHub Desktop.
Save rmannibucau/3760928 to your computer and use it in GitHub Desktop.
@Before
public void bind()
{
try {
if (ctxt == null) {
try {
Properties p = new Properties();
p.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
// ctxt = new InitialContext(p);
p.put(OpenEjbContainer.Provider.OPENEJB_ADDITIONNAL_CALLERS_KEY, getClass().getName());
ctxt = EJBContainer.createEJBContainer(p).getContext();
}
catch (Exception ignored) {
ignored.printStackTrace();
}
}
if(ctxt!=null)
ctxt.bind("inject", this);
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment