??xml version="1.0" encoding="utf-8" standalone="yes"?>国产亚洲日韩一区二区三区,亚洲国产成人精品激情,亚洲精品无码日韩国产不卡?V http://www.tkk7.com/bluesky/category/4546.html做好软gZ? #gcc -c helloworld.c -o helloworld.o //~译目标文g #gcc helloworld.o -o helloworld //~译成可执行exe #helloworld //q行exezh-cnSun, 21 Feb 2010 09:01:18 GMTSun, 21 Feb 2010 09:01:18 GMT60契约式开发webservice实践之spring-ws+Xmlbeanshttp://www.tkk7.com/bluesky/archive/2008/09/19/Writing_Contract-First_Web_Services_Use_Spring-ws_and_Xmlbeans.htmlblueskyblueskyFri, 19 Sep 2008 13:44:00 GMThttp://www.tkk7.com/bluesky/archive/2008/09/19/Writing_Contract-First_Web_Services_Use_Spring-ws_and_Xmlbeans.htmlhttp://www.tkk7.com/bluesky/comments/230022.htmlhttp://www.tkk7.com/bluesky/archive/2008/09/19/Writing_Contract-First_Web_Services_Use_Spring-ws_and_Xmlbeans.html#Feedback1http://www.tkk7.com/bluesky/comments/commentRss/230022.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/230022.html契约式开发webservice实践之spring-ws+Xmlbeans
1、开发环?br /> JDK1.4.2.*
Tomcat6.0.*
Spring-2.5.5
Spring-ws-1.5.4
XmlBeans-2.3


2、确定需要请求和应答的xml实例
Request.xml

<?xml version="1.0" encoding="UTF-8"?>
<wl_request  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://footmarktech.com/samples">
<flights>
 <flight><segment>PEK-CAN<segment><ticketNo>7841234656</ticketNo></flight>
 <flight><segment>PEK-CAN<segment><ticketNo>7841234656</ticketNo></flight>
</flights>
</wl_request>

Response.xml

<?xml version="1.0" encoding="UTF-8"?>
<wl_response  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://footmarktech.com/samples">
<flights>
 <flight><segment>PEK-CAN<segment><ticketNo>7841234656</ticketNo></flight>
 <flight><segment>PEK-CAN<segment><ticketNo>7841234656</ticketNo></flight>
</flights>
</wl_response>

3、设|XmlBeans环境
讄XMLBEANS_HOME
q将 %XMLBEANS_HOME%/bin增加到path路径?/p>

4、用xmlbeans tool准备数据契约xsd
Ҏ(gu)上一步骤h和应{的实例xml执行如下命o(h)
inst2xsd -enumerations never Request.xml Response.xml
生成的schema0.xsd文g命名?Airline.xsd

?Airline.xsd攑֜ ${web-context}/WEB-INF目录?br /> 5、用xmlbeans tool生成OXM数据映射对象
需要说明的是这些对象是跟Xmlbeans耦合比较紧的,不是POJO
执行如下命o(h)
scomp -out Airline.jar Airline.xsd

6、准备运行时和编译时jar?/p>


 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/acegi-security-1.0.7.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/activation-1.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/antlr-2.7.7.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/aopalliance-1.0.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/axiom-api-1.2.6.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/axiom-dom-1.2.6.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/axiom-impl-1.2.6.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/backport-util-concurrent-3.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/bsf-2.3.0.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/cglib-nodep-2.1_3.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-beanutils-1.7.0.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-codec-1.3.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-collections-3.2.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-configuration-1.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-digester-1.8.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-discovery-0.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-el-1.0.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-fileupload-1.2.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-httpclient-3.0.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-io-1.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-lang-2.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-logging-1.1.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-net-1.2.2.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-pool-1.3.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/commons-validator-1.3.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/concurrent-1.3.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/dom4j-1.6.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/ehcache-1.2.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/ezmorph-1.0.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/groovy-all-1.5.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/hibernate-3.2.6.ga.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/hsqldb-1.8.0.7.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/icu4j-3.4.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/jasypt-1.4.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/javassist-3.6.ga.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/jaxen-1.1.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/jaxrpc-1.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/jcaptcha-all-1.0-RC6.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/jcr-1.0.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/jdom-1.0.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/json-lib-2.2.1-jdk13.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/jta-spec1_0_1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/log4j-1.2.15.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/lucene-core-2.2.0.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/mail-1.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/mysql-connector-java-5.1.5-bin.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/ognl-2.7.2.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/oro-2.0.8.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/oscache-2.4.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/pdfbox-0.6.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/poi-3.0.1-FINAL-20070705.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/poi-contrib-3.0.1-FINAL-20070705.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/poi-scratchpad-3.0.1-FINAL-20070705.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/proxool-0.9.0RC3.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/serializer-2.7.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/slf4j-api-1.4.3.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/slf4j-log4j12-1.4.3.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/spring-2.5.5.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/stax-api-1.0.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/wsdl4j-1.6.2.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/wstx-asl-3.2.3.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xalan-2.7.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xercesImpl-2.8.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xfire-all-1.2.6.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xml-apis-1.3.04.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xom-1.1.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xpp3_min-1.1.3.4.0.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xstream-1.2.2.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/axis-saaj-1.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/axis-1.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/spring-oxm-1.5.4.jar" sourcepath="D:/maven-1.0.2/.maven/repository/springframework/srcs/spring-ws-1.5.4-with-dependencies.zip"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/spring-webmvc-2.5.5.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/spring-ws-core-1.5.4.jar" sourcepath="D:/maven-1.0.2/.maven/repository/springframework/srcs/spring-ws-1.5.4-with-dependencies.zip"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/spring-ws-security-1.5.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/spring-ws-support-1.5.4.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/spring-xml-1.5.4.jar" sourcepath="D:/maven-1.0.2/.maven/repository/springframework/srcs/spring-ws-1.5.4-with-dependencies.zip"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/jsr173_1.0_api.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/resolver.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xbean_xpath.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xbean.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xmlbeans-qname.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/xmlpublic.jar"/>
 <classpathentry kind="lib" path="web/src/context/WEB-INF/lib/Airline.jar"/>
 <classpathentry kind="output" path="web/src/context/WEB-INF/classes"/>


Spring-ws1.5.4必须使用springframework2.5版本以上
其对org.springframework.core.io.Resource版本要求较高
必须加入spring-webmvc-2.5.5.jar
org.springframework.web.servlet.FrameworkServlet?.5版本后被分到spring-webmvc.jar?q不包含于主spring包内

?可能有些jar包没有用?br /> 7、书写web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <display-name>Web</display-name>
 
 
 
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
 
 
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <servlet>
        <servlet-name>ws-spring-ws</servlet-name>
        <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
   </servlet>
  
  <servlet-mapping>
        <servlet-name>ws-spring-ws</servlet-name>
        <url-pattern>/spring-ws/*</url-pattern>
    </servlet-mapping>  
 

</web-app>

8、书写业务实?/p>

package demo1;

public class Order {
 private String id;

 public String getId() {
  return id;
 }

 public void setId(String id) {
  this.id = id;
 }
}

package demo1;

public interface OrderService {
 Order getOrder(String id);
}

 

package demo1;

public class OrderServiceImpl implements OrderService{
 public Order getOrder(String id) {
  Order order = new Order();
  order.setId(id);
  return order;
 }
 
 
}

书写spring配置攑֜classpath?br /> applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC
    "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

<beans default-autowire="no" default-lazy-init="false" default-dependency-check="none">
  <bean id="orderService" class="demo1.OrderServiceImpl"/>
</beans>

9、书写Spring-ws EndPoint

package demo1;

import org.springframework.oxm.Marshaller;
import org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint;

import com.footmarktech.samples.WlRequestDocument;
import com.footmarktech.samples.WlResponseDocument;

public class SampleMarshallingEndpoint extends
  AbstractMarshallingPayloadEndpoint {

 private final OrderService orderService;

 public SampleMarshallingEndpoint(OrderService orderService,
   Marshaller marshaller) {
  super(marshaller);
  this.orderService = orderService;
 }

 protected Object invokeInternal(Object request) throws Exception {
  com.footmarktech.samples.WlRequestDocument ab = null;
  ab = (WlRequestDocument)request;
  
  //TODO invoke orderService
  
  WlResponseDocument rs = (WlResponseDocument) WlResponseDocument.Factory.newInstance();
  rs.addNewWlResponse().addNewFlights().addNewFlight().setTicketNo(ab.getWlRequest().getFlights().getFlightArray(0).getTicketNo());
  return rs;
 }
}


10、书写ws-spring-ws-servlet.xml
攄?{web-context}/WEB-INF目录?/p>


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">


<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
 <property name="payloadCaching" value="true"/>
</bean>

<bean id="xmlBeansMarshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMarshaller" />

<bean id="orderEndPoint" class="demo1.SampleMarshallingEndpoint">
        <constructor-arg><ref bean="orderService"/></constructor-arg>
        <constructor-arg><ref bean="xmlBeansMarshaller"/></constructor-arg>
</bean>

<bean id="payloadMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
        <property name="defaultEndpoint" ref="orderEndPoint"/>
</bean>

 
   
<bean id="echo" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
   <property name="schema">
     <bean class="org.springframework.xml.xsd.SimpleXsdSchema">
       <property name="xsd" value="/WEB-INF/Airline.xsd"/>
     </bean>
   </property>
   <property name="portTypeName" value="Echo"/>
   <property name="locationUri" value="http://localhost:8080/ss1/spring-ws/echo/services"/>
 </bean>

</beans>

11、开发客L(fng)

配置a(chn)pplicationContext1.xml攄?classpath demo1.client包内


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">


<bean id="xmlBeansMarshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMarshaller" />

<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
 <property name="payloadCaching" value="true"/>
</bean>   
   
<bean id="webServiceTemplate1" class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory" />
<property name="marshaller" ref="xmlBeansMarshaller" />
<property name="unmarshaller" ref="xmlBeansMarshaller" />
<property name="messageSender">
 <bean class="org.springframework.ws.transport.http.CommonsHttpMessageSender">
  <property name="readTimeout" value="0" />
 </bean>
</property>
<property name="defaultUri" value="http://localhost:8080/ss1/spring-ws/echo/services" />
</bean>
   
   

</beans>

 

 

package demo1.client;

import java.io.File;
import java.io.IOException;

import javax.xml.transform.Source;

import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.jdom.JDOMException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.Resource;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.xml.transform.ResourceSource;
import org.springframework.xml.transform.StringResult;

import com.footmarktech.smscenter.webservice.SendSMDocument;
import com.footmarktech.smscenter.webservice.SendSMResponseDocument;
import com.footmarktech.samples.WlRequestDocument;
import com.footmarktech.samples.WlResponseDocument;

public class EchoClient {
 public static void RequestSpring() {
  ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext1.xml", EchoClient.class);
  WebServiceTemplate webServiceTemplate = (WebServiceTemplate) applicationContext
    .getBean("webServiceTemplate1");
  WlRequestDocument request = WlRequestDocument.Factory.newInstance();
  request.addNewWlRequest().addNewFlights().addNewFlight().setTicketNo(new Long(1231235555).longValue());
  
  WlResponseDocument response = (WlResponseDocument)webServiceTemplate.marshalSendAndReceive(request);
  System.out.println(response.getWlResponse().getFlights().getFlightArray(0).getTicketNo());
 }

 public static void main(String[] args) throws IOException, JDOMException {
  RequestSpring();

 }

}

12、参考资?br /> http://xmlbeans.apache.org/
http://static.springframework.org/spring-ws/sites/1.5/reference/html/index.html
http://mdasgin.blogspot.com/2008/06/web-servisleri-bir-makinede-sunulan.html
http://www.infoq.com/cn/articles/arjen-poutsma-spring-ws
http://www.infoq.com/cn/articles/sosnoski-code-first

下蝲pdf版文?/a>



bluesky 2008-09-19 21:44 发表评论
]]>
Extension Tapestry4`s restart service to clear my login cookieshttp://www.tkk7.com/bluesky/archive/2008/03/24/188261.htmlblueskyblueskyMon, 24 Mar 2008 07:34:00 GMThttp://www.tkk7.com/bluesky/archive/2008/03/24/188261.htmlhttp://www.tkk7.com/bluesky/comments/188261.htmlhttp://www.tkk7.com/bluesky/archive/2008/03/24/188261.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/188261.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/188261.html接上?自定义一个logout service 把我的login cookies 清楚?

Tapestry .java

package common.tapestry;

public final  class Tapestry {
  public static final String LOGOUT_SERVICE = "logout";
}

LogoutService.java
package common.tapestry.engine;

import java.io.IOException;

import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.engine.RestartService;

import common.tapestry.Tapestry;

public class LogoutService extends RestartService {
 private LoginCookiesManager loginCookiesManager;


 public void setLoginCookiesManager(
   LoginCookiesManager loginCookiesManager) {
  this.loginCookiesManager = loginCookiesManager;
 }

 public void service(IRequestCycle cycle) throws IOException {
  loginCookiesManager.removeCookies();
  super.service(cycle);
 }

 public String getName() {
  return Tapestry.LOGOUT_SERVICE;
 }
}

hivemodule.xml
<?xml version="1.0"?>
<module id="common.tapestry" version="1.0.0">

 <!-- extends tapestry RestartService and clear the login cookies info-->
    <service-point id="LogoutService" interface="org.apache.tapestry.engine.IEngineService">
        <invoke-factory>
            <construct class="common.tapestry.engine.LogoutService">
             <set-service property="request" service-id="tapestry.globals.HttpServletRequest" />
                <set-service property="response" service-id="tapestry.globals.HttpServletResponse" />
                <set-object property="servletPath" value="app-property:org.apache.tapestry.servlet-path" />
                <set-object property="linkFactory" value="infrastructure:linkFactory" />
                <set-object property="loginCookiesManager" value="service:common.tapestry.LoginCookiesManager"/>
             </construct>
        </invoke-factory>
    </service-point>

    <contribution configuration-id="tapestry.services.ApplicationServices">
        <service name="logout" object="service:common.tapestry.LogoutService" />
    </contribution>

</module>

in your Pages
<a jwcid="@ServiceLink" href="#" service="ognl:@common.tapestry.Tapestry@LOGOUT_SERVICE" target="_top">退?lt;/a>

pd?br /> 作者其他blog  http://oxyc.spaces.live.com
                        http://hiok.blog.sohu.com



bluesky 2008-03-24 15:34 发表评论
]]>
How to use cookies in tapestry4? my Tapestry4.1.5`LoginCookiesManagerImplhttp://www.tkk7.com/bluesky/archive/2008/03/24/188254.htmlblueskyblueskyMon, 24 Mar 2008 07:26:00 GMThttp://www.tkk7.com/bluesky/archive/2008/03/24/188254.htmlhttp://www.tkk7.com/bluesky/comments/188254.htmlhttp://www.tkk7.com/bluesky/archive/2008/03/24/188254.html#Feedback5http://www.tkk7.com/bluesky/comments/commentRss/188254.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/188254.htmlHow to use cookies in tapestry4? my Tapestry4.1.5`LoginCookiesManagerImpl

思\
首先BasePage是需要登陆的 protected ,
BasePage实现org.apache.tapestry.event.PageValidateListenerҎ(gu),判断asm对象Visit是否已经登陆
如没visit==null,去cookies扑֛用户名和密码从cycle中获得Login面
Login面实现common.tapestry.IConstructVisit接口。LoginPage登陆时保存用户名密码到cookies?q对cookies的值加?
cookies的key是baseUrl+key,取回时对cookiesD?加密解密的password攑ֈApplication的meta信息?

实现代码如下
抽象接口LoginCookiesManager

package common.tapestry.engine;

public interface LoginCookiesManager {
 
 String APPLICATION_META_KEY_DEFAULT_COOKIES_IS_ENCRYPTION = "common.tapestry.default-cookies-encrypt";//是否需要加?默认加密
 String APPLICATION_META_KEY_DEFAULT_COOKIES_ENCRYPTION_KEY = "common.tapestry.default-cookies-encryption-key";//加密的password

 public static final String COOKIES_KEY_LOGIN_USERNAME = "USERNAME";
 public static final String COOKIES_KEY_LOGIN_PASSWORD = "PASSWORD";
 
 /**
  * 用户名和密码写入cookies
  * @param username
  * @param password
  * @param maxAge
  */
 void writeCookies(String username,String password,int maxAge);
 /**
  * 清除用户名和密码cookies
  */
 void removeCookies();
 /**
  * 从cookies中获得用户名
  * @return
  */
 String getUsername();
 /**
  * 从cookies中获得密?br />   * @return
  */
 String getPassword();
}

