Commit 3a945e99 authored by jehan's avatar jehan

refactor proxy management interface

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@82 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent aee423ed
......@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package org.linphone.p2pproxy.api;
public interface P2pProxyManagement extends P2pProxyNetworkProbe,P2pProxyRtpRelayManagement,P2pProxySipProxyRegistrarManagement {
public interface P2pProxyManagement extends P2pProxyNetworkProbe,P2pProxySipProxyRegistrarManagement {
/**
* test if according both to local peer capabilities and supeer peer election polity this peer should become a super peer
......
......@@ -24,7 +24,6 @@ package org.linphone.p2pproxy.core;
import java.io.File;
import java.net.InetAddress;
import java.net.URI;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Enumeration;
import java.util.Properties;
......@@ -144,7 +143,7 @@ public class P2pProxyInstanceImpl implements P2pProxyInstance {
mConfigurator.setProperty(SipProxyRegistrar.REGISTRAR_PORT,Integer.toString(BASE_PROXY_SIP_PORT+mIndex));
// setup sip proxy
mP2pProxyAccountManagement = new P2pProxyAccountManagement(mJxtaNetworkManager);
mSipProxy = new SipProxyRegistrar(mConfigurator,mJxtaNetworkManager,mP2pProxyAccountManagement,mP2pProxyManagement);
mSipProxy = new SipProxyRegistrar(mConfigurator,mJxtaNetworkManager,mP2pProxyAccountManagement);
// setup sip client
mProviderForSipClient = new SipProvider(getPrivateHostAddress(),BASE_CLIENT_SIP_PORT+mIndex);
mProviderForSipClient.setOutboundProxy(new SocketAddress(getPrivateHostAddress(),BASE_PROXY_SIP_PORT+mIndex));
......
......@@ -39,10 +39,10 @@ import org.apache.log4j.PropertyConfigurator;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.api.P2pProxyManagement;
import org.linphone.p2pproxy.api.P2pProxyNotReadyException;
import org.linphone.p2pproxy.api.P2pProxySipProxyRegistrarManagement;
import org.linphone.p2pproxy.api.P2pProxyUserAlreadyExistException;
import org.linphone.p2pproxy.core.media.rtprelay.RtpRelayService;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrarAdvertisement;
import org.zoolu.sip.provider.SipStack;
import org.linphone.p2pproxy.launcher.P2pProxylauncherConstants;
......@@ -53,6 +53,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
private static P2pProxyManagement mP2pProxyManagement;
private static SipProxyRegistrar mSipAndPipeListener;
private static P2pProxyAccountManagementMBean mP2pProxyAccountManagement;
private static P2pProxySipProxyRegistrarManagement mP2pProxySipProxyRegistrarManagement;
public final static String ACCOUNT_MGR_MBEAN_NAME="org.linphone.p2proxy:type=account-manager";
public final static String PROXY_REG_MBEAN_NAME="org.linphone.p2proxy:type=proxy-registrar";
public final static String MAIN_MBEAN_NAME="org.linphone.p2proxy:type=main";
......@@ -265,7 +266,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
mP2pProxyAccountManagement = new P2pProxyAccountManagement(mJxtaNetworkManager);
// setup sip provider
SipStack.log_path = mConfigHomeDir+"/logs";
mSipAndPipeListener = new SipProxyRegistrar(mConfigurator,mJxtaNetworkManager,mP2pProxyAccountManagement,mP2pProxyManagement);
mSipAndPipeListener = new SipProxyRegistrar(mConfigurator,mJxtaNetworkManager,mP2pProxyAccountManagement);
//set management
try {
ObjectName lObjectName = new ObjectName(ACCOUNT_MGR_MBEAN_NAME);
......@@ -300,6 +301,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
mJxtaNetworkManager = new JxtaNetworkManager(aProperties,aConfigDir);
mServiceProvider = new EdgePeerServiceManager(aProperties, mJxtaNetworkManager);
mP2pProxyManagement = (P2pProxyManagement) mServiceProvider;
mP2pProxySipProxyRegistrarManagement = (P2pProxySipProxyRegistrarManagement) mServiceProvider;
mServiceProvider.start(3000L);
}
......@@ -308,6 +310,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
mJxtaNetworkManager = new JxtaNetworkManager(aProperties,aConfigDir);
mServiceProvider = new SuperPeerServiceManager(aProperties, mJxtaNetworkManager);
mP2pProxyManagement = (P2pProxyManagement) mServiceProvider;
mP2pProxySipProxyRegistrarManagement = (P2pProxySipProxyRegistrarManagement) mServiceProvider;
mServiceProvider.start(3000L);
}
private static void startSeeding(Configurator aProperties,File aConfigDir) throws Exception{
......@@ -315,6 +318,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
mJxtaNetworkManager = new JxtaNetworkManager(aProperties,aConfigDir);
mServiceProvider = new SeedingPeerServiceManager(aProperties, mJxtaNetworkManager,true);
mP2pProxyManagement = null;
mP2pProxySipProxyRegistrarManagement = (P2pProxySipProxyRegistrarManagement) mServiceProvider;
mServiceProvider.start(3000L);
}
private static void usage() {
......@@ -430,8 +434,7 @@ public static int isValidAccount(String aUserName){
public static String getSipProxyRegistrarUri() {
try {
isReady();
SipProxyRegistrarAdvertisement lSipProxyRegistrarAdvertisement = (SipProxyRegistrarAdvertisement) (mJxtaNetworkManager.getAdvertisement(null, SipProxyRegistrarAdvertisement.NAME, true));
return lSipProxyRegistrarAdvertisement.getAddress();
return mP2pProxySipProxyRegistrarManagement.getSipProxyRegistrarUri();
} catch (Exception e) {
return null;
}
......
......@@ -35,31 +35,26 @@ import org.linphone.p2pproxy.core.media.rtprelay.RtpRelayServiceClient;
import org.linphone.p2pproxy.core.rdvautoconfig.PeerInfoServiceClient;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrarAdvertisement;
public abstract class P2pProxyManagementImpl implements ServiceProvider,P2pProxyManagement {
protected final JxtaNetworkManager mJxtaNetworkManager;
public abstract class P2pProxyManagementImpl extends P2pProxySipProxyRegistrarManagementImpl implements ServiceProvider,P2pProxyManagement {
protected final Configurator mConfigurator;
private final PeerInfoServiceClient mPeerInfoServiceClient;
private final RtpRelayServiceClient mRtpRelayServiceClient;
private final static Logger mLog = Logger.getLogger(P2pProxyManagementImpl.class);
P2pProxyManagementImpl(Configurator aConfigurator, JxtaNetworkManager aJxtaNetworkManager) throws SocketException, UnknownHostException
{
mJxtaNetworkManager = aJxtaNetworkManager;
super(aJxtaNetworkManager);
mConfigurator = aConfigurator;
mPeerInfoServiceClient = new PeerInfoServiceClient(aConfigurator, aJxtaNetworkManager);
mRtpRelayServiceClient = new RtpRelayServiceClient(aConfigurator, aJxtaNetworkManager);
}
public void start(long aTimeout) throws P2pProxyException
{
mPeerInfoServiceClient.start(aTimeout);
mRtpRelayServiceClient.start(aTimeout);
}
public void stop() {
mPeerInfoServiceClient.stop();
mRtpRelayServiceClient.stop();
mLog.info("P2pProxyManagementImpl stopped");
}
......@@ -74,17 +69,6 @@ public abstract class P2pProxyManagementImpl implements ServiceProvider,P2pProxy
}
public Map<MediaType, InetSocketAddress> getAddresses() throws P2pProxyException {
return mRtpRelayServiceClient.getAddresses();
}
public String getSipProxyRegistrarUri() throws P2pProxyException {
try {
SipProxyRegistrarAdvertisement lSipProxyRegistrarAdvertisement = (SipProxyRegistrarAdvertisement) (mJxtaNetworkManager.getAdvertisement(null, SipProxyRegistrarAdvertisement.NAME, true));
return lSipProxyRegistrarAdvertisement.getAddress();
}catch (Exception e) {
throw new P2pProxyException(e);
}
}
}
package org.linphone.p2pproxy.core;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.api.P2pProxySipProxyRegistrarManagement;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrarAdvertisement;
public class P2pProxySipProxyRegistrarManagementImpl implements P2pProxySipProxyRegistrarManagement {
protected final JxtaNetworkManager mJxtaNetworkManager;
P2pProxySipProxyRegistrarManagementImpl(JxtaNetworkManager aJxtaNetworkManager) {
mJxtaNetworkManager = aJxtaNetworkManager;
}
public String getSipProxyRegistrarUri() throws P2pProxyException {
try {
SipProxyRegistrarAdvertisement lSipProxyRegistrarAdvertisement = (SipProxyRegistrarAdvertisement) (mJxtaNetworkManager.getAdvertisement(null, SipProxyRegistrarAdvertisement.NAME, true));
return lSipProxyRegistrarAdvertisement.getAddress();
}catch (Exception e) {
throw new P2pProxyException(e);
}
}
}
......@@ -17,15 +17,14 @@ import org.linphone.p2pproxy.core.media.rtprelay.RtpRelayService;
import org.linphone.p2pproxy.core.media.rtprelay.RtpRelayServerConfig;
import org.linphone.p2pproxy.core.rdvautoconfig.PeerInfoProviderService;
public class SeedingPeerServiceManager implements ServiceProvider {
protected final JxtaNetworkManager mJxtaNetworkManager;
public class SeedingPeerServiceManager extends P2pProxySipProxyRegistrarManagementImpl implements ServiceProvider {
protected final Configurator mConfigurator;
private final PeerInfoProviderService mPeerInfoProviderService;
private RtpRelayService mUdpRelayService = null;
private final static Logger mLog = Logger.getLogger(SeedingPeerServiceManager.class);
SeedingPeerServiceManager(Configurator aConfigurator, JxtaNetworkManager aJxtaNetworkManager,boolean enableUdpRelay) throws SocketException, UnknownHostException {
mJxtaNetworkManager = aJxtaNetworkManager;
super(aJxtaNetworkManager);
mConfigurator = aConfigurator;
mPeerInfoProviderService = new PeerInfoProviderService(aConfigurator, aJxtaNetworkManager);
if (enableUdpRelay == true) {
......
......@@ -5,9 +5,6 @@
package org.linphone.p2pproxy.core;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
......
......@@ -24,52 +24,31 @@ package org.linphone.p2pproxy.core.sipproxy;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import net.jxta.document.Advertisement;
import net.jxta.document.AdvertisementFactory;
import net.jxta.endpoint.MessageElement;
import net.jxta.endpoint.StringMessageElement;
import net.jxta.id.IDFactory;
import net.jxta.pipe.OutputPipe;
import net.jxta.pipe.PipeMsgEvent;
import net.jxta.pipe.PipeMsgListener;
import net.jxta.protocol.PipeAdvertisement;
import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.api.P2pProxyRtpRelayManagement;
import org.linphone.p2pproxy.api.P2pProxyUserNotFoundException;
import org.linphone.p2pproxy.core.Configurator;
import org.linphone.p2pproxy.core.JxtaNetworkManager;
import org.linphone.p2pproxy.core.P2pProxyAccountManagementMBean;
import org.linphone.p2pproxy.core.P2pProxyAdvertisementNotFoundException;
import org.linphone.p2pproxy.core.media.rtprelay.MediaType;
import org.linphone.p2pproxy.core.media.rtprelay.SdpProcessorImpl;
import org.linphone.p2pproxy.core.sipproxy.superpeers.P2pUserRegistrationAdvertisement;
import org.linphone.p2pproxy.core.sipproxy.superpeers.SuperPeerProxy;
import org.zoolu.sip.address.NameAddress;
import org.zoolu.sip.address.SipURL;
import org.zoolu.sip.header.ExpiresHeader;
import org.zoolu.sip.header.Header;
import org.zoolu.sip.header.MultipleHeader;
import org.zoolu.sip.header.RecordRouteHeader;
import org.zoolu.sip.header.RouteHeader;
import org.zoolu.sip.header.ViaHeader;
import org.zoolu.sip.message.Message;
import org.zoolu.sip.message.MessageFactory;
import org.zoolu.sip.provider.SipProvider;
import org.zoolu.sip.provider.SipProviderListener;
import org.zoolu.sip.provider.SipStack;
import org.zoolu.sip.provider.TransactionIdentifier;
import org.zoolu.sip.transaction.Transaction;
import org.zoolu.sip.transaction.TransactionServer;
import java.util.Collections;
......@@ -180,7 +159,7 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
}
public SipProxyRegistrar(Configurator lProperties,JxtaNetworkManager aJxtaNetworkManager,P2pProxyAccountManagementMBean aP2pProxyAccountManagement,P2pProxyRtpRelayManagement aP2pProxyRtpRelayManagement) throws IOException {
public SipProxyRegistrar(Configurator lProperties,JxtaNetworkManager aJxtaNetworkManager,P2pProxyAccountManagementMBean aP2pProxyAccountManagement) throws IOException {
mJxtaNetworkManager = aJxtaNetworkManager;
mP2pProxyAccountManagement = aP2pProxyAccountManagement;
mProperties = lProperties;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment