Source Code Cross Referenced for JMXAccessorEqualsCondition.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » catalina » ant » jmx » 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 » Sevlet Container » apache tomcat 6.0.14 » org.apache.catalina.ant.jmx 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.catalina.ant.jmx;
019:
020:        import java.io.IOException;
021:        import java.net.MalformedURLException;
022:
023:        import javax.management.MBeanServerConnection;
024:        import javax.management.ObjectName;
025:
026:        import org.apache.tools.ant.BuildException;
027:        import org.apache.tools.ant.ProjectComponent;
028:        import org.apache.tools.ant.taskdefs.condition.Condition;
029:
030:        /**
031:         *
032:         * Definition
033:         * <pre> 
034:         *   &lt;path id="catalina_ant">
035:         *       &lt;fileset dir="${catalina.home}/server/lib">
036:         *           &lt;include name="catalina-ant.jar"/>
037:         *           &lt;include name="catalina-ant-jmx.jar"/>
038:         *       &lt;/fileset>
039:         *   &lt;/path>
040:         *
041:         *   &lt;typedef
042:         *       name="jmxEquals"
043:         *       classname="org.apache.catalina.ant.jmx.JMXAccessorEqualsCondition"
044:         *       classpathref="catalina_ant"/>
045:         * </pre>
046:         * 
047:         * usage: Wait for start backup node
048:         * <pre>
049:         *     &lt;target name="wait"&gt;
050:         *        &lt;waitfor maxwait="${maxwait}" maxwaitunit="second" timeoutproperty="server.timeout" &gt;
051:         *           &lt;and&gt;
052:         *               &lt;socket server="${server.name}" port="${server.port}"/&gt;
053:         *               &lt;http url="${url}"/&gt;
054:         *               &lt;jmxEquals 
055:         *                   host="localhost" port="9014" username="controlRole" password="tomcat"
056:         *                   name="Catalina:type=IDataSender,host=localhost,senderAddress=192.168.111.1,senderPort=9025"
057:         *                   attribute="connected" value="true"
058:         *               /&gt;
059:         *           &lt;/and&gt;
060:         *       &lt;/waitfor&gt;
061:         *       &lt;fail if="server.timeout" message="Server ${url} don't answer inside ${maxwait} sec" /&gt;
062:         *       &lt;echo message="Server ${url} alive" /&gt;
063:         *   &lt;/target&gt;
064:         *
065:         * </pre>
066:         * 
067:         * @author Peter Rossbach
068:         * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
069:         * @since 5.5.10
070:         *
071:         */
072:        public class JMXAccessorEqualsCondition extends ProjectComponent
073:                implements  Condition {
074:
075:            // ----------------------------------------------------- Instance Variables
076:
077:            private String url = null;
078:            private String host = "localhost";
079:            private String port = "8050";
080:            private String password = null;
081:            private String username = null;
082:            private String name = null;
083:            private String attribute;
084:            private String value;
085:            private String ref = "jmx.server";
086:            // ----------------------------------------------------- Instance Info
087:
088:            /**
089:             * Descriptive information describing this implementation.
090:             */
091:            private static final String info = "org.apache.catalina.ant.JMXAccessorEqualsCondition/1.1";
092:
093:            /**
094:             * Return descriptive information about this implementation and the
095:             * corresponding version number, in the format
096:             * <code>&lt;description&gt;/&lt;version&gt;</code>.
097:             */
098:            public String getInfo() {
099:
100:                return (info);
101:
102:            }
103:
104:            // ----------------------------------------------------- Properties
105:
106:            /**
107:             * @return Returns the attribute.
108:             */
109:            public String getAttribute() {
110:                return attribute;
111:            }
112:
113:            /**
114:             * @param attribute The attribute to set.
115:             */
116:            public void setAttribute(String attribute) {
117:                this .attribute = attribute;
118:            }
119:
120:            /**
121:             * @return Returns the host.
122:             */
123:            public String getHost() {
124:                return host;
125:            }
126:
127:            /**
128:             * @param host The host to set.
129:             */
130:            public void setHost(String host) {
131:                this .host = host;
132:            }
133:
134:            /**
135:             * @return Returns the name.
136:             */
137:            public String getName() {
138:                return name;
139:            }
140:
141:            /**
142:             * @param objectName The name to set.
143:             */
144:            public void setName(String objectName) {
145:                this .name = objectName;
146:            }
147:
148:            /**
149:             * @return Returns the password.
150:             */
151:            public String getPassword() {
152:                return password;
153:            }
154:
155:            /**
156:             * @param password The password to set.
157:             */
158:            public void setPassword(String password) {
159:                this .password = password;
160:            }
161:
162:            /**
163:             * @return Returns the port.
164:             */
165:            public String getPort() {
166:                return port;
167:            }
168:
169:            /**
170:             * @param port The port to set.
171:             */
172:            public void setPort(String port) {
173:                this .port = port;
174:            }
175:
176:            /**
177:             * @return Returns the url.
178:             */
179:            public String getUrl() {
180:                return url;
181:            }
182:
183:            /**
184:             * @param url The url to set.
185:             */
186:            public void setUrl(String url) {
187:                this .url = url;
188:            }
189:
190:            /**
191:             * @return Returns the username.
192:             */
193:            public String getUsername() {
194:                return username;
195:            }
196:
197:            /**
198:             * @param username The username to set.
199:             */
200:            public void setUsername(String username) {
201:                this .username = username;
202:            }
203:
204:            /**
205:             * @return Returns the value.
206:             */
207:            public String getValue() {
208:                return value;
209:            }
210:
211:            // The setter for the "value" attribute
212:            public void setValue(String value) {
213:                this .value = value;
214:            }
215:
216:            /**
217:             * @return Returns the ref.
218:             */
219:            public String getRef() {
220:                return ref;
221:            }
222:
223:            /**
224:             * @param refId The ref to set.
225:             */
226:            public void setRef(String refId) {
227:                this .ref = refId;
228:            }
229:
230:            protected MBeanServerConnection getJMXConnection()
231:                    throws MalformedURLException, IOException {
232:                return JMXAccessorTask.accessJMXConnection(getProject(),
233:                        getUrl(), getHost(), getPort(), getUsername(),
234:                        getPassword(), ref);
235:            }
236:
237:            /**
238:             * @return The value
239:             */
240:            protected String accessJMXValue() {
241:                try {
242:                    Object result = getJMXConnection().getAttribute(
243:                            new ObjectName(name), attribute);
244:                    if (result != null)
245:                        return result.toString();
246:                } catch (Exception e) {
247:                    // ignore access or connection open errors
248:                }
249:                return null;
250:            }
251:
252:            // This method evaluates the condition
253:            public boolean eval() {
254:                if (value == null) {
255:                    throw new BuildException("value attribute is not set");
256:                }
257:                if ((name == null || attribute == null)) {
258:                    throw new BuildException(
259:                            "Must specify a 'attribute', name for equals condition");
260:                }
261:                //FIXME check url or host/parameter
262:                String jmxValue = accessJMXValue();
263:                if (jmxValue != null)
264:                    return jmxValue.equals(value);
265:                return false;
266:            }
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.