summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-12-07 03:53:54 +0000
committerMichi Henning <michi@zeroc.com>2004-12-07 03:53:54 +0000
commit517d158d746bfa6f5722d9ecd0264137269bfa79 (patch)
tree4a4e3dbb6ee6c1493e332ff14ffe09117f740425 /java
parentminor fixes (diff)
downloadice-517d158d746bfa6f5722d9ecd0264137269bfa79.tar.bz2
ice-517d158d746bfa6f5722d9ecd0264137269bfa79.tar.xz
ice-517d158d746bfa6f5722d9ecd0264137269bfa79.zip
Added context parameter to checkedCast().
Diffstat (limited to 'java')
-rw-r--r--java/CHANGES5
-rw-r--r--java/src/Ice/ObjectPrxHelper.java28
-rw-r--r--java/src/IceInternal/DirectReference.java2
-rw-r--r--java/src/IceInternal/FixedReference.java2
-rw-r--r--java/src/IceInternal/IndirectReference.java4
-rw-r--r--java/src/IceInternal/PropertyNames.java4
-rw-r--r--java/src/IceInternal/Reference.java14
-rw-r--r--java/src/IceInternal/RoutableReference.java6
-rw-r--r--java/test/Ice/operations/AllTests.java18
-rw-r--r--java/test/Ice/operations/CheckedCastLocator.java37
-rw-r--r--java/test/Ice/operations/Collocated.java9
-rw-r--r--java/test/Ice/operations/Server.java11
-rw-r--r--java/test/Ice/operations/Test.ice5
-rw-r--r--java/test/Ice/operations/TestCheckedCastI.java25
-rw-r--r--java/test/Ice/operationsAMD/CheckedCastLocator.java37
-rw-r--r--java/test/Ice/operationsAMD/Server.java11
-rw-r--r--java/test/Ice/operationsAMD/TestAMD.ice7
-rw-r--r--java/test/Ice/operationsAMD/TestCheckedCastI.java25
-rw-r--r--java/test/Ice/operationsAMD/build.xml20
19 files changed, 255 insertions, 15 deletions
diff --git a/java/CHANGES b/java/CHANGES
index 55bf9d2bb97..a6c2424efdc 100644
--- a/java/CHANGES
+++ b/java/CHANGES
@@ -1,6 +1,11 @@
Changes since version 2.0.0
---------------------------
+- Overloaded the checkedCast member function of the generated PrxHelper
+ classes to allow a trailing argument of type ::Ice::Context. This makes
+ it possible to do stateful things that require a context in a
+ servant locator's activate() method.
+
- Added support for bzip2 protocol compression. The implementation
uses the bzip2 classes from Ant. See the INSTALL file for more
information.
diff --git a/java/src/Ice/ObjectPrxHelper.java b/java/src/Ice/ObjectPrxHelper.java
index b87dcee662e..22dae62aecf 100644
--- a/java/src/Ice/ObjectPrxHelper.java
+++ b/java/src/Ice/ObjectPrxHelper.java
@@ -18,6 +18,12 @@ public class ObjectPrxHelper extends ObjectPrxHelperBase
}
public static ObjectPrx
+ checkedCast(Ice.ObjectPrx b, java.util.Map ctx)
+ {
+ return b;
+ }
+
+ public static ObjectPrx
checkedCast(Ice.ObjectPrx b, String f)
{
ObjectPrx d = null;
@@ -40,6 +46,28 @@ public class ObjectPrxHelper extends ObjectPrxHelperBase
}
public static ObjectPrx
+ checkedCast(Ice.ObjectPrx b, String f, java.util.Map ctx)
+ {
+ ObjectPrx d = null;
+ if(b != null)
+ {
+ Ice.ObjectPrx bb = b.ice_newFacet(f);
+ try
+ {
+ boolean ok = bb.ice_isA("::Object", ctx);
+ assert(ok);
+ ObjectPrxHelper h = new ObjectPrxHelper();
+ h.__copyFrom(bb);
+ d = h;
+ }
+ catch(Ice.FacetNotExistException ex)
+ {
+ }
+ }
+ return d;
+ }
+
+ public static ObjectPrx
uncheckedCast(Ice.ObjectPrx b)
{
return b;
diff --git a/java/src/IceInternal/DirectReference.java b/java/src/IceInternal/DirectReference.java
index cc6e027cd5a..7c7c4f7aa8c 100644
--- a/java/src/IceInternal/DirectReference.java
+++ b/java/src/IceInternal/DirectReference.java
@@ -31,7 +31,7 @@ public class DirectReference extends RoutableReference
return _endpoints;
}
- public Reference
+ public final Reference
changeEndpoints(Endpoint[] newEndpoints)
{
if(compare(newEndpoints, _endpoints))
diff --git a/java/src/IceInternal/FixedReference.java b/java/src/IceInternal/FixedReference.java
index 95daaf20a8b..2b997df7689 100644
--- a/java/src/IceInternal/FixedReference.java
+++ b/java/src/IceInternal/FixedReference.java
@@ -24,7 +24,7 @@ public class FixedReference extends Reference
_fixedConnections = fixedConns;
}
- public Ice.ConnectionI[]
+ public final Ice.ConnectionI[]
getFixedConnections()
{
return _fixedConnections;
diff --git a/java/src/IceInternal/IndirectReference.java b/java/src/IceInternal/IndirectReference.java
index 6e9239428a7..46c125c5175 100644
--- a/java/src/IceInternal/IndirectReference.java
+++ b/java/src/IceInternal/IndirectReference.java
@@ -28,13 +28,13 @@ public class IndirectReference extends RoutableReference
_locatorInfo = locInfo;
}
- public String
+ public final String
getAdapterId()
{
return _adapterId;
}
- public LocatorInfo
+ public final LocatorInfo
getLocatorInfo()
{
return _locatorInfo;
diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java
index 3096e2e3acd..82d19f76c49 100644
--- a/java/src/IceInternal/PropertyNames.java
+++ b/java/src/IceInternal/PropertyNames.java
@@ -7,7 +7,7 @@
//
// **********************************************************************
-// Generated by makeprops.py from file `PropertyNames.def', Mon Nov 29 11:38:13 2004
+// Generated by makeprops.py from file `../config/PropertyNames.def', Fri Dec 3 15:44:09 2004
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -171,9 +171,11 @@ public final class PropertyNames
"IcePatch2.Admin.ThreadPool.SizeMax",
"IcePatch2.Admin.ThreadPool.SizeWarn",
"IcePatch2.Admin.ThreadPool.StackSize",
+ "IcePatch2.ChunkSize",
"IcePatch2.Directory",
"IcePatch2.Endpoints",
"IcePatch2.PublishedEndpoints",
+ "IcePatch2.Thorough",
"IcePatch2.ThreadPool.Size",
"IcePatch2.ThreadPool.SizeMax",
"IcePatch2.ThreadPool.SizeWarn",
diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java
index 9eddb37d5db..24fc16dc41e 100644
--- a/java/src/IceInternal/Reference.java
+++ b/java/src/IceInternal/Reference.java
@@ -29,7 +29,7 @@ public abstract class Reference implements Cloneable
return _identity;
}
- public java.util.Map
+ public final java.util.Map
getContext()
{
return _context;
@@ -53,7 +53,7 @@ public abstract class Reference implements Cloneable
return _instance;
}
- public Reference
+ public final Reference
changeMode(int newMode)
{
if(newMode == _mode)
@@ -65,7 +65,7 @@ public abstract class Reference implements Cloneable
return r;
}
- public Reference
+ public final Reference
changeIdentity(Ice.Identity newIdentity)
{
if(newIdentity.equals(_identity))
@@ -77,7 +77,7 @@ public abstract class Reference implements Cloneable
return r;
}
- public Reference
+ public final Reference
changeContext(java.util.Map newContext)
{
if(newContext.equals(_context))
@@ -89,7 +89,7 @@ public abstract class Reference implements Cloneable
return r;
}
- public Reference
+ public final Reference
changeFacet(String newFacet)
{
if(newFacet.equals(_facet))
@@ -101,7 +101,7 @@ public abstract class Reference implements Cloneable
return r;
}
- public Reference
+ public final Reference
changeSecure(boolean newSecure)
{
if(newSecure == _secure)
@@ -113,7 +113,7 @@ public abstract class Reference implements Cloneable
return r;
}
- public synchronized int
+ public final synchronized int
hashCode()
{
if(_hashInitialized)
diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java
index bfa1d5836a6..bcd79b01591 100644
--- a/java/src/IceInternal/RoutableReference.java
+++ b/java/src/IceInternal/RoutableReference.java
@@ -11,13 +11,13 @@ package IceInternal;
public abstract class RoutableReference extends Reference
{
- public RouterInfo
+ public final RouterInfo
getRouterInfo()
{
return _routerInfo;
}
- public Endpoint[]
+ public final Endpoint[]
getRoutedEndpoints()
{
if(_routerInfo != null)
@@ -32,7 +32,7 @@ public abstract class RoutableReference extends Reference
return new Endpoint[0];
}
- public boolean
+ public final boolean
getCollocationOptimization()
{
return _collocationOptimization;
diff --git a/java/test/Ice/operations/AllTests.java b/java/test/Ice/operations/AllTests.java
index a53b1c88aad..40797e9b72f 100644
--- a/java/test/Ice/operations/AllTests.java
+++ b/java/test/Ice/operations/AllTests.java
@@ -39,6 +39,24 @@ public class AllTests
test(cl.equals(derived));
System.out.println("ok");
+ System.out.print("testing checked cast with context... ");
+ System.out.flush();
+ String cref = "test:default -p 12346 -t 10000";
+ Ice.ObjectPrx cbase = communicator.stringToProxy(cref);
+ test(cbase != null);
+
+ Test.TestCheckedCastPrx tccp = Test.TestCheckedCastPrxHelper.checkedCast(cbase);
+ java.util.Map c = tccp.getContext();
+ test(c == null || c.size() == 0);
+
+ c = new java.util.HashMap();
+ c.put("one", "hello");
+ c.put("two", "world");
+ tccp = Test.TestCheckedCastPrxHelper.checkedCast(cbase, c);
+ java.util.Map c2 = tccp.getContext();
+ test(c.equals(c2));
+ System.out.println("ok");
+
System.out.print("testing twoway operations... ");
System.out.flush();
Twoways.twoways(cl);
diff --git a/java/test/Ice/operations/CheckedCastLocator.java b/java/test/Ice/operations/CheckedCastLocator.java
new file mode 100644
index 00000000000..ed737ad384e
--- /dev/null
+++ b/java/test/Ice/operations/CheckedCastLocator.java
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+public final class CheckedCastLocator extends Ice.LocalObjectImpl implements Ice.ServantLocator
+{
+ public CheckedCastLocator()
+ {
+ _servant = new TestCheckedCastI();
+ }
+
+ public Ice.Object
+ locate(Ice.Current c, Ice.LocalObjectHolder cookie)
+ {
+ if(c.operation.equals("ice_isA"))
+ {
+ _servant.setContext(c.ctx);
+ }
+ return _servant;
+ }
+
+ public void
+ finished(Ice.Current current, Ice.Object servant, Ice.LocalObject cookie)
+ {
+ }
+
+ public void deactivate(String s)
+ {
+ }
+
+ TestCheckedCastI _servant;
+}
diff --git a/java/test/Ice/operations/Collocated.java b/java/test/Ice/operations/Collocated.java
index a8de2b7cc8e..441fe39dfe2 100644
--- a/java/test/Ice/operations/Collocated.java
+++ b/java/test/Ice/operations/Collocated.java
@@ -17,6 +17,15 @@ public class Collocated
Ice.Object object = new MyDerivedClassI(adapter, Ice.Util.stringToIdentity("test"));
adapter.add(object, Ice.Util.stringToIdentity("test"));
+ //
+ // Make a separate adapter with a servant locator. We use this to test
+ // that ::Ice::Context is correctly passed to checkedCast() operation.
+ //
+ communicator.getProperties().setProperty("CheckedCastAdapter.Endpoints", "default -p 12346 -t 10000");
+ adapter = communicator.createObjectAdapter("CheckedCastAdapter");
+ Ice.ServantLocator checkedCastLocator = new CheckedCastLocator();
+ adapter.addServantLocator(checkedCastLocator, "");
+
AllTests.allTests(communicator, true);
return 0;
diff --git a/java/test/Ice/operations/Server.java b/java/test/Ice/operations/Server.java
index eb61addc6f5..df43d08eda3 100644
--- a/java/test/Ice/operations/Server.java
+++ b/java/test/Ice/operations/Server.java
@@ -17,6 +17,17 @@ public class Server
Ice.Object object = new MyDerivedClassI(adapter, Ice.Util.stringToIdentity("test"));
adapter.add(object, Ice.Util.stringToIdentity("test"));
adapter.activate();
+
+ //
+ // Make a separate adapter with a servant locator. We use this to test
+ // that ::Ice::Context is correctly passed to checkedCast() operation.
+ //
+ communicator.getProperties().setProperty("CheckedCastAdapter.Endpoints", "default -p 12346 -t 10000");
+ adapter = communicator.createObjectAdapter("CheckedCastAdapter");
+ Ice.ServantLocator checkedCastLocator = new CheckedCastLocator();
+ adapter.addServantLocator(checkedCastLocator, "");
+ adapter.activate();
+
communicator.waitForShutdown();
return 0;
}
diff --git a/java/test/Ice/operations/Test.ice b/java/test/Ice/operations/Test.ice
index c57cb879968..47284aaf973 100644
--- a/java/test/Ice/operations/Test.ice
+++ b/java/test/Ice/operations/Test.ice
@@ -155,6 +155,11 @@ dictionary<string, MyEnum> StringMyEnumD;
void opDerived();
};
+interface TestCheckedCast
+{
+ Ice::Context getContext();
+};
+
};
#endif
diff --git a/java/test/Ice/operations/TestCheckedCastI.java b/java/test/Ice/operations/TestCheckedCastI.java
new file mode 100644
index 00000000000..503fd7d3a4b
--- /dev/null
+++ b/java/test/Ice/operations/TestCheckedCastI.java
@@ -0,0 +1,25 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+public final class TestCheckedCastI extends Test._TestCheckedCastDisp
+{
+ public java.util.Map
+ getContext(Ice.Current current)
+ {
+ return _ctx;
+ }
+
+ public void
+ setContext(java.util.Map ctx)
+ {
+ _ctx = ctx;
+ }
+
+ private java.util.Map _ctx;
+}
diff --git a/java/test/Ice/operationsAMD/CheckedCastLocator.java b/java/test/Ice/operationsAMD/CheckedCastLocator.java
new file mode 100644
index 00000000000..ed737ad384e
--- /dev/null
+++ b/java/test/Ice/operationsAMD/CheckedCastLocator.java
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+public final class CheckedCastLocator extends Ice.LocalObjectImpl implements Ice.ServantLocator
+{
+ public CheckedCastLocator()
+ {
+ _servant = new TestCheckedCastI();
+ }
+
+ public Ice.Object
+ locate(Ice.Current c, Ice.LocalObjectHolder cookie)
+ {
+ if(c.operation.equals("ice_isA"))
+ {
+ _servant.setContext(c.ctx);
+ }
+ return _servant;
+ }
+
+ public void
+ finished(Ice.Current current, Ice.Object servant, Ice.LocalObject cookie)
+ {
+ }
+
+ public void deactivate(String s)
+ {
+ }
+
+ TestCheckedCastI _servant;
+}
diff --git a/java/test/Ice/operationsAMD/Server.java b/java/test/Ice/operationsAMD/Server.java
index eb61addc6f5..df43d08eda3 100644
--- a/java/test/Ice/operationsAMD/Server.java
+++ b/java/test/Ice/operationsAMD/Server.java
@@ -17,6 +17,17 @@ public class Server
Ice.Object object = new MyDerivedClassI(adapter, Ice.Util.stringToIdentity("test"));
adapter.add(object, Ice.Util.stringToIdentity("test"));
adapter.activate();
+
+ //
+ // Make a separate adapter with a servant locator. We use this to test
+ // that ::Ice::Context is correctly passed to checkedCast() operation.
+ //
+ communicator.getProperties().setProperty("CheckedCastAdapter.Endpoints", "default -p 12346 -t 10000");
+ adapter = communicator.createObjectAdapter("CheckedCastAdapter");
+ Ice.ServantLocator checkedCastLocator = new CheckedCastLocator();
+ adapter.addServantLocator(checkedCastLocator, "");
+ adapter.activate();
+
communicator.waitForShutdown();
return 0;
}
diff --git a/java/test/Ice/operationsAMD/TestAMD.ice b/java/test/Ice/operationsAMD/TestAMD.ice
index 650fce73cd8..b2eae6c4e5c 100644
--- a/java/test/Ice/operationsAMD/TestAMD.ice
+++ b/java/test/Ice/operationsAMD/TestAMD.ice
@@ -10,6 +10,8 @@
#ifndef TEST_AMD_ICE
#define TEST_AMD_ICE
+#include<Ice/Current.ice>
+
module Test
{
@@ -154,6 +156,11 @@ dictionary<string, MyEnum> StringMyEnumD;
void opDerived();
};
+["ami", "amd"] interface TestCheckedCast
+{
+ Ice::Context getContext();
+};
+
};
#endif
diff --git a/java/test/Ice/operationsAMD/TestCheckedCastI.java b/java/test/Ice/operationsAMD/TestCheckedCastI.java
new file mode 100644
index 00000000000..a92cdef0f96
--- /dev/null
+++ b/java/test/Ice/operationsAMD/TestCheckedCastI.java
@@ -0,0 +1,25 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+public final class TestCheckedCastI extends Test._TestCheckedCastDisp
+{
+ public void
+ getContext_async(Test.AMD_TestCheckedCast_getContext cb, Ice.Current current)
+ {
+ cb.ice_response(_ctx);
+ }
+
+ public void
+ setContext(java.util.Map ctx)
+ {
+ _ctx = ctx;
+ }
+
+ private java.util.Map _ctx;
+}
diff --git a/java/test/Ice/operationsAMD/build.xml b/java/test/Ice/operationsAMD/build.xml
index 4d09acbf06f..359229a7322 100644
--- a/java/test/Ice/operationsAMD/build.xml
+++ b/java/test/Ice/operationsAMD/build.xml
@@ -11,6 +11,9 @@
<project name="test_Ice_operations" default="all" basedir=".">
+ <!-- get access to env variables globally -->
+ <property environment="env" />
+
<!-- set global properties for this build -->
<property name="top.dir" value="../../.."/>
<property name="lib.dir" value="${top.dir}/lib"/>
@@ -27,6 +30,20 @@
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
+
+ <!-- Define the slice.dir property -->
+ <condition property="slice.dir" value="slice">
+ <available file="slice" type="dir"/>
+ </condition>
+ <condition property="slice.dir" value="${env.ICE_HOME}/slice">
+ <and>
+ <available type="dir" file="${env.ICE_HOME}/slice"/>
+ <not>
+ <available file="slice" type="dir"/>
+ </not>
+ </and>
+ </condition>
+ <fail message="Slice source directory not found" unless="slice.dir"/>
</target>
<target name="generate" depends="init">
@@ -34,6 +51,9 @@
<mkdir dir="${generated.dir}"/>
<slice2java outputdir="${generated.dir}">
<fileset dir="." includes="TestAMD.ice"/>
+ <includepath>
+ <pathelement path="${slice.dir}" />
+ </includepath>
</slice2java>
</target>