List of usage examples for org.apache.wicket Session getAttribute
public final Serializable getAttribute(final String name)
From source file:almira.sample.web.AdminPage.java
License:Apache License
/** * Constructor./*w w w . ja v a2 s.c om*/ */ public AdminPage() { super(); final Label counterLabel = new Label(COUNTER_LABEL_ID, "0"); add(counterLabel); final Label feedbackLabel = new Label(FEEDBACK_LABEL_ID); add(feedbackLabel); add(new Link<String>("increment_counter_link") { @Override public void onClick() { final Session session = AdminPage.this.getSession(); int counterValue = 0; synchronized (session) { AtomicInteger counter = (AtomicInteger) session.getAttribute(COUNTER_LABEL_ID); if (counter == null) { counter = new AtomicInteger(); } counterValue = counter.incrementAndGet(); // trigger replication to other cluster nodes session.setAttribute(COUNTER_LABEL_ID, counter); } counterLabel.setDefaultModel(new Model<Integer>(counterValue)); LOG.fine("*** Catapult counter value=" + counterValue + " ***"); feedbackLabel.setDefaultModel(new Model<String>()); } }); add(new Link<String>("rebuild_index") { @Override public void onClick() { try { indexService.rebuildIndex(); feedbackLabel.setDefaultModel(new Model<String>("Rebuilding index.")); } catch (Exception e) { feedbackLabel.setDefaultModel(new Model<String>("Error rebuilding index!")); LOG.log(Level.SEVERE, "Error rebuilding", e); } } }); }
From source file:com.przemo.projectmanagementweb.helpers.ApplicationHelper.java
public static boolean isUserLoggedIn(Session session) { return session.getAttribute(LoginService.USER_ATTRIBUTE) != null; }
From source file:com.przemo.projectmanagementweb.helpers.ApplicationHelper.java
public static Date lastLogin(Session session) { return (Date) session.getAttribute(LAST_LOGIN); }
From source file:org.ujorm.hotels.services.impl.AuthServiceImpl.java
License:Apache License
/** Get current customer from session */ @Override// w w w .j ava 2 s . c o m public Customer getCurrentCustomer() { Session session = getThreadSession(); Object result = session != null ? session.getAttribute(CUSTOMER_ATTR) : null; return result instanceof Customer ? (Customer) result : null; }