01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
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: package org.apache.geronimo.console.jmsmanager;
21:
22: import javax.enterprise.deploy.spi.DeploymentManager;
23: import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
24: import javax.enterprise.deploy.spi.factories.DeploymentFactory;
25: import javax.portlet.PortletRequest;
26: import javax.portlet.PortletSession;
27:
28: import org.apache.geronimo.console.util.PortletManager;
29: import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryWithKernel;
30: import org.apache.geronimo.kernel.Kernel;
31:
32: /**
33: * @version $Rev: 611338 $ $Date: 2008-01-11 16:42:22 -0800 (Fri, 11 Jan 2008) $
34: */
35: public class ManagementHelper {
36: private final static String PLUGIN_HELPER_KEY = "org.apache.geronimo.console.activemq.ManagementHelper";
37: private final Kernel kernel;
38:
39: public static ManagementHelper getManagementHelper(
40: PortletRequest request) {
41: ManagementHelper helper = (ManagementHelper) request
42: .getPortletSession(true).getAttribute(
43: PLUGIN_HELPER_KEY,
44: PortletSession.APPLICATION_SCOPE);
45: if (helper == null) {
46: Kernel kernel = PortletManager.getKernel();
47: helper = new ManagementHelper(kernel);
48: request.getPortletSession().setAttribute(PLUGIN_HELPER_KEY,
49: helper, PortletSession.APPLICATION_SCOPE);
50: }
51: return helper;
52: }
53:
54: public ManagementHelper(Kernel kernel) {
55: this .kernel = kernel;
56: }
57:
58: public DeploymentManager getDeploymentManager() {
59: DeploymentFactory factory = new DeploymentFactoryWithKernel(
60: kernel);
61: try {
62: return factory.getDeploymentManager(
63: "deployer:geronimo:inVM", null, null);
64: } catch (DeploymentManagerCreationException e) {
65: // log.error(e.getMessage(), e);
66: return null;
67: }
68: }
69: }
|