KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > iiop > ejb > StatelessSessionBean


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software 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 software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.iiop.ejb;
23
24 import javax.ejb.EJBException JavaDoc;
25
26 import org.jboss.test.util.ejb.SessionSupport;
27 import org.jboss.test.iiop.interfaces.Boo;
28 import org.jboss.test.iiop.interfaces.Foo;
29 import org.jboss.test.iiop.interfaces.IdlInterface;
30 import org.jboss.test.iiop.interfaces.NegativeArgumentException;
31 import org.jboss.test.iiop.interfaces.StatelessSession;
32 import org.jboss.test.iiop.interfaces.Zoo;
33 import org.jboss.test.iiop.util.Util;
34
35 /**
36  * @author reverbel@ime.usp.br
37  * @version $Revision: 37406 $
38  */

39 public class StatelessSessionBean
40    extends SessionSupport
41 {
42    public String JavaDoc getString()
43    {
44       return Util.STRING;
45    }
46    
47    public String JavaDoc testPrimitiveTypes(boolean flag, char c, byte b,
48                                     short s, int i, long l, float f, double d)
49    {
50       return Util.primitiveTypesToString(flag, c, b, s, i, l, f, d);
51    }
52    
53    public String JavaDoc testString(String JavaDoc s)
54    {
55       return Util.echo(s);
56    }
57    
58    public StatelessSession testStatelessSession(String JavaDoc s, StatelessSession t)
59    {
60       return t;
61    }
62    
63    public java.rmi.Remote JavaDoc testRemote(String JavaDoc s, java.rmi.Remote JavaDoc t)
64    {
65       return t;
66    }
67    
68    public Foo testSerializable(Foo foo)
69    {
70       return Util.echoFoo(foo);
71    }
72    
73    public int[] testIntArray(int[] a)
74    {
75       for (int i = 0; i < a.length; i++)
76          a[i]++;
77       return a;
78    }
79    
80    public Foo[] testValueArray(Foo[] a)
81    {
82       for (int i = 0; i < a.length; i++)
83          a[i] = Util.echoFoo(a[i]);
84       return a;
85    }
86    
87    public String JavaDoc testException(int i)
88       throws NegativeArgumentException
89    {
90       if (i >= 0)
91          return "#" + i;
92       else
93          throw new NegativeArgumentException(i);
94    }
95    
96    public Object JavaDoc fooValueToObject(Foo foo)
97    {
98       return Util.echoFoo(foo);
99    }
100    
101    public Object JavaDoc booValueToObject(Boo boo)
102    {
103       return Util.echoBoo(boo);
104    }
105    
106    public java.util.Vector JavaDoc valueArrayToVector(Foo[] a)
107    {
108       java.util.Vector JavaDoc v = new java.util.Vector JavaDoc();
109       
110       for (int i = 0; i < a.length; i++)
111          v.add(Util.echoFoo(a[i]));
112       return v;
113    }
114    
115    public Foo[] vectorToValueArray(java.util.Vector JavaDoc v)
116    {
117       Foo a[] = new Foo[v.size()];
118       
119       for (int i = 0; i < a.length; i++)
120          a[i] = Util.echoFoo((Foo)v.elementAt(i));
121       return a;
122    }
123    
124    public Object JavaDoc getException()
125    {
126       Object JavaDoc obj = null;
127       try
128          {
129             NegativeArgumentException e = new NegativeArgumentException(-7777);
130             throw e;
131          }
132       catch (NegativeArgumentException e)
133          {
134             obj = e;
135          }
136       return obj;
137    }
138    
139    public Object JavaDoc getZooValue()
140    {
141       return new Zoo("outer_zoo",
142                      "returned by getZooValue",
143                      new Zoo("inner_zoo", "inner"));
144    }
145    
146    public Object JavaDoc[] testReferenceSharingWithinArray(Object JavaDoc[] a)
147    {
148       int n = a.length;
149       Object JavaDoc[] b = new Object JavaDoc[2 * n];
150       for (int i = 0; i < n; i++)
151          b[i + n] = b[i] = a[i];
152       return b;
153    }
154    
155    public java.util.Collection JavaDoc testReferenceSharingWithinCollection(
156                                                       java.util.Collection JavaDoc cin)
157    {
158       java.util.Collection JavaDoc cout = new java.util.ArrayList JavaDoc(cin);
159       java.util.Iterator JavaDoc i = cin.iterator();
160       while (i.hasNext())
161          cout.add(i.next());
162       return cout;
163    }
164    
165    public org.omg.CORBA.Object JavaDoc testCorbaObject(org.omg.CORBA.Object JavaDoc obj)
166    {
167       return obj;
168    }
169
170    public IdlInterface testIdlInterface(IdlInterface ref)
171    {
172       return ref;
173    }
174
175 }
176
Popular Tags