001/* 002 * GWTEventService 003 * Copyright (c) 2011 and beyond, strawbill UG (haftungsbeschr?nkt) 004 * 005 * This is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Lesser General Public License as 007 * published by the Free Software Foundation; either version 3 of 008 * the License, or (at your option) any later version. 009 * Other licensing for GWTEventService may also be possible on request. 010 * Please view the license.txt of the project for more information. 011 * 012 * This software is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this software; if not, write to the Free 019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 021 */ 022package de.novanic.eventservice.service; 023 024import com.google.gwt.user.server.rpc.RemoteServiceServlet; 025import de.novanic.eventservice.client.event.domain.Domain; 026import de.novanic.eventservice.client.event.Event; 027import de.novanic.eventservice.client.event.filter.EventFilter; 028 029import javax.servlet.http.HttpServletRequest; 030 031/** 032 * RemoteEventServiceServlet is an implementation of {@link de.novanic.eventservice.service.EventExecutorService} as a servlet 033 * and can be used to add events via the server side. 034 * 035 * @author sstrohschein 036 * <br>Date: 20.09.2008 037 * <br>Time: 15:31:18 038 */ 039public abstract class RemoteEventServiceServlet extends RemoteServiceServlet implements EventExecutorService 040{ 041 /** 042 * Checks if the user is registered for event listening. 043 * @return true when the user is listening, otherwise false 044 */ 045 public boolean isUserRegistered() { 046 return getEventExecutorService().isUserRegistered(); 047 } 048 049 /** 050 * Checks if the user is registered for event listening. 051 * @param aDomain domain to check the registration for the user 052 * @return true when the user is listening, otherwise false 053 */ 054 public boolean isUserRegistered(Domain aDomain) { 055 return getEventExecutorService().isUserRegistered(aDomain); 056 } 057 058 /** 059 * Adds an event for all users 060 * @param aDomain the domain to add the event 061 * @param anEvent event to add 062 */ 063 public void addEvent(Domain aDomain, Event anEvent) { 064 getEventExecutorService().addEvent(aDomain, anEvent); 065 } 066 067 /** 068 * Adds an event for a specific user 069 * @param anEvent event to add 070 */ 071 public void addEventUserSpecific(Event anEvent) { 072 getEventExecutorService().addEventUserSpecific(anEvent); 073 } 074 075 /** 076 * Changes the {@link de.novanic.eventservice.client.event.filter.EventFilter} for the user-domain combination. 077 * The {@link de.novanic.eventservice.client.event.filter.EventFilter} can be removed with the method 078 * {@link de.novanic.eventservice.service.EventExecutorService#removeEventFilter(de.novanic.eventservice.client.event.domain.Domain)} 079 * or when that method is called with NULL as the {@link de.novanic.eventservice.client.event.filter.EventFilter} 080 * parameter value. 081 * @param aDomain domain to set the {@link de.novanic.eventservice.client.event.filter.EventFilter} 082 * @param anEventFilter new {@link de.novanic.eventservice.client.event.filter.EventFilter} 083 */ 084 public void setEventFilter(Domain aDomain, EventFilter anEventFilter) { 085 getEventExecutorService().setEventFilter(aDomain, anEventFilter); 086 } 087 088 /** 089 * Returns the EventFilter for the user domain combination. 090 * @param aDomain domain 091 * @return EventFilter for the domain 092 */ 093 public EventFilter getEventFilter(Domain aDomain) { 094 return getEventExecutorService().getEventFilter(aDomain); 095 } 096 097 /** 098 * Removes the {@link de.novanic.eventservice.client.event.filter.EventFilter} of the domain. 099 * @param aDomain domain to drop the {@link de.novanic.eventservice.client.event.filter.EventFilter} from 100 */ 101 public void removeEventFilter(Domain aDomain) { 102 getEventExecutorService().removeEventFilter(aDomain); 103 } 104 105 /** 106 * Creates an instance of {@link de.novanic.eventservice.service.EventExecutorService}. 107 * @return a new instance of {@link de.novanic.eventservice.service.EventExecutorService} 108 */ 109 private EventExecutorService getEventExecutorService() { 110 final EventExecutorServiceFactory theEventExecutorServiceFactory = EventExecutorServiceFactory.getInstance(); 111 return theEventExecutorServiceFactory.getEventExecutorService(getRequest()); 112 } 113 114 /** 115 * Returns the current request. 116 * @return current request 117 */ 118 protected HttpServletRequest getRequest() { 119 return getThreadLocalRequest(); 120 } 121 122 /** 123 * This method is overridden because applications with various GWT versions got a {@link SecurityException} 124 * @throws SecurityException 125 */ 126 @Override 127 protected void checkPermutationStrongName() throws SecurityException {} 128}