KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jts > CosTransactions > ControlImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28 //----------------------------------------------------------------------------
29
//
30
// Module: ControlImpl.java
31
//
32
// Description: Transaction Control object implementation.
33
//
34
// Product: com.sun.jts.CosTransactions
35
//
36
// Author: Simon Holdsworth
37
//
38
// Date: March, 1997
39
//
40
// Copyright (c): 1995-1997 IBM Corp.
41
//
42
// The source code for this program is not published or otherwise divested
43
// of its trade secrets, irrespective of what has been deposited with the
44
// U.S. Copyright Office.
45
//
46
// This software contains confidential and proprietary information of
47
// IBM Corp.
48
//----------------------------------------------------------------------------
49

50 package com.sun.jts.CosTransactions;
51
52 // Import required classes.
53

54 import java.util.*;
55
56 import org.omg.CORBA.*;
57 import org.omg.PortableServer.*;
58 import org.omg.CosTransactions.*;
59 import org.omg.PortableServer.POAPackage.ServantNotActive JavaDoc;
60 import org.omg.PortableServer.POAPackage.ServantAlreadyActive JavaDoc;
61
62 import com.sun.jts.otsidl.*;
63 import java.util.logging.Logger JavaDoc;
64 import java.util.logging.Level JavaDoc;
65 import com.sun.logging.LogDomains;
66 import com.sun.jts.utils.LogFormatter;
67 /**The ControlImpl interface is our implementation of the standard Control
68  * interface. It provides operations to set and subsequently obtain the
69  * Terminator and Coordinator objects from the given context. Our
70  * implementation also provides a method to obtain the corresponding
71  * transaction identifiers, and stacking methods.
72  *
73  * @version 0.01
74  *
75  * @author Simon Holdsworth, IBM Corporation
76  *
77  * @see
78  */

79 //----------------------------------------------------------------------------
80
// CHANGE HISTORY
81
//
82
// Version By Change Description
83
// 0.01 SAJH Initial implementation.
84
//------------------------------------------------------------------------------
85

86 public class ControlImpl extends JControlPOA implements Control {
87     
88     private static POA poa = null;
89     private Control thisRef = null;
90     
91     protected boolean temporary = false;
92     protected boolean inSuspended = false;
93     protected Status tranState = Status.StatusActive;
94     protected CoordinatorImpl coord = null;
95     protected Coordinator coordRef = null;
96     protected TerminatorImpl term = null;
97     protected Terminator JavaDoc termRef = null;
98     protected ControlImpl stacked = null;
99     protected GlobalTID globalTID = null;
100     protected Long JavaDoc localTID = null;
101     protected boolean representsRemote = false;
102     protected PropagationContext cachedContext = null;
103     
104     // Transaction checking values
105

106     protected int outgoing = 0;
107     protected int association = 0;
108     
109     /**
110      * Logger to log transaction messages
111      */

112     static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.TRANSACTION_LOGGER);
113     
114     /**Default ControlImpl constructor.
115      *
116      * @param
117      *
118      * @return
119      *
120      * @see
121      */

122     ControlImpl() {
123         
124         tranState = Status.StatusActive;
125         
126         // Add the Control object to the set of
127
// suspended ones for this process.
128
inSuspended = true;
129         CurrentTransaction.addSuspended(this);
130         
131     }
132     
133     /**Creates and initialises a new ControlImpl, given the TerminatorImpl and
134      * CoordinatorImpl objects, and the corresponding global and local identifiers.
135      *
136      * @param term The Terminator for the transaction.
137      * @param coord The Coordinator for the transaction.
138      * @param globalTID The global identifier for the transaction.
139      * @param localTID The local identifier for the transaction.
140      *
141      * @return
142      *
143      * @see
144      */

