Source Code Cross Referenced for PropertiesProbe.java in  » Database-ORM » MMBase » org » mmbase » module » builders » 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 » Database ORM » MMBase » org.mmbase.module.builders 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:        This software is OSI Certified Open Source Software.
004:        OSI Certified is a certification mark of the Open Source Initiative.
005:
006:        The license (Mozilla version 1.0) can be read at the MMBase site.
007:        See http://www.MMBase.org/license
008:
009:         */
010:        package org.mmbase.module.builders;
011:
012:        import java.util.*;
013:
014:        import org.mmbase.module.core.*;
015:        import org.mmbase.storage.search.*;
016:        import org.mmbase.storage.search.implementation.*;
017:
018:        import org.mmbase.util.logging.*;
019:
020:        /**
021:         * admin module, keeps track of all the worker pools
022:         * and adds/kills workers if needed (depending on
023:         * there load and info from the config module).
024:         *
025:         * @sql
026:         * @version $Id: PropertiesProbe.java,v 1.13 2007/02/25 17:56:59 nklasens Exp $
027:         * @author Daniel Ockeloen
028:         */
029:        public class PropertiesProbe implements  Runnable {
030:
031:            private static Logger log = Logging
032:                    .getLoggerInstance(PropertiesProbe.class.getName());
033:
034:            Thread kicker = null;
035:            Properties parent = null;
036:
037:            public PropertiesProbe(Properties parent) {
038:                this .parent = parent;
039:                init();
040:            }
041:
042:            public void init() {
043:                this .start();
044:            }
045:
046:            /**
047:             * Starts the admin Thread.
048:             */
049:            public void start() {
050:                /* Start up the main thread */
051:                if (kicker == null) {
052:                    kicker = new Thread(this , "PropertiesProbe");
053:                    kicker.setDaemon(true);
054:                    kicker.start();
055:                }
056:            }
057:
058:            /**
059:             * Stops the admin Thread.
060:             */
061:            public void stop() {
062:                /* Stop thread */
063:                kicker.interrupt();
064:                kicker = null;
065:            }
066:
067:            /**
068:             */
069:            public void run() {
070:                while (kicker != null) {
071:                    try {
072:                        Thread.sleep(10000);
073:                    } catch (InterruptedException e) {
074:                        return;
075:                    }
076:                    if (parent.getMachineName().equals("test1"))
077:                        doExpire();
078:                }
079:            }
080:
081:            private void doExpire() {
082:                try {
083:                    NodeSearchQuery query = new NodeSearchQuery(parent);
084:                    StepField keyField = query.getField(parent.getField("key"));
085:                    BasicFieldValueConstraint constraint1 = new BasicFieldValueConstraint(
086:                            keyField, "LASTVISIT");
087:                    StepField valueField = query.getField(parent
088:                            .getField("value"));
089:                    BasicFieldValueConstraint constraint2 = new BasicFieldValueConstraint(
090:                            valueField, 10536);
091:                    constraint2.setOperator(FieldCompareConstraint.LESS);
092:
093:                    BasicCompositeConstraint constraint = new BasicCompositeConstraint(
094:                            CompositeConstraint.LOGICAL_AND);
095:                    constraint.addChild(constraint1);
096:                    constraint.addChild(constraint2);
097:
098:                    query.setConstraint(constraint);
099:
100:                    List<MMObjectNode> nodes = parent.getNodes(query);
101:                    int max = 0;
102:                    for (Iterator<MMObjectNode> i = nodes.iterator(); i
103:                            .hasNext()
104:                            && max < 1000;) {
105:                        MMObjectNode node = i.next();
106:                        int number = node.getIntValue("parent");
107:                        log.info("Want delete on : " + number);
108:                        deleteProperties(number);
109:                        deleteUser(number);
110:                        max++;
111:                    }
112:                } catch (Exception e) {
113:                }
114:            }
115:
116:            private void deleteProperties(int id) {
117:                /* quicker, but ugly, so don't use
118:
119:                    try {
120:                        DataSource dataSource = (DataSource) parent.mmb.getStorageManagerFactory().getAttribute(Attributes.DATA_SOURCE);
121:                        Connection con = dataSource.getConnection();
122:                        Statement stmt = con.createStatement();
123:                        stmt.executeUpdate("delete from " + parent.mmb.baseName+"_" + parent.tableName + " where parent=" + id);
124:                        stmt.close();
125:                        con.close();
126:                    } catch (Exception e) {}
127:                 */
128:                try {
129:                    NodeSearchQuery query = new NodeSearchQuery(parent);
130:                    List<MMObjectNode> nodes = parent.getNodes(query);
131:                    for (MMObjectNode node : nodes) {
132:                        parent.removeNode(node);
133:                    }
134:                } catch (Exception e) {
135:                }
136:            }
137:
138:            private void deleteUser(int id) {
139:                MMObjectNode user = parent.getNode(id);
140:                if (user != null) {
141:                    user.getBuilder().removeNode(user);
142:                }
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.