Source Code Cross Referenced for SearchManagerBean.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » ui » admin » beans » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Wiki Engine » JSPWiki » com.ecyrd.jspwiki.ui.admin.beans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.ecyrd.jspwiki.ui.admin.beans;
002:
003:        import java.util.Collection;
004:        import java.util.Iterator;
005:
006:        import javax.management.NotCompliantMBeanException;
007:
008:        import org.apache.log4j.Logger;
009:
010:        import com.ecyrd.jspwiki.WikiContext;
011:        import com.ecyrd.jspwiki.WikiEngine;
012:        import com.ecyrd.jspwiki.WikiPage;
013:        import com.ecyrd.jspwiki.search.SearchManager;
014:        import com.ecyrd.jspwiki.ui.admin.SimpleAdminBean;
015:        import com.ecyrd.jspwiki.ui.progress.ProgressItem;
016:        import com.ecyrd.jspwiki.util.WikiBackgroundThread;
017:
018:        /**
019:         *  The SearchManagerBean is a simple AdminBean interface
020:         *  to the SearchManager.  It currently can be used to force
021:         *  a reload of all of the pages.
022:         *
023:         *  @since 2.6
024:         */
025:        public class SearchManagerBean extends SimpleAdminBean {
026:            private static final String PROGRESS_ID = "searchmanagerbean.reindexer";
027:
028:            public static final String[] METHODS = { "reload" };
029:
030:            private static Logger log = Logger
031:                    .getLogger(SearchManagerBean.class);
032:
033:            private WikiBackgroundThread m_updater;
034:
035:            public SearchManagerBean(WikiEngine engine)
036:                    throws NotCompliantMBeanException {
037:                super ();
038:                initialize(engine);
039:            }
040:
041:            public String[] getAttributeNames() {
042:                return new String[0];
043:            }
044:
045:            public String[] getMethodNames() {
046:                return METHODS;
047:            }
048:
049:            public String getTitle() {
050:                return "Search manager";
051:            }
052:
053:            /**
054:             *  Starts a background thread which goes through all the pages and adds them
055:             *  to the reindex queue.
056:             *  <p>
057:             *  This method prevents itself from being called twice.
058:             */
059:            public synchronized void reload() {
060:                if (m_updater == null) {
061:                    m_updater = new WikiBackgroundThread(m_engine, 0) {
062:                        int m_count;
063:                        int m_max;
064:
065:                        public void startupTask() throws Exception {
066:                            super .startupTask();
067:
068:                            setName("Reindexer started");
069:                        }
070:
071:                        public void backgroundTask() throws Exception {
072:                            Collection allPages = m_engine.getPageManager()
073:                                    .getAllPages();
074:
075:                            SearchManager mgr = m_engine.getSearchManager();
076:                            m_max = allPages.size();
077:
078:                            ProgressItem pi = new ProgressItem() {
079:                                public int getProgress() {
080:                                    return 100 * m_count / m_max;
081:                                }
082:                            };
083:
084:                            m_engine.getProgressManager().startProgress(pi,
085:                                    PROGRESS_ID);
086:
087:                            for (Iterator i = allPages.iterator(); i.hasNext();) {
088:                                WikiPage page = (WikiPage) i.next();
089:
090:                                mgr.reindexPage(page);
091:                                m_count++;
092:                            }
093:
094:                            m_engine.getProgressManager().stopProgress(
095:                                    PROGRESS_ID);
096:                            shutdown();
097:                            m_updater = null;
098:                        }
099:
100:                    };
101:
102:                    m_updater.start();
103:                }
104:            }
105:
106:            public int getType() {
107:                return CORE;
108:            }
109:
110:            public String doGet(WikiContext context) {
111:                if (m_updater != null) {
112:                    return "Update already in progress ("
113:                            + context.getEngine().getProgressManager()
114:                                    .getProgress(PROGRESS_ID) + "%)";
115:                }
116:
117:                return "<input type='submit' id='searchmanagerbean-reload' name='searchmanagerbean-reload' value='Force index reload'/>"
118:                        + "<div class='description'>Forces JSPWiki search engine to reindex all pages.  Use this if you think some pages are not being found even if they should.</div>";
119:            }
120:
121:            public String doPost(WikiContext context) {
122:                String val = context
123:                        .getHttpParameter("searchmanagerbean-reload");
124:
125:                if (val != null) {
126:                    reload();
127:
128:                    context.getWikiSession().addMessage(
129:                            "Started reload of all indexed pages...");
130:
131:                    return "";
132:                }
133:
134:                return doGet(context);
135:            }
136:
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.