KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > corba > logservice > LogCurrentImpl


1 // ====================================================================
2
//
3
// ECM: The Extensible Container Model
4
// Copyright (C) 2004 THALES
5
// Contact: openccm-ecm@objectweb.org
6
//
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Lesser General Public
9
// License as published by the Free Software Foundation; either
10
// version 2.1 of the License, or any later version.
11
//
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// Lesser General Public License for more details.
16
//
17
// You should have received a copy of the GNU Lesser General Public
18
// License along with this library; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
// USA
21
//
22
// Initial developer(s): Mathieu Vadet.
23
// Initial Funding: IST COACH European project (IST-2001-34445)
24
// http://www.ist-coach.org
25
//
26
// ====================================================================
27

28
29
30 package org.objectweb.corba.logservice;
31
32 import org.objectweb.corba.runtime.*;
33
34 /**
35  ** <p>Implementation of a <tt>CORBA::Current</tt> for the log service.
36  ** This current holds an 'id' which is propogated from the client-side to
37  ** the server side by the request interceptors.</p>
38  **
39  ** @see org.objectweb.corba.logservice.LogSRIImpl LogSRIImpl
40  ** @see org.objectweb.corba.logservice.LogCRIImpl LogCRIImpl
41  **/

42 public class LogCurrentImpl
43 extends org.omg.CORBA.LocalObject JavaDoc
44 implements LogCurrent
45 {
46     //
47
private org.omg.PortableInterceptor.ORBInitInfo JavaDoc _info;
48     private int _slot_id;
49     private String JavaDoc _orb_id;
50
51     public
52     LogCurrentImpl(org.omg.PortableInterceptor.ORBInitInfo JavaDoc info,
53                    int slotid,
54                    String JavaDoc orbid)
55     {
56         _info = info;
57         _slot_id = slotid;
58         _orb_id = orbid;
59      }
60
61     //
62
// internal operations
63
//
64

65     private org.omg.PortableInterceptor.Current JavaDoc
66     getPICurrent()
67     {
68         org.omg.CORBA.Object JavaDoc obj = null;
69         org.omg.PortableInterceptor.Current JavaDoc current = null;
70         try {
71             obj = _info.resolve_initial_references("PICurrent");
72         } catch (org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName JavaDoc ex) {
73         } catch (Exception JavaDoc ex) {
74             System.err.println("!!! LogCurrentImpl::getPICurrent exception caught: "+ex.getMessage());
75         } catch (Error JavaDoc err) {
76             System.err.println("!!! LogCurrentImpl::getPICurrent error caught: "+err.getMessage());
77         }
78
79         return org.omg.PortableInterceptor.CurrentHelper.narrow(obj);
80     }
81
82     private org.omg.CORBA.Any JavaDoc
83     extractId()
84     {
85         // get id from slot
86
System.err.println("### LogCurrentImpl::extractId called");
87         try {
88             return getPICurrent().get_slot(_slot_id);
89         } catch (org.omg.PortableInterceptor.InvalidSlot JavaDoc ex) {
90             System.err.println("!!! LogCurrentImpl::extractId slot_id does not exists: "+_slot_id);
91         }
92
93         return null;
94     }
95
96     private void
97     insertId(org.omg.CORBA.Any JavaDoc id)
98     {
99         // set id in slot
100
System.err.println("### LogCurrentImpl::insertId called");
101         try {
102             getPICurrent().set_slot(_slot_id, id);
103         } catch (org.omg.PortableInterceptor.InvalidSlot JavaDoc ex) {
104             System.err.println("!!! LogCurrentImpl::insertId slot_id does not exists: "+_slot_id);
105         }
106     }
107
108     //
109
// IDL:org/objectweb/corba/logservice/LogCurrent:1.0
110
//
111

112     final public org.omg.CORBA.Any JavaDoc
113     current_id()
114     {
115         return extractId();
116     }
117
118     final public void
119     current_id(org.omg.CORBA.Any JavaDoc cid)
120     {
121         insertId(cid);
122     }
123 }
124
Popular Tags