diff options
author | khorne | 2008-02-22 15:00:42 +0000 |
---|---|---|
committer | khorne | 2008-02-22 15:00:42 +0000 |
commit | 5eea216168f264d70eb560c6616ebbf3c6abd193 (patch) | |
tree | 895da079aad6d24e7ad453a7f3d2e39c38da9601 /bundles/org.eclipse.equinox.transforms.xslt | |
parent | e88b507c037a03d03232dcc728491d7c010a0294 (diff) | |
download | rt.equinox.bundles-5eea216168f264d70eb560c6616ebbf3c6abd193.tar.gz rt.equinox.bundles-5eea216168f264d70eb560c6616ebbf3c6abd193.tar.xz rt.equinox.bundles-5eea216168f264d70eb560c6616ebbf3c6abd193.zip |
Bug 218422 - Graduating the transform bundles from the incubator
Diffstat (limited to 'bundles/org.eclipse.equinox.transforms.xslt')
-rw-r--r-- | bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/ProcessPipeInputStream.java | 119 | ||||
-rw-r--r-- | bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/Activator.java | 3 | ||||
-rw-r--r-- | bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/XSLTStreamTransformer.java (renamed from bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/provisional/XSLTStreamTransformer.java) | 4 |
3 files changed, 3 insertions, 123 deletions
diff --git a/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/ProcessPipeInputStream.java b/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/ProcessPipeInputStream.java deleted file mode 100644 index 3035679da..000000000 --- a/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/ProcessPipeInputStream.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.equinox.internal.transforms; - -import java.io.*; - -/** - * This class allows the easy piping of data from an input stream to an external process. - * The resulting output is then returned via the {@link InputStream} methods of this class. - */ -public class ProcessPipeInputStream extends InputStream { - protected Process process = null; - protected InputStream standardInput; - protected IOException failure; - private String commandString; - private String[] environment; - private File workingDirectory; - - /** - * Create a new process pipe with the provided stream supplying the contents of the standard input to the process. - * - * @param standardInput the contents of standard input - */ - public ProcessPipeInputStream(InputStream standardInput, String commandString, String[] environment, File workingDirectory) { - this.standardInput = standardInput; - if (commandString == null) - throw new IllegalArgumentException(); - this.commandString = commandString; - this.environment = environment; - this.workingDirectory = workingDirectory; - } - - /** - * Get the command string for this process. - * The format of this String must conform to the specifications of the command parameter of {@link Runtime#exec(String[], String[], File)}. - * @return the command string. Never <code>null</code>. - */ - protected String getCommandString() { - return commandString; - } - - /** - * Get the environment variables for this process. - * The format of the Strings in this array must conform to the specifications of the environment parameter of {@link Runtime#exec(String[], String[], File)}. - * @return the environment variables or <code>null</code> - */ - protected String[] getEnvironment() { - return environment; - } - - /** - * Get the working directory for the process. - * @return the working directory or <code>null</code> - */ - protected File getWorkingDirectory() { - return workingDirectory; - } - - public int read() throws IOException { - synchronized (this) { - if (failure != null) { - IOException e = new IOException("Problem piping the stream."); //$NON-NLS-1$ - e.fillInStackTrace(); - e.initCause(failure); - throw e; - } - if (process == null) { - - process = Runtime.getRuntime().exec(getCommandString(), getEnvironment(), getWorkingDirectory()); - - Thread thread = new Thread(new Runnable() { - - public void run() { - byte[] buffer = new byte[2048]; - int len = 0; - try { - while ((len = standardInput.read(buffer)) > 0) { - process.getOutputStream().write(buffer, 0, len); - } - process.getOutputStream().close(); - } catch (IOException e) { - synchronized (ProcessPipeInputStream.this) { - failure = e; - process.destroy(); - } - } - - } - }); - thread.start(); - - } - return process.getInputStream().read(); - } - } - - /** - * Resets the stream. This has the effect of destroying the process, if one exists. - */ - public void reset() throws IOException { - synchronized (this) { - if (process != null) { - process.destroy(); - process = null; - failure = null; - } - } - super.reset(); - } -} diff --git a/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/Activator.java b/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/Activator.java index 53ecf2e77..b0188daa1 100644 --- a/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/Activator.java +++ b/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/Activator.java @@ -12,7 +12,6 @@ package org.eclipse.equinox.internal.transforms.xslt; import java.util.Properties; -import org.eclipse.equinox.internal.transforms.xslt.provisional.XSLTStreamTransformer; import org.eclipse.osgi.framework.log.FrameworkLog; import org.osgi.framework.*; import org.osgi.util.tracker.ServiceTracker; @@ -30,7 +29,7 @@ public class Activator implements BundleActivator { logTracker.open(); Properties properties = new Properties(); - properties.put("isStreamTransformer", "true"); //$NON-NLS-1$ //$NON-NLS-2$ + properties.put("equinox.transformerType", "xslt"); //$NON-NLS-1$ //$NON-NLS-2$ Object transformer = new XSLTStreamTransformer(logTracker); registration = context.registerService(Object.class.getName(), transformer, properties); diff --git a/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/provisional/XSLTStreamTransformer.java b/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/XSLTStreamTransformer.java index 27a1e7e7e..d2d5b1ee9 100644 --- a/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/provisional/XSLTStreamTransformer.java +++ b/bundles/org.eclipse.equinox.transforms.xslt/src/org/eclipse/equinox/internal/transforms/xslt/XSLTStreamTransformer.java @@ -9,7 +9,7 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.internal.transforms.xslt.provisional; +package org.eclipse.equinox.internal.transforms.xslt; import java.io.*; import java.lang.ref.SoftReference; @@ -19,7 +19,7 @@ import java.util.Map; import javax.xml.transform.*; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; -import org.eclipse.equinox.transforms.Pipe; +import org.eclipse.equinox.internal.transforms.Pipe; import org.eclipse.osgi.framework.log.FrameworkLog; import org.eclipse.osgi.framework.log.FrameworkLogEntry; import org.osgi.framework.FrameworkEvent; |