145     ControlImpl( TerminatorImpl term,
146     CoordinatorImpl coord,
147     GlobalTID globalTID,
148     Long JavaDoc localTID ) {
149         
150         
151         // Set up the instance variables.
152

153         this.term = term;
154         this.coord = coord;
155         this.globalTID = globalTID;
156         this.localTID = localTID;
157         tranState = Status.StatusActive;
158         
159         // Add the Control object to the set of suspended ones for this process.
160

161         inSuspended = true;
162         CurrentTransaction.addSuspended(this);
163         
164         // pass this control obj to the terminator to cleanup properly (Ram J)
165
if (term != null) {
166             term.setControl(this);
167         }
168     }
169     
170     /**Creates and initialises a new ControlImpl, given a Control object.
171      * This constructor is used to create a local ControlImpl when a remote factory
172      * has been used to create the Control object.
173      *
174      * @param ref The Control object for the transaction.
175      *
176      * @return
177      *
178      * @exception Unavailable The required information to set up the Control object
179      * is not available.
180      *
181      * @see
182      */

183     ControlImpl( Control ref )
184     throws Unavailable {
185         
186         // Set up the instance variables.
187

188         thisRef = ref;
189         representsRemote = true;
190         coordRef = ref.get_coordinator();
191         termRef = ref.get_terminator();
192         
193         // Get a PropagationContext from the Coordinator, which will contain the
194
// global TID for the transaction.
195

196         try {
197             cachedContext = coordRef.get_txcontext();
198             globalTID = new GlobalTID(cachedContext.current.otid);
199         } catch( Throwable JavaDoc exc ) {
200         }
201         
202         tranState = Status.StatusActive;
203         
204         // Don't add the Control object to the set of suspended ones for this process,
205
// as we may never get the opportunity to remove it.
206

207         //$ CurrentTransaction.addSuspended(this);
208

209     }
210     
211     /**Cleans up the state of the object.
212      *
213      * @param
214      *
215      * @return
216      *
217      * @see
218      */

219     synchronized public void finalize() {
220         
221         // Ensure that this object does not appear in the suspended set.
222

223         if( inSuspended )
224             CurrentTransaction.removeSuspended(this);
225         inSuspended = false;
226         
227         // If there is a Terminator reference, destroy the Terminator.
228

229         if( term != null ) term.destroy();
230         
231         // Remove the reference from the map.
232

233         /* TN - do not nullify the references yet
234         thisRef = null;
235         coord = null;
236         coordRef = null;
237         term = null;
238         termRef = null;
239         stacked = null;
240         globalTID = null;
241         localTID = null;
242          */

243         
244     }
245     
246     /**Returns the identifier that globally represents the transaction
247      *
248      * @param
249      *
250      * @return The global identifier.
251      *
252      * @see
253      */

254     public GlobalTID getGlobalTID() {
255         return globalTID;
256     }
257     
258     /**Returns the identifier that globally represents the transaction, and a
259      * value that indicates the state of the transaction.
260      *
261      * @param status An object to hold the status value, or null.
262      *
263      * @return The global identifier.
264      *
265      * @exception SystemException An error occurred. The minor code indicates
266      * the reason for the exception.
267      *
268      * @see
269      */

270     synchronized public otid_t getGlobalTID( StatusHolder status )
271     throws SystemException {
272         
273         otid_t result = null;
274         
275         // Return the transaction state.
276

277         if( status != null )
278             status.value = tranState;
279         
280         // If the object is asked for its OMGtid and has none, raise an exception.
281

282         if( globalTID == null ) {
283             
284             INTERNAL exc = new INTERNAL(MinorCode.NoGlobalTID,
285             CompletionStatus.COMPLETED_NO);
286             throw exc;
287         }
288         else
289             result = globalTID.realTID;
290         
291         return result;
292     }
293     
294     /**Returns the identifier that locally represents the transaction, and a value
295      * that indicates the state of the transaction.
296      * <p>
297      * If the transaction represented by the Control object has been completed,
298      * the identifier is still returned if possible.
299      *
300      * @param status An object to hold the status value, or null.
301      *
302      * @return The local transaction identifier.
303      *
304      * @exception SystemException An error occurred. The minor code indicates
305      * the reason for the exception.
306      *
307      * @see
308      */

