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


Java WebContextFactory类代码示例

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


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

示例1: doFilter

import org.directwebremoting.WebContextFactory; //导入依赖的package包/类
public Object doFilter(Object object, Method method, Object[] params, AjaxFilterChain chain) throws Exception
{
    ServletContext context = WebContextFactory.get().getServletContext();
    SessionFactory sessionFactory = (SessionFactory) context.getAttribute(ATTRIBUTE_SESSION);

    Transaction transaction = null;
    if (sessionFactory != null)
    {
        Session session = sessionFactory.getCurrentSession();
        transaction = session.beginTransaction();
    }
    else
    {
        log.error("SessionFactory not initialized for this web application. Use: H3SessionAjaxFilter.setSessionFactory(servletContext, sessionFactory);");
    }

    Object reply = chain.doFilter(object, method, params);

    if (transaction != null)
    {
        transaction.commit();
    }

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

示例2: 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

示例3: 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

示例4: 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

示例5: createEmptyPlaylist

import org.directwebremoting.WebContextFactory; //导入依赖的package包/类
public List<Playlist> createEmptyPlaylist() {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    Locale locale = localeResolver.resolveLocale(request);
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale);

    Date now = new Date();
    Playlist playlist = new Playlist();
    playlist.setUsername(securityService.getCurrentUsername(request));
    playlist.setCreated(now);
    playlist.setChanged(now);
    playlist.setShared(false);
    playlist.setName(dateFormat.format(now));

    playlistService.createPlaylist(playlist);
    return getReadablePlaylists();
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:17,代码来源:PlaylistService.java

示例6: createPlaylistForStarredSongs

import org.directwebremoting.WebContextFactory; //导入依赖的package包/类
public int createPlaylistForStarredSongs() {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    Locale locale = localeResolver.resolveLocale(request);
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale);

    Date now = new Date();
    Playlist playlist = new Playlist();
    String username = securityService.getCurrentUsername(request);
    playlist.setUsername(username);
    playlist.setCreated(now);
    playlist.setChanged(now);
    playlist.setShared(false);

    ResourceBundle bundle = ResourceBundle.getBundle("org.airsonic.player.i18n.ResourceBundle", locale);
    playlist.setName(bundle.getString("top.starred") + " " + dateFormat.format(now));

    playlistService.createPlaylist(playlist);
    List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
    List<MediaFile> songs = mediaFileDao.getStarredFiles(0, Integer.MAX_VALUE, username, musicFolders);
    playlistService.setFilesInPlaylist(playlist.getId(), songs);

    return playlist.getId();
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:24,代码来源:PlaylistService.java

示例7: playTopSong

import org.directwebremoting.WebContextFactory; //导入依赖的package包/类
/**
 * @param index Start playing at this index, or play all top songs if {@code null}.
 */
public PlayQueueInfo playTopSong(int id, Integer index) throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();

    String username = securityService.getCurrentUsername(request);
    boolean queueFollowingSongs = settingsService.getUserSettings(username).isQueueFollowingSongs();

    List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
    List<MediaFile> files = lastFmService.getTopSongs(mediaFileService.getMediaFile(id), 50, musicFolders);
    if (!files.isEmpty() && index != null) {
        if (queueFollowingSongs) {
            files = files.subList(index, files.size());
        } else {
            files = Arrays.asList(files.get(index));
        }
    }

    Player player = getCurrentPlayer(request, response);
    return doPlay(request, player, files).setStartPlayerAt(0);
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:24,代码来源:PlayQueueService.java

示例8: playPodcastChannel

import org.directwebremoting.WebContextFactory; //导入依赖的package包/类
public PlayQueueInfo playPodcastChannel(int id) throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();

    List<PodcastEpisode> episodes = podcastService.getEpisodes(id);
    List<MediaFile> files = new ArrayList<MediaFile>();
    for (PodcastEpisode episode : episodes) {
        if (episode.getStatus() == PodcastStatus.COMPLETED) {
            MediaFile mediaFile = mediaFileService.getMediaFile(episode.getMediaFileId());
            if (mediaFile != null && mediaFile.isPresent()) {
                files.add(mediaFile);
            }
        }
    }
    Player player = getCurrentPlayer(request, response);
    return doPlay(request, player, files).setStartPlayerAt(0);
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:18,代码来源:PlayQueueService.java

示例9: playPodcastEpisode

import org.directwebremoting.WebContextFactory; //导入依赖的package包/类
public PlayQueueInfo playPodcastEpisode(int id) throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();

    PodcastEpisode episode = podcastService.getEpisode(id, false);
    List<PodcastEpisode> allEpisodes = podcastService.getEpisodes(episode.getChannelId());
    List<MediaFile> files = new ArrayList<MediaFile>();

    String username = securityService.getCurrentUsername(request);
    boolean queueFollowingSongs = settingsService.getUserSettings(username).isQueueFollowingSongs();

    for (PodcastEpisode ep : allEpisodes) {
        if (ep.getStatus() == PodcastStatus.COMPLETED) {
            MediaFile mediaFile = mediaFileService.getMediaFile(ep.getMediaFileId());
            if (mediaFile != null && mediaFile.isPresent() &&
                (ep.getId().equals(episode.getId()) || queueFollowingSongs && !files.isEmpty())) {
                files.add(mediaFile);
            }
        }
    }
    Player player = getCurrentPlayer(request, response);
    return doPlay(request, player, files).setStartPlayerAt(0);
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:24,代码来源:PlayQueueService.java

示例10: playNewestPodcastEpisode

import org.directwebremoting.WebContextFactory; //导入依赖的package包/类
public PlayQueueInfo playNewestPodcastEpisode(Integer index) throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();

    List<PodcastEpisode> episodes = podcastService.getNewestEpisodes(10);
    List<MediaFile> files = Lists.transform(episodes, new Function<PodcastEpisode, MediaFile>() {
        @Override
        public MediaFile apply(PodcastEpisode episode) {
            return mediaFileService.getMediaFile(episode.getMediaFileId());
        }
    });

    String username = securityService.getCurrentUsername(request);
    boolean queueFollowingSongs = settingsService.getUserSettings(username).isQueueFollowingSongs();

    if (!files.isEmpty() && index != null) {
        if (queueFollowingSongs) {
            files = files.subList(index, files.size());
        } else {
            files = Arrays.asList(files.get(index));
        }
    }

    Player player = getCurrentPlayer(request, response);
    return doPlay(request, player, files).setStartPlayerAt(0);
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:27,代码来源:PlayQueueService.java

示例11: getBeanFactory

import org.directwebremoting.WebContextFactory; //导入依赖的package包/类
/**
 * @return A found BeanFactory configuration
 */
private BeanFactory getBeanFactory()
{
    // If someone has set a resource name then we need to load that.
    if (configLocation != null && configLocation.length > 0)
    {
        log.info("Spring BeanFactory via ClassPathXmlApplicationContext using " + configLocation.length + "configLocations.");
        return new ClassPathXmlApplicationContext(configLocation);
    }

    ServletContext srvCtx = WebContextFactory.get().getServletContext();
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();

    if (request != null)
    {
        return RequestContextUtils.getWebApplicationContext(request, srvCtx);
    }
    else
    {
        return WebApplicationContextUtils.getWebApplicationContext(srvCtx);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:SpringCreator.java

示例12: 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

示例13: scriptUpdated

import org.directwebremoting.WebContextFactory; //导入依赖的package包/类
/**
 * @return Whether or not the script (located at scriptPath) has been modified.
 */
private boolean scriptUpdated()
{
    if (null == scriptPath)
    {
        return false;
    }

    ServletContext sc = WebContextFactory.get().getServletContext();
    File scriptFile = new File(sc.getRealPath(scriptPath));
    if (scriptModified < scriptFile.lastModified())
    {
        log.debug("Script has been updated.");
        clazz = null; // make sure that this gets re-compiled.
        return true;
    }

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

示例14: 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

示例15: 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


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