1 22 package org.jboss.naming; 23 24 import javax.naming.InitialContext ; 25 26 import org.jboss.deployment.DeploymentException; 27 import org.jboss.system.ServiceMBeanSupport; 28 29 35 public class LinkRefPairService extends ServiceMBeanSupport 36 implements LinkRefPairServiceMBean 37 { 38 40 42 43 private String jndiName; 44 45 46 private String remoteJndiName; 47 48 49 private String localJndiName; 50 51 53 55 57 59 public String getJndiName() 60 { 61 return jndiName; 62 } 63 64 public String getLocalJndiName() 65 { 66 return localJndiName; 67 } 68 69 public String getRemoteJndiName() 70 { 71 return remoteJndiName; 72 } 73 74 public void setJndiName(String jndiName) 75 { 76 this.jndiName = jndiName; 77 } 78 79 public void setLocalJndiName(String jndiName) 80 { 81 this.localJndiName = jndiName; 82 } 83 84 public void setRemoteJndiName(String jndiName) 85 { 86 this.remoteJndiName = jndiName; 87 } 88 89 91 protected void startService() throws Exception 92 { 93 if (jndiName == null) 94 throw new DeploymentException("The jndiName is null for LinkRefPair " + getServiceName()); 95 if (remoteJndiName == null) 96 throw new DeploymentException("The remoteJndiName is null for LinkRefPair " + getServiceName()); 97 if (localJndiName == null) 98 throw new DeploymentException("The localJndiName is null for LinkRefPair " + getServiceName()); 99 100 LinkRefPair pair = new LinkRefPair(remoteJndiName, localJndiName); 101 InitialContext ctx = new InitialContext (); 102 try 103 { 104 Util.bind(ctx, jndiName, pair); 105 } 106 finally 107 { 108 ctx.close(); 109 } 110 } 111 112 protected void stopService() throws Exception 113 { 114 LinkRefPair pair = new LinkRefPair(remoteJndiName, localJndiName); 115 InitialContext ctx = new InitialContext (); 116 try 117 { 118 Util.unbind(ctx, jndiName); 119 } 120 finally 121 { 122 ctx.close(); 123 } 124 } 125 126 128 130 132 } 134 | Popular Tags |