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.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.storage.ReplicaStorage;
024 import org.codehaus.wadi.replication.storage.ReplicaStorageFactory;
025 import org.codehaus.wadi.replication.storage.basic.BasicReplicaStorageFactory;
026 import org.codehaus.wadi.servicespace.ServiceSpace;
027
028 /**
029 *
030 * @version $Rev$ $Date$
031 */
032 public class BasicReplicaStorageFactoryGBean implements ReplicaStorageFactory, GBeanLifecycle {
033 private BasicReplicaStorageFactory storageFactory;
034
035 public ReplicaStorage factory(ServiceSpace serviceSpace) {
036 return storageFactory.factory(serviceSpace);
037 }
038
039 public void doFail() {
040 storageFactory = null;
041 }
042
043 public void doStart() throws Exception {
044 storageFactory = new BasicReplicaStorageFactory();
045 }
046
047 public void doStop() throws Exception {
048 storageFactory = null;
049 }
050
051
052 public static final GBeanInfo GBEAN_INFO;
053
054 static {
055 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(BasicReplicaStorageFactoryGBean.class,
056 NameFactory.GERONIMO_SERVICE);
057
058 infoBuilder.addInterface(ReplicaStorageFactory.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 }