当前位置: 首页>>代码示例>>Java>>正文


Java WebContextFactory.get方法代码示例

本文整理汇总了Java中org.directwebremoting.WebContextFactory.get方法的典型用法代码示例。如果您正苦于以下问题:Java WebContextFactory.get方法的具体用法?Java WebContextFactory.get怎么用?Java WebContextFactory.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.directwebremoting.WebContextFactory的用法示例。


在下文中一共展示了WebContextFactory.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUsersToAffect

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * @return The collection of people to affect
 */
private Collection getUsersToAffect()
{
    WebContext wctx = WebContextFactory.get();
    String currentPage = wctx.getCurrentPage();

    // For all the browsers on the current page:
    Collection sessions = wctx.getScriptSessionsByPage(currentPage);

    // But not the current user!
    sessions.remove(wctx.getScriptSession());

    log.debug("Affecting " + sessions.size() + " users");

    return sessions;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:LiveHelp.java

示例2: generateId

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * Generates and returns a new unique id suitable to use for the
 * CSRF session cookie. This method is itself exempted from CSRF checking.
 */
public String generateId()
{
    WebContext webContext = WebContextFactory.get();

    // If the current session already has a set DWRSESSIONID then we return that
    HttpServletRequest request = webContext.getHttpServletRequest();
    HttpSession sess = request.getSession(false);
    if (sess != null && sess.getAttribute(ATTRIBUTE_DWRSESSIONID) != null)
    {
        return (String) sess.getAttribute(ATTRIBUTE_DWRSESSIONID);
    }

    // Otherwise generate a fresh ID
    IdGenerator idGenerator = webContext.getContainer().getBean(IdGenerator.class);
    return idGenerator.generate();
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:21,代码来源:System.java

示例3: getNowPlayingForCurrentPlayer

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * Returns details about what the current player is playing.
 *
 * @return Details about what the current player is playing, or <code>null</code> if not playing anything.
 */
public NowPlayingInfo getNowPlayingForCurrentPlayer() throws Exception {
    WebContext webContext = WebContextFactory.get();
    Player player = playerService.getPlayer(webContext.getHttpServletRequest(), webContext.getHttpServletResponse());

    for (NowPlayingInfo info : getNowPlaying()) {
        if (player.getId().equals(info.getPlayerId())) {
            return info;
        }
    }
    return null;
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:17,代码来源:NowPlayingService.java

示例4: convertInbound

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
public Object convertInbound(Class paramType, InboundVariable iv, InboundContext inctx)
{
    WebContext webcx = WebContextFactory.get();

    if (HttpServletRequest.class.isAssignableFrom(paramType))
    {
        return webcx.getHttpServletRequest();
    }

    if (HttpServletResponse.class.isAssignableFrom(paramType))
    {
        return webcx.getHttpServletResponse();
    }

    if (ServletConfig.class.isAssignableFrom(paramType))
    {
        return webcx.getServletConfig();
    }

    if (ServletContext.class.isAssignableFrom(paramType))
    {
        return webcx.getServletContext();
    }

    if (HttpSession.class.isAssignableFrom(paramType))
    {
        return webcx.getSession(true);
    }

    return null;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:32,代码来源:ServletConverter.java

示例5: Publisher

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * Create a new publish thread and start it
 */
public Publisher()
{
    WebContext webContext = WebContextFactory.get();
    ServletContext servletContext = webContext.getServletContext();

    serverContext = ServerContextFactory.get(servletContext);

    // A bit nasty: the call to serverContext.getScriptSessionsByPage()
    // below could fail because the system might need to read web.xml which
    // means it needs a ServletContext, which is only available  using
    // WebContext, which in turn requires a DWR thread. We can cache the
    // results simply by calling this in a DWR thread, as we are now.
    webContext.getScriptSessionsByPage("");

    synchronized (Publisher.class)
    {
        if (worker == null)
        {
            worker = new Thread(this, "Publisher");
            worker.start();
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:Publisher.java

示例6: execute

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
@Override
	public Replies execute(Calls calls) {
		WebContext webContext=WebContextFactory.get();
		
		String uri = webContext.getHttpServletRequest().getRequestURI();
		if(uri.indexOf("__System.pageLoaded")>-1||uri.indexOf("LoginService.adminLogin")>-1
							||uri.indexOf("LoginService.merUserLogin")>-1){
			return super.execute(calls);
		}
		HttpSession session = webContext.getSession(false);
//		String page=webContext.getCurrentPage();
		if (session == null) {
			logOut();
			return super.execute(new Calls());
		}
		return super.execute(calls);
	}
 
开发者ID:wufeisoft,项目名称:ryf_mms2,代码行数:18,代码来源:MyDWRRemoter.java

示例7: subscribe

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * Ensure that the clients know about server publishes
 * @param topic The topic being subscribed to
 * @param subscriptionId The ID to pass back to link to client side data
 */
@SuppressWarnings("unchecked")
public void subscribe(String topic, String subscriptionId)
{
    WebContext webContext = WebContextFactory.get();
    Hub hub = HubFactory.get();
    final ScriptSession session = webContext.getScriptSession();

    // Create a subscription block
    BrowserMessageListener subscription = new BrowserMessageListener(session, topic, subscriptionId);

    Map<String, BrowserMessageListener> subscriptions = (Map<String, BrowserMessageListener>) session.getAttribute(ATTRIBUTE_SUBSCRIPTIONS);
    if (subscriptions == null)
    {
        subscriptions = new HashMap<String, BrowserMessageListener>();
    }
    subscriptions.put(subscriptionId, subscription);
    session.setAttribute(ATTRIBUTE_SUBSCRIPTIONS, subscriptions);

    hub.subscribe(subscription.topic, subscription);
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:26,代码来源:System.java

示例8: get

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
public ServerContext get()
{
    ServerContext serverContext = WebContextFactory.get();
    if (serverContext == null)
    {
        // If not see if there is a singleton
        serverContext = StartupUtil.getSingletonServerContext();
        if (serverContext == null)
        {
            log.fatal("Error initializing ServerContext because this is not a DWR thread and there is more than one DWR servlet in the current classloader.");
            log.fatal("This probably means that either DWR has not been properly initialized (in which case you should delay the current action until it has)");
            log.fatal("or that there is more than 1 DWR servlet is configured in this classloader, in which case you should provide a ServletContext to the get() yourself.");
            throw new IllegalStateException("No singleton ServerContext see logs for possible causes and solutions.");
        }
    }

    return serverContext;
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:19,代码来源:DefaultServerContextBuilder.java

示例9: get

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * Accessor for the current ExecutionContext.
 * @return The current ExecutionContext or null if the current thread was
 * not started by DWR.
 * @deprecated Use WebContextFactory.get() for better results
 */
public static ExecutionContext get()
{
    WebContext context = WebContextFactory.get();
    if (context == null)
    {
        return null;
    }

    return new ExecutionContext(context);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:ExecutionContext.java

示例10: addMessage

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * @param text The new message text to add
 */
public void addMessage(String text)
{
    // Make sure we have a list of the list 10 messages
    if (text != null && text.trim().length() > 0)
    {
        messages.addFirst(new Message(text));
        while (messages.size() > 10)
        {
            messages.removeLast();
        }
    }

    WebContext wctx = WebContextFactory.get();
    String currentPage = wctx.getCurrentPage();

    // Clear the input box in the browser that kicked off this page only
    Util utilThis = new Util(wctx.getScriptSession());
    utilThis.setValue("text", "");

    // For all the browsers on the current page:
    Collection sessions = wctx.getScriptSessionsByPage(currentPage);
    Util utilAll = new Util(sessions);

    // Clear the list and add in the new set of messages
    utilAll.removeAllOptions("chatlog");
    utilAll.addOptions("chatlog", messages, "text");
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:JavaChat.java

示例11: addMessage

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * @param text The new message text to add
 */
public void addMessage(String text)
{
    if (text != null && text.trim().length() > 0)
    {
        messages.addFirst(new Message(text));
        while (messages.size() > 10)
        {
            messages.removeLast();
        }
    }

    WebContext wctx = WebContextFactory.get();
    String currentPage = wctx.getCurrentPage();

    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("receiveMessages(")
          .appendData(messages)
          .appendScript(");");

    // Loop over all the users on the current page
    Collection pages = wctx.getScriptSessionsByPage(currentPage);
    for (Iterator it = pages.iterator(); it.hasNext();)
    {
        ScriptSession otherSession = (ScriptSession) it.next();
        otherSession.addScript(script);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:JavascriptChat.java

示例12: getServletContext

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * Gets the servlet context from the current web context, if one exists,
 * otherwise gets it from the thread-local stash.
 */
static ServletContext getServletContext()
{
    WebContext webcx = WebContextFactory.get();
    if (webcx != null)
    {
        return webcx.getServletContext();
    }
    else
    {
        return servletContexts.get().getFirst();
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:DwrGuiceUtil.java

示例13: saveOperLog

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
public int saveOperLog(String action, String action_desc) {
	try {
		WebContext webContext = WebContextFactory.get();
		HttpServletRequest request = null;
		if(webContext != null)
			request = webContext.getHttpServletRequest();
		return saveOperLog(action, action_desc, request);
	} catch (Exception e) {
		logger.error(e.getMessage());
		return 0;
	}
}
 
开发者ID:wufeisoft,项目名称:ryf_mms2,代码行数:13,代码来源:PubDao.java

示例14: querySql4Special

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * 判断是否为管理员
 * @return
 */
public String querySql4Special() {
	String sql = "select * from  hlog  where ";
	WebContext wc = WebContextFactory.get();
	HttpSession hs = wc.getSession();
	String loginMid =hs.getAttribute(WebConstants.SESSION_LOGGED_ON_MID).toString();
	if (!"1".equals(loginMid)) {
		sql += " mid = '" + loginMid + "' and ";
	}
	return sql;
}
 
开发者ID:wufeisoft,项目名称:ryf_mms2,代码行数:15,代码来源:TransactionDao.java

示例15: getServletContext

import org.directwebremoting.WebContextFactory; //导入方法依赖的package包/类
/**
 * Gets the servlet context from the thread-local stash, if any,
 * otherwise from the current web context, if one exists,
 * otherwise from the singleton server context, if it exists,
 * otherwise from the first of all server contexts, if there are any,
 * otherwise null.
 */
public static ServletContext getServletContext()
{
    LinkedList<ServletContext> sclist = servletContexts.get();
    if (!sclist.isEmpty())
    {
        return sclist.getFirst();
    }

    WebContext webcx = WebContextFactory.get();
    if (webcx != null)
    {
        return webcx.getServletContext();
    }

    ServerContext serverContext = StartupUtil.getSingletonServerContext();
    if (serverContext != null)
    {
        return serverContext.getServletContext();
    }

    for (ServerContext sc : StartupUtil.getAllServerContexts())
    {
        // Use the ServletContext of the first ServerContext we see.
        return sc.getServletContext();
    }

    return null;
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:36,代码来源:DwrGuiceUtil.java


注:本文中的org.directwebremoting.WebContextFactory.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。