--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><fileset-config file-format-version="1.1.0" simple-config="false">
+<fileset name="src" enabled="true" check-config-name="Uguu Checks" type="remote" location="http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml" description="Uguu Software のコーディング スタイルです。"><file-match-pattern match-pattern="src\\java" include-pattern="true"/>
+</fileset>
+</fileset-config>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-0.1.8.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>uguu-backup</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.mevenide.ui.mavenbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.mevenide.ui.mavennature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <pomVersion>3</pomVersion>
+ <organization>
+ <name>Uguu Software</name>
+ <url>http://wiki.livedoor.jp/uguuxp/</url>
+ <logo>http://image02.wiki.livedoor.jp/u/p/uguuxp/82487bf1fed6e9af.png</logo>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports>
+<!--
+ <report>maven-changelog-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-checkstyle-plugin</report>
+-->
+ <report>maven-linkcheck-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-faq-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
--- /dev/null
+maven.compile.debug=true
+maven.compile.encoding=utf-8
+maven.compile.source=1.5
+
+maven.docs.outputencoding=utf-8
+
+maven.checkstyle.check.tests=false
+maven.checkstyle.header.file=${basedir}/LICENSE.txt
+maven.checkstyle.propertiesURL=http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml
+
+maven.test.failure.ignore=true
+
+maven.xdoc.date=right
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.distributionUrl=http://uguu-sysman.sourceforge.jp/maven/uguu-http-test/jars
+maven.xdoc.distributionType=jar
+
+maven.repo.remote=http://www.ibiblio.org/maven/,http://uguu-sysman.sourceforge.jp/maven/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <extend>${basedir}/project-base.xml</extend>
+ <artifactId>uguu-backup</artifactId>
+ <name>uguu-backup</name>
+ <groupId>uguu-backup</groupId>
+ <currentVersion>0.1.5</currentVersion>
+ <inceptionYear>2005</inceptionYear>
+ <package>jp.gr.java_conf.uguu.backup</package>
+ <description>バックアップを行います。</description>
+ <repository>
+ <connection>scm:cvs:pserver:anonymous@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-backup</connection>
+ <developerConnection>scm:cvs:ext:uguu@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-backup</developerConnection>
+ <url>http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/uguu-sysman/uguu-backup/</url>
+ </repository>
+ <developers>
+ <developer>
+ <name>uguu</name>
+ <id>2</id>
+ <email>uguu@users.sourceforge.jp</email>
+ <organization>Uguu Software</organization>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>BSD License</name>
+ </license>
+ </licenses>
+ <versions>
+ <version>
+ <name>0.1.5</name>
+ <tag>RELEASE_0_1_5</tag>
+ </version>
+ <version>
+ <name>0.1.4</name>
+ <tag>RELEASE_0_1_4</tag>
+ </version>
+ <version>
+ <name>0.1.3</name>
+ <tag>RELEASE_0_1_3</tag>
+ </version>
+ <version>
+ <name>0.1.2</name>
+ <tag>RELEASE_0_1_2</tag>
+ </version>
+ <version>
+ <name>0.1.1</name>
+ <tag>RELEASE_0_1_1</tag>
+ </version>
+ <version>
+ <name>0.1.0</name>
+ <tag>RELEASE_0_1_0</tag>
+ </version>
+ </versions>
+ <dependencies>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler</artifactId>
+ <version>0.1.8</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.backup.file;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+// TODO 差分バックアップも可能にする。
+// TODO バックアップ後、アーカイブにまとめられるようにする。
+/**
+ * <p>
+ * ファイルのバックアップを行います。
+ * 複数のファイルセットの、完全バックアップ、増分バックアップを行うことが出来ます。
+ * </p>
+ * <p>
+ * TODO 現在は完全バックアップのみ可能です。
+ * </p>
+ * @author uguu
+ */
+public class FileBackup implements IFileBackup {
+ /**
+ * <p>バックアップ先のディレクトリ。</p>
+ */
+ private String destDir;
+ /**
+ * <p>バックアップするファイル セットのリスト。</p>
+ */
+ private List<IFileSet> fileSets = new ArrayList<IFileSet>();
+ /**
+ * <p>
+ * {@link FileBackup} クラスの新しいインスタンスを初期化します。
+ * </p>
+ */
+ public FileBackup() {
+ // 何もしません。
+ }
+ /**
+ * <p>
+ * バックアップ先のディレクトリを指定して、 {@link FileBackup} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param destDir バックアップ先のディレクトリ。
+ */
+ public FileBackup(String destDir) {
+ this.destDir = destDir;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public String getDestinationDirectory() {
+ return this.destDir;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void setDestinationDirectory(String destDir) {
+ this.destDir = destDir;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public List<IFileSet> getFileSets() {
+ return this.fileSets;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void backup() throws IOException {
+ if (this.destDir == null) {
+ throw new IllegalStateException("バックアップ先のディレクトリが設定されていません。");
+ }
+ File destRootDir = new File(this.destDir);
+ if (destRootDir.exists()) {
+ if (!destRootDir.isDirectory()) {
+ throw new IllegalStateException("バックアップ先のディレクトリ " + destRootDir.getCanonicalPath() + " がディレクトリを表していません。");
+ }
+ } else {
+ if (!destRootDir.mkdirs()) {
+ throw new IOException("バックアップ先のディレクトリ " + destRootDir.getCanonicalPath() + " の作成に失敗しました。");
+ }
+ }
+ if (destRootDir.listFiles().length > 0) {
+ throw new IllegalStateException("バックアップ先のディレクトリが空ではありません。");
+ }
+ IFileSetCopy fileSetCopy = new FileSetCopy();
+ for (IFileSet fileSet : this.fileSets) {
+ File d = this.getDestDir(destRootDir, fileSet);
+ if (!d.mkdirs()) {
+ throw new IOException("ディレクトリ " + d.getCanonicalPath() + " の作成に失敗しました。");
+ }
+ fileSetCopy.copy(fileSet, d);
+ }
+ }
+ /**
+ * <p>
+ * ファイルセットのバックアップ先ディレクトリを返します。
+ * </p>
+ * @param destRootDir バックアップ先ディレクトリ。
+ * @param fileSet バックアップするファイルセット。
+ * @return ファイルセットのバックアップ先ディレクトリ。
+ * @throws IOException 入出力エラーが発生した場合。
+ */
+ private File getDestDir(File destRootDir, IFileSet fileSet) throws IOException {
+ String dirName = new File(fileSet.getBaseDirectory()).getCanonicalFile().getName(); // ベースディレクトリの正規の形式から、ディレクトリの名前を取得します。
+ if (dirName.length() == 0) {
+ dirName = "ROOT";
+ }
+ String destDirPath = destRootDir.getCanonicalPath() + File.separator + dirName;
+ for (int i = -1;; i++) {
+ File d;
+ if (i == -1) {
+ d = new File(destDirPath);
+ } else {
+ d = new File(destDirPath + "." + i);
+ }
+ if (!d.exists()) {
+ return d;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.backup.file;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Stack;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * <p>
+ * ファイルの集合 (ファイルセット) を表します。
+ * </p>
+ * <p>
+ * あるディレクトリを起点として、その下のファイルを表します。
+ * 指定したパターンにマッチするファイルを含むことができます。
+ * 含むパターンを省略すると、ディレクトリ以下のすべてのファイル、ディレクトリが対象となります。
+ * 指定したパターンにマッチするファイルを除外することができます。
+ * </p>
+ * @author uguu
+ */
+public class FileSet implements IFileSet {
+ /**
+ * <p>
+ * 集合に含まれるファイルを列挙する列挙子です。
+ * </p>
+ * @author uguu
+ */
+ class FileSetIterator implements Iterator<File> {
+ /**
+ * <p>集合に含むパターンのリスト。</p>
+ */
+ private List<Pattern> includePatterns;
+ /**
+ * <p>集合に含まないパターンのリスト。</p>
+ */
+ private List<Pattern> excludePatterns;
+ /**
+ * 列挙中のファイルのスタック。
+ */
+ private Stack<Iterator<File>> fileStack = new Stack<Iterator<File>>();
+ /**
+ * 次のファイル。
+ */
+ private File nextFile;
+ /**
+ * <p>
+ * {@link FileSetIterator} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param baseDir ベース ディレクトリ。
+ * @param includePatterns 集合に含むパターンのリスト。
+ * @param excludePatterns 集合に含まないパターンのリスト。
+ * @throws IllegalStateException ベース ディレクトリが設定されていない場合。
+ * @throws IOException 入出力エラーが発生した場合。
+ */
+ FileSetIterator(String baseDir, List<String> includePatterns, List<String> excludePatterns) throws IOException {
+ // ベースディレクトリの初期化。
+ File dir = new File(baseDir);
+ if (!dir.exists()) {
+ throw new FileNotFoundException("ベース ディレクトリが存在しません。");
+ }
+ if (!dir.isDirectory()) {
+ throw new FileNotFoundException("ベース ディレクトリがディレクトリを表していません。");
+ }
+ // 含むパターンのリストの初期化。
+ if (includePatterns == null) {
+ throw new NullPointerException("includePatterns");
+ }
+ this.includePatterns = new ArrayList<Pattern>();
+ for (String pattern : includePatterns) {
+ this.includePatterns.add(Pattern.compile(pattern));
+ }
+ // 含まないパターンのリストの初期化。
+ if (excludePatterns == null) {
+ throw new NullPointerException("excludePatterns");
+ }
+ this.excludePatterns = new ArrayList<Pattern>();
+ for (String pattern : excludePatterns) {
+ this.excludePatterns.add(Pattern.compile(pattern));
+ }
+ this.fileStack.push(Arrays.asList(dir.listFiles()).iterator());
+ this.nextFile = this.nextFile(this.fileStack);
+ }
+ /**
+ * <p>
+ * 次のファイルが存在するかどうかを判断します。
+ * </p>
+ * @return 次のファイルが存在する場合は true 。
+ */
+ public boolean hasNext() {
+ return (this.nextFile != null);
+ }
+ /**
+ * <p>
+ * 次のファイルを返します。
+ * </p>
+ * @return 次のファイル。
+ * @throws NoSuchElementException 次のファイルが存在しない場合。
+ * @throws IllegalStateException ファイルの入出力が原因で、次のファイルの取得に失敗した場合。
+ */
+ public File next() {
+ if (this.nextFile == null) {
+ throw new NoSuchElementException();
+ }
+ File result = this.nextFile;
+ try {
+ this.nextFile = this.nextFile(this.fileStack);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ return result;
+ }
+ /**
+ * <p>
+ * ファイル スタックを走査し、次のファイルを返します。
+ * </p>
+ * @param fileStack ファイル スタック。
+ * @return 次のファイル。
+ * 次のファイルが存在しない (走査が終了した) 場合は null 。
+ * @throws IOException 入出力エラーが発生した場合。
+ */
+ private File nextFile(Stack<Iterator<File>> fileStack) throws IOException {
+ while (!fileStack.empty()) {
+ Iterator<File> i = fileStack.peek();
+ while (i.hasNext()) {
+ File file = i.next();
+ if (this.isIncludeFile(file)) {
+ if (file.isFile()) {
+ return file;
+ } else if (file.isDirectory()) {
+ fileStack.push(Arrays.asList(file.listFiles()).iterator());
+ return file;
+ } else {
+ throw new UnknownError();
+ }
+ }
+ }
+ fileStack.pop();
+ }
+ return null;
+ }
+ /**
+ * <p>
+ * 指定したファイルが集合に含むかどうかを判断します。
+ * </p>
+ * @param file 判断する対象のファイル。
+ * @return 集合に含む場合は true 、含まない場合は false 。
+ * @throws IOException 入出力エラーが発生した場合。
+ */
+ private boolean isIncludeFile(File file) throws IOException {
+ String path = file.getCanonicalPath();
+ if (this.includePatterns.size() > 0) {
+ boolean isInclude = false;
+ for (Pattern p : this.includePatterns) {
+ Matcher m = p.matcher(path);
+ if (m.matches()) {
+ isInclude = true;
+ }
+ }
+ if (!isInclude) {
+ return false;
+ }
+ }
+ if (this.excludePatterns.size() > 0) {
+ for (Pattern p : this.excludePatterns) {
+ Matcher m = p.matcher(path);
+ if (m.matches()) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ /**
+ * <p>
+ * 常に {@link UnsupportedOperationException} 例外をスローします。
+ * </p>
+ * @throws UnsupportedOperationException メソッドを呼び出した場合。
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+ /**
+ * <p>ベース ディレクトリ。</p>
+ */
+ private String baseDir;
+ /**
+ * <p>集合に含むパターンのリスト。</p>
+ */
+ private List<String> includePatterns = new ArrayList<String>();
+ /**
+ * <p>集合に含まないパターンのリスト。</p>
+ */
+ private List<String> excludePatterns = new ArrayList<String>();
+ /**
+ * <p>
+ * {@link FileSet} クラスの新しいインスタンスを初期化します。
+ * </p>
+ */
+ public FileSet() {
+ // 何もしません。
+ }
+ /**
+ * <p>
+ * ベース ディレクトリを指定して、 {@link FileSet} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param baseDir ベース ディレクトリ。
+ */
+ public FileSet(String baseDir) {
+ this.baseDir = baseDir;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void setBaseDirectory(String baseDir) {
+ this.baseDir = baseDir;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public String getBaseDirectory() {
+ return this.baseDir;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public List<String> getIncludePatterns() {
+ return this.includePatterns;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public List<String> getExcludePatterns() {
+ return this.excludePatterns;
+ }
+ /**
+ * <p>
+ * 集合に含まれるファイルを列挙する列挙子を返します。
+ * </p>
+ * @return ファイルを列挙する列挙子。
+ * @throws IllegalStateException ファイルの入出力が原因で、列挙子の構築に失敗した場合。
+ */
+ public Iterator<File> iterator() {
+ try {
+ return new FileSetIterator(this.baseDir, this.includePatterns, this.excludePatterns);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.backup.file;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * ファイルセットを別のディレクトリにコピーします。
+ * </p>
+ * @author uguu
+ */
+public class FileSetCopy implements IFileSetCopy {
+ /**
+ * コピーに使用するバッファの長さ。
+ */
+ public static final int BUFFER_LENGTH = 1024 * 1024;
+ /**
+ * <p>リスナーのリスト。</p>
+ */
+ private List<IFileSetCopyListener> listeners = new ArrayList<IFileSetCopyListener>();
+ /**
+ * {@inheritDoc}
+ */
+ public List<IFileSetCopyListener> getListeners() {
+ return this.listeners;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void copy(IFileSet src, File dest) throws IOException {
+ // TODO 空のディレクトリもバックアップ対象にする。
+ // 引数をチェック。
+ if (src == null) {
+ throw new NullPointerException("src");
+ }
+ if (dest == null) {
+ throw new NullPointerException("dest");
+ }
+ File srcDir = new File(src.getBaseDirectory());
+ if (!srcDir.isDirectory()) {
+ throw new IllegalArgumentException("src.baseDirectory がディレクトリを表していません。");
+ }
+ if (this.isIncludeSubDirectory(srcDir, dest)) {
+ throw new IllegalArgumentException("コピー先のディレクトリが、ファイルセットのベース ディレクトリのサブディレクトリになっています。");
+ }
+ if (!dest.exists()) {
+ if (!dest.mkdirs()) {
+ throw new IOException(dest.getCanonicalPath() + " ディレクトリの作成に失敗しました。");
+ }
+ }
+ if (!dest.isDirectory()) {
+ throw new IllegalArgumentException("dest 引数がディレクトリを表していません。");
+ }
+ if (dest.listFiles().length > 0) {
+ throw new IllegalArgumentException("コピー先のディレクトリが空ではありません。");
+ }
+ // 全てのファイルのリストを取得。
+ List<File> srcFiles = new ArrayList<File>();
+ List<File> destFiles = new ArrayList<File>();
+ for (File srcFile : src) {
+ srcFiles.add(srcFile);
+ File destFile = this.getDestFile(srcFile, srcDir, dest);
+ destFiles.add(destFile);
+ }
+ // ファイルをコピー。
+ for (int copyedFiles = 0; copyedFiles < srcFiles.size();) {
+ File srcFile = srcFiles.get(copyedFiles);
+ File destFile = destFiles.get(copyedFiles);
+ if (srcFile.isFile()) {
+ this.raiseEvent(copyedFiles, srcFiles.size(), srcFile, destFile, 0);
+ if (!destFile.getParentFile().exists()) {
+ if (!destFile.getParentFile().mkdirs()) {
+ throw new IOException(destFile.getParentFile().getCanonicalPath() + " ディレクトリの作成に失敗しました。");
+ }
+ }
+ if (!destFile.createNewFile()) {
+ throw new IOException(destFile.getCanonicalPath() + " ファイルの作成に失敗しました。");
+ }
+ long copyedBytes = 0;
+ InputStream in = new BufferedInputStream(new FileInputStream(srcFile));
+ try {
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(destFile));
+ try {
+ byte[] buffer = new byte[BUFFER_LENGTH];
+ while (true) {
+ int len = in.read(buffer);
+ if (len == -1) {
+ break;
+ }
+ out.write(buffer, 0, len);
+ copyedBytes += len;
+ this.raiseEvent(copyedFiles, srcFiles.size(), srcFile, destFile, copyedBytes);
+ }
+ } finally {
+ out.close();
+ }
+ } finally {
+ in.close();
+ }
+ copyedFiles++;
+ } else if (srcFile.isDirectory()) {
+ this.raiseEvent(copyedFiles, srcFiles.size(), srcFile, destFile, 0);
+ if (!destFile.mkdirs()) {
+ throw new IOException(destFile.getCanonicalPath() + " ディレクトリの作成に失敗しました。");
+ }
+ copyedFiles++;
+ }
+ this.raiseEvent(copyedFiles, srcFiles.size(), srcFile, destFile, srcFile.length());
+ }
+ }
+ /**
+ * <p>
+ * ディレクトリ 1 がディレクトリ 2 をサブディレクトリとして含んでいるかどうかを調べます。
+ * </p>
+ * @param dir1 ディレクトリ 1 。
+ * @param dir2 ディレクトリ 2 。
+ * @return サブディレクトリとして含んでいる場合は true 、含んでいない場合は false 。
+ * @throws IOException パスの正規の形式の取得に失敗した場合。
+ */
+ private boolean isIncludeSubDirectory(File dir1, File dir2) throws IOException {
+ if (dir1.getCanonicalPath().equals(dir2.getCanonicalPath())) {
+ return true;
+ }
+ File parentDir = dir2.getParentFile();
+ if (parentDir == null) {
+ return false;
+ }
+ return this.isIncludeSubDirectory(dir1, parentDir);
+ }
+ /**
+ * <p>
+ * 元ファイルの元ディレクトリからの相対パスを求め、先ファイルを構築します。
+ * </p>
+ * <p>
+ * 元ファイルのパスから元ディレクトリのパスを取り除きます。
+ * これで相対パスが得られます。
+ * その相対パスと咲きディレクトリのパスから、先ファイルのパスを構築します。
+ * </p>
+ * @param srcFile 元ファイル。
+ * @param srcDir 元ディレクトリ。
+ * @param destDir 先ディレクトリ。
+ * @return 先ファイル。
+ * @throws IOException パスの正規の形式の取得に失敗した場合。
+ */
+ private File getDestFile(File srcFile, File srcDir, File destDir) throws IOException {
+ String relativePath = srcFile.getCanonicalPath().substring(srcDir.getCanonicalPath().length());
+ File destFile = new File(destDir, relativePath);
+ return destFile;
+ }
+ private void raiseEvent(int copyedFiles, int targetFiles, File sourceFile, File destinationFile, long copyedBytes) {
+ IFileSetCopyEvent e = new FileSetCopyEvent(copyedFiles, targetFiles, sourceFile, destinationFile, copyedBytes);
+ for (IFileSetCopyListener l : this.listeners) {
+ l.copying(this, e);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.backup.file;
+
+import java.io.File;
+
+/**
+ * <p>
+ * ファイルセットのコピーの進捗情報を持ちます。
+ * </p>
+ * @author uguu
+ */
+public class FileSetCopyEvent implements IFileSetCopyEvent {
+ /**
+ * <p>コピーが完了したファイルの個数。</p>
+ */
+ private int copyedFiles;
+ /**
+ * <p>コピー対象のファイルの個数。</p>
+ */
+ private int targetFiles;
+ /**
+ * <p>コピー元のファイル。</p>
+ */
+ private File sourceFile;
+ /**
+ * <p>コピー先のファイル。</p>
+ */
+ private File destinationFile;
+ /**
+ * <p>コピーが完了したバイト数。</p>
+ */
+ private long copyedBytes;
+ /**
+ * <p>
+ * {@link FileSetCopyEvent} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param copyedFiles コピーが完了したファイルの個数。
+ * @param targetFiles コピー対象のファイルの個数。
+ * @param sourceFile コピー元のファイル。
+ * @param destinationFile コピー先のファイル。
+ * @param copyedBytes コピーが完了したバイト数。
+ */
+ public FileSetCopyEvent(int copyedFiles, int targetFiles, File sourceFile, File destinationFile, long copyedBytes) {
+ this.copyedFiles = copyedFiles;
+ this.targetFiles = targetFiles;
+ this.sourceFile = sourceFile;
+ this.destinationFile = destinationFile;
+ this.copyedBytes = copyedBytes;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public int getCopyedFiles() {
+ return this.copyedFiles;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public int getTargetFiles() {
+ return this.targetFiles;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public File getSourceFile() {
+ return this.sourceFile;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public File getDestinationFile() {
+ return this.destinationFile;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public long getCopyedBytes() {
+ return this.copyedBytes;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.backup.file;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * <p>
+ * ファイルのバックアップを行います。
+ * 複数のファイルセットの、完全バックアップ、増分バックアップを行うことが出来ます。
+ * </p>
+ * @author uguu
+ */
+public interface IFileBackup {
+ /**
+ * <p>
+ * バックアップ先のディレクトリを返します。
+ * </p>
+ * @return バックアップ先のディレクトリ。
+ */
+ String getDestinationDirectory();
+ /**
+ * <p>
+ * バックアップ先のディレクトリを設定します。
+ * </p>
+ * @param destDir バックアップ先のディレクトリ。
+ */
+ void setDestinationDirectory(String destDir);
+ /**
+ * <p>
+ * バックアップするファイル セットのリストを返します。
+ * </p>
+ * @return バックアップするファイル セットのリスト。
+ */
+ List<IFileSet> getFileSets();
+ /**
+ * <p>
+ * バックアップを行います。
+ * </p>
+ * @throws IllegalStateException バックアップ先のディレクトリが設定されていない場合。
+ * バックアップ先のディレクトリがディレクトリを表していない場合。
+ * @throws IOException バックアップ先のディレクトリの作成に失敗した場合。
+ * バックアップ先のディレクトリが既に存在する場合。
+ * 入出力エラーが発生した場合。
+ */
+ void backup() throws IOException;
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.backup.file;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * <p>
+ * ファイルの集合 (ファイルセット) を表します。
+ * </p>
+ * <p>
+ * あるディレクトリを起点として、その下のファイルを表します。
+ * 指定したパターンにマッチするファイルを含むことができます。
+ * 含むパターンを省略すると、ディレクトリ以下のすべてのファイル、ディレクトリが対象となります。
+ * 指定したパターンにマッチするファイルを除外することができます。
+ * </p>
+ * @author uguu
+ */
+public interface IFileSet extends Iterable<File> {
+ /**
+ * <p>
+ * ベース ディレクトリを設定します。
+ * ベース ディレクトリとは、ファイルセットの起点となるディレクトリです。
+ * </p>
+ * @param baseDir ベース ディレクトリ。
+ * @throws NullPointerException baseDir 引数が null の場合。
+ */
+ void setBaseDirectory(String baseDir);
+ /**
+ * <p>
+ * ベース ディレクトリを返します。
+ * </p>
+ * @return ベース ディレクトリ。
+ */
+ String getBaseDirectory();
+ /**
+ * <p>
+ * 集合に含むパターンのリストです。
+ * 1 つもパターンが無い場合、全てのファイルが集合に含まれます。
+ * </p>
+ * @return 集合に含むパターンのリスト。
+ */
+ List<String> getIncludePatterns();
+ /**
+ * <p>
+ * 集合から除外するパターンのリストです。
+ * </p>
+ * @return 集合から除外するパターンのリスト。
+ */
+ List<String> getExcludePatterns();
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.backup.file;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * <p>
+ * ファイルセットを別のディレクトリにコピーします。
+ * </p>
+ * @author uguu
+ */
+public interface IFileSetCopy {
+ /**
+ * <p>
+ * リスナーのリストを返します。
+ * </p>
+ * @return リスナーのリスト。
+ */
+ List<IFileSetCopyListener> getListeners();
+ /**
+ * <p>
+ * ファイルセットを別のディレクトリへコピーします。
+ * </p>
+ * @param src コピー元のファイルセット。
+ * @param dest コピー先のディレクトリ。
+ * @throws NullPointerException src, dest 引数が null の場合。
+ * @throws IllegalArgumentException dest 引数がディレクトリを表していない場合。
+ * コピー先のディレクトリが、ファイルセットのベース ディレクトリの子ディレクトリの場合。
+ * コピー先のディレクトリが空ではない場合。
+ * @throws IOException 入出力エラーが発生した場合。
+ */
+ void copy(IFileSet src, File dest) throws IOException;
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.backup.file;
+
+import java.io.File;
+
+/**
+ * <p>
+ * ファイルセットのコピーの進捗情報を持ちます。
+ * </p>
+ * @author uguu
+ */
+public interface IFileSetCopyEvent {
+ /**
+ * <p>
+ * コピーが完了したファイルの個数を返します。
+ * </p>
+ * @return コピーが完了したファイルの個数。
+ */
+ int getCopyedFiles();
+ /**
+ * <p>
+ * コピー対象のファイルの個数を返します。
+ * </p>
+ * @return コピー対象のファイルの個数。
+ */
+ int getTargetFiles();
+ /**
+ * <p>
+ * コピー元のファイルを返します。
+ * </p>
+ * @return コピー元のファイル。
+ */
+ File getSourceFile();
+ /**
+ * <p>
+ * コピー先のファイルを返します。
+ * </p>
+ * @return コピー先のファイル。
+ */
+ File getDestinationFile();
+ /**
+ * <p>
+ * コピーが完了したバイト数を返します。
+ * </p>
+ * @return コピーが完了したバイト数。
+ */
+ long getCopyedBytes();
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.backup.file;
+
+/**
+ * <p>
+ * ファイルセットがコピーされるときに通知されるリスナーです。
+ * </p>
+ * @author uguu
+ */
+public interface IFileSetCopyListener {
+ /**
+ * <p>
+ * ファイルがコピーされると通知されます。
+ * </p>
+ * @param sender ファイルをコピーしている {@link IFileSetCopy} インスタンス。
+ * @param event コピーの状況。
+ */
+ void copying(IFileSetCopy sender, IFileSetCopyEvent event);
+}
--- /dev/null
+<body>
+ <p>バックアップを行う機能を持つパッケージです。</p>
+</body>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><fileset-config file-format-version="1.1.0" simple-config="false">
+<fileset name="src" enabled="true" check-config-name="Uguu Checks" type="remote" location="http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml" description="Uguu Software のコーディング スタイルです。"><file-match-pattern match-pattern="src\\java" include-pattern="true"/>
+</fileset>
+</fileset-config>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="MAVEN_REPO/commons-io/jars/commons-io-1.1.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-0.1.8.jar"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/test"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>uguu-filespace-watch</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.mevenide.ui.mavenbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.mevenide.ui.mavennature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <pomVersion>3</pomVersion>
+ <organization>
+ <name>Uguu Software</name>
+ <url>http://wiki.livedoor.jp/uguuxp/</url>
+ <logo>http://image02.wiki.livedoor.jp/u/p/uguuxp/82487bf1fed6e9af.png</logo>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports>
+<!--
+ <report>maven-changelog-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-checkstyle-plugin</report>
+-->
+ <report>maven-linkcheck-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-faq-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
--- /dev/null
+maven.compile.debug=true
+maven.compile.encoding=utf-8
+maven.compile.source=1.5
+
+maven.docs.outputencoding=utf-8
+
+maven.checkstyle.check.tests=false
+maven.checkstyle.header.file=${basedir}/LICENSE.txt
+maven.checkstyle.propertiesURL=http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml
+
+maven.test.failure.ignore=true
+
+maven.xdoc.date=right
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.distributionUrl=http://uguu-sysman.sourceforge.jp/maven/uguu-http-test/jars
+maven.xdoc.distributionType=jar
+
+maven.repo.remote=http://www.ibiblio.org/maven/,http://uguu-sysman.sourceforge.jp/maven/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <extend>${basedir}/project-base.xml</extend>
+ <artifactId>uguu-filespace-watch</artifactId>
+ <name>uguu-filespace-watch</name>
+ <groupId>uguu-filespace-watch</groupId>
+ <currentVersion>0.1.0</currentVersion>
+ <inceptionYear>2006</inceptionYear>
+ <package>jp.gr.java_conf.uguu.filespace</package>
+ <description>ドライブの空き容量を監視します。</description>
+ <repository>
+ <connection>scm:cvs:pserver:anonymous@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-filespace-watch</connection>
+ <developerConnection>scm:cvs:ext:uguu@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-filespace-watch</developerConnection>
+ <url>http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/uguu-sysman/uguu-filespace-watch/</url>
+ </repository>
+ <developers>
+ <developer>
+ <name>uguu</name>
+ <id>2</id>
+ <email>uguu@users.sourceforge.jp</email>
+ <organization>Uguu Software</organization>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>BSD License</name>
+ </license>
+ </licenses>
+ <versions>
+ <version>
+ <name>0.1.0</name>
+ <tag>RELEASE_0_1_0</tag>
+ </version>
+ </versions>
+ <dependencies>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.1</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler</artifactId>
+ <version>0.1.8</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.filespace_watch;
+
+/**
+ * <p>
+ * ドライブの空き容量が不足していることを表す例外です。
+ * エラーレベルを下回った場合にスローします。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public class FileSpaceShortageException extends RuntimeException {
+ /**
+ * <p>空き容量。</p>
+ */
+ private long fileSpace;
+ /**
+ * <p>
+ * {@link FileSpaceShortageException} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param fileSpace 空き容量。
+ */
+ public FileSpaceShortageException(long fileSpace) {
+ this.fileSpace = fileSpace;
+ }
+ /**
+ * <p>
+ * 空き容量を返します。
+ * </p>
+ * @return 空き容量。
+ */
+ public long getFileSpace() {
+ return this.fileSpace;
+ }
+ /**
+ * <p>
+ * 空き容量を設定します。
+ * </p>
+ * @param fileSpace 空き容量。
+ */
+ public void setFileSpace(long fileSpace) {
+ this.fileSpace = fileSpace;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.filespace_watch;
+
+import java.io.IOException;
+
+import org.apache.commons.io.FileSystemUtils;
+
+import jp.gr.java_conf.uguu.scheduler.WarningException;
+
+/**
+ * <p>
+ * ドライブの空き容量を監視します。
+ * 正常ならばその空き容量を返し、警告サイズ、エラーサイズを下回る場合、例外をスローします。
+ * </p>
+ * <p>
+ * 監視は {@link #watch()} メソッドの呼び出しで行いますが、これは恒久的に監視を行うものではなく、 1 度だけ監視を行います。
+ * 恒久的、定期的に監視を行う場合、連続してメソッドを呼び出してください。
+ * </p>
+ * @author uguu
+ */
+public class FileSpaceWatch {
+ /**
+ * <p>監視対象のディレクトリ。</p>
+ */
+ private String targetDir = ".";
+ /**
+ * <p>警告サイズ。</p>
+ */
+ private long warningSize = 0;
+ /**
+ * <p>エラーサイズ。</p>
+ */
+ private long errorSize = 0;
+ /**
+ * <p>
+ * エラーサイズを返します。
+ * </p>
+ * @return エラーサイズ。
+ */
+ public long getErrorSize() {
+ return this.errorSize;
+ }
+ /**
+ * <p>
+ * エラーサイズを設定します。
+ * </p>
+ * @param errorSize エラーサイズ。
+ */
+ public void setErrorSize(long errorSize) {
+ this.errorSize = errorSize;
+ }
+ /**
+ * <p>
+ * 監視対象のディレクトリを返します。
+ * </p>
+ * @return 監視対象のディレクトリ。
+ */
+ public String getTargetDir() {
+ return this.targetDir;
+ }
+ /**
+ * <p>
+ * 監視対象のディレクトリを設定します。
+ * </p>
+ * @param targetDir 監視対象のディレクトリ。
+ */
+ public void setTargetDir(String targetDir) {
+ this.targetDir = targetDir;
+ }
+ /**
+ * <p>
+ * 警告サイズを返します。
+ * </p>
+ * @return 警告サイズ。
+ */
+ public long getWarningSize() {
+ return this.warningSize;
+ }
+ /**
+ * <p>
+ * 警告サイズを設定します。
+ * </p>
+ * @param warningSize 警告サイズ。
+ */
+ public void setWarningSize(long warningSize) {
+ this.warningSize = warningSize;
+ }
+ /**
+ * <p>
+ * 空き容量を監視します。
+ * 恒久的に監視するわけではなく、このメソッドを呼び出したときに 1 度だけ監視します。
+ * 定期的、恒久的に監視するには、連続してこのメソッドを呼び出してください。
+ * </p>
+ * <p>
+ * 監視対象のディレクトリの容量が、警告サイズを下回った場合、 {@link WarningException} 例外をスローします。
+ * この場合、 {@link WarningException#getResult()} メソッドを呼び出して、空き容量を long 値として取得することができます。
+ * </p>
+ * <p>
+ * エラーサイズを下回った場合、 {@link FileSpaceShortageException} 例外をスローします。
+ * この場合、 {@link FileSpaceShortageException#getFileSpace()} メソッドを呼び出して、空き容量を long 値として取得することができます。
+ * </p>
+ * @return 空き容量。
+ * @throws WarningException 空き容量が警告サイズの場合。
+ * @throws FileSpaceShortageException 空き容量がエラーサイズを下回る場合。
+ * @throws IOException 空き容量の取得に失敗した場合。
+ */
+ public long watch() throws IOException {
+ if (this.targetDir == null) {
+ throw new IllegalStateException("targetDir プロパティが null です。");
+ }
+ if (this.errorSize < 0) {
+ throw new IllegalStateException("errorSize プロパティが 0 未満です。");
+ }
+ if (this.warningSize < 0) {
+ throw new IllegalStateException("warningSize プロパティが 0 未満です。");
+ }
+ if (this.warningSize < this.errorSize) {
+ throw new IllegalStateException("errorSize プロパティが warningSize プロパティより大きいです。");
+ }
+ long fs = FileSystemUtils.freeSpace(this.targetDir);
+ if (this.errorSize > fs) {
+ throw new FileSpaceShortageException(fs);
+ } else if (this.warningSize > fs) {
+ throw new WarningException(fs);
+ } else {
+ return fs;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.filespace_watch;
+
+import java.io.IOException;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.Task;
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+
+/**
+ * <p>
+ * ドライブの空き容量を監視するタスクです。
+ * 正常ならばその空き容量を返し、警告、エラーサイズ以下なら例外をスローします。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public class FileSpaceWatchTask extends FileSpaceWatch implements Task {
+ /**
+ * <p>
+ * 空き容量を監視します。
+ * 恒久的に監視するわけではなく、このメソッドを呼び出したときに 1 度だけ監視します。
+ * 定期的、恒久的に監視するには、連続してこのメソッドを呼び出してください。
+ * </p>
+ * <p>
+ * 監視対象のディレクトリの容量が、警告サイズを下回った場合、 {@link jp.gr.java_conf.uguu.scheduler.WarningException} 例外をスローします。
+ * この場合、 {@link jp.gr.java_conf.uguu.scheduler.WarningException#getResult()} メソッドを呼び出して、空き容量を long 値として取得することができます。
+ * </p>
+ * <p>
+ * エラーサイズを下回った場合、 {@link FileSpaceShortageException} 例外をスローします。
+ * この場合、 {@link FileSpaceShortageException#getFileSpace()} メソッドを呼び出して、空き容量を long 値として取得することができます。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスク イベント。
+ * @return 空き容量を表す long 値。
+ * @throws jp.gr.java_conf.uguu.scheduler.WarningException 空き容量が警告サイズを下回る場合。
+ * @throws FileSpaceShortageException 空き容量がエラーサイズの場合。
+ * @throws IOException 空き容量の取得に失敗した場合。
+ */
+ public Object task(Schedule schedule, TaskEvent event) throws IOException {
+ return this.watch();
+ }
+}
--- /dev/null
+<body>
+ <p>ドライブの空き容量を監視します。</p>
+</body>
\ No newline at end of file
--- /dev/null
+package jp.gr.java_conf.uguu.filespace_watch.test;
+
+import java.io.IOException;
+
+import jp.gr.java_conf.uguu.filespace_watch.FileSpaceShortageException;
+import jp.gr.java_conf.uguu.filespace_watch.FileSpaceWatch;
+import jp.gr.java_conf.uguu.scheduler.WarningException;
+import junit.framework.TestCase;
+
+public class FileSpaceWatchTest extends TestCase {
+ public FileSpaceWatchTest(String name) {
+ super(name);
+ }
+ /**
+ * 普通に使用します。
+ * targetDir に監視するディレクトリを指定します。
+ * warningSize に警告サイズ、 errorSize にエラーサイズを指定します。
+ * 空き容量が、警告サイズ、エラーサイズでもない場合、メソッド呼び出しは空き容量を返します。
+ * @throws Exception
+ */
+ public void test() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setWarningSize(1 * 1024 * 1024 * 1024); // 1 GB
+ w.setErrorSize(100 * 1024 * 1024); // 100 MB
+ long fs = w.watch();
+ assertTrue(fs > 0);
+ }
+ /**
+ * 警告サイズを下回る場合です。
+ * 警告サイズに {@link Long#MAX_VALUE} を設定しています。
+ * 空き容量がこの警告サイズを下回っているので、 {@link WarningException} 例外をスローします。
+ * @throws Exception
+ */
+ public void test2() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setWarningSize(Long.MAX_VALUE);
+ try {
+ w.watch();
+ fail();
+ } catch (WarningException e) {
+ long fs = (Long) e.getResult();
+ assertTrue(fs > 0);
+ }
+ }
+ /**
+ * エラーサイズを下回る場合です。
+ * エラーサイズに {@link Long#MAX_VALUE} を設定しています。
+ * 空き容量がエラーサイズを下回っているので、 {@link WarningException} 例外をスローします。
+ *
+ * エラーサイズとともに警告サイズを設定しているのは、 (エラーサイズ > 警告サイズ) の場合、 {@link IllegalStateException} 例外がスローされるからです。
+ *
+ * エラーサイズと警告サイズに同じ値を設定した場合、エラーサイズが優先して比較されます。
+ * @throws Exception
+ */
+ public void test3() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setWarningSize(Long.MAX_VALUE);
+ w.setErrorSize(Long.MAX_VALUE);
+ try {
+ w.watch();
+ fail();
+ } catch (FileSpaceShortageException e) {
+ long fs = e.getFileSpace();
+ assertTrue(fs > 0);
+ }
+ }
+ /**
+ * 監視対象に無効なパスを指定した場合です。
+ * {@link IOException} 例外がスローされます (これは commons-io の仕様です) 。
+ * @throws Exception
+ */
+ public void test5() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("hoge:/");
+ try {
+ w.watch();
+ fail();
+ } catch (IOException e) {
+ // 例外のチェックはしません。
+ }
+ }
+ /**
+ * 何も設定しないで監視した場合です。
+ * 監視対象は、カレントディレクトリを指します。
+ * 警告サイズ、エラーサイズは 0 に設定されています。
+ * @throws Exception
+ */
+ public void test6() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ long fs = w.watch();
+ assertTrue(fs > 0);
+ }
+ /**
+ * 監視対象に null を設定した場合です。
+ * {@link IllegalStateException} 例外がスローされます。
+ * @throws Exception
+ */
+ public void test6_1() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir(null);
+ try {
+ w.watch();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("targetDir プロパティが null です。", e.getMessage());
+ }
+ }
+ /**
+ * 監視対象に空文字列を設定した場合です。
+ * カレントディレクトリが監視対象になります。
+ * まぁ、通常はちゃんとディレクトリを設定してください。
+ * @throws Exception
+ */
+ public void test7() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("");
+ long fs = w.watch();
+ assertTrue(fs > 0);
+ }
+ /**
+ * 警告サイズに 0 (最小値) を設定した場合です。
+ * 問題ありません。
+ * @throws Exception
+ */
+ public void test8() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setWarningSize(0);
+ w.watch();
+ }
+ /**
+ * 警告サイズに -1 を設定した場合です。
+ * 警告サイズには 0 未満は設定できません。
+ * @throws Exception
+ */
+ public void test9() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setWarningSize(-1);
+ try {
+ w.watch();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("warningSize プロパティが 0 未満です。", e.getMessage());
+ }
+ }
+ /**
+ * 警告サイズに {@link Long#MIN_VALUE} を設定した場合です。
+ * 警告サイズには 0 未満は設定できません。
+ * @throws Exception
+ */
+ public void test10() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setWarningSize(Long.MIN_VALUE);
+ try {
+ w.watch();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("warningSize プロパティが 0 未満です。", e.getMessage());
+ }
+ }
+ /**
+ * エラーサイズに 0 (最小値) を設定した場合です。
+ * 問題ありません。
+ * @throws Exception
+ */
+ public void test11() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setErrorSize(0);
+ w.watch();
+ }
+ /**
+ * エラーサイズに -1 を設定した場合です。
+ * エラーサイズには 0 未満は設定できません。
+ * @throws Exception
+ */
+ public void test12() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setErrorSize(-1);
+ try {
+ w.watch();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("errorSize プロパティが 0 未満です。", e.getMessage());
+ }
+ }
+ /**
+ * エラーサイズに {@link Long#MIN_VALUE} を設定した場合です。
+ * エラーサイズには 0 未満は設定できません。
+ * @throws Exception
+ */
+ public void test13() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setErrorSize(Long.MIN_VALUE);
+ try {
+ w.watch();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("errorSize プロパティが 0 未満です。", e.getMessage());
+ }
+ }
+ /**
+ * 警告サイズ、エラーサイズに同じ値を設定した場合です。
+ * 問題ありません。
+ * @throws Exception
+ */
+ public void test14() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setWarningSize(0);
+ w.setErrorSize(0);
+ w.watch();
+ }
+ /**
+ * 警告サイズ < エラーサイズを設定した場合です。
+ * エラーサイズは警告サイズ以下の値を設定してください。
+ * @throws Exception
+ */
+ public void test15() throws Exception {
+ FileSpaceWatch w = new FileSpaceWatch();
+ w.setTargetDir("C:/");
+ w.setWarningSize(0);
+ w.setErrorSize(1);
+ try {
+ w.watch();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("errorSize プロパティが warningSize プロパティより大きいです。", e.getMessage());
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><fileset-config file-format-version="1.1.0" simple-config="false">
+<fileset name="src" enabled="true" check-config-name="Uguu Checks" type="remote" location="http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml" description="Uguu Software のコーディング スタイルです。"><file-match-pattern match-pattern="src\\java" include-pattern="true"/>
+</fileset>
+</fileset-config>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/test"/>
+ <classpathentry kind="src" path="src/test-conf"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-0.1.8.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>uguu-http-test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.mevenide.ui.mavenbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.mevenide.ui.mavennature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <pomVersion>3</pomVersion>
+ <organization>
+ <name>Uguu Software</name>
+ <url>http://wiki.livedoor.jp/uguuxp/</url>
+ <logo>http://image02.wiki.livedoor.jp/u/p/uguuxp/82487bf1fed6e9af.png</logo>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports>
+<!--
+ <report>maven-changelog-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-checkstyle-plugin</report>
+-->
+ <report>maven-linkcheck-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-faq-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
--- /dev/null
+maven.compile.debug=true
+maven.compile.encoding=utf-8
+maven.compile.source=1.5
+
+maven.docs.outputencoding=utf-8
+
+maven.checkstyle.check.tests=false
+maven.checkstyle.header.file=${basedir}/LICENSE.txt
+maven.checkstyle.propertiesURL=http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml
+
+maven.test.failure.ignore=true
+
+maven.xdoc.date=right
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.distributionUrl=http://uguu-sysman.sourceforge.jp/maven/uguu-http-test/jars
+maven.xdoc.distributionType=jar
+
+maven.repo.remote=http://www.ibiblio.org/maven/,http://uguu-sysman.sourceforge.jp/maven/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <extend>${basedir}/project-base.xml</extend>
+ <artifactId>uguu-http-test</artifactId>
+ <name>uguu-http-test</name>
+ <groupId>uguu-http-test</groupId>
+ <currentVersion>0.1.5</currentVersion>
+ <inceptionYear>2005</inceptionYear>
+ <package>jp.gr.java_conf.uguu.http_test</package>
+ <description>HTTP サーバに接続し、疎通を確認します。</description>
+ <repository>
+ <connection>scm:cvs:pserver:anonymous@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-http-test</connection>
+ <developerConnection>scm:cvs:ext:uguu@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-http-test</developerConnection>
+ <url>http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/uguu-sysman/uguu-http-test/</url>
+ </repository>
+ <developers>
+ <developer>
+ <name>uguu</name>
+ <id>2</id>
+ <email>uguu@users.sourceforge.jp</email>
+ <organization>Uguu Software</organization>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>BSD License</name>
+ </license>
+ </licenses>
+ <versions>
+ <version>
+ <name>0.1.5</name>
+ <tag>RELEASE_0_1_5</tag>
+ </version>
+ <version>
+ <name>0.1.4</name>
+ <tag>RELEASE_0_1_4</tag>
+ </version>
+ <version>
+ <name>0.1.3</name>
+ <tag>RELEASE_0_1_3</tag>
+ </version>
+ <version>
+ <name>0.1.2</name>
+ <tag>RELEASE_0_1_2</tag>
+ </version>
+ <version>
+ <name>0.1.1</name>
+ <tag>RELEASE_0_1_1</tag>
+ </version>
+ <version>
+ <name>0.1.0</name>
+ <tag>RELEASE_0_1_0</tag>
+ </version>
+ </versions>
+ <dependencies>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler</artifactId>
+ <version>0.1.8</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.http_test;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.URL;
+import java.net.Proxy.Type;
+
+/**
+ * <p>
+ * 指定した URL に HTTP 接続を試みます。
+ * </p>
+ * @author uguu
+ */
+public class HttpConnect {
+ /**
+ * 接続先 URL 。
+ */
+ private String url;
+ /**
+ * 接続に使用するプロキシのホスト名。
+ */
+ private String proxyHost;
+ /**
+ * 接続に使用するプロキシのポート。
+ */
+ private int proxyPort;
+ /**
+ * <p>
+ * 接続先 URL を返します。
+ * </p>
+ * @return 接続先 URL 。
+ */
+ public String getUrl() {
+ return this.url;
+ }
+ /**
+ * <p>
+ * 接続先 URL を設定します。
+ * </p>
+ * @param url 接続先 URL 。
+ */
+ public void setUrl(String url) {
+ this.url = url;
+ }
+ /**
+ * <p>
+ * 接続に使用するプロキシのホスト名を返します。
+ * </p>
+ * @return 接続に使用するプロキシのホスト名。
+ */
+ public String getProxyHost() {
+ return this.proxyHost;
+ }
+ /**
+ * <p>
+ * 接続に使用するプロキシのホスト名を設定します。
+ * </p>
+ * @param proxyHost 接続に使用するプロキシのホスト名。
+ */
+ public void setProxyHost(String proxyHost) {
+ this.proxyHost = proxyHost;
+ }
+ /**
+ * <p>
+ * 接続に使用するプロキシのポートを返します。
+ * </p>
+ * @return 接続に使用するプロキシのポート。
+ */
+ public int getProxyPort() {
+ return this.proxyPort;
+ }
+ /**
+ * <p>
+ * 接続に使用するプロキシのポートを設定します。
+ * </p>
+ * @param proxyPort 接続に使用するプロキシのポート。
+ */
+ public void setProxyPort(int proxyPort) {
+ this.proxyPort = proxyPort;
+ }
+ /**
+ * <p>
+ * 接続を試みます。
+ * プロキシのホスト名を設定すると、接続にプロキシを使用するようになります。
+ * </p>
+ * <p>
+ * {@link java.net.MalformedURLException} 例外がスローされた場合、接続先 URL の形式が間違えています。
+ * </p>
+ * <p>
+ * {@link java.net.ConnectException} 例外がスローされた場合、サーバへの接続に失敗しました。
+ * これは、接続先サーバがダウンしているか、そもそも接続先サーバが存在しない可能性があります。
+ * </p>
+ * <p>
+ * {@link IllegalArgumentException} 例外がスローされた場合、プロキシの設定が間違えている可能性があります (例えば、ポート番号が範囲外であるなど) 。
+ * </p>
+ * @return HTTP 接続試験の結果。
+ * @throws IOException 入出力エラーが発生した場合。
+ * @throws IllegalStateException 接続先 URL が設定されていない場合。
+ */
+ public HttpConnectResult connect() throws IOException {
+ if (this.url == null) {
+ throw new IllegalStateException("接続先 URL が設定されていません。");
+ }
+ HttpConnectResult result;
+ URL u = new URL(this.url);
+ HttpURLConnection httpConn = null;
+ if (this.proxyHost == null) {
+ httpConn = (HttpURLConnection) u.openConnection();
+ } else {
+ Proxy proxy = new Proxy(Type.HTTP, new InetSocketAddress(this.proxyHost, this.proxyPort));
+ httpConn = (HttpURLConnection) u.openConnection(proxy);
+ }
+ try {
+ result = new HttpConnectResult();
+ result.setStatusCode(httpConn.getResponseCode());
+ result.setResponseMessage(httpConn.getResponseMessage());
+ } finally {
+ httpConn.disconnect();
+ }
+ return result;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.http_test;
+
+/**
+ * <p>
+ * HTTP 接続試験の結果を表します。
+ * </p>
+ * @author uguu
+ */
+public class HttpConnectResult {
+ /**
+ * ステータスコード。
+ */
+ private int statusCode;
+ /**
+ * レスポンス メッセージ。
+ */
+ private String responseMessage;
+ /**
+ * <p>
+ * レスポンス メッセージを返します。
+ * </p>
+ * @return レスポンス メッセージ。
+ */
+ public String getResponseMessage() {
+ return this.responseMessage;
+ }
+ /**
+ * <p>
+ * レスポンス メッセージを設定します。
+ * </p>
+ * @param responseMessage レスポンス メッセージ。
+ */
+ public void setResponseMessage(String responseMessage) {
+ this.responseMessage = responseMessage;
+ }
+ /**
+ * <p>
+ * ステータスコードを返します。
+ * </p>
+ * @return ステータスコード。
+ */
+ public int getStatusCode() {
+ return this.statusCode;
+ }
+ /**
+ * <p>
+ * ステータスコードを設定します。
+ * </p>
+ * @param statusCode ステータスコード。
+ */
+ public void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.http_test;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.Task;
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+import jp.gr.java_conf.uguu.scheduler.WarningException;
+
+/**
+ * <p>
+ * HTTP 接続試験のタスクです。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public class HttpConnectTask implements Task<HttpConnectResult> {
+ /**
+ * 接続先 URL 。
+ */
+ private String url;
+ /**
+ * 接続に使用するプロキシのホスト名。
+ */
+ private String proxyHost;
+ /**
+ * 接続に使用するプロキシのポート。
+ */
+ private int proxyPort;
+ /**
+ * <p>
+ * 接続先 URL を返します。
+ * </p>
+ * @return 接続先 URL 。
+ */
+ public String getUrl() {
+ return this.url;
+ }
+ /**
+ * <p>
+ * 接続先 URL を設定します。
+ * </p>
+ * @param url 接続先 URL 。
+ */
+ public void setUrl(String url) {
+ this.url = url;
+ }
+ /**
+ * <p>
+ * 接続に使用するプロキシのホスト名を返します。
+ * </p>
+ * @return 接続に使用するプロキシのホスト名。
+ */
+ public String getProxyHost() {
+ return this.proxyHost;
+ }
+ /**
+ * <p>
+ * 接続に使用するプロキシのホスト名を設定します。
+ * </p>
+ * @param proxyHost 接続に使用するプロキシのホスト名。
+ */
+ public void setProxyHost(String proxyHost) {
+ this.proxyHost = proxyHost;
+ }
+ /**
+ * <p>
+ * 接続に使用するプロキシのポートを返します。
+ * </p>
+ * @return 接続に使用するプロキシのポート。
+ */
+ public int getProxyPort() {
+ return this.proxyPort;
+ }
+ /**
+ * <p>
+ * 接続に使用するプロキシのポートを設定します。
+ * </p>
+ * @param proxyPort 接続に使用するプロキシのポート。
+ */
+ public void setProxyPort(int proxyPort) {
+ this.proxyPort = proxyPort;
+ }
+ /**
+ * <p>
+ * HTTP 接続試験を行います。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスクの実行のイベント情報。
+ * @return HTTP 接続試験の結果。
+ * @throws IOException HTTP 接続試験に失敗した場合。
+ * @throws WarningException ステータスコードが 200 ではない場合。
+ */
+ public HttpConnectResult task(Schedule schedule, TaskEvent event) throws IOException {
+ // HTTP 接続試験を行います。
+ HttpConnect httpConnect = new HttpConnect();
+ httpConnect.setProxyHost(this.proxyHost);
+ httpConnect.setProxyPort(this.proxyPort);
+ httpConnect.setUrl(this.url);
+ HttpConnectResult result = httpConnect.connect();
+ if (result.getStatusCode() != HttpURLConnection.HTTP_OK) {
+ throw new WarningException(result);
+ }
+ return result;
+ }
+}
--- /dev/null
+<body>
+ <p>HTTP 接続試験を行う機能を持ちます。</p>
+</body>
\ No newline at end of file
--- /dev/null
+# \u30d7\u30ed\u30ad\u30b7\u7121\u3057\u3067\u666e\u901a\u306b\u63a5\u7d9a\u3067\u304d\u308b URL \u3002 (\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9=200)
+url.200=http://wiki.livedoor.jp/uguuxp/
+
+# \u5b58\u5728\u3057\u306a\u3044 URL \u3002 (\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9=404)
+url.404=http://wiki.livedoor.jp/uguuxp/foo/bar.html
+
+# \u5b58\u5728\u3057\u306a\u3044\u30db\u30b9\u30c8\u3002
+url.unknownhost=http://hoge.example.com/
+
+# \u6709\u52b9\u306a\u30d7\u30ed\u30ad\u30b7\u3002
+proxy.host=localhost
+proxy.port=80
+
+# \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306b\u306a\u308b\u30d7\u30ed\u30ad\u30b7
+timeout_proxy.host=10.0.0.0
+timeout_proxy.port=80
+
+# \u5b58\u5728\u3057\u306a\u3044\u30d7\u30ed\u30ad\u30b7 (\u63a5\u7d9a\u62d2\u5426)
+connect_refused_proxy.host=localhost
+connect_refused_proxy.port=65535
--- /dev/null
+package jp.gr.java_conf.uguu.http_test.test;
+
+import java.net.ConnectException;
+import java.net.UnknownHostException;
+import java.util.ResourceBundle;
+
+import jp.gr.java_conf.uguu.http_test.HttpConnectResult;
+import jp.gr.java_conf.uguu.http_test.HttpConnectTask;
+import jp.gr.java_conf.uguu.scheduler.WarningException;
+import junit.framework.TestCase;
+
+public class HttpConnectTaskTest extends TestCase {
+ private ResourceBundle rb = ResourceBundle.getBundle("test");
+ public HttpConnectTaskTest(String name) {
+ super(name);
+ }
+ public void test_accessor() throws Exception {
+ HttpConnectTask task = new HttpConnectTask();
+
+ // url
+ assertNull(task.getUrl());
+
+ task.setUrl("url");
+ assertEquals("url", task.getUrl());
+
+ task.setUrl("");
+ assertEquals("", task.getUrl());
+
+ task.setUrl(null);
+ assertNull(task.getUrl());
+
+ // proxyHost
+ assertNull(task.getProxyHost());
+
+ task.setProxyHost("proxyHost");
+ assertEquals("proxyHost", task.getProxyHost());
+
+ task.setProxyHost("");
+ assertEquals("", task.getProxyHost());
+
+ task.setProxyHost(null);
+ assertNull(task.getProxyHost());
+
+ // proxyPort
+ assertEquals(0, task.getProxyPort());
+
+ task.setProxyPort(8080);
+ assertEquals(8080, task.getProxyPort());
+
+ task.setProxyPort(0);
+ assertEquals(0, task.getProxyPort());
+ }
+ public void test_connect_普通に接続() throws Exception {
+ HttpConnectTask task = new HttpConnectTask();
+ task.setUrl(this.rb.getString("url.200"));
+ HttpConnectResult result = task.task(null, null);
+ assertEquals(200, result.getStatusCode());
+ assertEquals("OK", result.getResponseMessage());
+ }
+ public void test_connect_存在しないURLに接続() throws Exception {
+ HttpConnectTask task = new HttpConnectTask();
+ task.setUrl(this.rb.getString("url.404"));
+ try {
+ task.task(null, null);
+ fail();
+ } catch (WarningException e) {
+ HttpConnectResult result = (HttpConnectResult) e.getResult();
+ assertEquals(404, result.getStatusCode());
+ assertEquals("Not Found", result.getResponseMessage());
+ }
+ }
+ public void test_connect_存在しないホストに接続() throws Exception {
+ HttpConnectTask task = new HttpConnectTask();
+ task.setUrl(this.rb.getString("url.unknownhost"));
+ try {
+ task.task(null, null);
+ fail();
+ } catch (UnknownHostException e) {
+ // 例外は検証しません。
+ }
+ }
+ public void test_connect_プロキシで接続() throws Exception {
+ HttpConnectTask task = new HttpConnectTask();
+ task.setUrl(this.rb.getString("url.200"));
+ task.setProxyHost(this.rb.getString("proxy.host"));
+ task.setProxyPort(Integer.parseInt(this.rb.getString("proxy.port")));
+ HttpConnectResult result = task.task(null, null);
+ assertEquals(200, result.getStatusCode());
+ assertEquals("OK", result.getResponseMessage());
+ }
+ public void test_connect_設定しない場合にIllegalStateException() throws Exception {
+ HttpConnectTask task = new HttpConnectTask();
+ try {
+ task.task(null, null);
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("接続先 URL が設定されていません。", e.getMessage());
+ }
+ }
+ public void test_connect_存在しないプロキシで接続した場合はConnectExceptionによるタイムアウト_1() throws Exception {
+ HttpConnectTask task = new HttpConnectTask();
+ task.setUrl(this.rb.getString("url.200"));
+ task.setProxyHost(this.rb.getString("timeout_proxy.host"));
+ task.setProxyPort(Integer.parseInt(this.rb.getString("timeout_proxy.port")));
+ try {
+ task.task(null, null);
+ fail();
+ } catch (ConnectException e) {
+ assertEquals("Connection timed out: connect", e.getMessage());
+ }
+ }
+ public void test_connect_存在しないプロキシで接続した場合はConnectExceptionによるタイムアウト_2() throws Exception {
+ HttpConnectTask task = new HttpConnectTask();
+ task.setUrl(this.rb.getString("url.200"));
+ task.setProxyHost(this.rb.getString("connect_refused_proxy.host"));
+ task.setProxyPort(Integer.parseInt(this.rb.getString("connect_refused_proxy.port")));
+ try {
+ task.task(null, null);
+ fail();
+ } catch (ConnectException e) {
+ assertEquals("Connection refused: connect", e.getMessage());
+ }
+ }
+ public void test_connect_プロキシの設定が間違えている場合はIllegalArgumentException() throws Exception {
+ HttpConnectTask task = new HttpConnectTask();
+ task.setUrl(this.rb.getString("url.200"));
+ task.setProxyHost("localhost");
+ task.setProxyPort(-1);
+ try {
+ task.task(null, null);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("port out of range:-1", e.getMessage());
+ }
+ }
+}
--- /dev/null
+package jp.gr.java_conf.uguu.http_test.test;
+
+import java.net.ConnectException;
+import java.net.UnknownHostException;
+import java.util.ResourceBundle;
+
+import jp.gr.java_conf.uguu.http_test.HttpConnect;
+import jp.gr.java_conf.uguu.http_test.HttpConnectResult;
+import junit.framework.TestCase;
+
+public class HttpConnectTest extends TestCase {
+ private ResourceBundle rb = ResourceBundle.getBundle("test");
+ public HttpConnectTest(String name) {
+ super(name);
+ }
+ public void test_accessor() throws Exception {
+ HttpConnect httpConnect = new HttpConnect();
+
+ // url
+ assertNull(httpConnect.getUrl());
+
+ httpConnect.setUrl("url");
+ assertEquals("url", httpConnect.getUrl());
+
+ httpConnect.setUrl("");
+ assertEquals("", httpConnect.getUrl());
+
+ httpConnect.setUrl(null);
+ assertNull(httpConnect.getUrl());
+
+ // proxyHost
+ assertNull(httpConnect.getProxyHost());
+
+ httpConnect.setProxyHost("proxyHost");
+ assertEquals("proxyHost", httpConnect.getProxyHost());
+
+ httpConnect.setProxyHost("");
+ assertEquals("", httpConnect.getProxyHost());
+
+ httpConnect.setProxyHost(null);
+ assertNull(httpConnect.getProxyHost());
+
+ // proxyPort
+ assertEquals(0, httpConnect.getProxyPort());
+
+ httpConnect.setProxyPort(8080);
+ assertEquals(8080, httpConnect.getProxyPort());
+
+ httpConnect.setProxyPort(0);
+ assertEquals(0, httpConnect.getProxyPort());
+ }
+ public void test_connect_普通に接続() throws Exception {
+ HttpConnect httpConnect = new HttpConnect();
+ httpConnect.setUrl(this.rb.getString("url.200"));
+ HttpConnectResult result = httpConnect.connect();
+ assertEquals(200, result.getStatusCode());
+ assertEquals("OK", result.getResponseMessage());
+ }
+ public void test_connect_存在しないURLに接続() throws Exception {
+ HttpConnect httpConnect = new HttpConnect();
+ httpConnect.setUrl(this.rb.getString("url.404"));
+ HttpConnectResult result = httpConnect.connect();
+ assertEquals(404, result.getStatusCode());
+ assertEquals("Not Found", result.getResponseMessage());
+ }
+ public void test_connect_存在しないホストに接続() throws Exception {
+ HttpConnect httpConnect = new HttpConnect();
+ httpConnect.setUrl(this.rb.getString("url.unknownhost"));
+ try {
+ httpConnect.connect();
+ fail();
+ } catch (UnknownHostException e) {
+ // 例外は検証しません。
+ }
+ }
+ public void test_connect_プロキシで接続() throws Exception {
+ HttpConnect httpConnect = new HttpConnect();
+ httpConnect.setUrl(this.rb.getString("url.200"));
+ httpConnect.setProxyHost(this.rb.getString("proxy.host"));
+ httpConnect.setProxyPort(Integer.parseInt(this.rb.getString("proxy.port")));
+ HttpConnectResult result = httpConnect.connect();
+ assertEquals(200, result.getStatusCode());
+ assertEquals("OK", result.getResponseMessage());
+ }
+ public void test_connect_設定しない場合にIllegalStateException() throws Exception {
+ HttpConnect httpConnect = new HttpConnect();
+ try {
+ httpConnect.connect();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("接続先 URL が設定されていません。", e.getMessage());
+ }
+ }
+ public void test_connect_存在しないプロキシで接続した場合はConnectExceptionによるタイムアウト_1() throws Exception {
+ HttpConnect httpConnect = new HttpConnect();
+ httpConnect.setUrl(this.rb.getString("url.200"));
+ httpConnect.setProxyHost(this.rb.getString("timeout_proxy.host"));
+ httpConnect.setProxyPort(Integer.parseInt(this.rb.getString("timeout_proxy.port")));
+ try {
+ httpConnect.connect();
+ fail();
+ } catch (ConnectException e) {
+ assertEquals("Connection timed out: connect", e.getMessage());
+ }
+ }
+ public void test_connect_存在しないプロキシで接続した場合はConnectExceptionによるタイムアウト_2() throws Exception {
+ HttpConnect httpConnect = new HttpConnect();
+ httpConnect.setUrl(this.rb.getString("url.200"));
+ httpConnect.setProxyHost(this.rb.getString("connect_refused_proxy.host"));
+ httpConnect.setProxyPort(Integer.parseInt(this.rb.getString("connect_refused_proxy.port")));
+ try {
+ httpConnect.connect();
+ fail();
+ } catch (ConnectException e) {
+ assertEquals("Connection refused: connect", e.getMessage());
+ }
+ }
+ public void test_connect_プロキシの設定が間違えている場合はIllegalArgumentException() throws Exception {
+ HttpConnect httpConnect = new HttpConnect();
+ httpConnect.setUrl(this.rb.getString("url.200"));
+ httpConnect.setProxyHost("localhost");
+ httpConnect.setProxyPort(-1);
+ try {
+ httpConnect.connect();
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("port out of range:-1", e.getMessage());
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><fileset-config file-format-version="1.1.0" simple-config="false">
+<fileset name="src" enabled="true" check-config-name="Uguu Checks" type="remote" location="http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml" description="Uguu Software のコーディング スタイルです。"><file-match-pattern match-pattern="src\\java" include-pattern="true"/>
+</fileset>
+</fileset-config>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/test"/>
+ <classpathentry kind="src" path="src/test-conf"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-0.1.8.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>uguu-jdbc-test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.mevenide.ui.mavenbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.mevenide.ui.mavennature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <pomVersion>3</pomVersion>
+ <organization>
+ <name>Uguu Software</name>
+ <url>http://wiki.livedoor.jp/uguuxp/</url>
+ <logo>http://image02.wiki.livedoor.jp/u/p/uguuxp/82487bf1fed6e9af.png</logo>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports>
+<!--
+ <report>maven-changelog-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-checkstyle-plugin</report>
+-->
+ <report>maven-linkcheck-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-faq-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
--- /dev/null
+maven.compile.debug=true
+maven.compile.encoding=utf-8
+maven.compile.source=1.5
+
+maven.docs.outputencoding=utf-8
+
+maven.checkstyle.check.tests=false
+maven.checkstyle.header.file=${basedir}/LICENSE.txt
+maven.checkstyle.propertiesURL=http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml
+
+maven.test.failure.ignore=true
+
+maven.xdoc.date=right
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.distributionUrl=http://uguu-sysman.sourceforge.jp/maven/uguu-http-test/jars
+maven.xdoc.distributionType=jar
+
+maven.repo.remote=http://www.ibiblio.org/maven/,http://uguu-sysman.sourceforge.jp/maven/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <extend>${basedir}/project-base.xml</extend>
+ <artifactId>uguu-jdbc-test</artifactId>
+ <name>uguu-jdbc-test</name>
+ <groupId>uguu-jdbc-test</groupId>
+ <currentVersion>0.1.4</currentVersion>
+ <inceptionYear>2005</inceptionYear>
+ <package>jp.gr.java_conf.uguu.jdbc_test</package>
+ <description>DBMS に JDBC 接続し、疎通を確認します。</description>
+ <repository>
+ <connection>scm:cvs:pserver:anonymous@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-jdbc-test</connection>
+ <developerConnection>scm:cvs:ext:uguu@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-jdbc-test</developerConnection>
+ <url>http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/uguu-sysman/uguu-jdbc-test/</url>
+ </repository>
+ <developers>
+ <developer>
+ <name>uguu</name>
+ <id>2</id>
+ <email>uguu@users.sourceforge.jp</email>
+ <organization>Uguu Software</organization>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>BSD License</name>
+ </license>
+ </licenses>
+ <versions>
+ <version>
+ <name>0.1.4</name>
+ <tag>RELEASE_0_1_4</tag>
+ </version>
+ <version>
+ <name>0.1.3</name>
+ <tag>RELEASE_0_1_3</tag>
+ </version>
+ <version>
+ <name>0.1.2</name>
+ <tag>RELEASE_0_1_2</tag>
+ </version>
+ <version>
+ <name>0.1.1</name>
+ <tag>RELEASE_0_1_1</tag>
+ </version>
+ <version>
+ <name>0.1.0</name>
+ <tag>RELEASE_0_1_0</tag>
+ </version>
+ </versions>
+ <dependencies>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler</artifactId>
+ <version>0.1.8</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.jdbc_test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+/**
+ * <p>
+ * 指定したデータベースに JDBC 接続を試みます。
+ * </p>
+ * @author uguu
+ */
+public class JdbcConnect {
+ /**
+ * JDBC ドライバのクラス名。
+ */
+ private String className;
+ /**
+ * 接続するデータベースの URL 。
+ */
+ private String url;
+ /**
+ * 接続するアカウントのユーザ名。
+ */
+ private String user;
+ /**
+ * 接続するアカウントのパスワード。
+ */
+ private String password;
+ /**
+ * <p>
+ * JDBC ドライバのクラス名を返します。
+ * </p>
+ * @return JDBC ドライバのクラス名。
+ */
+ public String getClassName() {
+ return this.className;
+ }
+ /**
+ * <p>
+ * JDBC ドライバのクラス名を設定します。
+ * </p>
+ * @param className JDBC ドライバのクラス名。
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+ /**
+ * <p>
+ * 接続するアカウントのパスワードを返します。
+ * </p>
+ * @return 接続するアカウントのパスワード。
+ */
+ public String getPassword() {
+ return this.password;
+ }
+ /**
+ * <p>
+ * 接続するアカウントのパスワードを設定します。
+ * </p>
+ * @param password 接続するアカウントのパスワード。
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+ /**
+ * <p>
+ * 接続するデータベースの URL を返します。
+ * </p>
+ * @return 接続するデータベースの URL 。
+ */
+ public String getUrl() {
+ return this.url;
+ }
+ /**
+ * <p>
+ * 接続するデータベースの URL を設定します。
+ * </p>
+ * @param url 接続するデータベースの URL 。
+ */
+ public void setUrl(String url) {
+ this.url = url;
+ }
+ /**
+ * <p>
+ * 接続するアカウントのユーザ名を返します。
+ * </p>
+ * @return 接続するアカウントのユーザ名。
+ */
+ public String getUser() {
+ return this.user;
+ }
+ /**
+ * <p>
+ * 接続するアカウントのユーザ名を設定します。
+ * </p>
+ * @param user 接続するアカウントのユーザ名。
+ */
+ public void setUser(String user) {
+ this.user = user;
+ }
+ /**
+ * <p>
+ * 接続を試みます。
+ * 接続に成功した場合、メソッド呼び出しは正常に完了します。
+ * 接続に失敗した場合、 {@link java.sql.SQLException} 例外がスローされます。
+ * </p>
+ * @throws ClassNotFoundException JDBC ドライバのクラスの読み込みに失敗した場合。
+ * @throws SQLException 接続に失敗した場合。
+ * @throws NullPointerException {@link #className} プロパティが null の場合。
+ * {@link #url} プロパティが null の場合。
+ */
+ public void connect() throws ClassNotFoundException, SQLException {
+ if (this.getClassName() == null) {
+ throw new NullPointerException("className");
+ }
+ if (this.getUrl() == null) {
+ throw new NullPointerException("url");
+ }
+ Class.forName(this.getClassName());
+ Connection conn = DriverManager.getConnection(this.getUrl(), this.getUser(), this.getPassword());
+ conn.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.jdbc_test;
+
+import java.sql.SQLException;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.Task;
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+
+/**
+ * <p>
+ * JDBC 接続試験のためのタスクです。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public class JdbcConnectTask implements Task<Object> {
+ /**
+ * JDBC ドライバのクラス名。
+ */
+ private String className;
+ /**
+ * 接続するデータベースの URL 。
+ */
+ private String url;
+ /**
+ * 接続するアカウントのユーザ名。
+ */
+ private String user;
+ /**
+ * 接続するアカウントのパスワード。
+ */
+ private String password;
+ /**
+ * <p>
+ * JDBC ドライバのクラス名を返します。
+ * </p>
+ * @return JDBC ドライバのクラス名。
+ */
+ public String getClassName() {
+ return this.className;
+ }
+ /**
+ * <p>
+ * JDBC ドライバのクラス名を設定します。
+ * </p>
+ * @param className JDBC ドライバのクラス名。
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+ /**
+ * <p>
+ * 接続するアカウントのパスワードを返します。
+ * </p>
+ * @return 接続するアカウントのパスワード。
+ */
+ public String getPassword() {
+ return this.password;
+ }
+ /**
+ * <p>
+ * 接続するアカウントのパスワードを設定します。
+ * </p>
+ * @param password 接続するアカウントのパスワード。
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+ /**
+ * <p>
+ * 接続するデータベースの URL を返します。
+ * </p>
+ * @return 接続するデータベースの URL 。
+ */
+ public String getUrl() {
+ return this.url;
+ }
+ /**
+ * <p>
+ * 接続するデータベースの URL を設定します。
+ * </p>
+ * @param url 接続するデータベースの URL 。
+ */
+ public void setUrl(String url) {
+ this.url = url;
+ }
+ /**
+ * <p>
+ * 接続するアカウントのユーザ名を返します。
+ * </p>
+ * @return 接続するアカウントのユーザ名。
+ */
+ public String getUser() {
+ return this.user;
+ }
+ /**
+ * <p>
+ * 接続するアカウントのユーザ名を設定します。
+ * </p>
+ * @param user 接続するアカウントのユーザ名。
+ */
+ public void setUser(String user) {
+ this.user = user;
+ }
+ /**
+ * <p>
+ * JDBC 接続試験を行います。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスクの実行のイベント情報。
+ * @return 常に null 。
+ * @throws SQLException JDBC 接続に失敗した場合。
+ * @throws ClassNotFoundException JDBC ドライバが見つからなかった場合。
+ */
+ public Object task(Schedule schedule, TaskEvent event) throws ClassNotFoundException, SQLException {
+ // JDBC 接続試験を行います。
+ JdbcConnect jdbcConnect = new JdbcConnect();
+ jdbcConnect.setClassName(this.getClassName());
+ jdbcConnect.setUrl(this.getUrl());
+ jdbcConnect.setUser(this.getUser());
+ jdbcConnect.setPassword(this.getPassword());
+ jdbcConnect.connect();
+ return null;
+ }
+}
--- /dev/null
+<body>
+ <p>JDBC 接続試験を行う機能を持ちます。</p>
+</body>
\ No newline at end of file
--- /dev/null
+# \u5b58\u5728\u3059\u308b JDBC \u30c9\u30e9\u30a4\u30d0\u306e\u30af\u30e9\u30b9\u540d\u3002
+jdbc.class=
+# \u5b58\u5728\u3059\u308b DBMS \u306e URL \u3001\u30e6\u30fc\u30b6\u540d\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3002
+jdbc.url=
+jdbc.user=
+jdbc.password=
+# \u5b58\u5728\u3057\u306a\u3044 JDBC \u30c9\u30e9\u30a4\u30d0\u306e\u30af\u30e9\u30b9\u540d\u3002
+jdbc.unexist_class=
+# \u5b58\u5728\u3057\u306a\u3044 DBMS \u306e URL \u3002
+jdbc.unexist_url=
--- /dev/null
+package jp.gr.java_conf.uguu.jdbc_test.test;
+
+import java.sql.SQLException;
+import java.util.ResourceBundle;
+
+import jp.gr.java_conf.uguu.jdbc_test.JdbcConnectTask;
+import junit.framework.TestCase;
+
+public class JdbcConnectTaskTest extends TestCase {
+ private ResourceBundle rb = ResourceBundle.getBundle("test");
+ public JdbcConnectTaskTest(String name) {
+ super(name);
+ }
+ public void test_connect_接続に成功() throws ClassNotFoundException, SQLException {
+ JdbcConnectTask task = new JdbcConnectTask();
+ task.setClassName(this.rb.getString("jdbc.class"));
+ task.setUrl(this.rb.getString("jdbc.url"));
+ task.setUser(this.rb.getString("jdbc.user"));
+ task.setPassword(this.rb.getString("jdbc.password"));
+ task.task(null, null);
+ }
+ public void test_connect_classNameプロパティが指定されていない場合NullPointerException() throws ClassNotFoundException, SQLException {
+ JdbcConnectTask task = new JdbcConnectTask();
+ task.setClassName(null);
+ task.setUrl(this.rb.getString("jdbc.url"));
+ task.setUser(this.rb.getString("jdbc.user"));
+ task.setPassword(this.rb.getString("jdbc.password"));
+ try {
+ task.task(null, null);
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("className", e.getMessage());
+ }
+ }
+ public void test_connect_urlプロパティが指定されていない場合NullPointerException() throws ClassNotFoundException, SQLException {
+ JdbcConnectTask task = new JdbcConnectTask();
+ task.setClassName(this.rb.getString("jdbc.class"));
+ task.setUrl(null);
+ task.setUser(this.rb.getString("jdbc.user"));
+ task.setPassword(this.rb.getString("jdbc.password"));
+ try {
+ task.task(null, null);
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("url", e.getMessage());
+ }
+ }
+ public void test_connect_classNameプロパティに指定したクラスが存在しない場合ClassNotFoundException() throws SQLException {
+ JdbcConnectTask task = new JdbcConnectTask();
+ task.setClassName(this.rb.getString("jdbc.unexist_class"));
+ task.setUrl(this.rb.getString("jdbc.url"));
+ task.setUser(this.rb.getString("jdbc.user"));
+ task.setPassword(this.rb.getString("jdbc.password"));
+ try {
+ task.task(null, null);
+ fail();
+ } catch (ClassNotFoundException e) {
+ assertEquals(this.rb.getString("jdbc.unexist_class"), e.getMessage());
+ }
+ }
+ public void test_connect_接続に失敗した場合SQLException() throws ClassNotFoundException {
+ JdbcConnectTask task = new JdbcConnectTask();
+ task.setClassName(this.rb.getString("jdbc.class"));
+ task.setUrl(this.rb.getString("jdbc.unexist_url"));
+ task.setUser(this.rb.getString("jdbc.user"));
+ task.setPassword(this.rb.getString("jdbc.password"));
+ try {
+ task.task(null, null);
+ fail();
+ } catch (SQLException e) {
+ // メッセージは検証しません。
+ }
+ }
+}
--- /dev/null
+package jp.gr.java_conf.uguu.jdbc_test.test;
+
+import java.sql.SQLException;
+import java.util.ResourceBundle;
+
+import jp.gr.java_conf.uguu.jdbc_test.JdbcConnect;
+import junit.framework.TestCase;
+
+public class JdbcConnectTest extends TestCase {
+ private ResourceBundle rb = ResourceBundle.getBundle("test");
+ public JdbcConnectTest(String name) {
+ super(name);
+ }
+ public void test_connect_接続に成功() throws ClassNotFoundException, SQLException {
+ JdbcConnect jdbcConnect = new JdbcConnect();
+ jdbcConnect.setClassName(this.rb.getString("jdbc.class"));
+ jdbcConnect.setUrl(this.rb.getString("jdbc.url"));
+ jdbcConnect.setUser(this.rb.getString("jdbc.user"));
+ jdbcConnect.setPassword(this.rb.getString("jdbc.password"));
+ jdbcConnect.connect();
+ }
+ public void test_connect_classNameプロパティが指定されていない場合NullPointerException() throws ClassNotFoundException, SQLException {
+ JdbcConnect jdbcConnect = new JdbcConnect();
+ jdbcConnect.setClassName(null);
+ jdbcConnect.setUrl(this.rb.getString("jdbc.url"));
+ jdbcConnect.setUser(this.rb.getString("jdbc.user"));
+ jdbcConnect.setPassword(this.rb.getString("jdbc.password"));
+ try {
+ jdbcConnect.connect();
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("className", e.getMessage());
+ }
+ }
+ public void test_connect_urlプロパティが指定されていない場合NullPointerException() throws ClassNotFoundException, SQLException {
+ JdbcConnect jdbcConnect = new JdbcConnect();
+ jdbcConnect.setClassName(this.rb.getString("jdbc.class"));
+ jdbcConnect.setUrl(null);
+ jdbcConnect.setUser(this.rb.getString("jdbc.user"));
+ jdbcConnect.setPassword(this.rb.getString("jdbc.password"));
+ try {
+ jdbcConnect.connect();
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("url", e.getMessage());
+ }
+ }
+ public void test_connect_classNameプロパティに指定したクラスが存在しない場合ClassNotFoundException() throws SQLException {
+ JdbcConnect jdbcConnect = new JdbcConnect();
+ jdbcConnect.setClassName(this.rb.getString("jdbc.unexist_class"));
+ jdbcConnect.setUrl(this.rb.getString("jdbc.url"));
+ jdbcConnect.setUser(this.rb.getString("jdbc.user"));
+ jdbcConnect.setPassword(this.rb.getString("jdbc.password"));
+ try {
+ jdbcConnect.connect();
+ fail();
+ } catch (ClassNotFoundException e) {
+ assertEquals(this.rb.getString("jdbc.unexist_class"), e.getMessage());
+ }
+ }
+ public void test_connect_接続に失敗した場合SQLException() throws ClassNotFoundException {
+ JdbcConnect jdbcConnect = new JdbcConnect();
+ jdbcConnect.setClassName(this.rb.getString("jdbc.class"));
+ jdbcConnect.setUrl(this.rb.getString("jdbc.unexist_url"));
+ jdbcConnect.setUser(this.rb.getString("jdbc.user"));
+ jdbcConnect.setPassword(this.rb.getString("jdbc.password"));
+ try {
+ jdbcConnect.connect();
+ fail();
+ } catch (SQLException e) {
+ // メッセージは検証しません。
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><fileset-config file-format-version="1.1.0" simple-config="false">
+<fileset name="src" enabled="true" check-config-name="Uguu Checks" type="remote" location="http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml" description="Uguu Software のコーディング スタイルです。"><file-match-pattern match-pattern="src\\java" include-pattern="true"/>
+</fileset>
+</fileset-config>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/test"/>
+ <classpathentry kind="src" path="src/test-conf"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-0.1.8.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>uguu-ping</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.mevenide.ui.mavenbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.mevenide.ui.mavennature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <pomVersion>3</pomVersion>
+ <organization>
+ <name>Uguu Software</name>
+ <url>http://wiki.livedoor.jp/uguuxp/</url>
+ <logo>http://image02.wiki.livedoor.jp/u/p/uguuxp/82487bf1fed6e9af.png</logo>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports>
+<!--
+ <report>maven-changelog-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-checkstyle-plugin</report>
+-->
+ <report>maven-linkcheck-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-faq-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
--- /dev/null
+maven.compile.debug=true
+maven.compile.encoding=utf-8
+maven.compile.source=1.5
+
+maven.docs.outputencoding=utf-8
+
+maven.checkstyle.check.tests=false
+maven.checkstyle.header.file=${basedir}/LICENSE.txt
+maven.checkstyle.propertiesURL=http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml
+
+maven.test.failure.ignore=true
+
+maven.xdoc.date=right
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.distributionUrl=http://uguu-sysman.sourceforge.jp/maven/uguu-http-test/jars
+maven.xdoc.distributionType=jar
+
+maven.repo.remote=http://www.ibiblio.org/maven/,http://uguu-sysman.sourceforge.jp/maven/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <extend>${basedir}/project-base.xml</extend>
+ <artifactId>uguu-ping</artifactId>
+ <name>uguu-ping</name>
+ <groupId>uguu-ping</groupId>
+ <currentVersion>0.0.6</currentVersion>
+ <inceptionYear>2005</inceptionYear>
+ <package>jp.gr.java_conf.uguu.ping</package>
+ <description>Ping を行います。</description>
+ <repository>
+ <connection>scm:cvs:pserver:anonymous@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-ping</connection>
+ <developerConnection>scm:cvs:ext:uguu@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-ping</developerConnection>
+ <url>http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/uguu-sysman/uguu-ping/</url>
+ </repository>
+ <developers>
+ <developer>
+ <name>uguu</name>
+ <id>2</id>
+ <email>uguu@users.sourceforge.jp</email>
+ <organization>Uguu Software</organization>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>BSD License</name>
+ </license>
+ </licenses>
+ <versions>
+ <version>
+ <name>0.0.6</name>
+ <tag>RELEASE_0_0_6</tag>
+ </version>
+ <version>
+ <name>0.0.5</name>
+ <tag>RELEASE_0_0_5</tag>
+ </version>
+ <version>
+ <name>0.0.4</name>
+ <tag>RELEASE_0_0_4</tag>
+ </version>
+ <version>
+ <name>0.0.3</name>
+ <tag>RELEASE_0_0_3</tag>
+ </version>
+ <version>
+ <name>0.0.2</name>
+ <tag>RELEASE_0_0_2</tag>
+ </version>
+ <version>
+ <name>0.0.1</name>
+ <tag>RELEASE_0_0_1</tag>
+ </version>
+ </versions>
+ <dependencies>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler</artifactId>
+ <version>0.1.8</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.ping;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * Ping を行うクラスのベース クラスです。
+ * このクラスでは、 Ping を行い標準出力を取得するところまでを行います。
+ * このクラスを継承したクラスは、 ping コマンド文字列の構築、標準出力を解析し結果を生成する処理を実装する必要があります。
+ * </p>
+ * @author uguu
+ */
+public abstract class BasePing implements IPing {
+ /**
+ * Ping を行う回数の既定値。
+ */
+ private static final int COUNT_DEFAULT = 4;
+ /**
+ * タイムアウト (ミリ秒) 。
+ */
+ private Integer timeout;
+ /**
+ * Ping を行う回数。
+ */
+ private int count = COUNT_DEFAULT;
+ /**
+ * Ping を行うホスト。
+ */
+ private String host;
+ /**
+ * {@inheritDoc}
+ */
+ public int getCount() {
+ return this.count;
+ }
+ /**
+ * <p>
+ * Ping を行う回数を設定します。
+ * 既定は 4 です。
+ * </p>
+ * @param count Ping を行う回数。
+ */
+ public void setCount(int count) {
+ this.count = count;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Integer getTimeout() {
+ return this.timeout;
+ }
+ /**
+ * <p>
+ * タイムアウト (ミリ秒) を設定します。
+ * null の場合、環境ごとの既定値を使用します。
+ * 既定は null です。
+ * </p>
+ * @param timeout タイムアウト (ミリ秒) 。
+ */
+ public void setTimeout(Integer timeout) {
+ this.timeout = timeout;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public String getHost() {
+ return this.host;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void setHost(String host) {
+ this.host = host;
+ }
+ /**
+ * <p>
+ * Ping を行います。
+ * </p>
+ * @return Ping の結果のリスト。
+ * @throws IllegalStateException プロパティの値が適切ではない場合。
+ * @throws Exception コマンドの実行について、入出力エラーが発生した場合。
+ * コマンドが中断された場合。
+ * ホストが存在しない場合。
+ * その他、エラーが発生した場合。
+ */
+ public List<PingResult> ping() throws Exception {
+ if (this.host == null || "".equals(this.host)) {
+ throw new IllegalStateException("host プロパティは、有効なホスト名を指定してください。");
+ }
+ if (this.timeout != null) {
+ if (this.timeout < 0) {
+ throw new IllegalStateException("timeout プロパティは、 null または 0 <= timeout を指定してください。");
+ }
+ }
+ if (this.count < 1) {
+ throw new IllegalStateException("count プロパティは、 1 <= count <= 4294967295 を指定してください。");
+ }
+ /*
+ * Ping を行い、結果を取得します。
+ */
+ // ping コマンドを実行します。
+ List<String> command = this.pingCommands();
+ ProcessBuilder pb = new ProcessBuilder(command);
+ Process p = pb.start();
+ // 全ての標準出力、標準エラー出力を取得します。
+ List<String> stdout = this.getLines(p.getInputStream());
+ List<String> stderr = this.getLines(p.getErrorStream());
+ // ping コマンドの終了まで待ちます。
+ p.waitFor();
+ /*
+ * Ping の結果文字列を解析し、結果を生成します。
+ */
+ List<PingResult> resultList = this.pingResults(stdout, stderr);
+ return resultList;
+ }
+ private List<String> getLines(InputStream in) throws IOException {
+ List<String> lines = new ArrayList<String>();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ try {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ lines.add(line);
+ }
+ } finally {
+ reader.close();
+ }
+ return lines;
+ }
+ /**
+ * <p>
+ * Ping を行うために {@link ProcessBuilder} クラスに渡す文字列リストを構築します。
+ * このクラスは、 Ping を ping コマンドを使用して行いますが、環境によって引数が違います。
+ * 実装クラスは、環境ごとの引数リストを構築する必要があります。
+ * </p>
+ * @return {@link ProcessBuilder} クラスに渡す文字列リスト。
+ * @throws Exception 何らかのエラーが発生した場合。
+ */
+ protected abstract List<String> pingCommands() throws Exception;
+ /**
+ * <p>
+ * ping コマンドの結果の標準出力を解析して、 Ping の結果を構築します。
+ * このクラスは、 Ping を ping コマンドを使用して行いますが、環境によって出力される文字列が違います。
+ * 実装クラスは、環境ごとに文字列を解析して結果を構築する必要があります。
+ * </p>
+ * @param stdout 標準出力のリスト。 1 行ずつ格納されています。
+ * @param stderr 標準エラー出力のリスト。 1 行ずつ格納されています。
+ * @return Ping の結果リスト。
+ * @throws Exception 何らかのエラーが発生した場合。
+ */
+ protected abstract List<PingResult> pingResults(List<String> stdout, List<String> stderr) throws Exception;
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.ping;
+
+import java.util.List;
+
+/**
+ * <p>
+ * Ping を行うクラスのインターフェイスです。
+ * </p>
+ * @author uguu
+ */
+public interface IPing {
+ /**
+ * <p>
+ * Ping を行う回数を返します。
+ * </p>
+ * @return Ping を行う回数。
+ */
+ int getCount();
+ /**
+ * <p>
+ * Ping を行う回数を設定します。
+ * </p>
+ * @param count Ping を行う回数。
+ */
+ void setCount(int count);
+ /**
+ * <p>
+ * タイムアウト (ミリ秒) を返します。
+ * </p>
+ * @return タイムアウト (ミリ秒) 。
+ */
+ Integer getTimeout();
+ /**
+ * <p>
+ * タイムアウト (ミリ秒) を設定します。
+ * </p>
+ * @param timeout タイムアウト (ミリ秒) 。
+ */
+ void setTimeout(Integer timeout);
+ /**
+ * <p>
+ * Ping を行うホストを取得します。
+ * </p>
+ * @return Ping を行うホスト。
+ */
+ String getHost();
+ /**
+ * <p>
+ * Ping を行うホストほ設定します。
+ * </p>
+ * @param host Ping を行うホスト。
+ */
+ void setHost(String host);
+ /**
+ * <p>
+ * Ping を行い、その結果を返します。
+ * </p>
+ * @return Ping の結果のリスト。
+ * 設定によっては複数回の Ping を行うことがあるので、そのリストを返します。
+ * @throws Exception Ping の実行に失敗した場合。
+ * どのような例外がスローされるかは、実装クラスによって異なります。
+ */
+ List<PingResult> ping() throws Exception;
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.ping;
+
+/**
+ * <p>
+ * Ping を行う {@link IPing} インスタンスを生成します。
+ * </p>
+ * <p>
+ * {@link IPing} インスタンスは、環境 (主に OS の種類) によって、使用できるクラスが違います。
+ * {@link PingFactory} クラスは、環境ごとの適切な {@link IPing} インスタンスを生成することができます。
+ * </p>
+ * <p>
+ * このクラスは、以下の環境で適切な {@link IPing} インスタンスを返すことを確認しました。
+ * </p>
+ * <ul>
+ * <li>Windows 2000 Service Pack 4</li>
+ * <li>Windows XP Service Pack 2</li>
+ * </ul>
+ * @author uguu
+ */
+public class PingFactory {
+ /**
+ * OS の種類を表す文字列。
+ */
+ private String os;
+ /**
+ * <p>
+ * OS の種類を表す文字列を返します。
+ * </p>
+ * @return OS の種類を表す文字列。
+ */
+ public String getOs() {
+ return this.os;
+ }
+ /**
+ * <p>
+ * OS の種類を表す文字列を設定します。
+ * null の場合、 {@link PingFactory} クラスは、システム プロパティの "os.name" を参照します。
+ * 既定は null です。
+ * </p>
+ * @param os OS の種類を表す文字列。
+ */
+ public void setOs(String os) {
+ this.os = os;
+ }
+ /**
+ * <p>
+ * 環境ごとの適切な {@link IPing} インスタンスを生成し、返します。
+ * </p>
+ * @return 環境ごとの適切な {@link IPing} インスタンス。
+ * 適切な {@link IPing} インスタンスが見つからない場合は null 。
+ */
+ public IPing createPing() {
+ IPing ping = null;
+ String propOs;
+ if (this.os == null) {
+ propOs = System.getProperty("os.name");
+ } else {
+ propOs = this.os;
+ }
+ if (propOs.equals("Windows 2000")) {
+ ping = new PingWin2000();
+ } else if (propOs.equals("Windows XP")) {
+ ping = new PingWinXP();
+ }
+ return ping;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.ping;
+
+/**
+ * <p>
+ * Ping の結果を表します。
+ * </p>
+ * @author uguu
+ */
+public final class PingResult {
+ /**
+ * タイムアウトかどうか。
+ */
+ private boolean timeout;
+ /**
+ * 到達にかかった時間 (ミリ秒) 。
+ */
+ private Integer time;
+ /**
+ * Time To Live 。
+ */
+ private Integer ttl;
+ /**
+ * <p>
+ * 到達にかかった時間 (ミリ秒) を返します。
+ * タイムアウトの場合は null です。
+ * </p>
+ * @return 到達にかかった時間 (ミリ秒) 。
+ */
+ public Integer getTime() {
+ return this.time;
+ }
+ /**
+ * <p>
+ * 到達にかかった時間 (ミリ秒) を設定します。
+ * </p>
+ * @param time 到達にかかった時間 (ミリ秒) 。
+ */
+ public void setTime(Integer time) {
+ this.time = time;
+ }
+ /**
+ * <p>
+ * タイムアウトかどうかを返します。
+ * </p>
+ * @return タイムアウトかどうか。
+ */
+ public boolean isTimeout() {
+ return this.timeout;
+ }
+ /**
+ * <p>
+ * タイムアウトかどうかを設定します。
+ * </p>
+ * @param timeout タイムアウトかどうか。
+ */
+ public void setTimeout(boolean timeout) {
+ this.timeout = timeout;
+ }
+ /**
+ * <p>
+ * Time To Live を返します。
+ * タイムアウトの場合は null です。
+ * </p>
+ * @return Time To Live 。
+ */
+ public Integer getTtl() {
+ return this.ttl;
+ }
+ /**
+ * <p>
+ * Time To Live を設定します。
+ * </p>
+ * @param ttl Time To Live 。
+ */
+ public void setTtl(Integer ttl) {
+ this.ttl = ttl;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.ping;
+
+import java.util.List;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.Task;
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+
+/**
+ * <p>
+ * Ping を行うタスクです。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public class PingTask implements Task<List<PingResult>> {
+ /**
+ * タイムアウト (ミリ秒) 。
+ */
+ private Integer timeout;
+ /**
+ * Ping を行う回数。
+ */
+ private Integer count;
+ /**
+ * Ping を行うホスト。
+ */
+ private String host;
+ /**
+ * <p>
+ * Ping を行う回数を返します。
+ * </p>
+ * @return Ping を行う回数。
+ */
+ public Integer getCount() {
+ return this.count;
+ }
+ /**
+ * <p>
+ * Ping を行う回数を設定します。
+ * </p>
+ * @param count Ping を行う回数。
+ */
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+ /**
+ * <p>
+ * タイムアウト (ミリ秒) を返します。
+ * </p>
+ * @return タイムアウト (ミリ秒) 。
+ */
+ public Integer getTimeout() {
+ return this.timeout;
+ }
+ /**
+ * <p>
+ * タイムアウト (ミリ秒) を設定します。
+ * </p>
+ * @param timeout タイムアウト (ミリ秒) 。
+ */
+ public void setTimeout(Integer timeout) {
+ this.timeout = timeout;
+ }
+ /**
+ * <p>
+ * Ping を行うホストを取得します。
+ * </p>
+ * @return Ping を行うホスト。
+ */
+ public String getHost() {
+ return this.host;
+ }
+ /**
+ * <p>
+ * Ping を行うホストほ設定します。
+ * </p>
+ * @param host Ping を行うホスト。
+ */
+ public void setHost(String host) {
+ this.host = host;
+ }
+ /**
+ * <p>
+ * Ping を行います。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスクの実行のイベント情報。
+ * @return Ping の結果のリスト。
+ * @throws Exception Ping に失敗した場合。
+ */
+ public List<PingResult> task(Schedule schedule, TaskEvent event) throws Exception {
+ // Ping を行います。
+ PingFactory pingFactory = new PingFactory();
+ IPing ping = pingFactory.createPing();
+ if (this.timeout != null) {
+ ping.setTimeout(this.timeout);
+ }
+ if (this.count != null) {
+ ping.setCount(this.count);
+ }
+ if (this.host != null) {
+ ping.setHost(this.host);
+ }
+ List<PingResult> resultList = ping.ping();
+ return resultList;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.ping;
+
+import java.net.UnknownHostException;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * <p>
+ * Windows 2000 で Ping を行う機能を持ちます。
+ * </p>
+ * @author uguu
+ */
+public class PingWin2000 extends BasePing {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected List<String> pingCommands() {
+ List<String> commands = new ArrayList<String>();
+ commands.add("ping");
+ if (this.getTimeout() != null) {
+ commands.add("-w");
+ commands.add(this.getTimeout().toString());
+ }
+ commands.add("-n");
+ commands.add(Integer.toString(this.getCount()));
+ commands.add(this.getHost());
+ return commands;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected List<PingResult> pingResults(List<String> stdout, List<String> stderr) throws UnknownHostException {
+ List<PingResult> resultList = new ArrayList<PingResult>();
+ // 到達、タイムアウト、ホスト不明を表す正規表現を宣言します。
+ Pattern replyPattern = Pattern.compile("Reply from [0-9]{1,3}(\\.[0-9]{1,3}){3}: bytes=[0-9]{1,} time(=|<)[0-9]{1,}ms TTL=[0-9]{1,}");
+ Pattern timeoutPattern = Pattern.compile("Request timed out\\.");
+ Pattern unknownHostPattern = Pattern.compile("Unknown host .*\\.");
+ // 標準出力を解析します。
+ for (String line : stdout) {
+ Matcher replyMatcher = replyPattern.matcher(line);
+ Matcher timeoutMatcher = timeoutPattern.matcher(line);
+ Matcher unknownHostMatcher = unknownHostPattern.matcher(line);
+ if (replyMatcher.matches()) {
+ resultList.add(this.parseReplyResult(line));
+ } else if (timeoutMatcher.matches()) {
+ PingResult pingResult = new PingResult();
+ pingResult.setTime(null);
+ pingResult.setTimeout(true);
+ pingResult.setTtl(null);
+ resultList.add(pingResult);
+ } else if (unknownHostMatcher.matches()) {
+ throw new UnknownHostException(this.getHost());
+ }
+ }
+ return resultList;
+ }
+ private PingResult parseReplyResult(String line) {
+ try {
+ final int timeColumnIndex = 4;
+ final int ttlColumnIndex = 5;
+ PingResult result = new PingResult();
+ String[] columns = line.split(" ");
+ String timeColumn = columns[timeColumnIndex];
+ String ttlColumn = columns[ttlColumnIndex];
+ NumberFormat format;
+ result.setTimeout(false);
+ if (timeColumn.startsWith("time<")) {
+ result.setTime(0);
+ } else {
+ format = new DecimalFormat("time=#ms");
+ result.setTime(format.parse(timeColumn).intValue());
+ }
+ format = new DecimalFormat("TTL=#");
+ result.setTtl(format.parse(ttlColumn).intValue());
+ return result;
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.ping;
+
+import java.net.UnknownHostException;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * <p>
+ * Windows XP で Ping を行う機能を持ちます。
+ * </p>
+ * @author uguu
+ */
+public class PingWinXP extends BasePing {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected List<String> pingCommands() {
+ List<String> commands = new ArrayList<String>();
+ commands.add("ping");
+ if (this.getTimeout() != null) {
+ commands.add("-w");
+ commands.add(this.getTimeout().toString());
+ }
+ commands.add("-n");
+ commands.add(Integer.toString(this.getCount()));
+ commands.add(this.getHost());
+ return commands;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected List<PingResult> pingResults(List<String> stdout, List<String> stderr) throws UnknownHostException {
+ List<PingResult> resultList = new ArrayList<PingResult>();
+ // 到達、タイムアウト、ホスト不明を表す正規表現を宣言します。
+ Pattern replyPattern = Pattern.compile("Reply from [0-9]{1,3}(\\.[0-9]{1,3}){3}: bytes=[0-9]{1,} time(=|<)[0-9]{1,}ms TTL=[0-9]{1,}");
+ Pattern timeoutPattern = Pattern.compile("Request timed out\\.");
+ Pattern unknownHostPattern = Pattern.compile("Ping request could not find host .*\\. Please check the name and try again\\.");
+ // 標準出力を解析します。
+ for (String line : stdout) {
+ Matcher replyMatcher = replyPattern.matcher(line);
+ Matcher timeoutMatcher = timeoutPattern.matcher(line);
+ Matcher unknownHostMatcher = unknownHostPattern.matcher(line);
+ if (replyMatcher.matches()) {
+ resultList.add(this.parseReplyResult(line));
+ } else if (timeoutMatcher.matches()) {
+ PingResult pingResult = new PingResult();
+ pingResult.setTime(null);
+ pingResult.setTimeout(true);
+ pingResult.setTtl(null);
+ resultList.add(pingResult);
+ } else if (unknownHostMatcher.matches()) {
+ throw new UnknownHostException(this.getHost());
+ }
+ }
+ return resultList;
+ }
+ private PingResult parseReplyResult(String line) {
+ try {
+ final int timeColumnIndex = 4;
+ final int ttlColumnIndex = 5;
+ PingResult result = new PingResult();
+ String[] columns = line.split(" ");
+ String timeColumn = columns[timeColumnIndex];
+ String ttlColumn = columns[ttlColumnIndex];
+ NumberFormat format;
+ result.setTimeout(false);
+ if (timeColumn.startsWith("time<")) {
+ result.setTime(0);
+ } else {
+ format = new DecimalFormat("time=#ms");
+ result.setTime(format.parse(timeColumn).intValue());
+ }
+ format = new DecimalFormat("TTL=#");
+ result.setTtl(format.parse(ttlColumn).intValue());
+ return result;
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
--- /dev/null
+<body>
+ <p>Ping を行う機能を持つパッケージです。</p>
+</body>
\ No newline at end of file
--- /dev/null
+# \u30ed\u30fc\u30ab\u30eb\u3067 Ping \u306b\u6210\u529f\u3059\u308b\u30db\u30b9\u30c8\u3002
+ping.local.host=localhost
+
+# \u30ea\u30e2\u30fc\u30c8\u3067 Ping \u306b\u6210\u529f\u3059\u308b\u30db\u30b9\u30c8\u3002
+ping.remote.host=www.google.com
+
+# \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3059\u308b\u30db\u30b9\u30c8\u3002
+ping.timeout.host=10.0.0.0
+
+# Unknown Host \u306a\u30db\u30b9\u30c8\u3002
+ping.unknown.host=hoge.example.com
--- /dev/null
+package jp.gr.java_conf.uguu.ping.test;
+
+import java.net.UnknownHostException;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import jp.gr.java_conf.uguu.ping.IPing;
+import jp.gr.java_conf.uguu.ping.PingResult;
+import junit.framework.TestCase;
+
+public abstract class BasePingTest extends TestCase {
+ private ResourceBundle rb = ResourceBundle.getBundle("test");
+ public BasePingTest(String name) {
+ super(name);
+ }
+ protected abstract IPing createPing();
+ public void test_ping_localhostにPingを行って成功することを確認() throws Exception {
+ IPing ping = this.createPing();
+ ping.setCount(1);
+ ping.setHost(this.rb.getString("ping.local.host"));
+ List<PingResult> pingResultList = ping.ping();
+ // 結果を確認します。
+ assertEquals(1, pingResultList.size());
+ assertFalse(pingResultList.get(0).isTimeout());
+ assertTrue(pingResultList.get(0).getTime() >= 0);
+ assertTrue(pingResultList.get(0).getTtl() >= 0);
+ }
+ public void test_ping_www_google_comにPingを行って成功することを確認() throws Exception {
+ IPing ping = this.createPing();
+ ping.setCount(1);
+ ping.setHost(this.rb.getString("ping.remote.host"));
+ List<PingResult> pingResultList = ping.ping();
+ // 結果を確認します。
+ assertEquals(1, pingResultList.size());
+ assertFalse(pingResultList.get(0).isTimeout());
+ assertTrue(pingResultList.get(0).getTime() >= 0);
+ assertTrue(pingResultList.get(0).getTtl() >= 0);
+ }
+ public void test_ping_存在しないホストにPingを行ってタイムアウトすることを確認() throws Exception {
+ IPing ping = this.createPing();
+ ping.setCount(1);
+ ping.setHost(this.rb.getString("ping.timeout.host"));
+ List<PingResult> pingResultList = ping.ping();
+ // 結果を確認します。
+ assertEquals(1, pingResultList.size());
+ assertTrue(pingResultList.get(0).isTimeout());
+ assertNull(pingResultList.get(0).getTime());
+ assertNull(pingResultList.get(0).getTtl());
+ }
+ public void test_ping_存在しないホストにPingを行ってUnknownHostException() throws Exception {
+ IPing ping = this.createPing();
+ ping.setHost(this.rb.getString("ping.unknown.host"));
+ try {
+ ping.ping();
+ fail();
+ } catch (UnknownHostException e) {
+ assertEquals(this.rb.getString("ping.unknown.host"), e.getMessage());
+ }
+ }
+ public void test_ping_countの回数分の結果が返ることを確認() throws Exception {
+ IPing ping = this.createPing();
+ ping.setCount(10);
+ ping.setHost(this.rb.getString("ping.local.host"));
+ List<PingResult> pingResultList = ping.ping();
+ // 結果を確認します。
+ assertEquals(10, pingResultList.size());
+ assertFalse(pingResultList.get(0).isTimeout());
+ assertTrue(pingResultList.get(0).getTime() >= 0);
+ assertTrue(pingResultList.get(0).getTtl() >= 0);
+ assertFalse(pingResultList.get(1).isTimeout());
+ assertTrue(pingResultList.get(1).getTime() >= 0);
+ assertTrue(pingResultList.get(1).getTtl() >= 0);
+ assertFalse(pingResultList.get(2).isTimeout());
+ assertTrue(pingResultList.get(2).getTime() >= 0);
+ assertTrue(pingResultList.get(2).getTtl() >= 0);
+ assertFalse(pingResultList.get(3).isTimeout());
+ assertTrue(pingResultList.get(3).getTime() >= 0);
+ assertTrue(pingResultList.get(3).getTtl() >= 0);
+ assertFalse(pingResultList.get(4).isTimeout());
+ assertTrue(pingResultList.get(4).getTime() >= 0);
+ assertTrue(pingResultList.get(4).getTtl() >= 0);
+ assertFalse(pingResultList.get(5).isTimeout());
+ assertTrue(pingResultList.get(5).getTime() >= 0);
+ assertTrue(pingResultList.get(5).getTtl() >= 0);
+ assertFalse(pingResultList.get(6).isTimeout());
+ assertTrue(pingResultList.get(6).getTime() >= 0);
+ assertTrue(pingResultList.get(6).getTtl() >= 0);
+ assertFalse(pingResultList.get(7).isTimeout());
+ assertTrue(pingResultList.get(7).getTime() >= 0);
+ assertTrue(pingResultList.get(7).getTtl() >= 0);
+ assertFalse(pingResultList.get(8).isTimeout());
+ assertTrue(pingResultList.get(8).getTime() >= 0);
+ assertTrue(pingResultList.get(8).getTtl() >= 0);
+ assertFalse(pingResultList.get(9).isTimeout());
+ assertTrue(pingResultList.get(9).getTime() >= 0);
+ assertTrue(pingResultList.get(9).getTtl() >= 0);
+ }
+ public void test_ping_timeoutに無効な値を設定してIllegalStateException() throws Exception {
+ IPing ping = this.createPing();
+ ping.setHost(this.rb.getString("ping.local.host"));
+ // 下限 - 1。
+ ping.setTimeout(-1);
+ try {
+ ping.ping();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("timeout プロパティは、 null または 0 <= timeout を指定してください。", e.getMessage());
+ }
+ // 下限。
+ ping.setTimeout(0);
+ List<PingResult> pingResultList = ping.ping();
+ assertEquals(4, pingResultList.size());
+ // 上限。
+ ping.setTimeout(Integer.MAX_VALUE);
+ pingResultList = ping.ping();
+ assertEquals(4, pingResultList.size());
+ // null 。
+ ping.setTimeout(null);
+ pingResultList = ping.ping();
+ assertEquals(4, pingResultList.size());
+ }
+ public void test_ping_countに無効な値を設定してIllegalStateException() throws Exception {
+ IPing ping = this.createPing();
+ ping.setHost(this.rb.getString("ping.local.host"));
+ // 下限 - 1。
+ ping.setCount(0);
+ try {
+ ping.ping();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("count プロパティは、 1 <= count <= 4294967295 を指定してください。", e.getMessage());
+ }
+ // 下限。
+ ping.setCount(1);
+ List<PingResult> pingResultList = ping.ping();
+ assertEquals(1, pingResultList.size());
+ }
+ public void test_ping_hostに無効な値を設定してIllegalStateException() throws Exception {
+ IPing ping = this.createPing();
+ // null 。
+ ping.setHost(null);
+ try {
+ ping.ping();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("host プロパティは、有効なホスト名を指定してください。", e.getMessage());
+ }
+ // 空文字列。
+ ping.setHost("");
+ try {
+ ping.ping();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("host プロパティは、有効なホスト名を指定してください。", e.getMessage());
+ }
+ }
+}
--- /dev/null
+package jp.gr.java_conf.uguu.ping.test;
+
+import jp.gr.java_conf.uguu.ping.IPing;
+import jp.gr.java_conf.uguu.ping.PingWin2000;
+
+public class PingWin2000Test extends BasePingTest {
+ public PingWin2000Test(String name) {
+ super(name);
+ }
+ @Override
+ protected IPing createPing() {
+ return new PingWin2000();
+ }
+}
--- /dev/null
+package jp.gr.java_conf.uguu.ping.test;
+
+import jp.gr.java_conf.uguu.ping.IPing;
+import jp.gr.java_conf.uguu.ping.PingWinXP;
+
+public class PingWinXPTest extends BasePingTest {
+ public PingWinXPTest(String name) {
+ super(name);
+ }
+ @Override
+ protected IPing createPing() {
+ return new PingWinXP();
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><fileset-config file-format-version="1.1.0" simple-config="false">
+<fileset name="src" enabled="true" check-config-name="Uguu Checks" type="remote" location="http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml" description="Uguu Software のコーディング スタイルです。"><file-match-pattern match-pattern="src\\java" include-pattern="true"/>
+</fileset>
+</fileset-config>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/test"/>
+ <classpathentry kind="src" path="src/test-conf"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-0.1.9.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>uguu-scheduler-impl</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.mevenide.ui.mavenbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.mevenide.ui.mavennature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<project xmlns:j="jelly:core">
+ <preGoal name="dist:build-bin">
+ <mkdir dir="${maven.dist.bin.assembly.dir}/conf"/>
+ <copy todir="${maven.dist.bin.assembly.dir}/conf">
+ <fileset dir="${basedir}/src/test-conf"/>
+ </copy>
+ </preGoal>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <pomVersion>3</pomVersion>
+ <organization>
+ <name>Uguu Software</name>
+ <url>http://wiki.livedoor.jp/uguuxp/</url>
+ <logo>http://image02.wiki.livedoor.jp/u/p/uguuxp/82487bf1fed6e9af.png</logo>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports>
+<!--
+ <report>maven-changelog-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-checkstyle-plugin</report>
+-->
+ <report>maven-linkcheck-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-faq-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
--- /dev/null
+maven.compile.debug=true
+maven.compile.encoding=utf-8
+maven.compile.source=1.5
+
+maven.docs.outputencoding=utf-8
+
+maven.checkstyle.check.tests=false
+maven.checkstyle.header.file=${basedir}/LICENSE.txt
+maven.checkstyle.propertiesURL=http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml
+
+maven.test.failure.ignore=true
+
+maven.xdoc.date=right
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.distributionUrl=http://uguu-sysman.sourceforge.jp/maven/uguu-http-test/jars
+maven.xdoc.distributionType=jar
+
+maven.repo.remote=http://www.ibiblio.org/maven/,http://uguu-sysman.sourceforge.jp/maven/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <extend>${basedir}/project-base.xml</extend>
+ <artifactId>uguu-scheduler-impl</artifactId>
+ <name>uguu-scheduler-impl</name>
+ <groupId>uguu-scheduler</groupId>
+ <currentVersion>0.1.5</currentVersion>
+ <inceptionYear>2005</inceptionYear>
+ <package>jp.gr.java_conf.uguu.scheduler.impl</package>
+ <description>スケジュールに従ってタスクを実行するスケジューラの実装です。</description>
+ <repository>
+ <connection>scm:cvs:pserver:anonymous@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-scheduler-impl</connection>
+ <developerConnection>scm:cvs:ext:uguu@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-scheduler-impl</developerConnection>
+ <url>http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/uguu-sysman/uguu-scheduler-impl/</url>
+ </repository>
+ <developers>
+ <developer>
+ <name>uguu</name>
+ <id>2</id>
+ <email>uguu@users.sourceforge.jp</email>
+ <organization>Uguu Software</organization>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>BSD License</name>
+ </license>
+ </licenses>
+ <versions>
+ <version>
+ <name>0.1.5</name>
+ <tag>RELEASE_0_1_5</tag>
+ </version>
+ <version>
+ <name>0.1.4</name>
+ <tag>RELEASE_0_1_4</tag>
+ </version>
+ <version>
+ <name>0.1.3</name>
+ <tag>RELEASE_0_1_3</tag>
+ </version>
+ <version>
+ <name>0.1.2</name>
+ <tag>RELEASE_0_1_2</tag>
+ </version>
+ <version>
+ <name>0.1.1</name>
+ <tag>RELEASE_0_1_1</tag>
+ </version>
+ <version>
+ <name>0.1.0</name>
+ <tag>RELEASE_0_1_0</tag>
+ </version>
+ <version>
+ <name>0.0.1</name>
+ <tag>RELEASE_0_0_1</tag>
+ </version>
+ </versions>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler</artifactId>
+ <version>0.1.9</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+/**
+ * <p>
+ * 週の曜日を表します。
+ * </p>
+ * @author uguu
+ */
+public enum DayOfWeekEnum {
+ /**
+ * <p>
+ * 日曜日。
+ * </p>
+ */
+ SUNDAY,
+ /**
+ * <p>
+ * 月曜日。
+ * </p>
+ */
+ MONDAY,
+ /**
+ * <p>
+ * 火曜日。
+ * </p>
+ */
+ TUESDAY,
+ /**
+ * <p>
+ * 水曜日。
+ * </p>
+ */
+ WEDNESDAY,
+ /**
+ * <p>
+ * 木曜日。
+ * </p>
+ */
+ THURSDAY,
+ /**
+ * <p>
+ * 金曜日。
+ * </p>
+ */
+ FRIDAY,
+ /**
+ * <p>
+ * 土曜日。
+ * </p>
+ */
+ SATURDAY,
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.ScheduleIterable;
+import jp.gr.java_conf.uguu.scheduler.Scheduler;
+import jp.gr.java_conf.uguu.scheduler.SchedulerEventListener;
+import jp.gr.java_conf.uguu.scheduler.SchedulerEventListenerList;
+import jp.gr.java_conf.uguu.scheduler.SchedulerListener;
+
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p>
+ * {@link ExecutorService} 実装クラスを使用して定期的に処理を行うスケジューラの実装です。
+ * </p>
+ * <p>
+ * 初期化後は、スケジューラは動作を開始していません。
+ * 動作させるために、 {@link #start()} メソッドを呼び出してください。
+ * </p>
+ * <p>
+ * タスクは、スケジューラの初期化時に指定した {@link ExecutorService} 実装クラスによって実行されます。
+ * なので、指定した {@link ExecutorService} 実装クラスによって遅延が生じる可能性があります。
+ * 例えば、シングルスレッドの {@link ExecutorService} 実装クラスの場合、タスクの処理に時間がかかれば、後続のタスクの実行が遅延されます。
+ * マルチスレッドの {@link ExecutorService} 実装クラスの場合、タスクは別々のスレッドで実行されるので、遅延は生じません。
+ * マルチスレッドでもスレッドの数が足りなくなれば、遅延が生じるかもしれません。
+ * かといってスレッドが多すぎるとパフォーマンスに影響が出ます。
+ * このあたりの調整は、スケジューラを使用する側に委ねられます。
+ * 適切な {@link ExecutorService} 実装クラスを指定してください。
+ * </p>
+ * <p>
+ * スケジューラは、 {@link #stop()} メソッドが呼び出されるまで、基本的には終了しません (スケジューラを実行しているスレッドがデーモンスレッドでなければ、メインスレッドの終了とともに終了しますが) 。
+ * スケジューラを終了するために、 {@link #stop()} メソッドを呼び出してください。
+ * ただし、 {@link #stop()} メソッドは「これ以上のタスクを実行しない」というだけで、現在実行中のタスクを終了するものではありません。
+ * 現在実行中のタスクも含めて、スケジューラの全ての動作を終了させる場合、スケジューラの初期化時に指定した {@link ExecutorService} 実装クラスの {@link ExecutorService#shutdownNow()} メソッドを呼び出してください。
+ * </p>
+ * @author uguu
+ */
+public class ExecutorServiceScheduler implements Scheduler {
+ /**
+ * <p>
+ * タスクを実行します。
+ * </p>
+ * @author uguu
+ */
+ static class TaskRunner implements Runnable {
+ /**
+ * 実行するスケジュール。
+ */
+ private Schedule schedule;
+ /**
+ * <p>
+ * {@link TaskRunner} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param schedule 実行するスケジュール。
+ * @throws NullPointerException schedule 引数が null の場合。
+ */
+ TaskRunner(Schedule schedule) {
+ if (schedule == null) {
+ throw new NullPointerException("schedule");
+ }
+ this.schedule = schedule;
+ }
+ /**
+ * <p>
+ * タスクを実行します。
+ * </p>
+ */
+ public void run() {
+ this.schedule.execute();
+ }
+ }
+ /**
+ * <p>
+ * {@link TaskRunner} インスタンスを {@link ExecutorService} インスタンスを用いて定期的に実行します。
+ * </p>
+ * @author uguu
+ */
+ static class SchedulerRunner implements Runnable {
+ /**
+ * スケジューラが動作する間隔 (ミリ秒) 。
+ */
+ private static final int TASK_SPAN = 1000;
+ /**
+ * {@link TaskRunner} インスタンスを実行するサービス。
+ */
+ private ExecutorService executorService;
+ /**
+ * {@link SchedulerRunner} クラスが動作中かどうか。
+ */
+ private boolean running = false;
+ /**
+ * スケジュールのコンテナ。
+ */
+ private ScheduleIterable schedules;
+ /**
+ * リスナーのリスト。
+ */
+ private SchedulerEventListenerList listeners = new SchedulerEventListenerListImpl();
+ /**
+ * スケジューラ。
+ */
+ private Scheduler scheduler;
+ /**
+ * <p>
+ * {@link SchedulerRunner} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param executorService {@link TaskRunner} インスタンスを実行するサービス。
+ * @param scheduler スケジューラ。
+ * @throws NullPointerException executorService, scheduler 引数が null の場合。
+ */
+ public SchedulerRunner(ExecutorService executorService, Scheduler scheduler) {
+ if (executorService == null) {
+ throw new NullPointerException("executorService");
+ }
+ if (scheduler == null) {
+ throw new NullPointerException("scheduler");
+ }
+ this.executorService = executorService;
+ this.scheduler = scheduler;
+ this.schedules = new ScheduleIterableImpl(scheduler);
+ }
+ /**
+ * <p>
+ * スケジュールのコンテナを返します。
+ * </p>
+ * @return スケジュールのコンテナ。
+ */
+ public ScheduleIterable schedules() {
+ return this.schedules;
+ }
+ /**
+ * <p>
+ * リスナーのリストを返します。
+ * </p>
+ * @return リスナーのリスト。
+ */
+ public SchedulerEventListenerList listeners() {
+ return this.listeners;
+ }
+ /**
+ * <p>
+ * 定期的な実行を開始します。
+ * </p>
+ * @throws IllegalStateException 既に動作を開始している場合。
+ */
+ public void start() {
+ if (this.running) {
+ throw new IllegalStateException("スケジューラは既に動作を開始しています。");
+ }
+ this.running = true;
+ this.executorService.submit(this);
+ }
+ /**
+ * <p>
+ * 定期的な実行を停止します。
+ * </p>
+ * @throws IllegalStateException 既に動作を停止している場合。
+ */
+ public void stop() {
+ if (!this.running) {
+ throw new IllegalStateException("スケジューラは既に動作を停止しています。");
+ }
+ this.running = false;
+ this.executorService.shutdownNow();
+ }
+ /**
+ * <p>
+ * 動作中かどうかを判断します。
+ * </p>
+ * @return 動作中の場合は true 、停止している場合は false 。
+ */
+ public boolean isRunning() {
+ return this.running;
+ }
+ /**
+ * <p>
+ * 処理を実行します。
+ * {@link InterruptedException} 例外がスローされると、停止します。
+ * </p>
+ */
+ public void run() {
+ try {
+ try {
+ for (SchedulerEventListener l : this.listeners) {
+ if (l instanceof SchedulerListener) {
+ ((SchedulerListener) l).started(this.scheduler);
+ }
+ }
+ Map<Schedule, Future> futures = new HashMap<Schedule, Future>();
+ while (this.running) {
+ for (Schedule schedule : this.schedules) {
+ if (!this.isExecuting(futures, schedule)) {
+ TaskRunner runner = new TaskRunner(schedule);
+ Future future = this.executorService.submit(runner);
+ futures.put(schedule, future);
+ }
+ }
+ try {
+ Thread.sleep(TASK_SPAN);
+ } catch (InterruptedException e) {
+ if (!this.running) {
+ break;
+ }
+ throw e;
+ }
+ }
+ } finally {
+ this.running = false;
+ for (SchedulerEventListener l : this.listeners) {
+ if (l instanceof SchedulerListener) {
+ ((SchedulerListener) l).stopped(this.scheduler);
+ }
+ }
+ }
+ } catch (Throwable e) {
+ LogFactory.getLog(this.getClass()).fatal("スケジューラが中断されました。", e);
+ }
+ }
+ private boolean isExecuting(Map<Schedule, Future> futures, Schedule schedule) {
+ if (futures.containsKey(schedule)) {
+ Future future = futures.get(schedule);
+ return !future.isDone();
+ }
+ return false;
+ }
+ }
+ /**
+ * スケジューラの実際の処理。
+ */
+ private SchedulerRunner runner;
+ /**
+ * <p>
+ * スケジュールの実行に使用する {@link ExecutorService} インスタンスを指定して、 {@link ExecutorServiceScheduler} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param executorService スケジュールの実行に使用するサービス。
+ * @throws NullPointerException executorService 引数が null の場合。
+ */
+ public ExecutorServiceScheduler(ExecutorService executorService) {
+ this.runner = new SchedulerRunner(executorService, this);
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public ScheduleIterable getSchedules() {
+ return this.runner.schedules();
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public SchedulerEventListenerList getListeners() {
+ return this.runner.listeners();
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isRunning() {
+ return this.runner.isRunning();
+ }
+ /**
+ * <p>
+ * スケジューラの動作を開始します。
+ * 以降、トリガーの判断により、タスクが実行されます。
+ * </p>
+ * @throws IllegalStateException スケジューラが既に動作を開始している場合。
+ */
+ public void start() {
+ this.runner.start();
+ }
+ /**
+ * <p>
+ * スケジューラの動作を停止します。
+ * 具体的には、 {@link ExecutorService#shutdownNow()} メソッドを呼び出します。
+ * このメソッドを呼び出した後に {@link #start()} メソッドを呼び出しても、スケジューラは動作を再開しません。
+ * </p>
+ * @throws IllegalStateException スケジューラが既に動作を停止している場合。
+ */
+ public void stop() {
+ this.runner.stop();
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import java.util.Calendar;
+import java.util.Collection;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.SchedulerEventListener;
+import jp.gr.java_conf.uguu.scheduler.SchedulerEventListenerList;
+import jp.gr.java_conf.uguu.scheduler.Task;
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+import jp.gr.java_conf.uguu.scheduler.TaskFutureIterable;
+import jp.gr.java_conf.uguu.scheduler.TaskListener;
+import jp.gr.java_conf.uguu.scheduler.TaskResultEvent;
+import jp.gr.java_conf.uguu.scheduler.TaskStatusEnum;
+import jp.gr.java_conf.uguu.scheduler.Trigger;
+import jp.gr.java_conf.uguu.scheduler.TriggerList;
+import jp.gr.java_conf.uguu.scheduler.WarningException;
+import jp.gr.java_conf.uguu.scheduler.util.CalendarUtil;
+
+/**
+ * <p>
+ * スケジューラが管理するスケジュールです。
+ * スケジュールは、タスクを実行する条件を持つトリガー条件式と、トリガーによって実行されるタスクを持ちます。
+ * </p>
+ * <p>
+ * タスクは、指定しないこともできます。
+ * その場合、トリガーの条件が真になっても何もしません。
+ * また、トリガーは、指定しないこともできます。
+ * その場合、タスクが実行されることはありません。
+ * </p>
+ * @author uguu
+ */
+public class ScheduleImpl implements Schedule {
+ /**
+ * スケジュールの名前。
+ */
+ private String name;
+ /**
+ * タスクの実行を判断するトリガーのリスト。
+ */
+ private TriggerList includeTriggers = new TriggerListImpl();
+ /**
+ * タスクの実行を阻止するトリガーのリスト。
+ */
+ private TriggerList excludeTriggers = new TriggerListImpl();
+ /**
+ * タスク。
+ */
+ private Task task;
+ /**
+ * リスナーのリスト。
+ */
+ private SchedulerEventListenerList listeners;
+ /**
+ * タスク処理状態のコンテナ。
+ */
+ private TaskFutureIterableImpl futures = new TaskFutureIterableImpl();
+ /**
+ * 有効、無効。
+ */
+ private boolean enable = true;
+ /**
+ * カレンダー ユーティリティ。
+ */
+ private CalendarUtil cUtil = new CalendarUtil();
+ /**
+ * <p>
+ * {@link ScheduleImpl} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param name スケジュールの名前。
+ * @param listeners リスナーのリスト。
+ * @throws NullPointerException name 引数が null 又は空文字列の場合。
+ * listeners 引数が null の場合。
+ */
+ public ScheduleImpl(String name, SchedulerEventListenerList listeners) {
+ if (name == null || name.length() == 0) {
+ throw new NullPointerException("name");
+ }
+ if (listeners == null) {
+ throw new NullPointerException("listeners");
+ }
+ this.name = name;
+ this.listeners = listeners;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return this.name;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public TriggerList getIncludeTriggers() {
+ return this.includeTriggers;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public TriggerList getExcludeTriggers() {
+ return this.excludeTriggers;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Task getTask() {
+ return this.task;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void setTask(Task task) {
+ this.task = task;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEnable() {
+ return this.enable;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void setEnable(boolean enable) {
+ this.enable = enable;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public TaskFutureIterable getTaskFutures() {
+ return this.futures;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void execute() {
+ TaskEvent event = new TaskEventImpl(this.cUtil.createNow());
+ if (this.isFire(this.includeTriggers, this.excludeTriggers, event)) {
+ this.executeNow(event);
+ }
+ }
+ private boolean isFire(Collection<Trigger> includeTriggerCollection, Collection<Trigger> excludeTriggerCollection, TaskEvent event) {
+ boolean result = false;
+ for (Trigger t : includeTriggerCollection) {
+ if (t.isFire(this, event)) {
+ result = true;
+ }
+ }
+ for (Trigger t : excludeTriggerCollection) {
+ if (t.isFire(this, event)) {
+ result = false;
+ }
+ }
+ return result;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void executeNow() {
+ TaskEvent event = new TaskEventImpl(this.cUtil.createNow());
+ this.executeNow(event);
+ }
+ private void executeNow(TaskEvent event) {
+ for (SchedulerEventListener l : this.listeners) {
+ if (l instanceof TaskListener) {
+ ((TaskListener) l).beforeTask(this, event);
+ }
+ }
+ Calendar startTime = this.cUtil.createNow();
+ TaskFutureImpl future = new TaskFutureImpl(this.name, startTime);
+ this.futures.add(future);
+ Object result = null;
+ Throwable cause = null;
+ TaskStatusEnum status = null;
+ try {
+ result = this.task.task(this, event);
+ status = TaskStatusEnum.NORMAL;
+ } catch (WarningException e) {
+ result = e.getResult();
+ status = TaskStatusEnum.WARNING;
+ } catch (Throwable e) {
+ cause = e;
+ status = TaskStatusEnum.ERROR;
+ }
+ Calendar endTime = this.cUtil.createNow();
+ future.updateFinished(result, cause, endTime, status);
+ TaskResultEvent resultEvent = new TaskResultEventImpl(startTime, endTime, result, cause, status);
+ for (SchedulerEventListener l : this.listeners) {
+ if (l instanceof TaskListener) {
+ ((TaskListener) l).afterTask(this, resultEvent);
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.ScheduleIterable;
+import jp.gr.java_conf.uguu.scheduler.ScheduleListener;
+import jp.gr.java_conf.uguu.scheduler.Scheduler;
+import jp.gr.java_conf.uguu.scheduler.SchedulerEventListener;
+
+/**
+ * <p>
+ * スケジュールを格納するコンテナです。
+ * </p>
+ * @author uguu
+ */
+public class ScheduleIterableImpl implements ScheduleIterable {
+ /**
+ * <p>スケジュールのリスト。</p>
+ */
+ private List<Schedule> schedules = new ArrayList<Schedule>();
+ /**
+ * <p>リストに対するロック。</p>
+ */
+ private ReadWriteLock lock = new ReentrantReadWriteLock();
+ /**
+ * <p>スケジューラ。</p>
+ */
+ private Scheduler scheduler = null;
+ /**
+ * <p>
+ * {@link ScheduleIterableImpl} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param scheduler スケジューラ。
+ * @throws NullPointerException context 引数が null の場合。
+ */
+ public ScheduleIterableImpl(Scheduler scheduler) {
+ if (scheduler == null) {
+ throw new NullPointerException("scheduler");
+ }
+ this.scheduler = scheduler;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void clear() {
+ this.schedules.clear();
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Schedule create(String name) {
+ if (name == null) {
+ throw new NullPointerException("name");
+ }
+ name = name.trim();
+ if (name.length() == 0) {
+ throw new NullPointerException("name");
+ }
+ Lock l = this.lock.writeLock();
+ l.lock();
+ try {
+ if (this.get(name) != null) {
+ throw new IllegalArgumentException("同じ名前を持つスケジュールが存在します。");
+ }
+ Schedule s = new ScheduleImpl(name, this.scheduler.getListeners());
+ this.schedules.add(s);
+ for (SchedulerEventListener listener : this.scheduler.getListeners()) {
+ if (listener instanceof ScheduleListener) {
+ ((ScheduleListener) listener).added(s);
+ }
+ }
+ return s;
+ } finally {
+ l.unlock();
+ }
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Schedule get(String name) {
+ Lock l = this.lock.readLock();
+ l.lock();
+ try {
+ for (Schedule s : this.schedules) {
+ if (s.getName().equals(name)) {
+ return s;
+ }
+ }
+ return null;
+ } finally {
+ l.unlock();
+ }
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Schedule[] getAll() {
+ Lock l = this.lock.readLock();
+ l.lock();
+ try {
+ return this.schedules.toArray(new Schedule[0]);
+ } finally {
+ l.unlock();
+ }
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean remove(String name) {
+ Lock l = this.lock.writeLock();
+ l.lock();
+ try {
+ Schedule s = this.get(name);
+ boolean result = false;
+ if (s != null) {
+ result = this.schedules.remove(s);
+ for (SchedulerEventListener listener : this.scheduler.getListeners()) {
+ if (listener instanceof ScheduleListener) {
+ ((ScheduleListener) listener).removed(s);
+ }
+ }
+ }
+ return result;
+ } finally {
+ l.unlock();
+ }
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Iterator<Schedule> iterator() {
+ Lock l = this.lock.readLock();
+ l.lock();
+ try {
+ return this.schedules.iterator();
+ } finally {
+ l.unlock();
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import jp.gr.java_conf.uguu.scheduler.SchedulerEventListener;
+import jp.gr.java_conf.uguu.scheduler.SchedulerEventListenerList;
+
+/**
+ * <p>
+ * スケジューラ イベント リスナのリストの実装です。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public class SchedulerEventListenerListImpl extends CopyOnWriteArrayList<SchedulerEventListener> implements SchedulerEventListenerList {
+ // 実装はしません。
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import java.util.Calendar;
+
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+
+/**
+ * <p>
+ * タスクの実行のイベント情報を保持します。
+ * </p>
+ * @author uguu
+ */
+public class TaskEventImpl implements TaskEvent {
+ /**
+ * タスクの実行の開始時刻。
+ */
+ private Calendar startTime;
+ /**
+ * <p>
+ * {@link TaskEventImpl} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param startTime タスクの実行の開始時刻。
+ */
+ public TaskEventImpl(Calendar startTime) {
+ this.startTime = startTime;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Calendar getStartTime() {
+ return this.startTime;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import java.util.Calendar;
+
+import jp.gr.java_conf.uguu.scheduler.TaskFuture;
+import jp.gr.java_conf.uguu.scheduler.TaskStatusEnum;
+
+/**
+ * {@inheritDoc}
+ */
+@SuppressWarnings("serial")
+public class TaskFutureImpl implements TaskFuture {
+ /**
+ * タスクの名前。
+ */
+ private String name;
+ /**
+ * タスクの結果。
+ */
+ private Object result;
+ /**
+ * タスクの失敗原因。
+ */
+ private Throwable cause;
+ /**
+ * タスクの開始時刻。
+ */
+ private Calendar startTime;
+ /**
+ * タスクの終了時刻。
+ */
+ private Calendar endTime;
+ /**
+ * タスクの処理状態。
+ */
+ private TaskStatusEnum status;
+ /**
+ * タスクの実行が完了するまでブロックするためのキー。
+ */
+ private Object lockObject = new Object();
+ /**
+ * <p>
+ * {@link TaskFutureImpl} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param name タスクの名前。
+ * @param startTime タスクの開始時刻。
+ * @throws NullPointerException name, startTime 引数が null の場合。
+ */
+ public TaskFutureImpl(String name, Calendar startTime) {
+ if (name == null) {
+ throw new NullPointerException("name");
+ }
+ if (startTime == null) {
+ throw new NullPointerException("startTime");
+ }
+ this.name = name;
+ this.startTime = startTime;
+ this.status = TaskStatusEnum.EXECUTING;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Calendar getEndTime() {
+ return this.endTime;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return this.name;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Calendar getStartTime() {
+ return this.startTime;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public TaskStatusEnum getStatus() {
+ return this.status;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Object getResult() {
+ synchronized (this.lockObject) {
+ while (this.status == TaskStatusEnum.EXECUTING) {
+ try {
+ this.lockObject.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace(); // FIXME これで本当に良いのか実験する必要があります。
+ }
+ }
+ }
+ return this.result;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Throwable getCause() {
+ synchronized (this.lockObject) {
+ while (this.status == TaskStatusEnum.EXECUTING) {
+ try {
+ this.lockObject.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace(); // FIXME これで本当に良いのか実験する必要があります。
+ }
+ }
+ }
+ return this.cause;
+ }
+ /**
+ * <p>
+ * タスク結果の状態を、タスク完了状態に更新します。
+ * </p>
+ * @param result タスクの結果。
+ * @param cause タスクの失敗原因。
+ * @param endTime タスクの終了時刻。
+ * @param status タスクの処理結果。
+ * @throws NullPointerException endTime, status 引数が null の場合。
+ * @throws IllegalArgumentException status 引数が {@link TaskStatusEnum#EXECUTING} の場合。
+ * status 引数が {@link TaskStatusEnum#NORMAL}, または {@link TaskStatusEnum#WARNING} 値のときに、 cause 引数が null ではない場合。
+ * status 引数が {@link TaskStatusEnum#ERROR} 値のときに、 cause 引数が null 、または result 引数が null ではない場合。
+ */
+ public void updateFinished(Object result, Throwable cause, Calendar endTime, TaskStatusEnum status) {
+ if (endTime == null) {
+ throw new NullPointerException("endTime");
+ }
+ if (status == null) {
+ throw new NullPointerException("status");
+ }
+ if (status == TaskStatusEnum.EXECUTING) {
+ throw new IllegalArgumentException("status == TaskStatusEnum.EXECUTING");
+ }
+ if ((status == TaskStatusEnum.NORMAL || status == TaskStatusEnum.WARNING) && cause != null) {
+ throw new IllegalArgumentException("(status == TaskStatusEnum.NORMAL || status == TaskStatusEnum.WARNING) && cause != null");
+ }
+ if (status == TaskStatusEnum.ERROR && cause == null) {
+ throw new IllegalArgumentException("status == TaskStatusEnum.ERROR && cause == null");
+ }
+ if (status == TaskStatusEnum.ERROR && result != null) {
+ throw new IllegalArgumentException("status == TaskStatusEnum.ERROR && result != null");
+ }
+ synchronized (this.lockObject) {
+ this.result = result;
+ this.cause = cause;
+ this.endTime = endTime;
+ this.status = status;
+ this.lockObject.notifyAll();
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import jp.gr.java_conf.uguu.scheduler.TaskFuture;
+import jp.gr.java_conf.uguu.scheduler.TaskFutureIterable;
+
+/**
+ * <p>
+ * 複数のスケジュールを格納し、繰り返し返します。
+ * </p>
+ * @author uguu
+ */
+public class TaskFutureIterableImpl implements TaskFutureIterable {
+ /**
+ * <p>このコンテナが格納できるスケジュールの最大個数。</p>
+ */
+ public static final int MAX_SIZE = 100;
+ /**
+ * タスク処理状態のリスト。
+ */
+ private LinkedList<TaskFuture> futures = new LinkedList<TaskFuture>();
+ /**
+ * ロック。
+ */
+ private ReadWriteLock lock = new ReentrantReadWriteLock();
+ /**
+ * <p>
+ * タスクの処理状態を追加します。
+ * </p>
+ * @param future タスクの処理状態。
+ * @throws NullPointerException future 引数が null の場合。
+ */
+ public void add(TaskFuture future) {
+ if (future == null) {
+ throw new NullPointerException("future");
+ }
+ Lock l = this.lock.writeLock();
+ l.lock();
+ try {
+ this.futures.addFirst(future);
+ if (this.futures.size() > MAX_SIZE) {
+ this.futures.removeLast();
+ }
+ } finally {
+ l.unlock();
+ }
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public TaskFuture get() {
+ Lock l = this.lock.readLock();
+ l.lock();
+ try {
+ if (this.futures.size() > 0) {
+ return this.futures.getFirst();
+ }
+ return null;
+ } finally {
+ l.unlock();
+ }
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public TaskFuture[] get(int index, int length) {
+ Lock l = this.lock.readLock();
+ l.lock();
+ try {
+ return this.futures.subList(index, index + length).toArray(new TaskFuture[0]);
+ } finally {
+ l.unlock();
+ }
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public TaskFuture get(int index) {
+ Lock l = this.lock.readLock();
+ l.lock();
+ try {
+ return this.futures.get(index);
+ } finally {
+ l.unlock();
+ }
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public TaskFuture[] getAll() {
+ Lock l = this.lock.readLock();
+ l.lock();
+ try {
+ return this.futures.toArray(new TaskFuture[0]);
+ } finally {
+ l.unlock();
+ }
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public int size() {
+ Lock l = this.lock.readLock();
+ l.lock();
+ try {
+ return this.futures.size();
+ } finally {
+ l.unlock();
+ }
+ }
+ /**
+ * <p>
+ * 格納しているタスクの処理状態を繰り返し返す {@link Iterator} インスタンスを返します。
+ * この {@link Iterator} インスタンスは、このメソッドを呼び出した時点のスナップショットに対して繰り返し処理します。
+ * つまり、 {@link TaskFutureIterableImpl} インスタンスに新しいタスク処理状態が追加されても、 {@link Iterator} インスタンスはそれを検知しませんし、状態が変わったからといって {@link java.util.ConcurrentModificationException} 例外がスローされることもありません。
+ * </p>
+ * @return 格納しているタスクの処理状態を繰り返し返す {@link Iterator} インスタンス。
+ */
+ public Iterator<TaskFuture> iterator() {
+ Lock l = this.lock.readLock();
+ l.lock();
+ try {
+ return Arrays.asList(this.futures.toArray(new TaskFuture[0])).iterator();
+ } finally {
+ l.unlock();
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import java.util.Calendar;
+
+import jp.gr.java_conf.uguu.scheduler.TaskResultEvent;
+import jp.gr.java_conf.uguu.scheduler.TaskStatusEnum;
+
+/**
+ * <p>
+ * タスクの実行の結果のイベント情報を保持します。
+ * </p>
+ * @author uguu
+ */
+public class TaskResultEventImpl implements TaskResultEvent {
+ /**
+ * タスクの実行の開始時刻。
+ */
+ private Calendar startTime;
+ /**
+ * タスクの実行の終了時刻。
+ */
+ private Calendar endTime;
+ /**
+ * タスクの実行結果。
+ */
+ private Object result;
+ /**
+ * タスクのエラー原因。
+ */
+ private Throwable cause;
+ /**
+ * タスクの処理結果。
+ */
+ private TaskStatusEnum status;
+ /**
+ * <p>
+ * {@link TaskResultEventImpl} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param startTime タスクの実行の開始時刻。
+ * @param endTime タスクの実行の終了時刻。
+ * @param result タスクの実行結果。
+ * @param cause タスクのエラー原因。
+ * @param status タスクの処理結果。
+ * @throws NullPointerException startTime, endTime, status 引数が null の場合。
+ * @throws IllegalArgumentException status 引数が {@link TaskStatusEnum#EXECUTING} 値の場合。
+ * status 引数が {@link TaskStatusEnum#NORMAL}, または {@link TaskStatusEnum#WARNING} 値のときに、 cause 引数が null ではない場合。
+ * status 引数が {@link TaskStatusEnum#ERROR} 値のときに、 cause 引数が null, または result 引数が null ではない場合。
+ */
+ public TaskResultEventImpl(Calendar startTime, Calendar endTime, Object result, Throwable cause, TaskStatusEnum status) {
+ if (startTime == null) {
+ throw new NullPointerException("startTime");
+ }
+ if (endTime == null) {
+ throw new NullPointerException("endTime");
+ }
+ if (status == null) {
+ throw new NullPointerException("status");
+ }
+ if (status == TaskStatusEnum.EXECUTING) {
+ throw new IllegalArgumentException("status == TaskStatusEnum.EXECUTING");
+ }
+ if ((status == TaskStatusEnum.NORMAL || status == TaskStatusEnum.WARNING) && cause != null) {
+ throw new IllegalArgumentException("(status == TaskStatusEnum.NORMAL || status == TaskStatusEnum.WARNING) && cause != null");
+ }
+ if (status == TaskStatusEnum.ERROR && cause == null) {
+ throw new IllegalArgumentException("status == TaskStatusEnum.ERROR && cause == null");
+ }
+ if (status == TaskStatusEnum.ERROR && result != null) {
+ throw new IllegalArgumentException("status == TaskStatusEnum.ERROR && result != null");
+ }
+ this.startTime = startTime;
+ this.endTime = endTime;
+ this.result = result;
+ this.cause = cause;
+ this.status = status;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Calendar getStartTime() {
+ return this.startTime;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Calendar getEndTime() {
+ return this.endTime;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Object getResult() {
+ return this.result;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Throwable getCause() {
+ return this.cause;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public TaskStatusEnum getStatus() {
+ return this.status;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import java.util.Calendar;
+import java.util.List;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+import jp.gr.java_conf.uguu.scheduler.Trigger;
+import jp.gr.java_conf.uguu.scheduler.util.CalendarUtil;
+
+/**
+ * <p>
+ * 指定した時刻になるとタスクを起動するトリガーです。
+ * </p>
+ * <p>
+ * 年、月、日、曜日、時、分、秒のプロパティがあり、それぞれに数値、もしくは null を設定できます。
+ * 数値を設定すると、スケジュールの時刻と比較し、そのフィールドは真とします。
+ * null を設定すると、スケジュールの時刻とは比較せず、常にそのフィールドは真とします。
+ * そして、全てのフィールドが真になると、タスクを起動します。
+ * 例えば、年 = null, 月 = null, 日 = null, 曜日 = null, 時 = 18, 分 = 0, 秒 = 0 と設定すると、年月日曜日は null のために比較されず常に真、時分秒はスケジュール時刻と比較され 18:00 になると真になります。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public class TimeTrigger implements Trigger {
+ /**
+ * 年。
+ */
+ private Integer year;
+ /**
+ * 月。
+ */
+ private Integer month;
+ /**
+ * 日。
+ */
+ private Integer day;
+ /**
+ * 曜日。
+ */
+ private DayOfWeekEnum dayOfWeek;
+ /**
+ * 時。
+ */
+ private Integer hour;
+ /**
+ * 分。
+ */
+ private Integer minute;
+ /**
+ * 秒。
+ */
+ private Integer second;
+ /**
+ * 前回、判断を行った時刻。
+ */
+ private Calendar lastTime;
+ /**
+ * 判断を同期的に行うためのキー。
+ */
+ private Object lock = new Object();
+ /**
+ * 日を返します。
+ * @return 日。
+ */
+ public Integer getDay() {
+ return this.day;
+ }
+ /**
+ * 日を設定します。
+ * @param day 日。
+ */
+ public void setDay(Integer day) {
+ this.day = day;
+ }
+ /**
+ * 曜日を返します。
+ * @return 曜日。
+ */
+ public DayOfWeekEnum getDayOfWeek() {
+ return this.dayOfWeek;
+ }
+ /**
+ * 曜日を設定します。
+ * @param dayOfWeek 曜日。
+ */
+ public void setDayOfWeek(DayOfWeekEnum dayOfWeek) {
+ this.dayOfWeek = dayOfWeek;
+ }
+ /**
+ * 時を返します。
+ * @return 時。
+ */
+ public Integer getHour() {
+ return this.hour;
+ }
+ /**
+ * 時を設定します。
+ * @param hour 時。
+ */
+ public void setHour(Integer hour) {
+ this.hour = hour;
+ }
+ /**
+ * 分を返します。
+ * @return 分。
+ */
+ public Integer getMinute() {
+ return this.minute;
+ }
+ /**
+ * 分を設定します。
+ * @param minute 分。
+ */
+ public void setMinute(Integer minute) {
+ this.minute = minute;
+ }
+ /**
+ * 月を返します。
+ * @return 月。
+ */
+ public Integer getMonth() {
+ return this.month;
+ }
+ /**
+ * 月を設定します。
+ * @param month 月。
+ */
+ public void setMonth(Integer month) {
+ this.month = month;
+ }
+ /**
+ * 秒を返します。
+ * @return 秒。
+ */
+ public Integer getSecond() {
+ return this.second;
+ }
+ /**
+ * 秒を設定します。
+ * @param second 秒。
+ */
+ public void setSecond(Integer second) {
+ this.second = second;
+ }
+ /**
+ * 年を返します。
+ * @return 年。
+ */
+ public Integer getYear() {
+ return this.year;
+ }
+ /**
+ * 年を設定します。
+ * @param year 年。
+ */
+ public void setYear(Integer year) {
+ this.year = year;
+ }
+ /**
+ * <p>
+ * {@link TimeTrigger} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param year 年。
+ * @param month 月。
+ * @param day 日。
+ * @param dayOfWeek 曜日。
+ * @param hour 時。
+ * @param minute 分。
+ * @param second 秒。
+ */
+ public TimeTrigger(Integer year, Integer month, Integer day, DayOfWeekEnum dayOfWeek, Integer hour, Integer minute, Integer second) {
+ this.year = year;
+ this.month = month;
+ this.day = day;
+ this.dayOfWeek = dayOfWeek;
+ this.hour = hour;
+ this.minute = minute;
+ this.second = second;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isFire(Schedule schedule, TaskEvent event) {
+ List<Calendar> cList = null;
+ synchronized (this.lock) {
+ Calendar startTime = this.lastTime;
+ Calendar endTime = event.getStartTime();
+ this.lastTime = endTime;
+ CalendarUtil cUtil = new CalendarUtil();
+ cList = cUtil.getCalendarList(startTime, endTime);
+ }
+ for (Calendar c : cList) {
+ boolean result = true;
+ if (this.year != null) {
+ if (c.get(Calendar.YEAR) != this.year) {
+ result = false;
+ }
+ }
+ if (this.month != null) {
+ if ((c.get(Calendar.MONTH) + 1) != this.month) {
+ result = false;
+ }
+ }
+ if (this.dayOfWeek != null) {
+ switch (this.dayOfWeek) {
+ case SUNDAY:
+ if (c.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
+ result = false;
+ }
+ break;
+ case MONDAY:
+ if (c.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
+ result = false;
+ }
+ break;
+ case TUESDAY:
+ if (c.get(Calendar.DAY_OF_WEEK) != Calendar.TUESDAY) {
+ result = false;
+ }
+ break;
+ case WEDNESDAY:
+ if (c.get(Calendar.DAY_OF_WEEK) != Calendar.WEDNESDAY) {
+ result = false;
+ }
+ break;
+ case THURSDAY:
+ if (c.get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY) {
+ result = false;
+ }
+ break;
+ case FRIDAY:
+ if (c.get(Calendar.DAY_OF_WEEK) != Calendar.FRIDAY) {
+ result = false;
+ }
+ break;
+ case SATURDAY:
+ if (c.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
+ result = false;
+ }
+ break;
+ default:
+ }
+ }
+ if (this.day != null) {
+ if (c.get(Calendar.DAY_OF_MONTH) != this.day) {
+ result = false;
+ }
+ }
+ if (this.hour != null) {
+ if (c.get(Calendar.HOUR_OF_DAY) != this.hour) {
+ result = false;
+ }
+ }
+ if (this.minute != null) {
+ if (c.get(Calendar.MINUTE) != this.minute) {
+ result = false;
+ }
+ }
+ if (this.second != null) {
+ if (c.get(Calendar.SECOND) != this.second) {
+ result = false;
+ }
+ }
+ if (result) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.ScheduleListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p>
+ * タスクの開始、終了、失敗のタイミングで、 commons-logging でログを出力するリスナーです。
+ * 全てのタスクにこのリスナーを自動的に設定するために、 {@link TraceSchedulerListener} クラスも併せて参照してください。
+ * </p>
+ * @author uguu
+ * @see TraceSchedulerListener
+ */
+public class TraceScheduleListener implements ScheduleListener {
+ /**
+ * ロガー。
+ */
+ private Log log = LogFactory.getLog(this.getClass());
+ /**
+ * <p>
+ * スケジュールが追加されたというメッセージを出力します。
+ * </p>
+ * @param schedule スケジュール。
+ */
+ public void added(Schedule schedule) {
+ String l = schedule.getName() + " added.";
+ this.log.debug(l);
+ }
+ /**
+ * <p>
+ * スケジュールが削除されたというメッセージを出力します。
+ * </p>
+ * @param schedule スケジュール。
+ */
+ public void removed(Schedule schedule) {
+ String l = schedule.getName() + " removed.";
+ this.log.debug(l);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import jp.gr.java_conf.uguu.scheduler.Scheduler;
+import jp.gr.java_conf.uguu.scheduler.SchedulerListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p>
+ * スケジューラの状態の変更のタイミングで、 commons-logging でログを出力するリスナーです。
+ * </p>
+ * @author uguu
+ */
+public class TraceSchedulerListener implements SchedulerListener {
+ /**
+ * ロガー。
+ */
+ private Log log = LogFactory.getLog(this.getClass());
+ /**
+ * <p>
+ * スケジューラが起動したメッセージを出力します。
+ * </p>
+ * @param scheduler スケジューラ。
+ */
+ public void started(Scheduler scheduler) {
+ String l = "scheduler started,";
+ this.log.debug(l);
+ }
+ /**
+ * <p>
+ * スケジューラが停止したメッセージを出力します。
+ * </p>
+ * @param scheduler スケジューラ。
+ */
+ public void stopped(Scheduler scheduler) {
+ String l = "scheduler stopped,";
+ this.log.debug(l);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+import jp.gr.java_conf.uguu.scheduler.TaskListener;
+import jp.gr.java_conf.uguu.scheduler.TaskResultEvent;
+
+/**
+ * <p>
+ * タスクの開始、終了のタイミングで、 commons-logging でログを出力するリスナーです。
+ * </p>
+ * @author uguu
+ */
+public class TraceTaskListener implements TaskListener {
+ /**
+ * ロガー。
+ */
+ private Log log = LogFactory.getLog(this.getClass());
+ /**
+ * <p>
+ * タスクが終了したというメッセージを出力します。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスクの実行結果のイベント情報。
+ */
+ public void afterTask(Schedule schedule, TaskResultEvent event) {
+ String l = schedule.getName() + " task " + event.getStatus().toString() + " end.";
+ this.log.debug(l);
+ }
+ /**
+ * <p>
+ * タスクが開始したというメッセージを出力します。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスクの実行のイベント情報。
+ */
+ public void beforeTask(Schedule schedule, TaskEvent event) {
+ String l = schedule.getName() + " task start.";
+ this.log.debug(l);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.impl;
+
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import jp.gr.java_conf.uguu.scheduler.Trigger;
+import jp.gr.java_conf.uguu.scheduler.TriggerList;
+
+/**
+ * <p>
+ * トリガーのリストの実装です。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public class TriggerListImpl extends CopyOnWriteArrayList<Trigger> implements TriggerList {
+ // 特に実装はしません。
+}
--- /dev/null
+<body>
+ <p>java.util.Timer により動作するスケジューラです。</p>
+</body>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.util;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * <p>
+ * カレンダーに関するユーティリティ機能を持ちます。
+ * </p>
+ * @author uguu
+ */
+public class CalendarUtil {
+ /**
+ * <p>
+ * 開始時刻、終了時刻の範囲内に含まれる全ての時刻のリストを返します。
+ * </p>
+ * <ul>
+ * <li>開始時刻しか指定されなかった場合、リストには開始時刻のみ含まれます。
+ * <li>終了時刻しか指定されなかった場合、リストには終了時刻のみ含まれます。
+ * <li>開始時刻が終了時刻の後の場合、リストには終了時刻のみ含まれます。
+ * <li>開始時刻と終了時刻が同じ場合、リストには何も含まれません。
+ * <li>開始時刻が終了時刻の前の場合、開始時刻を除く 1 秒刻みの全ての時刻が含まれます。
+ * </ul>
+ * @param startTime 開始時刻。
+ * @param endTime 終了時刻。
+ * @return 時刻のリスト。
+ * @throws NullPointerException startTime と endTime がともに null の場合。
+ */
+ public List<Calendar> getCalendarList(Calendar startTime, Calendar endTime) {
+ if (startTime == null && endTime == null) {
+ throw new NullPointerException("startTime, endTime");
+ }
+ List<Calendar> calendarList = new ArrayList<Calendar>();
+ if (startTime == null) {
+ // 開始時刻しか指定されなかった場合。
+ calendarList.add(endTime);
+ } else if (endTime == null) {
+ // 終了時刻しか指定されなかった場合。
+ calendarList.add(startTime);
+ } else if (startTime.after(endTime)) {
+ // 開始時刻 > 終了時刻の後の場合。
+ calendarList.add(endTime);
+ } else {
+ // 開始時刻 < 終了時刻の場合。
+ Calendar c = (Calendar) startTime.clone();
+ while (!c.equals(endTime)) {
+ c = (Calendar) c.clone();
+ c.add(Calendar.SECOND, 1);
+ calendarList.add(c);
+ }
+ }
+ return calendarList;
+ }
+ /**
+ * <p>
+ * 指定した時刻の {@link Calendar} インスタンスを返します。
+ * </p>
+ * @param year 年。
+ * @param month 月。
+ * @param day 日。
+ * @param hour 時。
+ * @param minute 分。
+ * @param second 秒。
+ * @return {@link Calendar} インスタンス。
+ */
+ public Calendar create(int year, int month, int day, int hour, int minute, int second) {
+ Calendar c = Calendar.getInstance();
+ c.set(Calendar.YEAR, year);
+ c.set(Calendar.MONTH, month - 1);
+ c.set(Calendar.DAY_OF_MONTH, day);
+ c.set(Calendar.HOUR_OF_DAY, hour);
+ c.set(Calendar.MINUTE, minute);
+ c.set(Calendar.SECOND, second);
+ c.set(Calendar.MILLISECOND, 0);
+ return c;
+ }
+ /**
+ * <p>
+ * 現在時刻を表す {@link Calendar} インスタンスを返します。
+ * </p>
+ * @return 現在時刻を表す {@link Calendar} インスタンス。
+ */
+ public Calendar createNow() {
+ Calendar c = Calendar.getInstance();
+ c.set(Calendar.MILLISECOND, 0);
+ return c;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler.util;
+
+import java.util.ResourceBundle;
+
+/**
+ * <p>
+ * リソースを読み込み、値を返します。
+ * </p>
+ * @author uguu
+ */
+public class ResourceUtil {
+ /**
+ * リソース。
+ */
+ private ResourceBundle rb;
+ /**
+ * <p>
+ * {@link ResourceUtil} クラスの新しいインスタンスを初期化します。
+ * </p>
+ */
+ public ResourceUtil() {
+ this("uguu-scheduler");
+ }
+ /**
+ * <p>
+ * {@link ResourceUtil} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * @param resourceName 読み込むリソースのベース名。
+ */
+ public ResourceUtil(String resourceName) {
+ this.rb = ResourceBundle.getBundle(resourceName);
+ }
+ /**
+ * <p>
+ * リソースのキーの値を文字列で返します。
+ * </p>
+ * @param key 取得する文字列のキー。
+ * @return キーの値を表す文字列。
+ * キーに値が設定されていない場合は null 。
+ * @throws java.util.MissingResourceException 指定したキーがリソースに存在しない場合。
+ */
+ public String getString(String key) {
+ String value = this.rb.getString(key);
+ if ("".equals(value)) {
+ return null;
+ }
+ return value;
+ }
+ /**
+ * <p>
+ * リソースのキーの値を整数値で返します。
+ * </p>
+ * @param key 取得する値のキー。
+ * @return キーの値を表す整数値。
+ * キーに値が設定されていない場合は null 。
+ * @throws java.util.MissingResourceException 指定したキーがリソースに存在しない場合。
+ */
+ public Integer getInteger(String key) {
+ String value = this.getString(key);
+ if (value == null || "".equals(value)) {
+ return null;
+ }
+ return Integer.parseInt(value);
+ }
+}
--- /dev/null
+<body>
+ <p>ユーティリティです。</p>
+</body>
\ No newline at end of file
--- /dev/null
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
--- /dev/null
+org.apache.commons.logging.simplelog.defaultlog=debug
+org.apache.commons.logging.simplelog.showdatetime=true
+org.apache.commons.logging.simplelog.dateTimeFormat=yyyy-MM-dd HH:mm:ss.SSS
--- /dev/null
+package jp.gr.java_conf.uguu.scheduler.test.impl;
+
+import java.util.Random;
+import java.util.concurrent.Executors;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.Scheduler;
+import jp.gr.java_conf.uguu.scheduler.Task;
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+import jp.gr.java_conf.uguu.scheduler.TaskFuture;
+import jp.gr.java_conf.uguu.scheduler.WarningException;
+import jp.gr.java_conf.uguu.scheduler.impl.ExecutorServiceScheduler;
+import jp.gr.java_conf.uguu.scheduler.impl.TimeTrigger;
+import jp.gr.java_conf.uguu.scheduler.impl.TraceScheduleListener;
+import jp.gr.java_conf.uguu.scheduler.impl.TraceSchedulerListener;
+import jp.gr.java_conf.uguu.scheduler.impl.TraceTaskListener;
+import junit.framework.TestCase;
+
+public class ExecutorServiceSchedulerTest extends TestCase {
+ public ExecutorServiceSchedulerTest(String name) {
+ super(name);
+ }
+ public void test_シンプルな使い方() throws Exception {
+ @SuppressWarnings("serial")
+ class TestTask implements Task {
+ public Object task(Schedule schedule, TaskEvent event) throws Exception {
+ return null;
+ }
+ }
+
+ Scheduler scheduler = new ExecutorServiceScheduler(Executors.newCachedThreadPool());
+ scheduler.getListeners().add(new TraceSchedulerListener());
+ scheduler.getListeners().add(new TraceScheduleListener());
+ scheduler.getListeners().add(new TraceTaskListener());
+
+ Schedule schedule = scheduler.getSchedules().create("foo");
+ schedule.setTask(new TestTask());
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, null));
+
+ scheduler.start();
+ Thread.sleep(10000);
+ scheduler.stop();
+
+ for (TaskFuture future : schedule.getTaskFutures()) {
+ System.out.println("name: " + future.getName() + "\n"
+ + "startTime: " + future.getStartTime().getTime() + "\n"
+ + "endTime: " + future.getEndTime().getTime() + "\n");
+ }
+ }
+ public void test_警告とかエラーとか() throws Exception {
+ @SuppressWarnings("serial")
+ class TestTask implements Task {
+ private Random r = new Random();
+ public Object task(Schedule schedule, TaskEvent event) throws Exception {
+ double d = this.r.nextDouble();
+ if (d <= 0.3) {
+ return "normal";
+ } else if (d <= 0.6) {
+ throw new WarningException("warning");
+ } else {
+ throw new Error();
+ }
+ }
+ }
+
+ Scheduler scheduler = new ExecutorServiceScheduler(Executors.newCachedThreadPool());
+ scheduler.getListeners().add(new TraceSchedulerListener());
+ scheduler.getListeners().add(new TraceScheduleListener());
+ scheduler.getListeners().add(new TraceTaskListener());
+
+ Schedule schedule = scheduler.getSchedules().create("foo");
+ schedule.setTask(new TestTask());
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, null));
+
+ scheduler.start();
+ Thread.sleep(10000);
+ scheduler.stop();
+
+ for (TaskFuture future : schedule.getTaskFutures()) {
+ System.out.println("name: " + future.getName() + "\n"
+ + "startTime: " + future.getStartTime().getTime() + "\n"
+ + "endTime: " + future.getEndTime().getTime() + "\n"
+ + "status: " + future.getStatus().toString() + "\n"
+ + "result: " + future.getResult() + "\n"
+ + "cause: " + future.getCause() + "\n");
+ }
+ }
+ public void test_時間のかかるタスク() throws Exception {
+ @SuppressWarnings("serial")
+ class TestTask implements Task {
+ private int sleepTime;
+ public TestTask(int sleepTime) {
+ this.sleepTime = sleepTime;
+ }
+ public Object task(Schedule schedule, TaskEvent event) throws Exception {
+ Thread.sleep(this.sleepTime);
+ return null;
+ }
+ }
+
+ Scheduler scheduler = new ExecutorServiceScheduler(Executors.newCachedThreadPool());
+ scheduler.getListeners().add(new TraceSchedulerListener());
+ scheduler.getListeners().add(new TraceScheduleListener());
+ scheduler.getListeners().add(new TraceTaskListener());
+
+ Schedule schedule = scheduler.getSchedules().create("foo");
+ schedule.setTask(new TestTask(1000));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 00));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 10));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 20));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 30));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 40));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 50));
+
+ schedule = scheduler.getSchedules().create("bar");
+ schedule.setTask(new TestTask(3000));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 00));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 10));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 20));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 30));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 40));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 50));
+
+ schedule = scheduler.getSchedules().create("boo");
+ schedule.setTask(new TestTask(5000));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 00));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 10));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 20));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 30));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 40));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, 50));
+
+ scheduler.start();
+ Thread.sleep(60000);
+ scheduler.stop();
+ }
+ public void test_前回のスケジュールが実行していないときに次のスケジュールが実行されたら() throws Exception {
+ @SuppressWarnings("serial")
+ class TestTask implements Task {
+ private int sleepTime;
+ public TestTask(int sleepTime) {
+ this.sleepTime = sleepTime;
+ }
+ public Object task(Schedule schedule, TaskEvent event) throws Exception {
+ Thread.sleep(this.sleepTime);
+ return null;
+ }
+ }
+
+ Scheduler scheduler = new ExecutorServiceScheduler(Executors.newCachedThreadPool());
+ scheduler.getListeners().add(new TraceSchedulerListener());
+ scheduler.getListeners().add(new TraceScheduleListener());
+ scheduler.getListeners().add(new TraceTaskListener());
+
+ Schedule schedule = scheduler.getSchedules().create("foo");
+ schedule.setTask(new TestTask(1000));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, null));
+
+ schedule = scheduler.getSchedules().create("bar");
+ schedule.setTask(new TestTask(3000));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, null));
+
+ schedule = scheduler.getSchedules().create("boo");
+ schedule.setTask(new TestTask(5000));
+ schedule.getIncludeTriggers().add(new TimeTrigger(null, null, null, null, null, null, null));
+
+ scheduler.start();
+ Thread.sleep(20000);
+ scheduler.stop();
+ }
+}
--- /dev/null
+package jp.gr.java_conf.uguu.scheduler.test.util;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import jp.gr.java_conf.uguu.scheduler.util.CalendarUtil;
+import junit.framework.TestCase;
+
+public class CalendarUtilTest extends TestCase {
+ public CalendarUtilTest(String name) {
+ super(name);
+ }
+ public void test_getCalendarList_開始時刻だけ指定した場合のリストを確認() {
+ CalendarUtil u = new CalendarUtil();
+ Calendar startTime = u.create(2005, 11, 27, 10, 45, 17);
+ List<Calendar> calendarList = u.getCalendarList(startTime, null);
+ // 結果を確認します。
+ assertEquals(1, calendarList.size());
+ assertEquals(u.create(2005, 11, 27, 10, 45, 17), calendarList.get(0));
+ }
+ public void test_getCalendarList_終了時刻だけ指定した場合のリストを確認() {
+ CalendarUtil u = new CalendarUtil();
+ Calendar endTime = u.create(2005, 11, 27, 10, 45, 17);
+ List<Calendar> calendarList = u.getCalendarList(null, endTime);
+ // 結果を確認します。
+ assertEquals(1, calendarList.size());
+ assertEquals(u.create(2005, 11, 27, 10, 45, 17), calendarList.get(0));
+ }
+ public void test_getCalendarList_開始時刻と終了時刻が同じ場合のリストを確認() {
+ CalendarUtil u = new CalendarUtil();
+ Calendar startTime = u.create(2005, 11, 27, 10, 45, 17);
+ Calendar endTime = u.create(2005, 11, 27, 10, 45, 17);
+ List<Calendar> calendarList = u.getCalendarList(startTime, endTime);
+ // 結果を確認します。
+ assertEquals(0, calendarList.size());
+ }
+ public void test_getCalendarList_開始時刻が終了時刻の後の場合のリストを確認() {
+ CalendarUtil u = new CalendarUtil();
+ Calendar startTime = u.create(2005, 11, 27, 10, 45, 55);
+ Calendar endTime = u.create(2005, 11, 27, 10, 45, 17);
+ List<Calendar> calendarList = u.getCalendarList(startTime, endTime);
+ // 結果を確認します。
+ assertEquals(1, calendarList.size());
+ assertEquals(u.create(2005, 11, 27, 10, 45, 17), calendarList.get(0));
+ }
+ public void test_getCalendarList_開始時刻が終了時刻の前の場合のリストを確認() {
+ CalendarUtil u = new CalendarUtil();
+ Calendar startTime = u.create(2005, 11, 27, 10, 45, 55);
+ Calendar endTime = u.create(2005, 11, 27, 10, 46, 17);
+ List<Calendar> calendarList = u.getCalendarList(startTime, endTime);
+ // 結果を確認します。
+ assertEquals(22, calendarList.size());
+ assertEquals(u.create(2005, 11, 27, 10, 45, 56), calendarList.get(0));
+ assertEquals(u.create(2005, 11, 27, 10, 45, 57), calendarList.get(1));
+ assertEquals(u.create(2005, 11, 27, 10, 45, 58), calendarList.get(2));
+ assertEquals(u.create(2005, 11, 27, 10, 45, 59), calendarList.get(3));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 0), calendarList.get(4));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 1), calendarList.get(5));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 2), calendarList.get(6));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 3), calendarList.get(7));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 4), calendarList.get(8));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 5), calendarList.get(9));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 6), calendarList.get(10));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 7), calendarList.get(11));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 8), calendarList.get(12));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 9), calendarList.get(13));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 10), calendarList.get(14));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 11), calendarList.get(15));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 12), calendarList.get(16));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 13), calendarList.get(17));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 14), calendarList.get(18));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 15), calendarList.get(19));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 16), calendarList.get(20));
+ assertEquals(u.create(2005, 11, 27, 10, 46, 17), calendarList.get(21));
+ }
+ public void test_getCalendarList_開始時刻と終了時刻がnullの場合にNullPointerException() {
+ CalendarUtil u = new CalendarUtil();
+ try {
+ u.getCalendarList(null, null);
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("startTime, endTime", e.getMessage());
+ }
+ }
+ public void test_createCalendar() {
+ CalendarUtil u = new CalendarUtil();
+ Calendar c = u.create(2005, 11, 27, 23, 45, 55);
+ assertEquals(2005, c.get(Calendar.YEAR));
+ assertEquals(10, c.get(Calendar.MONTH));
+ assertEquals(27, c.get(Calendar.DAY_OF_MONTH));
+ assertEquals(23, c.get(Calendar.HOUR_OF_DAY));
+ assertEquals(45, c.get(Calendar.MINUTE));
+ assertEquals(55, c.get(Calendar.SECOND));
+ assertEquals(0, c.get(Calendar.MILLISECOND));
+ }
+ public void test_createNow() {
+ CalendarUtil u = new CalendarUtil();
+ Calendar c = u.createNow();
+ Calendar expected = new GregorianCalendar();
+ expected.set(Calendar.MILLISECOND, 0);
+ assertEquals(expected, c);
+ }
+}
--- /dev/null
+package jp.gr.java_conf.uguu.scheduler.test.util;
+
+import java.util.MissingResourceException;
+
+import jp.gr.java_conf.uguu.scheduler.util.ResourceUtil;
+import junit.framework.TestCase;
+
+public class ResourceUtilTest extends TestCase {
+ private ResourceUtil resUtil;
+ public ResourceUtilTest(String name) {
+ super(name);
+ }
+ @Override
+ public void setUp() {
+ this.resUtil = new ResourceUtil("jp.gr.java_conf.uguu.scheduler.test.util.ResourceUtilTestData.foo");
+ }
+ public void test_ResourceUtil() {
+ try {
+ new ResourceUtil("hoge");
+ fail();
+ } catch (MissingResourceException e) {
+ // 例外の検証はしません。
+ }
+ }
+ public void test_getString_1() {
+ assertEquals("foobarboo", this.resUtil.getString("foo"));
+ }
+ public void test_getString_2() {
+ assertEquals("999", this.resUtil.getString("bar"));
+ }
+ public void test_getString_3() {
+ assertNull(this.resUtil.getString("boo"));
+ }
+ public void test_getString_4() {
+ try {
+ this.resUtil.getString("hoge");
+ fail();
+ } catch (MissingResourceException e) {
+ // 例外の検証はしません。
+ }
+ }
+ public void test_getInteger_1() {
+ try {
+ this.resUtil.getInteger("foo");
+ fail();
+ } catch (NumberFormatException e) {
+ // 例外の検証はしません。
+ }
+ }
+ public void test_getInteger_2() {
+ assertEquals((Integer) 999, this.resUtil.getInteger("bar"));
+ }
+ public void test_getInteger_3() {
+ assertNull(this.resUtil.getInteger("boo"));
+ }
+ public void test_getInteger_4() {
+ try {
+ this.resUtil.getString("hoge");
+ fail();
+ } catch (MissingResourceException e) {
+ // 例外の検証はしません。
+ }
+ }
+}
--- /dev/null
+foo=foobarboo
+bar=999
+boo=
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><fileset-config file-format-version="1.1.0" simple-config="false">
+<fileset name="src" enabled="true" check-config-name="Uguu Checks" type="remote" location="http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml" description="Uguu Software のコーディング スタイルです。"><file-match-pattern match-pattern="src\\java" include-pattern="true"/>
+</fileset>
+</fileset-config>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-0.1.9.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/hsqldb/jars/hsqldb-1.8.0.1.jar"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/conf"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>uguu-scheduler-persistence</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.mevenide.ui.mavenbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.mevenide.ui.mavennature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
--- /dev/null
+#HSQL Database Engine
+#Sun Feb 05 14:12:39 JST 2006
+hsqldb.script_format=0
+runtime.gc_interval=0
+sql.enforce_strict_size=false
+hsqldb.cache_size_scale=8
+readonly=false
+hsqldb.nio_data_file=true
+hsqldb.cache_scale=14
+version=1.8.0
+hsqldb.default_table_type=memory
+hsqldb.cache_file_scale=1
+hsqldb.log_size=200
+modified=no
+hsqldb.cache_version=1.7.0
+hsqldb.original_version=1.8.0
+hsqldb.compatible_version=1.8.0
--- /dev/null
+CREATE SCHEMA PUBLIC AUTHORIZATION DBA
+CREATE MEMORY TABLE SCHEDULE_PERSISTENCE(SCHEDULE_ID VARCHAR(36) NOT NULL PRIMARY KEY,SCHEDULE_DATA BINARY NOT NULL)
+CREATE USER SA PASSWORD ""
+GRANT DBA TO SA
+SET WRITE_DELAY 20
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <pomVersion>3</pomVersion>
+ <organization>
+ <name>Uguu Software</name>
+ <url>http://wiki.livedoor.jp/uguuxp/</url>
+ <logo>http://image02.wiki.livedoor.jp/u/p/uguuxp/82487bf1fed6e9af.png</logo>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports>
+<!--
+ <report>maven-changelog-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-checkstyle-plugin</report>
+-->
+ <report>maven-linkcheck-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-faq-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
--- /dev/null
+maven.compile.debug=true
+maven.compile.encoding=utf-8
+maven.compile.source=1.5
+
+maven.docs.outputencoding=utf-8
+
+maven.checkstyle.check.tests=false
+maven.checkstyle.header.file=${basedir}/LICENSE.txt
+maven.checkstyle.propertiesURL=http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml
+
+maven.test.failure.ignore=true
+
+maven.xdoc.date=right
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.distributionUrl=http://uguu-sysman.sourceforge.jp/maven/uguu-http-test/jars
+maven.xdoc.distributionType=jar
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <extend>${basedir}/project-base.xml</extend>
+ <artifactId>uguu-scheduler-persistence</artifactId>
+ <name>uguu-scheduler-persistence</name>
+ <groupId>uguu-scheduler-persistence</groupId>
+ <currentVersion>0.0.0</currentVersion>
+ <inceptionYear>2006</inceptionYear>
+ <package>jp.gr.java_conf.uguu.scheduler_persistence</package>
+ <description>
+ スケジューラのリスナ、タスクを永続化します。
+ スケジューラを終了しても、スケジューラに設定した内容を復元することができます。
+ </description>
+ <repository>
+ <connection>scm:cvs:pserver:anonymous@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-scheduler-persistence</connection>
+ <developerConnection>scm:cvs:ext:uguu@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-scheduler-persistence</developerConnection>
+ <url>http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/uguu-sysman/uguu-scheduler-persistence/</url>
+ </repository>
+ <developers>
+ <developer>
+ <name>uguu</name>
+ <id>2</id>
+ <email>uguu@users.sourceforge.jp</email>
+ <organization>Uguu Software</organization>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>BSD License</name>
+ </license>
+ </licenses>
+ <dependencies>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler</artifactId>
+ <version>0.1.9</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.1</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+jdbc.classname=org.hsqldb.jdbcDriver
+jdbc.url=jdbc:hsqldb:file:data/;shutdown=true
+jdbc.username=sa
+jdbc.password=
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler_persistence;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ResourceBundle;
+
+/**
+ * <p>
+ * データベース接続のユーティリティです。
+ * </p>
+ * @author uguu
+ */
+public final class ConnectionUtil {
+ /**
+ * <p>JDBC ドライバのクラス名。</p>
+ */
+ private static String jdbcClassname;
+ /**
+ * <p>JDBC の接続 URL 。</p>
+ */
+ private static String jdbcUrl;
+ /**
+ * <p>JDBC の接続ユーザ名。</p>
+ */
+ private static String jdbcUsername;
+ /**
+ * <p>JDBC のパスワード。</p>
+ */
+ private static String jdbcPassword;
+ static {
+ // リソースから JDBC の接続情報を読み込みます。
+ ResourceBundle rb = ResourceBundle.getBundle("scheduler-persistence");
+ jdbcClassname = rb.getString("jdbc.classname");
+ jdbcUrl = rb.getString("jdbc.url");
+ jdbcUsername = rb.getString("jdbc.username");
+ jdbcPassword = rb.getString("jdbc.password");
+ // JDBC ドライバをロードします。
+ try {
+ Class.forName(jdbcClassname);
+ } catch (ClassNotFoundException e) {
+ throw new Error(e);
+ }
+ }
+ private ConnectionUtil() {
+ throw new UnsupportedOperationException();
+ }
+ /**
+ * <p>
+ * データベース接続を開きます。
+ * </p>
+ * @return データベース接続。
+ * @throws SQLException データベースへの接続に失敗した場合。
+ */
+ public static Connection open() throws SQLException {
+ Connection conn = DriverManager.getConnection(jdbcUrl, jdbcUsername, jdbcPassword);
+ return conn;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler_persistence;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.Scheduler;
+import jp.gr.java_conf.uguu.scheduler.Task;
+import jp.gr.java_conf.uguu.scheduler.Trigger;
+
+/**
+ * <p>
+ * スケジュールをデータソースに永続化、復元します。
+ * </p>
+ * @author uguu
+ */
+public class PersistenceDao {
+ /**
+ * <p>ID を管理しているマップ。</p>
+ */
+ private Map<Schedule, String> scheduleMap = new HashMap<Schedule, String>();
+ /**
+ * <p>
+ * スケジュールを永続化します。
+ * </p>
+ * @param schedule 永続化するスケジュール。
+ * @throws NullPointerException schedule 引数が null の場合。
+ * @throws SQLException データソースへのアクセスに失敗した場合。
+ * @throws IOException 直列化、入出力に失敗した場合。
+ */
+ public void update(Schedule schedule) throws SQLException, IOException {
+ if (schedule == null) {
+ throw new NullPointerException("schedule");
+ }
+ if (this.scheduleMap.containsKey(schedule)) {
+ String id = this.scheduleMap.get(schedule);
+ byte[] byteData = this.getScheduleByteData(schedule);
+ this.updateSchedule(id, byteData);
+ } else {
+ String id = UUID.randomUUID().toString();
+ this.scheduleMap.put(schedule, id);
+ byte[] byteData = this.getScheduleByteData(schedule);
+ this.insertSchedule(id, byteData);
+ }
+ }
+ private void insertSchedule(String id, byte[] byteData) throws SQLException {
+ Connection conn = ConnectionUtil.open();
+ try {
+ conn.setAutoCommit(false);
+ try {
+ String sql = "insert into schedule_persistence (schedule_id, schedule_data) values (?, ?)";
+ PreparedStatement st = conn.prepareStatement(sql);
+ try {
+ st.setString(1, id);
+ st.setBytes(2, byteData);
+ int result = st.executeUpdate();
+ if (result != 1) {
+ throw new SQLException("追加に失敗しました。");
+ }
+ } finally {
+ st.close();
+ }
+ conn.commit();
+ } finally {
+ conn.rollback();
+ }
+ } finally {
+ conn.close();
+ }
+ }
+ private void updateSchedule(String id, byte[] byteData) throws SQLException {
+ Connection conn = ConnectionUtil.open();
+ try {
+ conn.setAutoCommit(false);
+ try {
+ String sql = "update schedule_persistence set schedule_data = ? where schedule_id = ?";
+ PreparedStatement st = conn.prepareStatement(sql);
+ try {
+ st.setBytes(1, byteData);
+ st.setString(2, id);
+ int result = st.executeUpdate();
+ if (result != 1) {
+ throw new SQLException("更新に失敗しました。");
+ }
+ } finally {
+ st.close();
+ }
+ conn.commit();
+ } finally {
+ conn.rollback();
+ }
+ } finally {
+ conn.close();
+ }
+ }
+ /**
+ * <p>
+ * 永続化されているスケジュールを削除します。
+ * </p>
+ * @param schedule 削除するスケジュール。
+ * @throws NullPointerException schedule 引数が null の場合。
+ * @throws IllegalArgumentException 指定したスケジュールが管理されていない場合。
+ * @throws SQLException データソースへのアクセスに失敗した場合。
+ */
+ public void remove(Schedule schedule) throws SQLException {
+ if (schedule == null) {
+ throw new NullPointerException("schedule");
+ }
+ if (!this.scheduleMap.containsKey(schedule)) {
+ throw new IllegalArgumentException("そのスケジュールは管理されていません。");
+ }
+ String id = this.scheduleMap.get(schedule);
+ this.removeSchedule(id);
+ this.scheduleMap.remove(schedule);
+ }
+ private void removeSchedule(String id) throws SQLException {
+ Connection conn = ConnectionUtil.open();
+ try {
+ conn.setAutoCommit(false);
+ try {
+ String sql = "delete from schedule_persistence where schedule_id = ?";
+ PreparedStatement st = conn.prepareStatement(sql);
+ try {
+ st.setString(1, id);
+ int result = st.executeUpdate();
+ if (result != 1) {
+ throw new SQLException("削除に失敗しました。");
+ }
+ } finally {
+ st.close();
+ }
+ conn.commit();
+ } finally {
+ conn.rollback();
+ }
+ } finally {
+ conn.close();
+ }
+ }
+ /**
+ * <p>
+ * スケジューラに、永続化されている全てのスケジュールを読み込みます。
+ * </p>
+ * @param scheduler スケジュールを読み込むスケジューラ。
+ * @throws NullPointerException scheduler 引数が null の場合。
+ * @throws SQLException データソースへのアクセスに失敗した場合。
+ * @throws IOException クラスの復元、入出力に失敗した場合。
+ * @throws ClassNotFoundException 復元しようとしたクラスが存在しない場合。
+ */
+ public void load(Scheduler scheduler) throws SQLException, IOException, ClassNotFoundException {
+ if (scheduler == null) {
+ throw new NullPointerException("scheduler");
+ }
+ Connection conn = ConnectionUtil.open();
+ try {
+ String sql = "select schedule_id, schedule_data from schedule_persistence";
+ PreparedStatement st = conn.prepareStatement(sql);
+ try {
+ ResultSet rs = st.executeQuery();
+ try {
+ while (rs.next()) {
+ String id = rs.getString("schedule_id");
+ byte[] byteData = rs.getBytes("schedule_data");
+ Schedule schedule = this.getSchedule(byteData, scheduler);
+ this.scheduleMap.put(schedule, id);
+ }
+ } finally {
+ rs.close();
+ }
+ } finally {
+ st.close();
+ }
+ } finally {
+ conn.close();
+ }
+ }
+ private byte[] getScheduleByteData(Schedule schedule) throws IOException {
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ try {
+ ObjectOutputStream objOut = new ObjectOutputStream(byteOut);
+ try {
+ objOut.writeObject(schedule.getName());
+ objOut.writeObject(schedule.getIncludeTriggers().toArray(new Trigger[0]));
+ objOut.writeObject(schedule.getExcludeTriggers().toArray(new Trigger[0]));
+ objOut.writeObject(schedule.getTask());
+ objOut.writeObject(schedule.isEnable());
+ } finally {
+ objOut.close();
+ }
+ } finally {
+ byteOut.close();
+ }
+ byte[] byteData = byteOut.toByteArray();
+ return byteData;
+ }
+ private Schedule getSchedule(byte[] byteData, Scheduler scheduler) throws IOException, ClassNotFoundException {
+ Schedule schedule;
+ ByteArrayInputStream byteIn = new ByteArrayInputStream(byteData);
+ try {
+ ObjectInputStream objIn = new ObjectInputStream(byteIn);
+ try {
+ String name = (String) objIn.readObject();
+ Trigger[] includeTriggers = (Trigger[]) objIn.readObject();
+ Trigger[] excludeTriggers = (Trigger[]) objIn.readObject();
+ Task task = (Task) objIn.readObject();
+ boolean enable = (Boolean) objIn.readObject();
+ schedule = scheduler.getSchedules().create(name);
+ schedule.getIncludeTriggers().addAll(Arrays.asList(includeTriggers));
+ schedule.getExcludeTriggers().addAll(Arrays.asList(excludeTriggers));
+ schedule.setTask(task);
+ schedule.setEnable(enable);
+ } finally {
+ objIn.close();
+ }
+ } finally {
+ byteIn.close();
+ }
+ return schedule;
+ }
+ /**
+ * <p>
+ * テーブルを作成します。
+ * </p>
+ * @throws SQLException データソースへのアクセスに失敗した場合。
+ */
+ public void createTable() throws SQLException {
+ Connection conn = ConnectionUtil.open();
+ try {
+ String sql = "create table scheduler_persistence ("
+ + "schedule_id varchar(36) not null primary key"
+ + ",schedule_data binary not null"
+ + ")";
+ Statement st = conn.createStatement();
+ try {
+ st.executeUpdate(sql);
+ } finally {
+ st.close();
+ }
+ } finally {
+ conn.close();
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler_persistence;
+
+import java.io.IOException;
+import java.sql.SQLException;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.ScheduleListener;
+
+/**
+ * <p>
+ * スケジュールの追加、削除に応じて永続化を制御するリスナーです。
+ * </p>
+ * @author uguu
+ */
+public class PersistenceScheduleListener implements ScheduleListener {
+ /**
+ * <p>永続化 DAO 。</p>
+ */
+ private PersistenceDao persistenceDao;
+ /**
+ * <p>
+ * {@link PersistenceScheduleListener} クラスの新しいインスタンスを初期化します。
+ * 永続化 DAO は、 {@link PersistenceSchedulerListener} クラスや {@link PersistenceTaskListener} クラスに指定したインスタンスと同じインスタンスを指定してください。
+ * </p>
+ * @param persistenceDao 永続化 DAO 。
+ */
+ public PersistenceScheduleListener(PersistenceDao persistenceDao) {
+ if (persistenceDao == null) {
+ throw new NullPointerException("persistenceDao");
+ }
+ this.persistenceDao = persistenceDao;
+ }
+ /**
+ * <p>
+ * スケジュールが追加されたとき、スケジュールを永続化します。
+ * </p>
+ * @param schedule スケジュール。
+ * @throws Error 永続化に失敗した場合。
+ */
+ public void added(Schedule schedule) {
+ try {
+ this.persistenceDao.update(schedule);
+ } catch (SQLException e) {
+ throw new Error(e);
+ } catch (IOException e) {
+ throw new Error(e);
+ }
+ }
+ /**
+ * <p>
+ * スケジュールが削除されたとき、永続化されたスケジュールを削除します。
+ * </p>
+ * @param schedule スケジュール。
+ * @throws Error 削除に失敗した場合。
+ */
+ public void removed(Schedule schedule) {
+ try {
+ this.persistenceDao.remove(schedule);
+ } catch (SQLException e) {
+ throw new Error(e);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler_persistence;
+
+import java.io.IOException;
+import java.sql.SQLException;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.Scheduler;
+import jp.gr.java_conf.uguu.scheduler.SchedulerListener;
+
+/**
+ * <p>
+ * スケジューラの動作に応じて永続化を制御するリスナーです。
+ * </p>
+ * @author uguu
+ */
+public class PersistenceSchedulerListener implements SchedulerListener {
+ /**
+ * <p>永続化 DAO 。</p>
+ */
+ private PersistenceDao persistenceDao;
+ /**
+ * <p>
+ * {@link PersistenceSchedulerListener} クラスの新しいインスタンスを初期化します。
+ * 永続化 DAO は、 {@link PersistenceScheduleListener} クラスや {@link PersistenceTaskListener} クラスに指定したインスタンスと同じインスタンスを指定してください。
+ * </p>
+ * @param persistenceDao 永続化 DAO 。
+ */
+ public PersistenceSchedulerListener(PersistenceDao persistenceDao) {
+ if (persistenceDao == null) {
+ throw new NullPointerException("persistenceDao");
+ }
+ this.persistenceDao = persistenceDao;
+ }
+ /**
+ * <p>
+ * スケジューラが開始したときに、永続化されている全てのスケジュールを復元します。
+ * </p>
+ * @param scheduler スケジューラ。
+ * @throws Error 復元に失敗した場合。
+ */
+ public void started(Scheduler scheduler) {
+ try {
+ this.persistenceDao.load(scheduler);
+ } catch (SQLException e) {
+ throw new Error(e);
+ } catch (IOException e) {
+ throw new Error(e);
+ } catch (ClassNotFoundException e) {
+ throw new Error(e);
+ }
+ }
+ /**
+ * <p>
+ * スケジューラが停止したときに、全てのスケジュールを永続化します。
+ * </p>
+ * @param scheduler スケジューラ。
+ * @throws Error 永続化に失敗した場合。
+ */
+ public void stopped(Scheduler scheduler) {
+ for (Schedule schedule : scheduler.getSchedules()) {
+ try {
+ this.persistenceDao.update(schedule);
+ } catch (SQLException e) {
+ throw new Error(e);
+ } catch (IOException e) {
+ throw new Error(e);
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler_persistence;
+
+import java.io.IOException;
+import java.sql.SQLException;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+import jp.gr.java_conf.uguu.scheduler.TaskListener;
+import jp.gr.java_conf.uguu.scheduler.TaskResultEvent;
+
+/**
+ * <p>
+ * タスクの動作に応じて永続化を制御するリスナーです。
+ * </p>
+ * @author uguu
+ */
+public class PersistenceTaskListener implements TaskListener {
+ /**
+ * <p>永続化 DAO 。</p>
+ */
+ private PersistenceDao persistenceDao;
+ /**
+ * <p>
+ * {@link PersistenceTaskListener} クラスの新しいインスタンスを初期化します。
+ * 永続化 DAO は、 {@link PersistenceScheduleListener} クラスや {@link PersistenceSchedulerListener} クラスに指定したインスタンスと同じインスタンスを指定してください。
+ * </p>
+ * @param persistenceDao 永続化 DAO 。
+ */
+ public PersistenceTaskListener(PersistenceDao persistenceDao) {
+ if (persistenceDao == null) {
+ throw new NullPointerException("persistenceDao");
+ }
+ this.persistenceDao = persistenceDao;
+ }
+ /**
+ * <p>
+ * タスクが実行される前は、何もしません。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスク イベント。
+ */
+ public void beforeTask(Schedule schedule, TaskEvent event) {
+ // 何もしません。
+ }
+ /**
+ * <p>
+ * タスクが実行された後、スケジュールを永続化します。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスク結果イベント。
+ * @throws Error 永続化に失敗した場合。
+ */
+ public void afterTask(Schedule schedule, TaskResultEvent event) {
+ try {
+ this.persistenceDao.update(schedule);
+ } catch (SQLException e) {
+ throw new Error(e);
+ } catch (IOException e) {
+ throw new Error(e);
+ }
+ }
+}
--- /dev/null
+package jp.gr.java_conf.uguu.scheduler_persistence;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.Task;
+import jp.gr.java_conf.uguu.scheduler.TaskEvent;
+
+public class SchedulerPersistenceTask implements Task {
+ public Object task(Schedule schedule, TaskEvent event) throws Exception {
+ // TODO メソッドを実装します。
+ return null;
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><fileset-config file-format-version="1.1.0" simple-config="false">
+<fileset name="src" enabled="true" check-config-name="Uguu Checks" type="remote" location="http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml" description="Uguu Software のコーディング スタイルです。"><file-match-pattern match-pattern="src\\java" include-pattern="true"/>
+</fileset>
+</fileset-config>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>uguu-scheduler</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.mevenide.ui.mavenbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.mevenide.ui.mavennature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <pomVersion>3</pomVersion>
+ <organization>
+ <name>Uguu Software</name>
+ <url>http://wiki.livedoor.jp/uguuxp/</url>
+ <logo>http://image02.wiki.livedoor.jp/u/p/uguuxp/82487bf1fed6e9af.png</logo>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports>
+<!--
+ <report>maven-changelog-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-checkstyle-plugin</report>
+-->
+ <report>maven-linkcheck-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-faq-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
--- /dev/null
+maven.compile.debug=true
+maven.compile.encoding=utf-8
+maven.compile.source=1.5
+
+maven.docs.outputencoding=utf-8
+
+maven.checkstyle.check.tests=false
+maven.checkstyle.header.file=${basedir}/LICENSE.txt
+maven.checkstyle.propertiesURL=http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml
+
+maven.test.failure.ignore=true
+
+maven.xdoc.date=right
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.distributionUrl=http://uguu-sysman.sourceforge.jp/maven/uguu-http-test/jars
+maven.xdoc.distributionType=jar
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <extend>${basedir}/project-base.xml</extend>
+ <artifactId>uguu-scheduler</artifactId>
+ <name>uguu-scheduler</name>
+ <groupId>uguu-scheduler</groupId>
+ <currentVersion>0.1.9</currentVersion>
+ <inceptionYear>2005</inceptionYear>
+ <package>jp.gr.java_conf.uguu.scheduler</package>
+ <description>
+ スケジュールに従ってタスクを実行するスケジューラのインターフェイスです。
+ このコンポーネントはただのインターフェイスであり、実行可能なコンポーネントではありません。
+ スケジューラの実装は uguu-scheduler-impl を参照してください。
+ </description>
+ <repository>
+ <connection>scm:cvs:pserver:anonymous@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-scheduler</connection>
+ <developerConnection>scm:cvs:ext:uguu@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-scheduler</developerConnection>
+ <url>http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/uguu-sysman/uguu-scheduler/</url>
+ </repository>
+ <developers>
+ <developer>
+ <name>uguu</name>
+ <id>2</id>
+ <email>uguu@users.sourceforge.jp</email>
+ <organization>Uguu Software</organization>
+ </developer>
+ </developers>
+ <versions>
+ <version>
+ <name>0.1.9</name>
+ <tag>RELEASE_0_1_9</tag>
+ </version>
+ <version>
+ <name>0.1.8</name>
+ <tag>RELEASE_0_1_8</tag>
+ </version>
+ <version>
+ <name>0.1.7</name>
+ <tag>RELEASE_0_1_7</tag>
+ </version>
+ <version>
+ <name>0.1.6</name>
+ <tag>RELEASE_0_1_6</tag>
+ </version>
+ <version>
+ <name>0.1.5</name>
+ <tag>RELEASE_0_1_5</tag>
+ </version>
+ <version>
+ <name>0.1.4</name>
+ <tag>RELEASE_0_1_4</tag>
+ </version>
+ <version>
+ <name>0.1.3</name>
+ <tag>RELEASE_0_1_3</tag>
+ </version>
+ <version>
+ <name>0.1.2</name>
+ <tag>RELEASE_0_1_2</tag>
+ </version>
+ <version>
+ <name>0.1.1</name>
+ <tag>RELEASE_0_1_1</tag>
+ </version>
+ <version>
+ <name>0.1.0</name>
+ <tag>RELEASE_0_1_0</tag>
+ </version>
+ </versions>
+ <licenses>
+ <license>
+ <name>BSD License</name>
+ </license>
+ </licenses>
+</project>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+/**
+ * <p>
+ * スケジューラが管理するスケジュールです。
+ * スケジュールは、タスクを実行する条件を持つトリガー条件式と、トリガーによって実行されるタスクを持ちます。
+ * </p>
+ * <p>
+ * スケジュールは、 {@link Scheduler#getSchedules()} メソッドで取得できる {@link ScheduleIterable} クラスの {@link ScheduleIterable#create(String)} メソッドで作成することができます。
+ * </p>
+ * <p>
+ * タスクは、指定しないこともできます。
+ * その場合、トリガーの条件が真になっても何もしません。
+ * また、トリガーは、指定しないこともできます。
+ * その場合、タスクが実行されることはありません。
+ * </p>
+ * <p>
+ * スケジュールは、初期状態では有効です。
+ * 詳しくは {@link #isEnable()} メソッドを参照してください。
+ * </p>
+ * @author uguu
+ */
+public interface Schedule {
+ /**
+ * <p>
+ * スケジュールの名前を返します。
+ * スケジュールの名前は、スケジュールの初期化時に付けられて、それ以降変更することはできません。
+ * スケジュールの名前を変更したい場合、別のスケジュールを作成しなおしてください。
+ * </p>
+ * @return スケジュールの名前。
+ */
+ String getName();
+ /**
+ * <p>
+ * タスクの実行を判断するトリガーのリストを返します。
+ * このリストに含まれるトリガーの 1 つでも真ならば、スケジュールはタスクを実行しようとします。
+ * ({@link #getExcludeTriggers()} メソッドのリストに含まれるトリガーが 1 つでも真ならば、タスクは実行されません。)
+ * </p>
+ * @return タスクの実行を判断するトリガーのリスト。
+ */
+ TriggerList getIncludeTriggers();
+ /**
+ * <p>
+ * タスクの実行を阻止するトリガーのリストを返します。
+ * このリストに含まれるトリガーの 1 つでも真ならば、タスクは実行されません。
+ * 例えば、 {@link #getIncludeTriggers()} メソッドのリストに毎日 0:00 に真になるトリガーを追加し、このメソッドのリストに土曜日、日曜日に真になるトリガーを追加すると、月曜日から金曜日の 0:00 にタスクが実行されることになります。
+ * </p>
+ * @return タスクの実行を阻止するトリガーのリスト。
+ */
+ TriggerList getExcludeTriggers();
+ /**
+ * <p>
+ * スケジュールにより実行されるタスクを返します。
+ * </p>
+ * @return スケジュールにより実行されるタスク。
+ */
+ Task getTask();
+ /**
+ * <p>
+ * スケジュールにより実行されるタスクを設定します。
+ * null を設定した場合、トリガーの条件が真になっても何もしません。
+ * </p>
+ * @param task スケジュールにより実行されるタスク。
+ */
+ void setTask(Task task);
+ /**
+ * <p>
+ * タスクの処理状態を取得します。
+ * </p>
+ * @return タスクの処理状態を格納しているコンテナ。
+ */
+ TaskFutureIterable getTaskFutures();
+ /**
+ * <p>
+ * スケジュールが有効か無効かを返します。
+ * スケジュールが有効のときはタスクが実行されますが、スケジュールが無効のときは、トリガーの条件を満たしてもタスクは実行されません。
+ * スケジュールは、初期状態で有効です。
+ * </p>
+ * @return スケジュールが有効の場合は true 、無効の場合は false 。
+ */
+ boolean isEnable();
+ /**
+ * <p>
+ * スケジュールの有効、無効を設定します。
+ * </p>
+ * @param enable スケジュールを有効にする場合は true 、無効にする場合は false 。
+ */
+ void setEnable(boolean enable);
+ /**
+ * <p>
+ * スケジュールの実行を試みます。
+ * このメソッドは、スケジューラによって定期的に呼び出されます。
+ * このメソッドが呼び出されたら、スケジュールはトリガーによりタスクを実行するかどうかを判断し、場合によってはタスクを実行してください。
+ * </p>
+ */
+ void execute();
+ /**
+ * <p>
+ * 即座にスケジュールを実行します。
+ * このメソッドは、トリガーによる判断を行わずに、即座にタスクを実行してください。
+ * </p>
+ */
+ void executeNow();
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+/**
+ * <p>
+ * 複数のスケジュールを格納します。
+ * </p>
+ * @author uguu
+ */
+public interface ScheduleIterable extends Iterable<Schedule> {
+ /**
+ * <p>
+ * 新規のスケジュールを作成します。
+ * スケジュールの名前は {@link String#trim()} メソッドでトリムされます。
+ * </p>
+ * @param name 新規のスケジュールの名前。
+ * @return 新規のスケジュール。
+ * @throws NullPointerException name 引数が null 、またはトリムして空文字列の場合。
+ * @throws IllegalArgumentException 指定した名前のスケジュールが既に存在する場合。
+ */
+ Schedule create(String name);
+ /**
+ * <p>
+ * スケジューラから全てのスケジュールを削除します。
+ * </p>
+ * <p>
+ * スケジュールの削除に成功すると、 {@link ScheduleListener#removed(Schedule)} メソッドが通知されます。
+ * </p>
+ */
+ void clear();
+ /**
+ * <p>
+ * 指定した名前を持つスケジュールを返します。
+ * </p>
+ * @param name スケジュールの名前。
+ * @return 指定した名前を持つスケジュール。
+ * 指定した名前を持つスケジュールが存在しない場合は null 。
+ */
+ Schedule get(String name);
+ /**
+ * <p>
+ * 全てのスケジュールを返します。
+ * </p>
+ * @return 全てのスケジュール。
+ * スケジュールが全く存在しない場合は、長さ 0 の配列。
+ */
+ Schedule[] getAll();
+ /**
+ * <p>
+ * 指定した名前を持つスケジュールを削除します。
+ * </p>
+ * <p>
+ * スケジュールの削除に成功すると、 {@link ScheduleListener#removed(Schedule)} メソッドが通知されます。
+ * </p>
+ * @param name スケジュールの名前。
+ * @return スケジュールの削除に成功した場合は true 、指定したスケジュールが無くてスケジュールの削除に失敗した場合は false 。
+ */
+ boolean remove(String name);
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+/**
+ * <p>
+ * スケジュールの動作に関して通知されるリスナーです。
+ * </p>
+ * <p>
+ * リスナーは、スケジューラによって、複数のスレッドでインスタンスのメソッドが呼び出される可能性があります。
+ * リスナーの実装は、その点に注意してください。
+ * </p>
+ * @author uguu
+ */
+public interface ScheduleListener extends SchedulerEventListener {
+ /**
+ * <p>
+ * スケジュールが追加されたときに通知されます。
+ * </p>
+ * @param schedule 追加されたスケジュール。
+ */
+ void added(Schedule schedule);
+ /**
+ * <p>
+ * スケジュールが削除されたときに通知されます。
+ * </p>
+ * @param schedule 削除されたスケジュール。
+ */
+ void removed(Schedule schedule);
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+/**
+ * <p>
+ * スケジュールを管理します。
+ * スケジュールは、トリガーとタスクの組で、トリガーの条件により、タスクを起動します。
+ * </p>
+ * @author uguu
+ */
+public interface Scheduler {
+ /**
+ * <p>
+ * スケジューラを起動します。
+ * 以降、トリガーの判断により、タスクが実行されます。
+ * </p>
+ */
+ void start();
+ /**
+ * <p>
+ * スケジューラを停止します。
+ * 実行中のタスクが直ちに停止するかどうかは、実装クラスによります。
+ * </p>
+ */
+ void stop();
+ /**
+ * <p>
+ * スケジューラが動作中かどうかを返します。
+ * </p>
+ * @return スケジューラが動作している場合は true 、停止している場合は false 。
+ */
+ boolean isRunning();
+ /**
+ * <p>
+ * スケジューラの管理下のスケジュールのコレクションを返します。
+ * スケジューラへのスケジュールの追加、削除は、このコレクションで行います。
+ * </p>
+ * @return スケジュールのコレクション。
+ */
+ ScheduleIterable getSchedules();
+ /**
+ * <p>
+ * リスナーのリストを返します。
+ * </p>
+ * @return リスナーのリスト。
+ */
+ SchedulerEventListenerList getListeners();
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+/**
+ * <p>
+ * スケジューラに関するイベント リスナーが実装する必要のある、タグ インターフェイスです。
+ * </p>
+ * @author uguu
+ */
+public interface SchedulerEventListener {
+ // 何も定義しません。
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+import java.util.List;
+
+/**
+ * <p>
+ * スケジューラ イベント リスナのリストです。
+ * </p>
+ * @author uguu
+ */
+public interface SchedulerEventListenerList extends List<SchedulerEventListener> {
+ // 何も定義しません。
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+/**
+ * <p>
+ * スケジューラが起動、停止するときに通知されるリスナーです。
+ * </p>
+ * <p>
+ * リスナーは、スケジューラによって、複数のスレッドでインスタンスのメソッドが呼び出される可能性があります。
+ * リスナーの実装は、その点に注意してください。
+ * </p>
+ * @author uguu
+ */
+public interface SchedulerListener extends SchedulerEventListener {
+ /**
+ * <p>
+ * スケジューラが起動するときに通知されます。
+ * </p>
+ * @param scheduler スケジューラ。
+ */
+ void started(Scheduler scheduler);
+ /**
+ * <p>
+ * スケジューラが停止するときに通知されます。
+ * </p>
+ * @param scheduler スケジューラ。
+ */
+ void stopped(Scheduler scheduler);
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * スケジュールが実行するタスクです。
+ * スケジューラでタスクを実行するには、このインターフェイスを実装し、トリガーとともにスケジュールを作成してスケジューラに登録します。
+ * </p>
+ * <p>
+ * タスクは、スケジューラによって、複数のスレッドで同じインスタンスの {@link #task(Schedule, TaskEvent)} メソッドが呼び出される可能性があります。
+ * 例えば、タスクの実行に 1 分以上かかるとして、そのタスクを 10 秒間隔で呼び出した場合、前回のタスクが完了する前にタスクが呼び出される可能性があります。
+ * タスクの実装は、その点に注意してください。
+ * </p>
+ * <p>
+ * タスクは、永続化のために、直列化可能である必要があります。
+ * </p>
+ * @param <T> タスクの実行結果の型。
+ * @author uguu
+ */
+public interface Task<T> extends Serializable {
+ /**
+ * <p>
+ * 実行するタスクを定義します。
+ * タスクの実行結果を返すことができますが、何も返さない場合は null を返すこともできます。
+ * また、タスクが失敗した場合、自由に例外をスローすることができます。
+ * 重大な問題は発生しなかったが通常終了でもない場合、 {@link WarningException} 例外をスローしてください。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスクの実行のイベント情報。
+ * @return タスクの実行結果。
+ * @throws WarningException 警告で終了した場合。
+ * @throws Exception タスクが失敗した場合。
+ */
+ T task(Schedule schedule, TaskEvent event) throws Exception;
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+import java.util.Calendar;
+
+/**
+ * <p>
+ * タスクの実行のイベント情報を保持します。
+ * </p>
+ * @author uguu
+ *
+ */
+public interface TaskEvent {
+ /**
+ * <p>
+ * タスクの実行が開始した時刻を返します。
+ * </p>
+ * @return タスクの実行が開始した時刻。
+ */
+ Calendar getStartTime();
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+import java.io.Serializable;
+import java.util.Calendar;
+
+/**
+ * <p>
+ * タスクの処理状態を表します。
+ * {@link TaskFuture} インターフェイスは、タスクの処理状態を非同期に取得することができます。
+ * 例えば、タスクが実行中であっても、タスクが完了しているかどうかを取得することができますし、タスクが実行中であってもタスクの結果を取得しようとすることができます (この場合、 {@link IllegalStateException} 例外がスローされますが) 。
+ * </p>
+ * <p>
+ * タスクの処理状態は、永続化のため、直列化可能である必要があります。
+ * </p>
+ * @author uguu
+ */
+public interface TaskFuture extends Serializable {
+ /**
+ * <p>
+ * タスクの名前を返します。
+ * </p>
+ * @return タスクの名前。
+ */
+ String getName();
+ /**
+ * <p>
+ * タスクの実行の開始時刻を返します。
+ * </p>
+ * @return タスクの実行の開始時刻。
+ */
+ Calendar getStartTime();
+ /**
+ * <p>
+ * タスクの実行の終了時刻を返します。
+ * </p>
+ * @return タスクの実行の終了時刻。
+ * タスクの実行が終了していない場合は null 。
+ */
+ Calendar getEndTime();
+ /**
+ * <p>
+ * タスクが通常終了、または警告終了した場合、タスクの実行結果を返します。
+ * タスクがエラー終了した場合、 null を返します。
+ * </p>
+ * <p>
+ * タスクの実行が終了していない場合、 {@link IllegalStateException} 例外がスローされます。
+ * この場合、 {@link #getStatus()} メソッドでタスクの処理状態を取得し、タスクが実行中でないことを確認してから呼び出してください。
+ * </p>
+ * @return タスクの実行結果。
+ * エラー終了した場合は null 。
+ * @throws IllegalStateException タスクの実行が終了していない場合。
+ */
+ Object getResult();
+ /**
+ * <p>
+ * タスクがエラー終了した場合、エラーの原因を返します。
+ * タスクが通常終了、または警告終了した場合、 null を返します。
+ * </p>
+ * <p>
+ * タスクの実行が終了していない場合、 {@link IllegalStateException} 例外がスローされます。
+ * この場合、 {@link #getStatus()} メソッドでタスクの処理状態を取得し、タスクが実行中でないことを確認してから呼び出してください。
+ * </p>
+ * @return エラーの原因。
+ * 通常終了した場合は null 。
+ * @throws IllegalStateException タスクの実行が終了していない場合。
+ */
+ Throwable getCause();
+ /**
+ * <p>
+ * タスクの処理状態を返します。
+ * </p>
+ * @return タスクの処理状態。
+ */
+ TaskStatusEnum getStatus();
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+/**
+ * <p>
+ * 複数の {@link TaskFuture} インスタンスを繰り返し取得することが出来ます。
+ * </p>
+ * <p>
+ * このクラスは {@link TaskFuture} インスタンスを<strong>新しい順</strong>に取得します。
+ * つまり、先頭が最新のタスク処理状態で、末尾は最も古いタスク処理状態です。
+ * </p>
+ * @author uguu
+ */
+public interface TaskFutureIterable extends Iterable<TaskFuture> {
+ /**
+ * <p>
+ * 最新のタスク処理状態を返します。
+ * ただし、最新のタスク処理状態が存在しない場合、 null を返します。
+ * このメソッドは、以下の呼び出しと同じ意味を持ちます。
+ * </p>
+ * <pre>
+ * ITaskFuture f = null;
+ * try {
+ * f = get(0);
+ * } catch (IndexOutOfBoundsException e) {
+ * }
+ * </pre>
+ * @return 最新のタスク処理状態。
+ * 最新のタスク処理状態が存在しない場合は null 。
+ */
+ TaskFuture get();
+ /**
+ * <p>
+ * 指定したインデックス番号の位置にあるタスク処理状態を返します。
+ * </p>
+ * @param index 取得するタスク処理状態の位置を表すインデックス番号。
+ * @return 指定したインデックス番号の位置にあるタスク処理状態。
+ * @throws IndexOutOfBoundsException インデックス番号が範囲外の場合。
+ */
+ TaskFuture get(int index);
+ /**
+ * <p>
+ * 指定したインデックス番号の位置から指定した個数のタスク処理状態を配列で返します。
+ * </p>
+ * @param index 取得を開始する位置を表すインデックス番号。
+ * @param length 取得する個数。
+ * @return 指定した範囲のタスク処理状態の配列。
+ * @throws IndexOutOfBoundsException インデックス番号が範囲外の場合。
+ * インデックス番号と個数を足した位置が範囲外の場合。
+ */
+ TaskFuture[] get(int index, int length);
+ /**
+ * <p>
+ * 全てのタスク処理状態を返します。
+ * </p>
+ * @return 全てのタスク処理状態。
+ */
+ TaskFuture[] getAll();
+ /**
+ * <p>
+ * 格納しているタスク処理状態の個数を返します。
+ * </p>
+ * @return 格納しているタスク処理状態の個数。
+ */
+ int size();
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+/**
+ * <p>
+ * タスクの動作に関して通知されるリスナーです。
+ * </p>
+ * <p>
+ * リスナーは、スケジューラによって、複数のスレッドでインスタンスのメソッドが呼び出される可能性があります。
+ * リスナーの実装は、その点に注意してください。
+ * </p>
+ * @author uguu
+ */
+public interface TaskListener extends SchedulerEventListener {
+ /**
+ * <p>
+ * タスクが実行される直前に呼び出されます。
+ * タスクは、このメソッドの呼出し後に実行されます。
+ * したがって、このメソッドの呼び出しが長引くと、タスクの実行が遅延するので注意してください。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスクの実行のイベント情報。
+ */
+ void beforeTask(Schedule schedule, TaskEvent event);
+ /**
+ * <p>
+ * タスクの実行が完了したあとに呼び出されます。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスクの実行結果のイベント情報。
+ */
+ void afterTask(Schedule schedule, TaskResultEvent event);
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+import java.util.Calendar;
+
+/**
+ * <p>
+ * タスクの実行が完了したイベント情報を保持します。
+ * </p>
+ * @author uguu
+ *
+ */
+public interface TaskResultEvent {
+ /**
+ * <p>
+ * タスクの実行が開始した時刻を返します。
+ * </p>
+ * @return タスクの実行が開始した時刻。
+ */
+ Calendar getStartTime();
+ /**
+ * <p>
+ * タスクの実行が終了した時刻を返します。
+ * </p>
+ * @return タスクの実行が終了した時刻。
+ */
+ Calendar getEndTime();
+ /**
+ * <p>
+ * タスクが通常終了、または警告終了した場合、タスクの実行結果を返します。
+ * タスクがエラー終了した場合、 null を返します。
+ * </p>
+ * @return タスクの実行結果。
+ * タスクがエラー終了した場合、 null 。
+ */
+ Object getResult();
+ /**
+ * <p>
+ * タスクがエラー終了した場合、エラーの原因を返します。
+ * タスクが通常終了、または警告終了した場合、 null を返します。
+ * </p>
+ * @return エラーの原因。
+ * タスクが通常終了、または警告終了した場合、 null 。
+ */
+ Throwable getCause();
+ /**
+ * <p>
+ * タスクの処理結果を返します。
+ * 処理結果なので、 {@link TaskStatusEnum#EXECUTING} 値になることはありません。
+ * </p>
+ * @return タスクの処理結果。
+ */
+ TaskStatusEnum getStatus();
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+/**
+ * <p>
+ * タスクの処理結果を表す列挙型です。
+ * </p>
+ * @author uguu
+ */
+public enum TaskStatusEnum {
+ /**
+ * <p>
+ * 実行中。
+ * タスクは実行中で、終了していないことを表します。
+ * </p>
+ */
+ EXECUTING,
+ /**
+ * <p>
+ * 通常終了。
+ * 何の問題もなく終了したことを表します。
+ * </p>
+ */
+ NORMAL,
+ /**
+ * <p>
+ * 警告終了。
+ * 例外やエラーは発生しなかったが、何らかの問題が発生したことを表します。
+ * </p>
+ */
+ WARNING,
+ /**
+ * <p>
+ * エラー終了。
+ * 例外やエラーが発生して終了したことを表します。
+ * </p>
+ */
+ ERROR,
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * タスクを実行する判断を行うトリガーです。
+ * トリガーは、タスクを実行する判断を行う条件を内部に持っており、スケジュールの問い合わせによりタスクを実行するかどうかの真偽値を返します。
+ * スケジュールは、登録されたトリガーに問い合わせを行い、条件が整ったときにタスクを実行します。
+ * </p>
+ * <p>
+ * トリガーは、スケジューラによって、複数のスレッドで々インスタンスのメソッドが呼び出される可能性があります。
+ * トリガーの実装は、その点に注意してください。
+ * </p>
+ * <p>
+ * トリガーは、永続化のために、直列化可能である必要があります。
+ * </p>
+ * @author uguu
+ */
+public interface Trigger extends Serializable {
+ /**
+ * <p>
+ * タスクを実行するかどうかを判断します。
+ * </p>
+ * @param schedule スケジュール。
+ * @param event タスクの実行のイベント情報。
+ * @return タスクを実行するべきなら true 、タスクを実行しないべきなら false 。
+ */
+ boolean isFire(Schedule schedule, TaskEvent event);
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+import java.util.List;
+
+/**
+ * <p>
+ * トリガーのリストです。
+ * </p>
+ * @author uguu
+ */
+public interface TriggerList extends List<Trigger> {
+ // 何も実装しません。
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.scheduler;
+
+/**
+ * <p>
+ * 警告レベルの終了であることを表す例外です。
+ * </p>
+ * <p>
+ * タスクは、普通にメソッド呼び出しが返ると、通常終了となります。
+ * 重大な問題が発生して、例外、エラーがスローされると、エラー終了となります。
+ * これらに対して、<strong>重大な問題はないが通常終了ではない</strong>、そういうことを表す場合にこの例外をスローしてください。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public final class WarningException extends RuntimeException {
+ /**
+ * <p>
+ * タスクの結果。
+ * </p>
+ */
+ private Object result;
+ /**
+ * <p>
+ * {@link WarningException} クラスの新しいインスタンスを初期化します。
+ * </p>
+ * <p>
+ * result 引数には、通常終了だった時に返すはずだった戻り値を指定してください。
+ * もちろん、 null を設定しても問題ありません。
+ * </p>
+ * @param result タスクの処理結果。
+ */
+ public WarningException(Object result) {
+ this.result = result;
+ }
+ /**
+ * <p>
+ * タスクの処理結果を返します。
+ * </p>
+ * @return タスクの処理結果。
+ */
+ public Object getResult() {
+ return this.result;
+ }
+}
--- /dev/null
+<body>
+ <p>トリガーによりタスクを起動させるスケジューラです。</p>
+</body>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><fileset-config file-format-version="1.1.0" simple-config="false">
+<fileset name="src" enabled="true" check-config-name="Uguu Checks" type="remote" location="http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml" description="Uguu Software のコーディング スタイルです。"><file-match-pattern match-pattern="src\\java" include-pattern="true"/>
+</fileset>
+</fileset-config>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/conf"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler-persistence/jars/uguu-scheduler-persistence-0.0.0.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/jspapi/jars/jsp-api-2.0.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/jstl/jars/jstl-1.1.2.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/servletapi/jars/servlet-api-2.4.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/taglibs/jars/standard-1.1.2.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-backup/jars/uguu-backup-0.1.5.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-http-test/jars/uguu-http-test-0.1.5.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-jdbc-test/jars/uguu-jdbc-test-0.1.4.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-ping/jars/uguu-ping-0.0.6.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-0.1.9.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-impl-0.1.5.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+work
+target
+.settings
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>uguu-sysman-web</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.mevenide.ui.mavenbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.mevenide.ui.mavennature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ <nature>com.sysdeo.eclipse.tomcat.tomcatnature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<tomcatProjectProperties>
+ <rootDir>/src/webapp/</rootDir>
+ <exportSource>false</exportSource>
+ <reloadable>true</reloadable>
+ <redirectLogger>false</redirectLogger>
+ <updateXml>true</updateXml>
+ <warLocation></warLocation>
+ <extraInfo></extraInfo>
+ <webPath>/uguu-sysman-web</webPath>
+ <webClassPathEntries>
+ <webClassPathEntry>/uguu-sysman-web/target/classes</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/aopalliance/jars/aopalliance-1.0.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/commons-beanutils/jars/commons-beanutils-1.7.0.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/commons-digester/jars/commons-digester-1.7.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/commons-fileupload/jars/commons-fileupload-1.0.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/commons-logging/jars/commons-logging-1.0.4.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/commons-validator/jars/commons-validator-1.2.0.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/javassist/jars/javassist-3.0.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/jstl/jars/jstl-1.1.2.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/ognl/jars/ognl-2.6.7.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/oro/jars/oro-2.0.8.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/poi/jars/poi-2.5.1-final-20040804.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/seasar/jars/s2-extension-2.3.4.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/seasar/jars/s2-framework-2.3.4.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/seasar/jars/s2-struts-1.2.0.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/seasar/jars/s2-struts-tiger-1.2.0.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/struts/jars/struts-1.2.8.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/struts/jars/struts-el-1.2.8.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/taglibs/jars/standard-1.1.2.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/uguu-backup/jars/uguu-backup-0.1.4.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/uguu-http-test/jars/uguu-http-test-0.1.4.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/uguu-jdbc-test/jars/uguu-jdbc-test-0.1.3.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/uguu-ping/jars/uguu-ping-0.0.5.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-0.1.6.jar</webClassPathEntry>
+ <webClassPathEntry>MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-impl-0.1.3.jar</webClassPathEntry>
+ </webClassPathEntries>
+</tomcatProjectProperties>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <pomVersion>3</pomVersion>
+ <organization>
+ <name>Uguu Software</name>
+ <url>http://wiki.livedoor.jp/uguuxp/</url>
+ <logo>http://image02.wiki.livedoor.jp/u/p/uguuxp/82487bf1fed6e9af.png</logo>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports>
+<!--
+ <report>maven-changelog-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-checkstyle-plugin</report>
+-->
+ <report>maven-linkcheck-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-faq-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
--- /dev/null
+maven.compile.debug=true
+maven.compile.encoding=utf-8
+maven.compile.source=1.5
+
+maven.docs.outputencoding=utf-8
+
+maven.checkstyle.check.tests=false
+maven.checkstyle.header.file=${basedir}/LICENSE.txt
+maven.checkstyle.propertiesURL=http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml
+
+maven.test.failure.ignore=true
+
+maven.xdoc.date=right
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.distributionUrl=http://uguu-sysman.sourceforge.jp/maven/uguu-http-test/jars
+maven.xdoc.distributionType=jar
+
+maven.repo.remote=http://www.ibiblio.org/maven/,http://uguu-sysman.sourceforge.jp/maven/,http://seasar.sourceforge.jp/maven/,file://${basedir}/src/lib/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <extend>${basedir}/project-base.xml</extend>
+ <artifactId>sysman</artifactId>
+ <name>sysman</name>
+ <groupId>uguu</groupId>
+ <currentVersion>0.0.0</currentVersion>
+ <inceptionYear>2005</inceptionYear>
+ <package>jp.gr.java_conf.uguu.sysman</package>
+ <description>システムの監視、運用を行うツールです。</description>
+ <repository>
+ <connection>scm:cvs:pserver:anonymous@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-sysman</connection>
+ <developerConnection>scm:cvs:ext:uguu@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-sysman</developerConnection>
+ <url>http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/uguu-sysman/uguu-sysman/</url>
+ </repository>
+ <developers>
+ <developer>
+ <name>uguu</name>
+ <id>2</id>
+ <email>uguu@users.sourceforge.jp</email>
+ <organization>Uguu Software</organization>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>BSD License</name>
+ </license>
+ </licenses>
+ <dependencies>
+ <!-- スケジューラ -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <type>jar</type>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler</artifactId>
+ <version>0.1.9</version>
+ <type>jar</type>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler-impl</artifactId>
+ <version>0.1.5</version>
+ <type>jar</type>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>uguu-scheduler-persistence</groupId>
+ <artifactId>uguu-scheduler-persistence</artifactId>
+ <version>0.0.0</version>
+ <type>jar</type>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>uguu-http-test</groupId>
+ <artifactId>uguu-http-test</artifactId>
+ <version>0.1.5</version>
+ <type>jar</type>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>uguu-jdbc-test</groupId>
+ <artifactId>uguu-jdbc-test</artifactId>
+ <version>0.1.4</version>
+ <type>jar</type>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>uguu-ping</groupId>
+ <artifactId>uguu-ping</artifactId>
+ <version>0.0.6</version>
+ <type>jar</type>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>uguu-backup</groupId>
+ <artifactId>uguu-backup</artifactId>
+ <version>0.1.5</version>
+ <type>jar</type>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
+ <!-- JSTL -->
+ <dependency>
+ <groupId>jstl</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.1.2</version>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ <properties>
+ <war.bundle>true</war.bundle>
+ </properties>
+ </dependency>
+ <!-- Servlet/JSP -->
+ <dependency>
+ <groupId>servletapi</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>jspapi</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.0</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="Shift_JIS"?>
+<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container//EN" "http://www.seasar.org/dtd/components.dtd">
+<components namespace="aop">
+ <component name="traceInterceptor" class="org.seasar.framework.aop.interceptors.TraceInterceptor"/>
+ <component name="traceThrowsInterceptor" class="org.seasar.framework.aop.interceptors.TraceThrowsInterceptor"/>
+</components>
--- /dev/null
+<?xml version="1.0" encoding="Shift_JIS"?>
+<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN" "http://www.seasar.org/dtd/components21.dtd">
+<components>
+ <include path="s2struts.dicon"/>
+ <include path="uguu-sysman.dicon"/>
+</components>
--- /dev/null
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
--- /dev/null
+<?xml version="1.0" encoding="Shift_JIS"?>
+<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN" "http://www.seasar.org/dtd/components21.dtd">
+<components namespace="s2struts">
+ <component name="messageFacade" class="org.seasar.struts.action.MessageFacadeImpl" instance="request"/>
+ <component name="s2strutsContext" class="org.seasar.struts.context.S2StrutsContextImpl" instance="session"/>
+ <component name="requestProcessorFactory" class="org.seasar.struts.processor.RequestProcessorFactoryImpl"/>
+ <component name="componentNameCreator" class="org.seasar.struts.action.ComponentNameCreatorImpl"/>
+ <component name="classRegister" class="org.seasar.struts.util.ClassRegisterImpl"/>
+ <component name="actionFactory" class="org.seasar.struts.action.ActionFactoryImpl"/>
+ <component name="acceptor" class="org.seasar.struts.processor.AcceptorImpl"/>
+ <component name="executeProcessor" class="org.seasar.struts.processor.ActionExecuteProcessorImpl"/>
+ <component name="validateProcessor" class="org.seasar.struts.processor.ValidateProcessorImpl"/>
+ <component name="inputValueFormProcessor" class="org.seasar.struts.processor.InputValueFormProcessorImpl"/>
+ <component name="requestProcessor" class="org.seasar.struts.processor.S2RequestProcessor" instance="prototype">
+ <aspect pointcut="processActionForm">
+ <component class="org.seasar.struts.interceptors.ProcessPojoFormInterceptor"/>
+ </aspect>
+ </component>
+ <!--
+ <component name="tilesRequestProcessor" class="org.seasar.struts.processor.S2TilesRequestProcessor" instance="prototype">
+ <aspect pointcut="processActionForm">
+ <component class="org.seasar.struts.interceptors.ProcessPojoFormInterceptor"/>
+ </aspect>
+ </component>
+ -->
+ <!-- ZeroConfig Components -->
+ <component name="autoStrutsConfigRule" class="org.seasar.struts.config.AutoStrutsConfigRuleImpl"/>
+ <component name="zeroConfigActionRule" class="org.seasar.struts.config.rule.ZeroConfigActionRuleImpl"/>
+ <component name="zeroConfigActionFormRule" class="org.seasar.struts.config.rule.ZeroConfigActionFormRuleImpl"/>
+ <component name="dateConfigRegister" class="org.seasar.struts.validator.config.DateConfigRegisterImpl">
+ <property name="pattern">"yyyy/MM/dd"</property>
+ </component>
+ <component name="maskConfigRegister" class="org.seasar.struts.validator.config.MaskConfigRegisterImpl"/>
+ <component name="maxlengthConfigRegister" class="org.seasar.struts.validator.config.MaxlengthConfigRegisterImpl"/>
+ <component name="minlengthConfigRegister" class="org.seasar.struts.validator.config.MinlengthConfigRegisterImpl"/>
+ <component name="maxbytelengthConfigRegister" class="org.seasar.struts.validator.config.MaxbytelengthConfigRegisterImpl"/>
+ <component name="minbytelengthConfigRegister" class="org.seasar.struts.validator.config.MinbytelengthConfigRegisterImpl"/>
+ <component name="intRangeConfigRegister" class="org.seasar.struts.validator.config.IntRangeConfigRegisterImpl"/>
+ <component name="floatRangeConfigRegister" class="org.seasar.struts.validator.config.FloatRangeConfigRegisterImpl"/>
+ <component name="doubleRangeConfigRegister" class="org.seasar.struts.validator.config.DoubleRangeConfigRegisterImpl"/>
+ <component name="validatorFieldConfigRegister" class="org.seasar.struts.validator.config.ValidatorFieldConfigRegisterImpl"/>
+</components>
--- /dev/null
+org.apache.commons.logging.simplelog.defaultlog=info
+org.apache.commons.logging.simplelog.showdatetime=true
+org.apache.commons.logging.simplelog.dateTimeFormat=yyyy-MM-dd HH:mm:ss.SSS
--- /dev/null
+<?xml version="1.0" encoding="Shift_JIS"?>
+<!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN" "http://www.seasar.org/dtd/components21.dtd">
+<components>
+ <component class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister">
+ <property name="instanceDef">@org.seasar.framework.container.deployer.InstanceDefFactory@REQUEST</property>
+ <initMethod name="addClassPattern">
+ <arg>"jp.gr.java_conf.uguu.sysman.web.action"</arg>
+ <arg>".*Impl"</arg>
+ </initMethod>
+ </component>
+ <component name="scheduler" class="jp.gr.java_conf.uguu.scheduler.impl.ExecutorServiceScheduler" instance="singleton">
+ <arg>@java.util.concurrent.Executors@newCachedThreadPool()</arg>
+ </component>
+</components>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.sysman.web.constant;
+
+/**
+ * <p>
+ * サーブレット コンテキストに格納するインスタンスのキーを定義しています。
+ * </p>
+ * @author uguu
+ */
+public final class ServletContextConstant {
+ /**
+ * <p>スケジューラを格納するキー。</p>
+ */
+ public static final String SCHEDULER = "jp.gr.java_conf.uguu.sysman.web.scheduler";
+ /**
+ * <p>
+ * インスタンスの生成を禁止します。
+ * </p>
+ */
+ private ServletContextConstant() {
+ throw new UnsupportedOperationException();
+ }
+}
--- /dev/null
+<body>
+ <p>定数を定義するクラスが格納されています。</p>
+</body>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.sysman.web.filter;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * <p>
+ * リクエストの文字エンコーディングを設定するフィルタです。
+ * </p>
+ * @author uguu
+ */
+public class CharacterEncodingFilter implements Filter {
+ /**
+ * <p>リクエストに設定する文字エンコーディング。</p>
+ */
+ private String encoding;
+ /**
+ * <p>
+ * 何もしません。
+ * </p>
+ */
+ public void destroy() {
+ // 何もしません。
+ }
+ /**
+ * <p>
+ * リクエストに文字エンコーディングを設定します。
+ * </p>
+ * @param request リクエスト。
+ * @param response レスポンス。
+ * @param chain フィルタ チェイン。
+ * @throws IOException 入出力に失敗した場合。
+ * @throws ServletException サーブレットの処理に失敗した場合。
+ */
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+ if (this.encoding != null) {
+ request.setCharacterEncoding(this.encoding);
+ }
+ chain.doFilter(request, response);
+ }
+ /**
+ * <p>
+ * フィルタ設定を取得します。
+ * </p>
+ * @param config フィルタ設定。
+ */
+ public void init(FilterConfig config) {
+ this.encoding = config.getInitParameter("encoding");
+ }
+}
--- /dev/null
+<body>
+ <p>フィルタが格納されています。</p>
+</body>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.sysman.web.listener;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.concurrent.Executors;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import jp.gr.java_conf.uguu.scheduler.Scheduler;
+import jp.gr.java_conf.uguu.scheduler.impl.ExecutorServiceScheduler;
+import jp.gr.java_conf.uguu.scheduler.impl.TraceScheduleListener;
+import jp.gr.java_conf.uguu.scheduler.impl.TraceSchedulerListener;
+import jp.gr.java_conf.uguu.scheduler_persistence.PersistenceDao;
+import jp.gr.java_conf.uguu.scheduler_persistence.PersistenceScheduleListener;
+import jp.gr.java_conf.uguu.scheduler_persistence.PersistenceSchedulerListener;
+import jp.gr.java_conf.uguu.scheduler_persistence.PersistenceTaskListener;
+import jp.gr.java_conf.uguu.sysman.web.constant.ServletContextConstant;
+
+/**
+ * <p>
+ * スケジューラの起動、停止を行うリスナです。
+ * </p>
+ * @author uguu
+ */
+public class SchedulerListener implements ServletContextListener {
+ /**
+ * <p>
+ * スケジューラを起動します。
+ * </p>
+ * @param event イベント情報。
+ */
+ public void contextInitialized(ServletContextEvent event) {
+ ServletContext ctx = event.getServletContext();
+ // スケジューラを開始します。
+ Scheduler scheduler = new ExecutorServiceScheduler(Executors.newCachedThreadPool());
+ PersistenceDao persistenceDao = new PersistenceDao();
+ try {
+ persistenceDao.load(scheduler);
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ scheduler.getListeners().add(new PersistenceSchedulerListener(persistenceDao));
+ scheduler.getListeners().add(new PersistenceScheduleListener(persistenceDao));
+ scheduler.getListeners().add(new PersistenceTaskListener(persistenceDao));
+ scheduler.getListeners().add(new TraceSchedulerListener());
+ scheduler.getListeners().add(new TraceScheduleListener());
+ scheduler.start();
+ ctx.setAttribute(ServletContextConstant.SCHEDULER, scheduler);
+ }
+ /**
+ * <p>
+ * スケジューラを停止します。
+ * </p>
+ * @param event イベント情報。
+ */
+ public void contextDestroyed(ServletContextEvent event) {
+ ServletContext ctx = event.getServletContext();
+ // スケジューラを停止します。
+ Scheduler scheduler = (Scheduler) ctx.getAttribute(ServletContextConstant.SCHEDULER);
+ scheduler.stop();
+ }
+}
--- /dev/null
+<body>
+ <p>リスナが格納されています。</p>
+</body>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.sysman.web.servlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import jp.gr.java_conf.uguu.scheduler.Scheduler;
+import jp.gr.java_conf.uguu.sysman.web.constant.ServletContextConstant;
+
+/**
+ * <p>
+ * 空のスケジュールを追加します。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public final class AddScheduleServlet extends BaseServlet {
+ /**
+ * <p>
+ * スケジュールを追加します。
+ * </p>
+ * @param request HTTP リクエスト。
+ * @param response HTTP レスポンス。
+ * @throws Exception 処理に失敗した場合。
+ * @throws IllegalArgumentException scheduleName パラメータが null または空文字列の場合。
+ */
+ @Override
+ protected void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ String scheduleName = request.getParameter("scheduleName");
+ if (scheduleName == null || "".equals(scheduleName)) {
+ throw new IllegalArgumentException("追加するスケジュールの名前を入力してください。");
+ }
+ ServletContext ctx = this.getServletContext();
+ Scheduler scheduler = (Scheduler) ctx.getAttribute(ServletContextConstant.SCHEDULER);
+ scheduler.getSchedules().create(scheduleName);
+ request.getRequestDispatcher("/page/addSchedule.jsp").forward(request, response);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.sysman.web.servlet;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * <p>
+ * サーブレットの基底抽象クラスです。
+ * GET, POST リクエストを受け取り、 {@link #execute(HttpServletRequest, HttpServletResponse)} メソッドを呼び出します。
+ * {@link #execute(HttpServletRequest, HttpServletResponse)} メソッドでは {@link java.lang.Exception} 例外をスローすることが出来ますが、全ての {@link java.lang.Exception} 例外は {@link javax.servlet.ServletException} 例外としてスローされます。
+ * </p>
+ * @author uguu
+ */
+public abstract class BaseServlet extends HttpServlet {
+ /**
+ * <p>
+ * GET, POST リクエストを処理します。
+ * </p>
+ * @param request HTTP リクエスト。
+ * @param response HTTP レスポンス。
+ * @throws Exception 処理に失敗した場合。
+ */
+ protected abstract void execute(HttpServletRequest request, HttpServletResponse response) throws Exception;
+ /**
+ * <p>
+ * GET リクエストを受け取り、 {@link #execute(HttpServletRequest, HttpServletResponse)} メソッドを呼び出します。
+ * </p>
+ * @param request HTTP リクエスト。
+ * @param response HTTP レスポンス。
+ * @throws ServletException サーブレットの処理に失敗した場合。
+ */
+ @Override
+ protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
+ try {
+ this.execute(request, response);
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+ /**
+ * <p>
+ * POST リクエストを受け取り、 {@link #execute(HttpServletRequest, HttpServletResponse)} メソッドを呼び出します。
+ * </p>
+ * @param request HTTP リクエスト。
+ * @param response HTTP レスポンス。
+ * @throws ServletException サーブレットの処理に失敗した場合。
+ */
+ @Override
+ protected final void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
+ try {
+ this.execute(request, response);
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+}
--- /dev/null
+package jp.gr.java_conf.uguu.sysman.web.servlet;
+
+public class ScheduleDetailServlet {
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.sysman.web.servlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import jp.gr.java_conf.uguu.scheduler.Schedule;
+import jp.gr.java_conf.uguu.scheduler.Scheduler;
+import jp.gr.java_conf.uguu.sysman.web.constant.ServletContextConstant;
+
+/**
+ * <p>
+ * スケジュールのリストをリクエストとして返します。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public final class ScheduleListServlet extends BaseServlet {
+ /**
+ * <p>
+ * スケジュールのリストをリクエストに埋め込みます。
+ * </p>
+ * @param request HTTP リクエスト。
+ * @param response HTTP レスポンス。
+ * @throws Exception 処理に失敗した場合。
+ */
+ @Override
+ protected void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ ServletContext ctx = this.getServletContext();
+ Scheduler scheduler = (Scheduler) ctx.getAttribute(ServletContextConstant.SCHEDULER);
+ Schedule[] schedules = scheduler.getSchedules().getAll();
+ request.setAttribute("schedules", schedules);
+ request.getRequestDispatcher("/page/scheduleList.jsp").forward(request, response);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package jp.gr.java_conf.uguu.sysman.web.servlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import jp.gr.java_conf.uguu.scheduler.Scheduler;
+import jp.gr.java_conf.uguu.sysman.web.constant.ServletContextConstant;
+
+/**
+ * <p>
+ * スケジュールを削除します。
+ * </p>
+ * @author uguu
+ */
+@SuppressWarnings("serial")
+public final class ScheduleRemoveServlet extends BaseServlet {
+ /**
+ * <p>
+ * スケジュールを削除します。
+ * </p>
+ * @param request HTTP リクエスト。
+ * @param response HTTP レスポンス。
+ * @throws Exception 処理に失敗した場合。
+ */
+ @Override
+ protected void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ String scheduleName = request.getParameter("scheduleName");
+ if (scheduleName == null || "".equals(scheduleName)) {
+ throw new IllegalArgumentException("削除するスケジュールの名前を入力してください。");
+ }
+ ServletContext ctx = this.getServletContext();
+ Scheduler scheduler = (Scheduler) ctx.getAttribute(ServletContextConstant.SCHEDULER);
+ scheduler.getSchedules().remove(scheduleName);
+ request.getRequestDispatcher("/page/scheduleRemove.jsp").forward(request, response);
+ }
+}
--- /dev/null
+package jp.gr.java_conf.uguu.sysman.web.servlet;
+
+public class ScheduleUpdateServlet {
+
+}
--- /dev/null
+<body>
+ <p>サーブレットが格納されています。</p>
+</body>
\ No newline at end of file
--- /dev/null
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
+<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
+<%@ taglib uri="http://struts.apache.org/tags-html-el" prefix="html-el" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html:html lang="true">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <link href="css/uguu-sysman.css" rel="stylesheet" type="text/css">
+ <title>SysMan - スケジュールの詳細</title>
+ </head>
+ <body>
+ <div class="header">
+ <h1>SysMan - スケジュールの詳細</h1>
+ </div>
+ <div class="menu">
+ <h2>メニュー</h2>
+ <ul>
+ <li><html:link action="/schedule_list">スケジュールのリスト</html:link></li>
+ </ul>
+ </div>
+ <div class="body">
+ <div class="message">
+ <ul>
+ <c:forEach items="${messages}" var="message">
+ <li><span class="errorMessage"><c:out value="${message}"/></span></li>
+ </c:forEach>
+ </ul>
+ </div>
+ <html:form action="/schedule_detail">
+ <p>名前: <c:out value="${name}"/><input type="hidden" name="name" value="${name}"></p>
+ <p>
+ 有効:
+ <c:choose>
+ <c:when test="${enable == 'true'}">
+ <input type="checkbox" name="enable" value="true" checked>
+ </c:when>
+ <c:otherwise>
+ <input type="checkbox" name="enable" value="true">
+ </c:otherwise>
+ </c:choose>
+ </p>
+ <p>
+ タスク:
+ <div class="task.backup">
+ <c:choose>
+ <c:when test="${taskType == 'backup'}">
+ <input type="radio" name="taskType" value="backup" checked>バックアップ
+ </c:when>
+ <c:otherwise>
+ <input type="radio" name="taskType" value="backup">バックアップ
+ </c:otherwise>
+ </c:choose>
+ <p>バックアップ元: <input type="text" name="backupSource" value="${backupSource}"></p>
+ <p>バックアップ先: <input type="text" name="backupDestination" value="${backupDestination}"></p>
+ </div>
+ <div class="task.http-test">
+ <c:choose>
+ <c:when test="${taskType == 'http-test'}">
+ <input type="radio" name="taskType" value="http-test" checked>HTTP 接続試験
+ </c:when>
+ <c:otherwise>
+ <input type="radio" name="taskType" value="http-test">HTTP 接続試験
+ </c:otherwise>
+ </c:choose>
+ <p>接続先 URL: <input type="text" name="httpTestUrl" value="${httpTestUrl}"}></p>
+ <p>プロキシ ホスト: <input type="text" name="httpTestProxyHost" value="${httpTestProxyHost}"></p>
+ <p>プロキシ ポート: <input type="text" name="httpTestProxyPort" value="${httpTestProxyPort}"></p>
+ </div>
+ <div class="task.jdbc-test">
+ <c:choose>
+ <c:when test="${taskType == 'jdbc-test'}">
+ <input type="radio" name="taskType" value="jdbc-test" checked>JDBC 接続試験
+ </c:when>
+ <c:otherwise>
+ <input type="radio" name="taskType" value="jdbc-test">JDBC 接続試験
+ </c:otherwise>
+ </c:choose>
+ <p>JDBC ドライバ クラス名: <input type="text" name="jdbcTestClassName" value="${jdbcTestClassName}"></p>
+ <p>接続先 URL: <input type="text" name="jdbcTestUrl" value="${jdbcTestUrl}"></p>
+ <p>ユーザ名: <input type="text" name="jdbcTestUser" value="${jdbcTestUser}"></p>
+ <p>パスワード: <input type="text" name="jdbcTestPassword" value="${jdbcTestPassword}"></p>
+ </div>
+ <div class="task.ping">
+ <c:choose>
+ <c:when test="${taskType == 'ping'}">
+ <input type="radio" name="taskType" value="ping" checked>Ping 試験
+ </c:when>
+ <c:otherwise>
+ <input type="radio" name="taskType" value="ping">Ping 試験
+ </c:otherwise>
+ </c:choose>
+ <p>接続先ホスト: <input type="text" name="pingHost"></p>
+ </div>
+ </p>
+ <p>
+ トリガー:
+ 年 <input type="text" name="triggerYear">
+ 月 <input type="text" name="triggerMonth">
+ 日 <input type="text" name="triggerDay">
+ 時 <input type="text" name="triggerHour">
+ 分 <input type="text" name="triggerMinute">
+ 秒 <input type="text" name="triggerSecond">
+ </p>
+ <p>
+ <input type="hidden" name="command" value="update">
+ <input type="submit" value="変更">
+ </p>
+ </html:form>
+ </div>
+ <div class="footer">
+ <p>Copyright (C) 2005 uguu, All Rights Reserved.</p>
+ </div>
+ </body>
+</html:html>
--- /dev/null
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <link href="css/uguu-sysman.css" rel="stylesheet" type="text/css">
+ <title>SysMan - スケジュールのリスト</title>
+ </head>
+ <body>
+ <div class="header">
+ <h1>SysMan - スケジュールのリスト</h1>
+ </div>
+ <div class="menu">
+ <h2>メニュー</h2>
+ <ul>
+ <li><a href="<c:url value="/schedule_list.do"/>">再表示</a></li>
+ <li>スケジュール
+ <ul>
+ <c:forEach items="${schedules}" var="schedule">
+ <li><a href="#${schedule.name}"><c:out value="${schedule.name}"/></a></li>
+ </c:forEach>
+ <li><form name="add_schedule" action="<c:url value="/add_schedule.do"/>"><input type="text" name="name"><a href="javascript:document.add_schedule.submit()">新規のスケジュールの追加</a></form></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+ <div class="body">
+ <div class="message">
+ <ul>
+ <c:forEach items="${messages}" var="message">
+ <li><span class="errorMessage"><c:out value="${message}"/></span></li>
+ </c:forEach>
+ </ul>
+ </div>
+ <c:forEach items="${schedules}" var="schedule">
+ <div class="schedule">
+ <h2>スケジュール: <a name="${schedule.name}"><c:out value="${schedule.name}"/></a></h2>
+ <a href="<c:url value="/schedule_detail.do">
+ <c:param name="command" value="view"/>
+ <c:param name="name" value="${schedule.name}"/>
+ </c:url>">編集</a>
+ <a href="<c:url value="/schedule_remove.do">
+ <c:param name="name" value="${schedule.name}"/>
+ </c:url>"
+ onclick="return confirm('スケジュール「${schedule.name}」を削除してもよろしいですか?')">削除</a>
+ <c:choose>
+ <c:when test="${fn:length(schedule.taskFutures.all) != 0}">
+ <table>
+ <tr>
+ <th>開始時刻</th>
+ <th>終了時刻</th>
+ <th>状態</th>
+ </tr>
+ <c:forEach items="${schedule.taskFutures.all}" var="taskFuture" begin="0" end="9" step="1" varStatus="lineNumber">
+ <c:choose>
+ <c:when test="${lineNumber.count mod 2 == 0}">
+ <tr>
+ <td class="even"><fmt:formatDate value="${taskFuture.startTime.time}" pattern="yyyy/MM/dd HH:mm:ss"/></td>
+ <td class="even"><fmt:formatDate value="${taskFuture.endTime.time}" pattern="yyyy/MM/dd HH:mm:ss"/></td>
+ <td class="even"><c:out value="${taskFuture.status}"/></td>
+ </tr>
+ </c:when>
+ <c:otherwise>
+ <tr>
+ <td class="odd"><fmt:formatDate value="${taskFuture.startTime.time}" pattern="yyyy/MM/dd HH:mm:ss"/></td>
+ <td class="odd"><fmt:formatDate value="${taskFuture.endTime.time}" pattern="yyyy/MM/dd HH:mm:ss"/></td>
+ <td class="odd"><c:out value="${taskFuture.status}"/></td>
+ </tr>
+ </c:otherwise>
+ </c:choose>
+ </c:forEach>
+ <c:if test="${fn:length(schedule.taskFutures.all) > 10}">
+ <tr>
+ <td colspan="3" align="right">...more</td>
+ </tr>
+ </c:if>
+ </table>
+ </c:when>
+ <c:otherwise>
+ <p>まだ実行されていません。</p>
+ </c:otherwise>
+ </c:choose>
+ </div>
+ </c:forEach>
+ </div>
+ <div class="footer">
+ <p>Copyright (C) 2005 uguu, All Rights Reserved.</p>
+ </div>
+ </body>
+</html>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
+<struts-config>
+ <!-- ======================================== Form Bean Definitions -->
+ <form-beans>
+ <form-bean
+ name="dummyForm"
+ type="org.apache.struts.action.DynaActionForm"
+ />
+ </form-beans>
+ <!-- ================================= Global Exception Definitions -->
+ <global-exceptions>
+ </global-exceptions>
+ <!-- =================================== Global Forward Definitions -->
+ <global-forwards>
+ </global-forwards>
+ <!-- =================================== Action Mapping Definitions -->
+ <action-mappings>
+ <action
+ path="/schedule_list"
+ type="jp.gr.java_conf.uguu.sysman.web.action.ScheduleListAction"
+ scope="request"
+ name="dummyForm"
+ >
+ <forward
+ name="success"
+ path="/WEB-INF/page/schedule_list.jsp"
+ />
+ </action>
+ <action
+ path="/add_schedule"
+ type="jp.gr.java_conf.uguu.sysman.web.action.AddScheduleAction"
+ scope="request"
+ name="dummyForm"
+ >
+ <forward
+ name="success"
+ path="/schedule_detail.do?command=view"
+ />
+ <forward
+ name="error"
+ path="/schedule_list.do"
+ />
+ </action>
+ <action
+ path="/schedule_detail"
+ type="jp.gr.java_conf.uguu.sysman.web.action.ScheduleDetailAction"
+ scope="request"
+ name="dummyForm"
+ parameter="command"
+ >
+ <forward
+ name="view_success"
+ path="/WEB-INF/page/schedule_detail.jsp"
+ />
+ <forward
+ name="view_error"
+ path="/schedule_list.do"
+ />
+ <forward
+ name="update_success"
+ path="/schedule_list.do"
+ />
+ <forward
+ name="update_error"
+ path="/WEB-INF/page/schedule_detail.jsp"
+ />
+ </action>
+ <action
+ path="/schedule_remove"
+ type="jp.gr.java_conf.uguu.sysman.web.action.ScheduleRemoveAction"
+ scope="request"
+ name="dummyForm"
+ >
+ <forward
+ name="success"
+ path="/schedule_list.do"
+ />
+ </action>
+ </action-mappings>
+ <!-- ===================================== Controller Configuration -->
+ <controller processorClass="org.seasar.struts.processor.S2RequestProcessor"/>
+ <!-- ================================ Message Resources Definitions -->
+ <message-resources parameter="message"/>
+ <!-- ======================================= Plug Ins Configuration -->
+ <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
+ <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
+ </plug-in>
+ <plug-in className="org.seasar.struts.plugin.AutoStrutsConfigRegisterPlugIn">
+ <set-property property="enableJar" value="false"/>
+ <set-property property="actionClassPattern" value="jp.gr.java_conf.uguu.sysman.web.action.*Action"/>
+ <set-property property="formClassPattern" value="jp.gr.java_conf.uguu.sysman.web.action.*Dto"/>
+ <set-property property="docRoot" value="/"/>
+ <set-property property="viewExtension" value="jsp,html"/>
+ </plug-in>
+</struts-config>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
+<tiles-definitions>
+ <definition name="${YOUR_DEFINITION_HERE}">
+ </definition>
+</tiles-definitions>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN" "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
+<form-validation>
+ <!--
+ This is a minimal Validator form file with a couple of examples.
+ -->
+ <global>
+ <!-- An example global constant
+ <constant>
+ <constant-name>postalCode</constant-name>
+ <constant-value>^\d{5}\d*$</constant-value>
+ </constant>
+ end example-->
+ </global>
+ <formset>
+ <!-- An example form -->
+ <form name="logonForm">
+ <field property="username" depends="required">
+ <arg key="logonForm.username"/>
+ </field>
+ <field property="password" depends="required,mask">
+ <arg key="logonForm.password"/>
+ <var>
+ <var-name>mask</var-name>
+ <var-value>^[0-9a-zA-Z]*$</var-value>
+ </var>
+ </field>
+ </form>
+ </formset>
+ <!-- An example formset for another locale -->
+ <formset language="fr">
+ <constant>
+ <constant-name>postalCode</constant-name>
+ <constant-value>^[0-9a-zA-Z]*$</constant-value>
+ </constant>
+ <!-- An example form -->
+ <form name="logonForm">
+ <field property="username" depends="required">
+ <arg key="logonForm.username"/>
+ </field>
+ <field property="password" depends="required,mask">
+ <arg key="logonForm.password"/>
+ <var>
+ <var-name>mask</var-name>
+ <var-value>^[0-9a-zA-Z]*$</var-value>
+ </var>
+ </field>
+ </form>
+ </formset>
+</form-validation>
--- /dev/null
+<!DOCTYPE form-validation PUBLIC
+ "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
+ "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
+<!--
+
+ This file contains the default Struts Validator pluggable validator
+ definitions. It should be placed somewhere under /WEB-INF and
+ referenced in the struts-config.xml under the plug-in element
+ for the ValidatorPlugIn.
+
+ <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
+ <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
+ /WEB-INF/validation.xml"/>
+ </plug-in>
+
+ These are the default error messages associated with
+ each validator defined in this file. They should be
+ added to your projects ApplicationResources.properties
+ file or you can associate new ones by modifying the
+ pluggable validators msg attributes in this file.
+
+ # Struts Validator Error Messages
+ errors.required={0} is required.
+ errors.minlength={0} can not be less than {1} characters.
+ errors.maxlength={0} can not be greater than {1} characters.
+ errors.invalid={0} is invalid.
+
+ errors.byte={0} must be a byte.
+ errors.short={0} must be a short.
+ errors.integer={0} must be an integer.
+ errors.long={0} must be a long.
+ errors.float={0} must be a float.
+ errors.double={0} must be a double.
+
+ errors.date={0} is not a date.
+ errors.range={0} is not in the range {1} through {2}.
+ errors.creditcard={0} is an invalid credit card number.
+ errors.email={0} is an invalid e-mail address.
+ errors.url={0} is an invalid url (web address).
+
+ errors.minbytelength={0} can not be less than {1} bytes.
+ errors.maxbytelength={0} can not be greater than {1} bytes.
+
+ Note: Starting in Struts 1.2.0 the default javascript definitions have
+ been consolidated to commons-validator. The default can be overridden
+ by supplying a <javascript> element with a CDATA section, just as
+ in struts 1.1.
+
+-->
+
+<form-validation>
+
+ <global>
+
+ <validator name="required"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateRequired"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ msg="errors.required"/>
+
+ <validator name="requiredif"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateRequiredIf"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ msg="errors.required"/>
+
+ <validator name="validwhen"
+ msg="errors.required"
+ classname="org.apache.struts.validator.validwhen.ValidWhen"
+ method="validateValidWhen"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"/>
+
+
+ <validator name="minlength"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateMinLength"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.minlength"
+ jsFunction="org.apache.commons.validator.javascript.validateMinLength"/>
+
+
+ <validator name="maxlength"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateMaxLength"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.maxlength"
+ jsFunction="org.apache.commons.validator.javascript.validateMaxLength"/>
+
+
+
+ <validator name="mask"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateMask"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.invalid"/>
+
+
+ <validator name="byte"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateByte"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.byte"
+ jsFunctionName="ByteValidations"/>
+
+
+ <validator name="short"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateShort"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.short"
+ jsFunctionName="ShortValidations"/>
+
+
+ <validator name="integer"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateInteger"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.integer"
+ jsFunctionName="IntegerValidations"/>
+
+
+
+ <validator name="long"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateLong"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.long"/>
+
+
+ <validator name="float"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateFloat"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.float"
+ jsFunctionName="FloatValidations"/>
+
+ <validator name="double"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateDouble"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.double"/>
+
+
+ <validator name="date"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateDate"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.date"
+ jsFunctionName="DateValidations"/>
+
+
+ <validator name="intRange"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateIntRange"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends="integer"
+ msg="errors.range"/>
+
+
+ <validator name="floatRange"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateFloatRange"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends="float"
+ msg="errors.range"/>
+
+ <validator name="doubleRange"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateDoubleRange"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends="double"
+ msg="errors.range"/>
+
+ <validator name="creditCard"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateCreditCard"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.creditcard"/>
+
+
+ <validator name="email"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateEmail"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.email"/>
+
+ <validator name="url"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateUrl"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.url"/>
+
+ <validator name="minbytelength"
+ classname="org.seasar.struts.validator.FieldChecks"
+ method="validateMinByteLength"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.minbytelength"/>
+
+
+ <validator name="maxbytelength"
+ classname="org.seasar.struts.validator.FieldChecks"
+ method="validateMaxByteLength"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.maxbytelength"/>
+
+ <!--
+ This simply allows struts to include the validateUtilities into a page, it should
+ not be used as a validation rule.
+ -->
+ <validator name="includeJavaScriptUtilities"
+ classname=""
+ method=""
+ methodParams=""
+ depends=""
+ msg=""
+ jsFunction="org.apache.commons.validator.javascript.validateUtilities"/>
+
+ </global>
+
+</form-validation>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>SysMan Web UI</display-name>
+ <!-- -->
+ <!-- Listener -->
+ <!-- -->
+ <listener>
+ <listener-class>jp.gr.java_conf.uguu.sysman.web.listener.SchedulerListener</listener-class>
+ </listener>
+ <!-- -->
+ <!-- Filter -->
+ <!-- -->
+ <filter>
+ <filter-name>characterEncodingFilter</filter-name>
+ <filter-class>jp.gr.java_conf.uguu.sysman.web.filter.CharacterEncodingFilter</filter-class>
+ <init-param>
+ <param-name>encoding</param-name>
+ <param-value>UTF-8</param-value>
+ </init-param>
+ </filter>
+ <filter-mapping>
+ <filter-name>characterEncodingFilter</filter-name>
+ <url-pattern>*</url-pattern>
+ </filter-mapping>
+ <!-- -->
+ <!-- Servlet -->
+ <!-- -->
+ <!-- Struts -->
+ <servlet>
+ <servlet-name>action</servlet-name>
+ <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
+ <init-param>
+ <param-name>config</param-name>
+ <param-value>/WEB-INF/struts-config.xml</param-value>
+ </init-param>
+ <init-param>
+ <param-name>debug</param-name>
+ <param-value>2</param-value>
+ </init-param>
+ <init-param>
+ <param-name>detail</param-name>
+ <param-value>2</param-value>
+ </init-param>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>action</servlet-name>
+ <url-pattern>*.do</url-pattern>
+ </servlet-mapping>
+ <!-- -->
+ <!-- Welcome File List -->
+ <!-- -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+</web-app>
--- /dev/null
+h1, h2, h3, h4, h5, h6 {
+ border-bottom: 1px solid gray;
+}
+th {
+ background: silver;
+}
+td.odd {
+ background: #E6E6E6;
+}
+td.even {
+ background: #F5F5F5;
+}
+div.footer {
+ border-top: 1px solid gray;
+}
--- /dev/null
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
+<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
+<logic:redirect action="/schedule_list" />
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><fileset-config file-format-version="1.1.0" simple-config="false">
+<fileset name="src" enabled="true" check-config-name="Uguu Checks" type="remote" location="http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml" description="Uguu Software のコーディング スタイルです。"><file-match-pattern match-pattern="src\\java" include-pattern="true"/>
+</fileset>
+</fileset-config>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/conf"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-backup/jars/uguu-backup-0.1.0.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-http-test/jars/uguu-http-test-0.1.1.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-jdbc-test/jars/uguu-jdbc-test-0.1.0.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-ping/jars/uguu-ping-0.0.2.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-0.1.3.jar"/>
+ <classpathentry kind="var" path="MAVEN_REPO/uguu-scheduler/jars/uguu-scheduler-impl-0.1.0.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+.fbwarnings
+target
+work
+xdocs
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>uguu-sysman</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.mevenide.ui.mavenbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.mevenide.ui.mavennature</nature>
+ <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/*
+ * Copyright (C) 2005 uguu, All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact clarkware@clarkware.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <pomVersion>3</pomVersion>
+ <organization>
+ <name>Uguu Software</name>
+ <url>http://wiki.livedoor.jp/uguuxp/</url>
+ <logo>http://image02.wiki.livedoor.jp/u/p/uguuxp/82487bf1fed6e9af.png</logo>
+ </organization>
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <unitTest>
+ <resources>
+ <resource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </unitTest>
+ <resources>
+ <resource>
+ <directory>src/conf</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports>
+<!--
+ <report>maven-changelog-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-checkstyle-plugin</report>
+-->
+ <report>maven-linkcheck-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-faq-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jcoverage-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-pmd-plugin</report>
+ <report>maven-simian-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
--- /dev/null
+maven.compile.debug=true
+maven.compile.encoding=utf-8
+maven.compile.source=1.5
+
+maven.docs.outputencoding=utf-8
+
+maven.checkstyle.check.tests=false
+maven.checkstyle.header.file=${basedir}/LICENSE.txt
+maven.checkstyle.propertiesURL=http://uguu-sysman.sourceforge.jp/checkstyle/uguu.checkstyle.xml
+
+maven.test.failure.ignore=true
+
+maven.xdoc.date=right
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.distributionUrl=http://uguu-sysman.sourceforge.jp/maven/uguu-http-test/jars
+maven.xdoc.distributionType=jar
+
+maven.repo.remote=http://www.ibiblio.org/maven/,http://uguu-sysman.sourceforge.jp/maven/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <extend>${basedir}/project-base.xml</extend>
+ <artifactId>sysman</artifactId>
+ <name>sysman</name>
+ <groupId>uguu</groupId>
+ <currentVersion>0.0.0</currentVersion>
+ <inceptionYear>2005</inceptionYear>
+ <package>jp.gr.java_conf.uguu.sysman</package>
+ <description>システムの監視、運用を行うツールです。</description>
+ <repository>
+ <connection>scm:cvs:pserver:anonymous@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-sysman</connection>
+ <developerConnection>scm:cvs:ext:uguu@cvs.sourceforge.jp:/cvsroot/uguu-sysman:uguu-sysman</developerConnection>
+ <url>http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/uguu-sysman/uguu-sysman/</url>
+ </repository>
+ <developers>
+ <developer>
+ <name>uguu</name>
+ <id>2</id>
+ <email>uguu@users.sourceforge.jp</email>
+ <organization>Uguu Software</organization>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>BSD License</name>
+ </license>
+ </licenses>
+ <dependencies>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler</artifactId>
+ <version>0.1.4</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>uguu-scheduler</groupId>
+ <artifactId>uguu-scheduler-impl</artifactId>
+ <version>0.1.1</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>uguu-http-test</groupId>
+ <artifactId>uguu-http-test</artifactId>
+ <version>0.1.2</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>uguu-jdbc-test</groupId>
+ <artifactId>uguu-jdbc-test</artifactId>
+ <version>0.1.1</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>uguu-ping</groupId>
+ <artifactId>uguu-ping</artifactId>
+ <version>0.0.3</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>uguu-backup</groupId>
+ <artifactId>uguu-backup</artifactId>
+ <version>0.1.2</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
--- /dev/null
+org.apache.commons.logging.simplelog.defaultlog=debug
+org.apache.commons.logging.simplelog.showdatetime=true
+org.apache.commons.logging.simplelog.dateTimeFormat=yyyy-MM-dd HH:mm:ss.SSS