diff --git a/j2me.cdc.platform/src/org/netbeans/modules/j2me/cdc/platform/CDCInstallImpl.java b/j2me.cdc.platform/src/org/netbeans/modules/j2me/cdc/platform/CDCInstallImpl.java --- a/j2me.cdc.platform/src/org/netbeans/modules/j2me/cdc/platform/CDCInstallImpl.java +++ b/j2me.cdc.platform/src/org/netbeans/modules/j2me/cdc/platform/CDCInstallImpl.java @@ -48,6 +48,8 @@ import org.netbeans.modules.j2me.cdc.platform.spi.CDCPlatformDetector; import org.netbeans.modules.j2me.cdc.platform.wizard.CDCWizardIterator; +import org.netbeans.spi.java.platform.PlatformInstall; +import org.netbeans.spi.java.platform.PlatformInstallRegistration; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; import org.openide.util.Lookup; @@ -58,17 +60,11 @@ * * @author Svatopluk Dedic */ -class CDCInstallImpl extends org.netbeans.spi.java.platform.PlatformInstall { +@PlatformInstallRegistration(position=400) +public class CDCInstallImpl extends PlatformInstall { private CDCPlatformDetector detector; - CDCInstallImpl() { - } - - static CDCInstallImpl create() { - return new CDCInstallImpl(); - } - /** * Performs a quick & dirty check whether there's a JRE installed. * The method looks into the folder for something, which - depending on diff --git a/j2me.cdc.platform/src/org/netbeans/modules/j2me/cdc/platform/resources/layer.xml b/j2me.cdc.platform/src/org/netbeans/modules/j2me/cdc/platform/resources/layer.xml --- a/j2me.cdc.platform/src/org/netbeans/modules/j2me/cdc/platform/resources/layer.xml +++ b/j2me.cdc.platform/src/org/netbeans/modules/j2me/cdc/platform/resources/layer.xml @@ -46,17 +46,6 @@ - - - - - - - - - - - diff --git a/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/J2SEInstallImpl.java b/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/J2SEInstallImpl.java --- a/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/J2SEInstallImpl.java +++ b/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/J2SEInstallImpl.java @@ -52,6 +52,8 @@ import java.io.IOException; import java.util.Collections; +import org.netbeans.spi.java.platform.PlatformInstall; +import org.netbeans.spi.java.platform.PlatformInstallRegistration; import org.openide.WizardDescriptor; @@ -60,14 +62,8 @@ * * @author Svatopluk Dedic */ -class J2SEInstallImpl extends org.netbeans.spi.java.platform.PlatformInstall { - - J2SEInstallImpl() { - } - - static J2SEInstallImpl create() { - return new J2SEInstallImpl(); - } +@PlatformInstallRegistration(position=100) +public class J2SEInstallImpl extends PlatformInstall { /** * Performs a quick & dirty check whether there's a JRE installed. diff --git a/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/resources/layer.xml b/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/resources/layer.xml --- a/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/resources/layer.xml +++ b/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/resources/layer.xml @@ -56,18 +56,6 @@ - - - - - - - - - - - - diff --git a/java.platform/src/org/netbeans/modules/java/platform/InstallerRegistry.java b/java.platform/src/org/netbeans/modules/java/platform/InstallerRegistry.java --- a/java.platform/src/org/netbeans/modules/java/platform/InstallerRegistry.java +++ b/java.platform/src/org/netbeans/modules/java/platform/InstallerRegistry.java @@ -63,7 +63,7 @@ */ public class InstallerRegistry { - private static final String INSTALLER_REGISTRY_FOLDER = "org-netbeans-api-java/platform/installers"; // NOI18N + public static final String INSTALLER_REGISTRY_FOLDER = "org-netbeans-api-java/platform/installers"; // NOI18N private static Reference defaultInstance = new WeakReference(null); private static final Logger LOG = Logger.getLogger(InstallerRegistry.class.getName()); @@ -102,6 +102,7 @@ return platformInstalls; } else { + this.lookup.lookupAll(GeneralPlatformInstall.class); // MISL bug? otherwise ordering is wrong this.lookup.lookupAll(CustomPlatformInstall.class); this.lookup.lookupAll(PlatformInstall.class); final List installs = diff --git a/java.platform/src/org/netbeans/spi/java/platform/PlatformInstallRegistration.java b/java.platform/src/org/netbeans/spi/java/platform/PlatformInstallRegistration.java new file mode 100644 --- /dev/null +++ b/java.platform/src/org/netbeans/spi/java/platform/PlatformInstallRegistration.java @@ -0,0 +1,57 @@ +/* + * 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.netbeans.spi.java.platform; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import org.netbeans.modules.java.platform.InstallerRegistry; +import org.openide.util.lookup.NamedServiceDefinition; + +@NamedServiceDefinition(path=InstallerRegistry.INSTALLER_REGISTRY_FOLDER, serviceType={GeneralPlatformInstall.class, PlatformInstall.class, CustomPlatformInstall.class}) +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.TYPE) +public @interface PlatformInstallRegistration { + int position() default Integer.MAX_VALUE; +} diff --git a/java.platform/test/unit/src/org/netbeans/modules/java/platform/PlatformInstallTest.java b/java.platform/test/unit/src/org/netbeans/modules/java/platform/PlatformInstallTest.java --- a/java.platform/test/unit/src/org/netbeans/modules/java/platform/PlatformInstallTest.java +++ b/java.platform/test/unit/src/org/netbeans/modules/java/platform/PlatformInstallTest.java @@ -66,8 +66,7 @@ } public void testLookup () { - final String INSTALLER_REGISTRY_FOLDER = "org-netbeans-api-java/platform/installers"; // NOI18N - final Lookup lkp = Lookups.forPath(INSTALLER_REGISTRY_FOLDER); + final Lookup lkp = Lookups.forPath(InstallerRegistry.INSTALLER_REGISTRY_FOLDER); lkp.lookupAll(GeneralPlatformInstall.class); assertEquals(0,lkp.lookupAll(CustomPlatformInstall.class).size()); diff --git a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/customwizard/Installer.java b/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/customwizard/Installer.java --- a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/customwizard/Installer.java +++ b/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/customwizard/Installer.java @@ -46,22 +46,16 @@ import org.openide.util.NbBundle; import org.openide.WizardDescriptor; import org.netbeans.spi.java.platform.CustomPlatformInstall; +import org.netbeans.spi.java.platform.PlatformInstallRegistration; /** * Installer factory for standard UEI Emulator * * @author Adam Sotona */ +@PlatformInstallRegistration(position=300) public class Installer extends CustomPlatformInstall { - static Installer create() { - return new Installer(); - } - - private Installer() { - //to avoid instantiation - } - public WizardDescriptor.InstantiatingIterator createIterator() { return InstallerIterator.getDefault(); } diff --git a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/resources/layer.xml b/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/resources/layer.xml --- a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/resources/layer.xml +++ b/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/resources/layer.xml @@ -44,23 +44,6 @@ made subject to such option by the copyright holder. --> - - - - - - - - - - - - - - - - - diff --git a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/wizard/Installer.java b/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/wizard/Installer.java --- a/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/wizard/Installer.java +++ b/mobility.cldcplatform/src/org/netbeans/modules/mobility/cldcplatform/wizard/Installer.java @@ -46,18 +46,16 @@ import org.openide.util.NbBundle; import org.openide.WizardDescriptor; import org.netbeans.spi.java.platform.CustomPlatformInstall; +import org.netbeans.spi.java.platform.PlatformInstallRegistration; /** * Installer factory for standard UEI Emulator * * @author Adam Sotona */ +@PlatformInstallRegistration(position=200) public class Installer extends CustomPlatformInstall { - static Installer create() { - return new Installer(); - } - public WizardDescriptor.InstantiatingIterator createIterator() { return InstallerIterator.getDefault(); }