You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2016/07/21 08:12:18 UTC
cxf git commit: [CXF-6973] Allow to configure http conduits and
destinations using features
Repository: cxf
Updated Branches:
refs/heads/master fe4ee94be -> f761e1823
[CXF-6973] Allow to configure http conduits and destinations using features
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f761e182
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f761e182
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f761e182
Branch: refs/heads/master
Commit: f761e1823ef1fc9aa051d89bf0a9172c5925cdda
Parents: fe4ee94
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Thu Jul 21 10:11:58 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Thu Jul 21 10:12:12 2016 +0200
----------------------------------------------------------------------
.../cxf/transport/http/HttpConduitConfig.java | 73 ++++++++++++++++++++
.../cxf/transport/http/HttpConduitFeature.java | 48 +++++++++++++
.../transport/http/HttpDestinationConfig.java | 37 ++++++++++
.../transport/http/HttpDestinationFeature.java | 47 +++++++++++++
4 files changed, 205 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/f761e182/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpConduitConfig.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpConduitConfig.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpConduitConfig.java
new file mode 100644
index 0000000..bf09d5b
--- /dev/null
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpConduitConfig.java
@@ -0,0 +1,73 @@
+/**
+ * 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.cxf.transport.http;
+
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.configuration.security.AuthorizationPolicy;
+import org.apache.cxf.configuration.security.ProxyAuthorizationPolicy;
+import org.apache.cxf.transport.http.auth.HttpAuthSupplier;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
+
+/**
+ * Holds http conduit configs for the HttpConduitFeature
+ */
+public class HttpConduitConfig {
+ private TLSClientParameters tlsClientParameters;
+ private HTTPClientPolicy clientPolicy;
+ private HttpAuthSupplier authSupplier;
+ private ProxyAuthorizationPolicy proxyAuthorizationPolicy;
+ private AuthorizationPolicy authorizationPolicy;
+
+ public void setTlsClientParameters(TLSClientParameters tlsClientParameters) {
+ this.tlsClientParameters = tlsClientParameters;
+ }
+ public HTTPClientPolicy getClientPolicy() {
+ return clientPolicy;
+ }
+ public void setClientPolicy(HTTPClientPolicy clientPolicy) {
+ this.clientPolicy = clientPolicy;
+ }
+ public void setAuthSupplier(HttpAuthSupplier authSupplier) {
+ this.authSupplier = authSupplier;
+ }
+ public void setProxyAuthorizationPolicy(ProxyAuthorizationPolicy proxyAuthorizationPolicy) {
+ this.proxyAuthorizationPolicy = proxyAuthorizationPolicy;
+ }
+ public void setAuthorizationPolicy(AuthorizationPolicy authorizationPolicy) {
+ this.authorizationPolicy = authorizationPolicy;
+ }
+
+ public void apply(HTTPConduit conduit) {
+ if (tlsClientParameters != null) {
+ conduit.setTlsClientParameters(tlsClientParameters);
+ }
+ if (clientPolicy != null) {
+ conduit.setClient(clientPolicy);
+ }
+ if (authSupplier != null) {
+ conduit.setAuthSupplier(authSupplier);
+ }
+ if (proxyAuthorizationPolicy != null) {
+ conduit.setProxyAuthorization(proxyAuthorizationPolicy);
+ }
+ if (authorizationPolicy != null) {
+ conduit.setAuthorization(authorizationPolicy);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/f761e182/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpConduitFeature.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpConduitFeature.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpConduitFeature.java
new file mode 100644
index 0000000..73c297b
--- /dev/null
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpConduitFeature.java
@@ -0,0 +1,48 @@
+/**
+ * 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.cxf.transport.http;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.transport.Conduit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Programmatically configure a http conduit. This can also be used as a DOSGi
+ * intent.
+ */
+public class HttpConduitFeature extends AbstractFeature {
+ static final Logger LOG = LoggerFactory.getLogger(HttpConduitFeature.class);
+ private HttpConduitConfig conduitConfig;
+
+ @Override
+ public void initialize(Client client, Bus bus) {
+ Conduit conduit = client.getConduit();
+ if (conduitConfig != null && conduit instanceof HTTPConduit) {
+ conduitConfig.apply((HTTPConduit)conduit);
+ }
+ }
+
+ public void setConduitConfig(HttpConduitConfig conduitConfig) {
+ this.conduitConfig = conduitConfig;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/f761e182/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpDestinationConfig.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpDestinationConfig.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpDestinationConfig.java
new file mode 100644
index 0000000..200053b
--- /dev/null
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpDestinationConfig.java
@@ -0,0 +1,37 @@
+/**
+ * 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.cxf.transport.http;
+
+import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
+
+/**
+ * Holds configuration data for a http destination
+ */
+public class HttpDestinationConfig {
+
+ private HTTPServerPolicy serverPolicy;
+
+ public void apply(AbstractHTTPDestination destination) {
+ destination.setServer(serverPolicy);
+ }
+
+ public void setServerPolicy(HTTPServerPolicy serverPolicy) {
+ this.serverPolicy = serverPolicy;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/f761e182/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpDestinationFeature.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpDestinationFeature.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpDestinationFeature.java
new file mode 100644
index 0000000..a90194f
--- /dev/null
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpDestinationFeature.java
@@ -0,0 +1,47 @@
+/**
+ * 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.cxf.transport.http;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.transport.Destination;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Programmatically configure a http destination. This can also be used as a DOSGi
+ * intent.
+ */
+public class HttpDestinationFeature extends AbstractFeature {
+ static final Logger LOG = LoggerFactory.getLogger(HttpDestinationFeature.class);
+ private HttpDestinationConfig destinationConfig;
+
+ @Override
+ public void initialize(Server server, Bus bus) {
+ Destination destination = server.getDestination();
+ if (destinationConfig != null && destination instanceof AbstractHTTPDestination) {
+ destinationConfig.apply((AbstractHTTPDestination)destination);
+ }
+ }
+
+ public void setDestinationConfig(HttpDestinationConfig destinationConfig) {
+ this.destinationConfig = destinationConfig;
+ }
+}