Author: gtully
Date: Tue Apr 5 09:47:19 2011
New Revision: 1088944
URL: http://svn.apache.org/viewvc?rev=1088944&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3268 - Cannot use <SslContext> tag in
blueprint configuration. Pull Resource from the api such that that string
schema matches the java api. A resource is still used in the implementation
such that a local or relative path or uri is supported
Added:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/Utils.java
(with props)
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/SpringSslContext.java
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerFactory.java
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/SpringSslContext.java
URL:
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/SpringSslContext.java?rev=1088944&r1=1088943&r2=1088944&view=diff
==============================================================================
---
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/SpringSslContext.java
(original)
+++
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/SpringSslContext.java
Tue Apr 5 09:47:19 2011
@@ -17,6 +17,7 @@
package org.apache.activemq.spring;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
@@ -30,7 +31,6 @@ import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import org.apache.activemq.broker.SslContext;
-import org.springframework.core.io.Resource;
/**
* Extends the SslContext so that it's easier to configure from spring.
@@ -48,8 +48,8 @@ public class SpringSslContext extends Ss
private String keyStoreAlgorithm=KeyManagerFactory.getDefaultAlgorithm();
private String
trustStoreAlgorithm=TrustManagerFactory.getDefaultAlgorithm();
- private Resource keyStore;
- private Resource trustStore;
+ private String keyStore;
+ private String trustStore;
private String keyStorePassword;
private String trustStorePassword;
@@ -100,7 +100,7 @@ public class SpringSslContext extends Ss
}
KeyStore ks = KeyStore.getInstance(trustStoreType);
- InputStream is=trustStore.getInputStream();
+ InputStream is=Utils.resourceFromString(trustStore).getInputStream();
try {
ks.load(is, trustStorePassword==null? null :
trustStorePassword.toCharArray());
} finally {
@@ -115,7 +115,7 @@ public class SpringSslContext extends Ss
}
KeyStore ks = KeyStore.getInstance(keyStoreType);
- InputStream is=keyStore.getInputStream();
+ InputStream is=Utils.resourceFromString(keyStore).getInputStream();
try {
ks.load(is, keyStorePassword==null? null :
keyStorePassword.toCharArray());
} finally {
@@ -132,20 +132,20 @@ public class SpringSslContext extends Ss
return keyStoreType;
}
- public Resource getKeyStore() {
+ public String getKeyStore() {
return keyStore;
}
- public void setKeyStore(Resource keyResource) {
- this.keyStore = keyResource;
+ public void setKeyStore(String keyStore) throws MalformedURLException {
+ this.keyStore = keyStore;
}
- public Resource getTrustStore() {
+ public String getTrustStore() {
return trustStore;
}
- public void setTrustStore(Resource trustResource) {
- this.trustStore = trustResource;
+ public void setTrustStore(String trustStore) throws MalformedURLException {
+ this.trustStore = trustStore;
}
public String getKeyStoreAlgorithm() {
Added:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/Utils.java
URL:
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/Utils.java?rev=1088944&view=auto
==============================================================================
---
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/Utils.java
(added)
+++
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/Utils.java
Tue Apr 5 09:47:19 2011
@@ -0,0 +1,41 @@
+/**
+ * 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.spring;
+
+import java.io.File;
+import java.net.MalformedURLException;
+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;
+
+public class Utils {
+
+ public static Resource resourceFromString(String uri) throws
MalformedURLException {
+ 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 resource;
+ }
+}
Propchange:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/Utils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/Utils.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
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=1088944&r1=1088943&r2=1088944&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
Tue Apr 5 09:47:19 2011
@@ -24,6 +24,7 @@ import java.util.Map;
import org.apache.activemq.broker.BrokerFactoryHandler;
import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.spring.Utils;
import org.apache.activemq.util.IntrospectionSupport;
import org.apache.activemq.util.URISupport;
import org.slf4j.Logger;
@@ -100,17 +101,8 @@ public class XBeanBrokerFactory implemen
}
protected ApplicationContext createApplicationContext(String uri) throws
MalformedURLException {
- LOG.debug("Now 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);
- }
+ Resource resource = Utils.resourceFromString(uri);
+ LOG.debug("Using " + resource + " from " + uri);
return new ResourceXmlApplicationContext(resource) {
@Override
protected void initBeanDefinitionReader(XmlBeanDefinitionReader
reader) {