Example usage for org.apache.wicket.request.cycle RequestCycle setMetaData

List of usage examples for org.apache.wicket.request.cycle RequestCycle setMetaData

Introduction

In this page you can find the example usage for org.apache.wicket.request.cycle RequestCycle setMetaData.

Prototype

public final <T> RequestCycle setMetaData(final MetaDataKey<T> key, final T object) 

Source Link

Document

Sets the metadata for this request cycle using the given key.

Usage

From source file:at.molindo.wicketutils.utils.RequestCycleCache.java

License:Apache License

public static <K, V> void put(final RequestCycle cycle, final MetaDataKey<Pair<K, V>> metaDataKey, final K key,
        final V value) {
    if (metaDataKey == null) {
        throw new NullPointerException("metaDataKey");
    }//from w w  w. j  a v a 2 s . c o m
    if (key == null) {
        throw new NullPointerException("key");
    }

    cycle.setMetaData(metaDataKey, Pair.pair(key, value));
}

From source file:com.github.javawithmarcus.wicket.cdi.DetachEventEmitter.java

License:Apache License

@Override
public void onRequestHandlerResolved(RequestCycle cycle, IRequestHandler handler) {
    // this is a wicket request, schedule detach event to be fired

    cycle.setMetaData(DETACH_SCHEDULED_KEY, true);
}

From source file:com.github.javawithmarcus.wicket.cdi.DetachEventEmitter.java

License:Apache License

@Override
public void onDetach(RequestCycle cycle) {
    if (Boolean.TRUE.equals(cycle.getMetaData(DETACH_SCHEDULED_KEY))) {
        logger.debug("Firing Detach event {}", cycle.getRequest().getUrl());

        detachEvent.fire(new DetachEvent());

        cycle.setMetaData(DETACH_SCHEDULED_KEY, null);
    }//from   w w w.  j  a v a2s  . c  o m
}

From source file:com.wyndhamjade.util.wicket.newrelic.NewRelicRequestCycleListener.java

License:Apache License

@Override
public void onBeginRequest(final RequestCycle cycle) {
    cycle.setMetaData(FIRST_HANDLER, true);
    final Session session = Session.get();
    if (session != null && session instanceof NewRelicSessionSupport) {
        final NewRelicSessionSupport sessionInfo = (NewRelicSessionSupport) session;
        NewRelic.setUserName(sessionInfo.getUserName());
        NewRelic.setAccountName(sessionInfo.getAccountName());
    }// w ww  .jav a  2s . c o m
}

From source file:com.wyndhamjade.util.wicket.newrelic.NewRelicRequestCycleListener.java

License:Apache License

@Override
public void onRequestHandlerResolved(final RequestCycle cycle, final IRequestHandler handler) {
    if (cycle.getMetaData(FIRST_HANDLER)) {
        cycle.setMetaData(FIRST_HANDLER, false);

        final StringBuilder s = new StringBuilder();

        if (handler instanceof IComponentRequestHandler) {
            final IRequestableComponent c = ((IComponentRequestHandler) handler).getComponent();
            s.append('/');
            s.append(pageClassToPath(c.getPage().getClass()));
            s.append('/');
            s.append(componentToPath(c));
        } else if (handler instanceof IPageClassRequestHandler) {
            s.append('/');
            s.append(pageClassToPath(((IPageClassRequestHandler) handler).getPageClass()));
        } else {/*from  w  w w.  j  ava 2  s .  c  om*/
            NewRelic.ignoreTransaction();
            return;
        }

        NewRelic.setTransactionName(null, s.toString());
    }
}

From source file:org.brixcms.web.BrixRequestCycleProcessor.java

License:Apache License

