* @return the current application instance if available, otherwise
* <code>null</code>
*
- * @see #setCurrentApplication(Application)
+ * @see #setCurrent(Application)
*
* @since 7.0
*/
- public static Application getCurrentApplication() {
+ public static Application getCurrent() {
return currentApplication.get();
}
*
* @param application
*
- * @see #getCurrentApplication()
+ * @see #getCurrent()
* @see ThreadLocal
*
* @since 7.0
*/
- public static void setCurrentApplication(Application application) {
+ public static void setCurrent(Application application) {
currentApplication.set(application);
}
*/
public Root getRootForRequest(WrappedRequest request)
throws RootRequiresMoreInformationException {
- Root root = Root.getCurrentRoot();
+ Root root = Root.getCurrent();
if (root != null) {
return root;
}
}
// Set thread local here so it is available in init
- Root.setCurrentRoot(root);
+ Root.setCurrent(root);
if (!initedRoots.contains(rootId)) {
boolean initRequiresBrowserDetails = isRootPreserved()
* Finds a converter that can convert from the given presentation type to
* the given model type and back. Uses the given application to find a
* {@link ConverterFactory} or, if application is null, uses the
- * {@link Application#getCurrentApplication()}.
+ * {@link Application#getCurrent()}.
*
* @param <PRESENTATIONTYPE>
* The presentation type
Class<MODELTYPE> modelType, Application application) {
Converter<PRESENTATIONTYPE, MODELTYPE> converter = null;
if (application == null) {
- application = Application.getCurrentApplication();
+ application = Application.getCurrent();
}
if (application != null) {
public WebBrowser getWebBrowser() {
WebApplicationContext context = (WebApplicationContext) Application
- .getCurrentApplication().getContext();
+ .getCurrent().getContext();
return context.getBrowser();
}
};
}
public static Page getCurrent() {
- Root currentRoot = Root.getCurrentRoot();
+ Root currentRoot = Root.getCurrent();
if (currentRoot == null) {
return null;
}
if (application == null) {
return;
}
- Application.setCurrentApplication(application);
+ Application.setCurrent(application);
/*
* Get or create an application context and an application
}
} finally {
- Root.setCurrentRoot(null);
- Application.setCurrentApplication(null);
+ Root.setCurrent(null);
+ Application.setCurrent(null);
PortletSession session = request
.getPortletSession(false);
if (application == null) {
return;
}
- Application.setCurrentApplication(application);
+ Application.setCurrent(application);
/*
* Get or create a WebApplicationContext and an ApplicationManager
.onRequestEnd(request, response);
}
} finally {
- Root.setCurrentRoot(null);
- Application.setCurrentApplication(null);
+ Root.setCurrent(null);
+ Application.setCurrent(null);
HttpSession session = request.getSession(false);
if (session != null) {
// if we do not yet have a currentRoot, it should be initialized
// shortly, and we should send the initial UIDL
- boolean sendUIDL = Root.getCurrentRoot() == null;
+ boolean sendUIDL = Root.getCurrent() == null;
try {
CombinedRequest combinedRequest = new CombinedRequest(request);
public Root getRoot() {
if (!rootFetched) {
- root = Root.getCurrentRoot();
+ root = Root.getCurrent();
rootFetched = true;
}
return root;
public WebBrowser getWebBrowser() {
WebApplicationContext context = (WebApplicationContext) Application
- .getCurrentApplication().getContext();
+ .getCurrent().getContext();
return context.getBrowser();
}
};
public WebBrowser getWebBrowser() {
PortletApplicationContext2 context = (PortletApplicationContext2) Application
- .getCurrentApplication().getContext();
+ .getCurrent().getContext();
return context.getBrowser();
}
};
* <p>
* Getting a null value is often a problem in constructors of regular
* components and in the initializers of custom composite components. A
- * standard workaround is to use {@link Application#getCurrentApplication()}
+ * standard workaround is to use {@link Application#getCurrent()}
* to retrieve the application instance that the current request relates to.
* Another way is to move the problematic initialization to
* {@link #attach()}, as described in the documentation of the method.
* @param root
* the root to register as the current root
*
- * @see #getCurrentRoot()
+ * @see #getCurrent()
* @see ThreadLocal
*/
- public static void setCurrentRoot(Root root) {
+ public static void setCurrent(Root root) {
currentRoot.set(root);
}
* @return the current root instance if available, otherwise
* <code>null</code>
*
- * @see #setCurrentRoot(Root)
+ * @see #setCurrent(Root)
*/
- public static Root getCurrentRoot() {
+ public static Root getCurrent() {
return currentRoot.get();
}
}
public void testApplicationConverterFactoryInBackgroundThread() {
- Application.setCurrentApplication(null);
+ Application.setCurrent(null);
final Application appWithCustomIntegerConverter = new Application();
appWithCustomIntegerConverter
.setConverterFactory(new ConverterFactory42());
final Application appWithCustomIntegerConverter = new Application();
appWithCustomIntegerConverter
.setConverterFactory(new ConverterFactory42());
- Application.setCurrentApplication(appWithCustomIntegerConverter);
+ Application.setCurrent(appWithCustomIntegerConverter);
TextField tf = new TextField("", "123");
tf.setConverter(Integer.class);
final Application fieldAppWithCustomIntegerConverter = new Application();
fieldAppWithCustomIntegerConverter
.setConverterFactory(new ConverterFactory42());
- Application.setCurrentApplication(new Application());
+ Application.setCurrent(new Application());
TextField tf = new TextField("", "123") {
@Override
public void testNumberDoubleConverterChange() {
final Application a = new Application();
- Application.setCurrentApplication(a);
+ Application.setCurrent(a);
TextField tf = new TextField() {
@Override
public Application getApplication() {
public void testDefaultNumberConversion() {
Application app = new Application();
- Application.setCurrentApplication(app);
+ Application.setCurrent(app);
TextField tf = new TextField();
tf.setLocale(new Locale("en", "US"));
tf.setPropertyDataSource(new MethodProperty<Integer>(paulaBean,
}
public void testIntegerDataSource() {
- Application.setCurrentApplication(new Application());
+ Application.setCurrent(new Application());
Label l = new Label("Foo");
Property ds = new MethodProperty<Integer>(Person.createTestPerson1(),
"age");
public void buttonClick(ClickEvent event) {
final ExternalResource r = new ExternalResource(
"http://www.google.com");
- Root.getCurrentRoot().getPage().open(r);
+ Root.getCurrent().getPage().open(r);
}
public void buttonClick(ClickEvent event) {
final ExternalResource r = new ExternalResource(
"http://www.google.com");
- Root.getCurrentRoot().getPage().open(r, "mytarget");
+ Root.getCurrent().getPage().open(r, "mytarget");
}
public void buttonClick(ClickEvent event) {
final ExternalResource r = new ExternalResource(
"http://www.google.com");
- Root.getCurrentRoot().getPage().open(r, "secondtarget");
+ Root.getCurrent().getPage().open(r, "secondtarget");
}
w.addComponent(s);
- Root.getCurrentRoot().addWindow(w);
+ Root.getCurrent().addWindow(w);
}
public class ThreadLocalInstances extends AbstractTestApplication {
private static final Application staticInitApplication = Application
- .getCurrentApplication();
- private static final Root staticInitRoot = Root.getCurrentRoot();
+ .getCurrent();
+ private static final Root staticInitRoot = Root.getCurrent();
private final Root mainWindow = new Root() {
boolean paintReported = false;
}
private void reportCurrentStatus(String phase) {
- reportStatus(phase, Application.getCurrentApplication(),
- Root.getCurrentRoot());
+ reportStatus(phase, Application.getCurrent(),
+ Root.getCurrent());
}
private void reportStatus(String phase, Application application, Root root) {
protected abstract Integer getTicketNumber();
protected WebBrowser getBrowser() {
- ApplicationContext context = Application.getCurrentApplication()
+ ApplicationContext context = Application.getCurrent()
.getContext();
if (context instanceof AbstractWebApplicationContext) {
AbstractWebApplicationContext webContext = (AbstractWebApplicationContext) context;
helloButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
String msg = "Running in ";
- msg += Application.getCurrentApplication().isProductionMode() ? "production"
+ msg += Application.getCurrent().isProductionMode() ? "production"
: "debug";
msg += " mode in a Root with the caption "
- + Root.getCurrentRoot().getCaption();
+ + Root.getCurrent().getCaption();
Notification.show(msg);
}