Skip to main content
summaryrefslogtreecommitdiffstats
blob: 33f2439eaeaab97567a7328e685fe108d9e8f339 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*******************************************************************************
 * Copyright (c) 2001, 2010 Oracle Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * Contributors:
 *     Oracle Corporation - initial API and implementation
 *******************************************************************************/
/**
 * 
 */
package org.eclipse.jst.jsf.designtime.internal.view.model.jsp.analyzer;

import org.eclipse.core.resources.IProject;
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.eclipse.jst.jsf.core.internal.JSFCorePlugin;
import org.osgi.framework.Bundle;

class ServletBeanProxyContributor extends ConfigurationContributorAdapter
{
    private final JSFVersion _jsfVersion;

    public ServletBeanProxyContributor(final IProject project)
    {
        _jsfVersion = getProjectVersion(project);
        if (_jsfVersion == null)
        {
            throw new IllegalArgumentException("jsfVersion must not be null"); //$NON-NLS-1$
        }
    }

    @Override
    public void contributeClasspaths(
            final IConfigurationContributionController controller)
            throws CoreException
    {
        if (_jsfVersion != null && _jsfVersion.compareTo(JSFVersion.V1_2) < 0)
        {
            final Bundle servletBundle = Platform.getBundle("javax.servlet"); //$NON-NLS-1$
            controller.contributeClasspath(servletBundle, (IPath) null,
                    IConfigurationContributionController.APPEND_USER_CLASSPATH,
                    true);

            final Bundle jspBundle = Platform.getBundle("javax.servlet.jsp"); //$NON-NLS-1$
            controller.contributeClasspath(jspBundle, (IPath) null,
                    IConfigurationContributionController.APPEND_USER_CLASSPATH,
                    true);
        }
        else
        {
            final Bundle coreBundle = JSFCorePlugin.getDefault().getBundle();
            controller.contributeClasspath(coreBundle,
                    "/jars/fake_jsp_21.jar", //$NON-NLS-1$
                    IConfigurationContributionController.APPEND_USER_CLASSPATH,
                    false);
            controller.contributeClasspath(coreBundle,
                    "/jars/fake_el.jar", //$NON-NLS-1$
                    IConfigurationContributionController.APPEND_USER_CLASSPATH,
                    false);
        }
    }

    static JSFVersion getProjectVersion(final IProject project)
    {
        return JSFVersion.valueOfProject(project);
    }

}

Back to the top