Author: gtrasuk
Date: Thu Apr  4 07:32:53 2013
New Revision: 1464321

URL: http://svn.apache.org/r1464321
Log:
Merging limited revisions from trunk.  r1140819 - Update build documentation.  
r121190 - Fix RIVER-149

Modified:
    river/jtsk/branches/2.2/   (props changed)
    river/jtsk/branches/2.2/asm/asm-3.2.jar   (props changed)
    river/jtsk/branches/2.2/asm/asm-commons-3.2.jar   (props changed)
    river/jtsk/branches/2.2/qa/   (props changed)
    river/jtsk/branches/2.2/qa/README.txt   (props changed)
    river/jtsk/branches/2.2/qa/doc/HowToRunATest.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/HowToWriteATest.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/discoverygroupmanagement-req.doc   (props 
changed)
    river/jtsk/branches/2.2/qa/doc/discoverygroupmanagement-req.html   (props 
changed)
    river/jtsk/branches/2.2/qa/doc/discoverylocatormanagement-req.doc   (props 
changed)
    river/jtsk/branches/2.2/qa/doc/discoverylocatormanagement-req.html   (props 
changed)
    river/jtsk/branches/2.2/qa/doc/discoverymanagement-req.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/discoverymanagement-req.html   (props 
changed)
    river/jtsk/branches/2.2/qa/doc/discoverymanagement-test.doc   (props 
changed)
    river/jtsk/branches/2.2/qa/doc/discoverymanagement-test.html   (props 
changed)
    river/jtsk/branches/2.2/qa/doc/discoveryservice-req.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/discoveryservice-req.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/discoveryservice-test.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/discoveryservice-test.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/eventmailbox-req.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/eventmailbox-req.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/eventmailbox-test.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/eventmailbox-test.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/index-requirements.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/index-testdescriptions.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/index.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/javaspace_req.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/javaspace_test.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/joinmanager-req.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/joinmanager-req.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/joinmanager-test.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/locatordiscovery-req.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/locatordiscovery-req.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/locatordiscovery-test.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/lookupdiscovery-req.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/lookupdiscovery-req.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/lookupdiscovery-test.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/qaMethodWorkArch.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/qaarch.sdw   (props changed)
    river/jtsk/branches/2.2/qa/doc/renewalmanager-req.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/renewalmanager-req.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/renewalservice-req.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/renewalservice-req.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/renewalservice-test.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/renewalservice-test.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/servicediscovery-req.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/servicediscovery-req.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/servicediscovery-test.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/servicediscovery-test.html   (props changed)
    river/jtsk/branches/2.2/qa/doc/testcategories.doc   (props changed)
    river/jtsk/branches/2.2/qa/doc/testcategories.html   (props changed)
    river/jtsk/branches/2.2/src-doc/static/build.html
    river/jtsk/branches/2.2/src/com/sun/jini/resource/Service.java
    river/jtsk/branches/2.2/src/net/jini/config/ConfigurationProvider.java
    river/jtsk/branches/2.2/src/net/jini/export/ServerContext.java

Propchange: river/jtsk/branches/2.2/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Apr  4 07:32:53 2013
@@ -1,14 +1,16 @@
 classes
-lib-ext
-build.properties
-deps
-configentry
-nbproject
+LICENSE.txt
+River-149-patch-final.diff
+River-149-patch.diff
 build
 .*
 lib-dl
+lib-ext
 lib
-dist
+build.properties
 doc
-LICENSE.txt
+deps
+configentry
+nbproject
 NOTICE.txt
+dist

Propchange: river/jtsk/branches/2.2/
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk:r1140819,1211940

Propchange: river/jtsk/branches/2.2/asm/asm-3.2.jar
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/asm/asm-3.2.jar:r1140819,1211940

Propchange: river/jtsk/branches/2.2/asm/asm-commons-3.2.jar
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/asm/asm-commons-3.2.jar:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/README.txt
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/README.txt:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/HowToRunATest.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/HowToRunATest.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/HowToWriteATest.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/HowToWriteATest.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoverygroupmanagement-req.doc
------------------------------------------------------------------------------
  Merged 
/river/jtsk/trunk/qa/doc/discoverygroupmanagement-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoverygroupmanagement-req.html
------------------------------------------------------------------------------
  Merged 
