Return-Path: Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: (qmail 37963 invoked from network); 8 Jun 2010 09:21:49 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Jun 2010 09:21:49 -0000 Received: (qmail 95510 invoked by uid 500); 8 Jun 2010 09:21:49 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 95474 invoked by uid 500); 8 Jun 2010 09:21:48 -0000 Mailing-List: contact commits-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwebbeans.apache.org Delivered-To: mailing list commits@openwebbeans.apache.org Received: (qmail 95465 invoked by uid 99); 8 Jun 2010 09:21:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jun 2010 09:21:48 +0000 X-ASF-Spam-Status: No, hits=-1649.4 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jun 2010 09:21:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E8489238899C; Tue, 8 Jun 2010 09:21:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r952583 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/ container/ context/ context/creational/ decorator/ intercept/ intercept/webbeans/ proxy/ util/ xml/ Date: Tue, 08 Jun 2010 09:21:24 -0000 To: commits@openwebbeans.apache.org From: struberg@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100608092124.E8489238899C@eris.apache.org> Author: struberg Date: Tue Jun 8 09:21:23 2010 New Revision: 952583 URL: http://svn.apache.org/viewvc?rev=952583&view=rev Log: OWB-275 cleanup code Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ExternalScope.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.java Tue Jun 8 09:21:23 2010 @@ -97,28 +97,43 @@ public class OwbParametrizedTypeImpl imp public boolean equals(Object obj) { if (this == obj) + { return true; + } if (obj == null) + { return false; + } if (getClass() != obj.getClass()) + { return false; + } OwbParametrizedTypeImpl other = (OwbParametrizedTypeImpl) obj; if (!Arrays.equals(getActualTypeArguments(), other.getActualTypeArguments())) + { return false; + } if (owner == null) { if (other.owner != null) return false; } else if (!owner.equals(other.owner)) + { return false; + } if (rawType == null) { if (other.rawType != null) + { return false; + } } else if (!rawType.equals(other.rawType)) + { return false; + } + return true; } Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java Tue Jun 8 09:21:23 2010 @@ -104,7 +104,8 @@ public final class WebBeansFinder } catch (ClassNotFoundException e) { - throw new WebBeansException("Class not found exception in creating instance with class : " + singletonName, e); } + throw new WebBeansException("Class not found exception in creating instance with class : " + singletonName, e); + } } } Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ExternalScope.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ExternalScope.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ExternalScope.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ExternalScope.java Tue Jun 8 09:21:23 2010 @@ -20,16 +20,16 @@ package org.apache.webbeans.container; import java.lang.annotation.Annotation; -import javax.enterprise.inject.spi.BeforeBeanDiscovery; import org.apache.webbeans.config.DefaultAnnotation; /** * A wrapper for an external scope which can be added by - * {@link BeforeBeanDiscovery#addScope(Class, boolean, boolean)}. + * {@link javax.enterprise.inject.spi.BeforeBeanDiscovery#addScope(Class, boolean, boolean)}. */ -public class ExternalScope { +public class ExternalScope +{ private Class scope; private boolean normal; @@ -61,7 +61,7 @@ public class ExternalScope { /** * @return an instance of the annotation class we got set - * in {@link BeforeBeanDiscovery#addScope(Class, boolean, boolean)} + * in {@link javax.enterprise.inject.spi.BeforeBeanDiscovery#addScope(Class, boolean, boolean)} */ public Annotation getScopeAnnotation() { Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java Tue Jun 8 09:21:23 2010 @@ -21,7 +21,6 @@ package org.apache.webbeans.container; import java.lang.annotation.Annotation; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; @@ -38,7 +37,6 @@ import javax.enterprise.inject.spi.Injec import org.apache.webbeans.annotation.AnyLiteral; import org.apache.webbeans.annotation.DefaultLiteral; import org.apache.webbeans.component.AbstractOwbBean; -import org.apache.webbeans.config.WebBeansFinder; import org.apache.webbeans.exception.WebBeansConfigurationException; import org.apache.webbeans.exception.inject.NullableDependencyException; import org.apache.webbeans.logger.WebBeansLogger; @@ -57,7 +55,7 @@ import org.apache.webbeans.util.WebBeans *

