diff --git a/collab.ui/src/org/netbeans/modules/collab/ui/beaninfo/package-info.java b/collab.ui/src/org/netbeans/modules/collab/ui/beaninfo/package-info.java new file mode 100644 --- /dev/null +++ b/collab.ui/src/org/netbeans/modules/collab/ui/beaninfo/package-info.java @@ -0,0 +1,5 @@ +@BeanInfoSearchPath +package org.netbeans.modules.collab.ui.beaninfo; + +import org.openide.nodes.BeanInfoSearchPath; + diff --git a/collab.ui/src/org/netbeans/modules/collab/ui/options/AccountNode.java b/collab.ui/src/org/netbeans/modules/collab/ui/options/AccountNode.java --- a/collab.ui/src/org/netbeans/modules/collab/ui/options/AccountNode.java +++ b/collab.ui/src/org/netbeans/modules/collab/ui/options/AccountNode.java @@ -43,20 +43,17 @@ */ package org.netbeans.modules.collab.ui.options; +import com.sun.collablet.*; import java.awt.Image; import java.beans.*; import java.io.IOException; -import java.util.*; - +import org.netbeans.modules.collab.core.Debug; +import org.netbeans.modules.collab.ui.actions.*; import org.openide.actions.*; import org.openide.nodes.*; import org.openide.util.*; import org.openide.util.actions.SystemAction; -import com.sun.collablet.*; -import org.netbeans.modules.collab.core.Debug; -import org.netbeans.modules.collab.ui.actions.*; - /** * * @@ -79,37 +76,6 @@ }; //////////////////////////////////////////////////////////////////////////// - // Static initializer - //////////////////////////////////////////////////////////////////////////// - static { - // Add our own bean info search path, since we want to provide BeanInfo - // for the Account class, but it's in another package. Note, this code - // goes here because this class may be referenced before others in the - // module (including DefaultUserInterface). If, however, other classes - // also want to provide alternate BeanInfo, then this code may need to - // move to the first class likely to be loaded. - final String BEAN_INFO_PATH = "org.netbeans.modules.collab.ui.beaninfo"; // NOI18N - - boolean found = false; - - String[] paths = Introspector.getBeanInfoSearchPath(); - - for (int i = 0; i < paths.length; i++) { - if (paths[i].equals(BEAN_INFO_PATH)) { - found = true; - - break; - } - } - - if (!found) { - List pathList = new ArrayList(Arrays.asList(paths)); - pathList.add(BEAN_INFO_PATH); - Introspector.setBeanInfoSearchPath((String[]) pathList.toArray(new String[pathList.size()])); - } - } - - //////////////////////////////////////////////////////////////////////////// // Instance variables //////////////////////////////////////////////////////////////////////////// private Account account; diff --git a/core.execution/src/org/netbeans/core/execution/Install.java b/core.execution/src/org/netbeans/core/execution/Install.java --- a/core.execution/src/org/netbeans/core/execution/Install.java +++ b/core.execution/src/org/netbeans/core/execution/Install.java @@ -110,23 +110,10 @@ @OnStart public class Install implements Runnable { - private static final String BEANINFO_PATH - = "org.netbeans.core.execution.beaninfo"; // NOI18N - private static final Logger LOG = Logger.getLogger(Install.class.getName()); public @Override void run() { TopSecurityManager.register(SecMan.DEFAULT); - - // Add beaninfo search path. - String[] sp = Introspector.getBeanInfoSearchPath(); - java.util.List paths = Arrays.asList(sp); - if(!paths.contains(BEANINFO_PATH)) { - paths = new ArrayList(paths); - paths.add(BEANINFO_PATH); - Introspector.setBeanInfoSearchPath( - paths.toArray(new String[0])); - } } @OnStop @@ -136,16 +123,6 @@ showPendingTasks(); TopSecurityManager.unregister(SecMan.DEFAULT); - - // Remove beaninfo search path. - String[] sp = Introspector.getBeanInfoSearchPath(); - java.util.List paths = Arrays.asList(sp); - if(paths.contains(BEANINFO_PATH)) { - paths = new ArrayList(paths); - paths.remove(BEANINFO_PATH); - Introspector.setBeanInfoSearchPath( - paths.toArray(new String[0])); - } } } diff --git a/core.execution/src/org/netbeans/core/execution/beaninfo/package-info.java b/core.execution/src/org/netbeans/core/execution/beaninfo/package-info.java new file mode 100644 --- /dev/null +++ b/core.execution/src/org/netbeans/core/execution/beaninfo/package-info.java @@ -0,0 +1,5 @@ +@BeanInfoSearchPath +package org.netbeans.core.execution.beaninfo; + +import org.openide.nodes.BeanInfoSearchPath; + diff --git a/core.startup/apichanges.xml b/core.startup/apichanges.xml --- a/core.startup/apichanges.xml +++ b/core.startup/apichanges.xml @@ -56,6 +56,21 @@ + + + getDefault + + + + + +

+ Adding a new method registerBeanInfoSearchPath to CoreBridge. +

+
+ + +
getDefault diff --git a/core.startup/manifest.mf b/core.startup/manifest.mf --- a/core.startup/manifest.mf +++ b/core.startup/manifest.mf @@ -3,5 +3,5 @@ OpenIDE-Module-Localizing-Bundle: org/netbeans/core/startup/Bundle.properties OpenIDE-Module-Layer: org/netbeans/core/startup/layer.xml OpenIDE-Module-Provides: org.openide.modules.InstalledFileLocator -OpenIDE-Module-Specification-Version: 1.44 +OpenIDE-Module-Specification-Version: 1.45 diff --git a/core.startup/src/org/netbeans/core/startup/CoreBridge.java b/core.startup/src/org/netbeans/core/startup/CoreBridge.java --- a/core.startup/src/org/netbeans/core/startup/CoreBridge.java +++ b/core.startup/src/org/netbeans/core/startup/CoreBridge.java @@ -85,6 +85,10 @@ /** Abstracts away from definition of property editors. * @since 1.7 */ public abstract void registerPropertyEditors(); + + /** + * @since 1.45 */ + public abstract void registerBeanInfoSearchPath(); public abstract Lookup lookupCacheLoad (); @@ -153,6 +157,9 @@ public void registerPropertyEditors() { } + + public void registerBeanInfoSearchPath() { + } public int cli(String[] string, InputStream inputStream, OutputStream outputStream, OutputStream errorStream, File file) { return 0; diff --git a/core.startup/src/org/netbeans/core/startup/Main.java b/core.startup/src/org/netbeans/core/startup/Main.java --- a/core.startup/src/org/netbeans/core/startup/Main.java +++ b/core.startup/src/org/netbeans/core/startup/Main.java @@ -250,18 +250,6 @@ InstalledFileLocatorImpl.prepareCache(); - // Initialize beans - [PENDING - better place for this ?] - // [PENDING - can PropertyEditorManager garbage collect ?] - String[] sysbisp = Introspector.getBeanInfoSearchPath(); - String[] nbbisp = new String[] { - "org.netbeans.beaninfo", // NOI18N - }; - String[] allbisp = new String[sysbisp.length + nbbisp.length]; - System.arraycopy(nbbisp, 0, allbisp, 0, nbbisp.length); - System.arraycopy(sysbisp, 0, allbisp, nbbisp.length, sysbisp.length); - Introspector.setBeanInfoSearchPath(allbisp); - - try { if (!Boolean.getBoolean("netbeans.full.hack") && !Boolean.getBoolean("netbeans.close")) { // ----------------------------------------------------------------------------------------------------- @@ -307,7 +295,11 @@ // property editors are registered in modules, so wait a while before loading them CoreBridge.getDefault().registerPropertyEditors(); StartLog.logProgress ("PropertyEditors registered"); // NOI18N - + + // BeanInfo search paths are registered in module layers. Wait till all modules are loaded + CoreBridge.getDefault().registerBeanInfoSearchPath(); + StartLog.logProgress ("BeanInfo search path registered"); // NOI18N + org.netbeans.Main.finishInitialization(); StartLog.logProgress("Ran any delayed command-line options"); // NOI18N diff --git a/form/src/org/netbeans/modules/form/FormEditorModule.java b/form/src/org/netbeans/modules/form/FormEditorModule.java --- a/form/src/org/netbeans/modules/form/FormEditorModule.java +++ b/form/src/org/netbeans/modules/form/FormEditorModule.java @@ -45,10 +45,6 @@ package org.netbeans.modules.form; import java.beans.Beans; -import java.beans.Introspector; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import org.openide.modules.ModuleInstall; /** @@ -56,9 +52,6 @@ */ public class FormEditorModule extends ModuleInstall { - private static final String BEANINFO_PATH_AWT = "org.netbeans.modules.form.beaninfo.awt"; // NOI18N - private static final String BEANINFO_PATH_SWING = "org.netbeans.modules.form.beaninfo.swing"; // NOI18N - @Override public void restored() { Beans.setDesignTime(true); @@ -69,26 +62,10 @@ javax.swing.KeyStroke.class, org.netbeans.modules.form.editors.KeyStrokeEditor.class); - // Add beaninfo search path. - String[] sp = Introspector.getBeanInfoSearchPath(); - List paths = new ArrayList(Arrays.asList(sp)); - if (!paths.contains(BEANINFO_PATH_AWT)) { - paths.add(BEANINFO_PATH_AWT); - } - if (!paths.contains(BEANINFO_PATH_SWING)) { - paths.add(BEANINFO_PATH_SWING); - } - Introspector.setBeanInfoSearchPath(paths.toArray(new String[paths.size()])); } @Override public void uninstalled() { - // Remove beaninfo search path. - String[] sp = Introspector.getBeanInfoSearchPath(); - List paths = new ArrayList(Arrays.asList(sp)); - paths.remove(BEANINFO_PATH_AWT); - paths.remove(BEANINFO_PATH_SWING); - Introspector.setBeanInfoSearchPath(paths.toArray(new String[paths.size()])); } } diff --git a/form/src/org/netbeans/modules/form/beaninfo/awt/package-info.java b/form/src/org/netbeans/modules/form/beaninfo/awt/package-info.java new file mode 100644 --- /dev/null +++ b/form/src/org/netbeans/modules/form/beaninfo/awt/package-info.java @@ -0,0 +1,5 @@ +@BeanInfoSearchPath +package org.netbeans.modules.form.beaninfo.awt; + +import org.openide.nodes.BeanInfoSearchPath; + diff --git a/form/src/org/netbeans/modules/form/beaninfo/swing/package-info.java b/form/src/org/netbeans/modules/form/beaninfo/swing/package-info.java new file mode 100644 --- /dev/null +++ b/form/src/org/netbeans/modules/form/beaninfo/swing/package-info.java @@ -0,0 +1,5 @@ +@BeanInfoSearchPath +package org.netbeans.modules.form.beaninfo.swing; + +import org.openide.nodes.BeanInfoSearchPath; + diff --git a/ide.kit/test/qa-functional/data/whitelist_1.txt b/ide.kit/test/qa-functional/data/whitelist_1.txt --- a/ide.kit/test/qa-functional/data/whitelist_1.txt +++ b/ide.kit/test/qa-functional/data/whitelist_1.txt @@ -1,12 +1,16 @@ #OK on Nov 22, 2012, was #218044 org.netbeans.modules.javascript2.editor.ModuleInstaller +#OK on Nov 22, 2012, was #210323 +org.netbeans.modules.openide.nodes.NodesRegistrationSupport$BeanInfoReg +org.netbeans.modules.openide.nodes.NodesRegistrationSupport$BeanInfoRegistration + #OK on Oct 29, 2012, was #220904 -org.netbeans.modules.openide.nodes.PERegistrationSupport -org.netbeans.modules.openide.nodes.PERegistrationSupport$ClassReg -org.netbeans.modules.openide.nodes.PERegistrationSupport$PEClassRegistration -org.netbeans.modules.openide.nodes.PERegistrationSupport$PEPackageRegistration -org.netbeans.modules.openide.nodes.PERegistrationSupport$PkgReg +org.netbeans.modules.openide.nodes.NodesRegistrationSupport +org.netbeans.modules.openide.nodes.NodesRegistrationSupport$ClassReg +org.netbeans.modules.openide.nodes.NodesRegistrationSupport$PEClassRegistration +org.netbeans.modules.openide.nodes.NodesRegistrationSupport$PEPackageRegistration +org.netbeans.modules.openide.nodes.NodesRegistrationSupport$PkgReg #OK on Oct 31, 2012, needed because of enabled logging due to #220899 org.eclipse.core.runtime.internal.adaptor.EclipseLogFactory diff --git a/o.n.core/src/org/netbeans/beaninfo/package-info.java b/o.n.core/src/org/netbeans/beaninfo/package-info.java new file mode 100644 --- /dev/null +++ b/o.n.core/src/org/netbeans/beaninfo/package-info.java @@ -0,0 +1,5 @@ +@BeanInfoSearchPath +package org.netbeans.beaninfo; + +import org.openide.nodes.BeanInfoSearchPath; + diff --git a/o.n.core/src/org/netbeans/core/CoreBridgeImpl.java b/o.n.core/src/org/netbeans/core/CoreBridgeImpl.java --- a/o.n.core/src/org/netbeans/core/CoreBridgeImpl.java +++ b/o.n.core/src/org/netbeans/core/CoreBridgeImpl.java @@ -163,6 +163,10 @@ public void registerPropertyEditors() { doRegisterPropertyEditors(); } + + public void registerBeanInfoSearchPath() { + NodeOp.registerBeanInfoSearchPath(); + } /**Flag to avoid multiple adds of the same path to the * of PropertyEditorManager if multiple tests call diff --git a/openide.nodes/apichanges.xml b/openide.nodes/apichanges.xml --- a/openide.nodes/apichanges.xml +++ b/openide.nodes/apichanges.xml @@ -49,6 +49,23 @@ Nodes API + + + Adding @BeanInfoSearchPath annotation + + + + + +

+ Adding @BeanInfoSearchPath annotation + to allow convenient way of registering BeanInfo search path. +

+
+ + + +
Adding @PropertyEditorRegistration and @PropertyEditorSearchPath annotations diff --git a/openide.nodes/manifest.mf b/openide.nodes/manifest.mf --- a/openide.nodes/manifest.mf +++ b/openide.nodes/manifest.mf @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.nodes OpenIDE-Module-Localizing-Bundle: org/openide/nodes/Bundle.properties AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 7.31 +OpenIDE-Module-Specification-Version: 7.32 diff --git a/openide.nodes/src/org/netbeans/modules/openide/nodes/PEAnnotationProcessor.java b/openide.nodes/src/org/netbeans/modules/openide/nodes/NodesAnnotationProcessor.java rename from openide.nodes/src/org/netbeans/modules/openide/nodes/PEAnnotationProcessor.java rename to openide.nodes/src/org/netbeans/modules/openide/nodes/NodesAnnotationProcessor.java --- a/openide.nodes/src/org/netbeans/modules/openide/nodes/PEAnnotationProcessor.java +++ b/openide.nodes/src/org/netbeans/modules/openide/nodes/NodesAnnotationProcessor.java @@ -64,6 +64,7 @@ import org.openide.filesystems.annotations.LayerBuilder; import org.openide.filesystems.annotations.LayerGeneratingProcessor; import org.openide.filesystems.annotations.LayerGenerationException; +import org.openide.nodes.BeanInfoSearchPath; import org.openide.nodes.PropertyEditorRegistration; import org.openide.nodes.PropertyEditorSearchPath; import org.openide.util.lookup.ServiceProvider; @@ -76,9 +77,9 @@ */ @ServiceProvider(service=Processor.class) @SupportedSourceVersion(SourceVersion.RELEASE_6) -public class PEAnnotationProcessor extends LayerGeneratingProcessor { +public class NodesAnnotationProcessor extends LayerGeneratingProcessor { - public PEAnnotationProcessor() { + public NodesAnnotationProcessor() { } @Override @@ -86,6 +87,7 @@ Set set = new HashSet(); set.add(PropertyEditorSearchPath.class.getName()); set.add(PropertyEditorRegistration.class.getName()); + set.add(BeanInfoSearchPath.class.getName()); return set; } @@ -93,19 +95,22 @@ protected boolean handleProcess(Set annotations, RoundEnvironment roundEnv) throws LayerGenerationException { Messager messager = processingEnv.getMessager(); + + // handle @PropertyEditorSearchPath for (Element e : roundEnv.getElementsAnnotatedWith(PropertyEditorSearchPath.class)) { String pkg = findPackage(e); String pkgFilename = pkg.replace(".", "-"); //NOI18N LayerBuilder builder = layer(e); - LayerBuilder.File file = builder.file(PERegistrationSupport.LOOKUP_PATH + LayerBuilder.File file = builder.file(NodesRegistrationSupport.PE_LOOKUP_PATH + "/Package-" + pkgFilename + ".instance"); //NOI18N - file.methodvalue("instanceCreate", PERegistrationSupport.class.getName(), + file.methodvalue("instanceCreate", NodesRegistrationSupport.class.getName(), "createPackageRegistration"); //NOI18N - file.stringvalue(PERegistrationSupport.PACKAGE, pkg); - file.stringvalue("instanceOf", PERegistrationSupport.PEPackageRegistration.class.getName()); + file.stringvalue(NodesRegistrationSupport.PACKAGE, pkg); + file.stringvalue("instanceOf", NodesRegistrationSupport.PEPackageRegistration.class.getName()); file.write(); } + // handle @PropertyEditorRegistration for (Element e : roundEnv.getElementsAnnotatedWith(PropertyEditorRegistration.class)) { if (e.getKind() == ElementKind.CLASS) { String className = ((TypeElement) e).getQualifiedName().toString(); @@ -130,10 +135,10 @@ LayerBuilder builder = layer(e); String clsFileName = className.replace(".", "-"); //NOI18N - LayerBuilder.File file = builder.instanceFile(PERegistrationSupport.LOOKUP_PATH, "Class-" + clsFileName); //NOI18N - file.methodvalue("instanceCreate", PERegistrationSupport.class.getName(), "createClassRegistration"); //NOI18N - file.stringvalue(PERegistrationSupport.EDITOR_CLASS, className); //NOI18N - file.stringvalue("instanceOf", PERegistrationSupport.PEClassRegistration.class.getName()); + LayerBuilder.File file = builder.instanceFile(NodesRegistrationSupport.PE_LOOKUP_PATH, "Class-" + clsFileName); //NOI18N + file.methodvalue("instanceCreate", NodesRegistrationSupport.class.getName(), "createClassRegistration"); //NOI18N + file.stringvalue(NodesRegistrationSupport.EDITOR_CLASS, className); //NOI18N + file.stringvalue("instanceOf", NodesRegistrationSupport.PEClassRegistration.class.getName()); int i = 1; for (AnnotationValue type : targetTypes) { String clsName = type.accept(new SimpleAnnotationValueVisitor6() { @@ -149,6 +154,20 @@ file.write(); } } + + // handle @BeanInfoSearchPath + for (Element e : roundEnv.getElementsAnnotatedWith(BeanInfoSearchPath.class)) { + String pkg = findPackage(e); + String pkgFilename = pkg.replace(".", "-"); //NOI18N + LayerBuilder builder = layer(e); + LayerBuilder.File file = builder.file(NodesRegistrationSupport.BEANINFO_LOOKUP_PATH + + "/BeanInfo-" + pkgFilename + ".instance"); //NOI18N + file.methodvalue("instanceCreate", NodesRegistrationSupport.class.getName(), + "createBeanInfoRegistration"); //NOI18N + file.stringvalue(NodesRegistrationSupport.PACKAGE, pkg); + file.stringvalue("instanceOf", NodesRegistrationSupport.BeanInfoRegistration.class.getName()); + file.write(); + } return true; } diff --git a/openide.nodes/src/org/netbeans/modules/openide/nodes/PERegistrationSupport.java b/openide.nodes/src/org/netbeans/modules/openide/nodes/NodesRegistrationSupport.java rename from openide.nodes/src/org/netbeans/modules/openide/nodes/PERegistrationSupport.java rename to openide.nodes/src/org/netbeans/modules/openide/nodes/NodesRegistrationSupport.java --- a/openide.nodes/src/org/netbeans/modules/openide/nodes/PERegistrationSupport.java +++ b/openide.nodes/src/org/netbeans/modules/openide/nodes/NodesRegistrationSupport.java @@ -41,6 +41,7 @@ */ package org.netbeans.modules.openide.nodes; +import java.beans.Introspector; import java.beans.PropertyEditorManager; import java.lang.reflect.Array; import java.util.Arrays; @@ -59,14 +60,16 @@ * * @author Jan Horvath */ -public final class PERegistrationSupport { +public final class NodesRegistrationSupport { - static final String LOOKUP_PATH = "Services/PropertyEditorManager"; //NOI18N + static final String PE_LOOKUP_PATH = "Services/PropertyEditorManager"; //NOI18N + static final String BEANINFO_LOOKUP_PATH = "Services/Introspector"; //NOI18N static final String PACKAGE = "packagePath"; //NOI18N static final String EDITOR_CLASS = "propertyEditorClass"; //NOI18N - static ClassReg clsReg = null; - static PkgReg pkgReg = null; + private static ClassReg clsReg = null; + private static PkgReg pkgReg = null; + private static BeanInfoReg beanInfoReg = null; public static synchronized void registerPropertyEditors() { if (clsReg == null) { @@ -77,6 +80,12 @@ } } + public static void registerBeanInfoSearchPath() { + if (beanInfoReg == null) { + beanInfoReg = new BeanInfoReg(); + } + } + /** * Creates instance of PEPackageRegistration based on layer.xml * attribute values @@ -109,6 +118,11 @@ return new PEClassRegistration(editorClass, targetTypes); } + public static BeanInfoRegistration createBeanInfoRegistration(final Map attrs) { + String pkg = (String) attrs.get(PACKAGE); + return new BeanInfoRegistration(pkg); + } + /** * returns Class from canonical class name like java.lang.String[] */ @@ -149,7 +163,7 @@ } return result; } - + public static class PEPackageRegistration { final String pkg; @@ -168,17 +182,25 @@ } } + public static class BeanInfoRegistration { + final String searchPath; + + BeanInfoRegistration(String searchPath) { + this.searchPath = searchPath; + } + } + private static final class ClassReg implements LookupListener { Result lookupResult = null; ClassReg() { - lookupResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEClassRegistration.class); + lookupResult = Lookup.getDefault().lookupResult(NodesRegistrationSupport.PEClassRegistration.class); register(); lookupResult.addLookupListener(this); } synchronized void register() { - lookupResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEClassRegistration.class); + lookupResult = Lookup.getDefault().lookupResult(NodesRegistrationSupport.PEClassRegistration.class); ClassLoader clsLoader = Thread.currentThread().getContextClassLoader(); for (PEClassRegistration clsReg : lookupResult.allInstances()) { @@ -208,13 +230,13 @@ if (originalPath == null) { originalPath = Arrays.asList(PropertyEditorManager.getEditorSearchPath()); } - pkgResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEPackageRegistration.class); + pkgResult = Lookup.getDefault().lookupResult(NodesRegistrationSupport.PEPackageRegistration.class); register(); pkgResult.addLookupListener(this); } synchronized void register() { - pkgResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEPackageRegistration.class); + pkgResult = Lookup.getDefault().lookupResult(NodesRegistrationSupport.PEPackageRegistration.class); Set newPath = new LinkedHashSet (); for (PEPackageRegistration pkgReg : pkgResult.allInstances()) { newPath.add(pkgReg.pkg); @@ -228,4 +250,34 @@ register(); } } + + static final class BeanInfoReg implements LookupListener { + Result beanInfoResult; + private static List originalPath = null; + + BeanInfoReg() { + if (originalPath == null) { + originalPath = Arrays.asList(Introspector.getBeanInfoSearchPath()); + } + beanInfoResult = Lookup.getDefault().lookupResult(BeanInfoRegistration.class); + register(); + beanInfoResult.addLookupListener(this); + } + + synchronized void register() { + beanInfoResult = Lookup.getDefault().lookupResult(BeanInfoRegistration.class); + Set newPath = new LinkedHashSet (); + for (BeanInfoRegistration biReg : beanInfoResult.allInstances()) { + newPath.add(biReg.searchPath); + } + newPath.addAll(originalPath); + Introspector.setBeanInfoSearchPath(newPath.toArray(new String[newPath.size()])); + } + + @Override + public void resultChanged(LookupEvent ev) { + register(); + } + } + } diff --git a/openide.nodes/src/org/openide/nodes/BeanInfoSearchPath.java b/openide.nodes/src/org/openide/nodes/BeanInfoSearchPath.java new file mode 100644 --- /dev/null +++ b/openide.nodes/src/org/openide/nodes/BeanInfoSearchPath.java @@ -0,0 +1,59 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.openide.nodes; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Add the annotated package to the list of package names that will be used for finding BeanInfo. + * + * @since 7.32 + * @author Jan Horvath + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.PACKAGE) +public @interface BeanInfoSearchPath { + +} diff --git a/openide.nodes/src/org/openide/nodes/NodeOp.java b/openide.nodes/src/org/openide/nodes/NodeOp.java --- a/openide.nodes/src/org/openide/nodes/NodeOp.java +++ b/openide.nodes/src/org/openide/nodes/NodeOp.java @@ -56,7 +56,7 @@ import java.util.logging.Logger; import javax.swing.Action; import javax.swing.JPopupMenu; -import org.netbeans.modules.openide.nodes.PERegistrationSupport; +import org.netbeans.modules.openide.nodes.NodesRegistrationSupport; import org.openide.util.Enumerations; import org.openide.util.Lookup; import org.openide.util.Utilities; @@ -468,7 +468,15 @@ * @since 7.30 */ public static void registerPropertyEditors() { - PERegistrationSupport.registerPropertyEditors(); + NodesRegistrationSupport.registerPropertyEditors(); + } + + /** Registers BeanInfo search path collected from @BeanInfoSearchPath annotations + * + * @since 7.32 + */ + public static void registerBeanInfoSearchPath() { + NodesRegistrationSupport.registerBeanInfoSearchPath(); } /** more info in class javadoc. diff --git a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PEAnnotationProcessorTest.java b/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PEAnnotationProcessorTest.java --- a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PEAnnotationProcessorTest.java +++ b/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PEAnnotationProcessorTest.java @@ -41,14 +41,15 @@ */ package org.netbeans.modules.openide.nodes; +import java.beans.Introspector; import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Collection; import org.netbeans.junit.NbTestCase; -import org.netbeans.modules.openide.nodes.PERegistrationSupport.PEClassRegistration; -import org.netbeans.modules.openide.nodes.PERegistrationSupport.PEPackageRegistration; +import org.netbeans.modules.openide.nodes.NodesRegistrationSupport.PEClassRegistration; +import org.netbeans.modules.openide.nodes.NodesRegistrationSupport.PEPackageRegistration; import org.openide.nodes.NodeOp; import org.openide.util.Lookup; import org.openide.util.test.AnnotationProcessorTestUtils; @@ -147,5 +148,17 @@ PEPackageRegistration pkgReg = lookup.iterator().next(); assertEquals("org.netbeans.modules.openide.nodes", pkgReg.pkg); } + + public void testBeanInfoRegistration() { + String[] path = Introspector.getBeanInfoSearchPath(); + int l = path.length; + NodeOp.registerBeanInfoSearchPath(); + path = Introspector.getBeanInfoSearchPath(); + assertTrue(path.length == l + 1); + for (int i = 0; i < path.length; i++) { + System.out.println("- " + path[i]); + + } + } } diff --git a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PELookupTest.java b/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PELookupTest.java --- a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PELookupTest.java +++ b/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PELookupTest.java @@ -62,9 +62,9 @@ } public void testPackageUnregistering() { - MockLookup.setInstances(new PERegistrationSupport.PEPackageRegistration("test1.pkg")); + MockLookup.setInstances(new NodesRegistrationSupport.PEPackageRegistration("test1.pkg")); NodeOp.registerPropertyEditors(); - MockLookup.setInstances(new PERegistrationSupport.PEPackageRegistration("test2.pkg")); + MockLookup.setInstances(new NodesRegistrationSupport.PEPackageRegistration("test2.pkg")); String[] editorSearchPath = PropertyEditorManager.getEditorSearchPath(); int count = 0; diff --git a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PERegistrationSupportTest.java b/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PERegistrationSupportTest.java --- a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PERegistrationSupportTest.java +++ b/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PERegistrationSupportTest.java @@ -54,7 +54,7 @@ } public void doTest(String type) throws ClassNotFoundException { - Class cls = PERegistrationSupport.getClassFromCanonicalName(type); + Class cls = NodesRegistrationSupport.getClassFromCanonicalName(type); assertEquals(type, cls.getCanonicalName()); } diff --git a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/package-info.java b/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/package-info.java --- a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/package-info.java +++ b/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/package-info.java @@ -1,5 +1,7 @@ @PropertyEditorSearchPath +@BeanInfoSearchPath package org.netbeans.modules.openide.nodes; +import org.openide.nodes.BeanInfoSearchPath; import org.openide.nodes.PropertyEditorSearchPath; diff --git a/xml.tax/src/org/netbeans/modules/xml/tax/TAXModuleInstall.java b/xml.tax/src/org/netbeans/modules/xml/tax/TAXModuleInstall.java deleted file mode 100644 --- a/xml.tax/src/org/netbeans/modules/xml/tax/TAXModuleInstall.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ -package org.netbeans.modules.xml.tax; - -import java.beans.*; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import org.openide.modules.OnStart; -import org.openide.modules.OnStop; - -/** - * Module installation class for tax module. - * - * @author Libor Kramolis - */ -@OnStart -public class TAXModuleInstall implements Runnable { - - private static final String BEANINFO_PATH = "org.netbeans.modules.xml.tax.beans.beaninfo"; // NOI18N - - @Override - public void run () { - String[] sp = Introspector.getBeanInfoSearchPath(); - String[] newSP = new String[sp.length + 1]; - System.arraycopy(sp, 0, newSP, 0, sp.length); - newSP[newSP.length - 1] = BEANINFO_PATH; - Introspector.setBeanInfoSearchPath(newSP); - } - - @OnStop - public static final class Down implements Runnable{ - - @Override - public void run () { - List searchPath; - - searchPath = new LinkedList (Arrays.asList (Introspector.getBeanInfoSearchPath())); - searchPath.remove (BEANINFO_PATH); - Introspector.setBeanInfoSearchPath ((String[])searchPath.toArray (new String[0])); - } - } - -} diff --git a/xml.tax/src/org/netbeans/modules/xml/tax/beans/beaninfo/package-info.java b/xml.tax/src/org/netbeans/modules/xml/tax/beans/beaninfo/package-info.java new file mode 100644 --- /dev/null +++ b/xml.tax/src/org/netbeans/modules/xml/tax/beans/beaninfo/package-info.java @@ -0,0 +1,5 @@ +@BeanInfoSearchPath +package org.netbeans.modules.xml.tax.beans.beaninfo; + +import org.openide.nodes.BeanInfoSearchPath; +