Author: bdaw
Date: 2007-09-05 06:46:01 -0400 (Wed, 05 Sep 2007)
New Revision: 8171
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/portlet.xml
Log:
JBPORTAL-1535 - Make GG xml retrieval timeout parameterizable
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-09-05
02:41:25 UTC (rev 8170)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/WidgetPortlet.java 2007-09-05
10:46:01 UTC (rev 8171)
@@ -44,20 +44,37 @@
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss dot
com">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
public class WidgetPortlet extends GenericPortlet
{
+ private static final org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(WidgetPortlet.class);
+ public final static String INIT_PARAM_CONNECTION_TIMEOUT =
"connectionTimeout";
+
/** . */
private final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
/** . */
private GGProvider provider = new GGProvider();
+
public void init() throws PortletException
{
provider.start();
+ String timeout =
getPortletConfig().getInitParameter(INIT_PARAM_CONNECTION_TIMEOUT);
+ if (timeout != null && timeout.length() > 0)
+ {
+ try
+ {
+ provider.setConnectionTimeout(Integer.parseInt(timeout));
+ }
+ catch (NumberFormatException e)
+ {
+ log.error("Failed to parse connectionTimeout init parameter - should be
integer number: ", e);
+ }
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java 2007-09-05
02:41:25 UTC (rev 8170)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGProvider.java 2007-09-05
10:46:01 UTC (rev 8171)
@@ -45,6 +45,7 @@
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss dot
com">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
public class GGProvider
@@ -63,6 +64,9 @@
private ExecutorService executor;
/** . */
+ private int connectionTimeout = 500;
+
+ /** . */
private static final Collection CATEGORIES = Collections.unmodifiableList(new
CollectionBuilder()
.add(new GGWidgetCategoryInfo("all", "Popular"))
.add(new GGWidgetCategoryInfo("news", "News"))
@@ -169,6 +173,17 @@
return widgets;
}
+
+ public int getConnectionTimeout()
+ {
+ return connectionTimeout;
+ }
+
+ public void setConnectionTimeout(int connectionTimeout)
+ {
+ this.connectionTimeout = connectionTimeout;
+ }
+
private class GGWidgetEntry implements Callable
{
@@ -265,7 +280,7 @@
public Object call() throws MalformedURLException
{
- return new GGQueryResultBuilder(query).build();
+ return new GGQueryResultBuilder(query, getConnectionTimeout()).build();
}
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-09-05
02:41:25 UTC (rev 8170)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/google/provider/GGQueryResultBuilder.java 2007-09-05
10:46:01 UTC (rev 8171)
@@ -52,6 +52,7 @@
* @todo make the timeouts parameterizable
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss dot
com">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
public class GGQueryResultBuilder
@@ -65,7 +66,7 @@
/** . */
private final URL url;
- public GGQueryResultBuilder(GGQuery query) throws MalformedURLException
+ public GGQueryResultBuilder(GGQuery query, int connectionTimeout) throws
MalformedURLException
{
if (query == null)
{
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/portlet.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/portlet.xml 2007-09-05
02:41:25 UTC (rev 8170)
+++
branches/JBoss_Portal_Branch_2_6/widget/src/resources/widget-war/WEB-INF/portlet.xml 2007-09-05
10:46:01 UTC (rev 8171)
@@ -32,6 +32,11 @@
<portlet-name>GoogleWidgetPortlet</portlet-name>
<display-name>Google Widget Portlet</display-name>
<portlet-class>org.jboss.portal.widget.WidgetPortlet</portlet-class>
+ <init-param>
+ <description>Connection timeout when retreiving gadgets from google
directory</description>
+ <name>connectionTimeout</name>
+ <value>500</value>
+ </init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
Show replies by date