/* * TeleStax, Open Source Cloud Communications * Copyright 2011-2016, TeleStax Inc. and individual contributors * by the @authors tag. * * This program is free software: you can redistribute it and/or modify * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation; either version 3 of * the License, or (at your option) any later version. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package org.jdiameter.common.impl.app.s13; import org.jdiameter.api.app.AppSession; import org.jdiameter.api.s13.ClientS13Session; import org.jdiameter.api.s13.ServerS13Session; import org.jdiameter.client.impl.app.s13.ClientS13SessionDataLocalImpl; import org.jdiameter.common.api.app.IAppSessionDataFactory; import org.jdiameter.common.api.app.s13.IS13SessionData; import org.jdiameter.server.impl.app.s13.ServerS13SessionDataLocalImpl; public class S13LocalSessionDataFactory implements IAppSessionDataFactory<IS13SessionData> { @Override public IS13SessionData getAppSessionData(Class<? extends AppSession> clazz, String sessionId) { if (clazz.equals(ClientS13Session.class)) { ClientS13SessionDataLocalImpl data = new ClientS13SessionDataLocalImpl(); data.setSessionId(sessionId); return data; } else if (clazz.equals(ServerS13Session.class)) { ServerS13SessionDataLocalImpl data = new ServerS13SessionDataLocalImpl(); data.setSessionId(sessionId); return data; } else { throw new IllegalArgumentException("Invalid Session Class: " + clazz.toString()); } } }