You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/01/19 10:09:57 UTC
svn commit: r1435511 -
/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java
Author: davsclaus
Date: Sat Jan 19 09:09:57 2013
New Revision: 1435511
URL: http://svn.apache.org/viewvc?rev=1435511&view=rev
Log:
CAMEL-5645: Allow to load certificate from classpath or file using resource helper.
Modified:
camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java
Modified: camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java?rev=1435511&r1=1435510&r2=1435511&view=diff
==============================================================================
--- camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java (original)
+++ camel/trunk/components/camel-apns/src/main/java/org/apache/camel/component/apns/factory/ApnsServiceFactory.java Sat Jan 19 09:09:57 2013
@@ -17,6 +17,7 @@
package org.apache.camel.component.apns.factory;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStream;
import javax.net.ssl.SSLContext;
@@ -35,6 +36,7 @@ import org.apache.camel.component.apns.u
import org.apache.camel.component.apns.util.ParamUtils;
import org.apache.camel.component.apns.util.ResourceUtils;
import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.ResourceHelper;
public class ApnsServiceFactory implements CamelContextAware {
@@ -169,7 +171,7 @@ public class ApnsServiceFactory implemen
configureApnsDestinations(builder);
try {
configureApnsCertificate(builder);
- } catch (FileNotFoundException e) {
+ } catch (IOException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
@@ -177,7 +179,7 @@ public class ApnsServiceFactory implemen
return apnsService;
}
- private void configureApnsCertificate(ApnsServiceBuilder builder) throws FileNotFoundException {
+ private void configureApnsCertificate(ApnsServiceBuilder builder) throws IOException {
if (getSslContext() != null) {
builder.withSSLContext(getSslContext());
return;
@@ -189,10 +191,7 @@ public class ApnsServiceFactory implemen
InputStream certificateInputStream = null;
try {
- certificateInputStream = camelContext.getClassResolver().loadResourceAsStream(getCertificatePath());
- if (certificateInputStream == null) {
- throw new FileNotFoundException("Cannot load " + getCertificatePath() + " from classpath");
- }
+ certificateInputStream = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext.getClassResolver(), getCertificatePath());
builder.withCert(certificateInputStream, getCertificatePassword());
} finally {
ResourceUtils.close(certificateInputStream);