KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > orb > portableInterceptor > PICurrentImpl


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1999-2004 Gerald Brose
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */

21 package org.jacorb.orb.portableInterceptor;
22
23 import org.omg.PortableInterceptor.*;
24 import org.omg.CORBA.*;
25 import java.util.*;
26 /**
27  * This is the current object for the portable
28  * interceptors. It is merely a slot table, but
29  * can be bound to a thread scope.
30  *
31  * See PI Spec p. 6-55ff
32  *
33  * @author Nicolas Noffke
34  * @version $Id: PICurrentImpl.java,v 1.9 2004/05/06 12:40:00 nicolas Exp $
35  */

36
37 public class PICurrentImpl extends org.omg.CORBA.LocalObject JavaDoc
38   implements org.omg.PortableInterceptor.Current JavaDoc{
39
40   private Any[] m_slots = null;
41   private ORB m_orb = null;
42   
43   /**
44    * Create an empty current object.
45    * All slots will contain an empty Any.
46    */

47   public PICurrentImpl(ORB orb, int no_of_anys) {
48     m_orb = orb;
49     m_slots = new Any[no_of_anys];
50
51     for(int _i = 0; _i < m_slots.length; _i++)
52       m_slots[_i] = m_orb.create_any();
53   }
54
55   /**
56    * Make a deep copy of an existing PICurrent.
57    */

58   public PICurrentImpl(PICurrentImpl source){
59     m_orb = source.m_orb;
60     m_slots = new Any[source.m_slots.length];
61
62     for(int _i = 0; _i < m_slots.length; _i++){
63       m_slots[_i] = m_orb.create_any();
64       ((org.jacorb.orb.Any) m_slots[_i]).insert_object(source.m_slots[_i].type(),
65                           ((org.jacorb.orb.Any) source.m_slots[_i]).value());
66     }
67   }
68     
69   // implementation of org.omg.PortableInterceptor.CurrentOperations interface
70
public Any get_slot(int id) throws InvalidSlot {
71     if ((id >= m_slots.length) || (id < 0))
72       throw new InvalidSlot();
73     
74     return (Any) m_slots[id];
75   }
76   
77   public void set_slot(int id, Any data) throws InvalidSlot {
78     if ((id >= m_slots.length) || (id < 0))
79       throw new InvalidSlot();
80     
81     m_slots[id] = data;
82   }
83 } // PICurrentImpl
84

85
86
87
88
89
90
Popular Tags