private void handlePlugin(String name, String spec, String[] args, boolean wait) { System.setSecurityManager(new RMISecurityManager()); TransitModel model = getTransitModel(args); boolean waitForCompletion = deployHandler(model, name, spec, args, wait); if (!waitForCompletion) { if (m_plugin instanceof Disposable) { Disposable disposable = (Disposable) m_plugin; disposable.dispose(); } if (model instanceof DefaultTransitModel) { DefaultTransitModel disposable = (DefaultTransitModel) model; disposable.dispose(); } System.exit(0); } }
private TransitModel getTransitModel(String[] args) { final String key = "dpml.transit.model"; String property = null; for (int i = 0; i < args.length; i++) { String arg = args[i]; if (arg.startsWith("-D" + key + "=")) { property = arg.substring(21); break; } } if (null != property) { if (property.startsWith("registry:")) { try { return (TransitModel) new URL(property).getContent(new Class[] {TransitModel.class}); } catch (Exception e) { final String error = "Unable to resolve registry reference: " + property; throw new TransitError(error, e); } } else { final String error = "System property value for the key ': " + key + "' contains an unrecognized value: " + property; throw new TransitError(error); } } // // otherwise let Transit handle model creation // try { Logger logger = getLogger().getChildLogger("transit"); return DefaultTransitModel.getDefaultModel(logger); } catch (Exception e) { final String error = "Transit model establishment failure."; throw new TransitError(error, e); } }