LoginCookiesManagerImpl 实现

package common.tapestry.engine;

import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.tapestry.engine.IPropertySource;
import org.apache.tapestry.services.AbsoluteURLBuilder;
import org.apache.tapestry.services.CookieSource;
import org.apache.tapestry.web.WebRequest;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.exceptions.EncryptionOperationNotPossibleException;

public class LoginCookiesManagerImpl implements LoginCookiesManager {
 private static StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor();
 private IPropertySource applicationPropertySource;
 private CookieSource cookieSource;
 private WebRequest request;
 private AbsoluteURLBuilder absoluteURLBuilder;

 public void setApplicationPropertySource(
   IPropertySource applicationPropertySource) {
  this.applicationPropertySource = applicationPropertySource;
  String encrypKey = getCookiesEncryptionKey();
  standardPBEStringEncryptor.setPassword(encrypKey);
 }

 private String decrypt(String value) {
  String tmp = value;
  try {
   tmp = standardPBEStringEncryptor.decrypt(value);
  } catch (EncryptionOperationNotPossibleException e) {
   throw new ApplicationRuntimeException("please clear your cookies");
  }
  return tmp;
 }

 private String encrypt(String value) {
  return standardPBEStringEncryptor.encrypt(value);
 }

 private String getCookiesEncryptionKey() {
  String temp = applicationPropertySource
    .getPropertyValue(APPLICATION_META_KEY_DEFAULT_COOKIES_ENCRYPTION_KEY);
  return (temp != null) ? temp : "crypassword";
 }

 private boolean isCookiesEncryption() {
  String temp = applicationPropertySource
    .getPropertyValue(APPLICATION_META_KEY_DEFAULT_COOKIES_IS_ENCRYPTION);
  return (temp != null) ? Boolean.valueOf(temp).booleanValue() : true;
 }

 public void removeCookies() {
  String cookiesKeyLogin_username = generateApplicationCookiesKey_Login__Username();
  String cookiesKeyLogin_password = generateApplicationCookiesKey_Login__Password();
  cookieSource.removeCookieValue(cookiesKeyLogin_username);
  cookieSource.removeCookieValue(cookiesKeyLogin_password);
 }

 public void writeCookies(String username, String password, int maxAge) {
  writeCookiesValue_Login__Username(username, maxAge);
  writeCookiesValue_Login__Password(password, maxAge);
 }

 public String getUsername() {
  String value = cookieSource
    .readCookieValue(generateApplicationCookiesKey_Login__Username());
  if (isCookiesEncryption()) {
   value = decrypt(value);
  }
  return value;
 }

 public String getPassword() {
  String value = cookieSource
    .readCookieValue(generateApplicationCookiesKey_Login__Password());
  if (isCookiesEncryption()) {
   value = decrypt(value);
  }
  return value;
 }

 private void writeCookiesValue_Login__Username(String username, int maxAge) {
  String key = generateApplicationCookiesKey_Login__Username();
  String value = username;
  if (isCookiesEncryption()) {
   value = encrypt(username);
  }
  cookieSource.writeCookieValue(key, value, maxAge);
 }

 private void writeCookiesValue_Login__Password(String password, int maxAge) {
  String key = generateApplicationCookiesKey_Login__Password();
  String value = password;
  if (isCookiesEncryption()) {
   value = encrypt(password);
  }
  cookieSource.writeCookieValue(key, value, maxAge);
 }

 private String generateApplicationCookiesKey_Login__Username() {
  return generateApplicationCookiesKey(COOKIES_KEY_LOGIN_USERNAME);
 }

 private String generateApplicationCookiesKey_Login__Password() {
  return generateApplicationCookiesKey(COOKIES_KEY_LOGIN_PASSWORD);
 }

 private String generateApplicationCookiesKey(String key) {
  String contextPath = request.getContextPath();
  return absoluteURLBuilder.constructURL(contextPath + "/") + key;
 }

 public void setCookieSource(CookieSource cookieSource) {
  this.cookieSource = cookieSource;
 }

 public void setRequest(WebRequest request) {
  this.request = request;
 }

 public void setAbsoluteURLBuilder(AbsoluteURLBuilder absoluteURLBuilder) {
  this.absoluteURLBuilder = absoluteURLBuilder;
 }

}

hivemodule.xml配置

<?xml version="1.0"?>
<module id="common.tapestry" version="1.0.0">
<service-point id="LoginCookiesManager" interface="common.tapestry.engine.LoginCookiesManager">
<invoke-factory>
   <construct class="common.tapestry.engine.LoginCookiesManagerImpl" >
     <set-object property="cookieSource" value="infrastructure:cookieSource"/>
     <set-service property="absoluteURLBuilder" service-id="tapestry.request.AbsoluteURLBuilder"/>
              <set-service property="request" service-id="tapestry.globals.WebRequest"/>  
              <set-object property="applicationPropertySource" value="service:tapestry.props.ApplicationPropertySource"/>             
      </construct>
  </invoke-factory> 
</service-point>

<contribution configuration-id="tapestry.Infrastructure">
    <property name="loginCookiesManager" object="service:common.tapestry.LoginCookiesManager"/>
</contribution>
</module>

使用

在BasePage中获得该service

public LoginCookiesManager getLoginCookiesManager() {
  LoginCookiesManager svc = (LoginCookiesManager) getRequestCycle().getInfrastructure().getProperty("loginCookiesManager");
  return svc;
 }
 
/**
  * 判断用户是否已经登陆
  *
  * @return
  */
 private boolean isUserLoggedIn() {
  Object asmVisit = this.getRequestCycle().getInfrastructure().getApplicationStateManager().get(ASM_VISIT);

  if (!(asmVisit instanceof IVisit)) {
   throw new ApplicationRuntimeException(
     "The visit class must implements " + IVisit.class);
  }
  IVisit visit = (IVisit) asmVisit;
  if (visit == null || (visit != null && !visit.isLoggedIn())) {
   IPage loginPage = getRequestCycle().getPage(PAGE_LOGIN);
   if (loginPage instanceof IConstructVisit) {
    //从cookies中找回用户名和密?br />     String cookiesLoginUsername = getLoginCookiesManager().getUsername();
    String cookiesLoginPassword = getLoginCookiesManager().getPassword();
    IConstructVisit constructVisit = (IConstructVisit) loginPage;
    visit = constructVisit.doConstructVisit(this.getRequestCycle(),
      cookiesLoginUsername, cookiesLoginPassword);
   } else {
    throw new ApplicationRuntimeException("The " + PAGE_LOGIN
      + " class must implements " + IConstructVisit.class);
   }
  }
  if (visit == null)
   return Boolean.FALSE.booleanValue();
  return visit.isLoggedIn();
 } 


Logincdd现如下接?br /> package common.tapestry;

import org.apache.tapestry.IRequestCycle;

public interface IConstructVisit {
 public IVisit doConstructVisit(IRequestCycle cycle, String username,String password);
}

 
pd?br /> 其他blog地址  http://oxyc.spaces.live.com/
                         http://hiok.blog.sohu.com



bluesky 2008-03-24 15:26 发表评论
]]>
通讯名词解释http://www.tkk7.com/bluesky/archive/2006/06/09/51613.htmlblueskyblueskyFri, 09 Jun 2006 01:42:00 GMThttp://www.tkk7.com/bluesky/archive/2006/06/09/51613.htmlhttp://www.tkk7.com/bluesky/comments/51613.htmlhttp://www.tkk7.com/bluesky/archive/2006/06/09/51613.html#Feedback2http://www.tkk7.com/bluesky/comments/commentRss/51613.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/51613.html  WCDMAQ指直接扩频的码分多址复用方式Q一U适用于数字蜂H移动通信的新技术?
  CDMA2000Q指多蝲波的码分多址复用方式Q一U适用于数字蜂H移动通信的新技术?
  GSMQ?指一U蜂H数字移动通信pȝQv源于泛欧标准Q是目前Ud通信应用最多的技术体制?
  ATMQ?异步传输模式QATM交换机是未来宽带l合业务数据|中的核?j)设?
  CATVQ指以有U的形式传输、分配电(sh)视、调频信号及(qing)其它信息l用L(fng)pȝ?
  IPQ一U互联网协议Q是分组的非面向q接的数据传输协?
  STPQ?信o(h)转换点,在信令网中用于{接信?
  SDHQ?是一套可q行同步数字传输、复用和交叉q接的标准化数字信号传输体制
  DWDMQ?密集波分复用Q指在光U的同一H口中信道间隔较?yu)的光L分复用?
  3GQ指W三代移动网l,在用户高速移动状态时的峰值速率可达144KbpsQ处于步行状态时峰值速率可达384 KpbsQ处于静(rn)止状态时峰值速率可达2 MbpsQ不q有些初始网l徏设仅支持64 Kbps。ITU通过其IMT-2000目和一些关键标准组l如3GPP?GPP2来协?G标准?nbsp;
  ASICQ指专用集成?sh)\Q专门设计以执行一个或多个特定功能的集成电(sh)路?nbsp;
  ATMQ指异步传输模式Q基于固定大分l数据传输的|络技术。分l长度短固定,使ATM讑֤能在同一|络中传输视频、话韛_数据Q防止Q何一U数据信号霸占整个线路?
  骨干|:(x)指网l中承蝲高密度大量信号的组成部分。交换网l的骨干|一般包括主q线路由器和交换机,数据|络的骨q网一般包括本地环间的主链路?nbsp;
  宽带Q指描述一个系l覆盖很宽的频率范围的词汇,比话音信道宽很多Q亦U「宽频」?
  BWAQ指宽带无线接入Q一U宽带点对多Ҏ(gu)UK信业务Q运行的频带?GHz?0GHz之间Q因应「最后一里」话韟뀁数据和视频业务{高速业务进行优化,作ؓ(f)q接用户和运营商本地交换机的可选择的另一U进|技术?nbsp;
  CDMAQ指码分多址Q是2GUd通信技术标准之一Q属于扩频技术标准,Ҏ(gu)有的话音和数据位分配一个伪随机QPNQ码Q通过扰码方式在空中发送编码话韻Iq按照原始格式对话音q行译码。对每个发射机分配一个独特的相关码,可以使多个对话共享同一频谱?nbsp;
  CDMA2000 1xQ指以CDMAOne标准提供增强话音定w的技术规|峰值数据速率最高可? MbpsQ相关的规格包括1xRTTQ无U传输技术)(j)Q?xEVDOQ纯数据版)(j)?xEVDVQ话x(chng)据版Q?nbsp;
  DWDMQ指密集波分复用pȝQ能够一根光U承载多个数据信道(或L长)(j)。商用DWDMpȝ目前已经辑ֈ100个信道?nbsp;
  DSLQ指数字用户U,在本地环路或用户U上传送数字数据的技术,亦称xDSLQ如ADSL、HDSL、VDSL、MDSL和RDSL?nbsp;
  GPRSQ指通用分组无线业务Q一UETSI GSMW?+阶段的数据分l无U接入技术规|其无U接口支持共享媒介分l接入,而不同于GSM的专用信道拨h入。GPRS是徏讑֜已有的GSM|络架构之上Q需要添加新的网l元素来q接核心(j)|和公众分组|络?nbsp;
  GSMQ指h于欧z的一U全球蜂H移动电(sh)话通信pȝQ已l在170多个国家|络Q用TDMA无线传播技术?nbsp;
  NGNQ指下一代网l,以数据分lؓ(f)基础的网l,能够提供多种业务Q利用多U宽带传送技术,支持用户无限制地接入C同服务提供商Q能够支持普通的Ud方式Q不间断的向用户提供业务?nbsp;
  PCSQ指个h通信pȝQؓ(f)本集团基于PHS技术的无线本地接入pȝQ目前被中国?sh)信和中国网通采用?nbsp;
  PSTNQ指公共交换?sh)话|,沿用已久的国际电(sh)话系l,利用铜缆通过?sh)\交换q接传送话韛_数据?路由器:(x)指一U通信讑֤Q可在网l中选择数据的传送\径?nbsp;
  软交换:(x)指Y件交换的~略语,是一U应用协议接口,用于q接传统的PSTN|和IP|络Qƈ对包括话韟뀁传真、数据和视频的流量进行管理?nbsp;
  TD-SCDMAQ指时分同步码分多址Q是中国倡导的第三代Ud通信技术,支持话音和数据?nbsp;
  WCDMAQ指宽带CDMAQ是3G数字Ud|络的UMTS标准Q采用CDMA技术,提供增强的话韛_量,理论上数据速率的峰值可? Mbps?nbsp;
  无线本地接入pȝQ指提供无线接入到固|的讑֤Q支持局部范围内的有限移动。无U本地接入系l的命名Ҏ(gu)不同生厂商或采用的技术不同而有不同命名。如本集团称自n的无U本地接入系lؓ(f)PCS讑֤Q基于PHS技术而开发)(j)Q但其它供货商可能称cM讑֤为PHS或者PAS讑֤。此外,无线本地接入pȝq可以基于其它技术而开发,如CDMA450 WLL和SCDMA?



bluesky 2006-06-09 09:42 发表评论
]]>
猎h带狗q捕Q兔子刚?0步,猎狗去追兔子Q已知猎狗跑2步的旉兔子?步,猎狗?步的距离与兔子跑7步的距离相等。那么猎狗跑多少步可以捕莯只兔子?http://www.tkk7.com/bluesky/archive/2006/05/19/47036.htmlblueskyblueskyFri, 19 May 2006 05:11:00 GMThttp://www.tkk7.com/bluesky/archive/2006/05/19/47036.htmlhttp://www.tkk7.com/bluesky/comments/47036.htmlhttp://www.tkk7.com/bluesky/archive/2006/05/19/47036.html#Feedback1http://www.tkk7.com/bluesky/comments/commentRss/47036.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/47036.html猎h带狗q捕Q兔子刚?0步,猎狗去追兔子Q已知猎狗跑2步的旉兔子?步,猎狗?步的距离与兔子跑7步的距离相等。那么猎狗跑多少步可以捕莯只兔子?
距离80?br />2a/x = 3b/y
-> 2ay = 3bx
-> x = 2ay/3b

