[jboss-svn-commits] JBL Code SVN: r21511 - in labs/jbosslabs/branches/stats-qa: index and 4 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Aug 13 08:54:03 EDT 2008


Author: wrzep
Date: 2008-08-13 08:54:02 -0400 (Wed, 13 Aug 2008)
New Revision: 21511

Added:
   labs/jbosslabs/branches/stats-qa/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java
   labs/jbosslabs/branches/stats-qa/project.properties
Modified:
   labs/jbosslabs/branches/stats-qa/index/project.properties
   labs/jbosslabs/branches/stats-qa/index/project.xml
   labs/jbosslabs/branches/stats-qa/index/src/main/webapp/WEB-INF/portlet.xml
   labs/jbosslabs/branches/stats-qa/kosmos/conf/portlet/WEB-INF/portlet.template.xml
   labs/jbosslabs/branches/stats-qa/kosmos/project.xml
Log:
 svn merge -r 20584:21509 https://svn.jboss.org/repos/labs/labs/jbosslabs/trunk/stats-server/sources


Modified: labs/jbosslabs/branches/stats-qa/index/project.properties
===================================================================
--- labs/jbosslabs/branches/stats-qa/index/project.properties	2008-08-13 12:21:44 UTC (rev 21510)
+++ labs/jbosslabs/branches/stats-qa/index/project.properties	2008-08-13 12:54:02 UTC (rev 21511)
@@ -1 +1,4 @@
+maven.repo.remote=http://repo1.maven.org/maven
+maven.junit.fork=yes
+
 maven.war.src=${basedir}/src/main/webapp

Modified: labs/jbosslabs/branches/stats-qa/index/project.xml
===================================================================
--- labs/jbosslabs/branches/stats-qa/index/project.xml	2008-08-13 12:21:44 UTC (rev 21510)
+++ labs/jbosslabs/branches/stats-qa/index/project.xml	2008-08-13 12:54:02 UTC (rev 21511)
@@ -5,51 +5,53 @@
   See terms of license at gnu.org. 
  -->
 <project>
- 	<pomVersion>3</pomVersion>
-	<id>stats-index</id>
+        <pomVersion>3</pomVersion>
+        <id>stats-index</id>
     <name>Stats Main Page</name>
     <extend>../project.xml</extend>
     <dependencies>
-    		
-    	 <dependency>
-    	            <id>portlet-api</id>
-    	            <version>1.0</version>
-    	        </dependency>
-    	
-    	   <dependency>
-    	            <groupId>jboss</groupId>
-    	            <artifactId>portal-common-lib</artifactId>
-    	            <version>1.0</version>
-    	            <jar>portal-common-lib.jar</jar>
-    	        </dependency>
+    
+         <dependency>
+                    <id>portlet-api</id>
+                    <version>1.0</version>
+                </dependency>
+    
+           <dependency>
+                    <groupId>jboss</groupId>
+                    <artifactId>portal-common-lib</artifactId>
+                    <version>1.0</version>
+                    <jar>portal-common-lib.jar</jar>
+                </dependency>
           <dependency>
-    	            <groupId>jboss</groupId>
-    	            <artifactId>portal-core-lib</artifactId>
-    	            <version>1.0</version>
-    	            <jar>portal-core-lib.jar</jar>
-    	        </dependency>
-    	        <dependency>
-    	            <groupId>jboss</groupId>
-    	            <artifactId>jboss-portlet-api-lib</artifactId>
-    	            <version>1.0</version>
-    	            <jar>jboss-portlet-api-lib.jar</jar>
-    	        </dependency>
-    	        <dependency>
-    	            <groupId>jboss</groupId>
-    	            <artifactId>portal-api-lib</artifactId>
-    	            <version>1.0</version>
-    	            <jar>portal-api-lib.jar</jar>
-    	        </dependency>
+                    <groupId>jboss</groupId>
+                    <artifactId>portal-core-lib</artifactId>
+                    <version>1.0</version>
+                    <jar>portal-core-lib.jar</jar>
+                </dependency>
+<!--
+                <dependency>
+                    <groupId>jboss</groupId>
+                    <artifactId>jboss-portlet-api-lib</artifactId>
+                    <version>1.0</version>
+                    <jar>jboss-portlet-api-lib.jar</jar>
+                </dependency>
+    
+                <dependency>
+                    <groupId>jboss</groupId>
+                    <artifactId>portal-api-lib</artifactId>
+                    <version>1.0</version>
+                    <jar>portal-api-lib.jar</jar>
+                </dependency>
+-->
+                <dependency>
+                    <groupId>jboss</groupId>
+                    <artifactId>portal-portlet-lib</artifactId>
+                    <version>1.0</version>
+                    <jar>portal-portlet-lib.jar</jar>
+                </dependency>
 
