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

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

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

    少年阿賓

    那些青春的歲月

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      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>
       <!--日志攔截功能,用于監(jiān)控soap內(nèi)容,開發(fā)后可以刪除 -->
       <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服務(wù)啟動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應(yīng)用上下文環(huán)境
     private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
       "com/abin/lee/cxf/applicationContext-cxf.xml");

     /**
      * 實現(xiàn)ApplicationContextAware接口的回調(diào)方法,設(shè)置上下文環(huán)境
      *
      * @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"}); 方法二: 在文件系統(tǒng)路徑下尋找配置文件來實例化容器 [這...  閱讀全文
    posted @ 2012-08-20 12:34 abin 閱讀(24206) | 評論 (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應(yīng)用上下文環(huán)境
     private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
       "com/abin/lee/spring/applicationContext-queue.xml");

     /**
      * 實現(xiàn)ApplicationContextAware接口的回調(diào)方法,設(shè)置上下文環(huán)境
      *
      * @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應(yīng)用上下文環(huán)境
     private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
       "com/abin/lee/spring/applicationContext-queue.xml");

     /**
      * 實現(xiàn)ApplicationContextAware接口的回調(diào)方法,設(shè)置上下文環(huán)境
      *
      * @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 閱讀(2166) | 評論 (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 {
     /**
      * 創(chuàng)建二維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 閱讀(4202) | 評論 (1)編輯 收藏

    Spring+Quartz的集群配置

     

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

    官網(wǎng):http://quartz-scheduler.org/

    學(xué)習(xí)文檔:http://quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/

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

    spring集成官網(wǎng):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 閱讀(1305) | 評論 (0)編輯 收藏

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

    僅列出標(biāo)題
    共50頁: First 上一頁 32 33 34 35 36 37 38 39 40 下一頁 Last 
    主站蜘蛛池模板: 亚洲国产人成网站在线电影动漫| 最新中文字幕电影免费观看| 黄桃AV无码免费一区二区三区 | 一二三四免费观看在线视频中文版 | 久久亚洲中文字幕精品有坂深雪| 亚洲AV无码专区亚洲AV伊甸园| 一区视频免费观看| 91亚洲va在线天线va天堂va国产 | 色播在线永久免费视频网站| 一级视频在线免费观看| 九九九精品视频免费| 亚洲免费无码在线| 亚洲国产综合AV在线观看| 亚洲欧美日韩中文二区| 日韩色视频一区二区三区亚洲| 亚洲情a成黄在线观看动漫尤物| 亚洲av日韩av无码黑人| 亚洲综合免费视频| 亚洲一区二区三区自拍公司| 色婷婷7777免费视频在线观看| 国产亚洲人成在线影院| 污污免费在线观看| 亚洲人成网站色7799| 日本亚洲欧美色视频在线播放 | 亚洲人成网站在线观看播放动漫 | 亚洲AV无码久久久久网站蜜桃 | 精品国产亚洲一区二区三区在线观看| 亚洲国产精品无码中文lv| 色屁屁www影院免费观看视频| 国产精品免费久久| 1000部羞羞禁止免费观看视频| 福利免费在线观看| 8x8x华人永久免费视频| 丁香花在线视频观看免费| 成人免费网站视频www| 一个人免费视频观看在线www| 国产免费不卡视频| 四虎在线播放免费永久视频| 亚洲熟女一区二区三区| 91嫩草亚洲精品| 黄色毛片免费网站|