[jboss-cvs] JBossAS SVN: r90034 - in projects/ejb-book/trunk/ch06-filetransfer/src: main/resources and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 10 01:39:12 EDT 2009


Author: ALRubinger
Date: 2009-06-10 01:39:11 -0400 (Wed, 10 Jun 2009)
New Revision: 90034

Removed:
   projects/ejb-book/trunk/ch06-filetransfer/src/main/resources/META-INF/
Modified:
   projects/ejb-book/trunk/ch06-filetransfer/src/main/java/org/jboss/ejb3/examples/ch06/filetransfer/FileTransferBean.java
   projects/ejb-book/trunk/ch06-filetransfer/src/test/java/org/jboss/ejb3/examples/ch06/filetransfer/FileTransferUnitTestCase.java
Log:
[EJBBOOK-8] Hardcode the connect port/host as to not muddy the examples w/ XML

Modified: projects/ejb-book/trunk/ch06-filetransfer/src/main/java/org/jboss/ejb3/examples/ch06/filetransfer/FileTransferBean.java
===================================================================
--- projects/ejb-book/trunk/ch06-filetransfer/src/main/java/org/jboss/ejb3/examples/ch06/filetransfer/FileTransferBean.java	2009-06-10 04:18:09 UTC (rev 90033)
+++ projects/ejb-book/trunk/ch06-filetransfer/src/main/java/org/jboss/ejb3/examples/ch06/filetransfer/FileTransferBean.java	2009-06-10 05:39:11 UTC (rev 90034)
@@ -26,7 +26,6 @@
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
 import javax.ejb.PostActivate;
 import javax.ejb.PrePassivate;
 import javax.ejb.Remote;
@@ -67,19 +66,23 @@
    private static final Logger log = Logger.getLogger(FileTransferBean.class);
 
    /**
-    * Name of the environment entry containing the host to which we'll connect
+    * Name of the EJB, used in Global JNDI addresses
     */
-   private static final String ENV_ENTRY_NAME_CONNECT_HOST = "connectHost";
+   public static final String EJB_NAME = "FileTransferEJB";
 
    /**
-    * Name of the environment entry containing the port to which we'll connect
+    * The name of the host to which we'll connect.
+    * In production systems would typically be externalized
+    * via configurable environment entry
     */
-   private static final String ENV_ENTRY_NAME_CONNECT_PORT = "connectPort";
+   private static String CONNECT_HOST = "localhost";
 
    /**
-    * Name of the EJB, referenced from ejb-jar.xml and used in Global JNDI addresses
+    * The port to which we'll connect.
+    * In production systems would typically be externalized
+    * via configurable environment entry
     */
-   public static final String EJB_NAME = "FileTransferEJB";
+   private static int CONNECT_PORT = 12345;
 
    //-------------------------------------------------------------------------------------||
    // Instance Members -------------------------------------------------------------------||
@@ -94,22 +97,6 @@
    private FTPClient client;
 
    /**
-    * The name of the host to which we'll connect.
-    * Initialized from the environment entry named
-    * {@link FileTransferBean#ENV_ENTRY_NAME_CONNECT_HOST}
-    */
-   @Resource(name = ENV_ENTRY_NAME_CONNECT_HOST)
-   private String connectHost;
-
-   /**
-    * The port to which we'll connect.
-    * Initialized from the environment entry named
-    * {@link FileTransferBean#ENV_ENTRY_NAME_CONNECT_PORT}
-    */
-   @Resource(name = ENV_ENTRY_NAME_CONNECT_PORT)
-   private int connectPort;
-
-   /**
     * Name of the present working directory.  In cases where
     * we're passivated, if this is specified
     * we'll change into this directory upon activation.
@@ -367,46 +354,18 @@
     */
    public String getConnectHost()
    {
-      final String connectHost = this.connectHost;
-      if (connectHost == null || connectHost.length() == 0)
-      {
-         throw new IllegalStateException("Connect host must have been defined by env-entry name: "
-               + ENV_ENTRY_NAME_CONNECT_HOST);
-      }
-      return connectHost;
+      return CONNECT_HOST;
    }
 
    /**
-    * @param connectHost the connectHost to set
-    */
-   public void setConnectHost(final String connectHost)
-   {
-      this.connectHost = connectHost;
-   }
-
-   /**
     * @return the connectPort
     */
    public int getConnectPort()
    {
-      final int connectPort = this.connectPort;
-      if (connectPort <= 0)
-      {
-         throw new IllegalStateException("Connect port must have been defined by env-entry name \""
-               + ENV_ENTRY_NAME_CONNECT_PORT + "\" and must be a positive integer");
-      }
-      return connectPort;
+      return CONNECT_PORT;
    }
 
    /**
-    * @param connectPort the connectPort to set
-    */
-   public void setConnectPort(final int connectPort)
-   {
-      this.connectPort = connectPort;
-   }
-
-   /**
     * @return the client
     */
    protected final FTPClient getClient()

Modified: projects/ejb-book/trunk/ch06-filetransfer/src/test/java/org/jboss/ejb3/examples/ch06/filetransfer/FileTransferUnitTestCase.java
===================================================================
--- projects/ejb-book/trunk/ch06-filetransfer/src/test/java/org/jboss/ejb3/examples/ch06/filetransfer/FileTransferUnitTestCase.java	2009-06-10 04:18:09 UTC (rev 90033)
+++ projects/ejb-book/trunk/ch06-filetransfer/src/test/java/org/jboss/ejb3/examples/ch06/filetransfer/FileTransferUnitTestCase.java	2009-06-10 05:39:11 UTC (rev 90034)
@@ -77,11 +77,6 @@
    private static final int FTP_SERVICE_BIND_PORT = 12345;
 
    /**
-    * Host to which the FTP Client will connect
-    */
-   private static final String FTP_CLIENT_CONNECT_HOST = "127.0.0.1";
-
-   /**
     * Name of the users configuration file for the server
     */
    private static final String FILE_NAME_USERS_CONFIG = "ftpusers.properties";
@@ -155,14 +150,9 @@
    @Before
    public void createFtpClient() throws Exception
    {
-
       // Create client
       final FileTransferBean ftpClient = new FileTransferBean();
 
-      // Set properties
-      ftpClient.setConnectHost(FTP_CLIENT_CONNECT_HOST);
-      ftpClient.setConnectPort(FTP_SERVICE_BIND_PORT);
-
       // Connect
       ftpClient.connect();
 




More information about the jboss-cvs-commits mailing list