-    	        <dependency>
-    	            <groupId>jboss</groupId>
-    	            <artifactId>portal-portlet-lib</artifactId>
-    	            <version>1.0</version>
-    	            <jar>portal-portlet-lib.jar</jar>
-    	        </dependency>
-
     </dependencies>
-	<build>
-	        <sourceDirectory>src/main/java</sourceDirectory>
-	    </build>
-</project>
+        <build>
+                <sourceDirectory>src/main/java</sourceDirectory>
+            </build>
+</project>
\ No newline at end of file

Modified: labs/jbosslabs/branches/stats-qa/index/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- labs/jbosslabs/branches/stats-qa/index/src/main/webapp/WEB-INF/portlet.xml	2008-08-13 12:21:44 UTC (rev 21510)
+++ labs/jbosslabs/branches/stats-qa/index/src/main/webapp/WEB-INF/portlet.xml	2008-08-13 12:54:02 UTC (rev 21511)
@@ -5,7 +5,8 @@
 
   <portlet>
 	<portlet-name>StatsIndexPortlet</portlet-name>
-	<portlet-class>org.jboss.labs.JspPortlet</portlet-class>
+	<portlet-class>org.jboss.labs.JspPortlet</portlet-class>
+	 <expiration-cache>3600</expiration-cache>
 	<init-param>
 	  <name>page.jsp</name>
 	  <value>main.jsp</value>

