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

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

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

    少年阿賓

    那些青春的歲月

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks

    #

    /**
     *
     */
    package com.abin.lee.cxf;

    import javax.jws.WebService;

    /**
     * @author abin
     *
     */
    @WebService(targetNamespace="cxf.lee.abin.com")
    public interface IUserService {
     public String getMessage(String message);
    }





    package com.abin.lee.cxf;

    import javax.jws.WebService;

    @WebService(endpointInterface="com.abin.lee.cxf.IUserService")
    public class UserService implements IUserService{

     public String getMessage(String message) {
      return message+" welcome to beijing";
     }
     
    }






    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=" xmlns:xsi=" xmlns:tx=" xmlns:jaxws=" xmlns:cxf=" xmlns:wsa=" xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/tx
     http://www.springframework.org/schema/tx/spring-beans-3.0.xsd
     http://cxf.apache.org/core
     http://cxf.apache.org/schemas/core.xsd
     http://cxf.apache.org/jaxws
     http://cxf.apache.org/schemas/jaxws.xsd
     http://www.springframework.org/schema/aop
     http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
     http://www.springframework.org/schema/context
      <import resource="classpath:META-INF/cxf/cxf.xml" />
     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
     <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
     
     <cxf:bus>
      <cxf:features>
       <!--日志攔截功能,用于監控soap內容,開發后可以刪除 -->
       <cxf:logging/>
       <wsa:addressing/>
      </cxf:features>
     </cxf:bus> 

     <bean id="userService" class="com.abin.lee.cxf.UserService"></bean>
     <jaxws:endpoint id="userWebservice" implementor="#userService" address="/UserService" publish="true" />


    </beans>

     





    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
       <!--
         classpath*:com/abin/lee/spring/queue/applicationContext-springqueue.xml,
         classpath*:com/abin/lee/quartz/applicationContext-quartzCluster.xml,
         classpath*:com/abin/lee/quartz/applicationContext-quartzHeartCluster.xml,
         classpath*:com/abin/lee/quartz/applicationContext-activemq.xml
       -->
       classpath*:com/abin/lee/cxf/applicationContext-cxf.xml
      </param-value>
     </context-param>
     <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
     <!--cxf服務啟動servlet-->
     <servlet>   
      <servlet-name>CXFServlet</servlet-name>   
      <servlet-class>   
                org.apache.cxf.transport.servlet.CXFServlet    
      </servlet-class>   
      <load-on-startup>1</load-on-startup>   
     </servlet>   
     <servlet-mapping>   
      <servlet-name>CXFServlet</servlet-name>   
      <url-pattern>/service/*</url-pattern>   
     </servlet-mapping> 






    package com.abin.lee.spring;

    import org.springframework.beans.BeansException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.ApplicationContextAware;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    /**
     *
     * 獲取spring容器,以訪問容器中定義的其他bean
     *
     * @author lyltiger
     * @since MOSTsView 3.0 2009-11-16
     */
    public class SpringContextUtil implements ApplicationContextAware {

     // Spring應用上下文環境
     private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
       "com/abin/lee/cxf/applicationContext-cxf.xml");

     /**
      * 實現ApplicationContextAware接口的回調方法,設置上下文環境
      *
      * @param applicationContext
      */
     public void setApplicationContext(ApplicationContext applicationContext) {
      SpringContextUtil.applicationContext = applicationContext;
     }

     /**
      * @return ApplicationContext
      */
     public static ApplicationContext getApplicationContext() {
      return applicationContext;
     }

     /**
      * 獲取對象 這里重寫了bean方法,起主要作用
      *
      * @param name
      * @return Object 一個以所給名字注冊的bean的實例
      * @throws BeansException
      */
     public static Object getBean(String name) throws BeansException {
      return applicationContext.getBean(name);
     }

    }









    package com.abin.lee.cxf.test;

    import com.abin.lee.cxf.UserService;
    import com.abin.lee.spring.SpringContextUtil;

    import junit.framework.TestCase;

    public class TestUserService extends TestCase{
     public void testcxf(){
      UserService userService=(UserService)SpringContextUtil.getBean("userService");
      
      String response=userService.getMessage("abin");
      System.out.println("response="+response);
      System.exit(0);
     }
    }



         摘要: 1.實例化spring容器 和 從容器獲取Bean對象 實例化Spring容器常用的兩種方式: 方法一: 在類路徑下尋找配置文件來實例化容器 [推薦使用] ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"beans.xml"}); 方法二: 在文件系統路徑下尋找配置文件來實例化容器 [這...  閱讀全文
    posted @ 2012-08-20 12:34 abin 閱讀(24197) | 評論 (2)編輯 收藏

    package com.abin.lee.queue;

    import java.util.Queue;

    public interface IMakeQueue {
     public void addQueue(Object obj);
     public boolean hasQueue();
     public Object getQueueHeader();
     public int queueSize();
     public boolean delQueue();
    }




    package com.abin.lee.queue;

    import java.util.Queue;
    import java.util.concurrent.LinkedBlockingQueue;

    public class MakeQueue implements IMakeQueue{
     private static Queue queue=new LinkedBlockingQueue();

     public void addQueue(Object obj) {
      queue.offer(obj);
     }

     public boolean hasQueue() {
      boolean flag=false;
      if(queue.isEmpty()){
       flag=true;
      }
      return flag;
     }

     public Object getQueueHeader() {
      Object obj=queue.peek();
      return obj;
     }

     public int queueSize() {
      int queueSize=queue.size();
      return queueSize;
     }

     public boolean delQueue() {
      boolean flag=false;
      Object obj=queue.poll();
      if(obj!=null){
       flag=true;
      }
      return flag;
     }
     
    }






    package com.abin.lee.queue;

    import org.springframework.beans.BeansException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.ApplicationContextAware;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    /**
     *
     * 獲取spring容器,以訪問容器中定義的其他bean
     *
     * @author lyltiger
     * @since MOSTsView 3.0 2009-11-16
     */
    public class SpringContextUtil implements ApplicationContextAware {

     // Spring應用上下文環境
     private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
       "com/abin/lee/spring/applicationContext-queue.xml");

     /**
      * 實現ApplicationContextAware接口的回調方法,設置上下文環境
      *
      * @param applicationContext
      */
     public void setApplicationContext(ApplicationContext applicationContext) {
      SpringContextUtil.applicationContext = applicationContext;
     }

     /**
      * @return ApplicationContext
      */
     public static ApplicationContext getApplicationContext() {
      return applicationContext;
     }

     /**
      * 獲取對象 這里重寫了bean方法,起主要作用
      *
      * @param name
      * @return Object 一個以所給名字注冊的bean的實例
      * @throws BeansException
      */
     public static Object getBean(String name) throws BeansException {
      return applicationContext.getBean(name);
     }

    }





    package com.abin.lee.queue;

    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    import java.util.Map;

    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    public class QueueServlet extends HttpServlet{
     
     protected void doPost(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
      Map map=request.getParameterMap();
      String name1=(String)((Object[])map.get("name1"))[0];
      String name2=(String)((Object[])map.get("name2"))[0];
      MakeQueue makeQueue = (MakeQueue)SpringContextUtil.getBean("makeQueue");//bean的名稱
      System.out.println(makeQueue.queueSize());
      makeQueue.addQueue(name1);
      makeQueue.addQueue(name2);
      System.out.println(makeQueue.queueSize());
      
      ServletOutputStream out=response.getOutputStream();
      BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(out));
      writer.write("success");
      writer.flush();
      writer.close();
     }
    }





    package com.abin.lee.spring;

    import java.util.ArrayList;
    import java.util.List;

    import junit.framework.TestCase;

    import org.apache.http.HttpEntity;
    import org.apache.http.HttpResponse;
    import org.apache.http.NameValuePair;
    import org.apache.http.client.HttpClient;
    import org.apache.http.client.entity.UrlEncodedFormEntity;
    import org.apache.http.client.methods.HttpPost;
    import org.apache.http.impl.client.DefaultHttpClient;
    import org.apache.http.message.BasicNameValuePair;
    import org.apache.http.protocol.HTTP;
    import org.apache.http.util.EntityUtils;

    public class SpringUnit extends TestCase {
     private static final String HTTP_URL="http://localhost:1010/WebService/servlet/QueueServlet";
     public void testBean() {
      HttpClient client=new DefaultHttpClient();
      HttpPost post=new HttpPost(HTTP_URL);
      try {
       List<NameValuePair> nvps=new ArrayList<NameValuePair>();
       nvps.add(new BasicNameValuePair("name1", "lee"));
       nvps.add(new BasicNameValuePair("name2", "abin"));
       post.setEntity(new UrlEncodedFormEntity(nvps,HTTP.UTF_8));
       HttpResponse response=client.execute(post);
       HttpEntity entity=response.getEntity();
       String result=EntityUtils.toString(entity);
       System.out.println("result="+result);
      } catch (Exception e) {
       e.printStackTrace();
      }
     }
    }







    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=" xmlns:xsi=" xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               http://www.springframework.org/schema/aop
               http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
               http://www.springframework.org/schema/context
              

     <!-- Queue全局隊列 -->
     <bean id="makeQueue" class="com.abin.lee.queue.MakeQueue" scope="singleton" />
     

    </beans>


    方法一:
    package com.abin.lee.queue;

    import org.springframework.beans.BeansException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.ApplicationContextAware;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    /**
     *
     * 獲取spring容器,以訪問容器中定義的其他bean
     *
     * @author lyltiger
     * @since MOSTsView 3.0 2009-11-16
     */
    public class SpringContextUtil implements ApplicationContextAware {

     // Spring應用上下文環境
     private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
       "com/abin/lee/spring/applicationContext-queue.xml");

     /**
      * 實現ApplicationContextAware接口的回調方法,設置上下文環境
      *
      * @param applicationContext
      */
     public void setApplicationContext(ApplicationContext applicationContext) {
      SpringContextUtil.applicationContext = applicationContext;
     }

     /**
      * @return ApplicationContext
      */
     public static ApplicationContext getApplicationContext() {
      return applicationContext;
     }

     /**
      * 獲取對象 這里重寫了bean方法,起主要作用
      *
      * @param name
      * @return Object 一個以所給名字注冊的bean的實例
      * @throws BeansException
      */
     public static Object getBean(String name) throws BeansException {
      return applicationContext.getBean(name);
     }

    }





    方法二:

    package com.abin.lee.queue;

    import org.springframework.beans.factory.BeanFactory;
    import org.springframework.beans.factory.xml.XmlBeanFactory;
    import org.springframework.core.io.ClassPathResource;

    public class BeanFactoryUtil {
     private static BeanFactory factory = new XmlBeanFactory(
       new ClassPathResource(
         "com/abin/lee/spring/applicationContext-queue.xml"));

     public static BeanFactory getFactory() {
      return factory;
     }

     public static void setFactory(BeanFactory factory) {
      BeanFactoryUtil.factory = factory;
     }
     
     public static Object getBean(String name){
      return factory.getBean(name);
     }
    }







    具體用法:

    package com.abin.lee.queue;

    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    import java.util.Map;

    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    public class QueueServlet extends HttpServlet{
     
     protected void doPost(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
      Map map=request.getParameterMap();
      String name1=(String)((Object[])map.get("name1"))[0];
      String name2=(String)((Object[])map.get("name2"))[0];
      MakeQueue makeQueue = (MakeQueue)BeanFactoryUtil.getBean("makeQueue");//bean的名稱
      System.out.println(makeQueue.queueSize());
      makeQueue.addQueue(name1);
      makeQueue.addQueue(name2);
      System.out.println(makeQueue.queueSize());
      
      ServletOutputStream out=response.getOutputStream();
      BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(out));
      writer.write("success");
      writer.flush();
      writer.close();
     }
    }



    posted @ 2012-08-20 11:34 abin 閱讀(2159) | 評論 (0)編輯 收藏

    package com.abin.lee.sort;

    import java.util.Collections;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;

    public class CollectionIterator {
     /**
      * 創建二維MAP
      *
      * @return
      */
     public static Map<String, Map<String, String>> createMap() {
      Map<String, Map<String, String>> map2 = Collections
        .synchronizedMap(new HashMap<String, Map<String, String>>());
      Map<String, String> map1 = Collections
        .synchronizedMap(new HashMap<String, String>());
      Map<String, String> map3 = Collections
        .synchronizedMap(new HashMap<String, String>());
      map1.put("abin", "varyall");
      map1.put("abing", "boy");
      map1.put("peng", "boy");
      map1.put("pengzi", "man");
      map2.put("user", map1);

      map3.put("chinese", "beijing");
      map3.put("china", "shanghai");
      map2.put("contury", map3);

      return map2;
     }
     /**
      * 解析二維MAP
      * @param map
      * @return
      */
     
     public static String getMap(Map<String, Map<String, String>> map) {
      for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
       Map.Entry entry=(Map.Entry)iterator.next();
       //先遍歷一維map
       System.out.println("one map name="+entry.getKey());
       System.out.println("one map name="+entry.getValue());
       Map<String, String> map1=(Map<String, String>)entry.getValue();
       if(entry.getValue() instanceof Map){
        for(Iterator it=map1.entrySet().iterator();it.hasNext();){
         Map.Entry entry2=(Map.Entry)it.next();
         //再遍歷二維map
         System.out.println("two map name="+entry2.getKey());
         System.out.println("two map name="+entry2.getValue());
        }
       }
      }

      return null;
     }
     public static void main(String[] args) {
      Map<String, Map<String, String>> map=createMap();
      getMap(map);
      
     }
    }

    posted @ 2012-08-18 15:51 abin 閱讀(4194) | 評論 (1)編輯 收藏

    Spring+Quartz的集群配置

     

    http://blog.sina.com.cn/s/blog_4b0210750100z6jb.html#SinaEditor_Temp_FontName
    posted @ 2012-08-17 18:01 abin 閱讀(490) | 評論 (0)編輯 收藏

    官網:http://quartz-scheduler.org/

    學習文檔:http://quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/

    例子:http://quartz-scheduler.org/documentation/quartz-2.1.x/examples/ 

    spring集成官網:http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/scheduling.html#scheduling-quartz



    http://blog.csdn.net/lan861698789/article/details/7620104
    posted @ 2012-08-17 11:14 abin 閱讀(1299) | 評論 (0)編輯 收藏

         摘要: HttpsURLConnection 擴展 HttpURLConnection,支持各種特定于 https 功能。此類使用 HostnameVerifier 和 SSLSocketFactory。為這兩個類都定義了默認實現。但是,可以根據每個類(靜態的)或每個實例來替換該實現。所有新 HttpsURLConnection 實例在創建時將被分配“默認的”靜態值,通過在連接前調...  閱讀全文
    posted @ 2012-08-16 09:48 abin 閱讀(6376) | 評論 (0)編輯 收藏

    package org.lee.abin.dom4j;


    import org.dom4j.Document;
    import org.dom4j.DocumentHelper;
    import org.dom4j.Element;

    public class Dom4jCreate {
     public static String CreateXml(){
      Document document=DocumentHelper.createDocument();
      document.setXMLEncoding("UTF-8");
      Element rootElement=document.addElement("abin").addAttribute("version", "1.01");
      Element first=rootElement.addElement("header").addAttribute("type", "input");
      Element second=first.addElement("one").addText("中國");
      
      return document.asXML();
     }
     public static void main(String[] args) {
      Dom4jCreate dom4jC=new Dom4jCreate();
      String result=dom4jC.CreateXml();
      System.out.println("result="+result);
     }

    }

    posted @ 2012-08-16 01:02 abin 閱讀(687) | 評論 (1)編輯 收藏

    Java HTTPS Client FAQ: Can you share some source code for a Java HTTPS client application?

    Sure, here's the source code for an example Java HTTPS client program I just used to download the contents of an HTTPS (SSL) URL. I actually found some of this in a newsgroup a while ago, but I can't find the source today to give them credit, so my apologies for that.

    I just used this program to troubleshoot a problem with Java and HTTPS URLs, including all that nice Java SSL keystore and cacerts stuff you may run into when working with Java, HTTPS/SSL, and hitting a URL.

    This Java program should work if you are hitting an HTTPS URL that has a valid SSL certificate from someone like Verisign or Thawte, but will not work with other SSL certificates unless you go down the Java keystore road.

    Example Java HTTPS client program

    Here's the source code for my simple Java HTTPS client program:




    package foo;

    import java.net.URL;
    import java.io.*;
    import javax.net.ssl.HttpsURLConnection;

    public class JavaHttpsExample
    {
      public static void main(String[] args)
      throws Exception
      {
        String httpsURL = "https://your.https.url.here/";
        URL myurl = new URL(httpsURL);
        HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
        InputStream ins = con.getInputStream();
        InputStreamReader isr = new InputStreamReader(ins);
        BufferedReader in = new BufferedReader(isr);

        String inputLine;

        while ((inputLine = in.readLine()) != null)
        {
          System.out.println(inputLine);
        }

        in.close();
      }
    }






    Just change the URL shown there to the HTTPS URL you want to access, and hopefully everything will work well for you. (If not, there's always that Comment section down below, lol.)




    http://www.devdaily.com/blog/post/java/simple-https-example
    posted @ 2012-08-16 00:41 abin 閱讀(759) | 評論 (0)編輯 收藏

    僅列出標題
    共50頁: First 上一頁 32 33 34 35 36 37 38 39 40 下一頁 Last 
    主站蜘蛛池模板: 亚洲精品自产拍在线观看动漫| 免费国产成人午夜在线观看| 99久久99久久免费精品小说| 波多野结衣久久高清免费| 亚洲男人的天堂在线播放| 一级特黄录像免费播放中文版| 天天操夜夜操免费视频| 亚洲三级电影网址| xxxx日本在线播放免费不卡| 成年网站免费视频A在线双飞| 亚洲AV无一区二区三区久久| 亚美影视免费在线观看 | 免费的全黄一级录像带| 亚洲精品国产日韩无码AV永久免费网| 亚洲成在人线aⅴ免费毛片| 成人免费无码大片A毛片抽搐色欲| 久久综合亚洲色一区二区三区| a级毛片免费在线观看| 中文字幕精品亚洲无线码一区应用| 理论片在线观看免费| 亚洲第一成年免费网站| 亚洲成人一级电影| 免费成人福利视频| 亚洲综合激情另类小说区| 中文字幕的电影免费网站| 亚洲国产成人久久一区WWW| 看一级毛片免费观看视频| 四虎永久在线精品免费观看视频| 亚洲国产精品久久久久| 无码精品人妻一区二区三区免费| 精品久久久久久久免费加勒比| 亚洲视频精品在线观看| 91精品啪在线观看国产线免费| 亚洲第一页在线视频| 国产91在线免费| 最近最好最新2019中文字幕免费| 亚洲综合欧美色五月俺也去| 精品国产亚洲男女在线线电影 | 亚洲av专区无码观看精品天堂| 免费国产美女爽到喷出水来视频| 三级网站免费观看|