excercise 2 done

This commit is contained in:
2025-12-12 22:48:54 +01:00
parent a60e3de86a
commit 27259a12e0
123 changed files with 2946 additions and 1 deletions

Binary file not shown.

View File

@@ -0,0 +1,53 @@
// task 2.
// module
module GraphicsApp
{
// forward declaration of shape.
// because we use it in rectangle
interface GraphicalObject;
typedef sequence<GraphicalObject> ObjectSequence;
// rectangle contains shapes which GraphicalObjects a
interface Rectangle
{
// exception to be thrown if index out of range
exception IndexOutOfBounds {};
// hopping this will be an array of Graphical-objects.
attribute ObjectSequence objects;
// function to add object
void addObject(in GraphicalObject newShape);
// and may be remove an object from a position?
void removeObjectAtPosition(in unsigned long index)
raises (IndexOutOfBounds);
};
interface Shape
{
// draw to be overriden in java
void draw();
// and info
void showInfo();
};
// GraphicalShape object extends Shape
interface GraphicalObject : Shape
{
// unqualified member
attribute boolean is_filled;
// we cannot set this, so only getter will be implemented.
// only time a shape can change is if it's in the matrix or if Dr.Strange is in town.
readonly attribute string name;
};
};

View File

@@ -0,0 +1,15 @@
package GraphicsApp;
/**
* GraphicsApp/GraphicalObject.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// GraphicalShape object extends Shape
public interface GraphicalObject extends GraphicalObjectOperations, GraphicsApp.Shape, org.omg.CORBA.portable.IDLEntity
{
} // interface GraphicalObject

View File

@@ -0,0 +1,87 @@
package GraphicsApp;
/**
* GraphicsApp/GraphicalObjectHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// GraphicalShape object extends Shape
abstract public class GraphicalObjectHelper
{
private static String _id = "IDL:GraphicsApp/GraphicalObject:1.0";
public static void insert (org.omg.CORBA.Any a, GraphicsApp.GraphicalObject 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 GraphicsApp.GraphicalObject 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 (GraphicsApp.GraphicalObjectHelper.id (), "GraphicalObject");
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static GraphicsApp.GraphicalObject read (org.omg.CORBA.portable.InputStream istream)
{
return narrow (istream.read_Object (_GraphicalObjectStub.class));
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, GraphicsApp.GraphicalObject value)
{
ostream.write_Object ((org.omg.CORBA.Object) value);
}
public static GraphicsApp.GraphicalObject narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof GraphicsApp.GraphicalObject)
return (GraphicsApp.GraphicalObject)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 ();
GraphicsApp._GraphicalObjectStub stub = new GraphicsApp._GraphicalObjectStub ();
stub._set_delegate(delegate);
return stub;
}
}
public static GraphicsApp.GraphicalObject unchecked_narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof GraphicsApp.GraphicalObject)
return (GraphicsApp.GraphicalObject)obj;
else
{
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
GraphicsApp._GraphicalObjectStub stub = new GraphicsApp._GraphicalObjectStub ();
stub._set_delegate(delegate);
return stub;
}
}
}

View File

@@ -0,0 +1,40 @@
package GraphicsApp;
/**
* GraphicsApp/GraphicalObjectHolder.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// GraphicalShape object extends Shape
public final class GraphicalObjectHolder implements org.omg.CORBA.portable.Streamable
{
public GraphicsApp.GraphicalObject value = null;
public GraphicalObjectHolder ()
{
}
public GraphicalObjectHolder (GraphicsApp.GraphicalObject initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = GraphicsApp.GraphicalObjectHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
GraphicsApp.GraphicalObjectHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return GraphicsApp.GraphicalObjectHelper.type ();
}
}

View File

@@ -0,0 +1,24 @@
package GraphicsApp;
/**
* GraphicsApp/GraphicalObjectOperations.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// GraphicalShape object extends Shape
public interface GraphicalObjectOperations extends GraphicsApp.ShapeOperations
{
// unqualified member
boolean is_filled ();
// unqualified member
void is_filled (boolean newIs_filled);
// only time a shape can change is if it's in the matrix or if Dr.Strange is in town.
String name ();
} // interface GraphicalObjectOperations

View File

@@ -0,0 +1,120 @@
package GraphicsApp;
/**
* GraphicsApp/GraphicalObjectPOA.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// GraphicalShape object extends Shape
public abstract class GraphicalObjectPOA extends org.omg.PortableServer.Servant
implements GraphicsApp.GraphicalObjectOperations, org.omg.CORBA.portable.InvokeHandler
{
// Constructors
private static java.util.Hashtable _methods = new java.util.Hashtable ();
static
{
_methods.put ("_get_is_filled", new java.lang.Integer (0));
_methods.put ("_set_is_filled", new java.lang.Integer (1));
_methods.put ("_get_name", new java.lang.Integer (2));
_methods.put ("draw", new java.lang.Integer (3));
_methods.put ("showInfo", 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 ())
{
// unqualified member
case 0: // GraphicsApp/GraphicalObject/_get_is_filled
{
boolean $result = false;
$result = this.is_filled ();
out = $rh.createReply();
out.write_boolean ($result);
break;
}
// unqualified member
case 1: // GraphicsApp/GraphicalObject/_set_is_filled
{
boolean newIs_filled = in.read_boolean ();
this.is_filled (newIs_filled);
out = $rh.createReply();
break;
}
// only time a shape can change is if it's in the matrix or if Dr.Strange is in town.
case 2: // GraphicsApp/GraphicalObject/_get_name
{
String $result = null;
$result = this.name ();
out = $rh.createReply();
out.write_string ($result);
break;
}
// draw to be overriden in java
case 3: // GraphicsApp/Shape/draw
{
this.draw ();
out = $rh.createReply();
break;
}
// and info
case 4: // GraphicsApp/Shape/showInfo
{
this.showInfo ();
out = $rh.createReply();
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:GraphicsApp/GraphicalObject:1.0",
"IDL:GraphicsApp/Shape:1.0"};
public String[] _all_interfaces (org.omg.PortableServer.POA poa, byte[] objectId)
{
return (String[])__ids.clone ();
}
public GraphicalObject _this()
{
return GraphicalObjectHelper.narrow(
super._this_object());
}
public GraphicalObject _this(org.omg.CORBA.ORB orb)
{
return GraphicalObjectHelper.narrow(
super._this_object(orb));
}
} // class GraphicalObjectPOA

View File

@@ -0,0 +1,62 @@
package GraphicsApp;
/**
* GraphicsApp/ObjectSequenceHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
abstract public class ObjectSequenceHelper
{
private static String _id = "IDL:GraphicsApp/ObjectSequence:1.0";
public static void insert (org.omg.CORBA.Any a, GraphicsApp.GraphicalObject[] 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 GraphicsApp.GraphicalObject[] 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 = GraphicsApp.GraphicalObjectHelper.type ();
__typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
__typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (GraphicsApp.ObjectSequenceHelper.id (), "ObjectSequence", __typeCode);
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static GraphicsApp.GraphicalObject[] read (org.omg.CORBA.portable.InputStream istream)
{
GraphicsApp.GraphicalObject value[] = null;
int _len0 = istream.read_long ();
value = new GraphicsApp.GraphicalObject[_len0];
for (int _o1 = 0;_o1 < value.length; ++_o1)
value[_o1] = GraphicsApp.GraphicalObjectHelper.read (istream);
return value;
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, GraphicsApp.GraphicalObject[] value)
{
ostream.write_long (value.length);
for (int _i0 = 0;_i0 < value.length; ++_i0)
GraphicsApp.GraphicalObjectHelper.write (ostream, value[_i0]);
}
}

View File

@@ -0,0 +1,39 @@
package GraphicsApp;
/**
* GraphicsApp/ObjectSequenceHolder.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
public final class ObjectSequenceHolder implements org.omg.CORBA.portable.Streamable
{
public GraphicsApp.GraphicalObject value[] = null;
public ObjectSequenceHolder ()
{
}
public ObjectSequenceHolder (GraphicsApp.GraphicalObject[] initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = GraphicsApp.ObjectSequenceHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
GraphicsApp.ObjectSequenceHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return GraphicsApp.ObjectSequenceHelper.type ();
}
}

Binary file not shown.

View File

@@ -0,0 +1,15 @@
package GraphicsApp;
/**
* GraphicsApp/Rectangle.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// rectangle contains shapes which GraphicalObjects a
public interface Rectangle extends RectangleOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
{
} // interface Rectangle

View File

@@ -0,0 +1,87 @@
package GraphicsApp;
/**
* GraphicsApp/RectangleHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// rectangle contains shapes which GraphicalObjects a
abstract public class RectangleHelper
{
private static String _id = "IDL:GraphicsApp/Rectangle:1.0";
public static void insert (org.omg.CORBA.Any a, GraphicsApp.Rectangle 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 GraphicsApp.Rectangle 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 (GraphicsApp.RectangleHelper.id (), "Rectangle");
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static GraphicsApp.Rectangle read (org.omg.CORBA.portable.InputStream istream)
{
return narrow (istream.read_Object (_RectangleStub.class));
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, GraphicsApp.Rectangle value)
{
ostream.write_Object ((org.omg.CORBA.Object) value);
}
public static GraphicsApp.Rectangle narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof GraphicsApp.Rectangle)
return (GraphicsApp.Rectangle)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 ();
GraphicsApp._RectangleStub stub = new GraphicsApp._RectangleStub ();
stub._set_delegate(delegate);
return stub;
}
}
public static GraphicsApp.Rectangle unchecked_narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof GraphicsApp.Rectangle)
return (GraphicsApp.Rectangle)obj;
else
{
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
GraphicsApp._RectangleStub stub = new GraphicsApp._RectangleStub ();
stub._set_delegate(delegate);
return stub;
}
}
}

View File

@@ -0,0 +1,40 @@
package GraphicsApp;
/**
* GraphicsApp/RectangleHolder.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// rectangle contains shapes which GraphicalObjects a
public final class RectangleHolder implements org.omg.CORBA.portable.Streamable
{
public GraphicsApp.Rectangle value = null;
public RectangleHolder ()
{
}
public RectangleHolder (GraphicsApp.Rectangle initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = GraphicsApp.RectangleHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
GraphicsApp.RectangleHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return GraphicsApp.RectangleHelper.type ();
}
}

View File

@@ -0,0 +1,27 @@
package GraphicsApp;
/**
* GraphicsApp/RectangleOperations.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// rectangle contains shapes which GraphicalObjects a
public interface RectangleOperations
{
// hopping this will be an array of shapes.
GraphicsApp.GraphicalObject[] objects ();
// hopping this will be an array of shapes.
void objects (GraphicsApp.GraphicalObject[] newObjects);
// function to add shape
void addObject (GraphicsApp.GraphicalObject newShape);
// and may be remove a shape from a position?
void removeObjectAtPosition (int index) throws GraphicsApp.RectanglePackage.IndexOutOfBounds;
} // interface RectangleOperations

View File

@@ -0,0 +1,114 @@
package GraphicsApp;
/**
* GraphicsApp/RectanglePOA.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// rectangle contains shapes which GraphicalObjects a
public abstract class RectanglePOA extends org.omg.PortableServer.Servant
implements GraphicsApp.RectangleOperations, org.omg.CORBA.portable.InvokeHandler
{
// Constructors
private static java.util.Hashtable _methods = new java.util.Hashtable ();
static
{
_methods.put ("_get_objects", new java.lang.Integer (0));
_methods.put ("_set_objects", new java.lang.Integer (1));
_methods.put ("addObject", new java.lang.Integer (2));
_methods.put ("removeObjectAtPosition", new java.lang.Integer (3));
}
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 ())
{
// hopping this will be an array of shapes.
case 0: // GraphicsApp/Rectangle/_get_objects
{
GraphicsApp.GraphicalObject $result[] = null;
$result = this.objects ();
out = $rh.createReply();
GraphicsApp.ObjectSequenceHelper.write (out, $result);
break;
}
// hopping this will be an array of shapes.
case 1: // GraphicsApp/Rectangle/_set_objects
{
GraphicsApp.GraphicalObject newObjects[] = GraphicsApp.ObjectSequenceHelper.read (in);
this.objects (newObjects);
out = $rh.createReply();
break;
}
// function to add shape
case 2: // GraphicsApp/Rectangle/addObject
{
GraphicsApp.GraphicalObject newShape = GraphicsApp.GraphicalObjectHelper.read (in);
this.addObject (newShape);
out = $rh.createReply();
break;
}
// and may be remove a shape from a position?
case 3: // GraphicsApp/Rectangle/removeObjectAtPosition
{
try {
int index = in.read_ulong ();
this.removeObjectAtPosition (index);
out = $rh.createReply();
} catch (GraphicsApp.RectanglePackage.IndexOutOfBounds $ex) {
out = $rh.createExceptionReply ();
GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.write (out, $ex);
}
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:GraphicsApp/Rectangle:1.0"};
public String[] _all_interfaces (org.omg.PortableServer.POA poa, byte[] objectId)
{
return (String[])__ids.clone ();
}
public Rectangle _this()
{
return RectangleHelper.narrow(
super._this_object());
}
public Rectangle _this(org.omg.CORBA.ORB orb)
{
return RectangleHelper.narrow(
super._this_object(orb));
}
} // class RectanglePOA

View File

@@ -0,0 +1,25 @@
package GraphicsApp.RectanglePackage;
/**
* GraphicsApp/RectanglePackage/IndexOutOfBounds.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
public final class IndexOutOfBounds extends org.omg.CORBA.UserException
{
public IndexOutOfBounds ()
{
super(IndexOutOfBoundsHelper.id());
} // ctor
public IndexOutOfBounds (String $reason)
{
super(IndexOutOfBoundsHelper.id() + " " + $reason);
} // ctor
} // class IndexOutOfBounds

View File

@@ -0,0 +1,72 @@
package GraphicsApp.RectanglePackage;
/**
* GraphicsApp/RectanglePackage/IndexOutOfBoundsHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
abstract public class IndexOutOfBoundsHelper
{
private static String _id = "IDL:GraphicsApp/Rectangle/IndexOutOfBounds:1.0";
public static void insert (org.omg.CORBA.Any a, GraphicsApp.RectanglePackage.IndexOutOfBounds 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 GraphicsApp.RectanglePackage.IndexOutOfBounds extract (org.omg.CORBA.Any a)
{
return read (a.create_input_stream ());
}
private static org.omg.CORBA.TypeCode __typeCode = null;
private static boolean __active = false;
synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
synchronized (org.omg.CORBA.TypeCode.class)
{
if (__typeCode == null)
{
if (__active)
{
return org.omg.CORBA.ORB.init().create_recursive_tc ( _id );
}
__active = true;
org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [0];
org.omg.CORBA.TypeCode _tcOf_members0 = null;
__typeCode = org.omg.CORBA.ORB.init ().create_exception_tc (GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.id (), "IndexOutOfBounds", _members0);
__active = false;
}
}
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static GraphicsApp.RectanglePackage.IndexOutOfBounds read (org.omg.CORBA.portable.InputStream istream)
{
GraphicsApp.RectanglePackage.IndexOutOfBounds value = new GraphicsApp.RectanglePackage.IndexOutOfBounds ();
// read and discard the repository ID
istream.read_string ();
return value;
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, GraphicsApp.RectanglePackage.IndexOutOfBounds value)
{
// write the repository ID
ostream.write_string (id ());
}
}

View File

@@ -0,0 +1,38 @@
package GraphicsApp.RectanglePackage;
/**
* GraphicsApp/RectanglePackage/IndexOutOfBoundsHolder.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
public final class IndexOutOfBoundsHolder implements org.omg.CORBA.portable.Streamable
{
public GraphicsApp.RectanglePackage.IndexOutOfBounds value = null;
public IndexOutOfBoundsHolder ()
{
}
public IndexOutOfBoundsHolder (GraphicsApp.RectanglePackage.IndexOutOfBounds initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.type ();
}
}

Binary file not shown.

View File

@@ -0,0 +1,13 @@
package GraphicsApp;
/**
* GraphicsApp/Shape.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
public interface Shape extends ShapeOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
{
} // interface Shape

Binary file not shown.

View File

@@ -0,0 +1,85 @@
package GraphicsApp;
/**
* GraphicsApp/ShapeHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
abstract public class ShapeHelper
{
private static String _id = "IDL:GraphicsApp/Shape:1.0";
public static void insert (org.omg.CORBA.Any a, GraphicsApp.Shape 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 GraphicsApp.Shape 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 (GraphicsApp.ShapeHelper.id (), "Shape");
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static GraphicsApp.Shape read (org.omg.CORBA.portable.InputStream istream)
{
return narrow (istream.read_Object (_ShapeStub.class));
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, GraphicsApp.Shape value)
{
ostream.write_Object ((org.omg.CORBA.Object) value);
}
public static GraphicsApp.Shape narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof GraphicsApp.Shape)
return (GraphicsApp.Shape)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 ();
GraphicsApp._ShapeStub stub = new GraphicsApp._ShapeStub ();
stub._set_delegate(delegate);
return stub;
}
}
public static GraphicsApp.Shape unchecked_narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof GraphicsApp.Shape)
return (GraphicsApp.Shape)obj;
else
{
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
GraphicsApp._ShapeStub stub = new GraphicsApp._ShapeStub ();
stub._set_delegate(delegate);
return stub;
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,38 @@
package GraphicsApp;
/**
* GraphicsApp/ShapeHolder.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
public final class ShapeHolder implements org.omg.CORBA.portable.Streamable
{
public GraphicsApp.Shape value = null;
public ShapeHolder ()
{
}
public ShapeHolder (GraphicsApp.Shape initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = GraphicsApp.ShapeHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
GraphicsApp.ShapeHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return GraphicsApp.ShapeHelper.type ();
}
}

View File

@@ -0,0 +1,19 @@
package GraphicsApp;
/**
* GraphicsApp/ShapeOperations.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
public interface ShapeOperations
{
// draw to be overriden in java
void draw ();
// and info
void showInfo ();
} // interface ShapeOperations

Binary file not shown.

View File

@@ -0,0 +1,82 @@
package GraphicsApp;
/**
* GraphicsApp/ShapePOA.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
public abstract class ShapePOA extends org.omg.PortableServer.Servant
implements GraphicsApp.ShapeOperations, org.omg.CORBA.portable.InvokeHandler
{
// Constructors
private static java.util.Hashtable _methods = new java.util.Hashtable ();
static
{
_methods.put ("draw", new java.lang.Integer (0));
_methods.put ("showInfo", new java.lang.Integer (1));
}
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 ())
{
// draw to be overriden in java
case 0: // GraphicsApp/Shape/draw
{
this.draw ();
out = $rh.createReply();
break;
}
// and info
case 1: // GraphicsApp/Shape/showInfo
{
this.showInfo ();
out = $rh.createReply();
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:GraphicsApp/Shape:1.0"};
public String[] _all_interfaces (org.omg.PortableServer.POA poa, byte[] objectId)
{
return (String[])__ids.clone ();
}
public Shape _this()
{
return ShapeHelper.narrow(
super._this_object());
}
public Shape _this(org.omg.CORBA.ORB orb)
{
return ShapeHelper.narrow(
super._this_object(orb));
}
} // class ShapePOA

View File

@@ -0,0 +1,157 @@
package GraphicsApp;
/**
* GraphicsApp/_GraphicalObjectStub.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// GraphicalShape object extends Shape
public class _GraphicalObjectStub extends org.omg.CORBA.portable.ObjectImpl implements GraphicsApp.GraphicalObject
{
// unqualified member
public boolean is_filled ()
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("_get_is_filled", true);
$in = _invoke ($out);
boolean $result = $in.read_boolean ();
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 is_filled ( );
} finally {
_releaseReply ($in);
}
} // is_filled
// unqualified member
public void is_filled (boolean newIs_filled)
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("_set_is_filled", true);
$out.write_boolean (newIs_filled);
$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) {
is_filled (newIs_filled );
} finally {
_releaseReply ($in);
}
} // is_filled
// only time a shape can change is if it's in the matrix or if Dr.Strange is in town.
public String name ()
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("_get_name", 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 name ( );
} finally {
_releaseReply ($in);
}
} // name
// draw to be overriden in java
public void draw ()
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("draw", true);
$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) {
draw ( );
} finally {
_releaseReply ($in);
}
} // draw
// and info
public void showInfo ()
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("showInfo", true);
$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) {
showInfo ( );
} finally {
_releaseReply ($in);
}
} // showInfo
// Type-specific CORBA::Object operations
private static String[] __ids = {
"IDL:GraphicsApp/GraphicalObject:1.0",
"IDL:GraphicsApp/Shape:1.0"};
public String[] _ids ()
{
return (String[])__ids.clone ();
}
private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
{
String str = s.readUTF ();
com.sun.corba.se.impl.orbutil.IORCheckImpl.check(str, "GraphicsApp._GraphicalObjectStub");
String[] args = null;
java.util.Properties props = null;
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);
try {
org.omg.CORBA.Object obj = orb.string_to_object (str);
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
_set_delegate (delegate);
} finally {
orb.destroy() ;
}
}
private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
{
String[] args = null;
java.util.Properties props = null;
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);
try {
String str = orb.object_to_string (this);
s.writeUTF (str);
} finally {
orb.destroy() ;
}
}
} // class _GraphicalObjectStub

View File

@@ -0,0 +1,140 @@
package GraphicsApp;
/**
* GraphicsApp/_RectangleStub.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
// rectangle contains shapes which GraphicalObjects a
public class _RectangleStub extends org.omg.CORBA.portable.ObjectImpl implements GraphicsApp.Rectangle
{
// hopping this will be an array of shapes.
public GraphicsApp.GraphicalObject[] objects ()
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("_get_objects", true);
$in = _invoke ($out);
GraphicsApp.GraphicalObject $result[] = GraphicsApp.ObjectSequenceHelper.read ($in);
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 objects ( );
} finally {
_releaseReply ($in);
}
} // objects
// hopping this will be an array of shapes.
public void objects (GraphicsApp.GraphicalObject[] newObjects)
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("_set_objects", true);
GraphicsApp.ObjectSequenceHelper.write ($out, newObjects);
$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) {
objects (newObjects );
} finally {
_releaseReply ($in);
}
} // objects
// function to add shape
public void addObject (GraphicsApp.GraphicalObject newShape)
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("addObject", true);
GraphicsApp.GraphicalObjectHelper.write ($out, newShape);
$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) {
addObject (newShape );
} finally {
_releaseReply ($in);
}
} // addObject
// and may be remove a shape from a position?
public void removeObjectAtPosition (int index) throws GraphicsApp.RectanglePackage.IndexOutOfBounds
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("removeObjectAtPosition", true);
$out.write_ulong (index);
$in = _invoke ($out);
return;
} catch (org.omg.CORBA.portable.ApplicationException $ex) {
$in = $ex.getInputStream ();
String _id = $ex.getId ();
if (_id.equals ("IDL:GraphicsApp/Rectangle/IndexOutOfBounds:1.0"))
throw GraphicsApp.RectanglePackage.IndexOutOfBoundsHelper.read ($in);
else
throw new org.omg.CORBA.MARSHAL (_id);
} catch (org.omg.CORBA.portable.RemarshalException $rm) {
removeObjectAtPosition (index );
} finally {
_releaseReply ($in);
}
} // removeObjectAtPosition
// Type-specific CORBA::Object operations
private static String[] __ids = {
"IDL:GraphicsApp/Rectangle:1.0"};
public String[] _ids ()
{
return (String[])__ids.clone ();
}
private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
{
String str = s.readUTF ();
com.sun.corba.se.impl.orbutil.IORCheckImpl.check(str, "GraphicsApp._RectangleStub");
String[] args = null;
java.util.Properties props = null;
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);
try {
org.omg.CORBA.Object obj = orb.string_to_object (str);
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
_set_delegate (delegate);
} finally {
orb.destroy() ;
}
}
private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
{
String[] args = null;
java.util.Properties props = null;
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);
try {
String str = orb.object_to_string (this);
s.writeUTF (str);
} finally {
orb.destroy() ;
}
}
} // class _RectangleStub

Binary file not shown.

View File

@@ -0,0 +1,91 @@
package GraphicsApp;
/**
* GraphicsApp/_ShapeStub.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from Graphics.idl
* Tuesday, November 11, 2025 6:46:29 PM CET
*/
public class _ShapeStub extends org.omg.CORBA.portable.ObjectImpl implements GraphicsApp.Shape
{
// draw to be overriden in java
public void draw ()
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("draw", true);
$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) {
draw ( );
} finally {
_releaseReply ($in);
}
} // draw
// and info
public void showInfo ()
{
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("showInfo", true);
$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) {
showInfo ( );
} finally {
_releaseReply ($in);
}
} // showInfo
// Type-specific CORBA::Object operations
private static String[] __ids = {
"IDL:GraphicsApp/Shape:1.0"};
public String[] _ids ()
{
return (String[])__ids.clone ();
}
private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
{
String str = s.readUTF ();
com.sun.corba.se.impl.orbutil.IORCheckImpl.check(str, "GraphicsApp._ShapeStub");
String[] args = null;
java.util.Properties props = null;
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);
try {
org.omg.CORBA.Object obj = orb.string_to_object (str);
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
_set_delegate (delegate);
} finally {
orb.destroy() ;
}
}
private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
{
String[] args = null;
java.util.Properties props = null;
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);
try {
String str = orb.object_to_string (this);
s.writeUTF (str);
} finally {
orb.destroy() ;
}
}
} // class _ShapeStub

