summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/ObjectPrx.java385
-rw-r--r--java/src/Ice/_ObjectDel.java22
-rw-r--r--java/src/Ice/_ObjectDelD.java55
-rw-r--r--java/src/Ice/_ObjectDelM.java140
-rw-r--r--java/src/IceInternal/Direct.java110
5 files changed, 711 insertions, 1 deletions
diff --git a/java/src/Ice/ObjectPrx.java b/java/src/Ice/ObjectPrx.java
index a1d7afdfad5..bc6a9f87da4 100644
--- a/java/src/Ice/ObjectPrx.java
+++ b/java/src/Ice/ObjectPrx.java
@@ -10,6 +10,389 @@
package Ice;
-public abstract class ObjectPrx
+public class ObjectPrx
{
+ public final int
+ ice_hash()
+ {
+ return _reference.hashValue;
+ }
+
+ public final boolean
+ ice_isA(String s)
+ {
+ int __cnt = 0;
+ while (true)
+ {
+ try
+ {
+ _ObjectDel __del = __getDelegate();
+ return __del.ice_isA(s);
+ }
+ catch (LocationForward __ex)
+ {
+ __locationForward(__ex);
+ }
+ catch (IceInternal.NonRepeatable __ex)
+ {
+ __cnt = __handleException(__ex.get(), __cnt);
+ }
+ catch (LocalException __ex)
+ {
+ __cnt = __handleException(__ex, __cnt);
+ }
+ }
+ }
+
+ public final void
+ ice_ping()
+ {
+ int __cnt = 0;
+ while (true)
+ {
+ try
+ {
+ _ObjectDel __del = __getDelegate();
+ __del.ice_ping();
+ return;
+ }
+ catch (LocationForward __ex)
+ {
+ __locationForward(__ex);
+ }
+ catch (IceInternal.NonRepeatable __ex)
+ {
+ __cnt = __handleException(__ex.get(), __cnt);
+ }
+ catch (LocalException __ex)
+ {
+ __cnt = __handleException(__ex, __cnt);
+ }
+ }
+ }
+
+ public final String
+ ice_getIdentity()
+ {
+ return _reference.identity;
+ }
+
+ public final ObjectPrx
+ ice_newIdentity(String newIdentity)
+ {
+ if (newIdentity.equals(_reference.identity))
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrx proxy = new ObjectPrx();
+ proxy.setup(_reference.changeIdentity(newIdentity));
+ return proxy;
+ }
+ }
+
+ public final String
+ ice_getFacet()
+ {
+ return _reference.facet;
+ }
+
+ public final ObjectPrx
+ ice_newFacet(String newFacet)
+ {
+ if (newFacet.equals(_reference.facet))
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrx proxy = new ObjectPrx();
+ proxy.setup(_reference.changeFacet(newFacet));
+ return proxy;
+ }
+ }
+
+ public final ObjectPrx
+ ice_twoway()
+ {
+ IceInternal.Reference ref =
+ _reference.changeMode(IceInternal.Reference.ModeTwoway);
+ if (ref.equals(_reference))
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrx proxy = new ObjectPrx();
+ proxy.setup(ref);
+ return proxy;
+ }
+ }
+
+ public final ObjectPrx
+ ice_oneway()
+ {
+ IceInternal.Reference ref =
+ _reference.changeMode(IceInternal.Reference.ModeOneway);
+ if (ref.equals(_reference))
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrx proxy = new ObjectPrx();
+ proxy.setup(ref);
+ return proxy;
+ }
+ }
+
+ public final ObjectPrx
+ ice_batchOneway()
+ {
+ IceInternal.Reference ref =
+ _reference.changeMode(IceInternal.Reference.ModeBatchOneway);
+ if (ref.equals(_reference))
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrx proxy = new ObjectPrx();
+ proxy.setup(ref);
+ return proxy;
+ }
+ }
+
+ public final ObjectPrx
+ ice_datagram()
+ {
+ IceInternal.Reference ref =
+ _reference.changeMode(IceInternal.Reference.ModeDatagram);
+ if (ref.equals(_reference))
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrx proxy = new ObjectPrx();
+ proxy.setup(ref);
+ return proxy;
+ }
+ }
+
+ public final ObjectPrx
+ ice_batchDatagram()
+ {
+ IceInternal.Reference ref =
+ _reference.changeMode(IceInternal.Reference.ModeBatchDatagram);
+ if (ref.equals(_reference))
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrx proxy = new ObjectPrx();
+ proxy.setup(ref);
+ return proxy;
+ }
+ }
+
+ public final ObjectPrx
+ ice_secure(boolean b)
+ {
+ IceInternal.Reference ref = _reference.changeSecure(b);
+ if (ref.equals(_reference))
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrx proxy = new ObjectPrx();
+ proxy.setup(ref);
+ return proxy;
+ }
+ }
+
+ public final ObjectPrx
+ ice_timeout(int t)
+ {
+ IceInternal.Reference ref = _reference.changeTimeout(t);
+ if (ref.equals(_reference))
+ {
+ return this;
+ }
+ else
+ {
+ ObjectPrx proxy = new ObjectPrx();
+ proxy.setup(ref);
+ return proxy;
+ }
+ }
+
+ public final void
+ ice_flush()
+ {
+ _ObjectDel __del = __getDelegate();
+ __del.ice_flush();
+ }
+
+ public final IceInternal.Reference
+ __reference()
+ {
+ return _reference;
+ }
+
+ public final void
+ __copyFrom(Ice.ObjectPrx from)
+ {
+ setup(from.__reference());
+ }
+
+ public final synchronized int
+ __handleException(LocalException ex, int cnt)
+ {
+ _delegate = null;
+
+ final int max = 1; // TODO: Make number of retries configurable
+
+ try
+ {
+ throw ex;
+ }
+ catch (CloseConnectionException e)
+ {
+ //
+ // We always retry on a close connection exception, as this
+ // indicates graceful server shutdown.
+ //
+ // TODO: configurable timeout before we try again?
+ }
+ catch (SocketException e)
+ {
+ ++cnt;
+ }
+ catch (DNSException e)
+ {
+ ++cnt;
+ }
+ catch (TimeoutException e)
+ {
+ ++cnt;
+ }
+
+ IceInternal.TraceLevels traceLevels =
+ _reference.instance.traceLevels();
+ Logger logger = _reference.instance.logger();
+
+ if (cnt > max)
+ {
+ if (traceLevels.retry >= 1)
+ {
+ String s = "cannot retry operation call because retry limit " +
+ "has been exceeded\n" + ex;
+ logger.trace(traceLevels.retryCat, s);
+ }
+ throw ex;
+ }
+
+ if (traceLevels.retry >= 1)
+ {
+ String s = "re-trying operation call because of exception\n" + ex;
+ logger.trace(traceLevels.retryCat, s);
+ }
+
+ //
+ // Reset the endpoints to the original endpoints upon retry
+ //
+ _reference = _reference.changeEndpoints(_reference.origEndpoints);
+
+ return cnt;
+ }
+
+ public final synchronized void
+ __rethrowException(LocalException ex)
+ {
+ _delegate = null;
+
+ throw ex;
+ }
+
+ public final synchronized void
+ __locationForward(LocationForward ex)
+ {
+ _delegate = null;
+
+ if (!_reference.identity.equals(ex._prx._reference.identity))
+ {
+ throw new ReferenceIdentityException();
+ }
+
+ _reference = _reference.changeEndpoints(ex._prx._reference.endpoints);
+
+ /*
+ IceInternal.TraceLevels traceLevels =
+ _reference.instance.traceLevels();
+ Logger logger = _reference.instance.logger();
+
+ if (traceLevels.locationForward >= 1)
+ {
+ String s = "location forward for object with identity `" +
+ _reference.identity + "'";
+ logger.trace(traceLevels.locationForwardCat, s);
+ }
+ */
+ }
+
+ protected final synchronized _ObjectDel
+ __getDelegate()
+ {
+ if (_delegate == null)
+ {
+ ObjectAdapter adapter = _reference.instance.objectAdapterFactory().
+ findObjectAdapter(this);
+ if (adapter != null)
+ {
+ _ObjectDelD delegate = __createDelegateD();
+ delegate.setup(_reference, adapter);
+ _delegate = delegate;
+ }
+ else
+ {
+ _ObjectDelM delegate = __createDelegateM();
+ delegate.setup(_reference);
+ _delegate = delegate;
+ }
+ }
+
+ return _delegate;
+ }
+
+ protected _ObjectDelM
+ __createDelegateM()
+ {
+ return new _ObjectDelM();
+ }
+
+ protected _ObjectDelD
+ __createDelegateD()
+ {
+ return new _ObjectDelD();
+ }
+
+ //
+ // Only for use by IceInternal.ProxyFactory
+ //
+ public final void
+ setup(IceInternal.Reference ref)
+ {
+ //
+ // No need to synchronize, as this operation is only called
+ // upon initial initialization.
+ //
+ _reference = ref;
+ }
+
+ private IceInternal.Reference _reference;
+ private _ObjectDel _delegate;
}
diff --git a/java/src/Ice/_ObjectDel.java b/java/src/Ice/_ObjectDel.java
new file mode 100644
index 00000000000..a090a429a95
--- /dev/null
+++ b/java/src/Ice/_ObjectDel.java
@@ -0,0 +1,22 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+package Ice;
+
+public interface _ObjectDel
+{
+ boolean ice_isA(String id)
+ throws LocationForward, IceInternal.NonRepeatable;
+
+ void ice_ping()
+ throws LocationForward, IceInternal.NonRepeatable;
+
+ void ice_flush();
+}
diff --git a/java/src/Ice/_ObjectDelD.java b/java/src/Ice/_ObjectDelD.java
new file mode 100644
index 00000000000..68b5af3cdc9
--- /dev/null
+++ b/java/src/Ice/_ObjectDelD.java
@@ -0,0 +1,55 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+package Ice;
+
+public class _ObjectDelD implements _ObjectDel
+{
+ public boolean
+ ice_isA(String s)
+ throws LocationForward, IceInternal.NonRepeatable
+ {
+ IceInternal.Direct __direct =
+ new IceInternal.Direct(__adapter, __reference, "ice_isA");
+ return __direct.facetServant().ice_isA(s);
+ }
+
+ public void
+ ice_ping()
+ throws LocationForward, IceInternal.NonRepeatable
+ {
+ IceInternal.Direct __direct =
+ new IceInternal.Direct(__adapter, __reference, "ice_ping");
+ __direct.facetServant().ice_ping();
+ }
+
+ public void
+ ice_flush()
+ {
+ // Nothing to do for direct delegates
+ }
+
+ protected ObjectAdapter __adapter;
+ protected IceInternal.Reference __reference;
+
+ //
+ // Only for use by ObjectPrx
+ //
+ final void
+ setup(IceInternal.Reference ref, ObjectAdapter adapter)
+ {
+ //
+ // No need to synchronize, as this operation is only called
+ // upon initial initialization.
+ //
+ __reference = ref;
+ __adapter = adapter;
+ }
+}
diff --git a/java/src/Ice/_ObjectDelM.java b/java/src/Ice/_ObjectDelM.java
new file mode 100644
index 00000000000..b33c8d56c5b
--- /dev/null
+++ b/java/src/Ice/_ObjectDelM.java
@@ -0,0 +1,140 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+package Ice;
+
+public class _ObjectDelM implements _ObjectDel
+{
+ public boolean
+ ice_isA(String s)
+ throws LocationForward, IceInternal.NonRepeatable
+ {
+ IceInternal.Outgoing __out =
+ new IceInternal.Outgoing(__emitter, __reference);
+ IceInternal.BasicStream __is = __out.is();
+ IceInternal.BasicStream __os = __out.os();
+ __os.writeString("ice_isA");
+ __os.writeString(s);
+ if (!__out.invoke())
+ {
+ throw new UnknownUserException();
+ }
+ return __is.readBool();
+ }
+
+ public void
+ ice_ping()
+ throws LocationForward, IceInternal.NonRepeatable
+ {
+ IceInternal.Outgoing __out =
+ new IceInternal.Outgoing(__emitter, __reference);
+ IceInternal.BasicStream __os = __out.os();
+ __os.writeString("ice_ping");
+ if (!__out.invoke())
+ {
+ throw new UnknownUserException();
+ }
+ }
+
+ public void
+ ice_flush()
+ {
+ __emitter.flushBatchRequest();
+ }
+
+ protected IceInternal.Emitter __emitter;
+ protected IceInternal.Reference __reference;
+
+ //
+ // Only for use by ObjectPrx
+ //
+ final void
+ setup(IceInternal.Reference ref)
+ {
+ //
+ // No need to synchronize, as this operation is only called
+ // upon initial initialization.
+ //
+ __reference = ref;
+
+ java.util.LinkedList endpoints = new java.util.LinkedList();
+ switch (__reference.mode)
+ {
+ case IceInternal.Reference.ModeTwoway:
+ case IceInternal.Reference.ModeOneway:
+ case IceInternal.Reference.ModeBatchOneway:
+ {
+ for (int i = 0; i < __reference.endpoints.length; i++)
+ {
+ if (!__reference.endpoints[i].datagram())
+ {
+ endpoints.add(__reference.endpoints[i]);
+ }
+ }
+ break;
+ }
+
+ case IceInternal.Reference.ModeDatagram:
+ case IceInternal.Reference.ModeBatchDatagram:
+ {
+ for (int i = 0; i < __reference.endpoints.length; i++)
+ {
+ if (__reference.endpoints[i].datagram())
+ {
+ endpoints.add(__reference.endpoints[i]);
+ }
+ }
+ break;
+ }
+ }
+
+ if (__reference.secure)
+ {
+ java.util.ListIterator i = endpoints.listIterator();
+ while (i.hasNext())
+ {
+ IceInternal.Endpoint endpoint = (IceInternal.Endpoint)i.next();
+ if (!endpoint.secure())
+ {
+ i.remove();
+ }
+ }
+ }
+ else
+ {
+ java.util.ListIterator i = endpoints.listIterator();
+ while (i.hasNext())
+ {
+ IceInternal.Endpoint endpoint = (IceInternal.Endpoint)i.next();
+ if (endpoint.secure())
+ {
+ i.remove();
+ }
+ }
+ }
+
+ final int sz = endpoints.size();
+ if (endpoints.isEmpty())
+ {
+ throw new NoEndpointException();
+ }
+
+ IceInternal.Endpoint[] arr =
+ (IceInternal.Endpoint[])endpoints.toArray();
+
+ // TODO
+ //random_shuffle(endpoints.begin(), endpoints.end());
+
+ IceInternal.EmitterFactory factory =
+ __reference.instance.emitterFactory();
+ __emitter = factory.create(arr);
+ assert(__emitter != null);
+ }
+}
diff --git a/java/src/IceInternal/Direct.java b/java/src/IceInternal/Direct.java
new file mode 100644
index 00000000000..098c89991d4
--- /dev/null
+++ b/java/src/IceInternal/Direct.java
@@ -0,0 +1,110 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+package IceInternal;
+
+public final class Direct
+{
+ public
+ Direct(Ice.ObjectAdapter adapter, Reference ref, String operation)
+ {
+ _adapter = adapter;
+ _reference = ref;
+ _operation = operation;
+
+ try
+ {
+ _servant = _adapter.identityToServant(_reference.identity);
+
+ if (_servant == null)
+ {
+ int pos = _reference.identity.indexOf('#');
+ if (pos != -1)
+ {
+ _locator = _adapter.findServantLocator(
+ _reference.identity.substring(0, pos));
+ if (_locator != null)
+ {
+ _servant = _locator.locate(_adapter,
+ _reference.identity,
+ _operation,
+ _cookie);
+ }
+ }
+ }
+
+ if (_servant == null)
+ {
+ _locator = _adapter.findServantLocator("");
+ if (_locator != null)
+ {
+ _servant = _locator.locate(_adapter,
+ _reference.identity,
+ _operation,
+ _cookie);
+ }
+ }
+
+ if (_servant != null && ref.facet.length() > 0)
+ {
+ _facetServant = _servant.ice_findFacet(ref.facet);
+ if (_facetServant == null)
+ {
+ throw new Ice.FacetNotExistException();
+ }
+ }
+ }
+ finally
+ {
+ if (_locator != null && _servant != null)
+ {
+ _locator.finished(_adapter, _reference.identity, _operation,
+ _servant, _cookie.value);
+ }
+ }
+
+ if (_servant == null)
+ {
+ throw new Ice.ObjectNotExistException();
+ }
+ }
+
+ protected void
+ finalize()
+ throws Throwable
+ {
+ if (_locator != null && _servant != null)
+ {
+ _locator.finished(_adapter, _reference.identity, _operation,
+ _servant, _cookie.value);
+ }
+ }
+
+ public Ice.Object
+ facetServant()
+ {
+ if (_facetServant != null)
+ {
+ return _facetServant;
+ }
+ else
+ {
+ return _servant;
+ }
+ }
+
+ private Ice.ObjectAdapter _adapter;
+ private Reference _reference;
+ private String _operation;
+ private Ice.Object _servant;
+ private Ice.Object _facetServant;
+ private Ice.ServantLocator _locator;
+ private Ice.LocalObjectHolder _cookie = new Ice.LocalObjectHolder();
+}