|
|
|
|||||
|
Another solution about package mapping in Java
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:
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. 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.
|
|
|||||
|
Is there any comment ?
|
|
|||||
|
Quote:
In my point of view, these two config items(Ice.Package.Workflow/Ice.Default.Package) are very ugly and they pollute the Ice's simplicity and consistency because they require the assembler/tester to know some code detail of Ice program. Last edited by rc_hz : 08-23-2006 at 10:09 PM. |
|
|||||
|
Another solution
1.Add a global meta in slice definition(This is the same as above) :
Code:
[["java:package:com.acme"]]
module Workflow {
class Document {
// ...
};
};
1)The first one is just as usual: Code:
package com.acme.Workflow;
public abstract class Document {
//...
};
Code:
package com.zeroc.Workflow;
public class Document {
public static final string CLASSNAME = "com.acme.Workflow.Document";
}
1) Try to load Workflow.Document class. 2) If 1) fails, try to load com.zeroc.Workflow.Document class. If this succeeds, it further tries to load the class with the name of com.zeroc.Workflow.Document.CLASSNAME, that is, com.acme.Workflow.Document. 3) Otherwise, this type id can not be resolved. Last edited by rc_hz : 08-23-2006 at 10:37 PM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| OSX package on Intel MAC | ctennis | Bug Reports | 2 | 11-23-2006 09:32 PM |
| solution to install ICE-3.1.1 on freebsd.6.1 | canyoudink | Bug Reports | 0 | 10-19-2006 12:36 PM |
| Which solution is better when programming with ICE? | nyingchi | Help Center | 3 | 09-29-2006 07:24 AM |
| a misstake for IceCS-2.0.0 vs.net2003 solution? | lkw | Bug Reports | 3 | 01-04-2005 07:45 PM |
| package metadata directive - ClassCast Exception | vsonnathi | Bug Reports | 1 | 09-28-2004 11:46 AM |