&Cutting-Edge GWT: Advanced Recipes for Java Developers Google Web Toolkit (GWT) is an open source Java development framework for building Ajax-enabled web applications. Instead of the hodgepodge of technologies that developers typically use for AjaxJavaScript, HTML, CSS, and XMLHttpRequestGWT lets developers implement rich client applications with pure Java, using familiar idioms from the AWT, Swing, and SWT. GWT goes beyond most Ajax frameworks by making it easy to build desktop-like applications that run in the ubiquitous browser, where the richness of the user interface is limited only by the developers imagination. This book focuses on the more advanced aspects of GWT that you need to implement real-world applications with rich user interfaces but without the heavy lifting of JavaScript and other Ajax-related technologies. Each solution in this practical, hands-on book is more than a recipe. The sample programs are carefully explained in detail to help you quickly master advanced GWT techniques, such as implementing drag-and-drop, integrating JavaScript libraries, and using advanced event handling methodologies. Solutions covered include Building custom GWT widgets, including both high-level composites and low-level components Implementing a viewport class that includes iPhone-style automated scrolling Integrating web services with GWT applications Incorporating the Script.aculo.us JavaScript framework into GWT applications Combining Hibernate and GWT to implement database-backed web applications Extending the GWT PopupPanel class to implement a draggable and resizable window Creating a drag-and-drop module, complete with drag sources and drop targets Deploying GWT applications to an external server Dynamically resizing flex tables Using GWT widgets in legacy applications developed with other frameworks, such as Struts and JavaServer Faces Complete Sample Code Available at www.coolandusefulgwt.com All of the code used in this book has been tested, both in hosted and web modes, and in an external version of Tomcat (version 5.5.17), under Windows, Linux, and Mac OS X. For Windows and Linux, we used 1.4.60, and for the Mac we used 1.4.61. NOTE: There are three separate versions of the code. Please download the correct JAR file for the operating system you are using. Foreword xiii Preface xvi Acknowledgments xviii About the Authors xix Solution 1: GWT Fundamentals and Beyond 1 Solution 2: JavaScript Integration 53 Solution 3: Custom Widget Implementation 71 Solution 4: Viewports and Maps 103 Solution 5: Access to Online Web Services 133 Solution 6: Drag and Drop 167 Solution 7: Simple Windows 199 Solution 8: Flex Tables 237 Solution 9: File Uploads 283 Solution 10: Hibernate Integration 303 Solution 11: Deployment to an External Server 325 Solution 12: GWT and Legacy Code 343 Index 371
From the Book:PREFACE: PrefaceWhat This Book Is AboutThis book describes the Java Media Framework (JMF) API and how to use itto integrate audio and video playback into Java applications and applets.The JMF API consists of three pieces: playback, capture and video conferencing.This book covers only the first piece, specifically, the Java MediaPlayer API.This book does not stop at the API, however. It also discusses the differentimplementations of that API, how they differ, and even their failure to conformto the API. Where the API is open to interpretation, a discussion of variousinterpretations is undertaken.This discussion appears in the context of developing a framework for build-ingyour own custom Player implementation. The framework code appearingin this book provides all the API-compliance code necessary for building anAPI-compliant Java Media Player, leaving you to focus on the media-specificcoding issues.Finally, this book has sprinkled throughout examples from the EssentialJMF Toolkit, a collection of reusable Java classes for many multimedia occasions.1Who Should Read This Book?This book is written for the Java engineer or aspiring Java engineer who needsto integrate audio and video into his applications or applets. It assumes somefamiliarity with the Java language but you need not be an expert. Webmasterswith JavaScript and perl experience could easily adopt some of the examplesin this book for rudimentary multimedia applications. In other words, if youare interested in Java and multimedia, this book becomes you.1Cocktail parties, barmitzvahs,baptisms, etc.Who Should Buy This Book?Everyone.Structure of This BookThis book contains four distinct parts. We have even named the parts andinserted a decorative page between them so there is no doubt as to which iswhich.Part I, "Using the Java Media Framework," comprises the first ten chapters.Part I was written for the reader who wants to learn to use the JMF Player.After finishing Part I, you will know all there is to know about using a Playerfor playback of currently supported media types.If that is not enough to satisfy you, Part II, "Extending the Java MediaFramework," will show you how to build a complete Player to support a newmedia type. Not only will Part II show you how to do this, but when you arefinished, you will have a good deal of code available to use with still newerand more exciting media types.In addition, Part II covers the building of a custom GUI for a Player, againproviding lots of reusable code. And, if that were not enough, Part II coversthe creation of a new DataSource for support of an actual protocol, the NNTPprotocol for downloading articles from news groups. Put together the customPlayer and DataSource developed in Part II and you have a Java Media Playerfor reading articles from your favorite news group. Strange, but elegant!In Part III, "Building JMF Applets and Applications," a simple media mixerapplication is presented. Using this application you can generate HTML forinclusion in your web pages that need to playback multiple media sources.The MultiPlayer class, also presented in Part III, can then be dropped rightinto your applet to play the media described by the HTML.The books finishes up with a collection of appendices in Part IV. Hereinyou will find complete reference material for the JMF API and the EssentialJMF Toolkit. There is also a discussion of the use of the JMF with variousbrowsers, some potentially useful URL resources and a virtual glossary, toboot.Using This BookThe first three parts of this book can, more or less, stand alone. If you do nothave an immediate need to create your own Player, reading Part I and referencingthe appendices as needed will meet your needs.If you need to create your own custom Player to support a new media format,Part II is for you. If you are in a real hurry, you may be able to get by withjust reading Chapter 18, "Creating a Custom Player." You can at least startthere and refer back to earlier chapters in Part II as necessary. In any case,understanding Part II really depends upon having the knowledge and wisdomcontained in Part I. If you did not get such knowledge from somewhere else,you may as well get it from there.If you need an easy way to play multiple media files from an applet, godirectly to Part III.Part IV is the work horse section of the book: It is there when you need it,ready and willing.We recommend you do not read this book backwards. We cannot guaranteethat there are no hidden, satanic messages.Gathering the PiecesTo derive the fullest benefit and pleasure from reading this book, you willneed to have the following pieces of software installed on your computingdevice. A version of the JDKThe Swing component set from the Java Foundation ClassesAn implementation of the JMFThe Essential JMF example source and ToolkitA section is dedicated to the acquisition and installation of each of thesepieces. In addition to this software, there is the presumption that some fundamentalsoftware already exists on your computer, specifically, the necessaryaudio and video device drivers. For Solaris and Windows machines that havenot been butchered by an overzealous system administrator, this a safeassumption.Downloading JDKTo use Sun's implementation of the JMF, you will first need to have installedsome flavor of JDK 1.1.x. The latest version is available at ...
(NOTE: Each chapter beings with an Introduction and concludes with a Summary.) Preface. What This Book is About. Who Should Read This Book? Structure of This Book. Whose Java? Downloading Example Source. Building the Examples. Setting Up the Environment. How To Build. A Word About the Examples. Some Conventions. Help From Fellow Travelers. A Word About Borrowed Words. Acknowledgments. 1. Why JNI? Virtual Machine, Real Machine. JNI and Binary Compatibility. Memory Loss. The JNI Solution. Features of the JNI. 2. Hello JNI World. The Big Picture. The Steps. Identify Native Functionality. Describing the Interface to the Native Code. Writing the Java Code. Using javac to Generate Class Files. Using javah to Generate Include Files. Writing Native Code. Building a Library. Loading and Invoking the native Method. Building and Running Your Java Application. The Steps in Pictures. 3. Setting Java Variables, Invoking Java Methods. What Is All This Talk About C and C++? Some of the Basics. Setting Java Object Data Fields. Native Access to an Objects Own Data Fields. Making It Happen. Native Access to Another Object's Data Fields. Making It Happen. Getting a Java Object's Data Fields. Invoking a Java Method. Native Access to an Objects Own Methods. Native Access to Private Methods of Another Object. Making It Happen. A Disclaimer of Sorts. Returning a Value From Java Methods. Non-Virtual Method Invocation. Use of JNI Non-Virtual Functions. Yet More Ways to Call a Java Method. 4. Native Types, Signatures and Other Details. Java Types. Java Native Types. Primitive Native Types. Reference Native Types. Programming Considerations. The jvalue Type. Field and Method Identifier Types. Method Signatures. Signature and Constructors. Type Signatures and Data Fields. The JNIEnv Pointer. A Word About Passing Arguments. 5. Objects and Classes. JNI References. Code Natively, Reference Locally. Coding Globally. Releasing a Local Reference. A Few More Facts About Native References. JNI Object Functions. Determining an Object's Class. Creating a New Object Instance. Using NewObject. Using NewObjectA. Using NewObjectV. Example Object Creation. Allocating Memory for an Object. Comparing Two References. A Native instanceof. Testing Class Inheritance Relationship. JNI Class Functions. From Class Name to Class. From Class to Superclass. From Bytes to Class. A Simple Class Loader. A Loader Using DefineClass. 6. Arrays and Strings. JNI Array Functions. Object Arrays. Array of Arrays. Some Output. Primitive Type Arrays. Creating a Primitive Array. Getting Primitive Array Elements. Accessing the Entire Array Contents of a Primitive Array. An Example: Accessing an Entire Array. Accessing a of a Primitive Array. JNI String Functions. UTF-8 String Handling. Creating a New String Object. Unicode String Functions. 7. Exceptions. Throwing Exceptions. Throwing an Exception. Building and Throwing an Exception. When Does an Exception Get Raised? Catching Exceptions. A Native Try-Catch. Passing Exceptions to Java. A JNI Stack Trace. General Exception Handling Guidelines. 8. Monitors. JNI Synchronization Support. The Producer-Consumer Problem. A Java Implementation. A JNI Producer-Consumer Implementation. The C++ Product Info Class. The init Method. C++/Java Object Correspondence. Native Implementation of Produce Method. Native Implementation of Consume Method. A Native Wait and Notify. Native Producer-Consumer Output. A Reminder. A Global Reference as Lock. 9. Java and C++. C++ Legacy Code. The General Strategy. Mirroring Example. The C++ Side. The Java Side. Type Mappings. Object Construction. Finalization. Cloning. Serialization. The Native Methods. The Registry Interface. Object Construction and the Registry. Instance Data Access and the Registry. Object Finalization and the Registry. Object Cloning and the Registry. Serialization and the Registry. The Registry Implementation. MFC Implementation of ObjMap. Tools.h++ Implementation of ObjMap. Static Variables and Methods. C++ Class Methods. Public Data Field Access. Java Mirroring at Work 176 An Alternative to the Registry. Some Other Issues. Multiple Inheritance. C++ Templates. 10. Conversion of C Structures. The Java Source. The C Adapter Code. POSIX User Database Access. Using structConverter. Running the C Preprocessor. The structConverter Configuration File. Running structConverter. The Java Source File. StructConverter Data Type Conversion. InitFIDs and the static Block. The Adapter Source File. Field ID Initialization. Adapter Code. Tying It All Together. Another Database Example. Updating a Booking Record. Generating Just Java. Some Design Considerations. A Bit More About structConverter. 11. Native Serial I/O. The portio Package. Using portio. Portio Template Class Files. Augmenting portio. Portio and POSIX tty. The PosixPortDriver Class. The PosixPortReader Class. The PosixPortPrivate Class. The POSIX Native Code. Opening and Closing a Port Using POSIX System Calls. Reading and Writing a Port Using POSIX System Calls. Using POSIX System Calls flush, sendBreak and purge. Setting POSIX Device Parameters. Portio and Win32 COM. 12. Running the JVM From a C/C++ Application. JVM Initialization. Stack and Heap Values. Garbage Collection Settings. Load Verification Mode. The classpath Field. The properties Field (JDK 1.1.2 and Greater). Application Hooks for the JVM. Invocation API Overview. invokeMain: Creating a JVM. A Java-enabled Application in Action. Building a Java-Enabled Application. The Invocation API and Reflection. JNI and Reflection. Running miniInvoker. A Small Disclaimer. Registering Native Methods. The JNINativeMethod Structure. Using RegisterNatives. Building for Native Method Registration. Avoiding Static Libraries. 13. An NT Service Application. The Service Control Manager. Registering a Service With the SCM. The Service Process. The Executing Service. Reporting Service Status. The service_controller Routine. The Java Agent Server. Starting the Java Agent Server. Stopping the Java Agent Server. Support for Java Agent Creation. The JVM as Service: Some Considerations. The JVM's Current Working Directory. Displaying a Frame. Some Common Errors. A Java Agent Service. Overview of a Java Logging Agent. Source for a Java Logging Agent. Making It Happen. 14. Debugging Native Methods. What Is It You Are Debugging? JNI Debugging Tips. Microsoft Visual Studio. The JVM: Starting a Debug Session. Debugging on Solaris. Using dbx. Debugging With Sun Workshop. When All Else Fails. 15. JDK 1.2 Enhancements to JNI. Summary of Enhancements. Summary of Additional Functionality. JDK 1.2 JNI Enhancements. JVM Initialization. Improvements to Invocation API Functions. FindClass Enhancements. New JDK 1.2 JNI Functions. Weak References. Critical Region String and Array Manipulation. Local Reference Management. Core Reflection Support. String Character Extraction. New Invocation API Functionality. Loading and Unloading Notification. Native Library Management Via Class Loaders. Appendix A. JNI Reference. Notation. The Invocation API. Appendix B. 1.0 Native Methods vs. JNI. javah Usage. Using javah to Generate 1.0-Style Native Code. Using javah to Generate JNI Function Prototypes. Include File Requirements. The Pieces, Side-by-Side. Building Native Libraries. A printString Example. The Execution Environment. Function Specification and Naming. Data Types. Argument Handling. Signatures. Accessing Java Data Fields. Accessing Instance Data. Accessing Class Data. Invoking Methods. Invoking a Java Instance Method. Invoking a Java Class Method. Creating an Object. Exceptions. String Manipulation. Arrays. Garbage Collection Issues. Appendix C. structConverter Reference. Command Syntax. Options. Appendix D. javah Reference. Command Syntax. Options. Description. Environment Variables. Appendix E. Native Methods, Applets, Security. General JDK Security. Netscape Communicator Security. Netscape Capabilities API and Object Signing. Avoiding Signatures. Using Native Code With Applets. How Did the Native Library Get There?
Mining and exploration companies wishing to capitalize on the current up-turn in the gold price and other commodity sectors must overcome the difficult task of making new discoveries. Advanced technology can provide a significant edge, for both scientific discovery and increased confidence in deeper drilling, thereby significantly reducing the risk exposure in these exploration environments. Making a discovery is difficult and is arguably more difficult as undiscovered deposits today are more likely found at greater depths. The financial risk with deep drilling is hindering deep exploration. However, deeper drilling will be required to achieve more discoveries. Advanced exploration technology and processes are available today that can assist the mining and exploration community with their efforts to yield discovery in a timelier manner. However, the mining industry has been traditionally slow to embrace new technologies particularly if they are not easily understood or when the cost paradigm is out of sync with traditional spending habits regarding drilling versus other technologies. Recent advances in digital signal processing, and faster computers, coupled with the ability to collect very high resolution and deep geophysical data provides new opportunity to further geoscientific investigation at greater depths prior to drilling. Drill targeting can be then more focused thereby providing better returns per metre drilled. In essence, high potential ground may not be under-explored. Economists have often said a critical failure in exploration is the inefficiencies of exploration while exploring highly prospective regions. Today, images to depths of over 1500 metres for key targeting parameters can assist with required deeper exploration within favourable land packages. Moreover, technology can now provide a means to revitalize exploration in mature mining camps. This paper discusses a new approach of "bottom-up" vs "top-down" exploration and demonstrates application of these deep looking technologies and how they can be scientifically applied to address economic concerns that face the industry such as drilling risk and discovery rates.