1 22 package org.objectweb.petals.kernel.registry.jndi.mock; 23 24 import javax.naming.Binding ; 25 import javax.naming.NameClassPair ; 26 27 import org.objectweb.petals.kernel.registry.jndi.JNDIConnection; 28 import org.objectweb.petals.kernel.registry.msg.request.RegistryRequest; 29 import org.objectweb.petals.kernel.registry.msg.request.RegistryRequest.RequestType; 30 31 36 public class MockJNDIConnection extends JNDIConnection { 37 38 public MockJNDIConnection(int port, String host) { 39 super(port, host); 40 } 41 42 45 private static final long serialVersionUID = 1L; 46 47 protected boolean isBind; 48 49 protected boolean isCreateSubcontext; 50 51 protected boolean isDestroySubcontext; 52 53 protected boolean isList; 54 55 protected boolean isListBindings; 56 57 protected boolean isLookup; 58 59 protected boolean isLookupLink; 60 61 protected boolean isRebind; 62 63 protected boolean isRename; 64 65 protected boolean isUnbind; 66 67 public boolean isUnbind() { 68 return isUnbind; 69 } 70 71 public void setUnbind(boolean isUnbind) { 72 this.isUnbind = isUnbind; 73 } 74 75 public boolean isDestroySubcontext() { 76 return isDestroySubcontext; 77 } 78 79 public void setDestroySubcontext(boolean isDestroySubcontext) { 80 this.isDestroySubcontext = isDestroySubcontext; 81 } 82 83 public Object send(RegistryRequest registryRequest) { 84 Object out = null; 85 if (registryRequest.getType().equals(RequestType.bind)) { 86 isBind = true; 87 } else if (registryRequest.getType().equals( 88 RequestType.createSubcontext)) { 89 isCreateSubcontext = true; 90 } else if (registryRequest.getType().equals( 91 RequestType.destroySubcontext)) { 92 isDestroySubcontext = true; 93 } else if (registryRequest.getType().equals(RequestType.list)) { 94 isList = true; 95 out = new NameClassPair [0]; 96 } else if (registryRequest.getType().equals(RequestType.listBindings)) { 97 isListBindings = true; 98 out = new Binding [0]; 99 } else if (registryRequest.getType().equals(RequestType.lookup)) { 100 isLookup = true; 101 } else if (registryRequest.getType().equals(RequestType.lookupLink)) { 102 isLookupLink = true; 103 } else if (registryRequest.getType().equals(RequestType.rebind)) { 104 isRebind = true; 105 } else if (registryRequest.getType().equals(RequestType.rename)) { 106 isRename = true; 107 } else if (registryRequest.getType().equals(RequestType.unbind)) { 108 isUnbind = true; 109 } 110 return out; 111 } 112 113 public boolean isBind() { 114 return isBind; 115 } 116 117 public void setBind(boolean isBind) { 118 this.isBind = isBind; 119 } 120 121 public boolean isCreateSubcontext() { 122 return isCreateSubcontext; 123 } 124 125 public void setCreateSubcontext(boolean isCreateSubcontext) { 126 this.isCreateSubcontext = isCreateSubcontext; 127 } 128 129 public boolean isList() { 130 return isList; 131 } 132 133 public void setList(boolean isList) { 134 this.isList = isList; 135 } 136 137 public boolean isListBindings() { 138 return isListBindings; 139 } 140 141 public void setListBindings(boolean isListBindings) { 142 this.isListBindings = isListBindings; 143 } 144 145 public boolean isLookup() { 146 return isLookup; 147 } 148 149 public void setLookup(boolean isLookup) { 150 this.isLookup = isLookup; 151 } 152 153 public boolean isLookupLink() { 154 return isLookupLink; 155 } 156 157 public void setLookupLink(boolean isLookupLink) { 158 this.isLookupLink = isLookupLink; 159 } 160 161 public boolean isRebind() { 162 return isRebind; 163 } 164 165 public void setRebind(boolean isRebind) { 166 this.isRebind = isRebind; 167 } 168 169 public boolean isRename() { 170 return isRename; 171 } 172 173 public void setRename(boolean isRename) { 174 this.isRename = isRename; 175 } 176 177 } 178 | Popular Tags |