309     synchronized public long getLocalTID( StatusHolder status )
310     throws SystemException {
311         
312         long result = 0;
313         
314         // Return the transaction state.
315

316         if( status != null )
317             status.value = tranState;
318         
319         // If the internal id has not been defined, raise an exception.
320

321         if( localTID == null ) {
322             INTERNAL exc = new INTERNAL(MinorCode.NoGlobalTID,
323             CompletionStatus.COMPLETED_NO);
324             throw exc;
325         } else {
326             result = localTID.longValue();
327         }
328         
329         return result;
330     }
331     
332     
333     /**Returns a reference to the stacked ControlImpl if there is one, otherwise
334      * returns a NULL reference.
335      * <p>
336      * A value is returned that indicates the state of the transaction.
337      * <p>
338      * If the transaction represented by the Control object has been completed,
339      * the reference is still returned if possible.
340      * The stacked Control object is removed from the stack.
341      *
342      * @param status An object to hold the status value, or null.
343      *
344      * @return The stacked Control object.
345      *
346      * @see
347      */

348     synchronized ControlImpl popControl( StatusHolder status ) {
349         
350         ControlImpl result = null;
351         
352         // Return the transaction state.
353

354         if( status != null )
355             status.value = tranState;
356         
357         // Get the value of the stacked Control object.
358
// Remove the stacked Control object (if any).
359

360         result = stacked;
361         stacked = null;
362         
363         return result;
364     }
365     
366     /**Stacks the given ControlImpl on the target of the operation, so that it can
367      * later be restored, and returns a value that indicates the state of the
368      * transaction.
369      * If there is already a stacked ControlImpl object, the operation throws an
370      * exception. If the transaction has already completed, no stacking is done.
371      *
372      * @param control The Control object to be stacked.
373      * @param status An object to hold the status value, or null.
374      *
375      * @return
376      *
377      * @exception SystemException An error occurred. The minor code indicates
378      * the reason for the exception.
379      *
380      * @see
381      */

382     synchronized void pushControl( ControlImpl control,
383     StatusHolder status )
384     throws SystemException {
385         
386         if( tranState == Status.StatusActive ) {
387             
388             // If a Control object is already stacked on this one, raise an exception.
389

390             if( stacked != null ) {
391                 INTERNAL exc = new INTERNAL(MinorCode.AlreadyStacked,
392                 CompletionStatus.COMPLETED_NO);
393                 throw exc;
394             }
395             
396             // Make the stacked Control object the given one.
397

398             else
399                 stacked = control;
400         }
401         
402         // Return the transaction state.
403

404         if( status != null )
405             status.value = tranState;
406     }
407     
408     /**Returns the Terminator object for the transaction.
409      * We raise the Unavailable exception when there is no Terminator.
410      * If the transaction has been completed, an appropriate exception is raised.
411      *
412      * This operation is part of the OMG interface and must not return any
413      * exceptions other than those defined in the OMG interface.
414      *
415      * @param
416      *
417      * @return The Terminator for the transaction.
418      *
419      * @exception Unavailable The Terminator object is not available.
420      * @exception SystemException The operation failed.
421      *
422      * @see
423      */

