Java 类akka.actor.UntypedActorContext 实例源码

项目:maker    文件:HelloWorld.java   
@Override
public void onReceive(final Object message) throws Exception {
  boolean _equals = Objects.equal(message, Greeter.Msg.DONE);
  if (_equals) {
    this.log.info("DONE!");
    UntypedActorContext _context = this.getContext();
    ActorRef _self = this.getSelf();
    _context.stop(_self);
  } else {
    boolean _equals_1 = Objects.equal(message, "me");
    if (_equals_1) {
      this.log.info("hello,tung!");
      this.unhandled(message);
    } else {
      this.unhandled(message);
    }
  }
}
项目:Megapode    文件:ComponentHandler.java   
@Override
    public void onReceive(Object rawMessage) throws Exception {
//      log.info("Page got: "+rawMessage.getClass().getCanonicalName());
        if (rawMessage instanceof ComponentMessage){
//          log.info("Handelling Request");
            Future<String> rendered = null;
            try {
                final ComponentMessage message = (ComponentMessage)rawMessage;
                rendered = future(new Callable<String>() {
                      public String call() throws Exception {
                          IWidget component = components.get(message.getRouteToken()).getConstructor(Map.class, ActorRef.class, UntypedActorContext.class).newInstance(routers, getSender(), context());
                          component.initialise(message.getParameters().toArray(new Object[0]));
                          return build(component);
                      }
                    }, context().dispatcher());

            } catch (Exception e){
                rendered = Futures.failed(e);
            }
            akka.pattern.Patterns.pipe(rendered, this.getContext().dispatcher()).to(getSender());
        } 
        else {
            unhandled(rawMessage);
        }
    }
项目:Megapode    文件:RendererHandler.java   
@Override
    public void onReceive(Object rawMessage) throws Exception {
//      log.info("Renderer got: "+rawMessage.getClass().getCanonicalName());
        if (rawMessage instanceof RenderMessage){
            RenderMessage message = (RenderMessage)rawMessage;
            //final ActorRef coordinatingActor, final UntypedActorContext actorContext

            Class<? extends IRenderer> renderer = renderers.get(message.getRenderer());
            Constructor<? extends IRenderer> constr = renderer.getConstructor(Map.class, ActorRef.class, UntypedActorContext.class, VelocityEngine.class);
            IRenderer page = constr.newInstance(routers, getSender(), this.context(), engine);
            Future<String> rendered = null;
            if (message.getTemplateName() != null){
                rendered = page.render(message.getTemplateName(), message.getContext());
            } else {
                rendered = page.render(message.getContext());
            }

            //log.info("Rendered: "+rendered);
            akka.pattern.Patterns.pipe(rendered, this.getContext().dispatcher()).to(getSender());
            //getSender().tell(rendered, getSelf());
        } 
        else {
            unhandled(rawMessage);
        }
    }
项目:Megapode    文件:PersistanceHandler.java   
@Override
    public void onReceive(Object rawMessage) throws Exception {
//      log.info("PersistanceHandler got: "+rawMessage.getClass().getCanonicalName());
        if (rawMessage instanceof PersistanceMessage){
            PersistanceMessage message = (PersistanceMessage)rawMessage;

            String task_name = message.getPersistanceTask();
            Class<? extends IDataAccessor> calculationClass = persistanceTasks.get(task_name);
            Constructor<? extends IDataAccessor> constr = calculationClass.getConstructor(Map.class, ActorRef.class, UntypedActorContext.class, Connection.class);
            IDataAccessor persistor = constr.newInstance(routers, getSender(), this.context(), this.connection);

            Future<Object> result = (Future<Object>) persistor.performTask(message.getArgs().toArray(new Object[0]));//.calculate(message.getArgs().toArray(new Object[0]));
            //Pattern.
            akka.pattern.Patterns.pipe(result, this.getContext().dispatcher()).to(getSender());
            //          Map<String, ?> result = persistor.performTask(message.getArgs().toArray());
//          getSender().tell(result, getSelf());
        } 
        else {
            unhandled(rawMessage);
        }
    }
