openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r963046 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: jms/JMSManager.java jms/JMSModel.java lifecycle/AbstractLifeCycle.java proxy/JavassistProxyFactory.java util/ClassUtil.java util/SecurityUtil.java
Date Sun, 11 Jul 2010 11:06:48 GMT
Author: gerdogdu
Date: Sun Jul 11 11:06:47 2010
New Revision: 963046

URL: http://svn.apache.org/viewvc?rev=963046&view=rev
Log:
Improvement, no functional change

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jms/JMSManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jms/JMSModel.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.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/ClassUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jms/JMSManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jms/JMSManager.java?rev=963046&r1=963045&r2=963046&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jms/JMSManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jms/JMSManager.java
Sun Jul 11 11:06:47 2010
@@ -30,13 +30,18 @@ import org.apache.webbeans.util.Asserts;
 
 public class JMSManager
 {
-    private Set<JMSModel> jmsModels = new CopyOnWriteArraySet<JMSModel>();
+    private final Set<JMSModel> jmsModels = new CopyOnWriteArraySet<JMSModel>();
 
     public JMSManager()
     {
         
     }
     
+    public void clear()
+    {
+        this.jmsModels.clear();
+    }
+    
     public static JMSManager getInstance()
     {
         return (JMSManager)WebBeansFinder.getSingletonInstance(JMSManager.class.getName());

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jms/JMSModel.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jms/JMSModel.java?rev=963046&r1=963045&r2=963046&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jms/JMSModel.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jms/JMSModel.java Sun
Jul 11 11:06:47 2010
@@ -30,15 +30,11 @@ public class JMSModel
         TOPIC
     }
 
-    private JMSType jmsType;
-    
-    private String jndiName;
-    
-    private String mappedName;
-    
-    private boolean isJndiNameDefined;
-    
-    private Set<Annotation> bindings = new HashSet<Annotation>();
+    private final JMSType jmsType;    
+    private String jndiName;    
+    private final String mappedName;    
+    private boolean isJndiNameDefined;    
+    private final Set<Annotation> bindings = new HashSet<Annotation>();
     
     
     public JMSModel(JMSType jmsType, String jndiName, String mappedName)
@@ -155,7 +151,5 @@ public class JMSModel
         }
         return true;
     }
-
-
-    
+   
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java?rev=963046&r1=963045&r2=963046&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
Sun Jul 11 11:06:47 2010
@@ -29,6 +29,7 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.corespi.ServiceLoader;
+import org.apache.webbeans.jms.JMSManager;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.plugins.PluginLoader;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
@@ -162,6 +163,9 @@ public abstract class AbstractLifeCycle 
             //Delete AnnotateTypeCache
             AnnotatedElementFactory.getInstance().clear();
             
+            //Delete JMS Model Cache
+            JMSManager.getInstance().clear();
+            
             //After Stop
             afterStopApplication(endObject);
             

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=963046&r1=963045&r2=963046&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
Sun Jul 11 11:06:47 2010
@@ -59,13 +59,10 @@ public final class JavassistProxyFactory
 
     }
     
-    private  Map<OwbBean<?>, Class<?>> normalScopedBeanProxyClasses = new
ConcurrentHashMap<OwbBean<?>, Class<?>>();
-    
-    private  Map<OwbBean<?>, Class<?>> dependentScopedBeanProxyClasses
= new ConcurrentHashMap<OwbBean<?>, Class<?>>();
-    
-    private  Map<OwbBean<?>, Class<?>> interceptorProxyClasses = new ConcurrentHashMap<OwbBean<?>,
Class<?>>();
-    
-    private  Map<OwbBean<?>, Class<?>> ejbProxyClasses = new ConcurrentHashMap<OwbBean<?>,
Class<?>>();
+    private Map<OwbBean<?>, Class<?>> normalScopedBeanProxyClasses = new
ConcurrentHashMap<OwbBean<?>, Class<?>>();    
+    private Map<OwbBean<?>, Class<?>> dependentScopedBeanProxyClasses =
new ConcurrentHashMap<OwbBean<?>, Class<?>>();    
+    private Map<OwbBean<?>, Class<?>> interceptorProxyClasses = new ConcurrentHashMap<OwbBean<?>,
Class<?>>();    
+    private Map<OwbBean<?>, Class<?>> ejbProxyClasses = new ConcurrentHashMap<OwbBean<?>,
Class<?>>();    
     
     public   Map<OwbBean<?>, Class<?>> getInterceptorProxyClasses()
     {
@@ -92,6 +89,7 @@ public final class JavassistProxyFactory
         return ejbProxyClasses.get(bean);
     }
     
+
     public  Class<?> defineEjbBeanProxyClass(OwbBean<?> bean, ProxyFactory factory)
     {
         Class<?> clazz = ejbProxyClasses.get(bean);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=963046&r1=963045&r2=963046&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
Sun Jul 11 11:06:47 2010
@@ -30,6 +30,7 @@ import java.lang.reflect.TypeVariable;
 import java.lang.reflect.WildcardType;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.security.PrivilegedActionException;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.text.DateFormat;
@@ -168,18 +169,26 @@ public final class ClassUtil
     {
         try
         {
+            if(System.getSecurityManager() != null)
+            {
+                return SecurityUtil.doPrivilegedObjectCreate(clazz);
+            }            
+            
             return clazz.newInstance();
-        }
-        catch (InstantiationException e)
-        {
-            logger.error(e);
-        }
-        catch (IllegalAccessException e)
+            
+        }catch(Exception e)
         {
-            logger.error(e);
-        }
+            Throwable cause = e;
+            if(e instanceof PrivilegedActionException)
+            {
+                cause = ((PrivilegedActionException)e).getCause();
+            }
+            
+            String error = "Error is occured while creating an instance of class : " + clazz.getName();

+            logger.error(error, cause);
+            throw new WebBeansException(error,cause); 
         
-        return null;
+        }
     }
 
     public static Class<?> getClassFromName(String name)

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=963046&r1=963045&r2=963046&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
Sun Jul 11 11:06:47 2010
@@ -24,6 +24,8 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.Properties;
 
 import javassist.util.proxy.ProxyFactory;
@@ -189,6 +191,11 @@ public class SecurityUtil
         
         return value;
     }
+    
+    public static Object doPrivilegedObjectCreate(Class<?> clazz) throws PrivilegedActionException
+    {
+        return AccessController.doPrivileged(new PrivilegedActionForObjectCreation(clazz));
+    }
 
     public static void doPrivilegedSetSystemProperty(String propertyName, String value)
     {
@@ -251,6 +258,34 @@ public class SecurityUtil
         }
         
     }
+    
+    protected static class PrivilegedActionForObjectCreation implements PrivilegedExceptionAction<Object>
+    {
+        Class<?> clazz;
+        
+        protected PrivilegedActionForObjectCreation(Class<?> clazz)
+        {
+            this.clazz = clazz;
+        }
+
+        @Override
+        public Object run() throws Exception
+        {
+            try
+            {
+                return clazz.newInstance();
+            }
+            catch (InstantiationException e)
+            {
+                throw e;
+            }
+            catch (IllegalAccessException e)
+            {
+                throw e;
+            }
+        }
+        
+    }
 
     protected static class PrivilegedActionForProxyFactory implements PrivilegedAction<Object>
     {



Mime
View raw message