--- /dev/null
+interface ejemplo{
+ //atributos
+ readonly attribute long entero;
+ attribute string cadena;
+
+ //operaciones
+ oneway void operacion1(in long numero);
+ string operacion2(in string nombre);
+};
--- /dev/null
+IOR:000000000000001049444c3a656a656d706c6f3a312e3000000000010000000000000082000102000000000a3132372e302e302e31008f3700000031afabcb00000000206830646600000001000000000000000100000008526f6f74504f410000000008000000010000000014000000000000020000000100000020000000000001000100000002050100010001002000010109000000010001010000000026000000020002
--- /dev/null
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.LineNumberReader;
+
+import org.omg.CORBA.*;
+
+public class Cliente {
+
+ /**
+ * @param args
+ * @throws IOException
+ */
+ public static void main(String[] args) throws IOException {
+ ORB orb = ORB.init(args, null);
+
+ LineNumberReader input = new LineNumberReader(new FileReader("server.ior"));
+ String ior = input.readLine();
+
+ org.omg.CORBA.Object obj = orb.string_to_object(ior);
+
+ ejemplo ej = ejemploHelper.narrow(obj);
+
+
+ //usando el objecto ej
+ ej.operacion1(3);
+ System.out.println(ej.operacion2(" cadena "));
+ System.out.println(ej.entero());
+
+
+ }
+
+}
--- /dev/null
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+
+import org.omg.CORBA.*;
+import org.omg.CORBA.ORBPackage.InvalidName;
+import org.omg.PortableServer.*;
+import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
+import org.omg.PortableServer.POAPackage.ServantNotActive;
+import org.omg.PortableServer.POAPackage.WrongPolicy;
+
+public class Servidor {
+
+ /**
+ * @param args
+ * @throws InvalidName
+ * @throws AdapterInactive
+ * @throws WrongPolicy
+ * @throws ServantNotActive
+ * @throws FileNotFoundException
+ */
+ public static void main(String[] args) throws InvalidName, AdapterInactive, ServantNotActive, WrongPolicy, FileNotFoundException {
+ //inicializacion del orb
+ ORB orb = ORB.init(args, null);
+
+ //creacion del poa raiz
+ POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
+
+ //crear y activar sirvientes
+ poa.the_POAManager().activate();
+ ejemploImpl sirviente = new ejemploImpl();
+ org.omg.CORBA.Object obj = poa.servant_to_reference(sirviente);
+
+ String ior = orb.object_to_string(obj);
+ PrintWriter ps = new PrintWriter(new FileOutputStream(new File("server.ior")));
+ ps.println(ior);
+ ps.close();
+
+ orb.run();
+ }
+
+}
--- /dev/null
+
+/**
+* _ejemploStub.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from ejemplo.idl
+* domingo 8 de junio de 2008 13H38' CEST
+*/
+
+public class _ejemploStub extends org.omg.CORBA.portable.ObjectImpl implements ejemplo
+{
+
+
+ //atributos
+ public int entero ()
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("_get_entero", true);
+ $in = _invoke ($out);
+ int $result = $in.read_long ();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return entero ( );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // entero
+
+ public String cadena ()
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("_get_cadena", true);
+ $in = _invoke ($out);
+ String $result = $in.read_string ();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return cadena ( );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // cadena
+
+ public void cadena (String newCadena)
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("_set_cadena", true);
+ $out.write_string (newCadena);
+ $in = _invoke ($out);
+ return;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ cadena (newCadena );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // cadena
+
+
+ //operaciones
+ public void operacion1 (int numero)
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("operacion1", false);
+ $out.write_long (numero);
+ $in = _invoke ($out);
+ return;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ operacion1 (numero );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // operacion1
+
+ public String operacion2 (String nombre)
+ {
+ org.omg.CORBA.portable.InputStream $in = null;
+ try {
+ org.omg.CORBA.portable.OutputStream $out = _request ("operacion2", true);
+ $out.write_string (nombre);
+ $in = _invoke ($out);
+ String $result = $in.read_string ();
+ return $result;
+ } catch (org.omg.CORBA.portable.ApplicationException $ex) {
+ $in = $ex.getInputStream ();
+ String _id = $ex.getId ();
+ throw new org.omg.CORBA.MARSHAL (_id);
+ } catch (org.omg.CORBA.portable.RemarshalException $rm) {
+ return operacion2 (nombre );
+ } finally {
+ _releaseReply ($in);
+ }
+ } // operacion2
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {
+ "IDL:ejemplo:1.0"};
+
+ public String[] _ids ()
+ {
+ return (String[])__ids.clone ();
+ }
+
+ private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
+ {
+ String str = s.readUTF ();
+ String[] args = null;
+ java.util.Properties props = null;
+ org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str);
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
+ _set_delegate (delegate);
+ }
+
+ private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
+ {
+ String[] args = null;
+ java.util.Properties props = null;
+ String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this);
+ s.writeUTF (str);
+ }
+} // class _ejemploStub
--- /dev/null
+interface ejemplo{
+ //atributos
+ readonly attribute long entero;
+ attribute string cadena;
+
+ //operaciones
+ oneway void operacion1(in long numero);
+ string operacion2(in string nombre);
+};
--- /dev/null
+
+/**
+* ejemplo.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from ejemplo.idl
+* domingo 8 de junio de 2008 13H38' CEST
+*/
+
+public interface ejemplo extends ejemploOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
+{
+} // interface ejemplo
--- /dev/null
+
+/**
+* ejemploHelper.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from ejemplo.idl
+* domingo 8 de junio de 2008 13H38' CEST
+*/
+
+abstract public class ejemploHelper
+{
+ private static String _id = "IDL:ejemplo:1.0";
+
+ public static void insert (org.omg.CORBA.Any a, ejemplo that)
+ {
+ org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
+ a.type (type ());
+ write (out, that);
+ a.read_value (out.create_input_stream (), type ());
+ }
+
+ public static ejemplo extract (org.omg.CORBA.Any a)
+ {
+ return read (a.create_input_stream ());
+ }
+
+ private static org.omg.CORBA.TypeCode __typeCode = null;
+ synchronized public static org.omg.CORBA.TypeCode type ()
+ {
+ if (__typeCode == null)
+ {
+ __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (ejemploHelper.id (), "ejemplo");
+ }
+ return __typeCode;
+ }
+
+ public static String id ()
+ {
+ return _id;
+ }
+
+ public static ejemplo read (org.omg.CORBA.portable.InputStream istream)
+ {
+ return narrow (istream.read_Object (_ejemploStub.class));
+ }
+
+ public static void write (org.omg.CORBA.portable.OutputStream ostream, ejemplo value)
+ {
+ ostream.write_Object ((org.omg.CORBA.Object) value);
+ }
+
+ public static ejemplo narrow (org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof ejemplo)
+ return (ejemplo)obj;
+ else if (!obj._is_a (id ()))
+ throw new org.omg.CORBA.BAD_PARAM ();
+ else
+ {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
+ _ejemploStub stub = new _ejemploStub ();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+ public static ejemplo unchecked_narrow (org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof ejemplo)
+ return (ejemplo)obj;
+ else
+ {
+ org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
+ _ejemploStub stub = new _ejemploStub ();
+ stub._set_delegate(delegate);
+ return stub;
+ }
+ }
+
+}
--- /dev/null
+
+/**
+* ejemploHolder.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from ejemplo.idl
+* domingo 8 de junio de 2008 13H38' CEST
+*/
+
+public final class ejemploHolder implements org.omg.CORBA.portable.Streamable
+{
+ public ejemplo value = null;
+
+ public ejemploHolder ()
+ {
+ }
+
+ public ejemploHolder (ejemplo initialValue)
+ {
+ value = initialValue;
+ }
+
+ public void _read (org.omg.CORBA.portable.InputStream i)
+ {
+ value = ejemploHelper.read (i);
+ }
+
+ public void _write (org.omg.CORBA.portable.OutputStream o)
+ {
+ ejemploHelper.write (o, value);
+ }
+
+ public org.omg.CORBA.TypeCode _type ()
+ {
+ return ejemploHelper.type ();
+ }
+
+}
--- /dev/null
+
+public class ejemploImpl extends ejemploPOA {
+
+ private int entero=0;
+ private String cadena="ejemplo";
+
+ public ejemploImpl(){
+ super();
+ }
+
+ public String cadena() {
+ return cadena;
+ }
+
+ public void cadena(String newCadena) {
+ cadena = newCadena;
+
+ }
+
+ public int entero() {
+ return entero;
+ }
+
+ public void operacion1(int numero) {
+ entero += numero;
+ }
+
+ public String operacion2(String nombre) {
+ return cadena+nombre;
+ }
+
+}
--- /dev/null
+
+/**
+* ejemploOperations.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from ejemplo.idl
+* domingo 8 de junio de 2008 13H38' CEST
+*/
+
+public interface ejemploOperations
+{
+
+ //atributos
+ int entero ();
+ String cadena ();
+ void cadena (String newCadena);
+
+ //operaciones
+ void operacion1 (int numero);
+ String operacion2 (String nombre);
+} // interface ejemploOperations
--- /dev/null
+
+/**
+* ejemploPOA.java .
+* Generated by the IDL-to-Java compiler (portable), version "3.2"
+* from ejemplo.idl
+* domingo 8 de junio de 2008 13H38' CEST
+*/
+
+public abstract class ejemploPOA extends org.omg.PortableServer.Servant
+ implements ejemploOperations, org.omg.CORBA.portable.InvokeHandler
+{
+
+ // Constructors
+
+ private static java.util.Hashtable _methods = new java.util.Hashtable ();
+ static
+ {
+ _methods.put ("_get_entero", new java.lang.Integer (0));
+ _methods.put ("_get_cadena", new java.lang.Integer (1));
+ _methods.put ("_set_cadena", new java.lang.Integer (2));
+ _methods.put ("operacion1", new java.lang.Integer (3));
+ _methods.put ("operacion2", new java.lang.Integer (4));
+ }
+
+ public org.omg.CORBA.portable.OutputStream _invoke (String $method,
+ org.omg.CORBA.portable.InputStream in,
+ org.omg.CORBA.portable.ResponseHandler $rh)
+ {
+ org.omg.CORBA.portable.OutputStream out = null;
+ java.lang.Integer __method = (java.lang.Integer)_methods.get ($method);
+ if (__method == null)
+ throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+
+ switch (__method.intValue ())
+ {
+
+ //atributos
+ case 0: // ejemplo/_get_entero
+ {
+ int $result = (int)0;
+ $result = this.entero ();
+ out = $rh.createReply();
+ out.write_long ($result);
+ break;
+ }
+
+ case 1: // ejemplo/_get_cadena
+ {
+ String $result = null;
+ $result = this.cadena ();
+ out = $rh.createReply();
+ out.write_string ($result);
+ break;
+ }
+
+ case 2: // ejemplo/_set_cadena
+ {
+ String newCadena = in.read_string ();
+ this.cadena (newCadena);
+ out = $rh.createReply();
+ break;
+ }
+
+
+ //operaciones
+ case 3: // ejemplo/operacion1
+ {
+ int numero = in.read_long ();
+ this.operacion1 (numero);
+ out = $rh.createReply();
+ break;
+ }
+
+ case 4: // ejemplo/operacion2
+ {
+ String nombre = in.read_string ();
+ String $result = null;
+ $result = this.operacion2 (nombre);
+ out = $rh.createReply();
+ out.write_string ($result);
+ break;
+ }
+
+ default:
+ throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
+ }
+
+ return out;
+ } // _invoke
+
+ // Type-specific CORBA::Object operations
+ private static String[] __ids = {
+ "IDL:ejemplo:1.0"};
+
+ public String[] _all_interfaces (org.omg.PortableServer.POA poa, byte[] objectId)
+ {
+ return (String[])__ids.clone ();
+ }
+
+ public ejemplo _this()
+ {
+ return ejemploHelper.narrow(
+ super._this_object());
+ }
+
+ public ejemplo _this(org.omg.CORBA.ORB orb)
+ {
+ return ejemploHelper.narrow(
+ super._this_object(orb));
+ }
+
+
+} // class ejemploPOA