org.openide.modules.ModuleInfo Java Examples

The following examples show how to use org.openide.modules.ModuleInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstalledUpdateProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, UpdateItem> getUpdateItems () throws IOException {
    Map<String, UpdateItem> res = new HashMap<String, UpdateItem> ();
    for (ModuleInfo info : defaultProvider().getModuleInfos (true).values ()) {
        Date time = null; // XXX: it's too expensive, should be extracted lazy - Utilities.readInstallTimeFromUpdateTracking (info);
        String installTime = null;
        if (time != null) {
            installTime = Utilities.formatDate(time);
        }
        UpdateItemImpl impl = new InstalledModuleItem (
                info.getCodeNameBase (),
                info.getSpecificationVersion () == null ? null : info.getSpecificationVersion ().toString (),
                info,
                null, // XXX author
                null, // installed cluster
                installTime

                );

        UpdateItem updateItem = Utilities.createUpdateItem (impl);
        res.put (info.getCodeName () + '_' + info.getSpecificationVersion (), updateItem);
    }
    return res;
}
 
Example #2
Source File: OpenProjectList.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void removeModuleInfo(final Project prj, final ModuleInfo info) {
    // info can be null in case we are closing a project from disabled module
    if (info != null) {
        MUTEX.writeAccess(new Mutex.Action<Void>() {
            public @Override Void run() {
            List<Project> prjlist = openProjectsModuleInfos.get(info);
            if (prjlist != null) {
                prjlist.remove(prj);
                if (prjlist.isEmpty()) {
                    info.removePropertyChangeListener(infoListener);
                    openProjectsModuleInfos.remove(info);
                }
            }
            return null;
        }
        });
    }
}
 
Example #3
Source File: MonitorSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void resultChanged(LookupEvent lookupEvent) {
    java.util.Iterator it = res.allInstances ().iterator ();
    boolean moduleFound=false;
    while (it.hasNext ()) {
        ModuleInfo mi = (ModuleInfo)it.next ();
        if (mi.getCodeName ().startsWith(spy.getModuleId())) {
            spy.setEnabled(mi.isEnabled());
            if (httpMonitorInfo==null) {
                httpMonitorInfo=mi;                        
                monitorInfoListener = new MonitorInfoListener(spy);
                httpMonitorInfo.addPropertyChangeListener(monitorInfoListener);
            }
            moduleFound=true;
            break;
        }
    }
    if (!moduleFound) {
        if (httpMonitorInfo!=null) {
            httpMonitorInfo.removePropertyChangeListener(monitorInfoListener);
            httpMonitorInfo=null;
            spy.setEnabled(false);
        }
    }            
}
 
Example #4
Source File: MostRecentModules.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * The relevant section of the version number of the most recent module.
 * <p>
 * The build process modifies the version number of modules so that the
 * first two parts are maintained and the next two parts are the yyyymmdd
 * date and hhmmss time of the build as integers.
 * <p>
 * The format of the returned string is "yyyymmdd.hhmmss".
 * <p>
 * If the build process hasn't updated the version number (when running from
 * the IDE, for example), null will be returned.
 *
 * @return The relevant section of the version number of the most recent
 * module.
 */
public static synchronized String getMostRecentVersion() {
    if (!found && !isRunningUnitTest()) {
        final List<ModuleInfo> modules = getModules();
        final String[] versionParts = modules.get(0).getSpecificationVersion().toString().split("\\.");
        if (versionParts.length == 4) {
            final String yyyymmdd = versionParts[2];
            StringBuilder hhmmss = new StringBuilder(String.valueOf(versionParts[3]));
            while (hhmmss.length() < 6) {
                hhmmss.insert(0, "0");
            }

            mostRecentVersion = String.format("%s.%s", yyyymmdd, hhmmss.toString());

            // Just in case...
            if (mostRecentVersion.length() > 15) {
                mostRecentVersion = mostRecentVersion.substring(0, 15);
            }
        }

        found = true;
    }

    return mostRecentVersion;
}
 
