使用已弃用的http实现,可以从有效负载或属性中动态设置出站http端点上的URL:
public class AddAircraftFragment extends Fragment
{
RecyclerView recyclerView;
private static final int SELECT_PICTURE = 111;
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.fragment_add_aircraft, container, false);
recyclerView=(RecyclerView)rootView.findViewById(R.id.recyclerAircraftAdd);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
AircraftAdapter adapter = new AircraftAdapter();
recyclerView.setAdapter(adapter);
return rootView;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
BitmapFactory.Options btmapOptions;
if (requestCode == SELECT_PICTURE && resultCode == Activity.RESULT_OK) {
final Uri selectedImageUri = data.getData();
String tempPath = getPath(selectedImageUri, this.getActivity());
final Bitmap bm;
btmapOptions = new BitmapFactory.Options();
btmapOptions.inSampleSize = 2;
bm = BitmapFactory.decodeFile(tempPath, btmapOptions);
AircraftAdapter.bmp = bm;
}
}
public String getPath(Uri uri, Activity activity)
{
String[] projection = {MediaStore.MediaColumns.DATA};
Cursor cursor = activity.managedQuery(uri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
public void onAttach(Activity activity)
{
super.onAttach(activity);
}
public void onDetach()
{
super.onDetach();
}
是否可以使用新的http请求连接器执行此操作?
答案 0 :(得分:2)
是的,确实如此。这是一个简单的例子:
<http:request-config
name="HTTP_Request_Configuration"
host="#[flowVars.address]"
port="80"
basePath="/"
doc:name="HTTP Request Configuration"/>
<flow name="httpFlow">
...
<set-variable
variableName="address"
value="#[message.inboundProperties.'http.query.params'.site]"
doc:name="Set site address variable"/>
<http:request
config-ref="HTTP_Request_Configuration"
path="/"
method="GET"
doc:name="Get dynamic HTTP"/>
</flow>
只需使用您需要的MEL表达式定义主机属性。
主机= “#[flowVars.someVariable]”