<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    honzeland

    記錄點滴。。。

    常用鏈接

    統計

    Famous Websites

    Java

    Linux

    P2P

    最新評論

    2010年1月21日 #

    Interesting books read or being read

    Oracle Performance Tuning for 10gR2, Second Edition -- http://www.amazon.com/Oracle-Performance-Tuning-10gR2-Second/dp/1555583458

    posted @ 2011-04-07 15:30 honzeland 閱讀(202) | 評論 (0)編輯 收藏

    GAE Logging

    Official document: http://code.google.com/appengine/docs/java/runtime.html#Logging  
    Log4j configuration in production env:
    http://blog.xam.de/2010/03/logging-in-google-appengine-for-java.html 
    http://www.mail-archive.com/google-appengine-java@googlegroups.com/msg06396.html

    posted @ 2010-11-11 12:52 honzeland 閱讀(269) | 評論 (0)編輯 收藏

    Read a Stress Test Report

    Load Average: 

    1. http://www.teamquest.com/resources/gunther/display/5/index.htm
    2. 
    http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages (Great)

    posted @ 2010-11-05 14:16 honzeland 閱讀(275) | 評論 (0)編輯 收藏

    GAE Mapping

    Executing Simple Joins Across Owned Relationships

    posted @ 2010-10-27 13:27 honzeland 閱讀(250) | 評論 (0)編輯 收藏

    Servlet Mappings - rules, pattern....

    http://www.rawbw.com/~davidm/tini/TiniHttpServer/docs/ServletMappings.html

    posted @ 2010-10-22 22:41 honzeland 閱讀(286) | 評論 (0)編輯 收藏

    GWT-RPC in a Nutshell - go through the internal

    GWT-RPC in a Nutshell: http://www.gdssecurity.com/l/b/2009/10/08/gwt-rpc-in-a-nutshell/

    posted @ 2010-10-22 22:40 honzeland 閱讀(223) | 評論 (0)編輯 收藏

    [zz] Tuning Your Stress Test Harness

    HTTP://WWW.THESERVERSIDE.COM/NEWS/1365219/TUNING-YOUR-STRESS-TEST-HARNESS?ASRC=SS_CLA_315053&PSRC=CLT_81

    posted @ 2010-09-11 12:27 honzeland 閱讀(243) | 評論 (0)編輯 收藏

    GWT 2 Spring 3 JPA 2 Hibernate 3.5 Tutorial – Eclipse and Maven 2 showcase

    See details at: http://www.javacodegeeks.com/2010/07/gwt-2-spring-3-jpa-2-hibernate-35.html
    Executing Simple Joins Across Owned Relationships for gae: http://gae-java-persistence.blogspot.com/2010/03/executing-simple-joins-across-owned.html

    posted @ 2010-08-20 13:01 honzeland 閱讀(417) | 評論 (0)編輯 收藏

    Java remote invocation frameworks (RPC)

    1. Remote Method Invocation (RMI)

    2. Hessian

    3. Burlap

    4. HTTP invoker

    5. EJB

    6. JAX-RPC

    7. JMX

    posted @ 2010-06-09 14:25 honzeland 閱讀(249) | 評論 (0)編輯 收藏

    Tomcat Architecture Diagram

    zz from http://marakana.com/forums/tomcat/general/106.html


    Valve and Filter:
    "Valve" is Tomcat specific notion, and they get applied at a higher level than anything in a specific webapp. Also, they work only in Tomcat.

    "Filter" is a Servlet Specification notion and should work in any compliant servlet container. They get applied at a lower level than all of Tomcat's
    Valves.

    However, consider also the division between your application and the application  server. Think whether the feature you're planning is part of your application, or is it rather a generic feature of the application server, which could have uses in other applications as well. This would be the correct criteria to decide between Valve and Filter.

    Order for filter: The order in which they are defined matters. The container will execute the filters in the order in which they are defined.

    posted @ 2010-05-10 10:39 honzeland 閱讀(1541) | 評論 (0)編輯 收藏

    Hibernate Annotations

    Use one single table "blank_fields" for both A and B. "blank_fields" has fields: 'ref_id', 'blank_field', 'type'. 'type' is used to identify which entity the record belongs to. Use 'type' + 'ref_id' to specify the collection of elements for one entity.

    @Entity
    @Table(name 
    = "table_a")
    public class A {
        
    private Set<BlankField> blankFields = new HashSet<BlankField>();
       
        @CollectionOfElements
        @Fetch(FetchMode.SUBSELECT)
        @Enumerated(EnumType.ORDINAL)
        @JoinTable(name 
    = "blank_fields", joinColumns = { @JoinColumn(name = "ref_id") })
        @Cascade(value 
    = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
        @Column(name 
    = "blank_field", nullable = false)
        @SQLInsert(sql 
    = "INSERT INTO blank_fields(ref_id, blank_field, type) VALUES(?,?,0)")
        @Where(clause 
    = "type=0")
        
    public Set<BlankField> getBlankFields() { // BlankField is an enum
            
    return blankFields;
        }

        @SuppressWarnings(
    "unused")
        
    private void setBlankFields(Set<BlankField> blankFields) {
            
    this.blankFields = blankFields;
        }
    // End B

    @Entity
    @Table(name 
    = "table_b")
    public class B {
        
    private Set<BlankField> blankFields = new HashSet<BlankField>();
       
        @CollectionOfElements
        @Fetch(FetchMode.SUBSELECT)
        @Enumerated(EnumType.ORDINAL)
        @JoinTable(name 
    = "blank_fields", joinColumns = { @JoinColumn(name = "ref_id") })
        @Cascade(value 
    = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
        @Column(name 
    = "blank_field", nullable = false)
        @SQLInsert(sql 
    = "INSERT INTO blank_fields(ref_id, blank_field, type) VALUES(?,?,1)"// used for insert
        @Where(clause = "type=1"// used for query, if not @CollectionOfElements, such as @OneToMany, use @WhereJoinTable instead
        public Set<BlankField> getBlankFields() {
            
    return blankFields;
        }

        @SuppressWarnings(
    "unused")
        
    private void setBlankFields(Set<BlankField> blankFields) {
            
    this.blankFields = blankFields;
        }
    }

    當然還有其他的方式來實現上面的需求,上面采用的單表來記錄不同實體的associations(這兒是CollectionOfElements,并且返回的是Set<Enum>,不是Set<Embeddable>),然后用'type'來區分不同的實體,這樣做的好處是:數據庫冗余少,易于擴展,對于新的實體,只需加一個type值,而不需更改數據庫表結構。另外一種采用單表的方式是為每個實體增加新的字段,如
    "blank_fields": 'a_id', 'b_id', 'blank_field', a_id reference table_a (id), b_id reference table_b (id). 這樣在映射的時候更簡單,
    對于A,映射為
    @JoinTable(name = "blank_fields", joinColumns = { @JoinColumn(name = "a_id") })
    對于B,映射為
    @JoinTable(name = "blank_fields", joinColumns = { @JoinColumn(name = "b_id") })
    這樣作的缺點是:帶來了數據庫冗余,對于blank_fields來講,任一條記錄,a_id和b_id中只有一個不為null。當多個實體共用這個表時,用上面的方法更合理,如果共用實體不多時,這種方法更方便。

    posted @ 2010-04-20 17:20 honzeland 閱讀(454) | 評論 (0)編輯 收藏

    One Hibernate Session Multiple Transactions

    The case to use One Hibernate Session Multiple Transactions:
    each transaction would NOT affect others.
    i.e., open multiple transactions on the same session, even though one transaction rolls back, other transactions can be committed. If one action fails, others should fail too, then we should use one transaction for all actions.

    Note:
    A rollback with a single Session will lead to that Session being cleared (through "Session.clear()").
    So do lazy collections still work if the session is cleared? =>Not of any objects that you loaded up until the rollback. Only for new objects loaded afterwards.
    We should load necessary objects to session for each transactional action to avoid LazyInitializationException, even if those objects are loaded before other forward transactional actions, since forward action may be rolled back and clear the session.

    BTW, Hibernate Session.merge() is different with Session.update() by:
    Item item2 = session.merge(item);
    item2 
    == item; // false, item - DETACHED, item2 - PERSIST
    session.update(item); // no return value, make item PERSIST


    posted @ 2010-03-01 11:47 honzeland 閱讀(409) | 評論 (0)編輯 收藏

    org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only

    發生這種異常的case:
        @Transactional
        
    public void foo() {
            
    try{
                bar();
            } 
    catch (RuntimeException re) {
                
    // caught but not throw further
                
            }
            
        }

        @Transactional
        
    public void bar() {
            
        }
    如果foo在調用bar的時候,bar拋出RuntimeException,Spring在bar return時將Transactional標記為Rollback only, 而foo捕獲了bar的RuntimeException,所以Spring將會commit foo的事務,但是foo和bar使用的是同一事務,因此在commit foo事務時,將會拋出UnexpectedRollbackException。注意:如果foo和bar在同一class中,不會出現這種情況,因為:

    Since this mechanism is based on proxies, only 'external' method calls coming in through the proxy will be intercepted. This means that 'self-invocation', i.e. a method within the target object calling some other method of the target object, won't lead to an actual transaction at runtime even if the invoked method is marked with @Transactional!

    可以通過配置log4j來debug Spring事務獲取情況:
    To delve more into it I would turn up your log4j logging to debug and also look at what ExerciseModuleController is doing at line 91, e.g.: add a logger for org.springframework.transaction

    posted @ 2010-02-24 18:02 honzeland 閱讀(6984) | 評論 (0)編輯 收藏

    Discussion for Open Session In View Pattern for Hibernate

    From: http://www.mail-archive.com/stripes-users@lists.sourceforge.net/msg02908.html


    posted @ 2010-01-29 17:20 honzeland 閱讀(212) | 評論 (0)編輯 收藏

    Quartz scheduled executions

    這周被Quartz折騰了一番。
    我們知道,Quartz采用JobDataMap實現向Job實例傳送配置屬性,正如Quartz官方文檔說的那樣:

    How can I provide properties/configuration for a Job instance? The key is the JobDataMap, which is part of the JobDetail object.
    The JobDataMap can be used to hold any number of (serializable) objects which you wish to have made available to the job instance when it executes.
    JobDataMap map = context.getJobDetail().getJobDataMap();

    我們通過map向Job實例傳送多個objects,其中有一個是個bean,一個是基本類型。對于scheduled triggers,我們要求bean對于所有的序列都不變,包括其屬性,而基本類型可以在Job運行過程中改變,并影響下一個序列。實際情況是,對于下個序列,bean的屬性被上次的修改了,而基本類型卻維持第一次put到Map里面的值。正好和我們要求的相反。

    受bean的影響,以為map里面包含的都是更新的對象,即每個序列里面的JobDetail是同一個對象,但是基本類型的結果否認了這一點。回頭重新翻閱了下Quartz的文檔:

    Now, some additional notes about a job's state data (aka JobDataMap): A Job instance can be defined as "stateful" or "non-stateful". Non-stateful jobs only have their JobDataMap stored at the time they are added to the scheduler. This means that any changes made to the contents of the job data map during execution of the job will be lost, and will not seen by the job the next time it executes.

    Job有兩個子接口:StatefulJob and InterruptableJob,我們繼承的是InterruptableJob,或許Quartz應該有個InterruptableStatefulJob。另外StatefulJob不支持并發執行,和我們的需求不匹配,我們有自己的同步控制,Job必須可以并發運行。

    然后查看了Quartz的相關源碼:

    // RAMJobStore.storeJob
    public void storeJob(SchedulingContext ctxt, JobDetail newJob,
                
    boolean replaceExisting) throws ObjectAlreadyExistsException {
            JobWrapper jw 
    = new JobWrapper((JobDetail)newJob.clone()); // clone a new one
            .
            jobsByFQN.put(jw.key, jw);
            
    }

    也就是說,store里面放的是初始JobDetail的克隆,在序列運行完時,只有StatefulJob才會更新store里面的JobDetail:

    // RAMJobStore.triggeredJobComplete
    public void triggeredJobComplete(SchedulingContext ctxt, Trigger trigger,
                JobDetail jobDetail, 
    int triggerInstCode) {
        JobWrapper jw 
    = (JobWrapper) jobsByFQN.get(jobKey);
        
        
    if (jw != null) {
            JobDetail jd 
    = jw.jobDetail;
            
    if (jd.isStateful()) {
                JobDataMap newData 
    = jobDetail.getJobDataMap();
                
    if (newData != null) {
                    newData 
    = (JobDataMap)newData.clone();
                    newData.clearDirtyFlag();
                }
                jd.setJobDataMap(newData); 
    // set to new one
                
            
        }

    }



    然后,每次序列運行時所用的JobDetail,是存放在Store里面的克隆。

    // RAMJobStore.retrieveJob
    public JobDetail retrieveJob(SchedulingContext ctxt, String jobName,
            String groupName) {
        JobWrapper jw 
    = (JobWrapper) jobsByFQN.get(JobWrapper.getJobNameKey(
            jobName, groupName));
        
    return (jw != null? (JobDetail)jw.jobDetail.clone() : null// clone a new
    }


    問題很清楚了,存放在Store里面的JobDetail是初始對象的克隆,然后每個序列所用的JobDetail, 是Store里面的克隆,只有Stateful job,Store里面的JobDetail才更新。
    最有Quartz里面使用的clone():

    // Shallow copy the jobDataMap.  Note that this means that if a user
    // modifies a value object in this map from the cloned Trigger
    // they will also be modifying this Trigger.
    if (jobDataMap != null) {
        copy.jobDataMap 
    = (JobDataMap)jobDataMap.clone();
    }


    所以對于前面所講的,修改bean的屬性,會影響所有clone的對象,因此,我們可以將基本類型封裝到一個bean里面,map里面存放的是bean,然后通過修改bean的屬性,來達到影響下一個序列的目的。

    posted @ 2010-01-21 17:38 honzeland 閱讀(409) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 免费无码又爽又刺激高潮软件| 国产亚洲精品VA片在线播放| 在线观看成人免费| 亚洲第一区在线观看| jzzijzzij在线观看亚洲熟妇| 免费在线观影网站| 亚洲国产精品无码久久SM| 人人玩人人添人人澡免费| 小小影视日本动漫观看免费 | 亚洲精品中文字幕无码蜜桃| 亚洲H在线播放在线观看H| 中文字幕免费观看全部电影| 最近中文字幕无吗免费高清| 亚洲av无码专区国产乱码在线观看| a视频免费在线观看| 国产人成免费视频| 日韩精品视频在线观看免费 | 国产免费av一区二区三区| 野花视频在线官网免费1| 成年女性特黄午夜视频免费看| 亚洲综合色丁香婷婷六月图片| 午夜一级毛片免费视频| 四虎成人精品国产永久免费无码| 亚洲欭美日韩颜射在线二| 香蕉视频亚洲一级| 亚洲情XO亚洲色XO无码| 麻豆成人久久精品二区三区免费| 亚洲精品无码永久在线观看你懂的| 久久免费视频99| 亚洲国产欧美国产综合一区 | 深夜免费在线视频| 亚洲最大成人网色| 青青青青青青久久久免费观看| 污网站免费在线观看| 亚洲av午夜福利精品一区| 国产一精品一AV一免费孕妇 | 亚洲欧洲日产国码二区首页 | 亚洲αv在线精品糸列| 成全视频免费高清 | 9久热这里只有精品免费 | 一本大道一卡二大卡三卡免费|