Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 333617
Collapse All | Expand All

(-)schema/moduleFactories.exsd (-19 / +18 lines)
Lines 1-6 Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.wst.server.core">
3
<schema targetNamespace="org.eclipse.wst.server.core" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
4
<annotation>
5
      <appInfo>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.wst.server.core" id="moduleFactories" name="Module Factories"/>
6
         <meta.schema plugin="org.eclipse.wst.server.core" id="moduleFactories" name="Module Factories"/>
Lines 10-16 Link Here
10
      </documentation>
10
      </documentation>
11
   </annotation>
11
   </annotation>
12
12
13
  <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
14
13
   <element name="extension">
15
   <element name="extension">
16
      <annotation>
17
         <appInfo>
18
            <meta.element />
19
         </appInfo>
20
      </annotation>
14
      <complexType>
21
      <complexType>
15
         <sequence>
22
         <sequence>
16
            <element ref="moduleFactory" minOccurs="1" maxOccurs="unbounded"/>
23
            <element ref="moduleFactory" minOccurs="1" maxOccurs="unbounded"/>
Lines 105-110 Link Here
105
112
106
   <annotation>
113
   <annotation>
107
      <appInfo>
114
      <appInfo>
115
         <meta.section type="apiInfo"/>
116
      </appInfo>
117
      <documentation>
118
         Value of the attribute &lt;b&gt;class&lt;/b&gt; must be a fully qualified name of a Java class that extends &lt;code&gt;org.eclipse.wst.server.core.model.ModuleFactoryDelegate&lt;/code&gt; and contains a public 0-arg constructor.
119
      </documentation>
120
   </annotation>
121
122
   <annotation>
123
      <appInfo>
108
         <meta.section type="since"/>
124
         <meta.section type="since"/>
109
      </appInfo>
125
      </appInfo>
110
      <documentation>
126
      <documentation>
Lines 135-164 Link Here
135
      </documentation>
151
      </documentation>
136
   </annotation>
152
   </annotation>
137
153
138
   <annotation>
139
      <appInfo>
140
         <meta.section type="apiInfo"/>
141
      </appInfo>
142
      <documentation>
143
         Value of the attribute &lt;b&gt;class&lt;/b&gt; must be a fully qualified name of a Java class that extends &lt;code&gt;org.eclipse.wst.server.core.model.ModuleFactoryDelegate&lt;/code&gt; and contains a public 0-arg constructor.
144
      </documentation>
145
   </annotation>
146
147
   <annotation>
148
      <appInfo>
149
         <meta.section type="implementation"/>
150
      </appInfo>
151
      <documentation>
152
         
153
      </documentation>
154
   </annotation>
155
154
156
   <annotation>
155
   <annotation>
157
      <appInfo>
156
      <appInfo>
158
         <meta.section type="copyright"/>
157
         <meta.section type="copyright"/>
159
      </appInfo>
158
      </appInfo>
160
      <documentation>
159
      <documentation>
161
         Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br&gt;
160
         Copyright (c) 2000, 2011 IBM Corporation and others.&lt;br&gt;