Modified: labs/jbosslabs/branches/stats-qa/kosmos/conf/portlet/WEB-INF/portlet.template.xml
===================================================================
--- labs/jbosslabs/branches/stats-qa/kosmos/conf/portlet/WEB-INF/portlet.template.xml	2008-08-13 12:21:44 UTC (rev 21510)
+++ labs/jbosslabs/branches/stats-qa/kosmos/conf/portlet/WEB-INF/portlet.template.xml	2008-08-13 12:54:02 UTC (rev 21511)
@@ -1,130 +1,130 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
-xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0">
-
-  <portlet>
-	<portlet-name>JBossJiraMonitoringPortlet</portlet-name>
-	<portlet-class>hu.midori.kosmos.portlet.jira.JiraMonitoringPortlet</portlet-class>
-	<init-param>
-	  <name>monitored.resource</name>
-	  <value>JBoss JIRA</value>
-	</init-param>
-	<init-param>
-	  <name>service.url</name>
-	  <value>#{kosmos.server.url}/kosmos-services/jira-service</value>
-	</init-param>
-	<init-param>
-	  <name>monitored.urls</name>
-	  <value>
-		http://jira.jboss.com/jira/browse/JBAS
-<!-- 		
-		http://jira.jboss.com/jira/browse/JBWEB,
-		http://jira.jboss.com/jira/browse/JBMICROCONT,
-		http://jira.jboss.com/jira/browse/JBESB,
-		http://jira.jboss.com/jira/browse/RHM,
-		http://jira.jboss.com/jira/browse/JBRULES,
-		http://jira.jboss.com/jira/browse/JBPM,
-		http://jira.jboss.com/jira/browse/JBTM,
-		http://jira.jboss.com/jira/browse/JBWS,
-		http://jira.jboss.com/jira/browse/DNA,
-		http://jira.jboss.com/jira/browse/JBIDE,
-		http://jira.jboss.com/jira/browse/JBPROFILER,
-		http://jira.jboss.com/jira/browse/JSFUNIT,
-		http://jira.jboss.com/jira/browse/RF,
-		http://jira.jboss.com/jira/browse/JBCACHE,
-		http://jira.jboss.com/jira/browse/JBGRAVEL,
-		http://jira.jboss.com/jira/browse/JBPORTAL,
-		http://jira.jboss.com/jira/browse/JBFORUMS,
-		http://jira.jboss.com/jira/browse/JBWIKI,
-		http://jira.jboss.com/jira/browse/JBBLOG,
-		http://jira.jboss.com/jira/browse/SWAP,
-		http://jira.jboss.com/jira/browse/PBR,
-		http://jira.jboss.com/jira/browse/JBSEAM,
-		http://jira.jboss.com/jira/browse/EJBTHREE	
-		http://jira.jboss.com/jira/browse/JBAOP,!!!
-		http://jira.jboss.com/jira/browse/SECURITY,
-		http://jira.jboss.com/jira/browse/JBSSO,
-		http://jira.jboss.com/jira/browse/JBSER,
-		http://jira.jboss.com/jira/browse/JBREM,
-		http://jira.jboss.com/jira/browse/KOSMOS,
-		http://jira.jboss.com/jira/browse/DAVCACHE,
-		http://jira.jboss.com/jira/browse/ENVERS,
-		http://jira.jboss.com/jira/browse/JBREPORT,
-		http://jira.jboss.com/jira/browse/JBSHOTOKU,
-		http://jira.jboss.com/jira/browse/MTAJZR,
-		http://jira.jboss.com/jira/browse/JBJMX,
-		http://jira.jboss.com/jira/browse/JASSIST,
-		http://jira.jboss.com/jira/browse/XNIO
--->					
-	  </value>
-	</init-param>
-	<supports>
-	  <mime-type>text/html</mime-type>
-	  <portlet-mode>HELP</portlet-mode>
-	  <portlet-mode>VIEW</portlet-mode>
-	</supports>
-	<supported-locale>de</supported-locale>
-	<supported-locale>en</supported-locale>
-	<supported-locale>fr</supported-locale>
-	<supported-locale>hu</supported-locale>
-	<supported-locale>ja</supported-locale>
-	<supported-locale>pl</supported-locale>
-	<resource-bundle>hu.midori.kosmos.portlet.jira.jira_monitoring</resource-bundle>
-	<portlet-info>
-	  <title>JIRA Monitoring</title>
-	</portlet-info>
-  </portlet>
-<!-- 
-  <portlet>
-	<portlet-name>JBossProductsSfMonitoringPortlet</portlet-name>
-	<portlet-class>hu.midori.kosmos.portlet.sf.SfMonitoringPortlet</portlet-class>
-	<init-param>
-	  <name>monitored.resource</name>
-	  <value>JBoss Products</value>
-	</init-param>
-	<init-param>
-	  <name>service.url</name>
-	  <value>#{kosmos.server.url}/kosmos-services/sf-service</value>
-	</init-param>
-	<init-param>
-	  <name>monitored.urls</name>
-	  <value>
-		http://sourceforge.net/projects/jboss/
-	  </value>
-	</init-param>
-	<supports>
-	  <mime-type>text/html</mime-type>
-	  <portlet-mode>HELP</portlet-mode>
-	  <portlet-mode>VIEW</portlet-mode>
-	</supports>
-	<supported-locale>de</supported-locale>
-	<supported-locale>en</supported-locale>
-	<supported-locale>fr</supported-locale>
-	<supported-locale>hu</supported-locale>
-	<supported-locale>ja</supported-locale>
-	<supported-locale>pl</supported-locale>
-	<resource-bundle>hu.midori.kosmos.portlet.sf.sf_monitoring</resource-bundle>
-	<portlet-info>
-	  <title>SourceForge Monitoring</title>
-	</portlet-info>
-  </portlet>
- -->
-  <portlet>
-	<portlet-name>JBossSvnMonitoringPortlet</portlet-name>
-	<portlet-class>hu.midori.kosmos.portlet.svn.SvnMonitoringPortlet</portlet-class>
-	<init-param>
-	  <name>monitored.resource</name>
-	  <value>JBoss Subversion Repository</value>
-	</init-param>
-	<init-param>
-	  <name>service.url</name>
-	  <value>#{kosmos.server.url}/kosmos-services/svn-service</value>
-	</init-param>
-	<init-param>
-	  <name>monitored.urls</name>
-	  <value>
-<!-- 
+<?xml version="1.0" encoding="UTF-8"?>
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0">
+
+  <portlet>
+        <portlet-name>JBossJiraMonitoringPortlet</portlet-name>
+        <portlet-class>hu.midori.kosmos.portlet.jira.JiraMonitoringPortlet</portlet-class>
+        <expiration-cache>3600</expiration-cache>
+        <init-param>
+          <name>monitored.resource</name>
+          <value>JBoss JIRA</value>
+        </init-param>
+        <init-param>
+          <name>service.url</name>
+          <value>#{kosmos.server.url}/kosmos-services/jira-service</value>
+        </init-param>
+        <init-param>
+          <name>monitored.urls</name>
+          <value>
+                https://jira.jboss.org/jira/browse/JBAS,
+                https://jira.jboss.org/jira/browse/JBWEB,
+                https://jira.jboss.org/jira/browse/JBMICROCONT,
+                https://jira.jboss.org/jira/browse/JBESB,
+                https://jira.jboss.org/jira/browse/RHM,
+                https://jira.jboss.org/jira/browse/JBRULES,
+                https://jira.jboss.org/jira/browse/JBPM,
+                https://jira.jboss.org/jira/browse/JBTM,
+                https://jira.jboss.org/jira/browse/JBWS,
+                https://jira.jboss.org/jira/browse/DNA,
+                https://jira.jboss.org/jira/browse/JBIDE,
+                https://jira.jboss.org/jira/browse/JBPROFILER,
+                https://jira.jboss.org/jira/browse/JSFUNIT,
+                https://jira.jboss.org/jira/browse/RF,
+                https://jira.jboss.org/jira/browse/JBCACHE,
+                https://jira.jboss.org/jira/browse/GRAVEL,
+                https://jira.jboss.org/jira/browse/JBPORTAL,
+                https://jira.jboss.org/jira/browse/JBFORUMS,
+                https://jira.jboss.org/jira/browse/JBWIKI,
+                https://jira.jboss.org/jira/browse/JBBLOG,
+                https://jira.jboss.org/jira/browse/SWAP,
+                https://jira.jboss.org/jira/browse/PBR,
+                https://jira.jboss.org/jira/browse/JBSEAM,
+                https://jira.jboss.org/jira/browse/EJBTHREE,
+                https://jira.jboss.org/jira/browse/JBAOP,
+ http://opensource.atlassian.com/projects/hibernate/browse/HHH,
+                https://jira.jboss.org/jira/browse/SECURITY,
+                https://jira.jboss.org/jira/browse/JBSSO,
+                https://jira.jboss.org/jira/browse/JBSER,
+                https://jira.jboss.org/jira/browse/JBREM,
+                https://jira.jboss.org/jira/browse/KOSMOS,
+                https://jira.jboss.org/jira/browse/DAVCACHE,
+                https://jira.jboss.org/jira/browse/ENVERS,
+                https://jira.jboss.org/jira/browse/JBREPORT,
+                https://jira.jboss.org/jira/browse/JBSHOTOKU,
+                https://jira.jboss.org/jira/browse/MTAJZR,
+                https://jira.jboss.org/jira/browse/JBJMX,
+                https://jira.jboss.org/jira/browse/JASSIST,
+                https://jira.jboss.org/jira/browse/XNIO
+          </value>
+        </init-param>
+        <supports>
+          <mime-type>text/html</mime-type>
+          <portlet-mode>HELP</portlet-mode>
+          <portlet-mode>VIEW</portlet-mode>
+        </supports>
+        <supported-locale>de</supported-locale>
+        <supported-locale>en</supported-locale>
+        <supported-locale>fr</supported-locale>
+        <supported-locale>hu</supported-locale>
+        <supported-locale>ja</supported-locale>
+        <supported-locale>pl</supported-locale>
+        <resource-bundle>hu.midori.kosmos.portlet.jira.jira_monitoring</resource-bundle>
+        <portlet-info>
+          <title>JIRA Monitoring</title>
+        </portlet-info>
+  </portlet>
+<!-- 
+  <portlet>
+        <portlet-name>JBossProductsSfMonitoringPortlet</portlet-name>
+        <portlet-class>hu.midori.kosmos.portlet.sf.SfMonitoringPortlet</portlet-class>
+        <init-param>
+          <name>monitored.resource</name>
+          <value>JBoss Products</value>
+        </init-param>
+        <init-param>
+          <name>service.url</name>
+          <value>#{kosmos.server.url}/kosmos-services/sf-service</value>
+        </init-param>
+        <init-param>
+          <name>monitored.urls</name>
+          <value>
+                http://sourceforge.net/projects/jboss/
+          </value>
+        </init-param>
+        <supports>
+          <mime-type>text/html</mime-type>
+          <portlet-mode>HELP</portlet-mode>
+          <portlet-mode>VIEW</portlet-mode>
+        </supports>
+        <supported-locale>de</supported-locale>
+        <supported-locale>en</supported-locale>
+        <supported-locale>fr</supported-locale>
+        <supported-locale>hu</supported-locale>
+        <supported-locale>ja</supported-locale>
+        <supported-locale>pl</supported-locale>
+        <resource-bundle>hu.midori.kosmos.portlet.sf.sf_monitoring</resource-bundle>
+        <portlet-info>
+          <title>SourceForge Monitoring</title>
+        </portlet-info>
+  </portlet>
+ -->
+  <portlet>
+        <portlet-name>JBossSvnMonitoringPortlet</portlet-name>
+        <portlet-class>hu.midori.kosmos.portlet.svn.SvnMonitoringPortlet</portlet-class>
+        <expiration-cache>3600</expiration-cache>
+        <init-param>
+          <name>monitored.resource</name>
+          <value>JBoss Subversion Repository</value>
+        </init-param>
+        <init-param>
+          <name>service.url</name>
+          <value>#{kosmos.server.url}/kosmos-services/svn-service</value>
+        </init-param>
+        <init-param>
+          <name>monitored.urls</name>
+          <value>
 http://anonsvn.jboss.org/repos/jbossas/trunk/,
 http://anonsvn.jboss.org/repos/jbossweb/trunk/,
 http://anonsvn.jboss.org/repos/jbossas/projects/microcontainer/trunk/,
@@ -137,12 +137,11 @@
 http://anonsvn.jboss.org/repos/jsfunit/trunk/,
 http://anonsvn.jboss.org/repos/richfaces/trunk/,
 http://anonsvn.jboss.org/repos/gravel/gravel.1/trunk/,
--->
 <!-- http://anonsvn.jboss.org/repos/jbosscache/, splitted trunk -->
 <!-- http://anonsvn.jboss.org/repos/portal/, splitted trunk -->
 <!-- http://anonsvn.jboss.org/repos/jbossws/, splitted trunk -->
-<!-- 
-http://anonsvn.labs.jboss.com/labs/jbossforums/trunk/,
+<!-- http://anonsvn.labs.jboss.com/labs/jbossforums/trunk/, -->
+http://anonsvn.labs.jboss.com/labs/jbossforums/branches/forums120P26/,
 http://anonsvn.labs.jboss.com/labs/jbosslabs/trunk/portal-extensions/jbosswiki/,
 http://anonsvn.jboss.org/repos/jbossblog/trunk/,
 http://anonsvn.jboss.org/repos/labs/labs/portletswap/,
@@ -158,26 +157,25 @@
 http://anonsvn.labs.jboss.com/labs/davcache/trunk/,
 http://anonsvn.labs.jboss.com/labs/reportingservices/trunk/,
 http://anonsvn.labs.jboss.com/labs/shotoku/trunk/,
-http://anonsvn.jboss.org/repos/xnio/xnio-base/trunk/
--->
-http://anonsvn.jboss.org/repos/envers/trunk/
-	  </value>
-	</init-param>
-	<supports>
-	  <mime-type>text/html</mime-type>
-	  <portlet-mode>HELP</portlet-mode>
-	  <portlet-mode>VIEW</portlet-mode>
-	</supports>
-	<supported-locale>de</supported-locale>
-	<supported-locale>en</supported-locale>
-	<supported-locale>fr</supported-locale>
-	<supported-locale>hu</supported-locale>
-	<supported-locale>ja</supported-locale>
-	<supported-locale>pl</supported-locale>
-	<resource-bundle>hu.midori.kosmos.portlet.svn.svn_monitoring</resource-bundle>
-	<portlet-info>
-	  <title>Subversion Monitoring</title>
-	</portlet-info>
-  </portlet>
-
-</portlet-app>
+http://anonsvn.jboss.org/repos/xnio/xnio-base/trunk/,
+http://anonsvn.jboss.org/repos/envers/trunk/
+          </value>
+        </init-param>
+        <supports>
+          <mime-type>text/html</mime-type>
+          <portlet-mode>HELP</portlet-mode>
+          <portlet-mode>VIEW</portlet-mode>
+        </supports>
+        <supported-locale>de</supported-locale>
+        <supported-locale>en</supported-locale>
+        <supported-locale>fr</supported-locale>
+        <supported-locale>hu</supported-locale>
+        <supported-locale>ja</supported-locale>
+        <supported-locale>pl</supported-locale>
+        <resource-bundle>hu.midori.kosmos.portlet.svn.svn_monitoring</resource-bundle>
+        <portlet-info>
+          <title>Subversion Monitoring</title>
+        </portlet-info>
+  </portlet>
+
+</portlet-app>
\ No newline at end of file

