Return-Path: Delivered-To: apmail-incubator-aries-commits-archive@minotaur.apache.org Received: (qmail 17573 invoked from network); 2 Apr 2010 13:43:24 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Apr 2010 13:43:24 -0000 Received: (qmail 70787 invoked by uid 500); 2 Apr 2010 09:43:24 -0000 Delivered-To: apmail-incubator-aries-commits-archive@incubator.apache.org Received: (qmail 70726 invoked by uid 500); 2 Apr 2010 09:43:23 -0000 Mailing-List: contact aries-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: aries-dev@incubator.apache.org Delivered-To: mailing list aries-commits@incubator.apache.org Received: (qmail 70708 invoked by uid 99); 2 Apr 2010 09:43:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Apr 2010 09:43:22 +0000 X-ASF-Spam-Status: No, hits=-1250.6 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Apr 2010 09:43:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 175E52388A43; Fri, 2 Apr 2010 09:43:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r930209 [2/2] - in /incubator/aries/trunk/subsystem: ./ org.osgi.service.composite/ org.osgi.service.composite/src/ org.osgi.service.composite/src/main/ org.osgi.service.composite/src/main/java/ org.osgi.service.composite/src/main/java/org/... Date: Fri, 02 Apr 2010 09:43:00 -0000 To: aries-commits@incubator.apache.org From: gnodet@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100402094301.175E52388A43@eris.apache.org> Added: incubator/aries/trunk/subsystem/subsystem-install/src/main/java/org/apache/aries/subsystem/install/internal/SubsystemInstaller.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-install/src/main/java/org/apache/aries/subsystem/install/internal/SubsystemInstaller.java?rev=930209&view=auto ============================================================================== --- incubator/aries/trunk/subsystem/subsystem-install/src/main/java/org/apache/aries/subsystem/install/internal/SubsystemInstaller.java (added) +++ incubator/aries/trunk/subsystem/subsystem-install/src/main/java/org/apache/aries/subsystem/install/internal/SubsystemInstaller.java Fri Apr 2 09:42:59 2010 @@ -0,0 +1,99 @@ +/* + * Licensed 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.aries.subsystem.install.internal; + +import java.io.File; +import java.io.IOException; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.Manifest; + +import org.apache.aries.subsystem.SubsystemAdmin; +import org.apache.aries.subsystem.SubsystemConstants; +import org.apache.felix.fileinstall.ArtifactInstaller; + +public class SubsystemInstaller implements ArtifactInstaller { + + private SubsystemAdmin subsystemAdmin; + + public SubsystemAdmin getSubsystemAdmin() { + return subsystemAdmin; + } + + public void setSubsystemAdmin(SubsystemAdmin subsystemAdmin) { + this.subsystemAdmin = subsystemAdmin; + } + + public void install(File file) throws Exception { + if (file.isDirectory()) { + subsystemAdmin.install("jardir:" + file.getPath()); + } else { + subsystemAdmin.install(file.toURI().toURL().toExternalForm()); + } + } + + public void update(File file) throws Exception { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void uninstall(File file) throws Exception { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean canHandle(File artifact) + { + JarFile jar = null; + try + { + // Handle OSGi bundles with the default deployer + String name = artifact.getName(); + if (!artifact.canRead() + || name.endsWith(".txt") || name.endsWith(".xml") + || name.endsWith(".properties") || name.endsWith(".cfg")) + { + // that's file type which is not supported as bundle and avoid + // exception in the log + return false; + } + jar = new JarFile(artifact); + Manifest m = jar.getManifest(); + if (m.getMainAttributes().getValue(new Attributes.Name(SubsystemConstants.SUBSYSTEM_MANIFESTVERSION)) != null + && m.getMainAttributes().getValue(new Attributes.Name(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME)) != null + && m.getMainAttributes().getValue(new Attributes.Name(SubsystemConstants.SUBSYSTEM_VERSION)) != null) + { + return true; + } + } + catch (Exception e) + { + // Ignore + } + finally + { + if (jar != null) + { + try + { + jar.close(); + } + catch (IOException e) + { + // Ignore + } + } + } + return false; + } + +} Added: incubator/aries/trunk/subsystem/subsystem-install/src/main/resources/OSGI-INF/blueprint/subsystem-install.xml URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-install/src/main/resources/OSGI-INF/blueprint/subsystem-install.xml?rev=930209&view=auto ============================================================================== --- incubator/aries/trunk/subsystem/subsystem-install/src/main/resources/OSGI-INF/blueprint/subsystem-install.xml (added) +++ incubator/aries/trunk/subsystem/subsystem-install/src/main/resources/OSGI-INF/blueprint/subsystem-install.xml Fri Apr 2 09:42:59 2010 @@ -0,0 +1,30 @@ + + + + + + + + + + + + +