@Override public void injectJavaEEResources(Object managedBeanInstance) { Class<?> currentClass = managedBeanInstance.getClass(); SecurityService securityService = webBeansContext.getSecurityService(); while (currentClass != null && Object.class != currentClass) { Field[] fields = securityService.doPrivilegedGetDeclaredFields(currentClass); for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; Annotation ann = AnnotationUtil.hasOwbInjectableResource(field.getDeclaredAnnotations()); if (ann == null) continue; @SuppressWarnings("unchecked") ResourceReference<Object, ?> resourceRef = new ResourceReference(field.getDeclaringClass(), field.getName(), field.getType(), ann); boolean acess = field.isAccessible(); try { securityService.doPrivilegedSetAccessible(field, true); field.set(managedBeanInstance, getResourceReference(resourceRef)); } catch (Exception e) { throw new WebBeansException("Unable to inject field" + field, e); } finally { securityService.doPrivilegedSetAccessible(field, acess); } } currentClass = currentClass.getSuperclass(); } }
Method overloadedMethod = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod( creatorMethod.getDeclaringClass().getSuperclass(), creatorMethod.getName(),
Constructor<?> c = webBeansContext.getSecurityService().doPrivilegedGetConstructor(clazz, WebBeansContext.class); if (c == null) return webBeansContext.getSecurityService().doPrivilegedObjectCreate(clazz);
private void close() { try { if(this.jmsObject != null) { Method method = this.jmsObject.getClass().getMethod("close"); if(!method.isAccessible()) { jmsComponent.getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(method, true); } method.invoke(this.jmsObject); } } catch (Exception e) { throw new WebBeansException("Unable to close JMS resources"); } }
/** * JavaEE components can not inject {@link javax.enterprise.inject.spi.InjectionPoint}. * @param clazz javaee component class info * @throws WebBeansConfigurationException exception if condition is not applied */ public void checkInjectionPointForInjectInjectionPoint(Class<?> clazz) { Asserts.nullCheckForClass(clazz); Field[] fields = webBeansContext.getSecurityService().doPrivilegedGetDeclaredFields(clazz); for(Field field : fields) { if(field.getAnnotation(Inject.class) != null) { if(field.getType() == InjectionPoint.class) { Annotation[] anns = getQualifierAnnotations(field.getDeclaredAnnotations()); if (AnnotationUtil.hasAnnotation(anns, Default.class)) { throw new WebBeansConfigurationException("Java EE Component class : " + clazz + " can not inject InjectionPoint"); } } } } }
Field field = webBeansContext.getSecurityService().doPrivilegedGetDeclaredField(ownerBeanClass, fieldName); Class<?>[] parameters = (Class<?>[])in.readObject(); Method method = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(ownerBeanClass, methodName, parameters); injectionMember = method;
public <T> Constructor<T> getNoArgConstructor(Class<T> clazz) { return webBeansContext.getSecurityService().doPrivilegedGetDeclaredConstructor(clazz); }
@Override protected AnnotatedConstructor<T> createConstructor() { // create proxy subclass Class<T> classToProxy = annotatedType.getJavaClass(); ClassLoader classLoader = webBeansContext.getApplicationBoundaryService().getBoundaryClassLoader(classToProxy); if (classLoader == null) { classLoader = Thread.currentThread().getContextClassLoader(); } proxySubClass = webBeansContext.getSubclassProxyFactory().createImplementedSubclass(classLoader, annotatedType); Constructor<T> ct = (Constructor<T>) webBeansContext.getSecurityService().doPrivilegedGetDeclaredConstructors(proxySubClass)[0]; Constructor<T> parentCtor; try { parentCtor = classToProxy.getConstructor(ct.getParameterTypes()); } catch (NoSuchMethodException e) { throw new IllegalStateException(e); } return new SubClassAnnotatedConstructorImpl<T>(webBeansContext, parentCtor, ct, annotatedType); }
/** * Creates the instance from the constructor. Each constructor parameter * instance is resolved using the resolution algorithm. */ public T doInjection() { try { if(!con.isAccessible()) { getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(con, true); } instance = con.newInstance(createParameters()); transientCreationalContext.release(); return instance; } catch (Exception e) { throw new WebBeansException(e); } }
public void injectJavaEEResources(Object managedBeanInstance) Field[] fields = webBeansContext.getSecurityService().doPrivilegedGetDeclaredFields(managedBeanInstance.getClass()); for(Field field : fields) webBeansContext.getSecurityService().doPrivilegedSetAccessible(field, true);
if (!field.isAccessible()) webBeansContext.getSecurityService().doPrivilegedSetAccessible(field, true);
doPrivilegedGetDeclaredMethod(clazz, method.getJavaMember().getName(), method.getJavaMember().getParameterTypes()); if(classMethod == null)
Field[] fields = webBeansContext.getSecurityService().doPrivilegedGetDeclaredFields(currentClass); webBeansContext.getSecurityService().doPrivilegedSetAccessible(field, true);
getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(field, true);
getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(method, true);
ownerBean.getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(view, true);