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

(-)src/org/eclipse/rwt/RWT.java (-1 / +14 lines)
Lines 13-19 Link Here
13
 ******************************************************************************/
13
 ******************************************************************************/
14
package org.eclipse.rwt;
14
package org.eclipse.rwt;
15
15
16
import java.lang.reflect.*;
16
import java.lang.reflect.Field;
17
import java.lang.reflect.Modifier;
17
import java.util.*;
18
import java.util.*;
18
19
19
import javax.servlet.http.HttpServletRequest;
20
import javax.servlet.http.HttpServletRequest;
Lines 225-230 Link Here
225
    return ContextProvider.getSession();
226
    return ContextProvider.getSession();
226
  }
227
  }
227
  
228
  
229
  // TODO [DISCUSS_API]
230
  /**
231
   * Returns the <code>IApplicationStore</code> instance that represents the web context's
232
   * global data storage area.
233
   * 
234
   * @return instance of {@link IApplicationStore}
235
   * @since 1.4
236
   */
237
  public static IApplicationStore getApplicationStore() {
238
    return ( IApplicationStore )RWTContext.getSingleton( ApplicationStoreImpl.class );
239
  }
240
  
228
  /**
241
  /**
229
   * Returns the <code>HttpServletRequest</code> that is currently
242
   * Returns the <code>HttpServletRequest</code> that is currently
230
   * processed.
243
   * processed.
(-)src/org/eclipse/rwt/internal/engine/RWTContextUtil.java (+1 lines)
Lines 34-39 Link Here
34
    = RWTContext.class.getName() + "#RWTContext";
34
    = RWTContext.class.getName() + "#RWTContext";
35
 
35
 
36
  private static final Class[] INSTANCE_TYPES = new Class[] {
36
  private static final Class[] INSTANCE_TYPES = new Class[] {
37
    ApplicationStoreImpl.class,   // TODO [DISCUSS_API]
37
    ThemeManagerInstance.class,
38
    ThemeManagerInstance.class,
38
    ResourceManagerImpl.class,
39
    ResourceManagerImpl.class,
39
    ResourceManager.class,
40
    ResourceManager.class,
(-)src/org/eclipse/rwt/internal/service/ApplicationStoreImpl.java (+45 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 EclipseSource and others.
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
 *    EclipseSource - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.service;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
16
import org.eclipse.rwt.service.IApplicationStore;
17
18
// TODO [DISCUSS_API]
19
public class ApplicationStoreImpl implements IApplicationStore {
20
  private final Map attributes;
21
  
22
  public ApplicationStoreImpl() {
23
    attributes = new HashMap();
24
  }
25
  
26
  public Object getAttribute( String name ) {
27
    Object result;
28
    synchronized( attributes ) {
29
      result = attributes.get( name );
30
    }
31
    return result;
32
  }
33
34
  public void setAttribute( String name, Object value ) {
35
    synchronized( attributes ) {
36
      attributes.put( name, value );
37
    }
38
  }
39
40
  public void removeAttribute( String name ) {
41
    synchronized( attributes ) {
42
      attributes.remove( name );
43
    }
44
  }
45
}
(-)src/org/eclipse/rwt/service/IApplicationStore.java (+48 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 EclipseSource and others.
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
 *    EclipseSource - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.service;
12
13
// TODO [DISCUSS_API]
14
/**
15
 * The <code>IApplicationStore</code> can be used as store for data that spans
16
 * the lifecycle of a web application instance.
17
 * 
18
 * 
19
 * <p><strong>Note:</strong> the <code>IApplicationStore</code> implementation is used
20
 * in the so called application-scope. That means all information stored here will be 
21
 * lost once the application web context is destroyed. Application-scope also implies
22
 * concurrent access. Therefore the implementation of <code>IApplicationStore</code>
23
 * has to provide a proper synchronization of its storage datastructure.</p>
24
 * 
25
 * @see org.eclipse.rwt.RWT
26
 * @since 1.4
27
 */
