日系框架之seasar2(S2JSF)---(中)

RequestDumpUtil.java

packageexamples.jsf.util;
importjava.util.Collections;
importjava.util.Enumeration;
importjava.util.Iterator;
importjava.util.Locale;
importjava.util.SortedSet;
importjava.util.TreeSet;
importjavax.servlet.ServletContext;
importjavax.servlet.http.Cookie;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpSession;
publicclassRequestDumpUtil{
  publicstaticvoiddumpRequestHeaders(finalStringBuffersb,
      finalHttpServletRequestrequest,finalStringlf,
      finalStringindent){
    for(finalIteratorit=toSortedSet(request.getHeaderNames())
        .iterator();it.hasNext();){
      finalStringname=(String)it.next();
      finalStringvalue=request.getHeader(name);
      sb.append(indent);
      sb.append("[header]").append(name);
      sb.append("=").append(value);
      sb.append(lf);
    }
  }
  publicstaticvoiddumpContextAttributes(finalStringBuffersb,
      finalServletContextservletContext,finalStringlf,
      finalStringindent){
    if(servletContext==null){
      return;
    }
    for(finalIteratorit=toSortedSet(servletContext.getAttributeNames())
        .iterator();it.hasNext();){
      finalStringname=(String)it.next();
      finalObjectattr=servletContext.getAttribute(name);
      sb.append(indent);
      sb.append("[context]").append(name).append("=").append(attr);
      sb.append(lf);
    }
  }
  publicstaticvoiddumpCookies(finalStringBuffersb,
      finalHttpServletRequestrequest,finalStringlf,
      finalStringindent){
    Cookiecookies[]=request.getCookies();
    if(cookies==null){
      cookies=newCookie[0];
    }
    for(inti=0;i<cookies.length;i++){
      sb.append(indent);
      sb.append("[cookie]").append(cookies[i].getName());
      sb.append("=").append(cookies[i].getValue());
      sb.append(lf);
    }
  }
  publicstaticvoiddumpRequestAttributes(finalStringBuffersb,
      finalHttpServletRequestrequest,finalStringlf,
      finalStringindent){
    for(finalIteratorit=toSortedSet(request.getAttributeNames())
        .iterator();it.hasNext();){
      finalStringname=(String)it.next();
      finalObjectattr=request.getAttribute(name);
      sb.append(indent);
      sb.append("[request]").append(name).append("=").append(attr);
      sb.append(lf);
    }
  }
  publicstaticvoiddumpSessionAttributes(finalStringBuffersb,
      finalHttpServletRequestrequest,finalStringlf,
      finalStringindent){
    finalHttpSessionsession=request.getSession(false);
    if(session==null){
      return;
    }
    for(finalIteratorit=toSortedSet(session.getAttributeNames())
        .iterator();it.hasNext();){
      finalStringname=(String)it.next();
      finalObjectattr=session.getAttribute(name);
      sb.append(indent);
      sb.append("[session]").append(name).append("=").append(attr);
      sb.append(lf);
    }
  }
  privatestaticSortedSettoSortedSet(finalEnumerationenu){
    finalSortedSetset=newTreeSet();
    set.addAll(Collections.list(enu));
    returnset;
  }
  publicstaticvoiddumpRequestParameters(finalStringBuffersb,
      finalHttpServletRequestrequest,finalStringlf,
      finalStringindent){
    for(finalIteratorit=toSortedSet(request.getParameterNames())
        .iterator();it.hasNext();){
      finalStringname=(String)it.next();
      sb.append(indent);
      sb.append("[param]").append(name).append("=");
      finalStringvalues[]=request.getParameterValues(name);
      for(inti=0;i<values.length;i++){
        if(i>0){
          sb.append(",");
        }
        sb.append(values[i]);
      }
      sb.append(lf);
    }
  }
  publicstaticvoiddumpRequestAndContextProperties(finalStringBuffersb,
      finalHttpServletRequestrequest,finalServletContextcontext,
      finalStringlf,finalStringindent){
    finalHttpSessionsession=request.getSession(false);
    sb.append(indent);
    sb.append("Requestclass="+request.getClass().getName()).append(
        ",instance=").append(request);
    sb.append(lf);
    sb.append(indent);
    sb.append("RequestedSessionId=")
        .append(request.getRequestedSessionId());
    sb.append(lf);
    sb.append(indent);
    if(session!=null){
      sb.append("SessionSessionId=").append(session.getId());
      sb.append(lf).append(indent);
    }
    sb.append("REQUEST_URI=").append(request.getRequestURI());
    sb.append(",SERVLET_PATH=").append(request.getServletPath());
    sb.append(lf).append(indent);
    if(session!=null){
      sb.append("Session::CreationTime=").append(
          session.getCreationTime());
      sb.append(",LastAccessedTime=").append(
          session.getLastAccessedTime());
      sb.append(",MaxInactiveInterval=").append(
          session.getMaxInactiveInterval());
      sb.append(lf).append(indent);
    }
    sb.append("CharacterEncoding="+request.getCharacterEncoding());
    sb.append(",ContentLength=").append(request.getContentLength());
    sb.append(",ContentType=").append(request.getContentType());
    sb.append(",Locale=").append(request.getLocale());
    sb.append(",Locales=");
    finalEnumerationlocales=request.getLocales();
    booleanfirst=true;
    while(locales.hasMoreElements()){
      finalLocalelocale=(Locale)locales.nextElement();
      if(first){
        first=false;
      }else{
        sb.append(",");
      }
      sb.append(locale.toString());
    }
    sb.append(",Scheme=").append(request.getScheme());
    sb.append(",isSecure=").append(request.isSecure());
    sb.append(lf).append(indent);
    sb.append("SERVER_PROTOCOL=").append(request.getProtocol());
    sb.append(",REMOTE_ADDR=").append(request.getRemoteAddr());
    sb.append(",REMOTE_HOST=").append(request.getRemoteHost());
    sb.append(",SERVER_NAME=").append(request.getServerName());
    sb.append(",SERVER_PORT=").append(request.getServerPort());
    sb.append(lf);
    sb.append(indent);
    sb.append("ContextRealPath=").append(context.getRealPath("/"));
    sb.append(lf).append(indent);
    sb.append("SERVER_SOFTWARE=").append(context.getServerInfo());
    sb.append(",ServletContextName=").append(
        context.getServletContextName());
    sb.append(",MajorVersion=").append(context.getMajorVersion());
    sb.append(",MinorVersion=").append(context.getMinorVersion());
    sb.append(lf).append(indent);
    sb.append("ContextPath=").append(request.getContextPath());
    sb.append(",REQUEST_METHOD=").append(request.getMethod());
    sb.append(",QUERY_STRING=").append(request.getQueryString());
    sb.append(",PathInfo=").append(request.getPathInfo());
    sb.append(",RemoteUser=").append(request.getRemoteUser());
    sb.append(lf);
  }
}

 

 

