1 package cz.cuni.amis.pogamut.base.agent.jmx.proxy;
2
3 import java.io.IOException;
4 import java.net.MalformedURLException;
5 import java.util.logging.Logger;
6
7 import javax.management.MalformedObjectNameException;
8 import javax.management.ObjectName;
9
10 import cz.cuni.amis.pogamut.base.agent.IGhostAgent;
11 import cz.cuni.amis.pogamut.base.communication.command.IAct;
12 import cz.cuni.amis.pogamut.base.communication.command.ICommandListener;
13 import cz.cuni.amis.pogamut.base.communication.exception.CommunicationException;
14 import cz.cuni.amis.pogamut.base.communication.messages.CommandMessage;
15 import cz.cuni.amis.pogamut.base.communication.worldview.IWorldView;
16 import cz.cuni.amis.pogamut.base.utils.jmx.PogamutJMX;
17 import cz.cuni.amis.utils.token.Token;
18 import cz.cuni.amis.utils.token.Tokens;
19
20
21
22
23
24 public class GhostAgentJMXProxy extends AgentJMXProxy implements IGhostAgent {
25
26 IAct act = null;
27
28 public GhostAgentJMXProxy(String agentJMXAddress) throws MalformedURLException, IOException, MalformedObjectNameException {
29 super(agentJMXAddress);
30 final ObjectName actMBeanName = PogamutJMX.getObjectName(getObjectName(), PogamutJMX.ACT_NAME);
31 act = new IAct() {
32
33 Token componentId = Tokens.get(PogamutJMX.ACT_NAME);
34
35 @Override
36 public void act(CommandMessage command) throws CommunicationException {
37 try {
38 getMBeanServerConnection().invoke(actMBeanName, "act", new Object[]{command}, null);
39 } catch (Exception ex) {
40 throw new CommunicationException("JMX error sending command.", ex, this);
41 }
42 }
43
44 @Override
45 public void addCommandListener(Class commandClass, ICommandListener listener) {
46 throw new UnsupportedOperationException("Not supported yet.");
47 }
48
49 @Override
50 public void removeCommandListener(Class commandClass, ICommandListener listener) {
51 throw new UnsupportedOperationException("Not supported yet.");
52 }
53
54 @Override
55 public Token getComponentId() {
56 return componentId;
57 }
58
59 @Override
60 public boolean isCommandListening(Class commandClass,
61 ICommandListener listener) {
62 throw new UnsupportedOperationException("Not supported yet.");
63 }
64
65 };
66 }
67
68 @Override
69 public IAct getAct() {
70 return act;
71 }
72
73 @Override
74 public IWorldView getWorldView() {
75 throw new UnsupportedOperationException("Not supported yet.");
76 }
77
78 }