/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/


import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

// line 2 "Class_DistributableRMI.ump"
public class ClientImpl implements java.io.Serializable , IClientImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public ClientImpl()
  {}
  //------------------------
  // Reference to the proxy
  //------------------------
  Client self;
  
  public void setSelf(Client proxy)
  {
    self=proxy;
  }

  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCode()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public void delete()
  {}

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
public interface IVendorImpl extends java.rmi.Remote, IAgentImpl
{
  public void setSelf(Vendor proxy) throws RemoteException;
  public int getHashCode() throws RemoteException;
  public Order getOrder(int index) throws RemoteException;
  public List<Order> getOrders() throws RemoteException;
  public int numberOfOrders() throws RemoteException;
  public boolean hasOrders() throws RemoteException;
  public int indexOfOrder(Order aOrder) throws RemoteException;
  public Customer getCustomer(int index) throws RemoteException;
  public List<Customer> getCustomers() throws RemoteException;
  public int numberOfCustomers() throws RemoteException;
  public boolean hasCustomers() throws RemoteException;
  public int indexOfCustomer(Customer aCustomer) throws RemoteException;
  public boolean addOrder(Order aOrder) throws RemoteException;
  public boolean removeOrder(Order aOrder) throws RemoteException;
  public boolean addOrderAt(Order aOrder, int index) throws RemoteException;
  public boolean addOrMoveOrderAt(Order aOrder, int index) throws RemoteException;
  public boolean addCustomer(Customer aCustomer) throws RemoteException;
  public boolean removeCustomer(Customer aCustomer) throws RemoteException;
  public boolean addCustomerAt(Customer aCustomer, int index) throws RemoteException;
  public boolean addOrMoveCustomerAt(Customer aCustomer, int index) throws RemoteException;
  public void delete() throws RemoteException;
   public Product findProduct(ProductType productType) throws RemoteException;
   public Order makeOrder(Customer aCustomer, Product aProduct) throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;

// line 33 "../ecommerceRMI0.ump"
public class Agent implements java.io.Serializable, IAgentImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Agent Attributes
  private  transient String name;

  //Agent Associations
  private transient  List<Warehouse> warehouses;
  private transient  SystemManager systemManager;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Agent(String aName, UmpleRuntime.UmpleComponent umpleComponent)
  {
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Agent.class)
        UmpleRuntime.getInstance().newAgent(aName, umpleComponent, this);

