1 17 18 package org.apache.geronimo.console.jmsmanager.handlers; 19 20 import java.io.IOException ; 21 import java.net.URI ; 22 import java.util.Iterator ; 23 import java.util.List ; 24 25 import javax.management.ObjectName ; 26 import javax.portlet.ActionRequest; 27 import javax.portlet.ActionResponse; 28 import javax.portlet.PortletException; 29 30 import org.apache.commons.logging.Log; 31 import org.apache.commons.logging.LogFactory; 32 import org.apache.geronimo.console.jmsmanager.AbstractJMSManager; 33 import org.apache.geronimo.gbean.GBeanData; 34 import org.apache.geronimo.gbean.AbstractName; 35 import org.apache.geronimo.kernel.DependencyManager; 36 import org.apache.geronimo.kernel.repository.Artifact; 37 import org.apache.geronimo.kernel.config.Configuration; 38 import org.apache.geronimo.kernel.config.ConfigurationManager; 39 import org.apache.geronimo.kernel.config.ConfigurationUtil; 40 41 public class RemoveDestinationHandler extends AbstractJMSManager implements 42 PortletResponseHandler { 43 44 protected static Log log = LogFactory 45 .getLog(RemoveDestinationHandler.class); 46 47 public void processAction(ActionRequest request, ActionResponse response) 48 throws IOException , PortletException { 49 String destinationConfigURIName = request 50 .getParameter(DESTINATION_CONFIG_URI); 51 try { 52 ConfigurationManager configurationManager = ConfigurationUtil 53 .getConfigurationManager(kernel); 54 Artifact destinationConfigArtifact = Artifact.create(destinationConfigURIName); 55 AbstractName configurationObjectName = Configuration.getConfigurationAbstractName(destinationConfigArtifact); 56 57 List stores = configurationManager.listStores(); 58 assert stores.size() == 1 :"Piling one hack on another, this code only works with exactly one store"; 59 ObjectName storeName = (ObjectName ) stores.iterator().next(); 60 61 DependencyManager dm = kernel.getDependencyManager(); 63 GBeanData topicBrowser = kernel.getGBeanData(configurationObjectName); 67 java.util.Set children = dm.getChildren(topicBrowser.getAbstractName()); 68 for (Iterator i = children.iterator(); i.hasNext();) { 69 ObjectName o = (ObjectName ) i.next(); 70 if ("TopicBrowser".equals(o.getKeyProperty("j2eeType"))) { 71 kernel.invoke(o, "unsubscribe"); 72 break; 73 } 74 } 75 76 kernel.stopGBean(configurationObjectName); 79 kernel.invoke(storeName, "uninstall", 80 new Object [] {destinationConfigArtifact}, 81 new String [] {URI .class.getName()}); 82 } catch (Exception e) { 83 log.error("problem removing destination: " 84 + destinationConfigURIName, e); 85 } 86 } 87 88 } 89 | Popular Tags |