mirror of https://github.com/apache/activemq.git
rolled back the creation of the file: scheme and made the xbean: scheme handle files or URLs as well as classpath resources
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@518632 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a640190fc4
commit
c729994739
|
@ -1,36 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* 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.xbean;
|
||||
|
||||
import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
|
||||
import org.apache.xbean.spring.context.FileSystemXmlApplicationContext;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class FileXBeanBrokerFactory extends XBeanBrokerFactory {
|
||||
@Override
|
||||
protected ApplicationContext createApplicationContext(String uri) {
|
||||
String name = uri.toString();
|
||||
if (name.startsWith("//")) {
|
||||
name = name.substring(2);
|
||||
}
|
||||
return new FileSystemXmlApplicationContext(name);
|
||||
}
|
||||
}
|
|
@ -17,15 +17,22 @@
|
|||
*/
|
||||
package org.apache.activemq.xbean;
|
||||
|
||||
import java.beans.PropertyEditorManager;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.broker.BrokerFactoryHandler;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.xbean.spring.context.ResourceXmlApplicationContext;
|
||||
import org.apache.xbean.spring.context.impl.URIEditor;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
|
||||
import org.apache.xbean.spring.context.impl.URIEditor;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
import java.beans.PropertyEditorManager;
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
/**
|
||||
* @version $Revision$
|
||||
|
@ -68,7 +75,19 @@ public class XBeanBrokerFactory implements BrokerFactoryHandler {
|
|||
return broker;
|
||||
}
|
||||
|
||||
protected ApplicationContext createApplicationContext(String uri) {
|
||||
return new ClassPathXmlApplicationContext(uri);
|
||||
protected ApplicationContext createApplicationContext(String uri) throws MalformedURLException {
|
||||
System.out.println("####Êattempting to figure out the type of resource: " + uri);
|
||||
Resource resource;
|
||||
File file = new File(uri);
|
||||
if (file.exists()) {
|
||||
resource = new FileSystemResource(uri);
|
||||
}
|
||||
else if (ResourceUtils.isUrl(uri)) {
|
||||
resource = new UrlResource(uri);
|
||||
}
|
||||
else {
|
||||
resource = new ClassPathResource(uri);
|
||||
}
|
||||
return new ResourceXmlApplicationContext(resource);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
class=org.apache.activemq.xbean.FileXBeanBrokerFactory
|
|
@ -55,7 +55,7 @@ public class BrokerXmlConfigTest extends TestCase {
|
|||
|
||||
protected void setUp() throws Exception {
|
||||
System.setProperty("activemq.base", "target");
|
||||
broker = BrokerFactory.createBroker("file:src/release/conf/activemq.xml");
|
||||
broker = BrokerFactory.createBroker("xbean:src/release/conf/activemq.xml");
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue