package org.eclipse.jetty.osgi.boot;

import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppProvider;
import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.component.AbstractLifeCycle;

public class OSGiAppProvider extends AbstractLifeCycle implements AppProvider
{
    DeploymentManager _manager;
    
    public ContextHandler createContextHandler(App app) throws Exception
    {
        return null;
    }

    public void setDeploymentManager(DeploymentManager deploymentManager)
    {
        _manager=deploymentManager;
    }

}

@@ -31,16 +31,133 @@
 .boot;%0A%0A
+import java.io.File;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.concurrent.ConcurrentHashMap;%0A%0A
 import o
@@ -185,16 +185,16 @@
 oy.App;%0A
-
 import o
@@ -505,24 +505,114 @@
 r _manager;%0A
+    Map%3CContextHandler,OSGiApp%3E _apps = new ConcurrentHashMap%3CContextHandler, OSGiApp%3E();%0A
     %0A    pub
@@ -694,16 +694,19 @@
     
+ //
  return 
 null
@@ -705,12 +705,66 @@
 urn 
-null
+pre-created Context%0A        return ((OSGiApp)app)._context
 ;%0A  
@@ -891,10 +891,1248 @@
 %0A    %7D%0A%0A
+    public void addContext(ContextHandler context) throws Exception%0A    %7B%0A        // TODO apply configuration specific to this provider%0A        %0A        // wrap context as an App%0A        OSGiApp app = new OSGiApp(_manager,this,context.getDisplayName(),null,context);%0A        _apps.put(context,app);%0A        _manager.addApp(app);%0A    %7D%0A%0A    public void addContext(String contextxml) throws Exception%0A    %7B%0A        // TODO apply configuration specific to this provider%0A        // TODO construct ContextHandler%0A        ContextHandler context=null;%0A        // wrap context as an App%0A        OSGiApp app = new OSGiApp(_manager,this,context.getDisplayName(),null,context);%0A        _apps.put(context,app);%0A        _manager.addApp(app);%0A    %7D%0A    %0A    public void removeContext(ContextHandler context) throws Exception%0A    %7B%0A        // wrap context as an App%0A        OSGiApp app = _apps.get(context);%0A        %0A    %7D%0A    %0A    %0A    class OSGiApp extends App%0A    %7B%0A        final ContextHandler _context;%0A        public OSGiApp(DeploymentManager manager, AppProvider provider, String originId, File archivePath, ContextHandler context)%0A        %7B%0A            super(manager,provider,originId,archivePath);%0A            _context=context;%0A        %7D%0A    %7D%0A
 %7D%0A

work in progress for OSGi boot to use Deployment manager