public synchronized void deploy(Deployable deployable) if (!canBeDeployed(deployable)) + getDeployableDir(deployable) + "]. The required web context is already in use" + " by another application."); if (!getContainer().getCapability().supportsDeployableType(deployable.getType())) + " archives are not supported for deployment in [" + getContainer().getId() + "]. Got [" + deployable.getFile() + "]"); String deployableDir = getDeployableDir(deployable); if (!shouldDeployExpanded(deployable.getType())) throw new ContainerException("Container " + getContainer().getName() + " cannot deploy expanded " + deployable.getType() + " deployables"); if (!getFileHandler().isDirectory(deployable.getFile())) doDeploy(deployableDir, deployable);
/** * Replace the slashes with <code>#</code> in the deployable name (see: CARGO-1041). * {@inheritDoc} */ @Override protected String getDeployableName(Deployable deployable) { return super.getDeployableName(deployable).replace('/', '#'); } }
/** * {@inheritDoc} */ @Override public void deploy(Deployable deployable) { // If necessary, warn the user about this deployer's limitations warn(); super.deploy(deployable); }
getLogger().info("Deploying [" + deployable.getFile() + "] to [" + deployableDir + "]...", this.getClass().getName()); if (!getFileHandler().isDirectory(deployableDir)) String target = getFileHandler().append(deployableDir, getDeployableName(deployable)); if (deployable.isExpanded()) if (getFileHandler().exists(target) && !getFileHandler().isDirectory(target)) getFileHandler().delete(target); getFileHandler().copyDirectory(deployable.getFile(), target); if (getFileHandler().exists(target) && getFileHandler().isDirectory(target)) getFileHandler().delete(target); getFileHandler().copyFile(deployable.getFile(), target, true);
/** * Test that the handling of ShouldDeployExpanded functions correctly. */ public void testShouldDeployExpanded() { AbstractCopyingInstalledLocalDeployer deployer = new TestableCopyingDeployer( createContainer(createContainerCapability(DeployableType.WAR), null)); assertTrue(deployer.shouldDeployExpanded(DeployableType.WAR)); deployer.setShouldDeployExpanded(DeployableType.WAR, true); assertTrue(deployer.shouldDeployExpanded(DeployableType.WAR)); deployer.setShouldDeployExpanded(DeployableType.WAR, false); assertFalse(deployer.shouldDeployExpanded(DeployableType.WAR)); deployer.setShouldDeployExpanded(DeployableType.WAR, true); assertTrue(deployer.shouldDeployExpanded(DeployableType.WAR)); }
protected void doDeploy(String deployableDir, Deployable deployable) super.doDeploy(deployableDir, deployable);
/** * Removes previously deployed artifact. * * @param deployable artifact to undeploy */ @Override public void undeploy(Deployable deployable) { if (deployable.getType() != DeployableType.WAR) { super.undeploy(deployable); return; } WAR war = (WAR) deployable; String fileName = getFileHandler().append(getDeployableDir(deployable), war.getContext() + ".war"); if (getFileHandler().exists(fileName)) { getLogger().info("Undeploying [" + fileName + "]...", this.getClass().getName()); getFileHandler().delete(fileName); } }
super.doDeploy(deployableDir, deployable);
/** * Removes previously deployed artifact. * * @param deployable artifact to undeploy */ @Override public void undeploy(Deployable deployable) { if (deployable.getType() != DeployableType.WAR) { super.undeploy(deployable); return; } WAR war = (WAR) deployable; String fileName = getFileHandler().append(getDeployableDir(deployable), war.getContext() + ".war"); if (getFileHandler().exists(fileName)) { getLogger().info("Undeploying [" + fileName + "]...", this.getClass().getName()); getFileHandler().delete(fileName); } }
super.doDeploy(deployableDir, deployable);
/** * Replace the slashes with <code>#</code> in the deployable name (see: CARGO-1041). * {@inheritDoc} */ @Override protected String getDeployableName(Deployable deployable) { return super.getDeployableName(deployable).replace('/', '#'); } }
/** * {@inheritDoc} */ @Override public void deploy(Deployable deployable) { // If necessary, warn the user about this deployer's limitations warn(); super.deploy(deployable); }
/** * Removes previously deployed artifact. * * @param deployable artifact to undeploy */ @Override public void undeploy(Deployable deployable) { if (deployable.getType() == DeployableType.WAR) { WAR war = (WAR) deployable; undeployFile(getDeployableDir(deployable), war.getContext() + ".war"); } else if (deployable.getType() == DeployableType.EAR) { EAR ear = (EAR) deployable; undeployFile(getDeployableDir(deployable), ear.getName() + ".ear"); } else if (deployable.getType() == DeployableType.FILE || deployable.getType() == DeployableType.SAR) { String fileName = getFileHandler().getName(deployable.getFile()); undeployFile(getDeployableDir(deployable), fileName); } else { super.undeploy(deployable); return; } }
/** * {@inheritDoc}. We override the base implementation because JOnAS 4.x handles hot deployment * differently than just copying files over. */ @Override protected void doDeploy(String deployableDir, Deployable deployable) { String jonasDeployableDir = deployableDir; boolean isRunning = admin.isServerRunning("ping", 0); if (!isRunning) { jonasDeployableDir = getFileHandler().append(jonasDeployableDir, "autoload"); } super.doDeploy(jonasDeployableDir, deployable); if (isRunning) { // hot deployment through JOnAS admin String deployableName = getDeployableName(deployable); boolean deployed = admin.deploy(deployableName); if (!deployed) { throw new CargoException("Unable to deploy file " + deployableName + " through JOnAS admin"); } } }
/** * {@inheritDoc}. We override the base implementation because WebLogic requires that expanded * WAR directories to end with <code>.war</code> so we have to rename the expanded WAR * directory. See <a href="http://e-docs.bea.com/wls/docs81/deployment/overview.html#1036349"> * the WebLogic documentation for Exploded Archive Directories</a>. */ @Override protected String getDeployableName(Deployable deployable) { String deployableName = super.getDeployableName(deployable); if (DeployableType.WAR.equals(deployable.getType()) && deployable.isExpanded()) { deployableName += ".war"; } return deployableName; }
deployer.deploy(getDeployables());
/** * Removes previously deployed artifact. * * @param deployable artifact to undeploy */ @Override public void undeploy(Deployable deployable) { if (deployable.getType() == DeployableType.WAR) { WAR war = (WAR) deployable; undeployFile(getDeployableDir(deployable), war.getContext() + ".war"); } else if (deployable.getType() == DeployableType.EAR) { EAR ear = (EAR) deployable; undeployFile(getDeployableDir(deployable), ear.getName() + ".ear"); } else if (deployable.getType() == DeployableType.FILE || deployable.getType() == DeployableType.SAR) { String fileName = getFileHandler().getName(deployable.getFile()); undeployFile(getDeployableDir(deployable), fileName); } else { super.undeploy(deployable); return; } }
/** * {@inheritDoc}. We override the base implementation because JOnAS 4.x handles hot deployment * differently than just copying files over. */ @Override protected void doDeploy(String deployableDir, Deployable deployable) { String jonasDeployableDir = deployableDir; boolean isRunning = admin.isServerRunning("ping", 0); if (!isRunning) { jonasDeployableDir = getFileHandler().append(jonasDeployableDir, "autoload"); } super.doDeploy(jonasDeployableDir, deployable); if (isRunning) { // hot deployment through JOnAS admin String deployableName = getDeployableName(deployable); boolean deployed = admin.deploy(deployableName); if (!deployed) { throw new CargoException("Unable to deploy file " + deployableName + " through JOnAS admin"); } } }
/** * {@inheritDoc}. We override the base implementation because WebLogic requires that expanded * WAR directories to end with <code>.war</code> so we have to rename the expanded WAR * directory. See <a href="http://e-docs.bea.com/wls/docs81/deployment/overview.html#1036349"> * the WebLogic documentation for Exploded Archive Directories</a>. */ @Override protected String getDeployableName(Deployable deployable) { String deployableName = super.getDeployableName(deployable); if (DeployableType.WAR.equals(deployable.getType()) && deployable.isExpanded()) { deployableName += ".war"; } return deployableName; }
deployer.deploy(getDeployables());