Examples of ModManager


Examples of de.mhus.framework.mod.ModManager

     * @throws Exception
     */
    public void testBundles2() throws Exception
    {
     
      ModManager manager = new ModManager(base);

      MyConfig a1 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c/>").getDocumentElement() ) );
      MyConfig a2 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c/>").getDocumentElement() ) );
      IModConfig[] ac1 = new IModConfig[] { a1, a2 };
      MyBundle b1 = new MyBundle("mybundle", false, ac1 );
     
      List<IModActivator> activators1 = new LinkedList<IModActivator>();
      manager.initializeBundle(b1,activators1);
      assertTrue( activators1.size() == 2 );
      assertTrue( manager.getActivators().size() == 2 );
     
      IModActivator act1 = activators1.get(0);
      assertTrue( act1.getStatus() == IModActivator.STATUS.INITIALIZED );
      manager.enableActivators(activators1);
      assertTrue( act1.getStatus() == IModActivator.STATUS.ENABLED );
      manager.disableActivators(activators1);
     
      MyConfig a3 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c/>").getDocumentElement() ) );
      MyConfig a4 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c/>").getDocumentElement() ) );
      IModConfig[] ac2 = new IModConfig[] { a3, a4 };
      MyBundle b2 = new MyBundle("mybundle", false, ac2 );
           
      List<IModActivator> activators2 = new LinkedList<IModActivator>();
      manager.initializeBundle(b2,activators2);
      assertTrue( activators2.size() == 2 );     
      assertTrue( manager.getActivators().size() == 4 );
     
      IModActivator act2 = activators2.get(0);
      assertTrue( act2.getStatus() == IModActivator.STATUS.INITIALIZED );
      manager.enableActivators(activators2);
      assertTrue( act2.getStatus() == IModActivator.STATUS.ENABLED );
      manager.disableActivators(activators2);
     
      assertTrue( act1.getStatus() == IModActivator.STATUS.DISABLED );
      manager.disposeActivators(activators1);
      assertTrue( act1.getStatus() == IModActivator.STATUS.CLOSED );

      assertTrue( act2.getStatus() == IModActivator.STATUS.DISABLED );
      manager.disposeActivators(activators2);
      assertTrue( act2.getStatus() == IModActivator.STATUS.CLOSED );
     
      assertTrue( manager.getActivators().size() == 0 );
    }
View Full Code Here

Examples of de.mhus.framework.mod.ModManager

     *
     * @throws Exception
     */
    public void testServiceRegister() throws Exception {
     
      ModManager manager = new ModManager(base);

      MyConfig a1 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c register_service='1'/>").getDocumentElement() ) );
      MyConfig a2 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c lookup_service='1'/>").getDocumentElement() ) );
      IModConfig[] ac1 = new IModConfig[] { a1, a2 };
      MyBundle b1 = new MyBundle("mybundle", false, ac1 );
     
      List<IModActivator> activators = new LinkedList<IModActivator>();
      manager.initializeBundle(b1,activators);
     
      Map<Class<?>, List<IService>> services = manager.getServices();
      assertTrue( services.get( ISimpleService.class ).size() == 1 );
     
      manager.enableActivators(activators); // lookup single service
      assertTrue( activators.get(1).getStatus() == STATUS.ENABLED );
     
      manager.disableActivators(activators);
      manager.disposeActivators(activators);
     
      services = manager.getServices();
      assertTrue( services.get( ISimpleService.class ).size() == 0 );
     
    }
View Full Code Here

Examples of de.mhus.framework.mod.ModManager

     *
     * @throws Exception
     */
    public void testServiceLookupException() throws Exception {
     
      ModManager manager = new ModManager(base);

      MyConfig a1 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c id='test1'/>").getDocumentElement() ) );
      MyConfig a2 = new MyConfig( SimpleActivator.class.getCanonicalName(), new XmlConfig( null, MXml.loadXml("<c id='test2' lookup_service='1'/>").getDocumentElement() ) );
      IModConfig[] ac1 = new IModConfig[] { a1, a2 };
      MyBundle b1 = new MyBundle("mybundle", false, ac1 );
     
      List<IModActivator> activators = new LinkedList<IModActivator>();
      manager.initializeBundle(b1,activators);
     
      Map<Class<?>, List<IService>> services = manager.getServices();
      assertTrue( services.get( ISimpleService.class ) == null );
     
     
    manager.enableActivators(activators); // lookup single service
      assertTrue( activators.get(1).getStatus() == STATUS.INITIALIZED );
   
      manager.disableActivators(activators);
      manager.disposeActivators(activators);
     
    }
View Full Code Here

Examples of de.mhus.framework.mod.ModManager

 
  public void testBundle() throws Exception {
    Base base = new Base();
   
    ModManager bundleManager = new ModManager(base);
    ModManager modManager = new ModManager(base);
   
    // Create Config
    HashConfig c1 = new HashConfig();
    c1.setString("class", SimpleActivator.class.getCanonicalName());
    c1.setString("id", "test1");
    c1.setString("name", "Simple1");

    HashConfig c2 = new HashConfig();
    c2.setString("class", SimpleActivator.class.getCanonicalName());
    c2.setString("id", "test2");
    c2.setString("name", "Simple2");
   
    HashConfig c3 = new HashConfig();
    c3.setString("class", SimpleActivator.class.getCanonicalName());
    c3.setString("id", "test3");
    c3.setString("name", "Simple3");
   
    ModBundle bundle1 = new ModBundle(new IModConfig[] { new ModConfig(c1), new ModConfig(c2)}, "bundle1", true);
   
    ModBundle bundle2 = new ModBundle(new IModConfig[] { new ModConfig(c3) }, "bundle2", true);
   
    modManager.append(bundle1);
    modManager.append(bundle2);

    bundleManager.initializeModule(bundle1,null);
    bundleManager.initializeModule(bundle2,null);
    bundleManager.intialize();
    bundleManager.enable();
View Full Code Here

Examples of net.ftb.tools.ModManager

     * @return boolean - represents whether it was successful in initializing mods
     */
    private boolean initializeMods () {
        Logger.logDebug("pack dir...");
        Logger.logInfo(ModPack.getSelectedPack().getDir());
        ModManager man = new ModManager(new JFrame(), true);
        man.setVisible(true);
        while (man == null) {
        }
        while (!man.worker.isDone()) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ignored) {
            }
        }
        if (man.erroneous) {
            return false;
        }
        try {
            MCInstaller.installMods(ModPack.getSelectedPack().getDir());
            man.cleanUp();
        } catch (IOException e) {
            Logger.logDebug("Exception: ", e);
        }
        return true;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.