読者です 読者をやめる 読者になる 読者になる

Apache HttpComponentsをSeasar2のコンポーネントとして扱う

seasar

次でできるっポイ

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
  "http://www.seasar.org/dtd/components24.dtd">
<components>
  <component name="httpScheme" class="org.apache.http.conn.scheme.Scheme">
    <arg>"http"</arg>
    <arg>@org.apache.http.conn.scheme.PlainSocketFactory@getSocketFactory()</arg>
    <arg>80</arg>
  </component>

  <component name="httpsScheme" class="org.apache.http.conn.scheme.Scheme">
    <arg>"https"</arg>
    <arg>@org.apache.http.conn.ssl.SSLSocketFactory@getSocketFactory()</arg>
    <arg>443</arg>
  </component>

  <component name="schemeRegistry" class="org.apache.http.conn.scheme.SchemeRegistry">
    <initMethod name="register"><arg>httpScheme</arg></initMethod>
    <initMethod name="register"><arg>httpsScheme</arg></initMethod>
  </component>

  <component name="httpParams" class="org.apache.http.params.BasicHttpParams">
    <initMethod>#self.(
      @org.apache.http.conn.params.ConnManagerParams@setMaxTotalConnections(#self, 10)
    )</initMethod>
  </component>

  <component name="clientConnectionManager" class="org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager">
    <arg>httpParams</arg>
    <arg>schemeRegistry</arg>
    <destroyMethod name="shutdown"></destroyMethod>
  </component>

  <component class="org.apache.http.impl.client.DefaultHttpClient">
    <arg>clientConnectionManager</arg>
    <arg>httpParams</arg>
  </component>
</components>