From: <jbo...@li...> - 2005-12-14 11:58:34
|
Author: aron.gombas Date: 2005-12-14 06:58:14 -0500 (Wed, 14 Dec 2005) New Revision: 1814 Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/WebdavCachedDataStore.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java Log: 2 new events added to CacheDataStore iface Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java 2005-12-14 11:07:38 UTC (rev 1813) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java 2005-12-14 11:58:14 UTC (rev 1814) @@ -124,13 +124,34 @@ return resources.getString(key); } - + + /** + * Must be called before the first file gets stored. + * @see CachedDataStore + */ + protected void beginXxx() { + log.debug(String.format("Beginning store session....")); + store.begin(); + } + + /** + * Must be called after the last file got stored. + * @see CachedDataStore + */ + protected void endXxx() { + 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 CachedDataStore */ protected String storeFile(String fileName, InputStream in) { try { + log.debug(String.format("Storing \"%s\"...", fileName)); + // delegate to the concrete store implementation return store.storeFile(fileName, in); } catch (Exception ex) { Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java 2005-12-14 11:07:38 UTC (rev 1813) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java 2005-12-14 11:58:14 UTC (rev 1814) @@ -17,13 +17,31 @@ * @version $Id$ */ public interface CachedDataStore { - /** TODO */ - // public void begin(); + /** + * Called before a service starts storing its files. + * A service call results in the sequence: + * <pre> + * begin() + * storeFile() + * storeFile() + * ... + * end() + * </pre> + * This can be used mostly for optimization purposes. + * Leave the implementation empty if there is no way to optimize + * "bulk storings" in your concrete implementation. + * @see #end() + */ + public void begin(); + /** + * Called after a service has stored all its files. + * @see #begin() + */ + public void end(); + /** * Stores the passed stream to an implementation-dependent "storage". * @return the absolute URL that points to the resulted file. */ - public String storeFile(String fileName, InputStream in) throws Exception;// TODO rename "store" - /** TODO */ - //public void end(); + public String storeFile(String fileName, InputStream in) throws Exception; } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/WebdavCachedDataStore.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/WebdavCachedDataStore.java 2005-12-14 11:07:38 UTC (rev 1813) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/WebdavCachedDataStore.java 2005-12-14 11:58:14 UTC (rev 1814) @@ -56,6 +56,14 @@ this.clientUrl = clientUrl; } + /** This method is left empty as there is no optimization opportunity. */ + public void begin() { + } + + /** This method is left empty as there is no optimization opportunity. */ + public void end() { + } + /** * Saves the passed stream to a WebDAV repository-based cache and returns * the absolute URL pointing to the resulted file. Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java 2005-12-14 11:07:38 UTC (rev 1813) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java 2005-12-14 11:58:14 UTC (rev 1814) @@ -75,6 +75,8 @@ public Object reloadData(Object key) { String url = key.toString(); List<CcProject> projects = new ArrayList<CcProject>(); + + beginXxx(); try { Document dom = ScrapingUtils.downloadHtmlDom(new URL(url)); @@ -157,6 +159,8 @@ } catch(Exception ex) { log.error("Unable to scrape", ex); } + + endXxx(); return projects; } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-12-14 11:07:38 UTC (rev 1813) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-12-14 11:58:14 UTC (rev 1814) @@ -72,7 +72,9 @@ public Object reloadData(Object key) { String url = key.toString(); List<JiraProject> projects = new ArrayList<JiraProject>(); - + + beginXxx(); + try { // download database info connect(url); @@ -271,6 +273,8 @@ } catch(Exception ex) { log.error("Unable to scrape", ex); } + + endXxx(); return projects; } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-12-14 11:07:38 UTC (rev 1813) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-12-14 11:58:14 UTC (rev 1814) @@ -101,6 +101,8 @@ public Object reloadData(Object key) { String url = key.toString(); List<SvnRepository> repositories = new ArrayList<SvnRepository>(); + + beginXxx(); try { // get repository info @@ -126,6 +128,8 @@ } catch (Exception ex) { log.error("Unable to process the SVN repo", ex); } + + endXxx(); return repositories; } |