/******************************************************************************* * Copyright (c) 2010 SpringSource, a divison of VMware, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * SpringSource, a division of VMware, Inc. - initial API and implementation *******************************************************************************/ package org.eclipse.virgo.ide.runtime.internal.core.command; import java.io.IOException; import java.net.URI; import java.util.Map; import java.util.concurrent.TimeoutException; import javax.management.openmbean.CompositeData; import org.eclipse.virgo.ide.facet.core.FacetCorePlugin; import org.eclipse.virgo.ide.runtime.core.IServerBehaviour; import org.eclipse.virgo.ide.runtime.internal.core.DeploymentIdentity; import org.eclipse.wst.server.core.IModule; /** * {@link IServerCommand} to deploy a PAR or bundle. * @author Christian Dupuis * @since 1.0.1 */ public class JmxServer20DeployCommand extends AbstractJmxServerDeployerCommand<CompositeData> implements IServerCommand<DeploymentIdentity> { private static final String ITEM_SYMBOLIC_NAME = "symbolicName"; //$NON-NLS-1$ private static final String ITEM_VERSION = "version"; //$NON-NLS-1$ /** * Creates a new {@link JmxServer20DeployCommand}. */ public JmxServer20DeployCommand(IServerBehaviour serverBehaviour, IModule module) { super(serverBehaviour, module); } /** * {@inheritDoc} */ public DeploymentIdentity execute() throws IOException, TimeoutException { CompositeData returnValue = doExecute(); if (returnValue != null) { String symbolicName = (String) ((CompositeData) returnValue).get(ITEM_SYMBOLIC_NAME); String version = (String) ((CompositeData) returnValue).get(ITEM_VERSION); Map<String, DeploymentIdentity> identities = serverBehaviour.getDeploymentIdentities(); DeploymentIdentity identity = new DeploymentIdentity(symbolicName, version); identities.put(module.getId(), identity); return identity; } return null; } /** * {@inheritDoc} */ protected Object[] getOperationArguments() { URI uri = null; if (module.getModuleType().getId().equals(FacetCorePlugin.PLAN_FACET_ID)) { String fileName = module.getId(); fileName = fileName.substring(fileName.lastIndexOf('/') + 1); uri = getUri(serverBehaviour.getModuleDeployUri(module).append(fileName)); } else { uri = getUri(serverBehaviour.getModuleDeployUri(module)); } return new Object[] { uri.toString(), false }; } /** * {@inheritDoc} */ protected String getOperationName() { return "deploy"; } }