use of com.helger.as2.cmd.CommandManager 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.CommandManager in project as2-server by phax.
the class AS2ServerXMLSession method loadCommandProcessor.
protected void loadCommandProcessor(@Nonnull final CommandManager aCommandMgr, @Nonnull final IMicroElement aElement) throws OpenAS2Exception {
final AbstractCommandProcessor aCmdProcesor = AS2XMLHelper.createComponent(aElement, AbstractCommandProcessor.class, this, m_sBaseDirectory);
aCommandMgr.addProcessor(aCmdProcesor);
s_aLogger.info(" loaded command processor " + aCmdProcesor.getName());
}
Aggregations