本文整理汇总了Java中javax.ejb.EJBContext类的典型用法代码示例。如果您正苦于以下问题:Java EJBContext类的具体用法?Java EJBContext怎么用?Java EJBContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EJBContext类属于javax.ejb包,在下文中一共展示了EJBContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BusinessObjectHelper
import javax.ejb.EJBContext; //导入依赖的package包/类
/** Creates a new instance of BusinessObjectHelper */
public BusinessObjectHelper(
SessionContext ctx,
UserService userService,
EJBContext context) {
this.ctx = ctx;
this.userService = userService;
this.context = context;
// 05.02..2013, krane, Client application crashes server, when selecting a large collection.
// So for entities in this List, the collections are not initialized to show in rich-client
// TODO: make this customizable or make a client application, which not automatically requests everything
collectionVetoList.add("nirwana");
collectionVetoList.add("shipped");
collectionVetoList.add("shipping");
collectionVetoList.add("versand");
collectionVetoList.add("papierkorb");
collectionVetoList.add("trash");
collectionVetoList.add("goods-in");
collectionVetoList.add("wareneingang");
collectionVetoList.add("goods-out");
collectionVetoList.add("warenausgang");
}
示例2: lookupSessionContext
import javax.ejb.EJBContext; //导入依赖的package包/类
public void lookupSessionContext() throws TestFailureException {
try {
try {
final InitialContext ctx = new InitialContext();
Assert.assertNotNull("The InitialContext is null", ctx);
// lookup in enc
final SessionContext sctx = (SessionContext) ctx.lookup("java:comp/env/sessioncontext");
Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx);
// lookup using global name
final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx);
// verify context was set via legacy set method
Assert.assertNotNull("The SessionContext is null from setter method", ejbContext);
} catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
} catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
示例3: lookupSessionContext
import javax.ejb.EJBContext; //导入依赖的package包/类
public void lookupSessionContext() throws TestFailureException {
try {
try {
final InitialContext ctx = new InitialContext();
Assert.assertNotNull("The InitialContext is null", ctx);
// lookup in enc
final SessionContext sctx = (SessionContext) ctx.lookup("java:comp/env/sessioncontext");
Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx);
// lookup using global name
final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx);
} catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
} catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
示例4: lookupMessageDrivenContext
import javax.ejb.EJBContext; //导入依赖的package包/类
@Override
public void lookupMessageDrivenContext() throws TestFailureException {
try {
try {
final InitialContext ctx = new InitialContext();
Assert.assertNotNull("The InitialContext is null", ctx);
// lookup in enc
final MessageDrivenContext sctx = (MessageDrivenContext) ctx.lookup("java:comp/env/mdbcontext");
Assert.assertNotNull("The MessageDrivenContext got from java:comp/env/mdbcontext is null", sctx);
// lookup using global name
final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
Assert.assertNotNull("The MessageDrivenContext got from java:comp/EJBContext is null ", ejbCtx);
// verify context was set via legacy set method
Assert.assertNotNull("The MessageDrivenContext is null from setter method", mdbContext);
} catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
} catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
示例5: lookupMessageDrivenContext
import javax.ejb.EJBContext; //导入依赖的package包/类
public void lookupMessageDrivenContext() throws TestFailureException {
try {
try {
final InitialContext ctx = new InitialContext();
Assert.assertNotNull("The InitialContext is null", ctx);
// lookup in enc
final MessageDrivenContext sctx = (MessageDrivenContext) ctx.lookup("java:comp/env/mdbcontext");
Assert.assertNotNull("The MessageDrivenContext got from java:comp/env/mdbcontext is null", sctx);
// lookup using global name
final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
Assert.assertNotNull("The MessageDrivenContext got from java:comp/EJBContext is null ", ejbCtx);
} catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
} catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
示例6: lookupMessageDrivenContext
import javax.ejb.EJBContext; //导入依赖的package包/类
@Override
public void lookupMessageDrivenContext() throws TestFailureException {
try {
try {
final InitialContext ctx = new InitialContext();
Assert.assertNotNull("The InitialContext is null", ctx);
// lookup in enc
final MessageDrivenContext messageDrivenContext = (MessageDrivenContext) ctx.lookup("java:comp/env/mdbcontext");
Assert.assertNotNull("The SessionContext got from java:comp/env/mdbcontext is null", messageDrivenContext);
// lookup using global name
final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx);
// verify context was set via legacy set method
Assert.assertNotNull("The MdbContext is null from setter method", mdbContext);
} catch (final Exception e) {
Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
} catch (final AssertionFailedError afe) {
throw new TestFailureException(afe);
}
}
示例7: deploy
import javax.ejb.EJBContext; //导入依赖的package包/类
@Override
public void deploy(final BeanContext beanContext) throws OpenEJBException {
synchronized (this) {
final Object deploymentId = beanContext.getDeploymentID();
cmpEngine.deploy(beanContext);
beanContext.setContainerData(cmpEngine);
beanContext.set(EJBContext.class, new EntityContext(securityService));
// try to set deploymentInfo static field on bean implementation class
try {
final Field field = beanContext.getCmpImplClass().getField("deploymentInfo");
field.set(null, beanContext);
} catch (final Exception e) {
// ignore
}
// add to indexes
deploymentsById.put(deploymentId, beanContext);
beansByClass.put(beanContext.getCmpImplClass(), beanContext);
beanContext.setContainer(this);
}
}
示例8: MdbInstanceFactory
import javax.ejb.EJBContext; //导入依赖的package包/类
/**
* Creates a MdbInstanceFactory for a single specific deployment.
*
* @param beanContext the deployment for which instances will be created
* @param securityService the transaction manager for this container system
* @param instanceLimit the maximal number of instances or <= 0 if unlimited
*/
public MdbInstanceFactory(final BeanContext beanContext, final SecurityService securityService, final int instanceLimit) throws OpenEJBException {
this.beanContext = beanContext;
this.instanceLimit = instanceLimit;
mdbContext = new MdbContext(securityService);
try {
final Context context = beanContext.getJndiEnc();
context.bind("comp/EJBContext", mdbContext);
context.bind("comp/TimerService", new TimerServiceWrapper());
} catch (final NamingException e) {
throw new OpenEJBException("Failed to bind EJBContext/TimerService", e);
}
beanContext.set(EJBContext.class, this.mdbContext);
}
示例9: SecurityContext
import javax.ejb.EJBContext; //导入依赖的package包/类
/** Create a SecurityContext based on a EJB Context
* @param ctx The EJB Context to use
*/
SecurityContext(EJBContext ctx) {
if(ctx == null) {
log.error("Trying to create a Security Context with a null value");
throw new IllegalArgumentException("Context can't be null");
}
ejb = ctx;
}
示例10: EjbSecurityContext
import javax.ejb.EJBContext; //导入依赖的package包/类
public EjbSecurityContext() {
try {
InitialContext initialContext = new InitialContext();
context = (EJBContext)initialContext.lookup("java:comp/EJBContext");
} catch (NamingException e) {
throw new IllegalStateException("EJBContext not found", e);
}
}
示例11: autodetectEjbSecurityContext
import javax.ejb.EJBContext; //导入依赖的package包/类
@Test
public void autodetectEjbSecurityContext() throws Exception {
ClassLoader mockClassLoader = mock(ClassLoader.class);
when(mockClassLoader.loadClass("org.jpasecurity.spring.authentication.SpringSecurityContext"))
.thenThrow(new ClassNotFoundException());
when(mockClassLoader.loadClass("org.jpasecurity.security.authentication.CdiSecurityContext"))
.thenThrow(new ClassNotFoundException());
when(mockClassLoader.loadClass("org.jpasecurity.jsf.authentication.JsfSecurityContext"))
.thenThrow(new ClassNotFoundException());
when(mockClassLoader.loadClass("org.jpasecurity.security.authentication.EjbSecurityContext"))
.thenReturn((Class)EjbSecurityContext.class);
when(mockClassLoader.getResources("jndi.properties")).thenReturn(Collections.<URL>emptyEnumeration());
when(mockClassLoader.loadClass(javaURLContextFactory.class.getName()))
.thenReturn((Class)javaURLContextFactory.class);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, javaURLContextFactory.class.getName());
System.setProperty(Context.URL_PKG_PREFIXES, NamingContext.class.getPackage().getName());
InitialContext initialContext = new InitialContext();
initialContext.createSubcontext("java:comp");
EJBContext ejbContext = mock(EJBContext.class);
initialContext.bind("java:comp/EJBContext", ejbContext);
AutodetectingSecurityContext securityContext = new AutodetectingSecurityContext();
Thread.currentThread().setContextClassLoader(mockClassLoader);
SecurityContext authenticationProvider = securityContext.autodetectSecurityContext();
assertTrue(authenticationProvider instanceof EjbSecurityContext);
}
示例12: isPrivateReference
import javax.ejb.EJBContext; //导入依赖的package包/类
private <R extends JndiReference> boolean isPrivateReference(final R a) {
if (!isResourceRef(a)) {
return false;
}
final Class[] types = {EJBContext.class, EntityContext.class, SessionContext.class, MessageDrivenContext.class, UserTransaction.class};
for (final Class type : types) {
if (type.getName().equals(a.getType())) {
return true;
}
}
return false;
}
示例13: getEjbContext
import javax.ejb.EJBContext; //导入依赖的package包/类
public EJBContext getEjbContext() {
return ejbContext;
}
示例14: EjbJpaTxnManager
import javax.ejb.EJBContext; //导入依赖的package包/类
public EjbJpaTxnManager(EJBContext context) {
super();
this.context = context;
}
示例15: getEJBContext
import javax.ejb.EJBContext; //导入依赖的package包/类
protected EJBContext getEJBContext() {
return this.ejbContext;
}