view src/share/classes/org/omg/PortableServer/package.html @ 0:55540e827aef

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
children 91006f157c46
line wrap: on
line source
 Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.

 This code is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License version 2 only, as
 published by the Free Software Foundation.  Sun designates this
 particular file as subject to the "Classpath" exception as provided
 by Sun in the LICENSE file that accompanied this code.

 This code is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 version 2 for more details (a copy is included in the LICENSE file that
 accompanied this code).

 You should have received a copy of the GNU General Public License version
 2 along with this work; if not, write to the Free Software Foundation,
 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

 Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 CA 95054 USA or visit if you need additional information or
 have any questions.


<body bgcolor="white">
Provides classes and interfaces for making the server side of your applications 
portable across multivendor ORBs.

<P>In Java, Portable Object Adaptor (POA)-based Dynamic Skeleton Interface (DSI) 
servants inherit from the  standard <TT>DynamicImplementation</TT> class, which 
inherits from the <TT>Servant</TT> class. The native <TT>Servant</TT> type is 
defined by the <TT>PortableServer</TT> module for the POA. In Java, the 
  <TT>Servant</TT> type is mapped to the Java 
  <TT>org.omg.PortableServer.Servant</TT> class.
  It serves as the base class for all POA servant 
  implementations and provides a number of methods that may 
  be invoked by the application programmer, as well as methods 
  which are invoked by the POA itself and may be overridden by 
  the user to control aspects of servant behavior. 
<H2>Package Specification</H2>
<P>For a precise list of supported sections of official OMG specifications with which 
the Java[tm] Platform, Standard Edition 6 complies, see <A 
HREF="../CORBA/doc-files/compliance.html">Official Specifications for CORBA 
support in Java[tm] SE 6</A>.

<H2>POA-related Interfaces</H2>

<P>The <TT>PortableServer</TT> module defines the following POA-related interfaces:

<P>In addition, the POA defines the <TT>Servant</TT> native type.

<H3>Operations classes</H3>

<P>Each of the interfaces listed above has an associated <code>Operations</code> interface.  The <code>Operations</code> interface is generated by the <code>idlj</code> compiler and contains the method signatures for methods defined in its associated interface.  The <code>Operations</code> interface can be accessed by both the client and the server, while its associated interface can only be called by the client.

<H3>Value Classes</H3>

Classes ending in the suffix <code>PolicyValue</code> provide the values used for the <code>create_POA</code> call, which sets the policy for the POA.   See the <a href="#sampleserver">sample code</a> below for a demonstration.  <code>PolicyValue</code> files include the following:

<H3>Helper Classes</H3>

<P>Helper classes, which are generated for all user-defined types in an OMG IDL 
interface, supply static methods needed to manipulate those types.  There is only one method in a helper class that an application programmer uses: the  <code>narrow</code> method.  Only Java interfaces mapped from IDL interfaces will have a helper class that includes a <code>narrow</code> method, so in the <code>PortableServer</code> package, only the following classes have a <code>narrow</code> method:

<H3>POA Classes</H3>

<P>POA classes are used to implement the <code>ServantActivator</code> or <code>ServantLocator</code>.


<P>The <code>ForwardRequest</code> exception indicates to the ORB 
that it is responsible for delivering the current request and subsequent <code>ForwardRequest</code> requests to the object denoted in the 
 <code>forward_reference</code> member of the exception.

<H3>Interfaces Implemented by the Application Programmer</H3>

<P>Most of what <code>PortableServer</code> does is transparent to the user.  The result is that programmers will use only a few of the interfaces mentioned above.  The remaining interfaces will be provided by the ORB implementation.  The interfaces of interest to application programmers are the following:
	<P>Adapter activators are associated with POAs.  An adapter activator supplies a POA with the ability to create child POAs on demand, as a side-effect of receiving a request that names the child POA (or one of its children), or when <code>find_POA</code> is called with an activate parameter value of <code>TRUE</code>.  An application server that creates all its needed POAs at the beginning of execution does not need to use or provide an adapter activator; it is necessary only for the case in which POAs need to be created during request processing.
	<P>When the POA has the <code>NON_RETAIN</code> policy, it uses servant managers that are <code>ServantLocator</code>s.
	<P>When the POA has the <code>RETAIN</code> policy, it uses servant managers that are <code>ServantActivator</code>s.

<H2>Package <TT>org.omg.PortableServer.ServantLocatorPackage</TT></H2>

<P>This package supplies a <TT>CookieHolder</TT> class for passing 
the <TT>Cookie</TT> type as an <code>out</code> parameter. The <code>CookieHolder</code> class 
follows exactly the same pattern as the other holder classes for basic types.

<H2>Related Documentation</H2>

<P>For an overview of Java IDL, please see:
<LI><A HREF="../../../../technotes/guides/idl/index.html">Java IDL home page</A>.

<H2>Example Code</H2>
<a name="sampleserver"></a>
<H3>Example Server Code</H3>
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.rmi.PortableRemoteObject ;
import org.omg.PortableServer.*;
import java.util.*;
import org.omg.CORBA.*;
import javax.rmi.CORBA.Stub;
import javax.rmi.CORBA.Util;

public class HelloServer {
    public HelloServer(String[] args) {
        try {
            Properties p = System.getProperties();
         //   p.put("org.omg.CORBA.ORBClass", "");
            ORB orb = ORB.init( args, p );

            POA rootPOA = (POA)orb.resolve_initial_references("RootPOA");
            Policy[] tpolicy = new Policy[3];
            tpolicy[0] = rootPOA.create_lifespan_policy(
                LifespanPolicyValue.TRANSIENT );
            tpolicy[1] = rootPOA.create_request_processing_policy(
                RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY );
            tpolicy[2] = rootPOA.create_servant_retention_policy(
            POA tpoa = rootPOA.create_POA("MyTransientPOA", null, tpolicy);

            String  ObjectId = "MyObjectId";
            byte[] oid = ObjectId.getBytes();

            org.omg.CORBA.Object obj = tpoa.create_reference_with_id(oid,
                new _HelloImpl_Tie()._all_interfaces(tpoa, oid)[0]);
            HelloInterface helloRef = (HelloInterface)PortableRemoteObject.narrow(
                obj, HelloInterface.class );

            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);
            System.out.println("Hello Server: Ready...");
         } catch (Exception e) {
            System.out.println("Trouble: " + e);

     public static void main(String args[]) {
         new HelloServer( args );



@since 1.4
@serial exclude