You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by as...@apache.org on 2004/10/14 09:17:21 UTC
svn commit: rev 54776 - in webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement: FileLoder Scheduler test
Author: aslom
Date: Thu Oct 14 00:17:20 2004
New Revision: 54776
Modified:
webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/FileLoder/FileWriter.java
webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/FileLoder/FilesLoader.java
webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/Scheduler/SchedulerTask.java
webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/test/HotDeployementTest.java
Log:
applied Deepal patch
Modified: webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/FileLoder/FileWriter.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/FileLoder/FileWriter.java (original)
+++ webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/FileLoder/FileWriter.java Thu Oct 14 00:17:20 2004
@@ -1,55 +1,59 @@
-package org.apache.axis.deployement.FileLoder;
-
-import java.util.Vector;
-import java.io.PrintStream;
-import java.io.FileOutputStream;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @author Deepal Jayasinghe
- * Oct 5, 2004
- * 2:55:31 PM
- *
- */
-public class FileWriter {
-
- private String filename = "./resource/Deploye.txt";
- public void writeToFile(Vector invect){
- {
- FileOutputStream out; // declare a file output object
- PrintStream p; // declare a print stream object
- try
- {
- // Create a new file output stream
- out = new FileOutputStream(filename);
- p = new PrintStream( out );
- int size = invect.size();
- String tempnaem;
- for (int i = 0; i < size; i++) {
- tempnaem = (String) invect.get(i);
- p.println(tempnaem);
- }
- p.close();
- }
- catch (Exception e)
- {
- System.err.println ("Error writing to file");
- }
- }
-
- }
-
-}
+package org.apache.axis.deployement.FileLoder;
+
+import org.apache.axis.deployement.FileLoder.utill.FileList;
+import org.apache.axis.deployement.FileLoder.utill.FileItem;
+
+import java.util.Vector;
+import java.io.PrintStream;
+import java.io.FileOutputStream;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Deepal Jayasinghe
+ * Oct 5, 2004
+ * 2:55:31 PM
+ *
+ */
+public class FileWriter {
+
+ private String filename = "./resource/Deploye.txt";
+ public void writeToFile(){
+ {
+ FileOutputStream out; // declare a file output object
+ PrintStream p; // declare a print stream object
+ try
+ {
+ // Create a new file output stream
+ out = new FileOutputStream(filename);
+ p = new PrintStream( out );
+ Vector invect = FileList.getJarlist();
+ int size = invect.size();
+ FileItem tempnaem;
+ for (int i = 0; i < size; i++) {
+ tempnaem = (FileItem) invect.get(i);
+ p.println(tempnaem.getFilename());
+ }
+ p.close();
+ }
+ catch (Exception e)
+ {
+ System.err.println ("Error writing to file");
+ }
+ }
+
+ }
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/FileLoder/FilesLoader.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/FileLoder/FilesLoader.java (original)
+++ webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/FileLoder/FilesLoader.java Thu Oct 14 00:17:20 2004
@@ -1,123 +1,85 @@
-package org.apache.axis.deployement.FileLoder;
-
-import org.apache.axis.deployement.FileLoder.utill.UnZipJAR;
-
-import java.util.Vector;
-import java.util.Date;
-import java.io.File;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @author Deepal Jayasinghe
- * Oct 5, 2004
- * 11:31:48 AM
- *
- */
-public class FilesLoader {
- /**
- * This is to store all the jar files in a specified folder (WEB_INF)
- */
- private static Vector jarlist = new Vector();
-
- private String foldername="D:/Axis 2.0/projects/Deployement/test-data/" ;
-
- public void searchFolder(){
- String files[];
- Vector currentjars = new Vector();
- File root = new File(foldername);
- // adding the root folder to the vector
- currentjars.addElement(root);
-
- while (currentjars.size() > 0) { // loop until empty
- File dir = (File)currentjars.elementAt(0); // get first dir
- currentjars.remove(0); // remove it
- files = dir.list(); // get list of files
-
- for (int i = 0; i < files.length; i++) { // iterate
- File f = new File(dir, files[i]);
- if (f.isDirectory()) { // see if it's a directory
- currentjars.insertElementAt(f, 0);
- } // add dir to start of agenda
- else if (! FilesLoader.isFileExist(f.getName())){
- addNewWS(f);
- }
- }
- }
- }
-
- public void init(){
- try{
- jarlist.removeAllElements();
- initDeployedWS();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
-
-
- private static void addNewWS(File file){
- String filename = file.getName();
- int size = jarlist.size();
- boolean exist = false;
-
- for (int i = 0; i < size; i++) {
- String s = (String) jarlist.elementAt(i);
- if(s.equals(filename)){
- exist = true;
- break;
- }
- }
-
- if(! exist){
- jarlist.add(filename) ;
- FileWriter writer = new FileWriter();
- writer.writeToFile(jarlist);
- //todo write a triger
- System.out.println("New Web service is deployed "+ filename);
- }
- }
-
-
- private void initDeployedWS() {
- FileReader fileReader = new FileReader();
- Vector fiels = fileReader.getDeployedJars();
- int size = fiels.size();
- for (int i = 0; i < size-1; i++) {
- jarlist.add((String)fiels.get(i));
- }
- }
-
- private static boolean isFileExist(String filename) {
- // to check whether the file is a jar file
- if(! filename.endsWith(".jar")){
- return true;
- }
- int vetsize = jarlist.size();
- String file;
- for (int i = 0; i < vetsize - 1; i++) {
- file = (String) jarlist.get(i);
- if(file.equals(filename)){
- return true;
- }
-
- }
- return false;
- }
-}
-
-
-
+package org.apache.axis.deployement.FileLoder;
+
+import org.apache.axis.deployement.FileLoder.utill.UnZipJAR;
+import org.apache.axis.deployement.FileLoder.utill.FileList;
+import org.apache.axis.deployement.FileLoder.utill.FileItem;
+
+import java.util.Vector;
+import java.util.Date;
+import java.io.File;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Deepal Jayasinghe
+ * Oct 5, 2004
+ * 11:31:48 AM
+ *
+ */
+public class FilesLoader {
+ /**
+ * to store curreently checking jars
+ */
+ private Vector current_jars;
+
+ private FileList fileList;
+
+ private String foldername;
+
+ public FilesLoader(String foldername) {
+ this.foldername = foldername;
+ this.fileList = new FileList();
+ fileList.init();
+ }
+
+ public void searchFolder(){
+ String files[];
+ current_jars = new Vector();
+ File root = new File(foldername);
+ // adding the root folder to the vector
+ current_jars.addElement(root);
+
+ while (current_jars.size() > 0) { // loop until empty
+ File dir = (File)current_jars.elementAt(0); // get first dir
+ current_jars.remove(0); // remove it
+ files = dir.list(); // get list of files
+
+ for (int i = 0; i < files.length ; i++) { // iterate
+ File f = new File(dir, files[i]);
+ if (f.isDirectory()) { // see if it's a directory
+ current_jars.insertElementAt(f, 0);
+ } // add dir to start of agenda
+ else if (isJarFile(f.getName())){
+ FileItem fileItem = new FileItem(f,f.getName(),true);
+ fileList.addFile(fileItem);
+ }
+ }
+ }
+ fileList.update();
+ }
+
+ private boolean isJarFile(String filename) {
+ // to check whether the file is a jar file
+ if(! filename.endsWith(".jar")){
+ return false;
+ }else
+ return true;
+ }
+
+
+}
+
+
+
Modified: webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/Scheduler/SchedulerTask.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/Scheduler/SchedulerTask.java (original)
+++ webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/Scheduler/SchedulerTask.java Thu Oct 14 00:17:20 2004
@@ -1,92 +1,93 @@
-package org.apache.axis.deployement.Scheduler;
-
-import org.apache.axis.deployement.FileLoder.FilesLoader;
-
-import java.util.TimerTask;
-import java.util.Date;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @author Deepal Jayasinghe
- * Oct 5, 2004
- * 9:55:11 AM
- *
- */
-public class SchedulerTask implements Runnable {
- final Object lock = new Object();
-
- private FilesLoader filesLoader = new FilesLoader();
-
- int state = VIRGIN;
- static final int VIRGIN = 0;
- static final int SCHEDULED = 1;
- static final int CANCELLED = 2;
-
- TimerTask timerTask;
-
- /**
- * Creates a new scheduler task.
- */
-
- public SchedulerTask() {
- }
-
- /**
- * The action to be performed by this scheduler task.
- */
-
- public void run(){
- soundAlarm();
- }
-
- private void soundAlarm() {
- filesLoader.searchFolder();
- }
-
- /**
- * Cancels this scheduler task.
- * <p>
- * This method may be called repeatedly; the second and subsequent calls have no effect.
- * @return true if this task was already scheduled to run
- */
-
- public boolean cancel() {
- synchronized(lock) {
- if (timerTask != null) {
- timerTask.cancel();
- }
- boolean result = (state == SCHEDULED);
- state = CANCELLED;
- return result;
- }
- }
-
- /**
- * Returns the <i>scheduled</i> execution time of the most recent actual execution of this task.
- * (If this method is invoked while task execution is in progress, the return value is the
- * scheduled execution time of the ongoing task execution.)
- * @return the time at which the most recent execution of this task was scheduled to occur,
- * in the format returned by <code>Date.getTime()</code>. The return value is
- * undefined if the task has yet to commence its first execution.
- */
-
- public long scheduledExecutionTime() {
- synchronized(lock) {
- return timerTask == null ? 0 : timerTask.scheduledExecutionTime();
- }
- }
-
-}
+package org.apache.axis.deployement.Scheduler;
+
+import org.apache.axis.deployement.FileLoder.FilesLoader;
+
+import java.util.TimerTask;
+import java.util.Date;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Deepal Jayasinghe
+ * Oct 5, 2004
+ * 9:55:11 AM
+ *
+ */
+public class SchedulerTask implements Runnable {
+ final Object lock = new Object();
+
+ private String filename = "D:/Axis 2.0/projects/Deployement/test-data/" ;
+ private FilesLoader filesLoader = new FilesLoader(filename);
+
+ int state = VIRGIN;
+ static final int VIRGIN = 0;
+ static final int SCHEDULED = 1;
+ static final int CANCELLED = 2;
+
+ TimerTask timerTask;
+
+ /**
+ * Creates a new scheduler task.
+ */
+
+ public SchedulerTask() {
+ }
+
+ /**
+ * The action to be performed by this scheduler task.
+ */
+
+ public void run(){
+ soundAlarm();
+ }
+
+ private void soundAlarm() {
+ filesLoader.searchFolder();
+ }
+
+ /**
+ * Cancels this scheduler task.
+ * <p>
+ * This method may be called repeatedly; the second and subsequent calls have no effect.
+ * @return true if this task was already scheduled to run
+ */
+
+ public boolean cancel() {
+ synchronized(lock) {
+ if (timerTask != null) {
+ timerTask.cancel();
+ }
+ boolean result = (state == SCHEDULED);
+ state = CANCELLED;
+ return result;
+ }
+ }
+
+ /**
+ * Returns the <i>scheduled</i> execution time of the most recent actual execution of this task.
+ * (If this method is invoked while task execution is in progress, the return value is the
+ * scheduled execution time of the ongoing task execution.)
+ * @return the time at which the most recent execution of this task was scheduled to occur,
+ * in the format returned by <code>Date.getTime()</code>. The return value is
+ * undefined if the task has yet to commence its first execution.
+ */
+
+ public long scheduledExecutionTime() {
+ synchronized(lock) {
+ return timerTask == null ? 0 : timerTask.scheduledExecutionTime();
+ }
+ }
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/test/HotDeployementTest.java
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/test/HotDeployementTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/deepal/deployment/src/org/apache/axis/deployement/test/HotDeployementTest.java Thu Oct 14 00:17:20 2004
@@ -1,52 +1,52 @@
-package org.apache.axis.deployement.test;
-
-import org.apache.axis.deployement.Scheduler.Scheduler;
-import org.apache.axis.deployement.Scheduler.SchedulerTask;
-import org.apache.axis.deployement.Scheduler.DeploymentIterator;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @author Deepal Jayasinghe
- * Oct 5, 2004
- * 9:43:39 AM
- *
- */
-public class HotDeployementTest {
- private final Scheduler scheduler = new Scheduler();
- private final SimpleDateFormat dateFormat =
- new SimpleDateFormat("dd MMM yyyy HH:mm:ss.SSS");
- private final int hourOfDay, minute, second;
-
- public HotDeployementTest(int hourOfDay, int minute, int second) {
- this.hourOfDay = hourOfDay;
- this.minute = minute;
- this.second = second;
- }
-
- public void start() {
- scheduler.schedule(new SchedulerTask(),new DeploymentIterator(hourOfDay, minute, second));
- }
-
- public static void main(String[] args) {
- HotDeployementTest alarmClock = new HotDeployementTest(7, 0, 0);
- alarmClock.start();
- }
-}
-
-
+package org.apache.axis.deployement.test;
+
+import org.apache.axis.deployement.Scheduler.Scheduler;
+import org.apache.axis.deployement.Scheduler.SchedulerTask;
+import org.apache.axis.deployement.Scheduler.DeploymentIterator;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Deepal Jayasinghe
+ * Oct 5, 2004
+ * 9:43:39 AM
+ *
+ */
+public class HotDeployementTest {
+ private final Scheduler scheduler = new Scheduler();
+ private final SimpleDateFormat dateFormat =
+ new SimpleDateFormat("dd MMM yyyy HH:mm:ss.SSS");
+ private final int hourOfDay, minute, second;
+
+ public HotDeployementTest(int hourOfDay, int minute, int second) {
+ this.hourOfDay = hourOfDay;
+ this.minute = minute;
+ this.second = second;
+ }
+
+ public void start() {
+ scheduler.schedule(new SchedulerTask(),new DeploymentIterator(hourOfDay, minute, second));
+ }
+
+ public static void main(String[] args) {
+ HotDeployementTest alarmClock = new HotDeployementTest(10, 0, 0);
+ alarmClock.start();
+ }
+}
+
+