You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by pa...@apache.org on 2011/09/13 16:06:22 UTC

svn commit: r1170188 [1/7] - in /incubator/ace/trunk: ./ ace-deployment-verifier-ui/ ace-deployment-verifier-ui/src/ ace-deployment-verifier-ui/src/main/ ace-deployment-verifier-ui/src/main/java/ ace-deployment-verifier-ui/src/main/java/org/ ace-deploy...

Author: pauls
Date: Tue Sep 13 14:06:20 2011
New Revision: 1170188

URL: http://svn.apache.org/viewvc?rev=1170188&view=rev
Log:
Provide extension that can verify a deployment for a given target (ACE-180)

Added:
    incubator/ace/trunk/ace-deployment-verifier/
    incubator/ace/trunk/ace-deployment-verifier-ui/
    incubator/ace/trunk/ace-deployment-verifier-ui/pom.xml
    incubator/ace/trunk/ace-deployment-verifier-ui/src/
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java
    incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/Activator.java
    incubator/ace/trunk/ace-deployment-verifier/pom.xml
    incubator/ace/trunk/ace-deployment-verifier/src/
    incubator/ace/trunk/ace-deployment-verifier/src/main/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/VerifierService.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/Activator.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierBundleRevision.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierResolverState.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierServiceImpl.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/Logger.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/capabilityset/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/Candidates.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/HostBundleRevision.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/ResolveException.java   (with props)
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/Resolver.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/ResolverWire.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/resolver/ResourceNotFoundException.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/FelixConstants.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/MapToDictionary.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/SecureAction.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/StringComparator.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/Util.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/VersionRange.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/manifestparser/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/manifestparser/ParsedHeaderClause.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/util/manifestparser/R4LibraryClause.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/wiring/
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java
    incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/wiring/BundleWireImpl.java
    incubator/ace/trunk/ace-deployment-verifier/src/test/
    incubator/ace/trunk/ace-deployment-verifier/src/test/java/
    incubator/ace/trunk/ace-deployment-verifier/src/test/java/org/
    incubator/ace/trunk/ace-deployment-verifier/src/test/java/org/apache/
    incubator/ace/trunk/ace-deployment-verifier/src/test/java/org/apache/ace/
    incubator/ace/trunk/ace-deployment-verifier/src/test/java/org/apache/ace/deployment/
    incubator/ace/trunk/ace-deployment-verifier/src/test/java/org/apache/ace/deployment/verifier/
    incubator/ace/trunk/ace-deployment-verifier/src/test/java/org/apache/ace/deployment/verifier/impl/
    incubator/ace/trunk/ace-deployment-verifier/src/test/java/org/apache/ace/deployment/verifier/impl/VerifierTest.java
Modified:
    incubator/ace/trunk/ace-target-devserver/pom.xml
    incubator/ace/trunk/pom.xml
    incubator/ace/trunk/pom/pom.xml

Added: incubator/ace/trunk/ace-deployment-verifier-ui/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier-ui/pom.xml?rev=1170188&view=auto
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier-ui/pom.xml (added)
+++ incubator/ace/trunk/ace-deployment-verifier-ui/pom.xml Tue Sep 13 14:06:20 2011
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ace</groupId>
+        <artifactId>ace-pom</artifactId>
+        <version>0.8.1-incubator-SNAPSHOT</version>
+        <relativePath>../pom/pom.xml</relativePath>
+    </parent>
+
+    <version>0.8.1-incubator-SNAPSHOT</version>
+    <artifactId>org.apache.ace.deployment.verifier.ui</artifactId>
+    <packaging>bundle</packaging>
+
+    <name>Apache ACE :: Deployment :: Verifier :: UI</name>
+    <description />
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/ace/trunk/ace-deployment-verifier-ui</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/ace/trunk/ace-deployment-verifier-ui</developerConnection>
+        <url>http://svn.apache.org/repos/asf/incubator/ace/trunk/ace-deployment-verifier-ui</url>
+    </scm>
+
+   <properties>
+        <private.package>
+            org.apache.ace.deployment.verifier.ui
+        </private.package>
+        <bundle.activator>
+            org.apache.ace.deployment.verifier.ui.Activator
+        </bundle.activator>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.deployment.verifier</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.dependencymanager</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.webui.vaadin</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.vaadin</groupId>
+            <artifactId>vaadin</artifactId>
+        </dependency>
+    </dependencies>
+</project>

