changed code for reading in sql vars, and synchronously creating hrf
authorblk <blk@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 25 Jun 2002 03:35:52 +0000 (03:35 +0000)
committerblk <blk@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 25 Jun 2002 03:35:52 +0000 (03:35 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@186 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/hs/ClubShibSQLHandleRepository.java
src/edu/internet2/middleware/shibboleth/hs/HandleServlet.java

index 039a7ae..5b52cb2 100755 (executable)
@@ -2,6 +2,7 @@ package edu.internet2.middleware.shibboleth.hs;
 
 import java.util.*;
 import java.sql.*;
+import javax.servlet.*;
 import javax.servlet.http.*;
 
 public class ClubShibSQLHandleRepository extends HandleRepositoryFactory{
@@ -17,10 +18,12 @@ public class ClubShibSQLHandleRepository extends HandleRepositoryFactory{
     public ClubShibSQLHandleRepository(HttpServlet HS) 
        throws HandleException 
     {
-       DBdriver = HS.getInitParameter("DBdriver");
-       DBuser = HS.getInitParameter("DBuser");
-       DBpass = HS.getInitParameter("DBpass");
-       DBdomain = HS.getInitParameter("DBdomain");
+       ServletConfig sc = HS.getServletConfig();
+       ServletContext sctx = sc.getServletContext();
+       DBdriver = sctx.getInitParameter("DBdriver");
+       DBuser = sctx.getInitParameter("DBuser");
+       DBpass = sctx.getInitParameter("DBpass");
+       DBdomain = sctx.getInitParameter("DBdomain");
        DBurl = "jdbc:mysql://"+DBdomain+"/shib"+
            "?user="+DBuser+"&password="+DBpass+"&autoReconnect=true";
            
index 5f95b0f..513fffb 100644 (file)
@@ -43,11 +43,7 @@ public class HandleServlet extends HttpServlet {
                                            is );
            
            log.info("HS: Initializing Handle Repository with "+rep+" repository type.");
-           System.err.println("HS: Initializing Handle Repository with "+rep+" repository type.");
-           hrf = HandleRepositoryFactory.getInstance
-               ( Constants.POLICY_CLUBSHIB, 
-                 rep,
-                 this );
+           hrf = getHandleRepository();
        }
        catch (SAMLException ex) {
            log.fatal("Error initializing SAML libraries: "+ ex);
@@ -224,6 +220,29 @@ public class HandleServlet extends HttpServlet {
            throw new HandleException("Unable to obtain client address.");
        }    
     }
+
+
+    private synchronized HandleRepositoryFactory getHandleRepository()
+       throws HandleException{
+
+       ServletConfig sc = getServletConfig();
+       ServletContext sctx = sc.getServletContext(); 
+       HandleRepositoryFactory hrf = (HandleRepositoryFactory)sctx.getAttribute("HandleRepository");
+
+       log.debug("Context attribute for HandleRepository: "+hrf);
+           
+       if(hrf == null){
+           // make one
+           String repositoryType = this.getServletContext().getInitParameter("repository");
+           hrf = HandleRepositoryFactory.getInstance(                                                Constants.POLICY_CLUBSHIB, 
+                                                                                                     repositoryType,
+                                                                                                     this );
+       }
+       return hrf;
+    }
+
+
 }
+