This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 150194
Collapse All | Expand All

(-)a/groovy.support/nbproject/project.xml (-1 / +1 lines)
Lines 119-125 Link Here
119
                    <compile-dependency/>
119
                    <compile-dependency/>
120
                    <run-dependency>
120
                    <run-dependency>
121
                        <release-version>1</release-version>
121
                        <release-version>1</release-version>
122
                        <specification-version>1.13</specification-version>
122
                        <specification-version>1.23</specification-version>
123
                    </run-dependency>
123
                    </run-dependency>
124
                </dependency>
124
                </dependency>
125
                <dependency>
125
                <dependency>
(-)a/groovy.support/src/org/netbeans/modules/groovy/support/GroovyActionProvider.java (+2 lines)
Lines 62-67 Link Here
62
import org.netbeans.api.project.SourceGroup;
62
import org.netbeans.api.project.SourceGroup;
63
import org.netbeans.api.project.Sources;
63
import org.netbeans.api.project.Sources;
64
import org.netbeans.spi.project.ActionProvider;
64
import org.netbeans.spi.project.ActionProvider;
65
import org.netbeans.spi.project.ProjectServiceProvider;
65
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
66
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
66
import org.netbeans.spi.project.support.ant.PropertyUtils;
67
import org.netbeans.spi.project.support.ant.PropertyUtils;
67
import org.openide.DialogDisplayer;
68
import org.openide.DialogDisplayer;
Lines 87-92 Link Here
87
 * 
88
 * 
88
 * @author Martin Adamek
89
 * @author Martin Adamek
89
 */
90
 */
