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    package org.apache.camel.core.xml;
018    
019    import javax.xml.bind.annotation.XmlAccessType;
020    import javax.xml.bind.annotation.XmlAccessorType;
021    import javax.xml.bind.annotation.XmlAttribute;
022    import javax.xml.bind.annotation.XmlRootElement;
023    
024    import org.apache.camel.ManagementStatisticsLevel;
025    import org.apache.camel.model.IdentifiedType;
026    
027    /**
028     * The JAXB type class for the configuration of jmxAgent
029     *
030     * @version $Revision: 911871 $
031     */
032    @XmlRootElement(name = "jmxAgent")
033    @XmlAccessorType(XmlAccessType.FIELD)
034    public class CamelJMXAgentDefinition extends IdentifiedType {
035    
036        /**
037         * Disable JMI (default false)
038         */
039        @XmlAttribute(required = false)
040        private String disabled = "false";
041    
042        /**
043         * Only register processor if a custom id was defined for it.
044         */
045        @XmlAttribute(required = false)
046        private String onlyRegisterProcessorWithCustomId = "false";
047    
048        /**
049         * RMI connector registry port (default 1099)
050         */
051        @XmlAttribute(required = false)
052        private String registryPort;
053    
054        /**
055         * RMI connector server port (default -1 not used)
056         */
057        @XmlAttribute(required = false)
058        private String connectorPort;
059    
060        /**
061         * MBean server default domain name (default org.apache.camel)
062         */
063        @XmlAttribute(required = false)
064        private String mbeanServerDefaultDomain;
065    
066        /**
067         * MBean object domain name (default org.apache.camel)
068         */
069        @XmlAttribute(required = false)
070        private String mbeanObjectDomainName;
071    
072        /**
073         * JMX Service URL path (default /jmxrmi)
074         */
075        @XmlAttribute(required = false)
076        private String serviceUrlPath;
077    
078        /**
079         * A flag that indicates whether the agent should be created
080         */
081        @XmlAttribute(required = false)
082        private String createConnector = "true";
083    
084        /**
085         * A flag that indicates whether the platform mbean server should be used
086         */
087        @XmlAttribute(required = false)
088        private String usePlatformMBeanServer = "true";
089    
090        /**
091         * Level of granularity for performance statistics enabled
092         */
093        @XmlAttribute(required = false)
094        private ManagementStatisticsLevel statisticsLevel = ManagementStatisticsLevel.All;
095    
096        public String getDisabled() {
097            return disabled;
098        }
099    
100        public boolean isAgentDisabled() {
101            return disabled != null && Boolean.parseBoolean(disabled);
102        }
103    
104        public void setDisabled(String disabled) {
105            this.disabled = disabled;
106        }
107    
108        public String getOnlyRegisterProcessorWithCustomId() {
109            return onlyRegisterProcessorWithCustomId;
110        }
111    
112        public void setOnlyRegisterProcessorWithCustomId(String onlyRegisterProcessorWithCustomId) {
113            this.onlyRegisterProcessorWithCustomId = onlyRegisterProcessorWithCustomId;
114        }
115    
116        public String getRegistryPort() {
117            return registryPort;
118        }
119    
120        public void setRegistryPort(String registryPort) {
121            this.registryPort = registryPort;
122        }
123    
124        public String getConnectorPort() {
125            return connectorPort;
126        }
127    
128        public void setConnectorPort(String connectorPort) {
129            this.connectorPort = connectorPort;
130        }
131    
132        public String getMbeanServerDefaultDomain() {
133            return mbeanServerDefaultDomain;
134        }
135    
136        public void setMbeanServerDefaultDomain(String mbeanServerDefaultDomain) {
137            this.mbeanServerDefaultDomain = mbeanServerDefaultDomain;
138        }
139    
140        public String getMbeanObjectDomainName() {
141            return mbeanObjectDomainName;
142        }
143    
144        public void setMbeanObjectDomainName(String mbeanObjectDomainName) {
145            this.mbeanObjectDomainName = mbeanObjectDomainName;
146        }
147    
148        public String getServiceUrlPath() {
149            return serviceUrlPath;
150        }
151    
152        public void setServiceUrlPath(String serviceUrlPath) {
153            this.serviceUrlPath = serviceUrlPath;
154        }
155    
156        public String getCreateConnector() {
157            return createConnector;
158        }
159    
160        public void setCreateConnector(String createConnector) {
161            this.createConnector = createConnector;
162        }
163    
164        public String getUsePlatformMBeanServer() {
165            return usePlatformMBeanServer;
166        }
167    
168        public void setUsePlatformMBeanServer(String usePlatformMBeanServer) {
169            this.usePlatformMBeanServer = usePlatformMBeanServer;
170        }
171    
172        public ManagementStatisticsLevel getStatisticsLevel() {
173            return statisticsLevel;
174        }
175    
176        public void setStatisticsLevel(ManagementStatisticsLevel statisticsLevel) {
177            this.statisticsLevel = statisticsLevel;
178        }
179    
180        @Override
181        public String toString() {
182            StringBuilder sb = new StringBuilder();
183            sb.append("CamelJMXAgent[");
184            sb.append("usePlatformMBeanServer=").append(usePlatformMBeanServer);
185            if (createConnector != null) {
186                sb.append(", createConnector=").append(createConnector);
187            }
188            if (connectorPort != null) {
189                sb.append(", connectorPort=").append(connectorPort);
190            }
191            if (registryPort != null) {
192                sb.append(", registryPort=").append(registryPort);
193            }
194            if (serviceUrlPath != null) {
195                sb.append(", serviceUrlPath=").append(serviceUrlPath);
196            }
197            if (mbeanServerDefaultDomain != null) {
198                sb.append(", mbeanServerDefaultDomain=").append(mbeanServerDefaultDomain);
199            }
200            if (mbeanObjectDomainName != null) {
201                sb.append(", mbeanObjectDomainName=").append(mbeanObjectDomainName);
202            }
203            if (statisticsLevel != null) {
204                sb.append(", statisticsLevel=").append(statisticsLevel);
205            }
206            sb.append("]");
207            return sb.toString();
208        }
209    
210    }