4*a = 7*b
->a = 7b/4

带入x = 2ay/3b
x = 2*7by/12b
x = 7y/6

 (tng)

b = 4a/7


(n*a - 80*b)/y = n*a/x

n*a*x - 80*b*x = n*a*y
n*a*(x-y) = 80*b*x
n = 80*b*x
 (tng) (tng) ------------
 (tng) (tng) (tng) a*(x-y)
 (tng) (tng) =  (tng)80 *4a/7* 7y/6
 (tng) (tng) ----------------
 (tng) (tng) a* (7y/6 - y)

 (tng)= 80*4/7 *7y/6
 (tng)---------------
 (tng)1y/6
 (tng)= 80*4=320

 (tng)

 (tng)

 (tng)



bluesky 2006-05-19 13:11 发表评论
]]>
使用Maven的顺?/title><link>http://www.tkk7.com/bluesky/archive/2006/03/29/38008.html</link><dc:creator>bluesky</dc:creator><author>bluesky</author><pubDate>Wed, 29 Mar 2006 03:44:00 GMT</pubDate><guid>http://www.tkk7.com/bluesky/archive/2006/03/29/38008.html</guid><wfw:comment>http://www.tkk7.com/bluesky/comments/38008.html</wfw:comment><comments>http://www.tkk7.com/bluesky/archive/2006/03/29/38008.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/bluesky/comments/commentRss/38008.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/bluesky/services/trackbacks/38008.html</trackback:ping><description><![CDATA[check-out from cvs first<br /><br />修改修改 project.properties<br /><br />1.create-domain<br />2.create-launcher<br />3.启动weblogic<br />4.deploy-datasource<br />5.deploy<br /><br />ok<br /><img src ="http://www.tkk7.com/bluesky/aggbug/38008.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/bluesky/" target="_blank">bluesky</a> 2006-03-29 11:44 <a href="http://www.tkk7.com/bluesky/archive/2006/03/29/38008.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>3?5日工作ȝ http://www.tkk7.com/bluesky/archive/2006/03/16/35536.htmlblueskyblueskyThu, 16 Mar 2006 01:04:00 GMThttp://www.tkk7.com/bluesky/archive/2006/03/16/35536.htmlhttp://www.tkk7.com/bluesky/comments/35536.htmlhttp://www.tkk7.com/bluesky/archive/2006/03/16/35536.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/35536.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/35536.htmlencountered SQLException [weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool cp_baggage to allocate to applications, please increase the size of the pool and retry..]; nested exception is weblogic.jdbc.extensions.PoolLimitSQLException: weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool cp_baggage to allocate to applications, please increase the size of the pool and retry..{ exceptionClass=org.springframework.jdbc.UncategorizedSQLException}


服务->q接~冲?>最大容?>5


问一? after checkout a new project from cvs how to use Maven to deploy the web ear to the weblogic? what is the first,second 

copy build.properties.sample to build.properties
then modify it to fit your environment.

2. install weblogic plugin for weblogic (if not installed ) by
maven plugin:download -DartifactId=maven-weblogic-plugin -DgroupId=footmark-plugins -Dversion=0.1.1

3. invoking maven weblogic:prepare-domain to prepare weblogic runtime 

4.invoking maven:create-launcher to create weblogic launcher which can be used to debug or run weblogic application server 

that's all 

catch me immediately if you have further more questions.

ok,i see



