From: <jbo...@li...> - 2006-05-31 16:08:04
|
Author: adamw Date: 2006-05-31 12:07:56 -0400 (Wed, 31 May 2006) New Revision: 4525 Added: labs/shotoku/trunk/shotoku-tags/ labs/shotoku/trunk/shotoku-tags/maven.xml labs/shotoku/trunk/shotoku-tags/project.properties labs/shotoku/trunk/shotoku-tags/project.xml labs/shotoku/trunk/shotoku-tags/shotoku-tags.iml labs/shotoku/trunk/shotoku-tags/src/ labs/shotoku/trunk/shotoku-tags/src/java/ labs/shotoku/trunk/shotoku-tags/src/java/org/ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagService.java labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagTools.java labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceLocal.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-86 Initial checkin Property changes on: labs/shotoku/trunk/shotoku-tags ___________________________________________________________________ Name: svn:ignore + target Added: labs/shotoku/trunk/shotoku-tags/maven.xml =================================================================== --- labs/shotoku/trunk/shotoku-tags/maven.xml 2006-05-31 15:52:22 UTC (rev 4524) +++ labs/shotoku/trunk/shotoku-tags/maven.xml 2006-05-31 16:07:56 UTC (rev 4525) @@ -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-tags.jar" + tofile="../target/${shotoku.sar.dir}/shotoku-tags.ejb3" + overwrite="true" /> + </goal> +</project> Added: labs/shotoku/trunk/shotoku-tags/project.properties =================================================================== --- labs/shotoku/trunk/shotoku-tags/project.properties 2006-05-31 15:52:22 UTC (rev 4524) +++ labs/shotoku/trunk/shotoku-tags/project.properties 2006-05-31 16:07:56 UTC (rev 4525) @@ -0,0 +1,4 @@ +maven.repo.remote=http://repository.atlassian.com,http://www.ibiblio.org/maven,http://dist.codehaus.org/ + +maven.final.name=${pom.artifactId} + Added: labs/shotoku/trunk/shotoku-tags/project.xml =================================================================== --- labs/shotoku/trunk/shotoku-tags/project.xml 2006-05-31 15:52:22 UTC (rev 4524) +++ labs/shotoku/trunk/shotoku-tags/project.xml 2006-05-31 16:07:56 UTC (rev 4525) @@ -0,0 +1,25 @@ +<?xml version='1.0' encoding='ISO-8859-1'?> +<project> + <pomVersion>3</pomVersion> + <extend>../project.xml</extend> + <id>shotoku-tags</id> + <name>Shotoku tags</name> + + <dependencies> + <dependency> + <groupId>shotoku</groupId> + <artifactId>shotoku-base</artifactId> + <jar>shotoku-base.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/shotoku-tags/shotoku-tags.iml =================================================================== --- labs/shotoku/trunk/shotoku-tags/shotoku-tags.iml 2006-05-31 15:52:22 UTC (rev 4524) +++ labs/shotoku/trunk/shotoku-tags/shotoku-tags.iml 2006-05-31 16:07:56 UTC (rev 4525) @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module version="4" relativePaths="true" type="JAVA_MODULE"> + <component name="ModuleRootManager" /> + <component name="NewModuleRootManager"> + <output url="file://$MODULE_DIR$/target" /> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" /> + </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" /> + <orderEntry type="library" name="commons" level="application" /> + <orderEntryProperties /> + </component> +</module> + Added: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagService.java =================================================================== --- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagService.java 2006-05-31 15:52:22 UTC (rev 4524) +++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagService.java 2006-05-31 16:07:56 UTC (rev 4525) @@ -0,0 +1,10 @@ +package org.jboss.shotoku.tags; + +import org.jboss.shotoku.service.AdministratedService; + +/** + * @author Adam Warski (ad...@as...) + */ +public interface TagService extends AdministratedService { + +} Added: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagTools.java =================================================================== --- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagTools.java 2006-05-31 15:52:22 UTC (rev 4524) +++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagTools.java 2006-05-31 16:07:56 UTC (rev 4525) @@ -0,0 +1,43 @@ +package org.jboss.shotoku.tags; + +import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.tags.service.TagServiceImpl; +import org.jboss.mx.util.MBeanProxyExt; +import org.jboss.mx.util.MBeanServerLocator; + +/** + * @author Adam Warski (ad...@as...) + */ +public class TagTools { + public static final String TAG_SERVICE_NAME = "shotoku:service=tag"; + + private static TagService instance; + + /** + * Gets an instance of Shotoku tag service - this should be always the same + * the object, so the dirty sets work properly. + * @return An instance of org.jboss.shotoku.svn.SvnService + */ + public static TagService getService() { + try { + if (instance == null) { + if (ContentManager.isEmbedded()) { + // Embedded mode - simply creating a new service instance. + instance = new TagServiceImpl(); + instance.create(); + instance.start(); + } else { + // Application server mode - creating a proxy to a mbean. + instance = (TagService) MBeanProxyExt.create( + TagService.class, + TAG_SERVICE_NAME, + MBeanServerLocator.locate()); + } + } + + return instance; + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} Added: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java =================================================================== --- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java 2006-05-31 15:52:22 UTC (rev 4524) +++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceImpl.java 2006-05-31 16:07:56 UTC (rev 4525) @@ -0,0 +1,141 @@ +/* + * 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.tags.service; + +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.Calendar; +import java.util.Set; + +import javax.ejb.Local; + +import org.apache.commons.configuration.Configuration; +import org.apache.log4j.Logger; +import org.jboss.annotation.ejb.Management; +import org.jboss.annotation.ejb.Service; +import org.jboss.annotation.ejb.Depends; +import org.jboss.shotoku.svn.SvnService; +import org.jboss.shotoku.svn.SvnTools; +import org.jboss.shotoku.svn.SvnContentManager; +import org.jboss.shotoku.svn.service.delayed.DelayedOperation; +import org.jboss.shotoku.tools.Constants; +import org.jboss.shotoku.tools.Tools; +import org.jboss.shotoku.service.AdministratedServiceImpl; +import org.jboss.shotoku.service.AdministratedServiceGetter; +import org.jboss.shotoku.service.AdministratedService; +import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.tags.service.TagServiceLocal; +import org.jboss.shotoku.tags.TagService; +import org.jboss.shotoku.tags.TagTools; +import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; +import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; + +/** + * @author Adam Warski (ad...@as...) + * @author Damon Sicore (da...@si...) + */ +@Service(objectName=TagTools.TAG_SERVICE_NAME) +@Local(TagServiceLocal.class) +@Management(TagService.class) +@Depends(Constants.SHOTOKU_SERVICE_NAME) +public class TagServiceImpl extends AdministratedServiceImpl + implements TagService, TagServiceLocal { + private static final Logger log = Logger.getLogger(TagService.class); + + /* + * Service lifecycle management. + */ + + public void create() throws Exception { + super.create(); + + // Enabling administration for this service. + Tools.getService().addAdministratedService(new AdministratedServiceGetter() { + public AdministratedService getService() { + return TagTools.getService(); + } + }); + + log.info("Tag service created."); + } + + public void start() throws Exception { + super.start(); + + // Starting the updater thread. + new Thread() { + { + setDaemon(true); + } + + public void run() { + while (getServiceRunnable()) { + try { + sleep(getTimerInterval()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + update(); + } catch (Throwable t) { + // Making sure that an exception won't stop the thread. + } + + setLastUpdate(Calendar.getInstance().getTimeInMillis()); + } + + log.info("Tag service deaemon thread terminated."); + } + }.start(); + + log.info("Tag service started with update interval: "+ getTimerInterval()); + } + + public void stop() { + super.stop(); + log.info("Tag service signaled to stop."); + } + + public void destroy() { + } + + /* + * Timer-handling functions. + */ + + public void update() { + + } + + public String getServiceId() { + return "ShotokuTagService"; + } + + public String getServiceName() { + return "Tag service"; + } + + public String getServiceDescription() { + return "Shotoku tag service"; + } +} Added: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceLocal.java =================================================================== --- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceLocal.java 2006-05-31 15:52:22 UTC (rev 4524) +++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/service/TagServiceLocal.java 2006-05-31 16:07:56 UTC (rev 4525) @@ -0,0 +1,30 @@ +/* + * 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.tags.service; + +/** + * @author Adam Warski (ad...@as...) + * @author Damon Sicore (da...@si...) + */ +public interface TagServiceLocal { + +} |