Example #5
Source File: SerialDataConvertor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    if (evt == null) return;

    String name = evt.getPropertyName();
    if (name == null)
        return;
    // setting was changed
    else if (name == SaveSupport.PROP_SAVE)
        provideSaveCookie();
    // .settings file was changed
    else if (name == SaveSupport.PROP_FILE_CHANGED) {
        miUnInitialized = true;
        if (moduleCodeBase != null) {
            ModuleInfo mi = ModuleInfoManager.getDefault().getModule(moduleCodeBase);
            ModuleInfoManager.getDefault().
                unregisterPropertyChangeListener(this, mi);
        }
        instanceCookieChanged(null);
    } else if(ModuleInfo.PROP_ENABLED.equals(evt.getPropertyName())) {
        instanceCookieChanged(null);
    }
}
 
Example #6
Source File: ColumnElementTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
    try {
        super.setUp();

        Lookup.getDefault().lookup(ModuleInfo.class);

        // We need to set up netbeans.dirs so that the NBInst URLMapper correctly
        // finds our driver jar file
        File jarFile = new File(JDBCDriverManager.class.getProtectionDomain().getCodeSource().getLocation().toURI());
        File clusterDir = jarFile.getParentFile().getParentFile();
        System.setProperty("netbeans.dirs", clusterDir.getAbsolutePath());

        getProperties();

        dbsupport = DbSupport.getInstance(driverClassName);

        conn = getConnection();
    } catch (SQLException sqle) {
        reportSQLException(sqle);
        throw sqle;
    }
}
 
Example #7
Source File: Netigso.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void stopLoader(ModuleInfo m, ClassLoader loader) {
    NetigsoLoader nl = (NetigsoLoader)loader;
    Bundle b = nl.getBundle();
    try {
        assert b != null;
        try {
            LOG.log(Level.FINE, "Stopping bundle {0}", m.getCodeNameBase());
            b.stop();
        } catch (BundleException possible) {
            if (isRealBundle(b)) {
                throw possible;
            }
            LOG.log(Level.FINE, "Not stopping fragment {0}", m.getCodeNameBase());
        }
    } catch (BundleException ex) {
        throw new IllegalStateException(ex);
    }
}
 
Example #8
Source File: Lookup.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void listenOn(ClassLoader cl) {
    boolean doesNotContainCl = false;
    synchronized(moduleChangeListeners) {
        if (!moduleChangeListeners.containsKey(cl)) {
            doesNotContainCl = true;
        }
    }
    if (doesNotContainCl) {
        Collection<? extends ModuleInfo> allInstances = moduleLookupResult.allInstances();
        synchronized (moduleChangeListeners) {
            if (!moduleChangeListeners.containsKey(cl)) { // Still does not contain
                for (ModuleInfo mi : allInstances) {
                    if (mi.isEnabled() && mi.getClassLoader() == cl) {
                        ModuleChangeListener l = new ModuleChangeListener(cl);
                        mi.addPropertyChangeListener(WeakListeners.propertyChange(l, mi));
                        moduleChangeListeners.put(cl, l);
                    }
                }
            }
        }
    }
}
 
Example #9
Source File: NbInstaller.java    From netbeans with Apache License 2.0 6 votes vote down vote up
final String findProperty(ModuleInfo m, String name, boolean localized) {
    final String fullName = m.getCodeNameBase() + '.' + name;
    final String nullValue = "\u0000"; // NOI18N
    if (modulePropertiesCached) {
        String val = moduleProperties.getProperty(fullName);
        if (nullValue.equals(val)) { 
            return null;
        }
        if (val != null) {
            return val;
        }
        LOG.log(Level.FINE, "not cached value: {0} for {1}", new Object[]{name, m});
    } 
    Object p = localized ? m.getLocalizedAttribute(name) : m.getAttribute(name);
    if (p == null) {
        moduleProperties.setProperty(fullName, nullValue);
        Stamps.getModulesJARs().scheduleSave(this, CACHE, false);
        return null;
    }
    String prop = p instanceof String ? (String)p : null;
    if (prop != null) {
        moduleProperties.setProperty(fullName, prop);
        Stamps.getModulesJARs().scheduleSave(this, CACHE, false);
    }
    return prop;
}
 
