1 17 18 package org.apache.geronimo.console.jmsmanager.renderers; 19 20 import java.io.IOException ; 21 import java.util.ArrayList ; 22 import java.util.Collections ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 import java.util.Set ; 26 27 import javax.management.ObjectName ; 28 import javax.portlet.PortletException; 29 import javax.portlet.RenderRequest; 30 import javax.portlet.RenderResponse; 31 import javax.jms.Destination ; 32 33 import org.apache.commons.logging.Log; 34 import org.apache.commons.logging.LogFactory; 35 import org.apache.geronimo.console.jmsmanager.AbstractJMSManager; 36 import org.apache.geronimo.console.jmsmanager.DestinationInfo; 37 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 38 import org.apache.geronimo.kernel.DependencyManager; 39 import org.apache.geronimo.kernel.Kernel; 40 import org.apache.geronimo.kernel.KernelRegistry; 41 import org.apache.geronimo.gbean.AbstractNameQuery; 42 import org.apache.geronimo.gbean.AbstractName; 43 44 public class ViewDestinationsRenderer extends AbstractJMSManager implements 45 PortletRenderer { 46 47 protected static Log log = LogFactory 48 .getLog(ViewDestinationsRenderer.class); 49 50 public String render(RenderRequest request, RenderResponse response) 51 throws PortletException, IOException { 52 53 List destinationList = getDestinationList(request, response); 54 55 request.setAttribute(DESTINATION_LIST, destinationList); 56 57 return "/WEB-INF/view/jmsmanager/view.jsp"; 58 } 59 60 public List getDestinationList(RenderRequest request, 61 RenderResponse response) { 62 Kernel kernel = KernelRegistry.getSingleKernel(); 63 64 Set destinations = kernel.listGBeans(new AbstractNameQuery(Destination .class.getName())); 65 List destinationInfos = new ArrayList (destinations.size()); 66 DependencyManager dm = kernel.getDependencyManager(); 67 for (Iterator iterator = destinations.iterator(); iterator.hasNext();) { 68 AbstractName destinationName = (AbstractName) iterator.next(); 69 70 try { 71 Class type; 72 try { 73 type = Class.forName((String ) kernel.getAttribute( 74 destinationName, "adminObjectInterface")); 75 } catch (ClassCastException cce) { 76 type = (Class ) kernel.getAttribute(destinationName, 77 "adminObjectInterface"); 78 } 79 Set parents = dm.getParents(destinationName); 80 Iterator i = parents.iterator(); 81 if (!i.hasNext()) { 84 continue; 85 } 86 ObjectName parent = (ObjectName ) i.next(); 87 String adminObjectName = (String ) destinationName.getName().get(NameFactory.J2EE_NAME); 88 if (adminObjectName.equals("MDBTransferBeanOutQueue") 89 || adminObjectName.equals("SendReceiveQueue")) { 90 continue; 91 } 92 String configURI = parent.getKeyProperty("name"); 93 if (configURI.startsWith("\"")) { 94 configURI = configURI.substring(1); 95 } 96 if (configURI.endsWith("\"")) { 97 configURI = configURI.substring(0, configURI.length() - 1); 98 } 99 100 DestinationInfo info = new DestinationInfo(adminObjectName, 101 (String ) kernel.getAttribute(destinationName, "PhysicalName"), 102 type, 103 (String ) destinationName.getName().get(NameFactory.J2EE_APPLICATION), 104 (String ) destinationName.getName().get(NameFactory.JCA_RESOURCE), 105 configURI); 106 destinationInfos.add(info); 107 } catch (Exception e) { 108 log.error(e); 109 } 110 } 111 Collections.sort(destinationInfos); 112 return destinationInfos; 113 } 114 115 } 116 | Popular Tags |