Main Page   Packages   Class Hierarchy   Compound List   File List   Compound Members  

SOAImpl Class Reference

Inheritance diagram for SOAImpl:

Inheritance graph
[legend]
Collaboration diagram for SOAImpl:

Collaboration graph
[legend]
List of all members.

Public Methods

void export (org.omg.CORBA.Object impl)
void exportWithPort (org.omg.CORBA.Object impl, int port)
void export (ObjectImpl impl, Context hints, NamingContext nc) throws JonathanException, BAD_OPERATION
void unexport (org.omg.CORBA.Object impl)

Protected Attributes

NamingContext nc

Private Methods

 SOAImpl (Context _c, Object[] components)

Private Attributes

SingleOAdapter adapter
DelegateFactory dfactory
ContextFactory context_factory

Detailed Description

Encapsulates a instance under a CORBA compliant interface, by implementing SimpleAdapter.

SimpleAdapter is a very simple adapter type, providing operations to export and unexport CORBA objects. The methods of SOAImpl implementing the effective functionalities of SimpleAdapter delegate to an underlying adapter of type SingleOAdapter, possibly used by different personnalities.

An object adapter is only responsible for the identification and activation of servant objects: The code of an object adapter has thus no reason to deal with other problems such as distribution. However, it is convenient, when exporting an object, to have it also exported to a naming context that will deal with distribution aspects. SOAImpl lets a context be used, or alternatively, a specific naming context be specified at export time.

Definition at line 68 of file SOAImpl.java.


Constructor & Destructor Documentation

SOAImpl::SOAImpl ( Context _c,
Object components[] ) [inline, private]
 

Returns an SOAImpl instance.

When initialized this way, the default binder associated with this naming context is obtained as a kernel service of name "david.soa.orb".

If the "david.soa.orb" property is not set, the setORB method should be used to set the default ORB.

Parameters:
kernel   a instance;
Returns:
an SOAImpl instance.

Definition at line 92 of file SOAImpl.java.

00092                                            {
00093       nc = (NamingContext) components[0];
00094       dfactory = (DelegateFactory) components[1];
00095       adapter = (SingleOAdapter) components[2];
00096       context_factory = (ContextFactory) components[3];
00097    }


Member Function Documentation

void SOAImpl::export ( ObjectImpl impl,
Context hints,
NamingContext nc ) [inline]
 

Exports a CORBA object implementation to the target adapter, and recursively to the provided naming context.

Parameters:
impl   a CORBA object implementation;
hints   additional information;
nc   a naming context to export the adapter identifier to.
Exceptions:
JonathanException   if something goes wrong.
BAD_OPERATION   if the delegate of impl has not been set: this may mean that its base class has not been generated by the appropriate IDL compiler.

Definition at line 150 of file SOAImpl.java.

00151                                               {
00152       Reference delegate = null;
00153       if( dfactory != null) {
00154          delegate = dfactory.newDelegate(impl);
00155       } else {
00156          try {
00157             delegate = (Reference) impl._get_delegate();
00158          } catch (ClassCastException e) {
00159             throw new ExportException(e);
00160          }
00161       }
00162       Identifier id;
00163       // The current convention states that if the returned id is null,
00164       // the object has already been exported to the minimal adapter.
00165       // this convention is not necessarily the most intuitive one...
00166       id = adapter.export(delegate,hints,nc);
00167       if (id != null) {
00168          // the object has not been exported by the minimal adapter.
00169          Identifier[] refs = delegate.getIdentifiers();
00170          if (refs != null && refs.length > 0) {
00171             int nb = refs.length;
00172             Identifier[] new_refs = new Identifier[nb+1];
00173             System.arraycopy(refs,0,new_refs,0,nb);
00174             new_refs[nb] = id;
00175             delegate.setIdentifiers(new_refs);
00176          } else {
00177             delegate.setIdentifiers(new Identifier[] {id});
00178          }
00179       }
00180    }

void SOAImpl::export ( org.omg.CORBA.Object impl ) [inline]
 

Exports a CORBA object to the target adapter.

This method calls the export method of 3 arguments. The second argument is a Integer instance of value 0.

Parameters:
object   a CORBA object.

Reimplemented from _SimpleAdapterImplBase.

Definition at line 109 of file SOAImpl.java.

00109                                                  {
00110       try {
00111          export((ObjectImpl) impl,null,nc);
00112       } catch (JonathanException e) {
00113          throw CORBAHelpers.systemException(e,CompletionStatus.COMPLETED_NO);
00114       }
00115    }

void SOAImpl::exportWithPort ( org.omg.CORBA.Object impl,
int port ) [inline]
 

Exports a CORBA object to the target adapter, using the specified TCP port.

This method calls the export method of 3 arguments. The second argument is a Integer instance of value port.

Parameters:
object   a CORBA object;
port   a TCP port number.

Reimplemented from _SimpleAdapterImplBase.

Definition at line 127 of file SOAImpl.java.

00127                                                                   {
00128       try {
00129          Context context = context_factory.newContext();
00130          context.addElement("port",int.class,port,(char) 0);
00131          export((ObjectImpl) impl,context,nc);
00132          context.release();
00133       }  catch (JonathanException e) {
00134          throw CORBAHelpers.systemException(e,CompletionStatus.COMPLETED_NO);
00135       }
00136    }

void SOAImpl::unexport ( org.omg.CORBA.Object impl ) [inline]
 

Unexports the provided CORBA object.

If the provided object has not been exported to the target adapter, this method silently returns.

Parameters:
object   a CORBA object.

Reimplemented from _SimpleAdapterImplBase.

Definition at line 190 of file SOAImpl.java.

00190                                                    {
00191       Reference delegate = null;
00192       try {
00193          delegate = (Reference) ((ObjectImpl) impl)._get_delegate();
00194       } catch (ClassCastException e) {
00195          return;
00196       }
00197       Identifier[] refs = delegate.getIdentifiers();
00198       int nb;
00199       if (refs != null && (nb = refs.length) > 0) {
00200          Identifier id, rid;
00201          for (int i = 0; i < nb; i++) {
00202             id = refs[i];
00203             rid = refs[i];
00204             while (rid != null) {
00205                if (rid.getContext().equals(adapter)) {
00206                   rid.unexport();
00207                   rid = null;
00208                } else {
00209                   rid = (Identifier) rid.resolve();
00210                }
00211             }
00212          }
00213       }
00214    }


Member Data Documentation

SingleOAdapter SOAImpl::adapter [private]
 

Definition at line 70 of file SOAImpl.java.

ContextFactory SOAImpl::context_factory [private]
 

Definition at line 72 of file SOAImpl.java.

DelegateFactory SOAImpl::dfactory [private]
 

Definition at line 71 of file SOAImpl.java.

NamingContext SOAImpl::nc [protected]
 

The naming context responsible for distribution handling.

Definition at line 77 of file SOAImpl.java.


The documentation for this class was generated from the following file:
Generated at Fri May 31 19:25:24 2002 for Jonathan by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001