28
public interface IApplicationStore {
29
30
  /**
31
   * Stores the given value object with the given name as key in this
32
   * <code>IApplicationStore</code> instance.
33
   */
34
  void setAttribute( String name, Object value );
35
36
  /**
37
   * Returns the value object which is stored under the given name in this
38
   * <code>IApplicationStore</code> instance or null if no value object has been stored.
39
   */
40
  Object getAttribute( String name );
41
42
  /**
43
   * Removes the value object which is stored under the given name in this
44
   * <code>IApplicationStore</code> instance. Does nothing if no value object was stored
45
   * under the given name.
46
   */
47
  void removeAttribute( String name );
48
}
(-)src/org/eclipse/RWTHostTestSuite.java (+1 lines)
Lines 74-79 Link Here
74
    suite.addTestSuite( Scope_Test.class );
74
    suite.addTestSuite( Scope_Test.class );
75
    suite.addTestSuite( ServiceHandler_Test.class );
75
    suite.addTestSuite( ServiceHandler_Test.class );
76
    suite.addTestSuite( SessionStore_Test.class );
76
    suite.addTestSuite( SessionStore_Test.class );
77
    suite.addTestSuite( ApplicationStoreImpl_Test.class );
77
    suite.addTestSuite( EngineConfig_Test.class );
78
    suite.addTestSuite( EngineConfig_Test.class );
78
    suite.addTestSuite( QxCleanup_Test.class );
79
    suite.addTestSuite( QxCleanup_Test.class );
79
    suite.addTestSuite( ResourceManagerImpl_Test.class );
80
    suite.addTestSuite( ResourceManagerImpl_Test.class );
(-)src/org/eclipse/rwt/RWT_Test.java (+9 lines)
Lines 11-18 Link Here
11
11
12
import junit.framework.TestCase;
12
import junit.framework.TestCase;
13
13
14
import org.eclipse.rwt.internal.engine.RWTContext;
14
import org.eclipse.rwt.internal.lifecycle.DisplayUtil;
15
import org.eclipse.rwt.internal.lifecycle.DisplayUtil;
16
import org.eclipse.rwt.internal.service.ApplicationStoreImpl;
15
import org.eclipse.rwt.internal.service.RequestParams;
17
import org.eclipse.rwt.internal.service.RequestParams;
18
import org.eclipse.rwt.service.IApplicationStore;
16
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWTException;
20
import org.eclipse.swt.SWTException;
18
import org.eclipse.swt.widgets.Display;
21
import org.eclipse.swt.widgets.Display;
Lines 62-67 Link Here
62
    assertNotNull( requestThread[ 0 ] );
65
    assertNotNull( requestThread[ 0 ] );
63
  }
66
  }
64
67
68
  public void testGetApplicationStore() {
69
    IApplicationStore applicationStore = RWT.getApplicationStore();
70
71
    assertSame( applicationStore, RWTContext.getSingleton( ApplicationStoreImpl.class ) );
72
  }
73
  
65
  protected void setUp() throws Exception {
74
  protected void setUp() throws Exception {
66
    Fixture.setUp();
75
    Fixture.setUp();
67
  }
76
  }
(-)src/org/eclipse/rwt/internal/service/ApplicationStoreImpl_Test.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 EclipseSource and others.
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
 *    EclipseSource - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.rwt.internal.service;
12
13
import junit.framework.TestCase;
14
15
16
public class ApplicationStoreImpl_Test extends TestCase {
17
  private static final String VALUE = "value";
18
  private static final String KEY = "key";
19
20
  public void testGetAttribute() {
21
    ApplicationStoreImpl applicationStore = new ApplicationStoreImpl();
22
    applicationStore.setAttribute( KEY, VALUE );
23
    
24
    Object attribute = applicationStore.getAttribute( KEY );
25
    
26
    assertSame( VALUE, attribute );
27
  }
28
29
  public void testRemoveAttribute() {
30
    ApplicationStoreImpl applicationStore = new ApplicationStoreImpl();
31
    applicationStore.setAttribute( KEY, VALUE );
32
    
33
    applicationStore.removeAttribute( KEY );
34
    
35
    assertSame( null, applicationStore.getAttribute( KEY ) );
36
  }
37
}

Return to bug 341712