View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    * 
4    * 
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    * http://www.opensource.org/licenses/ecl2.php
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.kuali.rice.ksb.messaging;
18  
19  import org.kuali.rice.ksb.cache.RiceCacheAdministrator;
20  import org.kuali.rice.ksb.cache.RiceCacheAdministratorImpl;
21  import org.kuali.rice.ksb.service.KSBServiceLocator;
22  import org.springframework.beans.factory.FactoryBean;
23  import org.springframework.beans.factory.InitializingBean;
24  
25  
26  /**
27   * Returns a {@link RiceCacheAdministrator}.  Starts and registers this 
28   * cache with the bus.
29   * 
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class RiceCacheExporterFactoryBean implements FactoryBean, InitializingBean {
33  	
34  	private String serviceName;
35  	private RiceCacheAdministratorImpl cache;
36  	protected RemotedServiceRegistry remotedServiceRegistry;
37  
38  	public Object getObject() throws Exception {
39  		return cache;
40  	}
41  
42  	public Class getObjectType() {
43  		return RiceCacheAdministrator.class;
44  	}
45  
46  	public boolean isSingleton() {
47  		return true;
48  	}
49  
50  	public String getServiceName() {
51  	    return this.serviceName;
52  	}
53  
54  	public void setServiceName(String serviceName) {
55  	    this.serviceName = serviceName;
56  	}
57  
58  	public void afterPropertiesSet() throws Exception {
59  		if (cache == null) {
60  			cache = new RiceCacheAdministratorImpl();
61  			cache.setServiceName(this.getServiceName());
62  			cache.setForceRegistryRefresh(false);
63  			if (remotedServiceRegistry == null) {
64  				remotedServiceRegistry = KSBServiceLocator.getServiceDeployer();
65  			}
66  			cache.setRemotedServiceRegistry(remotedServiceRegistry);
67  			cache.start();
68  		}
69  	}
70  	
71  
72  	/**
73  	 * @return the remotedServiceRegistry
74  	 */
75  	public RemotedServiceRegistry getRemotedServiceRegistry() {
76  		return this.remotedServiceRegistry;
77  	}
78  
79  	/**
80  	 * @param remotedServiceRegistry the remotedServiceRegistry to set
81  	 */
82  	public void setRemotedServiceRegistry(
83  			RemotedServiceRegistry remotedServiceRegistry) {
84  		this.remotedServiceRegistry = remotedServiceRegistry;
85  	}
86  
87  }