* * @version $Rev$ $Date$ - * @see WebBeansFinder + * @see org.apache.webbeans.config.WebBeansFinder */ public class InjectionResolver { @@ -101,7 +99,7 @@ public class InjectionResolver * Returns bean manager injection resolver. * * @return bean manager injection resolver - * @see WebBeansFinder + * @see org.apache.webbeans.config.WebBeansFinder */ public static InjectionResolver getInstance() { @@ -113,7 +111,7 @@ public class InjectionResolver /** * Check the type of the injection point. *

- * Injection point type can not be {@link TypeVariable}. + * Injection point type can not be {@link java.lang.reflect.TypeVariable}. *

* * @param injectionPoint injection point @@ -136,7 +134,7 @@ public class InjectionResolver * injection point definition. * * @param injectionPoint injection point - * @throws If bean is not avialable in the current deployment for given injection + * @throws WebBeansConfigurationException If bean is not avialable in the current deployment for given injection */ public void checkInjectionPoints(InjectionPoint injectionPoint) { @@ -389,9 +387,7 @@ public class InjectionResolver /** * Resolution by type. * - * @param bean type info * @param injectionPointType injection point api type - * @param injectionPointTypeArguments actual type arguments if parameterized type * @param qualifiers qualifiers of the injection point * @return set of resolved beans */ @@ -494,7 +490,6 @@ public class InjectionResolver /** * Returns specialized beans if exists, otherwise return input result * - * @param bean class type * @param result result beans * @return specialized beans if exists, otherwise return input result */ @@ -565,7 +560,6 @@ public class InjectionResolver /** * Returns filtered bean set according to the qualifiers. * - * @param bean class * @param remainingSet bean set for filtering by qualifier * @param annotations qualifiers on injection point * @return filtered bean set according to the qualifiers Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java Tue Jun 8 09:21:23 2010 @@ -72,8 +72,8 @@ public final class ContextFactory public static void destroyRequestContext(Object request) { - ContextsService contextService = ServiceLoader.getService(ContextsService.class); - contextService.endContext(RequestScoped.class, request); + ContextsService contextService = ServiceLoader.getService(ContextsService.class); + contextService.endContext(RequestScoped.class, request); } public static void initSessionContext(Object session) @@ -91,7 +91,7 @@ public final class ContextFactory public static void destroySessionContext(Object session) { - ContextsService contextService = ServiceLoader.getService(ContextsService.class); + ContextsService contextService = ServiceLoader.getService(ContextsService.class); contextService.endContext(SessionScoped.class, session); } @@ -121,7 +121,7 @@ public final class ContextFactory */ public static void destroyApplicationContext(Object parameter) { - ContextsService contextService = ServiceLoader.getService(ContextsService.class); + ContextsService contextService = ServiceLoader.getService(ContextsService.class); contextService.endContext(ApplicationScoped.class, parameter); } @@ -140,7 +140,7 @@ public final class ContextFactory public static void destroySingletonContext(Object parameter) { - ContextsService contextService = ServiceLoader.getService(ContextsService.class); + ContextsService contextService = ServiceLoader.getService(ContextsService.class); contextService.endContext(Singleton.class, parameter); } @@ -159,7 +159,7 @@ public final class ContextFactory public static void destroyConversationContext() { - ContextsService contextService = ServiceLoader.getService(ContextsService.class); + ContextsService contextService = ServiceLoader.getService(ContextsService.class); contextService.endContext(ConversationScoped.class, null); } @@ -250,7 +250,7 @@ public final class ContextFactory */ public static void activateContext(Class scopeType) { - ContextsService contextService = ServiceLoader.getService(ContextsService.class); + ContextsService contextService = ServiceLoader.getService(ContextsService.class); contextService.activateContext(scopeType); } @@ -259,7 +259,7 @@ public final class ContextFactory */ public static void deActivateContext(Class scopeType) { - ContextsService contextService = ServiceLoader.getService(ContextsService.class); + ContextsService contextService = ServiceLoader.getService(ContextsService.class); contextService.deActivateContext(scopeType); } Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java Tue Jun 8 09:21:23 2010 @@ -41,7 +41,7 @@ public class CreationalContextImpl im /**Contextual bean dependent instances*/ //contextual instance --> dependents - private Map>> dependentObjects = + private Map>> dependentObjects = Collections.synchronizedMap(new WeakHashMap>>()); /**Contextual bean*/ Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java Tue Jun 8 09:21:23 2010 @@ -142,7 +142,7 @@ public class WebBeansDecorator extend else { throw new WebBeansConfigurationException("Decorators must have a one @Delegate injection point. " + - "But the decorator bean : " + toString() + " has more than one"); + "But the decorator bean : " + toString() + " has more than one"); } } } @@ -155,7 +155,7 @@ public class WebBeansDecorator extend } String message = new String("Error in decorator : "+ toString() + ". The delegate injection point must be an injected field, " + - "initializer method parameter or bean constructor method parameter. "); + "initializer method parameter or bean constructor method parameter. "); if(!(ipFound.getMember() instanceof Constructor)) { @@ -534,27 +534,27 @@ public class WebBeansDecorator extend return this.wrappedBean.getBeanClass(); } - @Override - public Set> getStereotypes() - { + @Override + public Set> getStereotypes() + { if(this.customDecorator != null) { return this.customDecorator.getStereotypes(); } - - return this.wrappedBean.getStereotypes(); - } - - @Override - public Set getDecoratedTypes() - { + + return this.wrappedBean.getStereotypes(); + } + + @Override + public Set getDecoratedTypes() + { if(this.customDecorator != null) { return this.customDecorator.getDecoratedTypes(); } - - return this.decoratedTypes; - } + + return this.decoratedTypes; + } @Override public boolean isAlternative() @@ -566,11 +566,11 @@ public class WebBeansDecorator extend return this.wrappedBean.isAlternative(); } - + @Override public void validatePassivationDependencies() { this.wrappedBean.validatePassivationDependencies(); - } - + } + } Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java Tue Jun 8 09:21:23 2010 @@ -319,7 +319,7 @@ public class InvocationContextImpl imple return result; } - + /** * {@inheritDoc} */ @@ -338,38 +338,38 @@ public class InvocationContextImpl imple { if (params.length != this.parameters.length) { - throw new IllegalArgumentException("Expected " + this.parameters.length + " " + - "parameters, but only got " + params.length + " parameters"); + throw new IllegalArgumentException("Expected " + this.parameters.length + " " + + "parameters, but only got " + params.length + " parameters"); } Class[] methodParameters = this.method.getParameterTypes(); int i = 0; for (Object obj : params) { - Class parameterType = methodParameters[i++]; - if (obj == null) + Class parameterType = methodParameters[i++]; + if (obj == null) { - if (parameterType.isPrimitive()) + if (parameterType.isPrimitive()) { throw new IllegalArgumentException("Expected parameter " + i + " to be primitive type " + parameterType.getName() + - ", but got a parameter that is null"); + ", but got a parameter that is null"); } } else { - //Primitive check - if(parameterType.isPrimitive()) - { - //First change to wrapper for comparision - parameterType = ClassUtil.getPrimitiveWrapper(parameterType); - } - - //Actual check - if (!parameterType.isInstance(obj)) - { + //Primitive check + if(parameterType.isPrimitive()) + { + //First change to wrapper for comparision + parameterType = ClassUtil.getPrimitiveWrapper(parameterType); + } + + //Actual check + if (!parameterType.isInstance(obj)) + { throw new IllegalArgumentException("Expected parameter " + i + " to be of type " + parameterType.getName() + - ", but got a parameter of type " + obj.getClass().getName()); - } + ", but got a parameter of type " + obj.getClass().getName()); + } } } Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java Tue Jun 8 09:21:23 2010 @@ -74,8 +74,8 @@ import org.apache.webbeans.xml.XMLAnnota */ public class WebBeansInterceptor extends AbstractOwbBean implements OwbInterceptor { - private static final WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansInterceptor.class); - + private static final WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansInterceptor.class); + /** InterceptorBindingTypes exist on the interceptor class */ private Map, Annotation> interceptorBindingSet = new HashMap, Annotation>(); @@ -156,18 +156,18 @@ public class WebBeansInterceptor exte /* This interceptor is enabled if all of its interceptor bindings are present on the bean */ for (Annotation ann : getInterceptorBindings()) { - Class bindingType = ann.annotationType(); - int index = bindingTypes.indexOf(bindingType); - if (index < 0) - { - return false; /* at least one of this interceptors types is not in the beans bindingTypes */ - } - - if (!AnnotationUtil.hasAnnotationMember(bindingTypes.get(index), annots.get(index), ann)) - - { - return false; - } + Class bindingType = ann.annotationType(); + int index = bindingTypes.indexOf(bindingType); + if (index < 0) + { + return false; /* at least one of this interceptors types is not in the beans bindingTypes */ + } + + if (!AnnotationUtil.hasAnnotationMember(bindingTypes.get(index), annots.get(index), ann)) + + { + return false; + } } return true; @@ -398,36 +398,36 @@ public class WebBeansInterceptor exte return this.delegateBean.getBeanClass(); } - @Override - public Set> getStereotypes() - { - return this.delegateBean.getStereotypes(); - } - - @Override - public Object intercept(InterceptionType type, T instance,InvocationContext ctx) - { - Method method = getMethod(type); - try - { - method.invoke(instance,new Object[]{ctx}); - } - catch (Exception e) - { - logger.error(e); - throw new WebBeansException(e); - } - - return null; - } - - @Override - public boolean intercepts(InterceptionType type) - { - Method method = getMethod(type); - - return method != null ? true : false; - } + @Override + public Set> getStereotypes() + { + return this.delegateBean.getStereotypes(); + } + + @Override + public Object intercept(InterceptionType type, T instance,InvocationContext ctx) + { + Method method = getMethod(type); + try + { + method.invoke(instance,new Object[]{ctx}); + } + catch (Exception e) + { + logger.error(e); + throw new WebBeansException(e); + } + + return null; + } + + @Override + public boolean intercepts(InterceptionType type) + { + Method method = getMethod(type); + + return method != null ? true : false; + } @Override public boolean isAlternative() Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java Tue Jun 8 09:21:23 2010 @@ -238,30 +238,30 @@ public final class JavassistProxyFactory return result; } - + public static Class getProxyClass(ProxyFactory factory) { - Class proxyClass = null; + Class proxyClass = null; try { - proxyClass = SecurityUtil.doPrivilegedCreateClass(factory); - + proxyClass = SecurityUtil.doPrivilegedCreateClass(factory); + }catch(Exception e) { ProxyFactory.classLoaderProvider = new ProxyFactory.ClassLoaderProvider(){ - @Override - public ClassLoader get(ProxyFactory pf) - { - return Thread.currentThread().getContextClassLoader(); - } - + @Override + public ClassLoader get(ProxyFactory pf) + { + return Thread.currentThread().getContextClassLoader(); + } + }; - - proxyClass = SecurityUtil.doPrivilegedCreateClass(factory); - } - + + proxyClass = SecurityUtil.doPrivilegedCreateClass(factory); + } + return proxyClass; } Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java Tue Jun 8 09:21:23 2010 @@ -942,18 +942,18 @@ public final class AnnotationUtil */ public static boolean hasAnyQualifier(Bean bean) { - Asserts.assertNotNull(bean, "bean parameter can not be null"); - Set qualifiers = bean.getQualifiers(); - - for(Annotation ann : qualifiers) - { - if(ann.annotationType().equals(Any.class)) - { - return true; - } - } - - return false; + Asserts.assertNotNull(bean, "bean parameter can not be null"); + Set qualifiers = bean.getQualifiers(); + + for(Annotation ann : qualifiers) + { + if(ann.annotationType().equals(Any.class)) + { + return true; + } + } + + return false; } Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java Tue Jun 8 09:21:23 2010 @@ -25,208 +25,161 @@ import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; import javassist.util.proxy.ProxyFactory; - -public class SecurityUtil -{ - - private final static int METHOD_CLASS_GETDECLAREDCONSTRUCTOR = 0x01; - - private final static int METHOD_CLASS_GETDECLAREDCONSTRUCTORS = 0x02; - - private final static int METHOD_CLASS_GETDECLAREDMETHOD = 0x03; - - private final static int METHOD_CLASS_GETDECLAREDMETHODS = 0x04; - - private final static int METHOD_CLASS_GETDECLAREDFIELD = 0x05; - - private final static int METHOD_CLASS_GETDECLAREDFIELDS = 0x06; - - @SuppressWarnings("unchecked") - public static Constructor doPrivilegedGetDeclaredConstructor(Class clazz, Class... parameterTypes) throws NoSuchMethodException - { - Object obj = AccessController.doPrivileged( - new PrivilegedActionForClass(clazz, parameterTypes, METHOD_CLASS_GETDECLAREDCONSTRUCTOR)); - if (obj instanceof NoSuchMethodException) throw (NoSuchMethodException)obj; - return (Constructor)obj; - } - - @SuppressWarnings("unchecked") - public static Constructor[] doPrivilegedGetDeclaredConstructors(Class clazz) - { - Object obj = AccessController.doPrivileged( - new PrivilegedActionForClass(clazz, null, METHOD_CLASS_GETDECLAREDCONSTRUCTORS)); - return (Constructor[])obj; - } - - public static Method doPrivilegedGetDeclaredMethod(Class clazz, String name, Class... parameterTypes) throws NoSuchMethodException - { - Object obj = AccessController.doPrivileged( - new PrivilegedActionForClass(clazz, new Object[] {name, parameterTypes}, METHOD_CLASS_GETDECLAREDMETHOD)); - if (obj instanceof NoSuchMethodException) throw (NoSuchMethodException)obj; - return (Method)obj; - } - - public static Method[] doPrivilegedGetDeclaredMethods(Class clazz) - { - Object obj = AccessController.doPrivileged( - new PrivilegedActionForClass(clazz, null, METHOD_CLASS_GETDECLAREDMETHODS)); - return (Method[])obj; - } - - public static Field doPrivilegedGetDeclaredField(Class clazz, String name) throws NoSuchFieldException - { - Object obj = AccessController.doPrivileged( - new PrivilegedActionForClass(clazz, name, METHOD_CLASS_GETDECLAREDFIELD)); - if (obj instanceof NoSuchFieldException) throw (NoSuchFieldException)obj; - return (Field)obj; - } - - public static Field[] doPrivilegedGetDeclaredFields(Class clazz) - { - Object obj = AccessController.doPrivileged( - new PrivilegedActionForClass(clazz, null, METHOD_CLASS_GETDECLAREDFIELDS)); - return (Field[])obj; - } - - protected static class PrivilegedActionForClass implements PrivilegedAction - { - Class clazz; - - Object parameters; - - int method; - - protected PrivilegedActionForClass(Class clazz, Object parameters, int method) - { - this.clazz = clazz; - this.parameters = parameters; - this.method = method; - } - - public Object run() - { - try - { - switch (method) - { - case METHOD_CLASS_GETDECLAREDCONSTRUCTOR: - return clazz.getDeclaredConstructor((Class[])parameters); - case METHOD_CLASS_GETDECLAREDCONSTRUCTORS: - return clazz.getDeclaredConstructors(); - case METHOD_CLASS_GETDECLAREDMETHOD: - String name = (String)((Object[])parameters)[0]; - Class[] realParameters = (Class[])((Object[])parameters)[1]; - return clazz.getDeclaredMethod(name, realParameters); - case METHOD_CLASS_GETDECLAREDMETHODS: - return clazz.getDeclaredMethods(); - case METHOD_CLASS_GETDECLAREDFIELD: - return clazz.getDeclaredField((String)parameters); - case METHOD_CLASS_GETDECLAREDFIELDS: - return clazz.getDeclaredFields(); - } - } - catch (Exception exception) - { - return exception; - } - return null; - } - - } - - public static Object doPrivilegedSetAccessible(AccessibleObject obj, boolean flag) - { - AccessController.doPrivileged(new PrivilegedActionForAccessibleObject(obj, flag)); - return null; - }; - - protected static class PrivilegedActionForAccessibleObject implements PrivilegedAction - { - - AccessibleObject object; - - boolean flag; - - protected PrivilegedActionForAccessibleObject(AccessibleObject object, boolean flag) - { - this.object = object; - this.flag = flag; - } - - public Object run() - { - object.setAccessible(flag); - return null; - } - } - - - public static Class doPrivilegedCreateClass(ProxyFactory factory) - { - Class ret = (Class)AccessController.doPrivileged(new PrivilegedActionForProxyFactory(factory)); - return ret; - } - - protected static class PrivilegedActionForProxyFactory implements PrivilegedAction - { - ProxyFactory factory; - - protected PrivilegedActionForProxyFactory(ProxyFactory factory) - { - this.factory = factory; - } - - public Object run() - { - return factory.createClass(); - } - } - -/* - public static Set doPrivilegedSetAdd(Set set, T item) - { - AccessController.doPrivileged(new PrivilegedActionForSet(set, item)); - return null; - } - - protected static class PrivilegedActionForSet implements PrivilegedAction - { - Set set; - - T item; - - protected PrivilegedActionForSet(Set set, T item) - { - this.set = set; - this.item = item; - } - - public T run() - { - set.add(item); - return null; - } - } - - public static String doPrivilegedToString(java.lang.annotation.Annotation a) - { - return (String)AccessController.doPrivileged(new PrivilegedActionForAnnotation(a)); - } - - protected static class PrivilegedActionForAnnotation implements PrivilegedAction - { - java.lang.annotation.Annotation annotation; - - protected PrivilegedActionForAnnotation(java.lang.annotation.Annotation annotation) - { - this.annotation = annotation; - } - - public Object run() - { - return annotation.toString(); - } - } -*/ - + +public class SecurityUtil +{ + + private final static int METHOD_CLASS_GETDECLAREDCONSTRUCTOR = 0x01; + + private final static int METHOD_CLASS_GETDECLAREDCONSTRUCTORS = 0x02; + + private final static int METHOD_CLASS_GETDECLAREDMETHOD = 0x03; + + private final static int METHOD_CLASS_GETDECLAREDMETHODS = 0x04; + + private final static int METHOD_CLASS_GETDECLAREDFIELD = 0x05; + + private final static int METHOD_CLASS_GETDECLAREDFIELDS = 0x06; + + @SuppressWarnings("unchecked") + public static Constructor doPrivilegedGetDeclaredConstructor(Class clazz, Class... parameterTypes) throws NoSuchMethodException + { + Object obj = AccessController.doPrivileged( + new PrivilegedActionForClass(clazz, parameterTypes, METHOD_CLASS_GETDECLAREDCONSTRUCTOR)); + if (obj instanceof NoSuchMethodException) throw (NoSuchMethodException)obj; + return (Constructor)obj; + } + + @SuppressWarnings("unchecked") + public static Constructor[] doPrivilegedGetDeclaredConstructors(Class clazz) + { + Object obj = AccessController.doPrivileged( + new PrivilegedActionForClass(clazz, null, METHOD_CLASS_GETDECLAREDCONSTRUCTORS)); + return (Constructor[])obj; + } + + public static Method doPrivilegedGetDeclaredMethod(Class clazz, String name, Class... parameterTypes) throws NoSuchMethodException + { + Object obj = AccessController.doPrivileged( + new PrivilegedActionForClass(clazz, new Object[] {name, parameterTypes}, METHOD_CLASS_GETDECLAREDMETHOD)); + if (obj instanceof NoSuchMethodException) throw (NoSuchMethodException)obj; + return (Method)obj; + } + + public static Method[] doPrivilegedGetDeclaredMethods(Class clazz) + { + Object obj = AccessController.doPrivileged( + new PrivilegedActionForClass(clazz, null, METHOD_CLASS_GETDECLAREDMETHODS)); + return (Method[])obj; + } + + public static Field doPrivilegedGetDeclaredField(Class clazz, String name) throws NoSuchFieldException + { + Object obj = AccessController.doPrivileged( + new PrivilegedActionForClass(clazz, name, METHOD_CLASS_GETDECLAREDFIELD)); + if (obj instanceof NoSuchFieldException) throw (NoSuchFieldException)obj; + return (Field)obj; + } + + public static Field[] doPrivilegedGetDeclaredFields(Class clazz) + { + Object obj = AccessController.doPrivileged( + new PrivilegedActionForClass(clazz, null, METHOD_CLASS_GETDECLAREDFIELDS)); + return (Field[])obj; + } + + protected static class PrivilegedActionForClass implements PrivilegedAction + { + Class clazz; + + Object parameters; + + int method; + + protected PrivilegedActionForClass(Class clazz, Object parameters, int method) + { + this.clazz = clazz; + this.parameters = parameters; + this.method = method; + } + + public Object run() + { + try + { + switch (method) + { + case METHOD_CLASS_GETDECLAREDCONSTRUCTOR: + return clazz.getDeclaredConstructor((Class[])parameters); + case METHOD_CLASS_GETDECLAREDCONSTRUCTORS: + return clazz.getDeclaredConstructors(); + case METHOD_CLASS_GETDECLAREDMETHOD: + String name = (String)((Object[])parameters)[0]; + Class[] realParameters = (Class[])((Object[])parameters)[1]; + return clazz.getDeclaredMethod(name, realParameters); + case METHOD_CLASS_GETDECLAREDMETHODS: + return clazz.getDeclaredMethods(); + case METHOD_CLASS_GETDECLAREDFIELD: + return clazz.getDeclaredField((String)parameters); + case METHOD_CLASS_GETDECLAREDFIELDS: + return clazz.getDeclaredFields(); + } + } + catch (Exception exception) + { + return exception; + } + return null; + } + + } + + public static Object doPrivilegedSetAccessible(AccessibleObject obj, boolean flag) + { + AccessController.doPrivileged(new PrivilegedActionForAccessibleObject(obj, flag)); + return null; + }; + + protected static class PrivilegedActionForAccessibleObject implements PrivilegedAction + { + + AccessibleObject object; + + boolean flag; + + protected PrivilegedActionForAccessibleObject(AccessibleObject object, boolean flag) + { + this.object = object; + this.flag = flag; + } + + public Object run() + { + object.setAccessible(flag); + return null; + } + } + + + public static Class doPrivilegedCreateClass(ProxyFactory factory) + { + Class ret = (Class)AccessController.doPrivileged(new PrivilegedActionForProxyFactory(factory)); + return ret; + } + + protected static class PrivilegedActionForProxyFactory implements PrivilegedAction + { + ProxyFactory factory; + + protected PrivilegedActionForProxyFactory(ProxyFactory factory) + { + this.factory = factory; + } + + public Object run() + { + return factory.createClass(); + } + } + } Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java?rev=952583&r1=952582&r2=952583&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLUtil.java Tue Jun 8 09:21:23 2010 @@ -67,78 +67,78 @@ public class XMLUtil { protected static boolean verifyNameSpace(Element element) { - boolean ret; - if (element.getNamespaceURI() == null) - { - return false; - } - Node node; - NodeList ns = element.getChildNodes(); - for(int i=0; i