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.console.util;
018    
019    import java.util.Map;
020    import javax.security.auth.Subject;
021    import javax.security.auth.login.LoginException;
022    import javax.security.auth.spi.LoginModule;
023    
024    import org.apache.geronimo.gbean.AbstractName;
025    import org.apache.geronimo.gbean.GBeanData;
026    import org.apache.geronimo.kernel.Naming;
027    import org.apache.geronimo.kernel.config.ConfigurationModuleType;
028    import org.apache.geronimo.kernel.repository.Artifact;
029    import org.apache.geronimo.management.AppClientModule;
030    import org.apache.geronimo.management.EJB;
031    import org.apache.geronimo.management.EJBModule;
032    import org.apache.geronimo.management.J2EEDeployedObject;
033    import org.apache.geronimo.management.J2EEModule;
034    import org.apache.geronimo.management.JDBCDataSource;
035    import org.apache.geronimo.management.JDBCDriver;
036    import org.apache.geronimo.management.JDBCResource;
037    import org.apache.geronimo.management.JMSResource;
038    import org.apache.geronimo.management.Servlet;
039    import org.apache.geronimo.management.geronimo.J2EEApplication;
040    import org.apache.geronimo.management.geronimo.J2EEDomain;
041    import org.apache.geronimo.management.geronimo.J2EEServer;
042    import org.apache.geronimo.management.geronimo.JCAAdminObject;
043    import org.apache.geronimo.management.geronimo.JCAConnectionFactory;
044    import org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory;
045    import org.apache.geronimo.management.geronimo.JCAResource;
046    import org.apache.geronimo.management.geronimo.JVM;
047    import org.apache.geronimo.management.geronimo.ResourceAdapter;
048    import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
049    import org.apache.geronimo.management.geronimo.WebModule;
050    import org.apache.geronimo.system.logging.SystemLog;
051    
052    /**
053     * A helper interface to navigate between management objects.  This is not
054     * complete; it will be expanded as necessary.
055     *
056     * @version $Rev: 476229 $ $Date: 2006-11-17 12:48:02 -0500 (Fri, 17 Nov 2006) $
057     */
058    public interface ManagementHelper {
059        // root properties
060        J2EEDomain[] getDomains();
061    
062        // server properties
063        J2EEApplication[] getApplications(J2EEServer server);
064        AppClientModule[] getAppClients(J2EEServer server);
065        WebModule[] getWebModules(J2EEServer server);
066        EJBModule[] getEJBModules(J2EEServer server);
067        ResourceAdapterModule[] getRAModules(J2EEServer server);
068        ResourceAdapterModule[] getOutboundRAModules(J2EEServer server, String connectionFactoryInterface);
069        ResourceAdapterModule[] getOutboundRAModules(J2EEServer server, String[] connectionFactoryInterfaces);
070        ResourceAdapterModule[] getAdminObjectModules(J2EEServer server, String[] adminObjectInterfaces);
071        JCAManagedConnectionFactory[] getOutboundFactories(J2EEServer server, String connectionFactoryInterface);
072        JCAResource[] getJCAResources(J2EEServer server);
073        JDBCResource[] getJDBCResources(J2EEServer server);
074        JMSResource[] getJMSResources(J2EEServer server);
075        JVM[] getJavaVMs(J2EEServer server);
076    
077        // JVM properties
078        SystemLog getSystemLog(JVM jvm);
079    
080        // application properties
081        J2EEModule[] getModules(J2EEApplication application);
082        AppClientModule[] getAppClients(J2EEApplication application);
083        WebModule[] getWebModules(J2EEApplication application);
084        EJBModule[] getEJBModules(J2EEApplication application);
085        ResourceAdapterModule[] getRAModules(J2EEApplication application);
086        JCAResource[] getJCAResources(J2EEApplication application);
087        JDBCResource[] getJDBCResources(J2EEApplication application);
088        JMSResource[] getJMSResources(J2EEApplication application);
089    
090        // module properties
091        EJB[] getEJBs(EJBModule module);
092        Servlet[] getServlets(WebModule module);
093        ResourceAdapter[] getResourceAdapters(ResourceAdapterModule module);
094        JCAManagedConnectionFactory[] getOutboundFactories(ResourceAdapterModule module);
095        JCAManagedConnectionFactory[] getOutboundFactories(ResourceAdapterModule module, String connectionFactoryInterface);
096        JCAManagedConnectionFactory[] getOutboundFactories(ResourceAdapterModule module, String[] connectionFactoryInterfaces);
097        //todo: create an interface for admin objects
098        JCAAdminObject[] getAdminObjects(ResourceAdapterModule module, String[] adminObjectInterfaces);
099    
100        // resource adapter properties
101        JCAResource[] getRAResources(ResourceAdapter adapter);
102    
103        // resource properties
104        JDBCDataSource[] getDataSource(JDBCResource resource);
105        JDBCDriver[] getDriver(JDBCDataSource dataSource);
106        JCAConnectionFactory[] getConnectionFactories(JCAResource resource);
107        JCAManagedConnectionFactory getManagedConnectionFactory(JCAConnectionFactory factory);
108    
109        // Generic utility methods
110        Object getObject(AbstractName abstractName);
111        Artifact getConfigurationNameFor(AbstractName abstractName);
112        String getGBeanDescription(AbstractName abstractName);
113    
114        // Misc
115        void testLoginModule(J2EEServer server, LoginModule module, Map options);
116        Subject testLoginModule(J2EEServer server, LoginModule module, Map options, String username, String password) throws LoginException;
117        Object[] findByInterface(Class iface);
118        AbstractName getNameFor(Object component);
119        ConfigurationData[] getConfigurations(ConfigurationModuleType type, boolean includeChildModules);
120        /**
121         * Gets a JSR-77 Module (WebModule, EJBModule, etc.) for the specified configuration.
122         * Note: this only works if the configuration is running at the time you ask.
123         *
124         * @return The Module, or null if the configuration is not running.
125         */
126        J2EEDeployedObject getModuleForConfiguration(Artifact configuration);
127    
128        /**
129         * Adds a new GBean to an existing Configuration.
130         * @param configID  The configuration to add the GBean to.
131         * @param gbean     The data representing the GBean to add.
132         * @param start     If true, the GBean should be started as part of this call.
133         */
134        public void addGBeanToConfiguration(Artifact configID, GBeanData gbean, boolean start);
135    
136        /**
137         * This method returns the Naming object of the kernel.
138         */
139        public Naming getNaming();
140    
141        Object[] getGBeansImplementing(Class iface);
142    }