001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/search/tags/sakai_2-4-1/search-impl/impl/src/java/org/sakaiproject/search/component/service/impl/SearchReloadNotificationAction.java $
003: * $Id: SearchReloadNotificationAction.java 29315 2007-04-20 14:28:12Z ajpoland@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.search.component.service.impl;
021:
022: import org.apache.commons.logging.Log;
023: import org.apache.commons.logging.LogFactory;
024: import org.sakaiproject.event.api.Event;
025: import org.sakaiproject.event.api.Notification;
026: import org.sakaiproject.event.api.NotificationAction;
027: import org.sakaiproject.search.api.Diagnosable;
028: import org.sakaiproject.search.api.SearchService;
029: import org.w3c.dom.Element;
030:
031: /**
032: * @author ieb
033: */
034: public class SearchReloadNotificationAction implements
035: NotificationAction, Diagnosable {
036:
037: private static Log dlog = LogFactory
038: .getLog(SearchReloadNotificationAction.class);
039:
040: private SearchService searchService;
041:
042: private boolean diagnostics;
043:
044: private SearchReloadNotificationAction() {
045: dlog.debug("Constructor()");
046:
047: }
048:
049: public SearchReloadNotificationAction(SearchService searchService) {
050: dlog.debug("Constructor() " + searchService);
051: this .searchService = searchService;
052:
053: }
054:
055: /**
056: * @{inheritDoc}
057: */
058: public void set(Element arg0) {
059: dlog.debug("set Element");
060:
061: }
062:
063: /**
064: * @{inheritDoc}
065: */
066: public void set(NotificationAction arg0) {
067: dlog.debug("set Action");
068:
069: }
070:
071: /**
072: * @{inheritDoc}
073: */
074: public NotificationAction getClone() {
075: dlog.debug("Clone");
076:
077: SearchReloadNotificationAction clone = new SearchReloadNotificationAction(
078: searchService);
079: clone.set(this );
080: return clone;
081: }
082:
083: /**
084: * @{inheritDoc}
085: */
086: public void toXml(Element arg0) {
087: }
088:
089: /**
090: * @{inheritDoc}
091: */
092: public void notify(Notification arg0, Event event) {
093: dlog.debug("notify");
094:
095: if (!event.getEvent().equals(
096: SearchService.EVENT_TRIGGER_INDEX_RELOAD)) {
097: return;
098: }
099: // this is done so that if we want to persist the events, we can do so
100: // without
101: // being forced to keep a reference to the SearchService
102: if (diagnostics) {
103: dlog.info("Search Index Reloading ");
104: }
105: searchService.reload();
106: }
107:
108: /* (non-Javadoc)
109: * @see org.sakaiproject.search.api.Diagnosable#disableDiagnostics()
110: */
111: public void disableDiagnostics() {
112: diagnostics = false;
113: }
114:
115: /* (non-Javadoc)
116: * @see org.sakaiproject.search.api.Diagnosable#enableDiagnostics()
117: */
118: public void enableDiagnostics() {
119: diagnostics = true;
120: }
121:
122: /* (non-Javadoc)
123: * @see org.sakaiproject.search.api.Diagnosable#hasDiagnostics()
124: */
125: public boolean hasDiagnostics() {
126: return diagnostics;
127: }
128: }
|