[jboss-svn-commits] JBL Code SVN: r8859 - in labs/shotoku/trunk-2.6: shotoku-base and 10 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jan 15 19:44:44 EST 2007


Author: adamw
Date: 2007-01-15 19:44:35 -0500 (Mon, 15 Jan 2007)
New Revision: 8859

Added:
   labs/shotoku/trunk-2.6/shotoku-base-service/
   labs/shotoku/trunk-2.6/shotoku-base-service/maven.xml
   labs/shotoku/trunk-2.6/shotoku-base-service/project.properties
   labs/shotoku/trunk-2.6/shotoku-base-service/project.xml
   labs/shotoku/trunk-2.6/shotoku-base-service/shotoku-base-service.iml
   labs/shotoku/trunk-2.6/shotoku-base-service/src/
   labs/shotoku/trunk-2.6/shotoku-base-service/src/etc/
   labs/shotoku/trunk-2.6/shotoku-base-service/src/java/
   labs/shotoku/trunk-2.6/shotoku-base-service/src/java/org/
   labs/shotoku/trunk-2.6/shotoku-base-service/src/java/org/jboss/
   labs/shotoku/trunk-2.6/shotoku-base-service/src/java/org/jboss/shotoku/
   labs/shotoku/trunk-2.6/shotoku-base-service/src/java/org/jboss/shotoku/service/
   labs/shotoku/trunk-2.6/shotoku-base-service/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java
Removed:
   labs/shotoku/trunk-2.6/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java
Modified:
   labs/shotoku/trunk-2.6/maven.xml
   labs/shotoku/trunk-2.6/project.properties
   labs/shotoku/trunk-2.6/shotoku-base/maven.xml
   labs/shotoku/trunk-2.6/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java
   labs/shotoku/trunk-2.6/shotoku-file-access/maven.xml
   labs/shotoku/trunk-2.6/shotoku-file-access/project.properties
Log:
http://jira.jboss.com/jira/browse/JBLAB-817

Modified: labs/shotoku/trunk-2.6/maven.xml
===================================================================
--- labs/shotoku/trunk-2.6/maven.xml	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/maven.xml	2007-01-16 00:44:35 UTC (rev 8859)
@@ -24,7 +24,7 @@
                     excludes="" basedir="." banner="Shotoku build"
                     goals="${goal}" ignoreFailures="false" />
         </j:forEach>
-    </goal>
+    </goal>                
 
     <!-- Main goals -->
 

Modified: labs/shotoku/trunk-2.6/project.properties
===================================================================
--- labs/shotoku/trunk-2.6/project.properties	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/project.properties	2007-01-16 00:44:35 UTC (rev 8859)
@@ -4,8 +4,8 @@
 version=1.0-alpha3
 
 shotoku.sar.dir=shotoku.sar
-#shotoku.subprojects.cms=base,files,jcr,svn
-shotoku.subprojects.cms=base,svn
+#shotoku.subprojects.cms=base,base-service,files,jcr,svn
+shotoku.subprojects.cms=base,base-service,svn
 #shotoku.subprojects=${shotoku.subprojects.cms},aop,test,,admin,tags,feeds,file-access,portal
 shotoku.subprojects=${shotoku.subprojects.cms},aop,admin,tags,feeds,file-access
 

Modified: labs/shotoku/trunk-2.6/shotoku-base/maven.xml
===================================================================
--- labs/shotoku/trunk-2.6/shotoku-base/maven.xml	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/shotoku-base/maven.xml	2007-01-16 00:44:35 UTC (rev 8859)
@@ -5,13 +5,13 @@
 
     <goal name="build">
         <attainGoal name="java:compile" />
-        <attainGoal name="ejb" />
+        <attainGoal name="jar" />
     </goal>
 
     <goal name="deploy">
         <ant:copy
                 file="target/shotoku-base.jar"
-                tofile="${local.deploy.dir}/shotoku-base.ejb3"
+                tofile="../target/${shotoku.sar.dir}/shotoku-base.jar"
                 overwrite="true" />
     </goal>
 </project>