Added: incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java?rev=1170188&view=auto
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java (added)
+++ incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java Tue Sep 13 14:06:20 2011
@@ -0,0 +1,240 @@
+/*
+ * 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.ace.deployment.verifier.ui;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarInputStream;
+
+import org.apache.ace.client.repository.RepositoryObject;
+import org.apache.ace.client.repository.object.DeploymentArtifact;
+import org.apache.ace.client.repository.object.DeploymentVersionObject;
+import org.apache.ace.client.repository.object.GatewayObject;
+import org.apache.ace.client.repository.repository.DeploymentVersionRepository;
+import org.apache.ace.deployment.verifier.VerifierService;
+import org.apache.ace.deployment.verifier.VerifierService.VerifyEnvironment;
+import org.apache.ace.deployment.verifier.VerifierService.VerifyReporter;
+import org.apache.ace.webui.NamedObject;
+import org.apache.ace.webui.UIExtensionFactory;
+import org.osgi.framework.Constants;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.service.log.LogEntry;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.VerticalLayout;
+
+public class ACEVerifierExtension implements UIExtensionFactory {
+	volatile VerifierService m_verifier;
+	volatile DeploymentVersionRepository m_repo;
+
+	public Component create(Map<String, Object> context) {
+		RepositoryObject object = getRepositoryObjectFromContext(context);
+		
+		String id = object.getAttribute(GatewayObject.KEY_ID);
+		return new ManifestArea(id, (object.getAttribute("manifest") == null) ?  
+				Constants.BUNDLE_MANIFESTVERSION + ": " + "2" + "\n" +
+				Constants.BUNDLE_SYMBOLICNAME + ": " + "org.apache.felix.framework" + "\n" +
+				Constants.EXPORT_PACKAGE + ": " + VerifierService.SYSTEM_PACKAGES + "," + VerifierService.JRE_1_6_PACKAGES + "," +
+				"org.osgi.service.cm;version=1.2,org.osgi.service.metatype;version=1.1.1,org.osgi.service.cm; version=1.3.0,org.osgi.service.deploymentadmin.spi; version=1.0.1,org.osgi.service.deploymentadmin; version=1.1.0" + "\n":
+			    object.getAttribute("manifest"), object);
+		
+	}
+
+    private RepositoryObject getRepositoryObjectFromContext(Map<String, Object> context) {
+        Object contextObject = context.get("object");
+        if (contextObject == null) {
+            throw new IllegalStateException("No context object found");
+        }
+        // It looks like there is some bug (or some other reason that escapes
+        // me)
+        // why ace is using either the object directly or wraps it in a
+        // NamedObject first.
+        // Its unclear when it does which so for now we cater for both.
+        return ((RepositoryObject) (contextObject instanceof NamedObject ? ((NamedObject) contextObject)
+                .getObject() : contextObject));
+    }
+    
+    class ManifestArea extends VerticalLayout implements
+    Property.ValueChangeListener   {
+    	private volatile String text;
+    	private final com.vaadin.ui.TextArea editor;
+    	private final String m_id;
+    	private TextArea plainText;
+    	private final RepositoryObject m_object;
+
+        public ManifestArea(String id, String initialText, RepositoryObject object) {
+        	m_object = object;
+        	setCaption("VerifyResolve");
+        	m_id = id;
+            setSpacing(true);
+            setWidth("100%");
+            text = initialText;
+            editor = new com.vaadin.ui.TextArea(null, initialText);
+            editor.setRows(18);
+            editor.addListener(this);
+            editor.setImmediate(true);
+            editor.setWidth("100%");
+            editor.setHeight("70%");
+            addComponent(editor);
+
+            Button verify = new Button("Verify");
+            verify.addListener(new ClickListener() {
+				private PopupView popup;
+				public void buttonClick(ClickEvent event) {
+
+		            plainText.setReadOnly(false);
+					try {
+						DeploymentVersionObject version = m_repo.getMostRecentDeploymentVersion(m_id);
+						if (version != null)
+						{
+							DeploymentArtifact[] artifacts = version.getDeploymentArtifacts();
+							ByteArrayOutputStream output = new ByteArrayOutputStream();
+							final PrintStream out = new PrintStream(output);
+							Set<BundleRevision> bundles = new HashSet<BundleRevision>();
+							StringTokenizer tok = new StringTokenizer(editor.getValue().toString(), ":\n");
+							Map<String, String> manMap = new HashMap<String, String>();
+							while (tok.hasMoreTokens()) {
+								manMap.put(tok.nextToken(), tok.nextToken());
+							}
+							String ee = manMap.get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
+							if (ee == null) {
+								ee = VerifierService.EE_1_6;
+							}
+							final Map<String, String> envMap = new HashMap<String, String>();
+							envMap.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee);
+							VerifyEnvironment env = m_verifier.createEnvironment(envMap, new VerifyReporter() {
+								
+								public void reportWire(BundleRevision importer,
+										BundleRequirement reqirement, BundleRevision exporter,
+										BundleCapability capability) {
+									out.println("WIRE: " + reqirement + " -> " + capability + "\n");
+								}
+								
+								public void reportLog(LogEntry logEntry) {
+									out.println("Log(" + logEntry.getTime() + "): " + logEntry.getLevel() + " " + logEntry.getMessage());
+									if (logEntry.getException() != null) {
+										logEntry.getException().printStackTrace();
+									}
+								}
+								
+								public void reportException(Exception ex) {
+									ex.printStackTrace(out);
+								}
+							});
+							
+							bundles.add(env.addBundle(0, manMap));
+							Set<String> customizers = new HashSet<String>();
+							Set<String> processors = new HashSet<String>();
+							for (DeploymentArtifact data : artifacts) {
+								if (data.getDirective(Constants.BUNDLE_SYMBOLICNAME) != null) {
+									JarInputStream input = null;
+									try
+									{ 
+										input = new JarInputStream(new URL(data.getUrl()).openStream(), false);
+										final Attributes attributes = input.getManifest().getMainAttributes();
+										Map<String, String> manifest = new HashMap<String, String>();
+										for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
+											manifest.put(entry.getKey().toString(), entry.getValue().toString());
+										}
+										bundles.add(env.addBundle(bundles.size(), manifest));
+										if (attributes.getValue("DeploymentPackage-Customizer") != null) {
+											String typeString = attributes.getValue("Deployment-ProvidesResourceProcessor");
+											if (typeString != null) {
+												String[] types = typeString.split(",");
+												for (String type : types) {
+													customizers.add(type.trim());
+												}
+											}
+										}
+									} catch (Exception ex) {
+										ex.printStackTrace();
+									}
+									finally {
+										if (input != null) {
+											try {
+												input.close();
+											} catch (Exception ex) {
+												ex.printStackTrace();
+											}
+										}
+									}
+								}
+								else {
+									String processor = data.getDirective("Resource-Processor");
+									if (processor != null) {
+										processors.add(processor.trim());
+									}
+								}
+							}
+							plainText.setValue((
+									"Customizers match: " + customizers.containsAll(processors) + "\n" 
+									+ " (provided=" + customizers + ",required=" + processors + ")\n\n"
+									+ "Resolve: " + env.verifyResolve(bundles, null, null) + "\n\n"
+									+ output.toString()));
+						}
+						
+					} catch (Exception e) {
+						ByteArrayOutputStream output = new ByteArrayOutputStream();
+						e.printStackTrace(new PrintStream(output));
+						plainText.setValue(output.toString());
+					}
+
+					if (popup != null) {
+						removeComponent(popup);
+					}
+
+		            plainText.setReadOnly(true);
+					popup = new PopupView("Result", plainText);
+					popup.setHideOnMouseOut(false);
+					addComponent(popup);
+					popup.setPopupVisible(true);
+				}
+				
+			});
+            addComponent(verify);
+            plainText = new TextArea();
+            plainText.setImmediate(true);
+            plainText.setWidth("600px");
+            plainText.setHeight("400px");
+        }
+        
+        public void valueChange(ValueChangeEvent event) {
+            String text = (String) editor.getValue();
+            if (text != null) {
+            	m_object.addAttribute("manifest", text);
+            }
+        }
+    }
+}

Added: incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/Activator.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/Activator.java?rev=1170188&view=auto
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/Activator.java (added)
+++ incubator/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/Activator.java Tue Sep 13 14:06:20 2011
@@ -0,0 +1,57 @@
+/*
+ * 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.ace.deployment.verifier.ui;
+
+import java.util.Properties;
+
+import org.apache.ace.client.repository.repository.DeploymentVersionRepository;
+import org.apache.ace.deployment.verifier.VerifierService;
+import org.apache.ace.webui.UIExtensionFactory;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends DependencyActivatorBase {
+
+	@Override
+	public void init(BundleContext context, DependencyManager manager)
+			throws Exception {
+		manager.add(createComponent().setInterface(
+                UIExtensionFactory.class.getName(), new Properties() {
+                    {
+                        put(UIExtensionFactory.EXTENSION_POINT_KEY, UIExtensionFactory.EXTENSION_POINT_VALUE_TARGET);
+                    }
+                }).setImplementation(ACEVerifierExtension.class)
+                .add(createServiceDependency()
+                		.setService(VerifierService.class)
+                		.setRequired(true))
+                .add(createServiceDependency()
+                        .setService(DeploymentVersionRepository.class)
+                        .setRequired(true)
+                        ));
+	}
+
+	@Override
+	public void destroy(BundleContext context, DependencyManager manager)
+			throws Exception {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

Added: incubator/ace/trunk/ace-deployment-verifier/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier/pom.xml?rev=1170188&view=auto
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier/pom.xml (added)
+++ incubator/ace/trunk/ace-deployment-verifier/pom.xml Tue Sep 13 14:06:20 2011
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ace</groupId>
+        <artifactId>ace-pom</artifactId>
+        <version>0.8.1-incubator-SNAPSHOT</version>
+        <relativePath>../pom/pom.xml</relativePath>
+    </parent>
+
+    <version>0.8.1-incubator-SNAPSHOT</version>
+    <artifactId>org.apache.ace.deployment.verifier</artifactId>
+    <packaging>bundle</packaging>
+
+    <name>Apache ACE :: Deployment :: Verifier</name>
+    <description />
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/ace/trunk/ace-deployment-verifier</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/ace/trunk/ace-deployment-verifier</developerConnection>
+        <url>http://svn.apache.org/repos/asf/incubator/ace/trunk/ace-deployment-verifier</url>
+    </scm>
+
+    <properties>
+        <export.package>
+            org.apache.ace.deployment.verifier;version=${project.version},org.osgi.service.log,org.osgi.framework.wiring
+        </export.package>
+        <private.package>
+            org.apache.felix.*,org.apache.ace.deployment.verifier.impl.*
+        </private.package>
+        <import.package>
+            org.osgi.framework;version="[1.5,2)",*
+        </import.package>
+        <bundle.activator>
+            org.apache.ace.deployment.verifier.impl.Activator
+        </bundle.activator>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

Added: incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/VerifierService.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/VerifierService.java?rev=1170188&view=auto
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/VerifierService.java (added)
+++ incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/VerifierService.java Tue Sep 13 14:06:20 2011
@@ -0,0 +1,57 @@
+/*
+ * 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.ace.deployment.verifier;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.osgi.framework.BundleException;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.service.log.LogEntry;
+
+
+public interface VerifierService {
+	public static final String EE_1_7 = "JavaSE-1.6,JavaSE-1.7,J2SE-1.5,J2SE-1.4,J2SE-1.3,OSGi/Minimum-1.2,OSGi/Minimum-1.1,OSGi/Minimum-1.0";
+	public static final String EE_1_6 = "JavaSE-1.6,J2SE-1.5,J2SE-1.4,J2SE-1.3,OSGi/Minimum-1.2,OSGi/Minimum-1.1,OSGi/Minimum-1.0";
+	public static final String EE_1_5 = "J2SE-1.5,J2SE-1.4,J2SE-1.3,OSGi/Minimum-1.2,OSGi/Minimum-1.1,OSGi/Minimum-1.0";
+	public static final String EE_1_4 = "J2SE-1.4,J2SE-1.3,OSGi/Minimum-1.2,OSGi/Minimum-1.1,OSGi/Minimum-1.0";
+	public static final String EE_1_3 = "J2SE-1.3,OSGi/Minimum-1.1,OSGi/Minimum-1.0";
+	
+	public static final String SYSTEM_PACKAGES = "org.osgi.framework; version=1.5.0,org.osgi.framework.launch; version=1.0.0,org.osgi.framework.hooks.service; version=1.0.0,org.osgi.service.packageadmin; version=1.2.0,org.osgi.service.startlevel; version=1.1.0,org.osgi.service.url; version=1.0.0,org.osgi.util.tracker; version=1.4.0";
+	public static final String JRE_1_3_PACKAGES = "javax.accessibility;javax.naming;javax.naming.directory;javax.naming.event;javax.naming.ldap;javax.naming.spi;javax.rmi;javax.rmi.CORBA;javax.sound.midi;javax.sound.midi.spi;javax.sound.sampled;javax.sound.sampled.spi;javax.swing;javax.swing.border;javax.swing.colorchooser;javax.swing.event;javax.swing.filechooser;javax.swing.plaf;javax.swing.plaf.basic;javax.swing.plaf.metal;javax.swing.plaf.multi;javax.swing.table;javax.swing.text;javax.swing.text.html;javax.swing.text.html.parser;javax.swing.text.rtf;javax.swing.tree;javax.swing.undo;javax.transaction;org.omg.CORBA;org.omg.CORBA_2_3;org.omg.CORBA_2_3.portable;org.omg.CORBA.DynAnyPackage;org.omg.CORBA.ORBPackage;org.omg.CORBA.portable;org.omg.CORBA.TypeCodePackage;org.omg.CosNaming;org.omg.CosNaming.NamingContextPackage;org.omg.SendingContext;org.omg.stub.java.rmi;version=\"0.0.0.1_003_J2SE\"";
+	public static final String JRE_1_4_PACKAGES="javax.accessibility;javax.crypto;javax.crypto.interfaces;javax.crypto.spec;javax.imageio;javax.imageio.event;javax.imageio.metadata;javax.imageio.plugins.jpeg;javax.imageio.spi;javax.imageio.stream;javax.naming;javax.naming.directory;javax.naming.event;javax.naming.ldap;javax.naming.spi;javax.net;javax.net.ssl;javax.print;javax.print.attribute;javax.print.attribute.standard;javax.print.event;javax.rmi;javax.rmi.CORBA;javax.security.auth;javax.security.auth.callback;javax.security.auth.kerberos;javax.security.auth.login;javax.security.auth.spi;javax.security.auth.x500;javax.security.cert;javax.sound.midi;javax.sound.midi.spi;javax.sound.sampled;javax.sound.sampled.spi;javax.sql;javax.swing;javax.swing.border;javax.swing.colorchooser;javax.swing.event;javax.swing.filechooser;javax.swing.plaf;javax.swing.plaf.basic;javax.swing.plaf.metal;javax.swing.plaf.multi;javax.swing.table;javax.swing.text;javax.swing.text.html;javax.swing.text
 .html.parser;javax.swing.text.rtf;javax.swing.tree;javax.swing.undo;javax.transaction;javax.transaction.xa;javax.xml.parsers;javax.xml.transform;javax.xml.transform.dom;javax.xml.transform.sax;javax.xml.transform.stream;org.ietf.jgss;org.omg.CORBA;org.omg.CORBA_2_3;org.omg.CORBA_2_3.portable;org.omg.CORBA.DynAnyPackage;org.omg.CORBA.ORBPackage;org.omg.CORBA.portable;org.omg.CORBA.TypeCodePackage;org.omg.CosNaming;org.omg.CosNaming.NamingContextExtPackage;org.omg.CosNaming.NamingContextPackage;org.omg.Dynamic;org.omg.DynamicAny;org.omg.DynamicAny.DynAnyFactoryPackage;org.omg.DynamicAny.DynAnyPackage;org.omg.IOP;org.omg.IOP.CodecFactoryPackage;org.omg.IOP.CodecPackage;org.omg.Messaging;org.omg.PortableInterceptor;org.omg.PortableInterceptor.ORBInitInfoPackage;org.omg.PortableServer;org.omg.PortableServer.CurrentPackage;org.omg.PortableServer.POAManagerPackage;org.omg.PortableServer.POAPackage;org.omg.PortableServer.portable;org.omg.PortableServer.ServantLocatorPackage;org.omg.
 SendingContext;org.omg.stub.java.rmi;org.w3c.dom;org.w3c.dom.css;org.w3c.dom.events;org.w3c.dom.html;org.w3c.dom.stylesheets;org.w3c.dom.traversal;org.w3c.dom.views;org.xml.sax;org.xml.sax.ext;org.xml.sax.helpers;version=\"0.0.0.1_004_J2SE\"";
+	public static final String JRE_1_5_PACKAGES="javax.accessibility;javax.activity;javax.crypto;javax.crypto.interfaces;javax.crypto.spec;javax.imageio;javax.imageio.event;javax.imageio.metadata;javax.imageio.plugins.bmp;javax.imageio.plugins.jpeg;javax.imageio.spi;javax.imageio.stream;javax.management;javax.management.loading;javax.management.modelmbean;javax.management.monitor;javax.management.openmbean;javax.management.relation;javax.management.remote;javax.management.remote.rmi;javax.management.timer;javax.naming;javax.naming.directory;javax.naming.event;javax.naming.ldap;javax.naming.spi;javax.net;javax.net.ssl;javax.print;javax.print.attribute;javax.print.attribute.standard;javax.print.event;javax.rmi;javax.rmi.CORBA;javax.rmi.ssl;javax.security.auth;javax.security.auth.callback;javax.security.auth.kerberos;javax.security.auth.login;javax.security.auth.spi;javax.security.auth.x500;javax.security.cert;javax.security.sasl;javax.sound.midi;javax.sound.midi.spi;javax.sound.s
 ampled;javax.sound.sampled.spi;javax.sql;javax.sql.rowset;javax.sql.rowset.serial;javax.sql.rowset.spi;javax.swing;javax.swing.border;javax.swing.colorchooser;javax.swing.event;javax.swing.filechooser;javax.swing.plaf;javax.swing.plaf.basic;javax.swing.plaf.metal;javax.swing.plaf.multi;javax.swing.plaf.synth;javax.swing.table;javax.swing.text;javax.swing.text.html;javax.swing.text.html.parser;javax.swing.text.rtf;javax.swing.tree;javax.swing.undo;javax.transaction;javax.transaction.xa;javax.xml;javax.xml.datatype;javax.xml.namespace;javax.xml.parsers;javax.xml.transform;javax.xml.transform.dom;javax.xml.transform.sax;javax.xml.transform.stream;javax.xml.validation;javax.xml.xpath;org.ietf.jgss;org.omg.CORBA;org.omg.CORBA_2_3;org.omg.CORBA_2_3.portable;org.omg.CORBA.DynAnyPackage;org.omg.CORBA.ORBPackage;org.omg.CORBA.portable;org.omg.CORBA.TypeCodePackage;org.omg.CosNaming;org.omg.CosNaming.NamingContextExtPackage;org.omg.CosNaming.NamingContextPackage;org.omg.Dynamic;org.om
 g.DynamicAny;org.omg.DynamicAny.DynAnyFactoryPackage;org.omg.DynamicAny.DynAnyPackage;org.omg.IOP;org.omg.IOP.CodecFactoryPackage;org.omg.IOP.CodecPackage;org.omg.Messaging;org.omg.PortableInterceptor;org.omg.PortableInterceptor.ORBInitInfoPackage;org.omg.PortableServer;org.omg.PortableServer.CurrentPackage;org.omg.PortableServer.POAManagerPackage;org.omg.PortableServer.POAPackage;org.omg.PortableServer.portable;org.omg.PortableServer.ServantLocatorPackage;org.omg.SendingContext;org.omg.stub.java.rmi;org.omg.stub.javax.management.remote.rmi;org.w3c.dom;org.w3c.dom.bootstrap;org.w3c.dom.css;org.w3c.dom.events;org.w3c.dom.html;org.w3c.dom.ls;org.w3c.dom.ranges;org.w3c.dom.stylesheets;org.w3c.dom.traversal;org.w3c.dom.views;org.xml.sax;org.xml.sax.ext;org.xml.sax.helpers;version=\"0.0.0.1_005_J2SE\"";
+	public static final String JRE_1_6_PACKAGES="javax.accessibility;javax.activation;javax.activity;javax.annotation;javax.annotation.processing;javax.crypto;javax.crypto.interfaces;javax.crypto.spec;javax.imageio;javax.imageio.event;javax.imageio.metadata;javax.imageio.plugins.bmp;javax.imageio.plugins.jpeg;javax.imageio.spi;javax.imageio.stream;javax.jws;javax.jws.soap;javax.lang.model;javax.lang.model.element;javax.lang.model.type;javax.lang.model.util;javax.management;javax.management.loading;javax.management.modelmbean;javax.management.monitor;javax.management.openmbean;javax.management.relation;javax.management.remote;javax.management.remote.rmi;javax.management.timer;javax.naming;javax.naming.directory;javax.naming.event;javax.naming.ldap;javax.naming.spi;javax.net;javax.net.ssl;javax.print;javax.print.attribute;javax.print.attribute.standard;javax.print.event;javax.rmi;javax.rmi.CORBA;javax.rmi.ssl;javax.script;javax.security.auth;javax.security.auth.callback;javax.sec
 urity.auth.kerberos;javax.security.auth.login;javax.security.auth.spi;javax.security.auth.x500;javax.security.cert;javax.security.sasl;javax.sound.midi;javax.sound.midi.spi;javax.sound.sampled;javax.sound.sampled.spi;javax.sql;javax.sql.rowset;javax.sql.rowset.serial;javax.sql.rowset.spi;javax.swing;javax.swing.border;javax.swing.colorchooser;javax.swing.event;javax.swing.filechooser;javax.swing.plaf;javax.swing.plaf.basic;javax.swing.plaf.metal;javax.swing.plaf.multi;javax.swing.plaf.synth;javax.swing.table;javax.swing.text;javax.swing.text.html;javax.swing.text.html.parser;javax.swing.text.rtf;javax.swing.tree;javax.swing.undo;javax.tools;javax.transaction;javax.transaction.xa;javax.xml;javax.xml.bind;javax.xml.bind.annotation;javax.xml.bind.annotation.adapters;javax.xml.bind.attachment;javax.xml.bind.helpers;javax.xml.bind.util;javax.xml.crypto;javax.xml.crypto.dom;javax.xml.crypto.dsig;javax.xml.crypto.dsig.dom;javax.xml.crypto.dsig.keyinfo;javax.xml.crypto.dsig.spec;jav
 ax.xml.datatype;javax.xml.namespace;javax.xml.parsers;javax.xml.soap;javax.xml.stream;javax.xml.stream.events;javax.xml.stream.util;javax.xml.transform;javax.xml.transform.dom;javax.xml.transform.sax;javax.xml.transform.stax;javax.xml.transform.stream;javax.xml.validation;javax.xml.ws;javax.xml.ws.handler;javax.xml.ws.handler.soap;javax.xml.ws.http;javax.xml.ws.soap;javax.xml.ws.spi;javax.xml.ws.wsaddressing;javax.xml.xpath;org.ietf.jgss;org.omg.CORBA;org.omg.CORBA_2_3;org.omg.CORBA_2_3.portable;org.omg.CORBA.DynAnyPackage;org.omg.CORBA.ORBPackage;org.omg.CORBA.portable;org.omg.CORBA.TypeCodePackage;org.omg.CosNaming;org.omg.CosNaming.NamingContextExtPackage;org.omg.CosNaming.NamingContextPackage;org.omg.Dynamic;org.omg.DynamicAny;org.omg.DynamicAny.DynAnyFactoryPackage;org.omg.DynamicAny.DynAnyPackage;org.omg.IOP;org.omg.IOP.CodecFactoryPackage;org.omg.IOP.CodecPackage;org.omg.Messaging;org.omg.PortableInterceptor;org.omg.PortableInterceptor.ORBInitInfoPackage;org.omg.Porta
 bleServer;org.omg.PortableServer.CurrentPackage;org.omg.PortableServer.POAManagerPackage;org.omg.PortableServer.POAPackage;org.omg.PortableServer.portable;org.omg.PortableServer.ServantLocatorPackage;org.omg.SendingContext;org.omg.stub.java.rmi;org.omg.stub.javax.management.remote.rmi;org.w3c.dom;org.w3c.dom.bootstrap;org.w3c.dom.css;org.w3c.dom.events;org.w3c.dom.html;org.w3c.dom.ls;org.w3c.dom.ranges;org.w3c.dom.stylesheets;org.w3c.dom.traversal;org.w3c.dom.views;org.w3c.dom.xpath;org.xml.sax;org.xml.sax.ext;org.xml.sax.helpers;version=\"0.0.0.1_006_JavaSE\"";
+	public static final String JRE_1_7_PACKAGES="javax.accessibility;javax.activation;javax.activity;javax.annotation;javax.annotation.processing;javax.crypto;javax.crypto.interfaces;javax.crypto.spec;javax.imageio;javax.imageio.event;javax.imageio.metadata;javax.imageio.plugins.bmp;javax.imageio.plugins.jpeg;javax.imageio.spi;javax.imageio.stream;javax.jws;javax.jws.soap;javax.lang.model;javax.lang.model.element;javax.lang.model.type;javax.lang.model.util;javax.management;javax.management.loading;javax.management.modelmbean;javax.management.monitor;javax.management.openmbean;javax.management.relation;javax.management.remote;javax.management.remote.rmi;javax.management.timer;javax.naming;javax.naming.directory;javax.naming.event;javax.naming.ldap;javax.naming.spi;javax.net;javax.net.ssl;javax.print;javax.print.attribute;javax.print.attribute.standard;javax.print.event;javax.rmi;javax.rmi.CORBA;javax.rmi.ssl;javax.script;javax.security.auth;javax.security.auth.callback;javax.sec
 urity.auth.kerberos;javax.security.auth.login;javax.security.auth.spi;javax.security.auth.x500;javax.security.cert;javax.security.sasl;javax.smartcardio;javax.sound.midi;javax.sound.midi.spi;javax.sound.sampled;javax.sound.sampled.spi;javax.sql;javax.sql.rowset;javax.sql.rowset.serial;javax.sql.rowset.spi;javax.swing;javax.swing.border;javax.swing.colorchooser;javax.swing.event;javax.swing.filechooser;javax.swing.plaf;javax.swing.plaf.basic;javax.swing.plaf.metal;javax.swing.plaf.multi;javax.swing.plaf.nimbus;javax.swing.plaf.synth;javax.swing.table;javax.swing.text;javax.swing.text.html;javax.swing.text.html.parser;javax.swing.text.rtf;javax.swing.tree;javax.swing.undo;javax.tools;javax.transaction;javax.transaction.xa;javax.xml;javax.xml.bind;javax.xml.bind.annotation;javax.xml.bind.annotation.adapters;javax.xml.bind.attachment;javax.xml.bind.helpers;javax.xml.bind.util;javax.xml.crypto;javax.xml.crypto.dom;javax.xml.crypto.dsig;javax.xml.crypto.dsig.dom;javax.xml.crypto.d
 sig.keyinfo;javax.xml.crypto.dsig.spec;javax.xml.datatype;javax.xml.namespace;javax.xml.parsers;javax.xml.soap;javax.xml.stream;javax.xml.stream.events;javax.xml.stream.util;javax.xml.transform;javax.xml.transform.dom;javax.xml.transform.sax;javax.xml.transform.stax;javax.xml.transform.stream;javax.xml.validation;javax.xml.ws;javax.xml.ws.handler;javax.xml.ws.handler.soap;javax.xml.ws.http;javax.xml.ws.soap;javax.xml.ws.spi;javax.xml.ws.spi.http;javax.xml.ws.wsaddressing;javax.xml.xpath;org.ietf.jgss;org.omg.CORBA;org.omg.CORBA.DynAnyPackage;org.omg.CORBA.ORBPackage;org.omg.CORBA.TypeCodePackage;org.omg.CORBA.portable;org.omg.CORBA_2_3;org.omg.CORBA_2_3.portable;org.omg.CosNaming;org.omg.CosNaming.NamingContextExtPackage;org.omg.CosNaming.NamingContextPackage;org.omg.Dynamic;org.omg.DynamicAny;org.omg.DynamicAny.DynAnyFactoryPackage;org.omg.DynamicAny.DynAnyPackage;org.omg.IOP;org.omg.IOP.CodecFactoryPackage;org.omg.IOP.CodecPackage;org.omg.Messaging;org.omg.PortableIntercep
 tor;org.omg.PortableInterceptor.ORBInitInfoPackage;org.omg.PortableServer;org.omg.PortableServer.CurrentPackage;org.omg.PortableServer.POAManagerPackage;org.omg.PortableServer.POAPackage;org.omg.PortableServer.ServantLocatorPackage;org.omg.PortableServer.portable;org.omg.SendingContext;org.omg.stub.java.rmi;org.omg.stub.javax.management.remote.rmi;org.w3c.dom;org.w3c.dom.bootstrap;org.w3c.dom.css;org.w3c.dom.events;org.w3c.dom.html;org.w3c.dom.ls;org.w3c.dom.ranges;org.w3c.dom.stylesheets;org.w3c.dom.traversal;org.w3c.dom.views;org.w3c.dom.xpath;org.xml.sax;org.xml.sax.ext;org.xml.sax.helpers;version=\"0.0.0.1_007_JavaSE\"";
+	
+	public interface VerifyReporter {
+        void reportWire(BundleRevision importer, BundleRequirement reqirement, BundleRevision exporter, BundleCapability capability);
+		void reportLog(LogEntry logEntry);
+		void reportException(Exception ex);
+		
+	}
+	public interface VerifyEnvironment {
+		public BundleRevision addBundle(long id, Map<String, String> manifest) throws BundleException;
+		public boolean verifyResolve(Set<BundleRevision> mandatory, Set<BundleRevision> optional, Set<BundleRevision> ondemandFragments);
+	}
+	
+	public VerifyEnvironment createEnvironment(Map<String, String> config, VerifyReporter reporter);
+}
\ No newline at end of file

Added: incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/Activator.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/Activator.java?rev=1170188&view=auto
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/Activator.java (added)
+++ incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/Activator.java Tue Sep 13 14:06:20 2011
@@ -0,0 +1,34 @@
+/*
+ * 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.ace.deployment.verifier.impl;
+
+import org.apache.ace.deployment.verifier.VerifierService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+	public void start(BundleContext context) throws Exception {
+		context.registerService(VerifierService.class.getName(), new VerifierServiceImpl(), null);
+	}
+
+	public void stop(BundleContext context) throws Exception {
+	}
+
+}

Added: incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierBundleRevision.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierBundleRevision.java?rev=1170188&view=auto
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierBundleRevision.java (added)
+++ incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierBundleRevision.java Tue Sep 13 14:06:20 2011
@@ -0,0 +1,155 @@
+/*
+ * 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.ace.deployment.verifier.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.felix.framework.Logger;
+import org.apache.felix.framework.util.manifestparser.ManifestParser;
+import org.apache.felix.framework.util.manifestparser.R4Library;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.BundleWiring;
+
+public class VerifierBundleRevision implements BundleRevision {
+	private final String m_symbolicName;
+	private final Version m_version;
+	private final List<BundleCapability> m_declaredCaps;
+	private final List<BundleRequirement> m_declaredReqs;
+	private final int m_type;
+	private final Bundle m_bundle;
+	private final List<R4Library> m_declaredLibs;
+	private final Map<String, String> m_headers;
+
+	public VerifierBundleRevision(Logger log, Bundle bundle, Map<String, String> config, Map<String, String> headers) throws BundleException {
+		m_bundle = bundle;
+		m_headers = Collections.unmodifiableMap(headers);
+		ManifestParser parser = new ManifestParser(log, config, this, headers);
+		m_symbolicName = parser.getSymbolicName();
+		m_version = parser.getBundleVersion();
+		m_declaredCaps = (m_bundle.getBundleId() != 0) ? parser.getCapabilities() : aliasSymbolicName(parser.getCapabilities());
+		m_declaredReqs = parser.getRequirements();
+		m_type = headers.containsKey(Constants.FRAGMENT_HOST) ? BundleRevision.TYPE_FRAGMENT : 0;
+		m_declaredLibs = parser.getLibraries();
+	}
+
+	private static List<BundleCapability> aliasSymbolicName(List<BundleCapability> caps)
+    {
+        if (caps == null)
+        {
+            return new ArrayList<BundleCapability>(0);
+        }
+
+        List<BundleCapability> aliasCaps = new ArrayList<BundleCapability>(caps);
+
+        for (int capIdx = 0; capIdx < aliasCaps.size(); capIdx++)
+        {
+            // Get the attributes and search for bundle symbolic name.
+            for (Entry<String, Object> entry : aliasCaps.get(capIdx).getAttributes().entrySet())
+            {
+                // If there is a bundle symbolic name attribute, add the
+                // standard alias as a value.
+                if (entry.getKey().equalsIgnoreCase(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE))
+                {
+                    // Make a copy of the attribute array.
+                    Map<String, Object> aliasAttrs =
+                        new HashMap<String, Object>(aliasCaps.get(capIdx).getAttributes());
+                    // Add the aliased value.
+                    aliasAttrs.put(
+                        Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE,
+                        new String[] {
+                            (String) entry.getValue(),
+                            Constants.SYSTEM_BUNDLE_SYMBOLICNAME});
+                    // Create the aliased capability to replace the old capability.
+                    aliasCaps.set(capIdx, new BundleCapabilityImpl(
+                        caps.get(capIdx).getRevision(),
+                        caps.get(capIdx).getNamespace(),
+                        caps.get(capIdx).getDirectives(),
+                        aliasAttrs));
+                    // Continue with the next capability.
+                    break;
+                }
+            }
+        }
+
+        return aliasCaps;
+    }
+	
+	public Bundle getBundle() {
+		return m_bundle;
+	}
+
+	public String getSymbolicName() {
+		return m_symbolicName;
+	}
+
+	public Version getVersion() {
+		return m_version;
+	}
+
+	public List<BundleCapability> getDeclaredCapabilities(String namespace) {
+		return m_declaredCaps;
+	}
+
+	public List<BundleRequirement> getDeclaredRequirements(String namespace) {
+		return m_declaredReqs;
+	}
+	
+	public List<R4Library> getDeclaredNativeLibraries() {
+		return m_declaredLibs;
+	}
+
+	public int getTypes() {
+		return m_type;
+	}
+
+	public BundleWiring getWiring() {
+		return null;
+	}
+
+	public Map<String, String> getHeaders() {
+		return m_headers;
+	}
+	
+	public int hashCode() {
+		return (int) getBundle().getBundleId();
+	}
+	
+	public boolean equals(Object o) {
+		if (o instanceof VerifierBundleRevision) {
+			return o.hashCode() == hashCode();
+		}
+		return false;
+	}
+	
+	public String toString() {
+		return m_symbolicName + ";"+ Constants.VERSION_ATTRIBUTE + "=" + m_version + "(id=" + getBundle().getBundleId() + ")";
+	}
+}

Added: incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierResolverState.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierResolverState.java?rev=1170188&view=auto
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierResolverState.java (added)
+++ incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierResolverState.java Tue Sep 13 14:06:20 2011
@@ -0,0 +1,357 @@
+/*
+ * 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.ace.deployment.verifier.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+import org.apache.felix.framework.capabilityset.CapabilitySet;
+import org.apache.felix.framework.capabilityset.SimpleFilter;
+import org.apache.felix.framework.resolver.CandidateComparator;
+import org.apache.felix.framework.resolver.ResolveException;
+import org.apache.felix.framework.resolver.Resolver;
+import org.apache.felix.framework.util.Util;
+import org.apache.felix.framework.util.manifestparser.R4Library;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
+import org.osgi.framework.Constants;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+
+public class VerifierResolverState implements Resolver.ResolverState {
+
+	// Set of all revisions.
+	private final Set<BundleRevision> m_revisions;
+	// Set of all fragments.
+	private final Set<BundleRevision> m_fragments;
+	// Capability sets.
+	private final Map<String, CapabilitySet> m_capSets;
+	// Execution environment.
+	private final String m_fwkExecEnvStr;
+	// Parsed framework environments
+	private final Set<String> m_fwkExecEnvSet;
+
+	// void dump()
+	// {
+	// for (Entry<String, CapabilitySet> entry : m_capSets.entrySet())
+	// {
+	// System.out.println("+++ START CAPSET " + entry.getKey());
+	// entry.getValue().dump();
+	// System.out.println("+++ END CAPSET " + entry.getKey());
+	// }
+	// }
+
+	public VerifierResolverState(String fwkExecEnvStr) {
+		m_revisions = new HashSet<BundleRevision>();
+		m_fragments = new HashSet<BundleRevision>();
+		m_capSets = new HashMap<String, CapabilitySet>();
+
+		m_fwkExecEnvStr = (fwkExecEnvStr != null) ? fwkExecEnvStr.trim() : null;
+		m_fwkExecEnvSet = parseExecutionEnvironments(fwkExecEnvStr);
+
+		List<String> indices = new ArrayList<String>();
+		indices.add(BundleRevision.BUNDLE_NAMESPACE);
+		m_capSets.put(BundleRevision.BUNDLE_NAMESPACE, new CapabilitySet(
+				indices, true));
+
+		indices = new ArrayList<String>();
+		indices.add(BundleRevision.PACKAGE_NAMESPACE);
+		m_capSets.put(BundleRevision.PACKAGE_NAMESPACE, new CapabilitySet(
+				indices, true));
+
+		indices = new ArrayList<String>();
+		indices.add(BundleRevision.HOST_NAMESPACE);
+		m_capSets.put(BundleRevision.HOST_NAMESPACE, new CapabilitySet(indices,
+				true));
+	}
+
+	synchronized Set<BundleRevision> getUnresolvedRevisions() {
+		Set<BundleRevision> unresolved = new HashSet<BundleRevision>();
+		for (BundleRevision revision : m_revisions) {
+			if (revision.getWiring() == null) {
+				unresolved.add(revision);
+			}
+		}
+		return unresolved;
+	}
+
+	synchronized void addRevision(BundleRevision br) {
+		// Always attempt to remove the revision, since
+		// this method can be used for re-indexing a revision
+		// after it has been resolved.
+		removeRevision(br);
+
+		// Add the revision and index its declared or resolved
+		// capabilities depending on whether it is resolved or
+		// not.
+		m_revisions.add(br);
+		List<BundleCapability> caps = (br.getWiring() == null) ? br
+				.getDeclaredCapabilities(null) : br.getWiring()
+				.getCapabilities(null);
+		if (caps != null) {
+			for (BundleCapability cap : caps) {
+				// If the capability is from a different revision, then
+				// don't index it since it is a capability from a fragment.
+				// In that case, the fragment capability is still indexed.
+				if (cap.getRevision() == br) {
+					CapabilitySet capSet = m_capSets.get(cap.getNamespace());
+					if (capSet == null) {
+						capSet = new CapabilitySet(null, true);
+						m_capSets.put(cap.getNamespace(), capSet);
+					}
+					capSet.addCapability(cap);
+				}
+			}
+		}
+
+		if (Util.isFragment(br)) {
+			m_fragments.add(br);
+		}
+	}
+
+	synchronized void removeRevision(BundleRevision br) {
+		if (m_revisions.remove(br)) {
+			// We only need be concerned with declared capabilities here,
+			// because resolved capabilities will be a subset.
+			List<BundleCapability> caps = br.getDeclaredCapabilities(null);
+			if (caps != null) {
+				for (BundleCapability cap : caps) {
+					CapabilitySet capSet = m_capSets.get(cap.getNamespace());
+					if (capSet != null) {
+						capSet.removeCapability(cap);
+					}
+				}
+			}
+
+			if (Util.isFragment(br)) {
+				m_fragments.remove(br);
+			}
+		}
+	}
+
+	synchronized Set<BundleRevision> getFragments() {
+		return new HashSet(m_fragments);
+	}
+
+	//
+	// ResolverState methods.
+	//
+
+	public boolean isEffective(BundleRequirement req) {
+		String effective = req.getDirectives().get(
+				Constants.EFFECTIVE_DIRECTIVE);
+		return ((effective == null) || effective
+				.equals(Constants.EFFECTIVE_RESOLVE));
+	}
+
+	public synchronized SortedSet<BundleCapability> getCandidates(
+			BundleRequirement req, boolean obeyMandatory) {
+		BundleRevision reqRevision = req.getRevision();
+		SortedSet<BundleCapability> result = new TreeSet<BundleCapability>(
+				new CandidateComparator());
+
+		CapabilitySet capSet = m_capSets.get(req.getNamespace());
+		if (capSet != null) {
+			// Get the requirement's filter; if this is our own impl we
+			// have a shortcut to get the already parsed filter, otherwise
+			// we must parse it from the directive.
+			SimpleFilter sf = null;
+			if (req instanceof BundleRequirementImpl) {
+				sf = ((BundleRequirementImpl) req).getFilter();
+			} else {
+				String filter = req.getDirectives().get(
+						Constants.FILTER_DIRECTIVE);
+				if (filter == null) {
+					sf = new SimpleFilter(null, null, SimpleFilter.MATCH_ALL);
+				} else {
+					sf = SimpleFilter.parse(filter);
+				}
+			}
+
+			// Find the matching candidates.
+			Set<BundleCapability> matches = capSet.match(sf, obeyMandatory);
+			for (BundleCapability cap : matches) {
+				/* TODO: karl - is this correct?
+				 * if (System.getSecurityManager() != null) {
+					if (req.getNamespace().equals(
+							BundleRevision.PACKAGE_NAMESPACE)
+							&& (!((BundleProtectionDomain) ((BundleRevisionImpl) cap
+									.getRevision()).getProtectionDomain())
+									.impliesDirect(new PackagePermission(
+											(String) cap
+													.getAttributes()
+													.get(BundleRevision.PACKAGE_NAMESPACE),
+											PackagePermission.EXPORTONLY)) || !((reqRevision == null) || ((BundleProtectionDomain) reqRevision
+									.getProtectionDomain())
+									.impliesDirect(new PackagePermission(
+											(String) cap
+													.getAttributes()
+													.get(BundleRevision.PACKAGE_NAMESPACE),
+											cap.getRevision().getBundle(),
+											PackagePermission.IMPORT))))) {
+						if (reqRevision != cap.getRevision()) {
+							continue;
+						}
+					} else if (req.getNamespace().equals(
+							BundleRevision.BUNDLE_NAMESPACE)
+							&& (!((BundleProtectionDomain) ((BundleRevisionImpl) cap
+									.getRevision()).getProtectionDomain())
+									.impliesDirect(new BundlePermission(cap
+											.getRevision().getSymbolicName(),
+											BundlePermission.PROVIDE)) || !((reqRevision == null) || ((BundleProtectionDomain) reqRevision
+									.getProtectionDomain())
+									.impliesDirect(new BundlePermission(
+											reqRevision.getSymbolicName(),
+											BundlePermission.REQUIRE))))) {
+						continue;
+					} else if (req.getNamespace().equals(
+							BundleRevision.HOST_NAMESPACE)
+							&& (!((BundleProtectionDomain) reqRevision
+									.getProtectionDomain())
+									.impliesDirect(new BundlePermission(
+											reqRevision.getSymbolicName(),
+											BundlePermission.FRAGMENT)) || !((BundleProtectionDomain) ((BundleRevisionImpl) cap
+									.getRevision()).getProtectionDomain())
+									.impliesDirect(new BundlePermission(cap
+											.getRevision().getSymbolicName(),
+											BundlePermission.HOST)))) {
+						continue;
+					}
+				}*/
+
+				if (req.getNamespace().equals(BundleRevision.HOST_NAMESPACE)
+						&& (cap.getRevision().getWiring() != null)) {
+					continue;
+				}
+
+				result.add(cap);
+			}
+		}
+
+		// If we have resolver hooks, then we may need to filter our results
+		// based on a whitelist and/or fine-grained candidate filtering.
+		/*TODO: karl - is this correct?
+		 * if (!result.isEmpty() && !m_hooks.isEmpty()) {
+		 
+			// It we have a whitelist, then first filter out candidates
+			// from disallowed revisions.
+			if (m_whitelist != null) {
+				for (Iterator<BundleCapability> it = result.iterator(); it
+						.hasNext();) {
+					if (!m_whitelist.contains(it.next().getRevision())) {
+						it.remove();
+					}
+				}
+			}
+
+			// Now give the hooks a chance to do fine-grained filtering.
+			ShrinkableCollection<BundleCapability> shrinkable = new ShrinkableCollection<BundleCapability>(
+					result);
+			for (ResolverHook hook : m_hooks) {
+				try {
+					Felix.m_secureAction.invokeResolverHookMatches(hook, req,
+							shrinkable);
+				} catch (Throwable th) {
+					m_logger.log(Logger.LOG_WARNING,
+							"Resolver hook exception.", th);
+				}
+			}
+		}*/
+
+		return result;
+	}
+
+	public void checkExecutionEnvironment(BundleRevision revision)
+			throws ResolveException {
+		String bundleExecEnvStr = (String) ((VerifierBundleRevision) revision)
+				.getHeaders()
+				.get(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT);
+		if (bundleExecEnvStr != null) {
+			bundleExecEnvStr = bundleExecEnvStr.trim();
+
+			// If the bundle has specified an execution environment and the
+			// framework has an execution environment specified, then we must
+			// check for a match.
+			if (!bundleExecEnvStr.equals("") && (m_fwkExecEnvStr != null)
+					&& (m_fwkExecEnvStr.length() > 0)) {
+				StringTokenizer tokens = new StringTokenizer(bundleExecEnvStr,
+						",");
+				boolean found = false;
+				while (tokens.hasMoreTokens() && !found) {
+					if (m_fwkExecEnvSet.contains(tokens.nextToken().trim())) {
+						found = true;
+					}
+				}
+				if (!found) {
+					throw new ResolveException(
+							"Execution environment not supported: "
+									+ bundleExecEnvStr, revision, null);
+				}
+			}
+		}
+	}
+
+	public void checkNativeLibraries(BundleRevision revision)
+			throws ResolveException {
+		// Next, try to resolve any native code, since the revision is
+		// not resolvable if its native code cannot be loaded.
+		List<R4Library> libs = ((VerifierBundleRevision) revision)
+				.getDeclaredNativeLibraries();
+		if (libs != null) {
+			// If we have a zero-length native library array, then
+			// this means no native library class could be selected
+			// so we should fail to resolve.
+			if (libs.isEmpty()) {
+				throw new ResolveException("No matching native libraries found.", revision, null);
+			}
+		}
+	}
+
+	//
+	// Utility methods.
+	//
+
+	/**
+	 * Updates the framework wide execution environment string and a cached Set
+	 * of execution environment tokens from the comma delimited list specified
+	 * by the system variable 'org.osgi.framework.executionenvironment'.
+	 * 
+	 * @param fwkExecEnvStr
+	 *            Comma delimited string of provided execution environments
+	 * @return the parsed set of execution environments
+	 **/
+	private static Set<String> parseExecutionEnvironments(String fwkExecEnvStr) {
+		Set<String> newSet = new HashSet<String>();
+		if (fwkExecEnvStr != null) {
+			StringTokenizer tokens = new StringTokenizer(fwkExecEnvStr, ",");
+			while (tokens.hasMoreTokens()) {
+				newSet.add(tokens.nextToken().trim());
+			}
+		}
+		return newSet;
+	}
+
+}

