1. Trang chủ
  2. » Ngoại Ngữ

sams java distributed objects

693 294 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 693
Dung lượng 4,36 MB

Nội dung

Release Team[oR] 2001 [x] java Java Distributed Objects by Bill McCarty and Luke Cassady-Dorion ISBN: 0672315378 Sams © 1999, 936 pages Pros ready to design distributed architectures get wellexplained, expert help, with an emphasis on CORBA Table of Contents Back Cover Synopsis by Rebecca Rohan Interchangeable, interoperable software components are making it less timeconsuming to create sophisticated software that resides on more than one side of a network - an advantage that Java developers can press further in keeping CPU cycles at the most efficient spots on the network Distributing objects raises the complexity of projects by calling for arbitration among the software components and participating nodes, but Java Distributed Objects can help professionals achieve the flexible, transparent distribution necessary to create powerful, efficient architectures Java Distributed Objects emphasizes CORBA, which is defined jointly by over 800 companies and deemphasizes Microsoft's proprietary DCOM, though servlets, CGI, and DCOM get some attention An airline reservation system affords an example throughout the book Table of Contents JAVA Distributed Objects - Introduction - Part I Basic Concepts Chapter - Distributed Object Computing - 14 Chapter - TCP/IP Networking - 20 Chapter - Object-Oriented Analysis and Design - 41 Chapter - Distributed Architectures - 55 Chapter - Design Patterns - 73 Chapter - The Airline Reservation System Model - 90 Part II Java Chapter - JAVA Overview - 106 Chapter - JAVA Threads - 131 Chapter - JAVA Serialization and Beans - 149 Part III Java’s Networking and Enterprise APIs Chapter 10 - Security - 170 Chapter 11 - Relational Databases and Structured Query Language (SQL) - 190 Chapter 12 - JAVA Database Connectivity (JDBC) - 208 Chapter 13 - Sockets - 227 -2- Chapter 14 - Socket-Based Implementation of the Airline Reservation System - 248 Chapter 15 - Remote Method Invocation (RMI) - 262 Chapter 16 - RMI-Based Implementation of the Airline Reservation System - 279 Chapter 17 - JAVA Help, JAVA Mail, and Other JAVA APIs - 294 Part IV Non-CORBA Approaches to Distributed Computing Chapter 18 - Servlets and Common Gateway Interface (CGI) - 308 Chapter 19 - Servlet-Based Implementation of the Airline Reservation System - 327 Chapter 20 - Distributed Component Model (DCOM) - 334 Part V Non-CORBA Approaches to Distributed Computing Chapter 21 - CORBA Overview - 384 Chapter 22 - CORBA Architecture - 393 Chapter 23 - Survey of CORBA ORBs - 419 Chapter 24 - A CORBA Server - 429 Chapter 25 - A CORBA Client - 445 Chapter 26 - CORBA-Based Implementation of the Airline Reservation System - 474 Chapter 27 - Quick CORBA: CORBA Without IDL - 489 Part VI Advanced CORBA Chapter 28 - The Portable Object Adapter (POA) - 515 Chapter 29 - Internet Inter-ORB Protocol (IIOP) - 523 Chapter 30 - The Naming Service - 532 Chapter 31 - The Event Service - 550 Chapter 32 - Interface Repository, Dynamic Invocation, Introspection, and Reflection - 573 Chapter 33 - Other CORBA Facilities and Services - 592 Part VII Agent Technologies Chapter 34 - Voyager Agent Technology - 608 Chapter 35 Part VIII - Voyager-Based Implementation of the Airline Reservation System - 620 Summary and References Chapter 36 - Summary - 639 Appendix A - Useful Resources - 652 Appendix B - Quick References - 656 Appendix C - How to Get the Most From the CD-ROM - 689 Back Cover Learn the concepts and build the applications: • • • Learn to apply the Unified Modeling Language to describe distributed object architecture Understand how to describe and use Design Patterns with real-world examples Advanced Java 1.2 examples including Threads, Serialization and Beans, Security, JDBC, Sockets, and Remote Method Invocation (RMI) -3- • • • • In-depth coverage of CORBA Covers the Portable Object Adapter (POA) and Interface Definition Language (IDL) Understand and apply component-based development using DCOM Learn about agent technologies and tools such as Voyager About the Authors Bill McCarty, Ph.D., is a professor of MIS and computer science at Azusa Pacific University He has spent more than 20 years developing distributed computing applications and seven years teaching advanced programming to graduate students Dr McCarty is also coauthor of the well-received ObjectOriented Design in Java Luke Cassady-Dorion is a professional programmer with eight years of experience developing commercial distributed computing applications He specializes in Java/CORBA programming JAVA Distributed Objects Bill McCarty and Luke Cassady-Dorion Copyright © 1999 by Sams All rights reserved No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher No patent liability is assumed with respect to the use of the information contained herein Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions Neither is any liability assumed for damages resulting from the use of the information contained herein International Standard Book Number: 0-672-31537-8 Library of Congress Catalog Card Number: 98-86975 Printed in the United States of America First Printing: December 1998 00 99 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized Sams cannot attest to the accuracy of this information Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark The following are trademarks of the Object Management Group ®: CORBA ®, OMG ™, ORB™, Object Request Broker ™, IIOP™, OMG Interface Definition Language (IDL)™, and UML™ WARNING AND DISCLAIMER Every effort has been made to make this book as complete and as accurate as possible, -4- but no warranty or fitness is implied The information provided is on an “as is” basis The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the CD or programs accompanying it EXECUTIVE EDITOR Tim Ryan DEVELOPMENT EDITOR Gus Miklos MANAGING EDITOR Patrick Kanouse PROJECT EDITOR Carol L Bowers COPY EDITORS Tonya Maddox Bart Reed INDEXER Rebecca Salerno PROOFREADER Kim Cofer TECHNICAL EDITOR Mike Forsyth SOFTWARE DEVELOPMENT SPECIALIST Craig Atkins INTERIOR DESIGN Anne Jones COVER DESIGN Anne Jones LAYOUT TECHNICIAN Marcia Deboy -5- FOREWORD Every time I give a presentation somewhere in the world, I ask a simple question of the audience: “Raise your hand if your company is developing a distributed application.” Depending on the type of audience, I might get from 10 percent to 90 percent of the audience to admit that they are taking on this difficult development task The rest are wrong You see, every organization that features more than a single employee or a single computer—or needs to share information with another organization—is developing a distributed application If they’re not quite aware of that fact, then they are probably not designing their applications properly They might end up with a “sneakernet,” or they might find themselves with full-time personnel doing nothing but data file reformatting, or they might end up maintaining more server applications or application servers than necessary Every organization builds distributed applications; that is, applications which mirror, reinforce, or enhance the workflow of the company and its relationships with buyers and suppliers Because the purpose of an organization is to maximize the output of its employees by integrating their experience and abilities, the purpose of an Information Technology (IT) infrastructure is to maximize the output of its computing systems by integrating their data and functionality The complexity of distributed application development and integration—indeed, of any systems integration project—makes such projects difficult The rapid pace of change in the computer industry makes it nigh impossible This tome helps alleviate this problem by gathering together, in one place, descriptions and examples of most of the relevant commercial solutions to distributed application integration problems By recognizing the inherent and permanent heterogeneity of systems found in real IT shops today, this book provides a strong basis for making the tough choices between approaches based on the needs of the reader An easy style with abundant examples makes it a pleasure to read, so I invite the reader to dive in without any more delay! Richard Mark Soley, Ph.D Chairman and CEO Object Management Group, Inc September 1998 ABOUT THE AUTHORS Bill McCarty, Ph.D., is a professor of MIS and computer science at Azusa Pacific University He has spent more than 20 years developing distributed computing applications, and seven years teaching advanced programming to graduate students Dr McCarty is also coauthor of the well-received Object-Oriented Programming in Java Luke Cassady-Dorion is a professional programmer with eight years of experience developing commercial distributed computing applications He specializes in Java/CORBA programming Rick Hightower is a member of Intel’s Enterprise Architecture Lab He has a decade of experience writing software, from embedded systems to factory automation solutions Rick’s current work involves emerging solutions using middleware and component technologies, including Java and JavaBeans, COM, and CORBA Rick wrote Chapter 20 of this book -6- About the Technical Editor Mike Forsyth, Technical Director, Calligrafix, graduated with a computer science degree from Heriot Watt University, Edinburgh, Scotland, and developed high speed free text retrieval systems He is currently developing Java servlet and persistent store solutions using ObjectStore and Orbix in pan European Extranet projects ACKNOWLEDGMENTS Luke Andrew Cassady-Dorion: As I sit looking over the hundreds of pages that form the tome you are now holding, I am finally able to catch my breath and think about everything that has gone into this book Starting at ground zero, none of this could have come together without the work done by Bill McCarty, my co-author Bill, you have put together an excellent collection of work; thank you In addition, Tim Ryan, Gus Miklos, Jeff Taylor and the countless faces that I never see have worked day and night to help this project To all of you, this could never have happened without your help; bravo My family, who has always supported everything that I did (even when I dropped out of college and moved to California), your support means mountains to me All of my friends, who understood when I said that I could not go out as I had to “work on my book,” thank you, and the next round is on me Finally, to all of the musicians, composers and authors who kept me company as I wrote this book Maria Callas, Phillip Glass, Stephen Sondheim, Cole Porter, and Ayn Rand, your work has kept me sane during this long process Finally, a word of advice to my readers: Enjoy this book, but know that the best computer programmers come up for air Make sure that there is always time in your life for fun, fiction, family, friends and—of course—really good food Bill McCarty: As with any book, a small army has had a hand in bringing about this book Some of them I don’t even know by name, but I owe each of them my thanks I’m especially grateful for the work of my co-author, Luke, who wrote the CORBA material that forms the core of the book I’m also grateful for the wise counsel and able assistance of my literary agent, Margot Maley of Waterside Productions, without whom this book wouldn’t have been completed I thank Tim Ryan of Macmillan Computer Publishing who graciously offered help when I needed it and who generously spent many hours helping us write a better book Gus Miklos, our development editor, not only set straight many crooked constructions, but taught me much in the process I envy his future students My family patiently endured untold hardships during the writing of this book; I greatly appreciate their understanding, support, and love My eternal thanks go to the Lord Jesus Christ, who paid the full price of my redemption from sin and called me to be His disciple and friend To Him be all glory, and power, and honor now and forever TELL US WHAT YOU THINK! As the reader of this book, you are our most important critic and commentator We value your opinion and want to know what we’re doing right, what we could better, what areas you’d like to see us publish in, and any other words of wisdom you’re willing to pass our way As the Executive Editor for the Java team at Macmillan Computer Publishing, I welcome your comments You can fax, email, or write me directly to let me know what you did or didn’t like about this book—as well as what we can to make our books stronger Please note that I won’t have time to help you with Java programming problems When you write, please be sure to include this book’s title and author as well as your name and phone or fax number I will carefully review your comments and share them with the author and editors who worked on the book Fax: 317-817-7070 -7- Email: java@mcp.com Mail: Tim Ryan, Executive Editor Java Team Macmillan Computer Publishing 201 West 103rd Street Indianapolis, IN 46290 USA Introduction STRUCTURE OF THIS BOOK Now that you are familiar with the aims of this book, let’s explore its structure This will help you map out your study of the book As you’ll discover, you may not need to read every chapter Part I: Basic Concepts Distributed object technologies not stand on their own Instead, they depend on a set of related technologies that provide important services and facilities You can’t thoroughly understand distributed object technologies without a solid understanding of networks, sockets, and databases, for example The purpose of Part I is to acquaint you with these related technologies and prepare you for the more advanced material in subsequent parts of this book Chapter 1, “Distributed Object Computing” Chapter sets the stage for the main topic of this book by introducing fundamental concepts and terms related to distributed objects It also explains the structure of this book and provides some friendly advice intended to enhance your understanding and application of the material Specifically, Chapter covers what distributed object systems are; why objects should be distributed; which technologies facilitate the implementation of distributed object systems; which related technologies distributed objects draw upon; and who should read this book and how it should be used Chapter 2, “TCP/IP Networking” Chapter introduces the basic terms and concepts of TCP/IP networking, the technology of the Internet and Web You’ll learn how various protocols and Internet services work and how to perform simple TCP/IP troubleshooting Chapter 3, “Object-Oriented Analysis and Design” Chapter presents an overview of object-oriented analysis and design (OOA and OOD), including the Unified Modeling Language (UML), which is used in subsequent chapters to describe the structure of distributed object systems Chapter 4, “Distributed Architectures” Chapter presents an evolutionary perspective on distributed computing architectures You’ll learn the strengths and weaknesses of a variety of system architectures Chapter 5, “Design Patterns” Chapter provides an overview of the important and useful topic of design patterns, the themes that commonly appear in software designs You’ll learn how to describe and use -8- patterns and learn about several especially useful patterns Chapter 6, “The Airline Reservation System Model” Chapter presents an example application that we refer to throughout subsequent chapters, in which we implement portions of the example application using a variety of technologies The Airline Reservation System helps you see how technologies can be applied to real-world systems rather than the smaller pedagogical examples included in the explanatory chapters Part II: Java Part II presents the Java language and APIs important to distributed object systems Chapter 7, “Java Overview” Despite the impression conveyed by media hype, Java is not the only object-oriented language, nor is it the only language that you can use to build distributed object systems Programmers have successfully built distributed systems using other languages, notably Smalltalk and C++ However, this book is unabashedly Java-centric Here are some reasons for this choice: • Java is an easy language to read and learn Much of Java’s syntax and semantics are based on C++, so C++ programmers can readily get the gist of a section of Java code Moreover, Java omits some of the most gnarly features of C++, making Java programs generally simpler and clearer than their C++ counterparts • Java provides features that are important to the development of distributed object systems, such as thread programming, socket programming, object serialization, reusable components (Java Beans), a security API, and a SQL database API (JDBC) Although all these are available for C++, they are not a standard part of the language or its libraries We’ll briefly survey each of these features • Java bytecodes are portable, giving Java a real advantage over C++ in a heterogeneous network environment Java’s detractors decry the overhead implicit in the interpretation of bytecodes But Java compiler technology has improved significantly over the last several years Many expect that Java’s execution speed will soon rival, and in some cases surpass, that of C++ • Java is inexpensive You don’t need to purchase an expensive IDE to learn or use Java: You can run and modify the programs in this book using the freely available JDK Of course, if you decide to spend a great deal of time writing Java programs and getting paid for doing so, an IDE is a wise investment • The last reason is the best one: Java is fun One of the authors has been programming for almost three decades But not since those first weeks writing Fortran code for the IBM 1130 has programming been as much fun as the last several years spent writing Java code Having taught Java programming to dozens of students who’ve had the same experience, we can confidently predict that you too will enjoy Java For readers not familiar with Java, Chapter presents enough of the Java language and APIs to enable most readers—especially those already fluent in C++—to understand, modify, and run the example programs in this book If you find you’d prefer a more thorough explanation of Java, please consider Object-Oriented Programming in Java, by Gilbert and McCarty (Waite Group Press, 1997), which is designed to teach programming and software development as well as the Java language and APIs Chapter 8, “Java Threads” -9- Chapter presents threads, an important topic for distributed object systems The chapter deals not only with the syntax and semantics of Java’s thread facilities, but also with several pitfalls of thread programming, including race conditions and deadlocks Chapter 9, “Java Serialization and Beans” Chapter presents two additional Java APIs: serialization and Beans Serialization is important to creating persistent and portable objects, while beans are important to creating reusable software components Part III: Java’s Networking and Enterprise APIs Part III presents Java’s networking and enterprise APIs Distributed object systems use these APIs either directly or through the mediation of a distributed object technology Chapter 10, “Security” Chapter 10 presents Java’s security API, including ciphers and public key encryption systems Chapter 11, “Relational Databases and Structured Query Language (SQL)” Chapter 11 presents the basics of relational database technology, including an overview of Structured Query Language (SQL) Chapter 12, “Java Database Connectivity (JDBC)” Chapter 12 presents the JDBC API, which facilitates access to SQL databases Chapter 13, “Sockets” Chapter 13 explains socket programming and shows how to create clients and servers that exchange data using sockets Chapter 14, “Socket-Based Implementation of the Airline Reservation System” Chapter 14 describes a socket-based implementation of a portion of the Airline Reservation System example presented in Chapter Chapter 14 helps you place the explanations of Chapter 13 in a real-world context Chapter 15, “Remote Method Invocation (RMI)” Chapter 15 presents RMI and shows how to create and access remote objects Chapter 16, “RMI-Based Implementation of the Airline Reservation System” Chapter 16 describes an RMI-based implementation of a portion of the Airline Reservation System example presented in Chapter Chapter 16 helps you place the explanations of Chapter 15 in a real-world context Chapter 17, “Java Help, Java Mail, and Other Java APIs” - 10 - public abstract short getShort(String columnName) throws SQLException public abstract String getString(String columnName) throws SQLException public abstract String getString(int columnIndex) throws SQLException public abstract Time getTime(int columnIndex) throws SQLException public abstract Time getTime(String columnName) throws SQLException public abstract Timestamp getTimestamp( int columnIndex) throws SQLException public abstract Timestamp getTimestamp( String columnName) throws SQLException public abstract InputStream getUnicodeStream( int columnIndex) throws SQLException public abstract InputStream getUnicodeStream( String columnName) throws SQLException public abstract SQLWarning getWarnings() throws SQLException public abstract boolean next() throws SQLException public abstract boolean wasNull() throws SQLException JAVA.SQL.RESULTSETMETADATA The ResultSetMetaData interface establishes a framework for accessing information describing a result set The getColumnCount method returns the number of columns in the result set The getColumnLabel method returns the default label of the specified column The getColumnName method returns the name of the specified column The getColumnType returns a code (see java.sql.Types ) for the data type of the specified column For numeric columns, the getPrecision method returns the number of significant digits, and the getScale method returns the decimal point offset public interface ResultSetMetaData // Public Class Fields public static final int columnNoNulls public static final int columnNullable public static final int columnNullableUnknown // Public Methods public abstract String getCatalogName(int column) throws SQLException public abstract int getColumnCount() throws SQLException public abstract int getColumnDisplaySize(int column) throws SQLException public abstract String getColumnLabel(int column) throws SQLException public abstract String getColumnName(int column) throws SQLException public abstract int getColumnType(int column) throws SQLException - 679 - public abstract String getColumnTypeName(int column) throws SQLException public abstract String getSchemaName(int column) throws SQLException public abstract int getPrecision(int column) throws SQLException public abstract int getScale(int column) throws SQLException public abstract String getTableName(int column) throws SQLException public abstract boolean isAutoIncrement(int column) throws SQLException public abstract boolean isCaseSensitive(int column) throws SQLException public abstract boolean isCurrency(int column) throws SQLException public abstract boolean isDefinitelyWritable( int column) throws SQLException public abstract int isNullable(int column) throws SQLException public abstract boolean isReadOnly(int column) throws SQLException public abstract boolean isSearchable(int column) throws SQLException public abstract boolean isSigned(int column) throws SQLException public abstract boolean isWritable(int column) throws SQLException JAVA.SQL.STATEMENT The Statement interface establishes a framework for executing SQL queries and updates and for accessing their results The cancel method cancels a query being executed in another thread The clearWarnings method deletes warnings posted against the Statement The executeQuery method executes a query and returns a result set The executeUpdate method executes an update and returns a count of the updated rows The execute method executes a query that returns multiple results The methods getMoreResults , getResultSet, and getUpdateCount let you access the results The close method closes the Statement and any associated result sets The getWarnings method retrieves the first warning pending against the Statement The setQueryTimeout lets you specify how long the driver should wait for query completion public interface Statement public abstract void cancel() throws SQLException public abstract void clearWarnings() throws SQLException public abstract void close() throws SQLException public abstract boolean execute(String sql) throws SQLException public abstract ResultSet executeQuery(String sql) throws SQLException public abstract int executeUpdate(String sql) - 680 - throws SQLException public abstract int getMaxFieldSize() throws SQLException public abstract int getMaxRows() throws SQLException public abstract boolean getMoreResults() throws SQLException public abstract int getQueryTimeout() throws SQLException public abstract ResultSet getResultSet() throws SQLException public abstract int getUpdateCount() throws SQLException public abstract SQLWarning getWarnings() throws SQLException public abstract void setCursorName(String name ) throws SQLException public abstract void setEscapeProcessing( boolean enable) throws SQLException public abstract void setMaxFieldSize(int max) throws SQLException public abstract void setMaxRows(int max) throws SQLException public abstract void setQueryTimeout(int seconds) throws SQLException JAVA.SQL.TIME The Time class extends java.util.Date , letting JDBC identify a SQL time object and providing formatting and parsing operations that support the JDBC escape syntax for time values public class Time extends Date // Public Constructors public Time(int hour , int minute, int second) public Time(long time ) // Public Class Methods public static Time valueOf(String s) // Public Methods public int getDate() public int getDay() public int getMonth() public int getYear() public void setDate(int i) public void setMonth(int i) public void setTime(long time ) public void setYear(int i) public String toString() JAVA.SQL.TIMESTAMP The Timestamp class extends java.util.Date , letting JDBC identify a SQL timestamp object and providing formatting and parsing operations that support the JDBC - 681 - escape syntax for timestamp values The java.util.Date class stores time with a one-second resolution The Timestamp class includes an int that stores time with nanosecond resolution The getNanos method returns the value of the fractional second The after and before methods test whether a specified Timestamp instance is later or earlier than the current instance public class Timestamp extends Date // Public Constructors public Timestamp(int year, int month, int date, int hour, int minute, int second, int nano) public Timestamp(long time) // Public Class Methods public static Timestamp valueOf(String s) // Public Methods public boolean after(Timestamp ts) public boolean before(Timestamp ts) public boolean equals(Timestamp ts) public int getNanos() public void setNanos(int n) public String toString() JAVA.SQL.TYPES The Types class defines codes used to represent the SQL data types These codes are used by several JDBC methods, including ResultSetMetaData.getColumnType public public public public public public public public public public public public public public public public public public public public public public class Types extends Object static final int BIGINT static final int BINARY static final int BIT static final int CHAR static final int DATE static final int DECIMAL static final int DOUBLE static final int FLOAT static final int INTEGER static final int LONGVARBINARY static final int LONGVARCHAR static final int NULL static final int NUMERIC static final int OTHER static final int REAL static final int SMALLINT static final int TIME static final int TIMESTAMP static final int TINYINT static final int VARBINARY static final int VARCHAR ORG.COM.CORBA.BINDOPTIONS The BindOptions class represents the options used when a client binds to a server You pass these options to the bind method provided by the server’s Helper class If - 682 - the defer argument is true , connection is delayed until the first request is invoked on the server If the rebind argument is true , the client will attempt to recover from a lost connection by binding to another server public class BindOptions // Public Constructor public BindOptions(boolean defer, boolean rebind) ORG.COM.CORBA.BOA The BOA class represents a Basic Object Adapter, which lets servers activate and deactivate the objects they offer to clients The obj_is_ready method makes an object available to clients The deactivate_obj method makes an object unavailable A server should invoke impl_is_ready after it has activated all the objects it implements The get_Principal method returns the principal associated with an object public abstract class BOA extends Object // Public Methods public void deactivate_obj(Object obj) public Principal get_Principal(Object obj) public void impl_is_ready() public abstract void impl_is_ready(String service, Activator activator) public abstract void impl_is_ready(String service, Activator activator, boolean block) public void obj_is_ready(Object obj) public abstract void obj_is_ready(Object obj, String service, byte [] data ) ORG.COM.CORBA.COMPLETIONSTATUS The CompletionStatus class indicates whether an operation was completed before an exception was raised public final class CompletionStatus extends Object // Public Fields public final static int _COMPLETED_YES public final static int _COMPLETED_NO public final static int _COMPLETED_MAYBE public final static CompletionStatus COMPLETED_YES public final static CompletionStatus COMPLETED_NO public final static CompletionStatus COMPLETED_MAYBE // Public Class Method public static CompletionStatus from_int(int value) // Public Method public final int value() ORG.COM.CORBA.CONTEXT The Context interface establishes a framework for maintaining a client’s property list that’s propagated to the server when the client issues a request The use of the properties is not specified by CORBA The properties are organized as a tree; the default context can be accessed by invoking the ORB.get_default_context method - 683 - public interface Context // Public Methods public String context_name() public Context create_child(String context) public void delete_values(String property) public NVList get_values(String start, boolean restrict, String name ) public Context parent() public void set_one_value(String property, Any value) public void set_values(NVList values) ORG.COM.CORBA.INVALIDNAME The InvalidName exception is raised when the ORB is unable to resolve any of the names returned by list_initial_services to its corresponding implementation object public class InvalidName extends UserException ORG.COM.CORBA.OBJECT The Object interface is the root interface of the CORBA inheritance hierarchy It provides runtime type information and platform-independent reference equivalence testing Table B.1 summarizes the key methods of the Object interface TABLE B.1 KEY METHODS OF THE Object INTERFACE Method Function bind_options Sets the bind options associated with the current object boa Returns the BOA associated with a particular request or the default BOA if no request is active clone Creates a copy of the current object, which receives its own server connection create_request Creates and initializes a dynamic invocation request get_interface Returns the interface definition of the current object hash Computes a positive hash value for the current object is_a Queries whether an object implements the specified interface is_bound Returns true if a network connection to the implementation object has been established is_equivalent Compares the Interoperable Object Reference of the specified - 684 - object with that of the current object and returns true if they are equivalent is_local Returns true if the current object resides in the local address space is_persistent Returns true if the current object retains its value beyond the lifetime of its implementing process is_remote Returns true if the current object resides in a remote address space non_existent Uses ping to determine whether the implementation object is active and returns false if the object is found to be active object_name Returns the name of the object implementation principal Returns the principal associated with a request on the object or sets the principal associated with the current object to the specified principal repository_id Returns the repository identifier of the current object implementation’s most derived interface resolve_reference Creates an empty dynamic invocation request A client application can use the resolve_reference method to resolve the serverside interface with the specified service identifier The following method headers specify the arguments of the methods of the Object interface: public interface Object // Public Methods public BindOptions _bind_options() public BOA _boa() public Object _clone() public Request _create_request(Context context, String op, NVList args , NamedValue result, TypeCode[] exceptions, String [] contexts) public InterfaceDef _get_interface() public int _hash(int max) public _is_a(String repository) public boolean _is_bound() public boolean _is_equivalent(Object obj) public boolean _is_local() public boolean _is_persistent() public boolean _is_remote() public boolean _non_existent() public String _object_name() public Principal _principal() public void _principal(Principal principal) public String _repository_id() public Request _request(String op) - 685 - public Object _resolve_reference(String id) ORG.COM.CORBA.ORB The ORB class represents an Object Request Broker and provides a way to initialize the CORBA infrastructure, as well as a variety of methods used by clients and servers Table B.2 summarizes the key methods of the ORB class The ORB class also provides a set of methods for handling NamedValue, NVList, DynAny, DynArray, DynEnum, DynSeqeuence, DynStruct, and DynUnion objects and a set of methods that return TypeCode objects of various types Consult the Visibroker documentation for information about these methods TABLE B.2 KEY METHODS OF THE ORB INTERFACE Method Function init Initializes the ORB for use by an application or applet bind Attempts a bind on the ORB and returns a general reference BOA_init Initializes a BOA and returns a reference to the BOA create_output_cstream Creates an output stream create_input_ stream Creates an input stream from an output stream The input stream lets programs read the bytes written to the output stream default_bind_ options Gets or sets the global default bind options defaultPrincipal Gets or sets the global default Principal get_default_ context Returns the global default Context list_initial_ services Returns a list containing the names of object services initially available object_to _string Converts an object reference to a String and returns the result string_to_ object Converts a String to an object reference, narrowed to a specified interface, and returns the result get_next_ response Blocks until a response to a deferred operation request becomes available poll_next_ response Returns true if a response to a deferred operation is available - 686 - resolve_initial _references Resolves a member of the list returned by list_initial_services to its corresponding implementation object and returns the result send_multiple _requests_deferred Sends a set of operation requests without blocking send_multiple _requests_oneway Sends a set of one way operation requests, which have no return values The following method headers specify the arguments of the methods of the ORB class: public abstract class ORB // Public Class Methods public static BOA BOA_init() public static ORB init(String[] args , Properties p) public static ORB init(Applet app, Properties p) // Public Methods public Object bind(String repository, String object_name, String host_name, BindOptions opt) public public BOA BOA_init(String boa_type, Properties p) public abstract TypeCode create_alias_to( String repository, String type_name, TypeCode type ) public abstract Any create_any() public abstract TypeCode create_array_tc(int len, TypeCode type ) public DynAny create_basic_dyn_any(TypeCode type ) throws InconsistentTypeCode public abstract ContextList create_context_list() public DynAny create_dyn_any(Any value) public DynArray create_dyn_array(TypeCode type ) throws InconsistentTypeCode public DynEnum create_dyn_enum(TypeCode type ) throws InconsistentTypeCode public DynSequence create_dyn_sequence(TypeCode type ) throws InconsistentTypeCode public DynStruct create_dyn_struct(TypeCode type ) throws InconsistentTypeCode public DynUnion create_dyn_union(TypeCode type _ throws InconsistentTypeCode public TypeCode create_enum_tc(String repository, String type , String [] members) public abstract Environment create_environment() public abstract TypeCode create_estruct_tc( String repository, String type , TypeCode base , StructMember [] members) public abstract TypeCode create_exception_tc( String repository, String type , StructMember [] members) public abstract InputStream create_input_stream( - 687 - OutputStream out) public abstract TypeCode create_interface_tc( String repository, String type ) public abstract NVList create_list(int len) public abstract NamedValue create_named_value( String name , Any value, int flags) public abstract NVList create_operation_list( OperationDef op_def) public abstract OutputStream create_output_stream() public abstract TypeCode create_recursive_sequence_tc( int len, int offset) public abstract TypeCode create_sequence_tc( int len, TypeCode type ) public abstract TypeCode create_String_tc(int len) public abstract TypeCode create_struct_tc( String repository, String type , StructMember[] members) public abstract TypeCode create_union_tc( String repository, String type , TypeCode disc_type, UnionMembers [] members) public abstract TypeCode create_wstring_tc(int len) public abstract BindOptions default_bind_options() public abstract void default_bind_options( BindOptions opts ) public abstract Principal default_principal() public abstract void default_principal( Principal principal) public abstract Context get_default_context() public abstract Request get_next_response() public abstract TypeCode get_primitive_tc( TCKind kind ) public abstract String [] list initial_services() public abstract String object_to_string(Object obj) public abstract boolean poll_next_response() public abstract Object resolve_initial_references( String id) throws InvalidName public abstract void send_multiple_requests_deferred( Request [] reqs ) public abstract void send_multiple_requests_oneway( Request [] reqs ) public abstract Object string_to_object(String ior) ORG.COM.CORBA.PRINCIPAL The Principal class encapsulates a byte array that a client can associate with an operation request Client applications can set a default principal by invoking the ORB.default_principal method public abstract class Principal // Public Methods public abstract void name(byte [] public abstract byte[] name(() name ) - 688 - Appendix C: How to Get the Most From the CDROM Overview The CD-ROM that accompanies this book contains valuable software as well as other helpful material In addition to the software, the CD contains the complete code listings from each chapter and other useful documents WHAT’S ON THIS CD-ROM This CD-ROM contains scripts and source code mentioned throughout the book as well electronic books, third-party software and more The following is an overview of the directory structure of this disc: • Chapterxx\Listings\—Author examples and code listings as mentioned in the book xx is the chapter number • \Documents\—Documents related to Java distributed computing, such as the CORBA specification in Portable Document Format (PDF) • \Software\—Third-party software tools for developing Java distributed object applications and for use with the coding examples provided in the book including: Visibroker 3.2 from Inprise Sniff+ 3.0 from TakeFive JBuilder Publisher’s Edition Objectspace Voyager software JacORB CODE LISTINGS The code listings can be copied directly from the CD, compiled, and run, in order to supplement the discussions in each chapter These are provided as a learning tool The code listings are organized in subdirectories by chapter For example, if you need to find the listing for Passenger.java from Chapter 12, it is located in the path Drive:\Chapter12\Listings\filename.ext Variable default CDR-Drive is the CD-ROM drive letter for your system and code.exe is the file for which you’re searching In this example, it is Passenger.java SYSTEM REQUIREMENTS FOR THIS CD-ROM This CD-ROM was configured for use on systems running Windows NT 4.0 Workstation or Windows 95 on an Intel-based system Table C.1 describes the minimum system requirements to install the CD TABLE C.1 SYSTEM REQUIREMENTS - 689 - Component Requirement Processor 486DX or higher processor Operating System Microsoft Windows ® NT 4.0 Workstation or Windows ® 95 Memory 24MB Free storage space 9.5MB minimum Monitor VGA or higher resolution video adapter (SVGA 256-color recommended) Other Mouse or compatible pointing device CD-ROM drive 2X or higher Web browser Such as Netscape or Internet Explorer Optional An active Internet connection (highly recommended) HOW TO INSTALL PRODUCTS FROM THE CD-ROM Under Windows NT/95, just insert the disc and follow the directions of the program to create a program group for this CD-ROM From within this program group, you can install the source code and applications included on this disc You might also review documentation, preview files, or install products using Windows Explorer Note If you have AutoPlay disabled on your Windows NT/95 computer, the CDROM will not automatically install the Program Group To start the CD Product Browser manually, go to the Start Menu, select Run, then Browse to find your CD-ROM drive letter Select the file SETUP.EXE from the root directory and follow the instructions to install the program group for this book Installation Notes To install an application from this CD-ROM, you may use the program group icon or you may go directly to Windows Explorer by double-clicking on the MY COMPUTER icon on your desktop and selecting your CD-ROM drive Using either method, go to the desired folder and select the SETUP.EXE file or the file that has the extension EXE These are the installation programs for the software Many of these programs will lead you through the installation process If you have difficulty installing a program, try copying the contents of the folder onto your computer and then double-clicking on the EXE file Always refer to any documentation that may accompany the individual software Troubleshooting Common Problems The following are some typical installation problems you might encounter - 690 - Q I don’t see any directories on this CD-ROM It looks like I have a blank disc A First, try to clean the data side of the CD-ROM with a clean, soft cloth If the problem still exists, if possible, insert this CD-ROM into another computer to determine if the problem is with the disc or your CD-ROM drive Another cause of this problem might be that you have outdated CD-ROM drivers In order to view the directories and access the files on this disc, first verify the manufacturer of your CD-ROM drive from your system’s documentation Or, under Windows 95/NT, you may also check your CD-ROM manufacturer by going to \Settings\Control Panel\System and select the Device Manager Double-click on the CD-ROM and you will see the information on the manufacturer of your drive You may download the latest drivers from your manufacturer’s Web site or from www.microsoft.com/support Q The CD-ROM doesn’t run properly or just spins in my CD-ROM drive A The usual cause of this is a damaged or dirty disc Visually inspect the disc for possible flaws or defects, and clean it properly You should also test another CDROM in your drive This often reveals setup problems that are not disc specific If these procedures fail, you can contact us to get a replacement disc (contact information is at the end of this file) Q The programs run slowly or don’t run properly A Do you have at least the follow amounts of RAM (memory)? Windows NT: 24MB Windows 95: 24MB This might sound familiar, but Windows NT/95 programs not run well on fewer megabytes If you have only the minimum amount of RAM, the program might run slowly Check the individual software installation instructions for RAM requirements for the program you want to install Also, if you have only a single-spin CD-ROM drive, files will be accessed more slowly Q I get an error whenever I try to double-click on an EXE file included on the CDROM A Many of the programs included on this CD-ROM were created using a selfextracting format or require certain files to be present before installation can occur Instead of double-clicking on the filename directly from the CD, select the desired ZIP file, EXE file, or the entire directory containing the desired application Copy the file(s) to your hard drive into a newly created folder Double-click on the filename from your hard drive to extract the files into its own folder Select the SETUP.EXE or INSTALL.EXE file from within the folder Q The uninstall doesn’t remove all the icons or the program group created for this CD-ROM A This CD-ROM includes a very basic program group installation script that installs an uninstall file into your \Windows\temp directory and creates a new program group that includes a Readme file icon, uninstall icon, and a “Browse the CD” icon If the uninstall option fails to remove all of these icons, you may use Windows Explorer to go to the - 691 - \Windows\Start Menu\Programs directory to look for files applicable to this book and delete any of these files that remain The file Unwise.exe that was installed may also be removed from your \Windows\temp directory Note: If you copied the source code to your computer, you will also need to go to the directory that contains those files to delete any files Contacting Us for Support We cannot help you with computer problems, Windows problems, or third-party applications problems, but we can assist you with a problem you have with this book or the CDROM Note Problems with another company’s programs on the disc need to be resolved with the company that produced the program or demo If you need assistance with the information in this book or with the CD-ROM accompanying this book, please access the Knowledge Base on our Web site at http://www.superlibrary.com/general/support Our most Frequently Asked Questions are answered there If you not find the answer to your questions on our Web site, you may contact Macmillan Technical Support at (317) 581-3833 or e-mail us at support@mcp.com Internet Email Please be prepared to give us information on your computer system and a detailed account of the problem you’re experiencing support@mcp.com If you’re a member of an online service such as CompuServe, America Online, Prodigy, and so on, you can send Internet email through your service Regular Mail Macmillan Computer Publishing Support Department 201 West 103rd Street Indianapolis, IN 46290 Telephone: (317) 581-3833 Fax: (317) 581-4773 Visit us online at Internet World Wide Web (The Macmillan Information SuperLibrary): http://www.mcp.com/ SHAREWARE This product features Macromedia Shockwave ?, the standard for multimedia on the World Wide Web For further information regarding Shockwave, including upgrades and add-ons, visit the Shockwave section of the Macromedia World Wide Web site at - 692 - http://www.macromedia.com Shockwave ™ Copyright © 1995-1997 Macromedia, Inc All Rights Reserved Shockwave is a trademark of Macromedia, Inc Some of the programs included on this CD-ROM are shareware—try-before-you-buy— software Independent developers spend hundreds of hours creating, updating, and improving various utilities and tools that make everyone’s computing lives that much better These hard-working souls create the programs or add-on features that the retail products overlook, yet end users could use “If only I could find a program that could ” Please support these independent vendors by purchasing or registering any shareware software that you use for more than 30 days Check with the documentation provided with the software on where and how to register the product Thank you for your support of shareware! LICENSE AGREEMENT By opening this package, you are agreeing to be bound by the following agreement: Some of the software included with this product might be copyrighted, in which case all rights are reserved by the respective copyright holder You are licensed to use software copyrighted by the publisher and its licensors on a single computer You may copy and/or modify the software as needed to facilitate your use of it on a single computer Making copies of the software for any other purpose is a violation of the United States copyright laws This software is sold as is, without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose Neither the publisher nor its dealers or distributors assumes any liability for any alleged or actual damages arising from the use of this program (Some states not allow for the exclusion of implied warranties, so the exclusion might not apply to you.) - 693 -

Ngày đăng: 12/08/2016, 15:01

TỪ KHÓA LIÊN QUAN