public String getWorkspace() {
    String workspace = getWorkspaceFromUrl();

    if (workspace != null) {
        return workspace;
    }/*from www. j a v  a2  s.co m*/

    RequestCycle rc = RequestCycle.get();
    workspace = rc.getMetaData(WORKSPACE_METADATA);
    if (workspace == null) {
        WebRequest req = (WebRequest) RequestCycle.get().getRequest();
        WebResponse resp = (WebResponse) RequestCycle.get().getResponse();
        Cookie cookie = req.getCookie(COOKIE_NAME);
        workspace = getDefaultWorkspaceName();
        if (cookie != null) {
            if (cookie.getValue() != null)
                workspace = cookie.getValue();
        }
        if (!checkSession(workspace)) {
            workspace = getDefaultWorkspaceName();
        }
        if (workspace == null) {
            throw new IllegalStateException("Could not resolve jcr workspace to use for this request");
        }
        Cookie c = new Cookie(COOKIE_NAME, workspace);
        c.setPath("/");
        if (workspace.toString().equals(getDefaultWorkspaceName()) == false)
            resp.addCookie(c);
        else if (cookie != null)
            resp.clearCookie(cookie);
        rc.setMetaData(WORKSPACE_METADATA, workspace);
    }
    return workspace;
}

From source file:org.brixcms.web.BrixRequestMapper.java

License:Apache License

public String getWorkspace() {
    String workspace = getWorkspaceFromUrl();

    if (workspace != null) {
        return workspace;
    }/* ww w .j  a  v a 2 s.  c  o  m*/

    RequestCycle rc = RequestCycle.get();
    workspace = rc.getMetaData(WORKSPACE_METADATA);
    if (workspace == null) {
        WebRequest req = (WebRequest) RequestCycle.get().getRequest();
        WebResponse resp = (WebResponse) RequestCycle.get().getResponse();
        Cookie cookie = req.getCookie(COOKIE_NAME);
        workspace = getDefaultWorkspaceName();
        if (cookie != null) {
            if (cookie.getValue() != null) {
                workspace = cookie.getValue();
            }
        }
        if (!checkSession(workspace)) {
            workspace = getDefaultWorkspaceName();
        }
        if (workspace == null) {
            throw new IllegalStateException("Could not resolve jcr workspace to use for this request");
        }
        Cookie c = new Cookie(COOKIE_NAME, workspace);
        c.setPath("/");
        if (workspace.toString().equals(getDefaultWorkspaceName()) == false) {
            resp.addCookie(c);
        } else if (cookie != null) {
            resp.clearCookie(cookie);
        }
        rc.setMetaData(WORKSPACE_METADATA, workspace);
    }
    return workspace;
}

From source file:org.brixcms.workspace.WorkspaceUtils.java

License:Apache License

public static String getWorkspace() {
    String workspace = getWorkspaceFromUrl();

    if (workspace != null) {
        return workspace;
    }//from w  w  w .  j  a v a2s.  co m

    RequestCycle rc = RequestCycle.get();
    workspace = rc.getMetaData(WORKSPACE_METADATA);
    if (workspace == null) {
        WebRequest req = (WebRequest) RequestCycle.get().getRequest();
        WebResponse resp = (WebResponse) RequestCycle.get().getResponse();
        Cookie cookie = req.getCookie(COOKIE_NAME);
        workspace = getDefaultWorkspaceName();
        if (cookie != null) {
            if (cookie.getValue() != null)
                workspace = cookie.getValue();
        }
        if (!checkSession(workspace)) {
            workspace = getDefaultWorkspaceName();
        }
        if (workspace == null) {
            throw new IllegalStateException("Could not resolve jcr workspace to use for this request");
        }
        Cookie c = new Cookie(COOKIE_NAME, workspace);
        c.setPath("/");
        if (workspace.toString().equals(getDefaultWorkspaceName()) == false)
            resp.addCookie(c);
        else if (cookie != null)
            resp.clearCookie(cookie);
        rc.setMetaData(WORKSPACE_METADATA, workspace);
    }
    return workspace;
}

From source file:org.wicketstuff.jamon.request.cycle.JamonMonitoredRequestCycleContext.java

License:Apache License

public static void registerTo(RequestCycle cycle, boolean includeSourceNameInMonitorLabel) {
    RequestCycle requestCycle = cycle == null ? RequestCycle.get() : cycle;
    requestCycle.setMetaData(JamonMonitoredRequestCycleContextKey.KEY,
            new JamonMonitoredRequestCycleContext(includeSourceNameInMonitorLabel));
}