app.dicon

<?xmlversion="1.0"encoding="Shift_JIS"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container2.4//EN"
  "http://www.seasar.org/dtd/components24.dtd">
<components>
  <includepath="jsf.dicon"/>
  <includepath="teeda.dicon"/>
  <includepath="dao.dicon"/>
  <includepath="examples/jsf/dicon/allaop.dicon"/>
  <component
    class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister"
  >
    <propertyname="instanceDef">
      @org.seasar.framework.container.deployer.InstanceDefFactory@REQUEST
    </property>
    <initMethodname="addClassPattern">
      <arg>"examples.jsf.action.impl"</arg>
      <arg>".*ActionImpl"</arg>
    </initMethod>
  </component>
  <component
    class="org.seasar.framework.container.autoregister.AspectAutoRegister"
  >
    <propertyname="interceptor">actionInterceptorChain</property>
    <initMethodname="addClassPattern">
      <arg>"examples.jsf.action.impl"</arg>
      <arg>".*ActionImpl"</arg>
    </initMethod>
  </component>
  <component
    class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister"
  >
    <propertyname="instanceDef">
      @org.seasar.framework.container.deployer.InstanceDefFactory@REQUEST
    </property>
    <initMethodname="addClassPattern">
      <arg>"examples.jsf.dto"</arg>
      <arg>".*Dto"</arg>
    </initMethod>
  </component>
  <component
    class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister"
  >
    <initMethodname="addClassPattern">
      <arg>"examples.jsf.logic.impl"</arg>
      <arg>".*LogicImpl"</arg>
    </initMethod>
  </component>
  <component
    class="org.seasar.framework.container.autoregister.AspectAutoRegister"
  >
    <propertyname="interceptor">logicInterceptorChain</property>
    <initMethodname="addClassPattern">
      <arg>"examples.jsf.logic.impl"</arg>
      <arg>".*LogicImpl"</arg>
    </initMethod>
  </component>
</components>

 

 

 appMessages.properties和appMessages_ja.properties暂为空。

  convention.dicon

<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container2.4//EN"
  "http://www.seasar.org/dtd/components24.dtd">
<components>
  <componentclass="org.seasar.framework.convention.impl.NamingConventionImpl"/>
</components>

  jdbc.dicon(本例中未使用数据库,可按实际情况更改配置)

<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container2.4//EN"
  "http://www.seasar.org/dtd/components24.dtd">
