KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > orb > standardInterceptors > CodeSetInfoInterceptor


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.standardInterceptors;
22
23 import org.omg.PortableInterceptor.*;
24
25 import org.jacorb.orb.*;
26 import org.jacorb.orb.giop.CodeSet;
27
28 /**
29  * This interceptor creates a codeset TaggedComponent.
30  *
31  * @author Nicolas Noffke
32  * @version $Id: CodeSetInfoInterceptor.java,v 1.21 2004/12/20 11:35:22 simon.mcqueen Exp $
33  */

34
35 public class CodeSetInfoInterceptor
36     extends org.omg.CORBA.LocalObject JavaDoc
37     implements IORInterceptor
38 {
39     private org.omg.IOP.TaggedComponent JavaDoc tagc = null;
40
41     public CodeSetInfoInterceptor(ORB orb)
42     {
43         // create the info
44
org.omg.CONV_FRAME.CodeSetComponentInfo cs_info =
45             new org.omg.CONV_FRAME.CodeSetComponentInfo();
46
47         // fill the info
48
cs_info.ForCharData =
49             new org.omg.CONV_FRAME.
50                 CodeSetComponent( CodeSet.getTCSDefault(),
51                                   new int[] { CodeSet.getConversionDefault() } );
52
53         cs_info.ForWcharData =
54             new org.omg.CONV_FRAME.
55                 CodeSetComponent( CodeSet.getTCSWDefault(),
56                                   new int[] { CodeSet.UTF8 } );
57
58         // encapsulate it into TaggedComponent
59
CDROutputStream os = new CDROutputStream( orb );
60         os.beginEncapsulatedArray();
61         org.omg.CONV_FRAME.CodeSetComponentInfoHelper.write( os, cs_info );
62
63         tagc =
64             new org.omg.IOP.TaggedComponent JavaDoc( org.omg.IOP.TAG_CODE_SETS.value,
65                                              os.getBufferCopy());
66
67         os.close ();
68         os = null;
69         cs_info = null;
70     }
71
72     public String JavaDoc name()
73     {
74         return "CodeSetInfoComponentCreator";
75     }
76
77     public void destroy()
78     {
79     }
80
81     /**
82      * Creates default IOR codeset component.
83      */

84
85     public void establish_components( IORInfo info, int [] tags )
86     {
87         if (tags == null)
88             {
89                 info.add_ior_component_to_profile( tagc,
90                                                    org.omg.IOP.TAG_MULTIPLE_COMPONENTS.value );
91                 info.add_ior_component_to_profile( tagc,
92                                                    org.omg.IOP.TAG_INTERNET_IOP.value );
93             }
94         else
95             for (int i = 0; i < tags.length; i++)
96                 info.add_ior_component_to_profile(tagc, tags[i]);
97     }
98
99     public void establish_components( IORInfo info )
100     {
101         info.add_ior_component_to_profile( tagc,
102                                            org.omg.IOP.TAG_MULTIPLE_COMPONENTS.value );
103         info.add_ior_component_to_profile( tagc,
104                                            org.omg.IOP.TAG_INTERNET_IOP.value );
105     }
106 }
107
Popular Tags