Created
April 5, 2018 00:37
-
-
Save stuartwdouglas/8e69b5512962facbb0a6eac1f71135c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static { | |
WeldProvider weldProvider = new WeldProvider(); | |
CDI.setCDIProvider(new CDIProvider() { | |
@Override | |
public CDI<Object> getCDI() { | |
try { | |
BeanManager bm = (BeanManager) new InitialContext().lookup("java:comp/BeanManager"); | |
if (bm != null) { | |
return new AbstractCDI<Object>() { | |
@Override | |
public BeanManager getBeanManager() { | |
return bm; | |
} | |
}; | |
} | |
} catch (NamingException e) { | |
} | |
return weldProvider.getCDI(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment