Commit 5887c0c1 authored by Philippe Merle's avatar Philippe Merle

Added to new abstract classes into the Apache CXF binding intent framework.

parent 2cb46f0e
/**
* OW2 FraSCAti SCA Intents for Apache CXF
* Copyright (C) 2012 Inria, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Philippe Merle
*
* Contributor(s):
*
*/
package org.ow2.frascati.intent.cxf;
import org.apache.cxf.endpoint.Client;
/**
* Abstract binding intent class for configuring Apache CXF Client.
*
* @author Philippe Merle - Inria
*/
public abstract class AbstractClientIntent
extends AbstractBindingIntentHandler
{
// ----------------------------------------------------------------------
// Related to interface BindingIntentHandler.
// ----------------------------------------------------------------------
/**
* Apply this binding intent on a proxy instance.
*
* @param proxy the proxy instance to configure.
*
* @see BindingIntentHandler#apply(Object)
*/
@Override
public final void apply(Object proxy)
{
// Obtain the client associated to the proxy.
Client client = null;
// Is the proxy a Apache CXF Web Service client?
// if(proxy instanceof org.apache.cxf.jaxws.JaxWsClientProxy) {
client = org.apache.cxf.frontend.ClientProxy.getClient(proxy);
if(client == null) {
throw new IllegalArgumentException(proxy + " is not an Apache CXF Web Service client!");
}
// Configure the client.
configure(client);
super.apply(proxy);
}
// ----------------------------------------------------------------------
// Internal methods.
// ----------------------------------------------------------------------
/**
* Configure an Apache CXF client instance.
*
* @param conduit the Apache CXF client to configure.
*/
protected abstract void configure(Client client);
}
......@@ -28,56 +28,33 @@
package org.ow2.frascati.intent.cxf;
import java.util.List;
import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.MessageContext;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
/**
* Abstract binding intent class for configuring a JAX-WS Handler.
*
* @author Philippe Merle - Inria
*/
public abstract class AbstractHandlerIntent
extends AbstractBindingIntentHandler
extends AbstractWSBindingIntent
{
// ----------------------------------------------------------------------
// Related to interface BindingIntentHandler.
// Related to class AbstractWSBindingIntent.
// ----------------------------------------------------------------------
/**
* Apply this binding intent on a proxy instance.
*
* @param proxy the proxy instance to configure.
* Configure an Apache CXF WS binding instance.
*
* @see BindingIntentHandler#apply(Object)
* @param binding the Apache CXF WS binding to configure.
*/
@Override
public final void apply(Object proxy)
protected void configure(Binding binding)
{
// Obtain the binding associated to the proxy instance.
Binding binding = null;
if(proxy instanceof BindingProvider) {
binding = ((BindingProvider)proxy).getBinding();
}
if(proxy instanceof Server) {
binding = ((JaxWsEndpointImpl)((Server)proxy).getEndpoint()).getJaxwsBinding();
}
if(binding == null) {
throw new IllegalArgumentException(proxy + " is not an Apache CXF Web Service!");
}
// Configure the binding.
// Add this handler to the proxy instance.
List<Handler> list = binding.getHandlerChain();
list.add(this.getHandler());
binding.setHandlerChain(list);
super.apply(proxy);
}
// ----------------------------------------------------------------------
......
/**
* OW2 FraSCAti SCA Intents for Apache CXF
* Copyright (C) 2012 Inria, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
* Author: Philippe Merle
*
* Contributor(s):
*
*/
package org.ow2.frascati.intent.cxf;
import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
/**
* Abstract binding intent class for configuring Apache CXF WS bindings.
*
* @author Philippe Merle - Inria
*/
public abstract class AbstractWSBindingIntent
extends AbstractBindingIntentHandler
{
// ----------------------------------------------------------------------
// Related to interface BindingIntentHandler.
// ----------------------------------------------------------------------
/**
* Apply this binding intent on a proxy instance.
*
* @param proxy the proxy instance to configure.
*
* @see BindingIntentHandler#apply(Object)
*/
@Override
public final void apply(Object proxy)
{
// Obtain the WS binding associated to the proxy instance.
Binding binding = null;
if(proxy instanceof BindingProvider) {
binding = ((BindingProvider)proxy).getBinding();
}
if(proxy instanceof Server) {
binding = ((JaxWsEndpointImpl)((Server)proxy).getEndpoint()).getJaxwsBinding();
}
if(binding == null) {
throw new IllegalArgumentException(proxy + " is not an Apache CXF Web Service!");
}
// Configure the binding.
configure(binding);
super.apply(proxy);
}
// ----------------------------------------------------------------------
// Internal methods.
// ----------------------------------------------------------------------
/**
* Configure an Apache CXF WS binding instance.
*
* @param binding the Apache CXF WS binding to configure.
*/
protected abstract void configure(Binding binding);
}
......@@ -39,7 +39,7 @@ import org.oasisopen.sca.annotation.Property;
* @author Philippe Merle - Inria
*/
public class LoadBalancingIntent
extends AbstractBindingIntentHandler
extends AbstractClientIntent
{
// ----------------------------------------------------------------------
// Internal state.
......@@ -65,31 +65,19 @@ public class LoadBalancingIntent
}
// ----------------------------------------------------------------------
// Related to interface BindingIntentHandler.
// Related to class AbstractClientIntent.
// ----------------------------------------------------------------------
/**
* Apply this binding intent on a proxy instance.
* Configure an Apache CXF client instance.
*
* @param proxy the proxy instance to configure.
*
* @see BindingIntentHandler#apply(Object)
* @param conduit the Apache CXF client to configure.
*/
@Override
public final void apply(Object proxy)
protected void configure(Client client)
{
Client client = null;
// Is the proxy a Apache CXF Web Service client?
// if(proxy instanceof org.apache.cxf.jaxws.JaxWsClientProxy) {
client = org.apache.cxf.frontend.ClientProxy.getClient(proxy);
if(client == null) {
throw new IllegalArgumentException(proxy + " is not an Apache CXF Web Service client!");
}
// Configure the client instance with the load balancing feature.
ldf.initialize(client, null);
super.apply(proxy);
}
// ----------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment