Java Code Examples for org.apache.wicket.Application#get()

The following examples show how to use org.apache.wicket.Application#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApplicationHelper.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
public static IApplication ensureApplication() {
	if (Application.exists()) {
		return (IApplication)Application.get();
	}
	synchronized (SYNC_OBJ) {
		if (Application.exists()) {
			return (IApplication)Application.get();
		}
		WebApplication app = createApp((WebApplication)Application.get(getWicketApplicationName()));
		LabelDao.initLanguageMap();
		if (app != null) {
			if (!isInitComplete()) {
				initApp(app);
			}
			ThreadContext.setApplication(app);
		}
		return (IApplication)Application.get(getWicketApplicationName());
	}
}
 
Example 2
Source File: ApplicationHelper.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
public static void destroyApplication() {
	WebApplication app = (WebApplication)Application.get(getWicketApplicationName());
	WebApplicationContext ctx = getWebApplicationContext(app.getServletContext());
	app.internalDestroy(); //need to be called too
	if (ctx != null) {
		((XmlWebApplicationContext)ctx).close();
	}
	ThreadContext.setApplication(null);
	ThreadContext.setRequestCycle(null);
	ThreadContext.setSession(null);
}
 
Example 3
Source File: TestAdmin.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
	resetH2Home();
	System.getProperties().remove(OM_HOME);
	WebApplication app = (WebApplication)Application.get(getWicketApplicationName());
	if (app != null) {
		destroyApplication();
		setInitComplete(false);
	}
	System.setProperty("context", DEFAULT_CONTEXT_NAME);
	setWicketApplicationName(DEFAULT_CONTEXT_NAME);
	deleteQuietly(tempFolder);
}
 
Example 4
Source File: WebSocketMessageSenderDefault.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void send(IWebSocketPushMessage event) {
	Application application = Application.get(WicketWebInitializer.WICKET_FILTERNAME);
	WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application);
	IWebSocketConnectionRegistry connectionRegistry = webSocketSettings.getConnectionRegistry();
	Collection<IWebSocketConnection> connections = connectionRegistry.getConnections(application);
	log.trace("sending event to {} connections", connections.size());
	for (IWebSocketConnection connection : connections) {
		connection.sendMessage(event);
	}
}
 
Example 5
Source File: OrientDbWebApplication.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
protected static <T extends OrientDbWebApplication> T lookupApplication(Class<T> appClass)
{
	Application app = Application.exists()?Application.get():null;
	if(app!=null && appClass.isInstance(app)) return (T)app;
	else
	{
		for(String appKey: Application.getApplicationKeys())
		{
			app = Application.get(appKey);
			if(appClass.isInstance(app)) return (T)app;
		}
	}
	return null;
}
 
Example 6
Source File: WicketApplicationFilter.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException
{
  // Sollte eigentlich immer NULL ergeben, aber man weiss nie ...
  final Application previousOne = (Application.exists() == true) ? Application.get() : null;
  org.apache.wicket.ThreadContext.setApplication(this.application);
  try {
    chain.doFilter(request, response);
  } finally {
    if (previousOne != null) {
      org.apache.wicket.ThreadContext.setApplication(previousOne);
    } else {
      org.apache.wicket.ThreadContext.setApplication(null);
    }
  }
}
 
Example 7
Source File: OneWebApplication.java    From onedev with MIT License 4 votes vote down vote up
public static OneWebApplication get() {
	return (OneWebApplication) Application.get();
}
 
Example 8
Source File: EmailManager.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
private static IApplication getApp() {
	return (IApplication)Application.get(getWicketApplicationName());
}
 
Example 9
Source File: WebSocketHelper.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
public static IApplication getApp() {
	return (IApplication)Application.get(getWicketApplicationName());
}
 
Example 10
Source File: OntopolyContext.java    From ontopia with Apache License 2.0 4 votes vote down vote up
public static OntopolyRepository getOntopolyRepository() {
  OntopolyApplication app = (OntopolyApplication)Application.get();
  return app.getOntopolyRepository();
}
 
Example 11
Source File: OntopolyContext.java    From ontopia with Apache License 2.0 4 votes vote down vote up
public static TopicMap getTopicMap(String topicMapId) {
  OntopolyApplication app = (OntopolyApplication)Application.get();
  return app.getTopicMap(topicMapId);
}
 
Example 12
Source File: OntopolyContext.java    From ontopia with Apache License 2.0 4 votes vote down vote up
public static LockManager getLockManager() {
  OntopolyApplication app = (OntopolyApplication)Application.get();
  return app.getLockManager();
}
 
Example 13
Source File: TopologyWebSocketBehavior.java    From syncope with Apache License 2.0 4 votes vote down vote up
ConnCheck(final String key) {
    this.key = key;
    this.application = Application.get();
    this.session = Session.exists() ? Session.get() : null;
}
 
Example 14
Source File: TopologyWebSocketBehavior.java    From syncope with Apache License 2.0 4 votes vote down vote up
ResCheck(final String key) {
    this.key = key;
    this.application = Application.get();
    this.session = Session.exists() ? Session.get() : null;
}
 
Example 15
Source File: AjaxWizard.java    From syncope with Apache License 2.0 4 votes vote down vote up
ApplyFuture(final AjaxRequestTarget target) {
    this.target = target;
    this.application = Application.get();
    this.requestCycle = RequestCycle.get();
    this.session = Session.exists() ? Session.get() : null;
}
 
Example 16
Source File: LoginPage.java    From oodt with Apache License 2.0 4 votes vote down vote up
public LoginPage(PageParameters parameters) {
  super();
  final CurationApp app = (CurationApp)Application.get();
  final CurationSession session = (CurationSession)getSession();
  String ssoClass = app.getSSOImplClass();
  final AbstractWebBasedSingleSignOn sso = SingleSignOnFactory
      .getWebBasedSingleSignOn(ssoClass);
  sso.setReq(((WebRequest) RequestCycle.get().getRequest())
      .getHttpServletRequest());
  sso.setRes(((WebResponse) RequestCycle.get().getResponse())
      .getHttpServletResponse());
  
  String action = parameters.getString("action");
  String appNameString = app.getProjectName()+" CAS Curation Interface";
  add(new Label("login_project_name", appNameString));
  replace(new Label("crumb_name", "Login"));
  final WebMarkupContainer creds = new WebMarkupContainer("invalid_creds");
  final WebMarkupContainer connect = new WebMarkupContainer("connect_error");
  creds.setVisible(false);
  connect.setVisible(false);
  final TextField<String> loginUser = new TextField<String>("login_username", new Model<String>(""));
  final PasswordTextField pass = new PasswordTextField("password", new Model<String>(""));
  
  
  Form<?> form = new Form<Void>("login_form"){

    private static final long serialVersionUID = 1L;
    
    @Override
    protected void onSubmit() {
      String username = loginUser.getModelObject();
      String password = pass.getModelObject();
      
      if(sso.login(username, password)){
        session.setLoggedIn(true);
        session.setLoginUsername(username);
        setResponsePage(WorkbenchPage.class);
      }
      else{
        session.setLoggedIn(false);
        if (session.getLoginUsername() == null){
          connect.setVisible(true);
        }
        else{
          creds.setVisible(true);
        }
      }
      
    }
    
  };
  
  form.add(loginUser);
  form.add(pass);
  form.add(creds);
  form.add(connect);
  add(form);
  
  if(action.equals("logout")){
    sso.logout();
    session.setLoginUsername(null);
    session.setLoggedIn(false);
    PageParameters params = new PageParameters();
    params.add("action", "login");
    setResponsePage(LoginPage.class, params);
  }

}