bluesky 2006-03-16 09:04 发表评论
]]>
[转蝲]Java性能优化技巧集?/title><link>http://www.tkk7.com/bluesky/archive/2006/02/15/30812.html</link><dc:creator>bluesky</dc:creator><author>bluesky</author><pubDate>Wed, 15 Feb 2006 07:08:00 GMT</pubDate><guid>http://www.tkk7.com/bluesky/archive/2006/02/15/30812.html</guid><wfw:comment>http://www.tkk7.com/bluesky/comments/30812.html</wfw:comment><comments>http://www.tkk7.com/bluesky/archive/2006/02/15/30812.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/bluesky/comments/commentRss/30812.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/bluesky/services/trackbacks/30812.html</trackback:ping><description><![CDATA[<P> </P> <P><BR>===================================<BR>提纲:<BR>===================================<BR>一、通用?BR>  1.1 不用new关键词创建类的实?BR>  1.2 使用非阻塞I/O<BR>  1.3 慎用异常<BR>  1.4 不要重复初始化变?BR>  1.5 量指定cȝfinal修饰W?BR>  1.6 量使用局部变?BR>  1.7 乘法和除?BR>二、J2EE?BR>  2.1 使用~冲标记<BR>  2.2 始终通过?x)话Bean讉K实体Bean<BR>  2.3 选择合适的引用机制<BR>  2.4 在部|描q器中设|只d?BR>  2.5 ~冲对EJB Home的访?BR>  2.6 为EJB实现本地接口<BR>  2.7 生成主键<BR>  2.8 ?qing)时清除不再需要的?x)?BR>  2.9 在JSP面中关闭无用的?x)?BR>  2.10 Servlet与内存(sh)?BR>  2.11 HTTP Keep-Alive<BR>  2.12 JDBC与Unicode<BR>  2.13 JDBC与I/O<BR>  1.14 内存数据?BR>三、GUI?BR>  3.1 用JAR压羃cL?BR>  3.2 提示Applet装入q程<BR>  3.3 在画出图形之前预先装入它<BR>  3.4 覆盖updateҎ(gu)<BR>  3.5 延迟重画操作<BR>  3.6 使用双缓冲区<BR>  3.7 使用BufferedImage<BR>  3.8 使用VolatileImage<BR>  3.9 使用Window Blitting<BR>四、补充资?BR>===================================</P> <P>正文:<BR>===================================</P> <P> </P> <P> </P> <P>一、通用?/P> <P><BR>"通用?讨论的问题适合于大多数Java应用?/P> <P><BR>1.1 不用new关键词创建类的实?/P> <P><BR>用new关键词创建类的实例时Q构造函数链中的所有构造函数都?x)被自动调用。但如果一个对象实C(jin)Cloneable接口Q我们可以调用它的clone()Ҏ(gu)。clone()Ҏ(gu)不会(x)调用McL造函数?/P> <P><BR>在用设计模式(Design PatternQ的场合Q如果用Factory模式创徏对象Q则改用clone()Ҏ(gu)创徏新的对象实例非常单。例如,下面是Factory模式的一个典型实玎ͼ(x)</P> <P><BR>public static Credit getNewCredit() {return new Credit();} <BR> </P> <P><BR>改进后的代码使用clone()Ҏ(gu)Q如下所C:(x)</P> <P><BR>private static Credit BaseCredit = new Credit();public static Credit getNewCredit() {return (Credit) BaseCredit.clone();} <BR> </P> <P> </P> <P>上面的思\对于数组处理同样很有用?/P> <P><BR>1.2 使用非阻塞I/O</P> <P><BR>版本较低的JDK不支持非dI/O API。ؓ(f)避免I/OdQ一些应用采用了(jin)创徏大量U程的办法(在较好的情况下,?x)用一个缓冲池Q。这U技术可以在许多必须支持q发I/O的应用中见刎ͼ如Web服务器、报价和拍卖应用{。然而,创徏JavaU程需要相当可观的开销?/P> <P><BR>JDK 1.4引入?jin)非d的I/O库(java.nioQ。如果应用要求用版本较早的JDKQ在q里有一个支持非dI/O的Y件包?/P> <P><BR>请参见Sun中国|站的《调整Java的I/O性能》?/P> <P><BR>1.3 慎用异常</P> <P><BR>异常Ҏ(gu)能不利。抛出异帔R先要创徏一个新的对象。Throwable接口的构造函数调用名为fillInStackTrace()的本圎ͼNativeQ方法,fillInStackTrace()Ҏ(gu)(g)查堆栈,攉调用跟踪信息。只要有异常被抛出,VM必调整调用堆栈,因ؓ(f)在处理过E中创徏?jin)一个新的对象?/P> <P><BR>异常只能用于错误处理Q不应该用来控制E序程?/P> <P><BR>1.4 不要重复初始化变?/P> <P><BR>默认情况下,调用cȝ构造函数时Q?Java?x)把变量初始化成定的|(x)所有的对象被设|成nullQ整数变量(byte、short、int、longQ设|成0Qfloat和double变量讄?.0Q逻辑D|成false。当一个类从另一个类zӞq一点尤其应该注意,因ؓ(f)用new关键词创Z个对象时Q构造函数链中的所有构造函数都?x)被自动调用?/P> <P><BR>1.5 量指定cȝfinal修饰W?/P> <P><BR>带有final修饰W的cL不可z的。在Java核心(j)API中,有许多应用final的例子,例如java.lang.String。ؓ(f)StringcL定final防止?jin)h们覆盖length()Ҏ(gu)?/P> <P><BR>另外Q如果指定一个类为finalQ则该类所有的Ҏ(gu)都是final。Java~译器会(x)LZ(x)内联QinlineQ所有的finalҎ(gu)Q这和具体的~译器实现有养I(j)。此举能够性能q_提高50%?/P> <P><BR>1.6 量使用局部变?/P> <P><BR>调用Ҏ(gu)时传递的参数以及(qing)在调用中创徏的(f)时变量都保存在栈QStackQ中Q速度较快。其他变量,如静(rn)态变量、实例变量等Q都在堆QHeapQ中创徏Q速度较慢。另外,依赖于具体的~译?JVMQ局部变量还可能得到q一步优化。请参见《尽可能使用堆栈变量》?/P> <P><BR>1.7 乘法和除?/P> <P><BR>考虑下面的代码:(x)</P> <P><BR>for (val = 0; val < 100000; val +=5) { alterX = val * 8; myResult = val * 2; } <BR> </P> <P><BR>用移位操作替代乘法操作可以极大地提高性能。下面是修改后的代码Q?/P> <P><BR>for (val = 0; val < 100000; val += 5) { alterX = val << 3; myResult = val << 1; } <BR> </P> <P> </P> <P>修改后的代码不再做乘?sh)?的操作,而是改用{h(hun)的左U?位操作,每左U?位相当于乘(sh)2。相应地Q右U?位操作相当于除以2。值得一提的是,虽然UM操作速度快,但可能代码比较难于理解Q所以最好加上一些注释?/P> <P><BR>二、J2EE?/P> <P><BR>前面介绍的改善性能技巧适合于大多数Java应用Q接下来要讨论的问题适合于用JSP、EJB或JDBC的应用?/P> <P><BR>2.1 使用~冲标记</P> <P><BR>一些应用服务器加入?jin)面向JSP的缓冲标记功能。例如,BEA的WebLogic Server?.0版本开始支持这个功能,Open Symphony工程也同h持这个功能。JSP~冲标记既能够缓冲页面片断,也能够缓冲整个页面。当JSP面执行Ӟ如果目标片断已经在缓冲之中,则生成该片断的代码就不用再执行。页面~冲捕获Ҏ(gu)定URL的请求,q缓冲整个结果页面。对于购物篮、目录以?qing)门L(fng)站的主页来说Q这个功能极其有用。对于这cd用,面U缓冲能够保存页面执行的l果Q供后(h)h使用?/P> <P><BR>对于代码逻辑复杂的页面,利用~冲标记提高性能的效果比较明显;反之Q效果可能略逊一{V?/P> <P><BR>请参见《用~冲技术提高JSP应用的性能和稳定性》?/P> <P><BR>2.2 始终通过?x)话Bean讉K实体Bean</P> <P><BR>直接讉K实体Bean不利于性能。当客户E序q程讉K实体BeanӞ每一个getҎ(gu)都是一个远E调用。访问实体Bean的会(x)话Bean是本地的Q能够把所有数据组l成一个结构,然后q回它的倹{?/P> <P><BR>用会(x)话Bean装对实体Bean的访问能够改q事务管理,因ؓ(f)?x)话Bean只有在到达事务边界时才会(x)提交。每一个对getҎ(gu)的直接调用生一个事务,容器在每一个实体Bean的事务之后执行一?装入-d"操作?/P> <P><BR>一些时候,使用实体Bean?x)导致程序性能不佳。如果实体Bean的唯一用途就是提取和更新数据Q改成在?x)话Bean之内利用JDBC讉K数据库可以得到更好的性能?/P> <P><BR>2.3 选择合适的引用机制</P> <P><BR>在典型的JSP应用pȝ中,头、页脚部分往往被抽取出来,然后Ҏ(gu)需要引入页头、页脚。当前,在JSP面中引入外部资源的Ҏ(gu)主要有两U:(x)include指o(h)Q以?qing)include动作?/P> <P> </P> <P> </P> <P> </P> <P>include指o(h)Q例如。该指o(h)在编译时引入指定的资源。在~译之前Q带有include指o(h)的页面和指定的资源被合ƈ成一个文件。被引用的外部资源在~译时就定Q比q行时才定资源更高效?/P> <P>include动作Q例如。该动作引入指定面执行后生成的l果。由于它在运行时完成Q因此对输出l果的控制更加灵zR但Ӟ只有当被引用的内定wJ地改变Ӟ或者在对主面的请求没有出C前,被引用的面无法定Ӟ使用include动作才合?/P> <P> </P> <P><BR>2.4 在部|描q器中设|只d?/P> <P><BR>实体Bean的部|描q器允许把所有getҎ(gu)讄?只读"。当某个事务单元的工作只包含执行d操作的方法时Q设|只d性有利于提高性能Q因为容器不必再执行存储操作?/P> <P><BR>2.5 ~冲对EJB Home的访?/P> <P><BR>EJB Home接口通过JNDI名称查找获得。这个操作需要相当可观的开销。JNDI查找最好放入Servlet的init()Ҏ(gu)里面。如果应用中多处频繁地出现EJB讉KQ最好创Z个EJBHomeCachecREJBHomeCachecM般应该作为singleton实现?/P> <P><BR>2.6 为EJB实现本地接口</P> <P><BR>本地接口是EJB 2.0规范新增的内容,它得Bean能够避免q程调用的开销。请考虑下面的代码?/P> <P><BR>PayBeanHome home = (PayBeanHome)          javax.rmi.PortableRemoteObject.narrow          (ctx.lookup ("PayBeanHome"), PayBeanHome.class); PayBean bean = (PayBean)          javax.rmi.PortableRemoteObject.narrow          (home.create(), PayBean.class); <BR> </P> <P> </P> <P>W一个语句表C我们要LBean的Home接口。这个查N过JNDIq行Q它是一个RMI调用。然后,我们定位q程对象Q返回代理引用,q也是一个RMI调用。第二个语句C?jin)如何创Z个实例,涉及(qing)?jin)创建IIOPhq在|络上传输请求的stubE序Q它也是一个RMI调用?/P> <P><BR>要实现本地接口,我们必须作如下修改:(x)</P> <P><BR> </P> <P> </P> <P>Ҏ(gu)不能再抛出java.rmi.RemoteException异常Q包括从RemoteExceptionz的异常,比如TransactionRequiredException、TransactionRolledBackException和NoSuchObjectException。EJB提供?jin)等L(fng)本地异常Q如TransactionRequiredLocalException、TransactionRolledBackLocalException和NoSuchObjectLocalException?/P> <P>所有数据和q回值都通过引用的方式传递,而不是传递倹{?/P> <P>本地接口必须在EJB部v的机器上使用。简而言之,客户E序和提供服务的lg必须在同一个JVM上运行?/P> <P>如果Bean实现?jin)本地接口,则其引用不可串行化?/P> <P> </P> <P><BR>请参见《用本地引用提高EJB讉K效率》?/P> <P><BR>2.7 生成主键</P> <P><BR>在EJB之内生成主键有许多途径Q下面分析了(jin)几种常见的办法以?qing)它们的特点?/P> <P><BR>利用数据库内建的标识机制QSQL Server的IDENTITY或Oracle的SEQUENCEQ。这U方法的~点是EJB可移植性差?/P> <P><BR>由实体Bean自己计算主键|比如做增量操作)(j)。它的缺Ҏ(gu)要求事务可串行化Q而且速度也较慢?/P> <P><BR>利用NTP之类的时钟服务。这要求有面向特定^台的本地代码Q从而把Bean固定C(jin)特定的OS之上。另外,它还D?jin)这样一U可能,卛_多CPU的服务器上,同一个毫U之内生成了(jin)两个主键?/P> <P><BR>借鉴Microsoft的思\Q在Bean中创Z个GUID。然而,如果不求助于JNIQJava不能定|卡的MAC地址Q如果用JNIQ则E序p依赖于特定的OS?/P> <P><BR>q有其他几种办法Q但q些办法同样都有各自的局限。似乎只有一个答案比较理惻I(x)l合q用RMI和JNDI。先通过RMI注册把RMIq程对象l定到JNDI?wi)。客L(fng)序通过JNDIq行查找。下面是一个例子:(x)</P> <P><BR>public class keyGenerator extends UnicastRemoteObject implements Remote { private static long KeyValue = System.currentTimeMillis(); public static synchronized long getKey() throws RemoteException { return KeyValue++; } <BR> </P> <P> </P> <P>2.8 ?qing)时清除不再需要的?x)?/P> <P><BR>Z(jin)清除不再zd的会(x)话,许多应用服务器都有默认的?x)话时旉Q一般ؓ(f)30分钟。当应用服务器需要保存更多会(x)话时Q如果内存容量不I操作pȝ?x)把部分内存数据转移到磁盘,应用服务器也可能?gu)"最q最频繁使用"QMost Recently UsedQ算法把部分不活跃的?x)话转储到磁盘,甚至可能抛?内存?sh)?异常。在大规模系l中Q串行化?x)话的代h很昂늚。当?x)话不再需要时Q应当及(qing)时调用HttpSession.invalidate()Ҏ(gu)清除?x)话。HttpSession.invalidate()Ҏ(gu)通常可以在应用的退出页面调用?/P> <P><BR>2.9 在JSP面中关闭无用的?x)?/P> <P><BR>对于那些无需跟踪?x)话状态的面Q关闭自动创建的?x)话可以节省一些资源。用如下page指o(h)Q?/P> <P><BR> <BR> </P> <P> </P> <P><BR>2.10 Servlet与内存(sh)?/P> <P><BR>许多开发者随意地把大量信息保存到用户?x)话之中。一些时候,保存在会(x)话中的对象没有及(qing)时地被垃圑֛收机制回收。从性能上看Q典型的症状是用h到系l周期性地变慢Q却又不能把原因归于M一个具体的lg。如果监视JVM的堆I间Q它的表现是内存占用不正常地大v大落?/P> <P><BR>解决q类内存问题?sh)要有二U办法。第一U办法是Q在所有作用范围ؓ(f)?x)话的Bean中实现HttpSessionBindingListener接口。这P只要实现valueUnbound()Ҏ(gu)Q就可以昑ּ地释放Bean使用的资源?/P> <P><BR>另外一U办法就是尽快地把会(x)话作废。大多数应用服务器都有设|会(x)话作废间隔时间的选项。另外,也可以用~程的方式调用会(x)话的setMaxInactiveInterval()Ҏ(gu)Q该Ҏ(gu)用来讑֮在作废会(x)话之前,Servlet容器允许的客戯求的最大间隔时_(d)以秒计?/P> <P><BR>2.11 HTTP Keep-Alive</P> <P><BR>Keep-Alive功能使客L(fng)到服务器端的q接持箋(hu)有效Q当出现Ҏ(gu)务器的后l请求时QKeep-Alive功能避免?jin)徏立或者重新徏立连接。市(jng)Z的大部分Web服务器,包括iPlanet、IIS和ApacheQ都支持HTTP Keep-Alive。对于提供静(rn)态内容的|站来说Q这个功能通常很有用。但是,对于负担较重的网站来_(d)q里存在另外一个问题:(x)虽然为客户保留打开的连接有一定的好处Q但它同样媄(jing)响了(jin)性能Q因为在处理暂停期间Q本来可以释攄资源仍旧被占用。当Web服务器和应用服务器在同一台机器上q行ӞKeep-Alive功能对资源利用的影响其H出?/P> <P><BR>2.12 JDBC与Unicode</P> <P><BR>惛_你已l了(jin)解一些用JDBC时提高性能的措施,比如利用q接池、正地选择存储q程和直接执行的SQL、从l果集删除多余的列、预先编译SQL语句Q等{?/P> <P><BR>除了(jin)q些显而易见的选择之外Q另一个提高性能的好选择可能是把所有的字符数据都保存(sh)ؓ(f)UnicodeQ代码页13488Q。Java以Unicode形式处理所有数据,因此Q数据库驱动E序不必再执行{换过E。但应该CQ如果采用这U方式,数据库会(x)变得更大Q因为每个Unicode字符需?个字节存储空间。另外,如果有其他非Unicode的程序访问数据库Q性能问题?sh)旧会(x)出玎ͼ因?f)q时数据库驱动程序仍旧必L行{换过E?/P> <P><BR>2.13 JDBC与I/O</P> <P><BR>如果应用E序需要访问一个规模很大的数据集,则应当考虑使用块提取方式。默认情况下QJDBC每次提取32行数据。D例来_(d)假设我们要遍历一?000行的记录集,JDBC必须调用数据?57ơ才能提取到全部数据。如果把块大改?12Q则调用数据库的ơ数减到10ơ?/P> <P><BR>在一些情形下q种技术无效。例如,如果使用可滚动的记录集,或者在查询中指定了(jin)FOR UPDATEQ则块操作方式不再有效?/P> <P><BR>1.14 内存数据?/P> <P><BR>许多应用需要以用户为单位在?x)话对象中保存相当数量的数据Q典型的应用如购物篮和目录等。由于这cL据可以按照行/列的形式l织Q因此,许多应用创徏?jin)庞大的Vector或HashMap。在?x)话中保存这cL据极大地限制?jin)应用的可׾~性,因ؓ(f)服务器拥有的内存臛_必须辑ֈ每个?x)话占用的内存数量乘(sh)ƈ发用h大数量,它不仅服务器h(hun)格昂贵,而且垃圾攉的时间间隔也可能廉到难以忍受的E度?/P> <P><BR>一些h把购物篮/目录功能转移到数据库层,在一定程度上提高?sh)(jin)可伸羃性。然而,把这部分功能攑ֈ数据库层也存在问题,且问题的Ҏ(gu)与大多数关系数据库系l的体系l构有关。对于关pL据库来说Q运行时的重要原则之一是确保所有的写入操作E_、可靠,因而,所有的性能问题都与物理上把数据写入盘的能力有兟뀂关pL据库力图减少I/O操作Q特别是对于L作,但实现该目标的主要途径只是执行一套实现缓冲机制的复杂法Q而这正是数据库层W一h能瓉通常LCPU的主要原因?/P> <P><BR>一U替代传l关pL据库的方案是Q用在内存?sh)运行的数据库(In-memory DatabaseQ,例如TimesTen。内存数据库的出发点是允许数据(f)时地写入Q但q些数据不必怹C存到盘?sh),所有的操作都在内存?sh)进行。这P内存数据库不需要复杂的法来减I/O操作Q而且可以采用比较单的加锁机制Q因而速度很快?/P> <P><BR>三、GUI?/P> <P><BR>q一部分介绍的内定w合于图形用L(fng)面的应用QApplet和普通应用)(j)Q要用到AWT或Swing?/P> <P><BR>3.1 用JAR压羃cL?/P> <P><BR>Java档案文gQJAR文gQ是Ҏ(gu)JavaBean标准压羃的文Ӟ是发布JavaBeanlg的主要方式和推荐方式。JAR档案有助于减文件体U,~短下蝲旉。例如,它有助于Applet提高启动速度。一个JAR文g可以包含一个或者多个相关的Bean以及(qing)支持文gQ比如图形、声韟뀁HTML和其他资源?/P> <P><BR>要在HTML/JSP文g中指定JAR文gQ只需在Applet标记中加入ARCHIVE = "name.jar"声明?/P> <P><BR>请参见《用档案文件提?applet 的加载速度》?/P> <P><BR>3.2 提示Applet装入q程</P> <P><BR>你是否看到过使用Applet的网站,注意到在应该q行Applet的地方出C(jin)一个占位符Q当Applet的下载时间较长时Q会(x)发生什么事情?最大的可能是用户掉头d。在q种情况下,昄一个Applet正在下蝲的信息无疑有助于鼓励用户l箋(hu){待?/P> <P><BR>下面我们来看看一U具体的实现Ҏ(gu)。首先创Z个很的AppletQ该Applet负责在后C载正式的AppletQ?/P> <P> </P> <P>import java.applet.Applet;import java.applet.AppletStub;import java.awt.Label;import java.awt.Graphics;import java.awt.GridLayout; public class PreLoader extends Applet implements Runnable, AppletStub {    String largeAppletName;    Label label;    public void init() {       // 要求装蝲的正式Applet       largeAppletName = getParameter("applet");       // "L(fng){?提示信息       label = new Label("L(fng){?.." + largeAppletName);       add(label);    }     public void run(){       try {          // 获得待装载Applet的类          Class largeAppletClass = Class.forName(largeAppletName);           // 创徏待装载Applet的实?nbsp;        Applet largeApplet = (Applet)largeAppletClass.newInstance();           // 讄该Applet的StubE序          largeApplet.setStub(this);           // 取消"L(fng){?信息         remove(label);          // 讄布局         setLayout(new GridLayout(1, 0));         add(largeApplet);          // 昄正式的Applet         largeApplet.init();         largeApplet.start();      }      catch (Exception ex) {         // 昄错误信息         label.setText("不能装入指定的Applet");      }       // h屏幕      validate();   }    public void appletResize(int width, int height) {         // 把appletResize调用从stubE序传递到Applet        resize(width, height);   }}<BR> </P> <P> </P> <P>~译后的代码于2KQ下载速度很快。代码中有几个地方值得注意。首先,PreLoader实现?jin)AppletStub接口。一般地QApplet从调用者判断自qcodebase。在本例中,我们必须调用setStub()告诉Applet到哪里提取这个信息。另一个值得注意的地Ҏ(gu)QAppletStub接口包含许多和AppletcML(fng)Ҏ(gu)Q但appletResize()Ҏ(gu)除外。这里我们把对appletResize()Ҏ(gu)的调用传递给?jin)resize()Ҏ(gu)?/P> <P><BR>3.3 在画出图形之前预先装入它</P> <P><BR>ImageObserver接口可用来接收图形装入的提示信息。ImageObserver接口只有一个方法imageUpdate()Q能够用一ơrepaint()操作在屏q上d囑Ş。下面提供了(jin)一个例子?/P> <P> </P> <P>public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) {          if ((flags & ALLBITS) !=0 {               repaint();          }          else if (flags & (ERROR |ABORT )) != 0) {               error = true;               // 文g没有扑ֈQ考虑昄一个占位符               repaint();           }           return (flags & (ALLBITS | ERROR| ABORT)) == 0;} <BR> </P> <P> </P> <P>当图形信息可用时QimageUpdate()Ҏ(gu)被调用。如果需要进一步更斎ͼ该方法返回trueQ如果所需信息已经得到Q该Ҏ(gu)q回false?/P> <P><BR>3.4 覆盖updateҎ(gu)</P> <P><BR>update()Ҏ(gu)的默认动作是清除屏幕Q然后调用paint()Ҏ(gu)。如果用默认的update()Ҏ(gu)Q频J用图形的应用可能出现昄闪烁现象。要避免在paint()调用之前的屏q清除操作,只需按照如下方式覆盖update()Ҏ(gu)Q?/P> <P><BR>public void update(Graphics g) {     paint(g);} <BR> </P> <P><BR>更理想的Ҏ(gu)是:(x)覆盖update()Q只重画屏幕上发生变化的区域Q如下所C:(x)</P> <P><BR>public void update(Graphics g) {     g.clipRect(x, y, w, h);     paint(g);} <BR> </P> <P><BR>3.5 延迟重画操作</P> <P><BR>对于囑Ş用户界面的应用来_(d)性能低下的主要原因往往可以归结为重dq的效率低下。当用户改变H口大小或者滚动一个窗口时Q这一炚w常可以很明昑֜观察到。改变窗口大或者滚动屏q之cȝ操作D重画屏幕事g大量地、快速地生成Q甚臌q了(jin)相关代码的执行速度。对付这个问题最好的办法是忽略所?q到"的事件?/P> <P><BR>在这里引入一个数毫秒的时差,卛_果我们立x(chng)收到?jin)另一个重MӞ可以停止处理当前事g转而处理最后一个收到的重画事gQ否则,我们l箋(hu)q行当前的重画过E?/P> <P><BR>如果事g要启动一耗时的工作,分离Z个工作线E是一U较好的处理方式Q否则,一些部件可能被"ȝ"Q因为每ơ只能处理一个事件。下面提供了(jin)一个事件处理的单例子,但经q扩展后它可以用来控制工作线E?/P> <P><BR> </P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">public static void runOnce(String id</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> final long milliseconds) {          <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    synchronized(e_queue) { // e_queue: 所有事件的集合                <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>        if (!e_queue.containsKey(id)) {                       <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>            e_queue.put(token</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> new LastOne())</SPAN><SPAN style="COLOR: #008000">;</SPAN><SPAN style="COLOR: #008000">                </SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        }           <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    }            <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    final LastOne lastOne </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (LastOne) e_queue.get(token)</SPAN><SPAN style="COLOR: #008000">;</SPAN><SPAN style="COLOR: #008000">           </SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">    final long time </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> System.currentTimeMillis()</SPAN><SPAN style="COLOR: #008000">;</SPAN><SPAN style="COLOR: #008000"> // 获得当前旉           </SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">    lastOne.time </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> time</SPAN><SPAN style="COLOR: #008000">;</SPAN><SPAN style="COLOR: #008000">            </SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">    (new Thread() {<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>        public void run() {                <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>            if (milliseconds > </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">) {                    <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                try {<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                    Thread.sleep(milliseconds)</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">                } // 暂停U程                    <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                catch (Exception ex) {<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                }<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                    }                <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                    <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                    synchronized(lastOne.running) { // {待上一事gl束                    <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                        if (lastOne.time !</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> time) // 只处理最后一个事?nbsp;                   <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                        return</SPAN><SPAN style="COLOR: #008000">;</SPAN><SPAN style="COLOR: #008000">                </SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">                    }             <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>            }<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>          }<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    ).start()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">    } <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    private static Hashtable e_queue </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> new Hashtable()</SPAN><SPAN style="COLOR: #008000">;</SPAN><SPAN style="COLOR: #008000"> </SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">    private static class LastOne {       <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    public long time</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #008000">;</SPAN><SPAN style="COLOR: #008000">        </SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">    public Object running </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> new Object()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">    <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    } </SPAN></DIV> <P><BR> </P> <P> </P> <P>3.6 使用双缓冲区</P> <P><BR>在屏q之外的~冲区绘图,完成后立x(chng)整个囑Ş昄出来。由于有两个~冲区,所以程序可以来回切换。这P我们可以用一个低优先U的U程负责dQ得程序能够利用空闲的CPU旉执行其他d。下面的伪代码片断示范了(jin)q种技术?/P> <P><BR>Graphics myGraphics;Image myOffscreenImage = createImage(size().width, size().height);Graphics offscreenGraphics = myOffscreenImage.getGraphics(); offscreenGraphics.drawImage(img, 50, 50, this);myGraphics.drawImage(myOffscreenImage, 0, 0, this); <BR> </P> <P> </P> <P>3.7 使用BufferedImage</P> <P><BR>Java JDK 1.2使用?jin)一个Y昄讑֤Q得文本在不同的^C看v来相伹{ؓ(f)实现q个功能QJava必须直接处理构成文字的像素。由于这U技术要在内存(sh)大量地进行位复制操作Q早期的JDK在用这U技术时性能不佳。ؓ(f)解决q个问题而提出的Java标准实现?jin)一U新的图形类型,即BufferedImage?/P> <P><BR>BufferedImage子类描述的图形带有一个可讉K的图形数据缓冲区。一个BufferedImage包含一个ColorModel和一l光栅图形数据。这个类一般用RGBQ红、绿、蓝Q颜色模型,但也可以处理灰度U图形。它的构造函数很单,如下所C:(x)</P> <P><BR>public BufferedImage (int width, int height, int imageType) <BR> </P> <P> </P> <P>ImageType允许我们指定要缓冲的是什么类型的囑ŞQ比?-位RGB?-位RGB、灰度{?/P> <P><BR>3.8 使用VolatileImage</P> <P><BR>许多gq_和它们的操作pȝ都提供基本的g加速支持。例如,g加速一般提供矩形填充功能,和利用CPU完成同一d相比Q硬件加速的效率更高。由于硬件加速分M(jin)一部分工作Q允许多个工作流q发q行Q从而缓解了(jin)对CPU和系lȝ的压力,使得应用能够q行得更快。利用VolatileImage可以创徏g加速的囑Ş以及(qing)理囑Ş的内宏V由于它直接利用低层q_的能力,性能的改善程度主要取决于pȝ使用的图形适配器。VolatileImage的内定w时可能丢失,也即它是"不稳定的QvolatileQ?。因此,在用图形之前,最好检查一下它的内Ҏ(gu)否丢失。VolatileImage有两个能够检查内Ҏ(gu)否丢qҎ(gu)Q?/P> <P><BR>public abstract int validate(GraphicsConfiguration gc);public abstract Boolean contentsLost(); <BR> </P> <P> </P> <P>每次从VolatileImage对象复制内容或者写入VolatileImageӞ应该调用validate()Ҏ(gu)。contentsLost()Ҏ(gu)告诉我们Q自从最后一ơvalidate()调用之后Q图形的内容是否丢失?/P> <P><BR>虽然VolatileImage是一个抽象类Q但不要从它q里z子类。VolatileImage应该通过Component.createVolatileImage()或者GraphicsConfiguration.createCompatibleVolatileImage()Ҏ(gu)创徏?/P> <P><BR>3.9 使用Window Blitting</P> <P><BR>q行滚动操作Ӟ所有可见的内容一般都要重画,从而导致大量不必要的重d作。许多操作系l的囑Ş子系l,包括WIN32 GDI、MacOS和X/WindowsQ都支持Window Blitting技术。Window Blitting技术直接在屏幕~冲Z把图形移到新的位|,只重L出现的区域。要在Swing应用中用Window Blitting技术,讄Ҏ(gu)如下Q?/P> <P><BR>setScrollMode(int mode); <BR> </P> <P> </P> <P>在大多数应用中,使用q种技术能够提高滚动速度。只有在一U情形下QW(xu)indow Blitting?x)导致性能降低Q即应用在后台进行滚动操作。如果是用户在滚动一个应用,那么它L在前収ͼ无需担心(j)M负面影响?/P> <P> </P><img src ="http://www.tkk7.com/bluesky/aggbug/30812.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/bluesky/" target="_blank">bluesky</a> 2006-02-15 15:08 <a href="http://www.tkk7.com/bluesky/archive/2006/02/15/30812.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[struts]MVChttp://www.tkk7.com/bluesky/archive/2006/02/15/30783.htmlblueskyblueskyWed, 15 Feb 2006 04:22:00 GMThttp://www.tkk7.com/bluesky/archive/2006/02/15/30783.htmlhttp://www.tkk7.com/bluesky/comments/30783.htmlhttp://www.tkk7.com/bluesky/archive/2006/02/15/30783.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/30783.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/30783.html 
Struts is an open-source framework for building Model 2 web applications.

