@ProjectServiceProvider is preferred to @LookupProvider.Registration.
authorJesse Glick <jglick@netbeans.org>
Fri, 15 Jul 2011 09:51:22 -0400
changeset 175233a011dc2eb95
parent 17522 8c7f9a8e07bb
child 17525 d81178ecf7de
child 17527 b877c5fbce8d
@ProjectServiceProvider is preferred to @LookupProvider.Registration.
hudsonfindbugs/manifest.mf
hudsonfindbugs/nbproject/project.xml
hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/FindBugsProjectLookupProvider.java
hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/J2seFindBugsQueryProvider.java
hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/NBMFindBugsQueryProvider.java
hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/api/FindBugsQuery.java
hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/spi/FindBugsQueryImplementation.java
     1.1 --- a/hudsonfindbugs/manifest.mf	Fri Jul 15 09:28:42 2011 -0400
     1.2 +++ b/hudsonfindbugs/manifest.mf	Fri Jul 15 09:51:22 2011 -0400
     1.3 @@ -2,5 +2,5 @@
     1.4  OpenIDE-Module: org.netbeans.modules.hudsonfindbugs
     1.5  OpenIDE-Module-Layer: org/netbeans/modules/hudsonfindbugs/layer.xml
     1.6  OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/hudsonfindbugs/Bundle.properties
     1.7 -OpenIDE-Module-Specification-Version: 1.9
     1.8 +OpenIDE-Module-Specification-Version: 1.10
     1.9  
     2.1 --- a/hudsonfindbugs/nbproject/project.xml	Fri Jul 15 09:28:42 2011 -0400
     2.2 +++ b/hudsonfindbugs/nbproject/project.xml	Fri Jul 15 09:51:22 2011 -0400
     2.3 @@ -47,7 +47,7 @@
     2.4                      <compile-dependency/>
     2.5                      <run-dependency>
     2.6                          <release-version>1</release-version>
     2.7 -                        <specification-version>1.13</specification-version>
     2.8 +                        <specification-version>1.23</specification-version>
     2.9                      </run-dependency>
    2.10                  </dependency>
    2.11                  <dependency>
     3.1 --- a/hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/FindBugsProjectLookupProvider.java	Fri Jul 15 09:28:42 2011 -0400
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,83 +0,0 @@
     3.4 -/*
     3.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3.6 - * 
     3.7 - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     3.8 - * 
     3.9 - * The contents of this file are subject to the terms of either the GNU
    3.10 - * General Public License Version 2 only ("GPL") or the Common
    3.11 - * Development and Distribution License("CDDL") (collectively, the
    3.12 - * "License"). You may not use this file except in compliance with the
    3.13 - * License. You can obtain a copy of the License at
    3.14 - * http://www.netbeans.org/cddl-gplv2.html
    3.15 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    3.16 - * specific language governing permissions and limitations under the
    3.17 - * License.  When distributing the software, include this License Header
    3.18 - * Notice in each file and include the License file at
    3.19 - * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    3.20 - * particular file as subject to the "Classpath" exception as provided
    3.21 - * by Sun in the GPL Version 2 section of the License file that
    3.22 - * accompanied this code. If applicable, add the following below the
    3.23 - * License Header, with the fields enclosed by brackets [] replaced by
    3.24 - * your own identifying information:
    3.25 - * "Portions Copyrighted [year] [name of copyright owner]"
    3.26 - * 
    3.27 - * If you wish your version of this file to be governed by only the CDDL
    3.28 - * or only the GPL Version 2, indicate your decision by adding
    3.29 - * "[Contributor] elects to include this software in this distribution
    3.30 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    3.31 - * single choice of license, a recipient has the option to distribute
    3.32 - * your version of this file under either the CDDL, the GPL Version 2 or
    3.33 - * to extend the choice of license to its licensees as provided above.
    3.34 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    3.35 - * Version 2 license, then the option applies only if the new code is
    3.36 - * made subject to such option by the copyright holder.
    3.37 - * 
    3.38 - * Contributor(s):
    3.39 - * 
    3.40 - * Portions Copyrighted 2007 Sun Microsystems, Inc.
    3.41 - */
    3.42 -
    3.43 -package org.netbeans.modules.hudsonfindbugs;
    3.44 -
    3.45 -import org.netbeans.spi.project.LookupProvider;
    3.46 -import org.openide.util.Lookup;
    3.47 -import org.openide.util.lookup.Lookups;
    3.48 -
    3.49 -/**
    3.50 - *
    3.51 - * @author mkleint
    3.52 - */
    3.53 -public class FindBugsProjectLookupProvider implements LookupProvider {
    3.54 -    
    3.55 -    enum Type {
    3.56 -        J2SE,
    3.57 -        NBM
    3.58 -    }
    3.59 -    private Type type;
    3.60 -    
    3.61 -    private FindBugsProjectLookupProvider(Type type) {
    3.62 -        this.type = type;
    3.63 -    }
    3.64 -    
    3.65 -
    3.66 -    public Lookup createAdditionalLookup(Lookup baseContext) {
    3.67 -        //TODO asset check on the content of lookup
    3.68 -        if (type == Type.J2SE) {
    3.69 -            return Lookups.singleton(J2seFindBugsQueryProvider.createInstance());
    3.70 -        } else if (type == Type.NBM) {
    3.71 -            return Lookups.singleton(NBMFindBugsQueryProvider.createInstance());
    3.72 -        }
    3.73 -        return null;
    3.74 -    }
    3.75 -
    3.76 -    @LookupProvider.Registration(projectType="org-netbeans-modules-java-j2seproject")
    3.77 -    public static LookupProvider createJ2SELookupProvider() {
    3.78 -        return new FindBugsProjectLookupProvider(Type.J2SE);
    3.79 -    }
    3.80 -    
    3.81 -    @LookupProvider.Registration(projectType="org-netbeans-modules-apisupport-project")
    3.82 -    public static LookupProvider createNBMLookupProvider() {
    3.83 -        return new FindBugsProjectLookupProvider(Type.NBM);
    3.84 -    }
    3.85 -
    3.86 -}
     4.1 --- a/hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/J2seFindBugsQueryProvider.java	Fri Jul 15 09:28:42 2011 -0400
     4.2 +++ b/hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/J2seFindBugsQueryProvider.java	Fri Jul 15 09:51:22 2011 -0400
     4.3 @@ -47,24 +47,25 @@
     4.4  import org.netbeans.api.project.Project;
     4.5  import org.netbeans.modules.hudsonfindbugs.spi.FindBugsQueryImplementation;
     4.6  import org.netbeans.modules.java.j2seproject.api.J2SEPropertyEvaluator;
     4.7 +import org.netbeans.spi.project.ProjectServiceProvider;
     4.8  
     4.9  /**
    4.10   *
    4.11   * @author Martin Grebac
    4.12   */
    4.13 +@ProjectServiceProvider(service=FindBugsQueryImplementation.class, projectType="org-netbeans-modules-java-j2seproject")
    4.14  public final class J2seFindBugsQueryProvider implements FindBugsQueryImplementation {
    4.15  
    4.16      private static final Logger LOG = Logger.getLogger(J2seFindBugsQueryProvider.class.getName());
    4.17  
    4.18 -    public J2seFindBugsQueryProvider() {}
    4.19 -    
    4.20 -    public static FindBugsQueryImplementation createInstance() {
    4.21 -        // TODO possibly also use just one static instance everywhere..
    4.22 -        return new J2seFindBugsQueryProvider();
    4.23 +    private final Project project;
    4.24 +
    4.25 +    public J2seFindBugsQueryProvider(Project project) {
    4.26 +        this.project = project;
    4.27      }
    4.28      
    4.29      @CheckForNull
    4.30 -    public URL getFindBugsUrl(Project project, boolean remote) {
    4.31 +    public URL getFindBugsUrl(boolean remote) {
    4.32          if (!remote) {
    4.33              return null;
    4.34          }
    4.35 @@ -80,7 +81,7 @@
    4.36                      url = new URL(urlValue);
    4.37                  }
    4.38              } catch (MalformedURLException ex) {
    4.39 -                LOG.log(Level.INFO, "URL incorrect: " + urlValue + ex.getLocalizedMessage());
    4.40 +                LOG.log(Level.INFO, "URL incorrect: {0} {1}", new Object[] {urlValue, ex.getLocalizedMessage()});
    4.41              }
    4.42          }
    4.43          return url;
     5.1 --- a/hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/NBMFindBugsQueryProvider.java	Fri Jul 15 09:28:42 2011 -0400
     5.2 +++ b/hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/NBMFindBugsQueryProvider.java	Fri Jul 15 09:51:22 2011 -0400
     5.3 @@ -46,6 +46,7 @@
     5.4  import org.netbeans.api.project.Project;
     5.5  import org.netbeans.modules.apisupport.project.spi.NbModuleProvider;
     5.6  import org.netbeans.modules.hudsonfindbugs.spi.FindBugsQueryImplementation;
     5.7 +import org.netbeans.spi.project.ProjectServiceProvider;
     5.8  import org.openide.filesystems.FileUtil;
     5.9  import org.openide.util.Exceptions;
    5.10  
    5.11 @@ -53,20 +54,20 @@
    5.12   *
    5.13   * @author Martin Grebac
    5.14   */
    5.15 +@ProjectServiceProvider(service=FindBugsQueryImplementation.class, projectType="org-netbeans-modules-apisupport-project")
    5.16  public final class NBMFindBugsQueryProvider implements FindBugsQueryImplementation {
    5.17  
    5.18      private final static String NB_HUDSON_FBUGS_URLROOT = 
    5.19              "http://qa-findbugs.netbeans.org/job/FindBugsResults/lastSuccessfulBuild/artifact/";
    5.20 +
    5.21 +    private final Project project;
    5.22 +
    5.23 +    public NBMFindBugsQueryProvider(Project project) {
    5.24 +        this.project = project;
    5.25 +    }
    5.26      
    5.27 -    public NBMFindBugsQueryProvider() {}
    5.28 -    
    5.29 -    public static FindBugsQueryImplementation createInstance() {
    5.30 -        // TODO possibly also use just one static instance everywhere..
    5.31 -        return new NBMFindBugsQueryProvider();
    5.32 -    }
    5.33 -
    5.34      @CheckForNull
    5.35 -    public URL getFindBugsUrl(Project project, boolean remote) {
    5.36 +    public URL getFindBugsUrl(boolean remote) {
    5.37          URL url = null;
    5.38          NbModuleProvider prov = project.getLookup().lookup(NbModuleProvider.class);
    5.39          if (prov != null) {
     6.1 --- a/hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/api/FindBugsQuery.java	Fri Jul 15 09:28:42 2011 -0400
     6.2 +++ b/hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/api/FindBugsQuery.java	Fri Jul 15 09:51:22 2011 -0400
     6.3 @@ -74,7 +74,7 @@
     6.4          Parameters.notNull("project", project);
     6.5          FindBugsQueryImplementation query = project.getLookup().lookup(FindBugsQueryImplementation.class);
     6.6          if (query != null) {
     6.7 -            URL url = query.getFindBugsUrl(project, remote);
     6.8 +            URL url = query.getFindBugsUrl(remote);
     6.9              LOG.log(Level.FINE, "getFindBugsUrl({0}, {1}) -> {2}", new Object[] {project.getProjectDirectory(), remote, url});
    6.10              return url;
    6.11          }
    6.12 @@ -93,9 +93,9 @@
    6.13          Parameters.notNull("project", project);
    6.14          FindBugsQueryImplementation query = project.getLookup().lookup(FindBugsQueryImplementation.class);
    6.15          if (query != null) {
    6.16 -            URL url = query.getFindBugsUrl(project, false);
    6.17 +            URL url = query.getFindBugsUrl(false);
    6.18              if (url == null) {
    6.19 -                url = query.getFindBugsUrl(project, true);
    6.20 +                url = query.getFindBugsUrl(true);
    6.21              }
    6.22              LOG.log(Level.FINE, "getFindBugsUrl({0}) -> {1}", new Object[] {project.getProjectDirectory(), url});
    6.23              return url;
     7.1 --- a/hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/spi/FindBugsQueryImplementation.java	Fri Jul 15 09:28:42 2011 -0400
     7.2 +++ b/hudsonfindbugs/src/org/netbeans/modules/hudsonfindbugs/spi/FindBugsQueryImplementation.java	Fri Jul 15 09:51:22 2011 -0400
     7.3 @@ -43,7 +43,6 @@
     7.4  
     7.5  import java.net.URL;
     7.6  import org.netbeans.api.annotations.common.CheckForNull;
     7.7 -import org.netbeans.api.project.Project;
     7.8  
     7.9  /**
    7.10   * Implementations provide URLs for remote or local findbugs results for a specific projects. To be used by 
    7.11 @@ -64,6 +63,6 @@
    7.12       * If the resource doesn't exist, return null
    7.13       */
    7.14      @CheckForNull
    7.15 -    URL getFindBugsUrl(Project project, boolean remote);
    7.16 +    URL getFindBugsUrl(boolean remote);
    7.17  
    7.18  }