mirror of https://github.com/apache/activemq.git
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
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1034032 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e214256bec
commit
5ce31fae87
|
@ -20,14 +20,18 @@ import java.beans.PropertyEditorManager;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.activemq.broker.BrokerFactoryHandler;
|
import org.apache.activemq.broker.BrokerFactoryHandler;
|
||||||
import org.apache.activemq.broker.BrokerService;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.xbean.spring.context.ResourceXmlApplicationContext;
|
import org.apache.xbean.spring.context.ResourceXmlApplicationContext;
|
||||||
import org.apache.xbean.spring.context.impl.URIEditor;
|
import org.apache.xbean.spring.context.impl.URIEditor;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
@ -46,7 +50,22 @@ public class XBeanBrokerFactory implements BrokerFactoryHandler {
|
||||||
PropertyEditorManager.registerEditor(URI.class, URIEditor.class);
|
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 {
|
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();
|
String uri = config.getSchemeSpecificPart();
|
||||||
ApplicationContext context = createApplicationContext(uri);
|
ApplicationContext context = createApplicationContext(uri);
|
||||||
|
@ -93,6 +112,11 @@ public class XBeanBrokerFactory implements BrokerFactoryHandler {
|
||||||
} else {
|
} else {
|
||||||
resource = new ClassPathResource(uri);
|
resource = new ClassPathResource(uri);
|
||||||
}
|
}
|
||||||
return new ResourceXmlApplicationContext(resource);
|
return new ResourceXmlApplicationContext(resource) {
|
||||||
|
@Override
|
||||||
|
protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
|
||||||
|
reader.setValidating(isValidate());
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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>
|
Loading…
Reference in New Issue