001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.iiop.ejb;
023:
024: import javax.ejb.EJBException;
025:
026: import org.jboss.test.util.ejb.SessionSupport;
027: import org.jboss.test.iiop.interfaces.Boo;
028: import org.jboss.test.iiop.interfaces.Foo;
029: import org.jboss.test.iiop.interfaces.IdlInterface;
030: import org.jboss.test.iiop.interfaces.NegativeArgumentException;
031: import org.jboss.test.iiop.interfaces.StatelessSession;
032: import org.jboss.test.iiop.interfaces.Zoo;
033: import org.jboss.test.iiop.util.Util;
034:
035: /**
036: * @author reverbel@ime.usp.br
037: * @version $Revision: 57211 $
038: */
039: public class StatelessSessionBean extends SessionSupport {
040: public String getString() {
041: return Util.STRING;
042: }
043:
044: public String testPrimitiveTypes(boolean flag, char c, byte b,
045: short s, int i, long l, float f, double d) {
046: return Util.primitiveTypesToString(flag, c, b, s, i, l, f, d);
047: }
048:
049: public String testString(String s) {
050: return Util.echo(s);
051: }
052:
053: public StatelessSession testStatelessSession(String s,
054: StatelessSession t) {
055: return t;
056: }
057:
058: public java.rmi.Remote testRemote(String s, java.rmi.Remote t) {
059: return t;
060: }
061:
062: public Foo testSerializable(Foo foo) {
063: return Util.echoFoo(foo);
064: }
065:
066: public int[] testIntArray(int[] a) {
067: for (int i = 0; i < a.length; i++)
068: a[i]++;
069: return a;
070: }
071:
072: public Foo[] testValueArray(Foo[] a) {
073: for (int i = 0; i < a.length; i++)
074: a[i] = Util.echoFoo(a[i]);
075: return a;
076: }
077:
078: public String testException(int i) throws NegativeArgumentException {
079: if (i >= 0)
080: return "#" + i;
081: else
082: throw new NegativeArgumentException(i);
083: }
084:
085: public Object fooValueToObject(Foo foo) {
086: return Util.echoFoo(foo);
087: }
088:
089: public Object booValueToObject(Boo boo) {
090: return Util.echoBoo(boo);
091: }
092:
093: public java.util.Vector valueArrayToVector(Foo[] a) {
094: java.util.Vector v = new java.util.Vector();
095:
096: for (int i = 0; i < a.length; i++)
097: v.add(Util.echoFoo(a[i]));
098: return v;
099: }
100:
101: public Foo[] vectorToValueArray(java.util.Vector v) {
102: Foo a[] = new Foo[v.size()];
103:
104: for (int i = 0; i < a.length; i++)
105: a[i] = Util.echoFoo((Foo) v.elementAt(i));
106: return a;
107: }
108:
109: public Object getException() {
110: Object obj = null;
111: try {
112: NegativeArgumentException e = new NegativeArgumentException(
113: -7777);
114: throw e;
115: } catch (NegativeArgumentException e) {
116: obj = e;
117: }
118: return obj;
119: }
120:
121: public Object getZooValue() {
122: return new Zoo("outer_zoo", "returned by getZooValue", new Zoo(
123: "inner_zoo", "inner"));
124: }
125:
126: public Object[] testReferenceSharingWithinArray(Object[] a) {
127: int n = a.length;
128: Object[] b = new Object[2 * n];
129: for (int i = 0; i < n; i++)
130: b[i + n] = b[i] = a[i];
131: return b;
132: }
133:
134: public java.util.Collection testReferenceSharingWithinCollection(
135: java.util.Collection cin) {
136: java.util.Collection cout = new java.util.ArrayList(cin);
137: java.util.Iterator i = cin.iterator();
138: while (i.hasNext())
139: cout.add(i.next());
140: return cout;
141: }
142:
143: public org.omg.CORBA.Object testCorbaObject(org.omg.CORBA.Object obj) {
144: return obj;
145: }
146:
147: public IdlInterface testIdlInterface(IdlInterface ref) {
148: return ref;
149: }
150:
151: }
|