Skip to main content
summaryrefslogtreecommitdiffstats
blob: 23947381bc827a4da4f3910d38c4cfe244e499d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
 * 
 */
package org.eclipse.jst.jsf.facelet.core.internal.registry;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jem.internal.proxy.core.ConfigurationContributorAdapter;
import org.eclipse.jem.internal.proxy.core.IConfigurationContributionController;
import org.eclipse.jst.jsf.core.JSFVersion;
import org.osgi.framework.Bundle;

/**
 * Contributes dummy jsp servlet api to smooth the JEM instantiation for introspection.
 * 
 * @author cbateman
 *
 */
public class ServletBeanProxyContributor extends ConfigurationContributorAdapter
{
    private static final String JAVAX_SERVLET_JSP = "javax.servlet.jsp"; //$NON-NLS-1$
    private static final String JAVAX_SERVLET = "javax.servlet"; //$NON-NLS-1$
    private final JSFVersion _jsfVersion;

    /**
     * @param jsfVersion
     */
    public ServletBeanProxyContributor(final JSFVersion jsfVersion)
    {
        if (jsfVersion == null)
        {
            throw new IllegalArgumentException("jsfVersion must not be null"); //$NON-NLS-1$
        }
        
        _jsfVersion = jsfVersion;
    }

    @Override
    public void contributeClasspaths(
            final IConfigurationContributionController controller)
            throws CoreException
    {
        if (_jsfVersion != JSFVersion.V1_2)
        {
            final Bundle servletBundle = Platform.getBundle(JAVAX_SERVLET);
            controller.contributeClasspath(servletBundle, (IPath) null,
                    IConfigurationContributionController.APPEND_USER_CLASSPATH,
                    true);

            final Bundle jspBundle = Platform.getBundle(JAVAX_SERVLET_JSP);
            controller.contributeClasspath(jspBundle, (IPath) null,
                    IConfigurationContributionController.APPEND_USER_CLASSPATH,
                    true);
        }
        
    }
}

Back to the top