Skip to main content
Jump to: navigation, search

Difference between revisions of "Examples/Eclipse Business Expense Reporting Tool/User State Service"

Line 4: Line 4:
 
EBERT defines an Equinox/OSGi Service of type [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.examples/ebert/org.eclipse.examples.expenses.views/src/org/eclipse/examples/expenses/context/IUserContextService.java?root=Technology_Project&view=markup IUserContextService.java] along with two different implementations. Implementations of this type are responsible for one thing: answer, when asked, the user state (an instance of [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.examples/ebert/org.eclipse.examples.expenses.views/src/org/eclipse/examples/expenses/context/IUserContext.java?root=Technology_Project&view=markup IUserContext]) for the current user.
 
EBERT defines an Equinox/OSGi Service of type [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.examples/ebert/org.eclipse.examples.expenses.views/src/org/eclipse/examples/expenses/context/IUserContextService.java?root=Technology_Project&view=markup IUserContextService.java] along with two different implementations. Implementations of this type are responsible for one thing: answer, when asked, the user state (an instance of [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.examples/ebert/org.eclipse.examples.expenses.views/src/org/eclipse/examples/expenses/context/IUserContext.java?root=Technology_Project&view=markup IUserContext]) for the current user.
  
The notion of "current user" is pretty simple in the standalone case: there is only one user. The [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.examples/ebert/org.eclipse.examples.expenses.context.standalone/src/org/eclipse/examples/expenses/context/standalone/StandaloneUserContextService.java?root=Technology_Project&view=markup StandaloneUserContextService]
+
The notion of "current user" is pretty simple in the standalone case: there is only one user. The [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.examples/ebert/org.eclipse.examples.expenses.context.standalone/src/org/eclipse/examples/expenses/context/standalone/StandaloneUserContextService.java?root=Technology_Project&view=markup StandaloneUserContextService] simply returns an instance of [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.examples/ebert/org.eclipse.examples.expenses.context.standalone/src/org/eclipse/examples/expenses/context/standalone/StandaloneUserContext.java?root=Technology_Project&view=markup StandaloneUserContext] that it holds in a field. The [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.examples/ebert/org.eclipse.examples.expenses.context.standalone/src/org/eclipse/examples/expenses/context/standalone/Activator.java?root=Technology_Project&view=markup activator] for the bundle containing these types registers the service on bundle startup and deregisters it on shutdown.
 +
 
 +
The notion of "current user" is more interesting in the multiple-user case of RAP. [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.examples/ebert/org.eclipse.examples.expenses.application.rap/src/org/eclipse/examples/expenses/context/rap/RapUserContextService.java?root=Technology_Project&view=markup RapUserContextService] uses the HTTP Session state, accessible through APIs on RAP's RWT type. This returns for us an instance of [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.examples/ebert/org.eclipse.examples.expenses.application.rap/src/org/eclipse/examples/expenses/context/rap/RapUserContext.java?root=Technology_Project&view=markup RapUserContext] that is specific to the user tied to the current thread. As is the case with the standalone variant, this service is registered and deregistered by the bundle activator.

Revision as of 15:37, 26 February 2009

This page is under development

Managing the user state in a standalone application is relatively easy. EBERT runs as both a standalone application (RCP, ERCP) and as a multiple-user application (RAP). To support both environments, we have to be careful how we store user state.

EBERT defines an Equinox/OSGi Service of type IUserContextService.java along with two different implementations. Implementations of this type are responsible for one thing: answer, when asked, the user state (an instance of IUserContext) for the current user.

The notion of "current user" is pretty simple in the standalone case: there is only one user. The StandaloneUserContextService simply returns an instance of StandaloneUserContext that it holds in a field. The activator for the bundle containing these types registers the service on bundle startup and deregisters it on shutdown.

The notion of "current user" is more interesting in the multiple-user case of RAP. RapUserContextService uses the HTTP Session state, accessible through APIs on RAP's RWT type. This returns for us an instance of RapUserContext that is specific to the user tied to the current thread. As is the case with the standalone variant, this service is registered and deregistered by the bundle activator.

Back to the top