- Fixed issue where resource processors could close the underlying deployment package stream by closing the resource specific stream
- Completed event now contains a Boolean instead of a String as defined in compendium 114.11
- A few cosmetic changes
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@638325 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/AbstractDeploymentPackage.java b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/AbstractDeploymentPackage.java
index 7fa6076..837a1b2 100644
--- a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/AbstractDeploymentPackage.java
+++ b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/AbstractDeploymentPackage.java
@@ -309,9 +309,5 @@
*/
public abstract InputStream getCurrentEntryStream();
- public Bundle getBundle(Object symbolicName) {
- // TODO Auto-generated method stub
- return null;
- }
}
diff --git a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Constants.java b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Constants.java
index 1713973..a2fcabe 100644
--- a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Constants.java
+++ b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Constants.java
@@ -35,7 +35,7 @@
public static final String EVENTTOPIC_UNINSTALL = "org/osgi/service/deployment/UNINSTALL";
public static final String EVENTTOPIC_COMPLETE = "org/osgi/service/deployment/COMPLETE";
public static final String EVENTPROPERTY_DEPLOYMENTPACKAGE_NAME = "deploymentpackage.name";
- public static final String EVENTPROPERTY_SUCCESFUL = "succesful";
+ public static final String EVENTPROPERTY_SUCCESSFUL = "successful";
// miscellaneous constants
public static final String BUNDLE_LOCATION_PREFIX = "osgi-dp:";
diff --git a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java
index aec851c..aef5aac 100644
--- a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java
+++ b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java
@@ -25,6 +25,7 @@
import java.util.Collection;
import java.util.Dictionary;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -261,14 +262,14 @@
}
}
- private void delete(File tempPackage) {
- if (tempPackage.isDirectory()) {
- File[] childs = tempPackage.listFiles();
+ private void delete(File target) {
+ if (target.isDirectory()) {
+ File[] childs = target.listFiles();
for (int i = 0; i < childs.length; i++) {
delete(childs[i]);
}
}
- tempPackage.delete();
+ target.delete();
}
public DeploymentPackage[] listDeploymentPackages() {
@@ -311,9 +312,9 @@
}
private void sendCompleteEvent(String name, boolean success) {
- Dictionary props = new Properties();
+ Dictionary props = new Hashtable();
props.put(Constants.EVENTPROPERTY_DEPLOYMENTPACKAGE_NAME, name);
- props.put(Constants.EVENTPROPERTY_SUCCESFUL, String.valueOf(success));
+ props.put(Constants.EVENTPROPERTY_SUCCESSFUL, Boolean.valueOf(success));
Event completeEvent = new Event(Constants.EVENTTOPIC_COMPLETE, props);
m_eventAdmin.postEvent(completeEvent);
}
diff --git a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/FileDeploymentPackage.java b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/FileDeploymentPackage.java
index bd0e4c6..8e37b54 100644
--- a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/FileDeploymentPackage.java
+++ b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/FileDeploymentPackage.java
@@ -43,7 +43,7 @@
* Creates a new instance of a deployment package stored on disk.
*
* @param index Reference to the index file that contains the order in which all the resources of this deployment package were received
- * @param packageDir Reference to the directory in which the index and package cotents are stored.
+ * @param packageDir Reference to the directory in which the index and package contents are stored.
* @param bundleContext The bundle context
* @throws DeploymentException Thrown if the disk contents do not resemble a valid deployment package.
* @throws IOException Thrown if there was a problem reading the resources from disk.
diff --git a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/NonCloseableStream.java b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/NonCloseableStream.java
new file mode 100644
index 0000000..c4ae67c
--- /dev/null
+++ b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/NonCloseableStream.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+package org.apache.felix.deploymentadmin;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Stream that does nothing when close() is invoked, calls to one of the read methods will throw an <code>IOException</code>
+ * after close() is called. Also, mark/reset is not supported. Deployment Admin can use this class to pass on as an <code>InputStream</code>
+ * to a resource processor.
+ *
+ */
+public class NonCloseableStream extends InputStream {
+
+ private final InputStream m_input;
+ private boolean m_closed;
+
+ public NonCloseableStream(InputStream m_input) {
+ this.m_input = m_input;
+ }
+
+
+ // stream should not be actually closed, subsequent calls to read methods will throw an exception though
+
+ public void close() throws IOException {
+ if (m_closed) {
+ throw new IOException("Unable to read, stream is closed.");
+ }
+ m_closed = true;
+ }
+
+ public int read() throws IOException {
+ return m_input.read();
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException {
+ if (m_closed) {
+ throw new IOException("Unable to read, stream is closed.");
+ }
+ return m_input.read(b, off, len);
+ }
+
+ public int read(byte[] b) throws IOException {
+ if (m_closed) {
+ throw new IOException("Unable to read, stream is closed.");
+ }
+ return m_input.read(b);
+ }
+
+
+ // No mark & reset support
+
+ public boolean markSupported() {
+ return false;
+ }
+
+ public void mark(int readlimit) {
+ // do nothing
+ }
+
+ public void reset() throws IOException {
+ throw new IOException("Mark and reset are not available on this type of stream.");
+ }
+
+
+ // Unaffected methods
+
+ public int available() throws IOException {
+ return m_input.available();
+ }
+
+ public int hashCode() {
+ return m_input.hashCode();
+ }
+
+ public long skip(long n) throws IOException {
+ return m_input.skip(n);
+ }
+
+ public boolean equals(Object obj) {
+ return m_input.equals(obj);
+ }
+
+ public String toString() {
+ return m_input.toString();
+ }
+
+}
diff --git a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/StreamDeploymentPackage.java b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/StreamDeploymentPackage.java
index d5322c6..4c5b851 100644
--- a/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/StreamDeploymentPackage.java
+++ b/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/StreamDeploymentPackage.java
@@ -92,7 +92,7 @@
}
public InputStream getCurrentEntryStream() {
- return m_input;
+ return new NonCloseableStream(m_input);
}
}
\ No newline at end of file