Example #10
Source File: AutoSubmitTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
    UIHandler.flushImmediatelly();
    MetricsHandler.flushImmediatelly();
    System.setProperty("netbeans.user", getWorkDirPath());
    clearWorkDir();
    Locale.setDefault(new Locale("ts", "AU"));
    NbPreferences.root().node("org/netbeans/core").putBoolean("usageStatisticsEnabled", true);
    
    installer = Installer.findObject(Installer.class, true);
    assertNotNull(installer);
    //checkHandlers("After Installer find object", Logger.getLogger(Installer.UI_LOGGER_NAME));
    MockServices.setServices(A.class, D.class);
    //checkHandlers("After mock services set up", Logger.getLogger(Installer.UI_LOGGER_NAME));
    // Initialize the module system:
    Lookup.getDefault().lookupAll(ModuleInfo.class);
    //checkHandlers("After initialization of module system", Logger.getLogger(Installer.UI_LOGGER_NAME));
    MemoryURL.initialize();
    //checkHandlers("After all set up", Logger.getLogger(Installer.UI_LOGGER_NAME));
    installer.restored();
}
 
Example #11
Source File: MySQLDatabaseServerTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
    super.setUp();

    Lookup.getDefault().lookup(ModuleInfo.class);

    // We need to set up netbeans.dirs so that the NBInst URLMapper correctly
    // finds the mysql jar file
    File jarFile = Utilities.toFile(JDBCDriverManager.class.getProtectionDomain().getCodeSource().getLocation().toURI());
    File clusterDir = jarFile.getParentFile().getParentFile();
    System.setProperty("netbeans.dirs", clusterDir.getAbsolutePath());

    getProperties();

    server = MySQLDatabaseServer.getDefault();
    server.setUser(getUser());
    server.setPassword(getPassword());
    server.setHost(getHost());
    server.setPort(getPort());
}
 
Example #12
Source File: WindowManagerParser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Checks if module for given mode exists.
 * @return true if mode is valid - its module exists
 */
private boolean acceptMode (ModeParser modeParser, ModeConfig config) {
    InternalConfig cfg = modeParser.getInternalConfig();
    //Check module info
    if (cfg.moduleCodeNameBase != null) {
        ModuleInfo curModuleInfo = PersistenceManager.findModule
        (cfg.moduleCodeNameBase, cfg.moduleCodeNameRelease,
         cfg.moduleSpecificationVersion);
        if (curModuleInfo == null) {
            PersistenceManager.LOG.info("Cannot find module \'" +
                      cfg.moduleCodeNameBase + " " + cfg.moduleCodeNameRelease + " " + 
                      cfg.moduleSpecificationVersion + "\' for wsmode with name \'" + config.name + "\'"); // NOI18N
        }
        if ((curModuleInfo != null) && curModuleInfo.isEnabled()) {
            //Module is present and is enabled
            return true;
        } else {
            //Module is NOT present (it could be deleted offline)
            //or is NOT enabled
            return false;
        }
    } else {
        //No module info
        return true;
    }
}
 
Example #13
Source File: WindowManagerParser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Checks if module for given group exists.
 * @return true if group is valid - its module exists
 */
private boolean acceptGroup (GroupParser groupParser, GroupConfig config) {
    InternalConfig cfg = groupParser.getInternalConfig();
    //Check module info
    if (cfg.moduleCodeNameBase != null) {
        ModuleInfo curModuleInfo = PersistenceManager.findModule
                                    (cfg.moduleCodeNameBase, cfg.moduleCodeNameRelease,
                                     cfg.moduleSpecificationVersion);
        if (curModuleInfo == null) {
            
            PersistenceManager.LOG.log(Level.FINE, "Cannot find module \'" +
                      cfg.moduleCodeNameBase + " " + cfg.moduleCodeNameRelease + " " + 
                      cfg.moduleSpecificationVersion + "\' for group with name \'" + config.name + "\'"); // NOI18N
            
        }
        if ((curModuleInfo != null) && curModuleInfo.isEnabled()) {
            //Module is present and is enabled
            return true;
        } else {
            return false;
        }
    } else {
        //No module info
        return true;
    }
}
 
Example #14
Source File: ModuleDeleterImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean foundUpdateTracking (ModuleInfo moduleInfo) {
    File updateTracking = Utilities.locateUpdateTracking (moduleInfo);
    if (updateTracking != null && updateTracking.exists ()) {
        //err.log ("Find UPDATE_TRACKING: " + updateTracking + " found.");
        // check the write permission
        if (! Utilities.canWrite (updateTracking)) {
            err.log(Level.FINE,
                    "Cannot delete module " + moduleInfo.getCodeName() +
                    " because is forbidden to write in directory " +
                    updateTracking.getParentFile ().getParent ());
            return false;
        } else {
            return true;
        }
    } else {
        err.log(Level.FINE,
                "Cannot delete module " + moduleInfo.getCodeName() +
                " because no update_tracking file found.");
        return false;
    }
}
 
