View Javadoc

1   /*
2    * Copyright 2007-2009 Hippo
3    *
4    * Licensed under the Apache License, Version 2.0 (the  "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" 
12   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License.
15   */
16  package nl.hippo.client.event.service;
17  
18  import nl.hippo.client.api.ClientException;
19  import nl.hippo.client.api.event.EventAwareManager;
20  import nl.hippo.client.api.service.UpdateNotificationService;
21  import nl.hippo.client.event.EventAwareManagerImpl;
22  import nl.hippo.client.event.RepositoryChangeListener;
23  
24  public class UpdateNotificationServiceImpl implements UpdateNotificationService {
25  
26      private RepositoryChangeListener repositoryChangeListener;
27  
28      public UpdateNotificationServiceImpl(UpdateNotificationConfig config) throws ClientException {
29          EventAwareManager manager = new EventAwareManagerImpl(config);
30          repositoryChangeListener = new RepositoryChangeListener(config, manager);
31          repositoryChangeListener.setDaemon(true);
32      }
33  
34      public EventAwareManager getEventAwareManager() {
35          return repositoryChangeListener.getManager();
36      }
37  
38      public synchronized void start() {
39          repositoryChangeListener.start();
40      }
41  
42      public synchronized void stop() {
43          repositoryChangeListener.shutdown();
44      }
45  }