List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:at.molindo.wicketutils.utils.WicketUtils.java
License:Apache License
public static IRequestHandler getRequestHandler(final URL url) { if (url != null) { MockWebRequest request = new MockWebRequest(Url.parse(url.toString())); return Application.get().getRootRequestMapper().mapRequest(request); } else {//from w w w.j a va 2s.co m return null; } }
From source file:at.molindo.wicketutils.utils.WicketUtils.java
License:Apache License
public static boolean isDeployment() { return RuntimeConfigurationType.DEPLOYMENT.equals(Application.get().getConfigurationType()); }
From source file:at.molindo.wicketutils.utils.WicketUtils.java
License:Apache License
/** * replacement for {@link Classes}.resolveClass(String) * //from w ww . ja v a 2s .com * @param <T> * class type * @param className * Class to resolve * @return Resolved class */ @SuppressWarnings("unchecked") public static <T> Class<T> resolveClass(final String className) { if (className == null) { return null; } try { if (Application.exists()) { return (Class<T>) Application.get().getApplicationSettings().getClassResolver() .resolveClass(className); } return (Class<T>) Class.forName(className); } catch (ClassNotFoundException e) { log.warn("Could not resolve class: " + className); return null; } }
From source file:br.com.ieptbto.cra.security.UserRoleAuthorizationStrategy.java
License:Open Source License
@Override public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) { for (IAuthorizationStrategy strategy : strategies) { if (strategy.isInstantiationAuthorized(componentClass) == false) { ISecureApplication app = (ISecureApplication) Application.get(); throw new RestartResponseAtInterceptPageException(app.getLoginPage()); }//from w w w . j a va 2s . co m } return true; }
From source file:br.com.ieptbto.cra.security.UserRoleAuthorizationStrategy.java
License:Open Source License
@Override public boolean isActionAuthorized(Component component, Action action) { for (IAuthorizationStrategy strategy : strategies) { if (strategy.isActionAuthorized(component, action) == false) { // Essa parte do codigo foi alterada para sempre redirecionar // para pagina de login quando nao for autorizado. // return true (codigo original) ISecureApplication app = (ISecureApplication) Application.get(); PageParameters parameters = new PageParameters(); parameters.add("error", ErroValidacao.SEM_PERMISSAO_DE_ACESSO_A_PAGINA.getMensagemErro()); throw new RestartResponseAtInterceptPageException(app.getHomePage(), parameters); }/*from ww w . j a v a2 s . c o m*/ } return true; }
From source file:bugs.HttpSessionStoreModified.java
License:Apache License
/** * @see org.apache.wicket.session.ISessionStore#bind(Request, Session) *//*from w w w . j a va2 s . c o m*/ @Override public final void bind(final Request request, final Session newSession) { if (getAttribute(request, Session.SESSION_ATTRIBUTE_NAME) != newSession) { // call template method onBind(request, newSession); for (BindListener listener : getBindListeners()) { listener.bindingSession(request, newSession); } HttpSession httpSession = getHttpSession(request, false); if (httpSession != null) { // register an unbinding listener for cleaning up String applicationKey = Application.get().getName(); httpSession.setAttribute("Wicket:SessionUnbindingListener-" + applicationKey, new SessionBindingListener(applicationKey, newSession)); // register the session object itself setAttribute(request, Session.SESSION_ATTRIBUTE_NAME, newSession); } } }
From source file:bugs.HttpSessionStoreModified.java
License:Apache License
/** * @see org.apache.wicket.session.ISessionStore#getSessionId(org.apache.wicket.request.Request, * boolean)/*from ww w .ja va2 s . co m*/ */ @Override public String getSessionId(final Request request, final boolean create) { String id = null; HttpSession httpSession = getHttpSession(request, false); if (httpSession != null) { id = httpSession.getId(); } else if (create) { httpSession = getHttpSession(request, true); id = httpSession.getId(); IRequestLogger logger = Application.get().getRequestLogger(); if (logger != null) { logger.sessionCreated(id); } } return id; }
From source file:bugs.HttpSessionStoreModified.java
License:Apache License
/** * @see org.apache.wicket.session.ISessionStore#removeAttribute(org.apache.wicket.request.Request, * java.lang.String)/*from w w w . j av a2 s .com*/ */ @Override public final void removeAttribute(final Request request, final String name) { HttpSession httpSession = getHttpSession(request, false); if (httpSession != null) { String attributeName = getSessionAttributePrefix(request) + name; IRequestLogger logger = Application.get().getRequestLogger(); if (logger != null) { Object value = httpSession.getAttribute(attributeName); if (value != null) { logger.objectRemoved(value); } } httpSession.removeAttribute(attributeName); } }
From source file:bugs.HttpSessionStoreModified.java
License:Apache License
/** * @see org.apache.wicket.session.ISessionStore#setAttribute(org.apache.wicket.request.Request, * java.lang.String, java.io.Serializable) */// w w w . j av a2 s .c o m @Override public final void setAttribute(final Request request, final String name, final Serializable value) { // ignore call if the session was marked invalid HttpSession httpSession = getHttpSession(request, false); if (httpSession != null) { String attributeName = getSessionAttributePrefix(request) + name; IRequestLogger logger = Application.get().getRequestLogger(); if (logger != null) { if (httpSession.getAttribute(attributeName) == null) { logger.objectCreated(value); } else { logger.objectUpdated(value); } } setValueInternal(httpSession, value, attributeName); } }
From source file:codetroopers.wicket.HotReloadingClassResolver.java
License:Apache License
@Override public Iterator<URL> getResources(final String name) { Set<URL> resultSet = new TreeSet<URL>(new UrlExternalFormComparator()); try {// w ww . java2s.co m // Try the classloader for the wicket jar/bundle Enumeration<URL> resources = Application.class.getClassLoader().getResources(name); loadResources(resources, resultSet); // Try the classloader for the user's application jar/bundle resources = Application.get().getClass().getClassLoader().getResources(name); loadResources(resources, resultSet); // Try the context class loader resources = getClassLoader().getResources(name); loadResources(resources, resultSet); } catch (Exception e) { throw new WicketRuntimeException(e); } return resultSet.iterator(); }