91
@ProjectServiceProvider(service=ActionProvider.class, projectType="org-netbeans-modules-java-j2seproject")
90
public class GroovyActionProvider implements ActionProvider {
92
public class GroovyActionProvider implements ActionProvider {
91
93
92
    // from J2SEProjectProperties
94
    // from J2SEProjectProperties
(-)a/groovy.support/src/org/netbeans/modules/groovy/support/GroovyLookupProvider.java (-76 lines)
Lines 1-76 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.modules.groovy.support;
43
44
import java.util.ArrayList;
45
import java.util.List;
46
import org.netbeans.api.project.Project;
47
import org.netbeans.spi.project.LookupProvider;
48
import org.openide.util.Lookup;
49
import org.openide.util.lookup.Lookups;
50
51
/**
52
 *
53
 * @author Martin Adamek
54
 */
55
public class GroovyLookupProvider implements LookupProvider {
56
    @LookupProvider.Registration(projectType="org-netbeans-modules-java-j2seproject")
57
    public static GroovyLookupProvider createJavaSE() {
58
        return new GroovyLookupProvider();
59
    }
60
61
    private GroovyLookupProvider() {}
62
63
    public Lookup createAdditionalLookup(Lookup baseContext) {
64
        Project project = baseContext.lookup(Project.class);
65
        if (project == null) {
66
            throw new IllegalStateException("Lookup " + baseContext + " does not contain a Project");
67
        }
68
        List<Object> instances = new ArrayList<Object>(3);
69
        instances.add(new GroovyProjectExtender(project));
70
        instances.add(LookupMergerSupport.createActionProviderLookupMerger());
71
        instances.add(new GroovyActionProvider(project));
72
        instances.add(new GsfClasspathHook(project, baseContext));
73
        return Lookups.fixed(instances.toArray(new Object[instances.size()]));
74
    }
75
76
}
(-)a/groovy.support/src/org/netbeans/modules/groovy/support/GroovyProjectExtender.java (-1 / +4 lines)
Lines 62-67 Link Here
62
import org.netbeans.modules.groovy.support.spi.GroovyFeature;
62
import org.netbeans.modules.groovy.support.spi.GroovyFeature;
63
import org.netbeans.modules.gsfpath.api.classpath.GlobalPathRegistry;
63
import org.netbeans.modules.gsfpath.api.classpath.GlobalPathRegistry;
64
import org.netbeans.modules.gsfpath.spi.classpath.support.ClassPathSupport;
64
import org.netbeans.modules.gsfpath.spi.classpath.support.ClassPathSupport;
65
import org.netbeans.spi.project.ProjectServiceProvider;
65
import org.netbeans.spi.project.support.ant.EditableProperties;
66
import org.netbeans.spi.project.support.ant.EditableProperties;
66
import org.openide.filesystems.FileLock;
67
import org.openide.filesystems.FileLock;
67
import org.openide.filesystems.FileObject;
68
import org.openide.filesystems.FileObject;
Lines 77-82 Link Here
77
 * 
78
 * 
78
 * @author Martin Adamek
79
 * @author Martin Adamek
79
 */
80
 */
81
@ProjectServiceProvider(service={GroovyFeature.class, GroovyProjectExtender.class},
82
projectType="org-netbeans-modules-java-j2seproject")
80
public class GroovyProjectExtender implements GroovyFeature {
83
public class GroovyProjectExtender implements GroovyFeature {
81
84
82
    private static final String EXTENSIBLE_TARGET_NAME = "-pre-pre-compile"; // NOI18N
85
    private static final String EXTENSIBLE_TARGET_NAME = "-pre-pre-compile"; // NOI18N
Lines 91-97 Link Here
91
    private org.netbeans.modules.gsfpath.api.classpath.ClassPath gsfClassPath;
94
    private org.netbeans.modules.gsfpath.api.classpath.ClassPath gsfClassPath;
92
    private GroovyCustomizerPanel panel;
95
    private GroovyCustomizerPanel panel;
93
    
96
    
94
    GroovyProjectExtender(Project project) {
97
    public GroovyProjectExtender(Project project) {
95
        this.project = project;
98
        this.project = project;
96
    }
99
    }
97
100
(-)a/groovy.support/src/org/netbeans/modules/groovy/support/GsfClasspathHook.java (-2 / +3 lines)
Lines 41-48 Link Here
41
41
42
import org.netbeans.api.project.Project;
42
import org.netbeans.api.project.Project;
43
import org.netbeans.modules.groovy.support.spi.GroovyFeature;
43
import org.netbeans.modules.groovy.support.spi.GroovyFeature;
44
import org.netbeans.spi.project.ProjectServiceProvider;
44
import org.netbeans.spi.project.ui.ProjectOpenedHook;
45
import org.netbeans.spi.project.ui.ProjectOpenedHook;
45
import org.openide.util.Lookup;
46
46
47
/**
47
/**
48
 * Temporary solution to have GSF indexing enabled on projects with only
48
 * Temporary solution to have GSF indexing enabled on projects with only
Lines 52-62 Link Here
52
 * 
52
 * 
53
 * @author Martin Adamek
53
 * @author Martin Adamek
54
 */
54
 */
55
@ProjectServiceProvider(service=ProjectOpenedHook.class, projectType="org-netbeans-modules-java-j2seproject")
55
public class GsfClasspathHook extends ProjectOpenedHook {
56
public class GsfClasspathHook extends ProjectOpenedHook {
56
57
57
    private final Project project;
58
    private final Project project;
58
    
59
    
59
    public GsfClasspathHook(Project project, Lookup baseContext) {
60
    public GsfClasspathHook(Project project) {
60
        this.project = project;
61
        this.project = project;
61
    }
62
    }
62
    
63
    
(-)a/groovy.support/src/org/netbeans/modules/groovy/support/LookupMergerSupport.java (+1 lines)
Lines 62-67 Link Here
62
     * is found.
62
     * is found.
63
     * @return
63
     * @return
64
     */
64
     */
65
    @LookupMerger.Registration(projectType="org-netbeans-modules-java-j2seproject")
65
    public static LookupMerger<ActionProvider> createActionProviderLookupMerger() {
66
    public static LookupMerger<ActionProvider> createActionProviderLookupMerger() {
66
        return new ActionProviderMerger();
67
        return new ActionProviderMerger();
67
    }
68
    }
(-)a/hibernate/nbproject/project.xml (-1 / +1 lines)
Lines 247-253 Link Here
247
                    <compile-dependency/>
247
                    <compile-dependency/>
248
                    <run-dependency>
248
                    <run-dependency>
249
                        <release-version>1</release-version>
249
                        <release-version>1</release-version>
250
                        <specification-version>1.14</specification-version>
250
                        <specification-version>1.23</specification-version>
251
                    </run-dependency>
251
                    </run-dependency>
252
                </dependency>
252
                </dependency>
253
                <dependency>
253
                <dependency>
(-)a/hibernate/src/org/netbeans/modules/hibernate/service/HibernateProjectLookupExtender.java (-71 lines)
Lines 1-71 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 * 
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 * 
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 * 
35
 * Contributor(s):
36
 * 
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.hibernate.service;
41
42
import org.netbeans.modules.hibernate.service.spi.HibernateEnvironmentImpl;
43
import org.netbeans.api.project.Project;
44
import org.netbeans.modules.hibernate.service.api.HibernateEnvironment;
45
import org.netbeans.modules.hibernate.service.spi.HibernateVerificationWarningOverrider;
46
import org.netbeans.spi.project.LookupProvider;
47
import org.openide.util.Lookup;
48
import org.openide.util.lookup.Lookups;
49
50
51
/**
52
 * The class extends project lookup to include additional instances of 
53
 * Hibernate artifacts. This class is registered in the project's lookup.
54
 * 
55
 * @author Vadiraj Deshpande (Vadiraj.Deshpande@Sun.COM)
56
 */
57
@LookupProvider.Registration(projectType={
58
    "org-netbeans-modules-maven",
59
    "org-netbeans-modules-java-j2seproject",
60
    "org-netbeans-modules-web-project"
61
}, projectTypes=@LookupProvider.Registration.ProjectType(id="org-netbeans-modules-ant-freeform", position=700))
62
public class HibernateProjectLookupExtender implements LookupProvider {
63
64
    public Lookup createAdditionalLookup(Lookup baseContext) {
65
        Project project = baseContext.lookup(Project.class);
66
        HibernateEnvironment hibernateEnvironment = new HibernateEnvironmentImpl(project);
67
        HibernateVerificationWarningOverrider warningOverrider = new HibernateVerificationWarningOverrider(project);
68
        return Lookups.fixed(new Object[]{hibernateEnvironment, warningOverrider});
69
    }
70
71
}
(-)a/hibernate/src/org/netbeans/modules/hibernate/service/spi/HibernateEnvironmentImpl.java (+7 lines)
Lines 67-72 Link Here
67
import org.netbeans.modules.hibernate.mapping.model.MyClass;
67
import org.netbeans.modules.hibernate.mapping.model.MyClass;
68
import org.netbeans.modules.hibernate.util.CustomClassLoader;
68
import org.netbeans.modules.hibernate.util.CustomClassLoader;
69
import org.netbeans.modules.hibernate.util.HibernateUtil;
69
import org.netbeans.modules.hibernate.util.HibernateUtil;
70
import org.netbeans.spi.project.LookupProvider;
71
import org.netbeans.spi.project.ProjectServiceProvider;
70
import org.openide.filesystems.FileObject;
72
import org.openide.filesystems.FileObject;
71
import org.openide.filesystems.FileUtil;
73
import org.openide.filesystems.FileUtil;
72
import org.openide.loaders.DataObject;
74
import org.openide.loaders.DataObject;
Lines 81-86 Link Here
81
 *
83
 *
82
 * @author Vadiraj Deshpande (Vadiraj.Deshpande@Sun.COM)
84
 * @author Vadiraj Deshpande (Vadiraj.Deshpande@Sun.COM)
83
 */
85
 */
86
@ProjectServiceProvider(service=HibernateEnvironment.class, projectType={
87
    "org-netbeans-modules-maven",
88
    "org-netbeans-modules-java-j2seproject",
89
    "org-netbeans-modules-web-project"
90
}, projectTypes=@LookupProvider.Registration.ProjectType(id="org-netbeans-modules-ant-freeform", position=700))
84
public class HibernateEnvironmentImpl implements HibernateEnvironment {
91
public class HibernateEnvironmentImpl implements HibernateEnvironment {
85
92
86
    /** Handle to the current project to which this HibernateEnvironment is bound*/
93
    /** Handle to the current project to which this HibernateEnvironment is bound*/
(-)a/hibernate/src/org/netbeans/modules/hibernate/service/spi/HibernateVerificationWarningOverrider.java (+7 lines)
Lines 43-54 Link Here
43
import org.netbeans.modules.hibernate.service.api.HibernateEnvironment;
43
import org.netbeans.modules.hibernate.service.api.HibernateEnvironment;
44
import org.netbeans.modules.j2ee.jpa.verification.api.JPAVerificationWarningIds;
44
import org.netbeans.modules.j2ee.jpa.verification.api.JPAVerificationWarningIds;
45
import org.netbeans.modules.j2ee.jpa.verification.api.VerificationWarningOverrider;
45
import org.netbeans.modules.j2ee.jpa.verification.api.VerificationWarningOverrider;
46
import org.netbeans.spi.project.LookupProvider;
47
import org.netbeans.spi.project.ProjectServiceProvider;
46
48
47
/**
49
/**
48
 * To override specific verification warning
50
 * To override specific verification warning
49
 * 
51
 * 
50
 * @author Dongmei Cao
52
 * @author Dongmei Cao
51
 */
53
 */
54
@ProjectServiceProvider(service=VerificationWarningOverrider.class, projectType={
55
    "org-netbeans-modules-maven",
56
    "org-netbeans-modules-java-j2seproject",
57
    "org-netbeans-modules-web-project"
58
}, projectTypes=@LookupProvider.Registration.ProjectType(id="org-netbeans-modules-ant-freeform", position=701))
52
public class HibernateVerificationWarningOverrider implements VerificationWarningOverrider {
59
public class HibernateVerificationWarningOverrider implements VerificationWarningOverrider {
53
    
60
    
54
    private Project project;
61
    private Project project;
(-)a/maven.persistence/nbproject/project.xml (-1 / +1 lines)
Lines 133-139 Link Here
133
                    <compile-dependency/>
133
                    <compile-dependency/>
134
                    <run-dependency>
134
                    <run-dependency>
135
                        <release-version>1</release-version>
135
                        <release-version>1</release-version>
136
                        <specification-version>1.18</specification-version>
136
                        <specification-version>1.23</specification-version>
137
                    </run-dependency>
137
                    </run-dependency>
138
                </dependency>
138
                </dependency>
139
                <dependency>
139
                <dependency>
(-)a/maven.persistence/src/org/netbeans/modules/maven/persistence/CPExtender.java (-1 / +3 lines)
Lines 42-48 Link Here
42
import java.io.IOException;
42
import java.io.IOException;
43
import java.net.URI;
43
import java.net.URI;
44
import java.net.URL;
44
import java.net.URL;
45
import org.netbeans.modules.maven.api.PluginPropertyUtils;
46
import org.netbeans.modules.maven.api.customizer.ModelHandle;
45
import org.netbeans.modules.maven.api.customizer.ModelHandle;
47
import org.netbeans.modules.maven.spi.customizer.ModelHandleUtils;
46
import org.netbeans.modules.maven.spi.customizer.ModelHandleUtils;
48
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
47
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
Lines 53-58 Link Here
53
import org.netbeans.modules.maven.api.ModelUtils;
52
import org.netbeans.modules.maven.api.ModelUtils;
54
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
53
import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender;
55
import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation;
54
import org.netbeans.spi.java.project.classpath.ProjectClassPathModifierImplementation;
55
import org.netbeans.spi.project.ProjectServiceProvider;
56
import org.openide.filesystems.FileObject;
56
import org.openide.filesystems.FileObject;
57
import org.openide.util.Exceptions;
57
import org.openide.util.Exceptions;
58
58
Lines 60-65 Link Here
60
 *
60
 *
61
 * @author mkleint
61
 * @author mkleint
62
 */
62
 */
63
@ProjectServiceProvider(service={ProjectClassPathModifierImplementation.class, ProjectClassPathExtender.class},
64
projectType="org-netbeans-modules-maven")
63
public class CPExtender extends ProjectClassPathModifierImplementation implements ProjectClassPathExtender {
65
public class CPExtender extends ProjectClassPathModifierImplementation implements ProjectClassPathExtender {
64
    private static final String SL_15 = "1.5"; //NOI18N
66
    private static final String SL_15 = "1.5"; //NOI18N
65
    private Project project;
67
    private Project project;
(-)a/maven.persistence/src/org/netbeans/modules/maven/persistence/EntityClassScopeProviderImpl.java (-1 / +3 lines)
Lines 49-67 Link Here
49
import org.netbeans.modules.j2ee.persistence.spi.EntityClassScopeProvider;
49
import org.netbeans.modules.j2ee.persistence.spi.EntityClassScopeProvider;
50
import org.netbeans.modules.j2ee.persistence.spi.support.EntityMappingsMetadataModelHelper;
50
import org.netbeans.modules.j2ee.persistence.spi.support.EntityMappingsMetadataModelHelper;
51
import org.netbeans.modules.maven.api.classpath.ProjectSourcesClassPathProvider;
51
import org.netbeans.modules.maven.api.classpath.ProjectSourcesClassPathProvider;
52
import org.netbeans.spi.project.ProjectServiceProvider;
52
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileObject;
53
54
54
/**
55
/**
55
 *
56
 *
56
 * @author mkleint
57
 * @author mkleint
57
 */
58
 */
59
@ProjectServiceProvider(service=EntityClassScopeProvider.class, projectType="org-netbeans-modules-maven")
58
public class EntityClassScopeProviderImpl implements EntityClassScopeProvider {
60
public class EntityClassScopeProviderImpl implements EntityClassScopeProvider {
59
    
61
    
60
    Project project;
62
    Project project;
61
    EntityMappingsMetadataModelHelper helper;
63
    EntityMappingsMetadataModelHelper helper;
62
    EntityClassScope scope;
64
    EntityClassScope scope;
63
    
65
    
64
    EntityClassScopeProviderImpl(Project prj) {
66
    public EntityClassScopeProviderImpl(Project prj) {
65
        project = prj;
67
        project = prj;
66
    }
68
    }
67
    
69
    
(-)a/maven.persistence/src/org/netbeans/modules/maven/persistence/MavenPersistenceProvider.java (+3 lines)
Lines 50-55 Link Here
50
import org.netbeans.modules.j2ee.persistence.spi.PersistenceLocationProvider;
50
import org.netbeans.modules.j2ee.persistence.spi.PersistenceLocationProvider;
51
import org.netbeans.modules.j2ee.persistence.spi.PersistenceScopeProvider;
51
import org.netbeans.modules.j2ee.persistence.spi.PersistenceScopeProvider;
52
import org.netbeans.modules.j2ee.persistence.spi.PersistenceScopesProvider;
52
import org.netbeans.modules.j2ee.persistence.spi.PersistenceScopesProvider;
53
import org.netbeans.spi.project.ProjectServiceProvider;
53
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileObject;
54
import org.openide.util.WeakListeners;
55
import org.openide.util.WeakListeners;
55
56
Lines 57-62 Link Here
57
 *
58
 *
58
 * @author Daniel Mohni
59
 * @author Daniel Mohni
59
 */
60
 */
61
@ProjectServiceProvider(service={PersistenceLocationProvider.class, PersistenceScopeProvider.class, PersistenceScopesProvider.class},
62
projectType="org-netbeans-modules-maven")
60
public class MavenPersistenceProvider implements PersistenceLocationProvider, 
63
public class MavenPersistenceProvider implements PersistenceLocationProvider, 
61
        PersistenceScopeProvider, PersistenceScopesProvider 
64
        PersistenceScopeProvider, PersistenceScopesProvider 
62
{
65
{
(-)a/maven.persistence/src/org/netbeans/modules/maven/persistence/PersistenceLookupProvider.java (-83 lines)
Lines 1-83 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
package org.netbeans.modules.maven.persistence;
40
41
import org.netbeans.api.project.Project;
42
import org.netbeans.spi.project.LookupProvider;
43
import org.netbeans.spi.project.ui.RecommendedTemplates;
44
import org.openide.util.Lookup;
45
import org.openide.util.lookup.Lookups;
46
47
/**
48
 * extending the default maven project lookup.
49
 * @author  Milos Kleint 
50
 */
51
@LookupProvider.Registration(projectType="org-netbeans-modules-maven")
52
public class PersistenceLookupProvider implements LookupProvider {
53
    
54
    /** Creates a new instance of J2eeLookupProvider */
55
    public PersistenceLookupProvider() {
56
    }
57
    
58
    /**
59
     * 
60
     * @param context 
61
     * @return 
62
     */
63
    public Lookup createAdditionalLookup(Lookup context) {
64
//        // if there's more items later, just do a proxy..
65
        Project prj = context.lookup(Project.class);
66
        assert prj != null;
67
        return Lookups.fixed(new Object[] {
68
            new MavenPersistenceProvider(prj),
69
            new EntityClassScopeProviderImpl(prj),
70
            new RecoTemp(),
71
            new CPExtender(prj)
72
        });
73
    }
74
    
75
    private static class RecoTemp implements RecommendedTemplates {
76
        public String[] getRecommendedTypes() {
77
            return new String[] {
78
                "persistence" //NOI18N
79
            };
80
        }
81
    }
82
83
}
(-)a/maven.persistence/src/org/netbeans/modules/maven/persistence/RecommendedTemplatesImpl.java (+50 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.maven.persistence;
41
42
import org.netbeans.spi.project.ProjectServiceProvider;
43
import org.netbeans.spi.project.ui.RecommendedTemplates;
44
45
@ProjectServiceProvider(service=RecommendedTemplates.class, projectType="org-netbeans-modules-maven")
46
public class RecommendedTemplatesImpl implements RecommendedTemplates {
47
    public String[] getRecommendedTypes() {
48
        return new String[] {"persistence"};
49
    }
50
}
(-)a/maven.profiler/nbproject/project.xml (-1 / +1 lines)
Lines 97-103 Link Here
97
                    <compile-dependency/>
97
                    <compile-dependency/>
98
                    <run-dependency>
98
                    <run-dependency>
99
                        <release-version>1</release-version>
99
                        <release-version>1</release-version>
100
                        <specification-version>1.18</specification-version>
100
                        <specification-version>1.23</specification-version>
101
                    </run-dependency>
101
                    </run-dependency>
102
                </dependency>
102
                </dependency>
103
                <dependency>
103
                <dependency>
(-)a/maven.profiler/src/org/netbeans/modules/maven/profiler/LookupProviderImpl.java (-65 lines)
Lines 1-65 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.maven.profiler;
41
42
import org.netbeans.modules.maven.api.NbMavenProject;
43
import org.netbeans.api.project.Project;
44
import org.netbeans.spi.project.LookupProvider;
45
import org.openide.util.Lookup;
46
import org.openide.util.lookup.Lookups;
47
48
/**
49
 *
50
 * @author mkleint
51
 */
52
@LookupProvider.Registration(projectType="org-netbeans-modules-maven")
53
public class LookupProviderImpl implements LookupProvider {
54
55
    public Lookup createAdditionalLookup(Lookup baseContext) {
56
        
57
        NbMavenProject nbprj = baseContext.lookup(NbMavenProject.class);
58
        Project prj = baseContext.lookup(Project.class);
59
        assert prj != null;
60
        assert nbprj != null;
61
        
62
        return Lookups.fixed(new RunCheckerImpl(prj));
63
    }
64
65
}
(-)a/maven.profiler/src/org/netbeans/modules/maven/profiler/RunCheckerImpl.java (+2 lines)
Lines 47-52 Link Here
47
import org.netbeans.modules.maven.api.execute.ExecutionContext;
47
import org.netbeans.modules.maven.api.execute.ExecutionContext;
48
import org.netbeans.modules.maven.api.execute.LateBoundPrerequisitesChecker;
48
import org.netbeans.modules.maven.api.execute.LateBoundPrerequisitesChecker;
49
import org.netbeans.modules.profiler.utils.ProjectUtilities;
49
import org.netbeans.modules.profiler.utils.ProjectUtilities;
50
import org.netbeans.spi.project.ProjectServiceProvider;
50
import org.openide.util.RequestProcessor;
51
import org.openide.util.RequestProcessor;
51
52
52
/**
53
/**
Lines 54-59 Link Here
54
 * @author mkleint
55
 * @author mkleint
55
 * @author Jiri Sedlacek
56
 * @author Jiri Sedlacek
56
 */
57
 */
58
@ProjectServiceProvider(service=LateBoundPrerequisitesChecker.class, projectType="org-netbeans-modules-maven")
57
public class RunCheckerImpl implements LateBoundPrerequisitesChecker {
59
public class RunCheckerImpl implements LateBoundPrerequisitesChecker {
58
    
60
    
59
    private static final String ACTION_PROFILE = "profile"; // NOI18N
61
    private static final String ACTION_PROFILE = "profile"; // NOI18N
(-)a/maven.spring/nbproject/project.xml (-1 / +1 lines)
Lines 61-67 Link Here
61
                    <compile-dependency/>
61
                    <compile-dependency/>
62
                    <run-dependency>
62
                    <run-dependency>
63
                        <release-version>1</release-version>
63
                        <release-version>1</release-version>
64
                        <specification-version>1.19</specification-version>
64
                        <specification-version>1.23</specification-version>
65
                    </run-dependency>
65
                    </run-dependency>
66
                </dependency>
66
                </dependency>
67
                <dependency>
67
                <dependency>
(-)a/maven.spring/src/org/netbeans/modules/maven/spring/MavenSpringConfigProviderImpl.java (-1 / +3 lines)
Lines 50-55 Link Here
50
import org.netbeans.modules.spring.api.beans.SpringConstants;
50
import org.netbeans.modules.spring.api.beans.SpringConstants;
51
import org.netbeans.modules.spring.spi.beans.SpringConfigFileLocationProvider;
51
import org.netbeans.modules.spring.spi.beans.SpringConfigFileLocationProvider;
52
import org.netbeans.modules.spring.spi.beans.SpringConfigFileProvider;
52
import org.netbeans.modules.spring.spi.beans.SpringConfigFileProvider;
53
import org.netbeans.spi.project.ProjectServiceProvider;
53
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileUtil;
55
import org.openide.filesystems.FileUtil;
55
import org.openide.util.NbCollections;
56
import org.openide.util.NbCollections;
Lines 58-67 Link Here
58
 *
59
 *
59
 * @author mkleint
60
 * @author mkleint
60
 */
61
 */
62
@ProjectServiceProvider(service={SpringConfigFileProvider.class, SpringConfigFileLocationProvider.class}, projectType="org-netbeans-modules-maven")
61
public class MavenSpringConfigProviderImpl implements SpringConfigFileLocationProvider, SpringConfigFileProvider {
63
public class MavenSpringConfigProviderImpl implements SpringConfigFileLocationProvider, SpringConfigFileProvider {
62
    private Project prj;
64
    private Project prj;
63
    
65
    
64
    MavenSpringConfigProviderImpl(Project project) {
66
    public MavenSpringConfigProviderImpl(Project project) {
65
        prj = project;
67
        prj = project;
66
    }
68
    }
67
69
(-)a/maven.spring/src/org/netbeans/modules/maven/spring/MavenSpringLookupProvider.java (-67 lines)
Lines 1-67 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
41
package org.netbeans.modules.maven.spring;
42
43
import org.netbeans.api.project.Project;
44
import org.netbeans.spi.project.LookupProvider;
45
import org.openide.util.Lookup;
46
import org.openide.util.lookup.Lookups;
47
48
/**
49
 *
50
 * @author mkleint
51
 */
52
@LookupProvider.Registration(projectType="org-netbeans-modules-maven")
53
public class MavenSpringLookupProvider implements LookupProvider {
54
55
    public Lookup createAdditionalLookup(Lookup baseContext) {
56
        Project project = baseContext.lookup(Project.class);
57
        if (project == null) {
58
            throw new IllegalStateException("Lookup " + baseContext + " does not contain a Project");
59
        }
60
        return Lookups.fixed(
61
                new MavenSpringConfigProviderImpl(project),
62
                new RecommendedTemplatesImpl(project));
63
    }
64
65
66
67
}
(-)a/maven.spring/src/org/netbeans/modules/maven/spring/RecommendedTemplatesImpl.java (+2 lines)
Lines 41-52 Link Here
41
41
42
import org.netbeans.api.project.Project;
42
import org.netbeans.api.project.Project;
43
import org.netbeans.modules.maven.api.NbMavenProject;
43
import org.netbeans.modules.maven.api.NbMavenProject;
44
import org.netbeans.spi.project.ProjectServiceProvider;
44
import org.netbeans.spi.project.ui.RecommendedTemplates;
45
import org.netbeans.spi.project.ui.RecommendedTemplates;
45
46
46
/**
47
/**
47
 *
48
 *
48
 * @author Milos Kleint
49
 * @author Milos Kleint
49
 */
50
 */
51
@ProjectServiceProvider(service=RecommendedTemplates.class, projectType="org-netbeans-modules-maven")
50
public class RecommendedTemplatesImpl implements RecommendedTemplates {
52
public class RecommendedTemplatesImpl implements RecommendedTemplates {
51
53
52
    private static final String[] SPRING_TYPES = new String[] {
54
    private static final String[] SPRING_TYPES = new String[] {
(-)a/openide.filesystems/src/org/openide/filesystems/annotations/LayerBuilder.java (-2 / +4 lines)
Lines 41-47 Link Here
41
41
42
import java.io.IOException;
42
import java.io.IOException;
43
import java.io.InputStream;
43
import java.io.InputStream;
44
import java.io.ObjectOutputStream;
45
import java.net.URI;
44
import java.net.URI;
46
import java.util.Arrays;
45
import java.util.Arrays;
47
import java.util.LinkedHashMap;
46
import java.util.LinkedHashMap;
Lines 142-148 Link Here
142
        if (originatingElement == null) {
141
        if (originatingElement == null) {
143
            throw new IllegalArgumentException("Only applicable to builders with exactly one associated element");
142
            throw new IllegalArgumentException("Only applicable to builders with exactly one associated element");
144
        }
143
        }
145
        TypeMirror typeMirror = type != null ? processingEnv.getElementUtils().getTypeElement(type.getName().replace('$', '.')).asType() : null;
144
        TypeMirror typeMirror = type != null ?
145
            processingEnv.getTypeUtils().getDeclaredType(
146
                processingEnv.getElementUtils().getTypeElement(type.getName().replace('$', '.'))) :
147
            null;
146
        switch (originatingElement.getKind()) {
148
        switch (originatingElement.getKind()) {
147
            case CLASS: {
149
            case CLASS: {
148
                String clazz = processingEnv.getElementUtils().getBinaryName((TypeElement) originatingElement).toString();
150
                String clazz = processingEnv.getElementUtils().getBinaryName((TypeElement) originatingElement).toString();
(-)a/openide.util/src/org/openide/util/lookup/ExcludingLookup.java (+4 lines)
Lines 47-52 Link Here
47
47
48
import java.util.*;
48
import java.util.*;
49
import org.openide.util.LookupEvent;
49
import org.openide.util.LookupEvent;
50
import org.openide.util.Parameters;
50
51
51
52
52
/** Allows exclusion of certain instances from lookup.
53
/** Allows exclusion of certain instances from lookup.
Lines 67-72 Link Here
67
    ExcludingLookup(Lookup delegate, Class[] classes) {
68
    ExcludingLookup(Lookup delegate, Class[] classes) {
68
        this.delegate = delegate;
69
        this.delegate = delegate;
69
70
71
        for (Class c : classes) {
72
            Parameters.notNull("classes[x]", c);
73
        }
70
        if (classes.length == 1) {
74
        if (classes.length == 1) {
71
            this.classes = classes[0];
75
            this.classes = classes[0];
72
        } else {
76
        } else {
(-)a/projectapi/apichanges.xml (+22 lines)
Lines 125-130 Link Here
125
            <issue number="153923"/>
125
            <issue number="153923"/>
126
        </change>
126
        </change>
127
127
128
        <change id="ProjectServiceProvider">
129
            <api name="general"/>
130
            <summary>Add annotations <code>@ProjectServiceProvider</code> and <code>@LookupMerger.Registration</code></summary>
131
            <version major="1" minor="23"/>
132
            <date day="23" month="1" year="2009"/>
133
            <author login="jglick"/>
134
            <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="no" semantic="compatible" source="compatible">
135
                <p>
136
                    Implementations of <code>LookupProvider</code> should be converted wherever possible.
137
                </p>
138
            </compatibility>
139
            <description>
140
                <p>
141
                  Added annotations to register entries to project lookup individually.
142
                  These can be used instead of implementing a <code>LookupProvider</code>.
143
                  Since the entries are loaded on demand, this can help avoid needless class loading.
144
                </p>
145
            </description>
146
            <class package="org.netbeans.spi.project" name="ProjectServiceProvider"/>
147
            <class package="org.netbeans.spi.project" name="LookupMerger"/>
148
            <issue number="150194"/>
149
        </change>
128
        <change id="lookupprovider-ann">
150
        <change id="lookupprovider-ann">
129
            <api name="general"/>
151
            <api name="general"/>
130
            <summary>Add annotation @LookupProvider.Registration</summary>
152
            <summary>Add annotation @LookupProvider.Registration</summary>
(-)a/projectapi/manifest.mf (-1 / +1 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.projectapi/1
2
OpenIDE-Module: org.netbeans.modules.projectapi/1
3
OpenIDE-Module-Install: org/netbeans/modules/projectapi/Installer.class
3
OpenIDE-Module-Install: org/netbeans/modules/projectapi/Installer.class
4
OpenIDE-Module-Specification-Version: 1.22
4
OpenIDE-Module-Specification-Version: 1.23
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
6
OpenIDE-Module-Layer: org/netbeans/modules/projectapi/layer.xml
6
OpenIDE-Module-Layer: org/netbeans/modules/projectapi/layer.xml
7
7
(-)a/projectapi/src/org/netbeans/modules/projectapi/LazyLookupProviders.java (+158 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.projectapi;
41
42
import java.lang.reflect.Constructor;
43
import java.lang.reflect.Method;
44
import java.util.ArrayList;
45
import java.util.Arrays;
46
import java.util.Collection;
47
import java.util.List;
48
import java.util.Map;
49
import org.netbeans.api.project.Project;
50
import org.netbeans.spi.project.LookupMerger;
51
import org.netbeans.spi.project.LookupProvider;
52
import org.netbeans.spi.project.ProjectServiceProvider;
53
import org.openide.util.Exceptions;
54
import org.openide.util.Lookup;
55
import org.openide.util.Lookup.Template;
56
import org.openide.util.lookup.Lookups;
57
import org.openide.util.lookup.ProxyLookup;
58
59
/**
60
 * Factory methods for lazy {@link LookupProvider} registration.
61
 */
62
public class LazyLookupProviders {
63
64
    private LazyLookupProviders() {}
65
66
    /**
67
     * @see ProjectServiceProvider
68
     */
69
    public static LookupProvider forProjectServiceProvider(final Map<String,Object> attrs) throws ClassNotFoundException {
70
        return new LookupProvider() {
71
            public Lookup createAdditionalLookup(final Lookup lkp) {
72
                return new ProxyLookup() {
73
                    final Collection<String> serviceNames = Arrays.asList(((String) attrs.get("service")).split(",")); // NOI18N
74
                    Class<?> service;
75
                    protected @Override void beforeLookup(Template<?> template) {
76
                        if (service == null && serviceNames.contains(template.getType().getName())) { // NOI18N
77
                            service = template.getType();
78
                            try {
79
                                Object instance = loadPSPInstance((String) attrs.get("class"), (String) attrs.get("method"), lkp); // NOI18N
80
                                service.cast(instance);
81
                                setLookups(Lookups.singleton(instance));
82
                            } catch (Exception x) {
83
                                Exceptions.printStackTrace(x);
84
                            }
85
                        }
86
                    }
87
                };
88
            }
89
        };
90
    }
91
    private static Object loadPSPInstance(String implName, String methodName, Lookup lkp) throws Exception {
92
        Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(implName);
93
        if (methodName == null) {
94
            for (Constructor c : clazz.getConstructors()) {
95
                Object[] vals = valuesFor(c.getParameterTypes(), lkp);
96
                if (vals != null) {
97
                    return c.newInstance(vals);
98
                }
99
            }
100
        } else {
101
            for (Method m : clazz.getMethods()) {
102
                Object[] vals = valuesFor(m.getParameterTypes(), lkp);
103
                if (vals != null) {
104
                    return m.invoke(null, vals);
105
                }
106
            }
107
        }
108
        throw new RuntimeException(implName + "." + methodName); // NOI18N
109
    }
110
    private static Object[] valuesFor(Class[] params, Lookup lkp) {
111
        if (params.length > 2) {
112
            return null;
113
        }
114
        List<Object> values = new ArrayList<Object>();
115
        for (Class param : params) {
116
            if (param == Lookup.class) {
117
                values.add(lkp);
118
            } else if (param == Project.class) {
119
                Project project = lkp.lookup(Project.class);
120
                if (project == null) {
121
                    throw new IllegalArgumentException("Lookup " + lkp + " did not contain any Project instance");
122
                }
123
                values.add(project);
124
            } else {
125
                return null;
126
            }
127
        }
128
        return values.toArray();
129
    }
130
131
    /**
132
     * @see org.netbeans.spi.project.LookupMerger.Registration
133
     */
134
    public static MetaLookupMerger forLookupMerger(final Map<String,Object> attrs) throws ClassNotFoundException {
135
        return new MetaLookupMerger() {
136
            private LookupMerger<?> delegate;
137
            public boolean canNowMerge(Class<?> service) {
138
                if (delegate == null && service.getName().equals((String) attrs.get("service"))) { // NOI18N
139
                    try {
140
                        LookupMerger<?> m = (LookupMerger<?>) attrs.get("lookupMergerInstance"); // NOI18N
141
                        if (service != m.getMergeableClass()) {
142
                            throw new ClassCastException(service + " vs. " + m.getMergeableClass()); // NOI18N
143
                        }
144
                        delegate = m;
145
                        return true;
146
                    } catch (Exception x) {
147
                        Exceptions.printStackTrace(x);
148
                    }
149
                }
150
                return false;
151
            }
152
            public LookupMerger merger() {
153
                return delegate;
154
            }
155
        };
156
    }
157
158
}
(-)a/projectapi/src/org/netbeans/modules/projectapi/LookupProviderAnnotationProcessor.java (-1 / +199 lines)
Lines 39-55 Link Here
39
39
40
package org.netbeans.modules.projectapi;
40
package org.netbeans.modules.projectapi;
41
41
42
import java.util.ArrayList;
43
import java.util.List;
44
import java.util.Map;
42
import java.util.Set;
45
import java.util.Set;
43
import javax.annotation.processing.Processor;
46
import javax.annotation.processing.Processor;
44
import javax.annotation.processing.RoundEnvironment;
47
import javax.annotation.processing.RoundEnvironment;
45
import javax.annotation.processing.SupportedAnnotationTypes;
48
import javax.annotation.processing.SupportedAnnotationTypes;
46
import javax.annotation.processing.SupportedSourceVersion;
49
import javax.annotation.processing.SupportedSourceVersion;
47
import javax.lang.model.SourceVersion;
50
import javax.lang.model.SourceVersion;
51
import javax.lang.model.element.AnnotationMirror;
52
import javax.lang.model.element.AnnotationValue;
48
import javax.lang.model.element.Element;
53
import javax.lang.model.element.Element;
54
import javax.lang.model.element.ElementKind;
55
import javax.lang.model.element.ExecutableElement;
56
import javax.lang.model.element.Modifier;
49
import javax.lang.model.element.TypeElement;
57
import javax.lang.model.element.TypeElement;
58
import javax.lang.model.element.VariableElement;
59
import javax.lang.model.type.DeclaredType;
60
import javax.lang.model.type.TypeMirror;
61
import javax.lang.model.util.ElementFilter;
62
import org.netbeans.api.project.Project;
63
import org.netbeans.spi.project.LookupMerger;
50
import org.netbeans.spi.project.LookupProvider;
64
import org.netbeans.spi.project.LookupProvider;
65
import org.netbeans.spi.project.ProjectServiceProvider;
66
import org.openide.filesystems.annotations.LayerBuilder;
51
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
67
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
52
import org.openide.filesystems.annotations.LayerGenerationException;
68
import org.openide.filesystems.annotations.LayerGenerationException;
69
import org.openide.util.Lookup;
53
import org.openide.util.lookup.ServiceProvider;
70
import org.openide.util.lookup.ServiceProvider;
54
71
55
/**
72
/**
Lines 58-64 Link Here
58
 */
75
 */
59
@ServiceProvider(service=Processor.class)
76
@ServiceProvider(service=Processor.class)
60
@SupportedSourceVersion(SourceVersion.RELEASE_6)
77
@SupportedSourceVersion(SourceVersion.RELEASE_6)
61
@SupportedAnnotationTypes("org.netbeans.spi.project.LookupProvider.Registration")
78
@SupportedAnnotationTypes({
79
    "org.netbeans.spi.project.LookupProvider.Registration",
80
    "org.netbeans.spi.project.ProjectServiceProvider",
81
    "org.netbeans.spi.project.LookupMerger.Registration"
82
})
62
public class LookupProviderAnnotationProcessor extends LayerGeneratingProcessor {
83
public class LookupProviderAnnotationProcessor extends LayerGeneratingProcessor {
63
84
64
    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
85
    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
Lines 77-83 Link Here
77
                layer(e).instanceFile("Projects/" + type.id() + "/Lookup", null, LookupProvider.class).position(type.position()).write();
98
                layer(e).instanceFile("Projects/" + type.id() + "/Lookup", null, LookupProvider.class).position(type.position()).write();
78
            }
99
            }
79
        }
100
        }
101
        for (Element e : roundEnv.getElementsAnnotatedWith(ProjectServiceProvider.class)) {
102
            List<TypeMirror> services = findServiceAnnotation(e);
103
            if (services.isEmpty()) {
104
                throw new LayerGenerationException("Must specify at least one service", e);
105
            }
106
            String servicesBinName = null;
107
            for (TypeMirror service : services) {
108
                String n = processingEnv.getElementUtils().getBinaryName((TypeElement) processingEnv.getTypeUtils().asElement(service)).toString();
109
                if (n.equals(LookupMerger.class.getName())) {
110
                    throw new LayerGenerationException("@ProjectServiceProvider should not be used on LookupMerger; use @LookupMerger.Registration instead", e);
111
                }
112
                servicesBinName = servicesBinName == null ? n : servicesBinName + "," + n;
113
            }
114
            String[] binAndMethodNames = findPSPDefinition(e, services);
115
            ProjectServiceProvider psp = e.getAnnotation(ProjectServiceProvider.class);
116
            if (psp.projectType().length == 0 && psp.projectTypes().length == 0) {
117
                throw new LayerGenerationException("You must specify either projectType or projectTypes", e);
118
            }
119
            String fileBaseName = binAndMethodNames[0].replace('.', '-');
120
            if (binAndMethodNames[1] != null) {
121
                fileBaseName += "-" + binAndMethodNames[1];
122
            }
123
            for (String type : psp.projectType()) {
124
                LayerBuilder.File f = layer(e).file("Projects/" + type + "/Lookup/" + fileBaseName + ".instance").
125
                        methodvalue("instanceCreate", LazyLookupProviders.class.getName(), "forProjectServiceProvider").
126
                        stringvalue("class", binAndMethodNames[0]).
127
                        stringvalue("service", servicesBinName);
128
                if (binAndMethodNames[1] != null) {
129
                    f.stringvalue("method", binAndMethodNames[1]);
130
                }
131
                f.write();
132
            }
133
            for (LookupProvider.Registration.ProjectType type : psp.projectTypes()) {
134
                LayerBuilder.File f = layer(e).file("Projects/" + type.id() + "/Lookup/" + fileBaseName + ".instance").
135
                        methodvalue("instanceCreate", LazyLookupProviders.class.getName(), "forProjectServiceProvider").
136
                        stringvalue("class", binAndMethodNames[0]).
137
                        stringvalue("service", servicesBinName).
138
                        position(type.position());
139
                if (binAndMethodNames[1] != null) {
140
                    f.stringvalue("method", binAndMethodNames[1]);
141
                }
142
                f.write();
143
            }
144
        }
145
        for (Element e : roundEnv.getElementsAnnotatedWith(LookupMerger.Registration.class)) {
146
            LookupMerger.Registration lmr = e.getAnnotation(LookupMerger.Registration.class);
147
            String fileBaseName;
148
            DeclaredType impl;
149
            if (e.getKind() == ElementKind.CLASS) {
150
                fileBaseName = processingEnv.getElementUtils().getBinaryName((TypeElement) e).toString().replace('.', '-');
151
                impl = (DeclaredType) e.asType();
152
            } else {
153
                fileBaseName = processingEnv.getElementUtils().getBinaryName((TypeElement) e.getEnclosingElement()).toString().replace('.', '-') +
154
                        "-" + e.getSimpleName().toString();
155
                impl = (DeclaredType) ((ExecutableElement) e).getReturnType();
156
            }
157
            DeclaredType service = findLookupMergerType(impl);
158
            if (service == null) {
159
                throw new LayerGenerationException("Not assignable to LookupMerger<T> for some T", e);
160
            }
161
            String serviceBinName = processingEnv.getElementUtils().getBinaryName((TypeElement) service.asElement()).toString();
162
            if (lmr.projectType().length == 0 && lmr.projectTypes().length == 0) {
163
                throw new LayerGenerationException("You must specify either projectType or projectTypes", e);
164
            }
165
            for (String type : lmr.projectType()) {
166
                layer(e).file("Projects/" + type + "/Lookup/" + fileBaseName + ".instance").
167
                        methodvalue("instanceCreate", LazyLookupProviders.class.getName(), "forLookupMerger").
168
                        instanceAttribute("lookupMergerInstance", LookupMerger.class).
169
                        stringvalue("service", serviceBinName).
170
                        write();
171
            }
172
            for (LookupProvider.Registration.ProjectType type : lmr.projectTypes()) {
173
                layer(e).file("Projects/" + type.id() + "/Lookup/" + fileBaseName + ".instance").
174
                        methodvalue("instanceCreate", LazyLookupProviders.class.getName(), "forLookupMerger").
175
                        instanceAttribute("lookupMergerInstance", LookupMerger.class).
176
                        stringvalue("service", serviceBinName).
177
                        position(type.position()).
178
                        write();
179
            }
180
        }
80
        return true;
181
        return true;
81
    }
182
    }
82
183
184
    private List<TypeMirror> findServiceAnnotation(Element e) throws LayerGenerationException {
185
        for (AnnotationMirror ann : e.getAnnotationMirrors()) {
186
            if (!ProjectServiceProvider.class.getName().equals(ann.getAnnotationType().toString())) {
187
                continue;
188
            }
189
            for (Map.Entry<? extends ExecutableElement,? extends AnnotationValue> attr : ann.getElementValues().entrySet()) {
190
                if (!attr.getKey().getSimpleName().contentEquals("service")) {
191
                    continue;
192
                }
193
                List<TypeMirror> r = new ArrayList<TypeMirror>();
194
                for (Object item : (List<?>) attr.getValue().getValue()) {
195
                    r.add((TypeMirror) ((AnnotationValue) item).getValue());
196
                }
197
                return r;
198
            }
199
            throw new LayerGenerationException("No service attr found", e);
200
        }
201
        throw new LayerGenerationException("No @ProjectServiceProvider found", e);
202
    }
203
204
    private String[] findPSPDefinition(Element e, List<TypeMirror> services) throws LayerGenerationException {
205
        if (e.getKind() == ElementKind.CLASS) {
206
            TypeElement clazz = (TypeElement) e;
207
            for (TypeMirror service : services) {
208
                if (!processingEnv.getTypeUtils().isAssignable(clazz.asType(), service)) {
209
                    throw new LayerGenerationException("Not assignable to " + service, e);
210
                }
211
            }
212
            int constructorCount = 0;
213
            CONSTRUCTOR: for (ExecutableElement constructor : ElementFilter.constructorsIn(clazz.getEnclosedElements())) {
214
                if (!constructor.getModifiers().contains(Modifier.PUBLIC)) {
215
                    continue;
216
                }
217
                List<? extends VariableElement> params = constructor.getParameters();
218
                if (params.size() > 2) {
219
                    continue;
220
                }
221
                for (VariableElement param : params) {
222
                    if (!param.asType().equals(processingEnv.getElementUtils().getTypeElement(Project.class.getCanonicalName()).asType()) &&
223
                            !param.asType().equals(processingEnv.getElementUtils().getTypeElement(Lookup.class.getCanonicalName()).asType())) {
224
                        continue CONSTRUCTOR;
225
                    }
226
                }
227
                constructorCount++;
228
            }
229
            if (constructorCount != 1) {
230
                throw new LayerGenerationException("Must have exactly one public constructor optionally taking Project and/or Lookup", e);
231
            }
232
            return new String[] {processingEnv.getElementUtils().getBinaryName(clazz).toString(), null};
233
        } else {
234
            ExecutableElement meth = (ExecutableElement) e;
235
            for (TypeMirror service : services) {
236
                if (!processingEnv.getTypeUtils().isAssignable(meth.getReturnType(), service)) {
237
                    throw new LayerGenerationException("Not assignable to " + service, e);
238
                }
239
            }
240
            if (!meth.getModifiers().contains(Modifier.PUBLIC)) {
241
                throw new LayerGenerationException("Method must be public", e);
242
            }
243
            if (!meth.getModifiers().contains(Modifier.STATIC)) {
244
                throw new LayerGenerationException("Method must be static", e);
245
            }
246
            List<? extends VariableElement> params = meth.getParameters();
247
            if (params.size() > 2) {
248
                throw new LayerGenerationException("Method must take at most two parameters", e);
249
            }
250
            for (VariableElement param : params) {
251
                if (!param.asType().equals(processingEnv.getElementUtils().getTypeElement(Project.class.getCanonicalName()).asType()) &&
252
                        !param.asType().equals(processingEnv.getElementUtils().getTypeElement(Lookup.class.getCanonicalName()).asType())) {
253
                    throw new LayerGenerationException("Method parameters may be either Lookup or Project", e);
254
                }
255
            }
256
            return new String[] {
257
                processingEnv.getElementUtils().getBinaryName((TypeElement) meth.getEnclosingElement()).toString(),
258
                meth.getSimpleName().toString()};
259
        }
260
    }
261
262
    private DeclaredType findLookupMergerType(DeclaredType t) {
263
        String rawName = processingEnv.getTypeUtils().erasure(t).toString();
264
        if (rawName.equals(LookupMerger.class.getName())) {
265
            List<? extends TypeMirror> args = t.getTypeArguments();
266
            if (args.size() == 1) {
267
                return (DeclaredType) args.get(0);
268
            } else {
269
                return null;
270
            }
271
        }
272
        for (TypeMirror supe : processingEnv.getTypeUtils().directSupertypes(t)) {
273
            DeclaredType result = findLookupMergerType((DeclaredType) supe);
274
            if (result != null) {
275
                return result;
276
            }
277
        }
278
        return null;
279
    }
280
83
}
281
}
(-)a/projectapi/src/org/netbeans/modules/projectapi/MetaLookupMerger.java (+54 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.projectapi;
41
42
import org.netbeans.spi.project.LookupMerger;
43
import org.openide.util.Lookup;
44
45
/**
46
 * @see LazyLookupProviders#forLookupMerger
47
 */
48
public interface MetaLookupMerger {
49
50
    boolean canNowMerge(Class<?> service);
51
52
    LookupMerger/*|null*/ merger();
53
54
}
(-)a/projectapi/src/org/netbeans/spi/project/LookupMerger.java (+27 lines)
Lines 41-46 Link Here
41
41
42
package org.netbeans.spi.project;
42
package org.netbeans.spi.project;
43
43
44
import java.lang.annotation.ElementType;
45
import java.lang.annotation.Retention;
46
import java.lang.annotation.RetentionPolicy;
47
import java.lang.annotation.Target;
48
import org.netbeans.spi.project.LookupProvider.Registration.ProjectType;
44
import org.openide.util.Lookup;
49
import org.openide.util.Lookup;
45
50
46
/**
51
/**
Lines 72-75 Link Here
72
     */
77
     */
73
    T merge(Lookup lookup);
78
    T merge(Lookup lookup);
74
79
80
    /**
81
     * Registers a lookup merger for some project types.
82
     * The annotated class must be assignable to {@link LookupMerger} with a type parameter.
83
     * @since org.netbeans.modules.projectapi/1 1.23
84
     */
85
    @Retention(RetentionPolicy.SOURCE)
86
    @Target({ElementType.TYPE, ElementType.METHOD})
87
    @interface Registration {
88
89
        /**
90
         * Token(s) denoting one or more project types, e.g. {@code "org-netbeans-modules-java-j2seproject"}
91
         */
92
        String[] projectType() default {};
93
94
        /**
95
         * Alternate registration of project types with positions.
96
         * You must specify either this or {@link #projectType} (or both).
97
         */
98
        ProjectType[] projectTypes() default {};
99
100
    }
101
75
}
102
}
(-)a/projectapi/src/org/netbeans/spi/project/LookupProvider.java (-1 / +6 lines)
Lines 70-76 Link Here
70
    Lookup createAdditionalLookup(Lookup baseContext);
70
    Lookup createAdditionalLookup(Lookup baseContext);
71
71
72
    /**
72
    /**
73
     * Annotation to register LookupProvider instances.
73
     * Annotation to register {@link LookupProvider} instances.
74
     * <p>If you wish to unconditionally register one or more objects,
75
     * it will be more efficient and may be easier to use
76
     * {@link ProjectServiceProvider} (and/or {@link LookupMerger.Registration}).
74
     * @since org.netbeans.modules.projectapi 1.21
77
     * @since org.netbeans.modules.projectapi 1.21
75
     */
78
     */
76
    @Retention(RetentionPolicy.SOURCE)
79
    @Retention(RetentionPolicy.SOURCE)
Lines 83-94 Link Here
83
        /**
86
        /**
84
         * Alternate registration of project types with positions.
87
         * Alternate registration of project types with positions.
85
         * You must specify either this or {@link #projectType} (or both).
88
         * You must specify either this or {@link #projectType} (or both).
89
         * @since org.netbeans.modules.projectapi/1 1.22
86
         */
90
         */
87
        ProjectType[] projectTypes() default {};
91
        ProjectType[] projectTypes() default {};
88
        @Retention(RetentionPolicy.SOURCE)
92
        @Retention(RetentionPolicy.SOURCE)
89
        @Target({})
93
        @Target({})
90
        /**
94
        /**
91
         * Alternate individual registration for one project type.
95
         * Alternate individual registration for one project type.
96
         * @since org.netbeans.modules.projectapi/1 1.22
92
         */
97
         */
93
        @interface ProjectType {
98
        @interface ProjectType {
94
            /**
99
            /**
(-)a/projectapi/src/org/netbeans/spi/project/ProjectServiceProvider.java (+77 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.spi.project;
41
42
import java.lang.annotation.ElementType;
43
import java.lang.annotation.Retention;
44
import java.lang.annotation.RetentionPolicy;
45
import java.lang.annotation.Target;
46
import org.netbeans.api.project.Project;
47
import org.netbeans.spi.project.LookupProvider.Registration.ProjectType;
48
import org.openide.util.Lookup;
49
50
/**
51
 * Like {@link LookupProvider} but registers a single object into a project's lookup.
52
 * An annotated class must have one public constructor, which may take {@link Project} and/or {@link Lookup} parameters.
53
 * An annotated factory method must have similar parameters.
54
 * @since org.netbeans.modules.projectapi/1 1.23
55
 */
56
@Retention(RetentionPolicy.SOURCE)
57
@Target({ElementType.TYPE, ElementType.METHOD})
58
public @interface ProjectServiceProvider {
59
60
    /**
61
     * Service class(es) to be registered.
62
     * The annotated class must be assignable to the service class(es).
63
     */
64
    Class<?>[] service();
65
66
    /**
67
     * Token(s) denoting one or more project types, e.g. {@code "org-netbeans-modules-java-j2seproject"}
68
     */
69
    String[] projectType() default {};
70
71
    /**
72
     * Alternate registration of project types with positions.
73
     * You must specify either this or {@link #projectType} (or both).
74
     */
75
    ProjectType[] projectTypes() default {};
76
77
}
(-)a/projectapi/src/org/netbeans/spi/project/support/LookupProviderSupport.java (-6 / +27 lines)
Lines 54-59 Link Here
54
import javax.swing.event.ChangeListener;
54
import javax.swing.event.ChangeListener;
55
import org.netbeans.api.project.SourceGroup;
55
import org.netbeans.api.project.SourceGroup;
56
import org.netbeans.api.project.Sources;
56
import org.netbeans.api.project.Sources;
57
import org.netbeans.modules.projectapi.MetaLookupMerger;
57
import org.netbeans.spi.project.LookupMerger;
58
import org.netbeans.spi.project.LookupMerger;
58
import org.netbeans.spi.project.LookupProvider;
59
import org.netbeans.spi.project.LookupProvider;
59
import org.openide.ErrorManager;
60
import org.openide.ErrorManager;
Lines 108-113 Link Here
108
        private List<Lookup> currentLookups;
109
        private List<Lookup> currentLookups;
109
        
110
        
110
        private Lookup.Result<LookupMerger> mergers;
111
        private Lookup.Result<LookupMerger> mergers;
112
        private final Lookup.Result<MetaLookupMerger> metaMergers;
111
        private Reference<LookupListener> listenerRef;
113
        private Reference<LookupListener> listenerRef;
112
        //#68623: the proxy lookup fires changes only if someone listens on a particular template:
114
        //#68623: the proxy lookup fires changes only if someone listens on a particular template:
113
        private final List<Lookup.Result<?>> results = new ArrayList<Lookup.Result<?>>();
115
        private final List<Lookup.Result<?>> results = new ArrayList<Lookup.Result<?>>();
Lines 121-137 Link Here
121
            assert base != null;
123
            assert base != null;
122
            baseLookup = base;
124
            baseLookup = base;
123
            providerResult = providerLookup.lookup(new Lookup.Template<LookupProvider>(LookupProvider.class));
125
            providerResult = providerLookup.lookup(new Lookup.Template<LookupProvider>(LookupProvider.class));
126
            metaMergers = providerLookup.lookupResult(MetaLookupMerger.class);
124
            assert isAllJustLookupProviders(providerLookup) : 
127
            assert isAllJustLookupProviders(providerLookup) : 
125
                "Layer content at " + path + " contains other than LookupProvider instances! See messages.log file for more details."; //NOI18N
128
                "Layer content at " + path + " contains other than LookupProvider instances! See messages.log file for more details."; //NOI18N
126
            doDelegate(providerResult.allInstances());
129
            doDelegate();
127
            providerListener = new LookupListener() {
130
            providerListener = new LookupListener() {
128
                public void resultChanged(LookupEvent ev) {
131
                public void resultChanged(LookupEvent ev) {
129
                    // XXX this may need to be run asynchronously; deadlock-prone
132
                    // XXX this may need to be run asynchronously; deadlock-prone
130
                    doDelegate(providerResult.allInstances());
133
                    doDelegate();
131
                }
134
                }
132
            };
135
            };
133
            providerResult.addLookupListener(
136
            providerResult.addLookupListener(
134
                WeakListeners.create(LookupListener.class, providerListener, providerResult));
137
                WeakListeners.create(LookupListener.class, providerListener, providerResult));
138
            metaMergers.addLookupListener(
139
                WeakListeners.create(LookupListener.class, providerListener, metaMergers));
135
        }
140
        }
136
        
141
        
137
        //just for assertion evaluation.
142
        //just for assertion evaluation.
Lines 139-145 Link Here
139
            Lookup.Result<Object> res = lkp.lookupResult(Object.class);
144
            Lookup.Result<Object> res = lkp.lookupResult(Object.class);
140
            Set<Class<?>> set = res.allClasses();
145
            Set<Class<?>> set = res.allClasses();
141
            for (Class clzz : set) {
146
            for (Class clzz : set) {
142
                if (!LookupProvider.class.isAssignableFrom(clzz)) {
147
                if (!LookupProvider.class.isAssignableFrom(clzz) && !MetaLookupMerger.class.isAssignableFrom(clzz)) {
143
                    Logger.getLogger(LookupProviderSupport.class.getName()).warning("" + clzz.getName() + " is not instance of LookupProvider."); //NOI18N
148
                    Logger.getLogger(LookupProviderSupport.class.getName()).warning("" + clzz.getName() + " is not instance of LookupProvider."); //NOI18N
144
                    return false;
149
                    return false;
145
                }
150
                }
Lines 149-164 Link Here
149
        
154
        
150
        
155
        
151
        public void resultChanged(LookupEvent ev) {
156
        public void resultChanged(LookupEvent ev) {
152
            doDelegate(providerResult.allInstances());
157
            doDelegate();
158
        }
159
160
        protected @Override void beforeLookup(Lookup.Template<?> template) {
161
            for (MetaLookupMerger metaMerger : metaMergers.allInstances()) {
162
                if (metaMerger.canNowMerge(template.getType())) {
163
                    doDelegate();
164
                }
165
            }
153
        }
166
        }
154
        
167
        
155
        
168
        
156
        private synchronized void doDelegate(Collection<? extends LookupProvider> providers) {
169
        private synchronized void doDelegate() {
157
            //unregister listeners from the old results:
170
            //unregister listeners from the old results:
158
            for (Lookup.Result<?> r : results) {
171
            for (Lookup.Result<?> r : results) {
159
                r.removeLookupListener(this);
172
                r.removeLookupListener(this);
160
            }
173
            }
161
            
174
            
175
            Collection<? extends LookupProvider> providers = providerResult.allInstances();
162
            List<Lookup> newLookups = new ArrayList<Lookup>();
176
            List<Lookup> newLookups = new ArrayList<Lookup>();
163
            for (LookupProvider elem : providers) {
177
            for (LookupProvider elem : providers) {
164
                if (old.contains(elem)) {
178
                if (old.contains(elem)) {
Lines 186-192 Link Here
186
            l = WeakListeners.create(LookupListener.class, this, mergers);
200
            l = WeakListeners.create(LookupListener.class, this, mergers);
187
            listenerRef = new WeakReference<LookupListener>(l);
201
            listenerRef = new WeakReference<LookupListener>(l);
188
            mergers.addLookupListener(l);
202
            mergers.addLookupListener(l);
189
            for (LookupMerger lm : mergers.allInstances()) {
203
            Collection<LookupMerger> allMergers = new ArrayList<LookupMerger>(mergers.allInstances());
204
            for (MetaLookupMerger metaMerger : metaMergers.allInstances()) {
205
                LookupMerger merger = metaMerger.merger();
206
                if (merger != null) {
207
                    allMergers.add(merger);
208
                }
209
            }
210
            for (LookupMerger lm : allMergers) {
190
                Class<?> c = lm.getMergeableClass();
211
                Class<?> c = lm.getMergeableClass();
191
                if (filteredClasses.contains(c)) {
212
                if (filteredClasses.contains(c)) {
192
                    ErrorManager.getDefault().log(ErrorManager.WARNING,
213
                    ErrorManager.getDefault().log(ErrorManager.WARNING,
(-)a/projectapi/test/unit/src/org/netbeans/spi/project/support/LookupProviderSupportTest.java (+92 lines)
Lines 42-50 Link Here
42
package org.netbeans.spi.project.support;
42
package org.netbeans.spi.project.support;
43
43
44
import java.beans.PropertyChangeListener;
44
import java.beans.PropertyChangeListener;
45
import java.net.URL;
46
import java.net.URLClassLoader;
47
import java.util.Arrays;
48
import java.util.Collection;
45
import java.util.Collections;
49
import java.util.Collections;
46
import java.util.HashMap;
50
import java.util.HashMap;
47
import java.util.HashSet;
51
import java.util.HashSet;
52
import java.util.Set;
53
import java.util.SortedSet;
54
import java.util.TreeSet;
48
import javax.swing.Icon;
55
import javax.swing.Icon;
49
import javax.swing.JButton;
56
import javax.swing.JButton;
50
import javax.swing.JCheckBox;
57
import javax.swing.JCheckBox;
Lines 58-69 Link Here
58
import org.netbeans.junit.NbTestCase;
65
import org.netbeans.junit.NbTestCase;
59
import org.netbeans.spi.project.LookupMerger;
66
import org.netbeans.spi.project.LookupMerger;
60
import org.netbeans.spi.project.LookupProvider;
67
import org.netbeans.spi.project.LookupProvider;
68
import org.netbeans.spi.project.ProjectServiceProvider;
61
import org.openide.filesystems.FileObject;
69
import org.openide.filesystems.FileObject;
62
import org.openide.util.Lookup;
70
import org.openide.util.Lookup;
63
import org.openide.util.lookup.AbstractLookup;
71
import org.openide.util.lookup.AbstractLookup;
64
import org.openide.util.lookup.InstanceContent;
72
import org.openide.util.lookup.InstanceContent;
65
import org.openide.util.lookup.Lookups;
73
import org.openide.util.lookup.Lookups;
66
import org.openide.util.test.MockChangeListener;
74
import org.openide.util.test.MockChangeListener;
75
import org.openide.util.test.MockLookup;
67
76
68
/**
77
/**
69
 * @author mkleint
78
 * @author mkleint
Lines 285-289 Link Here
285
        public void removePropertyChangeListener(PropertyChangeListener listener) {
294
        public void removePropertyChangeListener(PropertyChangeListener listener) {
286
        }
295
        }
287
    }
296
    }
297
298
    public void testLazyProviders() throws Exception {
299
        // Cannot simply use static initializers to tell when classes are loaded;
300
        // these will not be run in case a service is loaded but not yet initialized.
301
        ClassLoader l = new URLClassLoader(new URL[] {
302
            LookupProviderSupportTest.class.getProtectionDomain().getCodeSource().getLocation()},
303
            LookupProviderSupportTest.class.getClassLoader()) {
304
            protected @Override synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
305
                if (name.startsWith(LookupProviderSupportTest.class.getName() + "$")) {
306
                    Class c = findLoadedClass(name);
307
                    if (c == null) {
308
                        // do not delegate to parent, i.e. be sure we have loaded it
309
                        c = findClass(name);
310
                        if (resolve) {
311
                            resolveClass(c);
312
                        }
313
                        loadedClasses.add(c);
314
                    }
315
                    return c;
316
                } else {
317
                    return super.loadClass(name, resolve);
318
                }
319
            }
320
        };
321
        Thread.currentThread().setContextClassLoader(l);
322
        MockLookup.setInstances(l);
323
        assertLoadedClasses();
324
        Lookup all = LookupProviderSupport.createCompositeLookup(Lookups.fixed("hello"), "Projects/x/Lookup");
325
        assertLoadedClasses();
326
        assertEquals("hello", all.lookup(String.class));
327
        assertLoadedClasses();
328
        Collection<?> svcs2 = all.lookupAll(l.loadClass(Service2.class.getName()));
329
        assertEquals(1, svcs2.size());
330
        assertEquals(ServiceImpl2.class.getName(), svcs2.iterator().next().getClass().getName());
331
        assertLoadedClasses("Service2", "ServiceImpl2");
332
        Collection<?> svcs1 = all.lookupAll(l.loadClass(Service1.class.getName()));
333
        assertLoadedClasses("MergedServiceImpl1", "Merger", "Service1", "Service2", "ServiceImpl1a", "ServiceImpl1b", "ServiceImpl2");
334
        assertEquals(svcs1.toString(), 1, svcs1.size());
335
        assertTrue(svcs1.toString(), svcs1.toString().contains("ServiceImpl1a@"));
336
        assertTrue(svcs1.toString(), svcs1.toString().contains("ServiceImpl1b@"));
337
        assertTrue(svcs1.toString(), svcs1.toString().contains("Merge["));
338
    }
339
    private static final Set<Class<?>> loadedClasses = new HashSet<Class<?>>();
340
    private static void assertLoadedClasses(String... names) {
341
        SortedSet<String> actual = new TreeSet<String>();
342
        for (Class<?> clazz : loadedClasses) {
343
            actual.add(clazz.getName().replaceFirst("^\\Q" + LookupProviderSupportTest.class.getName() + "$\\E", ""));
344
        }
345
        assertEquals(Arrays.toString(names), actual.toString());
346
    }
347
    public interface Service1 {}
348
    public interface Service2 {}
349
    @ProjectServiceProvider(projectType="x", service=Service1.class)
350
    public static class ServiceImpl1a implements Service1 {}
351
    public static class ServiceImpl1b implements Service1 {
352
        private ServiceImpl1b(boolean x) {assert x;}
353
        @ProjectServiceProvider(projectType="x", service=Service1.class)
354
        public static Service1 create() {return new ServiceImpl1b(true);}
355
    }
356
    @ProjectServiceProvider(projectType="x", service=Service2.class)
357
    public static class ServiceImpl2 implements Service2 {
358
        public ServiceImpl2(Lookup base) {
359
            assertNotNull(base.lookup(String.class));
360
        }
361
    }
362
    @LookupMerger.Registration(projectType="x")
363
    public static class Merger implements LookupMerger<Service1> {
364
        public Class<Service1> getMergeableClass() {
365
            return Service1.class;
366
        }
367
        public Service1 merge(final Lookup lkp) {
368
            return new MergedServiceImpl1(lkp.lookupAll(Service1.class));
369
        }
370
    }
371
    private static class MergedServiceImpl1 implements Service1 {
372
        private final Collection<? extends Service1> delegates;
373
        MergedServiceImpl1(Collection<? extends Service1> delegates) {
374
            this.delegates = delegates;
375
        }
376
        public @Override String toString() {
377
            return "Merge" + delegates;
378
        }
379
    }
288
    
380
    
289
}
381
}
(-)a/spring.beans/nbproject/project.xml (-1 / +1 lines)
Lines 227-233 Link Here
227
                    <compile-dependency/>
227
                    <compile-dependency/>
228
                    <run-dependency>
228
                    <run-dependency>
229
                        <release-version>1</release-version>
229
                        <release-version>1</release-version>
230
                        <specification-version>1.17</specification-version>
230
                        <specification-version>1.23</specification-version>
231
                    </run-dependency>
231
                    </run-dependency>
232
                </dependency>
232
                </dependency>
233
                <dependency>
233
                <dependency>
(-)a/spring.beans/src/org/netbeans/modules/spring/beans/ProjectLookupProvider.java (-107 lines)
Lines 1-107 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.modules.spring.beans;
43
44
import java.util.ArrayList;
45
import java.util.List;
46
import org.netbeans.api.project.Project;
47
import org.netbeans.spi.project.LookupProvider;
48
import org.openide.util.Lookup;
49
import org.openide.util.lookup.Lookups;
50
51
/**
52
 *
53
 * @author Andrei Badea
54
 */
55
public class ProjectLookupProvider implements LookupProvider {
56
57
    private final Kind kind;
58
    
59
    @LookupProvider.Registration(projectType={
60
        "org-netbeans-modules-java-j2seproject",
61
        "org-netbeans-modules-j2ee-ejbjarproject"
62
    })
63
    public static ProjectLookupProvider standard() {
64
        return new ProjectLookupProvider(Kind.NON_WEB);
65
    }
66
67
    @LookupProvider.Registration(projectType="org-netbeans-modules-web-project")
68
    public static ProjectLookupProvider web() {
69
        return new ProjectLookupProvider(Kind.WEB);
70
    }
71
72
    @LookupProvider.Registration(projectType="org-netbeans-modules-maven")
73
    public static ProjectLookupProvider simple() {
74
        return new ProjectLookupProvider(Kind.SIMPLE);
75
    }
76
77
    private ProjectLookupProvider(Kind kind) {
78
        this.kind = kind;
79
    }
80
81
    public Lookup createAdditionalLookup(Lookup baseContext) {
82
        Project project = baseContext.lookup(Project.class);
83
        if (project == null) {
84
            throw new IllegalStateException("Lookup " + baseContext + " does not contain a Project");
85
        }
86
        List<Object> instances = new ArrayList<Object>(3);
87
        instances.add(new ProjectSpringScopeProvider(project));
88
        if (kind != Kind.SIMPLE) {
89
            instances.add(new RecommendedTemplatesImpl(kind == Kind.WEB));
90
            instances.add(new SpringConfigFileLocationProviderImpl(project));
91
        }
92
        return Lookups.fixed(instances.toArray(new Object[instances.size()]));
93
    }
94
95
    enum Kind {
96
97
        // For most projects.
98
        NON_WEB,
99
100
        // For web projects, whose config file providers are provided by the Web MVC support
101
        // (since it needs to use the WebModule API).
102
        WEB,
103
104
        // For Maven projects, which implement everything.
105
        SIMPLE
106
    }
107
}
(-)a/spring.beans/src/org/netbeans/modules/spring/beans/ProjectSpringScopeProvider.java (+7 lines)
Lines 44-54 Link Here
44
import org.netbeans.api.project.Project;
44
import org.netbeans.api.project.Project;
45
import org.netbeans.modules.spring.api.beans.ConfigFileManager;
45
import org.netbeans.modules.spring.api.beans.ConfigFileManager;
46
import org.netbeans.modules.spring.api.beans.SpringScope;
46
import org.netbeans.modules.spring.api.beans.SpringScope;
47
import org.netbeans.spi.project.ProjectServiceProvider;
47
48
48
/**
49
/**
49
 *
50
 *
50
 * @author Andrei Badea
51
 * @author Andrei Badea
51
 */
52
 */
53
@ProjectServiceProvider(service=ProjectSpringScopeProvider.class, projectType={
54
    "org-netbeans-modules-java-j2seproject",
55
    "org-netbeans-modules-j2ee-ejbjarproject",
56
    "org-netbeans-modules-web-project",
57
    "org-netbeans-modules-maven"
58
})
52
public class ProjectSpringScopeProvider {
59
public class ProjectSpringScopeProvider {
53
60
54
    private final Project project;
61
    private final Project project;
(-)a/spring.beans/src/org/netbeans/modules/spring/beans/RecommendedTemplatesImpl.java (-1 / +15 lines)
Lines 39-44 Link Here
39
39
40
package org.netbeans.modules.spring.beans;
40
package org.netbeans.modules.spring.beans;
41
41
42
import org.netbeans.spi.project.ProjectServiceProvider;
42
import org.netbeans.spi.project.ui.RecommendedTemplates;
43
import org.netbeans.spi.project.ui.RecommendedTemplates;
43
44
44
/**
45
/**
Lines 57-66 Link Here
57
58
58
    private final boolean web;
59
    private final boolean web;
59
60
60
    public RecommendedTemplatesImpl(boolean web) {
61
    private RecommendedTemplatesImpl(boolean web) {
61
        this.web = web;
62
        this.web = web;
62
    }
63
    }
63
64
65
    @ProjectServiceProvider(service=RecommendedTemplates.class, projectType="org-netbeans-modules-web-project")
66
    public static RecommendedTemplates forWeb() {
67
        return new RecommendedTemplatesImpl(true);
68
    }
69
70
    @ProjectServiceProvider(service=RecommendedTemplates.class, projectType={
71
        "org-netbeans-modules-java-j2seproject",
72
        "org-netbeans-modules-j2ee-ejbjarproject"
73
    })
74
    public static RecommendedTemplates forNonWeb() {
75
        return new RecommendedTemplatesImpl(true);
76
    }
77
64
    public String[] getRecommendedTypes() {
78
    public String[] getRecommendedTypes() {
65
        return web ? SPRING_WEB_TYPES : SPRING_TYPES;
79
        return web ? SPRING_WEB_TYPES : SPRING_TYPES;
66
    }
80
    }
(-)a/spring.beans/src/org/netbeans/modules/spring/beans/SpringConfigFileLocationProviderImpl.java (+6 lines)
Lines 43-54 Link Here
43
import org.netbeans.api.project.SourceGroup;
43
import org.netbeans.api.project.SourceGroup;
44
import org.netbeans.modules.j2ee.core.api.support.SourceGroups;
44
import org.netbeans.modules.j2ee.core.api.support.SourceGroups;
45
import org.netbeans.modules.spring.spi.beans.SpringConfigFileLocationProvider;
45
import org.netbeans.modules.spring.spi.beans.SpringConfigFileLocationProvider;
46
import org.netbeans.spi.project.ProjectServiceProvider;
46
import org.openide.filesystems.FileObject;
47
import org.openide.filesystems.FileObject;
47
48
48
/**
49
/**
49
 *
50
 *
50
 * @author Andrei Badea
51
 * @author Andrei Badea
51
 */
52
 */
53
@ProjectServiceProvider(service=SpringConfigFileLocationProvider.class, projectType={
54
    "org-netbeans-modules-java-j2seproject",
55
    "org-netbeans-modules-j2ee-ejbjarproject",
56
    "org-netbeans-modules-web-project"
57
})
52
public class SpringConfigFileLocationProviderImpl implements SpringConfigFileLocationProvider {
58
public class SpringConfigFileLocationProviderImpl implements SpringConfigFileLocationProvider {
53
59
54
    private final Project project;
60
    private final Project project;
(-)a/spring.webmvc/nbproject/project.xml (-1 / +1 lines)
Lines 123-129 Link Here
123
                    <compile-dependency/>
123
                    <compile-dependency/>
124
                    <run-dependency>
124
                    <run-dependency>
125
                        <release-version>1</release-version>
125
                        <release-version>1</release-version>
126
                        <specification-version>1.13</specification-version>
126
                        <specification-version>1.23</specification-version>
127
                    </run-dependency>
127
                    </run-dependency>
128
                </dependency>
128
                </dependency>
129
                <dependency>
129
                <dependency>
(-)a/spring.webmvc/src/org/netbeans/modules/spring/webmvc/ProjectLookupProvider.java (-63 lines)
Lines 1-63 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.modules.spring.webmvc;
43
44
import org.netbeans.api.project.Project;
45
import org.netbeans.spi.project.LookupProvider;
46
import org.openide.util.Lookup;
47
import org.openide.util.lookup.Lookups;
48
49
/**
50
 *
51
 * @author Andrei Badea
52
 */
53
@LookupProvider.Registration(projectType="org-netbeans-modules-web-project")
54
public class ProjectLookupProvider implements LookupProvider {
55
56
    public Lookup createAdditionalLookup(Lookup baseContext) {
57
        Project project = baseContext.lookup(Project.class);
58
        if (project == null) {
59
            throw new IllegalStateException("Lookup " + baseContext + " does not contain a Project");
60
        }
61
        return Lookups.singleton(new WebProjectSpringConfigFileProvider(project));
62
    }
63
}
(-)a/spring.webmvc/src/org/netbeans/modules/spring/webmvc/WebProjectSpringConfigFileProvider.java (+3 lines)
Lines 51-56 Link Here
51
import org.netbeans.modules.spring.spi.beans.SpringConfigFileProvider;
51
import org.netbeans.modules.spring.spi.beans.SpringConfigFileProvider;
52
import org.netbeans.modules.web.api.webmodule.WebModule;
52
import org.netbeans.modules.web.api.webmodule.WebModule;
53
import org.netbeans.modules.web.spi.webmodule.WebModuleProvider;
53
import org.netbeans.modules.web.spi.webmodule.WebModuleProvider;
54
import org.netbeans.spi.project.ProjectServiceProvider;
54
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileUtil;
56
import org.openide.filesystems.FileUtil;
56
import org.openide.util.NbCollections;
57
import org.openide.util.NbCollections;
Lines 59-64 Link Here
59
 *
60
 *
60
 * @author Andrei Badea
61
 * @author Andrei Badea
61
 */
62
 */
63
@ProjectServiceProvider(service={SpringConfigFileProvider.class, SpringConfigFileLocationProvider.class},
64
projectType="org-netbeans-modules-web-project")
62
public class WebProjectSpringConfigFileProvider implements SpringConfigFileProvider, SpringConfigFileLocationProvider {
65
public class WebProjectSpringConfigFileProvider implements SpringConfigFileProvider, SpringConfigFileLocationProvider {
63
66
64
    private final Project project;
67
    private final Project project;
(-)a/visualweb.project.jsf/nbproject/project.xml (-1 / +1 lines)
Lines 147-153 Link Here
147
                    <compile-dependency/>
147
                    <compile-dependency/>
148
                    <run-dependency>
148
                    <run-dependency>
149
                        <release-version>1</release-version>
149
                        <release-version>1</release-version>
150
                        <specification-version>1.17</specification-version>
150
                        <specification-version>1.23</specification-version>
151
                    </run-dependency>
151
                    </run-dependency>
152
                </dependency>
152
                </dependency>
153
                <dependency>
153
                <dependency>
(-)a/visualweb.project.jsf/src/org/netbeans/modules/visualweb/project/jsf/libraries/ComplibLookupProvider.java (-19 / +4 lines)
Lines 9-32 Link Here
9
9
10
import org.netbeans.api.project.Project;
10
import org.netbeans.api.project.Project;
11
import org.netbeans.modules.visualweb.complib.api.ComplibService;
11
import org.netbeans.modules.visualweb.complib.api.ComplibService;
12
import org.netbeans.spi.project.LookupProvider;
12
import org.netbeans.spi.project.ProjectServiceProvider;
13
import org.netbeans.spi.project.ui.ProjectOpenedHook;
13
import org.netbeans.spi.project.ui.ProjectOpenedHook;
14
import org.openide.util.Lookup;
14
import org.openide.util.Lookup;
15
import org.openide.util.lookup.Lookups;
16
15
17
/**
16
/**
18
 * Code used to initialize and clean up complibs associated with a project.
17
 * Code used to initialize and clean up complibs associated with a project.
19
 * 
18
 * 
20
 * @author Edwin Goei
19
 * @author Edwin Goei
21
 */
20
 */
22
@LookupProvider.Registration(projectType="org-netbeans-modules-web-project")
21
@ProjectServiceProvider(service=ProjectOpenedHook.class, projectType="org-netbeans-modules-web-project")
23
public class ComplibLookupProvider implements LookupProvider {
22
public class ComplibProjectOpenedHook extends ProjectOpenedHook {
24
25
    public static class ComplibProjectOpenedHook extends ProjectOpenedHook {
26
23
27
        private Project project;
24
        private Project project;
28
25
29
        private ComplibProjectOpenedHook(Project project) {
26
        public ComplibProjectOpenedHook(Project project) {
30
            this.project = project;
27
            this.project = project;
31
        }
28
        }
32
29
Lines 46-61 Link Here
46
            }
43
            }
47
        }
44
        }
48
45
49
    }
50
51
    public Lookup createAdditionalLookup(Lookup baseContext) {
52
        Project project = baseContext.lookup(Project.class);
53
        if (project == null) {
54
            assert false : "Unable to derive Project";
55
            return Lookup.EMPTY;
56
        }
57
58
        ComplibProjectOpenedHook projectOpenedHook = new ComplibProjectOpenedHook(project);
59
        return Lookups.fixed(projectOpenedHook);
60
    }
61
}
46
}
(-)a/visualweb.project.jsfloader/nbproject/project.xml (-1 / +1 lines)
Lines 78-84 Link Here
78
                    <compile-dependency/>
78
                    <compile-dependency/>
79
                    <run-dependency>
79
                    <run-dependency>
80
                        <release-version>1</release-version>
80
                        <release-version>1</release-version>
81
                        <specification-version>1.17</specification-version>
81
                        <specification-version>1.23</specification-version>
82
                    </run-dependency>
82
                    </run-dependency>
83
                </dependency>
83
                </dependency>
84
                <dependency>
84
                <dependency>
(-)a/visualweb.project.jsfloader/src/org/netbeans/modules/visualweb/project/jsfloader/OpenEditOverride.java (-12 / +4 lines)
Lines 42-55 Link Here
42
import org.netbeans.core.spi.multiview.MultiViewElement;
42
import org.netbeans.core.spi.multiview.MultiViewElement;
43
import org.netbeans.core.spi.multiview.MultiViewElementCallback;
43
import org.netbeans.core.spi.multiview.MultiViewElementCallback;
44
import org.netbeans.spi.project.AuxiliaryConfiguration;
44
import org.netbeans.spi.project.AuxiliaryConfiguration;
45
import org.netbeans.spi.project.LookupProvider;
45
import org.netbeans.spi.project.ProjectServiceProvider;
46
import org.netbeans.spi.project.ui.ProjectOpenedHook;
46
import org.netbeans.spi.project.ui.ProjectOpenedHook;
47
import org.openide.awt.UndoRedo;
47
import org.openide.awt.UndoRedo;
48
import org.openide.filesystems.FileObject;
48
import org.openide.filesystems.FileObject;
49
import org.openide.filesystems.URLMapper;
49
import org.openide.filesystems.URLMapper;
50
import org.openide.loaders.DataObject;
50
import org.openide.loaders.DataObject;
51
import org.openide.util.Lookup;
51
import org.openide.util.Lookup;
52
import org.openide.util.lookup.Lookups;
53
import org.w3c.dom.Element;
52
import org.w3c.dom.Element;
54
import org.w3c.dom.NodeList;
53
import org.w3c.dom.NodeList;
55
54
Lines 59-66 Link Here
59
 * 
58
 * 
60
 * @author quynguyen
59
 * @author quynguyen
61
 */
60
 */
62
@LookupProvider.Registration(projectType="org-netbeans-modules-web-project")
61
@ProjectServiceProvider(service=ProjectOpenedHook.class, projectType="org-netbeans-modules-web-project")
63
public final class OpenEditOverride  implements LookupProvider {
62
public final class OpenEditOverride extends ProjectOpenedHook {
64
    // Taken from org.netbeans.modules.project.ui.ProjectUtilities
63
    // Taken from org.netbeans.modules.project.ui.ProjectUtilities
65
    private static final String OPEN_FILES_NS = "http://www.netbeans.org/ns/projectui-open-files/1"; // NOI18N
64
    private static final String OPEN_FILES_NS = "http://www.netbeans.org/ns/projectui-open-files/1"; // NOI18N
66
    private static final String OPEN_FILES_ELEMENT = "open-files"; // NOI18N
65
    private static final String OPEN_FILES_ELEMENT = "open-files"; // NOI18N
Lines 70-80 Link Here
70
    
69
    
71
    private static WeakHashMap<Project, HashMap<FileObject,String>> multiViewsByProject = new WeakHashMap<Project, HashMap<FileObject,String>>();
70
    private static WeakHashMap<Project, HashMap<FileObject,String>> multiViewsByProject = new WeakHashMap<Project, HashMap<FileObject,String>>();
72
    
71
    
73
    public Lookup createAdditionalLookup(Lookup baseContext) {
74
        Project proj = baseContext.lookup(Project.class);
75
        return Lookups.singleton(new ProjectOpenedHookImpl(proj));
76
    }
77
    
78
    private static void multiViewChanged(Project fromProject, DataObject multiViewDO, String multiViewId) {
72
    private static void multiViewChanged(Project fromProject, DataObject multiViewDO, String multiViewId) {
79
        HashMap<FileObject,String> projectMultiViews = multiViewsByProject.get(fromProject);
73
        HashMap<FileObject,String> projectMultiViews = multiViewsByProject.get(fromProject);
80
        
74
        
Lines 89-98 Link Here
89
        multiViewsByProject.remove(proj);
83
        multiViewsByProject.remove(proj);
90
    }
84
    }
91
    
85
    
92
    private static final class ProjectOpenedHookImpl extends ProjectOpenedHook {
93
        private WeakReference<Project> projectRef;
86
        private WeakReference<Project> projectRef;
94
        
87
        
95
        public ProjectOpenedHookImpl(Project project) {
88
        public OpenEditOverride(Project project) {
96
            this.projectRef = new WeakReference<Project>(project);
89
            this.projectRef = new WeakReference<Project>(project);
97
        }
90
        }
98
        
91
        
Lines 149-155 Link Here
149
                unregisterProject(project);
142
                unregisterProject(project);
150
            }
143
            }
151
        }
144
        }
152
    }
153
            
145
            
154
    static final class MultiViewDelegate implements MultiViewElement {
146
    static final class MultiViewDelegate implements MultiViewElement {
155
        private final MultiViewElement originalElement;
147
        private final MultiViewElement originalElement;
(-)a/websvc.core/nbproject/project.xml (-1 / +1 lines)
Lines 275-281 Link Here
275
                    <compile-dependency/>
275
                    <compile-dependency/>
276
                    <run-dependency>
276
                    <run-dependency>
277
                        <release-version>1</release-version>
277
                        <release-version>1</release-version>
278
                        <specification-version>1.17</specification-version>
278
                        <specification-version>1.23</specification-version>
279
                    </run-dependency>
279
                    </run-dependency>
280
                </dependency>
280
                </dependency>
281
                <dependency>
281
                <dependency>
(-)a/websvc.core/src/org/netbeans/modules/websvc/core/jaxws/projects/J2SEJAXWSVersionProvider.java (+2 lines)
Lines 63-74 Link Here
63
import org.netbeans.api.project.ProjectUtils;
63
import org.netbeans.api.project.ProjectUtils;
64
import org.netbeans.api.project.SourceGroup;
64
import org.netbeans.api.project.SourceGroup;
65
import org.netbeans.modules.websvc.api.jaxws.project.JAXWSVersionProvider;
65
import org.netbeans.modules.websvc.api.jaxws.project.JAXWSVersionProvider;
66
import org.netbeans.spi.project.ProjectServiceProvider;
66
import org.openide.filesystems.FileObject;
67
import org.openide.filesystems.FileObject;
67
68
68
/**
69
/**
69
 *
70
 *
70
 * @author mkuchtiak
71
 * @author mkuchtiak
71
 */
72
 */
73
@ProjectServiceProvider(service=JAXWSVersionProvider.class, projectType="org-netbeans-modules-java-j2seproject")
72
public class J2SEJAXWSVersionProvider implements JAXWSVersionProvider{
74
public class J2SEJAXWSVersionProvider implements JAXWSVersionProvider{
73
    
75
    
74
    private Project project;
76
    private Project project;
(-)a/websvc.core/src/org/netbeans/modules/websvc/core/jaxws/projects/J2SEProjectWSClientSupportProvider.java (+2 lines)
Lines 48-59 Link Here
48
48
49
import org.netbeans.modules.websvc.api.client.WebServicesClientSupport;
49
import org.netbeans.modules.websvc.api.client.WebServicesClientSupport;
50
import org.netbeans.modules.websvc.spi.client.WebServicesClientSupportProvider;
50
import org.netbeans.modules.websvc.spi.client.WebServicesClientSupportProvider;
51
import org.netbeans.spi.project.ProjectServiceProvider;
51
52
52
53
53
/** Provider object to locate web service client support for j2se project.
54
/** Provider object to locate web service client support for j2se project.
54
 *
55
 *
55
 * @author Milan Kuchtiak
56
 * @author Milan Kuchtiak
56
 */
57
 */
58
@ProjectServiceProvider(service=WebServicesClientSupportProvider.class, projectType="org-netbeans-modules-java-j2seproject")
57
public class J2SEProjectWSClientSupportProvider implements WebServicesClientSupportProvider {
59
public class J2SEProjectWSClientSupportProvider implements WebServicesClientSupportProvider {
58
60
59
    public J2SEProjectWSClientSupportProvider () {
61
    public J2SEProjectWSClientSupportProvider () {
(-)a/websvc.core/src/org/netbeans/modules/websvc/core/jaxws/projects/J2SEWSSupportLookupProvider.java (-4 / +2 lines)
Lines 57-62 Link Here
57
 *
57
 *
58
 * @author mkuchtiak
58
 * @author mkuchtiak
59
 */
59
 */
60
// XXX could probably be converted to use @ProjectServiceProvider instead
61
// (would need to do some refactoring first)
60
@LookupProvider.Registration(projectType="org-netbeans-modules-java-j2seproject")
62
@LookupProvider.Registration(projectType="org-netbeans-modules-java-j2seproject")
61
public class J2SEWSSupportLookupProvider implements LookupProvider {
63
public class J2SEWSSupportLookupProvider implements LookupProvider {
62
    
64
    
Lines 86-95 Link Here
86
        return Lookups.fixed(new Object[] {
88
        return Lookups.fixed(new Object[] {
87
            jaxWsClientSupportApi,
89
            jaxWsClientSupportApi,
88
            jaxRpcClientSupportApi,
90
            jaxRpcClientSupportApi,
89
            new J2SEProjectWSClientSupportProvider(),
90
            new JaxWsArtifactsClassPathProvider(project),
91
            new J2SEJAXWSVersionProvider(project),
92
            new JaxWsSourceForBinaryQueryImpl(project, false),
93
            openHook});
91
            openHook});
94
    }
92
    }
95
}
93
}
(-)a/websvc.core/src/org/netbeans/modules/websvc/core/jaxws/projects/JavaEEJAXWSVersionProvider.java (+6 lines)
Lines 56-66 Link Here
56
import org.netbeans.modules.websvc.core.WSStackUtils;
56
import org.netbeans.modules.websvc.core.WSStackUtils;
57
import org.netbeans.modules.websvc.wsstack.api.WSStack;
57
import org.netbeans.modules.websvc.wsstack.api.WSStack;
58
import org.netbeans.modules.websvc.wsstack.jaxws.JaxWs;
58
import org.netbeans.modules.websvc.wsstack.jaxws.JaxWs;
59
import org.netbeans.spi.project.ProjectServiceProvider;
59
60
60
/**
61
/**
61
 *
62
 *
62
 * @author rico
63
 * @author rico
63
 */
64
 */
65
@ProjectServiceProvider(service=JAXWSVersionProvider.class, projectType={
66
    "org-netbeans-modules-web-project",
67
    "org-netbeans-modules-j2ee-ejbjarproject",
68
    "org-netbeans-modules-j2ee-clientproject"
69
})
64
public class JavaEEJAXWSVersionProvider implements JAXWSVersionProvider{
70
public class JavaEEJAXWSVersionProvider implements JAXWSVersionProvider{
65
    
71
    
66
    private Project project;
72
    private Project project;
(-)a/websvc.core/src/org/netbeans/modules/websvc/core/jaxws/projects/JavaEEWSSupportLookupProvider.java (-28 / +10 lines)
Lines 59-92 Link Here
59
import org.netbeans.modules.websvc.api.jaxws.project.config.ServiceAlreadyExistsExeption;
59
import org.netbeans.modules.websvc.api.jaxws.project.config.ServiceAlreadyExistsExeption;
60
import org.netbeans.modules.websvc.core.JaxWsUtils;
60
import org.netbeans.modules.websvc.core.JaxWsUtils;
61
import org.netbeans.modules.websvc.jaxws.api.JAXWSSupport;
61
import org.netbeans.modules.websvc.jaxws.api.JAXWSSupport;
62
import org.netbeans.spi.project.LookupProvider;
62
import org.netbeans.spi.project.ProjectServiceProvider;
63
import org.netbeans.spi.project.ui.ProjectOpenedHook;
63
import org.netbeans.spi.project.ui.ProjectOpenedHook;
64
import org.openide.ErrorManager;
64
import org.openide.ErrorManager;
65
import org.openide.util.Lookup;
66
import org.openide.util.RequestProcessor;
65
import org.openide.util.RequestProcessor;
67
import org.openide.util.lookup.Lookups;
68
66
69
/**
67
/**
70
 * Lookup Provider for WS Support in JavaEE project types
71
 *
72
 * @author mkuchtiak
68
 * @author mkuchtiak
73
 */
69
 */
74
    @LookupProvider.Registration(projectType={
70
@ProjectServiceProvider(service=ProjectOpenedHook.class, projectType={
75
        "org-netbeans-modules-web-project",
71
    "org-netbeans-modules-web-project",
76
        "org-netbeans-modules-j2ee-ejbjarproject",
72
    "org-netbeans-modules-j2ee-ejbjarproject",
77
        "org-netbeans-modules-j2ee-clientproject"
73
    "org-netbeans-modules-j2ee-clientproject"
78
    })
74
})
79
public class JavaEEWSSupportLookupProvider implements LookupProvider {
75
public class JavaEEWSOpenHook extends ProjectOpenedHook {
80
76
81
    /** Creates a new instance of JavaEEWSSupportLookupProvider */
77
    private final Project prj;
82
    public JavaEEWSSupportLookupProvider() {
78
    public JavaEEWSOpenHook(Project prj) {
79
        this.prj = prj;
83
    }
80
    }
84
81
85
    public Lookup createAdditionalLookup(Lookup baseContext) {
86
        final Project prj = baseContext.lookup(Project.class);
87
88
        ProjectOpenedHook openhook = new ProjectOpenedHook() {
89
90
            PropertyChangeListener pcl;
82
            PropertyChangeListener pcl;
91
83
92
            protected void projectOpened() {
84
            protected void projectOpened() {
Lines 127-142 Link Here
127
                    }
119
                    }
128
                }
120
                }
129
            }
121
            }
130
        };
131
132
        ProjectWebServiceNotifier servicesNotifier = new ProjectWebServiceNotifier(prj);
133
        return Lookups.fixed(
134
                openhook,
135
                servicesNotifier,
136
                new JaxWsArtifactsClassPathProvider(prj),
137
                new JavaEEJAXWSVersionProvider(prj),
138
                new JaxWsSourceForBinaryQueryImpl(prj, true));
139
    }
140
122
141
    private class WebservicesChangeListener implements PropertyChangeListener {
123
    private class WebservicesChangeListener implements PropertyChangeListener {
142
124
(-)a/websvc.core/src/org/netbeans/modules/websvc/core/jaxws/projects/JaxWsArtifactsClassPathProvider.java (-1 / +8 lines)
Lines 65-70 Link Here
65
import org.netbeans.spi.java.classpath.ClassPathProvider;
65
import org.netbeans.spi.java.classpath.ClassPathProvider;
66
import org.netbeans.spi.java.classpath.PathResourceImplementation;
66
import org.netbeans.spi.java.classpath.PathResourceImplementation;
67
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
67
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
68
import org.netbeans.spi.project.ProjectServiceProvider;
68
import org.openide.filesystems.FileObject;
69
import org.openide.filesystems.FileObject;
69
import org.openide.filesystems.FileUtil;
70
import org.openide.filesystems.FileUtil;
70
import org.openide.modules.InstalledFileLocator;
71
import org.openide.modules.InstalledFileLocator;
Lines 73-78 Link Here
73
 *
74
 *
74
 * @author mkuchtiak
75
 * @author mkuchtiak
75
 */
76
 */
77
@ProjectServiceProvider(service=ClassPathProvider.class, projectType={
78
    "org-netbeans-modules-web-project",
79
    "org-netbeans-modules-j2ee-ejbjarproject",
80
    "org-netbeans-modules-j2ee-clientproject",
81
    "org-netbeans-modules-java-j2seproject"
82
})
76
public class JaxWsArtifactsClassPathProvider implements ClassPathProvider {
83
public class JaxWsArtifactsClassPathProvider implements ClassPathProvider {
77
    private Project project;
84
    private Project project;
78
    private ClassPath sourceCP, compileCP, bootCP, executeCP;
85
    private ClassPath sourceCP, compileCP, bootCP, executeCP;
Lines 84-90 Link Here
84
    };
91
    };
85
    private static final Logger LOG = Logger.getLogger(JaxWsArtifactsClassPathProvider.class.getName());
92
    private static final Logger LOG = Logger.getLogger(JaxWsArtifactsClassPathProvider.class.getName());
86
    
93
    
87
    JaxWsArtifactsClassPathProvider(Project project) {
94
    public JaxWsArtifactsClassPathProvider(Project project) {
88
        this.project = project;
95
        this.project = project;
89
    }
96
    }
90
    
97
    
(-)a/websvc.core/src/org/netbeans/modules/websvc/core/jaxws/projects/JaxWsSourceForBinaryQueryImpl.java (-1 / +16 lines)
Lines 63-68 Link Here
63
import org.netbeans.api.project.ant.AntArtifact;
63
import org.netbeans.api.project.ant.AntArtifact;
64
import org.netbeans.modules.websvc.api.jaxws.client.JAXWSClientSupport;
64
import org.netbeans.modules.websvc.api.jaxws.client.JAXWSClientSupport;
65
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
65
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
66
import org.netbeans.spi.project.ProjectServiceProvider;
66
import org.netbeans.spi.project.ant.AntArtifactProvider;
67
import org.netbeans.spi.project.ant.AntArtifactProvider;
67
import org.openide.filesystems.FileObject;
68
import org.openide.filesystems.FileObject;
68
import org.openide.filesystems.FileStateInvalidException;
69
import org.openide.filesystems.FileStateInvalidException;
Lines 80-91 Link Here
80
    private boolean hasServiceArtifacts;
81
    private boolean hasServiceArtifacts;
81
    private Set<URI> jarArtifacts = new HashSet<URI>();
82
    private Set<URI> jarArtifacts = new HashSet<URI>();
82
83
84
    @ProjectServiceProvider(service=SourceForBinaryQueryImplementation.class, projectType="org-netbeans-modules-java-j2seproject")
85
    public static SourceForBinaryQueryImplementation forJavaSE(Project project) {
86
        return new JaxWsSourceForBinaryQueryImpl(project, false);
87
    }
88
89
    @ProjectServiceProvider(service=SourceForBinaryQueryImplementation.class, projectType={
90
        "org-netbeans-modules-web-project",
91
        "org-netbeans-modules-j2ee-ejbjarproject",
92
        "org-netbeans-modules-j2ee-clientproject"
93
    })
94
    public static SourceForBinaryQueryImplementation forJavaEE(Project project) {
95
        return new JaxWsSourceForBinaryQueryImpl(project, true);
96
    }
97
83
    /** Constructor.
98
    /** Constructor.
84
     *
99
     *
85
     * @param project Project instance
100
     * @param project Project instance
86
     * @param hasServiceArtifacts true if project can contain services generated from WSDL
101
     * @param hasServiceArtifacts true if project can contain services generated from WSDL
87
     */
102
     */
88
    JaxWsSourceForBinaryQueryImpl(Project project, boolean hasServiceArtifacts) {
103
    private JaxWsSourceForBinaryQueryImpl(Project project, boolean hasServiceArtifacts) {
89
        this.project = project;
104
        this.project = project;
90
        this.hasServiceArtifacts = hasServiceArtifacts;
105
        this.hasServiceArtifacts = hasServiceArtifacts;
91
    }
106
    }
(-)a/websvc.core/src/org/netbeans/modules/websvc/core/jaxws/projects/ProjectWebServiceNotifier.java (+6 lines)
Lines 53-58 Link Here
53
import org.netbeans.modules.websvc.wsstack.api.WSStack;
53
import org.netbeans.modules.websvc.wsstack.api.WSStack;
54
import org.netbeans.modules.websvc.wsstack.jaxws.JaxWs;
54
import org.netbeans.modules.websvc.wsstack.jaxws.JaxWs;
55
import org.netbeans.modules.websvc.wsstack.jaxws.JaxWsStackProvider;
55
import org.netbeans.modules.websvc.wsstack.jaxws.JaxWsStackProvider;
56
import org.netbeans.spi.project.ProjectServiceProvider;
56
import org.netbeans.spi.project.support.ant.AntProjectHelper;
57
import org.netbeans.spi.project.support.ant.AntProjectHelper;
57
import org.netbeans.spi.project.support.ant.EditableProperties;
58
import org.netbeans.spi.project.support.ant.EditableProperties;
58
59
Lines 60-65 Link Here
60
 *
61
 *
61
 * @author mkuchtiak
62
 * @author mkuchtiak
62
 */
63
 */
64
@ProjectServiceProvider(service=WebServiceNotifier.class, projectType={
65
    "org-netbeans-modules-web-project",
66
    "org-netbeans-modules-j2ee-ejbjarproject",
67
    "org-netbeans-modules-j2ee-clientproject"
68
})
63
public class ProjectWebServiceNotifier implements WebServiceNotifier {
69
public class ProjectWebServiceNotifier implements WebServiceNotifier {
64
    private static final String J2EE_SERVER_INSTANCE = "j2ee.server.instance"; //NOI18N
70
    private static final String J2EE_SERVER_INSTANCE = "j2ee.server.instance"; //NOI18N
65
    
71
    
(-)a/websvc.jaxrpc/nbproject/project.xml (-1 / +1 lines)
Lines 190-196 Link Here
190
                    <compile-dependency/>
190
                    <compile-dependency/>
191
                    <run-dependency>
191
                    <run-dependency>
192
                        <release-version>1</release-version>
192
                        <release-version>1</release-version>
193
                        <specification-version>1.12</specification-version>
193
                        <specification-version>1.23</specification-version>
194
                    </run-dependency>
194
                    </run-dependency>
195
                </dependency>
195
                </dependency>
196
                <dependency>
196
                <dependency>
(-)a/websvc.jaxrpc/src/org/netbeans/modules/websvc/jaxrpc/project/JaxRpcArtifactsClassPathProvider.java (-1 / +8 lines)
Lines 57-62 Link Here
57
import org.netbeans.spi.java.classpath.ClassPathProvider;
57
import org.netbeans.spi.java.classpath.ClassPathProvider;
58
import org.netbeans.spi.java.classpath.PathResourceImplementation;
58
import org.netbeans.spi.java.classpath.PathResourceImplementation;
59
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
59
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
60
import org.netbeans.spi.project.ProjectServiceProvider;
60
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileUtil;
62
import org.openide.filesystems.FileUtil;
62
import org.openide.modules.InstalledFileLocator;
63
import org.openide.modules.InstalledFileLocator;
Lines 65-77 Link Here
65
 *
66
 *
66
 * @author mkuchtiak
67
 * @author mkuchtiak
67
 */
68
 */
69
@ProjectServiceProvider(service=ClassPathProvider.class, projectType={
70
    "org-netbeans-modules-java-j2seproject",
71
    "org-netbeans-modules-web-project",
72
    "org-netbeans-modules-j2ee-ejbjarproject",
73
    "org-netbeans-modules-j2ee-clientproject"
74
})
68
public class JaxRpcArtifactsClassPathProvider implements ClassPathProvider {
75
public class JaxRpcArtifactsClassPathProvider implements ClassPathProvider {
69
    private Project project;
76
    private Project project;
70
    private ClassPath sourceCP, compileCP, bootCP, executeCP;
77
    private ClassPath sourceCP, compileCP, bootCP, executeCP;
71
    
78
    
72
    private static final Logger LOG = Logger.getLogger(JaxRpcArtifactsClassPathProvider.class.getName());
79
    private static final Logger LOG = Logger.getLogger(JaxRpcArtifactsClassPathProvider.class.getName());
73
    
80
    
74
    JaxRpcArtifactsClassPathProvider(Project project) {
81
    public JaxRpcArtifactsClassPathProvider(Project project) {
75
        this.project = project;
82
        this.project = project;
76
    }
83
    }
77
    
84
    
(-)a/websvc.jaxrpc/src/org/netbeans/modules/websvc/jaxrpc/project/JaxRpcLookupProvider.java (-66 lines)
Lines 1-66 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
38
 */
39
package org.netbeans.modules.websvc.jaxrpc.project;
40
41
import org.netbeans.api.project.Project;
42
43
import org.netbeans.spi.project.LookupProvider;
44
import org.openide.util.Lookup;
45
import org.openide.util.lookup.Lookups;
46
47
/**
48
 * Lookup Provider provided by JAX-RPC Support for all projects
49
 *
50
 * @author mkuchtiak
51
 */
52
@LookupProvider.Registration(projectType={
53
    "org-netbeans-modules-java-j2seproject",
54
    "org-netbeans-modules-web-project",
55
    "org-netbeans-modules-j2ee-ejbjarproject",
56
    "org-netbeans-modules-j2ee-clientproject"
57
})
58
public class JaxRpcLookupProvider implements LookupProvider {
59
60
    public Lookup createAdditionalLookup(Lookup baseContext) {
61
        final Project prj = baseContext.lookup(Project.class);
62
63
        return Lookups.fixed(new Object[]{new JaxRpcArtifactsClassPathProvider(prj), new JaxRpcSourceForBinaryQuery()});
64
    }
65
66
}
(-)a/websvc.jaxrpc/src/org/netbeans/modules/websvc/jaxrpc/project/JaxRpcSourceForBinaryQuery.java (+7 lines)
Lines 49-54 Link Here
49
import org.netbeans.api.project.Project;
49
import org.netbeans.api.project.Project;
50
import org.netbeans.modules.websvc.api.jaxws.client.JAXWSClientSupport;
50
import org.netbeans.modules.websvc.api.jaxws.client.JAXWSClientSupport;
51
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
51
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
52
import org.netbeans.spi.project.ProjectServiceProvider;
52
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileUtil;
54
import org.openide.filesystems.FileUtil;
54
55
Lines 56-61 Link Here
56
 *
57
 *
57
 * @author mkuchtiak
58
 * @author mkuchtiak
58
 */
59
 */
60
@ProjectServiceProvider(service=SourceForBinaryQueryImplementation.class, projectType={
61
    "org-netbeans-modules-java-j2seproject",
62
    "org-netbeans-modules-web-project",
63
    "org-netbeans-modules-j2ee-ejbjarproject",
64
    "org-netbeans-modules-j2ee-clientproject"
65
})
59
public class JaxRpcSourceForBinaryQuery implements SourceForBinaryQueryImplementation {
66
public class JaxRpcSourceForBinaryQuery implements SourceForBinaryQueryImplementation {
60
67
61
    private final Map<URL, SourceForBinaryQuery.Result> cache = new HashMap<URL, SourceForBinaryQuery.Result>();
68
    private final Map<URL, SourceForBinaryQuery.Result> cache = new HashMap<URL, SourceForBinaryQuery.Result>();
(-)a/websvc.rest/nbproject/project.xml (-1 / +1 lines)
Lines 209-215 Link Here
209
                    <compile-dependency/>
209
                    <compile-dependency/>
210
                    <run-dependency>
210
                    <run-dependency>
211
                        <release-version>1</release-version>
211
                        <release-version>1</release-version>
212
                        <specification-version>1.12</specification-version>
212
                        <specification-version>1.23</specification-version>
213
                    </run-dependency>
213
                    </run-dependency>
214
                </dependency>
214
                </dependency>
215
                <dependency>
215
                <dependency>
(-)a/websvc.rest/src/org/netbeans/modules/websvc/rest/projects/WebProjectRestSupport.java (+2 lines)
Lines 71-76 Link Here
71
import org.netbeans.modules.websvc.wsstack.api.WSTool;
71
import org.netbeans.modules.websvc.wsstack.api.WSTool;
72
import org.netbeans.modules.websvc.wsstack.jaxrs.JaxRs;
72
import org.netbeans.modules.websvc.wsstack.jaxrs.JaxRs;
73
import org.netbeans.modules.websvc.wsstack.jaxrs.JaxRsStackProvider;
73
import org.netbeans.modules.websvc.wsstack.jaxrs.JaxRsStackProvider;
74
import org.netbeans.spi.project.ProjectServiceProvider;
74
import org.netbeans.spi.project.libraries.LibraryFactory;
75
import org.netbeans.spi.project.libraries.LibraryFactory;
75
import org.netbeans.spi.project.libraries.LibraryImplementation;
76
import org.netbeans.spi.project.libraries.LibraryImplementation;
76
import org.netbeans.spi.project.libraries.support.LibrariesSupport;
77
import org.netbeans.spi.project.libraries.support.LibrariesSupport;
Lines 83-88 Link Here
83
 *
84
 *
84
 * @author Nam Nguyen
85
 * @author Nam Nguyen
85
 */
86
 */
87
@ProjectServiceProvider(service=RestSupport.class, projectType="org-netbeans-modules-web-project")
86
public class WebProjectRestSupport extends RestSupport {
88
public class WebProjectRestSupport extends RestSupport {
87
89
88
    public static final String J2EE_SERVER_INSTANCE = "j2ee.server.instance";   //NOI18N
90
    public static final String J2EE_SERVER_INSTANCE = "j2ee.server.instance";   //NOI18N
(-)a/websvc.rest/src/org/netbeans/modules/websvc/rest/projects/WebRestSupportLookupProvider.java (-80 lines)
Lines 1-80 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 * 
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 * 
24
 * Contributor(s):
25
 * 
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 * 
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.modules.websvc.rest.projects;
43
44
import org.netbeans.api.project.Project;
45
import org.netbeans.modules.websvc.rest.spi.RestSupport;
46
import org.netbeans.spi.project.LookupProvider;
47
import org.netbeans.spi.project.ui.PrivilegedTemplates;
48
import org.openide.util.Lookup;
49
import org.openide.util.lookup.Lookups;
50
51
/** Lookup Provider for WS Support
52
 *
53
 * @author mkuchtiak
54
 */
55
@LookupProvider.Registration(projectType="org-netbeans-modules-web-project")
56
public class WebRestSupportLookupProvider implements LookupProvider {
57
    
58
    /** Creates a new instance of JaxWSLookupProvider */
59
    public WebRestSupportLookupProvider() {
60
    }
61
    
62
    public Lookup createAdditionalLookup(Lookup baseContext) {
63
        final Project prj = baseContext.lookup(Project.class);
64
        final RestSupport restSupport = new WebProjectRestSupport(prj);
65
        
66
//        PrivilegedTemplates templates = new PrivilegedTemplates() {
67
//            public String[] getPrivilegedTemplates() {
68
//                return new String[] {
69
//                    "Templates/WebServices/RestServicesFromEntities", // NOI18N
70
//                    "Templates/WebServices/RestServicesFromPatterns"  //NOI18N
71
//                    //"Templates/WebServices/RestClientStubs"    //NOI18N
72
//                };
73
//            }
74
//        };
75
        
76
        //ProjectRestServiceNotifier servicesNotifier = new ProjectRestServiceNotifier(prj);
77
        return Lookups.fixed(new Object[] {restSupport});
78
    }
79
    
80
}
(-)a/xml.jaxb/nbproject/project.xml (-2 / +2 lines)
Lines 149-155 Link Here
149
                    <compile-dependency/>
149
                    <compile-dependency/>
150
                    <run-dependency>
150
                    <run-dependency>
151
                        <release-version>1</release-version>
151
                        <release-version>1</release-version>
152
                        <specification-version>1.9.12</specification-version>
152
                        <specification-version>1.23</specification-version>
153
                    </run-dependency>
153
                    </run-dependency>
154
                </dependency>
154
                </dependency>
155
                <dependency>
155
                <dependency>
Lines 348-354 Link Here
348
                        <code-name-base>org.netbeans.modules.jellytools</code-name-base>
348
                        <code-name-base>org.netbeans.modules.jellytools</code-name-base>
349
                        <compile-dependency/>
349
                        <compile-dependency/>
350
                    </test-dependency>
350
                    </test-dependency>
351
		    <test-dependency>
351
                    <test-dependency>
352
                        <code-name-base>org.netbeans.modules.jellytools.platform</code-name-base>
352
                        <code-name-base>org.netbeans.modules.jellytools.platform</code-name-base>
353
                        <compile-dependency/>
353
                        <compile-dependency/>
354
                    </test-dependency>
354
                    </test-dependency>
(-)a/xml.jaxb/src/org/netbeans/modules/xml/jaxb/model/JAXBGenSourceClassPathProvider.java (-1 / +7 lines)
Lines 34-39 Link Here
34
import org.netbeans.api.project.SourceGroup;
34
import org.netbeans.api.project.SourceGroup;
35
import org.netbeans.api.project.Sources;
35
import org.netbeans.api.project.Sources;
36
import org.netbeans.spi.java.classpath.ClassPathProvider;
36
import org.netbeans.spi.java.classpath.ClassPathProvider;
37
import org.netbeans.spi.project.ProjectServiceProvider;
37
import org.openide.filesystems.FileObject;
38
import org.openide.filesystems.FileObject;
38
import org.openide.filesystems.FileUtil;
39
import org.openide.filesystems.FileUtil;
39
40
Lines 41-46 Link Here
41
 *
42
 *
42
 * @author gpatil
43
 * @author gpatil
43
 */
44
 */
45
@ProjectServiceProvider(service=ClassPathProvider.class, projectType={
46
    "org-netbeans-modules-java-j2seproject",
47
    "org-netbeans-modules-web-project",
48
    "org-netbeans-modules-j2ee-ejbjarproject"
49
})
44
public class JAXBGenSourceClassPathProvider implements ClassPathProvider {
50
public class JAXBGenSourceClassPathProvider implements ClassPathProvider {
45
    private static final String JAXB_GEN_SRC_ROOT = "/generated/addons/jaxb"; //NOI18N
51
    private static final String JAXB_GEN_SRC_ROOT = "/generated/addons/jaxb"; //NOI18N
46
    private static ThreadLocal inAPICall = new ThreadLocal() {
52
    private static ThreadLocal inAPICall = new ThreadLocal() {
Lines 54-60 Link Here
54
    private ClassPath sourceCP, compileCP, bootCP;
60
    private ClassPath sourceCP, compileCP, bootCP;
55
    private String buildDir = "build" ; //NOI18N
61
    private String buildDir = "build" ; //NOI18N
56
    private String jaxbSrcGenDir = buildDir + JAXB_GEN_SRC_ROOT; 
62
    private String jaxbSrcGenDir = buildDir + JAXB_GEN_SRC_ROOT; 
57
    JAXBGenSourceClassPathProvider(Project project) {
63
    public JAXBGenSourceClassPathProvider(Project project) {
58
        this.project = project;
64
        this.project = project;
59
        //TODO get/update buildDir, JAXB_SRC_GEN_DIR
65
        //TODO get/update buildDir, JAXB_SRC_GEN_DIR
60
    }
66
    }
(-)a/xml.jaxb/src/org/netbeans/modules/xml/jaxb/model/JAXBWizLookupProvider.java (-57 lines)
Lines 1-57 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
27
 */
28
package org.netbeans.modules.xml.jaxb.model;
29
30
import org.netbeans.api.project.Project;
31
import org.netbeans.modules.xml.jaxb.api.model.JAXBWizModel;
32
import org.netbeans.spi.project.LookupProvider;
33
import org.netbeans.spi.project.ui.ProjectOpenedHook;
34
import org.openide.util.Lookup;
35
import org.openide.util.lookup.Lookups;
36
37
/**
38
 *
39
 * @author gpatil
40
 */
41
@LookupProvider.Registration(projectType={
42
    "org-netbeans-modules-java-j2seproject",
43
    "org-netbeans-modules-web-project",
44
    "org-netbeans-modules-j2ee-ejbjarproject"
45
})
46
public class JAXBWizLookupProvider implements LookupProvider {
47
48
    public Lookup createAdditionalLookup(Lookup baseContext) {
49
        Project project = baseContext.lookup(Project.class);
50
        JAXBWizModel model = new JAXBWizModelImpl(project);
51
        JAXBGenSourceClassPathProvider cpProvider = 
52
                new JAXBGenSourceClassPathProvider(project);
53
        JAXBWizSourceForBinaryQueryImpl sfbq = new JAXBWizSourceForBinaryQueryImpl();
54
        ProjectOpenedHook poh = new JAXBWizProjectOpenedHookImpl(project);
55
        return Lookups.fixed(new Object[] {model, cpProvider, sfbq, poh});
56
    }
57
}
(-)a/xml.jaxb/src/org/netbeans/modules/xml/jaxb/model/JAXBWizModelImpl.java (+6 lines)
Lines 37-42 Link Here
37
import org.netbeans.modules.xml.jaxb.cfg.schema.Schemas;
37
import org.netbeans.modules.xml.jaxb.cfg.schema.Schemas;
38
import org.netbeans.modules.xml.jaxb.model.events.JAXBWizEventImpl;
38
import org.netbeans.modules.xml.jaxb.model.events.JAXBWizEventImpl;
39
import org.netbeans.modules.xml.jaxb.util.ProjectHelper;
39
import org.netbeans.modules.xml.jaxb.util.ProjectHelper;
40
import org.netbeans.spi.project.ProjectServiceProvider;
40
import org.openide.filesystems.FileChangeAdapter;
41
import org.openide.filesystems.FileChangeAdapter;
41
import org.openide.filesystems.FileEvent;
42
import org.openide.filesystems.FileEvent;
42
import org.openide.filesystems.FileObject;
43
import org.openide.filesystems.FileObject;
Lines 46-51 Link Here
46
 *
47
 *
47
 * @author gpatil
48
 * @author gpatil
48
 */
49
 */
50
@ProjectServiceProvider(service=JAXBWizModel.class, projectType={
51
    "org-netbeans-modules-java-j2seproject",
52
    "org-netbeans-modules-web-project",
53
    "org-netbeans-modules-j2ee-ejbjarproject"
54
})
49
public class JAXBWizModelImpl implements JAXBWizModel {
55
public class JAXBWizModelImpl implements JAXBWizModel {
50
    private List<JAXBWizEventListener> listeners = null;
56
    private List<JAXBWizEventListener> listeners = null;
51
    private Project project;
57
    private Project project;
(-)a/xml.jaxb/src/org/netbeans/modules/xml/jaxb/model/JAXBWizProjectOpenedHookImpl.java (+6 lines)
Lines 44-55 Link Here
44
import org.netbeans.modules.xml.jaxb.cfg.schema.Schemas;
44
import org.netbeans.modules.xml.jaxb.cfg.schema.Schemas;
45
import org.netbeans.modules.xml.jaxb.util.JAXBWizModuleConstants;
45
import org.netbeans.modules.xml.jaxb.util.JAXBWizModuleConstants;
46
import org.netbeans.modules.xml.jaxb.util.ProjectHelper;
46
import org.netbeans.modules.xml.jaxb.util.ProjectHelper;
47
import org.netbeans.spi.project.ProjectServiceProvider;
47
import org.netbeans.spi.project.ui.ProjectOpenedHook;
48
import org.netbeans.spi.project.ui.ProjectOpenedHook;
48
49
49
/**
50
/**
50
 *
51
 *
51
 * @author gpatil
52
 * @author gpatil
52
 */
53
 */
54
@ProjectServiceProvider(service=ProjectOpenedHook.class, projectType={
55
    "org-netbeans-modules-java-j2seproject",
56
    "org-netbeans-modules-web-project",
57
    "org-netbeans-modules-j2ee-ejbjarproject"
58
})
53
public class JAXBWizProjectOpenedHookImpl extends ProjectOpenedHook{
59
public class JAXBWizProjectOpenedHookImpl extends ProjectOpenedHook{
54
    private Project prj;
60
    private Project prj;
55
    
61
    
(-)a/xml.jaxb/src/org/netbeans/modules/xml/jaxb/model/JAXBWizSourceForBinaryQueryImpl.java (+6 lines)
Lines 49-54 Link Here
49
import org.netbeans.modules.xml.jaxb.cfg.schema.Schemas;
49
import org.netbeans.modules.xml.jaxb.cfg.schema.Schemas;
50
import org.netbeans.modules.xml.jaxb.util.ProjectHelper;
50
import org.netbeans.modules.xml.jaxb.util.ProjectHelper;
51
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
51
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
52
import org.netbeans.spi.project.ProjectServiceProvider;
52
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileUtil;
54
import org.openide.filesystems.FileUtil;
54
55
Lines 56-61 Link Here
56
 *
57
 *
57
 * @author gpatil
58
 * @author gpatil
58
 */
59
 */
60
@ProjectServiceProvider(service=SourceForBinaryQueryImplementation.class, projectType={
61
    "org-netbeans-modules-java-j2seproject",
62
    "org-netbeans-modules-web-project",
63
    "org-netbeans-modules-j2ee-ejbjarproject"
64
})
59
public class JAXBWizSourceForBinaryQueryImpl implements SourceForBinaryQueryImplementation {
65
public class JAXBWizSourceForBinaryQueryImpl implements SourceForBinaryQueryImplementation {
60
    private final Map<URL, SourceForBinaryQuery.Result> cache = new HashMap<URL, SourceForBinaryQuery.Result>();
66
    private final Map<URL, SourceForBinaryQuery.Result> cache = new HashMap<URL, SourceForBinaryQuery.Result>();
61
67

Return to bug 150194