corba/src/share/classes/com/sun/corba/se/spi/oa/ObjectAdapterBase.java
author ohair
Tue, 25 May 2010 15:52:11 -0700
changeset 5555 b2b5ed3f0d0d
parent 4 02bb8761fcce
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     2
 * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
package com.sun.corba.se.spi.oa ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
import org.omg.PortableInterceptor.ObjectReferenceTemplate ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
import org.omg.PortableInterceptor.ObjectReferenceFactory ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
import org.omg.CORBA.Policy ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
import org.omg.PortableInterceptor.ACTIVE ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
import com.sun.corba.se.spi.copyobject.ObjectCopierFactory ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
import com.sun.corba.se.spi.ior.IORFactories ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
import com.sun.corba.se.spi.ior.IORTemplate ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
import com.sun.corba.se.spi.ior.ObjectAdapterId;
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
import com.sun.corba.se.spi.ior.ObjectKeyTemplate ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
import com.sun.corba.se.spi.logging.CORBALogDomains ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
import com.sun.corba.se.spi.oa.OADestroyed ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
import com.sun.corba.se.spi.oa.ObjectAdapter ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
import com.sun.corba.se.spi.orb.ORB ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
import com.sun.corba.se.spi.protocol.PIHandler ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
import com.sun.corba.se.impl.logging.POASystemException ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
import com.sun.corba.se.impl.logging.OMGSystemException ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
import com.sun.corba.se.impl.oa.poa.Policies;
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
abstract public class ObjectAdapterBase extends org.omg.CORBA.LocalObject
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
    implements ObjectAdapter
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
{
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
    private ORB orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
    // Exception wrappers
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
    private final POASystemException _iorWrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
    private final POASystemException _invocationWrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
    private final POASystemException _lifecycleWrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
    private final OMGSystemException _omgInvocationWrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
    private final OMGSystemException _omgLifecycleWrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
    // Data related to the construction of object references and
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
    // supporting the Object Reference Template.
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
    private IORTemplate iortemp;
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
    private byte[] adapterId ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
    private ObjectReferenceTemplate adapterTemplate ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
    private ObjectReferenceFactory currentFactory ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
    public ObjectAdapterBase( ORB orb )
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
        this.orb = orb ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
        _iorWrapper = POASystemException.get( orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
            CORBALogDomains.OA_IOR ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
        _lifecycleWrapper = POASystemException.get( orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
            CORBALogDomains.OA_LIFECYCLE ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
        _omgLifecycleWrapper = OMGSystemException.get( orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
            CORBALogDomains.OA_LIFECYCLE ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
        _invocationWrapper = POASystemException.get( orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
            CORBALogDomains.OA_INVOCATION ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
        _omgInvocationWrapper = OMGSystemException.get( orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
            CORBALogDomains.OA_INVOCATION ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
    public final POASystemException iorWrapper()
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
        return _iorWrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
    public final POASystemException lifecycleWrapper()
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
        return _lifecycleWrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
    public final OMGSystemException omgLifecycleWrapper()
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
        return _omgLifecycleWrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
    public final POASystemException invocationWrapper()
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
        return _invocationWrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
    public final OMGSystemException omgInvocationWrapper()
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
        return _omgInvocationWrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
    /*
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
     * This creates the complete template.
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
     * When it is done, reference creation can proceed.
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
    final public void initializeTemplate( ObjectKeyTemplate oktemp,
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
        boolean notifyORB, Policies policies, String codebase,
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
        String objectAdapterManagerId, ObjectAdapterId objectAdapterId)
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
        adapterId = oktemp.getAdapterId() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
        iortemp = IORFactories.makeIORTemplate(oktemp) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
        // This calls acceptors which create profiles and may
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
        // add tagged components to those profiles.
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
        orb.getCorbaTransportManager().addToIORTemplate(
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
            iortemp, policies,
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
            codebase, objectAdapterManagerId, objectAdapterId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
        adapterTemplate = IORFactories.makeObjectReferenceTemplate( orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
            iortemp ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
        currentFactory = adapterTemplate ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
        if (notifyORB) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
            PIHandler pih = orb.getPIHandler() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
            if (pih != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
                // This runs the IORInterceptors.
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
                pih.objectAdapterCreated( this ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
        iortemp.makeImmutable() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
    final public org.omg.CORBA.Object makeObject( String repId, byte[] oid )
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
        return currentFactory.make_object( repId, oid ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
    final public byte[] getAdapterId()
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
        return adapterId ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
    final public ORB getORB()
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
        return orb ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
    abstract public Policy getEffectivePolicy( int type ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
    final public IORTemplate getIORTemplate()
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
        return iortemp ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
    abstract public int getManagerId() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
    abstract public short getState() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
    final public ObjectReferenceTemplate getAdapterTemplate()
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
        return adapterTemplate ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
    final public ObjectReferenceFactory getCurrentFactory()
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
        return currentFactory ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
    final public void setCurrentFactory( ObjectReferenceFactory factory )
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
        currentFactory = factory ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
    abstract public org.omg.CORBA.Object getLocalServant( byte[] objectId ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
    abstract public void getInvocationServant( OAInvocationInfo info ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
    abstract public void returnServant() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
    abstract public void enter() throws OADestroyed ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
    abstract public void exit() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
    abstract protected ObjectCopierFactory getObjectCopierFactory() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
    // Note that all current subclasses share the same implementation of this method,
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
    // but overriding it would make sense for OAs that use a different InvocationInfo.
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
    public OAInvocationInfo makeInvocationInfo( byte[] objectId )
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
        OAInvocationInfo info = new OAInvocationInfo( this, objectId ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
        info.setCopierFactory( getObjectCopierFactory() ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
        return info ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
    abstract public String[] getInterfaces( Object servant, byte[] objectId ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
}