Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 74655 invoked from network); 16 Sep 2008 23:53:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Sep 2008 23:53:42 -0000 Received: (qmail 84160 invoked by uid 500); 16 Sep 2008 23:53:39 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 84020 invoked by uid 500); 16 Sep 2008 23:53:38 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 84010 invoked by uid 99); 16 Sep 2008 23:53:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2008 16:53:38 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2008 23:52:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A9E002388A08; Tue, 16 Sep 2008 16:52:38 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r696105 - in /geronimo/server/trunk: buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/ framework/configs/plugin/ framework/configs/plugin/src/main/plan/ framework/configs/plugin/src/main/resources/ framework/... Date: Tue, 16 Sep 2008 23:52:30 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080916235238.A9E002388A08@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djencks Date: Tue Sep 16 16:52:24 2008 New Revision: 696105 URL: http://svn.apache.org/viewvc?rev=696105&view=rev Log: GERONIMO-4304 Register allowable plugin repositories, with credentials as appropriate Added: geronimo/server/trunk/framework/configs/plugin/src/main/resources/ geronimo/server/trunk/framework/configs/plugin/src/main/resources/plugin-repositories.properties (with props) Removed: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/SourceRepositoryFactory.java Modified: geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java geronimo/server/trunk/framework/configs/plugin/pom.xml geronimo/server/trunk/framework/configs/plugin/src/main/plan/plan.xml geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryList.java geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/RemoteSourceRepository.java geronimo/server/trunk/framework/modules/geronimo-plugin/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java geronimo/server/trunk/framework/modules/geronimo-plugin/src/test/java/org/apache/geronimo/system/plugin/PluginInstallerTest.java geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/JmxDiscoveryPublisher.java geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/AddRepositoryHandler.java geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/BaseImportExportHandler.java Modified: geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java (original) +++ geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java Tue Sep 16 16:52:24 2008 @@ -23,6 +23,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.Collections; +import java.net.URL; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.basic.BasicKernel; @@ -31,6 +33,8 @@ import org.apache.geronimo.system.plugin.DownloadResults; import org.apache.geronimo.system.plugin.PluginInstallerGBean; import org.apache.geronimo.system.plugin.SourceRepository; +import org.apache.geronimo.system.plugin.PluginRepositoryList; +import org.apache.geronimo.system.plugin.PluginRepositoryDownloader; import org.apache.geronimo.system.plugin.model.ArtifactType; import org.apache.geronimo.system.plugin.model.AttributesType; import org.apache.geronimo.system.plugin.model.PluginArtifactType; @@ -156,8 +160,9 @@ String targetServerPath = targetServerDirectory.getAbsolutePath(); Kernel kernel = new BasicKernel("Assembly"); + PluginRepositoryList pluginRepoList = new PluginRepositoryDownloader(Collections.singletonMap(localRepo, (String[]) null), true); try { - PluginInstallerGBean installer = new PluginInstallerGBean(targetRepositoryPath, targetServerPath, servers, kernel, getClass().getClassLoader()); + PluginInstallerGBean installer = new PluginInstallerGBean(targetRepositoryPath, targetServerPath, servers, pluginRepoList, kernel, getClass().getClassLoader()); installer.install(pluginList, sourceRepo, true, null, null, downloadPoller); if (overrides != null) { for (Override override: this.overrides) { Modified: geronimo/server/trunk/framework/configs/plugin/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/plugin/pom.xml?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/configs/plugin/pom.xml (original) +++ geronimo/server/trunk/framework/configs/plugin/pom.xml Tue Sep 16 16:52:24 2008 @@ -144,12 +144,12 @@ http://geronimo.apache.org/plugins/plugin-repository-list-2.2.txt - ~/.m2/repository schema/xsd/ + plugin-repositories.properties Modified: geronimo/server/trunk/framework/configs/plugin/src/main/plan/plan.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/plugin/src/main/plan/plan.xml?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/configs/plugin/src/main/plan/plan.xml (original) +++ geronimo/server/trunk/framework/configs/plugin/src/main/plan/plan.xml Tue Sep 16 16:52:24 2008 @@ -37,6 +37,9 @@ DefaultThreadPool + + DownloadedPluginRepos + DefaultServer @@ -93,7 +96,10 @@ http://geronimo.apache.org/plugins/plugin-repository-list-2.2.txt - ~/.m2/repository + var/config/plugin-repositories.properties + + ServerInfo + Added: geronimo/server/trunk/framework/configs/plugin/src/main/resources/plugin-repositories.properties URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/plugin/src/main/resources/plugin-repositories.properties?rev=696105&view=auto ============================================================================== --- geronimo/server/trunk/framework/configs/plugin/src/main/resources/plugin-repositories.properties (added) +++ geronimo/server/trunk/framework/configs/plugin/src/main/resources/plugin-repositories.properties Tue Sep 16 16:52:24 2008 @@ -0,0 +1,3 @@ +#List of known plugin repositories. Fomat: == +~/.m2/repository +http\://localhost\:8080/plugin/maven-repo/=system=manager \ No newline at end of file Propchange: geronimo/server/trunk/framework/configs/plugin/src/main/resources/plugin-repositories.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/framework/configs/plugin/src/main/resources/plugin-repositories.properties ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/framework/configs/plugin/src/main/resources/plugin-repositories.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java Tue Sep 16 16:52:24 2008 @@ -180,10 +180,10 @@ - public PluginListType listPlugins(URL mavenRepository, String username, String password) throws FailedLoginException, IOException { + public PluginListType listPlugins(URL mavenRepository) throws FailedLoginException, IOException { PluginInstaller installer = getPluginInstaller(); try { - return installer.listPlugins(mavenRepository, username, password); + return installer.listPlugins(mavenRepository); } finally { kernel.getProxyManager().destroyProxy(installer); } Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java Tue Sep 16 16:52:24 2008 @@ -21,17 +21,14 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; import javax.enterprise.deploy.shared.ModuleType; import javax.enterprise.deploy.spi.DeploymentManager; import javax.enterprise.deploy.spi.exceptions.TargetException; -import javax.enterprise.deploy.spi.Target; import javax.enterprise.deploy.spi.TargetModuleID; import javax.security.auth.login.FailedLoginException; @@ -42,8 +39,6 @@ import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager; import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl; import org.apache.geronimo.kernel.config.NoSuchStoreException; -import org.apache.geronimo.kernel.Kernel; -import org.apache.geronimo.kernel.KernelRegistry; import org.apache.geronimo.system.plugin.DownloadResults; import org.apache.geronimo.system.plugin.PluginInstallerGBean; import org.apache.geronimo.system.plugin.model.PluginArtifactType; @@ -137,7 +132,7 @@ URL repository; try { repository = new URL(repo); - data = mgr.listPlugins(repository, null, null); + data = mgr.listPlugins(repository); } catch (IOException e) { throw new DeploymentException("Unable to list configurations", e); } catch (FailedLoginException e) { Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java Tue Sep 16 16:52:24 2008 @@ -42,12 +42,8 @@ * * @param mavenRepository The base URL to the maven repository. This must * contain the file geronimo-plugins.xml - * @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 PluginListType listPlugins(URL mavenRepository, String username, String password) throws IOException, FailedLoginException; + public PluginListType listPlugins(URL mavenRepository) throws IOException, FailedLoginException; /** * Lists the plugins installed in the local Geronimo server, by name and Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java Tue Sep 16 16:52:24 2008 @@ -50,13 +50,13 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -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.gbean.annotation.GBean; +import org.apache.geronimo.gbean.annotation.ParamReference; +import org.apache.geronimo.gbean.annotation.ParamSpecial; +import org.apache.geronimo.gbean.annotation.SpecialAttributeType; import org.apache.geronimo.kernel.InvalidGBeanException; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.basic.BasicKernel; @@ -80,26 +80,28 @@ 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.PluginAttributeStore; +import org.apache.geronimo.system.configuration.RepositoryConfigurationStore; import org.apache.geronimo.system.plugin.model.ArtifactType; +import org.apache.geronimo.system.plugin.model.AttributesType; import org.apache.geronimo.system.plugin.model.ConfigXmlContentType; import org.apache.geronimo.system.plugin.model.CopyFileType; import org.apache.geronimo.system.plugin.model.DependencyType; import org.apache.geronimo.system.plugin.model.HashType; import org.apache.geronimo.system.plugin.model.LicenseType; +import org.apache.geronimo.system.plugin.model.ModuleType; import org.apache.geronimo.system.plugin.model.PluginArtifactType; import org.apache.geronimo.system.plugin.model.PluginListType; 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.plugin.model.AttributesType; -import org.apache.geronimo.system.plugin.model.ModuleType; 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.codehaus.plexus.util.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; @@ -109,8 +111,8 @@ * * @version $Rev$ $Date$ */ -public class PluginInstallerGBean implements PluginInstaller -{ +@GBean +public class PluginInstallerGBean implements PluginInstaller { private static final Logger log = LoggerFactory.getLogger(PluginInstallerGBean.class); private static int counter; @@ -125,6 +127,7 @@ private final ClassLoader classLoader; private final Map servers = new HashMap(); private final Collection persistentConfigurationLists; + private final PluginRepositoryList pluginRepositoryList; // 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]+)"); @@ -143,15 +146,16 @@ * @param classLoader classLoader @throws IOException exception if server instance cannot be loaded * @throws java.io.IOException from bad ServerInstance */ - public PluginInstallerGBean(ConfigurationManager configManager, - WritableListableRepository repository, - ConfigurationStore configStore, - Collection serverInstanceDatas, - final ServerInfo serverInfo, - ThreadPool threadPool, - final ArtifactManager artifactManager, - Collection persistentConfigurationLists, - final ClassLoader classLoader) throws IOException { + public PluginInstallerGBean(@ParamReference(name = "ConfigManager", namingType = "ConfigurationManager")ConfigurationManager configManager, + @ParamReference(name = "Repository", namingType = "Repository")WritableListableRepository repository, + @ParamReference(name = "ConfigStore", namingType = "ConfigurationStore")ConfigurationStore configStore, + @ParamReference(name = "ServerInstances", namingType = "ServerInstanceData")Collection serverInstanceDatas, + @ParamReference(name = "ServerInfo") final ServerInfo serverInfo, + @ParamReference(name = "ThreadPool")ThreadPool threadPool, + @ParamReference(name = "ArtifactManager") final ArtifactManager artifactManager, + @ParamReference(name = "PersistentConfigurationLists", namingType = "AttributeStore")Collection persistentConfigurationLists, + @ParamReference(name = "PluginRepositoryList")PluginRepositoryList pluginRepositoryList, + @ParamSpecial(type = SpecialAttributeType.classLoader) final ClassLoader classLoader) throws IOException { this.writeableRepo = repository; this.configStore = configStore; this.serverInfo = serverInfo; @@ -166,21 +170,23 @@ this.configManager = configManager; localSourceRepository = new GeronimoSourceRepository(configManager.getRepositories(), configManager.getArtifactResolver()); setUpServerInstances(serverInstanceDatas, serverInfo, artifactManager, servers, writeableRepo, true); + this.pluginRepositoryList = pluginRepositoryList; } /** * Constructor for use in assembling a new server. * - * @param serverInstanceDatas set of server layouts - * @param kernel kernel for current server - * @param classLoader classLoader * @param targetRepositoryPath location of repo to install into (not in current server) * @param targetServerPath location of server to install into (not current server - * @throws IOException if layouts can't be loaded + * @param serverInstanceDatas set of server layouts + * @param pluginRepositoryList + * @param kernel kernel for current server + * @param classLoader classLoader @throws IOException if layouts can't be loaded */ public PluginInstallerGBean(String targetRepositoryPath, String targetServerPath, Collection serverInstanceDatas, + PluginRepositoryList pluginRepositoryList, final Kernel kernel, final ClassLoader classLoader) throws Exception { final ArtifactManager artifactManager = new DefaultArtifactManager(); @@ -199,6 +205,7 @@ setUpServerInstances(serverInstanceDatas, serverInfo, artifactManager, servers, writeableRepo, false); this.configManager = buildConfigurationManager(artifactManager, writeableRepo, kernel, configStore, classLoader, servers); localSourceRepository = new GeronimoSourceRepository(configManager.getRepositories(), configManager.getArtifactResolver()); + this.pluginRepositoryList = pluginRepositoryList; } private static void setUpServerInstances(Collection serverInstanceDatas, @@ -280,7 +287,12 @@ } /* now for tests only */ - PluginInstallerGBean(ConfigurationManager configManager, WritableListableRepository repository, ConfigurationStore configStore, ServerInfo serverInfo, ThreadPool threadPool, Collection servers) { + PluginInstallerGBean(ConfigurationManager configManager, + WritableListableRepository repository, + ConfigurationStore configStore, + ServerInfo serverInfo, + ThreadPool threadPool, + Collection servers, PluginRepositoryList pluginRepositoryList) { this.configManager = configManager; localSourceRepository = new GeronimoSourceRepository(configManager.getRepositories(), configManager.getArtifactResolver()); this.writeableRepo = repository; @@ -308,6 +320,7 @@ } }); } + this.pluginRepositoryList = pluginRepositoryList; } /** @@ -323,18 +336,18 @@ DownloadResults downloadPoller = new DownloadResults(); File targetServerPath = serverInfo.resolveServer(relativeTargetServerPath); if (targetServerPath.exists()) { - FileUtils.forceDelete(targetServerPath); + FileUtils.forceDelete(targetServerPath); } String targetServerPathName = targetServerPath.getAbsolutePath(); Kernel kernel = new BasicKernel("assembly"); - + try { // kernel.boot(); PluginInstallerGBean installer = new PluginInstallerGBean( targetRepositoryPath, targetServerPathName, serverInstanceDatas, - kernel, + pluginRepositoryList, kernel, classLoader); installer.install(pluginList, localSourceRepository, true, null, null, downloadPoller); @@ -350,7 +363,7 @@ throw new NullPointerException("No such server: " + server + ", known servers: " + servers.keySet()); } PluginAttributeStore attributeStore = serverInstance.getAttributeStore(); - for (ModuleType module: overrides.getModule()) { + for (ModuleType module : overrides.getModule()) { Artifact artifact = Artifact.create(module.getName()); attributeStore.setModuleGBeans(artifact, module.getGbean(), module.isLoad(), module.getCondition()); attributeStore.save(); @@ -532,18 +545,16 @@ * * @param mavenRepository The base URL to the maven repository. This must * contain the file geronimo-plugins.xml - * @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 PluginListType listPlugins(URL mavenRepository, String username, String password) throws IOException, FailedLoginException { + public PluginListType listPlugins(URL mavenRepository) throws IOException, FailedLoginException { try { - SourceRepository repo = SourceRepositoryFactory.getSourceRepository(mavenRepository.toString(), username, password); - return repo.getPluginList(); + SourceRepository repo = pluginRepositoryList.getSourceRepository(mavenRepository.toString()); + if (repo != null) { + return repo.getPluginList(); + } } catch (IllegalStateException e) { - return null; } + return null; } private SourceRepository getDefaultSourceRepository(String defaultRepository, @@ -551,10 +562,10 @@ if (restrictToDefaultRepository && defaultRepository == null) { throw new IllegalArgumentException("You must supply a default repository if you want to restrict to it"); } - SourceRepository defaultSourceRepository = defaultRepository == null ? null : SourceRepositoryFactory.getSourceRepository(defaultRepository); + SourceRepository defaultSourceRepository = defaultRepository == null ? null : pluginRepositoryList.getSourceRepository(defaultRepository); return defaultSourceRepository; } - + /** * Installs a configuration from a remote repository into the local Geronimo server, * including all its dependencies. The caller will get the results when the @@ -601,7 +612,7 @@ public void install(PluginListType pluginsToInstall, SourceRepository defaultRepository, boolean restrictToDefaultRepository, String username, String password, DownloadPoller poller) { install(pluginsToInstall, defaultRepository, restrictToDefaultRepository, username, password, poller, true); } - + public void install(PluginListType pluginsToInstall, SourceRepository defaultRepository, boolean restrictToDefaultRepository, String username, String password, DownloadPoller poller, boolean validatePlugins) { List downloadedArtifacts = new ArrayList(); try { @@ -618,7 +629,7 @@ PluginArtifactType instance = metadata.getPluginArtifact().get(0); if (instance.getModuleId() != null) { - if (metadata.isPluginGroup() !=null && !metadata.isPluginGroup()) { + if (metadata.isPluginGroup() != null && !metadata.isPluginGroup()) { metaMap.put(toArtifact(instance.getModuleId()), metadata); } } @@ -653,7 +664,7 @@ Artifact entry = toArtifact(instance.getModuleId()); List repos = getRepos(pluginsToInstall, defaultRepository, restrictToDefaultRepository, instance); downloadArtifact(entry, metaMap, repos, - username, password, new ResultsFileWriteMonitor(poller), working, parentStack, false, servers, true); + username, password, new ResultsFileWriteMonitor(poller, log), working, parentStack, false, servers, true); downloadedArtifacts.add(entry); } else { List deps = instance.getDependency(); @@ -661,7 +672,7 @@ Artifact entry = toArtifact(dep); List repos = getRepos(pluginsToInstall, defaultRepository, restrictToDefaultRepository, instance); downloadArtifact(entry, metaMap, repos, - username, password, new ResultsFileWriteMonitor(poller), working, parentStack, false, servers, dep.isStart()); + username, password, new ResultsFileWriteMonitor(poller, log), working, parentStack, false, servers, dep.isStart()); downloadedArtifacts.add(entry); } } @@ -721,7 +732,7 @@ repoLocations = pluginsToInstall.getDefaultRepository(); } for (String repoLocation : repoLocations) { - SourceRepository repo = SourceRepositoryFactory.getSourceRepository(repoLocation); + SourceRepository repo = pluginRepositoryList.getSourceRepository(repoLocation); repos.add(repo); } } @@ -810,21 +821,21 @@ public DownloadResults checkOnInstall(Object key) { return checkOnInstall(key, true); } - + /** - * Gets the current progress of a download operation. + * Gets the current progress of a download operation. * - * @param key Identifies the operation to check on + * @param key Identifies the operation to check on * @param remove If true and the download operation has finished, the DownloadResults - * will be forgotten and the next call to this function will return null. - * Otherwise, the DownloadResults will be retained until this function is - * called with the remove parameter set to true. This parameter is - * only used when the download operation has finished - * (DownloadResults.isFinished() returns true). + * will be forgotten and the next call to this function will return null. + * Otherwise, the DownloadResults will be retained until this function is + * called with the remove parameter set to true. This parameter is + * only used when the download operation has finished + * (DownloadResults.isFinished() returns true). */ public DownloadResults checkOnInstall(Object key, boolean remove) { DownloadResults results = asyncKeys.get(key); - if (results != null) { + if (results != null) { results = results.duplicate(); if (results.isFinished() && remove) { asyncKeys.remove(key); @@ -856,16 +867,16 @@ // 2. Validate that we can install this validatePlugin(data); verifyPrerequisites(data); - + PluginArtifactType instance = data.getPluginArtifact().get(0); // 3. Install the CAR into the repository (it shouldn't be re-downloaded) if (instance.getModuleId() != null) { Artifact pluginArtifact = toArtifact(instance.getModuleId()); - ResultsFileWriteMonitor monitor = new ResultsFileWriteMonitor(poller); + ResultsFileWriteMonitor monitor = new ResultsFileWriteMonitor(poller, log); writeableRepo.copyToRepository(carFile, pluginArtifact, monitor); installConfigXMLData(pluginArtifact, instance, servers, true); if (instance.getCopyFile() != null) { - extractPluginFiles(pluginArtifact, data, monitor); + extractPluginFiles(pluginArtifact, instance, monitor); } } @@ -873,9 +884,9 @@ PluginListType pluginList = new PluginListType(); pluginList.getPlugin().add(data); pluginList.getDefaultRepository().addAll(instance.getSourceRepository()); - + SourceRepository defaultSourceRepository = getDefaultSourceRepository(defaultRepository, restrictToDefaultRepository); - + install(pluginList, defaultSourceRepository, restrictToDefaultRepository, username, password, poller, false); } catch (Exception e) { poller.setFailure(e); @@ -910,8 +921,8 @@ } if (!upgrade) { log.debug("Configuration {} is already installed", artifact); - throw new MissingDependencyException( - "Configuration " + artifact + " is already installed.", toArtifact(metadata.getModuleId()), (Stack) null); +// throw new MissingDependencyException( +// "Configuration " + artifact + " is already installed.", toArtifact(metadata.getModuleId()), (Stack) null); } } } @@ -1027,7 +1038,6 @@ soFar.add(configID); } // Download and install the main artifact - boolean pluginWasInstalled = false; Artifact[] matches = configManager.getArtifactResolver().queryArtifacts(configID); PluginArtifactType instance = null; if (matches.length == 0) { @@ -1065,7 +1075,7 @@ if (hash != null) { String actual = ConfigurationStoreUtil.getActualChecksum(tempFile, hash.getType()); if (!actual.equals(hash.getValue())) { - log.error("File download incorrect (expected {} hash {} but got {})", new String[] { hash.getType(), hash.getValue(), actual }); + log.error("File download incorrect (expected {} hash {} but got {})", new String[]{hash.getType(), hash.getValue(), actual}); throw new IOException("File download incorrect (expected " + hash.getType() + " hash " + hash.getValue() + " but got " + actual + ")"); } } @@ -1085,11 +1095,6 @@ } monitor.getResults().setCurrentMessage("Copying " + result.getArtifact() + " to the repository"); result.install(writeableRepo, monitor); - if (pluginData != null) { - installConfigXMLData(result.getArtifact(), instance, servers, loadOverride); - } else { - log.debug("No config XML data to install."); - } if (dependency) { monitor.getResults().addDependencyInstalled(configID); configID = result.getArtifact(); @@ -1097,16 +1102,11 @@ configID = result.getArtifact(); monitor.getResults().addInstalledConfigID(configID); } - pluginWasInstalled = true; if (pluginData != null) { log.debug("Installed plugin with moduleId={} and name={}", pluginData.getPluginArtifact().get(0).getModuleId(), pluginData.getName()); - } - else { + } else { log.debug("Installed artifact={}", configID); } - } catch (InvalidGBeanException e) { - log.error("Invalid gbean configuration", e); - throw new IllegalStateException("Invalid GBean configuration: " + e.getMessage(), e); } finally { //todo probably not needede result.close(); @@ -1170,14 +1170,29 @@ throw new IllegalStateException("Installed configuration into repository but ConfigStore cannot load it: " + e.getMessage(), e); } // Copy any files out of the artifact - PluginType currentPlugin = getPluginMetadata(configID); - if (pluginWasInstalled && currentPlugin != null) { - extractPluginFiles(configID, currentPlugin, monitor); + for (ServerInstance serverInstance: servers.values()) { + if (serverInstance.getAttributeStore().isModuleInstalled(configID)) { + return; + } + } + if (instance == null) { + PluginType currentPlugin = getPluginMetadata(configID); + if (currentPlugin != null) { + instance = currentPlugin.getPluginArtifact().get(0); + } + } + if (instance != null) { + try { + installConfigXMLData(configID, instance, servers, loadOverride); + } catch (InvalidGBeanException e) { + log.error("Invalid gbean configuration", e); + throw new IllegalStateException("Invalid GBean configuration: " + e.getMessage(), e); + } + extractPluginFiles(configID, instance, monitor); } } - private void extractPluginFiles(Artifact configID, PluginType currentPlugin, ResultsFileWriteMonitor monitor) throws IOException { - PluginArtifactType instance = currentPlugin.getPluginArtifact().get(0); + private void extractPluginFiles(Artifact configID, PluginArtifactType instance, ResultsFileWriteMonitor monitor) throws IOException { for (CopyFileType data : instance.getCopyFile()) { monitor.getResults().setCurrentFilePercent(-1); monitor.getResults().setCurrentFile(data.getValue()); @@ -1196,7 +1211,7 @@ throw new IllegalStateException("Unable to identify module " + configID + " to copy files from", e); } if (set.size() == 0) { - log.error("Installed '{}' configuration into repository but cannot locate file to copy {}", configID, sourceFile); + log.error("Installed configuration into repository but cannot locate file to copy {}", sourceFile); return; } if (set.iterator().next().getPath().endsWith("/")) { @@ -1228,11 +1243,11 @@ createDirectory(targetDir); URI targetURI = targetDir.toURI(); if (!targetDir.isDirectory()) { - log.error("Plugin install cannot write file {} to {} because {} is not a directory", new String[] { data.getValue(), destDir, targetDir.getAbsolutePath() }); + log.error("Plugin install cannot write file {} to {} because {} is not a directory", new String[]{data.getValue(), destDir, targetDir.getAbsolutePath()}); return; } if (!targetDir.canWrite()) { - log.error("Plugin install cannot write file {} to {} because {} is not writable", new String[] { data.getValue(), destDir, targetDir.getAbsolutePath() }); + log.error("Plugin install cannot write file {} to {} because {} is not writable", new String[]{data.getValue(), destDir, targetDir.getAbsolutePath()}); return; } int start = -1; @@ -1495,8 +1510,8 @@ * Generates dependencies and an optional prerequisite based on a list of * dependencies for a Gernonimo module. * - * @param real A list with elements of type Dependency - * @param deps A list with elements of type String (holding a module ID / Artifact name) + * @param real A list with elements of type Dependency + * @param deps A list with elements of type String (holding a module ID / Artifact name) * @param includeVersion whether to include a version in the plugin xml dependency */ private static void processDependencyList(List real, List deps, boolean includeVersion) { @@ -1628,7 +1643,8 @@ serverInstance.getAttributeStore().setModuleGBeans(configID, configXmlContent.getGbean(), loadOverride && configXmlContent.isLoad(), configXmlContent.getCondition()); } } else { - getServerInstance("default", servers).getAttributeStore().setModuleGBeans(configID, null, loadOverride, null); + ServerInstance serverInstance = getServerInstance("default", servers); + serverInstance.getAttributeStore().setModuleGBeans(configID, null, loadOverride, null); } } if (pluginData == null) { @@ -1743,8 +1759,8 @@ private int totalBytes; private String file; - public ResultsFileWriteMonitor(DownloadPoller results) { - this.results = results; + public ResultsFileWriteMonitor(DownloadPoller results, Logger log) { + this.results = new LoggingPoller(results, log); } public void setTotalBytes(int totalBytes) { @@ -1783,27 +1799,72 @@ } } - public static final GBeanInfo GBEAN_INFO; + private static class LoggingPoller implements DownloadPoller { + private final DownloadPoller downloadPoller; + private final Logger log; - 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", ServerInstanceData.class, "ServerInstanceData"); - infoFactory.addReference("ArtifactManager", ArtifactManager.class, "GBean"); - infoFactory.addReference("PersistentConfigurationLists", PersistentConfigurationList.class, "AttributeStore"); - infoFactory.addAttribute("classLoader", ClassLoader.class, false); - infoFactory.setConstructor(new String[]{"ConfigManager", "Repository", "ConfigStore", - "ServerInstances", "ServerInfo", "ThreadPool", "ArtifactManager", "PersistentConfigurationLists", "classLoader"}); + private LoggingPoller(DownloadPoller downloadPoller, Logger log) { + this.downloadPoller = downloadPoller; + this.log = log; + } - GBEAN_INFO = infoFactory.getBeanInfo(); - } + public void addRemovedConfigID(Artifact obsolete) { + log.info("Removed artifact: " + obsolete); + downloadPoller.addRemovedConfigID(obsolete); + } + + public void addInstalledConfigID(Artifact target) { + log.info("Installed artifact:" + target); + downloadPoller.addInstalledConfigID(target); + } + + public void addRestartedConfigID(Artifact target) { + log.info("Restarted artifact:" + target); + downloadPoller.addRestartedConfigID(target); + } + + public void addSkippedConfigID(MissingDependencyException e) { + log.info("Skipped artifact due to: ", e); + downloadPoller.addSkippedConfigID(e); + } + + public void addDependencyPresent(Artifact dep) { + log.info("Artifact already installed:" + dep); + downloadPoller.addDependencyPresent(dep); + } + + public void addDependencyInstalled(Artifact dep) { + log.info("Installed dependency:" + dep); + downloadPoller.addDependencyInstalled(dep); + } + + public void setCurrentFile(String currentFile) { + log.info("Current file:" + currentFile); + downloadPoller.setCurrentFile(currentFile); + } + + public void setCurrentMessage(String currentMessage) { + log.info(currentMessage); + downloadPoller.setCurrentMessage(currentMessage); + } - public static GBeanInfo getGBeanInfo() { - return GBEAN_INFO; + public void setCurrentFilePercent(int currentFileProgress) { + downloadPoller.setCurrentFilePercent(currentFileProgress); + } + + public void addDownloadBytes(long bytes) { + downloadPoller.addDownloadBytes(bytes); + } + + public void setFailure(Exception failure) { + log.info("Failure: ", failure); + downloadPoller.setFailure(failure); + } + + public void setFinished() { + log.info("Finished"); + downloadPoller.setFinished(); + } } + } Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryDownloader.java Tue Sep 16 16:52:24 2008 @@ -18,21 +18,32 @@ import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Properties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.apache.geronimo.gbean.AbstractName; -import org.apache.geronimo.gbean.GBeanInfo; -import org.apache.geronimo.gbean.GBeanInfoBuilder; +import org.apache.geronimo.gbean.annotation.GBean; +import org.apache.geronimo.gbean.annotation.ParamAttribute; +import org.apache.geronimo.gbean.annotation.ParamReference; +import org.apache.geronimo.gbean.annotation.ParamSpecial; +import org.apache.geronimo.gbean.annotation.SpecialAttributeType; import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.system.serverinfo.ServerInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * An implementation of PluginRepositoryList that downloads plugins from @@ -40,55 +51,121 @@ * * @version $Rev$ $Date$ */ +@GBean public class PluginRepositoryDownloader implements PluginRepositoryList { private static final Logger log = LoggerFactory.getLogger(PluginRepositoryDownloader.class); private List downloadRepositories = new ArrayList(); - private List userRepositories = new ArrayList(); - private Kernel kernel; - private AbstractName name; - private URL repositoryList; - - public PluginRepositoryDownloader(List downloadRepositories, List userRepositories, URL repositoryList, Kernel kernel, AbstractName name) { + private Map userRepositories = new HashMap(); + private final File userRepositoryList; + private final boolean restrictToKnownRepositories; + private final Kernel kernel; + private final AbstractName name; + private final URL repositoryList; + private static final String COMMENT = "List of known plugin repositories. Fomat: =="; + + public PluginRepositoryDownloader(@ParamAttribute(name = "downloadRepositories")List downloadRepositories, + @ParamAttribute(name = "userRepositoryList")String userRepositoryList, + @ParamAttribute(name = "repositoryList")URL repositoryList, + @ParamAttribute(name = "restrictToKnownRepositories")boolean restrictToKnownRepositories, + @ParamReference(name = "ServerInfo")ServerInfo serverInfo, + @ParamSpecial(type = SpecialAttributeType.kernel)Kernel kernel, + @ParamSpecial(type = SpecialAttributeType.abstractName)AbstractName name) { if (downloadRepositories != null) this.downloadRepositories = downloadRepositories; - if (userRepositories != null) this.userRepositories = userRepositories; this.repositoryList = repositoryList; + this.userRepositoryList = serverInfo.resolveServer(userRepositoryList); + this.restrictToKnownRepositories = restrictToKnownRepositories; this.kernel = kernel; this.name = name; + loadUserRepositories(); } - /** - * The list of repositories that were downloaded from central. - */ - public void setDownloadRepositories(List downloadRepositories) { - this.downloadRepositories = downloadRepositories; - if (this.downloadRepositories == null) this.downloadRepositories = new ArrayList(); + public PluginRepositoryDownloader(Map userRepositories, boolean restrictToKnownRepositories) { + this.userRepositories.putAll(userRepositories); + this.restrictToKnownRepositories = restrictToKnownRepositories; + userRepositoryList = null; + kernel = null; + name = null; + repositoryList = null; } - /** - * Any repositories that the user added manually - */ - public void setUserRepositories(List userRepositories) { - this.userRepositories = userRepositories; - if (this.userRepositories == null) this.userRepositories = new ArrayList(); + private synchronized void loadUserRepositories() { + userRepositories.clear(); + Properties properties = new Properties(); + boolean modified = false; + try { + InputStream in = new FileInputStream(userRepositoryList); + try { + properties.load(in); + for (Map.Entry entry : properties.entrySet()) { + String url = (String) entry.getKey(); + if (!url.endsWith("/")) { + url = url + "/"; + modified = true; + } + String rawCreds = (String) entry.getValue(); + String[] creds = null; + if (rawCreds.length() > 0) { + creds = rawCreds.split("="); + if (creds.length != 2) { + break; + } + } + userRepositories.put(url, creds); + } + } finally { + in.close(); + } + } catch (IOException e) { + //not much to do + } + if (modified) { + saveUserRepositories(); + } + } + + private synchronized void saveUserRepositories() { + Properties properties = new Properties(); + for (Map.Entry entry : userRepositories.entrySet()) { + String url = entry.getKey(); + String[] creds = entry.getValue(); + if (creds == null || creds.length != 2) { + properties.setProperty(url, ""); + } else { + properties.setProperty(url, creds[0] + "=" + creds[1]); + } + } + try { + OutputStream out = new FileOutputStream(userRepositoryList); + try { + properties.store(out, COMMENT); + } finally { + out.close(); + } + } catch (IOException e) { + //not much to do + } } + /** * Gets the union of centrally-listed repositories and user-added repositories. */ public List getRepositories() { List list = new ArrayList(); - for (String url : downloadRepositories) { - url = url.trim(); - if (!url.endsWith("/")) { - url = url + "/"; - } - try { - list.add(new URL(url)); - } catch (MalformedURLException e) { - log.error("Unable to format plugin repository URL " + url, e); + if (!restrictToKnownRepositories) { + for (String url : downloadRepositories) { + url = url.trim(); + if (!url.endsWith("/")) { + url = url + "/"; + } + try { + list.add(new URL(url)); + } catch (MalformedURLException e) { + log.error("Unable to format plugin repository URL " + url, e); + } } } - for (String userRepository : userRepositories) { + for (String userRepository : userRepositories.keySet()) { userRepository = userRepository.trim(); URL url = null; try { @@ -103,9 +180,37 @@ return list; } - static URI resolveRepository(String userRepository) { + public SourceRepository getSourceRepository(String repo) { + if (repo == null) { + throw new IllegalArgumentException("No repo supplied"); + } + URI repoURI = resolveRepository(repo); + if (repoURI == null) { + throw new IllegalStateException("Can't locate repo " + repo); + } + if (!repo.endsWith("/")) { + repo = repo + "/"; + } + String scheme = repoURI.getScheme(); + if (scheme.startsWith("http")) { + String[] creds = userRepositories.get(repo); + if (creds == null) { + return new RemoteSourceRepository(repoURI, null, null); + } else { + return new RemoteSourceRepository(repoURI, creds[0], creds[1]); + } + } else if ("file".equals(scheme)) { + return new LocalSourceRepository(new File(repoURI)); + } + throw new IllegalStateException("Cannot identify desired repo type for " + repo); + } + + private URI resolveRepository(String userRepository) { if (!userRepository.endsWith("/")) { - userRepository = userRepository + "/"; + userRepository = userRepository + "/"; + } + if (restrictToKnownRepositories && !userRepositories.containsKey(userRepository)) { + return null; } try { URI uri = new URI(userRepository); @@ -160,32 +265,9 @@ /** * Adds a new repository that the user put in manually. */ - public void addUserRepository(URL repo) { - userRepositories.add(repo.toString()); - try { - kernel.setAttribute(name, "userRepositories", userRepositories); - } catch (Exception e) { - log.error("Unable to save user repositories", e); - } + public synchronized void addUserRepository(URL repo, String userName, String password) { + userRepositories.put(repo.toString(), userName == null ? null : new String[]{userName, password}); + saveUserRepositories(); } - public static final GBeanInfo GBEAN_INFO; - - static { - GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(PluginRepositoryDownloader.class); - - infoFactory.addAttribute("downloadRepositories", List.class, true); - infoFactory.addAttribute("userRepositories", List.class, true); - infoFactory.addAttribute("repositoryList", URL.class, true); - infoFactory.addAttribute("kernel", Kernel.class, false); - infoFactory.addAttribute("abstractName", AbstractName.class, false); - infoFactory.addInterface(PluginRepositoryList.class); - infoFactory.setConstructor(new String[]{"downloadRepositories", "userRepositories", "repositoryList", "kernel", "abstractName"}); - - GBEAN_INFO = infoFactory.getBeanInfo(); - } - - public static GBeanInfo getGBeanInfo() { - return GBEAN_INFO; - } } Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryList.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryList.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryList.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginRepositoryList.java Tue Sep 16 16:52:24 2008 @@ -27,5 +27,7 @@ public interface PluginRepositoryList { public List getRepositories(); public void refresh(); - public void addUserRepository(URL repo); + public void addUserRepository(URL repo, String userName, String password); + + public SourceRepository getSourceRepository(String repo); } Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/RemoteSourceRepository.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/RemoteSourceRepository.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/RemoteSourceRepository.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/RemoteSourceRepository.java Tue Sep 16 16:52:24 2008 @@ -57,8 +57,8 @@ public class RemoteSourceRepository implements SourceRepository { private final URI base; - private String username = null; - private String password = null; + private final String username; + private final String password; public RemoteSourceRepository(URI base, String username, String password) { if (!base.getPath().endsWith("/")) { @@ -72,7 +72,7 @@ public PluginListType getPluginList() { try { URL uri = base.resolve("geronimo-plugins.xml").toURL(); - InputStream in = openStream(null, uri); + InputStream in = openStream(uri); if (in != null) { try { return PluginXmlUtil.loadPluginList(in); @@ -86,7 +86,7 @@ return null; } - public OpenResult open(Artifact artifact, FileWriteMonitor monitor) throws IOException, FailedLoginException { + public OpenResult open(final Artifact artifact, final FileWriteMonitor monitor) throws IOException, FailedLoginException { // If the artifact version is resolved then look for the artifact in the repo if (artifact.isResolved()) { @@ -162,8 +162,9 @@ }); for (Version version : available) { - URL location = getURL(new Artifact(artifact.getGroupId(), artifact.getArtifactId(), version, artifact.getType())); - OpenResult result = open(artifact, location); + Artifact versionedArtifact = new Artifact(artifact.getGroupId(), artifact.getArtifactId(), version, artifact.getType()); + URL location = getURL(versionedArtifact); + OpenResult result = open(versionedArtifact, location); if (result != null) { return result; } @@ -174,12 +175,11 @@ } private OpenResult open(Artifact artifact, URL location) throws IOException, FailedLoginException { - InputStream in = openStream(artifact, location); + InputStream in = openStream(location); return (in == null) ? null : new RemoteOpenResult(artifact, in); } - private InputStream openStream(Artifact artifact, URL location) throws IOException, FailedLoginException { - int size = 0; + private InputStream openStream(URL location) throws IOException, FailedLoginException { URLConnection con = location.openConnection(); if (con instanceof HttpURLConnection) { HttpURLConnection http = (HttpURLConnection) con; @@ -198,15 +198,8 @@ } else if (http.getResponseCode() == 404) { return null; // Not found at this repository } - if (http.getContentLength() > 0) { - size = http.getContentLength(); - } } else if (http.getResponseCode() == 404) { return null; // Not found at this repository - } else { - if (http.getContentLength() > 0) { - size = http.getContentLength(); - } } return http.getInputStream(); } @@ -220,10 +213,10 @@ try { URL metaURL = base.resolve( "maven-metadata.xml").toURL(); - in = openStream(null, metaURL); + in = openStream(metaURL); if (in == null) { // check for local maven metadata metaURL = base.resolve("maven-metadata-local.xml").toURL(); - in = openStream(null, metaURL); + in = openStream(metaURL); } if (in != null) { DocumentBuilder builder = XmlUtil.newDocumentBuilderFactory().newDocumentBuilder(); @@ -315,6 +308,9 @@ private File file; private RemoteOpenResult(Artifact artifact, InputStream in) { + if (!artifact.isResolved()) { + throw new IllegalStateException("Artifact is not resolved: " + artifact); + } this.artifact = artifact; this.in = in; } Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-plugin/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/test/java/org/apache/geronimo/system/plugin/CopyFileTest.java Tue Sep 16 16:52:24 2008 @@ -93,7 +93,8 @@ public void execute(String consumerName, Runnable runnable) { new Thread(runnable).start(); } - }, new ArrayList()); + }, new ArrayList(), + null); } public void testCopyFile() throws Exception { Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/test/java/org/apache/geronimo/system/plugin/PluginInstallerTest.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/test/java/org/apache/geronimo/system/plugin/PluginInstallerTest.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-plugin/src/test/java/org/apache/geronimo/system/plugin/PluginInstallerTest.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/test/java/org/apache/geronimo/system/plugin/PluginInstallerTest.java Tue Sep 16 16:52:24 2008 @@ -16,39 +16,20 @@ */ package org.apache.geronimo.system.plugin; -import java.io.IOException; import java.net.URL; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; -import java.util.List; -import java.util.LinkedHashSet; import java.util.concurrent.TimeUnit; import junit.framework.TestCase; -import org.apache.geronimo.gbean.AbstractName; -import org.apache.geronimo.kernel.config.Configuration; -import org.apache.geronimo.kernel.config.ConfigurationData; -import org.apache.geronimo.kernel.config.ConfigurationManager; -import org.apache.geronimo.kernel.config.ConfigurationStore; -import org.apache.geronimo.kernel.config.LifecycleException; -import org.apache.geronimo.kernel.config.LifecycleMonitor; -import org.apache.geronimo.kernel.config.LifecycleResults; -import org.apache.geronimo.kernel.config.NoSuchConfigException; -import org.apache.geronimo.kernel.config.NoSuchStoreException; -import org.apache.geronimo.kernel.config.InvalidConfigException; import org.apache.geronimo.kernel.mock.MockConfigStore; import org.apache.geronimo.kernel.mock.MockWritableListableRepository; import org.apache.geronimo.kernel.mock.MockConfigurationManager; -import org.apache.geronimo.kernel.repository.Artifact; -import org.apache.geronimo.kernel.repository.ArtifactResolver; -import org.apache.geronimo.kernel.repository.Repository; -import org.apache.geronimo.kernel.repository.Version; -import org.apache.geronimo.kernel.repository.MissingDependencyException; import org.apache.geronimo.system.plugin.model.PluginArtifactType; import org.apache.geronimo.system.plugin.model.PluginListType; import org.apache.geronimo.system.plugin.model.PluginType; import org.apache.geronimo.system.serverinfo.BasicServerInfo; +import org.apache.geronimo.system.serverinfo.ServerInfo; import org.apache.geronimo.system.threads.ThreadPool; /** @@ -67,8 +48,9 @@ String url = getClass().getResource("/geronimo-plugins.xml").toString(); int pos = url.lastIndexOf("/"); testRepo = url.substring(0, pos); + ServerInfo serverInfo = new BasicServerInfo("."); installer = new PluginInstallerGBean(new MockConfigurationManager(), new MockWritableListableRepository(), new MockConfigStore(), - new BasicServerInfo("."), new ThreadPool() { + serverInfo, new ThreadPool() { public int getPoolSize() { return 0; } @@ -88,11 +70,12 @@ public void execute(String consumerName, Runnable runnable) { new Thread(runnable).start(); } - }, new ArrayList()); + }, new ArrayList(), + new PluginRepositoryDownloader(Collections.emptyList(), "", null, false, serverInfo, null, null)); } public void testParsing() throws Exception { - PluginListType list = installer.listPlugins(new URL(testRepo), null, null); + PluginListType list = installer.listPlugins(new URL(testRepo)); assertNotNull(list); assertEquals(1, list.getDefaultRepository().size()); assertEquals(fakeRepo, list.getDefaultRepository().get(0)); 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=696105&r1=696104&r2=696105&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 Sep 16 16:52:24 2008 @@ -247,6 +247,10 @@ attributeChanged(); } + public boolean isModuleInstalled(Artifact artifact) { + return serverOverride.getConfiguration(artifact) != null; + } + public void addConfigSubstitutions(Properties properties) { localConfigSubstitutions.putAll(properties); Map configSubstutions = loadAllConfigSubstitutions(localConfigSubstitutions, prefix); Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/PluginAttributeStore.java Tue Sep 16 16:52:24 2008 @@ -39,4 +39,6 @@ public void setModuleGBeans(Artifact moduleName, List gbeans, boolean load, String condition) throws InvalidGBeanException; void addConfigSubstitutions(Properties properties); + + boolean isModuleInstalled(Artifact artifact); } Modified: geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/JmxDiscoveryPublisher.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/JmxDiscoveryPublisher.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/JmxDiscoveryPublisher.java (original) +++ geronimo/server/trunk/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/discovery/JmxDiscoveryPublisher.java Tue Sep 16 16:52:24 2008 @@ -31,7 +31,7 @@ import org.apache.geronimo.kernel.rmi.RMIRegistryService; /** - * @version $Rev:$ $Date:$ + * @version $Rev$ $Date$ */ @GBean public class JmxDiscoveryPublisher implements GBeanLifecycle { @@ -49,7 +49,7 @@ ) throws URISyntaxException, IOException { this.discoveryAgent = discoveryAgent; String query = null; - if (nodeName != null) { + if (nodeName != null && nodeName.length() > 0) { query = "node=" + nodeName; } if (clusterName != null) { Modified: geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java (original) +++ geronimo/server/trunk/plugins/clustering/geronimo-plugin-farm/src/main/java/org/apache/geronimo/farm/plugin/FarmGBean.java Tue Sep 16 16:52:24 2008 @@ -40,6 +40,8 @@ import org.apache.geronimo.system.plugin.DownloadResults; import org.apache.geronimo.system.plugin.PluginInstaller; import org.apache.geronimo.system.plugin.model.PluginListType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * //need interface for operations @@ -49,6 +51,7 @@ */ @GBean public class FarmGBean implements NodeListener, org.apache.geronimo.system.plugin.Farm { + private static final Logger log = LoggerFactory.getLogger(FarmGBean.class); private String defaultRepository; private EntityManagerFactory emf; @@ -65,6 +68,7 @@ public Map addNode(String clusterName, NodeInfo nodeInfo) { + log.info("Node " + nodeInfo.getName() + " added to cluster " + clusterName); JpaClusterInfo cluster; JpaNodeInfo jpaNodeInfo; synchronized (this) { @@ -82,6 +86,7 @@ } public void removeNode(String clusterName, String nodeName) { + log.info("Node " + nodeName + " renoved from cluster " + clusterName); synchronized (this) { JpaContext clusterContext = new JpaContext(emf); JpaClusterInfo cluster = clusterContext.getClusterInfo(clusterName); Modified: geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/AddRepositoryHandler.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/AddRepositoryHandler.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/AddRepositoryHandler.java (original) +++ geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/AddRepositoryHandler.java Tue Sep 16 16:52:24 2008 @@ -145,7 +145,10 @@ return false; } } - lists.get(0).addUserRepository(url); + //TODO fish these out of the request? + String userName = null; + String password = null; + lists.get(0).addUserRepository(url, userName, password); request.setAttribute("repository", repo); return true; } Modified: geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/BaseImportExportHandler.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/BaseImportExportHandler.java?rev=696105&r1=696104&r2=696105&view=diff ============================================================================== --- geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/BaseImportExportHandler.java (original) +++ geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/BaseImportExportHandler.java Tue Sep 16 16:52:24 2008 @@ -70,7 +70,7 @@ if (list == null || !repo.equals(listRepo)) { try { - list = pluginInstaller.listPlugins(new URL(repo), user, pass); + list = pluginInstaller.listPlugins(new URL(repo)); } catch (FailedLoginException e) { throw new PortletException("Invalid login for repository '" + repo + "'", e); }