MVC框架

A controller servlet that dispatches requests to appropriate action classes
provided by the application developer.

All requests are dispatched through a single controller servlet that is part of the
framework.

单独的控制器把所有的h集中分发

This controller provides numerous application-wide services, such as
database connection pooling and automatic request dispatching. The controller
creates action classes, which are built by the developer to perform the work of the
application. These action classes extend the Struts Action class. This is a perfect
example of a reusable framework part—the controller is designed to create
Action subclasses to perform work. This aspect of Struts is based on the Command
design pattern, which allows for parameterizing activities.

控制器提供了(jin)众多的应用程序范围的服务,例如数据库连接池,h自动分发.控制器创建开发者提供解决业务问题的action业务c?BR>q些actioncd括Struts Action class.控制器可以重复创建ActioncL复用框架

The action instances create model beans that perform domain-specific activities.
Examples of these activities include executing business logic, connecting to
databases, and calling other bean methods. The model beans encapsulate the real
work of the application, just as in Model 2. Once the action instance has utilized
the model beans to perform work, it forwards the models that contribute to the
display via the controller to a view component, generally a JSP (although other
view options are possible; see the discussion on Velocity in chapter 9). The view
extracts the model beans and presents the visual results to the user. As you can
see, this is the same general information flow described in Model 2. Struts provides
a great deal of the infrastructure to make it easy to accommodate this information
flow.

Struts handles other details of application development as well. The framework
includes numerous custom JSP tags to help you construct the view. It also
provides classes that aid in internationalization, database connection pooling, and
flexible resource mapping.

Struts is a fairly lightweight framework whose primary job is to facilitate building
web applications using Model 2. I estimate that Struts saves from 35 to 40 percent
of the typical amount of effort to build a Model 2 application. One of Struts?BR>strengths is its cohesiveness—it doesn’t supply services outside those needed for
building Model 2 applications. Other frameworks are much more extensive; the
Turbine framework is one of them.

摘自<ARTOF
JAVA WEB
DEVELOPMENT>



bluesky 2006-02-15 12:22 发表评论
]]>
[转蝲]JDK5.0?1个主要新特征http://www.tkk7.com/bluesky/archive/2006/02/10/30099.htmlblueskyblueskyFri, 10 Feb 2006 02:07:00 GMThttp://www.tkk7.com/bluesky/archive/2006/02/10/30099.htmlhttp://www.tkk7.com/bluesky/comments/30099.htmlhttp://www.tkk7.com/bluesky/archive/2006/02/10/30099.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/30099.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/30099.html阅读全文

bluesky 2006-02-10 10:07 发表评论
]]>
open source database (RDBMS)http://www.tkk7.com/bluesky/archive/2006/02/09/30001.htmlblueskyblueskyThu, 09 Feb 2006 02:01:00 GMThttp://www.tkk7.com/bluesky/archive/2006/02/09/30001.htmlhttp://www.tkk7.com/bluesky/comments/30001.htmlhttp://www.tkk7.com/bluesky/archive/2006/02/09/30001.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/30001.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/30001.htmlIngres
Ingres® is a mature, high-performance relational database solution. It offers scalability, integration and flexibility to leverage information resources across a wide range of platforms, including Linux, UNIX, Windows and OpenVMS. Reliable and cost effective, it supports mission-critical applications in small to medium-size businesses and high-volume deployments in large scale enterprises.
http://opensource.ca.com/projects/ingres/


EnterpriseDB

EnterpriseDB is an enterprise-class relational database management system (RDBMS) that is built on PostgreSQL, the world's most advanced open source database. EnterpriseDB is compatible with most Oracle applications, reliable and scalable enough for high-volume, mission-critical enterprise use, and surprisingly affordable.

http://www.enterprisedb.com/products/index.do

Mysql

The World's Most Popular Open Source Database
http://dev.mysql.com/

Postgresql
The world's most advanced open source database.

http://www.postgresql.org/



bluesky 2006-02-09 10:01 发表评论
]]>
web application development frameworks: request-based and component-based.http://www.tkk7.com/bluesky/archive/2006/01/11/27539.htmlblueskyblueskyWed, 11 Jan 2006 02:53:00 GMThttp://www.tkk7.com/bluesky/archive/2006/01/11/27539.htmlhttp://www.tkk7.com/bluesky/comments/27539.htmlhttp://www.tkk7.com/bluesky/archive/2006/01/11/27539.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/27539.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/27539.htmlThere are currently two major schools of web application development frameworks: request-based and component-based.


Request-based frameworks are very close to the original CGI specification. They use controllers and actions that directly handle incoming requests. Each request is fundamentally stateless. With the introduction of server-side sessions, a certain degree of statefulness has been achieved. The different frameworks basically differentiate themselves by the way they map logic to URLs and how data is structured and provided to the developer.


Component-based frameworks abstract the developer away from the internals of the request handling and encapsulate the logic into reusable components, often independent from the web medium. The state is automatically handled by the framework, based on the data that is present in each component instance. Together with some form of event handling, this development model is very similar to the features offered by desktop GUI toolkits. The different frameworks basically differentiate themselves by the provided component API and how components are combined together.

http://www.rifers.org/ 
https://rife-jumpstart.dev.java.net/



bluesky 2006-01-11 10:53 发表评论
]]>
[转蝲]使用TrueLicense来保护我们的JAVA软g产品http://www.tkk7.com/bluesky/archive/2006/01/10/27426.htmlblueskyblueskyTue, 10 Jan 2006 08:55:00 GMThttp://www.tkk7.com/bluesky/archive/2006/01/10/27426.htmlhttp://www.tkk7.com/bluesky/comments/27426.htmlhttp://www.tkk7.com/bluesky/archive/2006/01/10/27426.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/27426.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/27426.html阅读全文

bluesky 2006-01-10 16:55 发表评论
]]>
[转蝲]session.flush()http://www.tkk7.com/bluesky/archive/2006/01/09/27238.htmlblueskyblueskyMon, 09 Jan 2006 04:15:00 GMThttp://www.tkk7.com/bluesky/archive/2006/01/09/27238.htmlhttp://www.tkk7.com/bluesky/comments/27238.htmlhttp://www.tkk7.com/bluesky/archive/2006/01/09/27238.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/27238.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/27238.htmlhttp://hairroot.blogchina.com/hairroot/1639334.html

hibernate一个Session有一个CacheQcache屏蔽?jin)应用程序直接去讉K数据库,如果同一张table的同一row在先前已l被hq,那么Z下次h的时候还要去h一ơ呢Q把前面的cache住,再遇到这L(fng)h直接q回cache里边的即可?BR>
cache里边的数据如果含有脏数据Q需要跟数据库同步(也就是需要hibernate来发送update, delete, insertQ,调用session.flush()辑ֈ此目的。一般情况下Qhibernate在一个tx.commit()的时候会(x)自动调用session.flush();也可以应用程序手动调用session.flush()来立dsession的脏数据提交?BR>
Session session = HibernateSessionFactory.currentSession();
        Transaction tx = session.beginTransaction();
        try{
         Employee employee1 
= (Employee)session.load(Employee.class, new Integer(3));
         System.out.println(employee1);
         employee1.setAge((byte)98);
         session.flush();//发送employee1的updatel数据库
//         employee1.setAge((byte)43);
         tx.commit();//employee1已经被flushq,不会(x)再被flush。如果把上面以行代码注释取消Q还?sh)(x)再发一条update语句?/SPAN>
        }
        catch(HibernateException e){
            e.printStackTrace()
;
            tx.rollback();
        }

         tx 
= session.beginTransaction();
        Employee employee2 = (Employee) session.load(Employee.class, new Integer(3));
        employee2.setGender('f');
        System.out.println(employee2);
        tx.commit();

session.flush()的动作执行的时候,session中cache不会(x)被清I,所以上面的employee2和employee1q回的还是同一个实例?BR>
那些被flush()q的对象不会(x)在下ơflush()的时候再被flush()一ơ,除非两次flush()中间又生了(jin)新的脏数据?BR>
我认为应用程序基本上不需要显C去调用session.flush();而交ltx.commit()d可以了(jin)。原因是Q手动调用session.flush()虽然是往数据库提交了(jin)update{sql语句Q但是这些update真正的commit是在tx.commit()执行的时候。所以手动session.flush()后,其他的session或者是其他的应用程序看到的仍然q是数据库以前的数据?可以试验)

- 作者:(x) HairRoot 2005q?5?4? 星期?20:02



bluesky 2006-01-09 12:15 发表评论
]]>
Stripes框架http://www.tkk7.com/bluesky/archive/2006/01/05/26664.htmlblueskyblueskyThu, 05 Jan 2006 02:32:00 GMThttp://www.tkk7.com/bluesky/archive/2006/01/05/26664.htmlhttp://www.tkk7.com/bluesky/comments/26664.htmlhttp://www.tkk7.com/bluesky/archive/2006/01/05/26664.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/26664.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/26664.html兔子的离l叛?/A> 看到?jin)Stripes的介l?去看了(jin)?/H1>

q是以jsp+扩展标签为基本的框架~~