项目:Megapode    文件:CalculationHandler.java   
@Override
    public void onReceive(Object rawMessage) throws Exception {
//      log.info("CalculationHandler got: "+rawMessage.getClass().getCanonicalName());
        if (rawMessage instanceof CalculationMessage){
            CalculationMessage message = (CalculationMessage)rawMessage;

            String task_name = message.getTaskName();
//          log.info("CalculationHandler requested method task_name: "+task_name);
            Class<? extends ICalculation> calculationClass = calculations.get(task_name);
            Constructor<? extends ICalculation> constr = calculationClass.getConstructor(Map.class, ActorRef.class, UntypedActorContext.class);
            ICalculation calculation = constr.newInstance(routers, getSender(), this.context());

            Future<Object> result = (Future<Object>) calculation.calculate(message.getArgs().toArray(new Object[0]));
            //Pattern.
            akka.pattern.Patterns.pipe(result, this.getContext().dispatcher()).to(getSender());
            //getSender().tell(result, getSelf());
        } 
        else {
            unhandled(rawMessage);
        }
    }
项目:Megapode    文件:WidgetHandler.java   
@Override
    public void onReceive(Object rawMessage) throws Exception {
//      log.info("Page got: "+rawMessage.getClass().getCanonicalName());
        if (rawMessage instanceof ComponentMessage){
//          log.info("Handelling Request");
            Future<String> rendered = null;
            try {
                final ComponentMessage message = (ComponentMessage)rawMessage;
                rendered = future(new Callable<String>() {
                      public String call() throws Exception {
                          IWidget component = components.get(message.getRouteToken()).getConstructor(Map.class, ActorRef.class, UntypedActorContext.class).newInstance(routers, getSender(), context());
                          component.initialise(message.getParameters().toArray(new Object[0]));
                          return build(component);
                      }
                    }, context().dispatcher());

            } catch (Exception e){
                rendered = Futures.failed(e);
            }
            akka.pattern.Patterns.pipe(rendered, this.getContext().dispatcher()).to(getSender());
        } 
        else {
            unhandled(rawMessage);
        }
    }
项目:Megapode    文件:PageHandler.java   
private IPage loadPage(String path, String method, String query, Header[] headers, byte[] content) throws PageNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    Map<String, String> parameters = new HashMap<String, String>();
    for (PageRoute route: pages){
        if (route.getTemplate().match(path, parameters)){
            IPage page = route.getPageClass().getConstructor(Map.class, ActorRef.class, UntypedActorContext.class).newInstance(routers, getSender(), this.context());
            page.initialise(path, 
                    method,
                    query,
                    headers, 
                    content,
                    parameters
                    );
            return page;
        }
    }

    throw new PageNotFoundException(String.format("Page matching [%s] not found", path));
}
项目:Megapode    文件:TaskHandler.java   
@Override
    public void onReceive(Object rawMessage) throws Exception {
//      log.info("TaskHandler got: "+rawMessage.getClass().getCanonicalName());
        if (rawMessage instanceof TaskMessage){
            TaskMessage message = (TaskMessage)rawMessage;

            String task_name = message.getTaskName();
            Class<? extends ITask> taskClass = tasks.get(task_name);
            Constructor<? extends ITask> constr = taskClass.getConstructor(Map.class, ActorRef.class, UntypedActorContext.class);
            ITask task = constr.newInstance(routers, getSender(), this.context());

            task.act(message.getArgs().toArray(new Object[0]));
        } 
        else {
            unhandled(rawMessage);
        }
    }
