XFireHome M5M6-SNAPSHOTDevelopersDeveloper Space |
Sometimes you'll want to read/write your own custom types. This will give you direct access to the xml streams. Handling large dataSometimes you'll want to return large amounts of data which you don't want loaded into memory. Here a couple steps to help you get going. 1. Return or receive some kind of class which gives a reference to the data public ReferenceToData doSomething(...) {}
2. Create a org.codehaus.xfire.aegis.type.Type for ReferenceToData public class ReferenceToDataType extends Type { public ReferenceToDataType() { setTypeClass(ReferenceToData.class); setSchemaType(new QName(.. the QName of the type you're returning ..)); } public void writeObject(Object value, XMLStreamWriter writer, MessageContext context) { ReferenceToData data = (ReferenceToData) value; ... do you're writing to the writer } public Object readObject( MessageReader reader, MessageContext context ) { // If you're reading you can read in a reference to the data XMLStreamReader reader = context.getInMessage().getXMLStreamReader(); ReferenceToData data = read(reader); return data; } public void writeSchema(Element schemaRoot) { // override this to write out your schema // if you have it in DOM form you can convert it to YOM via DOMConverter } } 3. Register the ReferenceToDataType ServiceRegistry serviceRegistry = ....; // get this from the XFire instance Serivce service = serviceRegistry.getService("serviceName"); TypeMapping tm = AegisTypeBinding.getTypeMapping(service); tm.register(new ReferenceToDataType()); |