162
All rights reserved. This program and the accompanying materials are made 
161
All rights reserved. This program and the accompanying materials are made 
163
available under the terms of the Eclipse Public License v1.0 which accompanies 
162
available under the terms of the Eclipse Public License v1.0 which accompanies 
164
this distribution, and is available at 
163
this distribution, and is available at 
(-)servercore/org/eclipse/wst/server/core/ServerUtil.java (-6 / +9 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2003, 2010 IBM Corporation and others.
2
 * Copyright (c) 2003, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 91-103 Link Here
91
		List<IModule> list = new ArrayList<IModule>();
91
		List<IModule> list = new ArrayList<IModule>();
92
		
92
		
93
		ModuleFactory[] factories = ServerPlugin.getModuleFactories();
93
		ModuleFactory[] factories = ServerPlugin.getModuleFactories();
94
94
		if (factories != null) {
95
		if (factories != null) {
95
			for (ModuleFactory factory : factories) {
96
			for (ModuleFactory factory : factories) {
96
				IModule[] modules = factory.getModules(project, null);
97
				if (factory.isEnabled(project, null)){
97
				if (modules != null) {
98
					IModule[] modules = factory.getModules(project, null);
98
					for (IModule module : modules) {
99
					if (modules != null) {
99
						if (!list.contains(module))
100
						for (IModule module : modules) {
100
							list.add(module);
101
							if (!list.contains(module))
102
								list.add(module);
103
						}
101
					}
104
					}
102
				}
105
				}
103
			}
106
			}
(-)servercore/org/eclipse/wst/server/core/internal/ModuleFactory.java (-2 / +53 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
2
 * Copyright (c) 2003, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-22 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.List;
14
import java.util.List;
15
15
16
import org.eclipse.core.expressions.*;
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IProgressMonitor;
19
20
import org.eclipse.wst.server.core.IModule;
21
import org.eclipse.wst.server.core.IModule;
21
import org.eclipse.wst.server.core.IModuleType;
22
import org.eclipse.wst.server.core.IModuleType;
22
import org.eclipse.wst.server.core.model.InternalInitializer;
23
import org.eclipse.wst.server.core.model.InternalInitializer;
Lines 28-33 Link Here
28
	private IConfigurationElement element;
29
	private IConfigurationElement element;
29
	public ModuleFactoryDelegate delegate;
30
	public ModuleFactoryDelegate delegate;
30
	private List<IModuleType> moduleTypes;
31
	private List<IModuleType> moduleTypes;
32
	private Expression fContextualLaunchExpr = null;
31
33
32
	/**
34
	/**
33
	 * ModuleFactory constructor comment.
35
	 * ModuleFactory constructor comment.
Lines 137-142 Link Here
137
			return new IModule[0];
139
			return new IModule[0];
138
		}
140
		}
139
	}
141
	}
142
	
143
	/**
144
	 * Returns an expression that represents the enablement logic for the
145
	 * contextual project of this module factory <code>null</code> if none.
146
	 * @return an evaluatable expression or <code>null</code>
147
	 * @throws CoreException if the configuration element can't be
148
	 *  converted. Reasons include: (a) no handler is available to
149
	 *  cope with a certain configuration element or (b) the XML
150
	 *  expression tree is malformed.
151
	 */
152
	protected Expression getContextualLaunchEnablementExpression() throws CoreException {
153
		if (fContextualLaunchExpr == null) {
154
			IConfigurationElement[] elements = element.getChildren(ExpressionTagNames.ENABLEMENT);
155
			IConfigurationElement enablement = (elements != null && elements.length > 0) ? elements[0] : null; 
156
157
			if (enablement != null)
158
				fContextualLaunchExpr = ExpressionConverter.getDefault().perform(enablement);
159
		}
160
		return fContextualLaunchExpr;
161
	}
162
	
163
	/**
164
	 * Evaluate the given expression within the given context and return
165
	 * the result. Returns <code>true</code> if result is either TRUE or NOT_LOADED.
166
	 * This allows optimistic inclusion before plugins are loaded.
167
	 * Returns <code>true</code> if exp is <code>null</code>.
168
	 * 
169
	 * @param exp the enablement expression to evaluate or <code>null</code>
170
	 * @param context the context of the evaluation. 
171
	 * @return the result of evaluating the expression
172
	 * @throws CoreException
173
	 */
174
	protected boolean evalEnablementExpression(IEvaluationContext context, Expression exp) throws CoreException {
175
		// for compatibility with the current behaviour, if the exp == null we return true. Meaning that the factory doesn't
176
		// implement an expression and should be enabled for all cases.
177
		return (exp != null) ? ((exp.evaluate(context)) != EvaluationResult.FALSE) : true;
178
	}
179
	
180
	public boolean isEnabled(IProject project, IProgressMonitor monitor) {
181
		try {
182
			IEvaluationContext context = new EvaluationContext(null, project);
183
			context.addVariable("project", project);
184
			
185
			return evalEnablementExpression(context, getContextualLaunchEnablementExpression());
186
		} catch (Throwable t) {
187
			Trace.trace(Trace.SEVERE, "Error calling delegate " + toString(), t);
188
			return false;
189
		}
190
	}
140
191
141
	/*
192
	/*
142
	 * @see ModuleFactoryDelegate#findModule(String)
193
	 * @see ModuleFactoryDelegate#findModule(String)

Return to bug 333617