geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r601152 [2/4] - in /geronimo/server/trunk: ./ applications/welcome/geronimo-welcome/src/main/java/org/apache/geronimo/welcome/ assemblies/geronimo-boilerplate-minimal/src/main/underlay/META-INF/ assemblies/geronimo-boilerplate-minimal/src/m...
Date Tue, 04 Dec 2007 23:49:09 GMT
Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/InPlaceConfigurationUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/InPlaceConfigurationUtil.java?rev=601152&r1=601151&r2=601152&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/InPlaceConfigurationUtil.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/InPlaceConfigurationUtil.java Tue Dec  4 15:49:03 2007
@@ -30,28 +30,29 @@
 import org.apache.geronimo.kernel.config.ConfigurationData;
 
 /**
+ * //todo make this package access again!
  * @version $Rev$ $Date$
  */
-class InPlaceConfigurationUtil {
-	private static final String IN_PLACE_LOCATION_FILE = "inPlaceLocation.config";
-	
-    InPlaceConfigurationUtil() {
+public class InPlaceConfigurationUtil {
+    private static final String IN_PLACE_LOCATION_FILE = "inPlaceLocation.config";
+
+    public InPlaceConfigurationUtil() {
     }
 
     public boolean isInPlaceConfiguration(File source) {
         File inPlaceLocation = getInPlaceLocation(source);
         return inPlaceLocation.exists();
     }
-    
+
     public void writeInPlaceLocation(ConfigurationData configurationData, File source) throws IOException {
-    	if (null == configurationData.getInPlaceConfigurationDir()) {
-    		return;
-    	}
+        if (null == configurationData.getInPlaceConfigurationDir()) {
+            return;
+        }
 
         File inPlaceLocation = getInPlaceLocation(source);
         Writer writer = null;
         try {
-        	OutputStream os = new FileOutputStream(inPlaceLocation);
+            OutputStream os = new FileOutputStream(inPlaceLocation);
             writer = new PrintWriter(os);
             File inPlaceConfigurationDir = configurationData.getInPlaceConfigurationDir();
             String absolutePath = inPlaceConfigurationDir.getAbsolutePath();
@@ -59,36 +60,36 @@
             writer.close(); // also flushes the stream and shouldn't normally fail
             writer = null;
         } finally {
-        	if (null != writer) {
-        		try {
-        			writer.close();
-				} catch (IOException ignored) {
+            if (null != writer) {
+                try {
+                    writer.close();
+                } catch (IOException ignored) {
                     // ignored
-				}
-        	}
+                }
+            }
         }
     }
-    
+
     public File readInPlaceLocation(File source) throws IOException {
         File inPlaceLocation = getInPlaceLocation(source);
-        
+
         if (!inPlaceLocation.exists()) {
-        	return null;
+            return null;
         }
-        
+
         BufferedReader reader = null;
         try {
-        	InputStream is = new FileInputStream(inPlaceLocation);
-        	reader = new BufferedReader(new InputStreamReader(is));
-        	String path = reader.readLine();
-        	return new File(path);
+            InputStream is = new FileInputStream(inPlaceLocation);
+            reader = new BufferedReader(new InputStreamReader(is));
+            String path = reader.readLine();
+            return new File(path);
         } finally {
-        	if (null != reader) {
-        		try {
-        			reader.close();
-				} catch (IOException e) {
-				}
-        	}
+            if (null != reader) {
+                try {
+                    reader.close();
+                } catch (IOException e) {
+                }
+            }
         }
     }
 

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=601152&r1=601151&r2=601152&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java Tue Dec  4 15:49:03 2007
@@ -69,7 +69,7 @@
  *
  * @version $Rev$ $Date$
  */
-public class LocalAttributeManager implements PluginAttributeStore, PersistentConfigurationList, GBeanLifecycle {
+public class LocalAttributeManager implements LocalPluginAttributeStore, PersistentConfigurationList, GBeanLifecycle {
     private static final Log log = LogFactory.getLog(LocalAttributeManager.class);
 
     private static final String CONFIG_FILE_PROPERTY = "org.apache.geronimo.config.file";
@@ -98,10 +98,11 @@
     private String prefix;
     private File configSubstitutionsFile;
     private Properties localConfigSubstitutions;
+    private String resolvedPropertiesFile;
 
     public LocalAttributeManager(String configFile, String configSubstitutionsFileName, String configSubstitutionsPrefix, boolean readOnly, ServerInfo serverInfo) {
         this.configFile = System.getProperty(CONFIG_FILE_PROPERTY, configFile);
-        String resolvedPropertiesFile = System.getProperty(SUBSTITUTIONS_FILE_PROPERTY, configSubstitutionsFileName);
+        resolvedPropertiesFile = System.getProperty(SUBSTITUTIONS_FILE_PROPERTY, configSubstitutionsFileName);
         configSubstitutionsFile = resolvedPropertiesFile == null? null: serverInfo.resolveServer(resolvedPropertiesFile);
         localConfigSubstitutions = loadConfigSubstitutions(configSubstitutionsFile);
         prefix = System.getProperty(SUBSTITUTION_PREFIX_PREFIX, configSubstitutionsPrefix);
@@ -115,6 +116,19 @@
 
     public boolean isReadOnly() {
         return readOnly;
+    }
+
+
+    public String getConfigFile() {
+        return configFile;
+    }
+
+    public String getConfigSubstitutionsFile() {
+        return resolvedPropertiesFile;
+    }
+
+    public String getConfigSubstitutionsPrefix() {
+        return prefix;
     }
 
     public synchronized Collection applyOverrides(Artifact configName, Collection untypedGbeanDatas, ClassLoader classLoader) throws InvalidConfigException {

Added: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalPluginAttributeStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalPluginAttributeStore.java?rev=601152&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalPluginAttributeStore.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalPluginAttributeStore.java Tue Dec  4 15:49:03 2007
@@ -0,0 +1,32 @@
+/*
+ * 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.geronimo.system.configuration;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public interface LocalPluginAttributeStore extends PluginAttributeStore {
+    String getConfigFile();
+
+    String getConfigSubstitutionsFile();
+
+    String getConfigSubstitutionsPrefix();
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalPluginAttributeStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalPluginAttributeStore.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalPluginAttributeStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java?rev=601152&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java Tue Dec  4 15:49:03 2007
@@ -0,0 +1,120 @@
+/*
+ * 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.geronimo.system.plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.config.IOUtil;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.codehaus.plexus.archiver.Archiver;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.UnixStat;
+import org.codehaus.plexus.archiver.tar.TarArchiver;
+import org.codehaus.plexus.archiver.tar.TarLongFileMode;
+import org.codehaus.plexus.archiver.zip.ZipArchiver;
+//maven inconsistency -- if we can use 1.0-alpha-9 uncomment
+//import org.codehaus.plexus.archiver.util.DefaultFileSet;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class ArchiverGBean implements ServerArchiver {
+
+    private final ServerInfo serverInfo;
+
+
+    public ArchiverGBean(ServerInfo serverInfo) {
+        this.serverInfo = serverInfo;
+    }
+
+    public File archive(String sourcePath, String destPath, Artifact artifact) throws ArchiverException, IOException {
+        File source = serverInfo.resolve(sourcePath);
+        File dest = serverInfo.resolve(destPath);
+        String serverName = artifact.getArtifactId() + "-" + artifact.getVersion();
+        dest = new File(dest, serverName + "-bin." + artifact.getType());
+        Archiver archiver;
+        if ("tar.gz".equals(artifact.getType())) {
+            archiver = new TarArchiver();
+            TarArchiver.TarCompressionMethod tarCompressionMethod = new TarArchiver.TarCompressionMethod();
+            tarCompressionMethod.setValue("gzip");
+            ((TarArchiver) archiver).setCompression(tarCompressionMethod);
+            TarLongFileMode fileMode = new TarLongFileMode();
+            fileMode.setValue(TarLongFileMode.GNU);
+            ((TarArchiver) archiver).setLongfile(fileMode);
+        } else if ("zip".equals(artifact.getType())) {
+            archiver = new ZipArchiver();
+        } else {
+            throw new IllegalArgumentException("Unknown target type: " + artifact.getType());
+        }
+        archiver.setIncludeEmptyDirs(true);
+        archiver.setDestFile(dest);
+/* see if using plexus-archiver 1.0-alpha-7 same as maven lets us share code.  Following is for 1.0-alpha-9
+        DefaultFileSet all = new DefaultFileSet();
+        all.setDirectory(source);
+        archiver.addFileSet(all);
+*/
+        //workaround code
+        Map<String, File> all = IOUtil.listAllFileNames(source);
+        for (Map.Entry<String, File> entry : all.entrySet()) {
+            String destFileName = serverName + "/" + entry.getKey();
+            File sourceFile = entry.getValue();
+            if (!destFileName.endsWith(".bat") && sourceFile.isFile()) {
+                archiver.addFile(sourceFile, destFileName, UnixStat.DEFAULT_DIR_PERM);
+            }
+        }
+
+        //end workaround code
+        File bin = new File(source, "bin");
+        if (bin.exists()) {
+            Map<String, File> includes = IOUtil.listAllFileNames(bin);
+            for (Map.Entry<String, File> entry : includes.entrySet()) {
+                String destFileName = serverName + "/bin/" + entry.getKey();
+                File sourceFile = entry.getValue();
+                if (!destFileName.endsWith(".bat") && sourceFile.isFile()) {
+                    archiver.addFile(sourceFile, destFileName, UnixStat.DEFAULT_DIR_PERM);
+                }
+            }
+        }
+        archiver.createArchive();
+        return dest;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ArchiverGBean.class);
+        infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
+
+        infoFactory.setConstructor(new String[]{"ServerInfo"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java?rev=601152&r1=601151&r2=601152&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java Tue Dec  4 15:49:03 2007
@@ -85,13 +85,15 @@
      * operation completes.  Note that this method does not throw exceptions on failure,
      * but instead sets the failure property of the DownloadResults.
      *
+     * @param pluginsToInstall The list of configurations to install
+     * @param defaultRepository
+     * @param restrictToDefaultRepository
      * @param username         Optional username, if the maven repo uses HTTP Basic authentication.
      *                         Set this to null if no authentication is required.
      * @param password         Optional password, if the maven repo uses HTTP Basic authentication.
-     *                         Set this to null if no authentication is required.
-     * @param pluginsToInstall The list of configurations to install
+ *                         Set this to null if no authentication is required.
      */
-    public DownloadResults install(PluginListType pluginsToInstall, String username, String password);
+    public DownloadResults install(PluginListType pluginsToInstall, String defaultRepository, boolean restrictToDefaultRepository, String username, String password);
 
     /**
      * Installs a configuration from a remote repository into the local Geronimo server,
@@ -103,13 +105,15 @@
      * DownloadPoller.
      *
      * @param pluginsToInstall The list of configurations to install
+     * @param defaultRepository
+     * @param restrictToDefaultRepository
      * @param username         Optional username, if the maven repo uses HTTP Basic authentication.
      *                         Set this to null if no authentication is required.
      * @param password         Optional password, if the maven repo uses HTTP Basic authentication.
-     *                         Set this to null if no authentication is required.
+ *                         Set this to null if no authentication is required.
      * @param poller           Will be notified with status updates as the download proceeds
      */
-    public void install(PluginListType pluginsToInstall, String username, String password, DownloadPoller poller);
+    public void install(PluginListType pluginsToInstall, String defaultRepository, boolean restrictToDefaultRepository, String username, String password, DownloadPoller poller);
 
     /**
      * Installs a configuration from a remote repository into the local Geronimo server,
@@ -119,14 +123,15 @@
      * property of the DownloadResults that the caller can poll for.
      *
      * @param pluginsToInstall The list of configurations to install
+     * @param defaultRepository
+     *@param restrictToDefaultRepository
      * @param username         Optional username, if the maven repo uses HTTP Basic authentication.
      *                         Set this to null if no authentication is required.
      * @param password         Optional password, if the maven repo uses HTTP Basic authentication.
-     *                         Set this to null if no authentication is required.
-     *
-     * @return A key that can be passed to checkOnInstall
+ *                         Set this to null if no authentication is required.
+ * @return A key that can be passed to checkOnInstall
      */
-    public Object startInstall(PluginListType pluginsToInstall, String username, String password);
+    public Object startInstall(PluginListType pluginsToInstall, String defaultRepository, boolean restrictToDefaultRepository, String username, String password);
 
     /**
      * Installs a configuration downloaded from a remote repository into the local Geronimo
@@ -141,14 +146,15 @@
      *                  separately.  The metadata in the CAR file includes a repository URL
      *                  for these downloads, and the username and password arguments are
      *                  used in conjunction with that.
+     * @param defaultRepository
+     *@param restrictToDefaultRepository
      * @param username  Optional username, if the maven repo uses HTTP Basic authentication.
      *                  Set this to null if no authentication is required.
      * @param password  Optional password, if the maven repo uses HTTP Basic authentication.
-     *                  Set this to null if no authentication is required.
-     *
-     * @return A key that can be passed to checkOnInstall
+ *                  Set this to null if no authentication is required.
+ * @return A key that can be passed to checkOnInstall
      */
-    public Object startInstall(File carFile, String username, String password);
+    public Object startInstall(File carFile, String defaultRepository, boolean restrictToDefaultRepository, String username, String password);
 
     /**
      * Gets the current progress of a download operation.  Note that once the
@@ -178,7 +184,9 @@
      */
     public Dependency[] checkPrerequisites(PluginType plugin);
 
-    PluginListType createPluginListForRepositories(ConfigurationManager mgr, String repo) throws NoSuchStoreException;
+    PluginListType createPluginListForRepositories(String repo) throws NoSuchStoreException;
 
     public Artifact installLibrary(File libFile, String groupId) throws IOException;
+
+    void installPluginList(String targetRepositoryPath, String relativeTargetServerPath, PluginListType pluginList, DownloadResults downloadPoller) throws Exception;
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=601152&r1=601151&r2=601152&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java Tue Dec  4 15:49:03 2007
@@ -23,6 +23,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URI;
@@ -51,6 +52,7 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
 
 import javax.security.auth.login.FailedLoginException;
 import javax.xml.bind.JAXBException;
@@ -62,21 +64,25 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.ReferenceCollection;
 import org.apache.geronimo.gbean.ReferenceCollectionEvent;
 import org.apache.geronimo.gbean.ReferenceCollectionListener;
 import org.apache.geronimo.kernel.InvalidGBeanException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.basic.BasicKernel;
 import org.apache.geronimo.kernel.config.ConfigurationData;
-import org.apache.geronimo.kernel.config.ConfigurationInfo;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.KernelConfigurationManager;
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.config.NoSuchStoreException;
+import org.apache.geronimo.kernel.config.PersistentConfigurationList;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactManager;
+import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
 import org.apache.geronimo.kernel.repository.Dependency;
 import org.apache.geronimo.kernel.repository.FileWriteMonitor;
 import org.apache.geronimo.kernel.repository.ImportType;
@@ -86,6 +92,8 @@
 import org.apache.geronimo.kernel.repository.WritableListableRepository;
 import org.apache.geronimo.kernel.util.XmlUtil;
 import org.apache.geronimo.system.configuration.ConfigurationStoreUtil;
+import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
+import org.apache.geronimo.system.configuration.InPlaceConfigurationUtil;
 import org.apache.geronimo.system.plugin.model.ArtifactType;
 import org.apache.geronimo.system.plugin.model.ConfigXmlContentType;
 import org.apache.geronimo.system.plugin.model.CopyFileType;
@@ -97,9 +105,12 @@
 import org.apache.geronimo.system.plugin.model.PluginType;
 import org.apache.geronimo.system.plugin.model.PrerequisiteType;
 import org.apache.geronimo.system.plugin.model.PropertyType;
+import org.apache.geronimo.system.repository.Maven2Repository;
+import org.apache.geronimo.system.serverinfo.BasicServerInfo;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.system.threads.ThreadPool;
 import org.apache.geronimo.util.encoders.Base64;
+import org.codehaus.plexus.util.FileUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -124,18 +135,163 @@
     private final ServerInfo serverInfo;
     private final Map<Object, DownloadResults> asyncKeys;
     private final ThreadPool threadPool;
+    private final Collection<? extends ServerInstanceData> serverInstanceDatas;
+    private final ClassLoader classloader;
     private final Map<String, ServerInstance> servers = new HashMap<String, ServerInstance>();
 
     // This regular expression for repository filename is taken from Maven1Repository.MAVEN_1_PATTERN
     private static final Pattern MAVEN_1_PATTERN_PART = Pattern.compile("(.+)-([0-9].+)\\.([^0-9]+)");
 
-    public PluginInstallerGBean(ConfigurationManager configManager, WritableListableRepository repository, ConfigurationStore configStore, ServerInfo serverInfo, ThreadPool threadPool, Collection<ServerInstance> servers) {
+    /**
+     * GBean constructor.  Supply an existing ConfigurationManager.  Use for adding to the current server.
+     *
+     * @param configManager
+     * @param repository
+     * @param configStore
+     * @param serverInstanceDatas
+     * @param serverInfo
+     * @param threadPool
+     * @param artifactManager
+     * @param classloader
+     * @throws IOException
+     */
+    public PluginInstallerGBean(ConfigurationManager configManager,
+                                WritableListableRepository repository,
+                                ConfigurationStore configStore,
+                                Collection<? extends ServerInstanceData> serverInstanceDatas,
+                                final ServerInfo serverInfo,
+                                ThreadPool threadPool,
+                                final ArtifactManager artifactManager,
+                                final ClassLoader classloader) throws IOException {
+        this.writeableRepo = repository;
+        this.configStore = configStore;
+        this.serverInfo = serverInfo;
+        this.threadPool = threadPool;
+        asyncKeys = Collections.synchronizedMap(new HashMap<Object, DownloadResults>());
+        this.serverInstanceDatas = serverInstanceDatas;
+        this.classloader = classloader;
+        for (ServerInstanceData instance : serverInstanceDatas) {
+            addServerInstance(instance, artifactManager, writeableRepo, serverInfo, servers, true);
+        }
+        if (configManager == null) {
+            throw new IllegalArgumentException("No default server instance set up");
+        }
+        this.configManager = configManager;
+        if (serverInstanceDatas instanceof ReferenceCollection) {
+            ((ReferenceCollection) serverInstanceDatas).addReferenceCollectionListener(new ReferenceCollectionListener() {
+
+                public void memberAdded(ReferenceCollectionEvent event) {
+                    ServerInstanceData instance = (ServerInstanceData) event.getMember();
+                    try {
+                        addServerInstance(instance, artifactManager, writeableRepo, serverInfo, servers, true);
+                    } catch (IOException e) {
+                        //nothing to do?? log???
+                    }
+                }
+
+                public void memberRemoved(ReferenceCollectionEvent event) {
+                    ServerInstanceData instance = (ServerInstanceData) event.getMember();
+                    PluginInstallerGBean.this.servers.remove(instance.getName());
+                }
+            });
+        }
+    }
+
+    /**
+     * Constructor for use in assembling a new server.
+     *
+     * @param serverInstanceDatas
+     * @param kernel
+     * @param classloader
+     * @param targetRepositoryPath
+     * @param targetServerPath
+     * @throws IOException
+     */
+    public PluginInstallerGBean(String targetRepositoryPath,
+                                String targetServerPath,
+                                Collection<? extends ServerInstanceData> serverInstanceDatas,
+                                final Kernel kernel,
+                                final ClassLoader classloader) throws Exception {
+        final ArtifactManager artifactManager = new DefaultArtifactManager();
+
+        FileUtils.forceMkdir(new File(targetServerPath));
+        serverInfo = new BasicServerInfo(targetServerPath, false);
+        File targetRepositoryFile = serverInfo.resolve(targetRepositoryPath);
+        FileUtils.forceMkdir(targetRepositoryFile);
+        writeableRepo = new Maven2Repository(targetRepositoryFile);
+        configStore = new RepositoryConfigurationStore(writeableRepo);
+        threadPool = null;
+        asyncKeys = Collections.synchronizedMap(new HashMap<Object, DownloadResults>());
+        this.serverInstanceDatas = serverInstanceDatas;
+        this.classloader = classloader;
+        for (ServerInstanceData instance : serverInstanceDatas) {
+            addServerInstance(instance, artifactManager, writeableRepo, serverInfo, servers, false);
+        }
+        this.configManager = buildConfigurationManager(artifactManager, writeableRepo, kernel, configStore, classloader, servers);
+        if (serverInstanceDatas instanceof ReferenceCollection) {
+            ((ReferenceCollection) serverInstanceDatas).addReferenceCollectionListener(new ReferenceCollectionListener() {
+
+                public void memberAdded(ReferenceCollectionEvent event) {
+                    ServerInstanceData instance = (ServerInstanceData) event.getMember();
+                    try {
+                        addServerInstance(instance, artifactManager, writeableRepo, serverInfo, servers, false);
+                    } catch (IOException e) {
+                        //nothing to do?? log???
+                    }
+                }
+
+                public void memberRemoved(ReferenceCollectionEvent event) {
+                    ServerInstanceData instance = (ServerInstanceData) event.getMember();
+                    PluginInstallerGBean.this.servers.remove(instance.getName());
+                }
+            });
+        }
+    }
+
+    private static void addServerInstance(ServerInstanceData serverInstance,
+                                          ArtifactManager artifactManager,
+                                          WritableListableRepository targetRepo,
+                                          ServerInfo serverInfo,
+                                          Map<String, org.apache.geronimo.system.plugin.ServerInstance> servers,
+                                          boolean live) throws IOException {
+        File targetConfigDirectory = serverInfo.resolveServer(serverInstance.getConfigFile()).getParentFile();
+        FileUtils.forceMkdir(targetConfigDirectory);
+        org.apache.geronimo.system.plugin.ServerInstance instance = serverInstance.getServerInstance(artifactManager, targetRepo, serverInfo, servers, live);
+        servers.put(instance.getServerName(), instance);
+    }
+
+    private static ConfigurationManager buildConfigurationManager(ArtifactManager artifactManager,
+                                                                  WritableListableRepository targetRepo,
+                                                                  Kernel kernel,
+                                                                  ConfigurationStore targetStore,
+                                                                  ClassLoader classloader,
+                                                                  Map<String, org.apache.geronimo.system.plugin.ServerInstance> servers) throws IOException {
+        for (ServerInstance instance : servers.values()) {
+            if ("default".equals(instance.getServerName())) {
+                return new KernelConfigurationManager(kernel,
+                        Collections.singleton(targetStore),
+                        instance.getAttributeStore(),
+                        (PersistentConfigurationList) instance.getAttributeStore(),
+                        artifactManager,
+                        instance.getArtifactResolver(),
+                        Collections.singleton(targetRepo),
+                        null,
+                        classloader);
+            }
+        }
+        throw new IllegalStateException("No default server instance found: " + servers.keySet());
+    }
+
+    /* now for tests only */
+    PluginInstallerGBean(ConfigurationManager configManager, WritableListableRepository repository, ConfigurationStore configStore, ServerInfo serverInfo, ThreadPool threadPool, Collection<ServerInstance> servers) {
         this.configManager = configManager;
         this.writeableRepo = repository;
         this.configStore = configStore;
         this.serverInfo = serverInfo;
         this.threadPool = threadPool;
         asyncKeys = Collections.synchronizedMap(new HashMap<Object, DownloadResults>());
+        serverInstanceDatas = null;
+        classloader = null;
         for (ServerInstance instance : servers) {
             this.servers.put(instance.getServerName(), instance);
         }
@@ -156,6 +312,39 @@
     }
 
     /**
+     * This more or less clones the current PluginInstallerGBean to create one with the same server instances (structure) but using
+     * the current server as config store and assembling a server in a provided location.
+     *
+     * @param targetRepositoryPath     location of repository in new server (normally "repository")
+     * @param relativeTargetServerPath Location of server to assemble relative to current server
+     * @param pluginList
+     * @param downloadPoller
+     * @throws Exception
+     */
+    public void installPluginList(String targetRepositoryPath, String relativeTargetServerPath, PluginListType pluginList, DownloadResults downloadPoller) throws Exception {
+        String targetServerPath = serverInfo.resolveServer(relativeTargetServerPath).getAbsolutePath();
+        Kernel kernel = new BasicKernel("assembly");
+
+        try {
+
+            PluginInstallerGBean installer = new PluginInstallerGBean(
+                    targetRepositoryPath,
+                    targetServerPath,
+                    serverInstanceDatas,
+                    kernel,
+                    classloader);
+
+            //TODO Conceptual error warning!
+            //TODO we should treat the current server as a unified repo, not just pick one repo.
+            String defaultRepository =  writeableRepo.getRootPath();
+            installer.install(pluginList, defaultRepository, true, null, null, downloadPoller);
+        } finally {
+            kernel.shutdown();
+        }
+    }
+
+
+    /**
      * Lists the plugins installed in the local Geronimo server, by name and
      * ID.
      *
@@ -216,6 +405,10 @@
     public PluginType getPluginMetadata(Artifact moduleId) {
         File dir = writeableRepo.getLocation(moduleId);
 //        ConfigurationData configData;
+        return extractPluginMetadata(moduleId, dir);
+    }
+
+    private PluginType extractPluginMetadata(Artifact moduleId, File dir) {
         String source = dir.getAbsolutePath();
         try {
             if (dir.isDirectory()) {
@@ -226,7 +419,11 @@
                 File xml = new File(meta, "geronimo-plugin.xml");
 //                configData = configStore.loadConfiguration(moduleId);
                 if (!xml.isFile() || !xml.canRead() || xml.length() == 0) {
-                    return createDefaultMetadata(moduleId);
+                    if (moduleId != null) {
+                        return createDefaultMetadata(moduleId);
+                    } else {
+                        return null;
+                    }
                 }
                 InputStream in = new FileInputStream(xml);
                 try {
@@ -244,7 +441,11 @@
                 try {
                     ZipEntry entry = jar.getEntry("META-INF/geronimo-plugin.xml");
                     if (entry == null) {
-                        return createDefaultMetadata(moduleId);
+                        if (moduleId != null) {
+                            return createDefaultMetadata(moduleId);
+                        } else {
+                            return null;
+                        }
                     }
                     source = dir.getAbsolutePath() + "#META-INF/geronimo-plugin.xml";
                     InputStream in = jar.getInputStream(entry);
@@ -400,15 +601,17 @@
      * operation completes.  Note that this method does not throw exceptions on failure,
      * but instead sets the failure property of the DownloadResults.
      *
-     * @param username         Optional username, if the maven repo uses HTTP Basic authentication.
-     *                         Set this to null if no authentication is required.
-     * @param password         Optional password, if the maven repo uses HTTP Basic authentication.
-     *                         Set this to null if no authentication is required.
-     * @param pluginsToInstall The list of configurations to install
+     * @param pluginsToInstall            The list of configurations to install
+     * @param defaultRepository
+     * @param restrictToDefaultRepository
+     * @param username                    Optional username, if the maven repo uses HTTP Basic authentication.
+     *                                    Set this to null if no authentication is required.
+     * @param password                    Optional password, if the maven repo uses HTTP Basic authentication.
+     *                                    Set this to null if no authentication is required.
      */
-    public DownloadResults install(PluginListType pluginsToInstall, String username, String password) {
+    public DownloadResults install(PluginListType pluginsToInstall, String defaultRepository, boolean restrictToDefaultRepository, String username, String password) {
         DownloadResults results = new DownloadResults();
-        install(pluginsToInstall, username, password, results);
+        install(pluginsToInstall, defaultRepository, restrictToDefaultRepository, username, password, results);
         return results;
     }
 
@@ -421,14 +624,16 @@
      * throw exceptions on failure, but instead sets the failure property of the
      * DownloadPoller.
      *
-     * @param pluginsToInstall The list of configurations to install
-     * @param username         Optional username, if the maven repo uses HTTP Basic authentication.
-     *                         Set this to null if no authentication is required.
-     * @param password         Optional password, if the maven repo uses HTTP Basic authentication.
-     *                         Set this to null if no authentication is required.
-     * @param poller           Will be notified with status updates as the download proceeds
+     * @param pluginsToInstall            The list of configurations to install
+     * @param defaultRepository
+     * @param restrictToDefaultRepository
+     * @param username                    Optional username, if the maven repo uses HTTP Basic authentication.
+     *                                    Set this to null if no authentication is required.
+     * @param password                    Optional password, if the maven repo uses HTTP Basic authentication.
+     *                                    Set this to null if no authentication is required.
+     * @param poller                      Will be notified with status updates as the download proceeds
      */
-    public void install(PluginListType pluginsToInstall, String username, String password, DownloadPoller poller) {
+    public void install(PluginListType pluginsToInstall, String defaultRepository, boolean restrictToDefaultRepository, String username, String password, DownloadPoller poller) {
         try {
             Map<Artifact, PluginType> metaMap = new HashMap<Artifact, PluginType>();
             // Step 1: validate everything
@@ -463,22 +668,16 @@
                 Set<Artifact> working = new HashSet<Artifact>();
                 Stack<Artifact> parentStack = new Stack<Artifact>();
                 if (instance.getModuleId() != null) {
-                    List<String> repos = pluginsToInstall.getDefaultRepository();
-                    if (!instance.getSourceRepository().isEmpty()) {
-                        repos = instance.getSourceRepository();
-                    }
+                    List<String> repos = getRepos(pluginsToInstall, defaultRepository, restrictToDefaultRepository, instance);
                     downloadArtifact(toArtifact(instance.getModuleId()), metaMap, repos,
-                            username, password, new ResultsFileWriteMonitor(poller), working, parentStack, false);
+                            username, password, new ResultsFileWriteMonitor(poller), working, parentStack, false, servers);
                 } else {
                     List<DependencyType> deps = instance.getDependency();
                     for (DependencyType dep : deps) {
                         Artifact entry = toArtifact(dep);
-                        List<String> repos = pluginsToInstall.getDefaultRepository();
-                        if (!instance.getSourceRepository().isEmpty()) {
-                            repos = instance.getSourceRepository();
-                        }
+                        List<String> repos = getRepos(pluginsToInstall, defaultRepository, restrictToDefaultRepository, instance);
                         downloadArtifact(entry, metaMap, repos,
-                                username, password, new ResultsFileWriteMonitor(poller), working, parentStack, false);
+                                username, password, new ResultsFileWriteMonitor(poller), working, parentStack, false, servers);
                     }
                 }
                 // 4. Uninstall obsolete configurations
@@ -503,6 +702,10 @@
                     }
                 }
             }
+            //ensure config.xml is saved.
+            for (org.apache.geronimo.system.plugin.ServerInstance serverInstance : servers.values()) {
+                serverInstance.getAttributeStore().save();
+            }
         } catch (Exception e) {
             log.error("Unable to install plugin. ", e);
             poller.setFailure(e);
@@ -511,6 +714,22 @@
         }
     }
 
+    private List<String> getRepos(PluginListType pluginsToInstall, String defaultRepository, boolean restrictToDefaultRepository, PluginArtifactType instance) {
+        List<String> repos = pluginsToInstall.getDefaultRepository();
+        if (!instance.getSourceRepository().isEmpty()) {
+            repos = instance.getSourceRepository();
+        }
+        if (defaultRepository != null) {
+            List<String> allrepos = new ArrayList<String>();
+            allrepos.add(defaultRepository);
+            if (!restrictToDefaultRepository) {
+                allrepos.addAll(repos);
+            }
+            repos = allrepos;
+        }
+        return repos;
+    }
+
     /**
      * Installs a configuration from a remote repository into the local Geronimo server,
      * including all its dependencies.  The method returns immediately, providing a key
@@ -518,19 +737,20 @@
      * installation does not throw exceptions on failure, but instead sets the failure
      * property of the DownloadResults that the caller can poll for.
      *
-     * @param pluginsToInstall The list of configurations to install
-     * @param username         Optional username, if the maven repo uses HTTP Basic authentication.
-     *                         Set this to null if no authentication is required.
-     * @param password         Optional password, if the maven repo uses HTTP Basic authentication.
-     *                         Set this to null if no authentication is required.
-     * @return A key that can be passed to checkOnInstall
+     * @param pluginsToInstall            The list of configurations to install
+     * @param defaultRepository
+     * @param restrictToDefaultRepository
+     * @param username                    Optional username, if the maven repo uses HTTP Basic authentication.
+     *                                    Set this to null if no authentication is required.
+     * @param password                    Optional password, if the maven repo uses HTTP Basic authentication.
+     *                                    Set this to null if no authentication is required. @return A key that can be passed to checkOnInstall
      */
-    public Object startInstall(final PluginListType pluginsToInstall, final String username, final String password) {
+    public Object startInstall(final PluginListType pluginsToInstall, final String defaultRepository, final boolean restrictToDefaultRepository, final String username, final String password) {
         Object key = getNextKey();
         final DownloadResults results = new DownloadResults();
         Runnable work = new Runnable() {
             public void run() {
-                install(pluginsToInstall, username, password, results);
+                install(pluginsToInstall, defaultRepository, restrictToDefaultRepository, username, password, results);
             }
         };
         asyncKeys.put(key, results);
@@ -550,24 +770,25 @@
      * installation does not throw exceptions on failure, but instead sets the failure
      * property of the DownloadResults that the caller can poll for.
      *
-     * @param carFile  A CAR file downloaded from a remote repository.  This is a packaged
-     *                 configuration with included configuration information, but it may
-     *                 still have external dependencies that need to be downloaded
-     *                 separately.  The metadata in the CAR file includes a repository URL
-     *                 for these downloads, and the username and password arguments are
-     *                 used in conjunction with that.
-     * @param username Optional username, if the maven repo uses HTTP Basic authentication.
-     *                 Set this to null if no authentication is required.
-     * @param password Optional password, if the maven repo uses HTTP Basic authentication.
-     *                 Set this to null if no authentication is required.
-     * @return A key that can be passed to checkOnInstall
+     * @param carFile                     A CAR file downloaded from a remote repository.  This is a packaged
+     *                                    configuration with included configuration information, but it may
+     *                                    still have external dependencies that need to be downloaded
+     *                                    separately.  The metadata in the CAR file includes a repository URL
+     *                                    for these downloads, and the username and password arguments are
+     *                                    used in conjunction with that.
+     * @param defaultRepository
+     * @param restrictToDefaultRepository
+     * @param username                    Optional username, if the maven repo uses HTTP Basic authentication.
+     *                                    Set this to null if no authentication is required.
+     * @param password                    Optional password, if the maven repo uses HTTP Basic authentication.
+     *                                    Set this to null if no authentication is required. @return A key that can be passed to checkOnInstall
      */
-    public Object startInstall(final File carFile, final String username, final String password) {
+    public Object startInstall(final File carFile, final String defaultRepository, final boolean restrictToDefaultRepository, final String username, final String password) {
         Object key = getNextKey();
         final DownloadResults results = new DownloadResults();
         Runnable work = new Runnable() {
             public void run() {
-                install(carFile, username, password, results);
+                install(carFile, defaultRepository, restrictToDefaultRepository, username, password, results);
             }
         };
         asyncKeys.put(key, results);
@@ -600,19 +821,21 @@
     /**
      * Installs from a pre-downloaded CAR file
      *
-     * @param carFile  care file to install
-     * @param username repo username
-     * @param password repo password
-     * @param poller   monitor for reporting progress
+     * @param carFile                     care file to install
+     * @param defaultRepository
+     * @param restrictToDefaultRepository
+     * @param username                    repo username
+     * @param password                    repo password
+     * @param poller                      monitor for reporting progress
      */
-    public void install(File carFile, String username, String password, DownloadPoller poller) {
+    public void install(File carFile, String defaultRepository, boolean restrictToDefaultRepository, String username, String password, DownloadPoller poller) {
         try {
             // 1. Extract the configuration metadata
-            PluginType data = loadCARFile(carFile, true);
+            PluginType data = extractPluginMetadata(null, carFile);
             if (data == null) {
-                log.error("Invalid Configuration Archive " + carFile.getAbsolutePath() + " see server log for details");
+                log.error("Invalid Configuration Archive " + carFile.getAbsolutePath() + " no plugin metadata found");
                 throw new IllegalArgumentException(
-                        "Invalid Configuration Archive " + carFile.getAbsolutePath() + " see server log for details");
+                        "Invalid Configuration Archive " + carFile.getAbsolutePath() + " no plugin metadata found");
             }
 
             // 2. Validate that we can install this
@@ -623,7 +846,7 @@
                 Artifact pluginArtifact = toArtifact(instance.getModuleId());
                 ResultsFileWriteMonitor monitor = new ResultsFileWriteMonitor(poller);
                 writeableRepo.copyToRepository(carFile, pluginArtifact, monitor);
-                installConfigXMLData(pluginArtifact, instance);
+                installConfigXMLData(pluginArtifact, instance, servers);
                 if (instance.getCopyFile() != null) {
                     extractPluginFiles(pluginArtifact, data, monitor);
                 }
@@ -634,7 +857,7 @@
             PluginListType pluginList = new PluginListType();
             pluginList.getPlugin().add(data);
             pluginList.getDefaultRepository().addAll(instance.getSourceRepository());
-            install(pluginList, username, password, poller);
+            install(pluginList, defaultRepository, restrictToDefaultRepository, username, password, poller);
         } catch (Exception e) {
             poller.setFailure(e);
         } finally {
@@ -707,7 +930,7 @@
         for (PrerequisiteType prereq : prereqs) {
             Artifact artifact = toArtifact(prereq.getId());
             try {
-                if (getServerInstance("default").getArtifactResolver().queryArtifacts(artifact).length == 0) {
+                if (getServerInstance("default", servers).getArtifactResolver().queryArtifacts(artifact).length == 0) {
                     missingPrereqs.add(new Dependency(artifact, ImportType.ALL));
                 }
             } catch (NoServerInstanceException e) {
@@ -746,6 +969,7 @@
      * @param soFar       The set of dependencies already downloaded.
      * @param parentStack chain of modules that led to this dependency
      * @param dependency  Is this a dependency or the original artifact? @throws IOException                When there's a problem reading or writing data
+     * @param servers
      * @throws FailedLoginException       When a repository requires authentication and either no username
      *                                    and password are supplied or the username and password supplied
      *                                    are not accepted
@@ -753,7 +977,7 @@
      * @throws NoServerInstanceException  when no server descriptor is found for a specified configuration bit
      * @throws java.io.IOException        when a IO problem occurs
      */
-    private void downloadArtifact(Artifact configID, Map<Artifact, PluginType> metadata, List<String> repos, String username, String password, ResultsFileWriteMonitor monitor, Set<Artifact> soFar, Stack<Artifact> parentStack, boolean dependency) throws IOException, FailedLoginException, MissingDependencyException, NoServerInstanceException {
+    private void downloadArtifact(Artifact configID, Map<Artifact, PluginType> metadata, List<String> repos, String username, String password, ResultsFileWriteMonitor monitor, Set<Artifact> soFar, Stack<Artifact> parentStack, boolean dependency, Map<String, ServerInstance> servers) throws IOException, FailedLoginException, MissingDependencyException, NoServerInstanceException {
         if (soFar.contains(configID)) {
             return; // Avoid endless work due to circular dependencies
         } else {
@@ -762,6 +986,7 @@
         // Download and install the main artifact
         boolean pluginWasInstalled = false;
         Artifact[] matches = configManager.getArtifactResolver().queryArtifacts(configID);
+        PluginArtifactType instance = null;
         if (matches.length == 0) {
             // not present, needs to be downloaded
             monitor.getResults().setCurrentMessage("Downloading " + configID);
@@ -802,7 +1027,7 @@
                 }
                 // See if the download file has plugin metadata and use it in preference to what is in the catalog.
                 try {
-                    PluginType realPluginData = loadCARFile(tempFile, false);
+                    PluginType realPluginData = extractPluginMetadata(null, tempFile);
                     if (realPluginData != null) {
                         pluginData = realPluginData;
                     }
@@ -811,7 +1036,6 @@
                     throw (IOException) new IOException(
                             "Unable to read plugin metadata: " + e.getMessage()).initCause(e);
                 }
-                PluginArtifactType instance = null;
                 if (pluginData != null) { // it's a plugin, not a plain JAR
                     validatePlugin(pluginData);
                     instance = pluginData.getPluginArtifact().get(0);
@@ -824,7 +1048,7 @@
                     tempFile.deleteOnExit();
                 }
                 if (pluginData != null) {
-                    installConfigXMLData(result.getConfigID(), instance);
+                    installConfigXMLData(result.getConfigID(), instance, servers);
                 } else {
                     log.debug("No config XML data to install.");
                 }
@@ -837,8 +1061,7 @@
                 }
                 pluginWasInstalled = true;
                 if (pluginData != null)
-                    log.info(
-                            "Installed plugin with moduleId=" + pluginData.getPluginArtifact().get(0).getModuleId() + " and name=" + pluginData.getName());
+                    log.info("Installed plugin with moduleId=" + pluginData.getPluginArtifact().get(0).getModuleId() + " and name=" + pluginData.getName());
                 else
                     log.info("Installed artifact=" + configID);
             } catch (InvalidGBeanException e) {
@@ -858,7 +1081,6 @@
         }
         // Download and install the dependencies
         try {
-            ConfigurationData data = null;
             if (!configID.isResolved()) {
                 // See if something's running
                 for (int i = matches.length - 1; i >= 0; i--) {
@@ -873,6 +1095,7 @@
                 // Go with something that's installed
                 configID = matches[matches.length - 1];
             }
+            ConfigurationData data = null;
             if (configStore.containsConfiguration(configID)) {
                 if (configManager.isRunning(configID)) {
                     return; // its dependencies must be OK
@@ -880,13 +1103,24 @@
                 log.debug("Loading configuration=" + configID);
                 data = configStore.loadConfiguration(configID);
             }
-            Dependency[] dependencies = data == null ? getDependencies(writeableRepo, configID) : getDependencies(data);
             // Download the dependencies
             parentStack.push(configID);
-            for (Dependency dep : dependencies) {
-                Artifact artifact = dep.getArtifact();
-                log.debug("Attempting to download dependency=" + artifact + " for configuration=" + configID);
-                downloadArtifact(artifact, metadata, repos, username, password, monitor, soFar, parentStack, true);
+            if (instance == null) {
+                //no plugin metadata, guess with something else
+                Dependency[] dependencies = data == null ? getDependencies(writeableRepo, configID) : getDependencies(data);
+                for (Dependency dep : dependencies) {
+                    Artifact artifact = dep.getArtifact();
+                    log.debug("Attempting to download dependency=" + artifact + " for configuration=" + configID);
+                    downloadArtifact(artifact, metadata, repos, username, password, monitor, soFar, parentStack, true, servers);
+                }
+            } else {
+                //rely on plugin metadata if present.
+                List<DependencyType> deps = instance.getDependency();
+                for (DependencyType dep: deps) {
+                    Artifact artifact = toArtifact(dep);
+                    log.debug("Attempting to download dependency=" + artifact + " for configuration=" + configID);
+                    downloadArtifact(artifact, metadata, repos, username, password, monitor, soFar, parentStack, true, servers);
+                }
             }
             parentStack.pop();
         } catch (NoSuchConfigException e) {
@@ -1212,6 +1446,32 @@
      * something at the specified URL by passing the method 'HEAD'.
      */
     private static InputStream connect(URL url, String username, String password, ResultsFileWriteMonitor monitor, String method) throws IOException, FailedLoginException {
+        if (url.getProtocol().equals("file")) {
+            File path = new File(url.getPath());
+            if (!path.exists()) {
+                throw new IOException("No file at " + path);
+            }
+            if (path.isDirectory()) {
+                //todo this is awfully redundantly copying over and over again
+                //Code copied from RepositoryConfigurationStore
+                File file = File.createTempFile("geronimo-plugin-download-", ".tmp");
+                FileOutputStream output = new FileOutputStream(file);
+                ZipOutputStream out = new ZipOutputStream(output);
+                byte[] buf = new byte[10240];
+                writeToZip(path, out, "", buf);
+                InPlaceConfigurationUtil inPlaceConfUtil = new InPlaceConfigurationUtil();
+                if (inPlaceConfUtil.isInPlaceConfiguration(path)) {
+                    path = inPlaceConfUtil.readInPlaceLocation(path);
+                    writeToZip(path, out, "", buf);
+                }
+                out.closeEntry();
+                out.finish();
+                out.flush();
+                return new FileInputStream(file);
+            } else {
+                return new FileInputStream(path);
+            }
+        }
         URLConnection con = url.openConnection();
         if (con instanceof HttpURLConnection) {
             HttpURLConnection http = (HttpURLConnection) url.openConnection();
@@ -1276,6 +1536,33 @@
         }
     }
 
+    //Copied from RepositoryConfigurationStore
+    private static void writeToZip(File dir, ZipOutputStream out, String prefix, byte[] buf) throws IOException {
+        File[] all = dir.listFiles();
+        for (int i = 0; i < all.length; i++) {
+            File file = all[i];
+            if (file.isDirectory()) {
+                writeToZip(file, out, prefix + file.getName() + "/", buf);
+            } else {
+                ZipEntry entry = new ZipEntry(prefix + file.getName());
+                out.putNextEntry(entry);
+                writeToZipStream(file, out, buf);
+            }
+        }
+    }
+
+    //Copied from RepositoryConfigurationStore
+    private static void writeToZipStream(File file, OutputStream out, byte[] buf) throws IOException {
+        FileInputStream in = new FileInputStream(file);
+        int count;
+        try {
+            while ((count = in.read(buf, 0, buf.length)) > -1) {
+                out.write(buf, 0, count);
+            }
+        } finally {
+            in.close();
+        }
+    }
     /**
      * Searches for an artifact in the listed repositories, where the artifact
      * may have wildcards in the ID.
@@ -1545,34 +1832,6 @@
     }
 
     /**
-     * Read the plugin metadata out of a plugin CAR file on disk.
-     */
-    private PluginType loadCARFile(File file, boolean definitelyCAR) throws IOException, ParserConfigurationException, SAXException, JAXBException, XMLStreamException {
-        if (!file.canRead()) {
-            log.error("Cannot read from downloaded CAR file " + file.getAbsolutePath());
-            return null;
-        }
-        JarFile jar = new JarFile(file);
-        try {
-            JarEntry entry = jar.getJarEntry("META-INF/geronimo-plugin.xml");
-            if (entry == null) {
-                if (definitelyCAR) {
-                    log.error("Downloaded CAR file does not contain META-INF/geronimo-plugin.xml file");
-                }
-                return null;
-            }
-            InputStream in = jar.getInputStream(entry);
-            try {
-                return PluginXmlUtil.loadPluginMetadata(in);
-            } finally {
-                in.close();
-            }
-        } finally {
-            jar.close();
-        }
-    }
-
-    /**
      * Check whether the specified JVM versions match the current runtime
      * environment.
      *
@@ -1792,11 +2051,31 @@
         }
     }
 
-    public PluginListType createPluginListForRepositories(ConfigurationManager mgr, String repo) throws NoSuchStoreException {
+    public PluginListType createPluginListForRepositories(String repo) throws NoSuchStoreException {
         Map<PluginType, PluginType> pluginMap = new HashMap<PluginType, PluginType>();
-        List<AbstractName> stores = mgr.listStores();
+        Collection<? extends Repository> repos = configManager.getRepositories();
+        for (Repository listableRepository : repos) {
+            if (listableRepository instanceof WritableListableRepository) {
+                SortedSet<Artifact> artifacts = ((WritableListableRepository) listableRepository).list();
+                for (Artifact artifact : artifacts) {
+                    File location = listableRepository.getLocation(artifact);
+                    PluginType data = extractPluginMetadata(null, location);
+                    if (data != null) {
+                        PluginType key = toKey(data);
+                        PluginType existing = pluginMap.get(key);
+                        if (existing == null) {
+                            pluginMap.put(key, data);
+                        } else {
+                            existing.getPluginArtifact().addAll(data.getPluginArtifact());
+                        }
+                    }
+                }
+            }
+        }
+/*
+        List<AbstractName> stores = configManager.listStores();
         for (AbstractName name : stores) {
-            List<ConfigurationInfo> configs = mgr.listConfigurations(name);
+            List<ConfigurationInfo> configs = configManager.listConfigurations(name);
             for (ConfigurationInfo info : configs) {
                 PluginType data = getPluginMetadata(info.getConfigID());
 
@@ -1809,9 +2088,12 @@
                 }
             }
         }
+*/
         PluginListType pluginList = new PluginListType();
         pluginList.getPlugin().addAll(pluginMap.values());
-        pluginList.getDefaultRepository().add(repo);
+        if (repo != null) {
+            pluginList.getDefaultRepository().add(repo);
+        }
         return pluginList;
     }
 
@@ -1820,23 +2102,23 @@
      * If a plugin includes config.xml content, copy it into the attribute
      * store.
      */
-    private void installConfigXMLData(Artifact configID, PluginArtifactType pluginData) throws InvalidGBeanException, IOException, NoServerInstanceException {
+    private void installConfigXMLData(Artifact configID, PluginArtifactType pluginData, Map<String, ServerInstance> servers) throws InvalidGBeanException, IOException, NoServerInstanceException {
         if (configManager.isConfiguration(configID)) {
             if (pluginData != null && !pluginData.getConfigXmlContent().isEmpty()) {
                 for (ConfigXmlContentType configXmlContent : pluginData.getConfigXmlContent()) {
                     String serverName = configXmlContent.getServer();
-                    ServerInstance serverInstance = getServerInstance(serverName);
+                    ServerInstance serverInstance = getServerInstance(serverName, servers);
                     serverInstance.getAttributeStore().setModuleGBeans(configID, configXmlContent.getGbean(), configXmlContent.isLoad(), configXmlContent.getCondition());
                 }
             } else {
-                getServerInstance("default").getAttributeStore().setModuleGBeans(configID, null, true, null);
+                getServerInstance("default", servers).getAttributeStore().setModuleGBeans(configID, null, true, null);
             }
         }
         if (!pluginData.getConfigSubstitution().isEmpty()) {
             Map<String, Properties> propertiesMap = toPropertiesMap(pluginData.getConfigSubstitution());
             for (Map.Entry<String, Properties> entry : propertiesMap.entrySet()) {
                 String serverName = entry.getKey();
-                ServerInstance serverInstance = getServerInstance(serverName);
+                ServerInstance serverInstance = getServerInstance(serverName, servers);
                 serverInstance.getAttributeStore().addConfigSubstitutions(entry.getValue());
             }
         }
@@ -1844,13 +2126,13 @@
             Map<String, Properties> propertiesMap = toPropertiesMap(pluginData.getArtifactAlias());
             for (Map.Entry<String, Properties> entry : propertiesMap.entrySet()) {
                 String serverName = entry.getKey();
-                ServerInstance serverInstance = getServerInstance(serverName);
+                ServerInstance serverInstance = getServerInstance(serverName, servers);
                 serverInstance.getArtifactResolver().addAliases(entry.getValue());
             }
         }
     }
 
-    private ServerInstance getServerInstance(String serverName) throws NoServerInstanceException {
+    private ServerInstance getServerInstance(String serverName, Map<String, ServerInstance> servers) throws NoServerInstanceException {
         ServerInstance serverInstance = servers.get(serverName);
         if (serverInstance == null) {
             throw new NoServerInstanceException("No server instance configuration set up for name " + serverName);
@@ -2008,16 +2290,17 @@
 
     static {
         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(PluginInstallerGBean.class);
+        infoFactory.addInterface(PluginInstaller.class);
         infoFactory.addReference("ConfigManager", ConfigurationManager.class, "ConfigurationManager");
         infoFactory.addReference("Repository", WritableListableRepository.class, "Repository");
         infoFactory.addReference("ConfigStore", ConfigurationStore.class, "ConfigurationStore");
         infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
         infoFactory.addReference("ThreadPool", ThreadPool.class, "GBean");
-        infoFactory.addReference("ServerInstances", ServerInstance.class, "ServerInstance");
-        infoFactory.addInterface(PluginInstaller.class);
-
+        infoFactory.addReference("ServerInstances", ServerInstanceData.class, "ServerInstanceData");
+        infoFactory.addReference("ArtifactManager", ArtifactManager.class, "GBean");
+        infoFactory.addAttribute("classloader", ClassLoader.class, false);
         infoFactory.setConstructor(new String[]{"ConfigManager", "Repository", "ConfigStore",
-                "ServerInfo", "ThreadPool", "ServerInstances"});
+                "ServerInstances", "ServerInfo", "ThreadPool", "ArtifactManager", "classloader"});
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java?rev=601152&r1=601151&r2=601152&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java Tue Dec  4 15:49:03 2007
@@ -98,8 +98,8 @@
         URL url = null;
         try {
             URI uri = new URI(userRepository);
-            if (uri.getScheme() == null) {
-                if (uri.isAbsolute()) {
+            if (!uri.isAbsolute()) {
+                if (userRepository.startsWith("/")) {
                     url = new URI("file", userRepository, null).toURL();
                 } else if (userRepository.startsWith("~")) {
                     URI fullUri = new File(System.getProperty("user.home")).getAbsoluteFile().toURI().resolve(userRepository.substring(2));

Added: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ReferenceServerInstanceData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ReferenceServerInstanceData.java?rev=601152&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ReferenceServerInstanceData.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ReferenceServerInstanceData.java Tue Dec  4 15:49:03 2007
@@ -0,0 +1,97 @@
+/*
+ * 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.geronimo.system.plugin;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.geronimo.kernel.repository.ArtifactManager;
+import org.apache.geronimo.kernel.repository.ListableRepository;
+import org.apache.geronimo.system.configuration.LocalPluginAttributeStore;
+import org.apache.geronimo.system.resolver.LocalAliasedArtifactResolver;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class ReferenceServerInstanceData extends ServerInstanceData {
+
+    private final LocalPluginAttributeStore attributeStore;
+    private final LocalAliasedArtifactResolver artifactResolver;
+
+
+    public ReferenceServerInstanceData() {
+        attributeStore = null;
+        artifactResolver = null;
+    }
+
+    public ReferenceServerInstanceData(LocalPluginAttributeStore attributeStore, LocalAliasedArtifactResolver artifactResolver) {
+        this.attributeStore = attributeStore;
+        this.artifactResolver = artifactResolver;
+    }
+
+    @Override
+    public String getConfigFile() {
+        return attributeStore.getConfigFile();
+    }
+
+    @Override
+    public String getConfigSubstitutionsFile() {
+        return attributeStore.getConfigSubstitutionsFile();
+    }
+
+    @Override
+    public String getConfigSubstitutionsPrefix() {
+        return attributeStore.getConfigSubstitutionsPrefix();
+    }
+
+    @Override
+    public String getArtifactAliasesFile() {
+        return artifactResolver.getArtifactAliasesFile();
+    }
+
+    @Override
+    public ServerInstance getServerInstance(ArtifactManager artifactManager, ListableRepository targetRepo, ServerInfo serverInfo, Map<String, ServerInstance> serverInstances, boolean live) throws IOException {
+        if (live) {
+            return new ServerInstance(getName(), attributeStore, artifactResolver);
+        } else {
+            return super.getServerInstance(artifactManager, targetRepo, serverInfo, serverInstances, live);
+        }
+    }
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ReferenceServerInstanceData.class, "ServerInstanceData");
+        infoFactory.addAttribute("name", String.class, true, true);
+        infoFactory.addReference("AttributeStore", LocalPluginAttributeStore.class, "AttributeStore");
+        infoFactory.addReference("ArtifactResolver", LocalAliasedArtifactResolver.class, "ArtifactResolver");
+
+        infoFactory.setConstructor(new String[] {"AttributeStore", "ArtifactResolver"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ReferenceServerInstanceData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ReferenceServerInstanceData.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ReferenceServerInstanceData.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java?rev=601152&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java Tue Dec  4 15:49:03 2007
@@ -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.geronimo.system.plugin;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.codehaus.plexus.archiver.ArchiverException;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public interface ServerArchiver {
+    File archive(String sourcePath, String destPath, Artifact artifact) throws ArchiverException, IOException;
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstance.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstance.java?rev=601152&r1=601151&r2=601152&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstance.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstance.java Tue Dec  4 15:49:03 2007
@@ -58,20 +58,4 @@
     public AliasedArtifactResolver getArtifactResolver() {
         return artifactResolver;
     }
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ServerInstance.class, "ServerInstance");
-        infoFactory.addAttribute("serverName", String.class, true, true);
-        infoFactory.addReference("PluginAttributeStore", PluginAttributeStore.class, "AttributeStore");
-        infoFactory.addReference("ArtifactResolver", AliasedArtifactResolver.class, "ArtifactResolver");
-
-        infoFactory.setConstructor(new String[]{"serverName", "PluginAttributeStore", "ArtifactResolver"});
-
-        GBEAN_INFO = infoFactory.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
 }

Copied: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java (from r599234, geronimo/server/trunk/maven-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/ServerInstance.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java?p2=geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java&p1=geronimo/server/trunk/maven-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/ServerInstance.java&r1=599234&r2=601152&rev=601152&view=diff
==============================================================================
--- geronimo/server/trunk/maven-plugins/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/ServerInstance.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java Tue Dec  4 15:49:03 2007
@@ -18,22 +18,25 @@
  */
 
 
-package org.apache.geronimo.mavenplugins.car;
+package org.apache.geronimo.system.plugin;
 
 import java.io.IOException;
 import java.util.Collections;
 import java.util.Map;
 
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.kernel.repository.ArtifactManager;
 import org.apache.geronimo.kernel.repository.ListableRepository;
 import org.apache.geronimo.system.configuration.LocalAttributeManager;
+import org.apache.geronimo.system.configuration.LocalPluginAttributeStore;
 import org.apache.geronimo.system.resolver.ExplicitDefaultArtifactResolver;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
-public class ServerInstance {
+public class ServerInstanceData {
 
     private String name;
     private String attributeManagerFrom;
@@ -92,27 +95,46 @@
         this.artifactAliasesFileName = artifactAliasesFileName;
     }
 
-    public org.apache.geronimo.system.plugin.ServerInstance getServerInstance(ArtifactManager artifactManager, ListableRepository targetRepo, ServerInfo serverInfo, Map<String, org.apache.geronimo.system.plugin.ServerInstance> serverInstances) throws IOException {
+    public ServerInstance getServerInstance(ArtifactManager artifactManager, ListableRepository targetRepo, ServerInfo serverInfo, Map<String, org.apache.geronimo.system.plugin.ServerInstance> serverInstances, boolean live) throws IOException {
         ExplicitDefaultArtifactResolver geronimoArtifactResolver = new ExplicitDefaultArtifactResolver(
-                artifactAliasesFileName,
+                getArtifactAliasesFile(),
                 artifactManager,
                 Collections.singleton(targetRepo),
                 serverInfo);
-        LocalAttributeManager attributeStore;
+        LocalPluginAttributeStore attributeStore;
         if (attributeManagerFrom == null) {
-            attributeStore = new LocalAttributeManager(configFile,
-                    configSubstitutionsFileName,
-                    configSubstitutionsPrefix,
+            attributeStore = new LocalAttributeManager(getConfigFile(),
+                    getConfigSubstitutionsFile(),
+                    getConfigSubstitutionsPrefix(),
                     false,
                     serverInfo);
-            attributeStore.load();
+            ((LocalAttributeManager)attributeStore).load();
         } else {
-            org.apache.geronimo.system.plugin.ServerInstance shared = serverInstances.get(attributeManagerFrom);
+            ServerInstance shared = serverInstances.get(attributeManagerFrom);
             if (shared == null) {
                 throw new IllegalArgumentException("Incorrect configuration: no server instance named '" + attributeManagerFrom + "' defined before being shared from '" + name + "'");
             }
-            attributeStore = (LocalAttributeManager) shared.getAttributeStore();
+            attributeStore = (LocalPluginAttributeStore) shared.getAttributeStore();
         }
-        return new org.apache.geronimo.system.plugin.ServerInstance(name, attributeStore, geronimoArtifactResolver);
+        return new ServerInstance(name, attributeStore, geronimoArtifactResolver);
+    }
+
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ServerInstanceData.class, "ServerInstanceData");
+        infoFactory.addAttribute("name", String.class, true, true);
+        infoFactory.addAttribute("attributeManagerFrom", String.class, true, true);
+        infoFactory.addAttribute("configFile", String.class, true, true);
+        infoFactory.addAttribute("configSubstitutionsFileName", String.class, true, true);
+        infoFactory.addAttribute("configSubstitutionsPrefix", String.class, true, true);
+        infoFactory.addAttribute("artifactAliasesFileName", String.class, true, true);
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
     }
 }

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/ServerInstanceData.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message