Archived
This forum has been archived. Please start a new discussion on GitHub.
object factories in slice
Hello all,
I've found in the overview web pages an interesting way to play with objects factories
----
interface Invoice {
void addItems(ItemSeq items);
void submit();
};
interface InvoiceFactory {
Invoice* create();
};
----
that makes the usage of factories very simple (this is the python sample)
----
# Create a proxy for the invoice factory object.
proxy = communicator.stringToProxy("InvoiceFactory:tcp -p 9000")
# Narrow the proxy to the proper type.
factory = Biz.InvoiceFactoryPrx.checkedCast(proxy)
# Use the factory to obtain a proxy for a new invoice object.
invoice = factory.create()
----
Unfortunately, I'm not able to find in the documentation and in the samples other usages of this technique: is it possible to have more details (perhaps a working server implementation) ?
Thanks in advance
/gp
I've found in the overview web pages an interesting way to play with objects factories
----
interface Invoice {
void addItems(ItemSeq items);
void submit();
};
interface InvoiceFactory {
Invoice* create();
};
----
that makes the usage of factories very simple (this is the python sample)
----
# Create a proxy for the invoice factory object.
proxy = communicator.stringToProxy("InvoiceFactory:tcp -p 9000")
# Narrow the proxy to the proper type.
factory = Biz.InvoiceFactoryPrx.checkedCast(proxy)
# Use the factory to obtain a proxy for a new invoice object.
invoice = factory.create()
----
Unfortunately, I'm not able to find in the documentation and in the samples other usages of this technique: is it possible to have more details (perhaps a working server implementation) ?
Thanks in advance
/gp
0
Comments
-
For an example that also involves the use of Freeze, have a look at demo/Freeze/phonebook or demo/Freeze/library. Another example is demo/IcePack/hello, which also demonstrates the use of IcePack.0
-
Thanks for your quick reply,
I've borrowed from demo/IcePack/hello: here's my minimalist InvoiceFactoryI python implementationclass InvoiceFactoryI(Biz.InvoiceFactory): def create(self, current=None): adapter = current.adapter obj = adapter.addWithUUID(InvoiceI()) return Biz.InvoicePrx.uncheckedCast(obj)
And it seems to work.
Thank you very much.
/gp0