javax.ejb.EJBContext Java Examples
The following examples show how to use
javax.ejb.EJBContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContextLookupMdbPojoBean.java From tomee with Apache License 2.0 | 6 votes |
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); } }
Example #2
Source File: ContextLookupMdbBean.java From tomee with Apache License 2.0 | 6 votes |
@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); } }
Example #3
Source File: ContextLookupSingletonBean.java From tomee with Apache License 2.0 | 6 votes |
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); } }
Example #4
Source File: ContextLookupSingletonPojoBean.java From tomee with Apache License 2.0 | 6 votes |
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); } }
Example #5
Source File: EncSingletonBean.java From tomee with Apache License 2.0 | 6 votes |
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); } }
Example #6
Source File: EncStatelessBean.java From tomee with Apache License 2.0 | 6 votes |
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); } }
Example #7
Source File: ContextLookupStatelessPojoBean.java From tomee with Apache License 2.0 | 6 votes |
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); } }
Example #8
Source File: ContextLookupStatelessBean.java From tomee with Apache License 2.0 | 6 votes |
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); } }
Example #9
Source File: EncStatefulBean.java From tomee with Apache License 2.0 | 6 votes |
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); } }
Example #10
Source File: ContextLookupStatefulBean.java From tomee with Apache License 2.0 | 6 votes |
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); } }
Example #11
Source File: ContextLookupStatefulPojoBean.java From tomee with Apache License 2.0 | 6 votes |
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); } }
Example #12
Source File: EncMdbBean.java From tomee with Apache License 2.0 | 6 votes |
@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); } }
Example #13
Source File: CmpContainer.java From tomee with Apache License 2.0 | 6 votes |
@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); } }
Example #14
Source File: MapReduceStatePersisterTest.java From datawave with Apache License 2.0 | 6 votes |
@Before public void setup() throws Exception { System.setProperty(NpeUtils.NPE_OU_PROPERTY, "iamnotaperson"); System.setProperty("dw.metadatahelper.all.auths", "A,B,C,D"); connection = instance.getConnector("root", new PasswordToken("")); if (connection.tableOperations().exists(TABLE_NAME)) connection.tableOperations().delete(TABLE_NAME); if (connection.tableOperations().exists(INDEX_TABLE_NAME)) connection.tableOperations().delete(INDEX_TABLE_NAME); DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of(userDN, "CN=ca, OU=acme"), UserType.USER, Arrays.asList(auths), null, null, 0L); principal = new DatawavePrincipal(Collections.singletonList(user)); connectionFactory = createMock(AccumuloConnectionFactory.class); ctx = createStrictMock(EJBContext.class); bean = new MapReduceStatePersisterBean(); field(MapReduceStatePersisterBean.class, "connectionFactory").set(bean, connectionFactory); field(MapReduceStatePersisterBean.class, "ctx").set(bean, ctx); Logger.getLogger(MapReduceStatePersisterBean.class).setLevel(Level.OFF); }
Example #15
Source File: MdbInstanceFactory.java From tomee with Apache License 2.0 | 6 votes |
/** * 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); }
Example #16
Source File: QueryLogicFactoryBeanTest.java From datawave with Apache License 2.0 | 6 votes |
@Before public void setup() throws IllegalArgumentException, IllegalAccessException { System.setProperty(NpeUtils.NPE_OU_PROPERTY, "iamnotaperson"); System.setProperty("dw.metadatahelper.all.auths", "A,B,C,D"); Logger.getLogger(ClassPathXmlApplicationContext.class).setLevel(Level.OFF); Logger.getLogger(XmlBeanDefinitionReader.class).setLevel(Level.OFF); Logger.getLogger(DefaultListableBeanFactory.class).setLevel(Level.OFF); ClassPathXmlApplicationContext queryFactory = new ClassPathXmlApplicationContext(); queryFactory.setConfigLocation("TestQueryLogicFactory.xml"); queryFactory.refresh(); factoryConfig = queryFactory.getBean(QueryLogicFactoryConfiguration.class.getSimpleName(), QueryLogicFactoryConfiguration.class); Whitebox.setInternalState(bean, QueryLogicFactoryConfiguration.class, factoryConfig); Whitebox.setInternalState(bean, ClassPathXmlApplicationContext.class, queryFactory); ctx = createMock(EJBContext.class); logic = createMockBuilder(BaseQueryLogic.class).addMockedMethods("setLogicName", "getMaxPageSize", "getPageByteTrigger").createMock(); DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of("CN=Poe Edgar Allan eapoe, OU=acme", "<CN=ca, OU=acme>"), UserType.USER, null, null, null, 0L); principal = new DatawavePrincipal(Collections.singletonList(user)); }
Example #17
Source File: MergeWebappJndiContext.java From tomee with Apache License 2.0 | 5 votes |
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; }
Example #18
Source File: InjectionTest.java From tomee with Apache License 2.0 | 4 votes |
public EJBContext getInjectedContext() { return injectedContext; }
Example #19
Source File: EntityInstanceManager.java From tomee with Apache License 2.0 | 4 votes |
public void deploy(final BeanContext beanContext) { poolMap.put(beanContext.getDeploymentID(), new LinkedListStack(poolsize / 2)); beanContext.set(EJBContext.class, createEntityContext()); }
Example #20
Source File: EjbTimerServiceImpl.java From tomee with Apache License 2.0 | 4 votes |
/** * 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); }
Example #21
Source File: LookupUUIDUtil.java From datawave with Apache License 2.0 | 4 votes |
/** * Constructor * * @param configuration * Configuration bean for lookupUUID web service endpoints * @param queryExecutor * Service that executes queriesoptionalParamsToMap * @param context * The EJB's content */ public LookupUUIDUtil(final LookupUUIDConfiguration configuration, final QueryExecutor queryExecutor, final EJBContext context, final ResponseObjectFactory responseObjectFactory) { // Validate and assign the lookup UUID configuration if (null == configuration) { throw new IllegalArgumentException("Non-null configuration required to lookup UUIDs"); } this.lookupUUIDConfiguration = configuration; // Validate and assign the query executor if (null == queryExecutor) { throw new IllegalArgumentException("Non-null query executor required to lookup UUIDs"); } this.queryExecutor = queryExecutor; // Assign the EJB context this.ctx = context; // Assign the field event factory needed for the response objects this.responseObjectFactory = responseObjectFactory; // Populate the UUIDType map final List<UUIDType> types = this.lookupUUIDConfiguration.getUuidTypes(); this.uuidTypes.clear(); if (null != types) { for (final UUIDType type : types) { if (null != type) { this.uuidTypes.put(type.getFieldName().toUpperCase(), type); } } } // Assign the begin date try { this.beginAsDate = DateHelper.parseWithGMT(this.lookupUUIDConfiguration.getBeginDate()); } catch (DateTimeParseException e) { this.log.error(e.getMessage(), e); } // Assign the maximum number of UUIDs allowed for batch lookup. A zero or negative // value is interpreted as unlimited, which is automatically adjusted to -1. this.maxAllowedBatchLookupUUIDs = this.lookupUUIDConfiguration.getBatchLookupUpperLimit(); if (this.maxAllowedBatchLookupUUIDs <= 0) { this.maxAllowedBatchLookupUUIDs = -1; } this.defaultOptionalParams = this.lookupUUIDConfiguration.optionalParamsToMap(); }
Example #22
Source File: IbisManagerEjbBean.java From iaf with Apache License 2.0 | 4 votes |
protected EJBContext getEJBContext() { return this.sessionContext; }
Example #23
Source File: GenericMDB.java From iaf with Apache License 2.0 | 4 votes |
@Override protected EJBContext getEJBContext() { return this.ejbContext; }
Example #24
Source File: IfsaEjbBeanBase.java From iaf with Apache License 2.0 | 4 votes |
protected EJBContext getEJBContext() { return this.ejbContext; }
Example #25
Source File: EjbJpaTxnManager.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public EjbJpaTxnManager(EJBContext context) { super(); this.context = context; }
Example #26
Source File: EjbJpaTxnManager.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public EjbJpaTxnManager(EJBContext context) { super(); this.context = context; }
Example #27
Source File: QueryExecutorBeanTest.java From datawave with Apache License 2.0 | 4 votes |
@Before public void setup() throws Exception { System.setProperty(NpeUtils.NPE_OU_PROPERTY, "iamnotaperson"); System.setProperty("dw.metadatahelper.all.auths", "A,B,C,D"); QueryTraceCache traceCache = new QueryTraceCache(); Whitebox.invokeMethod(traceCache, "init"); cache = new QueryCache(); cache.init(); closedCache = new ClosedQueryCache(); bean = new QueryExecutorBean(); connectionFactory = createStrictMock(AccumuloConnectionFactory.class); auditor = new AuditBean(); auditService = createStrictMock(AuditService.class); metrics = createStrictMock(QueryMetricsBean.class); queryLogicFactory = createStrictMock(QueryLogicFactoryImpl.class); persister = createStrictMock(Persister.class); predictor = createStrictMock(QueryPredictor.class); ctx = createStrictMock(EJBContext.class); qlCache = new CreatedQueryLogicCacheBean(); queryExpirationConf = new QueryExpirationConfiguration(); queryExpirationConf.setPageSizeShortCircuitCheckTime(45); queryExpirationConf.setPageShortCircuitTimeout(58); queryExpirationConf.setCallTime(60); connectionRequestBean = createStrictMock(AccumuloConnectionRequestBean.class); setInternalState(auditor, AuditService.class, auditService); setInternalState(auditor, AuditParameterBuilder.class, new DefaultAuditParameterBuilder()); setInternalState(connectionRequestBean, EJBContext.class, ctx); setInternalState(bean, QueryCache.class, cache); setInternalState(bean, ClosedQueryCache.class, closedCache); setInternalState(bean, AccumuloConnectionFactory.class, connectionFactory); setInternalState(bean, AuditBean.class, auditor); setInternalState(bean, QueryMetricsBean.class, metrics); setInternalState(bean, QueryLogicFactory.class, queryLogicFactory); setInternalState(bean, QueryExpirationConfiguration.class, queryExpirationConf); setInternalState(bean, Persister.class, persister); setInternalState(bean, QueryPredictor.class, predictor); setInternalState(bean, EJBContext.class, ctx); setInternalState(bean, CreatedQueryLogicCacheBean.class, qlCache); setInternalState(bean, QueryTraceCache.class, traceCache); setInternalState(bean, Multimap.class, HashMultimap.create()); setInternalState(bean, LookupUUIDConfiguration.class, new LookupUUIDConfiguration()); setInternalState(bean, SecurityMarking.class, new ColumnVisibilitySecurityMarking()); setInternalState(bean, QueryParameters.class, new QueryParametersImpl()); setInternalState(bean, QueryMetricFactory.class, new QueryMetricFactoryImpl()); setInternalState(bean, AccumuloConnectionRequestBean.class, connectionRequestBean); // RESTEasy mock stuff dispatcher = MockDispatcherFactory.createDispatcher(); dispatcher.getRegistry().addSingletonResource(bean, "/DataWave/Query"); response = new MockHttpResponse(); }
Example #28
Source File: LookupUUIDUtil.java From datawave with Apache License 2.0 | 2 votes |
/** * Returns the EJB context that was active when this class was created. * * @return */ public EJBContext getContext() { return ctx; }
Example #29
Source File: AbstractEJBBase.java From iaf with Apache License 2.0 | votes |
abstract protected EJBContext getEJBContext();
Example #30
Source File: InjectionTest.java From tomee with Apache License 2.0 | votes |
EJBContext getInjectedContext();