Example #15
Source File: PersistenceHandlerTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Make sure that closed TCs are not deserialized during saving window system ie. also
 * during IDE exit. Test creates test TC and overwrites method readExternal. This method
 * should not be called.
 */
public void testSaveWindowSystem () throws Exception {
    Lookup.getDefault().lookup(ModuleInfo.class);
    
    IDEInitializer.addLayers
    (new String [] {"org/netbeans/core/windows/resources/layer-PersistenceHandlerTest.xml"});
    
    //Verify that test layer was added to default filesystem
    assertNotNull(FileUtil.getConfigFile("Windows2/Modes/editor/component00.wstcref"));
    
    PersistenceHandler.getDefault().load();
            
    //Check that test TopComponent is not instantiated before
    assertFalse
    ("Closed TopComponent was instantiated before window system save but it should not.",
     Component00.wasDeserialized());
    
    PersistenceHandler.getDefault().save();
    
    //Check if test TopComponent was instantiated
    assertFalse
    ("Closed TopComponent was instantiated during window system save but it should not.",
     Component00.wasDeserialized());
    
    IDEInitializer.removeLayers();
}
 
Example #16
Source File: WizardAction.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private static Class<?> getClass(String className) {
    Collection<? extends ModuleInfo> modules = Lookup.getDefault().lookupAll(ModuleInfo.class);
    for (ModuleInfo module : modules) {
        if (module.isEnabled()) {
            try {
                Class<?> implClass = module.getClassLoader().loadClass(className);
                if (WizardPanel.class.isAssignableFrom(implClass)) {
                    //noinspection unchecked
                    return (Class<?>) implClass;
                }
            } catch (ClassNotFoundException e) {
                // it's ok, continue
            }
        }
    }
    return null;
}
 
Example #17
Source File: WindowManagerModeTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
    if (!loaded) {
        // Load just once for all tests in this class
        Lookup.getDefault().lookup(ModuleInfo.class);
        PersistenceHandler.getDefault().load();
        loaded = true;
    }
}
 
Example #18
Source File: PerClusterEnablementCheck.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testAPISupportTriggersAlsoJavaKit() throws Exception {
    FeatureInfo apisupport = null;
    FeatureInfo java = null;
    for (FeatureInfo f : FeatureManager.features()) {
        if (f.getCodeNames().contains("org.netbeans.modules.apisupport.kit")) {
            apisupport = f;
        }
        if (f.getCodeNames().contains("org.netbeans.modules.java.kit")) {
            java = f;
        }
    }
    assertNotNull("apisupport feature found", apisupport);
    assertNotNull("java feature found", java);

    FindComponentModules find = new FindComponentModules(apisupport);
    Set<String> expectedNames = new HashSet<String>(java.getCodeNames());
    for (UpdateElement updateElement : find.getModulesForEnable()) {
        expectedNames.remove(updateElement.getCodeName());
    }
    for (ModuleInfo mi : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
        if (isEager(mi) || isAutoload(mi)) {
            expectedNames.remove(mi.getCodeNameBase());
        }
    }
    if (!expectedNames.isEmpty()) {
        fail(
            "java cluster shall be fully enabled, but this was missing:\n" +
            expectedNames.toString().replace(',', '\n')
        );
    }
}
 
Example #19
Source File: ProjectFalsePositiveTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
    clearWorkDir();

    ic.set(Collections.emptyList(), null);
    URI uri = ModuleInfo.class.getProtectionDomain().getCodeSource().getLocation().toURI();
    File jar = new File(uri);
    System.setProperty("netbeans.home", jar.getParentFile().getParent());
    System.setProperty("netbeans.user", getWorkDirPath());
    disableModule("org.netbeans.modules.subversion");

    FeatureInfo info = FeatureInfo.create(
        "cluster",
        ProjectFalsePositiveTest.class.getResource("FeatureInfo.xml"),
        ProjectFalsePositiveTest.class.getResource("TestBundle.properties")
    );
    ic.add(info);
    
    File dbp = new File(new File(getWorkDir(), "1st"), "dbproject");
    File db = new File(dbp, "project.properties");
    dbp.mkdirs();
    db.createNewFile();

    File dbp2 = new File(new File(getWorkDir(), "2nd"), "dbproject");
    File db2 = new File(dbp2, "project.properties");
    dbp2.mkdirs();
    db2.createNewFile();

    root = FileUtil.toFileObject(getWorkDir());
    assertNotNull("fileobject found", root);

    OpenProjects.getDefault().open(new Project[0], false);
    assertEquals("Empty", 0, OpenProjects.getDefault().getOpenProjects().length);
}
 