用扩展标{?感觉q是不如 Tapestry 的用ongl实现的组件来的好



bluesky 2006-01-05 10:32 发表评论
]]>
初步看了(jin)java动态代?/title><link>http://www.tkk7.com/bluesky/archive/2006/01/04/26568.html</link><dc:creator>bluesky</dc:creator><author>bluesky</author><pubDate>Wed, 04 Jan 2006 08:32:00 GMT</pubDate><guid>http://www.tkk7.com/bluesky/archive/2006/01/04/26568.html</guid><wfw:comment>http://www.tkk7.com/bluesky/comments/26568.html</wfw:comment><comments>http://www.tkk7.com/bluesky/archive/2006/01/04/26568.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.tkk7.com/bluesky/comments/commentRss/26568.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/bluesky/services/trackbacks/26568.html</trackback:ping><description><![CDATA[ProxyClass.java<BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000"> java.lang.reflect.InvocationHandler;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000"> java.lang.reflect.InvocationTargetException;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000"> java.lang.reflect.Proxy;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><BR><IMG id=Codehighlighter1_153_666_Open_Image onclick="this.style.display='none'; Codehighlighter1_153_666_Open_Text.style.display='none'; Codehighlighter1_153_666_Closed_Image.style.display='inline'; Codehighlighter1_153_666_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_153_666_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_153_666_Closed_Text.style.display='none'; Codehighlighter1_153_666_Open_Image.style.display='inline'; Codehighlighter1_153_666_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> ProxyClass </SPAN><SPAN id=Codehighlighter1_153_666_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_153_666_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> main(String arags[]) </SPAN><SPAN style="COLOR: #0000ff">throws</SPAN><SPAN style="COLOR: #000000"> IllegalArgumentException,<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            SecurityException, InstantiationException, IllegalAccessException,<BR><IMG id=Codehighlighter1_351_664_Open_Image onclick="this.style.display='none'; Codehighlighter1_351_664_Open_Text.style.display='none'; Codehighlighter1_351_664_Closed_Image.style.display='inline'; Codehighlighter1_351_664_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_351_664_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_351_664_Closed_Text.style.display='none'; Codehighlighter1_351_664_Open_Image.style.display='inline'; Codehighlighter1_351_664_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            InvocationTargetException, NoSuchMethodException </SPAN><SPAN id=Codehighlighter1_351_664_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_351_664_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        InvocationHandler handler </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> MyInvocationHandler();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        Class proxyClass </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> Proxy.getProxyClass(Foo.</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">.getClassLoader(),<BR><IMG id=Codehighlighter1_495_507_Open_Image onclick="this.style.display='none'; Codehighlighter1_495_507_Open_Text.style.display='none'; Codehighlighter1_495_507_Closed_Image.style.display='inline'; Codehighlighter1_495_507_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_495_507_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_495_507_Closed_Text.style.display='none'; Codehighlighter1_495_507_Open_Image.style.display='inline'; Codehighlighter1_495_507_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>                </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Class[] </SPAN><SPAN id=Codehighlighter1_495_507_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_495_507_Open_Text><SPAN style="COLOR: #000000">{ Foo.</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> }</SPAN></SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        Foo f </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (Foo) proxyClass.getConstructor(<BR><IMG id=Codehighlighter1_570_596_Open_Image onclick="this.style.display='none'; Codehighlighter1_570_596_Open_Text.style.display='none'; Codehighlighter1_570_596_Closed_Image.style.display='inline'; Codehighlighter1_570_596_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_570_596_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_570_596_Closed_Text.style.display='none'; Codehighlighter1_570_596_Open_Image.style.display='inline'; Codehighlighter1_570_596_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>                </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Class[] </SPAN><SPAN id=Codehighlighter1_570_596_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_570_596_Open_Text><SPAN style="COLOR: #000000">{ InvocationHandler.</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> }</SPAN></SPAN><SPAN style="COLOR: #000000">).newInstance(<BR><IMG id=Codehighlighter1_629_639_Open_Image onclick="this.style.display='none'; Codehighlighter1_629_639_Open_Text.style.display='none'; Codehighlighter1_629_639_Closed_Image.style.display='inline'; Codehighlighter1_629_639_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_629_639_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_629_639_Closed_Text.style.display='none'; Codehighlighter1_629_639_Open_Image.style.display='inline'; Codehighlighter1_629_639_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>                </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Object[] </SPAN><SPAN id=Codehighlighter1_629_639_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_629_639_Open_Text><SPAN style="COLOR: #000000">{ handler }</SPAN></SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        f.doSomething();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV><BR>Foo.java<BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_21_44_Open_Image onclick="this.style.display='none'; Codehighlighter1_21_44_Open_Text.style.display='none'; Codehighlighter1_21_44_Closed_Image.style.display='inline'; Codehighlighter1_21_44_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_21_44_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_21_44_Closed_Text.style.display='none'; Codehighlighter1_21_44_Open_Image.style.display='inline'; Codehighlighter1_21_44_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">interface</SPAN><SPAN style="COLOR: #000000"> Foo </SPAN><SPAN id=Codehighlighter1_21_44_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_21_44_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> doSomething();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV>MyInvocationHandler.java<BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000"> java.lang.reflect.InvocationHandler;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000"> java.lang.reflect.Method;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><BR><IMG id=Codehighlighter1_140_286_Open_Image onclick="this.style.display='none'; Codehighlighter1_140_286_Open_Text.style.display='none'; Codehighlighter1_140_286_Closed_Image.style.display='inline'; Codehighlighter1_140_286_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_140_286_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_140_286_Closed_Text.style.display='none'; Codehighlighter1_140_286_Open_Image.style.display='inline'; Codehighlighter1_140_286_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> MyInvocationHandler </SPAN><SPAN style="COLOR: #0000ff">implements</SPAN><SPAN style="COLOR: #000000"> InvocationHandler </SPAN><SPAN id=Codehighlighter1_140_286_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_140_286_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> Object invoke(Object proxy, Method method, Object[] args)<BR><IMG id=Codehighlighter1_229_283_Open_Image onclick="this.style.display='none'; Codehighlighter1_229_283_Open_Text.style.display='none'; Codehighlighter1_229_283_Closed_Image.style.display='inline'; Codehighlighter1_229_283_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_229_283_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_229_283_Closed_Text.style.display='none'; Codehighlighter1_229_283_Open_Image.style.display='inline'; Codehighlighter1_229_283_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">throws</SPAN><SPAN style="COLOR: #000000"> Throwable </SPAN><SPAN id=Codehighlighter1_229_283_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_229_283_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        System.out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Helloworld</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><img src ="http://www.tkk7.com/bluesky/aggbug/26568.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/bluesky/" target="_blank">bluesky</a> 2006-01-04 16:32 <a href="http://www.tkk7.com/bluesky/archive/2006/01/04/26568.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转蝲]文g和目录复制函?/title><link>http://www.tkk7.com/bluesky/archive/2005/12/29/25915.html</link><dc:creator>bluesky</dc:creator><author>bluesky</author><pubDate>Thu, 29 Dec 2005 09:52:00 GMT</pubDate><guid>http://www.tkk7.com/bluesky/archive/2005/12/29/25915.html</guid><wfw:comment>http://www.tkk7.com/bluesky/comments/25915.html</wfw:comment><comments>http://www.tkk7.com/bluesky/archive/2005/12/29/25915.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/bluesky/comments/commentRss/25915.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/bluesky/services/trackbacks/25915.html</trackback:ping><description><![CDATA[<A ><FONT color=#ff0000 size=6>http://spaces.msn.com/members/kliweik/</FONT></A><BR><BR>今天hQ要Roy帮我写了(jin)一个目录复制的函数Q记录,备后用,呵呵Q?BR><BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">/* Created on </SPAN><SPAN style="COLOR: #000000">2005</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">8</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">8</SPAN><SPAN style="COLOR: #000000"> <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top> * <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top> * @author wei.li  <BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top> * TODO 用来q行外部命o(h)的工L(fng) */<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>package com.linktone.photo.lucene</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>import java.io.File</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">import java.io.FileInputStream</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">import java.io.FileOutputStream</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">import java.io.IOException</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">import java.nio.channels.FileChannel</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>public class FileUtil {<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    /** * 功能:利用nio来快速复制文?nbsp;*/<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    public static void copyFile(String srcFile</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> String destFile)<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>            throws java.io.FileNotFoundException</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> java.io.IOException {<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>        FileInputStream fis </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> new FileInputStream(srcFile)</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        FileOutputStream fos </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> new FileOutputStream(destFile)</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        FileChannel fcin </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> fis.getChannel()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        FileChannel fcout </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> fos.getChannel()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        fcin.transferTo(</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> fcin.size()</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> fcout)</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        fcin.close()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        fcout.close()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        fis.close()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        fos.close()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">    }<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    /** * 功能:利用nio快速复制目?nbsp;*/<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    public static void copyDirectory(String srcDirectory</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> String destDirectory)<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>            throws java.io.FileNotFoundException</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> java.io.IOException { // 得到目录下的文g和目录数l?BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>        File srcDir </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> new File(srcDirectory)</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        File</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">[]</SPAN><SPAN style="COLOR: #000000"> fileList </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> srcDir.listFiles()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">        // 循环处理数组<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>        for (int i </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #008000">;</SPAN><SPAN style="COLOR: #008000"> i < fileList.length; i++) {</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">            if (fileList</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">[</SPAN><SPAN style="COLOR: #800000">i</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">]</SPAN><SPAN style="COLOR: #000000">.isFile()) {<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                // 数组中的对象为文?BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                // 如果目标目录不存在,创徏目标目录<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                File descDir </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> new File(destDirectory)</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">                if (!descDir.exists()) {<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                    descDir.mkdir()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">                } // 复制文g到目标目?BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                copyFile(srcDirectory + </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> + fileList</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">[</SPAN><SPAN style="COLOR: #800000">i</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">]</SPAN><SPAN style="COLOR: #000000">.getName()</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                        destDirectory + </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> + fileList</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">[</SPAN><SPAN style="COLOR: #800000">i</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">]</SPAN><SPAN style="COLOR: #000000">.getName())</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">            } else {<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                // 数组中的对象为目?BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                // 如果该子目录不存在就创徏Q其中也包含?jin)对多目录的处理?j)<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                File subDir </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> new File(destDirectory + </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                        + fileList</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">[</SPAN><SPAN style="COLOR: #800000">i</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">]</SPAN><SPAN style="COLOR: #000000">.getName())</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">                if (!subDir.exists()) {<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                    subDir.mkdir()</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">                }<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                // 递归处理子目?BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                copyDirectory(srcDirectory + </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> + fileList</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">[</SPAN><SPAN style="COLOR: #800000">i</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">]</SPAN><SPAN style="COLOR: #000000">.getName()</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>                        destDirectory + </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> + fileList</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">[</SPAN><SPAN style="COLOR: #800000">i</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">]</SPAN><SPAN style="COLOR: #000000">.getName())</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>            }<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>        }<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    }<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>    public static void main(String</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #800000">[]</SPAN><SPAN style="COLOR: #000000"> args) throws IOException {<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>        FileUtil.copyDirectory(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">e:/temp/index/test</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">e:/temp/index/test2</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN style="COLOR: #008000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">    }<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top>}<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><img src ="http://www.tkk7.com/bluesky/aggbug/25915.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/bluesky/" target="_blank">bluesky</a> 2005-12-29 17:52 <a href="http://www.tkk7.com/bluesky/archive/2005/12/29/25915.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转蝲]hibernate错误信息http://www.tkk7.com/bluesky/archive/2005/12/29/25912.htmlblueskyblueskyThu, 29 Dec 2005 09:43:00 GMThttp://www.tkk7.com/bluesky/archive/2005/12/29/25912.htmlhttp://www.tkk7.com/bluesky/comments/25912.htmlhttp://www.tkk7.com/bluesky/archive/2005/12/29/25912.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/25912.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/25912.html出处: http://spaces.msn.com/members/kliweik/
No row with the given identifier exists

表示你现在查询的对象所兌的对象有问题Q一般是因ؓ(f)数据的问题(该对象所兌的对象找不到Q?/P>

Caused by: org.dom4j.DocumentException: Invalid byte 2 of 2-byte UTF-8 sequence. Nested exception: Invalid byte 2 of 2-byte UTF-8 sequence.
如果出现q行错误说明你的xml配置文g有不规范的字W,(g)查下?

net.sf.hibernate.MappingException: Error reading resource: hibernate/Hello_Bean.hbm.xml
如果出现q行错误说明你的hibernate的XML配置文g有错

net.sf.hibernate.MappingException: Resource: hibernate/Hello_Bean.hbm.xml not found
如果出现q行错误说明hibernate的XML配置文g没有扑ֈQ你应该把XML文g攑֜与你的类文g同个目录?本文中是攑֜hibernate\classes\hibernate\目录下,也就是跟Hello_Bean.classcL件一赗?

net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property name in class hibernate.Hello_Bean
如果出现q行错误说明你的xml文g里设|的字段名name的gHello_Bean.javac里的getXXX或setXXXҎ(gu)不一致?

net.sf.hibernate.HibernateException: JDBC Driver class not found: org.gjt.mm.mysql.Driver
如果出现q行错误说明你的MYSQL驱动没有加进JB库里或者不在CLASSPATH里?/P>

bluesky 2005-12-29 17:43 发表评论
]]>
中止for循环break和return有区别么?http://www.tkk7.com/bluesky/archive/2005/12/29/25884.htmlblueskyblueskyThu, 29 Dec 2005 06:55:00 GMThttp://www.tkk7.com/bluesky/archive/2005/12/29/25884.htmlhttp://www.tkk7.com/bluesky/comments/25884.htmlhttp://www.tkk7.com/bluesky/archive/2005/12/29/25884.html#Feedback4http://www.tkk7.com/bluesky/comments/commentRss/25884.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/25884.html
for循环,continue,return,break

        for(int i=-5;i<1;i++){
            try{
                int k 
= 6/i;
                System.out.println(k);
            }catch(Exception e){
                System.out.println(
"error");
                //continue;//忽略错误l箋(hu)循环
                return;//中止循环
                //break;//中止循环
            }finally{
                //TODO无论成功p|都会(x)执行?BR>                System.out.println(
"finally code");
            }
        }

我看用break和return输出的都一?img src ="http://www.tkk7.com/bluesky/aggbug/25884.html" width = "1" height = "1" />

bluesky 2005-12-29 14:55 发表评论
]]>
Jbuilder2005内置的Tomcat5.0.27加蝲数据源配|的Ҏ(gu)http://www.tkk7.com/bluesky/archive/2005/12/24/25277.htmlblueskyblueskySat, 24 Dec 2005 00:43:00 GMThttp://www.tkk7.com/bluesky/archive/2005/12/24/25277.htmlhttp://www.tkk7.com/bluesky/comments/25277.htmlhttp://www.tkk7.com/bluesky/archive/2005/12/24/25277.html#Feedback1http://www.tkk7.com/bluesky/comments/commentRss/25277.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/25277.html

Snap002.gif
Snap003.gif Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif
Snap004.gif


bluesky 2005-12-24 08:43 发表评论
]]>
Jakarta Slide 使用W记http://www.tkk7.com/bluesky/archive/2005/12/23/25206.htmlblueskyblueskyFri, 23 Dec 2005 06:56:00 GMThttp://www.tkk7.com/bluesky/archive/2005/12/23/25206.htmlhttp://www.tkk7.com/bluesky/comments/25206.htmlhttp://www.tkk7.com/bluesky/archive/2005/12/23/25206.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/25206.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/25206.htmlicq00.gif
Jakarta slide
主要模型是一个文件仓库管理系l?可以用来做CMS基础框架;
能达到网l硬盘共享或者f(xi)tp服务器相同的作用,通过WebDav,slide可以上传,下蝲,删除文g--
Zweb的文件管理系l?