/river/jtsk/trunk/qa/doc/discoverygroupmanagement-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoverylocatormanagement-req.doc
------------------------------------------------------------------------------
  Merged 
/river/jtsk/trunk/qa/doc/discoverylocatormanagement-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoverylocatormanagement-req.html
------------------------------------------------------------------------------
  Merged 
/river/jtsk/trunk/qa/doc/discoverylocatormanagement-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoverymanagement-req.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/discoverymanagement-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoverymanagement-req.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/discoverymanagement-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoverymanagement-test.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/discoverymanagement-test.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoverymanagement-test.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/discoverymanagement-test.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoveryservice-req.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/discoveryservice-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoveryservice-req.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/discoveryservice-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoveryservice-test.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/discoveryservice-test.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/discoveryservice-test.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/discoveryservice-test.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/eventmailbox-req.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/eventmailbox-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/eventmailbox-req.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/eventmailbox-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/eventmailbox-test.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/eventmailbox-test.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/eventmailbox-test.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/eventmailbox-test.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/index-requirements.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/index-requirements.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/index-testdescriptions.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/index-testdescriptions.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/index.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/index.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/javaspace_req.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/javaspace_req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/javaspace_test.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/javaspace_test.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/joinmanager-req.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/joinmanager-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/joinmanager-req.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/joinmanager-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/joinmanager-test.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/joinmanager-test.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/locatordiscovery-req.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/locatordiscovery-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/locatordiscovery-req.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/locatordiscovery-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/locatordiscovery-test.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/locatordiscovery-test.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/lookupdiscovery-req.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/lookupdiscovery-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/lookupdiscovery-req.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/lookupdiscovery-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/lookupdiscovery-test.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/lookupdiscovery-test.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/qaMethodWorkArch.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/qaMethodWorkArch.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/qaarch.sdw
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/qaarch.sdw:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/renewalmanager-req.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/renewalmanager-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/renewalmanager-req.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/renewalmanager-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/renewalservice-req.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/renewalservice-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/renewalservice-req.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/renewalservice-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/renewalservice-test.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/renewalservice-test.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/renewalservice-test.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/renewalservice-test.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/servicediscovery-req.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/servicediscovery-req.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/servicediscovery-req.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/servicediscovery-req.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/servicediscovery-test.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/servicediscovery-test.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/servicediscovery-test.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/servicediscovery-test.html:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/testcategories.doc
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/testcategories.doc:r1140819,1211940

Propchange: river/jtsk/branches/2.2/qa/doc/testcategories.html
------------------------------------------------------------------------------
  Merged /river/jtsk/trunk/qa/doc/testcategories.html:r1140819,1211940

Modified: river/jtsk/branches/2.2/src-doc/static/build.html
URL: 
http://svn.apache.org/viewvc/river/jtsk/branches/2.2/src-doc/static/build.html?rev=1464321&r1=1464320&r2=1464321&view=diff
==============================================================================
--- river/jtsk/branches/2.2/src-doc/static/build.html (original)
+++ river/jtsk/branches/2.2/src-doc/static/build.html Thu Apr  4 07:32:53 2013
@@ -59,7 +59,7 @@ The following prerequisites must be met 
 <ul>
   <li> 
     The <b><code>bin</code></b> directory of the Java(TM) 2 SDK, Standard
-    Edition, v 1.4 (or later) must be in your executable search path. You can
+    Edition, v 1.5 (or later) must be in your executable search path. You can
     obtain the Java software at <a href="http://java.sun.com";>
     <code>http://java.sun.com</code></a> . 
   </li>