Example #20
Source File: EditorSanityTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testHTMLEditorKits() {
    JEditorPane pane = new JEditorPane();
    setContentTypeInAwt(pane, "text/html");
    
    // Test JDK kit
    EditorKit kitFromJdk = pane.getEditorKit();
    assertNotNull("Can't find JDK kit for text/html", kitFromJdk);
    assertTrue("Wrong JDK kit for text/html", kitFromJdk instanceof HTMLEditorKit);

    // Check that org.netbeans.modules.html.editor is available
    boolean htmlPresent = false;
    Collection<? extends ModuleInfo> modules = Lookup.getDefault().lookupAll(ModuleInfo.class);
    for(ModuleInfo info : modules) {
        if (info.getCodeNameBase().equals("org.netbeans.modules.html.editor")) {
            htmlPresent = true;
            break;
        }
    }

    if (htmlPresent) {
        // Test Netbeans kit
        EditorKit kitFromNb = CloneableEditorSupport.getEditorKit("text/html");
        assertNotNull("Can't find Nb kit for text/html", kitFromNb);
        assertEquals("Wrong Nb kit for text/html",
            "org.netbeans.modules.html.editor.api.HtmlKit", kitFromNb.getClass().getName());
    } else {
        log("Module org.netbeans.modules.html.editor not present, skipping HTMLKit test...");
    }
}
 
Example #21
Source File: OperationsTestImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void enableModule (UpdateUnit toEnable) throws Exception {
    FileObject fo = FileUtil.getConfigFile("Modules");
    File f = new File (getWorkDir (), "config/Modules");
    File f2 = new File (getWorkDir (), "modules");
    assertTrue (f.listFiles () != null && f.listFiles ().length != 0);
    assertTrue (f2.listFiles () != null && f2.listFiles ().length != 0);
    assertFalse (fileChanges[0]);
    assertNotNull (getModuleInfos ().get (toEnable.getCodeName ()));
    
    assertNotNull (toEnable);
    
    /* Cf. installModuleImpl:
    assertSame (toEnable, Utilities.toUpdateUnit (toEnable.getCodeName ()));
    */
    
    OperationContainer<OperationSupport> container = OperationContainer.createForEnable ();
    assertNotNull (container.add (toEnable.getInstalled ()));
    OperationSupport support = container.getSupport ();
    assertNotNull (support);
    support.doOperation (null);
    assertNotNull (toEnable.getInstalled ());
    
    assertTrue (f.listFiles () != null && f.listFiles ().length != 0);
    assertTrue (f2.listFiles () != null && f2.listFiles ().length != 0);
    assertEquals (1, fo.getChildren ().length);
    assertEquals (f.listFiles ()[0], FileUtil.toFile (fo.getChildren ()[0]));
    
    //Thread.sleep(3000);
    assertNotNull (getModuleInfos ().get (toEnable.getCodeName ()));
    ModuleInfo info = getModuleInfos ().get (toEnable.getCodeName ());
    assertNotNull (info);
    assertTrue (info.isEnabled ());
    assertNotNull (Utilities.toModule (toEnable.getCodeName (), null));
    assertTrue (Utilities.toModule (toEnable.getCodeName (), null).isEnabled ());
}
 
Example #22
Source File: FeatureInfo.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean isPresent() {
    Boolean p = cachePresent;
    if (p != null) {
        return p;
    }

    Set<String> codeNames = new HashSet<String>(getCodeNames());
    for (ModuleInfo moduleInfo : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
        codeNames.remove(moduleInfo.getCodeNameBase());
    }
    return cachePresent = codeNames.isEmpty();
}
 
