1 23 package org.objectweb.joram.client.connector; 24 25 import org.objectweb.joram.client.jms.ConnectionMetaData; 26 import org.objectweb.joram.client.jms.Destination; 27 import org.objectweb.joram.client.jms.Queue; 28 import org.objectweb.joram.client.jms.Topic; 29 import org.objectweb.joram.client.jms.admin.AdminModule; 30 import org.objectweb.joram.client.jms.admin.User; 31 32 import java.util.Iterator ; 33 import java.util.List ; 34 import java.util.Vector ; 35 36 37 41 public class LocalServer implements LocalServerMBean 42 { 43 44 private JoramAdapter adapter; 45 46 private String objectName; 47 private boolean eventProvider = false; 48 private boolean stateManageable = false; 49 private boolean statisticsProvider = false; 50 51 52 public LocalServer(JoramAdapter adapter) { 53 this.adapter = adapter; 54 } 55 56 public void setObjectName(String objectName) { 57 this.objectName = objectName; 58 } 59 60 public void setStateManageable(boolean stateManageable) { 61 this.stateManageable = stateManageable; 62 } 63 64 public void setStatisticsProvider(boolean statisticsProvider) { 65 this.statisticsProvider = statisticsProvider; 66 } 67 68 public void setEventProvider(boolean eventProvider) { 69 this.eventProvider = eventProvider; 70 } 71 72 public String getobjectName() { 73 return objectName; 74 } 75 76 public boolean iseventProvider() { 77 return eventProvider; 78 } 79 80 public boolean isstateManageable() { 81 return stateManageable; 82 } 83 84 public boolean isstatisticsProvider() { 85 return statisticsProvider; 86 } 87 88 public String getPlatformConfiguration() 89 { 90 if (adapter.platformServersIds != null 91 && adapter.platformServersIds.size() > 1) 92 return "Distributed"; 93 else 94 return "Centralized"; 95 } 96 97 public List getPlatformServersIds() 98 { 99 return adapter.platformServersIds; 100 } 101 102 public String getLocalServerId() 103 { 104 return "" + adapter.serverId; 105 } 106 107 public String getRelease() 108 { 109 return ConnectionMetaData.providerVersion; 110 } 111 112 public String getRunningMode() 113 { 114 if (adapter.getCollocatedServer().booleanValue()) 115 return "Collocated"; 116 return "Remote"; 117 } 118 119 public String getHost() 120 { 121 return adapter.hostName; 122 } 123 124 public String getPort() 125 { 126 return "" + adapter.serverPort; 127 } 128 129 public List getLocalQueuesNames() 130 { 131 try { 132 List list = AdminModule.getDestinations(); 133 Iterator it = list.iterator(); 134 Destination dest; 135 Vector names = new Vector (); 136 while (it.hasNext()) { 137 dest = (Destination) it.next(); 138 if (dest instanceof Queue) 139 names.add(dest.getAdminName()); 140 } 141 return names; 142 } 143 catch (Exception exc) { 144 return new Vector (); 145 } 146 } 147 148 public List getLocalTopicsNames() 149 { 150 try { 151 List list = AdminModule.getDestinations(); 152 Iterator it = list.iterator(); 153 Destination dest; 154 Vector names = new Vector (); 155 while (it.hasNext()) { 156 dest = (Destination) it.next(); 157 if (dest instanceof Topic) 158 names.add(dest.getAdminName()); 159 } 160 return names; 161 } 162 catch (Exception exc) { 163 return new Vector (); 164 } 165 } 166 167 public List getLocalUsersNames() 168 { 169 try { 170 List list = AdminModule.getUsers(); 171 Iterator it = list.iterator(); 172 User user; 173 Vector names = new Vector (); 174 while (it.hasNext()) { 175 user = (User) it.next(); 176 names.add(user.getName()); 177 } 178 return names; 179 } 180 catch (Exception exc) { 181 return new Vector (); 182 } 183 } 184 185 186 public void createLocalQueue(String jndiName) throws Exception 187 { 188 JoramAdapter.createQueue(jndiName); 189 } 190 191 public void createLocalTopic(String jndiName) throws Exception 192 { 193 JoramAdapter.createTopic(jndiName); 194 } 195 } 196 | Popular Tags |