Modified: labs/jbosslabs/branches/stats-qa/kosmos/project.xml
===================================================================
--- labs/jbosslabs/branches/stats-qa/kosmos/project.xml	2008-08-13 12:21:44 UTC (rev 21510)
+++ labs/jbosslabs/branches/stats-qa/kosmos/project.xml	2008-08-13 12:54:02 UTC (rev 21511)
@@ -27,6 +27,26 @@
 	    <artifactId>jfreechart</artifactId>
 	    <version>1.0.0</version>
 	</dependency>
+	<dependency>
+	    <groupId>commons-logging</groupId>
+	    <artifactId>commons-logging</artifactId>
+	    <version>1.1</version>
+	</dependency>
+	<dependency>
+		    <groupId>commons-lang</groupId>
+		    <artifactId>commons-lang</artifactId>
+		    <version>2.3</version>
+	</dependency>    
+	<dependency>
+		    <groupId>javax.servlet</groupId>
+		    <artifactId>servlet-api</artifactId>
+		    <version>2.4</version>
+	</dependency>    
+	<dependency>
+	        <groupId>org.tmate</groupId>
+	            <artifactId>javasvn</artifactId>
+	                <version>1.0.3</version>
+    </dependency>   
     </dependencies>
     <build>
         <sourceDirectory>src/java</sourceDirectory>

