use of com.helger.as2.app.session.AS2ServerXMLSession in project as2-server by phax.
the class MainOpenAS2Server method start.
public void start(@Nullable final String sConfigFilePath) {
AS2ServerXMLSession aXMLSession = null;
try {
s_aLogger.info(CAS2Info.NAME_VERSION + " - starting Server...");
// create the OpenAS2 Session object
// this is used by all other objects to access global configs and
// functionality
s_aLogger.info("Loading configuration...");
if (StringHelper.hasText(sConfigFilePath)) {
// Load config file
aXMLSession = new AS2ServerXMLSession(sConfigFilePath);
} else {
s_aLogger.info("Usage:");
s_aLogger.info("java " + getClass().getName() + " <configuration file>");
throw new Exception("Missing configuration file name on the commandline. You may specify src/main/resources/config/config.xml");
}
// start the active processor modules
s_aLogger.info("Starting Active Modules...");
aXMLSession.getMessageProcessor().startActiveModules();
final ICommandRegistry aCommandRegistry = aXMLSession.getCommandRegistry();
final CommandManager aCommandMgr = aXMLSession.getCommandManager();
final List<AbstractCommandProcessor> aCommandProcessors = aCommandMgr.getProcessors();
for (final AbstractCommandProcessor cmd : aCommandProcessors) {
s_aLogger.info("Loading Command Processor " + cmd.getClass().getName() + "");
cmd.init();
cmd.addCommands(aCommandRegistry);
new Thread(cmd, ClassHelper.getClassLocalName(cmd)).start();
}
// enter the command processing loop
s_aLogger.info("OpenAS2 Started");
// Start waiting for termination
breakOut: while (true) {
for (final AbstractCommandProcessor cmd : aCommandProcessors) {
if (cmd.isTerminated())
break breakOut;
}
// Wait outside loop in case no command processor is present
Thread.sleep(100);
}
s_aLogger.info("- OpenAS2 Stopped -");
} catch (final Throwable t) {
t.printStackTrace();
} finally {
if (aXMLSession != null) {
try {
aXMLSession.getMessageProcessor().stopActiveModules();
} catch (final OpenAS2Exception same) {
same.terminate();
}
}
s_aLogger.info("OpenAS2 has shut down");
}
}
use of com.helger.as2.app.session.AS2ServerXMLSession in project as2-server by phax.
the class XMLCommandRegistry method loadCommand.
protected void loadCommand(final IMicroElement eCommand, @Nullable final MultiCommand aParent) throws OpenAS2Exception {
final IAS2Session aSession = getSession();
final String sBaseDirectory = aSession instanceof AS2ServerXMLSession ? ((AS2ServerXMLSession) aSession).getBaseDirectory() : null;
final ICommand aCommand = AS2XMLHelper.createComponent(eCommand, ICommand.class, aSession, sBaseDirectory);
if (aParent != null)
aParent.getCommands().add(aCommand);
else
addCommand(aCommand);
}
Aggregations