Author: mnuttall
Date: Wed Dec 23 14:31:28 2009
New Revision: 893526
URL: http://svn.apache.org/viewvc?rev=893526&view=rev
Log:
ARIES-89: Implement application support: start parsing an enterprise bundle
application
Added:
incubator/aries/trunk/application/application-management/pom.xml
incubator/aries/trunk/application/application-management/src/
incubator/aries/trunk/application/application-management/src/main/
incubator/aries/trunk/application/application-management/src/main/java/
incubator/aries/trunk/application/application-management/src/main/java/org/
incubator/aries/trunk/application/application-management/src/main/java/org/apache/
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java
incubator/aries/trunk/application/application-management/src/main/resources/
incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/
incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/
incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml
Modified:
incubator/aries/trunk/application/application-management/ (props changed)
Propchange: incubator/aries/trunk/application/application-management/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Dec 23 14:31:28 2009
@@ -0,0 +1,4 @@
+target
+.classpath
+.project
+.settings
Added: incubator/aries/trunk/application/application-management/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/pom.xml?rev=893526&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-management/pom.xml (added)
+++ incubator/aries/trunk/application/application-management/pom.xml Wed Dec 23
14:31:28 2009
@@ -0,0 +1,59 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>application</artifactId>
+ <version>1.0.0-incubating-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.aries.application.management</groupId>
+ <artifactId>org.apache.aries.application.management</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Aries application management</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.api</artifactId>
+ <version>1.0.0-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.utils</artifactId>
+ <version>1.0.0-incubating-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <dependencyManagement>
+ <dependencies>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <sourceDirectory>.src/main/java</sourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+
<Bundle-SymbolicName>${pom.groupId}.management</Bundle-SymbolicName>
+
<Private-Package>org.apache.aries.application.management.impl</Private-Package>
+
<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
+
<_removeheaders>Ignore-Package,Include-Resource,Private-Package,Bundle-DocURL</_removeheaders>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added:
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
URL:
http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java?rev=893526&view=auto
==============================================================================
---
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
(added)
+++
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
Wed Dec 23 14:31:28 2009
@@ -0,0 +1,64 @@
+/*
+ * 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 WARRANTIESOR 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.application.management.impl;
+
+import java.io.File;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.DeploymentMetadata;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.BundleInfo;
+import org.osgi.framework.Bundle;
+
+public class AriesApplicationImpl implements AriesApplication {
+
+ public AriesApplicationImpl(ApplicationMetadata meta, List<Bundle> bundles)
{}
+ public AriesApplicationImpl () {}
+
+ public ApplicationMetadata getApplicationMetadata() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Set<BundleInfo> getBundles() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public DeploymentMetadata getDeploymentMetadata() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void store(File f) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void store(OutputStream in) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added:
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java?rev=893526&view=auto
==============================================================================
---
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java
(added)
+++
incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java
Wed Dec 23 14:31:28 2009
@@ -0,0 +1,147 @@
+/*
+ * 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 WARRANTIESOR 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.application.management.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.ApplicationMetadataManager;
+import org.apache.aries.application.management.ApplicationContext;
+import org.apache.aries.application.management.ApplicationListener;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.management.ManagementException;
+import org.apache.aries.application.utils.AppConstants;
+import org.apache.aries.application.utils.manifest.ManifestDefaultsInjector;
+import org.apache.aries.application.utils.manifest.ManifestProcessor;
+import org.osgi.framework.Bundle;
+
+public class AriesApplicationManagerImpl implements AriesApplicationManager {
+
+ private ApplicationMetadataManager _applicationMetadataManager;
+
+ public void setApplicationMetadataManager (ApplicationMetadataManager amm) {
+ _applicationMetadataManager = amm;
+ }
+
+
+
+ /**
+ * Create an AriesApplication from a .eba file
+ */
+ public AriesApplication createApplication(File ebaFile) throws
ManagementException {
+ /*
+ * ebaFile should be a zip file with a '.eba' extension
+ * as per http://incubator.apache.org/aries/applications.html
+ */
+
+ ApplicationMetadata applicationMetadata;
+ List<Bundle> bundlesInEba;
+
+ try {
+ if (!ebaFile.isFile()) {
+ throw new ManagementException ("Cannot create .eba from directory
yet");
+ }
+ ZipFile zipFile = new ZipFile(ebaFile);
+ Manifest applicationManifest = new Manifest();
+
+ // TODO: If there's a deployment.mf we can ignore the rest of the content
+
+ // Locate META-INF/APPLICATION.MF
+ ZipEntry entry = null;
+ Enumeration<? extends ZipEntry> entries = zipFile.entries();
+ while (entries.hasMoreElements()) {
+ entry = entries.nextElement();
+ if (entry.getName().replace("\\",
"/").equalsIgnoreCase(AppConstants.APPLICATION_MF)) {
+ applicationManifest =
ManifestProcessor.parseManifest(zipFile.getInputStream(entry));
+ break;
+ }
+ // Also look for application.xml to support .war file migration
+ }
+
+ // Ensure that the manifest has the necessary fields set
+ boolean manifestChanged =
ManifestDefaultsInjector.updateManifest(applicationManifest, ebaFile.getName(),
ebaFile);
+
+ applicationMetadata =
_applicationMetadataManager.createApplicationMetadata(applicationManifest);
+
+ // Process any other files in the .eba
+ // i.e. migrate wars to wabs
+
+ // Validate contents
+
+ // Perform provisioning
+
+ // Create deployment.mf if missing
+
+ // Write out updated .eba if we changed its contents
+
+ } catch (IOException iox) {
+ throw new ManagementException(iox);
+ }
+
+
+ // AriesApplication ariesApp = new AriesApplicationImpl (appMeta,
bundlesInEba);
+ return null; // ariesApp
+ }
+
+ public AriesApplication createApplication(URL url) throws
ManagementException {
+ return null;
+ }
+
+ public ApplicationContext getApplicationContext(AriesApplication app) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Set<ApplicationContext> getApplicationContexts() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ApplicationContext install(AriesApplication app) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void uninstall(ApplicationContext app) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void addApplicationListener(ApplicationListener l) {
+ // Need application listener lifecycle support
+ }
+
+ public void removeApplicationListener(ApplicationListener l) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+}
Added:
incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml
URL:
http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml?rev=893526&view=auto
==============================================================================
---
incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml
(added)
+++
incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml
Wed Dec 23 14:31:28 2009
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <bean id="app-manager"
class="org.apache.aries.application.management.impl.AriesApplicationManagerImpl"
scope="singleton" activation="lazy">
+ <property name="applicationMetadataManager" ref="app-metadata-manager"/>
+ </bean>
+
+ <reference id="app-metadata-manager" interface="ApplicationMetadataManager"/>
+
+ <service
interface="org.apache.aries.application.management.AriesApplicationManager"
ref="manager-service" />
+</blueprint>