Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.kevoree.library;
  
 
Created by duke on 8/26/14.
 
 public class ExternalMessageInjection implements Callable<String> {
 
     private String payload;
 
     private String path;
 
     private ModelRegistry registry;
 
     private ModelService service;
 
     public ExternalMessageInjection(String pString pathModelRegistry regModelService service) {
         this. = p;
         this. = path;
         this. = reg;
         this. = service;
     }
 
     public static final String channelPath = "/channels/";
 
     public static final String componentPath = "/components/";
 
 
     @Override
     public String call() throws Exception {
         try {
             if (.startsWith()) {
                 String id = .substring(.length());
                 Channel channel = this..getCurrentModel().getModel().findHubsByID(id);
                 if (channel != null) {
                     ChannelWrapper obj = (ChannelWrapperthis..lookup(channel);
                     if (obj != null) {
                         obj.call(new Callback<Object>() {
                             @Override
                             public void onSuccess(Object result) {
                                 //TODO collect result here
                             }
 
                             @Override
                             public void onError(Throwable exception) {
 
                             }
                         }, );
                     } else {
                         return "channel " + id + " not found on this platform";
                     }
                 }
             }
             if (.startsWith()) {
                 String id = .substring(.length());
                 if (!id.contains("/")) {
                     return "malformed url /components/<componentID>/<portID> expected, actually " + ;
                 }
                 String[] paths = id.split("/");
                 if (paths.length != 2) {
                     return "malformed url /components/<componentID>/<portID> expected, actually " +  + ": " + paths.length;
                 }
                 ComponentInstance component = this..getCurrentModel().getModel().findNodesByID(this..getNodeName()).findComponentsByID(paths[0]);
                 if (component != null) {
                     ComponentWrapper obj = (ComponentWrapperthis..lookup(component);
                     if (obj != null) {
                         ProvidedPortImpl pport = obj.getProvidedPorts().get(paths[1]);
                         if (pport != null) {
                             pport.call(new Callback() {
                                 @Override
                                 public void onSuccess(Object result) {
 
                                 }
 
                                 @Override
                                 public void onError(Throwable exception) {
 
                                 }
                             });
                         }
                         RequiredPortImpl rport = obj.getRequiredPorts().get(paths[1]);
                         if (rport != null) {
                             rport.call(new Callback() {
                                 @Override
                                 public void onSuccess(Object result) {
 
                                 }
                                @Override
                                public void onError(Throwable exception) {
                                }
                            });
                        }
                    } else {
                        return "component " + id + " not found on this platform";
                    }
                }
            }
        } catch (Exception e) {
            Log.error("Error during processing external call "e);
        }
        //TODO block if result is necessary
        return "ack";
    }
New to GrepCode? Check out our FAQ X