Changeset 342:349a8aa7708a in finroc_core-java


Ignore:
Timestamp:
25.05.2020 22:53:10 (6 weeks ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Tags:
tip
Message:

Adapts AdministationService to change in finroc_plugins_runtime_construction (CreateModule may return handle of created component)

Location:
admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • admin/AdminClient.java

    r329 r342  
    315315     * @param parentHandle Remote handle of parent module 
    316316     * @param spl Parameters 
    317      * @return Did module creation succeed? If not, contains error message. 
    318      */ 
    319     public String createModule(RemoteCreateAction cma, String name, int parentHandle, RemoteStaticParameterList spl) { 
     317     * @return If module creation succeeded, returns either null (legacy Finroc versions) or Integer with handle of created object (current Finroc releases)? If not, contains error message. 
     318     */ 
     319    public Object createModule(RemoteCreateAction cma, String name, int parentHandle, RemoteStaticParameterList spl) { 
    320320        try { 
    321321            MemoryBuffer mb = new MemoryBuffer(); 
     
    329329 
    330330            String cs = (String)this.callSynchronous(5000, AdminServer.CREATE_MODULE, cma.getHandle(), name, parentHandle, mb); 
     331            final String SUCCESS_PREFIX = "Created Element Handle: "; 
    331332            if (cs != null) { 
     333                if (cs.startsWith(SUCCESS_PREFIX)) { 
     334                    long handle = Long.parseLong(cs.substring(SUCCESS_PREFIX.length()).trim()); 
     335                    return (int)handle; 
     336                } 
    332337                return cs; 
    333338            } 
    334             return ""; 
     339            return null; 
    335340        } catch (Exception e) { 
    336341            Log.log(LogLevel.WARNING, getLogDescription(), e); 
  • admin/AdministrationService.java

    r329 r342  
    138138     * @param parentHandle Handle of parent element 
    139139     * @param serializedCreationParameters Serialized constructor parameters in case the module requires such - otherwise empty 
    140      * @return Empty string if it worked - otherwise error message 
     140     * @return "Created Element Handle: <handle>" if it worked - otherwise error message 
    141141     */ 
    142142    public String createModule(int createActionIndex, String moduleName, int parentHandle, MemoryBuffer serializedCreationParameters) { 
     
    178178 
    179179                    Log.log(LogLevel.USER, this, "Creating Module succeeded"); 
     180                    result = "Created Element Handle: " + created.getHandle(); 
    180181                } 
    181182            } 
Note: See TracChangeset for help on using the changeset viewer.