001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.deployment.plugin.jmx; 018 019 import java.util.ArrayList; 020 import java.util.Collection; 021 import java.util.Set; 022 023 import org.apache.commons.logging.Log; 024 import org.apache.commons.logging.LogFactory; 025 import org.apache.geronimo.deployment.ModuleConfigurer; 026 import org.apache.geronimo.gbean.AbstractName; 027 import org.apache.geronimo.gbean.AbstractNameQuery; 028 import org.apache.geronimo.kernel.GBeanNotFoundException; 029 import org.apache.geronimo.kernel.Kernel; 030 031 /** 032 * Connects to a kernel in the same VM. 033 * 034 * @version $Rev: 508724 $ $Date: 2007-02-17 03:01:26 -0500 (Sat, 17 Feb 2007) $ 035 */ 036 public class LocalDeploymentManager extends JMXDeploymentManager { 037 private static final Log log = LogFactory.getLog(LocalDeploymentManager.class); 038 private static final AbstractNameQuery CONFIGURER_QUERY = new AbstractNameQuery(ModuleConfigurer.class.getName()); 039 040 public LocalDeploymentManager(Kernel kernel) { 041 super(loadModuleConfigurers(kernel)); 042 initialize(kernel); 043 } 044 045 private static Collection<ModuleConfigurer> loadModuleConfigurers(Kernel kernel) { 046 Collection<ModuleConfigurer> moduleConfigurers = new ArrayList<ModuleConfigurer>(); 047 Set configurerNames = kernel.listGBeans(CONFIGURER_QUERY); 048 for (Object configurerName : configurerNames) { 049 AbstractName name = (AbstractName) configurerName; 050 try { 051 ModuleConfigurer configurer = (ModuleConfigurer) kernel.getGBean(name); 052 moduleConfigurers.add(configurer); 053 } catch (GBeanNotFoundException e) { 054 log.warn("No gbean found for name returned in query : " + name); 055 } 056 } 057 return moduleConfigurers; 058 } 059 060 }