1. | What is the minimal number of jar files required in a ServingXML distribution? |
| ServingXML versions 0.8.x, which minimally require Java 5, need servingxml.jar
and a conforming XSLT implementation (the versions of Xalan currently shipping with Java 5.x and 6.x will not work,
because of bugs in these versions.) Earlier ServingXML versions, which minimally require Java 1.4, need additional jar files, including
concurrent.jar , xml-apis.jar , and xercesImpl.jar .
Extensions such as Fop need more jar files.
|
2. | Using ServingXML within a Spring framework, how do I pass a Spring ApplicationContext
object down to a custom record filter? |
| Pass it through the parameters. In the application code, add it to the parameters before
executing a service.
ApplicationContext appContext ...
ParameterBuilder paramBuilder = new ParameterBuilder();
Name contextName = new QualifiedName("appContext");
paramBuilder.setObject(contextName, appContext);
Record parameters = paramBuilder.toRecord();
Flow flow = new FlowImpl(parameters, defaultStreamSource, defaultStreamSink);
service.execute(context, flow);
In the custom record filter, access the ApplicationContext object from the parameters.
public class MyRecordFilter extends AbstractRecordFilter
implements RecordFilter {
private static final Name contextName = new QualifiedName("appContext");
private ApplicationContext appContext;
public void startRecordStream(ServiceContext context, Flow flow) {
super.startRecordStream(context, flow);
this.appContext = (ApplicationContext)parameters.getObject(contextName);
}
|
3. | When creating the Flow , what can I use as a
default (empty) StreamSource ?
|
| StreamSource.NULL |
4. | Is it possible to pass the input file as a
String? |
| Yes, by passing a StringStreamSource when creating a Flow,
import com.servingxml.io.streamsource.StreamSource;
import com.servingxml.io.streamsource.StringStreamSource;
..
StreamSource streamSource = new StringStreamSource(str);
Flow flow = new FlowImpl(parameters, streamSource, streamSink);
|
5. | Is it possible to pass the resource file as an
InputStream? |
| Yes, using the createIocContainer method that takes
an InputStream,
IocContainerFactory iocContainerFactory = new IocContainerFactory();
iocContainerFactory.loadComponentDefinitions();
InputStream is;
//Initialize input stream
IocContainer resources =
iocContainerFactory.createIocContainer(is, parameters);
|
6. | Is it possible to pass the resource file as a
String? |
| Yes, using the createIocContainer method that takes
a Reader,
import java.io.Reader;
import java.io.StringReader;
IocContainerFactory iocContainerFactory = new IocContainerFactory();
iocContainerFactory.loadComponentDefinitions();
Reader reader = new StringReader(str);
IocContainer resources =
iocContainerFactory.createIocContainer(reader, parameters);
|
7. | How do I get the ouput XML as a string? |
| Use a StringStreamSink ,
import com.servingxml.io.streamsink.StringStreamSink;
...
StreamSink streamSink = new StringStreamSink();
Flow flow = new FlowImpl(parameters, streamSource, streamSink);
...
String s = streamSink.toString();
|