You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-commits@ws.apache.org by sc...@apache.org on 2005/07/29 18:13:38 UTC

svn commit: r226390 - in /webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl: AbstractResourceContext.java AbstractResourceHome.java

Author: scamp
Date: Fri Jul 29 09:13:34 2005
New Revision: 226390

URL: http://svn.apache.org/viewcvs?rev=226390&view=rev
Log:
fixed issue with singleton and issue with init() in homes

Modified:
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java?rev=226390&r1=226389&r2=226390&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceContext.java Fri Jul 29 09:13:34 2005
@@ -89,7 +89,16 @@
         }
         if ( m_home instanceof AbstractResourceHome )
         {
-            ( (AbstractResourceHome) m_home ).init();
+            AbstractResourceHome abstractResourceHome = ( (AbstractResourceHome) m_home );
+
+            //check if home has been initialized
+            synchronized (abstractResourceHome)
+            {
+                if( !abstractResourceHome.isInitialized())
+                {
+                    abstractResourceHome.init();
+                }
+            }
         }
     }
 

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java?rev=226390&r1=226389&r2=226390&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java Fri Jul 29 09:13:34 2005
@@ -141,11 +141,18 @@
     private Cache m_cache;
     private long m_sweeperDelay = DEFAULT_SWEEPER_DELAY;
     private Sweeper m_sweeper;
+
+
     private boolean m_initialized;
     private Class m_resourceClass;
     private List m_creationListeners = new ArrayList();
     private List m_destructionListeners = new ArrayList();
 
+    /**
+     * A static key used only for registering Singleton Resources
+     */
+    private static final Object SINGLETON_KEY = new Object();
+
     private static final String PLACEHOLDER_IPADDRESS = "$IP_ADDRESS$";
     private static final String PLACEHOLDER_HOSTNAME = "$HOST_NAME$";
 
@@ -522,7 +529,7 @@
 
     Object getNonNullKey( Object obj )
     {
-        return obj != null ? obj : new Object();
+        return obj != null ? obj : SINGLETON_KEY;
     }
 
     protected void initCachePolicy( Context initialContext )
@@ -729,6 +736,11 @@
 
     public String getResourceIdentifierReferenceParameterName()
     {
+        //case of singleton...
+        if(m_resourceIdRefParamName == null)
+        {
+            return null;
+        }
         return m_resourceIdRefParamName.toString();
     }
 
@@ -902,5 +914,16 @@
         }
         return Collections.synchronizedMap( resourceMap );
     }
+
+    /**
+     * Returns true if the home has been initialized, else false
+     *
+     * @return  true if the home has been initialized, else false
+     */
+    public boolean isInitialized()
+     {
+         return m_initialized;
+     }
+
 
 }