Deleted: labs/shotoku/trunk-2.6/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java
===================================================================
--- labs/shotoku/trunk-2.6/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java	2007-01-16 00:44:35 UTC (rev 8859)
@@ -1,293 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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.shotoku.service;
-
-import javax.ejb.Local;
-
-import org.jboss.annotation.ejb.Management;
-import org.jboss.annotation.ejb.Service;
-import org.jboss.shotoku.ContentManager;
-import org.jboss.shotoku.cache.ShotokuCacheItem;
-import org.jboss.shotoku.cache.UpdateThread;
-import org.jboss.shotoku.tools.Constants;
-import org.jboss.shotoku.tools.ConcurrentSet;
-import org.jboss.shotoku.tools.ConcurrentHashSet;
-import org.jboss.shotoku.tools.Tools;
-import org.apache.log4j.Logger;
-
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.Set;
-
-/**
- * 
- * @author Adam Warski (adamw at aster.pl)
- */
- at Service(objectName=Constants.SHOTOKU_SERVICE_NAME)
- at Local(ShotokuServiceLocal.class)
- at Management(ShotokuService.class)
-public class ShotokuServiceImpl extends AdministratedServiceImpl
-        implements ShotokuService, ShotokuServiceLocal {
-    Logger log = Logger.getLogger(AdministratedService.class);
-
-    /*
-     * Service-handling functions.
-     */
-
-    public void create() throws Exception {
-        super.create();
-
-        /*
-         * Setting up content managers.
-         */
-        ContentManager.setup();
-
-        log.info("ContentManager setup completed.  Getting the default service timer interval...");
-        updateThreadCount = ContentManager.getDefaultUpdateThreadCount();
-
-        setTimerInterval(ContentManager.getDefaultServiceInterval());
-
-        super.afterCreate();
-    }
-
-    public void start() throws Exception {
-        super.start();
-
-        log.info("Starting main update thread...");
-
-        startUpdateThread();
-
-        log.info("Starting update threads...");
-        setUpdateThreadCount(updateThreadCount);
-
-        log.info("Reseting keys during update in cache items...");
-        // Reseting just in case - if any thread unexpectadly died.
-        for (ShotokuCacheItem sci : cacheItems) {
-            sci.resetKeysDuringUpdate();
-        }
-
-        super.afterStart();
-    }
-
-    public void stop() {
-        super.stop();
-
-        signalExitAllUpdateThreads();
-        toRemove = 0;
-        log.info("All update threads stopped.");
-    }
-
-    public void destroy() {
-
-    }
-
-    /*
-     * Cache handling
-     */
-
-    private final ConcurrentMap<Object, Object> cache =
-            new ConcurrentHashMap<Object, Object>();
-    private final ConcurrentSet<ShotokuCacheItem> cacheItems =
-            new ConcurrentHashSet<ShotokuCacheItem>();
-    private final ConcurrentMap<Object, Long> lastUpdates =
-            new ConcurrentHashMap<Object, Long>();
-
-    public Object get(Object key) {
-        Object ret = cache.get(key);
-        if (Null.getInstance().equals(ret)) {
-            return null;
-        } else {
-            return ret;
-        }
-    }
-
-    public void put(Object key, Object o) {
-        touch(key);
-
-        if (o == null) {
-            cache.put(key, Null.getInstance());
-        } else {
-            cache.put(key, o);
-        }
-    }
-
-    public void touch(Object key) {
-        lastUpdates.put(key, System.currentTimeMillis());
-    }
-
-    public void remove(Object key) {
-        cache.remove(key);
-    }
-
-    public void register(ShotokuCacheItem cacheItem) {
-        cacheItems.add(cacheItem);
-    }
-
-    private int counter = 0;
-    private final Object counterSync = new Object();
-
-    public String getNextKeyBase() {
-        int c;
-        synchronized(counterSync) { c = counter++; }
-
-        return Constants.SHOTOKU_CACHE_KEY_BASE + c;
-    }
-
-    /*
-     * Update threads management.
-     */
-
-    private final ConcurrentSet<UpdateThread> allUpdateThreads =
-            new ConcurrentHashSet<UpdateThread>();
-    private final LinkedBlockingQueue<UpdateThread> updateThreads =
-            new LinkedBlockingQueue<UpdateThread>();
-    private int updateThreadCount;
-    /**
-     * Number of threads that should be removed, instead of returned
-     */
-    private volatile int toRemove = 0;
-
-    public int getUpdateThreadsCount() {
-        return updateThreads.size();
-    }
-
-    public void setUpdateThreadCount(int n) {
-        synchronized (updateThreads) {
-            int current = updateThreads.size();
-
-            if (current < n) {
-                for (int i=current; i<n; i++) {
-                    UpdateThread ut = new UpdateThread(this);
-                    updateThreads.offer(ut);
-                    allUpdateThreads.add(ut);
-                    ut.start();
-                }
-            } else if (n < current) {
-                toRemove += current - n;
-            }
-        }
-
-        log.info("Update thread count set to: " + n + ".");
-        updateThreadCount = n;
-    }
-
-    public UpdateThread acquireUpdateThread() {
-        try {
-            return updateThreads.take();
-        } catch (InterruptedException e) {
-            log.error("Error while acquireing an update thread (interrupted).", e);
-            return null;
-        }
-    }
-
-    public void releaseUpdateThread(UpdateThread ut) {
-        if (toRemove != 0) {
-            synchronized (updateThreads) {
-                if (toRemove != 0) {
-                    ut.signalExit();
-                    toRemove--;
-                    return;
-                }
-            }
-        }
-
-        updateThreads.offer(ut);
-    }
-
-    public void updateThreadExited(UpdateThread ut) {
-        allUpdateThreads.remove(ut);
-    }
-
-    private void signalExitAllUpdateThreads() {
-        for (UpdateThread ut : allUpdateThreads) {
-            ut.signalExit();
-        }
-    }
-
-    /*
-     * Update function.
-     */
-
-    public void update() {
-        for (ShotokuCacheItem sci : cacheItems) {
-            try {
-                sci.update();
-            } catch (Throwable t) {
-                log.error("Exception while updating a cache item.", t);
-            }
-        }
-    }
-
-    /*
-     * Description functions.
-     */
-
-    public AdministratedService getServiceInstance() {
-        return Tools.getService();
-    }
-
-    public String getServiceId() {
-        return "ShotokuService";
-    }
-
-    public String getServiceName() {
-        return "Shotoku service";
-    }
-
-    public String getServiceDescription() {
-        long now = System.currentTimeMillis();
-
-        StringBuffer sb = new StringBuffer("Cache service.<br />");
-        sb.append("Currently storing ").append(cache.size()).append(" items in the cache ");
-        sb.append("and ").append(cacheItems.size()).append(" ShotokuCacheItem objects.<br />");
-        sb.append("Objects in cache:<br />");
-        for (Object key : cache.keySet()) {
-            sb.append(key.toString()).append(" : ").append(
-                    cache.get(key).getClass().getName()).append(
-                    ", last updated ").append((now - lastUpdates.get(key)) / 1000).append(
-                    " seconds ago.<br />");
-        }
-
-        sb.append("Cache items:<br />");
-        for (ShotokuCacheItem sci : cacheItems) {
-            sb.append(sci.getClass().getName()).append("<br />");
-        }
-
-        return sb.toString();
-    }
-
-    /*
-     * Service administration.
-     */
-
-    private ConcurrentSet<AdministratedServiceGetter> services =
-            new ConcurrentHashSet<AdministratedServiceGetter>();
-
-    public void addAdministratedService(AdministratedServiceGetter asg) {
-        services.add(asg);
-    }
-
-    public Set<AdministratedServiceGetter> getAdministratedServices() {
-        return services;
-    }
-}