Added: incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierServiceImpl.java?rev=1170188&view=auto
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierServiceImpl.java (added)
+++ incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/ace/deployment/verifier/impl/VerifierServiceImpl.java Tue Sep 13 14:06:20 2011
@@ -0,0 +1,321 @@
+/*
+ * 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.ace.deployment.verifier.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.cert.X509Certificate;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.apache.ace.deployment.verifier.VerifierService;
+import org.apache.felix.framework.Logger;
+import org.apache.felix.framework.resolver.Resolver;
+import org.apache.felix.framework.resolver.ResolverImpl;
+import org.apache.felix.framework.resolver.ResolverWire;
+import org.apache.felix.framework.util.MapToDictionary;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.service.log.LogEntry;
+
+public class VerifierServiceImpl implements VerifierService {
+	public VerifyEnvironment createEnvironment(Map<String, String> config, VerifyReporter reporter) {
+		return new VerifyEnvironmentImpl(config, reporter);
+	}
+
+	private static final class VerifyEnvironmentImpl implements
+			VerifierService.VerifyEnvironment {
+		final Logger m_log = new Logger();
+		final VerifyReporter m_reporter;
+		final Map<String, String> m_config;
+		private final Map<Long, VerifierBundleRevision> m_bundles = new HashMap<Long, VerifierBundleRevision>();
+
+		public VerifyEnvironmentImpl(Map<String, String> config,
+				VerifyReporter reporter) {
+			m_config = config;
+			if (reporter == null) {
+				m_reporter = new VerifyReporter() {
+
+					public void reportWire(BundleRevision importer,
+							BundleRequirement reqirement,
+							BundleRevision exporter, BundleCapability capability) {
+						// TODO Auto-generated method stub
+
+					}
+
+					public void reportLog(LogEntry entry) {
+						// TODO Auto-generated method stub
+
+					}
+
+					public void reportException(Exception ex) {
+						// TODO Auto-generated method stub
+
+					}
+				};
+			} else {
+				m_reporter = reporter;
+			}
+			m_log.setLogger(new Object() {
+				@SuppressWarnings("unused")
+				public void log(final ServiceReference ref, final int level,
+						final String message, final Throwable t) {
+					final long time = System.currentTimeMillis();
+					m_reporter.reportLog(new LogEntry() {
+
+						public long getTime() {
+							return time;
+						}
+
+						public ServiceReference getServiceReference() {
+							return ref;
+						}
+
+						public String getMessage() {
+							return message;
+						}
+
+						public int getLevel() {
+							return level;
+						}
+
+						public Throwable getException() {
+							return t;
+						}
+
+						public Bundle getBundle() {
+							return null;
+						}
+					});
+				}
+			});
+			m_log.setLogLevel(Logger.LOG_DEBUG);
+		}
+
+		public boolean verifyResolve(Set<BundleRevision> mandatory,
+				Set<BundleRevision> optional,
+				Set<BundleRevision> ondemandFragments) {
+
+			VerifierResolverState state = new VerifierResolverState(
+					this.m_config.get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT));
+			for (VerifierBundleRevision rev : m_bundles.values()) {
+				state.addRevision(rev);
+			}
+			Resolver resolver = new ResolverImpl(m_log);
+			try {
+				Map<BundleRevision, List<ResolverWire>> result = resolver
+						.resolve(
+								state,
+								(mandatory == null) ? new HashSet<BundleRevision>()
+										: mandatory,
+								(optional == null) ? new HashSet<BundleRevision>()
+										: optional,
+								(ondemandFragments == null) ? new HashSet<BundleRevision>()
+										: ondemandFragments);
+				for (Entry<BundleRevision, List<ResolverWire>> entry : result
+						.entrySet()) {
+					for (ResolverWire wire : entry.getValue()) {
+						m_reporter.reportWire(wire.getRequirer(),
+								wire.getRequirement(), wire.getProvider(),
+								wire.getCapability());
+					}
+				}
+			} catch (Exception ex) {
+				m_reporter.reportException(ex);
+				return false;
+			}
+			return true;
+		}
+
+		public BundleRevision addBundle(final long id,
+				final Map<String, String> manifest) throws BundleException {
+			if (m_bundles.containsKey(id)) {
+				throw new BundleException("Bundle already exists for id: " + id);
+			}
+			VerifierBundleRevision rev = null;
+			m_bundles.put(id, (rev = new VerifierBundleRevision(m_log,
+					new Bundle() {
+
+						public int compareTo(Bundle o) {
+							return (int) (o.getBundleId() - getBundleId());
+						}
+
+						public int getState() {
+							return Bundle.INSTALLED;
+						}
+
+						public void start(int options) throws BundleException {
+							// TODO Auto-generated method stub
+
+						}
+
+						public void start() throws BundleException {
+							// TODO Auto-generated method stub
+
+						}
+
+						public void stop(int options) throws BundleException {
+							// TODO Auto-generated method stub
+
+						}
+
+						public void stop() throws BundleException {
+							// TODO Auto-generated method stub
+
+						}
+
+						public void update(InputStream input)
+								throws BundleException {
+							// TODO Auto-generated method stub
+
+						}
+
+						public void update() throws BundleException {
+							// TODO Auto-generated method stub
+
+						}
+
+						public void uninstall() throws BundleException {
+							// TODO Auto-generated method stub
+
+						}
+
+						public Dictionary<String, String> getHeaders() {
+							return new MapToDictionary(manifest);
+						}
+
+						public long getBundleId() {
+							return id;
+						}
+
+						public String getLocation() {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public ServiceReference<?>[] getRegisteredServices() {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public ServiceReference<?>[] getServicesInUse() {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public boolean hasPermission(Object permission) {
+							// TODO Auto-generated method stub
+							return false;
+						}
+
+						public URL getResource(String name) {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public Dictionary<String, String> getHeaders(
+								String locale) {
+							return getHeaders();
+						}
+
+						public String getSymbolicName() {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public Class<?> loadClass(String name)
+								throws ClassNotFoundException {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public Enumeration<URL> getResources(String name)
+								throws IOException {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public Enumeration<String> getEntryPaths(String path) {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public URL getEntry(String path) {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public long getLastModified() {
+							// TODO Auto-generated method stub
+							return 0;
+						}
+
+						public Enumeration<URL> findEntries(String path,
+								String filePattern, boolean recurse) {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public BundleContext getBundleContext() {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(
+								int signersType) {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public Version getVersion() {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public <A> A adapt(Class<A> type) {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+						public File getDataFile(String filename) {
+							// TODO Auto-generated method stub
+							return null;
+						}
+
+					}, m_config, manifest)));
+			return rev;
+		}
+
+	}
+}

Added: incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/Logger.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/Logger.java?rev=1170188&view=auto
==============================================================================
--- incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/Logger.java (added)
+++ incubator/ace/trunk/ace-deployment-verifier/src/main/java/org/apache/felix/framework/Logger.java Tue Sep 13 14:06:20 2011
@@ -0,0 +1,324 @@
+/*
+ * 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.framework;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import org.osgi.framework.*;
+
+/**
+ * <p>
+ * This class mimics the standard OSGi <tt>LogService</tt> interface. An
+ * instance of this class is used by the framework for all logging. By default
+ * this class logs messages to standard out. The log level can be set to
+ * control the amount of logging performed, where a higher number results in
+ * more logging. A log level of zero turns off logging completely.
+ * </p>
+ * <p>
+ * The log levels match those specified in the OSGi Log Service (i.e., 1 = error,
+ * 2 = warning, 3 = information, and 4 = debug). The default value is 1.
+ * </p>
+ * <p>
+ * This class also uses the System Bundle's context to track log services
+ * and will use the highest ranking log service, if present, as a back end
+ * instead of printing to standard out. The class uses reflection to invoking
+ * the log service's method to avoid a dependency on the log interface.
+ * </p>
+**/
+public class Logger implements ServiceListener
+{
+    public static final int LOG_ERROR = 1;
+    public static final int LOG_WARNING = 2;
+    public static final int LOG_INFO = 3;
+    public static final int LOG_DEBUG = 4;
+
+    private int m_logLevel = 1;
+    private BundleContext m_context = null;
+
+    private final static int LOGGER_OBJECT_IDX = 0;
+    private final static int LOGGER_METHOD_IDX = 1;
+    private ServiceReference m_logRef = null;
+    private Object[] m_logger = null;
+
+    public Logger()
+    {
+    }
+
+    public final synchronized void setLogLevel(int i)
+    {
+        m_logLevel = i;
+    }
+
+    public final synchronized int getLogLevel()
+    {
+        return m_logLevel;
+    }
+
+    protected void setSystemBundleContext(BundleContext context)
+    {
+        // TODO: Find a way to log to a log service inside the framework.
+        // The issue is that we log messages while holding framework
+        // internal locks -- hence, when a log service calls back into 
+        // the framework (e.g., by loading a class) we might deadlock. 
+        // One instance of this problem is tracked in FELIX-536.
+        // For now we just disable logging to log services inside the
+        // framework. 
+
+        // m_context = context;
+        // startListeningForLogService();
+    }
+
+    public final void log(int level, String msg)
+    {
+        _log(null, null, level, msg, null);
+    }
+
+    public final void log(int level, String msg, Throwable throwable)
+    {
+        _log(null, null, level, msg, throwable);
+    }
+
+    public final void log(ServiceReference sr, int level, String msg)
+    {
+        _log(null, sr, level, msg, null);
+    }
+
+    public final void log(ServiceReference sr, int level, String msg, Throwable throwable)
+    {
+        _log(null, sr, level, msg, throwable);
+    }
+
+    public final void log(Bundle bundle, int level, String msg)
+    {
+        _log(bundle, null, level, msg, null);
+    }
+
+    public final void log(Bundle bundle, int level, String msg, Throwable throwable)
+    {
+        _log(bundle, null, level, msg, throwable);
+    }
+
+    protected void doLog(
+        Bundle bundle, ServiceReference sr, int level,
+        String msg, Throwable throwable)
+    {
+        String s = "";
+        if (sr != null)
+        {
+            s = s + "SvcRef "  + sr + " ";
+        }
+        else if (bundle != null)
+        {
+            s = s + "Bundle " + bundle.toString() + " ";
+        }
+        s = s + msg;
+        if (throwable != null)
+        {
+            s = s + " (" + throwable + ")";
+        }
+        switch (level)
+        {
+            case LOG_DEBUG:
+                System.out.println("DEBUG: " + s);
+                break;
+            case LOG_ERROR:
+                System.out.println("ERROR: " + s);
+                if (throwable != null)
+                {
+                    if ((throwable instanceof BundleException) &&
+                        (((BundleException) throwable).getNestedException() != null))
+                    {
+                        throwable = ((BundleException) throwable).getNestedException();
+                    }
+                    throwable.printStackTrace();
+                }
+                break;
+            case LOG_INFO:
+                System.out.println("INFO: " + s);
+                break;
+            case LOG_WARNING:
+                System.out.println("WARNING: " + s);
+                break;
+            default:
+                System.out.println("UNKNOWN[" + level + "]: " + s);
+        }
+    }
+
+    private void _log(
+        Bundle bundle, ServiceReference sr, int level,
+        String msg, Throwable throwable)
+    {
+        // Save our own copy just in case it changes. We could try to do
+        // more conservative locking here, but let's be optimistic.
+        Object[] logger = m_logger;
+
+        if (m_logLevel >= level)
+        {
+            // Use the log service if available.
+            if (logger != null)
+            {
+                _logReflectively(logger, sr, level, msg, throwable);
+            }
+            // Otherwise, default logging action.
+            else
+            {
+                doLog(bundle, sr, level, msg, throwable);
+            }
+        }
+    }
+
+    private void _logReflectively(
+        Object[] logger, ServiceReference sr, int level, String msg, Throwable throwable)
+    {
+        if (logger != null)
+        {
+            Object[] params = {
+                sr, new Integer(level), msg, throwable
+            };
+            try
+            {
+                ((Method) logger[LOGGER_METHOD_IDX]).invoke(logger[LOGGER_OBJECT_IDX], params);
+            }
+            catch (InvocationTargetException ex)
+            {
+                System.err.println("Logger: " + ex);
+            }
+            catch (IllegalAccessException ex)
+            {
+                System.err.println("Logger: " + ex);
+            }
+        }
+    }
+
+    /**
+     * This method is called when the system bundle context is set;
+     * it simply adds a service listener so that the system bundle can track
+     * log services to be used as the back end of the logging mechanism. It also
+     * attempts to get an existing log service, if present, but in general
+     * there will never be a log service present since the system bundle is
+     * started before every other bundle.
+    **/
+    private synchronized void startListeningForLogService()
+    {
+        // Add a service listener for log services.
+        try
+        {
+            m_context.addServiceListener(
+                this, "(objectClass=org.osgi.service.log.LogService)");
+        }
+        catch (InvalidSyntaxException ex) {
+            // This will never happen since the filter is hard coded.
+        }
+        // Try to get an existing log service.
+        m_logRef = m_context.getServiceReference("org.osgi.service.log.LogService");
+        // Get the service object if available and set it in the logger.
+        if (m_logRef != null)
+        {
+            setLogger(m_context.getService(m_logRef));
+        }
+    }
+
+    /**
+     * This method implements the callback for the ServiceListener interface.
+     * It is public as a byproduct of implementing the interface and should
+     * not be called directly. This method tracks run-time changes to log
+     * service availability. If the log service being used by the framework's
+     * logging mechanism goes away, then this will try to find an alternative.
+     * If a higher ranking log service is registered, then this will switch
+     * to the higher ranking log service.
+    **/
+    public final synchronized void serviceChanged(ServiceEvent event)
+    {
+        // If no logger is in use, then grab this one.
+        if ((event.getType() == ServiceEvent.REGISTERED) && (m_logRef == null))
+        {
+            m_logRef = event.getServiceReference();
+            // Get the service object and set it in the logger.
+            setLogger(m_context.getService(m_logRef));
+        }
+        // If a logger is in use, but this one has a higher ranking, then swap
+        // it for the existing logger.
+        else if ((event.getType() == ServiceEvent.REGISTERED) && (m_logRef != null))
+        {
+            ServiceReference ref =
+                m_context.getServiceReference("org.osgi.service.log.LogService");
+            if (!ref.equals(m_logRef))
+            {
+                m_context.ungetService(m_logRef);
+                m_logRef = ref;
+                setLogger(m_context.getService(m_logRef));
+            }
+
+        }
+        // If the current logger is going away, release it and try to
+        // find another one.
+        else if ((event.getType() == ServiceEvent.UNREGISTERING) &&
+            m_logRef.equals(event.getServiceReference()))
+        {
+            // Unget the service object.
+            m_context.ungetService(m_logRef);
+            // Try to get an existing log service.
+            m_logRef = m_context.getServiceReference(
+                "org.osgi.service.log.LogService");
+            // Get the service object if available and set it in the logger.
+            if (m_logRef != null)
+            {
+                setLogger(m_context.getService(m_logRef));
+            }
+            else
+            {
+                setLogger(null);
+            }
+        }
+    }
+
+    /**
+     * This method sets the new log service object. It also caches the method to
+     * invoke. The service object and method are stored in array to optimistically
+     * eliminate the need to locking when logging.
+    **/
+    public void setLogger(Object logObj)
+    {
+        if (logObj == null)
+        {
+            m_logger = null;
+        }
+        else
+        {
+            Class[] formalParams = {
+                ServiceReference.class,
+                Integer.TYPE,
+                String.class,
+                Throwable.class
+            };
+
+            try
+            {
+                Method logMethod = logObj.getClass().getMethod("log", formalParams);
+                logMethod.setAccessible(true);
+                m_logger = new Object[] { logObj, logMethod };
+            }
+            catch (NoSuchMethodException ex)
+            {
+                System.err.println("Logger: " + ex);
+                m_logger = null;
+            }
+        }
+    }
+}