org.apache.slide.webdav.method.GetMethod  //处理h的类
org.apache.slide.webdav.util.DirectoryIndexGenerator  //回复h的类
所有的文g都通过q个cL"qo(h)" 如果是html把html源文件显C?BR>http://wiki.apache.org/jakarta-slide/FrontPage



bluesky 2005-12-23 14:56 发表评论
]]>
理解IOC容器的概念和DIhttp://www.tkk7.com/bluesky/archive/2005/12/23/25161.htmlblueskyblueskyFri, 23 Dec 2005 02:04:00 GMThttp://www.tkk7.com/bluesky/archive/2005/12/23/25161.htmlhttp://www.tkk7.com/bluesky/comments/25161.htmlhttp://www.tkk7.com/bluesky/archive/2005/12/23/25161.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/25161.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/25161.html015.jpg

Inversion of Control/Dependency Injection
IOC容器
相当于一个bean工厂,来管理整个应用程序中使用的bean,来管理这些bean的生命周?

实现IOC/DI是通过一堆描q文?IOC容器Ҏ(gu)q堆描述文g来实现创建对象提供服务等工作;

一般情况下,我们通过new一个对象ƈ调用q个对象的某个方法来完成服务.

既然有了(jin)IOC容器理概念,那么通过描述文g容器׃ؓ(f)我们创徏所需要对象和Ҏ(gu).

好处是减少?jin)硬~码.

There are three different implementation pattern types for IoC:

type-1 Services need to implement a dedicated interface through which they are provided with an object from which they can look up dependencies (other services). This is the pattern used by the earlier containers provided by Excalibur.
type-2 Services dependencies upon are assigned via JavaBeans properties (setter methods). Both HiveMind and Spring use this approach.
type-3 Services dependencies are provided as constructor parameters (and are not exposed as JavaBeans properties). This is the exclusive approach used by PicoContainer, and is also used in HiveMind and Spring.

http://jakarta.apache.org/hivemind/ioc.html

http://www.javaworld.com.tw/confluence/display/opensrc/Spring

bluesky 2005-12-23 10:04 发表评论
]]>
修正一下Hibernate取count(*)的方?/title><link>http://www.tkk7.com/bluesky/archive/2005/12/22/25069.html</link><dc:creator>bluesky</dc:creator><author>bluesky</author><pubDate>Thu, 22 Dec 2005 06:20:00 GMT</pubDate><guid>http://www.tkk7.com/bluesky/archive/2005/12/22/25069.html</guid><wfw:comment>http://www.tkk7.com/bluesky/comments/25069.html</wfw:comment><comments>http://www.tkk7.com/bluesky/archive/2005/12/22/25069.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.tkk7.com/bluesky/comments/commentRss/25069.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/bluesky/services/trackbacks/25069.html</trackback:ping><description><![CDATA[<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> getCount(String emailGroupId, String emailBatchId)<BR><IMG id=Codehighlighter1_92_758_Open_Image onclick="this.style.display='none'; Codehighlighter1_92_758_Open_Text.style.display='none'; Codehighlighter1_92_758_Closed_Image.style.display='inline'; Codehighlighter1_92_758_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_92_758_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_92_758_Closed_Text.style.display='none'; Codehighlighter1_92_758_Open_Image.style.display='inline'; Codehighlighter1_92_758_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">throws</SPAN><SPAN style="COLOR: #000000"> HibernateException </SPAN><SPAN id=Codehighlighter1_92_758_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_92_758_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        Session session </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> HibernateUtil.currentSession();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        Transaction tx </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> session.beginTransaction();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        String hql </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">select count(*) from EmailSendInfo where email_group_id = :emailGroupId and batch_id = :batchId</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        Query query </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> session.createQuery(hql);<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        query.setString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">emailGroupId</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">, emailGroupId);<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        query.setString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">batchId</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">, emailBatchId);<BR><IMG id=Codehighlighter1_447_560_Open_Image onclick="this.style.display='none'; Codehighlighter1_447_560_Open_Text.style.display='none'; Codehighlighter1_447_560_Closed_Image.style.display='inline'; Codehighlighter1_447_560_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_447_560_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_447_560_Closed_Text.style.display='none'; Codehighlighter1_447_560_Open_Image.style.display='inline'; Codehighlighter1_447_560_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN id=Codehighlighter1_447_560_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_447_560_Open_Text><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>         * for (Iterator it = query.iterate(); it.hasNext();) { return<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>         * ((Integer) it.next()).intValue(); }<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>         </SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_568_629_Open_Image onclick="this.style.display='none'; Codehighlighter1_568_629_Open_Text.style.display='none'; Codehighlighter1_568_629_Closed_Image.style.display='inline'; Codehighlighter1_568_629_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_568_629_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_568_629_Closed_Text.style.display='none'; Codehighlighter1_568_629_Open_Image.style.display='inline'; Codehighlighter1_568_629_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_568_629_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_568_629_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> ((Integer) query.iterate().next()).intValue();<BR><IMG id=Codehighlighter1_651_692_Open_Image onclick="this.style.display='none'; Codehighlighter1_651_692_Open_Text.style.display='none'; Codehighlighter1_651_692_Closed_Image.style.display='inline'; Codehighlighter1_651_692_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_651_692_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_651_692_Closed_Text.style.display='none'; Codehighlighter1_651_692_Open_Image.style.display='inline'; Codehighlighter1_651_692_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000"> (Exception e) </SPAN><SPAN id=Codehighlighter1_651_692_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_651_692_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">throw</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> HibernateException(</SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000">);<BR><IMG id=Codehighlighter1_702_755_Open_Image onclick="this.style.display='none'; Codehighlighter1_702_755_Open_Text.style.display='none'; Codehighlighter1_702_755_Closed_Image.style.display='inline'; Codehighlighter1_702_755_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_702_755_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_702_755_Closed_Text.style.display='none'; Codehighlighter1_702_755_Open_Image.style.display='inline'; Codehighlighter1_702_755_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">finally</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_702_755_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_702_755_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            tx.commit();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            HibernateUtil.closeSession();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>    }</SPAN></SPAN></DIV><img src ="http://www.tkk7.com/bluesky/aggbug/25069.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/bluesky/" target="_blank">bluesky</a> 2005-12-22 14:20 <a href="http://www.tkk7.com/bluesky/archive/2005/12/22/25069.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>俺用hibernate最原始的方法取得count(*)http://www.tkk7.com/bluesky/archive/2005/12/22/25050.htmlblueskyblueskyThu, 22 Dec 2005 04:27:00 GMThttp://www.tkk7.com/bluesky/archive/2005/12/22/25050.htmlhttp://www.tkk7.com/bluesky/comments/25050.htmlhttp://www.tkk7.com/bluesky/archive/2005/12/22/25050.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/25050.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/25050.html

    public int getCount(String emailGroupId, String emailBatchId)
            
throws HibernateException {

        Session session 
= HibernateUtil.currentSession();
        Transaction tx 
= session.beginTransaction();

        String hql 
= "select count(*) from EmailSendInfo where email_group_id = :emailGroupId and batch_id = :batchId";
        Query query 
= session.createQuery(hql);

        query.setString(
"emailGroupId", emailGroupId);
        query.setString(
"batchId", emailBatchId);

        
for (Iterator it = query.iterate(); it.hasNext();) {
            
return ((Integer) it.next()).intValue();
        }

        
return 0;
    }
得挺原始?俺又不会(x)用别?BR>
Spring+Hibernate 如何使用count(*)Q{Q?nbsp;
 
W一U方法:(x)
String hql 
= "select count(*) from User as user";
Integer count = (Integer)getHibernateTemplate().find(hql).listIterator().next();
return count.intValue();
W二U方法:(x)
String hql 
= "select count(*) from User as user";
return ((Integer)getHibernateTemplate().iterate(hql).next()).intValue();
W三U方法:(x)
String hql 
= "select count(*) from User as user";
Query query = getHibernateTemplate().createQuery( getSession(),hql);
return ((Integer)query.uniqueResult()).intValue();  
 
?jin)Spring 可是俺拿不到getHibernateTemplate 拿到LI?可能是因Z没有配置a(chn)pplicationContext.xml中的<beans></beans>
DAO support 需要注入一些东东吧,比如说sessionFactory... :(


bluesky 2005-12-22 12:27 发表评论
]]>
Hibernate的分?/title><link>http://www.tkk7.com/bluesky/archive/2005/12/21/24946.html</link><dc:creator>bluesky</dc:creator><author>bluesky</author><pubDate>Wed, 21 Dec 2005 06:16:00 GMT</pubDate><guid>http://www.tkk7.com/bluesky/archive/2005/12/21/24946.html</guid><wfw:comment>http://www.tkk7.com/bluesky/comments/24946.html</wfw:comment><comments>http://www.tkk7.com/bluesky/archive/2005/12/21/24946.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/bluesky/comments/commentRss/24946.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/bluesky/services/trackbacks/24946.html</trackback:ping><description><![CDATA[<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000"><FONT style="BACKGROUND-COLOR: #eeeeee"> </FONT>Session session </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> HibernateUtil.currentSession();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><BR>Transaction tx </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> session.beginTransaction();<BR>Query query </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> session.createQuery(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">from Cat</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><BR>query.setFirstResult(</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">);</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">开?/SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">query.setMaxResult(</SPAN><SPAN style="COLOR: #000000">10</SPAN><SPAN style="COLOR: #000000">);<FONT color=#006400>//最?/FONT><BR><IMG id=Codehighlighter1_258_292_Open_Image onclick="this.style.display='none'; Codehighlighter1_258_292_Open_Text.style.display='none'; Codehighlighter1_258_292_Closed_Image.style.display='inline'; Codehighlighter1_258_292_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_258_292_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_258_292_Closed_Text.style.display='none'; Codehighlighter1_258_292_Open_Image.style.display='inline'; Codehighlighter1_258_292_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000"> (Iterator it </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> query.iterate(); it.hasNext();) </SPAN><SPAN id=Codehighlighter1_258_292_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_258_292_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>      </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">Object obj = it.next();</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR>tx.commit();<BR>HibernateUtil.closeSession();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><BR>HibernateUtil.java<BR><BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_27_918_Open_Image onclick="this.style.display='none'; Codehighlighter1_27_918_Open_Text.style.display='none'; Codehighlighter1_27_918_Closed_Image.style.display='inline'; Codehighlighter1_27_918_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_27_918_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_27_918_Closed_Text.style.display='none'; Codehighlighter1_27_918_Open_Image.style.display='inline'; Codehighlighter1_27_918_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> HibernateUtil </SPAN><SPAN id=Codehighlighter1_27_918_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_27_918_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">final</SPAN><SPAN style="COLOR: #000000"> SessionFactory sessionFactory;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_91_314_Open_Image onclick="this.style.display='none'; Codehighlighter1_91_314_Open_Text.style.display='none'; Codehighlighter1_91_314_Closed_Image.style.display='inline'; Codehighlighter1_91_314_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_91_314_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_91_314_Closed_Text.style.display='none'; Codehighlighter1_91_314_Open_Image.style.display='inline'; Codehighlighter1_91_314_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_91_314_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_91_314_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_99_238_Open_Image onclick="this.style.display='none'; Codehighlighter1_99_238_Open_Text.style.display='none'; Codehighlighter1_99_238_Closed_Image.style.display='inline'; Codehighlighter1_99_238_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_99_238_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_99_238_Closed_Text.style.display='none'; Codehighlighter1_99_238_Open_Image.style.display='inline'; Codehighlighter1_99_238_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_99_238_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_99_238_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Create the SessionFactory</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">            Configuration cfg </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Configuration().configure();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            sessionFactory </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> cfg.buildSessionFactory();<BR><IMG id=Codehighlighter1_261_311_Open_Image onclick="this.style.display='none'; Codehighlighter1_261_311_Open_Text.style.display='none'; Codehighlighter1_261_311_Closed_Image.style.display='inline'; Codehighlighter1_261_311_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_261_311_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_261_311_Closed_Text.style.display='none'; Codehighlighter1_261_311_Open_Image.style.display='inline'; Codehighlighter1_261_311_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000"> (Throwable ex) </SPAN><SPAN id=Codehighlighter1_261_311_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_261_311_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">throw</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> ExceptionInInitializerError(ex);<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">final</SPAN><SPAN style="COLOR: #000000"> ThreadLocal session </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> ThreadLocal();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_420_668_Open_Image onclick="this.style.display='none'; Codehighlighter1_420_668_Open_Text.style.display='none'; Codehighlighter1_420_668_Closed_Image.style.display='inline'; Codehighlighter1_420_668_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_420_668_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_420_668_Closed_Text.style.display='none'; Codehighlighter1_420_668_Open_Image.style.display='inline'; Codehighlighter1_420_668_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> Session currentSession() </SPAN><SPAN id=Codehighlighter1_420_668_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_420_668_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        Session s </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (Session) session.get();<BR><IMG id=Codehighlighter1_478_653_Open_Image onclick="this.style.display='none'; Codehighlighter1_478_653_Open_Text.style.display='none'; Codehighlighter1_478_653_Closed_Image.style.display='inline'; Codehighlighter1_478_653_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_478_653_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_478_653_Closed_Text.style.display='none'; Codehighlighter1_478_653_Open_Image.style.display='inline'; Codehighlighter1_478_653_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (s </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN id=Codehighlighter1_478_653_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_478_653_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_487_530_Open_Image onclick="this.style.display='none'; Codehighlighter1_487_530_Open_Text.style.display='none'; Codehighlighter1_487_530_Closed_Image.style.display='inline'; Codehighlighter1_487_530_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_487_530_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_487_530_Closed_Text.style.display='none'; Codehighlighter1_487_530_Open_Image.style.display='inline'; Codehighlighter1_487_530_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_487_530_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_487_530_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                s </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> sessionFactory.openSession();<BR><IMG id=Codehighlighter1_561_630_Open_Image onclick="this.style.display='none'; Codehighlighter1_561_630_Open_Text.style.display='none'; Codehighlighter1_561_630_Closed_Image.style.display='inline'; Codehighlighter1_561_630_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_561_630_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_561_630_Closed_Text.style.display='none'; Codehighlighter1_561_630_Open_Image.style.display='inline'; Codehighlighter1_561_630_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            }</SPAN></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000"> (HibernateException e) </SPAN><SPAN id=Codehighlighter1_561_630_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_561_630_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> TODO Auto-generated catch block</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">                e.printStackTrace();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>            }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            session.set(s);<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> s;<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_706_915_Open_Image onclick="this.style.display='none'; Codehighlighter1_706_915_Open_Text.style.display='none'; Codehighlighter1_706_915_Closed_Image.style.display='inline'; Codehighlighter1_706_915_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_706_915_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_706_915_Closed_Text.style.display='none'; Codehighlighter1_706_915_Open_Image.style.display='inline'; Codehighlighter1_706_915_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> closeSession() </SPAN><SPAN id=Codehighlighter1_706_915_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_706_915_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        Session s </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (Session) session.get();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (s </SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)<BR><IMG id=Codehighlighter1_771_791_Open_Image onclick="this.style.display='none'; Codehighlighter1_771_791_Open_Text.style.display='none'; Codehighlighter1_771_791_Closed_Image.style.display='inline'; Codehighlighter1_771_791_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_771_791_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_771_791_Closed_Text.style.display='none'; Codehighlighter1_771_791_Open_Image.style.display='inline'; Codehighlighter1_771_791_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_771_791_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_771_791_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                s.close();<BR><IMG id=Codehighlighter1_822_891_Open_Image onclick="this.style.display='none'; Codehighlighter1_822_891_Open_Text.style.display='none'; Codehighlighter1_822_891_Closed_Image.style.display='inline'; Codehighlighter1_822_891_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_822_891_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_822_891_Closed_Text.style.display='none'; Codehighlighter1_822_891_Open_Image.style.display='inline'; Codehighlighter1_822_891_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            }</SPAN></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000"> (HibernateException e) </SPAN><SPAN id=Codehighlighter1_822_891_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_822_891_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> TODO Auto-generated catch block</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">                e.printStackTrace();<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>            }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        session.set(</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV><img src ="http://www.tkk7.com/bluesky/aggbug/24946.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/bluesky/" target="_blank">bluesky</a> 2005-12-21 14:16 <a href="http://www.tkk7.com/bluesky/archive/2005/12/21/24946.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MD5加密法http://www.tkk7.com/bluesky/archive/2005/12/19/24567.htmlblueskyblueskyMon, 19 Dec 2005 01:47:00 GMThttp://www.tkk7.com/bluesky/archive/2005/12/19/24567.htmlhttp://www.tkk7.com/bluesky/comments/24567.htmlhttp://www.tkk7.com/bluesky/archive/2005/12/19/24567.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/24567.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/24567.html 

