类javax.ejb.EJBContext源码实例Demo

下面列出了怎么用javax.ejb.EJBContext的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: datawave   文件: QueryLogicFactoryBeanTest.java
@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));
}
 
源代码2 项目: datawave   文件: MapReduceStatePersisterTest.java
@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);
}
 
源代码3 项目: 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);
    }

}
 
源代码4 项目: 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);
    }

}
 
源代码5 项目: 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);
    }

}
 
源代码6 项目: 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);
    }

}
 
源代码7 项目: 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);
    }

}
 
源代码8 项目: 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);
    }

}
 
源代码9 项目: 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);
    }

}
 
源代码10 项目: 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);
    }

}
 
源代码11 项目: 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);
    }

}
 
源代码12 项目: 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);
    }

}
 
源代码13 项目: 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);
    }

}
 
源代码14 项目: 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);
    }

}
 
源代码15 项目: 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);
    }
}
 
源代码16 项目: 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);
}
 
源代码17 项目: 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;
}
 
源代码18 项目: datawave   文件: LookupUUIDUtil.java
/**
 * 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();
}
 
源代码19 项目: datawave   文件: QueryExecutorBeanTest.java
@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();
}
 
源代码20 项目: gemfirexd-oss   文件: EjbJpaTxnManager.java
public EjbJpaTxnManager(EJBContext context) {
	super();
	this.context = context;
}
 
源代码21 项目: gemfirexd-oss   文件: EjbJpaTxnManager.java
public EjbJpaTxnManager(EJBContext context) {
	super();
	this.context = context;
}
 
源代码22 项目: iaf   文件: IfsaEjbBeanBase.java
protected EJBContext getEJBContext() {
    return this.ejbContext;
}
 
源代码23 项目: iaf   文件: GenericMDB.java
@Override
protected EJBContext getEJBContext() {
       return this.ejbContext;
   }
 
源代码24 项目: iaf   文件: IbisManagerEjbBean.java
protected EJBContext getEJBContext() {
    return this.sessionContext;
}
 
源代码25 项目: tomee   文件: EntityInstanceManager.java
public void deploy(final BeanContext beanContext) {
    poolMap.put(beanContext.getDeploymentID(), new LinkedListStack(poolsize / 2));
    beanContext.set(EJBContext.class, createEntityContext());
}
 
源代码26 项目: 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);
}
 
源代码27 项目: tomee   文件: InjectionTest.java
public EJBContext getInjectedContext() {
    return injectedContext;
}
 
源代码28 项目: datawave   文件: LookupUUIDUtil.java
/**
 * Returns the EJB context that was active when this class was created.
 * 
 * @return
 */
public EJBContext getContext() {
    return ctx;
}
 
源代码29 项目: iaf   文件: AbstractEJBBase.java
abstract protected EJBContext getEJBContext(); 
源代码30 项目: tomee   文件: InjectionTest.java
EJBContext getInjectedContext();