|
¤Þ¤º¤Ïñ½ã¤Ê¤È¤³¤í¤«¤é¡£Ping¤ò¤¦¤Ä¥¯¥é¥¤¥¢¥ó¥ÈPingClient¤òºî¤ê¤Þ¤·¤¿¡£ ¤³¤Î¥¯¥é¥¹¤Ï¡¢¥Õ¥£¡¼¥ë¥É¤Ë¥»¥Ã¥È¤µ¤ì¤¿Ping¥µ¡¼¥Ð¤¿¤Á¤ËPing¤ò¤¦¤Á¤Þ¤¹¡£ PingClient#doPing¥á¥½¥Ã¥É¤Ç¡¢¥Ö¥í¥°Ì¾¤ä¥Ö¥í¥°¤ÎURL¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£ XML-RPC·Á¼°¤ÎPing¥ê¥¯¥¨¥¹¥È¤ÎÀ¸À®¤Ï¡¢XML-RPC¤Î¥Ú¡¼¥¸¤Ë¤¢¤ë¤È¤ª¤êApache XML-RPC¤òÍѤ¤¤Æ¤¤¤Þ¤¹¡£ /*******************************************************************************
* Copyright (c) 2005 Masatomi KINO.
* All rights reserved.
* $Id: PingClient.java,v 1.5 2006/02/20 16:51:48 cvsuser Exp $
*******************************************************************************/
//ºîÀ®Æü: 2005/10/29
package nu.mine.kino.servlets.ping;
/**
* Ping¥µ¡¼¥Ð¤ËweblogUpdates.ping¤òÂǤĥ¯¥é¥¤¥¢¥ó¥È¤Ç¤¹¡£
*
* @author Masatomi KINO
* @version $Revision: 1.5 $
* @spring.bean id = "pingClient"
*/
public class PingClient {
private static final Logger logger = Logger.getLogger(PingClient.class);
private List endpointURLList = new ArrayList();
/**
* {@link PingClient#addEndpoint(String)} ¤Ç»ØÄꤵ¤ì¤¿
* ¥¨¥ó¥É¥Ý¥¤¥ó¥È¤ÎPing¥µ¡¼¥Ð¤ËPing¤òÂǤÁ¤Þ¤¹¡£
*
* @param weblogname Blog¤Î̾Á°
* @param weblogurl Blog¤ÎURL
*/
public void doPing(String weblogname, String weblogurl) {
logger.info("doPing(String, String) - start");
Iterator iterator = endpointURLList.iterator();
while (iterator.hasNext()) {
String destination = (String) iterator.next();
logger.info(destination + " : ¤ËPing¤òÂǤÁ¤Þ¤¹¡£");
logger.info("Weblog Name: " + weblogname);
logger.info("URL: " + weblogurl);
doPing(weblogname, weblogurl, destination); <-¸å½Ò
}
logger.info("doPing(String, String) - end");
}
/**
* @param endpointURLList
* @spring.property list = "http://ping.cocolog-nifty.com/xmlrpc"
*/
public void setEndpointURLList(List endpointURLList) {
this.endpointURLList = endpointURLList;
}
}
¼ÂºÝ¤ËApache XML-RPC¤ò»È¤Ã¤¿Ping¤Î½èÍý¤Ï°Ê²¼¤ÎÄ̤ê¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£ private void doPing(String weblogname, String weblogurl, String destination) {
logger.debug("doPing(String, String) - start");
// weblogUpdates.ping ¤ËÅϤ¹¥Ñ¥é¥á¥¿¤ò½çÈÖÄ̤êVector¤ËÆþ¤ì¤ë
Vector parameterList = new Vector();
parameterList.addElement(weblogname);
parameterList.addElement(weblogurl);
try {
XmlRpcClient client = null;
XmlRpc.setEncoding("UTF-8");
client = new XmlRpcClient(destination);
// ¤µ¤Ã¤¤Î¥¨¥ó¥É¥Ý¥¤¥ó¥È¤Î¡¢weblogUpdates.ping ¤È
// ¤¤¤¦¥á¥½¥Ã¥É¤ò¥³¡¼¥ë¤¹¤ë¡£¥Ñ¥é¥á¥¿¤ÏVector¤Ë³ÊǼ¡£
Hashtable response = (Hashtable) client.execute(
"weblogUpdates.ping", parameterList);
if (response != null) {
Enumeration e = response.keys();
while (e.hasMoreElements()) {
Object key = e.nextElement();
logger
.debug("KEY=" + key + " : VALUE="
+ response.get(key));
}
}
} catch (MalformedURLException e1) {
logger.error("doPing(String, String)", e1);
} catch (XmlRpcException e) {
logger.error("doPing(String, String)", e);
} catch (IOException e) {
logger.error("doPing(String, String)", e);
}
logger.debug("doPing(String, String) - end");
}
°Ê¾å¤ÇPing¤ò¤¦¤Ä¥¯¥é¥¤¥¢¥ó¥È¤Ï´°À®¤Ç¤¹¡£¤³¤ì¤Ç»î¤·¤ËPing¤ò¤¦¤Ã¤Æ¤ß¤¿¤È¤³¤í°Ê²¼¤Î¥ê¥¯¥¨¥¹¥È¤¬Post¤µ¤ì¤Þ¤·¤¿¡£ <?xml version="1.0"?>
<methodCall>
<methodName>weblogUpdates.ping</methodName>
<params>
<param><value>[weblogname]</value></param>
<param><value>[weblogurl]</value></param>
</params>
</methodCall>
¤³¤Îµ»ö¤Ï ¸½ºß¤Î¥¢¥¯¥»¥¹:3731 |