介绍MD5加密法基本情况MD5的全U是Message-Digest Algorithm 5Q在90q代初由MIT的计机U学实验室和RSA Data Security Inc发明Q经MD2、MD3和MD4发展而来?BR>Message-Digest泛指字节?Message)的Hash变换Q就是把一个Q意长度的字节串变换成一定长的大整数。请注意我用了(jin)"字节?而不?字符?q个词,是因U变换只与字节的值有养I与字W集或编码方式无兟?

MD5Q意长度的"字节?变换成一?28bit的大整数Qƈ且它是一个不可逆的字符串变换算法,换句话说是Q即使你看到源程序和法描述Q也无法一个MD5的值变换回原始的字W串Q从数学原理上说Q是因ؓ(f)原始的字W串有无I多个,q有点象不存在反函数的数学函数?/P>

MD5的典型应用是对一DMessage(字节?产生fingerprint(指纹)Q以防止?改"。D个例子,你将一D话写在一个叫readme.txt文g中,q对q个readme.txt产生一个MD5的值ƈ记录在案Q然后你可以传播q个文gl别人,别h如果修改?jin)文件中的Q何内容,你对q个文g重新计算MD5时就?x)发现。如果再有一个第三方的认证机构,用MD5q可以防止文件作者的"抵赖"Q这是所谓的数字{֐应用?/P>

MD5q广泛用于加密和解密技术上Q在很多操作pȝ中,用户的密码是以MD5|或类似的其它法Q的方式保存的,用户Login的时候,pȝ是把用户输入的密码计成MD5|然后再去和系l中保存的MD5D行比较,而系lƈ?知道"用户的密码是什么?/P>

一些黑客破莯U密码的Ҏ(gu)是一U被UCؓ(f)"跑字?的方法。有两种Ҏ(gu)得到字典Q一U是日常搜集的用做密码的字符串表Q另一U是用排列组合方法生成的Q先用MD5E序计算?gu)些字兔R的MD5|然后再用目标的MD5值在q个字典中检索?/P>

即假设密码的最大长度ؓ(f)8Q同时密码只能是字母和数字,?6+26+10=62个字W,排列l合出的字典的项数则是P(62,1)+P(62,2)....+P(62,8)Q那也已l是一个很天文的数字了(jin)Q存储这个字典就需要TBU的盘l,而且q种Ҏ(gu)q有一个前提,是能获得目标̎L(fng)密码MD5值的情况下才可以?/P>

在很多电(sh)子商务和C֌应用中,理用户的Account是一U最常用的基本功能,管很多Application Server提供?jin)这些基本组Ӟ但很多应用开发者ؓ(f)?jin)管理的更大的灵zL还是喜Ƣ采用关pL据库来管理用P懒惰的做法是用户的密码往往使用明文或简单的变换后直接保存在数据库中Q因此这些用L(fng)密码对Y件开发者或pȝ理员来说可以说毫无保密可言Q本文的目的是介lMD5的Java Bean的实玎ͼ同时l出用MD5来处理用L(fng)Account密码的例子,q种Ҏ(gu)使得理员和E序设计者都无法看到用户的密码,管他们可以初始化它们。但重要的一Ҏ(gu)对于用户密码讄?fn)惯的保?/P>

MD加密法的JAVA描述为:(x)

import java.security.*
import java.security.spec.*;  

 

class Md5{
public final static String MD5(String s)
char hexDigits[] = 
'0''1''2''3''4''5''6''7''8''9''a''b''c''d''e''f'}

try 
byte[] strTemp = s.getBytes(); 
MessageDigest mdTemp 
= MessageDigest.getInstance("MD5"); 
mdTemp.update(strTemp); 
byte[] md = mdTemp.digest(); 
int j = md.length; 
char str[] = new char[j * 2]; 
int k = 0
for (int i = 0; i < j; i++
byte byte0 = md[i]; 
str[k
++= hexDigits[byte0 >>> 4 & 0xf]; 
str[k
++= hexDigits[byte0 & 0xf]; 
}
 
return new String(str); 
}
 
catch (Exception e)
return null
}
 
}
 
public static void main(String[] args)
System.out.print(MD5.Md5(
"XX")); 
}



bluesky 2005-12-19 09:47 发表评论
]]>
Weblogic 配置 MailSessionhttp://www.tkk7.com/bluesky/archive/2005/12/16/24196.htmlblueskyblueskyFri, 16 Dec 2005 05:43:00 GMThttp://www.tkk7.com/bluesky/archive/2005/12/16/24196.htmlhttp://www.tkk7.com/bluesky/comments/24196.htmlhttp://www.tkk7.com/bluesky/archive/2005/12/16/24196.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/24196.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/24196.htmlWebligic 的MailSession 不能通过q程调用来获得必dwebloigc的容器中才能通过JNDI拿到 mail Session对象

http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-summary.html

属性的讄如下

mail.smtp.user=example
mail.smtp.port
=25
mail.debug
=true
mail.smtp.host
=192.168.8.1
mail.smtp.auth
=true

mail.smtp.form q(sh)能随便设|?必须是提供用户名密码验证后的那个用户的地址,不然q发不出?BR>
D的问题可能是webloigc的j2ee的Jmail paggage版本比较落后

bluesky 2005-12-16 13:43 发表评论
]]>
hibernate.cfg.xml配置sybase数据库不支持左连接sql语句http://www.tkk7.com/bluesky/archive/2005/12/16/24194.htmlblueskyblueskyFri, 16 Dec 2005 05:36:00 GMThttp://www.tkk7.com/bluesky/archive/2005/12/16/24194.htmlhttp://www.tkk7.com/bluesky/comments/24194.htmlhttp://www.tkk7.com/bluesky/archive/2005/12/16/24194.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/24194.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/24194.html<property name="hibernate.use_outer_join">false</property>
 把这句设|成false ׃?x)?left outer join 的sql语句
 
如果ture通过兌 mapping 映射 many-to-one 产生的sql语句 不能执行 提示sql语法有错?BR> 
 
  <many-to-one name="MemberInfo"
            insert
="false"
            update
="false" 
            not-null
="true">
            <column name
="member_no" />
            <column name
="corp_id" />
   </many-to-one>  


bluesky 2005-12-16 13:36 发表评论
]]>
Weblogic-JNDI-MailSession-javaMail-java.io.NotSerializableException: javax.mail.Sessionhttp://www.tkk7.com/bluesky/archive/2005/12/13/23687.htmlblueskyblueskyTue, 13 Dec 2005 07:54:00 GMThttp://www.tkk7.com/bluesky/archive/2005/12/13/23687.htmlhttp://www.tkk7.com/bluesky/comments/23687.htmlhttp://www.tkk7.com/bluesky/archive/2005/12/13/23687.html#Feedback0http://www.tkk7.com/bluesky/comments/commentRss/23687.htmlhttp://www.tkk7.com/bluesky/services/trackbacks/23687.htmlimport java.util.Properties;

import javax.mail.Session
;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class SendMail {
    Context ic 
= null;

    public SendMail() {
    }

    private Properties props
;

    public void send() throws Exception {

        // 使用JNDI查询Mail Session
        try {

            /*
             * Hashtable ht 
= new Hashtable();
             * ht.put(Context.INITIAL_CONTEXT_FACTORY,
             * 
"weblogic.jndi.WLInitialContextFactory");
             * ht.put(Context.PROVIDER_URL, "t3://localhost:7001/slide/"); ic =
             * new InitialContext(ht);
             */
            ic 
= getInitialContext();
            Session session = (Session) ic.lookup("mail/MailSession");

        } catch (NamingException e) {
            e.printStackTrace()
;
        }

    }

    public static void main(String args
[]) throws Exception {
        SendMail sendMail 
= new SendMail();
        sendMail.send();
        System.out.println("send ok");
    }

    public Context getInitialContext() throws Exception {
        String url 
= "t3://localhost:7001";
        String user = "weblogic";
        String password = "weblogic";
        Properties properties = null;
        try {
            properties 
= new Properties();
            properties.put(Context.INITIAL_CONTEXT_FACTORY,
                    
"weblogic.jndi.WLInitialContextFactory");
            properties.put(Context.PROVIDER_URL, url);
            if (user != null) {
                properties.put(Context.SECURITY_PRINCIPAL
, user);
                properties.put(Context.SECURITY_CREDENTIALS,
                        password 
== null ? "" : password);
            }

            return new InitialContext(properties)
;
        } catch (Exception e) {
            throw e
;
        }
    }

}

java.io.NotSerializableException: javax.mail.Session]

相关帖子

http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=122&threadID=10958&tstart=1112

http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=121&threadID=27136&tstart=15

http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=1&threadID=1450&tstart=1440

weblogic配置

服务-邮g-在此中Q?zhn)可以定义此邮件?x)话的配置?BR>
名称:MyMailSession
JNDI 名称:mail/MailSession
属?/FONT>
:
mail.debug=true
mail.smtp.port=25
mail.smtp.auth=true
mail.smtp.host=192.168.8.1

用来配置此邮件会(x)话的属性。这些属性名是在 JavaMail API 设计规范中指定的?/FONT>







bluesky 2005-12-13 15:54 发表评论
]]>
[转蝲]javamail发送邮?/title><link>http://www.tkk7.com/bluesky/archive/2005/12/13/23619.html</link><dc:creator>bluesky</dc:creator><author>bluesky</author><pubDate>Tue, 13 Dec 2005 03:41:00 GMT</pubDate><guid>http://www.tkk7.com/bluesky/archive/2005/12/13/23619.html</guid><wfw:comment>http://www.tkk7.com/bluesky/comments/23619.html</wfw:comment><comments>http://www.tkk7.com/bluesky/archive/2005/12/13/23619.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/bluesky/comments/commentRss/23619.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/bluesky/services/trackbacks/23619.html</trackback:ping><description><![CDATA[     摘要: http://spaces.msn.com/members/tcjava/ /*在java版经常看到有人问如何用javamail发送邮Ӟ如何接收邮gQ如何访问多个文件夹{。问题零散,而历史的回复早已l没在问题的vz之中。本Z前所做过一个java目Q其中包含有WebMail功能Q当初ؓ(f)用java实现而对javamail摸烦(ch)?jin)一D|_(d)ȝ有点收获。看到论坛中的经常有此方面的问题Q因此把我的...  <a href='http://www.tkk7.com/bluesky/archive/2005/12/13/23619.html'>阅读全文</a><img src ="http://www.tkk7.com/bluesky/aggbug/23619.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/bluesky/" target="_blank">bluesky</a> 2005-12-13 11:41 <a href="http://www.tkk7.com/bluesky/archive/2005/12/13/23619.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> վ֩ģ壺 <a href="http://www-554949.com" target="_blank">99þþƷƵ</a>| <a href="http://31xyz.com" target="_blank">þþӰԺ޾Ʒ</a>| <a href="http://o091i.com" target="_blank">ѹվ߹ۿҪ</a>| <a href="http://863409.com" target="_blank">ַѹۿ</a>| <a href="http://666za.com" target="_blank">˾þ¶ۺ</a>| <a href="http://cc58866.com" target="_blank">Ʒþþþa</a>| <a href="http://88ww99.com" target="_blank">츾þþƷ</a>| <a href="http://whyandroid.com" target="_blank">޾ƷƵ߹ۿ</a>| <a href="http://sdshfengji.com" target="_blank">쾫Ʒ߹ۿ</a>| <a href="http://shbailongma.com" target="_blank">2022ĻƵ</a>| <a href="http://hcdigi.com" target="_blank">޸һ</a>| <a href="http://zhaoav7.com" target="_blank">91㽶վ</a>| <a href="http://74rr.com" target="_blank">˾Ʒ2020</a>| <a href="http://papapa97.com" target="_blank">ҹƵվ</a>| <a href="http://anhuish.com" target="_blank">Ļþ2020 </a>| <a href="http://5222133.com" target="_blank">޹ۺϾƷ</a>| <a href="http://micehunan.com" target="_blank">ۺƵ</a>| <a href="http://jipiao020.com" target="_blank">˳ɵӰվþ</a>| <a href="http://szclinic.com" target="_blank">Ļַ</a>| <a href="http://3789re.com" target="_blank">߿ʮ˽վ</a>| <a href="http://qiwangxuan.com" target="_blank">mm1313޾Ʒ</a>| <a href="http://1y3c.com" target="_blank">fc2ѹƵվ</a>| <a href="http://minliusoft.com" target="_blank">337pձŷ޴</a>| <a href="http://bznys.com" target="_blank">Ƶ߹ۿ</a>| <a href="http://xsdggzs.com" target="_blank">VVA</a>| <a href="http://www-6209.com" target="_blank">99þѹۿ</a>| <a href="http://tttui.com" target="_blank">޹˾þۺһ</a>| <a href="http://xx9911.com" target="_blank">ëƬѹۿƵȫ</a>| <a href="http://bb927bb.com" target="_blank">Ƶ</a>| <a href="http://bjgelinhotel.com" target="_blank">ŮƷþþ</a>| <a href="http://61255555.com" target="_blank">þԭƷ</a>| <a href="http://1877808.com" target="_blank">Ƶһ߲</a>| <a href="http://sxhengshan.com" target="_blank">ëƬAëƬѲ</a>| <a href="http://1314a.com" target="_blank">պa</a>| <a href="http://686kp.com" target="_blank">¹AVר</a>| <a href="http://qqcao7.com" target="_blank">Ʒ99þѹۿ</a>| <a href="http://yamashida.com" target="_blank">޳aƬ߹</a>| <a href="http://1877808.com" target="_blank">ĻӰԺѲ</a>| <a href="http://445645.com" target="_blank">һëƬƵѹۿ</a>| <a href="http://xxxxnii.com" target="_blank">AvרDVD</a>| <a href="http://siqingsizu.com" target="_blank">ŷ˳ɾƷѹۿ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>