
class UmpleToPython {
  objectFactory_add_methods1 <<!<</*objectFactory_add_methods1*/>><<#
  if(isInterface!=true){
    append(realSb,"\n  {0} {1}({2}{3} proxy)",new Object[] {accessibility, "new"+uClass.getName(), arguments+argumentscomma,uClass.getName()});

  #>>
  {
    return new<<=uClass.getName()>>(<<=caller>><<=argumentscomma>>getComponent("<<=uClass.getName()>>"),proxy);
  }  
  <<#
  }
  if(isInterface!=true){
    append(realSb,"\n  {0} {1}({2}UmpleRuntime.UmpleComponent component{3} proxy)",new Object[] {accessibility, "new"+uClass.getName(), arguments+argumentscomma, ", "+uClass.getName()});
  #>>
  {
    while(true){
      try
      {
        return remoteFactories.get(getNodeId(component)).create<<=uClass.getName()>>(<<=caller>><<=argumentscomma>>proxy);
      }
      catch(Exception e) 
      {
        e.printStackTrace();
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }  
    }
  }
    <<#
    }
  append(realSb,"\n  {0}{1} {2}({3}{4} proxy)",new Object[] {webMethod,accessibilityCreate , "create"+uClass.getName(), arguments,argumentscomma+uClass.getName()});
  if(isInterface==true){
  #>>throws RemoteException;<<#
  }
  else{
    if(uClass.getIsSingleton()){
    #>>
    {
    <<=uClass.getName()>>Impl object= <<=uClass.getName()>>Impl.getInstance();
    <<#
    }
   else
   { 
#>>
  {
  <<=uClass.getName()>>Impl object = new <<=uClass.getName()>>Impl(<<=caller>>);<<#}#>>
    object.setSelf(proxy);
    proxy.setRealObject(object);
      try
      { 
        <<#if(uClass.getDistributeTechnology().equals("RMI")){#>> 
        UnicastRemoteObject.exportObject(object,0);
        <<#}
        else if(uClass.getDistributeTechnology().equals("WS")){
        #>>
        Endpoint.publish(nodes.get(getThisNodeId()).getUrl()+":"+String.valueOf(nodes.get(getThisNodeId()).getPort())+"/hw",object);
        <<#}#>>
      } 
      catch (Exception e)
      {
        System.err.println("Server Exception: " + e.toString());
        try { Thread.sleep(1000); } catch (InterruptedException interruptedException) {};
      }

  listOfObjects.add(object);
  return object; 
  }
  <<#
    }#>>!>>
}
