mx4j/src/core/mx4j/remote/resolver/iiop Resolver.java,1.2,1.3

Simone Bordet <[email protected]> Sat, 14 May 2005 10:14:53 +0000
Newsgroups gmane.comp.java.mx4j.cvs
Message-ID <[email protected]>
Update of /cvsroot/mx4j/mx4j/src/core/mx4j/remote/resolver/iiop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29039/src/core/mx4j/remote/resolver/iiop

Modified Files:
	Resolver.java 
Log Message:
Checking compliance of the ORB passed in the environment Map before calling JNDI

Index: Resolver.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/mx4j/remote/resolver/iiop/Resolver.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Resolver.java	18 Mar 2005 10:17:08 -0000	1.2
--- Resolver.java	14 May 2005 10:14:51 -0000	1.3
***************
*** 39,42 ****
--- 39,47 ----
  // CLIENT METHODS
  
+    protected RMIServer lookupStubInJNDI(JMXServiceURL url, Map environment) throws IOException
+    {
+       checkORB(environment);
+       return super.lookupStubInJNDI(url, environment);
+    }
  
     protected RMIServer decodeStub(JMXServiceURL url, Map environment) throws IOException
***************
*** 104,107 ****
--- 109,125 ----
     }
  
+    private ORB checkORB(Map environment)
+    {
+       if (environment == null) return null;
+       Object candidateORB = environment.get(ORB_KEY);
+       if (candidateORB != null)
+       {
+          // Throw as required by the spec
+          if (!(candidateORB instanceof ORB)) throw new IllegalArgumentException("Property " + ORB_KEY + " must specify a " + ORB.class.getName() + ", not " + candidateORB.getClass().getName());
+          return (ORB)candidateORB;
+       }
+       return null;
+    }
+ 
     /**
      * Creates a new ORB, if not already created.
***************
*** 112,123 ****
        if (orb == null)
        {
!          Object candidateORB = environment.get(ORB_KEY);
!          if (candidateORB != null)
!          {
!             // Throw as required by the spec
!             if (!(candidateORB instanceof ORB)) throw new IllegalArgumentException("Property " + ORB_KEY + " must specify a " + ORB.class.getName() + ", not " + candidateORB.getClass().getName());
!             orb = (ORB)candidateORB;
!          }
!          else
           {
              Properties props = new Properties();
--- 130,135 ----
        if (orb == null)
        {
!          orb = checkORB(environment);
!          if (orb == null)
           {
              Properties props = new Properties();



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click