<componentsnamespace="jdbc">
  <includepath="jta.dicon"/>
  <includepath="jdbc-extension.dicon"/>
  <componentclass="org.seasar.extension.jdbc.impl.BasicResultSetFactory"/>
  <componentclass="org.seasar.extension.jdbc.impl.ConfigurableStatementFactory">
    <arg>
      <componentclass="org.seasar.extension.jdbc.impl.BasicStatementFactory"/>
    </arg>
    <propertyname="fetchSize">100</property>
    <!--
    <propertyname="maxRows">100</property>
    -->
  </component>
  <!--
  <componentclass="org.seasar.extension.jdbc.impl.OracleResultSetFactory"/>
  <componentclass="org.seasar.extension.jdbc.impl.BooleanToIntStatementFactory"/>
  -->
  <!--forHSQLDB-->
  <componentname="xaDataSource"
    class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
    <propertyname="driverClassName">
      "org.hsqldb.jdbcDriver"
    </property>
    <propertyname="URL">
      "jdbc:hsqldb:hsql://localhost:9001"
      <!--
      "jdbc:hsqldb:file:"
        [email protected]@getBuildDir(@org.seasar.extension.dbcp.impl.ConnectionPoolImplTest@class).getCanonicalPath()
        +"/data/demo"
      -->
    </property>
    <propertyname="user">"sa"</property>
    <propertyname="password">""</property>
  </component>
  <!--forOracle-->
  <!--
  <componentname="xaDataSource"
    class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
    <propertyname="driverClassName">
      "oracle.jdbc.driver.OracleDriver"
    </property>
    <propertyname="URL">
      "jdbc:oracle:thin:@xxx:1521:xxx"
    </property>
    <propertyname="user">"xxx"</property>
    <propertyname="password">"xxx"</property>
  </component>
  -->
  <!--forPostgreSQL-->
  <!--
  <componentname="xaDataSource"
    class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
    <propertyname="driverClassName">
      "org.postgresql.Driver"
    </property>
    <propertyname="URL">
     "jdbc:postgresql://localhost/TEST"
    </property>
    <propertyname="user">"xxxx"</property>
    <propertyname="password">"xxxx"</property>
  </component>
  -->
  <!--MySQL
  -MySQL4.0以下でマルチバイト文字を扱う場合には,URL指定の後に,
    以下の接続パラメータを追加で指定してください.
    useUnicode=true
    characterEncoding=[MySQLのエンコーディングに対応した
    Javaのエンコーディング名]
    例:"jdbc:mysql://localhost:3306/test?useUnicode=true"+
    "&characterEncoding=Windows-31J"
  -MySQL5.0以降で,エンコーディングがeucjpmsの列を扱う場合には,
    URL指定の後に,以下の接続パラメータを追加で指定してください.
    characterEncoding=UTF-8またはWindows-31J
    characterSetResults=UTF-8またはWindows-31J
    例:"jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8"+
    "&characterSetResults=UTF-8"
    この指定をしない場合,Java側でUCS-2⇔EUC_JP_Solarisの変換が
    行なわれるため,ユーザー定義外字などの一部の文字が化けます.
    この指定をすることで,MySQL側でeucjpms⇔ucs2⇔utf8(cp932)の
    変換が行なわれ,Java側でUCS-2⇔UTF-8(Windows-31J)の変換が
    行なわれるようになります.この結果,文字化けを防げます.
    なおJISX0212(補助漢字)を使用する場合は,Windows-31Jではなく
    UTF-8を指定する必要があります.
  -上記以外の場合は,my.cnfでdefault-character-setの設定を適切に
    (cp932やutf8など.デフォルトのlatin1は不可)行なっていれば,
    文字化けは防げます.
  <componentname="xaDataSource"
    class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
    <propertyname="driverClassName">
      "com.mysql.jdbc.Driver"
    </property>
    <propertyname="URL">
      "jdbc:mysql://localhost:3306/test"
    </property>
    <propertyname="user">"xxx"</property>
    <propertyname="password">"xxx"</property>
  </component>
  -->
  <!--forSQLServer-->
  <!--
  <componentname="xaDataSource"
    class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
    <propertyname="driverClassName">
      "net.sourceforge.jtds.jdbc.Driver"
    </property>
    <propertyname="URL">
      "jdbc:jtds:sqlserver://localhost/TEST;instance=SQLEXPRESS"
    </property>
    <propertyname="user">"xxxx"</property>
    <propertyname="password">"xxxx"</property>
  </component>
  -->
  <componentname="connectionPool"
    class="org.seasar.extension.dbcp.impl.ConnectionPoolImpl">
    <propertyname="timeout">600</property>
    <propertyname="maxPoolSize">10</property>
    <propertyname="allowLocalTx">true</property>
    <destroyMethodname="close"/>
  </component>
  <componentname="DataSource"
    class="org.seasar.extension.dbcp.impl.DataSourceImpl"
  />
  <!--fromJNDI-->
  <!--
  <componentname="DataSource"
    class="javax.sql.DataSource">
    @org.seasar.extension.j2ee.JndiResourceLocator@lookup("java:comp/env/jdbc/DataSource")
  </component>
  -->
</components>

你可能感兴趣的:(框架,mysql,jdbc,JSF,HSQLDB)