Modified: river/jtsk/branches/2.2/src/com/sun/jini/resource/Service.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/branches/2.2/src/com/sun/jini/resource/Service.java?rev=1464321&r1=1464320&r2=1464321&view=diff
==============================================================================
--- river/jtsk/branches/2.2/src/com/sun/jini/resource/Service.java (original)
+++ river/jtsk/branches/2.2/src/com/sun/jini/resource/Service.java Thu Apr  4 
07:32:53 2013
@@ -30,6 +30,7 @@ import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.LinkedHashSet;
+import java.util.logging.Logger;
 
 
 /**
@@ -121,6 +122,9 @@ import java.util.LinkedHashSet;
 
 public final class Service {
 
+       private static final Logger log=
+               Logger.getLogger(Service.class.getName());
+
     private static final String prefix = "META-INF/services/";
 
     private Service() { }
@@ -271,6 +275,9 @@ public final class Service {
            try {
                Class c = Class.forName(cn, true, loader);
                if (!service.isAssignableFrom(c)) {
+                       log.severe("service classloader is "
+                                         + service.getClass().getClassLoader()
+                                         + ", provider loader is " + loader);
                    fail(service, "Provider " + cn + " is of incorrect type");
                }
                return c.newInstance();

Modified: river/jtsk/branches/2.2/src/net/jini/config/ConfigurationProvider.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/branches/2.2/src/net/jini/config/ConfigurationProvider.java?rev=1464321&r1=1464320&r2=1464321&view=diff
==============================================================================
--- river/jtsk/branches/2.2/src/net/jini/config/ConfigurationProvider.java 
(original)
+++ river/jtsk/branches/2.2/src/net/jini/config/ConfigurationProvider.java Thu 
Apr  4 07:32:53 2013
@@ -177,15 +177,30 @@ public class ConfigurationProvider {
     public static Configuration getInstance(String[] options, ClassLoader cl)
        throws ConfigurationException
     {
-       ClassLoader resourceLoader = (cl != null) ? cl :
-           (ClassLoader) Security.doPrivileged(
-               new PrivilegedAction() {
-                   public Object run() {
-                       return Thread.currentThread().getContextClassLoader();
-                   }
-               });
+               /*
+                 ClassLoader resourceLoader = (cl != null) ? cl :
+                 (ClassLoader) Security.doPrivileged(
+                 new PrivilegedAction() {
+                 public Object run() {
+                 return Thread.currentThread().getContextClassLoader();
+                 }
+                 });
+               */
+               ClassLoader resourceLoader=cl;
+               if (resourceLoader == null) {
+                       logger.fine("Null class loader provided, fetching 
context class loader...");
+                       resourceLoader = (cl != null) ? cl :
+                               (ClassLoader) Security.doPrivileged(
+                                                                               
                        new PrivilegedAction() {
+                                                                               
                                public Object run() {
+                                                                               
                                        return 
Thread.currentThread().getContextClassLoader();
+                                                                               
                                }
+                                                                               
                        });
+                       logger.fine("...resource class loader is now: " + 
resourceLoader);
+               }
        final ClassLoader finalResourceLoader = (resourceLoader == null)
            ? Utilities.bootstrapResourceLoader : resourceLoader;
+       logger.fine("Final resource class loader is: " + finalResourceLoader);
        String cname = null;
        ConfigurationException configEx = null;
        try {

Modified: river/jtsk/branches/2.2/src/net/jini/export/ServerContext.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/branches/2.2/src/net/jini/export/ServerContext.java?rev=1464321&r1=1464320&r2=1464321&view=diff
==============================================================================
--- river/jtsk/branches/2.2/src/net/jini/export/ServerContext.java (original)
+++ river/jtsk/branches/2.2/src/net/jini/export/ServerContext.java Thu Apr  4 
07:32:53 2013
@@ -15,7 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package net.jini.export;
 
 import com.sun.jini.resource.Service;
@@ -47,18 +46,25 @@ import net.jini.security.Security;
 public final class ServerContext {
 
     private static final ThreadLocal state = new ThreadLocal();
-    private static final ServerContext.Spi[] providers = (ServerContext.Spi[]) 
-       Security.doPrivileged(new PrivilegedAction() {
-           public Object run() {
-               ClassLoader cl = ClassLoader.getSystemClassLoader();
-               ArrayList list = new ArrayList(1);
-               Iterator i = Service.providers(ServerContext.Spi.class, cl);
-               while (i.hasNext()) {
-                   list.add(i.next());
-               }
-               return list.toArray(new ServerContext.Spi[list.size()]);
-           }
-       });
+    private static ServerContext.Spi[] providers = null;
+
+    private static ServerContext.Spi[] getProviders() {
+        if (providers == null) {
+            providers = (ServerContext.Spi[]) Security.doPrivileged(new 
PrivilegedAction() {
+
+                public Object run() {
+                    ClassLoader cl = 
Thread.currentThread().getContextClassLoader();
+                    ArrayList list = new ArrayList(1);
+                    Iterator i = Service.providers(ServerContext.Spi.class, 
cl);
+                    while (i.hasNext()) {
+                        list.add(i.next());
+                    }
+                    return list.toArray(new ServerContext.Spi[list.size()]);
+                }
+            });
+        }
+        return providers;
+    }
 
     /**
      * Prevents instantiation.
@@ -88,22 +94,21 @@ public final class ServerContext {
      * @see #getServerContextElement
      **/
     public static void doWithServerContext(Runnable runnable,
-                                          Collection context)
-    {
-       if (context == null) {
-           throw new NullPointerException("context cannot be null");
-       }
-       if (state.get() != null) {
-           throw new IllegalStateException(
-               "context is already set for this thread");
-       }
-
-       state.set(context);
-       try {
-           runnable.run();
-       } finally {
-           state.set(null);
-       }
+            Collection context) {
+        if (context == null) {
+            throw new NullPointerException("context cannot be null");
+        }
+        if (state.get() != null) {
+            throw new IllegalStateException(
+                    "context is already set for this thread");
+        }
+
+        state.set(context);
+        try {
+            runnable.run();
+        } finally {
+            state.set(null);
+        }
     }
 
     /**
@@ -153,20 +158,19 @@ public final class ServerContext {
      *         current thread
      **/
     public static Collection getServerContext()
-       throws ServerNotActiveException
-    {
-       Collection context = (Collection) state.get();
-       if (context == null) {
-           for (int i = 0; i < providers.length; i++) {
-               if ((context = providers[i].getServerContext()) != null) {
-                   break;
-               }
-           }
-       }
-       if (context == null) {
-           throw new ServerNotActiveException("not in remote call");
-       }
-       return context;
+            throws ServerNotActiveException {
+        Collection context = (Collection) state.get();
+        if (context == null) {
+            for (int i = 0; i < getProviders().length; i++) {
+                if ((context = getProviders()[i].getServerContext()) != null) {
+                    break;
+                }
+            }
+        }
+        if (context == null) {
+            throw new ServerNotActiveException("not in remote call");
+        }
+        return context;
     }
 
     /**
@@ -176,22 +180,23 @@ public final class ServerContext {
      * call to {@link ServerContext#doWithServerContext}.
      */
     public interface Spi {
-       /**
-        * Returns a server context collection for the current thread, or
-        * <code>null</code> if provider does not contain context for the
-        * current thread.
-        * 
-        * <p>The context information available from a given element of
-        * the collection is determined by that element's type.  The order
-        * of the elements is insignificant.  The collection may be empty.
-        *
-        * <p>The caller of this method cannot assume that the returned
-        * collection is modifiable.
-        *
-        * @return  the server context for the current thread,
-        *          or <code>null</code> if none known
-        */
-       Collection getServerContext();
+
+        /**
+         * Returns a server context collection for the current thread, or
+         * <code>null</code> if provider does not contain context for the
+         * current thread.
+         * 
+         * <p>The context information available from a given element of
+         * the collection is determined by that element's type.  The order
+         * of the elements is insignificant.  The collection may be empty.
+         *
+         * <p>The caller of this method cannot assume that the returned
+         * collection is modifiable.
+         *
+         * @return  the server context for the current thread,
+         *         or <code>null</code> if none known
+         */
+        Collection getServerContext();
     }
 
     /**
@@ -209,16 +214,15 @@ public final class ServerContext {
      *         the current thread
      **/
     public static Object getServerContextElement(Class type)
-       throws ServerNotActiveException
-    {
-       Collection context = getServerContext();
-       Iterator iter = context.iterator();
-       while (iter.hasNext()) {
-           Object elem = iter.next();
-           if (elem != null && type.isAssignableFrom(elem.getClass())) {
-               return elem;
-           }
-       }
-       return null;
-    }  
+            throws ServerNotActiveException {
+        Collection context = getServerContext();
+        Iterator iter = context.iterator();
+        while (iter.hasNext()) {
+            Object elem = iter.next();
+            if (elem != null && type.isAssignableFrom(elem.getClass())) {
+                return elem;
+            }
+        }
+        return null;
+    }
 }


Reply via email to