Example #23
Source File: CannotFindAsmTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testCannotLoadAsmClass() {
    ModuleInfo module = Modules.getDefault().findCodeNameBase("org.netbeans.core");
    final ClassLoader loader = module.getClassLoader();
    
    Class<?> clazz;
    try {
        clazz = Class.forName("org.objectweb.asm.ClassReader", true, loader);
    } catch (ClassNotFoundException ex) {
        // OK
        return;
    }
    fail("Loaded " + clazz + " from " + clazz.getClassLoader() + " via " + loader);
}
 
Example #24
Source File: PropertiesProviderTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
    clearWorkDir();
    
    Lookup.getDefault().lookup(ModuleInfo.class);
    
    MockServices.setServices(DD.class, Pool.class, FEQI.class);
}
 
Example #25
Source File: ProjectRejectedTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static void disableModule(String cnb) throws Exception, URISyntaxException {
    StringBuffer sb = new StringBuffer();
    boolean found = false;
    Exception ex2 = null;
    for (ModuleInfo info : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
        if (info.getCodeNameBase().equals(cnb)) {
            Method m = null;
            Class<?> c = info.getClass();
            for (;;) {
                if (c == null) {
                    throw ex2;
                }
                try {
                    m = c.getDeclaredMethod("setEnabled", Boolean.TYPE);
                } catch (Exception ex) {
                    ex2 = ex;
                }
                if (m != null) {
                    break;
                }
                c = c.getSuperclass();
            }
            m.setAccessible(true);
            m.invoke(info, false);
            assertFalse("Module is disabled", info.isEnabled());
            found = true;
        }
        sb.append(info.getCodeNameBase()).append('\n');
    }
    if (!found) {
        fail("No module found:\n" + sb);
    }
}
 
Example #26
Source File: CachingPreventsFileTouchesTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void assertEnabled(String cnb) {
    for (ModuleInfo mi : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
        if (mi.getCodeNameBase().equals(cnb)) {
            assertTrue("Is enabled", mi.isEnabled());
            return;
        }
    }
    fail("Not found " + cnb);
}
 
Example #27
Source File: MainLookupTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testInstanceInServicesFolderIsVisible() throws IOException {
    FileObject inst = FileUtil.createData(FileUtil.getConfigRoot(), "Services/Test/X.instance");
    inst.setAttribute("instanceCreate", Integer.valueOf(33));
    assertTrue("Is main lookup", MainLookup.getDefault() instanceof MainLookup);
    Lookup.getDefault().lookup(ModuleInfo.class);
    assertEquals("33 found", Integer.valueOf(33), Lookup.getDefault().lookup(Integer.class));
}
 
Example #28
Source File: TestBase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
    super.setUp();
    Lookup.getDefault().lookup(ModuleInfo.class);

    // We need to set up netbeans.dirs so that the NBInst URLMapper correctly
    // finds the driver jar file if the user is using the nbinst protocol
    File jarFile = Utilities.toFile(JDBCDriverManager.class.getProtectionDomain().getCodeSource().getLocation().toURI());
    File clusterDir = jarFile.getParentFile().getParentFile();
    System.setProperty("netbeans.dirs", clusterDir.getAbsolutePath());
    
    getProperties();
    setUrl();
}
 
Example #29
Source File: NbInstaller.java    From netbeans with Apache License 2.0 5 votes vote down vote up
final boolean isShowInAutoUpdateClient(ModuleInfo m) {
    String show = cache.findProperty(m, "AutoUpdate-Show-In-Client", false); // NOI18N
    if (show != null) {
        return Boolean.parseBoolean(show);
    }
    // OSGi bundles should be considered invisible by default since they are typically autoloads.
    // (NB modules get AutoUpdate-Show-In-Client inserted into the JAR by the build process.)
    if (m instanceof Module) {
        return !((Module)m).isNetigso();
    }
    return true;
}
 
Example #30
Source File: ModuleUpdateElementImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ModuleInfo getModuleInfo () {
    assert moduleInfo != null : "Each ModuleUpdateElementImpl has ModuleInfo, but " + this;
    
    // find really module info if present
    ModuleInfo info = Utilities.toModule (this.moduleInfo);
    if (info != null) {
        this.moduleInfo = info;
    } else {
        this.moduleInfo = item.getModuleInfo ();
    }
    
    return this.moduleInfo;
}