01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.deployment.plugin.jmx;
17:
18: import java.util.ArrayList;
19: import java.util.Collection;
20: import java.util.Set;
21:
22: import org.apache.commons.logging.Log;
23: import org.apache.commons.logging.LogFactory;
24: import org.apache.geronimo.deployment.ModuleConfigurer;
25: import org.apache.geronimo.gbean.AbstractName;
26: import org.apache.geronimo.gbean.AbstractNameQuery;
27: import org.apache.geronimo.kernel.GBeanNotFoundException;
28: import org.apache.geronimo.kernel.Kernel;
29:
30: /**
31: * Connects to a kernel in the same VM.
32: *
33: * @version $Rev: 508724 $ $Date: 2007-02-17 00:01:26 -0800 (Sat, 17 Feb 2007) $
34: */
35: public class LocalDeploymentManager extends JMXDeploymentManager {
36: private static final Log log = LogFactory
37: .getLog(LocalDeploymentManager.class);
38: private static final AbstractNameQuery CONFIGURER_QUERY = new AbstractNameQuery(
39: ModuleConfigurer.class.getName());
40:
41: public LocalDeploymentManager(Kernel kernel) {
42: super (loadModuleConfigurers(kernel));
43: initialize(kernel);
44: }
45:
46: private static Collection<ModuleConfigurer> loadModuleConfigurers(
47: Kernel kernel) {
48: Collection<ModuleConfigurer> moduleConfigurers = new ArrayList<ModuleConfigurer>();
49: Set configurerNames = kernel.listGBeans(CONFIGURER_QUERY);
50: for (Object configurerName : configurerNames) {
51: AbstractName name = (AbstractName) configurerName;
52: try {
53: ModuleConfigurer configurer = (ModuleConfigurer) kernel
54: .getGBean(name);
55: moduleConfigurers.add(configurer);
56: } catch (GBeanNotFoundException e) {
57: log.warn("No gbean found for name returned in query : "
58: + name);
59: }
60: }
61: return moduleConfigurers;
62: }
63:
64: }
|