public static Object newProxy(final BeanContext context, final InvocationHandler invocationHandler) { if (QueryProxy.class.isInstance(invocationHandler)) { EntityManager em = null; for (final Injection injection : context.getInjections()) { if (QueryProxy.class.equals(injection.getTarget())) { try { em = (EntityManager) context.getJndiEnc().lookup(injection.getJndiName()); } catch (final NamingException e) { throw new OpenEJBRuntimeException("a dynamic bean should reference at least one correct PersistenceContext", e); } } } if (em == null) { throw new OpenEJBRuntimeException("can't find the entity manager to use for the dynamic bean " + context.getEjbName()); } QueryProxy.class.cast(invocationHandler).setEntityManager(em); } return newProxy(context.getBeanClass(), invocationHandler); }
public static Object newProxy(final BeanContext context, final InvocationHandler invocationHandler) { if (QueryProxy.class.isInstance(invocationHandler)) { EntityManager em = null; for (final Injection injection : context.getInjections()) { if (QueryProxy.class.equals(injection.getTarget())) { try { em = (EntityManager) context.getJndiEnc().lookup(injection.getJndiName()); } catch (final NamingException e) { throw new OpenEJBRuntimeException("a dynamic bean should reference at least one correct PersistenceContext", e); } } } if (em == null) { throw new OpenEJBRuntimeException("can't find the entity manager to use for the dynamic bean " + context.getEjbName()); } QueryProxy.class.cast(invocationHandler).setEntityManager(em); } return newProxy(context.getBeanClass(), invocationHandler); }
@SuppressWarnings("unchecked") private void fillInjectionProperties(final ObjectRecipe objectRecipe, final Object managedBeanInstance) { final boolean usePrefix = true; final Class<?> clazz = managedBeanInstance.getClass(); for (final BeanContext beanContext : compContexts) { for (final Injection injection : beanContext.getInjections()) { if (injection.getTarget() == null) { continue; } if (!injection.getTarget().isAssignableFrom(clazz)) { continue; } try { final Object value = lookup(beanContext, injection); final String prefix; if (usePrefix) { prefix = injection.getTarget().getName() + "/"; } else { prefix = ""; } objectRecipe.setProperty(prefix + injection.getName(), value); } catch (final NamingException e) { logger.warning("Injection data not found in JNDI context: jndiName='" + injection.getJndiName() + "', target=" + injection.getTarget().getName() + "/" + injection.getName()); } } } }
Thread.currentThread().setContextClassLoader(beanContext.getClassLoader()); try { final PortData port = WsBuilder.toPortData(portInfo, beanContext.getInjections(), moduleBaseUrl, beanContext.getClassLoader());
deployApplication(appInfo, next.getValue().path, restEjbs, comp.getClassLoader(), comp.getInjections(), containerSystem.getAppContext(appInfo.appId).getWebBeansContext(), comp.getJndiContext(), providers, pojoConfigurations, application, wildcard); final BeanContext ctx = ejb.getValue().context; if (BeanType.MANAGED.equals(ctx.getComponentType())) { deployPojo("", ejb.getValue().path, ctx.getBeanClass(), null, ctx.getClassLoader(), ctx.getInjections(), ctx.getJndiContext(), containerSystem.getAppContext(appInfo.appId).getWebBeansContext(),
Thread.currentThread().setContextClassLoader(beanContext.getClassLoader()); try { final PortData port = WsBuilder.toPortData(portInfo, beanContext.getInjections(), moduleBaseUrl, beanContext.getClassLoader());
deployEJB(webApp.contextRoot, appPrefix, restEjbs.get(clazz).context, additionalProviders, appInfo.services); } else { deployPojo(webApp.contextRoot, appPrefix, ctx.getBeanClass(), null, ctx.getClassLoader(), ctx.getInjections(), context, owbCtx, additionalProviders, new ServiceConfiguration(ctx.getProperties(), appInfo.services));
public static <T> T inject(final T object) { assert object != null; final Class<?> clazz = object.getClass(); final BeanContext context = resolve(clazz); if (context != null) { // found the test class directly final InjectionProcessor processor = new InjectionProcessor(object, context.getInjections(), context.getJndiContext()); cdiInjections(context, object); try { return (T) processor.createInstance(); } catch (final OpenEJBException e) { throw new InjectionException(clazz.getName(), e); } } else if (!isAnnotatedLocalClient(clazz)) { // nothing to do throw new NoInjectionMetaDataException(clazz.getName()); } // the test class was not found in beans (OpenEJB ran from parent) but was annotated @LocalClient try { final InjectionProcessor<?> processor = ClientInjections.clientInjector(object); cdiInjections(null, object); return (T) processor.createInstance(); } catch (final OpenEJBException e) { throw new NoInjectionMetaDataException("Injection failed", e); } }
@SuppressWarnings("unchecked") public static <T> T inject(final T object) { assert object != null; final Class<?> clazz = object.getClass(); final BeanContext context = resolve(clazz); if (context != null) { // found the test class directly final InjectionProcessor processor = new InjectionProcessor(object, context.getInjections(), context.getJndiContext()); cdiInjections(context, object); try { return (T) processor.createInstance(); } catch (final OpenEJBException e) { throw new InjectionException(clazz.getName(), e); } } else if (!isAnnotatedLocalClient(clazz)) { // nothing to do throw new NoInjectionMetaDataException(clazz.getName()); } // the test class was not found in beans (OpenEJB ran from parent) but was annotated @LocalClient try { final InjectionProcessor<?> processor = ClientInjections.clientInjector(object); cdiInjections(null, object); return (T) processor.createInstance(); } catch (final OpenEJBException e) { throw new NoInjectionMetaDataException("Injection failed", e); } }
for (final Injection injection : beanContext.getInjections()) { if (injection.getTarget() == null) { continue;
final ThreadContext oldContext = ThreadContext.enter(callContext); try { final InjectionProcessor processor = new InjectionProcessor(testInstance, context.getInjections(), context.getJndiContext()); processor.createInstance(); } catch (final OpenEJBException e) {
injectionProcessor = new InjectionProcessor(rootInstance, getInjections(), InjectionProcessor.unwrap(ctx)); beanInstance = injectionProcessor.createInstance(); inject(beanInstance, creationalContext); for (final Injection injection : getInjections()) { if (beanClass.equals(injection.getTarget())) { final Injection updated = new Injection(injection.getJndiName(), injection.getName(), proxyClass); final InjectionProcessor interceptorInjector = new InjectionProcessor(iInstance, this.getInjections(), InjectionProcessor.unwrap(ctx)); try { final Object interceptorInstance = interceptorInjector.createInstance();
injectionProcessor = new InjectionProcessor(rootInstance, getInjections(), InjectionProcessor.unwrap(ctx)); beanInstance = injectionProcessor.createInstance(); inject(beanInstance, creationalContext); for (final Injection injection : getInjections()) { if (beanClass.equals(injection.getTarget())) { final Injection updated = new Injection(injection.getJndiName(), injection.getName(), proxyClass); final InjectionProcessor interceptorInjector = new InjectionProcessor(iInstance, this.getInjections(), InjectionProcessor.unwrap(ctx)); try { final Object interceptorInstance = interceptorInjector.createInstance();
deployment.setRunAsUser(bean.runAsUser); deployment.getInjections().addAll(injections);
final ThreadContext oldContext = ThreadContext.enter(callContext); try { final InjectionProcessor processor = new InjectionProcessor(inputTestInstance, context.getInjections(), context.getJndiContext()); processor.createInstance();
deployment.setRunAsUser(bean.runAsUser); deployment.getInjections().addAll(injections);
updateInjections(injections, classLoader, false); for (final BeanContext bean : appContext.getBeanContexts()) { // TODO: how if the same class in multiple webapps? updateInjections(bean.getInjections(), classLoader, true);
final ThreadContext oldContext = ThreadContext.enter(callContext); try { final InjectionProcessor processor = new InjectionProcessor(inputTestInstance, context.getInjections(), context.getJndiContext()); processor.createInstance();