libjpf-java-1.5.1+dfsg.orig/ 0000775 0001750 0001750 00000000000 11247552340 015060 5 ustar gregoa gregoa libjpf-java-1.5.1+dfsg.orig/jpf-boot-pom.xml 0000644 0001750 0001750 00000004365 10605753250 020121 0 ustar gregoa gregoa
org.java.plugin.boot.splash.
prefix
*/
void configure(ExtendedProperties config);
/**
* @return boot progress value that is normalized to [0; 1] interval
*/
float getProgress();
/**
* Sets boot progress value and optionally adjust visual progress bar
* control. The value should be in [0; 1] interval.
* @param value new progress value
*/
void setProgress(float value);
/**
* @return current text caption
*/
String getText();
/**
* Sets new text caption and optionally display it on the screen.
* @param value new text caption
*/
void setText(String value);
/**
* @return current image URL
*/
URL getImage();
/**
* Sets new image URL and optionally displays it on the splash screen.
* @param value new image URL
*/
void setImage(URL value);
/**
* @return true
if splash screen is displayed now
*/
boolean isVisible();
/**
* Shows/hides splash screen.
* @param value true
to show splash screen, false
* - to hide and dispose it
*/
void setVisible(boolean value);
/**
* Useful method to get access to handler internals. The actually returned
* object depends on handler implementation.
* @return original implementation of this handler, usually you return
* this
(useful for handler wrappers)
*/
Object getImplementation();
}
libjpf-java-1.5.1+dfsg.orig/source-boot/org/java/plugin/boot/ControlThread.java 0000644 0001750 0001750 00000030656 10554436520 026716 0 ustar gregoa gregoa /*****************************************************************************
* Java Plug-in Framework (JPF)
* Copyright (C) 2004-2007 Dmitry Olshansky
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
package org.java.plugin.boot;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @version $Id$
*/
final class ControlThread extends Thread {
static boolean isApplicationRunning(final InetAddress host,
final int port) {
try {
Socket socket = new Socket(host, port);
try {
socket.setKeepAlive(true);
String test = "" + System.currentTimeMillis(); //$NON-NLS-1$
OutputStream out = socket.getOutputStream();
InputStream in = null;
try {
System.out.println("found running control service on " //$NON-NLS-1$
+ host + ":" + port); //$NON-NLS-1$
out.write(("PING " + test).getBytes()); //$NON-NLS-1$
out.flush();
socket.shutdownOutput();
in = socket.getInputStream();
StringBuilder commandResult = new StringBuilder();
byte[] buf = new byte[16];
int len;
while ((len = in.read(buf)) != -1) {
commandResult.append(new String(buf, 0, len));
}
socket.shutdownInput();
if (commandResult.toString().startsWith("OK") //$NON-NLS-1$
&& (commandResult.toString().indexOf(test) != -1)) {
System.out.println("PING command succeed"); //$NON-NLS-1$
return true;
}
System.out.println("PING command failed"); //$NON-NLS-1$
} finally {
try {
out.close();
} catch (IOException ioe) {
// ignore
}
if (in != null) {
try {
in.close();
} catch (IOException ioe) {
// ignore
}
}
}
} finally {
socket.close();
}
} catch (IOException ioe) {
System.out.println(
"seems that there is no control service running on " //$NON-NLS-1$
+ host + ":" + port); //$NON-NLS-1$
//ioe.printStackTrace();
}
return false;
}
static boolean stopRunningApplication(final InetAddress host,
final int port) {
boolean result = false;
try {
Socket socket = new Socket(host, port);
try {
socket.setKeepAlive(true);
OutputStream out = socket.getOutputStream();
InputStream in = null;
try {
System.out.println("found running control service on " //$NON-NLS-1$
+ host + ":" + port); //$NON-NLS-1$
out.write("STOP".getBytes()); //$NON-NLS-1$
out.flush();
socket.shutdownOutput();
in = socket.getInputStream();
StringBuilder commandResult = new StringBuilder();
byte[] buf = new byte[16];
int len;
while ((len = in.read(buf)) != -1) {
commandResult.append(new String(buf, 0, len));
}
socket.shutdownInput();
if (commandResult.toString().startsWith("OK")) { //$NON-NLS-1$
System.out.println("STOP command succeed"); //$NON-NLS-1$
result = true;
} else {
System.out.println("STOP command failed"); //$NON-NLS-1$
}
} finally {
try {
out.close();
} catch (IOException ioe) {
// ignore
}
if (in != null) {
try {
in.close();
} catch (IOException ioe) {
// ignore
}
}
}
} finally {
socket.close();
}
} catch (IOException ioe) {
System.out.println(
"seems that there is no control service running on " //$NON-NLS-1$
+ host + ":" + port); //$NON-NLS-1$
//ioe.printStackTrace();
}
if (result) {
try {
Thread.sleep(2000);
} catch (InterruptedException ie) {
// ignore
}
}
return result;
}
private Log log;
private ServerSocket serverSocket;
private final ServiceApplication application;
private boolean appRunning;
ControlThread(final InetAddress host, final int port,
final ServiceApplication server) throws Exception {
log = LogFactory.getLog(this.getClass());
application = server;
serverSocket = new ServerSocket(port, 1, host);
appRunning = true;
setName("jpf-application-control-thread"); //$NON-NLS-1$
}
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
try {
while (true) {
try {
Socket clientSocket = serverSocket.accept();
try {
if (handleRequest(clientSocket)) {
break;
}
} finally {
try {
clientSocket.close();
} catch (IOException ioe) {
// ignore
}
}
} catch (Exception e) {
warn("error on server socket", e); //$NON-NLS-1$
break;
}
}
} catch (Exception e) {
error(e);
} finally {
try {
serverSocket.close();
} catch (IOException ioe) {
warn("error closing server socket", ioe); //$NON-NLS-1$
}
if (appRunning) {
stopApplication();
}
}
}
private synchronized boolean handleRequest(final Socket clientSocket) {
debug("handling control request"); //$NON-NLS-1$
if (!isValidRemoteHost(clientSocket.getInetAddress())) {
warn("incoming connection to control socket registered" //$NON-NLS-1$
+ " from REMOTE address " + clientSocket.getInetAddress() //$NON-NLS-1$
+ ", attempt to execute command was IGNORED"); //$NON-NLS-1$
try {
clientSocket.close();
} catch (IOException e) {
// ignore
}
return false;
}
debug("processing control request"); //$NON-NLS-1$
boolean result = false;
try {
String commandResult;
InputStream in = clientSocket.getInputStream();
OutputStream out = null;
try {
StringBuilder command = new StringBuilder();
byte[] buf = new byte[16];
int len;
while ((len = in.read(buf)) != -1) {
command.append(new String(buf, 0, len));
}
clientSocket.shutdownInput();
debug("got command - " + command); //$NON-NLS-1$
if ("STOP".equals(command.toString())) { //$NON-NLS-1$
stopApplication();
result = true;
commandResult = "OK: stop done"; //$NON-NLS-1$
} else if (command.toString().startsWith("PING")) { //$NON-NLS-1$
commandResult = "OK: " //$NON-NLS-1$
+ command.substring("PING".length()); //$NON-NLS-1$
} else {
commandResult = "ERROR: unknown command"; //$NON-NLS-1$
}
//debug("command executed");
//debug("sending command result - " + commandResult);
out = clientSocket.getOutputStream();
out.write(commandResult.getBytes());
out.flush();
clientSocket.shutdownOutput();
//debug("command result sent");
} finally {
try {
in.close();
} catch (IOException ioe) {
// ignore
}
if (out != null) {
try {
out.close();
} catch (IOException ioe) {
// ignore
}
}
}
} catch (IOException ioe) {
error("error processing control request", ioe); //$NON-NLS-1$
}
return result;
}
private void stopApplication() {
if (!appRunning) {
debug("application not running"); //$NON-NLS-1$
return;
}
appRunning = false;
debug("stopping application"); //$NON-NLS-1$
try {
Boot.stopApplication(application);
log = null;
} catch (Exception e) {
error("an error has occurred while stopping" //$NON-NLS-1$
+ " application", e); //$NON-NLS-1$
}
debug("application stopped from control thread"); //$NON-NLS-1$
}
private boolean isValidRemoteHost(final InetAddress addr) {
byte[] localAddr = serverSocket.getInetAddress().getAddress();
byte[] remoteAddr = addr.getAddress();
if (localAddr.length != remoteAddr.length) {
return false;
}
for (int i = 0; i < remoteAddr.length; i++) {
if (localAddr[i] != remoteAddr[i]) {
return false;
}
}
return true;
}
private void debug(final String msg) {
if (log != null) {
log.debug(msg);
} else {
System.out.println(msg);
}
}
private void warn(final String msg) {
if (log != null) {
log.warn(msg);
} else {
System.out.println(msg);
}
}
private void warn(final String msg, final Exception e) {
if (log != null) {
log.warn(msg, e);
} else {
System.out.println(msg);
e.printStackTrace();
}
}
private void error(final String msg, final Exception e) {
if (log != null) {
log.error(msg, e);
} else {
System.err.println(msg);
e.printStackTrace();
}
}
private void error(final Exception e) {
if (log != null) {
log.error(e);
} else {
e.printStackTrace();
}
}
}
libjpf-java-1.5.1+dfsg.orig/source-boot/org/java/plugin/boot/DefaultPluginsCollector.java 0000644 0001750 0001750 00000023715 10554435200 030733 0 ustar gregoa gregoa /*****************************************************************************
* Java Plug-in Framework (JPF)
* Copyright (C) 2004-2007 Dmitry Olshansky
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
package org.java.plugin.boot;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
import javax.xml.parsers.SAXParserFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.java.plugin.PluginManager.PluginLocation;
import org.java.plugin.standard.StandardPluginLocation;
import org.java.plugin.util.ExtendedProperties;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
/**
* Default implementation of plug-ins collector interface. Supported
* configuration parameters are:
*
./plugins
.
* Given repositories are scanned recursively collecting all folders that
* contain plugin.xml
or plugin-fragment.xml
and
* *.zip
and *.jar
files.
*
* Plug-ins locations descriptor is a simple XML syntax file that stores * locations of all available plug-in manifests and contexts (in terms of * {@link org.java.plugin.PluginManager.PluginLocation}). Here is an example: *
<plugins> * <plugin * manifest="http://localhost/myPlugins/plugin1/plugin.xml" * context="http://localhost/myPlugins/plugin1/"/> * <plugin * manifest="http://localhost/myPlugins/plugin2/plugin.xml" * context="http://localhost/myPlugins/plugin2/"/> * <plugin * manifest="http://www.plugins.com/repository/plugin1/plugin.xml" * context="http://www.plugins.com/repository/plugin1/"/> * <plugin * manifest="http://www.plugins.com/repository/plugin1/plugin.xml" * context="http://www.plugins.com/repository/plugin1/"/> * </plugins>* Using such simple descriptor you may, for example, publish plug-ins on a site * to make them available for clients without needing to download plug-ins * manually. * * @version $Id$ */ public class DefaultPluginsCollector implements PluginsCollector { protected static final String PARAM_PLUGINS_REPOSITORIES = "org.java.plugin.boot.pluginsRepositories"; //$NON-NLS-1$ protected static final String PARAM_PLUGINS_LOCATIONS_DESCRIPTORS = "org.java.plugin.boot.pluginsLocationsDescriptors"; //$NON-NLS-1$ protected Log log = LogFactory.getLog(this.getClass()); private List
false
.
*
* @see org.java.plugin.boot.BootErrorHandler#handleError(java.lang.String,
* java.lang.Exception)
*/
public boolean handleError(final String message, final Exception e) {
handleFatalError(message, e);
return false;
}
/**
* Does the same as {@link #handleFatalError(String)} always returns
* false
.
*
* @see org.java.plugin.boot.BootErrorHandler#handleError(java.lang.String,
* org.java.plugin.registry.IntegrityCheckReport)
*/
public boolean handleError(final String message,
final IntegrityCheckReport report) {
System.err.println(message);
return false;
}
}
libjpf-java-1.5.1+dfsg.orig/source-boot/org/java/plugin/boot/Resources_ru.properties 0000644 0001750 0001750 00000003703 10541226146 030067 0 ustar gregoa gregoa # Java Plug-in Framework (JPF)
# Copyright (C) 2004 - 2005 Dmitry Olshansky
# $Id$
# Boot errors related messages
bootFailed = \u0424\u0430\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0431\u043e\u0439 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.
bootAppInitFailed = \u043d\u0435 \u0443\u0434\u0430\u0451\u0442\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435
# Error handlers related messages
errorDialogueHeaderFatal = \u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443
errorDialogueHeaderNonFatal = \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b
integrityCheckFailed = \u041d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f?
initMethodNotFound = \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043f\u043b\u0430\u0433\u0438\u043d\u0435 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d \u043c\u0435\u0442\u043e\u0434 [{0}] \u0443 \u043a\u043b\u0430\u0441\u0441\u0430 {1}
# Error dialog related resources
errorLabel = \u041e\u0448\u0438\u0431\u043a\u0430: {0}
noLabel = \u041d\u0435\u0442
yesLabel = \u0414\u0430
closeLabel = \u0417\u0430\u043a\u0440\u044b\u0442\u044c
infoTabLabel = \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f
detailsTabLabel = \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438
libjpf-java-1.5.1+dfsg.orig/source-boot/org/java/plugin/boot/package.html 0000644 0001750 0001750 00000003273 10514424204 025547 0 ustar gregoa gregoa
This package contains helper classes to start/stop JPF based applications.
The main class here is Boot that contains standard entry point for Java applications - method main(String[]). The implemented boot sequence is following:
boot.properties
file from the
current directory. Default values are given from system properties.For details and supported configuration parameters see documentation for corresponding classes.
Note that described scenario is quite common and can be customized and changed in any point providing other implementations of key classes.
For a list of available configuration parameters see documentation for the Boot (applicable to any scenario) and DefaultApplicationInitializer (applicable to scenario when this class being used) classes.