424     
425     synchronized public Terminator JavaDoc get_terminator()
426     throws Unavailable, SystemException {
427         
428         Terminator JavaDoc result = termRef;
429         
430         // If the transaction has been completed, then raise an exception.
431
// Raise either TRANSACTION_ROLLEDBACK or INVALID_TRANSACTION depending on
432
// whether the transaction has aborted.
433

434         if( tranState == Status.StatusCommitted ) {
435             INVALID_TRANSACTION exc = new INVALID_TRANSACTION(MinorCode.Completed,
436             CompletionStatus.COMPLETED_NO);
437             throw exc;
438         }
439         
440         if( tranState == Status.StatusRolledBack ) {
441             TRANSACTION_ROLLEDBACK exc = new TRANSACTION_ROLLEDBACK(0,CompletionStatus.COMPLETED_NO);
442             throw exc;
443         }
444         
445         // If there is no Terminator reference, but a local Terminator, then get its
446
// reference and remember it.
447

448         if( termRef == null && term != null ) {
449             termRef = term.object();
450             result = termRef;
451         }
452         
453         // If there is no reference available, throw the Unavailable exception.
454

455         if( result == null ) {
456             Unavailable exc = new Unavailable();
457             throw exc;
458         }
459         
460         return result;
461     }
462     
463     synchronized public Terminator JavaDoc get_localTerminator()
464     throws Unavailable, SystemException {
465         
466         Terminator JavaDoc result = (Terminator JavaDoc) term;
467         
468         // If the transaction has been completed, then raise an exception.
469
// Raise either TRANSACTION_ROLLEDBACK or INVALID_TRANSACTION depending on
470
// whether the transaction has aborted.
471

472         if( tranState == Status.StatusCommitted ) {
473             INVALID_TRANSACTION exc = new INVALID_TRANSACTION(MinorCode.Completed,
474             CompletionStatus.COMPLETED_NO);
475             throw exc;
476         }
477         
478         if( tranState == Status.StatusRolledBack ) {
479             TRANSACTION_ROLLEDBACK exc = new TRANSACTION_ROLLEDBACK(0,CompletionStatus.COMPLETED_NO);
480             throw exc;
481         }
482         
483         // If there is no reference available, throw the Unavailable exception.
484

485         if (result == null) {
486             Unavailable exc = new Unavailable();
487             throw exc;
488         }
489         
490         return result;
491     }
492     
493     /**
494      * Returns the Coordinator for the transaction.
495      * If the transaction has been completed, an appropriate exception is raised.
496      *
497      * This operation is part of the OMG interface and must not return
498      * any exceptions other than those defined in the OMG interface.
499      *
500      * @param
501      *
502      * @return The Coordinator for the transaction.
503      *
504      * @exception Unavailable The Coordinator is not available.
505      * @exception SystemException The operation failed.
506      *
507      * @see
508      */

509     synchronized public Coordinator get_coordinator()
510     throws Unavailable, SystemException {
511         
512         Coordinator result = coordRef;
513         
514         // If the transaction has been completed, then raise an exception.
515
// Raise either TRANSACTION_ROLLEDBACK or INVALID_TRANSACTION depending on
516
// whether the transaction has aborted.
517

518         if( tranState == Status.StatusCommitted ) {
519             INVALID_TRANSACTION exc = new INVALID_TRANSACTION(MinorCode.Completed,
520             CompletionStatus.COMPLETED_NO);
521             throw exc;
522         }
523         
524         if( tranState == Status.StatusRolledBack ) {
525             TRANSACTION_ROLLEDBACK exc = new TRANSACTION_ROLLEDBACK(0,CompletionStatus.COMPLETED_NO);
526             throw exc;
527         }
528         
529         // If there is no Coordinator reference, but a local Coordinator, then get its
530
// reference and remember it.
531

532         if( coordRef == null && coord != null ) {
533             coordRef = coord.object();
534             result = coordRef;
535         }
536         
537         // If there is no reference available, throw the Unavailable exception.
538

539         if( result == null ) {
540             Unavailable exc = new Unavailable();
541             throw exc;
542         }
543         
544         return result;
545     }
546     
547     /**
548      * Returns the Coordinator for the transaction.
549      * If the transaction has been completed, an appropriate exception is raised.
550      *
551      * This operation is part of the OMG interface and must not return
552      * any exceptions other than those defined in the OMG interface.
553      *
554      * @param
555      *
556      * @return The Coordinator for the transaction.
557      *
558      * @exception Unavailable The Coordinator is not available.
559      * @exception SystemException The operation failed.
560      *
561      * @see
562      */

