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 320926
Collapse All | Expand All

(-)src/org/eclipse/rwt/internal/ConfigurationReader.java (-252 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 7-296 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
package org.eclipse.rwt.internal;
12
package org.eclipse.rwt.internal;
12
13
13
import java.io.*;
14
import java.net.URL;
15
import java.net.URLConnection;
16
import java.util.HashMap;
14
import java.util.HashMap;
17
import java.util.Map;
15
import java.util.Map;
18
16
19
import javax.xml.parsers.*;
17
import javax.xml.parsers.FactoryConfigurationError;
20
18
21
import org.w3c.dom.*;
22
import org.xml.sax.*;
23
19
24
20
/**
25
/** 
21
 * This is a helping class that reads configuration values from system
26
 * This is a helping class for the W4TApplication to read
22
 * properties.
27
 * the initialisations, which are stored in w4t.xml in the conf/
28
 * directory of the web applications root.
29
 */
23
 */
30
public class ConfigurationReader {
24
public class ConfigurationReader {
31
32
  private static final String W4_TOOLKIT_SCHEMA = "w4t.xsd";
33
  private static final String JAXP_SCHEMA_LANGUAGE
34
    = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
35
  private static final String W3C_XML_SCHEMA
36
    = "http://www.w3.org/2001/XMLSchema";
37
38
  
25
  
39
  private static Document document = null;
40
  private static IConfiguration configuration = null;
26
  private static IConfiguration configuration = null;
41
  private static final Map values = new HashMap();
27
  private static final Map values = new HashMap();
42
  private static File configurationFile = null;
43
  private static IEngineConfig engineConfig = null;
28
  private static IEngineConfig engineConfig = null;
44
    
29
    
45
  private static final class ConfigurationImpl implements IConfiguration {
30
  private static final class ConfigurationImpl implements IConfiguration {
46
31
47
    private IInitialization initialization = null;
48
    private IFileUpload fileUpload = null;
49
    
50
    public IInitialization getInitialization() {
51
      if( initialization == null ) {
52
        initialization = new InitializationImpl();
53
      }
54
      return initialization;
55
    }
56
57
    public IFileUpload getFileUpload() {
58
      if( fileUpload == null ) {
59
        fileUpload = new FileUploadImpl();
60
      }
61
      return fileUpload;
62
    }
63
  }
64
  
65
  private static final class InitializationImpl implements IInitialization {
66
67
    public String getStartUpForm() {
68
      // do not use Startup.class.getName() since in name space mode
69
      // that class must be loaded in session scope
70
      return getConfigValue( "startUpForm", "com.w4t.administration.Startup" );
71
    }
72
    
73
    public String getLifeCycle() {
32
    public String getLifeCycle() {
74
      String defaultValue = IInitialization.LIFE_CYCLE_DEFAULT;
33
      String defaultValue = IConfiguration.LIFE_CYCLE_DEFAULT;
75
      return getConfigValue( IInitialization.PARAM_LIFE_CYCLE, defaultValue );
34
      return getConfigValue( IConfiguration.PARAM_LIFE_CYCLE, defaultValue );
76
    }
77
78
    public String getErrorPage() {
79
      // do not use DefaultErrorForm.class.getName() since in name space mode
80
      // that class must be loaded in session scope
81
      String defaultValue = "com.w4t.administration.DefaultErrorForm";
82
      return getConfigValue( "errorPage", defaultValue );
83
    }
84
85
    public String getAdministrationStartupForm() {
86
      // do not use Startup.class.getName() since in name space mode
87
      // that class must be loaded in session scope
88
      String defaultValue = "com.w4t.administration.Startup";
89
      return getConfigValue( "administrationStartupForm", defaultValue );
90
    }
35
    }
91
36
    
92
    public String getMessagePage() {
93
      // do not use DefaultMessageForm.class.getName() since in name space mode
94
      // that class must be loaded in session scope
95
      String defaultValue = "com.w4t.administration.DefaultMessageForm";
96
      return getConfigValue( "messagePage", defaultValue );
97
    }
98
99
    public String getWorkDirectory() {
100
      return getConfigValue( "workDirectory", "WEB-INF/classes/" );
101
    }
102
103
    public long getClosingTimeout() {
104
      String value = getConfigValue( "closingTimeout", "3600000" );
105
      long result = Long.parseLong( value );
106
      return ( result < 60000 ) ? 60000 : result;
107
    }
108
109
    public long getSkimmerFrequenzy() {
110
      String value = getConfigValue( "skimmerFrequency", "60000" );
111
      return Long.parseLong( value );
112
    }
113
114
    public boolean isDirectMonitoringAccess() {
115
      String value = getConfigValue( "directMonitoringAccess", "true" );
116
      return Boolean.valueOf( value ).booleanValue();
117
    }
118
119
    public boolean isCompression() {
37
    public boolean isCompression() {
120
      String value = getConfigValue( "org.eclipse.rwt.compression", "false" );
38
      String value = getConfigValue( IConfiguration.PARAM_COMPRESSION,
39
      "false" );
121
      return Boolean.valueOf( value ).booleanValue();
40
      return Boolean.valueOf( value ).booleanValue();
122
    }
41
    }
123
42
    
124
    public boolean isProcessTime() {
125
      String value = getConfigValue( "processTime", "false" );
126
      return Boolean.valueOf( value ).booleanValue();
127
    }
128
129
    public String getNoscriptSubmitters() {
130
      String defaultValue = IInitialization.NOSCRIPT_SUBMITTERS_CREATE;
131
      return getConfigValue( "noscriptSubmitters", defaultValue );
132
    }
133
134
    public String getResources() {
43
    public String getResources() {
135
      String defaultValue = IInitialization.RESOURCES_DELIVER_FROM_DISK;
44
      String defaultValue = IConfiguration.RESOURCES_DELIVER_FROM_DISK;
136
      return getConfigValue( "resources", defaultValue );
45
      return getConfigValue( "resources", defaultValue );
137
    }
46
    }
138
139
    public long getMaxSessionUnboundToForceGC() {
140
      String tagName = "maxSessionUnboundToForceGC";
141
      String value = getConfigValue( tagName, "0" );
142
      return Long.parseLong( value );
143
    }
144
145
    public String getHandleMissingI18NResource() {
146
      String defaultValue = IInitialization.HANDLE_MISSING_I18N_RESOURCE_EMPTY;
147
      return getConfigValue( "handleMissingI18NResource", defaultValue );
148
    }
149
  }
47
  }
150
48
151
  private static final class FileUploadImpl implements IFileUpload {
152
153
    public long getMaxUploadSize() {
154
      String value = getConfigValue( "maxUploadSize", "4194304" );
155
      return Long.parseLong( value );
156
    }
157
158
    public int getMaxMemorySize() {
159
      String value = getConfigValue( "maxMemorySize", "524288" );
160
      return Integer.parseInt( value );
161
    }
162
  }
163
  
164
  public static IConfiguration getConfiguration() {
49
  public static IConfiguration getConfiguration() {
165
    if( configuration == null ) {
50
    if( configuration == null ) {
166
      configuration = new ConfigurationImpl();
51
      configuration = new ConfigurationImpl();
167
    }
52
    }
168
    return configuration;
53
    return configuration;
169
  }
54
  }
170
  
171
  public static void setConfigurationFile( final File configurationFile )
172
    throws FactoryConfigurationError, 
173
           ParserConfigurationException, 
174
           SAXException, 
175
           IOException
176
  {
177
    reset();
178
    if( configurationFile != null ) {
179
      if( !configurationFile.exists() ) {
180
        String msg =   "Parameter 'configurationFile ["
181
                     + configurationFile.toString()
182
                     + "]' does not exist.";
183
        throw new IllegalArgumentException( msg );
184
      }
185
      if( configurationFile.isDirectory() ) {
186
        String msg = "Parameter 'configurationFile' must not be a directory.";
187
        throw new IllegalArgumentException( msg );
188
      }
189
      ConfigurationReader.configurationFile  = configurationFile;
190
    }
191
    if( configurationFile != null ) {
192
      parseConfiguration();
193
    }
194
  }
195
55
196
  public static IEngineConfig getEngineConfig() {
56
  public static IEngineConfig getEngineConfig() {
197
    return engineConfig;
57
    return engineConfig;
198
  }
58
  }
199
  
59
200
  public static void setEngineConfig( final IEngineConfig engineConfig )
60
  public static void setEngineConfig( final IEngineConfig engineConfig )
201
    throws FactoryConfigurationError,
61
    throws FactoryConfigurationError
202
           ParserConfigurationException,
203
           SAXException,
204
           IOException
205
  {
62
  {
206
    ConfigurationReader.engineConfig = engineConfig;
63
    ConfigurationReader.engineConfig = engineConfig;
207
    setConfigurationFile( engineConfig.getConfigFile() );
208
  }
64
  }
209
  
210
  
211
  //////////////////
212
  // helping methods
213
65
214
  private static void reset() {
66
  public static void reset() {
215
    values.clear();
67
    values.clear();
216
    document = null;
217
    configuration = null;
68
    configuration = null;
218
    configurationFile = null;
219
  }
69
  }
220
  
70
221
  private static void parseConfiguration()
71
  //////////////////
222
    throws FactoryConfigurationError,
72
  // helping methods
223
           ParserConfigurationException, 
73
224
           SAXException, 
225
           IOException 
226
  {
227
    if( configurationFile != null ) {
228
      InputStream is = new FileInputStream( configurationFile );
229
      try {
230
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
231
        factory.setNamespaceAware( true );
232
        ClassLoader loader = ConfigurationReader.class.getClassLoader();
233
        final URL schema = loader.getResource( W4_TOOLKIT_SCHEMA );
234
        factory.setValidating( schema != null );
235
        try {
236
          factory.setAttribute( JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA );
237
        } catch( final IllegalArgumentException iae ) {
238
          // XML-Processing does not support JAXP 1.2 or greater
239
          factory.setNamespaceAware( false );
240
          factory.setValidating( false );
241
        }
242
        DocumentBuilder builder = factory.newDocumentBuilder();
243
        builder.setEntityResolver( new EntityResolver() {
244
          public InputSource resolveEntity( final String publicID, 
245
                                            final String systemID )
246
            throws IOException, SAXException
247
          {
248
            InputSource result = null;
249
            if( schema != null && systemID.endsWith( W4_TOOLKIT_SCHEMA ) ) {
250
              URLConnection connection = schema.openConnection();
251
              connection.setUseCaches( false );
252
              result = new InputSource( connection.getInputStream() );
253
            }
254
            return result;
255
          }
256
        } );
257
        
258
        // TODO: more sophisticated ErrorHandler implementation...
259
        builder.setErrorHandler( new ErrorHandler() {
260
          
261
          public void error( final SAXParseException spe )
262
            throws SAXException
263
          {
264
            System.out.println( "Error parsing W4 Toolkit configuration:" );
265
            System.out.println( configurationFile.toString() );
266
            System.out.println( spe.getMessage() );
267
          }
268
          
269
          public void fatalError( final SAXParseException spe )
270
            throws SAXException
271
          {
272
            String msg = "Fatal error parsing W4 Toolkit configuration:";
273
            System.out.println( msg );
274
            System.out.println( configurationFile.toString() );
275
            System.out.println( spe.getMessage() );
276
          }
277
          
278
          public void warning( final SAXParseException spe )
279
            throws SAXException
280
          {
281
            System.out.println( "Warning parsing W4 Toolkit configuration:" );
282
            System.out.println( configurationFile.toString() );
283
            System.out.println( spe.getMessage() );
284
          } 
285
          
286
        } );
287
        document = builder.parse( is );
288
      } finally {
289
        is.close();
290
      }
291
    }
292
  }
293
  
294
  private static String getConfigValue( final String tagName,
74
  private static String getConfigValue( final String tagName,
295
                                        final String defaultValue )
75
                                        final String defaultValue )
296
  {
76
  {
Lines 298-315 Link Here
298
      String result = "";
78
      String result = "";
299
      if( System.getProperty( tagName ) != null ) {
79
      if( System.getProperty( tagName ) != null ) {
300
        result = System.getProperty( tagName );
80
        result = System.getProperty( tagName );
301
      } else if( document != null ) {
302
        NodeList nodeList = document.getElementsByTagName( tagName );
303
        Node item = nodeList.item( 0 );
304
        if( item != null ) {
305
          Node firstChild = item.getFirstChild();
306
          if( firstChild != null ) {
307
            String nodeValue = firstChild.getNodeValue();
308
            result = nodeValue.trim();
309
          }
310
        } else {
311
          result = defaultValue;
312
        }
313
      } else {
81
      } else {
314
        result = defaultValue;
82
        result = defaultValue;
315
      }
83
      }
(-)src/org/eclipse/rwt/internal/EngineConfig.java (-9 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
package org.eclipse.rwt.internal;
12
package org.eclipse.rwt.internal;
12
13
Lines 37-50 Link Here
37
38
38
  // interface methods
39
  // interface methods
39
  ////////////////////
40
  ////////////////////
40
  
41
  public File getConfigFile() {
42
    File result = new File(   getServerContextDir().toString() 
43
                            + CONF 
44
                            + File.separator
45
                            + "W4T.xml" );
46
    return result;
47
  }
48
41
49
  public File getLibDir() {
42
  public File getLibDir() {
50
    File result = new File(   getServerContextDir().toString() 
43
    File result = new File(   getServerContextDir().toString() 
(-)src/org/eclipse/rwt/internal/IConfiguration.java (-3 / +35 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 7-15 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
package org.eclipse.rwt.internal;
12
package org.eclipse.rwt.internal;
12
13
14
import org.eclipse.rwt.internal.lifecycle.RWTLifeCycle;
15
13
/** 
16
/** 
14
 * <p>This interface provides access to the W4 Toolkit configuration
17
 * <p>This interface provides access to the W4 Toolkit configuration
15
 * settings.</p>
18
 * settings.</p>
Lines 17-23 Link Here
17
 */
20
 */
18
public interface IConfiguration {
21
public interface IConfiguration {
19
22
20
  IInitialization getInitialization();
23
  public static final String PARAM_LIFE_CYCLE = "lifecycle";
24
  public static final String PARAM_COMPRESSION = "org.eclipse.rwt.compression";
25
26
  public static final String LIFE_CYCLE_DEFAULT = RWTLifeCycle.class.getName();
27
28
  public static final String RESOURCES_DELIVER_FROM_DISK = "deliverFromDisk";
29
  public static final String RESOURCES_DELIVER_BY_SERVLET = "deliverByServlet";
30
31
  /**
32
   * specifies the implementation class that manages the lifecycle of each
33
   * request.
34
   */
35
  String getLifeCycle();
36
37
  /** 
38
   * <p>Returns whether the HTML output of the web appliction is sent
39
   * gzipped to browsers that support gzipped network communication
40
   * (Should be 'true' for productive versions to save network traffic 
41
   * and shorten loading time).</p>
42
   */
43
  boolean isCompression();
21
44
22
  IFileUpload getFileUpload();
45
  /**
46
   * <p>Returns whether static resources like JavaScript-libraries, images,
47
   * css-files etc. which are available on the applications
48
   * classpath are copied to disk and delivered as static files by
49
   * a web-server or delivered directly by the servlet engine.
50
   * Should be <code>RESOURCES_DELIVER_FROM_DISK</code> in most cases. 
51
   * Can be <code>RESOURCES_DELIVER_FROM_DISK</code> or 
52
   * <code>RESOURCES_DELIVER_BY_SERVLET</code>.
53
   */
54
  String getResources();
23
}
55
}
(-)src/org/eclipse/rwt/internal/IEngineConfig.java (-10 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
package org.eclipse.rwt.internal;
12
package org.eclipse.rwt.internal;
12
13
Lines 17-31 Link Here
17
 * usable for configuration of the W4T engine adapter.
18
 * usable for configuration of the W4T engine adapter.
18
 */
19
 */
19
public interface IEngineConfig {
20
public interface IEngineConfig {
20
  
21
  /**
22
   * This returns a file object that represent a W4T.xml config file
23
   * containing the configuration for the W4T engine. The file object
24
   * returned might differ for different engine adapters in the same VM.
25
   * 
26
   * @return A file object corresponding to a W4T config file.
27
   */
28
  public File getConfigFile();
29
21
30
  /**
22
  /**
31
   * This returns a file object representing a global lib directory
23
   * This returns a file object representing a global lib directory
(-)src/org/eclipse/rwt/internal/IInitialization.java (-187 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal;
12
13
/** 
14
 * <p>This interface provides the common W4Toolkit application parameter 
15
 * settings.</p>
16
 * <p>This interface is not intended to be implemented by clients.</p>
17
 * @see org.eclipse.rwt.internal.IConfiguration 
18
 */
19
public interface IInitialization {
20
21
  public static final String PARAM_LIFE_CYCLE = "lifecycle";
22
23
  public static final String LIFE_CYCLE_DEFAULT
24
    = "com.w4t.engine.lifecycle.standard.LifeCycle_Standard";
25
  
26
  public final static String NOSCRIPT_SUBMITTERS_NONE = "None";
27
  public final static String NOSCRIPT_SUBMITTERS_CREATE = "Create";
28
  public final static String NOSCRIPT_SUBMITTERS_USE = "Use";
29
  
30
  public static final String RESOURCES_DELIVER_FROM_DISK = "deliverFromDisk";
31
  public static final String RESOURCES_DELIVER_BY_SERVLET = "deliverByServlet";
32
33
  public static final String HANDLE_MISSING_I18N_RESOURCE_EMPTY = "Empty";
34
  public static final String HANDLE_MISSING_I18N_RESOURCE_FAIL = "Fail";
35
  public static final String HANDLE_MISSING_I18N_RESOURCE_EXPLICIT = "Explicit";
36
37
38
  /**
39
   * <p>Returns the fully qualified class name of the WebForm that will be 
40
   * displayed when the web application starts.</p> 
41
   */
42
  String getStartUpForm();
43
44
  /**
45
   * specifies the implementation class that manages the lifecycle of each
46
   * request.
47
   */
48
  String getLifeCycle();
49
  
50
  /**
51
   * <p>Returns the fully qualified class name of a WebForm that
52
   * displays Exceptions that broke the control flow within
53
   * the web application. If user-defined, this must be a subclass of
54
   * <code>WebForm</code> and must implement the 
55
   * <code>WebErrorForm</code> interface.</p>
56
   * @see org.eclipse.rwt.WebForm
57
   * @see org.eclipse.rwt.WebErrorForm
58
   */
59
  String getErrorPage();
60
61
  /**
62
   * <p>Returns the fully qualified class name of a WebForm that is used as
63
   * the entry point for an web-application providing administration
64
   * information about the main application.</p>
65
   */
66
  String getAdministrationStartupForm();
67
68
  /**
69
   * <p>Returns the fully qualified class name of a WebForm that
70
   * displays messages that were created within the web application.
71
   * If user-defined, this must be a subclass of
72
   * <code>WebForm</code> and must implement the
73
   * <code>MessageForm</code> interface.</p>
74
   * @see org.eclipse.rwt.WebForm
75
   * @see org.eclipse.rwt.MessageForm
76
   */
77
  String getMessagePage();
78
79
  /**
80
   * <p>Returns the path to a writeable directory, used for temporary files.</p>
81
   */
82
  String getWorkDirectory();
83
84
  /**
85
   * <p>Returns the maximum time till the closing of a WebForm on the
86
   * client is recognized at server side. Time interval, in ms.</p>
87
   */
88
  long getClosingTimeout();
89
90
  /**
91
   * <p>Returns the time interval between scans for closed WebForm at
92
   * the server side. This value should not be greater than
93
   * half of the closingTimeout value. Time interval, in ms.</p>
94
   */
95
  long getSkimmerFrequenzy();
96
  
97
  /**
98
   * <p>Returns whether the W4Toolkit administration pages are accessible
99
   * via the admin.html page (Shoud be 'false' for productive versions).</p>
100
   */
101
  boolean isDirectMonitoringAccess();
102
103
  /** 
104
   * <p>Returns whether the HTML output of the web appliction is sent
105
   * gzipped to browsers that support gzipped network communication
106
   * (Should be 'true' for productive versions to save network traffic 
107
   * and shorten loading time).</p>
108
   */
109
  boolean isCompression();
110
111
  /** 
112
   * <p>Returns whether the server-side processing time of the HTML
113
   * page is displayed (on the bottom of the page). This 
114
   * may be useful for application tuning (Should be 'false'
115
   * for productive versions).</p>
116
   */
117
  boolean isProcessTime();
118
119
  /**
120
   * <p>Returns whether special submitter images are used for browsers 
121
   * that have JavaScript disabled. Possible values are:
122
   * <ul>
123
   * <li><code>NOSCRIPT_SUBMITTERS_NONE<code><br>
124
   * If set to <code>NOSCRIPT_SUBMITTERS_NONE<code>, a standard submitter image 
125
   * is rendered in addition to the labels on link 
126
   * buttons, tree nodes etc.;</li>
127
   * <li><code>NOSCRIPT_SUBMITTERS_CREATE<code><br>
128
   * If set to <code>NOSCRIPT_SUBMITTERS_CREATE<code>, a special image is 
129
   * created automatically with the appropriate text and colors.
130
   * Images created only once and buffered on harddisk
131
   * in the webapplications image directory.
132
   * Setting this to 'create' requires an available X 
133
   * server on Unixes, however.</li>
134
   * <li><code>NOSCRIPT_SUBMITTERS_USE<code><br>
135
   * If set to <code>NOSCRIPT_SUBMITTERS_USE<code> earlier generated images 
136
   * are used but no new images are generated. If no image is
137
   * available from disk, a standard submitter image
138
   * is rendered in addition to the labels on link
139
   * buttons, tree nodes etc.;</li></ul></p>
140
   */
141
  String getNoscriptSubmitters();
142
143
  /**
144
   * <p>Returns whether static resources like JavaScript-libraries, images,
145
   * css-files etc. which are available on the applications
146
   * classpath are copied to disk and delivered as static files by
147
   * a web-server or delivered directly by the servlet engine.
148
   * Should be <code>RESOURCES_DELIVER_FROM_DISK</code> in most cases. 
149
   * Can be <code>RESOURCES_DELIVER_FROM_DISK</code> or 
150
   * <code>RESOURCES_DELIVER_BY_SERVLET</code>.
151
   */
152
  String getResources();
153
154
  /**
155
   * <p>This is a special option for certain environments, where
156
   * the gc algorithm comes too late to unload classes.
157
   * If set to a number > 0, this will enforce a gc after the
158
   * specified number of sessions has been invalidated.</p>
159
   */
160
  long getMaxSessionUnboundToForceGC();
161
162
  /**
163
   * <p>W4 Toolkit supports i18n by accepting values like 
164
   * 'property://someKey@some.package.SomePropertiesFile'
165
   * which are resolved on rendering, so that the specified
166
   * property is displayed in the HTML output that the user sees.</p>
167
   * 
168
   * <p>This attribute specifies the behaviour of the resolver
169
   * when the specifed resource could not be found as expected.
170
   * (For development, it may be convenient to set this to
171
   * <code>HANDLE_MISSING_I18N_RESOURCE_EMPTY</code>, whereas 
172
   * probably in productive environments the most sensible setting 
173
   * would be <code>HANDLE_MISSING_I18N_RESOURCE_EMPTY</code> here.)</p>
174
   * 
175
   * <p>Possible values are:
176
   * <ul>
177
   * <li><code>HANDLE_MISSING_I18N_RESOURCE_FAIL</code><br>
178
   * behaves like a failed assertion, that is a runtime exception is fired.</li>
179
   * <li><code>HANDLE_MISSING_I18N_RESOURCE_EMPTY</code><br>
180
   * does nothing and renders an empty String into the component's output.</li>
181
   * <li><code>HANDLE_MISSING_I18N_RESOURCE_EXPLICIT</code><br>
182
   * does nothing and renders the property URI literally into the 
183
   * component's output.</li></ul>
184
   * </p>
185
   */
186
  String getHandleMissingI18NResource();
187
}
(-)src/org/eclipse/rwt/internal/engine/RWTDelegate.java (-3 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
package org.eclipse.rwt.internal.engine;
12
package org.eclipse.rwt.internal.engine;
12
13
Lines 72-78 Link Here
72
  
73
  
73
  /////////////////////////////////////////
74
  /////////////////////////////////////////
74
  // Methods to be overridden by subclasses
75
  // Methods to be overridden by subclasses
75
  
76
76
  protected HttpServletRequest getWrappedRequest( final HttpServletRequest req )
77
  protected HttpServletRequest getWrappedRequest( final HttpServletRequest req )
77
    throws ServletException
78
    throws ServletException
78
  {
79
  {
Lines 95-101 Link Here
95
  
96
  
96
  private void createResourceManagerInstance() {
97
  private void createResourceManagerInstance() {
97
    IConfiguration configuration = ConfigurationReader.getConfiguration();
98
    IConfiguration configuration = ConfigurationReader.getConfiguration();
98
    String resources = configuration.getInitialization().getResources();
99
    String resources = configuration.getResources();
99
    ResourceManagerImpl.createInstance( getWebAppBase().toString(), resources );
100
    ResourceManagerImpl.createInstance( getWebAppBase().toString(), resources );
100
  }
101
  }
101
102
(-)src/org/eclipse/rwt/internal/lifecycle/LifeCycle.java (-11 / +8 lines)
Lines 18-40 Link Here
18
import org.eclipse.rwt.lifecycle.PhaseListener;
18
import org.eclipse.rwt.lifecycle.PhaseListener;
19
19
20
20
21
/** <p>The superclass for all implementations of the lifecycle of a request.</p>
21
/**
22
  *
22
 * The superclass for all implementations of the lifecycle of a request.
23
  * <p>Implementations can be provided for different compatibility modes. 
23
 */
24
  * LifeCycles are loaded depending on compatibility mode in the 
25
  * W4TModelCore using the org.eclipse.rap.engine.lifecycle.LifeCycleFactory.</p>
26
  */
27
public abstract class LifeCycle implements ILifeCycle {
24
public abstract class LifeCycle implements ILifeCycle {
28
  
25
29
  /** 
26
  /**
30
   * <p>Executes the lifecycle defined in this LifeCycle. Implementing 
27
   * Executes the lifecycle defined in this LifeCycle. Implementing subclasses
31
   * subclasses use this as entry point to the processing of their phases.</p> 
28
   * use this as entry point to the processing of their phases.
32
   */
29
   */
33
  public abstract void execute() throws ServletException, IOException;
30
  public abstract void execute() throws ServletException, IOException;
34
31
35
  public abstract void addPhaseListener( PhaseListener listener );
32
  public abstract void addPhaseListener( PhaseListener listener );
36
33
37
  public abstract void removePhaseListener( PhaseListener listener );
34
  public abstract void removePhaseListener( PhaseListener listener );
38
  
35
39
  public abstract Scope getScope();
36
  public abstract Scope getScope();
40
}
37
}
(-)src/org/eclipse/rwt/internal/lifecycle/LifeCycleFactory.java (-7 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
package org.eclipse.rwt.internal.lifecycle;
12
package org.eclipse.rwt.internal.lifecycle;
12
13
Lines 52-69 Link Here
52
      String lifeCycleClassName = null;
53
      String lifeCycleClassName = null;
53
      try {
54
      try {
54
        IConfiguration configuration = ConfigurationReader.getConfiguration();
55
        IConfiguration configuration = ConfigurationReader.getConfiguration();
55
        IInitialization initialization = configuration.getInitialization();
56
        lifeCycleClassName = configuration.getLifeCycle();
56
        lifeCycleClassName = initialization.getLifeCycle();
57
        Class lifeCycleClass = Class.forName( lifeCycleClassName );
57
        Class lifeCycleClass = Class.forName( lifeCycleClassName );
58
        result = ( LifeCycle )lifeCycleClass.newInstance();
58
        result = ( LifeCycle )lifeCycleClass.newInstance();
59
        if( result.getScope().equals( Scope.APPLICATION ) ) {
59
        if( result.getScope().equals( Scope.APPLICATION ) ) {
60
          globalLifeCycle = result;
60
          globalLifeCycle = result;
61
        }
61
        }
62
      } catch( Exception ex ) {
62
      } catch( Exception ex ) {
63
        // TODO [w4t] revise: throw exception instead of issuing a warning and
64
        //      returning the w4t standard life cycle
65
//        System.out.println( "Could not load lifecycle. " + ex.toString() );
66
//        result = new org.eclipse.rap.engine.lifecycle.standard.LifeCycle_Standard();
67
        String text = "Could not load life cycle implementation {0}: {1}";
63
        String text = "Could not load life cycle implementation {0}: {1}";
68
        Object[] args = new Object[] { lifeCycleClassName, ex.toString() };
64
        Object[] args = new Object[] { lifeCycleClassName, ex.toString() };
69
        String msg = MessageFormat.format( text, args );
65
        String msg = MessageFormat.format( text, args );
(-)src/org/eclipse/rwt/internal/service/AbstractServiceHandler.java (-4 / +3 lines)
Lines 36-42 Link Here
36
  static PrintWriter getOutputWriter() throws IOException {
36
  static PrintWriter getOutputWriter() throws IOException {
37
    OutputStreamWriter utf8Writer;
37
    OutputStreamWriter utf8Writer;
38
    OutputStream out = getResponse().getOutputStream();
38
    OutputStream out = getResponse().getOutputStream();
39
    if( isAcceptEncoding() && getInitProps().isCompression() ) {
39
    if( isAcceptEncoding() && getConfiguration().isCompression() ) {
40
      GZIPOutputStream zipStream = new GZIPOutputStream( out );
40
      GZIPOutputStream zipStream = new GZIPOutputStream( out );
41
      utf8Writer = new OutputStreamWriter( zipStream, HTML.CHARSET_NAME_UTF_8 );
41
      utf8Writer = new OutputStreamWriter( zipStream, HTML.CHARSET_NAME_UTF_8 );
42
      getResponse().setHeader( CONTENT_ENCODING, ENCODING_GZIP );
42
      getResponse().setHeader( CONTENT_ENCODING, ENCODING_GZIP );
Lines 46-54 Link Here
46
    return new PrintWriter( utf8Writer, false );
46
    return new PrintWriter( utf8Writer, false );
47
  }
47
  }
48
48
49
  static IInitialization getInitProps() {
49
  static IConfiguration getConfiguration() {
50
    IConfiguration configuration = ConfigurationReader.getConfiguration();
50
    return ConfigurationReader.getConfiguration();
51
    return configuration.getInitialization();
52
  }
51
  }
53
52
54
  protected static HttpServletRequest getRequest() {
53
  protected static HttpServletRequest getRequest() {
(-)src/org/eclipse/rwt/internal/service/JSLibraryServiceHandler.java (-4 / +3 lines)
Lines 72-78 Link Here
72
    response.setHeader( HTML.CONTENT_TYPE, HTML.CONTENT_TEXT_JAVASCRIPT );
72
    response.setHeader( HTML.CONTENT_TYPE, HTML.CONTENT_TEXT_JAVASCRIPT );
73
    response.setHeader( EXPIRES, EXPIRES_NEVER );
73
    response.setHeader( EXPIRES, EXPIRES_NEVER );
74
    response.setCharacterEncoding( HTML.CHARSET_NAME_UTF_8 );
74
    response.setCharacterEncoding( HTML.CHARSET_NAME_UTF_8 );
75
    if( isAcceptEncoding() && getInitProps().isCompression()) {
75
    if( isAcceptEncoding() && getConfiguration().isCompression()) {
76
      writeCompressedOutput();
76
      writeCompressedOutput();
77
    } else {
77
    } else {
78
      writeUnCompressedOutput();
78
      writeUnCompressedOutput();
Lines 126-134 Link Here
126
    return encodings != null && encodings.indexOf( JSLibraryServiceHandler.ENCODING_GZIP ) != -1;
126
    return encodings != null && encodings.indexOf( JSLibraryServiceHandler.ENCODING_GZIP ) != -1;
127
  }
127
  }
128
  
128
  
129
  private static IInitialization getInitProps() {
129
  private static IConfiguration getConfiguration() {
130
    IConfiguration configuration = ConfigurationReader.getConfiguration();
130
    return ConfigurationReader.getConfiguration();
131
    return configuration.getInitialization();
132
  }
131
  }
133
  
132
  
134
  private static JsConcatenator getJsConcatenator() {
133
  private static JsConcatenator getJsConcatenator() {
(-)src/org/eclipse/rwt/internal/lifecycle/PreserveWidgetsPhaseListener_Test.java (-2 lines)
Lines 46-53 Link Here
46
  }
46
  }
47
  
47
  
48
  protected void setUp() throws Exception {
48
  protected void setUp() throws Exception {
49
    System.setProperty( IInitialization.PARAM_LIFE_CYCLE,
50
                        RWTLifeCycle.class.getName() );
51
    Fixture.fakeContext();
49
    Fixture.fakeContext();
52
    Fixture.fakeNewRequest();
50
    Fixture.fakeNewRequest();
53
  }
51
  }
(-)src/org/eclipse/rwt/internal/lifecycle/RWTLifeCycle2_Test.java (-4 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2010 Innoopract Informationssysteme GmbH.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
package org.eclipse.rwt.internal.lifecycle;
12
package org.eclipse.rwt.internal.lifecycle;
12
13
Lines 20-26 Link Here
20
21
21
import org.eclipse.rwt.*;
22
import org.eclipse.rwt.*;
22
import org.eclipse.rwt.internal.AdapterFactoryRegistry;
23
import org.eclipse.rwt.internal.AdapterFactoryRegistry;
23
import org.eclipse.rwt.internal.IInitialization;
24
import org.eclipse.rwt.internal.engine.RWTDelegate;
24
import org.eclipse.rwt.internal.engine.RWTDelegate;
25
import org.eclipse.rwt.internal.service.*;
25
import org.eclipse.rwt.internal.service.*;
26
import org.eclipse.rwt.internal.theme.ThemeManager;
26
import org.eclipse.rwt.internal.theme.ThemeManager;
Lines 305-312 Link Here
305
    eventLog = new ArrayList();
305
    eventLog = new ArrayList();
306
    StartupPage.configurer = new RWTStartupPageConfigurer();
306
    StartupPage.configurer = new RWTStartupPageConfigurer();
307
    Fixture.clearSingletons();
307
    Fixture.clearSingletons();
308
    System.setProperty( IInitialization.PARAM_LIFE_CYCLE, 
309
                        RWTLifeCycle.class.getName() );
310
    ThemeManager.getInstance().initialize();
308
    ThemeManager.getInstance().initialize();
311
    Fixture.registerResourceManager();
309
    Fixture.registerResourceManager();
312
    PhaseListenerRegistry.add( new PreserveWidgetsPhaseListener() );
310
    PhaseListenerRegistry.add( new PreserveWidgetsPhaseListener() );
(-)src/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA_Test.java (-3 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 381-388 Link Here
381
  protected void setUp() throws Exception {
381
  protected void setUp() throws Exception {
382
    Fixture.fakeContext();
382
    Fixture.fakeContext();
383
    Fixture.fakeNewRequest();
383
    Fixture.fakeNewRequest();
384
    System.setProperty( IInitialization.PARAM_LIFE_CYCLE,
385
                        RWTLifeCycle.class.getName() );
386
    ThemeManager.getInstance().initialize();
384
    ThemeManager.getInstance().initialize();
387
    AdapterManager manager = AdapterManagerImpl.getInstance();
385
    AdapterManager manager = AdapterManagerImpl.getInstance();
388
    lifeCycleAdapterFactory = new AdapterFactory() {
386
    lifeCycleAdapterFactory = new AdapterFactory() {
(-)src/org/eclipse/rwt/internal/AdapterFactoryRegistry_Test.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
12
12
package org.eclipse.rwt.internal;
13
package org.eclipse.rwt.internal;
Lines 39-45 Link Here
39
  }
40
  }
40
41
41
  protected void setUp() throws Exception {
42
  protected void setUp() throws Exception {
42
    System.setProperty( IInitialization.PARAM_LIFE_CYCLE,
43
    System.setProperty( IConfiguration.PARAM_LIFE_CYCLE,
43
                        RWTLifeCycle.class.getName() );
44
                        RWTLifeCycle.class.getName() );
44
    Fixture.fakeContext();
45
    Fixture.fakeContext();
45
    Fixture.fakeNewRequest();
46
    Fixture.fakeNewRequest();
(-)src/org/eclipse/rwt/internal/ConfigurationReader_Test.java (-106 / +7 lines)
Lines 11-127 Link Here
11
 ******************************************************************************/
11
 ******************************************************************************/
12
package org.eclipse.rwt.internal;
12
package org.eclipse.rwt.internal;
13
13
14
import java.io.File;
15
16
import junit.framework.TestCase;
14
import junit.framework.TestCase;
17
15
18
import org.eclipse.rwt.Fixture;
19
20
16
21
public class ConfigurationReader_Test extends TestCase {
17
public class ConfigurationReader_Test extends TestCase {
22
  
18
23
  private final static File TEST_CONFIG_POOLS 
24
    = new File( Fixture.TEMP_DIR, "w4t_pools.xml" );
25
  private final static File TEST_CONFIG_PARTIAL
26
    = new File( Fixture.TEMP_DIR, "w4t_partial.xml" );
27
  private final static File TEST_XSD
28
    = new File( Fixture.TEMP_DIR, "W4T.xsd" );
29
  
30
  protected void setUp() throws Exception {
31
    ConfigurationReader.setConfigurationFile( null );
32
    Fixture.copyTestResource( "resources/w4t_partial.xml", 
33
                              TEST_CONFIG_PARTIAL );
34
  }
35
  
36
  protected void tearDown() throws Exception {
37
    System.getProperties().remove( "startUpForm" );
38
    System.getProperties().remove( "compatibilityMode" );
39
    
40
    if( TEST_CONFIG_POOLS.exists() ) {
41
      TEST_CONFIG_POOLS.delete();
42
    }
43
    if( TEST_CONFIG_PARTIAL.exists() ) {
44
      TEST_CONFIG_PARTIAL.delete();
45
    }
46
    if( TEST_XSD.exists() )  {
47
      TEST_XSD.delete();
48
    }
49
    ConfigurationReader.setConfigurationFile( null );
50
  }
51
  
52
  public void testConfigurationReading() {
19
  public void testConfigurationReading() {
53
    IConfiguration application = ConfigurationReader.getConfiguration();
20
    IConfiguration configuration = ConfigurationReader.getConfiguration();
54
    
21
    String lifeCycle = configuration.getLifeCycle();
55
    // initialization
22
    assertEquals( IConfiguration.LIFE_CYCLE_DEFAULT, lifeCycle );
56
    IInitialization initialization = application.getInitialization();
23
    boolean compression = configuration.isCompression();
57
    String startUpForm = initialization.getStartUpForm();
58
    assertEquals( "com.w4t.administration.Startup", startUpForm );
59
    String lifeCycle = initialization.getLifeCycle();
60
    assertEquals( "com.w4t.engine.lifecycle.standard.LifeCycle_Standard",
61
                  lifeCycle );
62
    String errorPage = initialization.getErrorPage();
63
    assertEquals( "com.w4t.administration.DefaultErrorForm", errorPage );
64
    String adminStartupForm = initialization.getAdministrationStartupForm();
65
    assertEquals(  "com.w4t.administration.Startup", adminStartupForm );
66
    String messagePage = initialization.getMessagePage();
67
    assertEquals( "com.w4t.administration.DefaultMessageForm", messagePage );
68
    String workDirectory = initialization.getWorkDirectory();
69
    assertEquals( "WEB-INF/classes/", workDirectory );
70
    long closingTimeout = initialization.getClosingTimeout();
71
    assertEquals( 3600000, closingTimeout );
72
    long skimmerFrequency = initialization.getSkimmerFrequenzy();
73
    assertEquals( 60000, skimmerFrequency );
74
    boolean directMonitoringAccess = initialization.isDirectMonitoringAccess();
75
    assertEquals( true, directMonitoringAccess );
76
    boolean compression = initialization.isCompression();
77
    assertEquals( false, compression );
24
    assertEquals( false, compression );
78
    boolean processTime = initialization.isProcessTime();
25
    String resources = configuration.getResources();
79
    assertEquals( false, processTime );
26
    assertEquals( IConfiguration.RESOURCES_DELIVER_FROM_DISK, resources );
80
    String nsSubmitters = initialization.getNoscriptSubmitters();
81
    assertEquals( IInitialization.NOSCRIPT_SUBMITTERS_CREATE, nsSubmitters );
82
    String resources = initialization.getResources();
83
    assertEquals( IInitialization.RESOURCES_DELIVER_FROM_DISK, resources );
84
    long maxSessionUnboundToForceGC
85
      = initialization.getMaxSessionUnboundToForceGC();
86
    assertEquals( 0, maxSessionUnboundToForceGC );
87
    String handleMissingI18NResource
88
      = initialization.getHandleMissingI18NResource();
89
    assertEquals( IInitialization.HANDLE_MISSING_I18N_RESOURCE_EMPTY,
90
                  handleMissingI18NResource );    
91
    
92
    // file upload
93
    IFileUpload fileUpload = application.getFileUpload();
94
    long maxUploadSize = fileUpload.getMaxUploadSize();
95
    assertEquals( 4194304, maxUploadSize );
96
    long maxMemorySize = fileUpload.getMaxMemorySize();
97
    assertEquals( 524288, maxMemorySize );
98
  }
99
  
100
  public void testPartialInitializationFile() throws Exception {
101
    ConfigurationReader.setConfigurationFile( TEST_CONFIG_PARTIAL );
102
    IConfiguration application = ConfigurationReader.getConfiguration();
103
    
104
    IInitialization initialization = application.getInitialization();
105
    String startUpForm = initialization.getStartUpForm();
106
    assertEquals( "com.w4t.FakeStartup", startUpForm );
107
    String lifeCycle = initialization.getLifeCycle();
108
    assertEquals( IInitialization.LIFE_CYCLE_DEFAULT, lifeCycle );
109
  }
110
  
111
  public void testConfigurationOverridingWithSystemProps() throws Exception {
112
    String startupFormProp = "trallala";
113
    System.setProperty( "startUpForm", startupFormProp );
114
    String compatibilityModeProp = "unknown";
115
    System.setProperty( "compatibilityMode", compatibilityModeProp );
116
    
117
    ConfigurationReader.setConfigurationFile( TEST_CONFIG_PARTIAL );
118
    IConfiguration application = ConfigurationReader.getConfiguration();
119
    
120
    IInitialization initialization = application.getInitialization();
121
    String startUpForm = initialization.getStartUpForm();
122
    assertEquals( startupFormProp, startUpForm );
123
    
124
    String lifeCycle = initialization.getLifeCycle();
125
    assertEquals( IInitialization.LIFE_CYCLE_DEFAULT, lifeCycle );
126
  }
27
  }
127
}
28
}
(-)src/org/eclipse/rwt/internal/EngineConfig_Test.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
12
12
package org.eclipse.rwt.internal;
13
package org.eclipse.rwt.internal;
Lines 38-43 Link Here
38
    assertTrue( config.getClassDir().exists() );    
39
    assertTrue( config.getClassDir().exists() );    
39
    assertTrue( config.getLibDir().exists() );
40
    assertTrue( config.getLibDir().exists() );
40
    assertTrue( config.getServerContextDir().exists() );
41
    assertTrue( config.getServerContextDir().exists() );
41
    assertTrue( config.getConfigFile().exists() );
42
  }
42
  }
43
}
43
}
(-)src/org/eclipse/rwt/internal/engine/RWTServletContextListener_Test.java (-4 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
12
12
package org.eclipse.rwt.internal.engine;
13
package org.eclipse.rwt.internal.engine;
Lines 95-104 Link Here
95
96
96
  protected void setUp() throws Exception {
97
  protected void setUp() throws Exception {
97
    Fixture.fakeContext();
98
    Fixture.fakeContext();
98
    System.setProperty( IInitialization.PARAM_LIFE_CYCLE, 
99
                        RWTLifeCycle.class.getName() );
100
  }
99
  }
101
  
100
102
  protected void tearDown() throws Exception {
101
  protected void tearDown() throws Exception {
103
    Fixture.tearDown();
102
    Fixture.tearDown();
104
    AdapterFactoryRegistry.clear();
103
    AdapterFactoryRegistry.clear();
(-)src/org/eclipse/rwt/internal/service/JSLibraryServiceHandler_Test.java (-3 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2010 Innoopract Informationssysteme GmbH.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
package org.eclipse.rwt.internal.service;
12
package org.eclipse.rwt.internal.service;
12
13
Lines 17-22 Link Here
17
import junit.framework.TestCase;
18
import junit.framework.TestCase;
18
19
19
import org.eclipse.rwt.*;
20
import org.eclipse.rwt.*;
21
import org.eclipse.rwt.internal.IConfiguration;
20
import org.eclipse.rwt.internal.util.HTML;
22
import org.eclipse.rwt.internal.util.HTML;
21
23
22
24
Lines 33-39 Link Here
33
  public void testResponseEncoding() throws IOException, ServletException {
35
  public void testResponseEncoding() throws IOException, ServletException {
34
    // as there is js concatenation in unit test mode switched of
36
    // as there is js concatenation in unit test mode switched of
35
    // we only test header settings...
37
    // we only test header settings...
36
    System.setProperty( "org.eclipse.rwt.compression", "true" );
38
    System.setProperty( IConfiguration.PARAM_COMPRESSION, "true" );
37
    
39
    
38
    // test with encoding not allowed by browser
40
    // test with encoding not allowed by browser
39
    TestResponse response = ( TestResponse )RWT.getResponse();
41
    TestResponse response = ( TestResponse )RWT.getResponse();
Lines 58-64 Link Here
58
    assertNotNull( encoding );
60
    assertNotNull( encoding );
59
    assertEquals( JSLibraryServiceHandler.ENCODING_GZIP, encoding );
61
    assertEquals( JSLibraryServiceHandler.ENCODING_GZIP, encoding );
60
    // clean up
62
    // clean up
61
    System.getProperties().remove( "org.eclipse.rwt.compression" );
63
    System.getProperties().remove( IConfiguration.PARAM_COMPRESSION );
62
  }
64
  }
63
  
65
  
64
  public void testRequestURLCreation() throws IOException {
66
  public void testRequestURLCreation() throws IOException {
(-)src/org/eclipse/rwt/Fixture.java (-32 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2009 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 *     EclipseSource - ongoing implementation
10
 ******************************************************************************/
11
 ******************************************************************************/
11
12
12
package org.eclipse.rwt;
13
package org.eclipse.rwt;
Lines 16-22 Link Here
16
17
17
import javax.servlet.http.*;
18
import javax.servlet.http.*;
18
import javax.xml.parsers.FactoryConfigurationError;
19
import javax.xml.parsers.FactoryConfigurationError;
19
import javax.xml.parsers.ParserConfigurationException;
20
20
21
import junit.framework.Assert;
21
import junit.framework.Assert;
22
22
Lines 33-39 Link Here
33
import org.eclipse.swt.internal.widgets.WidgetAdapter;
33
import org.eclipse.swt.internal.widgets.WidgetAdapter;
34
import org.eclipse.swt.widgets.Display;
34
import org.eclipse.swt.widgets.Display;
35
import org.eclipse.swt.widgets.Widget;
35
import org.eclipse.swt.widgets.Widget;
36
import org.xml.sax.SAXException;
37
36
38
public class Fixture {
37
public class Fixture {
39
38
Lines 58-82 Link Here
58
  public static void setUp() {
57
  public static void setUp() {
59
    // standard setup
58
    // standard setup
60
    commonSetUp();
59
    commonSetUp();
61
    System.setProperty( IInitialization.PARAM_LIFE_CYCLE,
62
                        RWTLifeCycle.class.getName() );
63
64
    ThemeManager.getInstance().initialize();
60
    ThemeManager.getInstance().initialize();
65
    registerAdapterFactories();
61
    registerAdapterFactories();
66
    PhaseListenerRegistry.add( Fixture.currentPhaseListener );
62
    PhaseListenerRegistry.add( Fixture.currentPhaseListener );
67
68
    // registration of mockup resource manager
63
    // registration of mockup resource manager
69
    registerResourceManager();
64
    registerResourceManager();
70
71
    SettingStoreManager.register( new MemorySettingStoreFactory() );
65
    SettingStoreManager.register( new MemorySettingStoreFactory() );
72
  }
66
  }
73
67
74
  public static void setUpWithoutResourceManager() {
68
  public static void setUpWithoutResourceManager() {
75
    // standard setup
69
    // standard setup
76
    commonSetUp();
70
    commonSetUp();
77
    System.setProperty( IInitialization.PARAM_LIFE_CYCLE,
78
                        RWTLifeCycle.class.getName() );
79
80
    // registration of adapter factories
71
    // registration of adapter factories
81
    registerAdapterFactories();
72
    registerAdapterFactories();
82
  }
73
  }
Lines 85-96 Link Here
85
    // disable js-versioning by default to make comparison easier
76
    // disable js-versioning by default to make comparison easier
86
    System.setProperty( SystemProps.USE_VERSIONED_JAVA_SCRIPT, "false" );
77
    System.setProperty( SystemProps.USE_VERSIONED_JAVA_SCRIPT, "false" );
87
    clearSingletons();
78
    clearSingletons();
88
    try {
89
      ConfigurationReader.setConfigurationFile( null );
90
    } catch( Throwable shouldNotHappen ) {
91
      throw new RuntimeException( shouldNotHappen );
92
    }
93
94
    TestResponse response = new TestResponse();
79
    TestResponse response = new TestResponse();
95
    TestRequest request = new TestRequest();
80
    TestRequest request = new TestRequest();
96
    request.setSession( new TestSession() );
81
    request.setSession( new TestSession() );
Lines 125-139 Link Here
125
    ContextProvider.disposeContext();
110
    ContextProvider.disposeContext();
126
    session.invalidate();
111
    session.invalidate();
127
    clearSingletons();
112
    clearSingletons();
128
    System.getProperties().remove( IInitialization.PARAM_LIFE_CYCLE );
113
    System.getProperties().remove( IConfiguration.PARAM_LIFE_CYCLE );
129
114
130
    AbstractBranding[] all = BrandingManager.getAll();
115
    AbstractBranding[] all = BrandingManager.getAll();
131
    for( int i = 0; i < all.length; i++ ) {
116
    for( int i = 0; i < all.length; i++ ) {
132
      BrandingManager.deregister( all[ i ] );
117
      BrandingManager.deregister( all[ i ] );
133
    }
118
    }
134
119
    ConfigurationReader.reset();
135
    LifeCycleFactory.destroy();
120
    LifeCycleFactory.destroy();
136
137
    PhaseListenerRegistry.clear();
121
    PhaseListenerRegistry.clear();
138
  }
122
  }
139
123
Lines 144-153 Link Here
144
  }
128
  }
145
129
146
  public static void createContext( final boolean fake )
130
  public static void createContext( final boolean fake )
147
    throws IOException,
131
    throws FactoryConfigurationError
148
           FactoryConfigurationError,
149
           ParserConfigurationException,
150
           SAXException
151
  {
132
  {
152
    if( fake ) {
133
    if( fake ) {
153
      setPrivateField( ResourceManagerImpl.class,
134
      setPrivateField( ResourceManagerImpl.class,
Lines 157-173 Link Here
157
    } else {
138
    } else {
158
      createContextWithoutResourceManager();
139
      createContextWithoutResourceManager();
159
      String webAppBase = CONTEXT_DIR.toString();
140
      String webAppBase = CONTEXT_DIR.toString();
160
      String deliverFromDisk = IInitialization.RESOURCES_DELIVER_FROM_DISK;
141
      String deliverFromDisk = IConfiguration.RESOURCES_DELIVER_FROM_DISK;
161
      ResourceManagerImpl.createInstance( webAppBase, deliverFromDisk );
142
      ResourceManagerImpl.createInstance( webAppBase, deliverFromDisk );
162
    }
143
    }
163
  }
144
  }
164
145
165
  public static void createContextWithoutResourceManager()
146
  public static void createContextWithoutResourceManager()
166
    throws FileNotFoundException,
147
    throws FactoryConfigurationError
167
           IOException,
168
           FactoryConfigurationError,
169
           ParserConfigurationException,
170
           SAXException
171
  {
148
  {
172
    CONTEXT_DIR.mkdirs();
149
    CONTEXT_DIR.mkdirs();
173
    File webInf = new File( CONTEXT_DIR, "WEB-INF" );
150
    File webInf = new File( CONTEXT_DIR, "WEB-INF" );
Lines 178-185 Link Here
178
    classes.mkdirs();
155
    classes.mkdirs();
179
    File libDir = new File( webInf, "lib" );
156
    File libDir = new File( webInf, "lib" );
180
    libDir.mkdirs();
157
    libDir.mkdirs();
181
    File w4tXml = new File( conf, "W4T.xml" );
182
    copyTestResource( "resources/w4t_fixture.xml", w4tXml );
183
158
184
    String webAppBase = CONTEXT_DIR.toString();
159
    String webAppBase = CONTEXT_DIR.toString();
185
    EngineConfig engineConfig = new EngineConfig( webAppBase );
160
    EngineConfig engineConfig = new EngineConfig( webAppBase );
Lines 208-213 Link Here
208
  {
183
  {
209
    ClassLoader loader = Fixture.class.getClassLoader();
184
    ClassLoader loader = Fixture.class.getClassLoader();
210
    InputStream is = loader.getResourceAsStream( resourceName );
185
    InputStream is = loader.getResourceAsStream( resourceName );
186
    if( is == null ) {
187
      throw new IllegalArgumentException( "Resource could not be found: "
188
                                          + resourceName );
189
    }
211
    try {
190
    try {
212
      OutputStream out = new FileOutputStream( destination );
191
      OutputStream out = new FileOutputStream( destination );
213
      try {
192
      try {
(-)src/resources/w4t_fixture.xml (-11 lines)
Removed Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<w4t:application xmlns:w4t="http://w4toolkit.com/" 
3
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
4
                 xsi:schemaLocation="http://w4toolkit.com/ w4t.xsd ">
5
	<initialisation>	
6
		<startUpForm>     		  
7
		        com.w4t.FixtureForm
8
		</startUpForm>
9
		<noscriptSubmitters>None</noscriptSubmitters>
10
	</initialisation>
11
</w4t:application>
(-)src/resources/w4t_partial.xml (-10 lines)
Removed Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<w4t:application xmlns:w4t="http://w4toolkit.com/" 
3
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
4
                 xsi:schemaLocation="http://w4toolkit.com/ w4t.xsd ">
5
	<initialisation>	
6
		<startUpForm>     		  
7
		        com.w4t.FakeStartup
8
		</startUpForm>
9
	</initialisation>
10
</w4t:application>
(-)Eclipse UI/org/eclipse/rap/ui/internal/servlet/EngineConfigWrapper.java (-39 lines)
Lines 47-56 Link Here
47
// TODO: [fappel] clean replacement mechanism that is anchored in W4Toolkit core
47
// TODO: [fappel] clean replacement mechanism that is anchored in W4Toolkit core
48
final class EngineConfigWrapper implements IEngineConfig {
48
final class EngineConfigWrapper implements IEngineConfig {
49
49
50
  private final static String FOLDER
51
    = EngineConfigWrapper.class.getPackage().getName().replace( '.', '/' );
52
  // path to a w4toolkit configuration file on the classpath
53
  private final static String CONFIG = FOLDER +"/config.xml";
54
  //  extension point id for adapter factory registration
50
  //  extension point id for adapter factory registration
55
  private static final String ID_ADAPTER_FACTORY
51
  private static final String ID_ADAPTER_FACTORY
56
    = "org.eclipse.rap.ui.adapterfactory";
52
    = "org.eclipse.rap.ui.adapterfactory";
Lines 103-122 Link Here
103
    return engineConfig.getClassDir();
99
    return engineConfig.getClassDir();
104
  }
100
  }
105
101
106
  public File getConfigFile() {
107
    File result = engineConfig.getConfigFile();
108
    if( !result.exists() ) {
109
      result.getParentFile().mkdirs();
110
      try {
111
        result.createNewFile();
112
        createConfiguration( result );
113
      } catch( final IOException shouldNotHappen ) {
114
        throw new RuntimeException( shouldNotHappen );
115
      }
116
    }
117
    return result;
118
  }
119
120
  public File getLibDir() {
102
  public File getLibDir() {
121
    return engineConfig.getLibDir();
103
    return engineConfig.getLibDir();
122
  }
104
  }
Lines 386-412 Link Here
386
    return stateLocation.append( "context" );
368
    return stateLocation.append( "context" );
387
  }
369
  }
388
370
389
  private static void createConfiguration( final File destination )
390
    throws FileNotFoundException, IOException
391
  {
392
    ClassLoader loader = EngineConfigWrapper.class.getClassLoader();
393
    InputStream is = loader.getResourceAsStream( CONFIG );
394
    try {
395
      OutputStream out = new FileOutputStream( destination );
396
      try {
397
        int character = is.read();
398
        while( character != -1 ) {
399
          out.write( character );
400
          character = is.read();
401
        }
402
      } finally {
403
        out.close();
404
      }
405
    } finally {
406
      is.close();
407
    }
408
  }
409
410
  private static void registerResources() {
371
  private static void registerResources() {
411
    IExtensionRegistry registry = Platform.getExtensionRegistry();
372
    IExtensionRegistry registry = Platform.getExtensionRegistry();
412
    IExtensionPoint point = registry.getExtensionPoint( ID_RESOURCES );
373
    IExtensionPoint point = registry.getExtensionPoint( ID_RESOURCES );
(-)Eclipse UI/org/eclipse/rap/ui/internal/servlet/config.xml (-7 lines)
Removed Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<w4t:application xmlns:w4t="http://w4toolkit.com/" 
3
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
                 xsi:schemaLocation="http://w4toolkit.com/ w4t.xsd ">
5
	<initialisation>
6
	</initialisation>
7
</w4t:application>

Return to bug 320926