You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by va...@apache.org on 2007/11/23 16:43:06 UTC
svn commit: r597690 - in /geronimo/server:
branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/
branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/
branches/2.0/modules/geroni...
Author: vamsic007
Date: Fri Nov 23 07:43:02 2007
New Revision: 597690
URL: http://svn.apache.org/viewvc?rev=597690&view=rev
Log:
GERONIMO-3611 Deployer should provide an "install-library" option to upload jars to repository
o Deployer util now supports an "install-library" option.
o Added an installLibrary method to PluginInstaller.
o Thanks to David Jencks for his suggestion.
Added:
geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java (with props)
geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java (with props)
geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java (with props)
geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java (with props)
geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java (with props)
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java (with props)
Modified:
geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
geronimo/server/branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
geronimo/server/branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
geronimo/server/branches/2.0/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java
geronimo/server/branches/2.0/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
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/DeployTool.java
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java
geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
Modified: geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java?rev=597690&r1=597689&r2=597690&view=diff
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java (original)
+++ geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java Fri Nov 23 07:43:02 2007
@@ -85,6 +85,7 @@
commandMetaData.add(SearchPluginsCommandMetaData.META_DATA);
commandMetaData.add(InstallPluginCommandMetaData.META_DATA);
commandMetaData.add(HelpCommandMetaData.META_DATA);
+ commandMetaData.add(InstallLibraryCommandMetaData.META_DATA);
addURI();
addHost();
Added: geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java?rev=597690&view=auto
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java (added)
+++ geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java Fri Nov 23 07:43:02 2007
@@ -0,0 +1,74 @@
+/**
+ * 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.cli.deployer;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.geronimo.cli.CLParserException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InstallLibraryCommandArgs implements CommandArgs {
+ private final static String ARGUMENT_GROUP_ID_SHORTFORM = "g";
+ private final static String ARGUMENT_GROUP_ID = "groupId";
+
+ protected final Options options;
+ protected CommandLine commandLine;
+
+ public InstallLibraryCommandArgs(String[] args) throws CLParserException {
+ options = new Options();
+ addGroupId();
+
+ CommandLineParser parser = new GnuParser();
+ try {
+ commandLine = parser.parse(options, args, true);
+ } catch (ParseException e) {
+ throw new CLParserException(e.getMessage(), e);
+ }
+
+ if (0 == commandLine.getArgs().length) {
+ throw new CLParserException("Must specify a LibraryFile.");
+ } else if (1 < commandLine.getArgs().length) {
+ throw new CLParserException("Too many arguments.");
+ }
+ }
+
+ protected void addGroupId() {
+ OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName(ARGUMENT_GROUP_ID);
+ optionBuilder = optionBuilder.withLongOpt(ARGUMENT_GROUP_ID);
+ optionBuilder = optionBuilder
+ .withDescription("If a groupId is provided, the library file will be installed under that groupId. "+
+ "Otherwise, default will be used.");
+ Option option = optionBuilder.create(ARGUMENT_GROUP_ID_SHORTFORM);
+ options.addOption(option);
+ }
+
+ public String getGroupId() {
+ return commandLine.getOptionValue(ARGUMENT_GROUP_ID_SHORTFORM);
+ }
+
+ public String[] getArgs() {
+ return commandLine.getArgs();
+ }
+
+}
Propchange: geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java?rev=597690&view=auto
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java (added)
+++ geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java Fri Nov 23 07:43:02 2007
@@ -0,0 +1,39 @@
+/**
+ * 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.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InstallLibraryCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new InstallLibraryCommandMetaData();
+
+ private InstallLibraryCommandMetaData() {
+ super("install-library", "2. Other Commands", "[--groupId grp] LibraryFile",
+ "Installs a library file into repository.\n"+
+ "If a groupId is provided, the library file will be installed under that groupId. "+
+ "Otherwise, default will be used. "+
+ "The artifactId, version and type are computed from the library file name which should be in the form "+
+ "<artifactId>-<version>.<type>, for e.g. mylib-1.0.jar.");
+ }
+
+ public CommandArgs parse(String[] newArgs) throws CLParserException {
+ return new InstallLibraryCommandArgs(newArgs);
+ }
+}
Propchange: geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/branches/2.0/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java?rev=597690&r1=597689&r2=597690&view=diff
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java (original)
+++ geronimo/server/branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java Fri Nov 23 07:43:02 2007
@@ -60,7 +60,7 @@
protected Kernel kernel;
private ConfigurationManager configurationManager;
- private CommandContext commandContext;
+ protected CommandContext commandContext;
private final Collection<ModuleConfigurer> moduleConfigurers;
public JMXDeploymentManager(Collection<ModuleConfigurer> moduleConfigurers) {
Modified: geronimo/server/branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java?rev=597690&r1=597689&r2=597690&view=diff
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java (original)
+++ geronimo/server/branches/2.0/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java Fri Nov 23 07:43:02 2007
@@ -53,6 +53,7 @@
import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.system.jmx.KernelDelegate;
import org.apache.geronimo.system.plugin.DownloadPoller;
@@ -285,6 +286,32 @@
return (URL[]) list.toArray(new URL[list.size()]);
}
+ public Artifact installLibrary(File libFile, String groupId) throws IOException {
+ File[] args = new File[]{libFile};
+ if(!isSameMachine) {
+ AbstractDeployCommand progress = new AbstractDeployCommand(CommandType.DISTRIBUTE, kernel, null, null, null, null, null, false) {
+ public void run() {
+ }
+ };
+ progress.addProgressListener(new ProgressListener() {
+ public void handleProgressEvent(ProgressEvent event) {
+ log.info(event.getDeploymentStatus().getMessage());
+ }
+ });
+ progress.setCommandContext(commandContext);
+ RemoteDeployUtil.uploadFilesToServer(args, progress);
+ }
+ Set set = kernel.listGBeans(new AbstractNameQuery(PluginInstaller.class.getName()));
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ AbstractName name = (AbstractName) it.next();
+ PluginInstaller installer = (PluginInstaller) kernel.getProxyManager().createProxy(name, PluginInstaller.class);
+ Artifact artifact = (Artifact) installer.installLibrary(libFile, groupId);
+ kernel.getProxyManager().destroyProxy(installer);
+ return artifact;
+ }
+ return null;
+ }
+
public static final GBeanInfo GBEAN_INFO;
public static final String GBEAN_REF_MODULE_CONFIGURERS = "ModuleConfigurers";
Added: geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java?rev=597690&view=auto
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java (added)
+++ geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java Fri Nov 23 07:43:02 2007
@@ -0,0 +1,63 @@
+/**
+ * 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.deployment.cli;
+
+import java.io.File;
+import java.io.PrintWriter;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+
+import org.apache.geronimo.cli.deployer.CommandArgs;
+import org.apache.geronimo.cli.deployer.InstallLibraryCommandArgs;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CommandInstallLibrary extends AbstractCommand {
+
+ public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+ if (!(commandArgs instanceof InstallLibraryCommandArgs)) {
+ throw new DeploymentSyntaxException("CommandArgs has the type [" + commandArgs.getClass() + "]; expected [" + InstallLibraryCommandArgs.class + "]");
+ }
+ InstallLibraryCommandArgs installLibraryCommandArgs = (InstallLibraryCommandArgs)commandArgs;
+ File libFile = new File(installLibraryCommandArgs.getArgs()[0]);
+ if(!libFile.exists() || !libFile.isFile() || !libFile.canRead()) {
+ throw new DeploymentException("File does not exist or not a normal file or not readable. "+libFile);
+ }
+ DeploymentManager dmgr = connection.getDeploymentManager();
+ if(dmgr instanceof GeronimoDeploymentManager) {
+ GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
+ String groupId = installLibraryCommandArgs.getGroupId();
+ try {
+ Artifact artifact = mgr.installLibrary(libFile, groupId);
+ if(artifact != null) {
+ out.print(DeployUtils.reformat("Installed "+artifact, 4, 72));
+ } else {
+ throw new DeploymentException("Unable to install library "+installLibraryCommandArgs.getArgs()[0]);
+ }
+ } catch (Exception e) {
+ throw new DeploymentException("Unable to install library "+installLibraryCommandArgs.getArgs()[0], e);
+ }
+ } else {
+ throw new DeploymentException("Cannot install library when connected to "+connection.getServerURI());
+ }
+ }
+}
Propchange: geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java?rev=597690&r1=597689&r2=597690&view=diff
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java (original)
+++ geronimo/server/branches/2.0/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java Fri Nov 23 07:43:02 2007
@@ -38,6 +38,7 @@
import org.apache.geronimo.cli.deployer.DeployCommandMetaData;
import org.apache.geronimo.cli.deployer.DeployerCLParser;
import org.apache.geronimo.cli.deployer.DistributeCommandMetaData;
+import org.apache.geronimo.cli.deployer.InstallLibraryCommandMetaData;
import org.apache.geronimo.cli.deployer.InstallPluginCommandMetaData;
import org.apache.geronimo.cli.deployer.ListModulesCommandMetaData;
import org.apache.geronimo.cli.deployer.ListTargetsCommandMetaData;
@@ -84,6 +85,7 @@
commands.put(UndeployCommandMetaData.META_DATA, new CommandUndeploy());
commands.put(SearchPluginsCommandMetaData.META_DATA, new CommandListConfigurations());
commands.put(InstallPluginCommandMetaData.META_DATA, new CommandInstallCAR());
+ commands.put(InstallLibraryCommandMetaData.META_DATA, new CommandInstallLibrary());
}
private boolean failed = false;
Modified: geronimo/server/branches/2.0/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java?rev=597690&r1=597689&r2=597690&view=diff
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java (original)
+++ geronimo/server/branches/2.0/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstaller.java Fri Nov 23 07:43:02 2007
@@ -153,4 +153,10 @@
* @param key Identifies the operation to check on
*/
public DownloadResults checkOnInstall(Object key);
+
+ /**
+ * @throws IOException
+ *
+ */
+ public Artifact installLibrary(File libFile, String groupId) throws IOException;
}
Modified: geronimo/server/branches/2.0/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=597690&r1=597689&r2=597690&view=diff
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java (original)
+++ geronimo/server/branches/2.0/modules/geronimo-system/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java Fri Nov 23 07:43:02 2007
@@ -44,6 +44,8 @@
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import javax.security.auth.login.FailedLoginException;
import javax.xml.parsers.DocumentBuilder;
@@ -110,6 +112,9 @@
private ThreadPool threadPool;
private PluginAttributeStore attributeStore;
+ // 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, PluginAttributeStore store) {
this.configManager = configManager;
this.writeableRepo = repository;
@@ -2138,5 +2143,21 @@
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
+ }
+
+ public Artifact installLibrary(File libFile, String groupId) throws IOException {
+ String artifactId = null, version = null, type = null;
+ Matcher matcher = MAVEN_1_PATTERN_PART.matcher("");
+ matcher.reset(libFile.getName());
+ if(matcher.matches()) {
+ artifactId = matcher.group(1);
+ version = matcher.group(2);
+ type = matcher.group(3);
+ } else {
+ throw new IllegalArgumentException("Filename "+libFile.getName()+" is not in the form <artifact>-<version>.<type>, for e.g. mylib-1.0.jar.");
+ }
+ Artifact artifact = new Artifact(groupId != null ? groupId : Artifact.DEFAULT_GROUP_ID, artifactId, version, type);
+ writeableRepo.copyToRepository(libFile, artifact, null);
+ return artifact;
}
}
Modified: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java?rev=597690&r1=597689&r2=597690&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java Fri Nov 23 07:43:02 2007
@@ -85,6 +85,7 @@
commandMetaData.add(SearchPluginsCommandMetaData.META_DATA);
commandMetaData.add(InstallPluginCommandMetaData.META_DATA);
commandMetaData.add(HelpCommandMetaData.META_DATA);
+ commandMetaData.add(InstallLibraryCommandMetaData.META_DATA);
addURI();
addHost();
Added: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java?rev=597690&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java Fri Nov 23 07:43:02 2007
@@ -0,0 +1,74 @@
+/**
+ * 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.cli.deployer;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.geronimo.cli.CLParserException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InstallLibraryCommandArgs implements CommandArgs {
+ private final static String ARGUMENT_GROUP_ID_SHORTFORM = "g";
+ private final static String ARGUMENT_GROUP_ID = "groupId";
+
+ protected final Options options;
+ protected CommandLine commandLine;
+
+ public InstallLibraryCommandArgs(String[] args) throws CLParserException {
+ options = new Options();
+ addGroupId();
+
+ CommandLineParser parser = new GnuParser();
+ try {
+ commandLine = parser.parse(options, args, true);
+ } catch (ParseException e) {
+ throw new CLParserException(e.getMessage(), e);
+ }
+
+ if (0 == commandLine.getArgs().length) {
+ throw new CLParserException("Must specify a LibraryFile.");
+ } else if (1 < commandLine.getArgs().length) {
+ throw new CLParserException("Too many arguments.");
+ }
+ }
+
+ protected void addGroupId() {
+ OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName(ARGUMENT_GROUP_ID);
+ optionBuilder = optionBuilder.withLongOpt(ARGUMENT_GROUP_ID);
+ optionBuilder = optionBuilder
+ .withDescription("If a groupId is provided, the library file will be installed under that groupId. "+
+ "Otherwise, default will be used.");
+ Option option = optionBuilder.create(ARGUMENT_GROUP_ID_SHORTFORM);
+ options.addOption(option);
+ }
+
+ public String getGroupId() {
+ return commandLine.getOptionValue(ARGUMENT_GROUP_ID_SHORTFORM);
+ }
+
+ public String[] getArgs() {
+ return commandLine.getArgs();
+ }
+
+}
Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandArgs.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java?rev=597690&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java Fri Nov 23 07:43:02 2007
@@ -0,0 +1,39 @@
+/**
+ * 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.cli.deployer;
+
+import org.apache.geronimo.cli.CLParserException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InstallLibraryCommandMetaData extends BaseCommandMetaData {
+ public static final CommandMetaData META_DATA = new InstallLibraryCommandMetaData();
+
+ private InstallLibraryCommandMetaData() {
+ super("install-library", "2. Other Commands", "[--groupId grp] LibraryFile",
+ "Installs a library file into repository.\n"+
+ "If a groupId is provided, the library file will be installed under that groupId. "+
+ "Otherwise, default will be used. "+
+ "The artifactId, version and type are computed from the library file name which should be in the form "+
+ "<artifactId>-<version>.<type>, for e.g. mylib-1.0.jar.");
+ }
+
+ public CommandArgs parse(String[] newArgs) throws CLParserException {
+ return new InstallLibraryCommandArgs(newArgs);
+ }
+}
Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/InstallLibraryCommandMetaData.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java?rev=597690&r1=597689&r2=597690&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java Fri Nov 23 07:43:02 2007
@@ -60,7 +60,7 @@
protected Kernel kernel;
private ConfigurationManager configurationManager;
- private CommandContext commandContext;
+ protected CommandContext commandContext;
private final Collection<ModuleConfigurer> moduleConfigurers;
public JMXDeploymentManager(Collection<ModuleConfigurer> moduleConfigurers) {
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=597690&r1=597689&r2=597690&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 Fri Nov 23 07:43:02 2007
@@ -52,6 +52,7 @@
import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.NoSuchStoreException;
import org.apache.geronimo.kernel.repository.Artifact;
@@ -306,6 +307,31 @@
kernel.getProxyManager().destroyProxy(repo);
}
return list.toArray(new URL[list.size()]);
+ }
+
+ public Artifact installLibrary(File libFile, String groupId) throws IOException {
+ File[] args = new File[]{libFile};
+ if(!isSameMachine) {
+ AbstractDeployCommand progress = new AbstractDeployCommand(CommandType.DISTRIBUTE, kernel, null, null, null, null, null, false) {
+ public void run() {
+ }
+ };
+ progress.addProgressListener(new ProgressListener() {
+ public void handleProgressEvent(ProgressEvent event) {
+ log.info(event.getDeploymentStatus().getMessage());
+ }
+ });
+ progress.setCommandContext(commandContext);
+ RemoteDeployUtil.uploadFilesToServer(args, progress);
+ }
+ Set<AbstractName> set = kernel.listGBeans(new AbstractNameQuery(PluginInstaller.class.getName()));
+ for (AbstractName name : set) {
+ PluginInstaller installer = (PluginInstaller) kernel.getProxyManager().createProxy(name, PluginInstaller.class);
+ Artifact artifact = (Artifact) installer.installLibrary(libFile, groupId);
+ kernel.getProxyManager().destroyProxy(installer);
+ return artifact;
+ }
+ return null;
}
public static final GBeanInfo GBEAN_INFO;
Added: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java?rev=597690&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java Fri Nov 23 07:43:02 2007
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.deployment.cli;
+
+import java.io.File;
+import java.io.PrintWriter;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+
+import org.apache.geronimo.cli.deployer.CommandArgs;
+import org.apache.geronimo.cli.deployer.InstallLibraryCommandArgs;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
+import org.apache.geronimo.kernel.repository.Artifact;
+import jline.ConsoleReader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CommandInstallLibrary extends AbstractCommand {
+
+ public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+ if (!(commandArgs instanceof InstallLibraryCommandArgs)) {
+ throw new DeploymentSyntaxException("CommandArgs has the type [" + commandArgs.getClass() + "]; expected [" + InstallLibraryCommandArgs.class + "]");
+ }
+ InstallLibraryCommandArgs installLibraryCommandArgs = (InstallLibraryCommandArgs)commandArgs;
+ File libFile = new File(installLibraryCommandArgs.getArgs()[0]);
+ if(!libFile.exists() || !libFile.isFile() || !libFile.canRead()) {
+ throw new DeploymentException("File does not exist or not a normal file or not readable. "+libFile);
+ }
+ DeploymentManager dmgr = connection.getDeploymentManager();
+ if(dmgr instanceof GeronimoDeploymentManager) {
+ GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
+ String groupId = installLibraryCommandArgs.getGroupId();
+ try {
+ Artifact artifact = mgr.installLibrary(libFile, groupId);
+ if(artifact != null) {
+ consoleReader.printString(DeployUtils.reformat("Installed "+artifact, 4, 72));
+ } else {
+ throw new DeploymentException("Unable to install library "+installLibraryCommandArgs.getArgs()[0]);
+ }
+ } catch (Exception e) {
+ throw new DeploymentException("Unable to install library "+installLibraryCommandArgs.getArgs()[0], e);
+ }
+ } else {
+ throw new DeploymentException("Cannot install library when connected to "+connection.getServerURI());
+ }
+ }
+}
Propchange: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java?rev=597690&r1=597689&r2=597690&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java Fri Nov 23 07:43:02 2007
@@ -38,6 +38,7 @@
import org.apache.geronimo.cli.deployer.DeployCommandMetaData;
import org.apache.geronimo.cli.deployer.DeployerCLParser;
import org.apache.geronimo.cli.deployer.DistributeCommandMetaData;
+import org.apache.geronimo.cli.deployer.InstallLibraryCommandMetaData;
import org.apache.geronimo.cli.deployer.InstallPluginCommandMetaData;
import org.apache.geronimo.cli.deployer.ListModulesCommandMetaData;
import org.apache.geronimo.cli.deployer.ListTargetsCommandMetaData;
@@ -85,6 +86,7 @@
commands.put(UndeployCommandMetaData.META_DATA, new CommandUndeploy());
commands.put(SearchPluginsCommandMetaData.META_DATA, new CommandListConfigurations());
commands.put(InstallPluginCommandMetaData.META_DATA, new CommandInstallCAR());
+ commands.put(InstallLibraryCommandMetaData.META_DATA, new CommandInstallLibrary());
}
private boolean failed = false;
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=597690&r1=597689&r2=597690&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 Fri Nov 23 07:43:02 2007
@@ -179,4 +179,6 @@
public Dependency[] checkPrerequisites(PluginType plugin);
PluginListType createPluginListForRepositories(ConfigurationManager mgr, String repo) throws NoSuchStoreException;
+
+ public Artifact installLibrary(File libFile, String groupId) throws IOException;
}
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=597690&r1=597689&r2=597690&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 Fri Nov 23 07:43:02 2007
@@ -47,6 +47,8 @@
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import javax.security.auth.login.FailedLoginException;
@@ -123,6 +125,9 @@
private final ThreadPool threadPool;
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) {
this.configManager = configManager;
this.writeableRepo = repository;
@@ -714,6 +719,22 @@
}
}
return missingPrereqs.toArray(new Dependency[missingPrereqs.size()]);
+ }
+
+ public Artifact installLibrary(File libFile, String groupId) throws IOException {
+ String artifactId = null, version = null, type = null;
+ Matcher matcher = MAVEN_1_PATTERN_PART.matcher("");
+ matcher.reset(libFile.getName());
+ if(matcher.matches()) {
+ artifactId = matcher.group(1);
+ version = matcher.group(2);
+ type = matcher.group(3);
+ } else {
+ throw new IllegalArgumentException("Filename "+libFile.getName()+" is not in the form <artifact>-<version>.<type>, for e.g. mylib-1.0.jar.");
+ }
+ Artifact artifact = new Artifact(groupId != null ? groupId : Artifact.DEFAULT_GROUP_ID, artifactId, version, type);
+ writeableRepo.copyToRepository(libFile, artifact, null);
+ return artifact;
}
/**