563     synchronized public Coordinator get_localCoordinator()
564     throws Unavailable, SystemException {
565         
566         Coordinator result = (Coordinator) coord;
567         
568         // If the transaction has been completed, then raise an exception.
569
// Raise either TRANSACTION_ROLLEDBACK or INVALID_TRANSACTION depending on
570
// whether the transaction has aborted.
571

572         if( tranState == Status.StatusCommitted ) {
573             INVALID_TRANSACTION exc = new INVALID_TRANSACTION(MinorCode.Completed,
574             CompletionStatus.COMPLETED_NO);
575             throw exc;
576         }
577         
578         if( tranState == Status.StatusRolledBack ) {
579             TRANSACTION_ROLLEDBACK exc = new TRANSACTION_ROLLEDBACK(0,CompletionStatus.COMPLETED_NO);
580             throw exc;
581         }
582         
583         // If there is no reference available, throw the Unavailable exception.
584

585         if( result == null ) {
586             Unavailable exc = new Unavailable();
587             throw exc;
588         }
589         
590         return result;
591     }
592     
593     /**This operation returns a value indicating that asynchonrous requests issued
594      * within the context of the current ControlImpl instance have not yet
595      * completed.
596      *
597      * @param
598      *
599      * @return Indicates there are outgoing requests.
600      *
601      * @see
602      */

603     
604     synchronized boolean isOutgoing() {
605         boolean result = (outgoing != 0);
606         return result;
607     }
608     
609     
610     /**This operation returns a value which indicates that this ControlImpl instance
611      * is associated with one or more threads.
612      *
613      * @param
614      *
615      * @return Indicates an exisiting association.
616      *
617      * @see
618      */

619     synchronized boolean isAssociated() {
620         boolean result = (association != 0);
621         return result;
622     }
623     
624     /**This operation returns the number of thread associations
625      *
626      * @param
627      *
628      * @return Indicates the number of thread associations.
629      *
630      * @see
631      */

632     synchronized int numAssociated() {
633         int result = association;
634         return result;
635     }
636     
637     /**Increment the thread association count.
638      *
639      * @param
640      *
641      * @return
642      *
643      * @see
644      */

645     synchronized void incrementAssociation() {
646         association++;
647     }
648     
649     /**Decrement the thread association count.
650      *
651      * @param
652      *
653      * @return Indicates the association count was above zero.
654      *
655      * @see
656      */

657     synchronized boolean decrementAssociation() {
658         boolean result = (association > 0);
659         if( result ) association--;
660         return result;
661     }
662     
663     /**Increment the incomplete asynchronous request counter.
664      *
665      * @param
666      *
667      * @return
668      *
669      * @see
670      */

671     synchronized void incrementOutgoing() {
672         outgoing++;
673     }
674     
675     /**Decrement the incomplete asynchronous request counter.
676      *
677      * @param
678      *
679      * @return Indicates the request counter was above zero.
680      *
681      * @see
682      */

683     synchronized boolean decrementOutgoing() {
684         boolean result = (outgoing > 0);
685         if( result ) outgoing--;
686         return result;
687     }
688     
689     /**Returns the state of the transaction as the Control object knows it.
690      *
691      * @param
692      *
693      * @return The transaction state.
694      *
695      * @see
696      */

697     synchronized public Status getTranState(){
698         Status result = tranState;
699         return result;
700     }
701     
702     /**Sets the state of the transaction as the Control object knows it.
703      * No checking is done to verify the state change is valid.
704      *
705      * @param int The new state.
706      *
707      * @return
708      *
709      * @see
710      */

711     synchronized public void setTranState( Status newState ) {
712         tranState = newState;
713     }
714     
715     
716     /**Locates the first stacked ancestor which has not aborted. If there is no
717      * such ancestor the operation returns null.
718      *
719      * @param
720      *
721      * @return The first stacked Control which does not represent an aborted
722      * transaction.
723      *
724      * @see
725      */

