Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 192421 Details for
Bug 341712
[API] IApplicationStore - Provide storage area for application scope
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
First draft of IApplicationStore
applicationstore-patch.txt (text/plain), 10.01 KB, created by
Frank Appel
on 2011-04-03 01:53:16 EDT
(
hide
)
Description:
First draft of IApplicationStore
Filename:
MIME Type:
Creator:
Frank Appel
Created:
2011-04-03 01:53:16 EDT
Size:
10.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt >Index: src/org/eclipse/rwt/RWT.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/rwt/RWT.java,v >retrieving revision 1.23 >diff -u -r1.23 RWT.java >--- src/org/eclipse/rwt/RWT.java 13 Mar 2011 15:20:43 -0000 1.23 >+++ src/org/eclipse/rwt/RWT.java 3 Apr 2011 05:32:29 -0000 >@@ -13,7 +13,8 @@ > ******************************************************************************/ > package org.eclipse.rwt; > >-import java.lang.reflect.*; >+import java.lang.reflect.Field; >+import java.lang.reflect.Modifier; > import java.util.*; > > import javax.servlet.http.HttpServletRequest; >@@ -225,6 +226,18 @@ > return ContextProvider.getSession(); > } > >+ // TODO [DISCUSS_API] >+ /** >+ * Returns the <code>IApplicationStore</code> instance that represents the web context's >+ * global data storage area. >+ * >+ * @return instance of {@link IApplicationStore} >+ * @since 1.4 >+ */ >+ public static IApplicationStore getApplicationStore() { >+ return ( IApplicationStore )RWTContext.getSingleton( ApplicationStoreImpl.class ); >+ } >+ > /** > * Returns the <code>HttpServletRequest</code> that is currently > * processed. >Index: src/org/eclipse/rwt/internal/engine/RWTContextUtil.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/engine/RWTContextUtil.java,v >retrieving revision 1.5 >diff -u -r1.5 RWTContextUtil.java >--- src/org/eclipse/rwt/internal/engine/RWTContextUtil.java 3 Apr 2011 04:54:25 -0000 1.5 >+++ src/org/eclipse/rwt/internal/engine/RWTContextUtil.java 3 Apr 2011 05:32:29 -0000 >@@ -34,6 +34,7 @@ > = RWTContext.class.getName() + "#RWTContext"; > > private static final Class[] INSTANCE_TYPES = new Class[] { >+ ApplicationStoreImpl.class, // TODO [DISCUSS_API] > ThemeManagerInstance.class, > ResourceManagerImpl.class, > ResourceManager.class, >Index: src/org/eclipse/rwt/internal/service/ApplicationStoreImpl.java >=================================================================== >RCS file: src/org/eclipse/rwt/internal/service/ApplicationStoreImpl.java >diff -N src/org/eclipse/rwt/internal/service/ApplicationStoreImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rwt/internal/service/ApplicationStoreImpl.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 EclipseSource and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * EclipseSource - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.rwt.internal.service; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.rwt.service.IApplicationStore; >+ >+// TODO [DISCUSS_API] >+public class ApplicationStoreImpl implements IApplicationStore { >+ private final Map attributes; >+ >+ public ApplicationStoreImpl() { >+ attributes = new HashMap(); >+ } >+ >+ public Object getAttribute( String name ) { >+ Object result; >+ synchronized( attributes ) { >+ result = attributes.get( name ); >+ } >+ return result; >+ } >+ >+ public void setAttribute( String name, Object value ) { >+ synchronized( attributes ) { >+ attributes.put( name, value ); >+ } >+ } >+ >+ public void removeAttribute( String name ) { >+ synchronized( attributes ) { >+ attributes.remove( name ); >+ } >+ } >+} >Index: src/org/eclipse/rwt/service/IApplicationStore.java >=================================================================== >RCS file: src/org/eclipse/rwt/service/IApplicationStore.java >diff -N src/org/eclipse/rwt/service/IApplicationStore.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rwt/service/IApplicationStore.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 EclipseSource and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * EclipseSource - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.rwt.service; >+ >+// TODO [DISCUSS_API] >+/** >+ * The <code>IApplicationStore</code> can be used as store for data that spans >+ * the lifecycle of a web application instance. >+ * >+ * >+ * <p><strong>Note:</strong> the <code>IApplicationStore</code> implementation is used >+ * in the so called application-scope. That means all information stored here will be >+ * lost once the application web context is destroyed. Application-scope also implies >+ * concurrent access. Therefore the implementation of <code>IApplicationStore</code> >+ * has to provide a proper synchronization of its storage datastructure.</p> >+ * >+ * @see org.eclipse.rwt.RWT >+ * @since 1.4 >+ */ >+public interface IApplicationStore { >+ >+ /** >+ * Stores the given value object with the given name as key in this >+ * <code>IApplicationStore</code> instance. >+ */ >+ void setAttribute( String name, Object value ); >+ >+ /** >+ * Returns the value object which is stored under the given name in this >+ * <code>IApplicationStore</code> instance or null if no value object has been stored. >+ */ >+ Object getAttribute( String name ); >+ >+ /** >+ * Removes the value object which is stored under the given name in this >+ * <code>IApplicationStore</code> instance. Does nothing if no value object was stored >+ * under the given name. >+ */ >+ void removeAttribute( String name ); >+} >#P org.eclipse.rap.rwt.test >Index: src/org/eclipse/RWTHostTestSuite.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.test/src/org/eclipse/RWTHostTestSuite.java,v >retrieving revision 1.77 >diff -u -r1.77 RWTHostTestSuite.java >--- src/org/eclipse/RWTHostTestSuite.java 3 Apr 2011 04:54:26 -0000 1.77 >+++ src/org/eclipse/RWTHostTestSuite.java 3 Apr 2011 05:32:29 -0000 >@@ -74,6 +74,7 @@ > suite.addTestSuite( Scope_Test.class ); > suite.addTestSuite( ServiceHandler_Test.class ); > suite.addTestSuite( SessionStore_Test.class ); >+ suite.addTestSuite( ApplicationStoreImpl_Test.class ); > suite.addTestSuite( EngineConfig_Test.class ); > suite.addTestSuite( QxCleanup_Test.class ); > suite.addTestSuite( ResourceManagerImpl_Test.class ); >Index: src/org/eclipse/rwt/RWT_Test.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.test/src/org/eclipse/rwt/RWT_Test.java,v >retrieving revision 1.1 >diff -u -r1.1 RWT_Test.java >--- src/org/eclipse/rwt/RWT_Test.java 14 Jan 2010 16:12:25 -0000 1.1 >+++ src/org/eclipse/rwt/RWT_Test.java 3 Apr 2011 05:32:29 -0000 >@@ -11,8 +11,11 @@ > > import junit.framework.TestCase; > >+import org.eclipse.rwt.internal.engine.RWTContext; > import org.eclipse.rwt.internal.lifecycle.DisplayUtil; >+import org.eclipse.rwt.internal.service.ApplicationStoreImpl; > import org.eclipse.rwt.internal.service.RequestParams; >+import org.eclipse.rwt.service.IApplicationStore; > import org.eclipse.swt.SWT; > import org.eclipse.swt.SWTException; > import org.eclipse.swt.widgets.Display; >@@ -62,6 +65,12 @@ > assertNotNull( requestThread[ 0 ] ); > } > >+ public void testGetApplicationStore() { >+ IApplicationStore applicationStore = RWT.getApplicationStore(); >+ >+ assertSame( applicationStore, RWTContext.getSingleton( ApplicationStoreImpl.class ) ); >+ } >+ > protected void setUp() throws Exception { > Fixture.setUp(); > } >Index: src/org/eclipse/rwt/internal/service/ApplicationStoreImpl_Test.java >=================================================================== >RCS file: src/org/eclipse/rwt/internal/service/ApplicationStoreImpl_Test.java >diff -N src/org/eclipse/rwt/internal/service/ApplicationStoreImpl_Test.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rwt/internal/service/ApplicationStoreImpl_Test.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 EclipseSource and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * EclipseSource - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.rwt.internal.service; >+ >+import junit.framework.TestCase; >+ >+ >+public class ApplicationStoreImpl_Test extends TestCase { >+ private static final String VALUE = "value"; >+ private static final String KEY = "key"; >+ >+ public void testGetAttribute() { >+ ApplicationStoreImpl applicationStore = new ApplicationStoreImpl(); >+ applicationStore.setAttribute( KEY, VALUE ); >+ >+ Object attribute = applicationStore.getAttribute( KEY ); >+ >+ assertSame( VALUE, attribute ); >+ } >+ >+ public void testRemoveAttribute() { >+ ApplicationStoreImpl applicationStore = new ApplicationStoreImpl(); >+ applicationStore.setAttribute( KEY, VALUE ); >+ >+ applicationStore.removeAttribute( KEY ); >+ >+ assertSame( null, applicationStore.getAttribute( KEY ) ); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 341712
: 192421