Home » geronimo-2.2-source-release » org.apache.geronimo.console.jmsmanager » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements.  See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership.  The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License.  You may obtain a copy of the License at
    9    *
   10    *  http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing,
   13    * software distributed under the License is distributed on an
   14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    * KIND, either express or implied.  See the License for the
   16    * specific language governing permissions and limitations
   17    * under the License.
   18    */
   19   
   20   
   21   package org.apache.geronimo.console.jmsmanager;
   22   
   23   import javax.enterprise.deploy.spi.DeploymentManager;
   24   import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
   25   import javax.enterprise.deploy.spi.factories.DeploymentFactory;
   26   import javax.portlet.PortletRequest;
   27   import javax.portlet.PortletSession;
   28   
   29   import org.apache.geronimo.console.util.PortletManager;
   30   import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryWithKernel;
   31   import org.apache.geronimo.kernel.Kernel;
   32   
   33   /**
   34    * @version $Rev: 701669 $ $Date: 2008-10-04 10:01:40 -0700 (Sat, 04 Oct 2008) $
   35    */
   36   public class ManagementHelper {
   37       private final static String PLUGIN_HELPER_KEY = "org.apache.geronimo.console.activemq.ManagementHelper";
   38       private final Kernel kernel;
   39   
   40       public static ManagementHelper getManagementHelper(PortletRequest request) {
   41           ManagementHelper helper = (ManagementHelper) request.getPortletSession(true).getAttribute(PLUGIN_HELPER_KEY, PortletSession.APPLICATION_SCOPE);
   42           if (helper == null) {
   43               Kernel kernel = PortletManager.getKernel();
   44               helper = new ManagementHelper(kernel);
   45               request.getPortletSession().setAttribute(PLUGIN_HELPER_KEY, helper, PortletSession.APPLICATION_SCOPE);
   46           }
   47           return helper;
   48       }
   49   
   50       public ManagementHelper(Kernel kernel) {
   51           this.kernel = kernel;
   52       }
   53   
   54       public DeploymentManager getDeploymentManager() {
   55           DeploymentFactory factory = new DeploymentFactoryWithKernel(kernel);
   56           try {
   57               return factory.getDeploymentManager("deployer:geronimo:inVM", null, null);
   58           } catch (DeploymentManagerCreationException e) {
   59               //            log.error(e.getMessage(), e);
   60               return null;
   61           }
   62       }
   63   }
   64   

Home » geronimo-2.2-source-release » org.apache.geronimo.console.jmsmanager » [javadoc | source]