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.kernel.proxy;
018    
019    import org.apache.geronimo.kernel.management.State;
020    
021    /**
022     * Interface provided by proxies generated by the Geronimo proxy managers.
023     * This lets a client call any of these methods on a proxy representing
024     * any Geronimo GBean.  However, this should not be used on any arbitrary
025     * GBean reference, as it might not be a proxy generated by Geronimo (for
026     * example, if you're running the GBean in Spring).
027     *
028     * Note that this includes the content of the JSR-77 StateManageable type,
029     * as well as getObjectName from the JSR-77 J2EEManagedObject type.
030     * However, it is not explicitly related to JSR-77 as that is not required
031     * in order to use the Geronimo kernel.
032     *
033     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
034     */
035    public interface GeronimoManagedBean {
036        /**
037         * Gets the unique name of this object.  The object name must comply with the ObjectName specification
038         * in the JMX specification and the restrictions in the J2EEManagementInterface.
039         *
040         * @return the unique name of this object within the server
041         */
042        String getObjectName();
043    
044        /**
045         * Gets the state of this component as an int.
046         * The int return is required by the JSR77 specification.
047         *
048         * @return the current state of this component
049         * @see #getStateInstance to obtain the State instance
050         */
051        int getState();
052    
053        /**
054         * Gets the state of this component as a State instance.
055         *
056         * @return the current state of this component
057         */
058        State getStateInstance();
059    
060        /**
061         * Gets the start time of this component
062         *
063         * @return time in milliseonds since epoch that this component was started.
064         */
065        long getStartTime();
066    
067    
068        /**
069         * Transitions the component to the starting state.  This method has access to the
070         * container.
071         * <p/>
072         * Normally a component uses this to cache data from other components. The other components will
073         * have been created at this stage, but not necessairly started and may not be ready to have methods
074         * invoked on them.
075         *
076         * @throws Exception if a problem occurs during the transition
077         * @throws IllegalStateException if this interceptor is not in the stopped or failed state
078         */
079        void start() throws Exception, IllegalStateException;
080    
081        /**
082         * Transitions the component to the starting state.  This method has access to the
083         * container.
084         * <p/>
085         * If this Component is a Container, then startRecursive is called on all child Components
086         * that are in the STOPPED or FAILED state.
087         * Normally a component uses this to cache data from other components. The other components will
088         * have been created at this stage, but not necessairly started and may not be ready to have methods
089         * invoked on them.
090         *
091         * @throws Exception if a problem occurs during the transition
092         * @throws IllegalStateException if this interceptor is not in the STOPPED or FAILED state
093         */
094        void startRecursive() throws Exception, IllegalStateException;
095    
096        /**
097         * Transitions the component to the stopping state.  This method has access to the
098         * container.
099         * <p/>
100         * If this is Component is a Container, then all its child components must be in the
101         * STOPPED or FAILED State.
102         * <p/>
103         * Normally a component uses this to drop references to data cached in the start method.
104         * The other components will not necessairly have been stopped at this stage and may not be ready
105         * to have methods invoked on them.
106         *
107         * @throws Exception if a problem occurs during the transition
108         * @throws IllegalStateException if this interceptor is not in the STOPPED or FAILED state
109         */
110        void stop() throws Exception, IllegalStateException;
111    }