Specify UTF-8 encoding for all Java agent commands
[lttng-ust.git] / liblttng-ust-java-agent / java / lttng-ust-agent-common / org / lttng / ust / agent / client / SessiondListLoggersCommand.java
index cb20ea90b499d5e2a3dd3c1347d8ae558cf01b49..1c7ef9b400f019e7611c36b5bb349c99cc628b5d 100644 (file)
@@ -20,10 +20,7 @@ package org.lttng.ust.agent.client;
 
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.lttng.ust.agent.AbstractLttngAgent;
+import java.util.Collection;
 
 /**
  * Session daemon command asking the Java agent to list its registered loggers,
@@ -32,29 +29,28 @@ import org.lttng.ust.agent.AbstractLttngAgent;
  * @author Alexandre Montplaisir
  * @author David Goulet
  */
-class SessiondListLoggersCommand implements ISessiondCommand {
+class SessiondListLoggersCommand extends SessiondCommand {
 
        @Override
-       public ILttngAgentResponse execute(AbstractLttngAgent<?> agent) {
-               final List<String> loggerList = new ArrayList<String>();
+       public LttngAgentResponse execute(ILttngTcpClientListener agent) {
+               final Collection<String> loggerList = agent.listAvailableEvents();
                int dataSize = 0;
 
-               for (String event : agent.listEnabledEvents()) {
-                       loggerList.add(event);
+               for (String event : agent.listAvailableEvents()) {
                        dataSize += event.length() + 1;
                }
 
                return new SessiondListLoggersResponse(loggerList, dataSize);
        }
 
-       private static class SessiondListLoggersResponse implements ILttngAgentResponse {
+       private static class SessiondListLoggersResponse extends LttngAgentResponse {
 
                private final static int SIZE = 12;
 
-               private final List<String> loggers;
+               private final Collection<String> loggers;
                private final int dataSize;
 
-               public SessiondListLoggersResponse(List<String> loggers, int dataSize) {
+               public SessiondListLoggersResponse(Collection<String> loggers, int dataSize) {
                        this.loggers = loggers;
                        this.dataSize = dataSize;
                }
@@ -62,7 +58,7 @@ class SessiondListLoggersCommand implements ISessiondCommand {
                @Override
                public ReturnCode getReturnCode() {
                        /* This command can't really fail */
-                       return ILttngAgentResponse.SUCESS_RESPONSE.getReturnCode();
+                       return ReturnCode.CODE_SUCCESS_CMD;
                }
 
                @Override
@@ -77,7 +73,7 @@ class SessiondListLoggersCommand implements ISessiondCommand {
                        buf.putInt(loggers.size());
 
                        for (String logger : loggers) {
-                               buf.put(logger.getBytes());
+                               buf.put(logger.getBytes(SESSIOND_PROTOCOL_CHARSET));
                                /* NULL terminated byte after the logger name. */
                                buf.put((byte) 0x0);
                        }
This page took 0.024293 seconds and 4 git commands to generate.