java applet qr code | Appendix C: Stateful Session EJB: FTP Client Example in Java

Maker QR Code in Java | Appendix C: Stateful Session EJB: FTP Client Example

480 | Appendix C: Stateful Session EJB: FTP Client Example
QR-Code Generation In Java
Using Barcode drawer for Java Control to generate, create QR Code ISO/IEC18004 image in Java applications.
www.OnBarcode.com
Reading QR-Code In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
}
Paint Code 128 Code Set A In Java
Using Barcode maker for Java Control to generate, create Code 128A image in Java applications.
www.OnBarcode.com
Generate EAN-13 Supplement 5 In Java
Using Barcode creation for Java Control to generate, create EAN13 image in Java applications.
www.OnBarcode.com
}
UCC - 12 Drawer In Java
Using Barcode printer for Java Control to generate, create UPC Symbol image in Java applications.
www.OnBarcode.com
Code 128B Drawer In Java
Using Barcode printer for Java Control to generate, create USS Code 128 image in Java applications.
www.OnBarcode.com
EncryptionUnitTestCase.java
Printing Denso QR Bar Code In Java
Using Barcode printer for Java Control to generate, create QR-Code image in Java applications.
www.OnBarcode.com
Uniform Symbology Specification ITF Encoder In Java
Using Barcode creator for Java Control to generate, create USS ITF 2/5 image in Java applications.
www.OnBarcode.com
package org.jboss.ejb3.examples.ch05.encryption; import org.jboss.logging.Logger; import org.junit.BeforeClass; import org.junit.Test; /** * Tests to ensure that the business methods of the EncryptionEJB * are working as expected * * @author <a href="mailto:alr@jboss.org">ALR</a> */ public class EncryptionUnitTestCase extends EncryptionTestCaseSupport { // ---------------------------------------------------------------------------|| // Class Members -------------------------------------------------------------|| // ---------------------------------------------------------------------------|| /** * Logger */ private static final Logger log = Logger.getLogger(EncryptionUnitTestCase. class); /** * POJO Encryption Service */ private static EncryptionBean encryptionService; // ---------------------------------------------------------------------------|| // Lifecycle -----------------------------------------------------------------|| // ---------------------------------------------------------------------------|| /** * Initializes the suite, invoked once before any tests are run */ @BeforeClass public static void initialize() throws Throwable { // Create the encryption service as a POJO encryptionService = new EncryptionBean(); encryptionService.initialize(); // We call init manually here } // ---------------------------------------------------------------------------|| // Tests ---------------------------------------------------------------------|| // ---------------------------------------------------------------------------|| /* * These tests will use the POJO set up in test initialization
Print QR Code In Java
Using Barcode encoder for Android Control to generate, create QR Code image in Android applications.
www.OnBarcode.com
Recognizing Quick Response Code In .NET Framework
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
*/ /** * @see {@link EncryptionTestCaseSupport#assertHashing(EncryptionCommon Business)} */ @Test public void testHashing() throws Throwable { // Log log.info("testHashing"); // Test via superclass this.assertHashing(encryptionService);
Scanning European Article Number 13 In Visual Studio .NET
Using Barcode decoder for .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Making Code 39 In VB.NET
Using Barcode drawer for .NET Control to generate, create Code 3/9 image in Visual Studio .NET applications.
www.OnBarcode.com
}
UPC-A Supplement 5 Recognizer In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Painting Barcode In None
Using Barcode maker for Office Word Control to generate, create Barcode image in Word applications.
www.OnBarcode.com
/** * @see {@link EncryptionTestCaseSupport#assertEncryption(EncryptionCommon Business)} */ @Test public void testEncryption() throws Throwable { // Log log.info("testEncryption"); // Test via superclass this.assertEncryption(encryptionService);
Barcode Generator In None
Using Barcode printer for Online Control to generate, create Barcode image in Online applications.
www.OnBarcode.com
Painting Code-128 In Visual Basic .NET
Using Barcode printer for .NET framework Control to generate, create ANSI/AIM Code 128 image in VS .NET applications.
www.OnBarcode.com
}
Code 3 Of 9 Maker In Objective-C
Using Barcode maker for iPad Control to generate, create Code-39 image in iPad applications.
www.OnBarcode.com
Barcode Creation In Java
Using Barcode creation for BIRT reports Control to generate, create Barcode image in Eclipse BIRT applications.
www.OnBarcode.com
}
Encode QR Code In Objective-C
Using Barcode drawer for iPad Control to generate, create QR Code image in iPad applications.
www.OnBarcode.com
Barcode Encoder In Visual Basic .NET
Using Barcode creation for Visual Studio .NET Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
FileTransferCommonBusiness.java
package org.jboss.ejb3.examples.ch06.filetransfer; /** * Contains the contract for operations common to all * business interfaces of the FileTransferEJB. * * Includes support for switching present working directories, * printing the current working directory, and making directories. * * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a> */ public interface FileTransferCommonBusiness { // ---------------------------------------------------------------------------|| // Contracts -----------------------------------------------------------------|| // ---------------------------------------------------------------------------|| /** * Makes a directory of the specified name * * @throws IllegalStateException If the client connection has not been initialized
482 | Appendix C: Stateful Session EJB: FTP Client Example
*/ void mkdir(String directory) throws IllegalStateException; /** * Changes into the named directory * * @param directory * @throws IllegalStateException If the client connection has not been initialized */ void cd(String directory) throws IllegalStateException; /** * Obtains the name of the current working directory * * @return * @throws IllegalStateException If the client connection has not been initialized */ String pwd() throws IllegalStateException; /** * Denotes that the client is done using this service; flushes * any pending operations and does all appropriate cleanup. If * already disconnected, this is a no-op. */ void disconnect(); /** * Opens the underlying connections to the target FTP Server, * performs any other tasks required before commands may be sent * (ie. login, etc) * * @throws IllegalStateException If already initialized/connected */ void connect() throws IllegalStateException; }
FileTransferException.java
package org.jboss.ejb3.examples.ch06.filetransfer; /** * Exception to indicate that a problem has occurred during * a file transfer operation. * * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a> */ public class FileTransferException extends RuntimeException { //--------------------------------------------------------------------------|| // Class Members -----------------------------------------------------------|| //--------------------------------------------------------------------------||
private static final long serialVersionUID = 1L; //--------------------------------------------------------------------------|| // Constructor -------------------------------------------------------------|| //--------------------------------------------------------------------------|| public FileTransferException() { super(); } public FileTransferException(final String message, final Throwable cause) { super(message, cause); } public FileTransferException(final String message) { super(message); } public FileTransferException(final Throwable cause) { super(cause); } }
FileTransferRemoteBusiness.java
package org.jboss.ejb3.examples.ch06.filetransfer; import javax.ejb.Remove; /** * Remote Business interface for the FileTransferEJB. * Because this will only be used in EJB environments, we define * a method to end the current session. * * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a> */ public interface FileTransferRemoteBusiness extends FileTransferCommonBusiness { // ---------------------------------------------------------------------------|| // Contracts -----------------------------------------------------------------|| // ---------------------------------------------------------------------------|| /** * Ends the current session; will result in a SFSB @Remove call * as the bean implementation class will annotate this with * {@link Remove} */ void endSession();
}
484 | Appendix C: Stateful Session EJB: FTP Client Example
Test Resources
FileTransferIntegrationTestCase.java
package org.jboss.ejb3.examples.ch06.filetransfer; import java.io.File; import javax.ejb.EJB; import javax.ejb.NoSuchEJBException; import junit.framework.TestCase; import import import import import import import import import import org.jboss.arquillian.api.Deployment; org.jboss.arquillian.junit.Arquillian; org.jboss.logging.Logger; org.jboss.shrinkwrap.api.ShrinkWrap; org.jboss.shrinkwrap.api.spec.JavaArchive; org.junit.After; org.junit.AfterClass; org.junit.BeforeClass; org.junit.Test; org.junit.runner.RunWith;
/** * Test cases to ensure that the FileTransferEJB is working as * a Stateful Session Bean from the EJB Container. * * Inherits some test support from {@link FileTransferTestCaseBase}, * and additionally tests EJB-specific tasks upon the * proxy. Shows that sessions operate in isolation, and that removal * of a session means you cannot use it anymore. * * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a> */ @RunWith(Arquillian.class) public class FileTransferIntegrationTestCase extends FileTransferTestCaseBase { //--------------------------------------------------------------------------|| // Class Members -----------------------------------------------------------|| //--------------------------------------------------------------------------|| /** * Logger */ private static final Logger log = Logger.getLogger(FileTransferIntegrationTest Case.class); /** * Name of the configuration file for the FTP server users */ private static final String FTP_SERVER_USERS_CONFIG_FILENAME = "ftpusers. properties";
/** * Port to which the FTP server should bind */ private static final int FTP_SERVER_BIND_PORT = 12345; /** * The FTP Server */ private static FtpServerPojo ftpServer; /** * The Deployment * @return */ @Deployment public static JavaArchive createDeployment() { final JavaArchive archive = ShrinkWrap.create("ftpclient.jar", JavaArchive. class).addPackage( FileTransferBean.class.getPackage()); log.info(archive.toString(true)); return archive; } //--------------------------------------------------------------------------|| // Instance Members --------------------------------------------------------|| //--------------------------------------------------------------------------|| /** * Our view of the EJB, remote business interface type of the Proxy */ @EJB private FileTransferRemoteBusiness client1; /** * Another FTP Client Session */ @EJB private FileTransferRemoteBusiness client2; //-------------------------------------------------------------------------|| // Lifecycle --------------------------------------------------------------|| //-------------------------------------------------------------------------|| /** * Creates and starts the FTP Server */ @BeforeClass public static void startFtpServer() throws Exception { // Create final FtpServerPojo server = new FtpServerPojo(); // Configure server.setUsersConfigFileName(FTP_SERVER_USERS_CONFIG_FILENAME);
Copyright © OnBarcode.com . All rights reserved.