Java 类javax.ejb.EJBContext 实例源码
项目:myWMS
文件:BusinessObjectHelper.java
/** 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");
}
项目:tomee
文件:ContextLookupStatefulPojoBean.java
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);
}
}
项目:tomee
文件:ContextLookupStatefulBean.java
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);
}
}
项目:tomee
文件:EncStatefulBean.java
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);
}
}
项目:tomee
文件:ContextLookupStatelessBean.java
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);
}
}
项目:tomee
文件:ContextLookupStatelessPojoBean.java
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);
}
}
项目:tomee
文件:EncStatelessBean.java
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);
}
}
项目:tomee
文件:EncSingletonBean.java
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);
}
}
项目:tomee
文件:ContextLookupSingletonPojoBean.java
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);
}
}
项目:tomee
文件:ContextLookupSingletonBean.java
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);
}
}
项目:tomee
文件:ContextLookupMdbBean.java
@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);
}
}
项目:tomee
文件:ContextLookupMdbPojoBean.java
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);
}
}
项目:tomee
文件:EncMdbBean.java
@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);
}
}
项目:tomee
文件:CmpContainer.java
@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);
}
}
项目:tomee
文件:MdbInstanceFactory.java
/**
* 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);
}
项目:jaffa-framework
文件:SecurityContext.java
/** 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;
}
项目:jpasecurity
文件:EjbSecurityContext.java
public EjbSecurityContext() {
try {
InitialContext initialContext = new InitialContext();
context = (EJBContext)initialContext.lookup("java:comp/EJBContext");
} catch (NamingException e) {
throw new IllegalStateException("EJBContext not found", e);
}
}
项目:jpasecurity
文件:AutodetectingSecurityContextTest.java
@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);
}
项目:tomee
文件:MergeWebappJndiContext.java
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;
}
项目:testee.fi-examples
文件:SessionBean.java
public EJBContext getEjbContext() {
return ejbContext;
}
项目:gemfirexd-oss
文件:EjbJpaTxnManager.java
public EjbJpaTxnManager(EJBContext context) {
super();
this.context = context;
}
项目:gemfirexd-oss
文件:EjbJpaTxnManager.java
public EjbJpaTxnManager(EJBContext context) {
super();
this.context = context;
}
项目:iaf
文件:IfsaEjbBeanBase.java
protected EJBContext getEJBContext() {
return this.ejbContext;
}
项目:iaf
文件:GenericMDB.java
protected EJBContext getEJBContext() {
return this.ejbContext;
}
项目:iaf
文件:IbisManagerEjbBean.java
protected EJBContext getEJBContext() {
return this.sessionContext;
}
项目:tomee
文件:EntityInstanceManager.java
public void deploy(final BeanContext beanContext) {
poolMap.put(beanContext.getDeploymentID(), new LinkedListStack(poolsize / 2));
beanContext.set(EJBContext.class, createEntityContext());
}
项目:tomee
文件:EjbTimerServiceImpl.java
/**
* Insure that timer methods can be invoked for the current operation on this Context.
*/
private void checkState() throws IllegalStateException {
final BaseContext context = (BaseContext) deployment.get(EJBContext.class);
context.doCheck(BaseContext.Call.timerMethod);
}
项目:tomee
文件:InjectionTest.java
public EJBContext getInjectedContext() {
return injectedContext;
}
项目:jaffa-framework
文件:SecurityManager.java
/** Bind a security context to a thread and contine executing the thread by running the
* supplied method against the specified object with the supplied paramters.
* In this case the security context is derived from an EJBContext.
* @param ctx Web Server Request Context to use
* @param obj The object contains the method to execute under the thread security context
* @param method The name of the method to execute in the specified object
* @param args An Object array of argument to pass to the method. If there are no parameters for the method null can be passed
* @throws Exception Returns any Exception that the method being invoked may return
* @return Returns any Object that the method being invoked can return
*/
public static Object runWithContext(EJBContext ctx, Object obj, String method, Object[] args)
throws Exception {
return runWithContext(new SecurityContext(ctx), obj, method, args);
}
项目:jaffa-framework
文件:SecurityManager.java
/** Bind a security context to a thread and contine executing the thread by running the
* supplied method against the specified object with the supplied paramters.
* In this case the security context is derived from an EJBContext.
* @return Returns any Object that the method being invoked can return
* @param sig This is an array of classes that represent the signature to the supplied method. This will be used for introspection for
* the supplied method on the given object
* @param ctx Web Server Request Context to use
* @param obj The object contains the method to execute under the thread security context
* @param method The name of the method to execute in the specified object
* @param args An Object array of argument to pass to the method. If there are no parameters for the method null can be passed
* @throws Exception Returns any Exception that the method being invoked may return
*/
public static Object runWithContext(EJBContext ctx, Object obj, String method, Object[] args, Class[] sig)
throws Exception {
return runWithContext(new SecurityContext(ctx), obj, method, args, sig);
}
项目:jaffa-framework
文件:SecurityManager.java
/** Bind a security context to a thread and contine executing the thread by running the
* supplied method against the specified object with the supplied paramters. The signature of
* the method is introspected used the classes associated to the objects in the parameter array
* If these classes are not able to specified the methods signiture, use the variation of this method
* that allows the class[] singature to be supplied.
* In this case the security context is derived from an EJBContext.
* @return Returns any Object that the method being invoked can return
* the supplied method on the given object
* @param ctx Web Server Request Context to use
* @param obj The object contains the method to execute under the thread security context
* @param method The name of the method to execute in the specified object
* @param args An Object array of argument to pass to the method. If there are no parameters for the method null can be passed
* @throws Exception Returns any Exception that the method being invoked may return
*/
public static Object runWithContext(EJBContext ctx, Object obj, Method method, Object[] args)
throws Exception {
return runWithContext(new SecurityContext(ctx), obj, method, args);
}
项目:iaf
文件:AbstractEJBBase.java
abstract protected EJBContext getEJBContext();
项目:tomee
文件:InjectionTest.java
EJBContext getInjectedContext();