Modified: labs/shotoku/trunk-2.6/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java
===================================================================
--- labs/shotoku/trunk-2.6/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java	2007-01-16 00:44:35 UTC (rev 8859)
@@ -33,7 +33,6 @@
 
 import org.jboss.shotoku.ContentManager;
 import org.jboss.shotoku.service.ShotokuService;
-import org.jboss.shotoku.service.ShotokuServiceImpl;
 import org.jboss.shotoku.exceptions.RepositoryException;
 import org.jboss.shotoku.exceptions.NameFormatException;
 import org.jboss.mx.util.MBeanProxyExt;
@@ -58,7 +57,9 @@
                 if (instance == null) {
                     if (ContentManager.isEmbedded()) {
                         // Embedded mode - simply creating a new service instance.
-                        instance = new ShotokuServiceImpl();
+                        instance = (ShotokuService) Thread.currentThread().
+                                getContextClassLoader().loadClass(
+                                "org.jboss.shotoku.service.ShotokuServiceImpl").newInstance();
                         instance.create();
                         instance.start();
                     } else {


Property changes on: labs/shotoku/trunk-2.6/shotoku-base-service
___________________________________________________________________
Name: svn:ignore
   + target


Added: labs/shotoku/trunk-2.6/shotoku-base-service/maven.xml
===================================================================
--- labs/shotoku/trunk-2.6/shotoku-base-service/maven.xml	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/shotoku-base-service/maven.xml	2007-01-16 00:44:35 UTC (rev 8859)
@@ -0,0 +1,17 @@
+<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:u="jelly:util">
+    <goal name="clean">
+        <attainGoal name="prj-clean" />
+    </goal>
+
+    <goal name="build">
+        <attainGoal name="java:compile" />
+        <attainGoal name="ejb" />
+    </goal>
+
+    <goal name="deploy">
+        <ant:copy
+                file="target/shotoku-base-service.jar"
+                tofile="${local.deploy.dir}/shotoku-base-service.ejb3"
+                overwrite="true" />
+    </goal>
+</project>

Added: labs/shotoku/trunk-2.6/shotoku-base-service/project.properties
===================================================================
--- labs/shotoku/trunk-2.6/shotoku-base-service/project.properties	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/shotoku-base-service/project.properties	2007-01-16 00:44:35 UTC (rev 8859)
@@ -0,0 +1,3 @@
+maven.repo.remote=http://repo1.maven.org/maven
+
+maven.final.name=${pom.artifactId}
\ No newline at end of file

Added: labs/shotoku/trunk-2.6/shotoku-base-service/project.xml
===================================================================
--- labs/shotoku/trunk-2.6/shotoku-base-service/project.xml	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/shotoku-base-service/project.xml	2007-01-16 00:44:35 UTC (rev 8859)
@@ -0,0 +1,46 @@
+<?xml version='1.0' encoding='ISO-8859-1'?>
+<project>
+    <pomVersion>3</pomVersion>
+    <extend>../project.xml</extend>
+    <id>shotoku-base-service</id>
+    <name>Shotoku base service</name>
+
+    <dependencies>
+	<dependency>
+            <groupId>shotoku</groupId>
+            <artifactId>shotoku-base</artifactId>
+            <jar>shotoku-base.jar</jar>
+        </dependency>	
+    
+        <dependency>
+            <groupId>jboss</groupId>
+            <artifactId>ejb3-persistence</artifactId>
+            <jar>ejb3-persistence.jar</jar>
+        </dependency>
+        <dependency>
+            <groupId>jboss</groupId>
+            <artifactId>jboss-ejb3x</artifactId>
+            <jar>jboss-ejb3x.jar</jar>
+        </dependency>
+        <dependency>
+            <groupId>jboss</groupId>
+            <artifactId>jboss-j2ee</artifactId>
+            <jar>jboss-j2ee.jar</jar>
+        </dependency>
+        <dependency>
+            <groupId>jboss</groupId>
+            <artifactId>jboss-annotations-ejb3</artifactId>
+            <jar>jboss-annotations-ejb3.jar</jar>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <sourceDirectory>src/java</sourceDirectory>
+        <resources>
+            <resource>
+                <directory>src/etc/</directory>
+                <include>**/*.xml</include>
+            </resource>
+        </resources>
+    </build>
+</project>

Added: labs/shotoku/trunk-2.6/shotoku-base-service/shotoku-base-service.iml
===================================================================
--- labs/shotoku/trunk-2.6/shotoku-base-service/shotoku-base-service.iml	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/shotoku-base-service/shotoku-base-service.iml	2007-01-16 00:44:35 UTC (rev 8859)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="shotoku-aop" />
+    <orderEntry type="module" module-name="shotoku-base" />
+    <orderEntry type="library" name="jboss" level="application" />
+    <orderEntryProperties />
+  </component>
+</module>
+

Added: labs/shotoku/trunk-2.6/shotoku-base-service/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java
===================================================================
--- labs/shotoku/trunk-2.6/shotoku-base-service/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/shotoku-base-service/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java	2007-01-16 00:44:35 UTC (rev 8859)
@@ -0,0 +1,293 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.shotoku.service;
+
+import javax.ejb.Local;
+
+import org.jboss.annotation.ejb.Management;
+import org.jboss.annotation.ejb.Service;
+import org.jboss.shotoku.ContentManager;
+import org.jboss.shotoku.cache.ShotokuCacheItem;
+import org.jboss.shotoku.cache.UpdateThread;
+import org.jboss.shotoku.tools.Constants;
+import org.jboss.shotoku.tools.ConcurrentSet;
+import org.jboss.shotoku.tools.ConcurrentHashSet;
+import org.jboss.shotoku.tools.Tools;
+import org.apache.log4j.Logger;
+
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.Set;
+
+/**
+ * 
+ * @author Adam Warski (adamw at aster.pl)
+ */
+ at Service(objectName=Constants.SHOTOKU_SERVICE_NAME)
+ at Local(ShotokuServiceLocal.class)
+ at Management(ShotokuService.class)
+public class ShotokuServiceImpl extends AdministratedServiceImpl
+        implements ShotokuService, ShotokuServiceLocal {
+    Logger log = Logger.getLogger(AdministratedService.class);
+
+    /*
+     * Service-handling functions.
+     */
+
+    public void create() throws Exception {
+        super.create();
+
+        /*
+         * Setting up content managers.
+         */
+        ContentManager.setup();
+
+        log.info("ContentManager setup completed.  Getting the default service timer interval...");
+        updateThreadCount = ContentManager.getDefaultUpdateThreadCount();
+
+        setTimerInterval(ContentManager.getDefaultServiceInterval());
+
+        super.afterCreate();
+    }
+
+    public void start() throws Exception {
+        super.start();
+
+        log.info("Starting main update thread...");
+
+        startUpdateThread();
+
+        log.info("Starting update threads...");
+        setUpdateThreadCount(updateThreadCount);
+
+        log.info("Reseting keys during update in cache items...");
+        // Reseting just in case - if any thread unexpectadly died.
+        for (ShotokuCacheItem sci : cacheItems) {
+            sci.resetKeysDuringUpdate();
+        }
+
+        super.afterStart();
+    }
+
+    public void stop() {
+        super.stop();
+
+        signalExitAllUpdateThreads();
+        toRemove = 0;
+        log.info("All update threads stopped.");
+    }
+
+    public void destroy() {
+
+    }
+
+    /*
+     * Cache handling
+     */
+
+    private final ConcurrentMap<Object, Object> cache =
+            new ConcurrentHashMap<Object, Object>();
+    private final ConcurrentSet<ShotokuCacheItem> cacheItems =
+            new ConcurrentHashSet<ShotokuCacheItem>();
+    private final ConcurrentMap<Object, Long> lastUpdates =
+            new ConcurrentHashMap<Object, Long>();
+
+    public Object get(Object key) {
+        Object ret = cache.get(key);
+        if (Null.getInstance().equals(ret)) {
+            return null;
+        } else {
+            return ret;
+        }
+    }
+
+    public void put(Object key, Object o) {
+        touch(key);
+
+        if (o == null) {
+            cache.put(key, Null.getInstance());
+        } else {
+            cache.put(key, o);
+        }
+    }
+
+    public void touch(Object key) {
+        lastUpdates.put(key, System.currentTimeMillis());
+    }
+
+    public void remove(Object key) {
+        cache.remove(key);
+    }
+
+    public void register(ShotokuCacheItem cacheItem) {
+        cacheItems.add(cacheItem);
+    }
+
+    private int counter = 0;
+    private final Object counterSync = new Object();
+
+    public String getNextKeyBase() {
+        int c;
+        synchronized(counterSync) { c = counter++; }
+
+        return Constants.SHOTOKU_CACHE_KEY_BASE + c;
+    }
+
+    /*
+     * Update threads management.
+     */
+
+    private final ConcurrentSet<UpdateThread> allUpdateThreads =
+            new ConcurrentHashSet<UpdateThread>();
+    private final LinkedBlockingQueue<UpdateThread> updateThreads =
+            new LinkedBlockingQueue<UpdateThread>();
+    private int updateThreadCount;
+    /**
+     * Number of threads that should be removed, instead of returned
+     */
+    private volatile int toRemove = 0;
+
+    public int getUpdateThreadsCount() {
+        return updateThreads.size();
+    }
+
+    public void setUpdateThreadCount(int n) {
+        synchronized (updateThreads) {
+            int current = updateThreads.size();
+
+            if (current < n) {
+                for (int i=current; i<n; i++) {
+                    UpdateThread ut = new UpdateThread(this);
+                    updateThreads.offer(ut);
+                    allUpdateThreads.add(ut);
+                    ut.start();
+                }
+            } else if (n < current) {
+                toRemove += current - n;
+            }
+        }
+
+        log.info("Update thread count set to: " + n + ".");
+        updateThreadCount = n;
+    }
+
+    public UpdateThread acquireUpdateThread() {
+        try {
+            return updateThreads.take();
+        } catch (InterruptedException e) {
+            log.error("Error while acquireing an update thread (interrupted).", e);
+            return null;
+        }
+    }
+
+    public void releaseUpdateThread(UpdateThread ut) {
+        if (toRemove != 0) {
+            synchronized (updateThreads) {
+                if (toRemove != 0) {
+                    ut.signalExit();
+                    toRemove--;
+                    return;
+                }
+            }
+        }
+
+        updateThreads.offer(ut);
+    }
+
+    public void updateThreadExited(UpdateThread ut) {
+        allUpdateThreads.remove(ut);
+    }
+
+    private void signalExitAllUpdateThreads() {
+        for (UpdateThread ut : allUpdateThreads) {
+            ut.signalExit();
+        }
+    }
+
+    /*
+     * Update function.
+     */
+
+    public void update() {
+        for (ShotokuCacheItem sci : cacheItems) {
+            try {
+                sci.update();
+            } catch (Throwable t) {
+                log.error("Exception while updating a cache item.", t);
+            }
+        }
+    }
+
+    /*
+     * Description functions.
+     */
+
+    public AdministratedService getServiceInstance() {
+        return Tools.getService();
+    }
+
+    public String getServiceId() {
+        return "ShotokuService";
+    }
+
+    public String getServiceName() {
+        return "Shotoku service";
+    }
+
+    public String getServiceDescription() {
+        long now = System.currentTimeMillis();
+
+        StringBuffer sb = new StringBuffer("Cache service.<br />");
+        sb.append("Currently storing ").append(cache.size()).append(" items in the cache ");
+        sb.append("and ").append(cacheItems.size()).append(" ShotokuCacheItem objects.<br />");
+        sb.append("Objects in cache:<br />");
+        for (Object key : cache.keySet()) {
+            sb.append(key.toString()).append(" : ").append(
+                    cache.get(key).getClass().getName()).append(
+                    ", last updated ").append((now - lastUpdates.get(key)) / 1000).append(
+                    " seconds ago.<br />");
+        }
+
+        sb.append("Cache items:<br />");
+        for (ShotokuCacheItem sci : cacheItems) {
+            sb.append(sci.getClass().getName()).append("<br />");
+        }
+
+        return sb.toString();
+    }
+
+    /*
+     * Service administration.
+     */
+
+    private ConcurrentSet<AdministratedServiceGetter> services =
+            new ConcurrentHashSet<AdministratedServiceGetter>();
+
+    public void addAdministratedService(AdministratedServiceGetter asg) {
+        services.add(asg);
+    }
+
+    public Set<AdministratedServiceGetter> getAdministratedServices() {
+        return services;
+    }
+}

Modified: labs/shotoku/trunk-2.6/shotoku-file-access/maven.xml
===================================================================
--- labs/shotoku/trunk-2.6/shotoku-file-access/maven.xml	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/shotoku-file-access/maven.xml	2007-01-16 00:44:35 UTC (rev 8859)
@@ -12,9 +12,10 @@
     </goal>
 
     <goal name="deploy">
-        <ant:copy
-                file="target/shotoku-file-access.war"
-                todir="${local.deploy.dir}" />
+        <ant:copy file="target/shotoku-file-access.jar"
+                  todir="../target/${shotoku.sar.dir}" />
+        <ant:copy file="target/shotoku-file-access.war"
+                  todir="${local.deploy.dir}" />
     </goal>
 
     <goal name="clean">

Modified: labs/shotoku/trunk-2.6/shotoku-file-access/project.properties
===================================================================
--- labs/shotoku/trunk-2.6/shotoku-file-access/project.properties	2007-01-15 21:22:39 UTC (rev 8858)
+++ labs/shotoku/trunk-2.6/shotoku-file-access/project.properties	2007-01-16 00:44:35 UTC (rev 8859)
@@ -4,3 +4,6 @@
 
 maven.final.name=${pom.artifactId}
 
+maven.war.classes.excludes=**/*
+maven.jar.includes=**/*.class
+




More information about the jboss-svn-commits mailing list