001    /**
002     *
003     * Copyright 2006 The Apache Software Foundation
004     *
005     *  Licensed under the Apache License, Version 2.0 (the "License");
006     *  you may not use this file except in compliance with the License.
007     *  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.clustering.wadi;
018    
019    import org.apache.geronimo.gbean.GBeanInfo;
020    import org.apache.geronimo.gbean.GBeanInfoBuilder;
021    import org.apache.geronimo.gbean.GBeanLifecycle;
022    import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
023    import org.codehaus.wadi.replication.manager.ReplicationManager;
024    import org.codehaus.wadi.replication.manager.ReplicationManagerFactory;
025    import org.codehaus.wadi.replication.manager.basic.BasicReplicationManagerFactory;
026    import org.codehaus.wadi.replication.strategy.BackingStrategyFactory;
027    import org.codehaus.wadi.servicespace.ServiceSpace;
028    
029    /**
030     *
031     * @version $Rev$ $Date$
032     */
033    public class BasicReplicationManagerFactoryGBean implements ReplicationManagerFactory, GBeanLifecycle {
034        private ReplicationManagerFactory factory;
035    
036        public ReplicationManager factory(ServiceSpace serviceSpace, BackingStrategyFactory backingStrategyFactory) {
037            return factory.factory(serviceSpace, backingStrategyFactory);
038        }
039        
040        public void doFail() {
041            factory = null;
042        }
043    
044        public void doStart() throws Exception {
045            factory = new BasicReplicationManagerFactory();
046        }
047    
048        public void doStop() throws Exception {
049            factory = null;
050        }
051        
052        public static final GBeanInfo GBEAN_INFO;
053        
054        static {
055            GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(BasicReplicationManagerFactoryGBean.class, 
056                    NameFactory.GERONIMO_SERVICE);
057    
058            infoBuilder.addInterface(ReplicationManagerFactory.class);
059            
060            infoBuilder.setConstructor(new String[0]);
061            
062            GBEAN_INFO = infoBuilder.getBeanInfo();
063        }
064        
065        public static GBeanInfo getGBeanInfo() {
066            return GBEAN_INFO;
067        }
068    }