1 22 package org.jboss.test.jmx.deployer; 23 24 import java.io.File ; 25 import java.net.URL ; 26 import javax.management.ObjectName ; 27 import org.jboss.deployment.DeploymentException; 28 import org.jboss.deployment.DeploymentInfo; 29 import org.jboss.system.ServiceMBeanSupport; 30 31 52 public class BrokenDeployer 53 extends ServiceMBeanSupport 54 implements BrokenDeployerMBean 55 { 56 public BrokenDeployer () 57 { 58 } 59 60 public String getName() 61 { 62 return "Broken Deployer"; 63 } 64 65 protected void startService() throws Exception 66 { 67 try 68 { 69 server.invoke( 71 org.jboss.deployment.MainDeployerMBean.OBJECT_NAME, 72 "addDeployer", 73 new Object [] {this}, 74 new String [] {"org.jboss.deployment.DeployerMBean"}); 75 } 76 catch (Exception e) {log.error("Could not register with MainDeployer", e);} 77 78 log.info("BrokenDeployer started"); 79 } 80 81 82 83 84 85 protected void stopService() 86 { 87 log.info("BrokenDeployer stopped"); 88 89 try 90 { 91 server.invoke( 93 org.jboss.deployment.MainDeployerMBean.OBJECT_NAME, 94 "removeDeployer", 95 new Object [] {this}, 96 new String [] {"org.jboss.deployment.DeployerMBean"}); 97 } 98 catch (Exception e) {log.error("Could not register with MainDeployer", e);} 99 100 } 101 102 public boolean accepts(DeploymentInfo sdi) 103 { 104 log.info("asking about file: " + sdi.url.toString()); 105 String file = new File (sdi.url.getFile()).toString(); 106 107 log.info("now asking about file: " + file); 108 return file.endsWith("xaa") 109 || file.endsWith("xbb") 110 || file.endsWith("xcc") 111 || file.endsWith("xdd") 112 || file.endsWith("xee") 113 || file.endsWith("xff") 114 || file.endsWith("xgg"); 115 } 116 117 public void init(DeploymentInfo sdi) 118 throws DeploymentException 119 { 120 String file = new File (sdi.url.getFile()).toString(); 121 if (file.endsWith("xaa")) 122 { 123 throw new DeploymentException("DeploymentException in init"); 124 } if (file.endsWith("xbb")) 126 { 127 throw new NullPointerException ("NullPointerException in init"); 128 } if (file.endsWith("xgg")) 130 { 131 try 132 { 133 sdi.watch = new URL ("File:/nowhere.jar"); 134 } 135 catch (Exception e) 136 { 137 log.error("could not create fake url"); 138 } 140 } 142 143 } 144 145 public void deploy(DeploymentInfo sdi) 146 throws DeploymentException 147 { 148 String file = new File (sdi.url.getFile()).toString(); 149 if (file.endsWith("xcc")) 150 { 151 throw new DeploymentException("DeploymentException in deploy"); 152 } if (file.endsWith("xdd")) 154 { 155 throw new NullPointerException ("NullPointerException in deploy"); 156 } } 158 159 public void undeploy(DeploymentInfo sdi) 160 throws DeploymentException 161 { 162 String file = new File (sdi.url.getFile()).toString(); 163 if (file.endsWith("xee")) 164 { 165 throw new DeploymentException("DeploymentException in undeploy"); 166 } if (file.endsWith("xff")) 168 { 169 throw new NullPointerException ("NullPointerException in undeploy"); 170 } } 172 } | Popular Tags |