PageRenderTime 41ms CodeModel.GetById 37ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/razpub/src/com/razie/pub/agent/TempUtilAgent.java

http://razpub.googlecode.com/
Java | 44 lines | 25 code | 7 blank | 12 comment | 0 complexity | bca3ea1352455fc2038f48bf030d1f74 MD5 | raw file
 1/**
 2 * Razvan's public code. Copyright 2008 based on Apache license (share alike) see LICENSE.txt for
 3 * details. No warranty implied nor any liability assumed for this code.
 4 */
 5package com.razie.pub.agent;
 6
 7import com.razie.pub.base.ExecutionContext;
 8import com.razie.pub.comms.AgentCloud;
 9import com.razie.pub.comms.AgentHandle;
10import com.razie.pub.comms.LightAuth;
11import com.razie.pub.http.LightCmdGET;
12import com.razie.pub.http.*;
13
14/** netbeans can't share unit classes forcing me to move testing code here - this is temp until i figure a workaround
15 *
16 * @author razvanc
17 */
18public class TempUtilAgent {
19	public static AgentHandle me = new AgentHandle("testagent1", "localhost",
20			"127.0.0.1", "4446", "http://localhost:4446");
21	public static AgentHandle other = new AgentHandle("testagent2", "localhost",
22			"127.0.0.1", "4447", "http://localhost:4447");
23
24
25   /** start an agent and mount basic services */
26   public static Agent startAgent(AgentHandle h, AgentCloud g) {
27      Agent agent = new Agent(h, g);
28      agent.getContext().enter();
29      agent.onInit();
30
31      LightAuth.init(new LightAuth("lightsoa"));
32
33      // we need a server with cmdget to accept bindings for services. You
34      // should do this for any
35      // agent
36      LightServer server = new LightServer(Integer.parseInt(h.port), 20, agent.getContext(), new LightContentServer(null));
37      server.registerHandler(new LightCmdGET());
38      agent.register(new AgentHttpService(agent, server));
39
40      agent.onStartup();
41      ExecutionContext.exit();
42      return agent;
43   }
44}