*** empty log message ***
authoragriesma
Mon, 06 Oct 2003 22:30:41 +0200
changeset 920893436bb3be7
parent 919 2008fecc763d
child 921 fb3720d6d08f
*** empty log message ***
src/java/isac/objectmanager/OManager.java
src/java/isac/objectmanager/ObjectManager.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/java/isac/objectmanager/OManager.java	Mon Oct 06 22:30:41 2003 +0200
     1.3 @@ -0,0 +1,22 @@
     1.4 +/*
     1.5 + * Created on Oct 6, 2003
     1.6 + *
     1.7 + * To change the template for this generated file go to
     1.8 + * Window>Preferences>Java>Code Generation>Code and Comments
     1.9 + */
    1.10 +package isac.objectmanager;
    1.11 +
    1.12 +import isac.session.SDialog;
    1.13 +
    1.14 +import java.rmi.Remote;
    1.15 +import java.rmi.RemoteException;
    1.16 +
    1.17 +/**
    1.18 + * @author gismo
    1.19 + *
    1.20 + * To change the template for this generated type comment go to
    1.21 + * Window>Preferences>Java>Code Generation>Code and Comments
    1.22 + */
    1.23 +public interface OManager extends Remote{
    1.24 +	public abstract SDialog getSessionDialog() throws RemoteException;
    1.25 +}
    1.26 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/java/isac/objectmanager/ObjectManager.java	Mon Oct 06 22:30:41 2003 +0200
     2.3 @@ -0,0 +1,74 @@
     2.4 +/*
     2.5 + * Created on Oct 6, 2003
     2.6 + *
     2.7 + * To change the template for this generated file go to
     2.8 + * Window>Preferences>Java>Code Generation>Code and Comments
     2.9 + */
    2.10 +package isac.objectmanager;
    2.11 +
    2.12 +import isac.session.SDialog;
    2.13 +import isac.session.SessionDialog;
    2.14 +
    2.15 +import java.rmi.Naming;
    2.16 +import java.rmi.RMISecurityManager;
    2.17 +import java.rmi.RemoteException;
    2.18 +import java.rmi.registry.LocateRegistry;
    2.19 +import java.rmi.server.UnicastRemoteObject;
    2.20 +
    2.21 +/**
    2.22 + * @author gismo
    2.23 + *
    2.24 + * To change the template for this generated type comment go to
    2.25 + * Window>Preferences>Java>Code Generation>Code and Comments
    2.26 + */
    2.27 +public class ObjectManager extends UnicastRemoteObject implements OManager {
    2.28 +	SessionDialog sdialog_;
    2.29 +	/**
    2.30 +	 * @throws RemoteException
    2.31 +	 */
    2.32 +	protected ObjectManager() throws RemoteException {
    2.33 +		//super();
    2.34 +		rmiBind();
    2.35 +		// TODO Auto-generated constructor stub
    2.36 +	}
    2.37 +
    2.38 +	public SDialog getSessionDialog() throws RemoteException{
    2.39 +			if(sdialog_==null)
    2.40 +				sdialog_=SessionDialog.getInstance();
    2.41 +			return sdialog_;
    2.42 +	}
    2.43 +
    2.44 +	public static void main(String[] args) {
    2.45 +		try {
    2.46 +			new ObjectManager();
    2.47 +		} catch (RemoteException e) {
    2.48 +			// TODO Auto-generated catch block
    2.49 +			e.printStackTrace();
    2.50 +		}
    2.51 +	}
    2.52 +	private void rmiBind(){
    2.53 +		if(System.getSecurityManager() == null) {
    2.54 +			System.setSecurityManager(new RMISecurityManager());
    2.55 +		}
    2.56 +
    2.57 +		String name = "//localhost/isac-ObjectManager";
    2.58 +		try {
    2.59 +			System.out.println("try to bind as "+name);
    2.60 +			Naming.rebind(name, this);
    2.61 +			System.out.println("Object Manager bound to "+name);
    2.62 +		} catch (java.rmi.ConnectException e) {	    
    2.63 +		System.err.println("failed to contact as "+name+
    2.64 +			" (creating RMI-Server on localhost:1099)");
    2.65 +		try{
    2.66 +		LocateRegistry.createRegistry(1099);
    2.67 +		rmiBind();
    2.68 +		}catch(java.rmi.RemoteException exc2){
    2.69 +		  System.err.println("can not create registry:"+exc2.getMessage());
    2.70 +		}
    2.71 +		} catch (Exception exc){ 
    2.72 +		System.err.println("failed to connect to rmiregistry");
    2.73 +		System.err.println(exc);
    2.74 +	}
    2.75 +	}
    2.76 +	
    2.77 +}