726     synchronized ControlImpl popAborted() {
727         
728         // Start with this object's stacked Control.
729

730         ControlImpl result = stacked;
731         boolean validTID = false;
732         StatusHolder outStatus = new StatusHolder();
733         while( result != null && !validTID ) {
734             
735             // Get the local transaction identifier for the stacked Control object,
736
// and ask the RecoveryManager if it represents a valid transaction.
737

738             Long JavaDoc localTID = null;
739             try {
740                 localTID = new Long JavaDoc(result.getLocalTID(outStatus)); }
741             catch( Throwable JavaDoc exc ) {}
742             validTID = RecoveryManager.validLocalTID(localTID);
743             
744             // If the transaction identifier is not valid, then the transaction must have
745
// rolled back, so discard it and get its stacked Control object, if any.
746

747             if( !validTID ) {
748                 
749                 // Get the stacked Control object from the one that represents a rolled
750
// back transaction, and try to resume that one instead.
751

752                 ControlImpl stacked = result.popControl(outStatus);
753                 result.destroy();
754                 
755                 // Discard the rolled-back Control object and continue until a valid one, or
756
// no stacked Control is found.
757

758                 result = stacked;
759             }
760         }
761         
762         return result;
763     }
764     
765     /**Determines whether the ControlImpl object represents a remote Control object
766      * or a local one.
767      *
768      * @param
769      *
770      * @return Indicates whether the ControlImpl represents a remote Control.
771      *
772      * @see
773      */

774     
775     synchronized boolean representsRemoteControl() {
776         boolean result = representsRemote;
777         return result;
778     }
779     
780     /**Returns the transaction context for the Coordinator.
781      *
782      * @param
783      *
784      * @return The transaction context.
785      *
786      * @exception Unavailable No transaction context is available.
787      *
788      * @see
789      */

790     synchronized PropagationContext getTXContext()
791     throws Unavailable {
792         PropagationContext result = null;
793         
794         // If the ControlImpl represents a remote transaction, then use the cached
795
// context, or get one from the Coordinator if there is no cached context.
796

797         if( representsRemote ) {
798             if( cachedContext == null )
799                 try {
800                     cachedContext = coordRef.get_txcontext();
801                 } catch( OBJECT_NOT_EXIST exc ) {
802                     TRANSACTION_ROLLEDBACK ex2 = new TRANSACTION_ROLLEDBACK(0,CompletionStatus.COMPLETED_NO);
803                     throw ex2;
804                 }
805             result = cachedContext;
806         }
807         
808         // For local transactions, get the context from the Coordinator.
809

810         else
811             result = coord.get_txcontext();
812         
813         return result;
814     }
815     
816     /**Dumps the state of the object.
817      *
818      * @param
819      *
820      * @return
821      *
822      * @see
823      */

824     void dump() {
825     }
826     
827     /**Returns the CORBA Object which represents this object.
828      *
829      * @param
830      *
831      * @return The CORBA object.
832      *
833      * @see
834      */

835     synchronized final Control object() {
836         if( thisRef == null ) {
837             if( poa == null )
838                 poa = Configuration.getPOA("transient"/*#Frozen*/);
839             
840             try {
841                 poa.activate_object(this);
842                 thisRef = ControlHelper.narrow(poa.servant_to_reference(this));
843             } catch( ServantAlreadyActive JavaDoc sexc ) {
844                 _logger.log(Level.SEVERE,"jts.create_control_object_error",sexc);
845                 String JavaDoc msg = LogFormatter.getLocalizedMessage(_logger,
846                 "jts.create_control_object_error");
847                 throw new org.omg.CORBA.INTERNAL JavaDoc(msg);
848             } catch( ServantNotActive JavaDoc snexc ) {
849                 _logger.log(Level.SEVERE,"jts.create_control_object_error",snexc);
850                 String JavaDoc msg = LogFormatter.getLocalizedMessage(_logger,
851                 "jts.create_control_object_error");
852                 throw new org.omg.CORBA.INTERNAL JavaDoc(msg);
853             } catch( Exception JavaDoc exc ) {
854                 _logger.log(Level.SEVERE,"jts.create_control_object_error",exc);
855                 String JavaDoc msg = LogFormatter.getLocalizedMessage(_logger,
856                 "jts.create_control_object_error");
857                 throw new org.omg.CORBA.INTERNAL JavaDoc(msg);
858             }
859         }
860         
861         return thisRef;
862     }
863     
864     /**Returns the ControlImpl which serves the given object.
865      *
866      * @param The CORBA Object.
867      *
868      * @return The ControlImpl object which serves it.
869      *
870      * @see
871      */

872     synchronized public static final ControlImpl servant( JControl control ) {
873         ControlImpl result = null;
874         
875         // GDH we will not be able to obtain the
876
// servant from our local POA for a proxy control object.
877
// so return null
878
if ( control != null && Configuration.getProxyChecker().isProxy(control)) {
879             return result;
880         }
881         
882         if( control instanceof ControlImpl ) {
883             result = (ControlImpl)control;
884         } else if( poa != null )
885            try {
886                 result = (ControlImpl)poa.reference_to_servant(control);
887                 if( result.thisRef == null )
888                     result.thisRef = control;
889             } catch( Exception JavaDoc exc ) {
890                 _logger.log(Level.WARNING,"jts.cannot_locate_servant","Control");
891                 
892             }
893         
894         return result;
895     }
896     
897     /**Destroys the ControlImpl object.
898      *
899      * @param
900      *
901      * @return
902      *
903      * @see
904      */

905     synchronized final void destroy() {
906         // GDH: We have no desire to destroy an underlying remote control object, instead we
907
// release it. We will finalise the local control wrapper below
908
if ( thisRef != null && Configuration.getProxyChecker().isProxy(thisRef)) {
909             thisRef._release();
910         } else {
911             if( poa != null &&
912             thisRef != null )
913                 try {
914                     poa.deactivate_object(poa.reference_to_id(thisRef));
915                     thisRef = null;
916                 } catch( Exception JavaDoc exc ) {
917                     _logger.log(Level.WARNING,"jts.object_destroy_error","Control");
918                     
919                     
920                 }
921         }
922         
923         finalize();
924         
925     }
926     
927     /**Added to prevent null delegate problem.
928      *
929      * @param
930      *
931      * @return
932      *
933      * @see
934      */

935     public boolean equals(java.lang.Object JavaDoc o) {
936         return this == o;
937     }
938     
939     /*
940      * These methods are there to satisy the compiler. At some point
941      * when we move towards a tie based model, the org.omg.Corba.Object
942      * interface method implementation below shall be discarded.
943      */

944     
945     private static org.omg.CORBA.NO_IMPLEMENT JavaDoc no_implement =
946     new org.omg.CORBA.NO_IMPLEMENT JavaDoc("This is a locally constrained object.");
947     
948     
949     public org.omg.CORBA.Object JavaDoc _duplicate() {
950         throw no_implement;
951         
952     }
953     
954     public void _release() {
955         throw no_implement;
956         
957     }
958     
959     public boolean _is_a(String JavaDoc repository_id) {
960         throw no_implement;
961         
962     }
963     
964     public boolean _is_equivalent(org.omg.CORBA.Object JavaDoc that) {
965         throw no_implement;
966         
967     }
968     
969     public boolean _non_existent() {
970         throw no_implement;
971         
972     }
973     
974     public int _hash(int maximum) {
975         throw no_implement;
976         
977     }
978     
979     public Request _request(String JavaDoc operation) {
980         throw no_implement;
981         
982     }
983     
984     public Request _create_request(Context ctx,
985     String JavaDoc operation,
986     NVList arg_list,
987     NamedValue result) {
988         throw no_implement;
989         
990     }
991     
992     public Request _create_request(Context ctx,
993     String JavaDoc operation,
994     NVList arg_list,
995     NamedValue result,
996     ExceptionList exceptions,
997     ContextList contexts) {
998         throw no_implement;
999         
1000    }
1001    
1002    public org.omg.CORBA.Object JavaDoc _get_interface_def() {
1003        throw no_implement;
1004        
1005    }
1006    
1007    public org.omg.CORBA.Policy JavaDoc _get_policy(int policy_type) {
1008        throw no_implement;
1009        
1010    }
1011    
1012    public org.omg.CORBA.DomainManager JavaDoc[] _get_domain_managers() {
1013        throw no_implement;
1014        
1015    }
1016    
1017    public org.omg.CORBA.Object JavaDoc _set_policy_override(
1018    org.omg.CORBA.Policy JavaDoc[] policies,
1019    org.omg.CORBA.SetOverrideType JavaDoc set_add) {
1020        throw no_implement;
1021        
1022    }
1023}
1024
Popular Tags