use of com.helger.as2.cmd.ICommandRegistry 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.cmd.ICommandRegistry in project as2-server by phax.
the class AS2ServerXMLSession method loadCommands.
protected void loadCommands(@Nonnull final IMicroElement aElement) throws OpenAS2Exception {
s_aLogger.info(" loading commands");
final ICommandRegistry cmdReg = AS2XMLHelper.createComponent(aElement, ICommandRegistry.class, this, m_sBaseDirectory);
m_aCommandRegistry = cmdReg;
}
Aggregations