      return;
    }
    else
    {
      UmpleRuntime.getInstance().newAgent(this);
    }

    name = aName;
    warehouses = new ArrayList<Warehouse>();
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public boolean setNameImpl(String aName)
  {
    boolean wasSet = false;
    name = aName;
    wasSet = true;
    return wasSet;
  }

  public String getNameImpl()
  {
    return name;
  }
  /* Code from template association_GetMany */
  public Warehouse getWarehousImpl(int index)
  {
    Warehouse aWarehous = warehouses.get(index);
    return aWarehous;
  }

  public List<Warehouse> getWarehousesImpl()
  {
    List<Warehouse> newWarehouses = Collections.unmodifiableList(warehouses);
    return newWarehouses;
  }

  public int numberOfWarehousesImpl()
  {
    int number = warehouses.size();
    return number;
  }

  public boolean hasWarehousesImpl()
  {
    boolean has = warehouses.size() > 0;
    return has;
  }

  public int indexOfWarehousImpl(Warehouse aWarehous)
  {
    int index = warehouses.indexOf(aWarehous);
    return index;
  }
  /* Code from template association_GetOne */
  public SystemManager getSystemManagerImpl()
  {
    return systemManager;
  }

  public boolean hasSystemManagerImpl()
  {
    boolean has = systemManager != null;
    return has;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfWarehouses()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addWarehousImpl(Warehouse aWarehous)
  {
    boolean wasAdded = false;
    if (warehouses.contains(aWarehous)) { return false; }
    warehouses.add(aWarehous);
    if (aWarehous.indexOfAgent(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aWarehous.addAgent(this);
      if (!wasAdded)
      {
        warehouses.remove(aWarehous);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeWarehousImpl(Warehouse aWarehous)
  {
    boolean wasRemoved = false;
    if (!warehouses.contains(aWarehous))
    {
      return wasRemoved;
    }

    int oldIndex = warehouses.indexOf(aWarehous);
    warehouses.remove(oldIndex);
    if (aWarehous.indexOfAgent(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aWarehous.removeAgent(this);
      if (!wasRemoved)
      {
        warehouses.add(oldIndex,aWarehous);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index)
  {  
    boolean wasAdded = false;
    if(addWarehous(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index)
  {
    boolean wasAdded = false;
    if(warehouses.contains(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addWarehousAt(aWarehous, index);
    }
    return wasAdded;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setSystemManagerImpl(SystemManager aSystemManager)
  {
    boolean wasSet = false;
    SystemManager existingSystemManager = systemManager;
    systemManager = aSystemManager;
    if (existingSystemManager != null && !existingSystemManager.equals(aSystemManager))
    {
      existingSystemManager.removeAgent(this);
    }
    if (aSystemManager != null)
    {
      aSystemManager.addAgent(this);
    }
    wasSet = true;
    return wasSet;
  }

  public void deleteImpl()
  {
    ArrayList<Warehouse> copyOfWarehouses = new ArrayList<Warehouse>(warehouses);
    warehouses.clear();
    for(Warehouse aWarehous : copyOfWarehouses)
    {
      aWarehous.removeAgent(this);
    }
    if (systemManager != null)
    {
      SystemManager placeholderSystemManager = systemManager;
      this.systemManager = null;
      placeholderSystemManager.removeAgent(this);
    }
  }


  public String toString()
  {
    return super.toString() + "["+
            "name" + ":" + getName()+ "]" + System.getProperties().getProperty("line.separator") +
            "  " + "systemManager = "+(getSystemManager()!=null?Integer.toHexString(System.identityHashCode(getSystemManager())):"null");
  }
  public void setRealObject(IAgentImpl aObject)
  {
    realObject=aObject;
  }

  transient IAgentImpl realObject=this;
  public Agent(String aName)
  {

this(aName,UmpleRuntime.getComponent("Agent"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setName(String aName)
  {
    while(true)
      try{
        return realObject.setNameImpl(aName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getName()
  {
    while(true)
      try{
        return realObject.getNameImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Warehouse getWarehous(int index)
  {
    while(true)
      try{
        return realObject.getWarehousImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Warehouse> getWarehouses()
  {
    while(true)
      try{
        return realObject.getWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfWarehouses()
  {
    while(true)
      try{
        return realObject.numberOfWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasWarehouses()
  {
    while(true)
      try{
        return realObject.hasWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.indexOfWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public SystemManager getSystemManager()
  {
    while(true)
      try{
        return realObject.getSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasSystemManager()
  {
    while(true)
      try{
        return realObject.hasSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.addWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.removeWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    while(true)
      try{
        return realObject.setSystemManagerImpl(aSystemManager);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  protected  IAgentImpl remoteObject;  
  public void setRemoteObject(IAgentImpl aRemoteObject)
  {
    remoteObject=aRemoteObject;
  }
  public IAgentImpl getRemoteObject()
  {
    return (IAgentImpl)remoteObject;
  }
  private void readObject(java.io.ObjectInputStream in) throws Exception
  {
    try
    {
      in.defaultReadObject();
      realObject=(IAgentImpl)remoteObject;
    }
    catch(Exception e)
    {
      throw e;
    }
    
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Agent)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.io.Serializable;

// line 38 "../ecommerceRMI0.ump"
public class Order implements java.io.Serializable
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Order Associations
  private Customer customer;
  private Vendor vendor;
  private Product product;
  private SystemManager systemManager;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Order(Product aProduct)
  {
    if (!setProduct(aProduct))
    {
      throw new RuntimeException("Unable to create Order due to aProduct. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetOne */
  public Customer getCustomer()
  {
    return customer;
  }

  public boolean hasCustomer()
  {
    boolean has = customer != null;
    return has;
  }
  /* Code from template association_GetOne */
  public Vendor getVendor()
  {
    return vendor;
  }

  public boolean hasVendor()
  {
    boolean has = vendor != null;
    return has;
  }
  /* Code from template association_GetOne */
  public Product getProduct()
  {
    return product;
  }
  /* Code from template association_GetOne */
  public SystemManager getSystemManager()
  {
    return systemManager;
  }

  public boolean hasSystemManager()
  {
    boolean has = systemManager != null;
    return has;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setCustomer(Customer aCustomer)
  {
    boolean wasSet = false;
    Customer existingCustomer = customer;
    customer = aCustomer;
    if (existingCustomer != null && !existingCustomer.equals(aCustomer))
    {
      existingCustomer.removeOrder(this);
    }
    if (aCustomer != null)
    {
      aCustomer.addOrder(this);
    }
    wasSet = true;
    return wasSet;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setVendor(Vendor aVendor)
  {
    boolean wasSet = false;
    Vendor existingVendor = vendor;
    vendor = aVendor;
    if (existingVendor != null && !existingVendor.equals(aVendor))
    {
      existingVendor.removeOrder(this);
    }
    if (aVendor != null)
    {
      aVendor.addOrder(this);
    }
    wasSet = true;
    return wasSet;
  }
  /* Code from template association_SetUnidirectionalOne */
  public boolean setProduct(Product aNewProduct)
  {
    boolean wasSet = false;
    if (aNewProduct != null)
    {
      product = aNewProduct;
      wasSet = true;
    }
    return wasSet;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    boolean wasSet = false;
    SystemManager existingSystemManager = systemManager;
    systemManager = aSystemManager;
    if (existingSystemManager != null && !existingSystemManager.equals(aSystemManager))
    {
      existingSystemManager.removeOrder(this);
    }
    if (aSystemManager != null)
    {
      aSystemManager.addOrder(this);
    }
    wasSet = true;
    return wasSet;
  }

  public void delete()
  {
    if (customer != null)
    {
      Customer placeholderCustomer = customer;
      this.customer = null;
      placeholderCustomer.removeOrder(this);
    }
    if (vendor != null)
    {
      Vendor placeholderVendor = vendor;
      this.vendor = null;
      placeholderVendor.removeOrder(this);
    }
    product = null;
    if (systemManager != null)
    {
      SystemManager placeholderSystemManager = systemManager;
      this.systemManager = null;
      placeholderSystemManager.removeOrder(this);
    }
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi.withMethods;
import java.util.*;
import java.lang.Thread;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface IMicrowaveImpl extends java.rmi.Remote
{
  public int getHashCodeImpl() throws RemoteException;
  public boolean setLightOnImpl(boolean aLightOn) throws RemoteException;
  public boolean setPowerTubeOnImpl(boolean aPowerTubeOn) throws RemoteException;
  public boolean setIsDoorOpenedImpl(boolean aIsDoorOpened) throws RemoteException;
  public boolean setIsButtonPressedImpl(boolean aIsButtonPressed) throws RemoteException;
  public boolean getLightOnImpl() throws RemoteException;
  public boolean getPowerTubeOnImpl() throws RemoteException;
  public boolean getIsDoorOpenedImpl() throws RemoteException;
  public boolean getIsButtonPressedImpl() throws RemoteException;
  public boolean _doorOpenedImpl() throws RemoteException;
  public boolean _buttonPressedImpl() throws RemoteException;
  public boolean _doorClosedImpl() throws RemoteException;
  public void deleteImpl() throws RemoteException;
  public void doorOpenedImpl() throws RemoteException;
  public void buttonPressedImpl() throws RemoteException;
  public void doorClosedImpl() throws RemoteException;
  public void runImpl() throws RemoteException;
   public void turnLightOnImpl(boolean on) throws RemoteException;
   public void energizePowerTubeImpl(boolean on) throws RemoteException;
   public void turnOffImpl() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface IVendorImpl extends java.rmi.Remote, IAgentImpl
{
  public int getHashCodeImpl() throws RemoteException;
  public Order getOrderImpl(int index) throws RemoteException;
  public List<Order> getOrdersImpl() throws RemoteException;
  public int numberOfOrdersImpl() throws RemoteException;
  public boolean hasOrdersImpl() throws RemoteException;
  public int indexOfOrderImpl(Order aOrder) throws RemoteException;
  public Customer getCustomerImpl(int index) throws RemoteException;
  public List<Customer> getCustomersImpl() throws RemoteException;
  public int numberOfCustomersImpl() throws RemoteException;
  public boolean hasCustomersImpl() throws RemoteException;
  public int indexOfCustomerImpl(Customer aCustomer) throws RemoteException;
  public boolean addOrderImpl(Order aOrder) throws RemoteException;
  public boolean removeOrderImpl(Order aOrder) throws RemoteException;
  public boolean addOrderAtImpl(Order aOrder, int index) throws RemoteException;
  public boolean addOrMoveOrderAtImpl(Order aOrder, int index) throws RemoteException;
  public boolean addCustomerImpl(Customer aCustomer) throws RemoteException;
  public boolean removeCustomerImpl(Customer aCustomer) throws RemoteException;
  public boolean addCustomerAtImpl(Customer aCustomer, int index) throws RemoteException;
  public boolean addOrMoveCustomerAtImpl(Customer aCustomer, int index) throws RemoteException;
  public void deleteImpl() throws RemoteException;
   public Product findProductImpl(ProductType productType) throws RemoteException;
   public Order makeOrderImpl(Customer aCustomer, Product aProduct) throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi2;
import java.io.Serializable;

// line 3 "../../Class_DistributableRMI2.ump"
public class ClientImpl extends CC implements java.io.Serializable , IClientImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public ClientImpl()
  {
    super();
  }
  //------------------------
  // Reference to the proxy
  //------------------------
  Client self;
  
  public void setSelf(Client proxy)
  {
    self=proxy;
  }

  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCode()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public void delete()
  {
    super.delete();
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

// line 34 "../ecommerceRMI1.ump"
public class AgentImpl implements java.io.Serializable , IAgentImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //AgentImpl Attributes
  private String name;

  //AgentImpl Associations
  private List<Warehouse> warehouses;
  private SystemManager systemManager;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public AgentImpl(String aName)
  {
    name = aName;
    warehouses = new ArrayList<Warehouse>();
  }
  //------------------------
  // Reference to the proxy
  //------------------------
  Agent self;
  
  public void setSelf(Agent proxy)
  {
    self=proxy;
  }

  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCode()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public boolean setName(String aName)
  {
    boolean wasSet = false;
    name = aName;
    wasSet = true;
    return wasSet;
  }

  public String getName()
  {
    return name;
  }
  /* Code from template association_GetMany */
  public Warehouse getWarehous(int index)
  {
    Warehouse aWarehous = warehouses.get(index);
    return aWarehous;
  }

  public List<Warehouse> getWarehouses()
  {
    List<Warehouse> newWarehouses = Collections.unmodifiableList(warehouses);
    return newWarehouses;
  }

  public int numberOfWarehouses()
  {
    int number = warehouses.size();
    return number;
  }

  public boolean hasWarehouses()
  {
    boolean has = warehouses.size() > 0;
    return has;
  }

  public int indexOfWarehous(Warehouse aWarehous)
  {
    int index = warehouses.indexOf(aWarehous);
    return index;
  }
  /* Code from template association_GetOne */
  public SystemManager getSystemManager()
  {
    return systemManager;
  }

  public boolean hasSystemManager()
  {
    boolean has = systemManager != null;
    return has;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfWarehouses()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addWarehous(Warehouse aWarehous)
  {
    boolean wasAdded = false;
    if (warehouses.contains(aWarehous)) { return false; }
    warehouses.add(aWarehous);
    if (aWarehous.indexOfAgent(self) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aWarehous.addAgent(self);
      if (!wasAdded)
      {
        warehouses.remove(aWarehous);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeWarehous(Warehouse aWarehous)
  {
    boolean wasRemoved = false;
    if (!warehouses.contains(aWarehous))
    {
      return wasRemoved;
    }

    int oldIndex = warehouses.indexOf(aWarehous);
    warehouses.remove(oldIndex);
    if (aWarehous.indexOfAgent(self) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aWarehous.removeAgent(self);
      if (!wasRemoved)
      {
        warehouses.add(oldIndex,aWarehous);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addWarehousAt(Warehouse aWarehous, int index)
  {  
    boolean wasAdded = false;
    if(addWarehous(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index)
  {
    boolean wasAdded = false;
    if(warehouses.contains(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addWarehousAt(aWarehous, index);
    }
    return wasAdded;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    boolean wasSet = false;
    SystemManager existingSystemManager = systemManager;
    systemManager = aSystemManager;
    if (existingSystemManager != null && !existingSystemManager.equals(aSystemManager))
    {
      existingSystemManager.removeAgent(self);
    }
    if (aSystemManager != null)
    {
      aSystemManager.addAgent(self);
    }
    wasSet = true;
    return wasSet;
  }

  public void delete()
  {
    ArrayList<Warehouse> copyOfWarehouses = new ArrayList<Warehouse>(warehouses);
    warehouses.clear();
    for(Warehouse aWarehous : copyOfWarehouses)
    {
      aWarehous.removeAgent(self);
    }
    if (systemManager != null)
    {
      SystemManager placeholderSystemManager = systemManager;
      this.systemManager = null;
      placeholderSystemManager.removeAgent(self);
    }
  }


  public String toString()
  {
    return super.toString() + "["+
            "name" + ":" + getName()+ "]" + System.getProperties().getProperty("line.separator") +
            "  " + "systemManager = "+(getSystemManager()!=null?Integer.toHexString(System.identityHashCode(getSystemManager())):"null");
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi3;
import java.io.Serializable;

import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
public class ClientRemote extends CCRemote implements IClientImpl
{
  Client realObject;
  public void setRealObject(Client aObject)
  {
    realObject=aObject;
  }
  public ClientRemote()
  {}
  public ClientRemote(Client aObject)
  {
    super(aObject);
    realObject=aObject;
  }
  public int getHashCodeImpl()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void deleteImpl()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi4;
import java.io.Serializable;

// line 3 "../../Class_DistributableRMI4.ump"
public class CC extends Father
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public CC()
  {
    super();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public void delete()
  {
    super.delete();
  }

  // line 7 "../../Class_DistributableRMI4.ump"
   public void someMethod1(){
    
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface ISupplierImpl extends java.rmi.Remote, IAgentImpl
{
  public int getHashCodeImpl() throws RemoteException;
  public Product getProductImpl(int index) throws RemoteException;
  public List<Product> getProductsImpl() throws RemoteException;
  public int numberOfProductsImpl() throws RemoteException;
  public boolean hasProductsImpl() throws RemoteException;
  public int indexOfProductImpl(Product aProduct) throws RemoteException;
  public boolean addProductImpl(Product aProduct) throws RemoteException;
  public boolean removeProductImpl(Product aProduct) throws RemoteException;
  public boolean addProductAtImpl(Product aProduct, int index) throws RemoteException;
  public boolean addOrMoveProductAtImpl(Product aProduct, int index) throws RemoteException;
  public void deleteImpl() throws RemoteException;
   public Product createProductImpl(String serialNumber, String productType) throws RemoteException;
   public void putInWarehouseImpl(Product aProduct, Warehouse warehouse) throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi.withMethods;
import java.util.*;
import java.lang.Thread;
import java.io.Serializable;

// line 2 "../../../Class_DistributableRMI_WithMethods.ump"
public class Microwave implements java.io.Serializable, IMicrowaveImpl, Runnable
{

  //------------------------
  // STATIC VARIABLES
  //------------------------

  public static final int TimeIncrementMs = 1000;

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Microwave Attributes
  private  transient boolean lightOn;
  private  transient boolean powerTubeOn;
  private  transient boolean isDoorOpened;
  private  transient boolean isButtonPressed;

  //Microwave State Machines
  public enum OperatingMicrowaveStateMachine { readyToCook, doorOpen, cooking, cookingInterrupted, cookingComplete, cookingExtended }
  private transient  OperatingMicrowaveStateMachine operatingMicrowaveStateMachine;
  
  //enumeration type of messages accepted by Microwave
  protected enum MessageType { doorOpened_M, buttonPressed_M, doorClosed_M }
  
  MessageQueue queue;
  Thread removal;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Microwave(UmpleRuntime.UmpleComponent umpleComponent)
  {
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Microwave.class)
        UmpleRuntime.getInstance().newMicrowave( umpleComponent, this);

      return;
    }
    else
    {
      UmpleRuntime.getInstance().newMicrowave(this);
    }

    lightOn = false;
    powerTubeOn = false;
    isDoorOpened = false;
    isButtonPressed = false;
    setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.readyToCook);
    queue = new MessageQueue();
    removal=new Thread(this);
    //start the thread of Microwave
    removal.start();
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public boolean setLightOnImpl(boolean aLightOn)
  {
    boolean wasSet = false;
    lightOn = aLightOn;
    wasSet = true;
    return wasSet;
  }

  public boolean setPowerTubeOnImpl(boolean aPowerTubeOn)
  {
    boolean wasSet = false;
    powerTubeOn = aPowerTubeOn;
    wasSet = true;
    return wasSet;
  }

  public boolean setIsDoorOpenedImpl(boolean aIsDoorOpened)
  {
    boolean wasSet = false;
    isDoorOpened = aIsDoorOpened;
    wasSet = true;
    return wasSet;
  }

  public boolean setIsButtonPressedImpl(boolean aIsButtonPressed)
  {
    boolean wasSet = false;
    isButtonPressed = aIsButtonPressed;
    wasSet = true;
    return wasSet;
  }

  public boolean getLightOnImpl()
  {
    return lightOn;
  }

  public boolean getPowerTubeOnImpl()
  {
    return powerTubeOn;
  }

  public boolean getIsDoorOpenedImpl()
  {
    return isDoorOpened;
  }

  public boolean getIsButtonPressedImpl()
  {
    return isButtonPressed;
  }

  public String getOperatingMicrowaveStateMachineFullName()
  {
    String answer = operatingMicrowaveStateMachine.toString();
    return answer;
  }

  public OperatingMicrowaveStateMachine getOperatingMicrowaveStateMachine()
  {
    return operatingMicrowaveStateMachine;
  }

  public boolean _doorOpenedImpl()
  {
    boolean wasEventProcessed = false;
    
    OperatingMicrowaveStateMachine aOperatingMicrowaveStateMachine = operatingMicrowaveStateMachine;
    switch (aOperatingMicrowaveStateMachine)
    {
      case readyToCook:
        // line 16 "../../../Class_DistributableRMI_WithMethods.ump"
        setIsDoorOpened(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.doorOpen);
        wasEventProcessed = true;
        break;
      case cooking:
        // line 38 "../../../Class_DistributableRMI_WithMethods.ump"
        setIsDoorOpened(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cookingInterrupted);
        wasEventProcessed = true;
        break;
      case cookingComplete:
        // line 49 "../../../Class_DistributableRMI_WithMethods.ump"
        setIsDoorOpened(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.doorOpen);
        wasEventProcessed = true;
        break;
      case cookingExtended:
        // line 58 "../../../Class_DistributableRMI_WithMethods.ump"
        setIsDoorOpened(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cookingInterrupted);
        wasEventProcessed = true;
        break;
      default:
        // Other states do respond to this event
    }

    return wasEventProcessed;
  }

  public boolean _buttonPressedImpl()
  {
    boolean wasEventProcessed = false;
    
    OperatingMicrowaveStateMachine aOperatingMicrowaveStateMachine = operatingMicrowaveStateMachine;
    switch (aOperatingMicrowaveStateMachine)
    {
      case readyToCook:
        // line 17 "../../../Class_DistributableRMI_WithMethods.ump"
        setIsButtonPressed(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cooking);
        wasEventProcessed = true;
        break;
      case cooking:
        // line 39 "../../../Class_DistributableRMI_WithMethods.ump"
        setIsButtonPressed(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cookingExtended);
        wasEventProcessed = true;
        break;
      case cookingComplete:
        // line 50 "../../../Class_DistributableRMI_WithMethods.ump"
        setIsButtonPressed(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cooking);
        wasEventProcessed = true;
        break;
      case cookingExtended:
        // line 59 "../../../Class_DistributableRMI_WithMethods.ump"
        setIsButtonPressed(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cookingExtended);
        wasEventProcessed = true;
        break;
      default:
        // Other states do respond to this event
    }

    return wasEventProcessed;
  }

  public boolean _doorClosedImpl()
  {
    boolean wasEventProcessed = false;
    
    OperatingMicrowaveStateMachine aOperatingMicrowaveStateMachine = operatingMicrowaveStateMachine;
    switch (aOperatingMicrowaveStateMachine)
    {
      case doorOpen:
        // line 25 "../../../Class_DistributableRMI_WithMethods.ump"
        setIsDoorOpened(false);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.readyToCook);
        wasEventProcessed = true;
        break;
      case cookingInterrupted:
        // line 44 "../../../Class_DistributableRMI_WithMethods.ump"
        setIsDoorOpened(false);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.readyToCook);
        wasEventProcessed = true;
        break;
      default:
        // Other states do respond to this event
    }

    return wasEventProcessed;
  }

  private void setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine aOperatingMicrowaveStateMachine)
  {
    operatingMicrowaveStateMachine = aOperatingMicrowaveStateMachine;

    // entry actions and do activities
    switch(operatingMicrowaveStateMachine)
    {
      case readyToCook:
        // line 12 "../../../Class_DistributableRMI_WithMethods.ump"
        // turn off light
        turnOff();
        break;
      case doorOpen:
        // line 21 "../../../Class_DistributableRMI_WithMethods.ump"
        // turn on light
        turnLightOn(true);
        break;
      case cooking:
        // line 29 "../../../Class_DistributableRMI_WithMethods.ump"
        // turn on light
        turnLightOn(true);
        // energize power tube
        energizePowerTube(true);
        //release a button
        setIsButtonPressed(false);
        break;
      case cookingInterrupted:
        // line 43 "../../../Class_DistributableRMI_WithMethods.ump"
        turnOff();
        break;
      case cookingComplete:
        // line 48 "../../../Class_DistributableRMI_WithMethods.ump"
        turnOff();
        break;
      case cookingExtended:
        // line 54 "../../../Class_DistributableRMI_WithMethods.ump"
        //release a button
        setIsButtonPressed(false);
        break;
    }
  }

  public void deleteImpl()
  {
    removal.interrupt();
  }

  protected class Message
  {
    MessageType type;
    
    //Message parameters
    Vector<Object> param;
    
    public Message(MessageType t, Vector<Object> p)
    {
      type = t; 
      param = p;
    }

    @Override
    public String toString()
    {
      return type + "," + param;
    }
  }
  
  protected class MessageQueue {
    Queue<Message> messages = new LinkedList<Message>();
    
    public synchronized void put(Message m)
    {
      messages.add(m); 
      notify();
    }

    public synchronized Message getNext()
    {
      try {
        while (messages.isEmpty()) 
        {
          wait();
        }
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return null;
      }

      //The element to be removed
      Message m = messages.remove(); 
      return (m);
    }
  }

  //------------------------------
  //messages accepted 
  //------------------------------

  public void doorOpenedImpl()
  {
    queue.put(new Message(MessageType.doorOpened_M, null));
  }

  public void buttonPressedImpl()
  {
    queue.put(new Message(MessageType.buttonPressed_M, null));
  }

  public void doorClosedImpl()
  {
    queue.put(new Message(MessageType.doorClosed_M, null));
  }

  
  @Override
  public void runImpl()
  {
    boolean status=false;
    while (true) 
    {
      Message m = queue.getNext();
      if(m == null)  return;
      
      switch (m.type)
      {
        case doorOpened_M:
          status = _doorOpened();
          break;
        case buttonPressed_M:
          status = _buttonPressed();
          break;
        case doorClosed_M:
          status = _doorClosed();
          break; 
        default:
      }
      if(!status)
      {
        // Error message is written or  exception is raised
      }
    }
  }

  /**
   * turn on light
   */
  // line 66 "../../../Class_DistributableRMI_WithMethods.ump"
   public void turnLightOnImpl(boolean on){
    System.out.println("turns the light "+ (on ? "on" : "off"));
    System.out.println("light " + (on ? "on" : "off"));
    setLightOn(on);
  }


  /**
   * energize/deenergize power tube
   */
  // line 73 "../../../Class_DistributableRMI_WithMethods.ump"
   public void energizePowerTubeImpl(boolean on){
    System.out.println("energizes/deenergize the power tube");
    System.out.println("power tube " + (on ? "on" : "off"));
    setPowerTubeOn(on);
  }

  // line 79 "../../../Class_DistributableRMI_WithMethods.ump"
   public void turnOffImpl(){
    // turn off light
    turnLightOn(false);
    //release button
    setIsButtonPressed(false);
    // de-energize power tube
    energizePowerTube(false);
  }

  // line 87 "../../../Class_DistributableRMI_WithMethods.ump"
   public static  void someMethod(){
    
  }


  public String toString()
  {
    return super.toString() + "["+
            "lightOn" + ":" + getLightOn()+ "," +
            "powerTubeOn" + ":" + getPowerTubeOn()+ "," +
            "isDoorOpened" + ":" + getIsDoorOpened()+ "," +
            "isButtonPressed" + ":" + getIsButtonPressed()+ "]";
  }
  public void setRealObject(IMicrowaveImpl aObject)
  {
    realObject=aObject;
  }

  transient IMicrowaveImpl realObject=this;
  public Microwave()
  {

this(UmpleRuntime.getComponent("Microwave"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setLightOn(boolean aLightOn)
  {
    while(true)
      try{
        return realObject.setLightOnImpl(aLightOn);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setPowerTubeOn(boolean aPowerTubeOn)
  {
    while(true)
      try{
        return realObject.setPowerTubeOnImpl(aPowerTubeOn);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setIsDoorOpened(boolean aIsDoorOpened)
  {
    while(true)
      try{
        return realObject.setIsDoorOpenedImpl(aIsDoorOpened);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setIsButtonPressed(boolean aIsButtonPressed)
  {
    while(true)
      try{
        return realObject.setIsButtonPressedImpl(aIsButtonPressed);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getLightOn()
  {
    while(true)
      try{
        return realObject.getLightOnImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getPowerTubeOn()
  {
    while(true)
      try{
        return realObject.getPowerTubeOnImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getIsDoorOpened()
  {
    while(true)
      try{
        return realObject.getIsDoorOpenedImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getIsButtonPressed()
  {
    while(true)
      try{
        return realObject.getIsButtonPressedImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean _doorOpened()
  {
    while(true)
      try{
        return realObject._doorOpenedImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean _buttonPressed()
  {
    while(true)
      try{
        return realObject._buttonPressedImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean _doorClosed()
  {
    while(true)
      try{
        return realObject._doorClosedImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void doorOpened ()
  {
    while(true)
      try{
        realObject.doorOpenedImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void buttonPressed ()
  {
    while(true)
      try{
        realObject.buttonPressedImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void doorClosed ()
  {
    while(true)
      try{
        realObject.doorClosedImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void run ()
  {
    while(true)
      try{
        realObject.runImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void turnLightOn(boolean on)
  {
    while(true)
      try{
        realObject.turnLightOnImpl(on);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void energizePowerTube(boolean on)
  {
    while(true)
      try{
        realObject.energizePowerTubeImpl(on);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void turnOff()
  {
    while(true)
      try{
        realObject.turnOffImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  protected  IMicrowaveImpl remoteObject;  
  public void setRemoteObject(IMicrowaveImpl aRemoteObject)
  {
    remoteObject=aRemoteObject;
  }
  public IMicrowaveImpl getRemoteObject()
  {
    return (IMicrowaveImpl)remoteObject;
  }
  private void readObject(java.io.ObjectInputStream in) throws Exception
  {
    try
    {
      in.defaultReadObject();
      realObject=(IMicrowaveImpl)remoteObject;
    }
    catch(Exception e)
    {
      throw e;
    }
    
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Microwave)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/
package ecommerceWS;
import ecommerceWS.Warehouse;
import ecommerceWS.Customer;
import java.net.URL;
import ecommerceWS.SystemManager;
import javax.xml.ws.Service;
import ecommerceWS.Vendor;
import java.util.regex.Matcher;
import javax.jws.soap.SOAPBinding;
import javax.xml.ws.Endpoint;
import javax.xml.bind.annotation.*;
import ecommerceWS.Agent;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.Unmarshaller;
import java.util.Properties;
import java.io.*;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import ecommerceWS.Supplier;
import javax.jws.WebMethod;
import java.util.*;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.namespace.QName;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.Pattern;
import java.io.InputStream;
@WebService(endpointInterface = "ecommerceWS.IUmpleRuntime")
public class UmpleRuntime implements IUmpleRuntime
{ 
  private static Boolean isAlive = true;
  static int thisNodeId=-1;
  private int numberOfNodes=0;
  private static String fileAddress="";
  static HashMap<Integer, UmpleNode> nodes=new HashMap<Integer, UmpleNode>();
  static HashMap <String, UmpleComponent> components= new HashMap<String, UmpleComponent>();
  public static void setFileAddress(String address)
  {
    fileAddress=address;
  }
  public static int getThisNodeId()
  {
    return thisNodeId;
  }
    private static void setThisNodeId(int id)
  {
    thisNodeId=id;
  }  


  private static void readPropertiesFile()
  {
      String location="configuration.txt";
      Properties prop = new Properties();
      InputStream input = null;

    try {

      input = new FileInputStream("node.properties");
      prop.load(input);
      if(getThisNodeId()<0)
        setThisNodeId(Integer.parseInt(prop.getProperty("name")));
      location=prop.getProperty("location");
      setFileAddress(location);
    } catch (IOException e)
    {
      e.printStackTrace();
      if(getThisNodeId()<0)
        setThisNodeId(0); 
      setFileAddress(location);   
    } 
    finally {
      if (input != null) {
        try {
          input.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
  public static UmpleComponent getComponent(String runtimeComponentName)
  {
    getInstance();
    UmpleComponent aComponent=components.get(runtimeComponentName.toLowerCase());
    if (aComponent!=null)
      return aComponent;
    else
      return components.get("local");  
  }

  public static void stopAll()
  {
    UmpleRuntime.getInstance().stopAllNodes();
  }
  public void stopAllNodes()
  {
    for(int node=0;node<numberOfNodes;node=node+1)
    {
      if(node!=getThisNodeId())
      {
        try
        {
          remoteFactories.get(node).stopNode();
        }
        catch(Exception e) {System.err.println(e.toString());}
      } 
    }
    stopNode(); 
  }
// ******************************** Factory
    public static UmpleRuntime theInstance = null;
    List<IUmpleRuntime> remoteFactories;

    public List<Object> listOfObjects;
    public List<Endpoint> listOfEndpoints;
    private Endpoint thisEndpoint;
    public static UmpleRuntime getInstance()
    {
      if(theInstance==null){
        theInstance = new UmpleRuntime();
        }
      return theInstance;
    }
   
    private UmpleRuntime()
    { 
      listOfEndpoints=new ArrayList<Endpoint>();
      listOfObjects=new ArrayList<Object>();
      remoteFactories= new ArrayList<IUmpleRuntime>();
      initialize();
    }
    public int getNodeId(int umpleNodeId)
    {
      int nodeId=umpleNodeId;
      if(nodeId>=numberOfNodes)
        nodeId=numberOfNodes-1;
      return nodeId;
    }
    public int getNodeId(UmpleComponent umpleComponent)
    {
      return umpleComponent.getNode().getId();
    }

    private void readConfigFile()
    {
      String input="{id=0; port=1099; https://localhost {component1}}{id=1; port=1700; https://localhost {component2}}";
      try (BufferedReader br = new BufferedReader(new FileReader(fileAddress))) {
        input="";
        String line;
        while ((line = br.readLine()) != null) {
           // Merging the lines
          input+=line+";";
        }
      }
      catch (IOException e)
      {
        e.printStackTrace();   
      }
      finally {
        if (input != null)
        {
          int startIndex=input.indexOf("{");
          if(startIndex>=0)
          //while(startIndex>=0)
          { 
            Pattern pattern1 = Pattern.compile("([\\{|\\(])([^\\}\\)]+)([\\{|\\(])");
            Pattern pattern2 = Pattern.compile("([\\}|\\)])([^\\{\\(]+)([\\}|\\)])");
            Pattern pattern3 = Pattern.compile("([\\{|\\(])([^\\{\\(\\}\\)]+)([\\}|\\)])");
            Pattern patternURL = Pattern.compile("(url)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)");
            Pattern patternName = Pattern.compile("(id)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)");
            Pattern patternPort = Pattern.compile("(port)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)"); 
            Pattern patternIp = Pattern.compile("(ip)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)"); 
            Pattern patternComponent = Pattern.compile("(\\s*)([^;,\\s]*)(\\s*)([,|;|\\r\\n|\\t])");                 
            Matcher matcher1 = pattern1.matcher(input); 
            Matcher matcher2 = pattern2.matcher(input);
            Matcher matcher3 = pattern3.matcher(input);
            String url="";
            String ip="";
            String name="";
            int port=1111;
            String part1="";
            String part2="";
            String part3="";
            String runtimeComponents="";
            String machine="";
            Boolean condition1=matcher1.find();
            Boolean condition2=matcher2.find();
            Boolean condition3=matcher3.find();
            while (condition1||condition2||condition3) 
            { 
              url="https://localhost";
              ip="localhost";
              name="";
              port=1111;
              part1="";
              part2="";
              part3="";
              runtimeComponents="";
              machine="";
              if(condition1)
                part1=matcher1.group(2);
              if(condition2)
                part2=matcher2.group(2);
              if(condition3)
                part3=matcher3.group(2);
              
              if(condition1&&matcher3.end()>matcher1.end())
              {
                machine=part1.toLowerCase()+part2.toLowerCase();
                runtimeComponents=part3.toLowerCase()+";";
                condition1=matcher1.find();
                condition2=matcher2.find();
                condition3=matcher3.find();
              }else
              {
                machine=part3.toLowerCase();
                condition3=matcher3.find();
              }
              Matcher matcherURL = patternURL.matcher(machine);
              if(matcherURL.find())
                url=matcherURL.group(3);

              Matcher matcherName = patternName.matcher(machine);
              if(matcherName.find())
                name=matcherName.group(3);

              Matcher matcherIp = patternIp.matcher(machine);
              if(matcherIp.find())
                ip=matcherIp.group(3);

              Matcher matcherPort = patternPort.matcher(machine);
              if(matcherPort.find())
                port=Integer.parseInt(matcherPort.group(3));
              UmpleNode aNode= new UmpleNode(Integer.parseInt(name));
              Matcher matcherComponent = patternComponent.matcher(runtimeComponents);
              while(matcherComponent.find())
              { String component=matcherComponent.group(2);
                UmpleComponent aComponent=new UmpleComponent(component,aNode);
                components.put(component,aComponent);
              }
              if(aNode.getId()==getThisNodeId())
              {
                UmpleComponent aComponent=new UmpleComponent("local",aNode);
                components.put("local",aComponent);
              }
              aNode.setPort(port);
              aNode.setUrl(url);
              aNode.setIp(ip);
              nodes.put(aNode.getId(),aNode);
            }
          }      
        }    
      }
    }
    public void initialize()
    {    
      if(fileAddress.equals(""))
        readPropertiesFile();
      readConfigFile();
      numberOfNodes= nodes.size();
      thisEndpoint=Endpoint.create(this);
      thisEndpoint.publish(nodes.get(getThisNodeId()).getUrl()+":"+String.valueOf(nodes.get(getThisNodeId()).getPort())+"/UmpleRuntime");

      for(int node=0;node<numberOfNodes;node=node+1)
      {
        if(node==getThisNodeId())
        {
          remoteFactories.add(this);
        }
        else
        {
          System.out.println("connecting to node: "+node);
          while(true)
          {
            try 
            {
              URL url = new URL(nodes.get(node).getUrl()+":"+String.valueOf(nodes.get(node).getPort())+"/UmpleRuntime?wsdl");
             
              QName qname = new QName("https://ecommerceWS/",
                  "UmpleRuntimeService");
              Service service = Service.create(url, qname);
              IUmpleRuntime proxy = service.getPort(IUmpleRuntime.class);
              remoteFactories.add(proxy);
              break;
            } 
            catch (Exception e) 
            {
              System.err.println("Client exception: " + e.toString());
              e.printStackTrace();
              try { Thread.sleep(5000); } catch (InterruptedException interruptedException) {};
            }
          } 
        } 
      }
    }
    public void stopNode()
    {
      System.out.println("stopping node");
      for(Endpoint e: listOfEndpoints)
      {
        e.stop();
      }
      thisEndpoint.stop();
      isAlive=false;
    }
    
  
  public void newWarehouse(String aName, UmpleRuntime.UmpleComponent component,Warehouse object)
  {

      while(true){
        try
        {
          Warehouse proxyObject = remoteFactories.get(getNodeId(component)).createWarehouse(aName);
          object.remoteUrl=proxyObject.remoteUrl;
          object.remotePort=proxyObject.remotePort;
          object.objectId=proxyObject.objectId;
          object.setRealObject(proxyObject.realObject);
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newWarehouse(Warehouse object){
    listOfObjects.add(object);
        object.remoteUrl=nodes.get(getThisNodeId()).getUrl();
        object.remotePort=String.valueOf(nodes.get(getThisNodeId()).getPort());
        object.objectId=object.getClass().getName()+String.valueOf(object.getHashCodeImpl());
        object.setRealObject(object);
        Endpoint e=Endpoint.create(object);
        e.publish(object.remoteUrl+":"+object.remotePort+"/"+object.getClass().getSimpleName()+object.objectId);
        listOfEndpoints.add(e);  
    }
    
  @WebMethod
synchronized public Warehouse createWarehouse(String aName)
    {
    Warehouse object= new Warehouse(aName,  UmpleRuntime.getComponent("local"));
    return object;
    }

  
  public void newAgent(String aName, UmpleRuntime.UmpleComponent component,Agent object)
  {

      while(true){
        try
        {
          Agent proxyObject = remoteFactories.get(getNodeId(component)).createAgent(aName);
          object.remoteUrl=proxyObject.remoteUrl;
          object.remotePort=proxyObject.remotePort;
          object.objectId=proxyObject.objectId;
          object.setRealObject(proxyObject.realObject);
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newAgent(Agent object){
    listOfObjects.add(object);
        object.remoteUrl=nodes.get(getThisNodeId()).getUrl();
        object.remotePort=String.valueOf(nodes.get(getThisNodeId()).getPort());
        object.objectId=object.getClass().getName()+String.valueOf(object.getHashCodeImpl());
        object.setRealObject(object);
        Endpoint e=Endpoint.create(object);
        e.publish(object.remoteUrl+":"+object.remotePort+"/"+object.getClass().getSimpleName()+object.objectId);
        listOfEndpoints.add(e);  
    }
    
  @WebMethod
synchronized public Agent createAgent(String aName)
    {
    Agent object= new Agent(aName,  UmpleRuntime.getComponent("local"));
    return object;
    }

  
  public void newSupplier(String aName, UmpleRuntime.UmpleComponent component,Supplier object)
  {

      while(true){
        try
        {
          Supplier proxyObject = remoteFactories.get(getNodeId(component)).createSupplier(aName);
          object.remoteUrl=proxyObject.remoteUrl;
          object.remotePort=proxyObject.remotePort;
          object.objectId=proxyObject.objectId;
          object.setRealObject(proxyObject.realObject);
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newSupplier(Supplier object){
    listOfObjects.add(object);
        object.remoteUrl=nodes.get(getThisNodeId()).getUrl();
        object.remotePort=String.valueOf(nodes.get(getThisNodeId()).getPort());
        object.objectId=object.getClass().getName()+String.valueOf(object.getHashCodeImpl());
        object.setRealObject(object);
        Endpoint e=Endpoint.create(object);
        e.publish(object.remoteUrl+":"+object.remotePort+"/"+object.getClass().getSimpleName()+object.objectId);
        listOfEndpoints.add(e);  
    }
    
  @WebMethod
synchronized public Supplier createSupplier(String aName)
    {
    Supplier object= new Supplier(aName,  UmpleRuntime.getComponent("local"));
    return object;
    }

  
  public void newVendor(String aName, UmpleRuntime.UmpleComponent component,Vendor object)
  {

      while(true){
        try
        {
          Vendor proxyObject = remoteFactories.get(getNodeId(component)).createVendor(aName);
          object.remoteUrl=proxyObject.remoteUrl;
          object.remotePort=proxyObject.remotePort;
          object.objectId=proxyObject.objectId;
          object.setRealObject(proxyObject.realObject);
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newVendor(Vendor object){
    listOfObjects.add(object);
        object.remoteUrl=nodes.get(getThisNodeId()).getUrl();
        object.remotePort=String.valueOf(nodes.get(getThisNodeId()).getPort());
        object.objectId=object.getClass().getName()+String.valueOf(object.getHashCodeImpl());
        object.setRealObject(object);
        Endpoint e=Endpoint.create(object);
        e.publish(object.remoteUrl+":"+object.remotePort+"/"+object.getClass().getSimpleName()+object.objectId);
        listOfEndpoints.add(e);  
    }
    
  @WebMethod
synchronized public Vendor createVendor(String aName)
    {
    Vendor object= new Vendor(aName,  UmpleRuntime.getComponent("local"));
    return object;
    }

  
  public void newCustomer(String aName, UmpleRuntime.UmpleComponent component,Customer object)
  {

      while(true){
        try
        {
          Customer proxyObject = remoteFactories.get(getNodeId(component)).createCustomer(aName);
          object.remoteUrl=proxyObject.remoteUrl;
          object.remotePort=proxyObject.remotePort;
          object.objectId=proxyObject.objectId;
          object.setRealObject(proxyObject.realObject);
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newCustomer(Customer object){
    listOfObjects.add(object);
        object.remoteUrl=nodes.get(getThisNodeId()).getUrl();
        object.remotePort=String.valueOf(nodes.get(getThisNodeId()).getPort());
        object.objectId=object.getClass().getName()+String.valueOf(object.getHashCodeImpl());
        object.setRealObject(object);
        Endpoint e=Endpoint.create(object);
        e.publish(object.remoteUrl+":"+object.remotePort+"/"+object.getClass().getSimpleName()+object.objectId);
        listOfEndpoints.add(e);  
    }
    
  @WebMethod
synchronized public Customer createCustomer(String aName)
    {
    Customer object= new Customer(aName,  UmpleRuntime.getComponent("local"));
    return object;
    }

  
  public void newSystemManager(UmpleRuntime.UmpleComponent component,SystemManager object)
  {

      while(true){
        try
        {
          SystemManager proxyObject = remoteFactories.get(getNodeId(component)).createSystemManager();
          object.remoteUrl=proxyObject.remoteUrl;
          object.remotePort=proxyObject.remotePort;
          object.objectId=proxyObject.objectId;
          object.setRealObject(proxyObject.realObject);
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newSystemManager(SystemManager object){
    listOfObjects.add(object);
        object.remoteUrl=nodes.get(getThisNodeId()).getUrl();
        object.remotePort=String.valueOf(nodes.get(getThisNodeId()).getPort());
        object.objectId=object.getClass().getName()+String.valueOf(object.getHashCodeImpl());
        object.setRealObject(object);
        Endpoint e=Endpoint.create(object);
        e.publish(object.remoteUrl+":"+object.remotePort+"/"+object.getClass().getSimpleName()+object.objectId);
        listOfEndpoints.add(e);  
    }
    
  @WebMethod
synchronized public SystemManager createSystemManager()
    {
    SystemManager object= SystemManager.getInstance(UmpleRuntime.getComponent("local"));
    return object;
    }

  public static void main (String [] args)
  {
    if (args.length>0){
      setThisNodeId(Integer.parseInt(args[0]));
      if (args.length>1)
        UmpleRuntime.setFileAddress(args[1]);
    }
     UmpleRuntime.getInstance();
    while(isAlive){
      try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
    }
  }
    public class UmpleNode
    {
      //------------------------
      // MEMBER VARIABLES
      //------------------------
      private int id;
      private String ip="localhost";
      private String url="https://localhost";
      private int port=1098;
      //------------------------
      // CONSTRUCTOR
      //------------------------

      public UmpleNode(int aId)
      {
        id= aId;
      }

      //------------------------
      // INTERFACE
      //------------------------
      public boolean setId(int aId)
      {
        boolean wasSet = false;
        id = aId;
        wasSet = true;
        return wasSet;
      }

      public boolean setIp(String aIp)
      {
        boolean wasSet = false;
        ip = aIp;
        wasSet = true;
        return wasSet;
      }

      public boolean setUrl(String aUrl)
      {
        boolean wasSet = false;
        url = aUrl;
        wasSet = true;
        return wasSet;
      }

      public boolean setPort(int aPort)
      {
        boolean wasSet = false;
        port = aPort;
        wasSet = true;
        return wasSet;
      }
      public int getId()
      {
        return id;
      }
      public String getIp()
      {
        return ip;
      }

      public String getUrl()
      {
        return url;
      }

      public int getPort()
      {
        return port;
      }
      public String toString()
      {
        return super.toString() + "["+"id" + ":" + getId()+ "]";
      }
    }

    public class UmpleComponent
    {

      //------------------------
      // MEMBER VARIABLES
      //------------------------

      //UmpleComponent Attributes
      private int number=0;
      private String name;
      private UmpleNode node;
      //------------------------
      // CONSTRUCTOR
      //------------------------

      public UmpleComponent(String aName,UmpleNode aNode)
      {
        name=aName;
        node=aNode;
      }
      //------------------------
      // INTERFACE
      //------------------------

      public boolean setNumber(int aNumber)
      {
        boolean wasSet = false;
        number = aNumber;
        wasSet = true;
        return wasSet;
      }

      public boolean setName(String aName)
      {
        boolean wasSet = false;
        name = aName;
        wasSet = true;
        return wasSet;
      }
      public boolean setNode(UmpleNode aNode)
      {
        boolean wasSet = false;
        node = aNode;
        wasSet = true;
        return wasSet;
      }
      public UmpleNode getNode()
      {
        return node;
      }

      public int getNumber()
      {
        return number;
      }

      public String getName()
      {
        return name;
      }
      public boolean equals(Object object) {
          if(object instanceof UmpleComponent && ((UmpleComponent)object).getName() == this.name) {
              return true;
          } else {
              return false;
          }
      }      
    }  
}
 
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi.withMethods2;
import java.util.*;
import java.lang.Thread;

// line 3 "../../../Class_DistributableRMI_WithMethods2.ump"
public class MicrowaveImpl extends CCImpl implements java.io.Serializable , IMicrowaveImpl, Runnable
{

  //------------------------
  // STATIC VARIABLES
  //------------------------

  public static final int TimeIncrementMs = 1000;

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //MicrowaveImpl Attributes
  private boolean lightOn;
  private boolean powerTubeOn;
  private boolean isDoorOpened;
  private boolean isButtonPressed;

  //MicrowaveImpl State Machines
  public enum OperatingMicrowaveStateMachine { readyToCook, doorOpen, cooking, cookingInterrupted, cookingComplete, cookingExtended }
  private OperatingMicrowaveStateMachine operatingMicrowaveStateMachine;
  
  //enumeration type of messages accepted by MicrowaveImpl
  protected enum MessageType { doorOpened_M, buttonPressed_M, doorClosed_M }
  
  MessageQueue queue;
  Thread removal;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public MicrowaveImpl()
  {
    super();
    lightOn = false;
    powerTubeOn = false;
    isDoorOpened = false;
    isButtonPressed = false;
    setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.readyToCook);
    queue = new MessageQueue();
    removal=new Thread(this);
    //start the thread of MicrowaveImpl
    removal.start();
  }
  //------------------------
  // Reference to the proxy
  //------------------------
  Microwave self;
  
  public void setSelf(Microwave proxy)
  {
    super.setSelf(proxy);
    self=proxy;
  }

  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCode()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public boolean setLightOn(boolean aLightOn)
  {
    boolean wasSet = false;
    lightOn = aLightOn;
    wasSet = true;
    return wasSet;
  }

  public boolean setPowerTubeOn(boolean aPowerTubeOn)
  {
    boolean wasSet = false;
    powerTubeOn = aPowerTubeOn;
    wasSet = true;
    return wasSet;
  }

  public boolean setIsDoorOpened(boolean aIsDoorOpened)
  {
    boolean wasSet = false;
    isDoorOpened = aIsDoorOpened;
    wasSet = true;
    return wasSet;
  }

  public boolean setIsButtonPressed(boolean aIsButtonPressed)
  {
    boolean wasSet = false;
    isButtonPressed = aIsButtonPressed;
    wasSet = true;
    return wasSet;
  }

  public boolean getLightOn()
  {
    return lightOn;
  }

  public boolean getPowerTubeOn()
  {
    return powerTubeOn;
  }

  public boolean getIsDoorOpened()
  {
    return isDoorOpened;
  }

  public boolean getIsButtonPressed()
  {
    return isButtonPressed;
  }

  public String getOperatingMicrowaveStateMachineFullName()
  {
    String answer = operatingMicrowaveStateMachine.toString();
    return answer;
  }

  public OperatingMicrowaveStateMachine getOperatingMicrowaveStateMachine()
  {
    return operatingMicrowaveStateMachine;
  }

  public boolean _doorOpened()
  {
    boolean wasEventProcessed = false;
    
    OperatingMicrowaveStateMachine aOperatingMicrowaveStateMachine = operatingMicrowaveStateMachine;
    switch (aOperatingMicrowaveStateMachine)
    {
      case readyToCook:
        // line 16 "../../../Class_DistributableRMI_WithMethods2.ump"
        setIsDoorOpened(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.doorOpen);
        wasEventProcessed = true;
        break;
      case cooking:
        // line 38 "../../../Class_DistributableRMI_WithMethods2.ump"
        setIsDoorOpened(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cookingInterrupted);
        wasEventProcessed = true;
        break;
      case cookingComplete:
        // line 49 "../../../Class_DistributableRMI_WithMethods2.ump"
        setIsDoorOpened(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.doorOpen);
        wasEventProcessed = true;
        break;
      case cookingExtended:
        // line 58 "../../../Class_DistributableRMI_WithMethods2.ump"
        setIsDoorOpened(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cookingInterrupted);
        wasEventProcessed = true;
        break;
      default:
        // Other states do respond to this event
    }

    return wasEventProcessed;
  }

  public boolean _buttonPressed()
  {
    boolean wasEventProcessed = false;
    
    OperatingMicrowaveStateMachine aOperatingMicrowaveStateMachine = operatingMicrowaveStateMachine;
    switch (aOperatingMicrowaveStateMachine)
    {
      case readyToCook:
        // line 17 "../../../Class_DistributableRMI_WithMethods2.ump"
        setIsButtonPressed(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cooking);
        wasEventProcessed = true;
        break;
      case cooking:
        // line 39 "../../../Class_DistributableRMI_WithMethods2.ump"
        setIsButtonPressed(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cookingExtended);
        wasEventProcessed = true;
        break;
      case cookingComplete:
        // line 50 "../../../Class_DistributableRMI_WithMethods2.ump"
        setIsButtonPressed(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cooking);
        wasEventProcessed = true;
        break;
      case cookingExtended:
        // line 59 "../../../Class_DistributableRMI_WithMethods2.ump"
        setIsButtonPressed(true);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.cookingExtended);
        wasEventProcessed = true;
        break;
      default:
        // Other states do respond to this event
    }

    return wasEventProcessed;
  }

  public boolean _doorClosed()
  {
    boolean wasEventProcessed = false;
    
    OperatingMicrowaveStateMachine aOperatingMicrowaveStateMachine = operatingMicrowaveStateMachine;
    switch (aOperatingMicrowaveStateMachine)
    {
      case doorOpen:
        // line 25 "../../../Class_DistributableRMI_WithMethods2.ump"
        setIsDoorOpened(false);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.readyToCook);
        wasEventProcessed = true;
        break;
      case cookingInterrupted:
        // line 44 "../../../Class_DistributableRMI_WithMethods2.ump"
        setIsDoorOpened(false);
        setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine.readyToCook);
        wasEventProcessed = true;
        break;
      default:
        // Other states do respond to this event
    }

    return wasEventProcessed;
  }

  private void setOperatingMicrowaveStateMachine(OperatingMicrowaveStateMachine aOperatingMicrowaveStateMachine)
  {
    operatingMicrowaveStateMachine = aOperatingMicrowaveStateMachine;

    // entry actions and do activities
    switch(operatingMicrowaveStateMachine)
    {
      case readyToCook:
        // line 12 "../../../Class_DistributableRMI_WithMethods2.ump"
        // turn off light
        turnOff();
        break;
      case doorOpen:
        // line 21 "../../../Class_DistributableRMI_WithMethods2.ump"
        // turn on light
        turnLightOn(true);
        break;
      case cooking:
        // line 29 "../../../Class_DistributableRMI_WithMethods2.ump"
        // turn on light
        turnLightOn(true);
        // energize power tube
        energizePowerTube(true);
        //release a button
        setIsButtonPressed(false);
        break;
      case cookingInterrupted:
        // line 43 "../../../Class_DistributableRMI_WithMethods2.ump"
        turnOff();
        break;
      case cookingComplete:
        // line 48 "../../../Class_DistributableRMI_WithMethods2.ump"
        turnOff();
        break;
      case cookingExtended:
        // line 54 "../../../Class_DistributableRMI_WithMethods2.ump"
        //release a button
        setIsButtonPressed(false);
        break;
    }
  }

  public void delete()
  {
    removal.interrupt();
    super.delete();
  }

  protected class Message
  {
    MessageType type;
    
    //Message parameters
    Vector<Object> param;
    
    public Message(MessageType t, Vector<Object> p)
    {
      type = t; 
      param = p;
    }

    @Override
    public String toString()
    {
      return type + "," + param;
    }
  }
  
  protected class MessageQueue {
    Queue<Message> messages = new LinkedList<Message>();
    
    public synchronized void put(Message m)
    {
      messages.add(m); 
      notify();
    }

    public synchronized Message getNext()
    {
      try {
        while (messages.isEmpty()) 
        {
          wait();
        }
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return null;
      }

      //The element to be removed
      Message m = messages.remove(); 
      return (m);
    }
  }

  //------------------------------
  //messages accepted 
  //------------------------------

  public void doorOpened ()
  {
    queue.put(new Message(MessageType.doorOpened_M, null));
  }

  public void buttonPressed ()
  {
    queue.put(new Message(MessageType.buttonPressed_M, null));
  }

  public void doorClosed ()
  {
    queue.put(new Message(MessageType.doorClosed_M, null));
  }

  
  @Override
  public void run ()
  {
    boolean status=false;
    while (true) 
    {
      Message m = queue.getNext();
      if(m == null)  return;
      
      switch (m.type)
      {
        case doorOpened_M:
          status = _doorOpened();
          break;
        case buttonPressed_M:
          status = _buttonPressed();
          break;
        case doorClosed_M:
          status = _doorClosed();
          break; 
        default:
      }
      if(!status)
      {
        // Error message is written or  exception is raised
      }
    }
  }

  /**
   * turn on light
   */
  // line 66 "../../../Class_DistributableRMI_WithMethods2.ump"
   public void turnLightOn(boolean on){
    System.out.println("turns the light "+ (on ? "on" : "off"));
    System.out.println("light " + (on ? "on" : "off"));
    setLightOn(on);
  }

  // line 72 "../../../Class_DistributableRMI_WithMethods2.ump"
   public static  void someMethod(){
    
  }


  public String toString()
  {
    return super.toString() + "["+
            "lightOn" + ":" + getLightOn()+ "," +
            "powerTubeOn" + ":" + getPowerTubeOn()+ "," +
            "isDoorOpened" + ":" + getIsDoorOpened()+ "," +
            "isButtonPressed" + ":" + getIsButtonPressed()+ "]";
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi3;
import java.io.Serializable;

// line 5 "../../Class_DistributableRMI3.ump"
public class Client extends CC implements ClientI ,java.io.Serializable, IClientImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Client(UmpleRuntime.UmpleComponent umpleComponent)
  {
    super();
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Client.class)
        UmpleRuntime.getInstance().newClient( umpleComponent, this);

      return;
    }
    else
    {
      UmpleRuntime.getInstance().newClient(this);
    }

  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public void deleteImpl()
  {
    super.delete();
  }

  public void setRealObject(IClientImpl aObject)
  {
  super.setRealObject(aObject);
    realObject=aObject;
  }

  transient IClientImpl realObject=this;
  public Client()
  {

this(UmpleRuntime.getComponent("Client"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  protected  IClientImpl remoteObject;  
  public void setRemoteObject(IClientImpl aRemoteObject)
  {
    remoteObject=aRemoteObject;
  }
  public IClientImpl getRemoteObject()
  {
    return (IClientImpl)remoteObject;
  }
  private void readObject(java.io.ObjectInputStream in) throws Exception
  {
    try
    {
      in.defaultReadObject();
      realObject=(IClientImpl)remoteObject;
    }
    catch(Exception e)
    {
      throw e;
    }
    
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Client)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi4;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.io.Serializable;

// line 13 "../../Class_DistributableRMI4.ump"
public class MicrowaveImpl extends CC implements java.io.Serializable , IMicrowaveImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public MicrowaveImpl()
  {
    super();
  }
  //------------------------
  // Reference to the proxy
  //------------------------
  Microwave self;
  
  public void setSelf(Microwave proxy)
  {
    self=proxy;
  }

  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCode()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public void delete()
  {
    super.delete();
  }

  // line 18 "../../Class_DistributableRMI4.ump"
   public int method1(int f){
    return f*2;
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi5;
import java.util.*;
import java.io.Serializable;

// line 39 "../../Class_DistributableRMI5.ump"
public class Microwave implements java.io.Serializable, IMicrowaveImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Microwave Attributes
  private  transient int x;
  private  transient String f;

  //Microwave Associations
  private transient  List<Client> clients;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Microwave(int aX, String aF, UmpleRuntime.UmpleComponent umpleComponent)
  {
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Microwave.class)
        UmpleRuntime.getInstance().newMicrowave(aX, aF, umpleComponent, this);

      return;
    }
    else
    {
      UmpleRuntime.getInstance().newMicrowave(this);
    }

    x = aX;
    f = aF;
    clients = new ArrayList<Client>();
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public boolean setXImpl(int aX)
  {
    boolean wasSet = false;
    x = aX;
    wasSet = true;
    return wasSet;
  }

  public boolean setFImpl(String aF)
  {
    boolean wasSet = false;
    f = aF;
    wasSet = true;
    return wasSet;
  }

  public int getXImpl()
  {
    return x;
  }

  public String getFImpl()
  {
    return f;
  }
  /* Code from template association_GetMany */
  public Client getClientImpl(int index)
  {
    Client aClient = clients.get(index);
    return aClient;
  }

  /**
   * key{x,f}
   */
  public List<Client> getClientsImpl()
  {
    List<Client> newClients = Collections.unmodifiableList(clients);
    return newClients;
  }

  public int numberOfClientsImpl()
  {
    int number = clients.size();
    return number;
  }

  public boolean hasClientsImpl()
  {
    boolean has = clients.size() > 0;
    return has;
  }

  public int indexOfClientImpl(Client aClient)
  {
    int index = clients.indexOf(aClient);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfClients()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addClientImpl(Client aClient)
  {
    boolean wasAdded = false;
    if (clients.contains(aClient)) { return false; }
    clients.add(aClient);
    if (aClient.indexOfMicrowave(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aClient.addMicrowave(this);
      if (!wasAdded)
      {
        clients.remove(aClient);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeClientImpl(Client aClient)
  {
    boolean wasRemoved = false;
    if (!clients.contains(aClient))
    {
      return wasRemoved;
    }

    int oldIndex = clients.indexOf(aClient);
    clients.remove(oldIndex);
    if (aClient.indexOfMicrowave(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aClient.removeMicrowave(this);
      if (!wasRemoved)
      {
        clients.add(oldIndex,aClient);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addClientAtImpl(Client aClient, int index)
  {  
    boolean wasAdded = false;
    if(addClient(aClient))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfClients()) { index = numberOfClients() - 1; }
      clients.remove(aClient);
      clients.add(index, aClient);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveClientAtImpl(Client aClient, int index)
  {
    boolean wasAdded = false;
    if(clients.contains(aClient))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfClients()) { index = numberOfClients() - 1; }
      clients.remove(aClient);
      clients.add(index, aClient);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addClientAt(aClient, index);
    }
    return wasAdded;
  }

  public void deleteImpl()
  {
    ArrayList<Client> copyOfClients = new ArrayList<Client>(clients);
    clients.clear();
    for(Client aClient : copyOfClients)
    {
      aClient.removeMicrowave(this);
    }
  }


  public String toString()
  {
    return super.toString() + "["+
            "x" + ":" + getX()+ "," +
            "f" + ":" + getF()+ "]";
  }
  public void setRealObject(IMicrowaveImpl aObject)
  {
    realObject=aObject;
  }

  transient IMicrowaveImpl realObject=this;
  public Microwave(int aX, String aF)
  {

this(aX,aF,UmpleRuntime.getComponent("Microwave"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setX(int aX)
  {
    while(true)
      try{
        return realObject.setXImpl(aX);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setF(String aF)
  {
    while(true)
      try{
        return realObject.setFImpl(aF);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int getX()
  {
    while(true)
      try{
        return realObject.getXImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getF()
  {
    while(true)
      try{
        return realObject.getFImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Client getClient(int index)
  {
    while(true)
      try{
        return realObject.getClientImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Client> getClients()
  {
    while(true)
      try{
        return realObject.getClientsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfClients()
  {
    while(true)
      try{
        return realObject.numberOfClientsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasClients()
  {
    while(true)
      try{
        return realObject.hasClientsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfClient(Client aClient)
  {
    while(true)
      try{
        return realObject.indexOfClientImpl(aClient);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addClient(Client aClient)
  {
    while(true)
      try{
        return realObject.addClientImpl(aClient);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeClient(Client aClient)
  {
    while(true)
      try{
        return realObject.removeClientImpl(aClient);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addClientAt(Client aClient, int index)
  {
    while(true)
      try{
        return realObject.addClientAtImpl(aClient,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveClientAt(Client aClient, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveClientAtImpl(aClient,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  protected  IMicrowaveImpl remoteObject;  
  public void setRemoteObject(IMicrowaveImpl aRemoteObject)
  {
    remoteObject=aRemoteObject;
  }
  public IMicrowaveImpl getRemoteObject()
  {
    return (IMicrowaveImpl)remoteObject;
  }
  private void readObject(java.io.ObjectInputStream in) throws Exception
  {
    try
    {
      in.defaultReadObject();
      realObject=(IMicrowaveImpl)remoteObject;
    }
    catch(Exception e)
    {
      throw e;
    }
    
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Microwave)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.util.*;
import java.io.Serializable;
import javax.xml.namespace.QName;
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;

// line 124 "../ecommerceWS.ump"
@WebService(endpointInterface = "ecommerceWS.ISystemManagerImpl")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(factoryMethod="umplenewInstance", propOrder={"remoteUrl", "objectId", "remotePort"})
public class SystemManager implements java.io.Serializable, ISystemManagerImpl
{

  //------------------------
  // STATIC VARIABLES
  //------------------------

  private static SystemManager theInstance = null;

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //SystemManager Associations
  private transient  List<Agent> agents;
  private transient  List<Warehouse> warehouses;
  private transient  List<Customer> customers;
  private transient  List<Order> orders;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  private SystemManager(UmpleRuntime.UmpleComponent umpleComponent)
  {
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== SystemManager.class)
        UmpleRuntime.getInstance().newSystemManager( umpleComponent, this);

      return;
    }
    else
    {
      UmpleRuntime.getInstance().newSystemManager(this);
    }

    agents = new ArrayList<Agent>();
    warehouses = new ArrayList<Warehouse>();
    customers = new ArrayList<Customer>();
    orders = new ArrayList<Order>();
  }

  public static SystemManager getInstance()
  {
    if(theInstance == null)
    {
      theInstance = new SystemManager();
    }
    return theInstance;
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public Agent getAgentImpl(int index)
  {
    Agent aAgent = agents.get(index);
    return aAgent;
  }

  public List<Agent> getAgents()
  {
    List<Agent> newAgents = Collections.unmodifiableList(agents);
    return newAgents;
  }

  public int numberOfAgentsImpl()
  {
    int number = agents.size();
    return number;
  }

  public boolean hasAgentsImpl()
  {
    boolean has = agents.size() > 0;
    return has;
  }

  public int indexOfAgentImpl(Agent aAgent)
  {
    int index = agents.indexOf(aAgent);
    return index;
  }
  /* Code from template association_GetMany */
  public Warehouse getWarehousImpl(int index)
  {
    Warehouse aWarehous = warehouses.get(index);
    return aWarehous;
  }

  public List<Warehouse> getWarehouses()
  {
    List<Warehouse> newWarehouses = Collections.unmodifiableList(warehouses);
    return newWarehouses;
  }

  public int numberOfWarehousesImpl()
  {
    int number = warehouses.size();
    return number;
  }

  public boolean hasWarehousesImpl()
  {
    boolean has = warehouses.size() > 0;
    return has;
  }

  public int indexOfWarehousImpl(Warehouse aWarehous)
  {
    int index = warehouses.indexOf(aWarehous);
    return index;
  }
  /* Code from template association_GetMany */
  public Customer getCustomerImpl(int index)
  {
    Customer aCustomer = customers.get(index);
    return aCustomer;
  }

  public List<Customer> getCustomers()
  {
    List<Customer> newCustomers = Collections.unmodifiableList(customers);
    return newCustomers;
  }

  public int numberOfCustomersImpl()
  {
    int number = customers.size();
    return number;
  }

  public boolean hasCustomersImpl()
  {
    boolean has = customers.size() > 0;
    return has;
  }

  public int indexOfCustomerImpl(Customer aCustomer)
  {
    int index = customers.indexOf(aCustomer);
    return index;
  }
  /* Code from template association_GetMany */
  public Order getOrderImpl(int index)
  {
    Order aOrder = orders.get(index);
    return aOrder;
  }

  public List<Order> getOrders()
  {
    List<Order> newOrders = Collections.unmodifiableList(orders);
    return newOrders;
  }

  public int numberOfOrdersImpl()
  {
    int number = orders.size();
    return number;
  }

  public boolean hasOrdersImpl()
  {
    boolean has = orders.size() > 0;
    return has;
  }

  public int indexOfOrderImpl(Order aOrder)
  {
    int index = orders.indexOf(aOrder);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfAgents()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addAgentImpl(Agent aAgent)
  {
    boolean wasAdded = false;
    if (agents.contains(aAgent)) { return false; }
    SystemManager existingSystemManager = aAgent.getSystemManager();
    if (existingSystemManager == null)
    {
      aAgent.setSystemManager(this);
    }
    else if (!this.equals(existingSystemManager))
    {
      existingSystemManager.removeAgent(aAgent);
      addAgent(aAgent);
    }
    else
    {
      agents.add(aAgent);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeAgentImpl(Agent aAgent)
  {
    boolean wasRemoved = false;
    if (agents.contains(aAgent))
    {
      agents.remove(aAgent);
      aAgent.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addAgentAtImpl(Agent aAgent, int index)
  {  
    boolean wasAdded = false;
    if(addAgent(aAgent))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfAgents()) { index = numberOfAgents() - 1; }
      agents.remove(aAgent);
      agents.add(index, aAgent);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveAgentAtImpl(Agent aAgent, int index)
  {
    boolean wasAdded = false;
    if(agents.contains(aAgent))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfAgents()) { index = numberOfAgents() - 1; }
      agents.remove(aAgent);
      agents.add(index, aAgent);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addAgentAt(aAgent, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfWarehouses()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addWarehousImpl(Warehouse aWarehous)
  {
    boolean wasAdded = false;
    if (warehouses.contains(aWarehous)) { return false; }
    SystemManager existingSystemManager = aWarehous.getSystemManager();
    if (existingSystemManager == null)
    {
      aWarehous.setSystemManager(this);
    }
    else if (!this.equals(existingSystemManager))
    {
      existingSystemManager.removeWarehous(aWarehous);
      addWarehous(aWarehous);
    }
    else
    {
      warehouses.add(aWarehous);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeWarehousImpl(Warehouse aWarehous)
  {
    boolean wasRemoved = false;
    if (warehouses.contains(aWarehous))
    {
      warehouses.remove(aWarehous);
      aWarehous.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index)
  {  
    boolean wasAdded = false;
    if(addWarehous(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index)
  {
    boolean wasAdded = false;
    if(warehouses.contains(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addWarehousAt(aWarehous, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfCustomers()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addCustomerImpl(Customer aCustomer)
  {
    boolean wasAdded = false;
    if (customers.contains(aCustomer)) { return false; }
    SystemManager existingSystemManager = aCustomer.getSystemManager();
    if (existingSystemManager == null)
    {
      aCustomer.setSystemManager(this);
    }
    else if (!this.equals(existingSystemManager))
    {
      existingSystemManager.removeCustomer(aCustomer);
      addCustomer(aCustomer);
    }
    else
    {
      customers.add(aCustomer);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeCustomerImpl(Customer aCustomer)
  {
    boolean wasRemoved = false;
    if (customers.contains(aCustomer))
    {
      customers.remove(aCustomer);
      aCustomer.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addCustomerAtImpl(Customer aCustomer, int index)
  {  
    boolean wasAdded = false;
    if(addCustomer(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveCustomerAtImpl(Customer aCustomer, int index)
  {
    boolean wasAdded = false;
    if(customers.contains(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addCustomerAt(aCustomer, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfOrders()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addOrderImpl(Order aOrder)
  {
    boolean wasAdded = false;
    if (orders.contains(aOrder)) { return false; }
    SystemManager existingSystemManager = aOrder.getSystemManager();
    if (existingSystemManager == null)
    {
      aOrder.setSystemManager(this);
    }
    else if (!this.equals(existingSystemManager))
    {
      existingSystemManager.removeOrder(aOrder);
      addOrder(aOrder);
    }
    else
    {
      orders.add(aOrder);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeOrderImpl(Order aOrder)
  {
    boolean wasRemoved = false;
    if (orders.contains(aOrder))
    {
      orders.remove(aOrder);
      aOrder.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addOrderAtImpl(Order aOrder, int index)
  {  
    boolean wasAdded = false;
    if(addOrder(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveOrderAtImpl(Order aOrder, int index)
  {
    boolean wasAdded = false;
    if(orders.contains(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addOrderAt(aOrder, index);
    }
    return wasAdded;
  }

  public void deleteImpl()
  {
    while( !agents.isEmpty() )
    {
      agents.get(0).setSystemManager(null);
    }
    while( !warehouses.isEmpty() )
    {
      warehouses.get(0).setSystemManager(null);
    }
    while( !customers.isEmpty() )
    {
      customers.get(0).setSystemManager(null);
    }
    while( !orders.isEmpty() )
    {
      orders.get(0).setSystemManager(null);
    }
  }


  transient ISystemManagerImpl realObject=this;
  private SystemManager()
  {

this(UmpleRuntime.getComponent("SystemManager"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Agent getAgent(int index)
  {
    while(true)
      try{
        return realObject.getAgentImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfAgents()
  {
    while(true)
      try{
        return realObject.numberOfAgentsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasAgents()
  {
    while(true)
      try{
        return realObject.hasAgentsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfAgent(Agent aAgent)
  {
    while(true)
      try{
        return realObject.indexOfAgentImpl(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Warehouse getWarehous(int index)
  {
    while(true)
      try{
        return realObject.getWarehousImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfWarehouses()
  {
    while(true)
      try{
        return realObject.numberOfWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasWarehouses()
  {
    while(true)
      try{
        return realObject.hasWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.indexOfWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Customer getCustomer(int index)
  {
    while(true)
      try{
        return realObject.getCustomerImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfCustomers()
  {
    while(true)
      try{
        return realObject.numberOfCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasCustomers()
  {
    while(true)
      try{
        return realObject.hasCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.indexOfCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrder(int index)
  {
    while(true)
      try{
        return realObject.getOrderImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrders()
  {
    while(true)
      try{
        return realObject.numberOfOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrders()
  {
    while(true)
      try{
        return realObject.hasOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addAgent(Agent aAgent)
  {
    while(true)
      try{
        return realObject.addAgentImpl(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeAgent(Agent aAgent)
  {
    while(true)
      try{
        return realObject.removeAgentImpl(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addAgentAt(Agent aAgent, int index)
  {
    while(true)
      try{
        return realObject.addAgentAtImpl(aAgent,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveAgentAt(Agent aAgent, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveAgentAtImpl(aAgent,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.addWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.removeWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.addCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.removeCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }


  public  String remoteUrl;
  public  String objectId;
  public  String remotePort; 
  private static SystemManager umplenewInstance()
  {
    return new SystemManager((UmpleRuntime.UmpleNode)null);
  }   

  protected SystemManager (UmpleRuntime.UmpleNode node)
  {
  }

  public void setRealObject(ISystemManagerImpl aObject)
  {
    realObject=aObject;
  }
  void afterUnmarshal(Unmarshaller u, Object parent)
  {
    initializeConnection();
  }
  private void initializeConnection()
  {
    if(objectId.contains(SystemManager.class.getName()))
    {  
      boolean success = false;
      while (!success) {        
        try 
        {
          URL url = new URL(remoteUrl+":"+remotePort+"/SystemManager"+objectId+"?wsdl");
          QName qname = new QName("https://ecommerceWS/","SystemManagerService");
          Service service = Service.create(url, qname);
          setRealObject(service.getPort(ISystemManagerImpl.class));
          success = true;
        } 
        catch (Exception e) 
        {
          System.err.println("Client exception: " + e.toString());
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }
      }
    }
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((SystemManager)obj).getHashCode());
  }  public static SystemManager getInstance(UmpleRuntime.UmpleComponent umpleComponent)
{
if(theInstance == null)
{
theInstance = new SystemManager(umpleComponent);
}
return theInstance;
}
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

// line 1 "Interface_DistributableRMI.ump"
public interface IClient
{
  
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi3;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface IClientImpl extends java.rmi.Remote, ICCImpl
{
  public int getHashCodeImpl() throws RemoteException;
  public void deleteImpl() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.io.Serializable;
import ecommerceRMI1.UmpleRuntime;
public class Agent implements java.io.Serializable
{  public void setRealObject(IAgentImpl aObject)
  {
    realObject=aObject;
  }

  IAgentImpl realObject;
  public Agent(String aName, UmpleRuntime.UmpleComponent component)
  {
    if(this.getClass()== Agent.class)    setRealObject(UmpleRuntime.getInstance().newAgent(aName, component, this));
  }
  public Agent(String aName)
  {
    if(this.getClass()== Agent.class)    setRealObject(UmpleRuntime.getInstance().newAgent(aName, this));
  }
  public void setSelf(Agent proxy)
  {
    while(true)
      try{
        realObject.setSelf(proxy);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCode();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setName(String aName)
  {
    while(true)
      try{
        return realObject.setName(aName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getName()
  {
    while(true)
      try{
        return realObject.getName();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Warehouse getWarehous(int index)
  {
    while(true)
      try{
        return realObject.getWarehous(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Warehouse> getWarehouses()
  {
    while(true)
      try{
        return realObject.getWarehouses();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfWarehouses()
  {
    while(true)
      try{
        return realObject.numberOfWarehouses();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasWarehouses()
  {
    while(true)
      try{
        return realObject.hasWarehouses();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.indexOfWarehous(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public SystemManager getSystemManager()
  {
    while(true)
      try{
        return realObject.getSystemManager();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasSystemManager()
  {
    while(true)
      try{
        return realObject.hasSystemManager();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public static int minimumNumberOfWarehouses()
  {
    while(true)
      try{
        return AgentImpl.minimumNumberOfWarehouses();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.addWarehous(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.removeWarehous(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addWarehousAt(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveWarehousAt(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    while(true)
      try{
        return realObject.setSystemManager(aSystemManager);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.delete();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Agent)obj).getHashCode());
  }
protected Agent(){}
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.io.Serializable;

// line 39 "../ecommerceRMI1.ump"
public class Order implements java.io.Serializable
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Order Associations
  private Customer customer;
  private Vendor vendor;
  private Product product;
  private SystemManager systemManager;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Order(Product aProduct)
  {
    if (!setProduct(aProduct))
    {
      throw new RuntimeException("Unable to create Order due to aProduct. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetOne */
  public Customer getCustomer()
  {
    return customer;
  }

  public boolean hasCustomer()
  {
    boolean has = customer != null;
    return has;
  }
  /* Code from template association_GetOne */
  public Vendor getVendor()
  {
    return vendor;
  }

  public boolean hasVendor()
  {
    boolean has = vendor != null;
    return has;
  }
  /* Code from template association_GetOne */
  public Product getProduct()
  {
    return product;
  }
  /* Code from template association_GetOne */
  public SystemManager getSystemManager()
  {
    return systemManager;
  }

  public boolean hasSystemManager()
  {
    boolean has = systemManager != null;
    return has;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setCustomer(Customer aCustomer)
  {
    boolean wasSet = false;
    Customer existingCustomer = customer;
    customer = aCustomer;
    if (existingCustomer != null && !existingCustomer.equals(aCustomer))
    {
      existingCustomer.removeOrder(this);
    }
    if (aCustomer != null)
    {
      aCustomer.addOrder(this);
    }
    wasSet = true;
    return wasSet;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setVendor(Vendor aVendor)
  {
    boolean wasSet = false;
    Vendor existingVendor = vendor;
    vendor = aVendor;
    if (existingVendor != null && !existingVendor.equals(aVendor))
    {
      existingVendor.removeOrder(this);
    }
    if (aVendor != null)
    {
      aVendor.addOrder(this);
    }
    wasSet = true;
    return wasSet;
  }
  /* Code from template association_SetUnidirectionalOne */
  public boolean setProduct(Product aNewProduct)
  {
    boolean wasSet = false;
    if (aNewProduct != null)
    {
      product = aNewProduct;
      wasSet = true;
    }
    return wasSet;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    boolean wasSet = false;
    SystemManager existingSystemManager = systemManager;
    systemManager = aSystemManager;
    if (existingSystemManager != null && !existingSystemManager.equals(aSystemManager))
    {
      existingSystemManager.removeOrder(this);
    }
    if (aSystemManager != null)
    {
      aSystemManager.addOrder(this);
    }
    wasSet = true;
    return wasSet;
  }

  public void delete()
  {
    if (customer != null)
    {
      Customer placeholderCustomer = customer;
      this.customer = null;
      placeholderCustomer.removeOrder(this);
    }
    if (vendor != null)
    {
      Vendor placeholderVendor = vendor;
      this.vendor = null;
      placeholderVendor.removeOrder(this);
    }
    product = null;
    if (systemManager != null)
    {
      SystemManager placeholderSystemManager = systemManager;
      this.systemManager = null;
      placeholderSystemManager.removeOrder(this);
    }
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;

import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
public class VendorRemote extends AgentRemote implements IVendorImpl
{
  Vendor realObject;
  public void setRealObject(Vendor aObject)
  {
    realObject=aObject;
  }
  public VendorRemote()
  {}
  public VendorRemote(Vendor aObject)
  {
    super(aObject);
    realObject=aObject;
  }
  public int getHashCodeImpl()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrderImpl(int index)
  {
    while(true)
      try{
        return realObject.getOrderImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Order> getOrdersImpl()
  {
    while(true)
      try{
        return realObject.getOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrdersImpl()
  {
    while(true)
      try{
        return realObject.numberOfOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrdersImpl()
  {
    while(true)
      try{
        return realObject.hasOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrderImpl(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Customer getCustomerImpl(int index)
  {
    while(true)
      try{
        return realObject.getCustomerImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Customer> getCustomersImpl()
  {
    while(true)
      try{
        return realObject.getCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfCustomersImpl()
  {
    while(true)
      try{
        return realObject.numberOfCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasCustomersImpl()
  {
    while(true)
      try{
        return realObject.hasCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfCustomerImpl(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.indexOfCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderImpl(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrderImpl(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAtImpl(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAtImpl(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomerImpl(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.addCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeCustomerImpl(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.removeCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomerAtImpl(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveCustomerAtImpl(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void deleteImpl()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Product findProductImpl(ProductType productType)
  {
    while(true)
      try{
        return realObject.findProductImpl(productType);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Order makeOrderImpl(Customer aCustomer, Product aProduct)
  {
    while(true)
      try{
        return realObject.makeOrderImpl(aCustomer,aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

// line 46 "../ecommerceRMI1.ump"
public class SupplierImpl extends AgentImpl implements java.io.Serializable , ISupplierImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //SupplierImpl Associations
  private List<Product> products;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public SupplierImpl(String aName)
  {
    super(aName);
    products = new ArrayList<Product>();
  }
  //------------------------
  // Reference to the proxy
  //------------------------
  Supplier self;
  
  public void setSelf(Supplier proxy)
  {
    super.setSelf(proxy);
    self=proxy;
  }

  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCode()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public Product getProduct(int index)
  {
    Product aProduct = products.get(index);
    return aProduct;
  }

  public List<Product> getProducts()
  {
    List<Product> newProducts = Collections.unmodifiableList(products);
    return newProducts;
  }

  public int numberOfProducts()
  {
    int number = products.size();
    return number;
  }

  public boolean hasProducts()
  {
    boolean has = products.size() > 0;
    return has;
  }

  public int indexOfProduct(Product aProduct)
  {
    int index = products.indexOf(aProduct);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfProducts()
  {
    return 0;
  }
  /* Code from template association_AddUnidirectionalMany */
  public boolean addProduct(Product aProduct)
  {
    boolean wasAdded = false;
    if (products.contains(aProduct)) { return false; }
    products.add(aProduct);
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeProduct(Product aProduct)
  {
    boolean wasRemoved = false;
    if (products.contains(aProduct))
    {
      products.remove(aProduct);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addProductAt(Product aProduct, int index)
  {  
    boolean wasAdded = false;
    if(addProduct(aProduct))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfProducts()) { index = numberOfProducts() - 1; }
      products.remove(aProduct);
      products.add(index, aProduct);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveProductAt(Product aProduct, int index)
  {
    boolean wasAdded = false;
    if(products.contains(aProduct))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfProducts()) { index = numberOfProducts() - 1; }
      products.remove(aProduct);
      products.add(index, aProduct);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addProductAt(aProduct, index);
    }
    return wasAdded;
  }

  public void delete()
  {
    products.clear();
    super.delete();
  }

  // line 52 "../ecommerceRMI1.ump"
   public Product createProduct(String serialNumber, String productType){
    Product aProduct=new Product(serialNumber,new ProductType(productType));
		addProduct(aProduct);
		return aProduct;
  }

  // line 58 "../ecommerceRMI1.ump"
   public void putInWarehouse(Product aProduct, Warehouse warehouse){
    warehouse.addProduct(aProduct);
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.util.*;
import java.io.Serializable;
import javax.xml.namespace.QName;
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;

// line 63 "../ecommerceWS.ump"
@WebService(endpointInterface = "ecommerceWS.IVendorImpl")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(factoryMethod="umplenewInstance", propOrder={})
public class Vendor extends Agent implements java.io.Serializable, IVendorImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Vendor Associations
  private transient  List<Warehouse> warehouses;
  private transient  List<Order> orders;
  private transient  List<Customer> customers;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Vendor(String aName, UmpleRuntime.UmpleComponent umpleComponent)
  {
    super(aName,umpleComponent);
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Vendor.class)
        UmpleRuntime.getInstance().newVendor(aName, umpleComponent, this);

      return;
    }

    warehouses = new ArrayList<Warehouse>();
    orders = new ArrayList<Order>();
    customers = new ArrayList<Customer>();
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public Warehouse getWarehousImpl(int index)
  {
    Warehouse aWarehous = warehouses.get(index);
    return aWarehous;
  }

  public List<Warehouse> getWarehouses()
  {
    List<Warehouse> newWarehouses = Collections.unmodifiableList(warehouses);
    return newWarehouses;
  }

  public int numberOfWarehousesImpl()
  {
    int number = warehouses.size();
    return number;
  }

  public boolean hasWarehousesImpl()
  {
    boolean has = warehouses.size() > 0;
    return has;
  }

  public int indexOfWarehousImpl(Warehouse aWarehous)
  {
    int index = warehouses.indexOf(aWarehous);
    return index;
  }
  /* Code from template association_GetMany */
  public Order getOrderImpl(int index)
  {
    Order aOrder = orders.get(index);
    return aOrder;
  }

  public List<Order> getOrders()
  {
    List<Order> newOrders = Collections.unmodifiableList(orders);
    return newOrders;
  }

  public int numberOfOrdersImpl()
  {
    int number = orders.size();
    return number;
  }

  public boolean hasOrdersImpl()
  {
    boolean has = orders.size() > 0;
    return has;
  }

  public int indexOfOrderImpl(Order aOrder)
  {
    int index = orders.indexOf(aOrder);
    return index;
  }
  /* Code from template association_GetMany */
  public Customer getCustomerImpl(int index)
  {
    Customer aCustomer = customers.get(index);
    return aCustomer;
  }

  public List<Customer> getCustomers()
  {
    List<Customer> newCustomers = Collections.unmodifiableList(customers);
    return newCustomers;
  }

  public int numberOfCustomersImpl()
  {
    int number = customers.size();
    return number;
  }

  public boolean hasCustomersImpl()
  {
    boolean has = customers.size() > 0;
    return has;
  }

  public int indexOfCustomerImpl(Customer aCustomer)
  {
    int index = customers.indexOf(aCustomer);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfWarehouses()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addWarehousImpl(Warehouse aWarehous)
  {
    boolean wasAdded = false;
    if (warehouses.contains(aWarehous)) { return false; }
    warehouses.add(aWarehous);
    if (aWarehous.indexOfVendor(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aWarehous.addVendor(this);
      if (!wasAdded)
      {
        warehouses.remove(aWarehous);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeWarehousImpl(Warehouse aWarehous)
  {
    boolean wasRemoved = false;
    if (!warehouses.contains(aWarehous))
    {
      return wasRemoved;
    }

    int oldIndex = warehouses.indexOf(aWarehous);
    warehouses.remove(oldIndex);
    if (aWarehous.indexOfVendor(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aWarehous.removeVendor(this);
      if (!wasRemoved)
      {
        warehouses.add(oldIndex,aWarehous);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index)
  {  
    boolean wasAdded = false;
    if(addWarehous(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index)
  {
    boolean wasAdded = false;
    if(warehouses.contains(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addWarehousAt(aWarehous, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfOrders()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addOrderImpl(Order aOrder)
  {
    boolean wasAdded = false;
    if (orders.contains(aOrder)) { return false; }
    Vendor existingVendor = aOrder.getVendor();
    if (existingVendor == null)
    {
      aOrder.setVendor(this);
    }
    else if (!this.equals(existingVendor))
    {
      existingVendor.removeOrder(aOrder);
      addOrder(aOrder);
    }
    else
    {
      orders.add(aOrder);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeOrderImpl(Order aOrder)
  {
    boolean wasRemoved = false;
    if (orders.contains(aOrder))
    {
      orders.remove(aOrder);
      aOrder.setVendor(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addOrderAtImpl(Order aOrder, int index)
  {  
    boolean wasAdded = false;
    if(addOrder(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveOrderAtImpl(Order aOrder, int index)
  {
    boolean wasAdded = false;
    if(orders.contains(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addOrderAt(aOrder, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfCustomers()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addCustomerImpl(Customer aCustomer)
  {
    boolean wasAdded = false;
    if (customers.contains(aCustomer)) { return false; }
    customers.add(aCustomer);
    if (aCustomer.indexOfVendor(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aCustomer.addVendor(this);
      if (!wasAdded)
      {
        customers.remove(aCustomer);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeCustomerImpl(Customer aCustomer)
  {
    boolean wasRemoved = false;
    if (!customers.contains(aCustomer))
    {
      return wasRemoved;
    }

    int oldIndex = customers.indexOf(aCustomer);
    customers.remove(oldIndex);
    if (aCustomer.indexOfVendor(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aCustomer.removeVendor(this);
      if (!wasRemoved)
      {
        customers.add(oldIndex,aCustomer);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addCustomerAtImpl(Customer aCustomer, int index)
  {  
    boolean wasAdded = false;
    if(addCustomer(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveCustomerAtImpl(Customer aCustomer, int index)
  {
    boolean wasAdded = false;
    if(customers.contains(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addCustomerAt(aCustomer, index);
    }
    return wasAdded;
  }

  public void deleteImpl()
  {
    ArrayList<Warehouse> copyOfWarehouses = new ArrayList<Warehouse>(warehouses);
    warehouses.clear();
    for(Warehouse aWarehous : copyOfWarehouses)
    {
      aWarehous.removeVendor(this);
    }
    while( !orders.isEmpty() )
    {
      orders.get(0).setVendor(null);
    }
    ArrayList<Customer> copyOfCustomers = new ArrayList<Customer>(customers);
    customers.clear();
    for(Customer aCustomer : copyOfCustomers)
    {
      aCustomer.removeVendor(this);
    }
    super.delete();
  }

  // line 68 "../ecommerceWS.ump"
   public Product findProductImpl(ProductType productType){
    for(Warehouse w:getWarehouses())
		{
			Product p= w.findProduct(productType);
			if(p!=null)
				return p;		
		}
		return null;
  }

  // line 77 "../ecommerceWS.ump"
   public Order makeOrderImpl(Customer aCustomer, Product aProduct){
    if(aProduct==null)
			return null;
		Order aOrder= new Order(aProduct);
		aOrder.setCustomer(aCustomer);
		aOrder.setVendor(this);
		return aOrder;
  }


  transient IVendorImpl realObject=this;
  public Vendor(String aName)
  {

this(aName,UmpleRuntime.getComponent("Vendor"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Warehouse getWarehous(int index)
  {
    while(true)
      try{
        return realObject.getWarehousImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfWarehouses()
  {
    while(true)
      try{
        return realObject.numberOfWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasWarehouses()
  {
    while(true)
      try{
        return realObject.hasWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.indexOfWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrder(int index)
  {
    while(true)
      try{
        return realObject.getOrderImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrders()
  {
    while(true)
      try{
        return realObject.numberOfOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrders()
  {
    while(true)
      try{
        return realObject.hasOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Customer getCustomer(int index)
  {
    while(true)
      try{
        return realObject.getCustomerImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfCustomers()
  {
    while(true)
      try{
        return realObject.numberOfCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasCustomers()
  {
    while(true)
      try{
        return realObject.hasCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.indexOfCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.addWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.removeWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.addCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.removeCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Product findProduct(ProductType productType)
  {
    while(true)
      try{
        return realObject.findProductImpl(productType);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Order makeOrder(Customer aCustomer, Product aProduct)
  {
    while(true)
      try{
        return realObject.makeOrderImpl(aCustomer,aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  private static Vendor umplenewInstance()
  {
    return new Vendor((UmpleRuntime.UmpleNode)null);
  }   

  protected Vendor (UmpleRuntime.UmpleNode node)
  {
    super(node);
  }

  public void setRealObject(IVendorImpl aObject)
  {
    super.setRealObject(aObject);
    realObject=aObject;
  }
  void afterUnmarshal(Unmarshaller u, Object parent)
  {
    initializeConnection();
  }
  private void initializeConnection()
  {
    if(objectId.contains(Vendor.class.getName()))
    {  
      boolean success = false;
      while (!success) {        
        try 
        {
          URL url = new URL(remoteUrl+":"+remotePort+"/Vendor"+objectId+"?wsdl");
          QName qname = new QName("https://ecommerceWS/","VendorService");
          Service service = Service.create(url, qname);
          setRealObject(service.getPort(IVendorImpl.class));
          success = true;
        } 
        catch (Exception e) 
        {
          System.err.println("Client exception: " + e.toString());
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }
      }
    }
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Vendor)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
public interface ICustomerImpl extends java.rmi.Remote
{
  public void setSelf(Customer proxy) throws RemoteException;
  public int getHashCode() throws RemoteException;
  public boolean setName(String aName) throws RemoteException;
  public String getName() throws RemoteException;
  public Vendor getVendor(int index) throws RemoteException;
  public List<Vendor> getVendors() throws RemoteException;
  public int numberOfVendors() throws RemoteException;
  public boolean hasVendors() throws RemoteException;
  public int indexOfVendor(Vendor aVendor) throws RemoteException;
  public Order getOrder(int index) throws RemoteException;
  public List<Order> getOrders() throws RemoteException;
  public int numberOfOrders() throws RemoteException;
  public boolean hasOrders() throws RemoteException;
  public int indexOfOrder(Order aOrder) throws RemoteException;
  public SystemManager getSystemManager() throws RemoteException;
  public boolean hasSystemManager() throws RemoteException;
  public boolean addVendor(Vendor aVendor) throws RemoteException;
  public boolean removeVendor(Vendor aVendor) throws RemoteException;
  public boolean addVendorAt(Vendor aVendor, int index) throws RemoteException;
  public boolean addOrMoveVendorAt(Vendor aVendor, int index) throws RemoteException;
  public boolean addOrder(Order aOrder) throws RemoteException;
  public boolean removeOrder(Order aOrder) throws RemoteException;
  public boolean addOrderAt(Order aOrder, int index) throws RemoteException;
  public boolean addOrMoveOrderAt(Order aOrder, int index) throws RemoteException;
  public boolean setSystemManager(SystemManager aSystemManager) throws RemoteException;
  public void delete() throws RemoteException;
   public Order orderProduct(String productType, String vendorName) throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.io.Serializable;

// line 81 "../ecommerceRMI0.ump"
public class Product implements java.io.Serializable
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Product Attributes
  private String serialNumber;

  //Product Associations
  private ProductType productType;

  //Helper Variables
  private boolean canSetProductType;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Product(String aSerialNumber, ProductType aProductType)
  {
    serialNumber = aSerialNumber;
    canSetProductType = true;
    if (!setProductType(aProductType))
    {
      throw new RuntimeException("Unable to create Product due to aProductType. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------

  public String getSerialNumber()
  {
    return serialNumber;
  }
  /* Code from template association_GetOne */
  public ProductType getProductType()
  {
    return productType;
  }
  /* Code from template association_SetUnidirectionalOne */
  private boolean setProductType(ProductType aNewProductType)
  {
    boolean wasSet = false;
    if (!canSetProductType) { return false; }
    canSetProductType = false;
    if (aNewProductType != null)
    {
      productType = aNewProductType;
      wasSet = true;
    }
    return wasSet;
  }

  public void delete()
  {}


  public String toString()
  {
    return super.toString() + "["+
            "serialNumber" + ":" + getSerialNumber()+ "]" + System.getProperties().getProperty("line.separator") +
            "  " + "productType = "+(getProductType()!=null?Integer.toHexString(System.identityHashCode(getProductType())):"null");
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi2;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface ICCImpl extends java.rmi.Remote
{
  public void delete() throws RemoteException;
   public void someMethod1() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi2;
import java.io.Serializable;

// line 8 "../../Class_DistributableRMI2.ump"
public class CC
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public CC()
  {}

  //------------------------
  // INTERFACE
  //------------------------

  public void delete()
  {}

  // line 11 "../../Class_DistributableRMI2.ump"
   public void someMethod1(){
    
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.util.*;
import java.io.Serializable;
import javax.xml.namespace.QName;
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;

// line 109 "../ecommerceWS.ump"
@WebService(endpointInterface = "ecommerceWS.ICustomerImpl")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(factoryMethod="umplenewInstance", propOrder={"remoteUrl", "objectId", "remotePort"})
public class Customer implements java.io.Serializable, ICustomerImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Customer Attributes
  private  transient String name;

  //Customer Associations
  private transient  List<Vendor> vendors;
  private transient  List<Order> orders;
  private transient  SystemManager systemManager;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Customer(String aName, UmpleRuntime.UmpleComponent umpleComponent)
  {
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Customer.class)
        UmpleRuntime.getInstance().newCustomer(aName, umpleComponent, this);

      return;
    }
    else
    {
      UmpleRuntime.getInstance().newCustomer(this);
    }

    name = aName;
    vendors = new ArrayList<Vendor>();
    orders = new ArrayList<Order>();
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public boolean setNameImpl(String aName)
  {
    boolean wasSet = false;
    name = aName;
    wasSet = true;
    return wasSet;
  }

  public String getNameImpl()
  {
    return name;
  }
  /* Code from template association_GetMany */
  public Vendor getVendorImpl(int index)
  {
    Vendor aVendor = vendors.get(index);
    return aVendor;
  }

  public List<Vendor> getVendors()
  {
    List<Vendor> newVendors = Collections.unmodifiableList(vendors);
    return newVendors;
  }

  public int numberOfVendorsImpl()
  {
    int number = vendors.size();
    return number;
  }

  public boolean hasVendorsImpl()
  {
    boolean has = vendors.size() > 0;
    return has;
  }

  public int indexOfVendorImpl(Vendor aVendor)
  {
    int index = vendors.indexOf(aVendor);
    return index;
  }
  /* Code from template association_GetMany */
  public Order getOrderImpl(int index)
  {
    Order aOrder = orders.get(index);
    return aOrder;
  }

  public List<Order> getOrders()
  {
    List<Order> newOrders = Collections.unmodifiableList(orders);
    return newOrders;
  }

  public int numberOfOrdersImpl()
  {
    int number = orders.size();
    return number;
  }

  public boolean hasOrdersImpl()
  {
    boolean has = orders.size() > 0;
    return has;
  }

  public int indexOfOrderImpl(Order aOrder)
  {
    int index = orders.indexOf(aOrder);
    return index;
  }
  /* Code from template association_GetOne */
  public SystemManager getSystemManagerImpl()
  {
    return systemManager;
  }

  public boolean hasSystemManagerImpl()
  {
    boolean has = systemManager != null;
    return has;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfVendors()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addVendorImpl(Vendor aVendor)
  {
    boolean wasAdded = false;
    if (vendors.contains(aVendor)) { return false; }
    vendors.add(aVendor);
    if (aVendor.indexOfCustomer(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aVendor.addCustomer(this);
      if (!wasAdded)
      {
        vendors.remove(aVendor);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeVendorImpl(Vendor aVendor)
  {
    boolean wasRemoved = false;
    if (!vendors.contains(aVendor))
    {
      return wasRemoved;
    }

    int oldIndex = vendors.indexOf(aVendor);
    vendors.remove(oldIndex);
    if (aVendor.indexOfCustomer(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aVendor.removeCustomer(this);
      if (!wasRemoved)
      {
        vendors.add(oldIndex,aVendor);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addVendorAtImpl(Vendor aVendor, int index)
  {  
    boolean wasAdded = false;
    if(addVendor(aVendor))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfVendors()) { index = numberOfVendors() - 1; }
      vendors.remove(aVendor);
      vendors.add(index, aVendor);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveVendorAtImpl(Vendor aVendor, int index)
  {
    boolean wasAdded = false;
    if(vendors.contains(aVendor))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfVendors()) { index = numberOfVendors() - 1; }
      vendors.remove(aVendor);
      vendors.add(index, aVendor);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addVendorAt(aVendor, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfOrders()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addOrderImpl(Order aOrder)
  {
    boolean wasAdded = false;
    if (orders.contains(aOrder)) { return false; }
    Customer existingCustomer = aOrder.getCustomer();
    if (existingCustomer == null)
    {
      aOrder.setCustomer(this);
    }
    else if (!this.equals(existingCustomer))
    {
      existingCustomer.removeOrder(aOrder);
      addOrder(aOrder);
    }
    else
    {
      orders.add(aOrder);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeOrderImpl(Order aOrder)
  {
    boolean wasRemoved = false;
    if (orders.contains(aOrder))
    {
      orders.remove(aOrder);
      aOrder.setCustomer(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addOrderAtImpl(Order aOrder, int index)
  {  
    boolean wasAdded = false;
    if(addOrder(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveOrderAtImpl(Order aOrder, int index)
  {
    boolean wasAdded = false;
    if(orders.contains(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addOrderAt(aOrder, index);
    }
    return wasAdded;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setSystemManagerImpl(SystemManager aSystemManager)
  {
    boolean wasSet = false;
    SystemManager existingSystemManager = systemManager;
    systemManager = aSystemManager;
    if (existingSystemManager != null && !existingSystemManager.equals(aSystemManager))
    {
      existingSystemManager.removeCustomer(this);
    }
    if (aSystemManager != null)
    {
      aSystemManager.addCustomer(this);
    }
    wasSet = true;
    return wasSet;
  }

  public void deleteImpl()
  {
    ArrayList<Vendor> copyOfVendors = new ArrayList<Vendor>(vendors);
    vendors.clear();
    for(Vendor aVendor : copyOfVendors)
    {
      aVendor.removeCustomer(this);
    }
    while( !orders.isEmpty() )
    {
      orders.get(0).setCustomer(null);
    }
    if (systemManager != null)
    {
      SystemManager placeholderSystemManager = systemManager;
      this.systemManager = null;
      placeholderSystemManager.removeCustomer(this);
    }
  }

  // line 115 "../ecommerceWS.ump"
   public Order orderProductImpl(String productType, String vendorName){
    for(Vendor v: getVendors())
		{
			if(v.getName().equals(vendorName))
				return v.makeOrder(this,v.findProduct(new ProductType(productType)));
		}
		return null;
  }


  public String toString()
  {
    return super.toString() + "["+
            "name" + ":" + getName()+ "]" + System.getProperties().getProperty("line.separator") +
            "  " + "systemManager = "+(getSystemManager()!=null?Integer.toHexString(System.identityHashCode(getSystemManager())):"null");
  }

  transient ICustomerImpl realObject=this;
  public Customer(String aName)
  {

this(aName,UmpleRuntime.getComponent("Customer"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setName(String aName)
  {
    while(true)
      try{
        return realObject.setNameImpl(aName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getName()
  {
    while(true)
      try{
        return realObject.getNameImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Vendor getVendor(int index)
  {
    while(true)
      try{
        return realObject.getVendorImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfVendors()
  {
    while(true)
      try{
        return realObject.numberOfVendorsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasVendors()
  {
    while(true)
      try{
        return realObject.hasVendorsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfVendor(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.indexOfVendorImpl(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrder(int index)
  {
    while(true)
      try{
        return realObject.getOrderImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrders()
  {
    while(true)
      try{
        return realObject.numberOfOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrders()
  {
    while(true)
      try{
        return realObject.hasOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public SystemManager getSystemManager()
  {
    while(true)
      try{
        return realObject.getSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasSystemManager()
  {
    while(true)
      try{
        return realObject.hasSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addVendor(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.addVendorImpl(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeVendor(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.removeVendorImpl(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addVendorAt(Vendor aVendor, int index)
  {
    while(true)
      try{
        return realObject.addVendorAtImpl(aVendor,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveVendorAt(Vendor aVendor, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveVendorAtImpl(aVendor,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    while(true)
      try{
        return realObject.setSystemManagerImpl(aSystemManager);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Order orderProduct(String productType, String vendorName)
  {
    while(true)
      try{
        return realObject.orderProductImpl(productType,vendorName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }


  public  String remoteUrl;
  public  String objectId;
  public  String remotePort; 
  private static Customer umplenewInstance()
  {
    return new Customer((UmpleRuntime.UmpleNode)null);
  }   

  protected Customer (UmpleRuntime.UmpleNode node)
  {
  }

  public void setRealObject(ICustomerImpl aObject)
  {
    realObject=aObject;
  }
  void afterUnmarshal(Unmarshaller u, Object parent)
  {
    initializeConnection();
  }
  private void initializeConnection()
  {
    if(objectId.contains(Customer.class.getName()))
    {  
      boolean success = false;
      while (!success) {        
        try 
        {
          URL url = new URL(remoteUrl+":"+remotePort+"/Customer"+objectId+"?wsdl");
          QName qname = new QName("https://ecommerceWS/","CustomerService");
          Service service = Service.create(url, qname);
          setRealObject(service.getPort(ICustomerImpl.class));
          success = true;
        } 
        catch (Exception e) 
        {
          System.err.println("Client exception: " + e.toString());
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }
      }
    }
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Customer)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi4;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.io.Serializable;
import java.rmi.RemoteException;
import java.io.Serializable;
import distributed.rmi4.UmpleRuntime;
public class Microwave extends CC implements java.io.Serializable
{  public void setRealObject(IMicrowaveImpl aObject)
  {
  super.setRealObject(aObject);
    realObject=aObject;
  }

  IMicrowaveImpl realObject;
  public Microwave(UmpleRuntime.UmpleComponent component)
  {
    if(this.getClass()== Microwave.class)    setRealObject(UmpleRuntime.getInstance().newMicrowave(component, this));
  }
  public Microwave()
  {
    if(this.getClass()== Microwave.class)    setRealObject(UmpleRuntime.getInstance().newMicrowave(this));
  }
  public void setSelf(Microwave proxy)
  {
    while(true)
      try{
        realObject.setSelf(proxy);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCode();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.delete();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public int method1(int f)
  {
    while(true)
      try{
        return realObject.method1(f);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Microwave)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;

import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
public class CustomerRemote implements ICustomerImpl
{
  Customer realObject;
  public void setRealObject(Customer aObject)
  {
    realObject=aObject;
  }
  public CustomerRemote()
  {}
  public CustomerRemote(Customer aObject)
  {
      realObject=aObject;
  }
  public int getHashCodeImpl()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setNameImpl(String aName)
  {
    while(true)
      try{
        return realObject.setNameImpl(aName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getNameImpl()
  {
    while(true)
      try{
        return realObject.getNameImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Vendor getVendorImpl(int index)
  {
    while(true)
      try{
        return realObject.getVendorImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Vendor> getVendorsImpl()
  {
    while(true)
      try{
        return realObject.getVendorsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfVendorsImpl()
  {
    while(true)
      try{
        return realObject.numberOfVendorsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasVendorsImpl()
  {
    while(true)
      try{
        return realObject.hasVendorsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfVendorImpl(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.indexOfVendorImpl(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrderImpl(int index)
  {
    while(true)
      try{
        return realObject.getOrderImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Order> getOrdersImpl()
  {
    while(true)
      try{
        return realObject.getOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrdersImpl()
  {
    while(true)
      try{
        return realObject.numberOfOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrdersImpl()
  {
    while(true)
      try{
        return realObject.hasOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrderImpl(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public SystemManager getSystemManagerImpl()
  {
    while(true)
      try{
        return realObject.getSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasSystemManagerImpl()
  {
    while(true)
      try{
        return realObject.hasSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addVendorImpl(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.addVendorImpl(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeVendorImpl(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.removeVendorImpl(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addVendorAtImpl(Vendor aVendor, int index)
  {
    while(true)
      try{
        return realObject.addVendorAtImpl(aVendor,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveVendorAtImpl(Vendor aVendor, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveVendorAtImpl(aVendor,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderImpl(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrderImpl(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAtImpl(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAtImpl(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setSystemManagerImpl(SystemManager aSystemManager)
  {
    while(true)
      try{
        return realObject.setSystemManagerImpl(aSystemManager);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void deleteImpl()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Order orderProductImpl(String productType, String vendorName)
  {
    while(true)
      try{
        return realObject.orderProductImpl(productType,vendorName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi2;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface IClientImpl extends java.rmi.Remote, ICCImpl
{
  public void setSelf(Client proxy) throws RemoteException;
  public int getHashCode() throws RemoteException;
  public void delete() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.io.Serializable;
import ecommerceRMI1.UmpleRuntime;
public class Customer implements java.io.Serializable
{  public void setRealObject(ICustomerImpl aObject)
  {
    realObject=aObject;
  }

  ICustomerImpl realObject;
  public Customer(String aName, UmpleRuntime.UmpleComponent component)
  {
    if(this.getClass()== Customer.class)    setRealObject(UmpleRuntime.getInstance().newCustomer(aName, component, this));
  }
  public Customer(String aName)
  {
    if(this.getClass()== Customer.class)    setRealObject(UmpleRuntime.getInstance().newCustomer(aName, this));
  }
  public void setSelf(Customer proxy)
  {
    while(true)
      try{
        realObject.setSelf(proxy);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCode();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setName(String aName)
  {
    while(true)
      try{
        return realObject.setName(aName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getName()
  {
    while(true)
      try{
        return realObject.getName();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Vendor getVendor(int index)
  {
    while(true)
      try{
        return realObject.getVendor(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Vendor> getVendors()
  {
    while(true)
      try{
        return realObject.getVendors();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfVendors()
  {
    while(true)
      try{
        return realObject.numberOfVendors();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasVendors()
  {
    while(true)
      try{
        return realObject.hasVendors();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfVendor(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.indexOfVendor(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrder(int index)
  {
    while(true)
      try{
        return realObject.getOrder(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Order> getOrders()
  {
    while(true)
      try{
        return realObject.getOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrders()
  {
    while(true)
      try{
        return realObject.numberOfOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrders()
  {
    while(true)
      try{
        return realObject.hasOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrder(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public SystemManager getSystemManager()
  {
    while(true)
      try{
        return realObject.getSystemManager();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasSystemManager()
  {
    while(true)
      try{
        return realObject.hasSystemManager();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public static int minimumNumberOfVendors()
  {
    while(true)
      try{
        return CustomerImpl.minimumNumberOfVendors();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addVendor(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.addVendor(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeVendor(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.removeVendor(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addVendorAt(Vendor aVendor, int index)
  {
    while(true)
      try{
        return realObject.addVendorAt(aVendor,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveVendorAt(Vendor aVendor, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveVendorAt(aVendor,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public static int minimumNumberOfOrders()
  {
    while(true)
      try{
        return CustomerImpl.minimumNumberOfOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrder(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrder(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAt(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAt(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    while(true)
      try{
        return realObject.setSystemManager(aSystemManager);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.delete();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Order orderProduct(String productType, String vendorName)
  {
    while(true)
      try{
        return realObject.orderProduct(productType,vendorName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Customer)obj).getHashCode());
  }
protected Customer(){}
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;

// line 100 "../ecommerceRMI0.ump"
public class Customer implements java.io.Serializable, ICustomerImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Customer Attributes
  private  transient String name;

  //Customer Associations
  private transient  List<Vendor> vendors;
  private transient  List<Order> orders;
  private transient  SystemManager systemManager;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Customer(String aName, UmpleRuntime.UmpleComponent umpleComponent)
  {
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Customer.class)
        UmpleRuntime.getInstance().newCustomer(aName, umpleComponent, this);

      return;
    }
    else
    {
      UmpleRuntime.getInstance().newCustomer(this);
    }

    name = aName;
    vendors = new ArrayList<Vendor>();
    orders = new ArrayList<Order>();
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public boolean setNameImpl(String aName)
  {
    boolean wasSet = false;
    name = aName;
    wasSet = true;
    return wasSet;
  }

  public String getNameImpl()
  {
    return name;
  }
  /* Code from template association_GetMany */
  public Vendor getVendorImpl(int index)
  {
    Vendor aVendor = vendors.get(index);
    return aVendor;
  }

  public List<Vendor> getVendorsImpl()
  {
    List<Vendor> newVendors = Collections.unmodifiableList(vendors);
    return newVendors;
  }

  public int numberOfVendorsImpl()
  {
    int number = vendors.size();
    return number;
  }

  public boolean hasVendorsImpl()
  {
    boolean has = vendors.size() > 0;
    return has;
  }

  public int indexOfVendorImpl(Vendor aVendor)
  {
    int index = vendors.indexOf(aVendor);
    return index;
  }
  /* Code from template association_GetMany */
  public Order getOrderImpl(int index)
  {
    Order aOrder = orders.get(index);
    return aOrder;
  }

  public List<Order> getOrdersImpl()
  {
    List<Order> newOrders = Collections.unmodifiableList(orders);
    return newOrders;
  }

  public int numberOfOrdersImpl()
  {
    int number = orders.size();
    return number;
  }

  public boolean hasOrdersImpl()
  {
    boolean has = orders.size() > 0;
    return has;
  }

  public int indexOfOrderImpl(Order aOrder)
  {
    int index = orders.indexOf(aOrder);
    return index;
  }
  /* Code from template association_GetOne */
  public SystemManager getSystemManagerImpl()
  {
    return systemManager;
  }

  public boolean hasSystemManagerImpl()
  {
    boolean has = systemManager != null;
    return has;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfVendors()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addVendorImpl(Vendor aVendor)
  {
    boolean wasAdded = false;
    if (vendors.contains(aVendor)) { return false; }
    vendors.add(aVendor);
    if (aVendor.indexOfCustomer(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aVendor.addCustomer(this);
      if (!wasAdded)
      {
        vendors.remove(aVendor);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeVendorImpl(Vendor aVendor)
  {
    boolean wasRemoved = false;
    if (!vendors.contains(aVendor))
    {
      return wasRemoved;
    }

    int oldIndex = vendors.indexOf(aVendor);
    vendors.remove(oldIndex);
    if (aVendor.indexOfCustomer(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aVendor.removeCustomer(this);
      if (!wasRemoved)
      {
        vendors.add(oldIndex,aVendor);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addVendorAtImpl(Vendor aVendor, int index)
  {  
    boolean wasAdded = false;
    if(addVendor(aVendor))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfVendors()) { index = numberOfVendors() - 1; }
      vendors.remove(aVendor);
      vendors.add(index, aVendor);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveVendorAtImpl(Vendor aVendor, int index)
  {
    boolean wasAdded = false;
    if(vendors.contains(aVendor))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfVendors()) { index = numberOfVendors() - 1; }
      vendors.remove(aVendor);
      vendors.add(index, aVendor);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addVendorAt(aVendor, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfOrders()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addOrderImpl(Order aOrder)
  {
    boolean wasAdded = false;
    if (orders.contains(aOrder)) { return false; }
    Customer existingCustomer = aOrder.getCustomer();
    if (existingCustomer == null)
    {
      aOrder.setCustomer(this);
    }
    else if (!this.equals(existingCustomer))
    {
      existingCustomer.removeOrder(aOrder);
      addOrder(aOrder);
    }
    else
    {
      orders.add(aOrder);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeOrderImpl(Order aOrder)
  {
    boolean wasRemoved = false;
    if (orders.contains(aOrder))
    {
      orders.remove(aOrder);
      aOrder.setCustomer(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addOrderAtImpl(Order aOrder, int index)
  {  
    boolean wasAdded = false;
    if(addOrder(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveOrderAtImpl(Order aOrder, int index)
  {
    boolean wasAdded = false;
    if(orders.contains(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addOrderAt(aOrder, index);
    }
    return wasAdded;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setSystemManagerImpl(SystemManager aSystemManager)
  {
    boolean wasSet = false;
    SystemManager existingSystemManager = systemManager;
    systemManager = aSystemManager;
    if (existingSystemManager != null && !existingSystemManager.equals(aSystemManager))
    {
      existingSystemManager.removeCustomer(this);
    }
    if (aSystemManager != null)
    {
      aSystemManager.addCustomer(this);
    }
    wasSet = true;
    return wasSet;
  }

  public void deleteImpl()
  {
    ArrayList<Vendor> copyOfVendors = new ArrayList<Vendor>(vendors);
    vendors.clear();
    for(Vendor aVendor : copyOfVendors)
    {
      aVendor.removeCustomer(this);
    }
    while( !orders.isEmpty() )
    {
      orders.get(0).setCustomer(null);
    }
    if (systemManager != null)
    {
      SystemManager placeholderSystemManager = systemManager;
      this.systemManager = null;
      placeholderSystemManager.removeCustomer(this);
    }
  }

  // line 106 "../ecommerceRMI0.ump"
   public Order orderProductImpl(String productType, String vendorName){
    for(Vendor v: getVendors())
		{
			if(v.getName().equals(vendorName))
				return v.makeOrder(this,v.findProduct(new ProductType(productType)));
		}
		return null;
  }


  public String toString()
  {
    return super.toString() + "["+
            "name" + ":" + getName()+ "]" + System.getProperties().getProperty("line.separator") +
            "  " + "systemManager = "+(getSystemManager()!=null?Integer.toHexString(System.identityHashCode(getSystemManager())):"null");
  }
  public void setRealObject(ICustomerImpl aObject)
  {
    realObject=aObject;
  }

  transient ICustomerImpl realObject=this;
  public Customer(String aName)
  {

this(aName,UmpleRuntime.getComponent("Customer"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setName(String aName)
  {
    while(true)
      try{
        return realObject.setNameImpl(aName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getName()
  {
    while(true)
      try{
        return realObject.getNameImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Vendor getVendor(int index)
  {
    while(true)
      try{
        return realObject.getVendorImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Vendor> getVendors()
  {
    while(true)
      try{
        return realObject.getVendorsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfVendors()
  {
    while(true)
      try{
        return realObject.numberOfVendorsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasVendors()
  {
    while(true)
      try{
        return realObject.hasVendorsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfVendor(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.indexOfVendorImpl(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrder(int index)
  {
    while(true)
      try{
        return realObject.getOrderImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Order> getOrders()
  {
    while(true)
      try{
        return realObject.getOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrders()
  {
    while(true)
      try{
        return realObject.numberOfOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrders()
  {
    while(true)
      try{
        return realObject.hasOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public SystemManager getSystemManager()
  {
    while(true)
      try{
        return realObject.getSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasSystemManager()
  {
    while(true)
      try{
        return realObject.hasSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addVendor(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.addVendorImpl(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeVendor(Vendor aVendor)
  {
    while(true)
      try{
        return realObject.removeVendorImpl(aVendor);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addVendorAt(Vendor aVendor, int index)
  {
    while(true)
      try{
        return realObject.addVendorAtImpl(aVendor,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveVendorAt(Vendor aVendor, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveVendorAtImpl(aVendor,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    while(true)
      try{
        return realObject.setSystemManagerImpl(aSystemManager);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Order orderProduct(String productType, String vendorName)
  {
    while(true)
      try{
        return realObject.orderProductImpl(productType,vendorName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  protected  ICustomerImpl remoteObject;  
  public void setRemoteObject(ICustomerImpl aRemoteObject)
  {
    remoteObject=aRemoteObject;
  }
  public ICustomerImpl getRemoteObject()
  {
    return (ICustomerImpl)remoteObject;
  }
  private void readObject(java.io.ObjectInputStream in) throws Exception
  {
    try
    {
      in.defaultReadObject();
      realObject=(ICustomerImpl)remoteObject;
    }
    catch(Exception e)
    {
      throw e;
    }
    
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Customer)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi4;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface ICCImpl extends java.rmi.Remote, IFatherImpl
{
  public void delete() throws RemoteException;
   public void someMethod1() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;

import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
public class SystemManagerRemote implements ISystemManagerImpl
{
  SystemManager realObject;
  public void setRealObject(SystemManager aObject)
  {
    realObject=aObject;
  }
  public SystemManagerRemote()
  {}
  public SystemManagerRemote(SystemManager aObject)
  {
      realObject=aObject;
  }
  public int getHashCodeImpl()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Agent getAgentImpl(int index)
  {
    while(true)
      try{
        return realObject.getAgentImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Agent> getAgentsImpl()
  {
    while(true)
      try{
        return realObject.getAgentsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfAgentsImpl()
  {
    while(true)
      try{
        return realObject.numberOfAgentsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasAgentsImpl()
  {
    while(true)
      try{
        return realObject.hasAgentsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfAgentImpl(Agent aAgent)
  {
    while(true)
      try{
        return realObject.indexOfAgentImpl(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Warehouse getWarehousImpl(int index)
  {
    while(true)
      try{
        return realObject.getWarehousImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Warehouse> getWarehousesImpl()
  {
    while(true)
      try{
        return realObject.getWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfWarehousesImpl()
  {
    while(true)
      try{
        return realObject.numberOfWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasWarehousesImpl()
  {
    while(true)
      try{
        return realObject.hasWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfWarehousImpl(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.indexOfWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Customer getCustomerImpl(int index)
  {
    while(true)
      try{
        return realObject.getCustomerImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Customer> getCustomersImpl()
  {
    while(true)
      try{
        return realObject.getCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfCustomersImpl()
  {
    while(true)
      try{
        return realObject.numberOfCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasCustomersImpl()
  {
    while(true)
      try{
        return realObject.hasCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfCustomerImpl(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.indexOfCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrderImpl(int index)
  {
    while(true)
      try{
        return realObject.getOrderImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Order> getOrdersImpl()
  {
    while(true)
      try{
        return realObject.getOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrdersImpl()
  {
    while(true)
      try{
        return realObject.numberOfOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrdersImpl()
  {
    while(true)
      try{
        return realObject.hasOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrderImpl(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addAgentImpl(Agent aAgent)
  {
    while(true)
      try{
        return realObject.addAgentImpl(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeAgentImpl(Agent aAgent)
  {
    while(true)
      try{
        return realObject.removeAgentImpl(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addAgentAtImpl(Agent aAgent, int index)
  {
    while(true)
      try{
        return realObject.addAgentAtImpl(aAgent,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveAgentAtImpl(Agent aAgent, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveAgentAtImpl(aAgent,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousImpl(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.addWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeWarehousImpl(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.removeWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomerImpl(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.addCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeCustomerImpl(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.removeCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomerAtImpl(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveCustomerAtImpl(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderImpl(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrderImpl(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAtImpl(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAtImpl(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void deleteImpl()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;

// line 60 "../ecommerceRMI0.ump"
public class Vendor extends Agent implements java.io.Serializable, IVendorImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Vendor Associations
  private transient  List<Order> orders;
  private transient  List<Customer> customers;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Vendor(String aName, UmpleRuntime.UmpleComponent umpleComponent)
  {
    super(aName,umpleComponent);
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Vendor.class)
        UmpleRuntime.getInstance().newVendor(aName, umpleComponent, this);

      return;
    }

    orders = new ArrayList<Order>();
    customers = new ArrayList<Customer>();
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public Order getOrderImpl(int index)
  {
    Order aOrder = orders.get(index);
    return aOrder;
  }

  public List<Order> getOrdersImpl()
  {
    List<Order> newOrders = Collections.unmodifiableList(orders);
    return newOrders;
  }

  public int numberOfOrdersImpl()
  {
    int number = orders.size();
    return number;
  }

  public boolean hasOrdersImpl()
  {
    boolean has = orders.size() > 0;
    return has;
  }

  public int indexOfOrderImpl(Order aOrder)
  {
    int index = orders.indexOf(aOrder);
    return index;
  }
  /* Code from template association_GetMany */
  public Customer getCustomerImpl(int index)
  {
    Customer aCustomer = customers.get(index);
    return aCustomer;
  }

  public List<Customer> getCustomersImpl()
  {
    List<Customer> newCustomers = Collections.unmodifiableList(customers);
    return newCustomers;
  }

  public int numberOfCustomersImpl()
  {
    int number = customers.size();
    return number;
  }

  public boolean hasCustomersImpl()
  {
    boolean has = customers.size() > 0;
    return has;
  }

  public int indexOfCustomerImpl(Customer aCustomer)
  {
    int index = customers.indexOf(aCustomer);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfOrders()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addOrderImpl(Order aOrder)
  {
    boolean wasAdded = false;
    if (orders.contains(aOrder)) { return false; }
    Vendor existingVendor = aOrder.getVendor();
    if (existingVendor == null)
    {
      aOrder.setVendor(this);
    }
    else if (!this.equals(existingVendor))
    {
      existingVendor.removeOrder(aOrder);
      addOrder(aOrder);
    }
    else
    {
      orders.add(aOrder);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeOrderImpl(Order aOrder)
  {
    boolean wasRemoved = false;
    if (orders.contains(aOrder))
    {
      orders.remove(aOrder);
      aOrder.setVendor(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addOrderAtImpl(Order aOrder, int index)
  {  
    boolean wasAdded = false;
    if(addOrder(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveOrderAtImpl(Order aOrder, int index)
  {
    boolean wasAdded = false;
    if(orders.contains(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addOrderAt(aOrder, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfCustomers()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addCustomerImpl(Customer aCustomer)
  {
    boolean wasAdded = false;
    if (customers.contains(aCustomer)) { return false; }
    customers.add(aCustomer);
    if (aCustomer.indexOfVendor(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aCustomer.addVendor(this);
      if (!wasAdded)
      {
        customers.remove(aCustomer);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeCustomerImpl(Customer aCustomer)
  {
    boolean wasRemoved = false;
    if (!customers.contains(aCustomer))
    {
      return wasRemoved;
    }

    int oldIndex = customers.indexOf(aCustomer);
    customers.remove(oldIndex);
    if (aCustomer.indexOfVendor(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aCustomer.removeVendor(this);
      if (!wasRemoved)
      {
        customers.add(oldIndex,aCustomer);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addCustomerAtImpl(Customer aCustomer, int index)
  {  
    boolean wasAdded = false;
    if(addCustomer(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveCustomerAtImpl(Customer aCustomer, int index)
  {
    boolean wasAdded = false;
    if(customers.contains(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addCustomerAt(aCustomer, index);
    }
    return wasAdded;
  }

  public void deleteImpl()
  {
    while( !orders.isEmpty() )
    {
      orders.get(0).setVendor(null);
    }
    ArrayList<Customer> copyOfCustomers = new ArrayList<Customer>(customers);
    customers.clear();
    for(Customer aCustomer : copyOfCustomers)
    {
      aCustomer.removeVendor(this);
    }
    super.delete();
  }

  // line 64 "../ecommerceRMI0.ump"
   public Product findProductImpl(ProductType productType){
    for(Warehouse w:getWarehouses())
		{
			Product p= w.findProduct(productType);
			if(p!=null)
				return p;		
		}
		return null;
  }

  // line 73 "../ecommerceRMI0.ump"
   public Order makeOrderImpl(Customer aCustomer, Product aProduct){
    if(aProduct==null)
			return null;
		Order aOrder= new Order(aProduct);
		aOrder.setCustomer(aCustomer);
		aOrder.setVendor(this);
		return aOrder;
  }

  public void setRealObject(IVendorImpl aObject)
  {
  super.setRealObject(aObject);
    realObject=aObject;
  }

  transient IVendorImpl realObject=this;
  public Vendor(String aName)
  {

this(aName,UmpleRuntime.getComponent("Vendor"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrder(int index)
  {
    while(true)
      try{
        return realObject.getOrderImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Order> getOrders()
  {
    while(true)
      try{
        return realObject.getOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrders()
  {
    while(true)
      try{
        return realObject.numberOfOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrders()
  {
    while(true)
      try{
        return realObject.hasOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Customer getCustomer(int index)
  {
    while(true)
      try{
        return realObject.getCustomerImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Customer> getCustomers()
  {
    while(true)
      try{
        return realObject.getCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfCustomers()
  {
    while(true)
      try{
        return realObject.numberOfCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasCustomers()
  {
    while(true)
      try{
        return realObject.hasCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.indexOfCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.addCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.removeCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Product findProduct(ProductType productType)
  {
    while(true)
      try{
        return realObject.findProductImpl(productType);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Order makeOrder(Customer aCustomer, Product aProduct)
  {
    while(true)
      try{
        return realObject.makeOrderImpl(aCustomer,aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  
  public void setRemoteObject(IVendorImpl aRemoteObject)
  {
    remoteObject=aRemoteObject;
  }
  public IVendorImpl getRemoteObject()
  {
    return (IVendorImpl)remoteObject;
  }
  private void readObject(java.io.ObjectInputStream in) throws Exception
  {
    try
    {
      in.defaultReadObject();
      realObject=(IVendorImpl)remoteObject;
    }
    catch(Exception e)
    {
      throw e;
    }
    
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Vendor)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
public interface ISystemManagerImpl extends java.rmi.Remote
{
  public void setSelf(SystemManager proxy) throws RemoteException;
  public int getHashCode() throws RemoteException;
  public Agent getAgent(int index) throws RemoteException;
  public List<Agent> getAgents() throws RemoteException;
  public int numberOfAgents() throws RemoteException;
  public boolean hasAgents() throws RemoteException;
  public int indexOfAgent(Agent aAgent) throws RemoteException;
  public Warehouse getWarehous(int index) throws RemoteException;
  public List<Warehouse> getWarehouses() throws RemoteException;
  public int numberOfWarehouses() throws RemoteException;
  public boolean hasWarehouses() throws RemoteException;
  public int indexOfWarehous(Warehouse aWarehous) throws RemoteException;
  public Customer getCustomer(int index) throws RemoteException;
  public List<Customer> getCustomers() throws RemoteException;
  public int numberOfCustomers() throws RemoteException;
  public boolean hasCustomers() throws RemoteException;
  public int indexOfCustomer(Customer aCustomer) throws RemoteException;
  public Order getOrder(int index) throws RemoteException;
  public List<Order> getOrders() throws RemoteException;
  public int numberOfOrders() throws RemoteException;
  public boolean hasOrders() throws RemoteException;
  public int indexOfOrder(Order aOrder) throws RemoteException;
  public boolean addAgent(Agent aAgent) throws RemoteException;
  public boolean removeAgent(Agent aAgent) throws RemoteException;
  public boolean addAgentAt(Agent aAgent, int index) throws RemoteException;
  public boolean addOrMoveAgentAt(Agent aAgent, int index) throws RemoteException;
  public boolean addWarehous(Warehouse aWarehous) throws RemoteException;
  public boolean removeWarehous(Warehouse aWarehous) throws RemoteException;
  public boolean addWarehousAt(Warehouse aWarehous, int index) throws RemoteException;
  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index) throws RemoteException;
  public boolean addCustomer(Customer aCustomer) throws RemoteException;
  public boolean removeCustomer(Customer aCustomer) throws RemoteException;
  public boolean addCustomerAt(Customer aCustomer, int index) throws RemoteException;
  public boolean addOrMoveCustomerAt(Customer aCustomer, int index) throws RemoteException;
  public boolean addOrder(Order aOrder) throws RemoteException;
  public boolean removeOrder(Order aOrder) throws RemoteException;
  public boolean addOrderAt(Order aOrder, int index) throws RemoteException;
  public boolean addOrMoveOrderAt(Order aOrder, int index) throws RemoteException;
  public void delete() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.util.*;
import java.io.Serializable;
import javax.xml.namespace.QName;
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import java.rmi.RemoteException;
@WebService
@SOAPBinding(style = Style.RPC)
public interface ISystemManagerImpl
{
@WebMethod
  public int getHashCodeImpl();
@WebMethod
  public Agent getAgentImpl(int index);
@WebMethod
  public int numberOfAgentsImpl();
@WebMethod
  public boolean hasAgentsImpl();
@WebMethod
  public int indexOfAgentImpl(Agent aAgent);
@WebMethod
  public Warehouse getWarehousImpl(int index);
@WebMethod
  public int numberOfWarehousesImpl();
@WebMethod
  public boolean hasWarehousesImpl();
@WebMethod
  public int indexOfWarehousImpl(Warehouse aWarehous);
@WebMethod
  public Customer getCustomerImpl(int index);
@WebMethod
  public int numberOfCustomersImpl();
@WebMethod
  public boolean hasCustomersImpl();
@WebMethod
  public int indexOfCustomerImpl(Customer aCustomer);
@WebMethod
  public Order getOrderImpl(int index);
@WebMethod
  public int numberOfOrdersImpl();
@WebMethod
  public boolean hasOrdersImpl();
@WebMethod
  public int indexOfOrderImpl(Order aOrder);
@WebMethod
  public boolean addAgentImpl(Agent aAgent);
@WebMethod
  public boolean removeAgentImpl(Agent aAgent);
@WebMethod
  public boolean addAgentAtImpl(Agent aAgent, int index);
@WebMethod
  public boolean addOrMoveAgentAtImpl(Agent aAgent, int index);
@WebMethod
  public boolean addWarehousImpl(Warehouse aWarehous);
@WebMethod
  public boolean removeWarehousImpl(Warehouse aWarehous);
@WebMethod
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index);
@WebMethod
  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index);
@WebMethod
  public boolean addCustomerImpl(Customer aCustomer);
@WebMethod
  public boolean removeCustomerImpl(Customer aCustomer);
@WebMethod
  public boolean addCustomerAtImpl(Customer aCustomer, int index);
@WebMethod
  public boolean addOrMoveCustomerAtImpl(Customer aCustomer, int index);
@WebMethod
  public boolean addOrderImpl(Order aOrder);
@WebMethod
  public boolean removeOrderImpl(Order aOrder);
@WebMethod
  public boolean addOrderAtImpl(Order aOrder, int index);
@WebMethod
  public boolean addOrMoveOrderAtImpl(Order aOrder, int index);
@WebMethod
  public void deleteImpl();
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;

// line 114 "../ecommerceRMI0.ump"
public class SystemManager implements java.io.Serializable, ISystemManagerImpl
{

  //------------------------
  // STATIC VARIABLES
  //------------------------

  private static SystemManager theInstance = null;

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //SystemManager Associations
  private transient  List<Agent> agents;
  private transient  List<Warehouse> warehouses;
  private transient  List<Customer> customers;
  private transient  List<Order> orders;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  private SystemManager(UmpleRuntime.UmpleComponent umpleComponent)
  {
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== SystemManager.class)
        UmpleRuntime.getInstance().newSystemManager( umpleComponent, this);

      return;
    }
    else
    {
      UmpleRuntime.getInstance().newSystemManager(this);
    }

    agents = new ArrayList<Agent>();
    warehouses = new ArrayList<Warehouse>();
    customers = new ArrayList<Customer>();
    orders = new ArrayList<Order>();
  }

  public static SystemManager getInstance()
  {
    if(theInstance == null)
    {
      theInstance = new SystemManager();
    }
    return theInstance;
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public Agent getAgentImpl(int index)
  {
    Agent aAgent = agents.get(index);
    return aAgent;
  }

  public List<Agent> getAgentsImpl()
  {
    List<Agent> newAgents = Collections.unmodifiableList(agents);
    return newAgents;
  }

  public int numberOfAgentsImpl()
  {
    int number = agents.size();
    return number;
  }

  public boolean hasAgentsImpl()
  {
    boolean has = agents.size() > 0;
    return has;
  }

  public int indexOfAgentImpl(Agent aAgent)
  {
    int index = agents.indexOf(aAgent);
    return index;
  }
  /* Code from template association_GetMany */
  public Warehouse getWarehousImpl(int index)
  {
    Warehouse aWarehous = warehouses.get(index);
    return aWarehous;
  }

  public List<Warehouse> getWarehousesImpl()
  {
    List<Warehouse> newWarehouses = Collections.unmodifiableList(warehouses);
    return newWarehouses;
  }

  public int numberOfWarehousesImpl()
  {
    int number = warehouses.size();
    return number;
  }

  public boolean hasWarehousesImpl()
  {
    boolean has = warehouses.size() > 0;
    return has;
  }

  public int indexOfWarehousImpl(Warehouse aWarehous)
  {
    int index = warehouses.indexOf(aWarehous);
    return index;
  }
  /* Code from template association_GetMany */
  public Customer getCustomerImpl(int index)
  {
    Customer aCustomer = customers.get(index);
    return aCustomer;
  }

  public List<Customer> getCustomersImpl()
  {
    List<Customer> newCustomers = Collections.unmodifiableList(customers);
    return newCustomers;
  }

  public int numberOfCustomersImpl()
  {
    int number = customers.size();
    return number;
  }

  public boolean hasCustomersImpl()
  {
    boolean has = customers.size() > 0;
    return has;
  }

  public int indexOfCustomerImpl(Customer aCustomer)
  {
    int index = customers.indexOf(aCustomer);
    return index;
  }
  /* Code from template association_GetMany */
  public Order getOrderImpl(int index)
  {
    Order aOrder = orders.get(index);
    return aOrder;
  }

  public List<Order> getOrdersImpl()
  {
    List<Order> newOrders = Collections.unmodifiableList(orders);
    return newOrders;
  }

  public int numberOfOrdersImpl()
  {
    int number = orders.size();
    return number;
  }

  public boolean hasOrdersImpl()
  {
    boolean has = orders.size() > 0;
    return has;
  }

  public int indexOfOrderImpl(Order aOrder)
  {
    int index = orders.indexOf(aOrder);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfAgents()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addAgentImpl(Agent aAgent)
  {
    boolean wasAdded = false;
    if (agents.contains(aAgent)) { return false; }
    SystemManager existingSystemManager = aAgent.getSystemManager();
    if (existingSystemManager == null)
    {
      aAgent.setSystemManager(this);
    }
    else if (!this.equals(existingSystemManager))
    {
      existingSystemManager.removeAgent(aAgent);
      addAgent(aAgent);
    }
    else
    {
      agents.add(aAgent);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeAgentImpl(Agent aAgent)
  {
    boolean wasRemoved = false;
    if (agents.contains(aAgent))
    {
      agents.remove(aAgent);
      aAgent.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addAgentAtImpl(Agent aAgent, int index)
  {  
    boolean wasAdded = false;
    if(addAgent(aAgent))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfAgents()) { index = numberOfAgents() - 1; }
      agents.remove(aAgent);
      agents.add(index, aAgent);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveAgentAtImpl(Agent aAgent, int index)
  {
    boolean wasAdded = false;
    if(agents.contains(aAgent))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfAgents()) { index = numberOfAgents() - 1; }
      agents.remove(aAgent);
      agents.add(index, aAgent);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addAgentAt(aAgent, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfWarehouses()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addWarehousImpl(Warehouse aWarehous)
  {
    boolean wasAdded = false;
    if (warehouses.contains(aWarehous)) { return false; }
    SystemManager existingSystemManager = aWarehous.getSystemManager();
    if (existingSystemManager == null)
    {
      aWarehous.setSystemManager(this);
    }
    else if (!this.equals(existingSystemManager))
    {
      existingSystemManager.removeWarehous(aWarehous);
      addWarehous(aWarehous);
    }
    else
    {
      warehouses.add(aWarehous);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeWarehousImpl(Warehouse aWarehous)
  {
    boolean wasRemoved = false;
    if (warehouses.contains(aWarehous))
    {
      warehouses.remove(aWarehous);
      aWarehous.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index)
  {  
    boolean wasAdded = false;
    if(addWarehous(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index)
  {
    boolean wasAdded = false;
    if(warehouses.contains(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addWarehousAt(aWarehous, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfCustomers()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addCustomerImpl(Customer aCustomer)
  {
    boolean wasAdded = false;
    if (customers.contains(aCustomer)) { return false; }
    SystemManager existingSystemManager = aCustomer.getSystemManager();
    if (existingSystemManager == null)
    {
      aCustomer.setSystemManager(this);
    }
    else if (!this.equals(existingSystemManager))
    {
      existingSystemManager.removeCustomer(aCustomer);
      addCustomer(aCustomer);
    }
    else
    {
      customers.add(aCustomer);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeCustomerImpl(Customer aCustomer)
  {
    boolean wasRemoved = false;
    if (customers.contains(aCustomer))
    {
      customers.remove(aCustomer);
      aCustomer.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addCustomerAtImpl(Customer aCustomer, int index)
  {  
    boolean wasAdded = false;
    if(addCustomer(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveCustomerAtImpl(Customer aCustomer, int index)
  {
    boolean wasAdded = false;
    if(customers.contains(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addCustomerAt(aCustomer, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfOrders()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addOrderImpl(Order aOrder)
  {
    boolean wasAdded = false;
    if (orders.contains(aOrder)) { return false; }
    SystemManager existingSystemManager = aOrder.getSystemManager();
    if (existingSystemManager == null)
    {
      aOrder.setSystemManager(this);
    }
    else if (!this.equals(existingSystemManager))
    {
      existingSystemManager.removeOrder(aOrder);
      addOrder(aOrder);
    }
    else
    {
      orders.add(aOrder);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeOrderImpl(Order aOrder)
  {
    boolean wasRemoved = false;
    if (orders.contains(aOrder))
    {
      orders.remove(aOrder);
      aOrder.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addOrderAtImpl(Order aOrder, int index)
  {  
    boolean wasAdded = false;
    if(addOrder(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveOrderAtImpl(Order aOrder, int index)
  {
    boolean wasAdded = false;
    if(orders.contains(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addOrderAt(aOrder, index);
    }
    return wasAdded;
  }

  public void deleteImpl()
  {
    while( !agents.isEmpty() )
    {
      agents.get(0).setSystemManager(null);
    }
    while( !warehouses.isEmpty() )
    {
      warehouses.get(0).setSystemManager(null);
    }
    while( !customers.isEmpty() )
    {
      customers.get(0).setSystemManager(null);
    }
    while( !orders.isEmpty() )
    {
      orders.get(0).setSystemManager(null);
    }
  }

  public void setRealObject(ISystemManagerImpl aObject)
  {
    realObject=aObject;
  }

  transient ISystemManagerImpl realObject=this;
  private SystemManager()
  {

this(UmpleRuntime.getComponent("SystemManager"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Agent getAgent(int index)
  {
    while(true)
      try{
        return realObject.getAgentImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Agent> getAgents()
  {
    while(true)
      try{
        return realObject.getAgentsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfAgents()
  {
    while(true)
      try{
        return realObject.numberOfAgentsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasAgents()
  {
    while(true)
      try{
        return realObject.hasAgentsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfAgent(Agent aAgent)
  {
    while(true)
      try{
        return realObject.indexOfAgentImpl(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Warehouse getWarehous(int index)
  {
    while(true)
      try{
        return realObject.getWarehousImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Warehouse> getWarehouses()
  {
    while(true)
      try{
        return realObject.getWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfWarehouses()
  {
    while(true)
      try{
        return realObject.numberOfWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasWarehouses()
  {
    while(true)
      try{
        return realObject.hasWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.indexOfWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Customer getCustomer(int index)
  {
    while(true)
      try{
        return realObject.getCustomerImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Customer> getCustomers()
  {
    while(true)
      try{
        return realObject.getCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfCustomers()
  {
    while(true)
      try{
        return realObject.numberOfCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasCustomers()
  {
    while(true)
      try{
        return realObject.hasCustomersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.indexOfCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrder(int index)
  {
    while(true)
      try{
        return realObject.getOrderImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Order> getOrders()
  {
    while(true)
      try{
        return realObject.getOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrders()
  {
    while(true)
      try{
        return realObject.numberOfOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrders()
  {
    while(true)
      try{
        return realObject.hasOrdersImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addAgent(Agent aAgent)
  {
    while(true)
      try{
        return realObject.addAgentImpl(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeAgent(Agent aAgent)
  {
    while(true)
      try{
        return realObject.removeAgentImpl(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addAgentAt(Agent aAgent, int index)
  {
    while(true)
      try{
        return realObject.addAgentAtImpl(aAgent,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveAgentAt(Agent aAgent, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveAgentAtImpl(aAgent,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.addWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.removeWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.addCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.removeCustomerImpl(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveCustomerAtImpl(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrderImpl(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAtImpl(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  protected  ISystemManagerImpl remoteObject;  
  public void setRemoteObject(ISystemManagerImpl aRemoteObject)
  {
    remoteObject=aRemoteObject;
  }
  public ISystemManagerImpl getRemoteObject()
  {
    return (ISystemManagerImpl)remoteObject;
  }
  private void readObject(java.io.ObjectInputStream in) throws Exception
  {
    try
    {
      in.defaultReadObject();
      realObject=(ISystemManagerImpl)remoteObject;
    }
    catch(Exception e)
    {
      throw e;
    }
    
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((SystemManager)obj).getHashCode());
  }  public static SystemManager getInstance(UmpleRuntime.UmpleComponent umpleComponent)
{
if(theInstance == null)
{
theInstance = new SystemManager(umpleComponent);
}
return theInstance;
}
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
public interface ISupplierImpl extends java.rmi.Remote, IAgentImpl
{
  public void setSelf(Supplier proxy) throws RemoteException;
  public int getHashCode() throws RemoteException;
  public Product getProduct(int index) throws RemoteException;
  public List<Product> getProducts() throws RemoteException;
  public int numberOfProducts() throws RemoteException;
  public boolean hasProducts() throws RemoteException;
  public int indexOfProduct(Product aProduct) throws RemoteException;
  public boolean addProduct(Product aProduct) throws RemoteException;
  public boolean removeProduct(Product aProduct) throws RemoteException;
  public boolean addProductAt(Product aProduct, int index) throws RemoteException;
  public boolean addOrMoveProductAt(Product aProduct, int index) throws RemoteException;
  public void delete() throws RemoteException;
   public Product createProduct(String serialNumber, String productType) throws RemoteException;
   public void putInWarehouse(Product aProduct, Warehouse warehouse) throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi4;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface IMicrowaveImpl extends java.rmi.Remote, ICCImpl
{
  public void setSelf(Microwave proxy) throws RemoteException;
  public int getHashCode() throws RemoteException;
  public void delete() throws RemoteException;
   public int method1(int f) throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi5;
import java.util.*;
import java.io.Serializable;

import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
public class MicrowaveRemote implements IMicrowaveImpl
{
  Microwave realObject;
  public void setRealObject(Microwave aObject)
  {
    realObject=aObject;
  }
  public MicrowaveRemote()
  {}
  public MicrowaveRemote(Microwave aObject)
  {
      realObject=aObject;
  }
  public int getHashCodeImpl()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setXImpl(int aX)
  {
    while(true)
      try{
        return realObject.setXImpl(aX);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setFImpl(String aF)
  {
    while(true)
      try{
        return realObject.setFImpl(aF);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int getXImpl()
  {
    while(true)
      try{
        return realObject.getXImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getFImpl()
  {
    while(true)
      try{
        return realObject.getFImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Client getClientImpl(int index)
  {
    while(true)
      try{
        return realObject.getClientImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Client> getClientsImpl()
  {
    while(true)
      try{
        return realObject.getClientsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfClientsImpl()
  {
    while(true)
      try{
        return realObject.numberOfClientsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasClientsImpl()
  {
    while(true)
      try{
        return realObject.hasClientsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfClientImpl(Client aClient)
  {
    while(true)
      try{
        return realObject.indexOfClientImpl(aClient);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addClientImpl(Client aClient)
  {
    while(true)
      try{
        return realObject.addClientImpl(aClient);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeClientImpl(Client aClient)
  {
    while(true)
      try{
        return realObject.removeClientImpl(aClient);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addClientAtImpl(Client aClient, int index)
  {
    while(true)
      try{
        return realObject.addClientAtImpl(aClient,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveClientAtImpl(Client aClient, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveClientAtImpl(aClient,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void deleteImpl()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi5;
import java.applet.*;
import java.util.*;
import java.io.Serializable;

// line 6 "../../Class_DistributableRMI5.ump"
// line 28 "../../Class_DistributableRMI5.ump"
public class Client implements java.io.Serializable, IClientImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Client Attributes
  private  transient String id;

  //Client Associations
  private transient  List<Microwave> microwaves;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Client(UmpleRuntime.UmpleComponent umpleComponent)
  {
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Client.class)
        UmpleRuntime.getInstance().newClient( umpleComponent, this);

      return;
    }
    else
    {
      UmpleRuntime.getInstance().newClient(this);
    }

    id = "s";
    microwaves = new ArrayList<Microwave>();
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public boolean setIdImpl(String aId)
  {
    boolean wasSet = false;
    id = aId;
    wasSet = true;
    return wasSet;
  }

  /**
   * isA ClientI;
   */
  public String getIdImpl()
  {
    return id;
  }
  /* Code from template association_GetMany */
  public Microwave getMicrowaveImpl(int index)
  {
    Microwave aMicrowave = microwaves.get(index);
    return aMicrowave;
  }

  public List<Microwave> getMicrowavesImpl()
  {
    List<Microwave> newMicrowaves = Collections.unmodifiableList(microwaves);
    return newMicrowaves;
  }

  public int numberOfMicrowavesImpl()
  {
    int number = microwaves.size();
    return number;
  }

  public boolean hasMicrowavesImpl()
  {
    boolean has = microwaves.size() > 0;
    return has;
  }

  public int indexOfMicrowaveImpl(Microwave aMicrowave)
  {
    int index = microwaves.indexOf(aMicrowave);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfMicrowaves()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addMicrowaveImpl(Microwave aMicrowave)
  {
    boolean wasAdded = false;
    if (microwaves.contains(aMicrowave)) { return false; }
    microwaves.add(aMicrowave);
    if (aMicrowave.indexOfClient(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aMicrowave.addClient(this);
      if (!wasAdded)
      {
        microwaves.remove(aMicrowave);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeMicrowaveImpl(Microwave aMicrowave)
  {
    boolean wasRemoved = false;
    if (!microwaves.contains(aMicrowave))
    {
      return wasRemoved;
    }

    int oldIndex = microwaves.indexOf(aMicrowave);
    microwaves.remove(oldIndex);
    if (aMicrowave.indexOfClient(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aMicrowave.removeClient(this);
      if (!wasRemoved)
      {
        microwaves.add(oldIndex,aMicrowave);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addMicrowaveAtImpl(Microwave aMicrowave, int index)
  {  
    boolean wasAdded = false;
    if(addMicrowave(aMicrowave))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfMicrowaves()) { index = numberOfMicrowaves() - 1; }
      microwaves.remove(aMicrowave);
      microwaves.add(index, aMicrowave);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveMicrowaveAtImpl(Microwave aMicrowave, int index)
  {
    boolean wasAdded = false;
    if(microwaves.contains(aMicrowave))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfMicrowaves()) { index = numberOfMicrowaves() - 1; }
      microwaves.remove(aMicrowave);
      microwaves.add(index, aMicrowave);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addMicrowaveAt(aMicrowave, index);
    }
    return wasAdded;
  }

  public void deleteImpl()
  {
    ArrayList<Microwave> copyOfMicrowaves = new ArrayList<Microwave>(microwaves);
    microwaves.clear();
    for(Microwave aMicrowave : copyOfMicrowaves)
    {
      aMicrowave.removeClient(this);
    }
  }


  /**
   * key{id}
   * isA CC;
   */
  // line 16 "../../Class_DistributableRMI5.ump"
   public static  void method2(){
    
  }

  // line 19 "../../Class_DistributableRMI5.ump"
   static  int method3(){
    return 12;
  }


  public String toString()
  {
    return super.toString() + "["+
            "id" + ":" + getId()+ "]";
  }
  public void setRealObject(IClientImpl aObject)
  {
    realObject=aObject;
  }

  transient IClientImpl realObject=this;
  public Client()
  {

this(UmpleRuntime.getComponent("Client"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setId(String aId)
  {
    while(true)
      try{
        return realObject.setIdImpl(aId);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getId()
  {
    while(true)
      try{
        return realObject.getIdImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Microwave getMicrowave(int index)
  {
    while(true)
      try{
        return realObject.getMicrowaveImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Microwave> getMicrowaves()
  {
    while(true)
      try{
        return realObject.getMicrowavesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfMicrowaves()
  {
    while(true)
      try{
        return realObject.numberOfMicrowavesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasMicrowaves()
  {
    while(true)
      try{
        return realObject.hasMicrowavesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfMicrowave(Microwave aMicrowave)
  {
    while(true)
      try{
        return realObject.indexOfMicrowaveImpl(aMicrowave);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addMicrowave(Microwave aMicrowave)
  {
    while(true)
      try{
        return realObject.addMicrowaveImpl(aMicrowave);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeMicrowave(Microwave aMicrowave)
  {
    while(true)
      try{
        return realObject.removeMicrowaveImpl(aMicrowave);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addMicrowaveAt(Microwave aMicrowave, int index)
  {
    while(true)
      try{
        return realObject.addMicrowaveAtImpl(aMicrowave,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveMicrowaveAt(Microwave aMicrowave, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveMicrowaveAtImpl(aMicrowave,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  protected  IClientImpl remoteObject;  
  public void setRemoteObject(IClientImpl aRemoteObject)
  {
    remoteObject=aRemoteObject;
  }
  public IClientImpl getRemoteObject()
  {
    return (IClientImpl)remoteObject;
  }
  private void readObject(java.io.ObjectInputStream in) throws Exception
  {
    try
    {
      in.defaultReadObject();
      realObject=(IClientImpl)remoteObject;
    }
    catch(Exception e)
    {
      throw e;
    }
    
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Client)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface ISystemManagerImpl extends java.rmi.Remote
{
  public int getHashCodeImpl() throws RemoteException;
  public Agent getAgentImpl(int index) throws RemoteException;
  public List<Agent> getAgentsImpl() throws RemoteException;
  public int numberOfAgentsImpl() throws RemoteException;
  public boolean hasAgentsImpl() throws RemoteException;
  public int indexOfAgentImpl(Agent aAgent) throws RemoteException;
  public Warehouse getWarehousImpl(int index) throws RemoteException;
  public List<Warehouse> getWarehousesImpl() throws RemoteException;
  public int numberOfWarehousesImpl() throws RemoteException;
  public boolean hasWarehousesImpl() throws RemoteException;
  public int indexOfWarehousImpl(Warehouse aWarehous) throws RemoteException;
  public Customer getCustomerImpl(int index) throws RemoteException;
  public List<Customer> getCustomersImpl() throws RemoteException;
  public int numberOfCustomersImpl() throws RemoteException;
  public boolean hasCustomersImpl() throws RemoteException;
  public int indexOfCustomerImpl(Customer aCustomer) throws RemoteException;
  public Order getOrderImpl(int index) throws RemoteException;
  public List<Order> getOrdersImpl() throws RemoteException;
  public int numberOfOrdersImpl() throws RemoteException;
  public boolean hasOrdersImpl() throws RemoteException;
  public int indexOfOrderImpl(Order aOrder) throws RemoteException;
  public boolean addAgentImpl(Agent aAgent) throws RemoteException;
  public boolean removeAgentImpl(Agent aAgent) throws RemoteException;
  public boolean addAgentAtImpl(Agent aAgent, int index) throws RemoteException;
  public boolean addOrMoveAgentAtImpl(Agent aAgent, int index) throws RemoteException;
  public boolean addWarehousImpl(Warehouse aWarehous) throws RemoteException;
  public boolean removeWarehousImpl(Warehouse aWarehous) throws RemoteException;
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index) throws RemoteException;
  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index) throws RemoteException;
  public boolean addCustomerImpl(Customer aCustomer) throws RemoteException;
  public boolean removeCustomerImpl(Customer aCustomer) throws RemoteException;
  public boolean addCustomerAtImpl(Customer aCustomer, int index) throws RemoteException;
  public boolean addOrMoveCustomerAtImpl(Customer aCustomer, int index) throws RemoteException;
  public boolean addOrderImpl(Order aOrder) throws RemoteException;
  public boolean removeOrderImpl(Order aOrder) throws RemoteException;
  public boolean addOrderAtImpl(Order aOrder, int index) throws RemoteException;
  public boolean addOrMoveOrderAtImpl(Order aOrder, int index) throws RemoteException;
  public void deleteImpl() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.util.*;
import java.io.Serializable;
import javax.xml.namespace.QName;
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import java.rmi.RemoteException;
@WebService
@SOAPBinding(style = Style.RPC)
public interface ICustomerImpl
{
@WebMethod
  public int getHashCodeImpl();
@WebMethod
  public boolean setNameImpl(String aName);
@WebMethod
  public String getNameImpl();
@WebMethod
  public Vendor getVendorImpl(int index);
@WebMethod
  public int numberOfVendorsImpl();
@WebMethod
  public boolean hasVendorsImpl();
@WebMethod
  public int indexOfVendorImpl(Vendor aVendor);
@WebMethod
  public Order getOrderImpl(int index);
@WebMethod
  public int numberOfOrdersImpl();
@WebMethod
  public boolean hasOrdersImpl();
@WebMethod
  public int indexOfOrderImpl(Order aOrder);
@WebMethod
  public SystemManager getSystemManagerImpl();
@WebMethod
  public boolean hasSystemManagerImpl();
@WebMethod
  public boolean addVendorImpl(Vendor aVendor);
@WebMethod
  public boolean removeVendorImpl(Vendor aVendor);
@WebMethod
  public boolean addVendorAtImpl(Vendor aVendor, int index);
@WebMethod
  public boolean addOrMoveVendorAtImpl(Vendor aVendor, int index);
@WebMethod
  public boolean addOrderImpl(Order aOrder);
@WebMethod
  public boolean removeOrderImpl(Order aOrder);
@WebMethod
  public boolean addOrderAtImpl(Order aOrder, int index);
@WebMethod
  public boolean addOrMoveOrderAtImpl(Order aOrder, int index);
@WebMethod
  public boolean setSystemManagerImpl(SystemManager aSystemManager);
@WebMethod
  public void deleteImpl();
@WebMethod
   public Order orderProductImpl(String productType, String vendorName);
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.util.*;
import java.io.Serializable;
import javax.xml.namespace.QName;
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import java.rmi.RemoteException;
@WebService
@SOAPBinding(style = Style.RPC)
public interface IVendorImpl extends IAgentImpl
{
@WebMethod
  public int getHashCodeImpl();
@WebMethod
  public Warehouse getWarehousImpl(int index);
@WebMethod
  public int numberOfWarehousesImpl();
@WebMethod
  public boolean hasWarehousesImpl();
@WebMethod
  public int indexOfWarehousImpl(Warehouse aWarehous);
@WebMethod
  public Order getOrderImpl(int index);
@WebMethod
  public int numberOfOrdersImpl();
@WebMethod
  public boolean hasOrdersImpl();
@WebMethod
  public int indexOfOrderImpl(Order aOrder);
@WebMethod
  public Customer getCustomerImpl(int index);
@WebMethod
  public int numberOfCustomersImpl();
@WebMethod
  public boolean hasCustomersImpl();
@WebMethod
  public int indexOfCustomerImpl(Customer aCustomer);
@WebMethod
  public boolean addWarehousImpl(Warehouse aWarehous);
@WebMethod
  public boolean removeWarehousImpl(Warehouse aWarehous);
@WebMethod
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index);
@WebMethod
  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index);
@WebMethod
  public boolean addOrderImpl(Order aOrder);
@WebMethod
  public boolean removeOrderImpl(Order aOrder);
@WebMethod
  public boolean addOrderAtImpl(Order aOrder, int index);
@WebMethod
  public boolean addOrMoveOrderAtImpl(Order aOrder, int index);
@WebMethod
  public boolean addCustomerImpl(Customer aCustomer);
@WebMethod
  public boolean removeCustomerImpl(Customer aCustomer);
@WebMethod
  public boolean addCustomerAtImpl(Customer aCustomer, int index);
@WebMethod
  public boolean addOrMoveCustomerAtImpl(Customer aCustomer, int index);
@WebMethod
  public void deleteImpl();
@WebMethod
   public Product findProductImpl(ProductType productType);
@WebMethod
   public Order makeOrderImpl(Customer aCustomer, Product aProduct);
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.io.Serializable;
import javax.xml.namespace.QName;
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;

// line 34 "../ecommerceWS.ump"
@WebService(endpointInterface = "ecommerceWS.IAgentImpl")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(factoryMethod="umplenewInstance", propOrder={"remoteUrl", "objectId", "remotePort"})
public class Agent implements java.io.Serializable, IAgentImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Agent Attributes
  private  transient String name;

  //Agent Associations
  private transient  SystemManager systemManager;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Agent(String aName, UmpleRuntime.UmpleComponent umpleComponent)
  {
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Agent.class)
        UmpleRuntime.getInstance().newAgent(aName, umpleComponent, this);

      return;
    }
    else
    {
      UmpleRuntime.getInstance().newAgent(this);
    }

    name = aName;
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public boolean setNameImpl(String aName)
  {
    boolean wasSet = false;
    name = aName;
    wasSet = true;
    return wasSet;
  }

  public String getNameImpl()
  {
    return name;
  }
  /* Code from template association_GetOne */
  public SystemManager getSystemManagerImpl()
  {
    return systemManager;
  }

  public boolean hasSystemManagerImpl()
  {
    boolean has = systemManager != null;
    return has;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setSystemManagerImpl(SystemManager aSystemManager)
  {
    boolean wasSet = false;
    SystemManager existingSystemManager = systemManager;
    systemManager = aSystemManager;
    if (existingSystemManager != null && !existingSystemManager.equals(aSystemManager))
    {
      existingSystemManager.removeAgent(this);
    }
    if (aSystemManager != null)
    {
      aSystemManager.addAgent(this);
    }
    wasSet = true;
    return wasSet;
  }

  public void deleteImpl()
  {
    if (systemManager != null)
    {
      SystemManager placeholderSystemManager = systemManager;
      this.systemManager = null;
      placeholderSystemManager.removeAgent(this);
    }
  }


  public String toString()
  {
    return super.toString() + "["+
            "name" + ":" + getName()+ "]" + System.getProperties().getProperty("line.separator") +
            "  " + "systemManager = "+(getSystemManager()!=null?Integer.toHexString(System.identityHashCode(getSystemManager())):"null");
  }

  transient IAgentImpl realObject=this;
  public Agent(String aName)
  {

this(aName,UmpleRuntime.getComponent("Agent"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setName(String aName)
  {
    while(true)
      try{
        return realObject.setNameImpl(aName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getName()
  {
    while(true)
      try{
        return realObject.getNameImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public SystemManager getSystemManager()
  {
    while(true)
      try{
        return realObject.getSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasSystemManager()
  {
    while(true)
      try{
        return realObject.hasSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    while(true)
      try{
        return realObject.setSystemManagerImpl(aSystemManager);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }


  public  String remoteUrl;
  public  String objectId;
  public  String remotePort; 
  private static Agent umplenewInstance()
  {
    return new Agent((UmpleRuntime.UmpleNode)null);
  }   

  protected Agent (UmpleRuntime.UmpleNode node)
  {
  }

  public void setRealObject(IAgentImpl aObject)
  {
    realObject=aObject;
  }
  void afterUnmarshal(Unmarshaller u, Object parent)
  {
    initializeConnection();
  }
  private void initializeConnection()
  {
    if(objectId.contains(Agent.class.getName()))
    {  
      boolean success = false;
      while (!success) {        
        try 
        {
          URL url = new URL(remoteUrl+":"+remotePort+"/Agent"+objectId+"?wsdl");
          QName qname = new QName("https://ecommerceWS/","AgentService");
          Service service = Service.create(url, qname);
          setRealObject(service.getPort(IAgentImpl.class));
          success = true;
        } 
        catch (Exception e) 
        {
          System.err.println("Client exception: " + e.toString());
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }
      }
    }
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Agent)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;

// line 38 "../ecommerceWS.ump"
@XmlAccessorType(XmlAccessType.FIELD)

public class Order implements java.io.Serializable
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Order Associations
  private Customer customer;
  private Vendor vendor;
  private Product product;
  private SystemManager systemManager;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Order(Product aProduct)
  {
    if (!setProduct(aProduct))
    {
      throw new RuntimeException("Unable to create Order due to aProduct. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetOne */
  public Customer getCustomer()
  {
    return customer;
  }

  public boolean hasCustomer()
  {
    boolean has = customer != null;
    return has;
  }
  /* Code from template association_GetOne */
  public Vendor getVendor()
  {
    return vendor;
  }

  public boolean hasVendor()
  {
    boolean has = vendor != null;
    return has;
  }
  /* Code from template association_GetOne */
  public Product getProduct()
  {
    return product;
  }
  /* Code from template association_GetOne */
  public SystemManager getSystemManager()
  {
    return systemManager;
  }

  public boolean hasSystemManager()
  {
    boolean has = systemManager != null;
    return has;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setCustomer(Customer aCustomer)
  {
    boolean wasSet = false;
    Customer existingCustomer = customer;
    customer = aCustomer;
    if (existingCustomer != null && !existingCustomer.equals(aCustomer))
    {
      existingCustomer.removeOrder(this);
    }
    if (aCustomer != null)
    {
      aCustomer.addOrder(this);
    }
    wasSet = true;
    return wasSet;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setVendor(Vendor aVendor)
  {
    boolean wasSet = false;
    Vendor existingVendor = vendor;
    vendor = aVendor;
    if (existingVendor != null && !existingVendor.equals(aVendor))
    {
      existingVendor.removeOrder(this);
    }
    if (aVendor != null)
    {
      aVendor.addOrder(this);
    }
    wasSet = true;
    return wasSet;
  }
  /* Code from template association_SetUnidirectionalOne */
  public boolean setProduct(Product aNewProduct)
  {
    boolean wasSet = false;
    if (aNewProduct != null)
    {
      product = aNewProduct;
      wasSet = true;
    }
    return wasSet;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    boolean wasSet = false;
    SystemManager existingSystemManager = systemManager;
    systemManager = aSystemManager;
    if (existingSystemManager != null && !existingSystemManager.equals(aSystemManager))
    {
      existingSystemManager.removeOrder(this);
    }
    if (aSystemManager != null)
    {
      aSystemManager.addOrder(this);
    }
    wasSet = true;
    return wasSet;
  }

  public void delete()
  {
    if (customer != null)
    {
      Customer placeholderCustomer = customer;
      this.customer = null;
      placeholderCustomer.removeOrder(this);
    }
    if (vendor != null)
    {
      Vendor placeholderVendor = vendor;
      this.vendor = null;
      placeholderVendor.removeOrder(this);
    }
    product = null;
    if (systemManager != null)
    {
      SystemManager placeholderSystemManager = systemManager;
      this.systemManager = null;
      placeholderSystemManager.removeOrder(this);
    }
  }

  // line 41 "../ecommerceWS.ump"
   public  Order(){
    
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

// line 116 "../ecommerceRMI1.ump"
public class SystemManagerImpl implements java.io.Serializable , ISystemManagerImpl
{

  //------------------------
  // STATIC VARIABLES
  //------------------------

  private static SystemManagerImpl theInstance = null;

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //SystemManagerImpl Associations
  private List<Agent> agents;
  private List<Warehouse> warehouses;
  private List<Customer> customers;
  private List<Order> orders;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  private SystemManagerImpl()
  {
    agents = new ArrayList<Agent>();
    warehouses = new ArrayList<Warehouse>();
    customers = new ArrayList<Customer>();
    orders = new ArrayList<Order>();
  }

  public static SystemManagerImpl getInstance()
  {
    if(theInstance == null)
    {
      theInstance = new SystemManagerImpl();
    }
    return theInstance;
  }
  //------------------------
  // Reference to the proxy
  //------------------------
  SystemManager self;
  
  public void setSelf(SystemManager proxy)
  {
    self=proxy;
  }

  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCode()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public Agent getAgent(int index)
  {
    Agent aAgent = agents.get(index);
    return aAgent;
  }

  public List<Agent> getAgents()
  {
    List<Agent> newAgents = Collections.unmodifiableList(agents);
    return newAgents;
  }

  public int numberOfAgents()
  {
    int number = agents.size();
    return number;
  }

  public boolean hasAgents()
  {
    boolean has = agents.size() > 0;
    return has;
  }

  public int indexOfAgent(Agent aAgent)
  {
    int index = agents.indexOf(aAgent);
    return index;
  }
  /* Code from template association_GetMany */
  public Warehouse getWarehous(int index)
  {
    Warehouse aWarehous = warehouses.get(index);
    return aWarehous;
  }

  public List<Warehouse> getWarehouses()
  {
    List<Warehouse> newWarehouses = Collections.unmodifiableList(warehouses);
    return newWarehouses;
  }

  public int numberOfWarehouses()
  {
    int number = warehouses.size();
    return number;
  }

  public boolean hasWarehouses()
  {
    boolean has = warehouses.size() > 0;
    return has;
  }

  public int indexOfWarehous(Warehouse aWarehous)
  {
    int index = warehouses.indexOf(aWarehous);
    return index;
  }
  /* Code from template association_GetMany */
  public Customer getCustomer(int index)
  {
    Customer aCustomer = customers.get(index);
    return aCustomer;
  }

  public List<Customer> getCustomers()
  {
    List<Customer> newCustomers = Collections.unmodifiableList(customers);
    return newCustomers;
  }

  public int numberOfCustomers()
  {
    int number = customers.size();
    return number;
  }

  public boolean hasCustomers()
  {
    boolean has = customers.size() > 0;
    return has;
  }

  public int indexOfCustomer(Customer aCustomer)
  {
    int index = customers.indexOf(aCustomer);
    return index;
  }
  /* Code from template association_GetMany */
  public Order getOrder(int index)
  {
    Order aOrder = orders.get(index);
    return aOrder;
  }

  public List<Order> getOrders()
  {
    List<Order> newOrders = Collections.unmodifiableList(orders);
    return newOrders;
  }

  public int numberOfOrders()
  {
    int number = orders.size();
    return number;
  }

  public boolean hasOrders()
  {
    boolean has = orders.size() > 0;
    return has;
  }

  public int indexOfOrder(Order aOrder)
  {
    int index = orders.indexOf(aOrder);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfAgents()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addAgent(Agent aAgent)
  {
    boolean wasAdded = false;
    if (agents.contains(aAgent)) { return false; }
    SystemManager existingSystemManager = aAgent.getSystemManager();
    if (existingSystemManager == null)
    {
      aAgent.setSystemManager(self);
    }
    else if (!self.equals(existingSystemManager))
    {
      existingSystemManager.removeAgent(aAgent);
      addAgent(aAgent);
    }
    else
    {
      agents.add(aAgent);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeAgent(Agent aAgent)
  {
    boolean wasRemoved = false;
    if (agents.contains(aAgent))
    {
      agents.remove(aAgent);
      aAgent.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addAgentAt(Agent aAgent, int index)
  {  
    boolean wasAdded = false;
    if(addAgent(aAgent))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfAgents()) { index = numberOfAgents() - 1; }
      agents.remove(aAgent);
      agents.add(index, aAgent);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveAgentAt(Agent aAgent, int index)
  {
    boolean wasAdded = false;
    if(agents.contains(aAgent))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfAgents()) { index = numberOfAgents() - 1; }
      agents.remove(aAgent);
      agents.add(index, aAgent);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addAgentAt(aAgent, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfWarehouses()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addWarehous(Warehouse aWarehous)
  {
    boolean wasAdded = false;
    if (warehouses.contains(aWarehous)) { return false; }
    SystemManager existingSystemManager = aWarehous.getSystemManager();
    if (existingSystemManager == null)
    {
      aWarehous.setSystemManager(self);
    }
    else if (!self.equals(existingSystemManager))
    {
      existingSystemManager.removeWarehous(aWarehous);
      addWarehous(aWarehous);
    }
    else
    {
      warehouses.add(aWarehous);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeWarehous(Warehouse aWarehous)
  {
    boolean wasRemoved = false;
    if (warehouses.contains(aWarehous))
    {
      warehouses.remove(aWarehous);
      aWarehous.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addWarehousAt(Warehouse aWarehous, int index)
  {  
    boolean wasAdded = false;
    if(addWarehous(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index)
  {
    boolean wasAdded = false;
    if(warehouses.contains(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addWarehousAt(aWarehous, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfCustomers()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addCustomer(Customer aCustomer)
  {
    boolean wasAdded = false;
    if (customers.contains(aCustomer)) { return false; }
    SystemManager existingSystemManager = aCustomer.getSystemManager();
    if (existingSystemManager == null)
    {
      aCustomer.setSystemManager(self);
    }
    else if (!self.equals(existingSystemManager))
    {
      existingSystemManager.removeCustomer(aCustomer);
      addCustomer(aCustomer);
    }
    else
    {
      customers.add(aCustomer);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeCustomer(Customer aCustomer)
  {
    boolean wasRemoved = false;
    if (customers.contains(aCustomer))
    {
      customers.remove(aCustomer);
      aCustomer.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addCustomerAt(Customer aCustomer, int index)
  {  
    boolean wasAdded = false;
    if(addCustomer(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveCustomerAt(Customer aCustomer, int index)
  {
    boolean wasAdded = false;
    if(customers.contains(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addCustomerAt(aCustomer, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfOrders()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addOrder(Order aOrder)
  {
    boolean wasAdded = false;
    if (orders.contains(aOrder)) { return false; }
    SystemManager existingSystemManager = aOrder.getSystemManager();
    if (existingSystemManager == null)
    {
      aOrder.setSystemManager(self);
    }
    else if (!self.equals(existingSystemManager))
    {
      existingSystemManager.removeOrder(aOrder);
      addOrder(aOrder);
    }
    else
    {
      orders.add(aOrder);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeOrder(Order aOrder)
  {
    boolean wasRemoved = false;
    if (orders.contains(aOrder))
    {
      orders.remove(aOrder);
      aOrder.setSystemManager(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addOrderAt(Order aOrder, int index)
  {  
    boolean wasAdded = false;
    if(addOrder(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    boolean wasAdded = false;
    if(orders.contains(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addOrderAt(aOrder, index);
    }
    return wasAdded;
  }

  public void delete()
  {
    while( !agents.isEmpty() )
    {
      agents.get(0).setSystemManager(null);
    }
    while( !warehouses.isEmpty() )
    {
      warehouses.get(0).setSystemManager(null);
    }
    while( !customers.isEmpty() )
    {
      customers.get(0).setSystemManager(null);
    }
    while( !orders.isEmpty() )
    {
      orders.get(0).setSystemManager(null);
    }
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/
package distributed.rmi5;
import java.rmi.Remote;
import java.util.Properties;
import java.applet.*;
import java.io.*;
import java.io.IOException;
import java.io.FileInputStream;
import java.rmi.registry.Registry;
import java.io.InputStreamReader;
import java.io.File;
import distributed.rmi5.Microwave;
import java.rmi.RemoteException;
import java.io.Serializable;
import distributed.rmi5.Client;
import java.util.regex.Matcher;
import java.rmi.registry.LocateRegistry;
import java.util.*;
import java.rmi.server.UnicastRemoteObject;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.Pattern;
import java.io.InputStream;
public class UmpleRuntime implements IUmpleRuntime
{ 
  private static Boolean isAlive = true;
  static int thisNodeId=-1;
  private int numberOfNodes=0;
  private static String fileAddress="";
  static HashMap<Integer, UmpleNode> nodes=new HashMap<Integer, UmpleNode>();
  static HashMap <String, UmpleComponent> components= new HashMap<String, UmpleComponent>();
  public static void setFileAddress(String address)
  {
    fileAddress=address;
  }
  public static int getThisNodeId()
  {
    return thisNodeId;
  }
    private static void setThisNodeId(int id)
  {
    thisNodeId=id;
  }  


  private static void readPropertiesFile()
  {
      String location="configuration.txt";
      Properties prop = new Properties();
      InputStream input = null;

    try {

      input = new FileInputStream("node.properties");
      prop.load(input);
      if(getThisNodeId()<0)
        setThisNodeId(Integer.parseInt(prop.getProperty("name")));
      location=prop.getProperty("location");
      setFileAddress(location);
    } catch (IOException e)
    {
      e.printStackTrace();
      if(getThisNodeId()<0)
        setThisNodeId(0); 
      setFileAddress(location);   
    } 
    finally {
      if (input != null) {
        try {
          input.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
  public static UmpleComponent getComponent(String runtimeComponentName)
  {
    getInstance();
    UmpleComponent aComponent=components.get(runtimeComponentName.toLowerCase());
    if (aComponent!=null)
      return aComponent;
    else
      return components.get("local");  
  }

  public static void stopAll()
  {
    UmpleRuntime.getInstance().stopAllNodes();
  }
  public void stopAllNodes()
  {
    for(int node=0;node<numberOfNodes;node=node+1)
    {
      if(node!=getThisNodeId())
      {
        try
        {
          remoteFactories.get(node).stopNode();
        }
        catch(Exception e) {System.err.println(e.toString());}
      } 
    }
    stopNode(); 
  }
// ******************************** Factory
    public static UmpleRuntime theInstance = null;
    List<IUmpleRuntime> remoteFactories;

    public List<Object> listOfObjects;
    public static UmpleRuntime getInstance()
    {
      if(theInstance==null){
        theInstance = new UmpleRuntime();
        }
      return theInstance;
    }
   
    private UmpleRuntime()
    { 
      listOfObjects=new ArrayList<Object>();
      remoteFactories= new ArrayList<IUmpleRuntime>();
      initialize();
    }
    public int getNodeId(int umpleNodeId)
    {
      int nodeId=umpleNodeId;
      if(nodeId>=numberOfNodes)
        nodeId=numberOfNodes-1;
      return nodeId;
    }
    public int getNodeId(UmpleComponent umpleComponent)
    {
      return umpleComponent.getNode().getId();
    }

    private void readConfigFile()
    {
      String input="{id=0; port=1099; https://localhost {component1}}{id=1; port=1700; https://localhost {component2}}";
      try (BufferedReader br = new BufferedReader(new FileReader(fileAddress))) {
        input="";
        String line;
        while ((line = br.readLine()) != null) {
           // Merging the lines
          input+=line+";";
        }
      }
      catch (IOException e)
      {
        e.printStackTrace();   
      }
      finally {
        if (input != null)
        {
          int startIndex=input.indexOf("{");
          if(startIndex>=0)
          //while(startIndex>=0)
          { 
            Pattern pattern1 = Pattern.compile("([\\{|\\(])([^\\}\\)]+)([\\{|\\(])");
            Pattern pattern2 = Pattern.compile("([\\}|\\)])([^\\{\\(]+)([\\}|\\)])");
            Pattern pattern3 = Pattern.compile("([\\{|\\(])([^\\{\\(\\}\\)]+)([\\}|\\)])");
            Pattern patternURL = Pattern.compile("(url)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)");
            Pattern patternName = Pattern.compile("(id)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)");
            Pattern patternPort = Pattern.compile("(port)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)"); 
            Pattern patternIp = Pattern.compile("(ip)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)"); 
            Pattern patternComponent = Pattern.compile("(\\s*)([^;,\\s]*)(\\s*)([,|;|\\r\\n|\\t])");                 
            Matcher matcher1 = pattern1.matcher(input); 
            Matcher matcher2 = pattern2.matcher(input);
            Matcher matcher3 = pattern3.matcher(input);
            String url="";
            String ip="";
            String name="";
            int port=1111;
            String part1="";
            String part2="";
            String part3="";
            String runtimeComponents="";
            String machine="";
            Boolean condition1=matcher1.find();
            Boolean condition2=matcher2.find();
            Boolean condition3=matcher3.find();
            while (condition1||condition2||condition3) 
            { 
              url="https://localhost";
              ip="localhost";
              name="";
              port=1111;
              part1="";
              part2="";
              part3="";
              runtimeComponents="";
              machine="";
              if(condition1)
                part1=matcher1.group(2);
              if(condition2)
                part2=matcher2.group(2);
              if(condition3)
                part3=matcher3.group(2);
              
              if(condition1&&matcher3.end()>matcher1.end())
              {
                machine=part1.toLowerCase()+part2.toLowerCase();
                runtimeComponents=part3.toLowerCase()+";";
                condition1=matcher1.find();
                condition2=matcher2.find();
                condition3=matcher3.find();
              }else
              {
                machine=part3.toLowerCase();
                condition3=matcher3.find();
              }
              Matcher matcherURL = patternURL.matcher(machine);
              if(matcherURL.find())
                url=matcherURL.group(3);

              Matcher matcherName = patternName.matcher(machine);
              if(matcherName.find())
                name=matcherName.group(3);

              Matcher matcherIp = patternIp.matcher(machine);
              if(matcherIp.find())
                ip=matcherIp.group(3);

              Matcher matcherPort = patternPort.matcher(machine);
              if(matcherPort.find())
                port=Integer.parseInt(matcherPort.group(3));
              UmpleNode aNode= new UmpleNode(Integer.parseInt(name));
              Matcher matcherComponent = patternComponent.matcher(runtimeComponents);
              while(matcherComponent.find())
              { String component=matcherComponent.group(2);
                UmpleComponent aComponent=new UmpleComponent(component,aNode);
                components.put(component,aComponent);
              }
              if(aNode.getId()==getThisNodeId())
              {
                UmpleComponent aComponent=new UmpleComponent("local",aNode);
                components.put("local",aComponent);
              }
              aNode.setPort(port);
              aNode.setUrl(url);
              aNode.setIp(ip);
              nodes.put(aNode.getId(),aNode);
            }
          }      
        }    
      }
    }
    Registry rmiRegistry;
    public void initialize()
    {    

      if(fileAddress.equals(""))
        readPropertiesFile();
      readConfigFile();
      numberOfNodes= nodes.size();
      startRMI();
      for(int node=0;node<numberOfNodes;node=node+1)
      {
        if(node==getThisNodeId())
        {
          remoteFactories.add(this);
        }
        else
        {
          System.out.println("connecting to node: "+node);
          Boolean success=false;
          while(!success)
          {
            try 
            {
              Registry registry = LocateRegistry.getRegistry(nodes.get(node).getIp(),nodes.get(node).getPort());
              IUmpleRuntime stub = (IUmpleRuntime) registry.lookup("UmpleRuntime"+String.valueOf(node));
              remoteFactories.add(stub);
              success=true;
            } 
            catch (Exception e) 
            {
              System.err.println("Client exception: " + e.toString());
              e.printStackTrace();
              try { Thread.sleep(5000); } catch (InterruptedException interruptedException) {};
            }
          } 
        } 
      }
    }
    public void startRMI() 
    {
      IUmpleRuntime stub;
      try
      {  
        // Bind the remote object's stub in the registry
        rmiRegistry= LocateRegistry.createRegistry(nodes.get(getThisNodeId()).getPort());
        stub = (IUmpleRuntime) UnicastRemoteObject.exportObject(this, nodes.get(getThisNodeId()).getPort());
        rmiRegistry.bind("UmpleRuntime"+String.valueOf(getThisNodeId()), stub);
        System.err.println("Server ready");
      } 
      catch (Exception e)
      {
        System.err.println("binding exception: " + e.toString());
      }
    }
    public void stopNode()
    {
      System.out.println("stopping node");
      try
      {
        stopRMI();
      }
      catch (Exception e)
      {
        System.err.println("Could not stop RMI:  "+ e.toString());
      }
      isAlive=false;
    }
    public void stopRMI() throws Exception
    {
      for(Object object: listOfObjects)
      {
        try
        {
          UnicastRemoteObject.unexportObject((Remote)object, true);
        }
        catch(Exception e)
        {
          throw e;
        }  
      }
      try
      {
        UnicastRemoteObject.unexportObject(this, true);
      }
      catch(Exception e)
      {
        throw e;
      }
    }
    
  
  public void newClient(UmpleRuntime.UmpleComponent component,Client object)
  {

      while(true){
        try
        {object.setRemoteObject(remoteFactories.get(getNodeId(component)).createClient());
          object.setRealObject(object.getRemoteObject());
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newClient(Client object){ 
        
        ClientRemote remoteObject;
        try{
        remoteObject = (ClientRemote)Class.forName(object.getClass().getName()+"Remote").getConstructor(object.getClass()).newInstance(object);
        }
        catch (Exception e)
        {
          System.err.println("Class not found " + e.toString());
          return;
        }
        listOfObjects.add(remoteObject); 
    while(true)
    {
      try
      {  
        UnicastRemoteObject.exportObject(remoteObject,nodes.get(getThisNodeId()).getPort());
        object.setRemoteObject(remoteObject);
        break;
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }
    }
      
    }
    
  synchronized public IClientImpl createClient()
    {
    Client object= new Client( UmpleRuntime.getComponent("local"));
    return object.getRemoteObject();
    }

  
  public void newMicrowave(int aX, String aF, UmpleRuntime.UmpleComponent component,Microwave object)
  {

      while(true){
        try
        {object.setRemoteObject(remoteFactories.get(getNodeId(component)).createMicrowave(aX, aF));
          object.setRealObject(object.getRemoteObject());
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newMicrowave(Microwave object){ 
        
        MicrowaveRemote remoteObject;
        try{
        remoteObject = (MicrowaveRemote)Class.forName(object.getClass().getName()+"Remote").getConstructor(object.getClass()).newInstance(object);
        }
        catch (Exception e)
        {
          System.err.println("Class not found " + e.toString());
          return;
        }
        listOfObjects.add(remoteObject); 
    while(true)
    {
      try
      {  
        UnicastRemoteObject.exportObject(remoteObject,nodes.get(getThisNodeId()).getPort());
        object.setRemoteObject(remoteObject);
        break;
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }
    }
      
    }
    
  synchronized public IMicrowaveImpl createMicrowave(int aX, String aF)
    {
    Microwave object= new Microwave(aX, aF,  UmpleRuntime.getComponent("local"));
    return object.getRemoteObject();
    }

  public static void main (String [] args)
  {
    if (args.length>0){
      setThisNodeId(Integer.parseInt(args[0]));
      if (args.length>1)
        UmpleRuntime.setFileAddress(args[1]);
    }
     UmpleRuntime.getInstance();
    while(isAlive){
      try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
    }
  }
    public class UmpleNode
    {
      //------------------------
      // MEMBER VARIABLES
      //------------------------
      private int id;
      private String ip="localhost";
      private String url="https://localhost";
      private int port=1098;
      //------------------------
      // CONSTRUCTOR
      //------------------------

      public UmpleNode(int aId)
      {
        id= aId;
      }

      //------------------------
      // INTERFACE
      //------------------------
      public boolean setId(int aId)
      {
        boolean wasSet = false;
        id = aId;
        wasSet = true;
        return wasSet;
      }

      public boolean setIp(String aIp)
      {
        boolean wasSet = false;
        ip = aIp;
        wasSet = true;
        return wasSet;
      }

      public boolean setUrl(String aUrl)
      {
        boolean wasSet = false;
        url = aUrl;
        wasSet = true;
        return wasSet;
      }

      public boolean setPort(int aPort)
      {
        boolean wasSet = false;
        port = aPort;
        wasSet = true;
        return wasSet;
      }
      public int getId()
      {
        return id;
      }
      public String getIp()
      {
        return ip;
      }

      public String getUrl()
      {
        return url;
      }

      public int getPort()
      {
        return port;
      }
      public String toString()
      {
        return super.toString() + "["+"id" + ":" + getId()+ "]";
      }
    }

    public class UmpleComponent
    {

      //------------------------
      // MEMBER VARIABLES
      //------------------------

      //UmpleComponent Attributes
      private int number=0;
      private String name;
      private UmpleNode node;
      //------------------------
      // CONSTRUCTOR
      //------------------------

      public UmpleComponent(String aName,UmpleNode aNode)
      {
        name=aName;
        node=aNode;
      }
      //------------------------
      // INTERFACE
      //------------------------

      public boolean setNumber(int aNumber)
      {
        boolean wasSet = false;
        number = aNumber;
        wasSet = true;
        return wasSet;
      }

      public boolean setName(String aName)
      {
        boolean wasSet = false;
        name = aName;
        wasSet = true;
        return wasSet;
      }
      public boolean setNode(UmpleNode aNode)
      {
        boolean wasSet = false;
        node = aNode;
        wasSet = true;
        return wasSet;
      }
      public UmpleNode getNode()
      {
        return node;
      }

      public int getNumber()
      {
        return number;
      }

      public String getName()
      {
        return name;
      }
      public boolean equals(Object object) {
          if(object instanceof UmpleComponent && ((UmpleComponent)object).getName() == this.name) {
              return true;
          } else {
              return false;
          }
      }      
    }  
}
 
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi3;
import java.io.Serializable;

// line 11 "../../Class_DistributableRMI3.ump"
public class CC implements java.io.Serializable, ICCImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public CC()
  {}

  //------------------------
  // INTERFACE
  //------------------------

  public void deleteImpl()
  {}

  // line 14 "../../Class_DistributableRMI3.ump"
   public void someMethod1Impl(){
    
  }

  public void setRealObject(ICCImpl aObject)
  {
    realObject=aObject;
  }

  transient ICCImpl realObject=this;
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void someMethod1()
  {
    while(true)
      try{
        realObject.someMethod1Impl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  protected  ICCImpl remoteObject;  
  public void setRemoteObject(ICCImpl aRemoteObject)
  {
    remoteObject=aRemoteObject;
  }
  public ICCImpl getRemoteObject()
  {
    return (ICCImpl)remoteObject;
  }
  private void readObject(java.io.ObjectInputStream in) throws Exception
  {
    try
    {
      in.defaultReadObject();
      realObject=(ICCImpl)remoteObject;
    }
    catch(Exception e)
    {
      throw e;
    }
    
  }
 
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;

import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
public class AgentRemote implements IAgentImpl
{
  Agent realObject;
  public void setRealObject(Agent aObject)
  {
    realObject=aObject;
  }
  public AgentRemote()
  {}
  public AgentRemote(Agent aObject)
  {
      realObject=aObject;
  }
  public int getHashCodeImpl()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setNameImpl(String aName)
  {
    while(true)
      try{
        return realObject.setNameImpl(aName);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public String getNameImpl()
  {
    while(true)
      try{
        return realObject.getNameImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Warehouse getWarehousImpl(int index)
  {
    while(true)
      try{
        return realObject.getWarehousImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Warehouse> getWarehousesImpl()
  {
    while(true)
      try{
        return realObject.getWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfWarehousesImpl()
  {
    while(true)
      try{
        return realObject.numberOfWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasWarehousesImpl()
  {
    while(true)
      try{
        return realObject.hasWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfWarehousImpl(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.indexOfWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public SystemManager getSystemManagerImpl()
  {
    while(true)
      try{
        return realObject.getSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasSystemManagerImpl()
  {
    while(true)
      try{
        return realObject.hasSystemManagerImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousImpl(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.addWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeWarehousImpl(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.removeWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setSystemManagerImpl(SystemManager aSystemManager)
  {
    while(true)
      try{
        return realObject.setSystemManagerImpl(aSystemManager);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void deleteImpl()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/
package distributed.rmi5;
// line 2 "../../Class_DistributableRMI5.ump"
public interface ClientI
{
  
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.util.*;
import java.io.Serializable;
import javax.xml.namespace.QName;
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;

// line 47 "../ecommerceWS.ump"
@WebService(endpointInterface = "ecommerceWS.ISupplierImpl")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(factoryMethod="umplenewInstance", propOrder={})
public class Supplier extends Agent implements java.io.Serializable, ISupplierImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Supplier Associations
  private transient  List<Warehouse> warehouses;
  private transient  List<Product> products;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Supplier(String aName, UmpleRuntime.UmpleComponent umpleComponent)
  {
    super(aName,umpleComponent);
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Supplier.class)
        UmpleRuntime.getInstance().newSupplier(aName, umpleComponent, this);

      return;
    }

    warehouses = new ArrayList<Warehouse>();
    products = new ArrayList<Product>();
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public Warehouse getWarehousImpl(int index)
  {
    Warehouse aWarehous = warehouses.get(index);
    return aWarehous;
  }

  public List<Warehouse> getWarehouses()
  {
    List<Warehouse> newWarehouses = Collections.unmodifiableList(warehouses);
    return newWarehouses;
  }

  public int numberOfWarehousesImpl()
  {
    int number = warehouses.size();
    return number;
  }

  public boolean hasWarehousesImpl()
  {
    boolean has = warehouses.size() > 0;
    return has;
  }

  public int indexOfWarehousImpl(Warehouse aWarehous)
  {
    int index = warehouses.indexOf(aWarehous);
    return index;
  }
  /* Code from template association_GetMany */
  public Product getProductImpl(int index)
  {
    Product aProduct = products.get(index);
    return aProduct;
  }

  public List<Product> getProducts()
  {
    List<Product> newProducts = Collections.unmodifiableList(products);
    return newProducts;
  }

  public int numberOfProductsImpl()
  {
    int number = products.size();
    return number;
  }

  public boolean hasProductsImpl()
  {
    boolean has = products.size() > 0;
    return has;
  }

  public int indexOfProductImpl(Product aProduct)
  {
    int index = products.indexOf(aProduct);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfWarehouses()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addWarehousImpl(Warehouse aWarehous)
  {
    boolean wasAdded = false;
    if (warehouses.contains(aWarehous)) { return false; }
    warehouses.add(aWarehous);
    if (aWarehous.indexOfSupplier(this) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aWarehous.addSupplier(this);
      if (!wasAdded)
      {
        warehouses.remove(aWarehous);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeWarehousImpl(Warehouse aWarehous)
  {
    boolean wasRemoved = false;
    if (!warehouses.contains(aWarehous))
    {
      return wasRemoved;
    }

    int oldIndex = warehouses.indexOf(aWarehous);
    warehouses.remove(oldIndex);
    if (aWarehous.indexOfSupplier(this) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aWarehous.removeSupplier(this);
      if (!wasRemoved)
      {
        warehouses.add(oldIndex,aWarehous);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index)
  {  
    boolean wasAdded = false;
    if(addWarehous(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index)
  {
    boolean wasAdded = false;
    if(warehouses.contains(aWarehous))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfWarehouses()) { index = numberOfWarehouses() - 1; }
      warehouses.remove(aWarehous);
      warehouses.add(index, aWarehous);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addWarehousAt(aWarehous, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfProducts()
  {
    return 0;
  }
  /* Code from template association_AddUnidirectionalMany */
  public boolean addProductImpl(Product aProduct)
  {
    boolean wasAdded = false;
    if (products.contains(aProduct)) { return false; }
    products.add(aProduct);
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeProductImpl(Product aProduct)
  {
    boolean wasRemoved = false;
    if (products.contains(aProduct))
    {
      products.remove(aProduct);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addProductAtImpl(Product aProduct, int index)
  {  
    boolean wasAdded = false;
    if(addProduct(aProduct))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfProducts()) { index = numberOfProducts() - 1; }
      products.remove(aProduct);
      products.add(index, aProduct);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveProductAtImpl(Product aProduct, int index)
  {
    boolean wasAdded = false;
    if(products.contains(aProduct))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfProducts()) { index = numberOfProducts() - 1; }
      products.remove(aProduct);
      products.add(index, aProduct);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addProductAt(aProduct, index);
    }
    return wasAdded;
  }

  public void deleteImpl()
  {
    ArrayList<Warehouse> copyOfWarehouses = new ArrayList<Warehouse>(warehouses);
    warehouses.clear();
    for(Warehouse aWarehous : copyOfWarehouses)
    {
      aWarehous.removeSupplier(this);
    }
    products.clear();
    super.delete();
  }

  // line 54 "../ecommerceWS.ump"
   public Product createProductImpl(String serialNumber, String productType){
    Product aProduct=new Product(serialNumber,new ProductType(productType));
		addProduct(aProduct);
		return aProduct;
  }

  // line 60 "../ecommerceWS.ump"
   public void putInWarehouseImpl(Product aProduct, Warehouse warehouse){
    warehouse.addProduct(aProduct);
  }


  transient ISupplierImpl realObject=this;
  public Supplier(String aName)
  {

this(aName,UmpleRuntime.getComponent("Supplier"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Warehouse getWarehous(int index)
  {
    while(true)
      try{
        return realObject.getWarehousImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfWarehouses()
  {
    while(true)
      try{
        return realObject.numberOfWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasWarehouses()
  {
    while(true)
      try{
        return realObject.hasWarehousesImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.indexOfWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Product getProduct(int index)
  {
    while(true)
      try{
        return realObject.getProductImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfProducts()
  {
    while(true)
      try{
        return realObject.numberOfProductsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasProducts()
  {
    while(true)
      try{
        return realObject.hasProductsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfProduct(Product aProduct)
  {
    while(true)
      try{
        return realObject.indexOfProductImpl(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.addWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.removeWarehousImpl(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveWarehousAtImpl(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addProduct(Product aProduct)
  {
    while(true)
      try{
        return realObject.addProductImpl(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeProduct(Product aProduct)
  {
    while(true)
      try{
        return realObject.removeProductImpl(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addProductAt(Product aProduct, int index)
  {
    while(true)
      try{
        return realObject.addProductAtImpl(aProduct,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveProductAt(Product aProduct, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveProductAtImpl(aProduct,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Product createProduct(String serialNumber, String productType)
  {
    while(true)
      try{
        return realObject.createProductImpl(serialNumber,productType);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void putInWarehouse(Product aProduct, Warehouse warehouse)
  {
    while(true)
      try{
        realObject.putInWarehouseImpl(aProduct,warehouse);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  private static Supplier umplenewInstance()
  {
    return new Supplier((UmpleRuntime.UmpleNode)null);
  }   

  protected Supplier (UmpleRuntime.UmpleNode node)
  {
    super(node);
  }

  public void setRealObject(ISupplierImpl aObject)
  {
    super.setRealObject(aObject);
    realObject=aObject;
  }
  void afterUnmarshal(Unmarshaller u, Object parent)
  {
    initializeConnection();
  }
  private void initializeConnection()
  {
    if(objectId.contains(Supplier.class.getName()))
    {  
      boolean success = false;
      while (!success) {        
        try 
        {
          URL url = new URL(remoteUrl+":"+remotePort+"/Supplier"+objectId+"?wsdl");
          QName qname = new QName("https://ecommerceWS/","SupplierService");
          Service service = Service.create(url, qname);
          setRealObject(service.getPort(ISupplierImpl.class));
          success = true;
        } 
        catch (Exception e) 
        {
          System.err.println("Client exception: " + e.toString());
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }
      }
    }
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Supplier)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.io.Serializable;
import javax.xml.namespace.QName;
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import java.rmi.RemoteException;
@WebService
@SOAPBinding(style = Style.RPC)
public interface IAgentImpl
{
@WebMethod
  public int getHashCodeImpl();
@WebMethod
  public boolean setNameImpl(String aName);
@WebMethod
  public String getNameImpl();
@WebMethod
  public SystemManager getSystemManagerImpl();
@WebMethod
  public boolean hasSystemManagerImpl();
@WebMethod
  public boolean setSystemManagerImpl(SystemManager aSystemManager);
@WebMethod
  public void deleteImpl();
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi.withMethods;
import java.util.*;
import java.lang.Thread;
import java.io.Serializable;

import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
public class MicrowaveRemote implements IMicrowaveImpl
{
  Microwave realObject;
  public void setRealObject(Microwave aObject)
  {
    realObject=aObject;
  }
  public MicrowaveRemote()
  {}
  public MicrowaveRemote(Microwave aObject)
  {
      realObject=aObject;
  }
  public int getHashCodeImpl()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setLightOnImpl(boolean aLightOn)
  {
    while(true)
      try{
        return realObject.setLightOnImpl(aLightOn);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setPowerTubeOnImpl(boolean aPowerTubeOn)
  {
    while(true)
      try{
        return realObject.setPowerTubeOnImpl(aPowerTubeOn);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setIsDoorOpenedImpl(boolean aIsDoorOpened)
  {
    while(true)
      try{
        return realObject.setIsDoorOpenedImpl(aIsDoorOpened);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setIsButtonPressedImpl(boolean aIsButtonPressed)
  {
    while(true)
      try{
        return realObject.setIsButtonPressedImpl(aIsButtonPressed);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getLightOnImpl()
  {
    while(true)
      try{
        return realObject.getLightOnImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getPowerTubeOnImpl()
  {
    while(true)
      try{
        return realObject.getPowerTubeOnImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getIsDoorOpenedImpl()
  {
    while(true)
      try{
        return realObject.getIsDoorOpenedImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getIsButtonPressedImpl()
  {
    while(true)
      try{
        return realObject.getIsButtonPressedImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean _doorOpenedImpl()
  {
    while(true)
      try{
        return realObject._doorOpenedImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean _buttonPressedImpl()
  {
    while(true)
      try{
        return realObject._buttonPressedImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean _doorClosedImpl()
  {
    while(true)
      try{
        return realObject._doorClosedImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void deleteImpl()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void doorOpenedImpl ()
  {
    while(true)
      try{
        realObject.doorOpenedImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void buttonPressedImpl ()
  {
    while(true)
      try{
        realObject.buttonPressedImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void doorClosedImpl ()
  {
    while(true)
      try{
        realObject.doorClosedImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void runImpl ()
  {
    while(true)
      try{
        realObject.runImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void turnLightOnImpl(boolean on)
  {
    while(true)
      try{
        realObject.turnLightOnImpl(on);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void energizePowerTubeImpl(boolean on)
  {
    while(true)
      try{
        realObject.energizePowerTubeImpl(on);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void turnOffImpl()
  {
    while(true)
      try{
        realObject.turnOffImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi5;
import java.util.*;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface IMicrowaveImpl extends java.rmi.Remote
{
  public int getHashCodeImpl() throws RemoteException;
  public boolean setXImpl(int aX) throws RemoteException;
  public boolean setFImpl(String aF) throws RemoteException;
  public int getXImpl() throws RemoteException;
  public String getFImpl() throws RemoteException;
  public Client getClientImpl(int index) throws RemoteException;
  public List<Client> getClientsImpl() throws RemoteException;
  public int numberOfClientsImpl() throws RemoteException;
  public boolean hasClientsImpl() throws RemoteException;
  public int indexOfClientImpl(Client aClient) throws RemoteException;
  public boolean addClientImpl(Client aClient) throws RemoteException;
  public boolean removeClientImpl(Client aClient) throws RemoteException;
  public boolean addClientAtImpl(Client aClient, int index) throws RemoteException;
  public boolean addOrMoveClientAtImpl(Client aClient, int index) throws RemoteException;
  public void deleteImpl() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi.withMethods2;
import java.rmi.RemoteException;
public interface ICCImpl extends java.rmi.Remote
{
  public void setSelf(CC proxy) throws RemoteException;
  public int getHashCode() throws RemoteException;
  public void delete() throws RemoteException;
   public void energizePowerTube(boolean on) throws RemoteException;
   public void turnOff() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/
package ecommerceRMI1;
import java.rmi.Remote;
import java.util.Properties;
import ecommerceRMI1.Agent;
import java.io.*;
import ecommerceRMI1.Vendor;
import ecommerceRMI1.Warehouse;
import java.io.IOException;
import java.io.FileInputStream;
import java.rmi.registry.Registry;
import java.io.InputStreamReader;
import java.io.File;
import java.rmi.RemoteException;
import java.io.Serializable;
import ecommerceRMI1.Customer;
import java.util.regex.Matcher;
import java.rmi.registry.LocateRegistry;
import java.util.*;
import ecommerceRMI1.Supplier;
import java.rmi.server.UnicastRemoteObject;
import ecommerceRMI1.SystemManager;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.Pattern;
import java.io.InputStream;
public class UmpleRuntime implements IUmpleRuntime
{ 
  private static Boolean isAlive = true;
  static int thisNodeId=-1;
  private int numberOfNodes=0;
  private static String fileAddress="";
  static HashMap<Integer, UmpleNode> nodes=new HashMap<Integer, UmpleNode>();
  static HashMap <String, UmpleComponent> components= new HashMap<String, UmpleComponent>();
  public static void setFileAddress(String address)
  {
    fileAddress=address;
  }
  public static int getThisNodeId()
  {
    return thisNodeId;
  }
    private static void setThisNodeId(int id)
  {
    thisNodeId=id;
  }  


  private static void readPropertiesFile()
  {
      String location="configuration.txt";
      Properties prop = new Properties();
      InputStream input = null;

    try {

      input = new FileInputStream("node.properties");
      prop.load(input);
      if(getThisNodeId()<0)
        setThisNodeId(Integer.parseInt(prop.getProperty("name")));
      location=prop.getProperty("location");
      setFileAddress(location);
    } catch (IOException e)
    {
      e.printStackTrace();
      if(getThisNodeId()<0)
        setThisNodeId(0); 
      setFileAddress(location);   
    } 
    finally {
      if (input != null) {
        try {
          input.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
  public static UmpleComponent getComponent(String runtimeComponentName)
  {
    getInstance();
    UmpleComponent aComponent=components.get(runtimeComponentName.toLowerCase());
    if (aComponent!=null)
      return aComponent;
    else
      return components.get("local");  
  }

  public static void stopAll()
  {
    UmpleRuntime.getInstance().stopAllNodes();
  }
  public void stopAllNodes()
  {
    for(int node=0;node<numberOfNodes;node=node+1)
    {
      if(node!=getThisNodeId())
      {
        try
        {
          remoteFactories.get(node).stopNode();
        }
        catch(Exception e) {System.err.println(e.toString());}
      } 
    }
    stopNode(); 
  }
// ******************************** Factory
    public static UmpleRuntime theInstance = null;
    List<IUmpleRuntime> remoteFactories;

    public List<Object> listOfObjects;
    public static UmpleRuntime getInstance()
    {
      if(theInstance==null){
        theInstance = new UmpleRuntime();
        }
      return theInstance;
    }
   
    private UmpleRuntime()
    { 
      listOfObjects=new ArrayList<Object>();
      remoteFactories= new ArrayList<IUmpleRuntime>();
      initialize();
    }
    public int getNodeId(int umpleNodeId)
    {
      int nodeId=umpleNodeId;
      if(nodeId>=numberOfNodes)
        nodeId=numberOfNodes-1;
      return nodeId;
    }
    public int getNodeId(UmpleComponent umpleComponent)
    {
      return umpleComponent.getNode().getId();
    }

    private void readConfigFile()
    {
      String input="{id=0; port=1099; https://localhost {component1}}{id=1; port=1700; https://localhost {component2}}";
      try (BufferedReader br = new BufferedReader(new FileReader(fileAddress))) {
        input="";
        String line;
        while ((line = br.readLine()) != null) {
           // Merging the lines
          input+=line+";";
        }
      }
      catch (IOException e)
      {
        e.printStackTrace();   
      }
      finally {
        if (input != null)
        {
          int startIndex=input.indexOf("{");
          if(startIndex>=0)
          //while(startIndex>=0)
          { 
            Pattern pattern1 = Pattern.compile("([\\{|\\(])([^\\}\\)]+)([\\{|\\(])");
            Pattern pattern2 = Pattern.compile("([\\}|\\)])([^\\{\\(]+)([\\}|\\)])");
            Pattern pattern3 = Pattern.compile("([\\{|\\(])([^\\{\\(\\}\\)]+)([\\}|\\)])");
            Pattern patternURL = Pattern.compile("(url)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)");
            Pattern patternName = Pattern.compile("(id)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)");
            Pattern patternPort = Pattern.compile("(port)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)"); 
            Pattern patternIp = Pattern.compile("(ip)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)"); 
            Pattern patternComponent = Pattern.compile("(\\s*)([^;,\\s]*)(\\s*)([,|;|\\r\\n|\\t])");                 
            Matcher matcher1 = pattern1.matcher(input); 
            Matcher matcher2 = pattern2.matcher(input);
            Matcher matcher3 = pattern3.matcher(input);
            String url="";
            String ip="";
            String name="";
            int port=1111;
            String part1="";
            String part2="";
            String part3="";
            String runtimeComponents="";
            String machine="";
            Boolean condition1=matcher1.find();
            Boolean condition2=matcher2.find();
            Boolean condition3=matcher3.find();
            while (condition1||condition2||condition3) 
            { 
              url="https://localhost";
              ip="localhost";
              name="";
              port=1111;
              part1="";
              part2="";
              part3="";
              runtimeComponents="";
              machine="";
              if(condition1)
                part1=matcher1.group(2);
              if(condition2)
                part2=matcher2.group(2);
              if(condition3)
                part3=matcher3.group(2);
              
              if(condition1&&matcher3.end()>matcher1.end())
              {
                machine=part1.toLowerCase()+part2.toLowerCase();
                runtimeComponents=part3.toLowerCase()+";";
                condition1=matcher1.find();
                condition2=matcher2.find();
                condition3=matcher3.find();
              }else
              {
                machine=part3.toLowerCase();
                condition3=matcher3.find();
              }
              Matcher matcherURL = patternURL.matcher(machine);
              if(matcherURL.find())
                url=matcherURL.group(3);

              Matcher matcherName = patternName.matcher(machine);
              if(matcherName.find())
                name=matcherName.group(3);

              Matcher matcherIp = patternIp.matcher(machine);
              if(matcherIp.find())
                ip=matcherIp.group(3);

              Matcher matcherPort = patternPort.matcher(machine);
              if(matcherPort.find())
                port=Integer.parseInt(matcherPort.group(3));
              UmpleNode aNode= new UmpleNode(Integer.parseInt(name));
              Matcher matcherComponent = patternComponent.matcher(runtimeComponents);
              while(matcherComponent.find())
              { String component=matcherComponent.group(2);
                UmpleComponent aComponent=new UmpleComponent(component,aNode);
                components.put(component,aComponent);
              }
              if(aNode.getId()==getThisNodeId())
              {
                UmpleComponent aComponent=new UmpleComponent("local",aNode);
                components.put("local",aComponent);
              }
              aNode.setPort(port);
              aNode.setUrl(url);
              aNode.setIp(ip);
              nodes.put(aNode.getId(),aNode);
            }
          }      
        }    
      }
    }
    Registry rmiRegistry;
    public void initialize()
    {    

      if(fileAddress.equals(""))
        readPropertiesFile();
      readConfigFile();
      numberOfNodes= nodes.size();
      startRMI();
      for(int node=0;node<numberOfNodes;node=node+1)
      {
        if(node==getThisNodeId())
        {
          remoteFactories.add(this);
        }
        else
        {
          System.out.println("connecting to node: "+node);
          Boolean success=false;
          while(!success)
          {
            try 
            {
              Registry registry = LocateRegistry.getRegistry(nodes.get(node).getIp(),nodes.get(node).getPort());
              IUmpleRuntime stub = (IUmpleRuntime) registry.lookup("UmpleRuntime"+String.valueOf(node));
              remoteFactories.add(stub);
              success=true;
            } 
            catch (Exception e) 
            {
              System.err.println("Client exception: " + e.toString());
              e.printStackTrace();
              try { Thread.sleep(5000); } catch (InterruptedException interruptedException) {};
            }
          } 
        } 
      }
    }
    public void startRMI() 
    {
      IUmpleRuntime stub;
      try
      {  
        // Bind the remote object's stub in the registry
        rmiRegistry= LocateRegistry.createRegistry(nodes.get(getThisNodeId()).getPort());
        stub = (IUmpleRuntime) UnicastRemoteObject.exportObject(this, nodes.get(getThisNodeId()).getPort());
        rmiRegistry.bind("UmpleRuntime"+String.valueOf(getThisNodeId()), stub);
        System.err.println("Server ready");
      } 
      catch (Exception e)
      {
        System.err.println("binding exception: " + e.toString());
      }
    }
    public void stopNode()
    {
      System.out.println("stopping node");
      try
      {
        stopRMI();
      }
      catch (Exception e)
      {
        System.err.println("Could not stop RMI:  "+ e.toString());
      }
      isAlive=false;
    }
    public void stopRMI() throws Exception
    {
      for(Object object: listOfObjects)
      {
        try
        {
          UnicastRemoteObject.unexportObject((Remote)object, true);
        }
        catch(Exception e)
        {
          throw e;
        }  
      }
      try
      {
        UnicastRemoteObject.unexportObject(this, true);
      }
      catch(Exception e)
      {
        throw e;
      }
    }
    
  
  public IWarehouseImpl newWarehouse(String aName, Warehouse proxy)
  {
    return newWarehouse(aName, getComponent("Warehouse"),proxy);
  }  
  public IWarehouseImpl newWarehouse(String aName, UmpleRuntime.UmpleComponent component, Warehouse proxy)
  {
    while(true){
      try
      {
        return remoteFactories.get(getNodeId(component)).createWarehouse(aName, proxy);
      }
      catch(Exception e) 
      {
        e.printStackTrace();
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }  
    }
  }
  public IWarehouseImpl createWarehouse(String aName, Warehouse proxy)
  {
  WarehouseImpl object = new WarehouseImpl(aName);
    object.setSelf(proxy);
    proxy.setRealObject(object);
      try
      {  
        UnicastRemoteObject.exportObject(object,0);
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }

  listOfObjects.add(object);
  return object; 
  }

  
  public IAgentImpl newAgent(String aName, Agent proxy)
  {
    return newAgent(aName, getComponent("Agent"),proxy);
  }  
  public IAgentImpl newAgent(String aName, UmpleRuntime.UmpleComponent component, Agent proxy)
  {
    while(true){
      try
      {
        return remoteFactories.get(getNodeId(component)).createAgent(aName, proxy);
      }
      catch(Exception e) 
      {
        e.printStackTrace();
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }  
    }
  }
  public IAgentImpl createAgent(String aName, Agent proxy)
  {
  AgentImpl object = new AgentImpl(aName);
    object.setSelf(proxy);
    proxy.setRealObject(object);
      try
      {  
        UnicastRemoteObject.exportObject(object,0);
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }

  listOfObjects.add(object);
  return object; 
  }

  
  public ISupplierImpl newSupplier(String aName, Supplier proxy)
  {
    return newSupplier(aName, getComponent("Supplier"),proxy);
  }  
  public ISupplierImpl newSupplier(String aName, UmpleRuntime.UmpleComponent component, Supplier proxy)
  {
    while(true){
      try
      {
        return remoteFactories.get(getNodeId(component)).createSupplier(aName, proxy);
      }
      catch(Exception e) 
      {
        e.printStackTrace();
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }  
    }
  }
  public ISupplierImpl createSupplier(String aName, Supplier proxy)
  {
  SupplierImpl object = new SupplierImpl(aName);
    object.setSelf(proxy);
    proxy.setRealObject(object);
      try
      {  
        UnicastRemoteObject.exportObject(object,0);
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }

  listOfObjects.add(object);
  return object; 
  }

  
  public IVendorImpl newVendor(String aName, Vendor proxy)
  {
    return newVendor(aName, getComponent("Vendor"),proxy);
  }  
  public IVendorImpl newVendor(String aName, UmpleRuntime.UmpleComponent component, Vendor proxy)
  {
    while(true){
      try
      {
        return remoteFactories.get(getNodeId(component)).createVendor(aName, proxy);
      }
      catch(Exception e) 
      {
        e.printStackTrace();
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }  
    }
  }
  public IVendorImpl createVendor(String aName, Vendor proxy)
  {
  VendorImpl object = new VendorImpl(aName);
    object.setSelf(proxy);
    proxy.setRealObject(object);
      try
      {  
        UnicastRemoteObject.exportObject(object,0);
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }

  listOfObjects.add(object);
  return object; 
  }

  
  public ICustomerImpl newCustomer(String aName, Customer proxy)
  {
    return newCustomer(aName, getComponent("Customer"),proxy);
  }  
  public ICustomerImpl newCustomer(String aName, UmpleRuntime.UmpleComponent component, Customer proxy)
  {
    while(true){
      try
      {
        return remoteFactories.get(getNodeId(component)).createCustomer(aName, proxy);
      }
      catch(Exception e) 
      {
        e.printStackTrace();
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }  
    }
  }
  public ICustomerImpl createCustomer(String aName, Customer proxy)
  {
  CustomerImpl object = new CustomerImpl(aName);
    object.setSelf(proxy);
    proxy.setRealObject(object);
      try
      {  
        UnicastRemoteObject.exportObject(object,0);
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }

  listOfObjects.add(object);
  return object; 
  }

  
  public ISystemManagerImpl newSystemManager(SystemManager proxy)
  {
    return newSystemManager(getComponent("SystemManager"),proxy);
  }  
  public ISystemManagerImpl newSystemManager(UmpleRuntime.UmpleComponent component, SystemManager proxy)
  {
    while(true){
      try
      {
        return remoteFactories.get(getNodeId(component)).createSystemManager(proxy);
      }
      catch(Exception e) 
      {
        e.printStackTrace();
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }  
    }
  }
  public ISystemManagerImpl createSystemManager(SystemManager proxy)
    {
    SystemManagerImpl object= SystemManagerImpl.getInstance();
    object.setSelf(proxy);
    proxy.setRealObject(object);
      try
      {  
        UnicastRemoteObject.exportObject(object,0);
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }

  listOfObjects.add(object);
  return object; 
  }

  public static void main (String [] args)
  {
    if (args.length>0){
      setThisNodeId(Integer.parseInt(args[0]));
      if (args.length>1)
        UmpleRuntime.setFileAddress(args[1]);
    }
     UmpleRuntime.getInstance();
    while(isAlive){
      try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
    }
  }
    public class UmpleNode
    {
      //------------------------
      // MEMBER VARIABLES
      //------------------------
      private int id;
      private String ip="localhost";
      private String url="https://localhost";
      private int port=1098;
      //------------------------
      // CONSTRUCTOR
      //------------------------

      public UmpleNode(int aId)
      {
        id= aId;
      }

      //------------------------
      // INTERFACE
      //------------------------
      public boolean setId(int aId)
      {
        boolean wasSet = false;
        id = aId;
        wasSet = true;
        return wasSet;
      }

      public boolean setIp(String aIp)
      {
        boolean wasSet = false;
        ip = aIp;
        wasSet = true;
        return wasSet;
      }

      public boolean setUrl(String aUrl)
      {
        boolean wasSet = false;
        url = aUrl;
        wasSet = true;
        return wasSet;
      }

      public boolean setPort(int aPort)
      {
        boolean wasSet = false;
        port = aPort;
        wasSet = true;
        return wasSet;
      }
      public int getId()
      {
        return id;
      }
      public String getIp()
      {
        return ip;
      }

      public String getUrl()
      {
        return url;
      }

      public int getPort()
      {
        return port;
      }
      public String toString()
      {
        return super.toString() + "["+"id" + ":" + getId()+ "]";
      }
    }

    public class UmpleComponent
    {

      //------------------------
      // MEMBER VARIABLES
      //------------------------

      //UmpleComponent Attributes
      private int number=0;
      private String name;
      private UmpleNode node;
      //------------------------
      // CONSTRUCTOR
      //------------------------

      public UmpleComponent(String aName,UmpleNode aNode)
      {
        name=aName;
        node=aNode;
      }
      //------------------------
      // INTERFACE
      //------------------------

      public boolean setNumber(int aNumber)
      {
        boolean wasSet = false;
        number = aNumber;
        wasSet = true;
        return wasSet;
      }

      public boolean setName(String aName)
      {
        boolean wasSet = false;
        name = aName;
        wasSet = true;
        return wasSet;
      }
      public boolean setNode(UmpleNode aNode)
      {
        boolean wasSet = false;
        node = aNode;
        wasSet = true;
        return wasSet;
      }
      public UmpleNode getNode()
      {
        return node;
      }

      public int getNumber()
      {
        return number;
      }

      public String getName()
      {
        return name;
      }
      public boolean equals(Object object) {
          if(object instanceof UmpleComponent && ((UmpleComponent)object).getName() == this.name) {
              return true;
          } else {
              return false;
          }
      }      
    }  
}
 
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.io.Serializable;
import ecommerceRMI1.UmpleRuntime;
public class SystemManager implements java.io.Serializable
{  public void setRealObject(ISystemManagerImpl aObject)
  {
    realObject=aObject;
  }

  ISystemManagerImpl realObject;
  private SystemManager(UmpleRuntime.UmpleComponent component)
  {
    if(this.getClass()== SystemManager.class)    setRealObject(UmpleRuntime.getInstance().newSystemManager(component, this));
  }
  private SystemManager()
  {
    if(this.getClass()== SystemManager.class)    setRealObject(UmpleRuntime.getInstance().newSystemManager(this));
  }
  public void setSelf(SystemManager proxy)
  {
    while(true)
      try{
        realObject.setSelf(proxy);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCode();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Agent getAgent(int index)
  {
    while(true)
      try{
        return realObject.getAgent(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Agent> getAgents()
  {
    while(true)
      try{
        return realObject.getAgents();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfAgents()
  {
    while(true)
      try{
        return realObject.numberOfAgents();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasAgents()
  {
    while(true)
      try{
        return realObject.hasAgents();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfAgent(Agent aAgent)
  {
    while(true)
      try{
        return realObject.indexOfAgent(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Warehouse getWarehous(int index)
  {
    while(true)
      try{
        return realObject.getWarehous(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Warehouse> getWarehouses()
  {
    while(true)
      try{
        return realObject.getWarehouses();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfWarehouses()
  {
    while(true)
      try{
        return realObject.numberOfWarehouses();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasWarehouses()
  {
    while(true)
      try{
        return realObject.hasWarehouses();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.indexOfWarehous(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Customer getCustomer(int index)
  {
    while(true)
      try{
        return realObject.getCustomer(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Customer> getCustomers()
  {
    while(true)
      try{
        return realObject.getCustomers();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfCustomers()
  {
    while(true)
      try{
        return realObject.numberOfCustomers();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasCustomers()
  {
    while(true)
      try{
        return realObject.hasCustomers();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.indexOfCustomer(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrder(int index)
  {
    while(true)
      try{
        return realObject.getOrder(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Order> getOrders()
  {
    while(true)
      try{
        return realObject.getOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrders()
  {
    while(true)
      try{
        return realObject.numberOfOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrders()
  {
    while(true)
      try{
        return realObject.hasOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrder(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public static int minimumNumberOfAgents()
  {
    while(true)
      try{
        return SystemManagerImpl.minimumNumberOfAgents();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addAgent(Agent aAgent)
  {
    while(true)
      try{
        return realObject.addAgent(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeAgent(Agent aAgent)
  {
    while(true)
      try{
        return realObject.removeAgent(aAgent);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addAgentAt(Agent aAgent, int index)
  {
    while(true)
      try{
        return realObject.addAgentAt(aAgent,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveAgentAt(Agent aAgent, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveAgentAt(aAgent,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public static int minimumNumberOfWarehouses()
  {
    while(true)
      try{
        return SystemManagerImpl.minimumNumberOfWarehouses();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.addWarehous(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeWarehous(Warehouse aWarehous)
  {
    while(true)
      try{
        return realObject.removeWarehous(aWarehous);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addWarehousAt(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveWarehousAt(aWarehous,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public static int minimumNumberOfCustomers()
  {
    while(true)
      try{
        return SystemManagerImpl.minimumNumberOfCustomers();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.addCustomer(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.removeCustomer(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addCustomerAt(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveCustomerAt(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public static int minimumNumberOfOrders()
  {
    while(true)
      try{
        return SystemManagerImpl.minimumNumberOfOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrder(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrder(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAt(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAt(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.delete();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((SystemManager)obj).getHashCode());
  }
private static SystemManager theInstance=null;
  public static SystemManager getInstance()
{
if(theInstance == null)
{
theInstance = new SystemManager();
}
return theInstance;
}  public static SystemManager getInstance(UmpleRuntime.UmpleComponent umpleComponent)
{
if(theInstance == null)
{
theInstance = new SystemManager(umpleComponent);
}
return theInstance;
}
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.io.Serializable;
import ecommerceRMI1.UmpleRuntime;
public class Supplier extends Agent implements java.io.Serializable
{  public void setRealObject(ISupplierImpl aObject)
  {
  super.setRealObject(aObject);
    realObject=aObject;
  }

  ISupplierImpl realObject;
  public Supplier(String aName, UmpleRuntime.UmpleComponent component)
  {
    if(this.getClass()== Supplier.class)    setRealObject(UmpleRuntime.getInstance().newSupplier(aName, component, this));
  }
  public Supplier(String aName)
  {
    if(this.getClass()== Supplier.class)    setRealObject(UmpleRuntime.getInstance().newSupplier(aName, this));
  }
  public void setSelf(Supplier proxy)
  {
    while(true)
      try{
        realObject.setSelf(proxy);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCode();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Product getProduct(int index)
  {
    while(true)
      try{
        return realObject.getProduct(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Product> getProducts()
  {
    while(true)
      try{
        return realObject.getProducts();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfProducts()
  {
    while(true)
      try{
        return realObject.numberOfProducts();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasProducts()
  {
    while(true)
      try{
        return realObject.hasProducts();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfProduct(Product aProduct)
  {
    while(true)
      try{
        return realObject.indexOfProduct(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public static int minimumNumberOfProducts()
  {
    while(true)
      try{
        return SupplierImpl.minimumNumberOfProducts();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addProduct(Product aProduct)
  {
    while(true)
      try{
        return realObject.addProduct(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeProduct(Product aProduct)
  {
    while(true)
      try{
        return realObject.removeProduct(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addProductAt(Product aProduct, int index)
  {
    while(true)
      try{
        return realObject.addProductAt(aProduct,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveProductAt(Product aProduct, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveProductAt(aProduct,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.delete();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Product createProduct(String serialNumber, String productType)
  {
    while(true)
      try{
        return realObject.createProduct(serialNumber,productType);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void putInWarehouse(Product aProduct, Warehouse warehouse)
  {
    while(true)
      try{
        realObject.putInWarehouse(aProduct,warehouse);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Supplier)obj).getHashCode());
  }
protected Supplier(){}
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.util.*;
import java.io.Serializable;
import javax.xml.namespace.QName;
import java.net.URL;
import javax.xml.ws.Service;
import javax.xml.ws.Endpoint;
import javax.jws.WebService;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import java.rmi.RemoteException;
@WebService
@SOAPBinding(style = Style.RPC)
public interface ISupplierImpl extends IAgentImpl
{
@WebMethod
  public int getHashCodeImpl();
@WebMethod
  public Warehouse getWarehousImpl(int index);
@WebMethod
  public int numberOfWarehousesImpl();
@WebMethod
  public boolean hasWarehousesImpl();
@WebMethod
  public int indexOfWarehousImpl(Warehouse aWarehous);
@WebMethod
  public Product getProductImpl(int index);
@WebMethod
  public int numberOfProductsImpl();
@WebMethod
  public boolean hasProductsImpl();
@WebMethod
  public int indexOfProductImpl(Product aProduct);
@WebMethod
  public boolean addWarehousImpl(Warehouse aWarehous);
@WebMethod
  public boolean removeWarehousImpl(Warehouse aWarehous);
@WebMethod
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index);
@WebMethod
  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index);
@WebMethod
  public boolean addProductImpl(Product aProduct);
@WebMethod
  public boolean removeProductImpl(Product aProduct);
@WebMethod
  public boolean addProductAtImpl(Product aProduct, int index);
@WebMethod
  public boolean addOrMoveProductAtImpl(Product aProduct, int index);
@WebMethod
  public void deleteImpl();
@WebMethod
   public Product createProductImpl(String serialNumber, String productType);
@WebMethod
   public void putInWarehouseImpl(Product aProduct, Warehouse warehouse);
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;

import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
public class SupplierRemote extends AgentRemote implements ISupplierImpl
{
  Supplier realObject;
  public void setRealObject(Supplier aObject)
  {
    realObject=aObject;
  }
  public SupplierRemote()
  {}
  public SupplierRemote(Supplier aObject)
  {
    super(aObject);
    realObject=aObject;
  }
  public int getHashCodeImpl()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Product getProductImpl(int index)
  {
    while(true)
      try{
        return realObject.getProductImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Product> getProductsImpl()
  {
    while(true)
      try{
        return realObject.getProductsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfProductsImpl()
  {
    while(true)
      try{
        return realObject.numberOfProductsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasProductsImpl()
  {
    while(true)
      try{
        return realObject.hasProductsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfProductImpl(Product aProduct)
  {
    while(true)
      try{
        return realObject.indexOfProductImpl(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addProductImpl(Product aProduct)
  {
    while(true)
      try{
        return realObject.addProductImpl(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeProductImpl(Product aProduct)
  {
    while(true)
      try{
        return realObject.removeProductImpl(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addProductAtImpl(Product aProduct, int index)
  {
    while(true)
      try{
        return realObject.addProductAtImpl(aProduct,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveProductAtImpl(Product aProduct, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveProductAtImpl(aProduct,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void deleteImpl()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Product createProductImpl(String serialNumber, String productType)
  {
    while(true)
      try{
        return realObject.createProductImpl(serialNumber,productType);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void putInWarehouseImpl(Product aProduct, Warehouse warehouse)
  {
    while(true)
      try{
        realObject.putInWarehouseImpl(aProduct,warehouse);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.io.Serializable;

// line 82 "../ecommerceRMI1.ump"
public class Product implements java.io.Serializable
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Product Attributes
  private String serialNumber;

  //Product Associations
  private ProductType productType;

  //Helper Variables
  private boolean canSetProductType;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Product(String aSerialNumber, ProductType aProductType)
  {
    serialNumber = aSerialNumber;
    canSetProductType = true;
    if (!setProductType(aProductType))
    {
      throw new RuntimeException("Unable to create Product due to aProductType. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------

  public String getSerialNumber()
  {
    return serialNumber;
  }
  /* Code from template association_GetOne */
  public ProductType getProductType()
  {
    return productType;
  }
  /* Code from template association_SetUnidirectionalOne */
  private boolean setProductType(ProductType aNewProductType)
  {
    boolean wasSet = false;
    if (!canSetProductType) { return false; }
    canSetProductType = false;
    if (aNewProductType != null)
    {
      productType = aNewProductType;
      wasSet = true;
    }
    return wasSet;
  }

  public void delete()
  {}


  public String toString()
  {
    return super.toString() + "["+
            "serialNumber" + ":" + getSerialNumber()+ "]" + System.getProperties().getProperty("line.separator") +
            "  " + "productType = "+(getProductType()!=null?Integer.toHexString(System.identityHashCode(getProductType())):"null");
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

// line 61 "../ecommerceRMI1.ump"
public class VendorImpl extends AgentImpl implements java.io.Serializable , IVendorImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //VendorImpl Associations
  private List<Order> orders;
  private List<Customer> customers;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public VendorImpl(String aName)
  {
    super(aName);
    orders = new ArrayList<Order>();
    customers = new ArrayList<Customer>();
  }
  //------------------------
  // Reference to the proxy
  //------------------------
  Vendor self;
  
  public void setSelf(Vendor proxy)
  {
    super.setSelf(proxy);
    self=proxy;
  }

  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCode()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public Order getOrder(int index)
  {
    Order aOrder = orders.get(index);
    return aOrder;
  }

  public List<Order> getOrders()
  {
    List<Order> newOrders = Collections.unmodifiableList(orders);
    return newOrders;
  }

  public int numberOfOrders()
  {
    int number = orders.size();
    return number;
  }

  public boolean hasOrders()
  {
    boolean has = orders.size() > 0;
    return has;
  }

  public int indexOfOrder(Order aOrder)
  {
    int index = orders.indexOf(aOrder);
    return index;
  }
  /* Code from template association_GetMany */
  public Customer getCustomer(int index)
  {
    Customer aCustomer = customers.get(index);
    return aCustomer;
  }

  public List<Customer> getCustomers()
  {
    List<Customer> newCustomers = Collections.unmodifiableList(customers);
    return newCustomers;
  }

  public int numberOfCustomers()
  {
    int number = customers.size();
    return number;
  }

  public boolean hasCustomers()
  {
    boolean has = customers.size() > 0;
    return has;
  }

  public int indexOfCustomer(Customer aCustomer)
  {
    int index = customers.indexOf(aCustomer);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfOrders()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addOrder(Order aOrder)
  {
    boolean wasAdded = false;
    if (orders.contains(aOrder)) { return false; }
    Vendor existingVendor = aOrder.getVendor();
    if (existingVendor == null)
    {
      aOrder.setVendor(self);
    }
    else if (!self.equals(existingVendor))
    {
      existingVendor.removeOrder(aOrder);
      addOrder(aOrder);
    }
    else
    {
      orders.add(aOrder);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeOrder(Order aOrder)
  {
    boolean wasRemoved = false;
    if (orders.contains(aOrder))
    {
      orders.remove(aOrder);
      aOrder.setVendor(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addOrderAt(Order aOrder, int index)
  {  
    boolean wasAdded = false;
    if(addOrder(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    boolean wasAdded = false;
    if(orders.contains(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addOrderAt(aOrder, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfCustomers()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addCustomer(Customer aCustomer)
  {
    boolean wasAdded = false;
    if (customers.contains(aCustomer)) { return false; }
    customers.add(aCustomer);
    if (aCustomer.indexOfVendor(self) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aCustomer.addVendor(self);
      if (!wasAdded)
      {
        customers.remove(aCustomer);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeCustomer(Customer aCustomer)
  {
    boolean wasRemoved = false;
    if (!customers.contains(aCustomer))
    {
      return wasRemoved;
    }

    int oldIndex = customers.indexOf(aCustomer);
    customers.remove(oldIndex);
    if (aCustomer.indexOfVendor(self) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aCustomer.removeVendor(self);
      if (!wasRemoved)
      {
        customers.add(oldIndex,aCustomer);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addCustomerAt(Customer aCustomer, int index)
  {  
    boolean wasAdded = false;
    if(addCustomer(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveCustomerAt(Customer aCustomer, int index)
  {
    boolean wasAdded = false;
    if(customers.contains(aCustomer))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfCustomers()) { index = numberOfCustomers() - 1; }
      customers.remove(aCustomer);
      customers.add(index, aCustomer);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addCustomerAt(aCustomer, index);
    }
    return wasAdded;
  }

  public void delete()
  {
    while( !orders.isEmpty() )
    {
      orders.get(0).setVendor(null);
    }
    ArrayList<Customer> copyOfCustomers = new ArrayList<Customer>(customers);
    customers.clear();
    for(Customer aCustomer : copyOfCustomers)
    {
      aCustomer.removeVendor(self);
    }
    super.delete();
  }

  // line 65 "../ecommerceRMI1.ump"
   public Product findProduct(ProductType productType){
    for(Warehouse w:getWarehouses())
		{
			Product p= w.findProduct(productType);
			if(p!=null)
				return p;		
		}
		return null;
  }

  // line 74 "../ecommerceRMI1.ump"
   public Order makeOrder(Customer aCustomer, Product aProduct){
    if(aProduct==null)
			return null;
		Order aOrder= new Order(aProduct);
		aOrder.setCustomer(aCustomer);
		aOrder.setVendor(self);
		return aOrder;
  }

}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi.withMethods2;
import java.util.*;
import java.lang.Thread;
import java.rmi.RemoteException;
public interface IMicrowaveImpl extends java.rmi.Remote, ICCImpl
{
  public void setSelf(Microwave proxy) throws RemoteException;
  public int getHashCode() throws RemoteException;
  public boolean setLightOn(boolean aLightOn) throws RemoteException;
  public boolean setPowerTubeOn(boolean aPowerTubeOn) throws RemoteException;
  public boolean setIsDoorOpened(boolean aIsDoorOpened) throws RemoteException;
  public boolean setIsButtonPressed(boolean aIsButtonPressed) throws RemoteException;
  public boolean getLightOn() throws RemoteException;
  public boolean getPowerTubeOn() throws RemoteException;
  public boolean getIsDoorOpened() throws RemoteException;
  public boolean getIsButtonPressed() throws RemoteException;
  public boolean _doorOpened() throws RemoteException;
  public boolean _buttonPressed() throws RemoteException;
  public boolean _doorClosed() throws RemoteException;
  public void delete() throws RemoteException;
  public void doorOpened() throws RemoteException;
  public void buttonPressed() throws RemoteException;
  public void doorClosed() throws RemoteException;
  public void run() throws RemoteException;
   public void turnLightOn(boolean on) throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;

// line 45 "../ecommerceRMI0.ump"
public class Supplier extends Agent implements java.io.Serializable, ISupplierImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Supplier Associations
  private transient  List<Product> products;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Supplier(String aName, UmpleRuntime.UmpleComponent umpleComponent)
  {
    super(aName,umpleComponent);
    if(umpleComponent.getNode().getId()!=UmpleRuntime.getThisNodeId())
    {
      if(this.getClass()== Supplier.class)
        UmpleRuntime.getInstance().newSupplier(aName, umpleComponent, this);

      return;
    }

    products = new ArrayList<Product>();
  }
  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCodeImpl()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------
  /* Code from template association_GetMany */
  public Product getProductImpl(int index)
  {
    Product aProduct = products.get(index);
    return aProduct;
  }

  public List<Product> getProductsImpl()
  {
    List<Product> newProducts = Collections.unmodifiableList(products);
    return newProducts;
  }

  public int numberOfProductsImpl()
  {
    int number = products.size();
    return number;
  }

  public boolean hasProductsImpl()
  {
    boolean has = products.size() > 0;
    return has;
  }

  public int indexOfProductImpl(Product aProduct)
  {
    int index = products.indexOf(aProduct);
    return index;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfProducts()
  {
    return 0;
  }
  /* Code from template association_AddUnidirectionalMany */
  public boolean addProductImpl(Product aProduct)
  {
    boolean wasAdded = false;
    if (products.contains(aProduct)) { return false; }
    products.add(aProduct);
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeProductImpl(Product aProduct)
  {
    boolean wasRemoved = false;
    if (products.contains(aProduct))
    {
      products.remove(aProduct);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addProductAtImpl(Product aProduct, int index)
  {  
    boolean wasAdded = false;
    if(addProduct(aProduct))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfProducts()) { index = numberOfProducts() - 1; }
      products.remove(aProduct);
      products.add(index, aProduct);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveProductAtImpl(Product aProduct, int index)
  {
    boolean wasAdded = false;
    if(products.contains(aProduct))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfProducts()) { index = numberOfProducts() - 1; }
      products.remove(aProduct);
      products.add(index, aProduct);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addProductAt(aProduct, index);
    }
    return wasAdded;
  }

  public void deleteImpl()
  {
    products.clear();
    super.delete();
  }

  // line 51 "../ecommerceRMI0.ump"
   public Product createProductImpl(String serialNumber, String productType){
    Product aProduct=new Product(serialNumber,new ProductType(productType));
		addProduct(aProduct);
		return aProduct;
  }

  // line 57 "../ecommerceRMI0.ump"
   public void putInWarehouseImpl(Product aProduct, Warehouse warehouse){
    warehouse.addProduct(aProduct);
  }

  public void setRealObject(ISupplierImpl aObject)
  {
  super.setRealObject(aObject);
    realObject=aObject;
  }

  transient ISupplierImpl realObject=this;
  public Supplier(String aName)
  {

this(aName,UmpleRuntime.getComponent("Supplier"));
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCodeImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Product getProduct(int index)
  {
    while(true)
      try{
        return realObject.getProductImpl(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Product> getProducts()
  {
    while(true)
      try{
        return realObject.getProductsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfProducts()
  {
    while(true)
      try{
        return realObject.numberOfProductsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasProducts()
  {
    while(true)
      try{
        return realObject.hasProductsImpl();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfProduct(Product aProduct)
  {
    while(true)
      try{
        return realObject.indexOfProductImpl(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addProduct(Product aProduct)
  {
    while(true)
      try{
        return realObject.addProductImpl(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeProduct(Product aProduct)
  {
    while(true)
      try{
        return realObject.removeProductImpl(aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addProductAt(Product aProduct, int index)
  {
    while(true)
      try{
        return realObject.addProductAtImpl(aProduct,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveProductAt(Product aProduct, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveProductAtImpl(aProduct,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.deleteImpl();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Product createProduct(String serialNumber, String productType)
  {
    while(true)
      try{
        return realObject.createProductImpl(serialNumber,productType);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void putInWarehouse(Product aProduct, Warehouse warehouse)
  {
    while(true)
      try{
        realObject.putInWarehouseImpl(aProduct,warehouse);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  
  public void setRemoteObject(ISupplierImpl aRemoteObject)
  {
    remoteObject=aRemoteObject;
  }
  public ISupplierImpl getRemoteObject()
  {
    return (ISupplierImpl)remoteObject;
  }
  private void readObject(java.io.ObjectInputStream in) throws Exception
  {
    try
    {
      in.defaultReadObject();
      realObject=(ISupplierImpl)remoteObject;
    }
    catch(Exception e)
    {
      throw e;
    }
    
  }
 
  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Supplier)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.io.Serializable;
import ecommerceRMI1.UmpleRuntime;
public class Vendor extends Agent implements java.io.Serializable
{  public void setRealObject(IVendorImpl aObject)
  {
  super.setRealObject(aObject);
    realObject=aObject;
  }

  IVendorImpl realObject;
  public Vendor(String aName, UmpleRuntime.UmpleComponent component)
  {
    if(this.getClass()== Vendor.class)    setRealObject(UmpleRuntime.getInstance().newVendor(aName, component, this));
  }
  public Vendor(String aName)
  {
    if(this.getClass()== Vendor.class)    setRealObject(UmpleRuntime.getInstance().newVendor(aName, this));
  }
  public void setSelf(Vendor proxy)
  {
    while(true)
      try{
        realObject.setSelf(proxy);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCode();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Order getOrder(int index)
  {
    while(true)
      try{
        return realObject.getOrder(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Order> getOrders()
  {
    while(true)
      try{
        return realObject.getOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfOrders()
  {
    while(true)
      try{
        return realObject.numberOfOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasOrders()
  {
    while(true)
      try{
        return realObject.hasOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.indexOfOrder(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public Customer getCustomer(int index)
  {
    while(true)
      try{
        return realObject.getCustomer(index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public List<Customer> getCustomers()
  {
    while(true)
      try{
        return realObject.getCustomers();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int numberOfCustomers()
  {
    while(true)
      try{
        return realObject.numberOfCustomers();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean hasCustomers()
  {
    while(true)
      try{
        return realObject.hasCustomers();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int indexOfCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.indexOfCustomer(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public static int minimumNumberOfOrders()
  {
    while(true)
      try{
        return VendorImpl.minimumNumberOfOrders();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.addOrder(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeOrder(Order aOrder)
  {
    while(true)
      try{
        return realObject.removeOrder(aOrder);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrderAt(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveOrderAt(aOrder,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public static int minimumNumberOfCustomers()
  {
    while(true)
      try{
        return VendorImpl.minimumNumberOfCustomers();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.addCustomer(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean removeCustomer(Customer aCustomer)
  {
    while(true)
      try{
        return realObject.removeCustomer(aCustomer);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addCustomerAt(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean addOrMoveCustomerAt(Customer aCustomer, int index)
  {
    while(true)
      try{
        return realObject.addOrMoveCustomerAt(aCustomer,index);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.delete();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Product findProduct(ProductType productType)
  {
    while(true)
      try{
        return realObject.findProduct(productType);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public Order makeOrder(Customer aCustomer, Product aProduct)
  {
    while(true)
      try{
        return realObject.makeOrder(aCustomer,aProduct);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Vendor)obj).getHashCode());
  }
protected Vendor(){}
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface ICustomerImpl extends java.rmi.Remote
{
  public int getHashCodeImpl() throws RemoteException;
  public boolean setNameImpl(String aName) throws RemoteException;
  public String getNameImpl() throws RemoteException;
  public Vendor getVendorImpl(int index) throws RemoteException;
  public List<Vendor> getVendorsImpl() throws RemoteException;
  public int numberOfVendorsImpl() throws RemoteException;
  public boolean hasVendorsImpl() throws RemoteException;
  public int indexOfVendorImpl(Vendor aVendor) throws RemoteException;
  public Order getOrderImpl(int index) throws RemoteException;
  public List<Order> getOrdersImpl() throws RemoteException;
  public int numberOfOrdersImpl() throws RemoteException;
  public boolean hasOrdersImpl() throws RemoteException;
  public int indexOfOrderImpl(Order aOrder) throws RemoteException;
  public SystemManager getSystemManagerImpl() throws RemoteException;
  public boolean hasSystemManagerImpl() throws RemoteException;
  public boolean addVendorImpl(Vendor aVendor) throws RemoteException;
  public boolean removeVendorImpl(Vendor aVendor) throws RemoteException;
  public boolean addVendorAtImpl(Vendor aVendor, int index) throws RemoteException;
  public boolean addOrMoveVendorAtImpl(Vendor aVendor, int index) throws RemoteException;
  public boolean addOrderImpl(Order aOrder) throws RemoteException;
  public boolean removeOrderImpl(Order aOrder) throws RemoteException;
  public boolean addOrderAtImpl(Order aOrder, int index) throws RemoteException;
  public boolean addOrMoveOrderAtImpl(Order aOrder, int index) throws RemoteException;
  public boolean setSystemManagerImpl(SystemManager aSystemManager) throws RemoteException;
  public void deleteImpl() throws RemoteException;
   public Order orderProductImpl(String productType, String vendorName) throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package distributed.rmi.withMethods2;
import java.util.*;
import java.lang.Thread;
import java.rmi.RemoteException;
import java.io.Serializable;
import distributed.rmi.withMethods2.UmpleRuntime;
public class Microwave extends CC implements java.io.Serializable
{  public void setRealObject(IMicrowaveImpl aObject)
  {
  super.setRealObject(aObject);
    realObject=aObject;
  }

  IMicrowaveImpl realObject;
  public Microwave(UmpleRuntime.UmpleComponent component)
  {
    if(this.getClass()== Microwave.class)    setRealObject(UmpleRuntime.getInstance().newMicrowave(component, this));
  }
  public Microwave()
  {
    if(this.getClass()== Microwave.class)    setRealObject(UmpleRuntime.getInstance().newMicrowave(this));
  }
  public void setSelf(Microwave proxy)
  {
    while(true)
      try{
        realObject.setSelf(proxy);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public int getHashCode()
  {
    while(true)
      try{
        return realObject.getHashCode();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setLightOn(boolean aLightOn)
  {
    while(true)
      try{
        return realObject.setLightOn(aLightOn);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setPowerTubeOn(boolean aPowerTubeOn)
  {
    while(true)
      try{
        return realObject.setPowerTubeOn(aPowerTubeOn);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setIsDoorOpened(boolean aIsDoorOpened)
  {
    while(true)
      try{
        return realObject.setIsDoorOpened(aIsDoorOpened);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean setIsButtonPressed(boolean aIsButtonPressed)
  {
    while(true)
      try{
        return realObject.setIsButtonPressed(aIsButtonPressed);
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getLightOn()
  {
    while(true)
      try{
        return realObject.getLightOn();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getPowerTubeOn()
  {
    while(true)
      try{
        return realObject.getPowerTubeOn();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getIsDoorOpened()
  {
    while(true)
      try{
        return realObject.getIsDoorOpened();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean getIsButtonPressed()
  {
    while(true)
      try{
        return realObject.getIsButtonPressed();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean _doorOpened()
  {
    while(true)
      try{
        return realObject._doorOpened();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean _buttonPressed()
  {
    while(true)
      try{
        return realObject._buttonPressed();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public boolean _doorClosed()
  {
    while(true)
      try{
        return realObject._doorClosed();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void delete()
  {
    while(true)
      try{
        realObject.delete();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void doorOpened ()
  {
    while(true)
      try{
        realObject.doorOpened();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void buttonPressed ()
  {
    while(true)
      try{
        realObject.buttonPressed();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void doorClosed ()
  {
    while(true)
      try{
        realObject.doorClosed();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
  public void run ()
  {
    while(true)
      try{
        realObject.run();
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public void turnLightOn(boolean on)
  {
    while(true)
      try{
        realObject.turnLightOn(on);
        break;
        }
    catch(Exception e) {System.err.println(e.toString());}
  }
   public static  void someMethod()
  {
    while(true)
      try{
        MicrowaveImpl.someMethod();
        }
    catch(Exception e) {System.err.println(e.toString());}
  }

  public boolean equals(Object obj)
  {    if(obj.getClass()!=this.getClass())
      return false;
    return (getHashCode()==((Microwave)obj).getHashCode());
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceWS;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;

// line 85 "../ecommerceWS.ump"
@XmlAccessorType(XmlAccessType.FIELD)

public class Product implements java.io.Serializable
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //Product Attributes
  private String serialNumber;

  //Product Associations
  private ProductType productType;

  //Helper Variables
  private boolean canSetProductType;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public Product(String aSerialNumber, ProductType aProductType)
  {
    serialNumber = aSerialNumber;
    canSetProductType = true;
    if (!setProductType(aProductType))
    {
      throw new RuntimeException("Unable to create Product due to aProductType. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html");
    }
  }

  //------------------------
  // INTERFACE
  //------------------------

  public String getSerialNumber()
  {
    return serialNumber;
  }
  /* Code from template association_GetOne */
  public ProductType getProductType()
  {
    return productType;
  }
  /* Code from template association_SetUnidirectionalOne */
  private boolean setProductType(ProductType aNewProductType)
  {
    boolean wasSet = false;
    if (!canSetProductType) { return false; }
    canSetProductType = false;
    if (aNewProductType != null)
    {
      productType = aNewProductType;
      wasSet = true;
    }
    return wasSet;
  }

  public void delete()
  {}

  // line 90 "../ecommerceWS.ump"
   public  Product(){
    
  }


  public String toString()
  {
    return super.toString() + "["+
            "serialNumber" + ":" + getSerialNumber()+ "]" + System.getProperties().getProperty("line.separator") +
            "  " + "productType = "+(getProductType()!=null?Integer.toHexString(System.identityHashCode(getProductType())):"null");
  }
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI0;
import java.util.*;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface IAgentImpl extends java.rmi.Remote
{
  public int getHashCodeImpl() throws RemoteException;
  public boolean setNameImpl(String aName) throws RemoteException;
  public String getNameImpl() throws RemoteException;
  public Warehouse getWarehousImpl(int index) throws RemoteException;
  public List<Warehouse> getWarehousesImpl() throws RemoteException;
  public int numberOfWarehousesImpl() throws RemoteException;
  public boolean hasWarehousesImpl() throws RemoteException;
  public int indexOfWarehousImpl(Warehouse aWarehous) throws RemoteException;
  public SystemManager getSystemManagerImpl() throws RemoteException;
  public boolean hasSystemManagerImpl() throws RemoteException;
  public boolean addWarehousImpl(Warehouse aWarehous) throws RemoteException;
  public boolean removeWarehousImpl(Warehouse aWarehous) throws RemoteException;
  public boolean addWarehousAtImpl(Warehouse aWarehous, int index) throws RemoteException;
  public boolean addOrMoveWarehousAtImpl(Warehouse aWarehous, int index) throws RemoteException;
  public boolean setSystemManagerImpl(SystemManager aSystemManager) throws RemoteException;
  public void deleteImpl() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/
package ecommerceRMI0;
import ecommerceRMI0.Agent;
import java.rmi.Remote;
import java.util.Properties;
import java.io.*;
import java.io.IOException;
import java.io.FileInputStream;
import java.rmi.registry.Registry;
import java.io.InputStreamReader;
import java.io.File;
import ecommerceRMI0.Vendor;
import java.rmi.RemoteException;
import java.io.Serializable;
import ecommerceRMI0.Supplier;
import java.util.regex.Matcher;
import java.rmi.registry.LocateRegistry;
import java.util.*;
import ecommerceRMI0.Customer;
import java.rmi.server.UnicastRemoteObject;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.Pattern;
import ecommerceRMI0.Warehouse;
import ecommerceRMI0.SystemManager;
import java.io.InputStream;
public class UmpleRuntime implements IUmpleRuntime
{ 
  private static Boolean isAlive = true;
  static int thisNodeId=-1;
  private int numberOfNodes=0;
  private static String fileAddress="";
  static HashMap<Integer, UmpleNode> nodes=new HashMap<Integer, UmpleNode>();
  static HashMap <String, UmpleComponent> components= new HashMap<String, UmpleComponent>();
  public static void setFileAddress(String address)
  {
    fileAddress=address;
  }
  public static int getThisNodeId()
  {
    return thisNodeId;
  }
    private static void setThisNodeId(int id)
  {
    thisNodeId=id;
  }  


  private static void readPropertiesFile()
  {
      String location="configuration.txt";
      Properties prop = new Properties();
      InputStream input = null;

    try {

      input = new FileInputStream("node.properties");
      prop.load(input);
      if(getThisNodeId()<0)
        setThisNodeId(Integer.parseInt(prop.getProperty("name")));
      location=prop.getProperty("location");
      setFileAddress(location);
    } catch (IOException e)
    {
      e.printStackTrace();
      if(getThisNodeId()<0)
        setThisNodeId(0); 
      setFileAddress(location);   
    } 
    finally {
      if (input != null) {
        try {
          input.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
  public static UmpleComponent getComponent(String runtimeComponentName)
  {
    getInstance();
    UmpleComponent aComponent=components.get(runtimeComponentName.toLowerCase());
    if (aComponent!=null)
      return aComponent;
    else
      return components.get("local");  
  }

  public static void stopAll()
  {
    UmpleRuntime.getInstance().stopAllNodes();
  }
  public void stopAllNodes()
  {
    for(int node=0;node<numberOfNodes;node=node+1)
    {
      if(node!=getThisNodeId())
      {
        try
        {
          remoteFactories.get(node).stopNode();
        }
        catch(Exception e) {System.err.println(e.toString());}
      } 
    }
    stopNode(); 
  }
// ******************************** Factory
    public static UmpleRuntime theInstance = null;
    List<IUmpleRuntime> remoteFactories;

    public List<Object> listOfObjects;
    public static UmpleRuntime getInstance()
    {
      if(theInstance==null){
        theInstance = new UmpleRuntime();
        }
      return theInstance;
    }
   
    private UmpleRuntime()
    { 
      listOfObjects=new ArrayList<Object>();
      remoteFactories= new ArrayList<IUmpleRuntime>();
      initialize();
    }
    public int getNodeId(int umpleNodeId)
    {
      int nodeId=umpleNodeId;
      if(nodeId>=numberOfNodes)
        nodeId=numberOfNodes-1;
      return nodeId;
    }
    public int getNodeId(UmpleComponent umpleComponent)
    {
      return umpleComponent.getNode().getId();
    }

    private void readConfigFile()
    {
      String input="{id=0; port=1099; https://localhost {component1}}{id=1; port=1700; https://localhost {component2}}";
      try (BufferedReader br = new BufferedReader(new FileReader(fileAddress))) {
        input="";
        String line;
        while ((line = br.readLine()) != null) {
           // Merging the lines
          input+=line+";";
        }
      }
      catch (IOException e)
      {
        e.printStackTrace();   
      }
      finally {
        if (input != null)
        {
          int startIndex=input.indexOf("{");
          if(startIndex>=0)
          //while(startIndex>=0)
          { 
            Pattern pattern1 = Pattern.compile("([\\{|\\(])([^\\}\\)]+)([\\{|\\(])");
            Pattern pattern2 = Pattern.compile("([\\}|\\)])([^\\{\\(]+)([\\}|\\)])");
            Pattern pattern3 = Pattern.compile("([\\{|\\(])([^\\{\\(\\}\\)]+)([\\}|\\)])");
            Pattern patternURL = Pattern.compile("(url)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)");
            Pattern patternName = Pattern.compile("(id)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)");
            Pattern patternPort = Pattern.compile("(port)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)"); 
            Pattern patternIp = Pattern.compile("(ip)(\\s*[=|:]\\s*)([^;\\s]*)(,|;|\\r\\n|\\t)"); 
            Pattern patternComponent = Pattern.compile("(\\s*)([^;,\\s]*)(\\s*)([,|;|\\r\\n|\\t])");                 
            Matcher matcher1 = pattern1.matcher(input); 
            Matcher matcher2 = pattern2.matcher(input);
            Matcher matcher3 = pattern3.matcher(input);
            String url="";
            String ip="";
            String name="";
            int port=1111;
            String part1="";
            String part2="";
            String part3="";
            String runtimeComponents="";
            String machine="";
            Boolean condition1=matcher1.find();
            Boolean condition2=matcher2.find();
            Boolean condition3=matcher3.find();
            while (condition1||condition2||condition3) 
            { 
              url="https://localhost";
              ip="localhost";
              name="";
              port=1111;
              part1="";
              part2="";
              part3="";
              runtimeComponents="";
              machine="";
              if(condition1)
                part1=matcher1.group(2);
              if(condition2)
                part2=matcher2.group(2);
              if(condition3)
                part3=matcher3.group(2);
              
              if(condition1&&matcher3.end()>matcher1.end())
              {
                machine=part1.toLowerCase()+part2.toLowerCase();
                runtimeComponents=part3.toLowerCase()+";";
                condition1=matcher1.find();
                condition2=matcher2.find();
                condition3=matcher3.find();
              }else
              {
                machine=part3.toLowerCase();
                condition3=matcher3.find();
              }
              Matcher matcherURL = patternURL.matcher(machine);
              if(matcherURL.find())
                url=matcherURL.group(3);

              Matcher matcherName = patternName.matcher(machine);
              if(matcherName.find())
                name=matcherName.group(3);

              Matcher matcherIp = patternIp.matcher(machine);
              if(matcherIp.find())
                ip=matcherIp.group(3);

              Matcher matcherPort = patternPort.matcher(machine);
              if(matcherPort.find())
                port=Integer.parseInt(matcherPort.group(3));
              UmpleNode aNode= new UmpleNode(Integer.parseInt(name));
              Matcher matcherComponent = patternComponent.matcher(runtimeComponents);
              while(matcherComponent.find())
              { String component=matcherComponent.group(2);
                UmpleComponent aComponent=new UmpleComponent(component,aNode);
                components.put(component,aComponent);
              }
              if(aNode.getId()==getThisNodeId())
              {
                UmpleComponent aComponent=new UmpleComponent("local",aNode);
                components.put("local",aComponent);
              }
              aNode.setPort(port);
              aNode.setUrl(url);
              aNode.setIp(ip);
              nodes.put(aNode.getId(),aNode);
            }
          }      
        }    
      }
    }
    Registry rmiRegistry;
    public void initialize()
    {    

      if(fileAddress.equals(""))
        readPropertiesFile();
      readConfigFile();
      numberOfNodes= nodes.size();
      startRMI();
      for(int node=0;node<numberOfNodes;node=node+1)
      {
        if(node==getThisNodeId())
        {
          remoteFactories.add(this);
        }
        else
        {
          System.out.println("connecting to node: "+node);
          Boolean success=false;
          while(!success)
          {
            try 
            {
              Registry registry = LocateRegistry.getRegistry(nodes.get(node).getIp(),nodes.get(node).getPort());
              IUmpleRuntime stub = (IUmpleRuntime) registry.lookup("UmpleRuntime"+String.valueOf(node));
              remoteFactories.add(stub);
              success=true;
            } 
            catch (Exception e) 
            {
              System.err.println("Client exception: " + e.toString());
              e.printStackTrace();
              try { Thread.sleep(5000); } catch (InterruptedException interruptedException) {};
            }
          } 
        } 
      }
    }
    public void startRMI() 
    {
      IUmpleRuntime stub;
      try
      {  
        // Bind the remote object's stub in the registry
        rmiRegistry= LocateRegistry.createRegistry(nodes.get(getThisNodeId()).getPort());
        stub = (IUmpleRuntime) UnicastRemoteObject.exportObject(this, nodes.get(getThisNodeId()).getPort());
        rmiRegistry.bind("UmpleRuntime"+String.valueOf(getThisNodeId()), stub);
        System.err.println("Server ready");
      } 
      catch (Exception e)
      {
        System.err.println("binding exception: " + e.toString());
      }
    }
    public void stopNode()
    {
      System.out.println("stopping node");
      try
      {
        stopRMI();
      }
      catch (Exception e)
      {
        System.err.println("Could not stop RMI:  "+ e.toString());
      }
      isAlive=false;
    }
    public void stopRMI() throws Exception
    {
      for(Object object: listOfObjects)
      {
        try
        {
          UnicastRemoteObject.unexportObject((Remote)object, true);
        }
        catch(Exception e)
        {
          throw e;
        }  
      }
      try
      {
        UnicastRemoteObject.unexportObject(this, true);
      }
      catch(Exception e)
      {
        throw e;
      }
    }
    
  
  public void newWarehouse(String aName, UmpleRuntime.UmpleComponent component,Warehouse object)
  {

      while(true){
        try
        {object.setRemoteObject(remoteFactories.get(getNodeId(component)).createWarehouse(aName));
          object.setRealObject(object.getRemoteObject());
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newWarehouse(Warehouse object){ 
        
        WarehouseRemote remoteObject;
        try{
        remoteObject = (WarehouseRemote)Class.forName(object.getClass().getName()+"Remote").getConstructor(object.getClass()).newInstance(object);
        }
        catch (Exception e)
        {
          System.err.println("Class not found " + e.toString());
          return;
        }
        listOfObjects.add(remoteObject); 
    while(true)
    {
      try
      {  
        UnicastRemoteObject.exportObject(remoteObject,nodes.get(getThisNodeId()).getPort());
        object.setRemoteObject(remoteObject);
        break;
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }
    }
      
    }
    
  synchronized public IWarehouseImpl createWarehouse(String aName)
    {
    Warehouse object= new Warehouse(aName,  UmpleRuntime.getComponent("local"));
    return object.getRemoteObject();
    }

  
  public void newAgent(String aName, UmpleRuntime.UmpleComponent component,Agent object)
  {

      while(true){
        try
        {object.setRemoteObject(remoteFactories.get(getNodeId(component)).createAgent(aName));
          object.setRealObject(object.getRemoteObject());
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newAgent(Agent object){ 
        
        AgentRemote remoteObject;
        try{
        remoteObject = (AgentRemote)Class.forName(object.getClass().getName()+"Remote").getConstructor(object.getClass()).newInstance(object);
        }
        catch (Exception e)
        {
          System.err.println("Class not found " + e.toString());
          return;
        }
        listOfObjects.add(remoteObject); 
    while(true)
    {
      try
      {  
        UnicastRemoteObject.exportObject(remoteObject,nodes.get(getThisNodeId()).getPort());
        object.setRemoteObject(remoteObject);
        break;
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }
    }
      
    }
    
  synchronized public IAgentImpl createAgent(String aName)
    {
    Agent object= new Agent(aName,  UmpleRuntime.getComponent("local"));
    return object.getRemoteObject();
    }

  
  public void newSupplier(String aName, UmpleRuntime.UmpleComponent component,Supplier object)
  {

      while(true){
        try
        {object.setRemoteObject(remoteFactories.get(getNodeId(component)).createSupplier(aName));
          object.setRealObject(object.getRemoteObject());
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newSupplier(Supplier object){ 
        
        SupplierRemote remoteObject;
        try{
        remoteObject = (SupplierRemote)Class.forName(object.getClass().getName()+"Remote").getConstructor(object.getClass()).newInstance(object);
        }
        catch (Exception e)
        {
          System.err.println("Class not found " + e.toString());
          return;
        }
        listOfObjects.add(remoteObject); 
    while(true)
    {
      try
      {  
        UnicastRemoteObject.exportObject(remoteObject,nodes.get(getThisNodeId()).getPort());
        object.setRemoteObject(remoteObject);
        break;
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }
    }
      
    }
    
  synchronized public ISupplierImpl createSupplier(String aName)
    {
    Supplier object= new Supplier(aName,  UmpleRuntime.getComponent("local"));
    return object.getRemoteObject();
    }

  
  public void newVendor(String aName, UmpleRuntime.UmpleComponent component,Vendor object)
  {

      while(true){
        try
        {object.setRemoteObject(remoteFactories.get(getNodeId(component)).createVendor(aName));
          object.setRealObject(object.getRemoteObject());
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newVendor(Vendor object){ 
        
        VendorRemote remoteObject;
        try{
        remoteObject = (VendorRemote)Class.forName(object.getClass().getName()+"Remote").getConstructor(object.getClass()).newInstance(object);
        }
        catch (Exception e)
        {
          System.err.println("Class not found " + e.toString());
          return;
        }
        listOfObjects.add(remoteObject); 
    while(true)
    {
      try
      {  
        UnicastRemoteObject.exportObject(remoteObject,nodes.get(getThisNodeId()).getPort());
        object.setRemoteObject(remoteObject);
        break;
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }
    }
      
    }
    
  synchronized public IVendorImpl createVendor(String aName)
    {
    Vendor object= new Vendor(aName,  UmpleRuntime.getComponent("local"));
    return object.getRemoteObject();
    }

  
  public void newCustomer(String aName, UmpleRuntime.UmpleComponent component,Customer object)
  {

      while(true){
        try
        {object.setRemoteObject(remoteFactories.get(getNodeId(component)).createCustomer(aName));
          object.setRealObject(object.getRemoteObject());
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newCustomer(Customer object){ 
        
        CustomerRemote remoteObject;
        try{
        remoteObject = (CustomerRemote)Class.forName(object.getClass().getName()+"Remote").getConstructor(object.getClass()).newInstance(object);
        }
        catch (Exception e)
        {
          System.err.println("Class not found " + e.toString());
          return;
        }
        listOfObjects.add(remoteObject); 
    while(true)
    {
      try
      {  
        UnicastRemoteObject.exportObject(remoteObject,nodes.get(getThisNodeId()).getPort());
        object.setRemoteObject(remoteObject);
        break;
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }
    }
      
    }
    
  synchronized public ICustomerImpl createCustomer(String aName)
    {
    Customer object= new Customer(aName,  UmpleRuntime.getComponent("local"));
    return object.getRemoteObject();
    }

  
  public void newSystemManager(UmpleRuntime.UmpleComponent component,SystemManager object)
  {

      while(true){
        try
        {object.setRemoteObject(remoteFactories.get(getNodeId(component)).createSystemManager());
          object.setRealObject(object.getRemoteObject());
          break;
        }
        catch(Exception e) 
        {
          e.printStackTrace();
          try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
        }  
      }
      }

  public void newSystemManager(SystemManager object){ 
        
        SystemManagerRemote remoteObject;
        try{
        remoteObject = (SystemManagerRemote)Class.forName(object.getClass().getName()+"Remote").getConstructor(object.getClass()).newInstance(object);
        }
        catch (Exception e)
        {
          System.err.println("Class not found " + e.toString());
          return;
        }
        listOfObjects.add(remoteObject); 
    while(true)
    {
      try
      {  
        UnicastRemoteObject.exportObject(remoteObject,nodes.get(getThisNodeId()).getPort());
        object.setRemoteObject(remoteObject);
        break;
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }
    }
      
    }
    
  synchronized public ISystemManagerImpl createSystemManager()
    {
    SystemManager object= SystemManager.getInstance(UmpleRuntime.getComponent("local"));
    return object.getRemoteObject();
    }

  public static void main (String [] args)
  {
    if (args.length>0){
      setThisNodeId(Integer.parseInt(args[0]));
      if (args.length>1)
        UmpleRuntime.setFileAddress(args[1]);
    }
     UmpleRuntime.getInstance();
    while(isAlive){
      try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
    }
  }
    public class UmpleNode
    {
      //------------------------
      // MEMBER VARIABLES
      //------------------------
      private int id;
      private String ip="localhost";
      private String url="https://localhost";
      private int port=1098;
      //------------------------
      // CONSTRUCTOR
      //------------------------

      public UmpleNode(int aId)
      {
        id= aId;
      }

      //------------------------
      // INTERFACE
      //------------------------
      public boolean setId(int aId)
      {
        boolean wasSet = false;
        id = aId;
        wasSet = true;
        return wasSet;
      }

      public boolean setIp(String aIp)
      {
        boolean wasSet = false;
        ip = aIp;
        wasSet = true;
        return wasSet;
      }

      public boolean setUrl(String aUrl)
      {
        boolean wasSet = false;
        url = aUrl;
        wasSet = true;
        return wasSet;
      }

      public boolean setPort(int aPort)
      {
        boolean wasSet = false;
        port = aPort;
        wasSet = true;
        return wasSet;
      }
      public int getId()
      {
        return id;
      }
      public String getIp()
      {
        return ip;
      }

      public String getUrl()
      {
        return url;
      }

      public int getPort()
      {
        return port;
      }
      public String toString()
      {
        return super.toString() + "["+"id" + ":" + getId()+ "]";
      }
    }

    public class UmpleComponent
    {

      //------------------------
      // MEMBER VARIABLES
      //------------------------

      //UmpleComponent Attributes
      private int number=0;
      private String name;
      private UmpleNode node;
      //------------------------
      // CONSTRUCTOR
      //------------------------

      public UmpleComponent(String aName,UmpleNode aNode)
      {
        name=aName;
        node=aNode;
      }
      //------------------------
      // INTERFACE
      //------------------------

      public boolean setNumber(int aNumber)
      {
        boolean wasSet = false;
        number = aNumber;
        wasSet = true;
        return wasSet;
      }

      public boolean setName(String aName)
      {
        boolean wasSet = false;
        name = aName;
        wasSet = true;
        return wasSet;
      }
      public boolean setNode(UmpleNode aNode)
      {
        boolean wasSet = false;
        node = aNode;
        wasSet = true;
        return wasSet;
      }
      public UmpleNode getNode()
      {
        return node;
      }

      public int getNumber()
      {
        return number;
      }

      public String getName()
      {
        return name;
      }
      public boolean equals(Object object) {
          if(object instanceof UmpleComponent && ((UmpleComponent)object).getName() == this.name) {
              return true;
          } else {
              return false;
          }
      }      
    }  
}
 
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
public interface IAgentImpl extends java.rmi.Remote
{
  public void setSelf(Agent proxy) throws RemoteException;
  public int getHashCode() throws RemoteException;
  public boolean setName(String aName) throws RemoteException;
  public String getName() throws RemoteException;
  public Warehouse getWarehous(int index) throws RemoteException;
  public List<Warehouse> getWarehouses() throws RemoteException;
  public int numberOfWarehouses() throws RemoteException;
  public boolean hasWarehouses() throws RemoteException;
  public int indexOfWarehous(Warehouse aWarehous) throws RemoteException;
  public SystemManager getSystemManager() throws RemoteException;
  public boolean hasSystemManager() throws RemoteException;
  public boolean addWarehous(Warehouse aWarehous) throws RemoteException;
  public boolean removeWarehous(Warehouse aWarehous) throws RemoteException;
  public boolean addWarehousAt(Warehouse aWarehous, int index) throws RemoteException;
  public boolean addOrMoveWarehousAt(Warehouse aWarehous, int index) throws RemoteException;
  public boolean setSystemManager(SystemManager aSystemManager) throws RemoteException;
  public void delete() throws RemoteException;
}
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!*/

package ecommerceRMI1;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

// line 101 "../ecommerceRMI1.ump"
public class CustomerImpl implements java.io.Serializable , ICustomerImpl
{

  //------------------------
  // MEMBER VARIABLES
  //------------------------

  //CustomerImpl Attributes
  private String name;

  //CustomerImpl Associations
  private List<Vendor> vendors;
  private List<Order> orders;
  private SystemManager systemManager;

  //------------------------
  // CONSTRUCTOR
  //------------------------

  public CustomerImpl(String aName)
  {
    name = aName;
    vendors = new ArrayList<Vendor>();
    orders = new ArrayList<Order>();
  }
  //------------------------
  // Reference to the proxy
  //------------------------
  Customer self;
  
  public void setSelf(Customer proxy)
  {
    self=proxy;
  }

  //------------------------
  // Returning the Hashcode
  //------------------------
  public int getHashCode()
  {
    return hashCode();
  }

  //------------------------
  // INTERFACE
  //------------------------

  public boolean setName(String aName)
  {
    boolean wasSet = false;
    name = aName;
    wasSet = true;
    return wasSet;
  }

  public String getName()
  {
    return name;
  }
  /* Code from template association_GetMany */
  public Vendor getVendor(int index)
  {
    Vendor aVendor = vendors.get(index);
    return aVendor;
  }

  public List<Vendor> getVendors()
  {
    List<Vendor> newVendors = Collections.unmodifiableList(vendors);
    return newVendors;
  }

  public int numberOfVendors()
  {
    int number = vendors.size();
    return number;
  }

  public boolean hasVendors()
  {
    boolean has = vendors.size() > 0;
    return has;
  }

  public int indexOfVendor(Vendor aVendor)
  {
    int index = vendors.indexOf(aVendor);
    return index;
  }
  /* Code from template association_GetMany */
  public Order getOrder(int index)
  {
    Order aOrder = orders.get(index);
    return aOrder;
  }

  public List<Order> getOrders()
  {
    List<Order> newOrders = Collections.unmodifiableList(orders);
    return newOrders;
  }

  public int numberOfOrders()
  {
    int number = orders.size();
    return number;
  }

  public boolean hasOrders()
  {
    boolean has = orders.size() > 0;
    return has;
  }

  public int indexOfOrder(Order aOrder)
  {
    int index = orders.indexOf(aOrder);
    return index;
  }
  /* Code from template association_GetOne */
  public SystemManager getSystemManager()
  {
    return systemManager;
  }

  public boolean hasSystemManager()
  {
    boolean has = systemManager != null;
    return has;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfVendors()
  {
    return 0;
  }
  /* Code from template association_AddManyToManyMethod */
  public boolean addVendor(Vendor aVendor)
  {
    boolean wasAdded = false;
    if (vendors.contains(aVendor)) { return false; }
    vendors.add(aVendor);
    if (aVendor.indexOfCustomer(self) != -1)
    {
      wasAdded = true;
    }
    else
    {
      wasAdded = aVendor.addCustomer(self);
      if (!wasAdded)
      {
        vendors.remove(aVendor);
      }
    }
    return wasAdded;
  }
  /* Code from template association_RemoveMany */
  public boolean removeVendor(Vendor aVendor)
  {
    boolean wasRemoved = false;
    if (!vendors.contains(aVendor))
    {
      return wasRemoved;
    }

    int oldIndex = vendors.indexOf(aVendor);
    vendors.remove(oldIndex);
    if (aVendor.indexOfCustomer(self) == -1)
    {
      wasRemoved = true;
    }
    else
    {
      wasRemoved = aVendor.removeCustomer(self);
      if (!wasRemoved)
      {
        vendors.add(oldIndex,aVendor);
      }
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addVendorAt(Vendor aVendor, int index)
  {  
    boolean wasAdded = false;
    if(addVendor(aVendor))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfVendors()) { index = numberOfVendors() - 1; }
      vendors.remove(aVendor);
      vendors.add(index, aVendor);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveVendorAt(Vendor aVendor, int index)
  {
    boolean wasAdded = false;
    if(vendors.contains(aVendor))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfVendors()) { index = numberOfVendors() - 1; }
      vendors.remove(aVendor);
      vendors.add(index, aVendor);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addVendorAt(aVendor, index);
    }
    return wasAdded;
  }
  /* Code from template association_MinimumNumberOfMethod */
  public static int minimumNumberOfOrders()
  {
    return 0;
  }
  /* Code from template association_AddManyToOptionalOne */
  public boolean addOrder(Order aOrder)
  {
    boolean wasAdded = false;
    if (orders.contains(aOrder)) { return false; }
    Customer existingCustomer = aOrder.getCustomer();
    if (existingCustomer == null)
    {
      aOrder.setCustomer(self);
    }
    else if (!self.equals(existingCustomer))
    {
      existingCustomer.removeOrder(aOrder);
      addOrder(aOrder);
    }
    else
    {
      orders.add(aOrder);
    }
    wasAdded = true;
    return wasAdded;
  }

  public boolean removeOrder(Order aOrder)
  {
    boolean wasRemoved = false;
    if (orders.contains(aOrder))
    {
      orders.remove(aOrder);
      aOrder.setCustomer(null);
      wasRemoved = true;
    }
    return wasRemoved;
  }
  /* Code from template association_AddIndexControlFunctions */
  public boolean addOrderAt(Order aOrder, int index)
  {  
    boolean wasAdded = false;
    if(addOrder(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    }
    return wasAdded;
  }

  public boolean addOrMoveOrderAt(Order aOrder, int index)
  {
    boolean wasAdded = false;
    if(orders.contains(aOrder))
    {
      if(index < 0 ) { index = 0; }
      if(index > numberOfOrders()) { index = numberOfOrders() - 1; }
      orders.remove(aOrder);
      orders.add(index, aOrder);
      wasAdded = true;
    } 
    else 
    {
      wasAdded = addOrderAt(aOrder, index);
    }
    return wasAdded;
  }
  /* Code from template association_SetOptionalOneToMany */
  public boolean setSystemManager(SystemManager aSystemManager)
  {
    boolean wasSet = false;
    SystemManager existingSystemManager = systemManager;
    systemManager = aSystemManager;
    if (existingSystemManager != null && !existingSystemManager.equals(aSystemManager))
    {
      existingSystemManager.removeCustomer(self);
    }
    if (aSystemManager != null)
    {
      aSystemManager.addCustomer(self);
    }
    wasSet = true;
    return wasSet;
  }

  public void delete()
  {
    ArrayList<Vendor> copyOfVendors = new ArrayList<Vendor>(vendors);
    vendors.clear();
    for(Vendor aVendor : copyOfVendors)
    {
      aVendor.removeCustomer(self);
    }
    while( !orders.isEmpty() )
    {
      orders.get(0).setCustomer(null);
    }
    if (systemManager != null)
    {
      SystemManager placeholderSystemManager = systemManager;
      this.systemManager = null;
      placeholderSystemManager.removeCustomer(self);
    }
  }

  // line 107 "../ecommerceRMI1.ump"
   public Order orderProduct(String productType, String vendorName){
    for(Vendor v: getVendors())
		{
			if(v.getName().equals(vendorName))
				return v.makeOrder(self,v.findProduct(new ProductType(productType)));
		}
		return null;
  }


  public String toString()
  {
    return super.toString() + "["+
            "name" + ":" + getName()+ "]" + System.getProperties().getProperty("line.separator") +
            "  " + "systemManager = "+(getSystemManager()!=null?Integer.toHexString(System.identityHashCode(getSystemManager())):"null");
  }
}