JBoss Portal SVN: r6595 - tags/JBoss_Portal_2_6_0_BETA1/build.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-03-07 19:00:42 -0500 (Wed, 07 Mar 2007)
New Revision: 6595
Modified:
tags/JBoss_Portal_2_6_0_BETA1/build/distrib.xml
Log:
correct packaging of cms
Modified: tags/JBoss_Portal_2_6_0_BETA1/build/distrib.xml
===================================================================
--- tags/JBoss_Portal_2_6_0_BETA1/build/distrib.xml 2007-03-08 00:00:23 UTC (rev 6594)
+++ tags/JBoss_Portal_2_6_0_BETA1/build/distrib.xml 2007-03-08 00:00:42 UTC (rev 6595)
@@ -192,7 +192,7 @@
<copy todir="${portal.build.normal.bin}/jboss-portal.sar">
<fileset dir="${source.dir}/core/output/resources/jboss-portal.sar"/>
</copy>
- <copy todir="${portal.build.ha.bin}/jboss-portal.sar/portal-cms.sar">
+ <copy todir="${portal.build.normal.bin}/jboss-portal.sar/portal-cms.sar">
<fileset dir="${source.dir}/core-cms/output/resources/portal-cms.sar" includes="**"/>
</copy>
<copy todir="${portal.build.normal.bin}/jboss-portal.sar">
17 years, 4 months
JBoss Portal SVN: r6594 - trunk/build.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-03-07 19:00:23 -0500 (Wed, 07 Mar 2007)
New Revision: 6594
Modified:
trunk/build/distrib.xml
Log:
correct packaging of cms
Modified: trunk/build/distrib.xml
===================================================================
--- trunk/build/distrib.xml 2007-03-07 23:42:08 UTC (rev 6593)
+++ trunk/build/distrib.xml 2007-03-08 00:00:23 UTC (rev 6594)
@@ -193,7 +193,7 @@
<copy todir="${portal.build.normal.bin}/jboss-portal.sar">
<fileset dir="${source.dir}/core/output/resources/jboss-portal.sar"/>
</copy>
- <copy todir="${portal.build.ha.bin}/jboss-portal.sar/portal-cms.sar">
+ <copy todir="${portal.build.normal.bin}/jboss-portal.sar/portal-cms.sar">
<fileset dir="${source.dir}/core-cms/output/resources/portal-cms.sar" includes="**"/>
</copy>
<copy todir="${portal.build.normal.bin}/jboss-portal.sar">
17 years, 4 months
JBoss Portal SVN: r6593 - tags/JBoss_Portal_2_6_0_BETA1/build.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-03-07 18:42:08 -0500 (Wed, 07 Mar 2007)
New Revision: 6593
Modified:
tags/JBoss_Portal_2_6_0_BETA1/build/distrib.xml
Log:
correct packaging of portal-admin.sar
Modified: tags/JBoss_Portal_2_6_0_BETA1/build/distrib.xml
===================================================================
--- tags/JBoss_Portal_2_6_0_BETA1/build/distrib.xml 2007-03-07 23:41:43 UTC (rev 6592)
+++ tags/JBoss_Portal_2_6_0_BETA1/build/distrib.xml 2007-03-07 23:42:08 UTC (rev 6593)
@@ -198,7 +198,7 @@
<copy todir="${portal.build.normal.bin}/jboss-portal.sar">
<fileset dir="${source.dir}/core-samples/output/resources" includes="portal-samples.sar/**"/>
<fileset dir="${source.dir}/core-management/output/resources" includes="portal-management.sar/**"/>
- <fileset dir="${source.dir}/core-admin/output/resources" includes="portal-admin.war/**"/>
+ <fileset dir="${source.dir}/core-admin/output/resources" includes="portal-admin.sar/**"/>
</copy>
<!--
<mkdir dir="${portal.build.normal.bin}/jboss-portal.sar/portal-wsrp.sar"/>
@@ -225,7 +225,7 @@
<copy todir="${portal.build.ha.bin}/jboss-portal-ha.sar">
<fileset dir="${source.dir}/core-samples/output/resources" includes="portal-samples.sar/**"/>
<fileset dir="${source.dir}/core-management/output/resources" includes="portal-management.sar/**"/>
- <fileset dir="${source.dir}/core-admin/output/resources" includes="portal-admin.war/**"/>
+ <fileset dir="${source.dir}/core-admin/output/resources" includes="portal-admin.sar/**"/>
</copy>
<!--
<mkdir dir="${portal.build.ha.bin}/jboss-portal-ha.sar/portal-wsrp.sar"/>
17 years, 4 months
JBoss Portal SVN: r6592 - trunk/build.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-03-07 18:41:43 -0500 (Wed, 07 Mar 2007)
New Revision: 6592
Modified:
trunk/build/distrib.xml
Log:
correct packaging of portal-admin.sar
Modified: trunk/build/distrib.xml
===================================================================
--- trunk/build/distrib.xml 2007-03-07 22:59:39 UTC (rev 6591)
+++ trunk/build/distrib.xml 2007-03-07 23:41:43 UTC (rev 6592)
@@ -75,7 +75,8 @@
</target>
<!-- Build JBoss Portal documentation -->
- <target name="doc.build">
+ <target name="doc.build"> <!-- Normal build -->
+ <ant dir="${source.dir}/build" antfile="build.xml"/>
<ant dir="${source.dir}-docs/referenceGuide" antfile="build.xml"/>
<ant dir="${source.dir}-docs/userGuide" antfile="build.xml"/>
<ant dir="${source.dir}-docs/quickstartuser" antfile="build.xml"/>
@@ -198,7 +199,7 @@
<copy todir="${portal.build.normal.bin}/jboss-portal.sar">
<fileset dir="${source.dir}/core-samples/output/resources" includes="portal-samples.sar/**"/>
<fileset dir="${source.dir}/core-management/output/resources" includes="portal-management.sar/**"/>
- <fileset dir="${source.dir}/core-admin/output/resources" includes="portal-admin.war/**"/>
+ <fileset dir="${source.dir}/core-admin/output/resources" includes="portal-admin.sar/**"/>
</copy>
<!--
<mkdir dir="${portal.build.normal.bin}/jboss-portal.sar/portal-wsrp.sar"/>
@@ -225,7 +226,7 @@
<copy todir="${portal.build.ha.bin}/jboss-portal-ha.sar">
<fileset dir="${source.dir}/core-samples/output/resources" includes="portal-samples.sar/**"/>
<fileset dir="${source.dir}/core-management/output/resources" includes="portal-management.sar/**"/>
- <fileset dir="${source.dir}/core-admin/output/resources" includes="portal-admin.war/**"/>
+ <fileset dir="${source.dir}/core-admin/output/resources" includes="portal-admin.sar/**"/>
</copy>
<!--
<mkdir dir="${portal.build.ha.bin}/jboss-portal-ha.sar/portal-wsrp.sar"/>
17 years, 4 months
JBoss Portal SVN: r6591 - in trunk/build/ide/intellij/idea60/modules: widget and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-07 17:59:39 -0500 (Wed, 07 Mar 2007)
New Revision: 6591
Modified:
trunk/build/ide/intellij/idea60/modules/common/common.iml
trunk/build/ide/intellij/idea60/modules/widget/widget.iml
Log:
updates to idea project files
Modified: trunk/build/ide/intellij/idea60/modules/common/common.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/common/common.iml 2007-03-07 22:58:37 UTC (rev 6590)
+++ trunk/build/ide/intellij/idea60/modules/common/common.iml 2007-03-07 22:59:39 UTC (rev 6591)
@@ -129,6 +129,24 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/apache-httpclient/lib/commons-httpclient.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/jboss/backport-concurrent/lib/jboss-backport-concurrent.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Modified: trunk/build/ide/intellij/idea60/modules/widget/widget.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/widget/widget.iml 2007-03-07 22:58:37 UTC (rev 6590)
+++ trunk/build/ide/intellij/idea60/modules/widget/widget.iml 2007-03-07 22:59:39 UTC (rev 6591)
@@ -29,6 +29,34 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module" module-name="api" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/apache-httpclient/lib/commons-httpclient.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/jboss/backport-concurrent/lib/jboss-backport-concurrent.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/apache-log4j/lib/log4j.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
17 years, 4 months
JBoss Portal SVN: r6590 - trunk/common/src/main/org/jboss/portal/test/common.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-07 17:58:37 -0500 (Wed, 07 Mar 2007)
New Revision: 6590
Modified:
trunk/common/src/main/org/jboss/portal/test/common/ObjectLoaderTestCase.java
Log:
improved a bit the test cases for object laoder
Modified: trunk/common/src/main/org/jboss/portal/test/common/ObjectLoaderTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/ObjectLoaderTestCase.java 2007-03-07 22:51:04 UTC (rev 6589)
+++ trunk/common/src/main/org/jboss/portal/test/common/ObjectLoaderTestCase.java 2007-03-07 22:58:37 UTC (rev 6590)
@@ -136,11 +136,25 @@
assertEquals(1, l2.loadCount);
//
- Object o3 = o_l.getObject(ctx, 1);
- assertEquals(o3, null);
+ o0 = o_l.getObject(ctx, 0);
+ assertEquals(o0, l0.o);
assertEquals(1, l0.loadCount);
assertEquals(1, l1.loadCount);
assertEquals(1, l2.loadCount);
+
+ //
+ o2 = o_l.getObject(ctx, 2);
+ assertEquals(o2, l2.o);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
+
+ //
+ o1 = o_l.getObject(ctx, 1);
+ assertEquals(o1, null);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
}
public void testLoadSync() throws Exception
@@ -173,12 +187,27 @@
assertEquals(1, l1.loadCount);
assertEquals(1, l2.loadCount);
+
//
- Object o3 = o_l.getObject(ctx, 1);
- assertEquals(o3, null);
+ o0 = o_l.getObject(ctx, 0);
+ assertEquals(o0, l0.o);
assertEquals(1, l0.loadCount);
assertEquals(1, l1.loadCount);
assertEquals(1, l2.loadCount);
+
+ //
+ o2 = o_l.getObject(ctx, 2);
+ assertEquals(o2, l2.o);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
+
+ //
+ o1 = o_l.getObject(ctx, 1);
+ assertEquals(o1, null);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
}
public void testLoadOne() throws Exception
17 years, 4 months
JBoss Portal SVN: r6589 - tags/JBoss_Portal_2_6_0_BETA1/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-03-07 17:51:04 -0500 (Wed, 07 Mar 2007)
New Revision: 6589
Removed:
tags/JBoss_Portal_2_6_0_BETA1/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db_old-beans.xml
Modified:
tags/JBoss_Portal_2_6_0_BETA1/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db-beans.xml
Log:
- corrected bug in identity 'db' testsuite
Modified: tags/JBoss_Portal_2_6_0_BETA1/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db-beans.xml
===================================================================
--- tags/JBoss_Portal_2_6_0_BETA1/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db-beans.xml 2007-03-07 22:44:51 UTC (rev 6588)
+++ tags/JBoss_Portal_2_6_0_BETA1/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db-beans.xml 2007-03-07 22:51:04 UTC (rev 6589)
@@ -72,7 +72,7 @@
</property>
</bean>
- <bean name="DBTestBean" class="org.jboss.portal.test.identity.db_old.DBUserTestCase">
+ <bean name="DBTestBean" class="org.jboss.portal.test.identity.db.DBIdentityTestCase">
<constructor factoryMethod="getBean">
<factory bean="BeanFactory"/>
<parameter>DBTestBean</parameter>
Deleted: tags/JBoss_Portal_2_6_0_BETA1/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db_old-beans.xml
===================================================================
--- tags/JBoss_Portal_2_6_0_BETA1/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db_old-beans.xml 2007-03-07 22:44:51 UTC (rev 6588)
+++ tags/JBoss_Portal_2_6_0_BETA1/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db_old-beans.xml 2007-03-07 22:51:04 UTC (rev 6589)
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ JBoss, a division of Red Hat ~
- ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
- ~ contributors as indicated by the @authors tag. See the ~
- ~ copyright.txt in the distribution for a full listing of ~
- ~ individual contributors. ~
- ~ ~
- ~ This is free software; you can redistribute it and/or modify it ~
- ~ under the terms of the GNU Lesser General Public License as ~
- ~ published by the Free Software Foundation; either version 2.1 of ~
- ~ the License, or (at your option) any later version. ~
- ~ ~
- ~ This software is distributed in the hope that it will be useful, ~
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
- ~ Lesser General Public License for more details. ~
- ~ ~
- ~ You should have received a copy of the GNU Lesser General Public ~
- ~ License along with this software; if not, write to the Free ~
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
- ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-
-<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
- xmlns="urn:jboss:bean-deployer">
-
- <bean name="DataSourceConfig" class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>DataSourceConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="HibernateConfig" class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>HibernateConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="JNDISupport" class="org.jboss.portal.test.framework.embedded.JNDISupport">
- </bean>
-
- <bean name="TransactionManagerSupport" class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
- </bean>
-
- <bean name="ConnectionManagerSupport" class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
- <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
- </bean>
-
- <bean name="DataSourceSupport" class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
- <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
- <property name="connectionManagerReference"><inject bean="ConnectionManagerSupport" property="connectionManagerReference"/></property>
- <property name="config"><inject bean="DataSourceConfig"/></property>
- </bean>
-
- <bean name="HibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
- <property name="config"><inject bean="HibernateConfig"/></property>
- <property name="jNDIName">java:/SessionFactory</property>
- <property name="mappings">
- <list elementClass="java.lang.String">
- <value>domain-single.hbm.xml</value>
- </list>
- </property>
- </bean>
-
- <bean name="DBTestBean" class="org.jboss.portal.test.identity.db_old.DBUserTestCase">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>DBTestBean</parameter>
- </constructor>
- <property name="hibernate"><inject bean="HibernateSupport"/></property>
- </bean>
-
-</deployment>
17 years, 4 months
JBoss Portal SVN: r6588 - trunk/common.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-07 17:44:51 -0500 (Wed, 07 Mar 2007)
New Revision: 6588
Modified:
trunk/common/build.xml
Log:
uncomment the test cases I had just commited as comments
Modified: trunk/common/build.xml
===================================================================
--- trunk/common/build.xml 2007-03-07 22:44:19 UTC (rev 6587)
+++ trunk/common/build.xml 2007-03-07 22:44:51 UTC (rev 6588)
@@ -204,7 +204,6 @@
<x-test>
<test todir="${test.reports}" name="org.jboss.portal.test.common.ObjectLoaderTestCase"/>
-<!--
<test todir="${test.reports}" name="org.jboss.portal.test.common.MarkupTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.common.TypedMapTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.common.test.InfoTestCase"/>
@@ -232,7 +231,6 @@
<test todir="${test.reports}" name="org.jboss.portal.test.common.CopyOnWriteRegistryTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.common.URLToolsTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.common.ToolsTestCase"/>
--->
</x-test>
<x-classpath>
<pathelement location="${build.classes}"/>
17 years, 4 months
JBoss Portal SVN: r6587 - in trunk: common/src/main/org/jboss/portal/common/concurrent and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-07 17:44:19 -0500 (Wed, 07 Mar 2007)
New Revision: 6587
Added:
trunk/common/src/main/org/jboss/portal/common/concurrent/loader/
trunk/common/src/main/org/jboss/portal/common/concurrent/loader/LoaderContext.java
trunk/common/src/main/org/jboss/portal/common/concurrent/loader/LoadingPolicy.java
trunk/common/src/main/org/jboss/portal/common/concurrent/loader/ObjectBatch.java
trunk/common/src/main/org/jboss/portal/common/concurrent/loader/ObjectLoader.java
trunk/common/src/main/org/jboss/portal/test/common/ObjectLoaderTestCase.java
trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetBatch.java
Removed:
trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetRetrieval.java
Modified:
trunk/common/build.xml
trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetFactory.java
trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetProvider.java
Log:
- extracted batch loading stuff into common.concurrent as it can be reused in other places.
- also refactored the implementation to allow easy reuse
Modified: trunk/common/build.xml
===================================================================
--- trunk/common/build.xml 2007-03-07 22:33:06 UTC (rev 6586)
+++ trunk/common/build.xml 2007-03-07 22:44:19 UTC (rev 6587)
@@ -72,6 +72,7 @@
<path refid="apache.log4j.classpath"/>
<path refid="jboss.test.classpath"/>
<path refid="junit.junit.classpath"/>
+ <path refid="jboss/backport.concurrent.classpath"/>
<path refid="apache.httpclient.classpath"/>
<pathelement location="../tools/lib/cargo-core-uberjar-0.8.jar"/>
<pathelement location="../tools/lib/cargo-ant-0.8.jar"/>
@@ -202,6 +203,8 @@
-->
<x-test>
+ <test todir="${test.reports}" name="org.jboss.portal.test.common.ObjectLoaderTestCase"/>
+<!--
<test todir="${test.reports}" name="org.jboss.portal.test.common.MarkupTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.common.TypedMapTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.common.test.InfoTestCase"/>
@@ -229,6 +232,7 @@
<test todir="${test.reports}" name="org.jboss.portal.test.common.CopyOnWriteRegistryTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.common.URLToolsTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.common.ToolsTestCase"/>
+-->
</x-test>
<x-classpath>
<pathelement location="${build.classes}"/>
Added: trunk/common/src/main/org/jboss/portal/common/concurrent/loader/LoaderContext.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/concurrent/loader/LoaderContext.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/concurrent/loader/LoaderContext.java 2007-03-07 22:44:19 UTC (rev 6587)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.concurrent.loader;
+
+import edu.emory.mathcs.backport.java.util.concurrent.CompletionService;
+
+/**
+ * Defines contextual services used for object batch loading service.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LoaderContext
+{
+
+ /** . */
+ private final CompletionService completionService;
+
+ public LoaderContext(CompletionService completionService)
+ {
+ if (completionService == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.completionService = completionService;
+ }
+
+ public CompletionService getCompletionService()
+ {
+ return completionService;
+ }
+}
Added: trunk/common/src/main/org/jboss/portal/common/concurrent/loader/LoadingPolicy.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/concurrent/loader/LoadingPolicy.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/concurrent/loader/LoadingPolicy.java 2007-03-07 22:44:19 UTC (rev 6587)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.concurrent.loader;
+
+/**
+ * Defines the loading policy for an object batch.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LoadingPolicy
+{
+
+ /**
+ * When an attempt is made to load one object, all objects are loaded and the current thread waits
+ * until all objects have been either loaded or failed.
+ */
+ public static final LoadingPolicy LOAD_ALL_SYNC = new LoadingPolicy();
+
+ /**
+ * When an attempt is made to load one object, all objects are loaded but the current thread will
+ * only have to wait the object it is requesting.
+ */
+ public static final LoadingPolicy LOAD_ALL_ASYNC = new LoadingPolicy();
+
+ /**
+ * When an attempt is made to load object object, only the requested object will be loaded.
+ */
+ public static final LoadingPolicy LOAD_ONE = new LoadingPolicy();
+
+ private LoadingPolicy()
+ {
+ }
+}
Added: trunk/common/src/main/org/jboss/portal/common/concurrent/loader/ObjectBatch.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/concurrent/loader/ObjectBatch.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/concurrent/loader/ObjectBatch.java 2007-03-07 22:44:19 UTC (rev 6587)
@@ -0,0 +1,158 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.concurrent.loader;
+
+import edu.emory.mathcs.backport.java.util.concurrent.locks.Lock;
+import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
+import edu.emory.mathcs.backport.java.util.concurrent.Future;
+import edu.emory.mathcs.backport.java.util.concurrent.Callable;
+import edu.emory.mathcs.backport.java.util.concurrent.ExecutionException;
+
+/**
+ * Defines a batch of virtual objects.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ObjectBatch
+{
+
+ /** . */
+ private Lock lock = new ReentrantLock();
+
+ /** . */
+ private ObjectLoader[] objectLoaders;
+
+ /** . */
+ private LoadingPolicy policy;
+
+ /** . */
+ private Future[] futures;
+
+ public ObjectBatch(ObjectLoader[] objectLoaders, LoadingPolicy policy)
+ {
+ this.objectLoaders = objectLoaders;
+ this.policy = policy;
+ }
+
+ public int getSize()
+ {
+ return objectLoaders.length;
+ }
+
+ public Object getObject(final LoaderContext ctx, int index) throws InterruptedException
+ {
+
+ //
+ lock.lock();
+ try
+ {
+ if (futures == null)
+ {
+ futures = new Future[objectLoaders.length];
+ }
+ if (futures[index] == null)
+ {
+ if (policy == LoadingPolicy.LOAD_ONE)
+ {
+ futures[index] = ctx.getCompletionService().submit(new CallableImpl(index));
+ }
+ else
+ {
+ // Fill holes
+ for (int i = 0; i < objectLoaders.length; i++)
+ {
+ if (futures[i] == null)
+ {
+ futures[i] = ctx.getCompletionService().submit(new CallableImpl(i));
+ }
+ }
+
+ // Wait for all to be done
+ if (policy == LoadingPolicy.LOAD_ALL_SYNC)
+ {
+ for (int i = 0; i < futures.length; i++)
+ {
+ try
+ {
+ futures[i].get();
+ }
+ catch (ExecutionException e)
+ {
+ Throwable t = e.getCause();
+
+ //
+ if (t instanceof Error)
+ {
+ throw (Error)t;
+ }
+ else
+ {
+ throw new Error("Unexpected exception", t);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ lock.unlock();
+ }
+
+ //
+ try
+ {
+ return futures[index].get();
+ }
+ catch (ExecutionException e)
+ {
+ return null;
+ }
+ }
+
+ private class CallableImpl implements Callable
+ {
+
+ /** . */
+ private final int index;
+
+ public CallableImpl(int index)
+ {
+ this.index = index;
+ }
+
+ public Object call() throws Exception
+ {
+ try
+ {
+ return objectLoaders[index].load();
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+ }
+}
Added: trunk/common/src/main/org/jboss/portal/common/concurrent/loader/ObjectLoader.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/concurrent/loader/ObjectLoader.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/concurrent/loader/ObjectLoader.java 2007-03-07 22:44:19 UTC (rev 6587)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.concurrent.loader;
+
+/**
+ * Defines loading capabilities for an object.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ObjectLoader
+{
+ /**
+ * Loads an object or return null.
+ */
+ Object load();
+}
Added: trunk/common/src/main/org/jboss/portal/test/common/ObjectLoaderTestCase.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/test/common/ObjectLoaderTestCase.java (rev 0)
+++ trunk/common/src/main/org/jboss/portal/test/common/ObjectLoaderTestCase.java 2007-03-07 22:44:19 UTC (rev 6587)
@@ -0,0 +1,235 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.concurrent.loader.ObjectLoader;
+import org.jboss.portal.common.concurrent.loader.ObjectBatch;
+import org.jboss.portal.common.concurrent.loader.LoadingPolicy;
+import org.jboss.portal.common.concurrent.loader.LoaderContext;
+import edu.emory.mathcs.backport.java.util.concurrent.Executor;
+import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
+import edu.emory.mathcs.backport.java.util.concurrent.ExecutorCompletionService;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ObjectLoaderTestCase extends TestCase
+{
+
+ private static volatile int counter;
+
+ private abstract static class AbstractObjectLoader implements ObjectLoader
+ {
+ int loadCount;
+ }
+
+ private static class SimpleObjectLoader extends AbstractObjectLoader
+ {
+
+ /** . */
+ final Object o;
+
+ public SimpleObjectLoader()
+ {
+ this.o = null;
+ }
+
+ public SimpleObjectLoader(Object o)
+ {
+ if (o == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.o = o;
+ }
+
+ public synchronized Object load()
+ {
+ loadCount++;
+ return o;
+ }
+ }
+
+ private static class RuntimeExceptionObjectLoader extends AbstractObjectLoader
+ {
+ public synchronized Object load()
+ {
+ loadCount++;
+ throw new RuntimeException();
+ }
+ }
+
+ private static class ErrorObjectLoader extends AbstractObjectLoader
+ {
+ public synchronized Object load()
+ {
+ loadCount++;
+ throw new Error();
+ }
+ }
+
+ private Executor executor;
+
+
+ protected void setUp() throws Exception
+ {
+ executor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS, new LinkedBlockingQueue());
+ }
+
+ protected void tearDown() throws Exception
+ {
+ executor = null;
+ }
+
+ public void testLoadAsync() throws Exception
+ {
+ LoaderContext ctx = new LoaderContext(new ExecutorCompletionService(executor));
+ SimpleObjectLoader l0 = new SimpleObjectLoader(new Object());
+ RuntimeExceptionObjectLoader l1 = new RuntimeExceptionObjectLoader();
+ SimpleObjectLoader l2 = new SimpleObjectLoader();
+ AbstractObjectLoader[] loaders = new AbstractObjectLoader[]{l0,l1,l2};
+ ObjectBatch o_l = new ObjectBatch(loaders, LoadingPolicy.LOAD_ALL_SYNC);
+
+ //
+ Object o0 = o_l.getObject(ctx, 0);
+ assertEquals(o0, l0.o);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
+
+ //
+ Object o2 = o_l.getObject(ctx, 2);
+ assertEquals(o2, l2.o);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
+
+ //
+ Object o1 = o_l.getObject(ctx, 1);
+ assertEquals(o1, null);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
+
+ //
+ Object o3 = o_l.getObject(ctx, 1);
+ assertEquals(o3, null);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
+ }
+
+ public void testLoadSync() throws Exception
+ {
+ LoaderContext ctx = new LoaderContext(new ExecutorCompletionService(executor));
+ SimpleObjectLoader l0 = new SimpleObjectLoader(new Object());
+ RuntimeExceptionObjectLoader l1 = new RuntimeExceptionObjectLoader();
+ SimpleObjectLoader l2 = new SimpleObjectLoader();
+ AbstractObjectLoader[] loaders = new AbstractObjectLoader[]{l0,l1,l2};
+ ObjectBatch o_l = new ObjectBatch(loaders, LoadingPolicy.LOAD_ALL_SYNC);
+
+ //
+ Object o0 = o_l.getObject(ctx, 0);
+ assertEquals(o0, l0.o);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
+
+ //
+ Object o2 = o_l.getObject(ctx, 2);
+ assertEquals(o2, l2.o);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
+
+ //
+ Object o1 = o_l.getObject(ctx, 1);
+ assertEquals(o1, null);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
+
+ //
+ Object o3 = o_l.getObject(ctx, 1);
+ assertEquals(o3, null);
+ assertEquals(1, l0.loadCount);
+ assertEquals(1, l1.loadCount);
+ assertEquals(1, l2.loadCount);
+ }
+
+ public void testLoadOne() throws Exception
+ {
+ LoaderContext ctx = new LoaderContext(new ExecutorCompletionService(executor));
+ SimpleObjectLoader l0 = new SimpleObjectLoader(new Object());
+ RuntimeExceptionObjectLoader l1 = new RuntimeExceptionObjectLoader();
+ SimpleObjectLoader l2 = new SimpleObjectLoader();
+ AbstractObjectLoader[] loaders = new AbstractObjectLoader[]{l0,l1,l2};
+ ObjectBatch o_l = new ObjectBatch(loaders, LoadingPolicy.LOAD_ONE);
+
+ //
+ Object o0 = o_l.getObject(ctx, 0);
+ assertEquals(o0, l0.o);
+ assertEquals(1, loaders[0].loadCount);
+ assertEquals(0, loaders[1].loadCount);
+ assertEquals(0, loaders[2].loadCount);
+
+ //
+ Object o2 = o_l.getObject(ctx, 2);
+ assertEquals(o2, l2.o);
+ assertEquals(1, loaders[0].loadCount);
+ assertEquals(0, loaders[1].loadCount);
+ assertEquals(1, loaders[2].loadCount);
+
+ //
+ Object o1 = o_l.getObject(ctx, 1);
+ assertEquals(o1, null);
+ assertEquals(1, loaders[0].loadCount);
+ assertEquals(1, loaders[1].loadCount);
+ assertEquals(1, loaders[2].loadCount);
+
+ //
+ o0 = o_l.getObject(ctx, 0);
+ assertEquals(o0, l0.o);
+ assertEquals(1, loaders[0].loadCount);
+ assertEquals(1, loaders[1].loadCount);
+ assertEquals(1, loaders[2].loadCount);
+
+ //
+ o2 = o_l.getObject(ctx, 2);
+ assertEquals(o2, l2.o);
+ assertEquals(1, loaders[0].loadCount);
+ assertEquals(1, loaders[1].loadCount);
+ assertEquals(1, loaders[2].loadCount);
+
+ //
+ o1 = o_l.getObject(ctx, 1);
+ assertEquals(o1, null);
+ assertEquals(1, loaders[0].loadCount);
+ assertEquals(1, loaders[1].loadCount);
+ assertEquals(1, loaders[2].loadCount);
+ }
+}
Copied: trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetBatch.java (from rev 6579, trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetRetrieval.java)
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetBatch.java (rev 0)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetBatch.java 2007-03-07 22:44:19 UTC (rev 6587)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.widget.google;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.concurrent.loader.ObjectBatch;
+import org.jboss.portal.common.concurrent.loader.LoadingPolicy;
+import org.jboss.portal.common.concurrent.loader.LoaderContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GGWidgetBatch
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(GGWidgetBatch.class);
+
+ /** . */
+ private final ObjectBatch batch;
+
+ public GGWidgetBatch(GGWidgetFactory[] factories)
+ {
+ this.batch = new ObjectBatch(factories, LoadingPolicy.LOAD_ALL_ASYNC);
+ }
+
+ public int getSize()
+ {
+ return batch.getSize();
+ }
+
+ public GGWidget getWidget(LoaderContext loaderContext, int index)
+ {
+ try
+ {
+ return (GGWidget)batch.getObject(loaderContext, index);
+ }
+ catch (InterruptedException e)
+ {
+ return null;
+ }
+ }
+}
Modified: trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetFactory.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetFactory.java 2007-03-07 22:33:06 UTC (rev 6586)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetFactory.java 2007-03-07 22:44:19 UTC (rev 6587)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.util.XML;
import org.jboss.portal.common.util.LocalizedString;
import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.concurrent.loader.ObjectLoader;
import org.jboss.portal.widget.google.type.DataType;
import org.jboss.portal.widget.google.type.StringType;
import org.jboss.portal.widget.google.type.LocationType;
@@ -48,7 +49,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class GGWidgetFactory
+public class GGWidgetFactory implements ObjectLoader
{
/** . */
@@ -68,6 +69,22 @@
return url;
}
+
+ public Object load()
+ {
+ try
+ {
+ return create();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+
+ //
+ return null;
+ }
+ }
+
public GGWidget create() throws Exception
{
DocumentBuilderFactory factory = XML.getDocumentBuilderFactory();
Modified: trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetProvider.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetProvider.java 2007-03-07 22:33:06 UTC (rev 6586)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetProvider.java 2007-03-07 22:44:19 UTC (rev 6587)
@@ -39,20 +39,21 @@
import org.jboss.portal.widget.WidgetProvider;
import org.jboss.portal.widget.Widget;
import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.common.concurrent.loader.ObjectBatch;
+import org.jboss.portal.common.concurrent.loader.ObjectLoader;
+import org.jboss.portal.common.concurrent.loader.LoadingPolicy;
+import org.jboss.portal.common.concurrent.loader.LoaderContext;
import org.apache.log4j.Logger;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.MutableAttributeSet;
-import edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
-import edu.emory.mathcs.backport.java.util.concurrent.Callable;
import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingDeque;
-import edu.emory.mathcs.backport.java.util.concurrent.locks.Lock;
-import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
+import edu.emory.mathcs.backport.java.util.concurrent.ExecutorCompletionService;
/**
* @todo first :
@@ -77,61 +78,53 @@
private static final Logger log = Logger.getLogger(GGWidgetProvider.class);
/** . */
- private volatile FutureTask future;
+ private ObjectBatch batch;
/** . */
- private final Lock lock = new ReentrantLock();
+ private ExecutorService executor;
/** . */
- private final ExecutorService executor = new ThreadPoolExecutor(3, 3, 0, TimeUnit.SECONDS, new LinkedBlockingDeque());
+ private LoaderContext loaderContext;
+ public GGWidgetProvider()
+ {
+ }
+
public void start()
{
+ executor = new ThreadPoolExecutor(4, 4, 0, TimeUnit.SECONDS, new LinkedBlockingDeque());
+ loaderContext = new LoaderContext(new ExecutorCompletionService(executor));
+ batch = new ObjectBatch(new ObjectLoader[]{new WidgetBuilder()}, LoadingPolicy.LOAD_ONE);
}
public void stop()
{
executor.shutdownNow();
+ executor = null;
+ loaderContext = null;
+ batch = null;
}
private Map getMap()
{
try
{
- lock.lock();
- try
- {
- if (future == null)
- {
- future = new FutureTask(new Callable()
- {
- public Object call() throws Exception
- {
- WidgetBuilder map = new WidgetBuilder();
- map.start();
- return map;
- }
- });
- executor.execute(future);
- }
- }
- finally
- {
- lock.unlock();
- }
- WidgetBuilder wmap = (WidgetBuilder)future.get();
- return wmap.map;
+ return (Map)batch.getObject(loaderContext, 0);
}
- catch (Exception e)
+ catch (InterruptedException e)
{
- e.printStackTrace();
- return Collections.EMPTY_MAP;
+ return null;
}
}
public Collection getKeys()
{
- return getMap().keySet();
+ Map map = getMap();
+ if (map == null)
+ {
+ return Collections.EMPTY_SET;
+ }
+ return map.keySet();
}
public Widget getWidget(String key)
@@ -140,14 +133,25 @@
{
throw new IllegalArgumentException();
}
- Map tmp = getMap();
- GGWidgetRetrieval.List retrievals = (GGWidgetRetrieval.List)tmp.get(key);
- if (retrievals != null)
+
+ //
+ Map map = getMap();
+ if (map == null)
{
- GGWidgetRetrieval retrieval = retrievals.getRetrieval(key);
- if (retrieval.getStatus() == GGWidgetRetrieval.AVAILABLE)
+ return null;
+ }
+
+ //
+ GGWidgetBatch batch = (GGWidgetBatch)map.get(key);
+ if (batch != null)
+ {
+ for (int i = 0;i < batch.getSize();i++)
{
- return retrieval.getWidget();
+ GGWidget widget = batch.getWidget(loaderContext, i);
+ if (widget != null && widget.getId().equals(key))
+ {
+ return widget;
+ }
}
}
@@ -155,13 +159,10 @@
return null;
}
- private class WidgetBuilder
+ private class WidgetBuilder implements ObjectLoader
{
- /** . */
- private Map map;
-
- public void start()
+ public Object load()
{
try
{
@@ -244,12 +245,13 @@
}
else
{
- GGWidgetRetrieval.List retrievals = new GGWidgetRetrieval.List(executor, tmp);
- for (int j = 0;j < retrievals.getSize();j++)
+ GGWidgetFactory[] factories = (GGWidgetFactory[])tmp.toArray(new GGWidgetFactory[tmp.size()]);
+ GGWidgetBatch retrievals = new GGWidgetBatch(factories);
+ for (int j = 0;j < factories.length;j++)
{
- GGWidgetFactory t = retrievals.getFactory(j);
- map.put(t.getURL().toString(), retrievals);
- log.info("Added widget for later retrieval" + t.getURL());
+ String furl = factories[j].getURL().toString();
+ map.put(furl, retrievals);
+ log.info("Added widget for later retrieval" + furl);
}
//
@@ -259,11 +261,12 @@
}
//
- this.map = Collections.unmodifiableMap(map);
+ return Collections.unmodifiableMap(map);
}
catch (Exception e)
{
e.printStackTrace();
+ return null;
}
}
}
Deleted: trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetRetrieval.java
===================================================================
--- trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetRetrieval.java 2007-03-07 22:33:06 UTC (rev 6586)
+++ trunk/widget/src/main/org/jboss/portal/widget/google/GGWidgetRetrieval.java 2007-03-07 22:44:19 UTC (rev 6587)
@@ -1,202 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.widget.google;
-
-import edu.emory.mathcs.backport.java.util.concurrent.FutureTask;
-import edu.emory.mathcs.backport.java.util.concurrent.Callable;
-import edu.emory.mathcs.backport.java.util.concurrent.CompletionService;
-import edu.emory.mathcs.backport.java.util.concurrent.ExecutorCompletionService;
-import edu.emory.mathcs.backport.java.util.concurrent.Future;
-import edu.emory.mathcs.backport.java.util.concurrent.Executor;
-import edu.emory.mathcs.backport.java.util.concurrent.locks.Lock;
-import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
-
-import java.util.Collection;
-
-import org.apache.log4j.Logger;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class GGWidgetRetrieval
-{
-
- /** . */
- private static final Logger log = Logger.getLogger(GGWidgetRetrieval.class);
-
- /** . */
- public static int UNAVAILABLE = 0;
-
- /** . */
- public static int AVAILABLE = 1;
-
- /** . */
- private GGWidget widget;
-
- public GGWidgetRetrieval(GGWidget widget)
- {
- this.widget = widget;
- }
-
- public GGWidget getWidget() throws IllegalStateException
- {
- if (widget == null)
- {
- throw new IllegalStateException("Widget not available");
- }
- return widget;
- }
-
- public int getStatus()
- {
- return widget != null ? AVAILABLE : UNAVAILABLE;
- }
-
- public static class List
- {
-
- /** . */
- private final GGWidgetFactory[] factories;
-
- /** . */
- private final Executor executor;
-
- /** . */
- private final Lock lock = new ReentrantLock();
-
- /** . */
- private FutureTask future;
-
- public List(Executor executor, Collection c)
- {
- this.executor = executor;
- this.factories = (GGWidgetFactory[])c.toArray(new GGWidgetFactory[c.size()]);
- }
-
- public int getSize()
- {
- return factories.length;
- }
-
- public GGWidgetFactory getFactory(int index)
- {
- return factories[index];
- }
-
- public GGWidgetRetrieval getRetrieval(String key)
- {
- for (int i = 0;i < factories.length;i++)
- {
- GGWidgetFactory factory = factories[i];
- if (key.equals(factory.getURL().toString()))
- {
- return getRetrieval(i);
- }
- }
- return null;
- }
-
- private class Fetcher implements Callable
- {
-
- /** . */
- private final int index;
-
- /** . */
- private GGWidgetRetrieval retrieval;
-
- public Fetcher(int index)
- {
- this.index = index;
- }
-
- public Object call() throws Exception
- {
- GGWidgetFactory factory = factories[index];
- try
- {
- log.info("Creating widget " + factory.getURL());
- GGWidget widget = factory.create();
- retrieval = new GGWidgetRetrieval(widget);
- }
- catch (Exception e)
- {
- log.error("Widget " + factory.getURL() + " was not retrievable", e);
- retrieval = new GGWidgetRetrieval(null);
- }
- return this;
- }
- }
-
- public GGWidgetRetrieval getRetrieval(int index)
- {
- //
- lock.lock();
- try
- {
- if (future == null)
- {
- future = new FutureTask(new Callable()
- {
- public Object call() throws Exception
- {
- log.info("Creating widget batch");
- CompletionService completionService = new ExecutorCompletionService(executor);
- for (int i = 0; i < factories.length; i++)
- {
- completionService.submit(new Fetcher(i));
- }
- GGWidgetRetrieval[] retrievals = new GGWidgetRetrieval[factories.length];
- for (int i = 0; i < factories.length; i++)
- {
- Future future = completionService.take();
- Fetcher fetcher = (Fetcher)future.get();
- retrievals[fetcher.index] = fetcher.retrieval;
- }
- return retrievals;
- }
- });
- executor.execute(future);
- }
- }
- finally
- {
- lock.unlock();
- }
-
- try
- {
- //
- GGWidgetRetrieval[] retrievals = (GGWidgetRetrieval[])future.get();
-
- //
- return retrievals[index];
- }
- catch (Exception e)
- {
- return new GGWidgetRetrieval(null);
- }
- }
- }
-}
17 years, 4 months
JBoss Portal SVN: r6586 - in trunk/identity: src/main/org/jboss/portal/identity and 1 other directories.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-03-07 17:33:06 -0500 (Wed, 07 Mar 2007)
New Revision: 6586
Removed:
trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db_old-beans.xml
Modified:
trunk/identity/build.xml
trunk/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java
trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db-beans.xml
Log:
- corrected bug in identity 'db' testsuite
Modified: trunk/identity/build.xml
===================================================================
--- trunk/identity/build.xml 2007-03-07 22:08:39 UTC (rev 6585)
+++ trunk/identity/build.xml 2007-03-07 22:33:06 UTC (rev 6586)
@@ -452,9 +452,9 @@
<x-test>
- <!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.db.DBIdentityTestCase"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPIdentityTestCase"/>-->
- <test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPSimpleUserModuleTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.identity.db.DBIdentityTestCase"/>
+ <!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPIdentityTestCase"/>-->
+ <!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPSimpleUserModuleTestCase"/>-->
<!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPSimpleRoleModuleTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPStaticGroupMembershipModuleTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPStaticRoleMembershipModuleTestCase"/>
Modified: trunk/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java 2007-03-07 22:08:39 UTC (rev 6585)
+++ trunk/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java 2007-03-07 22:33:06 UTC (rev 6586)
@@ -68,7 +68,7 @@
public static final String USER_PASSWORD_ATTRIBUTE_ID = "passwordAttributeID";
- public static final String USER_EMAIL_ATTRIBUTE_ID = "emailAttributeID";
+ //public static final String USER_EMAIL_ATTRIBUTE_ID = "emailAttributeID";
public static final String USER_CONTEXT_DN = "userCtxDN";
Modified: trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db-beans.xml
===================================================================
--- trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db-beans.xml 2007-03-07 22:08:39 UTC (rev 6585)
+++ trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db-beans.xml 2007-03-07 22:33:06 UTC (rev 6586)
@@ -72,7 +72,7 @@
</property>
</bean>
- <bean name="DBTestBean" class="org.jboss.portal.test.identity.db_old.DBUserTestCase">
+ <bean name="DBTestBean" class="org.jboss.portal.test.identity.db.DBIdentityTestCase">
<constructor factoryMethod="getBean">
<factory bean="BeanFactory"/>
<parameter>DBTestBean</parameter>
Deleted: trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db_old-beans.xml
===================================================================
--- trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db_old-beans.xml 2007-03-07 22:08:39 UTC (rev 6585)
+++ trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/db_old-beans.xml 2007-03-07 22:33:06 UTC (rev 6586)
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ JBoss, a division of Red Hat ~
- ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
- ~ contributors as indicated by the @authors tag. See the ~
- ~ copyright.txt in the distribution for a full listing of ~
- ~ individual contributors. ~
- ~ ~
- ~ This is free software; you can redistribute it and/or modify it ~
- ~ under the terms of the GNU Lesser General Public License as ~
- ~ published by the Free Software Foundation; either version 2.1 of ~
- ~ the License, or (at your option) any later version. ~
- ~ ~
- ~ This software is distributed in the hope that it will be useful, ~
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
- ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
- ~ Lesser General Public License for more details. ~
- ~ ~
- ~ You should have received a copy of the GNU Lesser General Public ~
- ~ License along with this software; if not, write to the Free ~
- ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
- ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-
-<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
- xmlns="urn:jboss:bean-deployer">
-
- <bean name="DataSourceConfig" class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>DataSourceConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="HibernateConfig" class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>HibernateConfig</parameter>
- </constructor>
- </bean>
-
- <bean name="JNDISupport" class="org.jboss.portal.test.framework.embedded.JNDISupport">
- </bean>
-
- <bean name="TransactionManagerSupport" class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
- </bean>
-
- <bean name="ConnectionManagerSupport" class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
- <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
- </bean>
-
- <bean name="DataSourceSupport" class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
- <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
- <property name="connectionManagerReference"><inject bean="ConnectionManagerSupport" property="connectionManagerReference"/></property>
- <property name="config"><inject bean="DataSourceConfig"/></property>
- </bean>
-
- <bean name="HibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
- <property name="config"><inject bean="HibernateConfig"/></property>
- <property name="jNDIName">java:/SessionFactory</property>
- <property name="mappings">
- <list elementClass="java.lang.String">
- <value>domain-single.hbm.xml</value>
- </list>
- </property>
- </bean>
-
- <bean name="DBTestBean" class="org.jboss.portal.test.identity.db_old.DBUserTestCase">
- <constructor factoryMethod="getBean">
- <factory bean="BeanFactory"/>
- <parameter>DBTestBean</parameter>
- </constructor>
- <property name="hibernate"><inject bean="HibernateSupport"/></property>
- </bean>
-
-</deployment>
17 years, 4 months