8.5

Table Of Contents
Embedding QXP Server Manager
You can embed QuarkXPress Server Manager in applications (stand-alone or otherwise).
To do so, you must first initialize QuarkXPress Server Manager, as shown below:
QConfigurationData initializationData = new QConfigurationData();
initializationData.setBeanDefinitionConfigFile("ManagerContainerConfig.xml");
QClassFactory.getInstance().init(initializationData);
You can configure other QuarkXPress Manager options using QConfigurationManager.
Next, you must register one or more QuarkXPress Server hosts, like so:
QConfigManager configManager =
QClassFactory.getInstance().getExecutionEngine().getConfigManager();
String currentDirectory = System.getProperty("user.dir");
configManager.setCacheFolder(
new File(new File(currentDirectory), "cache").getAbsolutePath());
configManager.setLogLevel(STANDALONE_CLIENT_LOG_LEVEL);
configManager.setPingType(QPingTypeEnum.PING_SIMPLE);
QConnectionInfo connInfo = new QConnectionInfo();
connInfo.setServerName(<XPRESS_SERVER_NAME>);
connInfo.setServerPort(<XPRESS_SERVER_PORT>);
connInfo.setUserName(<XPRESS_SERVER_ADMIN_USER>);
connInfo.setPassword(<XPRESS_SERVER_ADMIN_PASSWORD>);
QHostSummary host = new QHostSummary();
host.setConnectionInfo(connInfo);
configManager.registerHost(host);
Once you have done so, you can use the embedded QuarkXPress Server Manager as shown
below:
XMLRequest xmlRequest = new XMLRequest();
QRequestContext context = new QRequestContext();
context.setDocumentName(<SAMPLE_DOCUMENT>);
context.setResponseAsURL(false);
context.setRequest(xmlRequest);
QContentData response = QRequestProcessor.getInstance().processRequest(context);
System.out.println(response.getTextData());
Writing special request handlers
If you need to perform custom actions on specific flags, you need to define special flags
and write handlers for them. These flags can then be passed as GET parameters to the
servlet, as additional QParam parameters in QCommand (executed using
QManagerSvc.executeCommand), or as additional NameValueParam parameters in a
derived class of QRequest using QManagerSDKSvc.processRequest. The servlet will
automatically create parameters out of these flags and set these in the command before
sending it for execution.
To handle these special flags, you can write your request handler derived from the class
QRequestHandler. You can then insert this new handler class anywhere in the chain of
responsibility pattern, starting with QDocProviderImpl and ending with
QHostRequestHandler.
Try not to change end points. In your handler implementation, handle your special flags,
then either return a response after handling or pass the control to the successor for further
handling.
QXP SERVER 8.5 WEB INTEGRATION GUIDE | 27
GETTING STARTED