JAVA—咖啡館

          ——歡迎訪問rogerfan的博客,常來《JAVA——咖啡館》坐坐,喝杯濃香的咖啡,彼此探討一下JAVA技術,交流工作經驗,分享JAVA帶來的快樂!本網站部分轉載文章,如果有版權問題請與我聯系。

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            447 Posts :: 145 Stories :: 368 Comments :: 0 Trackbacks
          今天中午接到阿里巴巴的電話面試,電面了將近一個小時左右。感覺自己發揮得并不好,好多基礎的只是還是一知半解的, 雖然看過一些東西的源代碼,但是,很多東西,也只是限看過而且,但是一到用的時候,或者被問到的時候, 卻突然失憶……這里記錄一下今天問到的問題。給自己長長記性。

          ================================================

           

            PS 憑著記憶來把他問的問題整理一下,并列出來,準備一一理解清楚

           

            最開始的幾個問題我現在已經記不清楚了, 估計當時緊張了。

           

          ===================================================

           

           你對Java的集合框架了解嗎? 能否說說常用的類? 

           

           說說Hashtable與HashMap的區別: 源代碼級別的區別呢?

           

           平時用過的List有哪些? (除了ArrayList和LinkedList),ArrayList和LinkedList的區別?

           

           ArrayList的特點,內部容器是如何擴充的?

           

           Properties類的特點? 線程安全? 

           

          ===============================================

           平時使用過的框架有哪些? (我提到了Struts2)

           

           請說一下Struts2的初始化?和類的創建?(從源代碼角度出發)

           

           據你了解,除了反射還有什么方式可以動態的創建對象?(我提到了CGLIB…… 我以為他會接著問CGLIB,揪心中……,結果他沒問)

           

           請說一下Struts2 是如何把Action交給Spring托管的?它是單例的還是多例? 你們頁面的表單對象是多例還是單例?

           

           請說一下你們業務層對象是單例還是多例的?

           

           請說一下Struts2源代碼中有哪些設計模式?

           

          ======================================================

           

           請說一下,你覺得你最熟悉的技術特點? (我提到了并發編程)

           

           請說一下線程安全出現的原因? 

           

           請說一下線程池的中斷策略(4個)? 各有什么特點?

           

           請說一下Tomcat配置不同應用的不同端口如何配置? 如何配置數據源? 如何實現動態部署?

           

           請說一下Java常用的優化? 

           

           你了解最新的Servlet規范嗎? 簡單說一下?(我提到了推)

           

           那請你說一下“推”是如何實現的?

           

           線程安全下,StringBuffer與StringBuilder的區別? 它們是如何擴充內部數組容量的? (源代碼)

           

           請說一下Tomcat中的設計模式?(我提到觀察者模式)

           

           是否可以說說Java反射的相關優化機制? (我說我不太清楚…… 他說沒關系 - -!)

           

           請說一些Mysql的常用優化策略?

           

           因為我之前有提到過“推”,他可能對我的知識面比較感興趣,要我說說平時都看些什么書,還了解一些什么其他的技術范疇。

           (他首先提到SOA,我說有了解,并且是未來的趨勢,還有提到云計算,我說有過一定了解,但是并未深究)

           

           =====================================================

           之后是幾個職業方面的問題?

           

           你覺得你的潛力? 你在團隊中的位置? 你覺得跟團隊中最好的還有哪些差距?你要花多少時間趕上他們?

           

           你對阿里巴巴還有什么疑問嗎? (我很囧的問了,“阿里巴巴的牛人平時都跟你們有互動嗎?-----本意是指培訓,但是話沒說清楚……”,囧了……)


          PS,下面是時候對問題的整理,里面純粹僅限于個人淺見,如果有錯誤,還希望各位能指點一二。
          ==================================================================
          • 你對Java的集合框架了解嗎? 能否說說常用的類? 
          Java集合框架類圖:


           
          我常用的類:
          HashMap,Hashtable,HashSet,ArrayList,Vector,LinkedList,Collections,Arrays;

          • 說說Hashtable與HashMap的區別(源代碼級別)


                 1.最明顯的區別在于Hashtable 是同步的(每個方法都是synchronized),而HashMap則不是.

                 2.HashMap繼承至AbstractMap,Hashtable繼承至Dictionary ,前者為Map的骨干, 其內部已經實現了Map所需           要做的大部分工作, 它的子類只需要實現它的少量方法即可具有Map的多項特性。而后者內部都為抽象方法,需要           它的實現類一一作自己的實現,且該類已過時

                  3.兩者檢測是否含有key時,hash算法不一致,HashMap內部需要將key的hash碼重新計算一邊再檢測,而                    Hashtable則直接利用key本身的hash碼來做驗證。

          HashMap:

           

          Java代碼 復制代碼

           

            Hashtable:

           

          Java代碼 復制代碼
          1. int hash = key.hashCode();  

           

            4.兩者初始化容量大小不一致,HashMap內部為 16*0.75 , Hashtable 為 11*0.75

          HashMap:

           

          Java代碼 復制代碼
          1. static final int DEFAULT_INITIAL_CAPACITY = 16;   
          2. static final float DEFAULT_LOAD_FACTOR = 0.75f;   
          3. public HashMap() {   
          4.      this.loadFactor = DEFAULT_LOAD_FACTOR;   
          5.      threshold=(int)(DEFAULT_INITIAL_CAPACITY*DEFAULT_LOAD_FACTOR);   
          6.      table = new Entry[DEFAULT_INITIAL_CAPACITY];   
          7.      init();   
          8. }      
          9. ………………………………  

           

           Hashtable:

           

          Java代碼 復制代碼
          1. public Hashtable() {   
          2.     this(110.75f);   
          3. }   
          4. -----   
          5.  public Hashtable(int initialCapacity, float loadFactor) {   
          6.         ..........   
          7.     this.loadFactor = loadFactor;   
          8.     table = new Entry[initialCapacity];   
          9.     threshold = (int)(initialCapacity * loadFactor);   
          10.     }     

           

             其實后續的區別應該還有很多, 這里先列出4點。

           

          • 平時除了ArrayList和LinkedList外,還用過的List有哪些?
            ArrayList和LinkedList的區別?

           

          事實上,我用過的List主要就是這2個, 另外用過Vector.

          ArrayList和LinkedList的區別:

           

          1. 毫無疑問,第一點就是兩者的內部數據結構不同, ArrayList內部元素容器是一個Object的數組,
            而LinkedList內部實際上一個鏈表的數據結構,其有一個內部類來表示鏈表.
            Java代碼 復制代碼
            1. (ArrayList)   
            2. private transient Object[] elementData;    
            3.   
            4. ………………………………………………………………………………   
            5.   
            6. (LinkedList)   
            7. private transient Entry<E> header = new Entry<E>(nullnullnull);/鏈表頭    
            8.   
            9. //內部鏈表類.   
            10. private static class Entry<E> {   
            11.     E element; //數據元素   
            12.     Entry<E> next; // 前驅   
            13.     Entry<E> previous;//后驅   
            14.     Entry(E element, Entry<E> next, Entry<E> previous) {   
            15.         this.element = element;   
            16.         this.next = next;   
            17.         this.previous = previous;   
            18.     }   
            19. }     
             
          2. 兩者的父類不同,也就決定了兩者的存儲形式不同。 ArrayList繼承于 AbstractList,而LinkedList繼承于AbstractSequentialList. 兩者都實現了List的骨干結構,只是前者的訪問形式趨向于 “隨機訪問”數據存儲(如數組),后者趨向于 “連續訪問”數據存儲(如鏈接列表)

            Java代碼 復制代碼
            1. public class ArrayList<E> extends AbstractList<E>      
            2. ---------------------------------------------------------------------------------------   
            3. public class LinkedList<E> extends AbstractSequentialList<E>      
             
          3. 再有就是兩者的效率問題, ArrayList基于數組實現,所以毫無疑問可以直接用下標來索引,其索引數據快,插入元素設計到數組元素移動,或者數組擴充,所以插入元素要慢。LinkedList基于鏈表結構,插入元素只需要改變插入元素的前后項的指向即可,故插入數據要快,而索引元素需要向前向后遍歷,所以索引元素要慢。

          • ArrayList的特點,內部容器是如何擴充的?

          上一點談到了ArrayList的特點,這里略,重點來看其內部容器的擴充:
          Java代碼 復制代碼
          1. public void ensureCapacity(int minCapacity) {   
          2.         modCount++;   
          3.         int oldCapacity = elementData.length;   
          4.         if (minCapacity > oldCapacity) {   
          5.             Object oldData[] = elementData;   
          6.              //這里擴充的大小為原大小的大概 60%   
          7.             int newCapacity = (oldCapacity * 3) / 2 + 1;   
          8.             if (newCapacity < minCapacity)   
          9.                 newCapacity = minCapacity;   
          10.             //創建一個指定大小的新數組來覆蓋原數組   
          11.             elementData = Arrays.copyOf(elementData, newCapacity);   
          12.         }   
          13.     }     
           

          • Properties類的特點? 線程安全嗎? 
          Properties 繼承于Hashtable,,所以它是線程安全的. 其特點是: 它表示的是一個持久的屬性集,它可以保存在流中或者從流中加載,屬性列表的每一個鍵和它所對應的值都是一個“字符串” 其中,常用的方法是load()方法,從流中加載屬性:
          Java代碼 復制代碼
          1. <SPAN style="FONT-WEIGHT: normal">public synchronized void load(InputStream inStream) throws IOException {   
          2.         // 將輸入流轉換成LineReader   
          3.         load0(new LineReader(inStream));   
          4.     }   
          5.   
          6.     private void load0(LineReader lr) throws IOException {   
          7.         char[] convtBuf = new char[1024];   
          8.         int limit;   
          9.         int keyLen;   
          10.         int valueStart;   
          11.         char c;   
          12.         boolean hasSep;   
          13.         boolean precedingBackslash;   
          14.         // 一行一行處理   
          15.         while ((limit = lr.readLine()) >= 0) {   
          16.             c = 0;   
          17.             keyLen = 0;   
          18.             valueStart = limit;   
          19.             hasSep = false;   
          20.             precedingBackslash = false;   
          21.             // 下面用2個循環來處理key,value   
          22.             while (keyLen < limit) {   
          23.                 c = lr.lineBuf[keyLen];   
          24.                 // need check if escaped.   
          25.                 if ((c == '=' || c == ':') && !precedingBackslash) {   
          26.                     valueStart = keyLen + 1;   
          27.                     hasSep = true;   
          28.                     break;   
          29.                 } else if ((c == ' ' || c == '\t' || c == '\f')   
          30.                         && !precedingBackslash) {   
          31.                     valueStart = keyLen + 1;   
          32.                     break;   
          33.                 }   
          34.                 if (c == '\\') {   
          35.                     precedingBackslash = !precedingBackslash;   
          36.                 } else {   
          37.                     precedingBackslash = false;   
          38.                 }   
          39.                 keyLen++;   
          40.             }   
          41.   
          42.             while (valueStart < limit) {   
          43.                 c = lr.lineBuf[valueStart];   
          44.                 if (c != ' ' && c != '\t' && c != '\f') {   
          45.                     if (!hasSep && (c == '=' || c == ':')) {   
          46.                         hasSep = true;   
          47.                     } else {   
          48.                         break;   
          49.                     }   
          50.                 }   
          51.                 valueStart++;   
          52.             }   
          53.   
          54.             String key = loadConvert(lr.lineBuf, 0, keyLen, convtBuf);   
          55.             String value = loadConvert(lr.lineBuf, valueStart, limit   
          56.                     - valueStart, convtBuf);   
          57.             // 存入內部容器中,這里用的是Hashtable 內部的方法.   
          58.             put(key, value);   
          59.         }   
          60.     }</SPAN>  
           LineReader類,是Properties內部的類:
          Java代碼 復制代碼
          1. <SPAN style="FONT-WEIGHT: normal">class LineReader {   
          2.         public LineReader(InputStream inStream) {   
          3.             this.inStream = inStream;   
          4.             inByteBuf = new byte[8192];   
          5.         }   
          6.   
          7.         public LineReader(Reader reader) {   
          8.             this.reader = reader;   
          9.             inCharBuf = new char[8192];   
          10.         }   
          11.   
          12.         byte[] inByteBuf;   
          13.         char[] inCharBuf;   
          14.         char[] lineBuf = new char[1024];   
          15.         int inLimit = 0;   
          16.         int inOff = 0;   
          17.         InputStream inStream;   
          18.         Reader reader;   
          19.   
          20.         /**  
          21.          * 讀取一行  
          22.          *   
          23.          * @return  
          24.          * @throws IOException  
          25.          */  
          26.         int readLine() throws IOException {   
          27.             int len = 0;   
          28.             char c = 0;   
          29.             boolean skipWhiteSpace = true;// 空白   
          30.             boolean isCommentLine = false;// 注釋   
          31.             boolean isNewLine = true;// 是否新行.   
          32.             boolean appendedLineBegin = false;// 加 至行開始   
          33.             boolean precedingBackslash = false;// 反斜杠   
          34.             boolean skipLF = false;   
          35.             while (true) {   
          36.                 if (inOff >= inLimit) {   
          37.                     // 從輸入流中讀取一定數量的字節并將其存儲在緩沖區數組inCharBuf/inByteBuf中,這里區分字節流和字符流   
          38.                     inLimit = (inStream == null) ? reader.read(inCharBuf)   
          39.                             : inStream.read(inByteBuf);   
          40.                     inOff = 0;   
          41.                     // 讀取到的為空.   
          42.                     if (inLimit <= 0) {   
          43.                         if (len == 0 || isCommentLine) {   
          44.                             return -1;   
          45.                         }   
          46.                         return len;   
          47.                     }   
          48.                 }   
          49.                 if (inStream != null) {   
          50.                     // 由于是字節流,需要使用ISO8859-1來解碼   
          51.                     c = (char) (0xff & inByteBuf[inOff++]);   
          52.                 } else {   
          53.                     c = inCharBuf[inOff++];   
          54.                 }   
          55.   
          56.                 if (skipLF) {   
          57.                     skipLF = false;   
          58.                     if (c == '\n') {   
          59.                         continue;   
          60.                     }   
          61.                 }   
          62.                 if (skipWhiteSpace) {   
          63.                     if (c == ' ' || c == '\t' || c == '\f') {   
          64.                         continue;   
          65.                     }   
          66.                     if (!appendedLineBegin && (c == '\r' || c == '\n')) {   
          67.                         continue;   
          68.                     }   
          69.                     skipWhiteSpace = false;   
          70.                     appendedLineBegin = false;   
          71.                 }   
          72.                 if (isNewLine) {   
          73.                     isNewLine = false;   
          74.                     if (c == '#' || c == '!') {   
          75.                         // 注釋行,忽略.   
          76.                         isCommentLine = true;   
          77.                         continue;   
          78.                     }   
          79.                 }   
          80.                 // 讀取真正的屬性內容   
          81.                 if (c != '\n' && c != '\r') {   
          82.                     // 這里類似于ArrayList內部的容量擴充,使用字符數組來保存讀取的內容.   
          83.                     lineBuf[len++] = c;   
          84.                     if (len == lineBuf.length) {   
          85.                         int newLength = lineBuf.length * 2;   
          86.                         if (newLength < 0) {   
          87.                             newLength = Integer.MAX_VALUE;   
          88.                         }   
          89.                         char[] buf = new char[newLength];   
          90.                         System.arraycopy(lineBuf, 0, buf, 0, lineBuf.length);   
          91.                         lineBuf = buf;   
          92.                     }   
          93.                     if (c == '\\') {   
          94.                         precedingBackslash = !precedingBackslash;   
          95.                     } else {   
          96.                         precedingBackslash = false;   
          97.                     }   
          98.                 } else {   
          99.                     // reached EOL 文件結束   
          100.                     if (isCommentLine || len == 0) {   
          101.                         isCommentLine = false;   
          102.                         isNewLine = true;   
          103.                         skipWhiteSpace = true;   
          104.                         len = 0;   
          105.                         continue;   
          106.                     }   
          107.                     if (inOff >= inLimit) {   
          108.                         inLimit = (inStream == null) ? reader.read(inCharBuf)   
          109.                                 : inStream.read(inByteBuf);   
          110.                         inOff = 0;   
          111.                         if (inLimit <= 0) {   
          112.                             return len;   
          113.                         }   
          114.                     }   
          115.                     if (precedingBackslash) {   
          116.                         len -= 1;   
          117.                         skipWhiteSpace = true;   
          118.                         appendedLineBegin = true;   
          119.                         precedingBackslash = false;   
          120.                         if (c == '\r') {   
          121.                             skipLF = true;   
          122.                         }   
          123.                     } else {   
          124.                         return len;   
          125.                     }   
          126.                 }   
          127.             }   
          128.         }   
          129.     }   </SPAN>  
           這里特別的是,實際上,Properties從流中加載屬性集合,是通過將流中的字符或者字節分成一行行來處理的。

          • 請說一下Struts2的初始化?和類的創建?(從源代碼角度出發)
          (我當時回答這個問題的思路我想應該對了, 我說是通過反射加配置文件來做的)
          由于這個問題研究起來可以另外寫一篇專門的模塊,這里只列出相對簡單的流程,后續會希望有時間整理出具體的細節: 首先,Struts2是基于Xwork框架的,如果你有仔細看過Xwork的文檔,你會發現,它的初始化過程基于以下幾個類: Configuring XWork2 centers around the following classes:- 1. ConfigurationManager 2. ConfigurationProvider 3. Configuration 而在ConfigurationProvider的實現類XmlConfigurationProvider 的內部,你可以看到下面的代碼
          Java代碼 復制代碼
          1. <SPAN style="FONT-WEIGHT: normal"public XmlConfigurationProvider() {   
          2.         this("xwork.xml"true);   
          3. }</SPAN>  
           同樣的,Struts2的初始化也是這樣的一個類,只不過它繼承于Xwork原有的類,并針對Struts2做了一些特別的定制。
          Java代碼 復制代碼
          1. <SPAN style="FONT-WEIGHT: normal">public class StrutsXmlConfigurationProvider    
          2.    extends XmlConfigurationProvider {   
          3.     public StrutsXmlConfigurationProvider(boolean errorIfMissing)   
          4.     {   
          5.         this("struts.xml", errorIfMissing, null);   
          6.     }   
          7. ……  </SPAN>  
           如果你要查看這個類在哪里調用了,你會追蹤到Dispatch的類,
           記得嗎? 我們使用Struts2,第一步就是在Web.xml中配置一個過濾器 FilterDispatcher,
           沒錯,在web容器初始化過濾器的時候, 同時也會初始化Dispatch..

          FilterDispatch.init():
          Java代碼 復制代碼
          1. <SPAN style="FONT-WEIGHT: normal">public void init(FilterConfig filterConfig)    
          2. throws ServletException {   
          3.         try {   
          4.             this.filterConfig = filterConfig;   
          5.             initLogging();   
          6.             dispatcher = createDispatcher(filterConfig);   
          7.             dispatcher.init();////初始化Dispatcher.   
          8.             dispatcher.getContainer().inject(this);   
          9.             staticResourceLoader.setHostConfig(new FilterHostConfig(filterConfig));   
          10.         } finally {   
          11.             ActionContext.setContext(null);   
          12.         }   
          13.     }   </SPAN>  
           Dispatch.init():
          Java代碼 復制代碼
          1. <SPAN style="FONT-WEIGHT: normal">//這里是加載配置文件, 真正初始化Struts2的Action實例還沒開始,   
          2. public void init() {   
          3.         if (configurationManager == null) {   
          4.             configurationManager =    
          5. new ConfigurationManager(BeanSelectionProvider.DEFAULT_BEAN_NAME);   
          6.         }   
          7.         init_DefaultProperties(); // [1]   
          8.         init_TraditionalXmlConfigurations(); // [2]   
          9.         init_LegacyStrutsProperties(); // [3]   
          10.         init_CustomConfigurationProviders(); // [5]   
          11.         init_FilterInitParameters() ; // [6]   
          12.         init_AliasStandardObjects() ; // [7]   
          13.         Container container = init_PreloadConfiguration();   
          14.         container.inject(this);   
          15.         init_CheckConfigurationReloading(container);   
          16.         init_CheckWebLogicWorkaround(container);   
          17.         if (!dispatcherListeners.isEmpty()) {   
          18.             for (DispatcherListener l : dispatcherListeners) {   
          19.                 l.dispatcherInitialized(this);   
          20.             }   
          21.         }   
          22.     }   </SPAN>  
           到初始化Action類的時候, 你需要去FilterDispatcher的doFilter方法去看代碼, 你會發現:
          Java代碼 復制代碼
          1. <SPAN style="FONT-WEIGHT: normal">public void doFilter(ServletRequest req, ServletResponse res,   
          2.  FilterChain chain) throws IOException, ServletException {   
          3. ……            
          4. dispatcher.serviceAction(request, response, servletContext, mapping);</SPAN>  
           再追蹤到Dispatcher類,看到這個方法:
          Java代碼 復制代碼
          1. <SPAN style="FONT-WEIGHT: normal"public void serviceAction(HttpServletRequest request,   
          2.  HttpServletResponse response, ServletContext context,   
          3.   ActionMapping mapping) throws ServletException {   
          4.       ……   
          5.      ActionProxy proxy =config.getContainer().getInstance(   
          6.                                                       ActionProxyFactory.class).   
          7.                                                      createActionProxy(namespace,    
          8.                                                                                           name,    
          9.                                                                                         method,    
          10.                                                                                    extraContext,   
          11.                                                                                        truefalse);   
          12.   
          13.     ……</SPAN>  
           這行代碼已經明確的告訴你了, 它的作用就是創建ActionProxy,而我們想要知道的是,
          他是如何創建的;
          而上面代碼中的config,實際上是Xwork中的.Configuration, 如果你打開Xwork源代碼,你會發現,他其實是一個接口, 真正做處理的,這里是
          com.opensymphony.xwork2.config.impl.DefaultConfiguration類, 通過它的getContainer()方法,獲取到一個Container類型的實例,而Container也是一個接口, 其實現類是:

           

          com.opensymphony.xwork2.inject.ContainerImpl 他的getInstance(Class clazz):

          public <T> T getInstance(final Class<T> type) {

          Java代碼 復制代碼
          1. return callInContext(new ContextualCallable<T>() {   
          2.   public T call(InternalContext context) {   
          3.     return getInstance(type, context);   
          4.   }   
          5. });   

           返回的是你傳入的對象,而在這里就是:ActionProxyFactory(也是接口,真正返回的是com.opensymphony.xwork2.DefaultActionProxyFactory)


          而現在,到了真正開始處理加載Action實例的時候了:
          Java代碼 復制代碼
          1. public ActionProxy createActionProxy(ActionInvocation inv, String namespace, String actionName, String methodName,    
          2. boolean executeResult, boolean cleanupContext) {   
          3.         DefaultActionProxy proxy = new DefaultActionProxy(inv,   
          4.  namespace, actionName, methodName, executeResult, cleanupContext);   
          5.         container.inject(proxy);   
          6.         proxy.prepare();   
          7.         return proxy;   
          8.     }  

                 這里,我們主要關心的是: 
          Java代碼 復制代碼
          1. protected void prepare()  {   
          2.       ……   
          3.           invocation.init(this);   
          4. ……   
          5.     }  
           

           OK, 我們進去看看,這里發生了什么?

          這里也是面向接口編程,真實情況是,它調用了
          com.opensymphony.xwork2.DefaultActionInvocation的init(ActionProxy)方法
          Java代碼 復制代碼
          1. public void init(ActionProxy proxy) {   
          2.         ……   
          3.   
          4.         createAction(contextMap);   
          5.   
          6.         ……   
          7.     }  
           
          OK, 我們終于追蹤到我們所需要了解的地方了, 到底Struts2/Xwork的Action是如何創建的呢? 
          Java代碼 復制代碼
          1. protected void createAction(Map<String, Object> contextMap) {   
          2.         // load action   
          3.         String timerKey = "actionCreate: " + proxy.getActionName();   
          4.        ……   
          5. action =   
          6.  objectFactory.buildAction(proxy.getActionName(), proxy.getNamespace(), proxy.getConfig(), contextMap);   
          7.       ……  
           繼續跟進去看看,你會發現, 事情確實如此:
          Java代碼 復制代碼
          1. public Object buildAction(String actionName, String namespace, ActionConfig config, Map<String, Object> extraContext)    
          2. throws Exception {   
          3.         return buildBean(config.getClassName(), extraContext);   
          4.     }   
          5.                        
          6.        
          7. public Object buildBean(String className, Map<String, Object> extraContext, boolean injectInternal) throws Exception {   
          8.         Class clazz = getClassInstance(className);//根據Action的名字,進行初始化   
          9.         Object obj = buildBean(clazz, extraContext);   
          10. //利用反射來做實例初始化.   
          11.         if (injectInternal) {   
          12.             injectInternalBeans(obj);   
          13.         }   
          14.         return obj;   
          15.         }      
          16.  public Class getClassInstance(String className) throws ClassNotFoundException {   
          17.         if (ccl != null) {   
          18.             return ccl.loadClass(className);   
          19.         }   
          20.         return    
          21. ClassLoaderUtil.loadClass(className, this.getClass());   
          22. }      
          23. public Object buildBean(Class clazz, Map<String, Object> extraContext) throws Exception {   
          24.         return clazz.newInstance();   
          25.    }      
           OK, 整體來說,這個問題說清楚很難,因為你無法記住你追蹤到的所有的類,但是有一點是肯定的,那就是流程: 基本上我的理解就是 通過一系列配置文件的初始化,將文件轉換成對象,加載進內存中,再在處理請求時候(注意,只有當FilterDispatcher的doFilter第一次被調用時,才會去初始化Action類),加載Action類來進行業務處理。

           先整理這幾個問題…… 累呀!希望這幾天能把這些題目整理完, 整理過程中也順帶復習復習。
          posted on 2010-07-14 10:55 rogerfan 閱讀(892) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 宁都县| 铜陵市| 克山县| 兴国县| 临颍县| 图片| 屯昌县| 安图县| 巫山县| 武定县| 漠河县| 开平市| 盐亭县| 武宁县| 阳谷县| 南城县| 天台县| 柳林县| 米泉市| 达孜县| 晋江市| 四子王旗| 弥勒县| 尤溪县| 陕西省| 沂南县| 山东| 鹰潭市| 文山县| 乌兰浩特市| 镇赉县| 东明县| 墨竹工卡县| 肥西县| 岳阳市| 景宁| 扎赉特旗| 永泰县| 绵阳市| 岑溪市| 登封市|