Copied: labs/jbosslabs/branches/stats-qa/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java (from rev 21509, labs/jbosslabs/trunk/stats-server/sources/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java)
===================================================================
--- labs/jbosslabs/branches/stats-qa/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java	                        (rev 0)
+++ labs/jbosslabs/branches/stats-qa/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java	2008-08-13 12:54:02 UTC (rev 21511)
@@ -0,0 +1,197 @@
+/*
+ * Kosmos.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package hu.midori.kosmos.server;
+
+import hu.midori.kosmos.model.util.ZoomableImageLocator;
+import hu.midori.kosmos.server.store.StaticContentStore;
+import hu.midori.kosmos.server.util.ChartUtils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jfree.chart.JFreeChart;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * Each Kosmos service must extend this baseclass.
+ * Services are implemented as POJOs.
+ *
+ * @author <a href="mailto:aron.gombas at midori.hu">Aron Gombas</a>
+ * @version $Id$
+ */
+public abstract class AbstractKosmosService implements ApplicationContextAware {
+    private final static Log log = LogFactory.getLog(AbstractKosmosService.class);
+
+    /**
+     * Heavy lists will be trimmed to this size or set to -1 if you want to disable trimming.
+     * @see #trimList(List)
+     */
+    protected static final int MAX_LIST_SIZE = 8;
+
+    /** Horizontal resolution of small chart images. */
+    private static final int CHART_SMALL_RESOLUTION_X = 320;
+    /** Vertical resolution of small chart images. */
+    private static final int CHART_SMALL_RESOLUTION_Y = 240;
+    /** Horizontal resolution of small chart images. */
+    private static final int CHART_LARGE_RESOLUTION_X = 640;
+    /** Vertical resolution of small chart images. */
+    private static final int CHART_LARGE_RESOLUTION_Y = 480;
+
+    /** Spring web-application context. */
+    protected WebApplicationContext applicationContext;
+
+    /** The timestamp when the cache was most recently updated. */
+    private Date timestamp;
+    /** Localized resources. */
+    private ResourceBundle resources = null;
+    /** Pluggable static content store implementation. */
+    private StaticContentStore store;
+
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        this.applicationContext = (WebApplicationContext)applicationContext;
+    }
+
+    public void setStore(StaticContentStore store) {
+        this.store = store;
+    }
+
+    /**
+     * Returns the timestamp when the cache was most recently updated.
+     * This can be invoked only after the service method was called.
+     */
+    public Date getTimestamp() {
+        log.debug("Service invoked: returning timestamp...");
+        // init if timestamp wasn't initialized yet
+        if(timestamp == null)
+            timestamp = new Date();
+
+        return timestamp;
+    }
+
+    /** Updates the timestamp at service method calls. */
+    protected void updateTimestamp() {
+        this.timestamp = new Date();
+    }
+
+    /**
+     * Returns the localized string resource from the given resource bundle.
+     * For caching, it assumes that only one bundle is used per service.
+     * The locale is defined globally for the servlet, not as method parameter.
+     */
+    protected String getResourceString(String baseName, String key) {
+        // lazy-init the bundle
+        if(resources == null) {
+            String locale = applicationContext.getServletContext().getInitParameter("locale");
+            log.info(String.format("Loading resources \"%s\" for locale \"%s\"...", baseName, locale));
+            resources = ResourceBundle.getBundle(baseName);
+            	//StringUtils.isBlank(locale) ? ResourceBundle.getBundle(baseName) : ResourceBundle.getBundle(baseName, new Locale(locale));
+        }
+
+        return resources.getString(key);
+    }
+
+    /**
+     * Must be called before the first file gets stored.
+     * @see StaticContentStore
+     */
+    protected void beginStoreSession() {
+        log.debug(String.format("Beginning store session...."));
+        store.begin();
+    }
+
+    /**
+     * Must be called after the last file got stored.
+     * @see StaticContentStore
+     */
+    protected void endStoreSession() {
+        log.debug(String.format("Ending store session..."));
+        store.end();
+    }
+
+    /**
+     * Stores the passed stream to an implementation-dependent "storage".
+     * @return the absolute URL that points to the resulted file.
+     * @see StaticContentStore
+     */
+    protected String storeFile(String fileName, InputStream in) {
+        log.debug(String.format("Storing \"%s\"...", fileName));
+
+        try {
+            // delegate to the concrete store implementation
+            return store.storeFile(fileName, in);
+        } catch (Exception ex) {
+            log.error("Unable to store cached file", ex);
+            return "";
+        }
+    }
+
+    /**
+     * Stores the images generated from the passed chart in 2 resolutions.
+     * @param fileName must <strong>not</strong> contain the file extension.
+     * @return the locator with absolute URLs pointing to the resulted images.
+     * @see #storeFile(String, InputStream)
+     */
+    protected ZoomableImageLocator storeChart(String fileName, JFreeChart chart) {
+        String loresUrl = "";
+        try {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            ChartUtils.writeChartAsPng(chart, out, CHART_SMALL_RESOLUTION_X, CHART_SMALL_RESOLUTION_Y);
+            loresUrl = storeFile(fileName + "_small.png", new ByteArrayInputStream(out.toByteArray()));
+        } catch(IOException ex) {
+            log.error("Unable to write lo-res version of chart image", ex);
+        }
+
+        String hiresUrl = "";
+        try {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            ChartUtils.writeChartAsPng(chart, out, CHART_LARGE_RESOLUTION_X, CHART_LARGE_RESOLUTION_Y);
+            hiresUrl = storeFile(fileName + "_large.png", new ByteArrayInputStream(out.toByteArray()));
+        } catch(IOException ex) {
+            log.error("Unable to write hi-res version of chart image", ex);
+        }
+
+        return new ZoomableImageLocator(loresUrl, hiresUrl);
+    }
+
+    /**
+     * Trims long lists to some limited size to avoid large datasets that would result in
+     * huge network transfers and unuseable web pages.
+     */
+    protected List trimList(List data) {
+        if((MAX_LIST_SIZE != -1) && (data.size() > MAX_LIST_SIZE)) {
+        	
+        	List ret = new ArrayList();
+        	int i = 0;
+        	
+        	for (Object object : data) {
+				ret.add(data.get(i)); // Hope all passed lists perform get(i) in O(1)
+				i++;
+				if (i == MAX_LIST_SIZE)
+					return ret;
+			}
+        	
+        	//return data.subList(0, MAX_LIST_SIZE);
+        		// This returns a *view* of the portion of the list, hence does NOT solve the problem.
+        		// See AbstractList's javadoc.
+        }
+            
+        return data;
+    }
+}

Copied: labs/jbosslabs/branches/stats-qa/project.properties (from rev 21509, labs/jbosslabs/trunk/stats-server/sources/project.properties)
===================================================================
--- labs/jbosslabs/branches/stats-qa/project.properties	                        (rev 0)
+++ labs/jbosslabs/branches/stats-qa/project.properties	2008-08-13 12:54:02 UTC (rev 21511)
@@ -0,0 +1,2 @@
+maven.repo.remote=http://repo1.maven.org/maven
+maven.junit.fork=yes




More information about the jboss-svn-commits mailing list