Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 25467 invoked from network); 18 Mar 2008 11:25:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Mar 2008 11:25:13 -0000 Received: (qmail 76625 invoked by uid 500); 18 Mar 2008 11:25:11 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 76604 invoked by uid 500); 18 Mar 2008 11:25:10 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 76595 invoked by uid 99); 18 Mar 2008 11:25:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Mar 2008 04:25:10 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Mar 2008 11:24:28 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 954D51A9832; Tue, 18 Mar 2008 04:24:47 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r638325 - in /felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin: AbstractDeploymentPackage.java Constants.java DeploymentAdminImpl.java FileDeploymentPackage.java NonCloseableStream.java StreamDeploymentPackage.java Date: Tue, 18 Mar 2008 11:24:46 -0000 To: commits@felix.apache.org From: christian@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080318112447.954D51A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: christian Date: Tue Mar 18 04:24:45 2008 New Revision: 638325 URL: http://svn.apache.org/viewvc?rev=638325&view=rev Log: - 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 Added: felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/NonCloseableStream.java Modified: felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/AbstractDeploymentPackage.java felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Constants.java felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/FileDeploymentPackage.java felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/StreamDeploymentPackage.java Modified: felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/AbstractDeploymentPackage.java URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/AbstractDeploymentPackage.java?rev=638325&r1=638324&r2=638325&view=diff ============================================================================== --- felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/AbstractDeploymentPackage.java (original) +++ felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/AbstractDeploymentPackage.java Tue Mar 18 04:24:45 2008 @@ -309,9 +309,5 @@ */ public abstract InputStream getCurrentEntryStream(); - public Bundle getBundle(Object symbolicName) { - // TODO Auto-generated method stub - return null; - } } Modified: felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Constants.java URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Constants.java?rev=638325&r1=638324&r2=638325&view=diff ============================================================================== --- felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Constants.java (original) +++ felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Constants.java Tue Mar 18 04:24:45 2008 @@ -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:"; Modified: felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java?rev=638325&r1=638324&r2=638325&view=diff ============================================================================== --- felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java (original) +++ felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java Tue Mar 18 04:24:45 2008 @@ -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); } Modified: felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/FileDeploymentPackage.java URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/FileDeploymentPackage.java?rev=638325&r1=638324&r2=638325&view=diff ============================================================================== --- felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/FileDeploymentPackage.java (original) +++ felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/FileDeploymentPackage.java Tue Mar 18 04:24:45 2008 @@ -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. Added: felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/NonCloseableStream.java URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/NonCloseableStream.java?rev=638325&view=auto ============================================================================== --- felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/NonCloseableStream.java (added) +++ felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/NonCloseableStream.java Tue Mar 18 04:24:45 2008 @@ -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 IOException + * after close() is called. Also, mark/reset is not supported. Deployment Admin can use this class to pass on as an InputStream + * 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(); + } + +} Modified: felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/StreamDeploymentPackage.java URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/StreamDeploymentPackage.java?rev=638325&r1=638324&r2=638325&view=diff ============================================================================== --- felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/StreamDeploymentPackage.java (original) +++ felix/trunk/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/StreamDeploymentPackage.java Tue Mar 18 04:24:45 2008 @@ -92,7 +92,7 @@ } public InputStream getCurrentEntryStream() { - return m_input; + return new NonCloseableStream(m_input); } }