List of usage examples for java.beans.beancontext BeanContextServicesSupport BeanContextServicesSupport
public BeanContextServicesSupport()
From source file:DocumentTester.java
public static void main(String[] args) { BeanContextServicesSupport context = new BeanContextServicesSupport(); // a // bean// w ww . j ava 2 s. c o m // context DocumentBean doc1 = new DocumentBean("Test.txt"); context.add(doc1); context.addBeanContextServicesListener(doc1); // listen for new services WordCountServiceProvider provider = new WordCountServiceProvider(); context.addService(WordCount.class, provider); // add the service to the // context }
From source file:dk.dma.epd.shore.EPDShore.java
/** * Constructor/*from w w w . j a v a 2s . c o m*/ * * @param path * the home path to use */ private EPDShore(String path) throws IOException { super(); if (!StringUtils.isEmpty(path)) { homePath = Paths.get(path); } else { homePath = determineHomePath(Paths.get(System.getProperty("user.home"), ".epd-shore")); } new Bootstrap().run(this, new String[] { "epd-shore.properties", "settings.properties", "transponder.xml" }, new String[] { "workspaces", "routes", "shape/GSHHS_shp", "identities" }); // Set up log4j logging LOG = LoggerFactory.getLogger(EPDShore.class); // Set default exception handler Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler()); LOG.info("Starting eNavigation Prototype Display Shore - version " + VersionInfo.getVersionAndBuild()); LOG.info("Copyright (C) 2012 Danish Maritime Authority"); LOG.info("This program comes with ABSOLUTELY NO WARRANTY."); LOG.info("This is free software, and you are welcome to redistribute it under certain conditions."); LOG.info("For details see LICENSE file."); // Create the bean context (map handler) // mapHandler = new MapHandler(); beanHandler = new BeanContextServicesSupport(); // Load settings or get defaults and add to bean context settings = new EPDSettings(); LOG.info("Using settings file: " + getSettings().getSettingsFile()); settings.loadFromFile(); beanHandler.add(settings); // Determine if instance already running and if that is allowed OneInstanceGuard guard = new OneInstanceGuard(getHomePath().resolve("epd.lock").toString()); if (guard.isAlreadyRunning()) { handleEpdAlreadyRunning(); } // Enable GPS timer by adding it to bean context PntTime.init(settings.getSensorSettings().isUseTimeFromPnt()); beanHandler.add(PntTime.getInstance()); // aisHandler = new AisHandlerCommon(); aisHandler = new AisHandler(settings.getAisSettings()); aisHandler.loadView(); EPD.startThread(aisHandler, "AisHandler"); beanHandler.add(aisHandler); // Add StaticImages handler staticImages = new StaticImages(); beanHandler.add(staticImages); // Load routeManager routeManager = RouteManager.loadRouteManager(); beanHandler.add(routeManager); falManager = FALManager.loadFALManager(); beanHandler.add(falManager); // To be changed to load similar to routeManager // voyageManager = new VoyageManager(); voyageManager = VoyageManager.loadVoyageManager(); beanHandler.add(voyageManager); sruManager = SRUManager.loadSRUManager(); beanHandler.add(sruManager); // Create shore services shoreServicesCommon = new ShoreServices(getSettings().getEnavSettings()); beanHandler.add(shoreServicesCommon); // Create mona lisa route exchange monaLisaRouteExchange = new MonaLisaRouteOptimization(); beanHandler.add(monaLisaRouteExchange); // Create Maritime Cloud service maritimeCloudService = new MaritimeCloudService(); beanHandler.add(maritimeCloudService); maritimeCloudService.start(); // Create strategic route Handler; strategicRouteHandler = new StrategicRouteHandler(); beanHandler.add(strategicRouteHandler); // Create intended route handler intendedRouteHandler = new IntendedRouteHandler(); beanHandler.add(intendedRouteHandler); // Create the route suggestion handler // routeSuggestionHandler = new RouteSuggestionHandler(); routeSuggestionHandler = RouteSuggestionHandler.loadRouteSuggestionHandler(); beanHandler.add(routeSuggestionHandler); // Create a new MSI-NM handler msiNmHandler = new MsiNmServiceHandlerCommon(); beanHandler.add(msiNmHandler); // Create a chat service handler chatServiceHandler = new ChatServiceHandlerCommon(); beanHandler.add(chatServiceHandler); // Create identity handler identityHandler = new IdentityHandler(); beanHandler.add(identityHandler); // Start sensors startSensors(); pluginLoader = new PluginLoader(getProperties(), getHomePath(), getPropertyFileName()); try { pluginLoader.createPluginComponents(new Consumer<Object>() { public void accept(Object comp) { beanHandler.add(comp); } }); } catch (Exception e) { LOG.error("Failed to load plugin container " + e.getMessage()); } final CountDownLatch guiCreated = new CountDownLatch(1); // Create and show GUI SwingUtilities.invokeLater(new Runnable() { @Override public void run() { createAndShowGUI(); guiCreated.countDown(); } }); // Wait for gui to be created try { guiCreated.await(); } catch (InterruptedException e) { LOG.error("Interrupted while waiting for GUI to be created", e); } // Create vocthandler voctHandler = new VoctHandler(); beanHandler.add(voctHandler); // Create voct manager voctManager = new VOCTManager(); beanHandler.add(voctManager); voctManager.loadVOCTManager(); // Create FAL Handler falHandler = new FALHandler(); beanHandler.add(falHandler); // Create embedded transponder frame transponderFrame = new TransponderFrame(getHomePath().resolve("transponder.xml").toString(), true, mainFrame); mainFrame.getTopMenu().setTransponderFrame(transponderFrame); beanHandler.add(transponderFrame); if (settings.getSensorSettings().isStartTransponder()) { transponderFrame.startTransponder(); } }