1 9 package org.jboss.portal.server.deployment.jboss; 10 11 import org.jboss.deployment.DeploymentException; 12 import org.jboss.deployment.MainDeployerMBean; 13 import org.jboss.portal.server.util.Service; 14 15 import java.net.URL ; 16 17 31 public class MainDeployerFacade extends Service 32 { 33 34 35 private static final ThreadLocal local = new ThreadLocal (); 36 37 public static void log(DeploymentException e) 38 { 39 Session session = (Session)local.get(); 41 if (session != null && session.e == null) 42 { 43 session.e = e; 44 } 45 } 46 47 48 private MainDeployerMBean mainDeployer; 49 50 53 public MainDeployerMBean getMainDeployer() 54 { 55 return mainDeployer; 56 } 57 58 61 public void setMainDeployer(MainDeployerMBean mainDeployer) 62 { 63 this.mainDeployer = mainDeployer; 64 } 65 66 72 public void deploy(URL url) throws DeploymentException 73 { 74 perform(url, true); 75 } 76 77 83 public void undeploy(URL url) throws DeploymentException 84 { 85 perform(url, false); 86 } 87 88 private void perform(URL url, boolean deploy) throws DeploymentException 89 { 90 try 91 { 92 Session session = new Session(); 93 local.set(session); 94 95 if (deploy) 97 { 98 mainDeployer.deploy(url); 99 } 100 else 101 { 102 mainDeployer.undeploy(url); 103 } 104 105 if (session.e != null) 108 { 109 throw session.e; 110 } 111 } 112 finally 113 { 114 local.set(null); 115 } 116 } 117 118 121 private static class Session 122 { 123 private DeploymentException e; 124 } 125 } 126 | Popular Tags |