According to page 331 in Ice 3.1.0 manul, when we want to use a common package prefix, we have to do like this:
This solution has one big shortcoming: the application assembler should has some knowedge about the code, that is, he or she should know that "com.acme" or "com.xxx" package names; Furthermore, in practical applications, that having to configure these packages is very boring.Code:1.Add a global meta in slice definition: [["java:package:com.acme"]] module Workflow { class Document { // ... }; }; 2.Add one confication in config files: Ice.Package.Workflow=com.acme or Ice.Default.Package=com.acme
The following is another solution to this problem. The heart of it is the annotation feature in Java 5.
If we do like this, the application assembler don't need to any configration about packages.Code:1.Add a global meta in slice definition(This is the same as above): [["java:package:com.acme"]] module Workflow { class Document { // ... }; }; 2.change the behavior of slice2java a litte. Add an annotation to the java file: package com.acme.Workflow; @SomeAnnotation("com.acme") public abstract class Document { //... }; 3.When Ice begins to run, the class loader scans the class file. If it finds an @SomeAnnotation, it gets a map. That is: ::Workflow::Document ==> com.acme.Workflow.Document 4.When Ice run time unmarshals an exception or concrete class , it can contact the map first.

Reply With Quote