项目:IPPR2016    文件:AkkaSelector.java   
public synchronized Optional<ActorRef> findActor(final UntypedActorContext context,
    final String path) {
  final ActorSelection sel = context.actorSelection(path);

  try {
    final Future<ActorRef> fut = sel.resolveOne(TIMEOUT);
    final ActorRef ref = Await.result(fut, TIMEOUT.duration());
    LOG.debug("Actor [{}] is existing in context [{}], use this actor", path, context.system());
    return Optional.of(ref);
  } catch (final Exception e) {
    LOG.debug("Actor [{}] is not existing or answering in context [{}]", path, context.system());
    return Optional.empty();
  }
}
项目:hashsdn-controller    文件:ShardTransactionActorFactory.java   
ShardTransactionActorFactory(ShardDataTree dataTree, DatastoreContext datastoreContext,
        String txnDispatcherPath, ActorRef shardActor, UntypedActorContext actorContext, ShardStats shardMBean,
        String shardName) {
    this.dataTree = Preconditions.checkNotNull(dataTree);
    this.datastoreContext = Preconditions.checkNotNull(datastoreContext);
    this.txnDispatcherPath = Preconditions.checkNotNull(txnDispatcherPath);
    this.shardMBean = Preconditions.checkNotNull(shardMBean);
    this.actorContext = Preconditions.checkNotNull(actorContext);
    this.shardActor = Preconditions.checkNotNull(shardActor);
    this.shardName = Preconditions.checkNotNull(shardName);
}
项目:maker    文件:HelloWorld.java   
@Override
public void preStart() {
  UntypedActorContext _context = this.getContext();
  Props _create = Props.create(Greeter.class);
  final ActorRef greeter = _context.actorOf(_create, "greeter");
  ActorRef _self = this.getSelf();
  greeter.tell(Greeter.Msg.GREET, _self);
}
项目:Megapode    文件:FormParser.java   
public FormParser(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext) {
    super(routers, coordinatingActor, actorContext);
    parsers.put("application/x-www-form-urlencoded", new FormEncoding());
    parsers.put("application/json", new JsonEncoding());
    //multipart/form-data
}
项目:Megapode    文件:PersistanceBase.java   
public PersistanceBase(Map<Layers, ActorRef> routers, 
        ActorRef coordinatingActor, 
        UntypedActorContext actorContext, 
        Connection connection) {
    super(routers, coordinatingActor, actorContext);
    this.connection = connection;

}
项目:Megapode    文件:ConcurrantCallable.java   
public ConcurrantCallable(final Map<Layers, ActorRef> routers, final ActorRef coordinatingActor, final UntypedActorContext actorContext){
    this.coordinatingActor = coordinatingActor;
    setActorContext(actorContext);
    this.routers = routers;

    taskList = Collections.synchronizedList(new ArrayList<Future<Object>>());
    awaitListeners = new CopyOnWriteArraySet<Promise<Object>>();
}
项目:Megapode    文件:RendererBase.java   
public RendererBase(final Map<Layers, ActorRef> routers, 
        final ActorRef coordinatingActor, 
        final UntypedActorContext actorContext, 
        final VelocityEngine engine){
    super(routers, coordinatingActor, actorContext);
    this.engine = engine;
}
项目:IPPR2016    文件:AbstractTask.java   
public AbstractTask(final UntypedActorContext parentContext) {
  checkNotNull(parentContext);
  this.parentContext = parentContext;
}
项目:IPPR2016    文件:AbstractTask.java   
public <T> AbstractTask(final TaskCallback<T> callback, final UntypedActorContext parentContext) {
  checkNotNull(callback);
  checkNotNull(parentContext);
  this.callback = callback;
  this.parentContext = parentContext;
}
项目:IPPR2016    文件:AbstractTask.java   
protected UntypedActorContext getParentContext() {
  if (parentContext == null) {
    throw new UnsupportedOperationException("Context of parent is not set");
  }
  return parentContext;
}
项目:IPPR2016    文件:TaskManager.java   
public void executeTask(final TaskAllocation task, final UntypedActorContext context,
    final Object msg) {
  final ActorRef taskActor =
      context.actorOf(springExtension.props(task.getActorName()), getTaskId());
  taskActor.forward(msg, context);
}
项目:IPPR2016    文件:TaskManager.java   
public <T> void executeTask(final TaskAllocation task, final UntypedActorContext context,
    final Object msg, final TaskCallback<T> callback) {
  final ActorRef taskActor =
      context.actorOf(springExtension.props(task.getActorName(), callback), getTaskId());
  taskActor.forward(msg, context);
}
项目:IPPR2016    文件:TaskManager.java   
public void executeTaskInContext(final TaskAllocation task, final UntypedActorContext context,
    final Object msg) {
  final ActorRef taskActor =
      context.actorOf(springExtension.props(task.getActorName(), context), getTaskId());
  taskActor.forward(msg, context);
}
项目:IPPR2016    文件:CancelTimeoutTask.java   
public CancelTimeoutTask(final UntypedActorContext parentContext) {
  super(parentContext);
}
项目:IPPR2016    文件:StartTimeoutTask.java   
public StartTimeoutTask(final UntypedActorContext parentContext) {
  super(parentContext);
}
项目:IPPR2016    文件:SendMessagesTask.java   
public SendMessagesTask(final UntypedActorContext parentContext) {
  super(parentContext);
}
项目:IPPR2016    文件:ProcessInitializeTask.java   
public ProcessInitializeTask(final UntypedActorContext parentContext) {
  super(parentContext);
}
项目:Megapode    文件:CookieParser.java   
public CookieParser(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext) {
    super(routers, coordinatingActor, actorContext);
}
项目:Megapode    文件:DefaultRenderer.java   
public DefaultRenderer(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext, VelocityEngine engine) {
    super(routers, coordinatingActor, actorContext, engine);
    // TODO Auto-generated constructor stub
}
项目:Megapode    文件:TaskBase.java   
public TaskBase(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext) {
    super(routers, coordinatingActor, actorContext);
    // TODO Auto-generated constructor stub
}
项目:Megapode    文件:ConcurrantCallable.java   
public UntypedActorContext getActorContext() {
    return actorContext;
}
项目:Megapode    文件:ConcurrantCallable.java   
public void setActorContext(UntypedActorContext context) {
    actorContext = context;
}
项目:Megapode    文件:WidgetBase.java   
public WidgetBase(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext) {
    super(routers, coordinatingActor, actorContext);
}
项目:Megapode    文件:PageBase.java   
public PageBase(final Map<Layers, ActorRef> routers, final ActorRef coordinatingActor, final UntypedActorContext actorContext){
    super(routers, coordinatingActor, actorContext);
}
项目:Megapode    文件:CalculationBase.java   
public CalculationBase(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext) {
    super(routers, coordinatingActor, actorContext);
}
项目:Megapode    文件:ProfilePage.java   
public ProfilePage(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext) {
    super(routers, coordinatingActor, actorContext);
}
项目:Megapode    文件:ProfileTask.java   
public ProfileTask(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext) {
    super(routers, coordinatingActor, actorContext);

}
项目:Megapode    文件:ProfileWidget.java   
public ProfileWidget(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext) {
    super(routers, coordinatingActor, actorContext);
}
项目:Megapode    文件:ProfileCalculation.java   
public ProfileCalculation(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext) {
    super(routers, coordinatingActor, actorContext);
}
项目:Megapode    文件:ProfileRenderer.java   
public ProfileRenderer(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext, VelocityEngine engine) {
    super(routers, coordinatingActor, actorContext, engine);
}
项目:Megapode    文件:ProfileDataAccessor.java   
public ProfileDataAccessor(Map<Layers, ActorRef> routers,
        ActorRef coordinatingActor, UntypedActorContext actorContext,
        Connection connection) {
    super(routers, coordinatingActor, actorContext, connection);
    // TODO Auto-generated constructor stub
}