You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2010/11/11 19:40:26 UTC
svn commit: r1034032 - in /activemq/trunk/activemq-core/src:
main/java/org/apache/activemq/xbean/XBeanBrokerFactory.java
test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java
test/resources/org/apache/activemq/broker/out-of-order-broker-elements.xml
Author: gtully
Date: Thu Nov 11 18:40:26 2010
New Revision: 1034032
URL: http://svn.apache.org/viewvc?rev=1034032&view=rev
Log:
resolve https://issues.apache.org/activemq/browse/AMQ-2939 - allow xbean config validation to be disabled, url of the form xbean:...?validate=false will do it
Added:
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java (with props)
activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/out-of-order-broker-elements.xml (with props)
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerFactory.java
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerFactory.java?rev=1034032&r1=1034031&r2=1034032&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerFactory.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerFactory.java Thu Nov 11 18:40:26 2010
@@ -20,14 +20,18 @@ import java.beans.PropertyEditorManager;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
+import java.util.Map;
import org.apache.activemq.broker.BrokerFactoryHandler;
import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.util.IntrospectionSupport;
+import org.apache.activemq.util.URISupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xbean.spring.context.ResourceXmlApplicationContext;
import org.apache.xbean.spring.context.impl.URIEditor;
import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.io.ClassPathResource;
@@ -46,7 +50,22 @@ public class XBeanBrokerFactory implemen
PropertyEditorManager.registerEditor(URI.class, URIEditor.class);
}
+ private boolean validate = true;
+ public boolean isValidate() {
+ return validate;
+ }
+
+ public void setValidate(boolean validate) {
+ this.validate = validate;
+ }
+
public BrokerService createBroker(URI config) throws Exception {
+
+ Map map = URISupport.parseParameters(config);
+ if (!map.isEmpty()) {
+ IntrospectionSupport.setProperties(this, map);
+ config = URISupport.removeQuery(config);
+ }
String uri = config.getSchemeSpecificPart();
ApplicationContext context = createApplicationContext(uri);
@@ -93,6 +112,11 @@ public class XBeanBrokerFactory implemen
} else {
resource = new ClassPathResource(uri);
}
- return new ResourceXmlApplicationContext(resource);
+ return new ResourceXmlApplicationContext(resource) {
+ @Override
+ protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
+ reader.setValidating(isValidate());
+ }
+ };
}
}
Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java?rev=1034032&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java Thu Nov 11 18:40:26 2010
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.activemq.broker;
+
+import java.net.URI;
+import org.apache.activemq.xbean.XBeanBrokerFactory;
+import org.junit.Test;
+
+// https://issues.apache.org/activemq/browse/AMQ-2939
+public class OutOfOrderXMLTest {
+
+ @Test
+ public void verifyBrokerCreationWhenXmlOutOfOrderValidationFalse() throws Exception {
+ BrokerService answer =
+ BrokerFactory.createBroker(new URI("xbean:org/apache/activemq/broker/out-of-order-broker-elements.xml?validate=false"));
+ answer.stop();
+
+ }
+}
Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/OutOfOrderXMLTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/out-of-order-broker-elements.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/out-of-order-broker-elements.xml?rev=1034032&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/out-of-order-broker-elements.xml (added)
+++ activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/out-of-order-broker-elements.xml Thu Nov 11 18:40:26 2010
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+
+<!-- this file can only be parsed using the xbean-spring library with validation off -->
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
+
+ <broker xmlns="http://activemq.apache.org/schema/core">
+ <systemUsage>
+ <systemUsage>
+ <memoryUsage>
+ <memoryUsage limit="20 mb"/>
+ </memoryUsage>
+ <storeUsage>
+ <storeUsage limit="1 gb" name="foo"/>
+ </storeUsage>
+ <tempUsage>
+ <tempUsage limit="100 mb"/>
+ </tempUsage>
+ </systemUsage>
+ </systemUsage>
+ <destinations>
+ <queue physicalName="FOO.BAR"/>
+ <topic physicalName="SOME.TOPIC"/>
+ </destinations>
+
+ </broker>
+
+</beans>
Propchange: activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/out-of-order-broker-elements.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/out-of-order-broker-elements.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/out-of-order-broker-elements.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml