[vlma-devel] commit: The fields server and adapter of the Order class are redundant since adapter .server == server. (Adrien Grand )

git version control git at videolan.org
Mon May 12 16:51:23 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Mon May 12 16:48:07 2008 +0200| [1a6a58d4c0302d8ab65a03415efdc8d0393911cf]

The fields server and adapter of the Order class are redundant since adapter.server == server.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=1a6a58d4c0302d8ab65a03415efdc8d0393911cf
---

 .../java/org/videolan/vlma/OrderGiverImpl.java     |   10 +++----
 .../java/org/videolan/vlma/model/order/Order.java  |   26 ++-----------------
 2 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java b/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java
index 576b0f8..0734076 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/OrderGiverImpl.java
@@ -205,7 +205,7 @@ public class OrderGiverImpl implements OrderGiver {
                             logger.log(Level.DEBUG, g.medias.size() + " media against " + order.getMedias().medias.size() + " media");
                             if ((order.getMedias().medias.containsAll(g.medias))
                                     && (g.medias.containsAll(order.getMedias().medias))
-                                    && (order.getServer().getIp() == g.medias.get(0).getProgram().getPlayer())) {
+                                    && (order.getAdapter().getServer().getIp() == g.medias.get(0).getProgram().getPlayer())) {
                                 // Remove the mediaGroup
                                 groupIt.remove();
                                 // Remove its correspondant adapter
@@ -254,25 +254,23 @@ public class OrderGiverImpl implements OrderGiver {
                     while (i.hasNext() && j.hasNext()) {
                         MediaGroup g = i.next();
                         Adapter a = j.next();
-                        Server adapterServer = a.getServer();
                         // Server adapterServer = readyAdaptersServers.get(a);
                         Order o = Order.getOrderForMediaClass(g.getMediaClass());
                         o.setAdapter(a);
-                        o.setServer(adapterServer);
                         o.setMedias(g);
                         logger.log(Level.DEBUG, "Assigning channels on adapter "
-                                + a.getName() + " of server " + adapterServer.getName());
+                                + a.getName() + " of server " + a.getServer().getName());
                         /*
                          * Set the server to the programs of the diffused medias
                          * for this adapter
                          */
                         for (Media media : o.getMedias().medias) {
-                            media.getProgram().setPlayer(adapterServer.getIp());
+                            media.getProgram().setPlayer(a.getServer().getIp());
                         }
                         try {
                             o.start();
                         } catch (IOException e) {
-                            adapterServer.setUp(false);
+                            a.getServer().setUp(false);
                         }
                         orders.get(c).add(o);
                     }
diff --git a/vlma-model/src/main/java/org/videolan/vlma/model/order/Order.java b/vlma-model/src/main/java/org/videolan/vlma/model/order/Order.java
index 991fd92..15ede37 100644
--- a/vlma-model/src/main/java/org/videolan/vlma/model/order/Order.java
+++ b/vlma-model/src/main/java/org/videolan/vlma/model/order/Order.java
@@ -50,8 +50,6 @@ public abstract class Order {
 
     private static final Logger logger = Logger.getLogger(Order.class);
 
-    private Server server;
-
     private Adapter adapter;
 
     protected MediaGroup medias;
@@ -104,24 +102,6 @@ public abstract class Order {
     }
 
     /**
-     * Gets the server associated with the order.
-     *
-     * @return the server
-     */
-    public Server getServer() {
-        return server;
-    }
-
-    /**
-     * Sets the server associated with the order.
-     *
-     * @param server the server
-     */
-    public void setServer(Server server) {
-        this.server = server;
-    }
-
-    /**
      * Gets the media group to stream.
      *
      * @return the media group
@@ -154,7 +134,7 @@ public abstract class Order {
      * @throws IOException Connection aborted.
      */
     protected void telnetConnect() throws IOException {
-        telnetSocket = new Socket(server.getIp(), VLMa.getInstance().getInt("vlc.telnet.port"));
+        telnetSocket = new Socket(adapter.getServer().getIp(), VLMa.getInstance().getInt("vlc.telnet.port"));
         telnetOut = new PrintWriter(telnetSocket.getOutputStream(), true);
         telnetIn = new BufferedReader(new InputStreamReader(telnetSocket
                 .getInputStream()));
@@ -180,7 +160,7 @@ public abstract class Order {
      */
     protected void telnetCommand(String command) throws IOException {
         logger.log(Level.DEBUG, "Send command " + command + " to "
-                + server.getName());
+                + adapter.getServer().getName());
         telnetOut.println(command);
         int d = VLMa.getInstance().getInt("vlc.telnet.delay");
         while (!telnetIn.ready() && (d -= DEFAULT_TELNET_WAIT) > 0) {
@@ -193,7 +173,7 @@ public abstract class Order {
         while (telnetIn.ready()) {
             response += (char) telnetIn.read();
         }
-        Command.add(server, command, response);
+        Command.add(adapter.getServer(), command, response);
         logger.log(Level.DEBUG, "Command result: " + response);
     }
 



More information about the vlma-devel mailing list