Binary file not shown.

View File

@@ -0,0 +1,98 @@
// Copyright and License
import GraphicsApp.*;
import org.omg.CosNaming.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
// because we need GraphicalObject we have to do an implementation of it here.
// reversing the HelloServer.java here
class Graph extends GraphicalObjectPOA {
private boolean filled;
private String name;
private ORB orb;
public Graph(String name, boolean filled) {
this.name = name;
this.filled = filled;
}
public void setORB(ORB orb_val) {
this.orb = orb_val;
}
// draw
public void draw() {
System.out.println("Drawing graph: " + name);
}
// show info
public void showInfo() {
System.out.println("Graph Info -> Name: " + name + ", Filled: " + filled);
}
// getter for is filled
public boolean is_filled() {
return filled;
}
// setter for is filled
public void is_filled(boolean value) {
this.filled = value;
}
// name getter, not setting it.
public String name() {
return name;
}
}
public class GraphicsClient
{
static Rectangle rect;
public static void main(String args[])
{
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get reference to rootpoa and activate the POAManager
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
// reversing steps from HelloServer here as well.
// create servant and register it with the ORB
Graph graph = new Graph("Circle", true);
graph.setORB(orb);
// get object reference from the servant
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(graph);
GraphicalObject object = GraphicalObjectHelper.narrow(ref);
// get the root naming context
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
// Use NamingContextExt instead of NamingContext. This is
// part of the Interoperable naming Service.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// resolve the Object Reference in Naming
String name = "Graphics";
rect = RectangleHelper.narrow(ncRef.resolve_str(name));
System.out.println("Obtained a handle on server object: " + rect);
rect.addObject(object);
rect.removeObjectAtPosition(0);
} catch (Exception e) {
System.out.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,105 @@
// GraphicsServer.java
// I am not testing this server for fear of errors
// because if there are errors, I wont stop trying to debugg it untill tomorrow.
import GraphicsApp.*;
import org.omg.CosNaming.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
import java.util.*;
// overriding the rectangle Class.
// copying from the Hello Project, I believe we extend the RectanglePOA class
class Rect extends RectanglePOA {
private ORB orb;
private GraphicalObject[] objects;
public Rect() {
this.objects = new GraphicalObject[0];
}
public void setORB(ORB orb_val) {
this.orb = orb_val;
}
// getter
public GraphicalObject[] objects() {
return this.objects;
}
// setter
public void objects(GraphicalObject[] newObject) {
this.objects = newObject;
}
// add objects
public void addObject(GraphicalObject newObject) {
List<GraphicalObject> temp = new ArrayList<>(Arrays.asList(this.objects));
temp.add(newObject);
this.objects = temp.toArray(new GraphicalObject[0]);
}
// remove an object
public void removeObjectAtPosition(int index)
throws GraphicsApp.RectanglePackage.IndexOutOfBounds {
if (index < 0 || index >= this.objects.length) {
throw new GraphicsApp.RectanglePackage.IndexOutOfBounds();
}
List<GraphicalObject> temp = new ArrayList<>(Arrays.asList(this.objects));
temp.remove(index);
this.objects = temp.toArray(new GraphicalObject[0]);
}
}
public class GraphicsServer {
public static void main(String args[]) {
try{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get reference to rootpoa and activate the POAManager
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
// create servant and register it with the ORB
Rect rect = new Rect();
rect.setORB(orb);
// get object reference from the servant
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(rect);
Rectangle href = RectangleHelper.narrow(ref);
// get the root naming context
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
// Use NamingContextExt which is part of the Interoperable
// Naming Service (INS) specification.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// bind the Object Reference in Naming
String name = "Graphics";
NameComponent path[] = ncRef.to_name( name );
ncRef.rebind(path, href);
System.out.println("GraphicsServer ready and waiting ...");
// wait for invocations from clients
orb.run();
}
catch (Exception e) {
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
System.out.println("GraphicsServer Exiting ...");
}
}

Binary file not shown.