[tuxdroid-svn] r4728 - in software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-j
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-06-03 08:32:51
|
Author: remi
Date: 2009-06-03 10:32:45 +0200 (Wed, 03 Jun 2009)
New Revision: 4728
Added:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePlugin.java
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePluginConfiguration.java
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePluginException.java
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInCom.java
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInComListener.java
Removed:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/gadget/
Modified:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/pom.xml
Log:
* refactored project with "plugin" nomenclature instead of "gadget"
* bumped to 0.0.3
Modified: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/pom.xml
===================================================================
--- software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/pom.xml 2009-06-03 08:10:12 UTC (rev 4727)
+++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/pom.xml 2009-06-03 08:32:45 UTC (rev 4728)
@@ -1,10 +1,10 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.kysoh</groupId>
- <artifactId>tuxdroid-gadget-java-kit</artifactId>
+ <artifactId>tuxdroid-plugin-java-kit</artifactId>
<packaging>jar</packaging>
- <version>0.0.2</version>
- <name>Tuxdroid Gadget Java Kit</name>
+ <version>0.0.3</version>
+ <name>Smart-Core Plugin Java Kit</name>
<url>http://www.tuxisalive.com</url>
<dependencies>
<dependency>
Added: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePlugin.java
===================================================================
--- software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePlugin.java (rev 0)
+++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePlugin.java 2009-06-03 08:32:45 UTC (rev 4728)
@@ -0,0 +1,343 @@
+/* This file is part of "Smart-Core Plugin Java Kit".
+ * Copyright 2008, kysoh
+ * Author : Yoran Brault
+ * eMail : software@_bad_karma-lab.net (remove _bad_ before sending an email)
+ * Site : http://www.kysoh.com/
+ *
+ * "Smart-Core Plugin Java Kit" is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * "Smart-Core Plugin Java Kit" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with "Smart-Core Plugin Java Kit"; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package com.kysoh.tuxdroid.plugin.framework.plugin;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.lang.reflect.Field;
+import java.util.Map;
+
+/**
+ * This class is the base class helper for builder java plugins.
+ *
+ * @author yoran.brault@_bad_karma-lab.net (remove _bad_ before sending an
+ * email)
+ * @since 3 juin 08
+ */
+public abstract class SimplePlugin<CONFIGURATION extends SimplePluginConfiguration> {
+ public static final String ENVIRONEMENT_PREFIX = "tgp_";
+ /** configuration. */
+ private CONFIGURATION configuration;
+ private StdInCom stdInCom = null;
+
+ /**
+ * Class which implements the Stdin pipe listener.
+ */
+ class StdInComObserver implements StdInComListener
+ {
+ /**
+ * Event on stdin stopped event.
+ */
+ public void stopped()
+ {
+ try
+ {
+ SimplePlugin.this.onPluginStop();
+ } catch (Throwable e)
+ {
+ SimplePlugin.this.throwError(e);
+ }
+ }
+ }
+
+ /**
+ * @return the configuration
+ */
+ protected CONFIGURATION configuration() {
+ return configuration;
+ }
+
+ /**
+ * This is the generic method for throwing notifications to the server.
+ *
+ * @param notificationId
+ * ID of the notification (this should match with declared
+ * notifications in plugins.xml)
+ * @param arguments
+ * Notification arguments
+ */
+ protected void throwNotification(String notificationId, String... arguments) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(notificationId);
+ for (String argument : arguments) {
+ buffer.append(" '");
+ buffer.append(argument.replace("'", "\\'"));
+ buffer.append("'");
+ }
+ System.out.println(buffer.toString());
+ System.out.flush();
+ }
+
+ protected boolean isWindows() {
+ String osName = System.getProperty("os.name").toLowerCase();
+ return osName.startsWith("windows");
+ }
+
+ private void loadEnvironementData() throws SimplePluginException {
+ if (configuration == null) {
+ return;
+ }
+ Map<String, String> environement = System.getenv();
+ throwTrace("Loading environement");
+ for (String key : environement.keySet()) {
+ if (key.startsWith(ENVIRONEMENT_PREFIX)) {
+ String stringValue = environement.get(key);
+ key = key.substring(ENVIRONEMENT_PREFIX.length());
+ throwTrace(" " + key + ":" + stringValue);
+ Field field = null;
+
+ Class<?> class1 = configuration.getClass();
+ while (class1 != null) {
+ try {
+ field = class1.getDeclaredField(key);
+ } catch (Exception e) {
+ }
+ class1 = class1.getSuperclass();
+ }
+ if (field == null) {
+ continue;
+ }
+ field.setAccessible(true);
+ try {
+ if (field.getType() == String.class) {
+ field.set(configuration, stringValue);
+ } else if (field.getType() == int.class || field.getType() == Integer.class) {
+ field.set(configuration, Integer.parseInt(stringValue));
+ } else if (field.getType() == double.class || field.getType() == Double.class) {
+ field.set(configuration, Double.parseDouble(stringValue));
+ } else if (field.getType() == boolean.class || field.getType() == Boolean.class) {
+ field.set(configuration, Boolean.parseBoolean(stringValue));
+ } else if (field.getType().getSuperclass() == Enum.class) {
+ Enum newValue = Enum.valueOf((Class<Enum>) field.getType(), stringValue);
+ field.set(configuration, newValue);
+ } else {
+ this.throwError(new SimplePluginException("Unable to find conversion for : " + field.getType()));
+ continue;
+ }
+ } catch (Exception e) {
+ this.throwError(e);
+ continue;
+ }
+ }
+ }
+ }
+
+ /**
+ * This is a special notification used to send "speakable" messages to the
+ * server.
+ *
+ * @param content
+ * message content
+ */
+ public void throwMessage(String content, Object... arguments) {
+ String[] tmp = new String[arguments.length + 1];
+ tmp[0] = content;
+ for (int i = 0; i < arguments.length; i++) {
+ tmp[i + 1] = String.valueOf(arguments[i]);
+ }
+ throwNotification("message", tmp);
+ }
+
+ /**
+ * This method is used a starting point for the plugin. The standard way to
+ * use this adding in your inherited plugin class something like this :
+ *
+ * <pre>
+ * public static void main(String[] args) throws Exception {
+ * new MyBeautifulPlugin().boot(args, new MyPluginConfiguration());
+ * }
+ * </pre>
+ *
+ * @param arguments
+ * command line arguments (those you get with main
+ * @param configuration
+ * a new configuration object
+ */
+ protected void boot(String[] arguments, CONFIGURATION configuration) {
+ try {
+ if (arguments.length > 0) {
+ command = arguments[0];
+ }
+ this.configuration = configuration;
+ loadEnvironementData();
+ if (this.configuration.isDaemon())
+ {
+ stdInCom = new StdInCom();
+ StdInComObserver stdInComObserver = new StdInComObserver();
+ stdInCom.addListener(stdInComObserver);
+ stdInCom.start();
+ }
+ start();
+ if (!this.configuration.isDaemon())
+ {
+ onPluginStop();
+ }
+ } catch (Throwable e) {
+ throwError(e);
+ }
+ }
+
+ private String command = null;
+
+ /**
+ * @return the command
+ */
+ protected String getCommand() {
+ return command;
+ }
+
+ /**
+ * @param command
+ * the command to set
+ */
+ protected void setCommand(String command) {
+ this.command = command;
+ }
+
+ /**
+ * this method should be defined in your plugin class. This handle the main
+ * function of it. Be careful, if your make a plugin in "command mode" you
+ * should leave this as soon as possible. If your are making a "service"
+ * plugin, you can make you main loop here.
+ *
+ * @throws Throwable
+ * when something go wrong...
+ */
+ protected abstract void start() throws Throwable;
+
+ /**
+ * On plugin stop event.
+ * this method should be defined in your plugin class.
+ * @throws Throwable
+ * when something go wrong...
+ */
+ protected abstract void onPluginStop() throws Throwable;
+
+ /**
+ * Stop the plugin.
+ */
+ public void stop()
+ {
+ if (this.stdInCom != null)
+ {
+ this.stdInCom.stopPipe();
+ }
+ try {
+ this.onPluginStop();
+ } catch (Throwable e) {
+ this.throwError(e);
+ }
+ this.throwNotification("plugin", "exit");
+ }
+
+ /**
+ * This function throw a debug trace to the server. The server should have
+ * activate traces for this plugin in order to display them.
+ *
+ * @param message
+ * trace message
+ */
+ protected void throwTrace(String message) {
+ if (!configuration.isTraces()) {
+ return;
+ }
+ throwNotification("trace", message);
+ }
+
+ /**
+ * Throw the result of the "check" command to the framework.
+ *
+ * @param result
+ * Check command result
+ */
+ protected void throwResult(boolean result) {
+ String resultValue;
+ if (result) resultValue = "true";
+ else resultValue = "false";
+ throwNotification("check_result", resultValue);
+ }
+
+ /**
+ * When something go wrong, you can use this function to throw an exception
+ * to the server.
+ *
+ * @param throwable
+ * Exception to throw.
+ */
+ protected void throwError(Throwable throwable) {
+ if (configuration.isTraces()) {
+ final Writer result = new StringWriter();
+ final PrintWriter printWriter = new PrintWriter(result);
+ throwable.printStackTrace(printWriter);
+ throwNotification("error", result.toString());
+ } else {
+ throwNotification("error", throwable.getMessage());
+ }
+
+ }
+
+ protected File getStateFile(String name) {
+ // State files should stay in the working folder of plugins in order
+ // to be deleted when the plugin is updated (re-deployed)
+ File sessionId = new File("states");
+ sessionId.mkdirs();
+ sessionId = new File(sessionId, name);
+ return sessionId;
+ }
+
+ protected <E> E readState(Class<E> objectClass, String sessionId) {
+ try {
+ File file = getStateFile(sessionId);
+ E result;
+ if (file.exists()) {
+ ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(file));
+ result = (E) inputStream.readObject();
+ } else {
+
+ result = objectClass.newInstance();
+ }
+ return result;
+ } catch (Exception e) {
+ throwError(e);
+ return null;
+ }
+ }
+
+ protected void writeState(Object object, String sessionId) {
+ File file = getStateFile(sessionId);
+ try {
+ ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(file));
+ outputStream.writeObject(object);
+ outputStream.close();
+ } catch (Exception e) {
+ throwError(e);
+ }
+ }
+
+}
Property changes on: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePlugin.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePluginConfiguration.java
===================================================================
--- software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePluginConfiguration.java (rev 0)
+++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePluginConfiguration.java 2009-06-03 08:32:45 UTC (rev 4728)
@@ -0,0 +1,136 @@
+/* This file is part of "Smart-Core Plugin Java Kit".
+ * Copyright 2008, kysoh
+ * Author : Yoran Brault
+ * eMail : software@_bad_karma-lab.net (remove _bad_ before sending an email)
+ * Site : http://www.kysoh.com/
+ *
+ * "Smart-Core Plugin Java Kit" is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * "Smart-Core Plugin Java Kit" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with "Smart-Core Plugin Java Kit"; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package com.kysoh.tuxdroid.plugin.framework.plugin;
+
+public class SimplePluginConfiguration {
+ private boolean traces = false;
+ private int pitch = 100;
+ private String language = "en";
+ private String country = "US";
+ private String locutor = "Ryan";
+ private String ip = "127.0.0.1";
+ private boolean daemon = false;
+
+ /**
+ * @return the pitch
+ */
+ public int getPitch() {
+ return pitch;
+ }
+
+ /**
+ * @param pitch
+ * the pitch to set
+ */
+ public void setPitch(int pitch) {
+ this.pitch = pitch;
+ }
+
+ /**
+ * @return the language
+ */
+ public String getLanguage() {
+ return language;
+ }
+
+ /**
+ * @param language
+ * the language to set
+ */
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ /**
+ * @return the country
+ */
+ public String getCountry() {
+ return country;
+ }
+
+ /**
+ * @param country
+ * the country to set
+ */
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ /**
+ * @return the locutor
+ */
+ public String getLocutor() {
+ return locutor;
+ }
+
+ /**
+ * @param locutor
+ * the locutor to set
+ */
+ public void setLocutor(String locutor) {
+ this.locutor = locutor;
+ }
+
+ /**
+ * @return the traces
+ */
+ public boolean isTraces() {
+ return traces;
+ }
+
+ /**
+ * @param traces
+ * the traces to set
+ */
+ public void setTraces(boolean traces) {
+ this.traces = traces;
+ }
+
+ /**
+ * @param httpserver ip address.
+ */
+ public void setIP(String IP)
+ {
+ this.ip = IP;
+ }
+
+
+ /**
+ * Return current used ip adress.
+ * @return
+ */
+ public String getIP()
+ {
+ return this.ip;
+ }
+
+ /**
+ * Get if the gadget is a daemon or not.
+ * @return
+ */
+ public boolean isDaemon()
+ {
+ return this.daemon;
+ }
+
+}
Property changes on: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePluginConfiguration.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePluginException.java
===================================================================
--- software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePluginException.java (rev 0)
+++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePluginException.java 2009-06-03 08:32:45 UTC (rev 4728)
@@ -0,0 +1,45 @@
+/* This file is part of "Smart-Core Plugin Java Kit".
+ * Copyright 2008, kysoh
+ * Author : Yoran Brault
+ * eMail : software@_bad_karma-lab.net (remove _bad_ before sending an email)
+ * Site : http://www.kysoh.com/
+ *
+ * "Smart-Core Plugin Java Kit" is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * "Smart-Core Plugin Java Kit" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with "Smart-Core Plugin Java Kit"; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package com.kysoh.tuxdroid.plugin.framework.plugin;
+
+public class SimplePluginException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public SimplePluginException() {
+ super();
+ }
+
+ public SimplePluginException(String message) {
+ super(message);
+ }
+
+ public SimplePluginException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public SimplePluginException(Throwable cause) {
+ super(cause);
+ }
+
+}
Property changes on: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePluginException.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInCom.java
===================================================================
--- software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInCom.java (rev 0)
+++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInCom.java 2009-06-03 08:32:45 UTC (rev 4728)
@@ -0,0 +1,133 @@
+/* This file is part of "Smart-Core Plugin Java Kit" library.
+ * Copyright 2009, kysoh
+ * Author : Remi Jocaille
+ * eMail : rem...@c2...
+ * Site : http://www.kysoh.com/
+ *
+ * "Smart-Core Plugin Java Kit" is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * "Smart-Core Plugin Java Kit" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with "Smart-Core Plugin Java Kit"; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package com.kysoh.tuxdroid.plugin.framework.plugin;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+public class StdInCom extends Thread
+{
+ private boolean isRun = false;
+ private Object runMutex = new Object();
+ private StdInComListener stdInComListener = null;
+
+ /**
+ * Add a listener.
+ * @param StdInComListener Listener.
+ */
+ public void addListener(StdInComListener listener)
+ {
+ stdInComListener = listener;
+ }
+
+ /*
+ * Set the run state of the communication handling.
+ */
+ private void setRun(boolean value)
+ {
+ synchronized (runMutex)
+ {
+ isRun = value;
+ }
+ }
+
+ /*
+ * Get the run state of the communication handling.
+ */
+ private boolean getRun()
+ {
+ boolean result;
+ synchronized (runMutex)
+ {
+ result = isRun;
+ }
+ return result;
+ }
+
+ /**
+ * Stop the communication handling.
+ */
+ @SuppressWarnings("deprecation")
+ public void stopPipe()
+ {
+ if (!getRun())
+ {
+ return;
+ }
+ setRun(false);
+ try
+ {
+ join(500);
+ }
+ catch (InterruptedException e) {}
+ if (isAlive())
+ {
+ stop();
+ }
+ }
+
+ /**
+ * Loop to listening the commands from the host application.
+ */
+ @SuppressWarnings("static-access")
+ public void run()
+ {
+ if (getRun())
+ {
+ return;
+ }
+ setRun(true);
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ while (getRun())
+ {
+ // Read the next received command
+ String rcvLine;
+ try
+ {
+ while (!stdin.ready())
+ {
+ try {
+ this.sleep(200);
+ } catch (InterruptedException e) {}
+ }
+ rcvLine = stdin.readLine();
+ }
+ catch (IOException e)
+ {
+ break;
+ }
+ if (rcvLine.toLowerCase().startsWith("stop"))
+ {
+ if (stdInComListener != null)
+ {
+ stdInComListener.stopped();
+ }
+ this.setRun(false);
+ }
+ try {
+ this.sleep(100);
+ } catch (InterruptedException e) {}
+ }
+ }
+}
Property changes on: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInCom.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInComListener.java
===================================================================
--- software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInComListener.java (rev 0)
+++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInComListener.java 2009-06-03 08:32:45 UTC (rev 4728)
@@ -0,0 +1,28 @@
+/* This file is part of "Smart-Core Plugin Java Kit" library.
+ * Copyright 2009, kysoh
+ * Author : Remi Jocaille
+ * eMail : rem...@c2...
+ * Site : http://www.kysoh.com/
+ *
+ * "Smart-Core Plugin Java Kit" is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * "Smart-Core Plugin Java Kit" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with "Smart-Core Plugin Java Kit"; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package com.kysoh.tuxdroid.plugin.framework.plugin;
+
+public interface StdInComListener
+{
+ void stopped();
+}
Property changes on: software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInComListener.java
___________________________________________________________________
Name: svn:keywords
+ Id
|