summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/Application.java127
-rw-r--r--java/src/Ice/LocalException.java2
-rw-r--r--java/src/Ice/LocationForward.java22
-rw-r--r--java/src/Ice/Object.java161
-rw-r--r--java/src/Ice/UserException.java11
-rw-r--r--java/src/Ice/Util.java44
-rw-r--r--java/src/IceInternal/DispatchStatus.java57
-rw-r--r--java/src/IceInternal/Incoming.java50
8 files changed, 474 insertions, 0 deletions
diff --git a/java/src/Ice/Application.java b/java/src/Ice/Application.java
new file mode 100644
index 00000000000..a4f7cf93624
--- /dev/null
+++ b/java/src/Ice/Application.java
@@ -0,0 +1,127 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+package Ice;
+
+public class Application
+{
+ public
+ Application()
+ {
+ }
+
+ //
+ // This main() must be called by the global main(). main()
+ // initializes the Communicator, calls run(), and destroys
+ // the Communicator upon return from run(). It thereby handles
+ // all exceptions properly, i.e., error messages are printed
+ // if exceptions propagate to main(), and the Communicator is
+ // always destroyed, regardless of exceptions.
+ //
+ public final int
+ main(String appName, String[] args)
+ {
+ main(args, null);
+ }
+
+ public final int
+ main(String appName, String[] args, String configFile)
+ {
+ if (_communicator != null)
+ {
+ System.err.println(appName + ": only one instance of the "
+ "Application class can be used");
+ return 1;
+ }
+
+ _appName = appName;
+
+ int status = 0;
+
+ try
+ {
+ if (configFile != null)
+ {
+ Properties properties =
+ Util.createPropertiesFromFile(args, configFile);
+ _communicator = Util.initializeWithProperties(properties);
+ }
+ else
+ {
+ _communicator = Util.initialize(args);
+ }
+ status = run(args);
+ }
+ catch(LocalException ex)
+ {
+ System.err.println(_appName + ": " + ex);
+ ex.printStackTrace();
+ status = 1;
+ }
+ catch(Exception ex)
+ {
+ System.err.println(_appName + ": unknown exception");
+ ex.printStackTrace();
+ status = 1;
+ }
+
+ if (_communicator != null)
+ {
+ try
+ {
+ _communicator.destroy();
+ }
+ catch(LocalException ex)
+ {
+ System.err.println(_appName + ": " + ex);
+ ex.printStackTrace();
+ status = 1;
+ }
+ catch(Exception ex)
+ {
+ System.err.println(_appName + ": unknown exception");
+ ex.printStackTrace();
+ status = 1;
+ }
+ _communicator = null;
+ }
+
+ return status;
+ }
+
+ public abstract int
+ run(String[] args);
+
+ //
+ // Return the application name, i.e., argv[0].
+ //
+ public static String
+ appName()
+ {
+ return _appName;
+ }
+
+ //
+ // One limitation of this class is that there can only be one
+ // Application instance, with one global Communicator, accessible
+ // with this communicator() operation. This limitiation is due to
+ // how the signal handling functions below operate. If you require
+ // multiple Communicators, then you cannot use this Application
+ // framework class.
+ //
+ public static Communicator
+ communicator()
+ {
+ return _communicator;
+ }
+
+ private static String _appName;
+ private static Communicator _communicator;
+}
diff --git a/java/src/Ice/LocalException.java b/java/src/Ice/LocalException.java
index 44813f7d974..c106f424749 100644
--- a/java/src/Ice/LocalException.java
+++ b/java/src/Ice/LocalException.java
@@ -12,4 +12,6 @@ package Ice;
public abstract class LocalException extends RuntimeException
{
+ public abstract String
+ _name();
}
diff --git a/java/src/Ice/LocationForward.java b/java/src/Ice/LocationForward.java
new file mode 100644
index 00000000000..4fc5e6e5313
--- /dev/null
+++ b/java/src/Ice/LocationForward.java
@@ -0,0 +1,22 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+package Ice;
+
+public class LocationForward extends Exception
+{
+ public
+ LocationForward(ObjectPrx prx)
+ {
+ _prx = prx;
+ }
+
+ public ObjectPrx _prx;
+}
diff --git a/java/src/Ice/Object.java b/java/src/Ice/Object.java
index 0c94099a875..0adf62c847e 100644
--- a/java/src/Ice/Object.java
+++ b/java/src/Ice/Object.java
@@ -12,4 +12,165 @@ package Ice;
public abstract class Object
{
+ public
+ Object()
+ {
+ }
+
+ public final int
+ _hash()
+ {
+ // TODO: replace with hashCode? Call hashCode?
+ return 0;
+ }
+
+ public boolean
+ _isA(String s)
+ {
+ return s.equals("::Ice::Object");
+ }
+
+ public void
+ _ping()
+ {
+ // Nothing to do
+ }
+
+ public final IceInternal.DispatchStatus
+ ____isA(IceInternal.Incoming __in)
+ {
+ Stream __is = __in.is();
+ Stream __os = __in.os();
+ String s = __is.readString();
+ boolean __ret = _isA(s);
+ __os.writeBoolean(__ret);
+ return IceInternal.DispatchStatus.DispatchOK;
+ }
+
+ public final IceInternal.DispatchStatus
+ ____ping(IceInternal.Incoming __in)
+ {
+ _ping();
+ return IceInternal.DispatchStatus.DispatchOK;
+ }
+
+ public abstract String[]
+ __getClassIds();
+
+ public static String[] __all =
+ {
+ "_isA",
+ "_ping"
+ };
+
+ public IceInternal.DispatchStatus
+ __dispatch(IceInternal.Incoming in, String s)
+ {
+ int pos = java.util.Arrays.binarySearch(__all, s);
+ if (pos < 0)
+ {
+ return IceInternal.DispatchStatus.DispatchOperationNotExist;
+ }
+
+ switch (pos)
+ {
+ case 0:
+ {
+ return ____isA(in);
+ }
+ case 1:
+ {
+ return ____ping(in);
+ }
+ }
+
+ assert false;
+ return IceInternal.DispatchStatus.DispatchOperationNotExist;
+ }
+
+ public boolean
+ __isMutating(String s)
+ {
+ //
+ // None of the Ice::Object operations accessible via __dispatch()
+ // is mutating.
+ //
+ return false;
+ }
+
+ public void
+ __write(Stream __os)
+ {
+ synchronized(_activeFacetMapMutex)
+ {
+ final int sz = _activeFacetMap.size();
+ __os.writeInt(sz);
+
+ java.util.Set set = _activeFacetMap.keySet();
+ String[] keys = new String[sz];
+ set.toArray(keys);
+ for (int i = 0; i < sz; i++)
+ {
+ __os.writeString(keys[i]);
+ __os.writeObject((Object)_activeFacetMap.get(keys[i]));
+ }
+ }
+ }
+
+ public void
+ __read(Stream __is)
+ {
+ synchronized(_activeFacetMapMutex)
+ {
+ int sz = __is.readInt();
+
+ _activeFacetMap.clear();
+
+ while (sz-- > 0)
+ {
+ String key = __is.readString();
+ Object value = __is.readObject("");
+ _activeFacetMap.put(key, value);
+ }
+ }
+ }
+
+ public final void
+ _addFacet(Object facet, String name)
+ {
+ synchronized(_activeFacetMapMutex)
+ {
+ _activeFacetMap.put(name, facet);
+ }
+ }
+
+ public final void
+ _removeFacet(String name)
+ {
+ synchronized(_activeFacetMapMutex)
+ {
+ _activeFacetMap.remove(name);
+ }
+ }
+
+ public final void
+ _removeAllFacets()
+ {
+ synchronized(_activeFacetMapMutex)
+ {
+ _activeFacetMap.clear();
+ }
+ }
+
+ public final Object
+ _findFacet(String name)
+ {
+ synchronized(_activeFacetMapMutex)
+ {
+ return (Object)_activeFacetMap.get(name);
+ }
+ }
+
+ private java.util.HashMap _activeFacetMap = new java.util.HashMap();
+ private java.lang.Object _activeFacetMapMutex = new java.lang.Object();
}
diff --git a/java/src/Ice/UserException.java b/java/src/Ice/UserException.java
index 0e52273ff6a..83972c4a074 100644
--- a/java/src/Ice/UserException.java
+++ b/java/src/Ice/UserException.java
@@ -12,4 +12,15 @@ package Ice;
public abstract class UserException extends Exception
{
+ public abstract String
+ _name();
+
+ public abstract String[]
+ __getExceptionIds();
+
+ public abstract void
+ __write(Stream out);
+
+ public abstract void
+ __read(Stream out);
}
diff --git a/java/src/Ice/Util.java b/java/src/Ice/Util.java
new file mode 100644
index 00000000000..c3608e65985
--- /dev/null
+++ b/java/src/Ice/Util.java
@@ -0,0 +1,44 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+package Ice;
+
+public final class Util
+{
+ public static Properties
+ getDefaultProperties(String[] args)
+ {
+ return null;
+ }
+
+ public static Properties
+ createProperties(String[] args)
+ {
+ return null;
+ }
+
+ public static Properties
+ createPropertiesFromFile(String[] args, String configFile)
+ {
+ return null;
+ }
+
+ public static Communicator
+ initialize(String[] args)
+ {
+ return null;
+ }
+
+ public static Communicator
+ initializeWithProperties(Properties properties)
+ {
+ return null;
+ }
+}
diff --git a/java/src/IceInternal/DispatchStatus.java b/java/src/IceInternal/DispatchStatus.java
new file mode 100644
index 00000000000..3e65b6205cc
--- /dev/null
+++ b/java/src/IceInternal/DispatchStatus.java
@@ -0,0 +1,57 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+package IceInternal;
+
+public final class DispatchStatus
+{
+ public static final long _DispatchOK = 0;
+ public static final DispatchStatus DispatchOK = new DispatchStatus(_DispatchOK);
+ public static final long _DispatchUserException = 1;
+ public static final DispatchStatus DispatchUserException = new DispatchStatus(_DispatchUserException);
+ public static final long _DispatchLocationForward = 2;
+ public static final DispatchStatus DispatchLocationForward = new DispatchStatus(_DispatchLocationForward);
+ public static final long _DispatchObjectNotExist = 3;
+ public static final DispatchStatus DispatchObjectNotExist = new DispatchStatus(_DispatchObjectNotExist);
+ public static final long _DispatchFacetNotExist = 4;
+ public static final DispatchStatus DispatchFacetNotExist = new DispatchStatus(_DispatchFacetNotExist);
+ public static final long _DispatchOperationNotExist = 5;
+ public static final DispatchStatus DispatchOperationNotExist = new DispatchStatus(_DispatchOperationNotExist);
+ public static final long _DispatchUnknownLocalException = 6;
+ public static final DispatchStatus DispatchUnknownLocalException = new DispatchStatus(_DispatchUnknownLocalException);
+ public static final long _DispatchUnknownUserException = 7;
+ public static final DispatchStatus DispatchUnknownUserException = new DispatchStatus(_DispatchUnknownUserException);
+ public static final long _DispatchUnknownException = 8;
+ public static final DispatchStatus DispatchUnknownException = new DispatchStatus(_DispatchUnknownException);
+
+ public static DispatchStatus
+ convert(long val)
+ {
+ assert val < 9;
+ return __values[val];
+ }
+
+ public long
+ value()
+ {
+ return __value;
+ }
+
+ private
+ DispatchStatus(long val)
+ {
+ __value = val;
+ __values[val] = this;
+ }
+
+ private static DispatchStatus[] __values = new DispatchStatus[9];
+
+ private long __value;
+}
diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java
new file mode 100644
index 00000000000..2a880ed8b24
--- /dev/null
+++ b/java/src/IceInternal/Incoming.java
@@ -0,0 +1,50 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+package IceInternal;
+
+public class Incoming
+{
+ public
+ Incoming(Instance instance, Ice.ObjectAdapter adapter)
+ {
+ _adapter = adapter;
+ _is = new StreamI(instance);
+ _os = new StreamI(instance);
+ }
+
+ public void
+ invoke(Stream is)
+ {
+ _is.swap(is);
+ String identity = _is.readString();
+ String facet = _is.readString();
+ String operation = _is.readString();
+
+ // TODO
+ }
+
+ public Stream
+ is()
+ {
+ return _is;
+ }
+
+ public Stream
+ os()
+ {
+ return _os;
+ }
+
+ private Ice.ObjectAdapter _adapter;
+
+ private Stream _is;
+ private Stream _os;
+}