Archived
This forum has been archived. Please start a new discussion on GitHub.
Automatically Generating an ObjectFactory
in Help Center
Before I dive into the post proper, I'd just like to extend my appreciation for all the support I've got from these forums so far. Benoit and marc, I have taken your advice and stipped down my application to the bare minimum.
I'm still stuck on streaming and am examining the demoj\Ice\invoke example.
One thing I do not understand is how the ObjectFactory methods were generated in the C.java class:
My Slice definition is very simple:
However my generated class does not have those ObjectFactory methods and it is the cause of this exception:
Thanks!
I'm still stuck on streaming and am examining the demoj\Ice\invoke example.
One thing I do not understand is how the ObjectFactory methods were generated in the C.java class:
private static class __F extends Ice.LocalObjectImpl implements Ice.ObjectFactory { public Ice.Object create(String type) { assert(type.equals(ice_staticId())); return new C(); } } private static Ice.ObjectFactory _factory = new __F(); public static Ice.ObjectFactory ice_factory() { return _factory; }
My Slice definition is very simple:
module Streaming { class KodkodModel { void solve(); }; interface KodkodModelReceiver { void receiveKodkodModel(KodkodModel k); }; };
However my generated class does not have those ObjectFactory methods and it is the cause of this exception:
identity: kodkodmodelreceiverobject facet: operation: receiveKodkodModel Ice.NoObjectFactoryException reason = "class sliced to Ice.Object, which is abstract" type = "::Streaming::KodkodModel"
Thanks!
0
Comments
-
Hi,
The Slice compilers can only generate object factories for concrete classes. Since your class defines an operation, it is considered abstract. The application is responsible for defining a concrete subclass that implements the operations. Since the Slice compiler has no way of knowing what the name of that subclass might be, it's impossible for the compiler to generate a factory. Therefore, you must also define a subclass of ObjectFactory and register it with the communicator. Take a look at the example in demo/Ice/value for more details.
Take care,
- Mark0