Commit c208dc88 authored by Philippe Merle's avatar Philippe Merle

Added a new binding intent for auto redirection of HTTP requests.

parent 35638efd
/**
* OW2 FraSCAti SCA Intents for Apache CXF
* Copyright (C) 2013 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.transports.http.configuration.HTTPClientPolicy;
import org.oasisopen.sca.annotation.Property;
/**
* Binding intent class for configuring Apache CXF auto redirection.
*
* @author Philippe Merle - Inria
*/
public class AutoRedirectIntent extends AbstractHTTPClientPolicyIntent
{
// ----------------------------------------------------------------------
// SCA configuration.
// ----------------------------------------------------------------------
@Property(name="AutoRedirect")
private boolean autoRedirect;
// ----------------------------------------------------------------------
// Related to class AbstractHTTPClientPolicyIntent.
// ----------------------------------------------------------------------
/**
* @see AbstractHTTPClientPolicyIntent#configure(HTTPClientPolicy)
*/
protected final void configure(HTTPClientPolicy httpClientPolicy)
{
httpClientPolicy.setAutoRedirect(this.autoRedirect);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- OW2 FraSCAti SCA Intents for Apache CXF -->
<!-- Copyright (C) 2013 Inria, University Lille I -->
<!-- -->
<!-- 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): -->
<!-- -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="AutoRedirect">
<include name="AutoRedirectIntent"/>
<property name="AutoRedirect">true</property>
</composite>
<?xml version="1.0" encoding="UTF-8"?>
<!-- OW2 FraSCAti SCA Intents for Apache CXF -->
<!-- Copyright (C) 2013 Inria, University Lille I -->
<!-- -->
<!-- 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): -->
<!-- -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="AutoRedirectIntent">
<service name="intent" promote="AutoRedirectIntent/intent"/>
<component name="AutoRedirectIntent" constrainingType="BindingIntentHandlerType">
<implementation.java class="org.ow2.frascati.intent.cxf.AutoRedirectIntent"/>
<property name="AutoRedirect" source="$AutoRedirect"/>
</component>
</composite>
/**
* OW2 FraSCAti SCA Intents for Apache CXF
* Copyright (C) 2012 Inria, University of Lille 1
* Copyright (C) 2012-2013 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
......@@ -48,4 +48,13 @@ public class FraSCAtiTest {
String response = tw.getWeatherForUser("vschiavoni");
System.out.println(response);
}
@Test
public void testAutoRedirectIntent() throws Exception {
FraSCAti frascati = FraSCAti.newFraSCAti();
Component component = frascati.getComposite("twitter-weather-auto-redirect-intent");
TwitterWeather tw = frascati.getService(component, "tw", TwitterWeather.class);
String response = tw.getWeatherForUser("vschiavoni");
System.out.println(response);
}
}
<?xml version="1.0" encoding="ISO-8859-15"?>
<!-- OW2 FraSCAti Examples: Twitter and Weather orchestration -->
<!-- Copyright (C) 2008-2013 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 -->
<!-- -->
<!-- Contributors: -->
<!-- -->
<composite name="twitter-weather-auto-redirect-intent"
xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
xmlns:frascati="http://frascati.ow2.org/xmlns/sca/1.1"
targetNamespace="http://frascati.ow2.org/weather">
<service name="tw" promote="orchestration/TwitterWeather"/>
<component name="orchestration">
<implementation.java class="org.ow2.frascati.examples.twitterweather.lib.Orchestration" />
<reference name="twitter">
<!-- Here the uri is incorrect as should be https://twitter.com but everything is ok as auto redirection is activated by the AutoRedirect intent. -->
<frascati:binding.rest uri="http://twitter.com"
requires="AutoRedirect Logging"
/>
</reference>
<reference name="decoder" target="decoder"/>
<reference name="weather">
<binding.ws wsdli:wsdlLocation="http://www.webservicex.net/globalweather.asmx?wsdl"
wsdlElement="http://www.webservicex.net#wsdl.port(GlobalWeather/GlobalWeatherSoap)"/>
</reference>
</component>
<component name="decoder">
<implementation.java class="org.ow2.frascati.examples.twitterweather.lib.DecoderImpl" />
</component>
</composite>
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