You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2012/07/19 17:12:09 UTC

svn commit: r1363370 - /manifoldcf/branches/CONNECTORS-488/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java

Author: kwright
Date: Thu Jul 19 15:12:09 2012
New Revision: 1363370

URL: http://svn.apache.org/viewvc?rev=1363370&view=rev
Log:
Infrastructure for controlling caching parameters by configuration.

Modified:
    manifoldcf/branches/CONNECTORS-488/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java

Modified: manifoldcf/branches/CONNECTORS-488/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-488/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java?rev=1363370&r1=1363369&r2=1363370&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-488/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java (original)
+++ manifoldcf/branches/CONNECTORS-488/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java Thu Jul 19 15:12:09 2012
@@ -67,6 +67,11 @@ public class MeridioAuthority extends or
   private String UserName = null;
   private String Password = null;
 
+  private String cacheLifetime = null;
+  private String cacheLRUsize = null;
+  private long responseLifetime = 60000L;
+  private int LRUsize = 1000;
+
   /** Cache manager. */
   protected ICacheManager cacheManager = null;
   
@@ -125,12 +130,29 @@ public class MeridioAuthority extends or
     UserName = configParams.getParameter("UserName");
     Password = configParams.getObfuscatedParameter("Password");
 
+    cacheLifetime = configParams.getParameter("CacheLifetimeMins");
+    if (cacheLifetime == null)
+      cacheLifetime = "1";
+    cacheLRUsize = configParams.getParameter("CacheLRUSize");
+    if (cacheLRUsize == null)
+      cacheLRUsize = "1000";    
+
   }
 
   /** Set up connection before attempting to use it */
   protected void attemptToConnect()
     throws ManifoldCFException
   {
+    try
+    {
+      responseLifetime = Long.parseLong(this.cacheLifetime) * 60L * 1000L;
+      LRUsize = Integer.parseInt(this.cacheLRUsize);
+    }
+    catch (NumberFormatException e)
+    {
+      throw new ManifoldCFException("Cache lifetime or Cache LRU size must be an integer: "+e.getMessage(),e);
+    }
+
     if (meridio_ == null)
     {
 
@@ -437,6 +459,8 @@ public class MeridioAuthority extends or
       MetaCartaWSProxyPort = null;
       UserName = null;
       Password = null;
+      cacheLifetime = null;
+      cacheLRUsize = null;
     }
     Logging.authorityConnectors.debug("Meridio: Exiting 'disconnect' method");
   }
@@ -455,7 +479,8 @@ public class MeridioAuthority extends or
     ICacheDescription objectDescription = new AuthorizationResponseDescription(userName,
       DmwsURL.toString(),RmwsURL.toString(),MetaCartawsURL.toString(),
       DMWSProxyHost,DMWSProxyPort,RMWSProxyHost,RMWSProxyPort,
-      MetaCartaWSProxyHost,MetaCartaWSProxyPort,this.UserName,this.Password);
+      MetaCartaWSProxyHost,MetaCartaWSProxyPort,this.UserName,this.Password,
+      responseLifetime,LRUsize);
     
     // Enter the cache
     ICacheHandle ch = cacheManager.enterCache(new ICacheDescription[]{objectDescription},null,null);
@@ -1312,8 +1337,6 @@ public class MeridioAuthority extends or
     );
   }
 
-  protected static long responseLifetime = 60000L;
-  protected static int LRUsize = 1000;
   protected static StringSet emptyStringSet = new StringSet();
   
   /** This is the cache object descriptor for cached access tokens from
@@ -1337,13 +1360,16 @@ public class MeridioAuthority extends or
     protected String adminUserName;
     protected String adminPassword;
 
+    protected long responseLifetime;
+    
     /** The expiration time */
     protected long expirationTime = -1;
     
     /** Constructor. */
     public AuthorizationResponseDescription(String userName, String DmwsURL, String RmwsURL, String wsURL,
       String DMWSProxyHost, String DMWSProxyPort, String RMWSProxyHost, String RMWSProxyPort,
-      String wsProxyHost, String wsProxyPort, String adminUserName, String adminPassword)
+      String wsProxyHost, String wsProxyPort, String adminUserName, String adminPassword,
+      long responseLifetime, int LRUsize)
     {
       super("MeridioAuthority",LRUsize);
       this.userName = userName;
@@ -1358,6 +1384,7 @@ public class MeridioAuthority extends or
       this.wsProxyPort = wsProxyPort;
       this.adminUserName = adminUserName;
       this.adminPassword = adminPassword;
+      this.responseLifetime = responseLifetime;
     }
 
     /** Return the invalidation keys for this object. */