From 704c84b6445a3b3a5a65c4330183aad39271e579 Mon Sep 17 00:00:00 2001 From: Mark Pollack Date: Sun, 13 Feb 2011 00:47:46 -0200 Subject: [PATCH] Add JMX namespace parser --- .../document/mongodb/config/MongoParser.java | 4 +-- ...MongoRepositoryConfigDefinitionParser.java | 15 +++++++++++ .../MongoRepositoryNamespaceHandler.java | 16 +++++++++++ .../SimpleMongoRepositoryConfiguration.java | 15 +++++++++++ .../mongodb/monitor/AssertMetrics.java | 2 +- .../mongodb/config/spring-mongo-1.0.xsd | 27 +++++++++++++++++++ .../src/test/resources/server-jmx.xml | 19 +++---------- 7 files changed, 79 insertions(+), 19 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoParser.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoParser.java index a2f81e793..db3600f85 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoParser.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2010 the original author or authors. + * Copyright 2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import org.springframework.util.StringUtils; import org.w3c.dom.Element; /** - * Parser for <mongo;gt; definitions. + * Parser for <mongo;gt; definitions. If no name * * @author Mark Pollack */ diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoRepositoryConfigDefinitionParser.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoRepositoryConfigDefinitionParser.java index b7475c526..602314a92 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoRepositoryConfigDefinitionParser.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoRepositoryConfigDefinitionParser.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.data.document.mongodb.config; import org.springframework.beans.factory.support.BeanDefinitionBuilder; diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoRepositoryNamespaceHandler.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoRepositoryNamespaceHandler.java index 08dc7014b..2299a91df 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoRepositoryNamespaceHandler.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/MongoRepositoryNamespaceHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.data.document.mongodb.config; import org.springframework.beans.factory.xml.NamespaceHandlerSupport; @@ -22,5 +37,6 @@ public class MongoRepositoryNamespaceHandler extends NamespaceHandlerSupport { new MongoRepositoryConfigDefinitionParser()); registerBeanDefinitionParser("mongo", new MongoParser()); + registerBeanDefinitionParser("jmx", new MongoJmxParser()); } } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/SimpleMongoRepositoryConfiguration.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/SimpleMongoRepositoryConfiguration.java index de9ba52d8..ca1d079be 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/SimpleMongoRepositoryConfiguration.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/config/SimpleMongoRepositoryConfiguration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.data.document.mongodb.config; import org.springframework.data.document.mongodb.repository.MongoRepository; diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/monitor/AssertMetrics.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/monitor/AssertMetrics.java index 6356edd6d..b9bd6f5ca 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/monitor/AssertMetrics.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/monitor/AssertMetrics.java @@ -42,7 +42,7 @@ public class AssertMetrics extends AbstractMonitor { @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Warning") public int getWarning() { - return getBtree("hits"); + return getBtree("warning"); } @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Msg") diff --git a/spring-data-mongodb/src/main/resources/org/springframework/data/document/mongodb/config/spring-mongo-1.0.xsd b/spring-data-mongodb/src/main/resources/org/springframework/data/document/mongodb/config/spring-mongo-1.0.xsd index 4dd4ecacc..c133aaad4 100644 --- a/spring-data-mongodb/src/main/resources/org/springframework/data/document/mongodb/config/spring-mongo-1.0.xsd +++ b/spring-data-mongodb/src/main/resources/org/springframework/data/document/mongodb/config/spring-mongo-1.0.xsd @@ -77,6 +77,22 @@ The host to connect to a MongoDB server. Default is localhost + + + + + + + + + + + + + @@ -87,6 +103,17 @@ The host to connect to a MongoDB server. Default is localhost + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-mongodb/src/test/resources/server-jmx.xml b/spring-data-mongodb/src/test/resources/server-jmx.xml index 75226d806..0a61119cd 100644 --- a/spring-data-mongodb/src/test/resources/server-jmx.xml +++ b/spring-data-mongodb/src/test/resources/server-jmx.xml @@ -3,27 +3,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" + xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - - - - - - - - - - - - - - - - +