1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-06 07:32:46 +00:00

Removed deprecated ScriptTemplateService

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-07-31 13:43:10 -03:00
parent 4fff207e32
commit 7eca70e881
5 changed files with 12 additions and 148 deletions

View File

@@ -170,9 +170,9 @@ public class CharacterServiceImpl extends AbstractService implements
return true; return true;
// remove chat listeners // remove chat listeners
chatService.getGlobalChannel().removeChatChannelListener( chatService.getGlobalChannel().removeMessageListener(
globalChatListener); globalChatListener);
chatService.getTradeChannel().removeChatChannelListener( chatService.getTradeChannel().removeMessageListener(
tradeChatListener); tradeChatListener);
// // remove broadcast listener // // remove broadcast listener
@@ -185,9 +185,9 @@ public class CharacterServiceImpl extends AbstractService implements
}); });
// register global chat listener // register global chat listener
chatService.getGlobalChannel().addChatChannelListener( chatService.getGlobalChannel().addMessageListener(
globalChatListener); globalChatListener);
chatService.getTradeChannel().addChatChannelListener(tradeChatListener); chatService.getTradeChannel().addMessageListener(tradeChatListener);
// query client game guard -- if key is invalid, the connection will be // query client game guard -- if key is invalid, the connection will be
// closed as soon as possible // closed as soon as possible

View File

@@ -58,7 +58,7 @@ public interface ChatChannel {
* @param listener * @param listener
* the listener * the listener
*/ */
void addChatChannelListener(ChatChannelListener listener); void addMessageListener(ChatChannelListener listener);
/** /**
* Removes a {@link ChatChannelListener}. * Removes a {@link ChatChannelListener}.
@@ -66,7 +66,7 @@ public interface ChatChannel {
* @param listener * @param listener
* the listener * the listener
*/ */
void removeChatChannelListener(ChatChannelListener listener); void removeMessageListener(ChatChannelListener listener);
/** /**
* Adds a {@link ChatChannelFilter} that will be used to filter each message * Adds a {@link ChatChannelFilter} that will be used to filter each message
@@ -75,7 +75,7 @@ public interface ChatChannel {
* @param filter * @param filter
* the filter * the filter
*/ */
void addChatChannelFilter(ChatChannelFilter filter); void addMessageFilter(ChatChannelFilter filter);
/** /**
* Removes a {@link ChatChannelListener}. * Removes a {@link ChatChannelListener}.
@@ -83,7 +83,7 @@ public interface ChatChannel {
* @param filter * @param filter
* the filter * the filter
*/ */
void removeChatChannelFilter(ChatChannelFilter filter); void removeMessageFilter(ChatChannelFilter filter);
/** /**
* @return the chat channel numeric ID * @return the chat channel numeric ID

View File

@@ -246,25 +246,25 @@ public class SimpleChatService extends AbstractService implements ChatService {
} }
@Override @Override
public void addChatChannelListener(ChatChannelListener listener) { public void addMessageListener(ChatChannelListener listener) {
Preconditions.checkNotNull(listener, "listener"); Preconditions.checkNotNull(listener, "listener");
listeners.add(listener); listeners.add(listener);
} }
@Override @Override
public void removeChatChannelListener(ChatChannelListener listener) { public void removeMessageListener(ChatChannelListener listener) {
Preconditions.checkNotNull(listener, "listener"); Preconditions.checkNotNull(listener, "listener");
listeners.remove(listener); listeners.remove(listener);
} }
@Override @Override
public void addChatChannelFilter(ChatChannelFilter filter) { public void addMessageFilter(ChatChannelFilter filter) {
Preconditions.checkNotNull(filter, "filter"); Preconditions.checkNotNull(filter, "filter");
filters.add(filter); filters.add(filter);
} }
@Override @Override
public void removeChatChannelFilter(ChatChannelFilter filter) { public void removeMessageFilter(ChatChannelFilter filter) {
Preconditions.checkNotNull(filter, "filter"); Preconditions.checkNotNull(filter, "filter");
filters.remove(filter); filters.remove(filter);
} }

View File

@@ -1,105 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.service.game.template;
import java.util.Map;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.l2jserver.model.id.TemplateID;
import com.l2jserver.model.template.Template;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.AbstractService.Depends;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
import com.l2jserver.service.configuration.ConfigurationService;
import com.l2jserver.service.core.LoggingService;
import com.l2jserver.service.game.scripting.ScriptContext;
import com.l2jserver.service.game.scripting.ScriptingService;
import com.l2jserver.util.factory.CollectionFactory;
@Depends({ LoggingService.class, ConfigurationService.class,
ScriptingService.class })
public class ScriptTemplateService extends AbstractService implements
TemplateService {
private final ScriptingService scriptingService;
private final ScriptTemplateServiceConfiguration config;
private final Injector injector;
private ScriptContext context;
@SuppressWarnings("rawtypes")
private Map<TemplateID, Template> templates = CollectionFactory.newMap();
@Inject
public ScriptTemplateService(ScriptingService scriptingService,
ConfigurationService configService, Injector injector) {
this.scriptingService = scriptingService;
this.injector = injector;
this.config = configService
.get(ScriptTemplateServiceConfiguration.class);
}
@Override
protected void doStart() throws ServiceStartException {
if (context == null) {
try {
context = scriptingService.load(config.getTemplateDescriptor())
.get(0);
} catch (Exception e) {
throw new ServiceStartException(e);
}
return;
}
if (context.isInitialized())
context.shutdown();
context.init();
}
@Override
@SuppressWarnings("unchecked")
public <T extends Template<?>> T getTemplate(TemplateID<T, ?> id) {
Preconditions.checkNotNull(id, "id");
return (T) templates.get(id);
}
public void addTemplate(Class<? extends Template<?>> t) {
Preconditions.checkNotNull(t, "t");
final Template<?> template = injector.getInstance(t);
if (templates.containsKey(template.getID()))
throw new TemplateException("Template with ID" + template.getID()
+ " is already registered for "
+ templates.get(template.getID()));
if (template.getID() != null)
templates.put(template.getID(), template);
}
public void removeTemplate(Template<?> t) {
Preconditions.checkNotNull(t, "t");
// TODO templates.remove(t);
}
@Override
protected void doStop() throws ServiceStopException {
if (context.isInitialized())
context.shutdown();
context = null;
}
}

View File

@@ -1,31 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.service.game.template;
import java.io.File;
import com.l2jserver.service.configuration.Configuration;
import com.l2jserver.service.configuration.Configuration.ConfigurationName;
@ConfigurationName("template")
public interface ScriptTemplateServiceConfiguration extends Configuration {
@ConfigurationPropertyGetter(name = "template.descriptor", defaultValue = "data/script/template/template.xml")
File getTemplateDescriptor();
@ConfigurationPropertySetter(name = "template.descriptor")
void setTemplateDescriptor(File file);
}