Tal vez una de las fusiones más raras que he visto de una comunidad social con un framework sobre transacciones bancarias, esta clase la encontre en el grupo de jPOS y la verdad como Twittero, me dejo algo alucinado.
Actualización 18/06/09
La única utilidad que le veo es que los log del SysLog del Q2Server aparecen como nuevos mensajes en tu cuenta de Twitter , ha sido probado y funciona.
/* * jPOS Project [http://jpos.org] * Copyright (C) 2000-2008 Alejandro P. Revilla * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.jpos.util; import java.util.Date; import java.util.Locale; import java.util.Iterator; import java.io.IOException; import java.text.SimpleDateFormat; import org.jpos.core.Configurable; import org.jpos.core.Configuration; import org.jpos.core.ConfigurationException; import org.jpos.q2.Q2; import winterwell.jtwitter.*; /** * Twitter Listener * * requires jtwitter.jar from http://www.winterwell.com/software/jtwitter.php * * Sample configuration: * * <log-listener class="org.jpos.util.TwitterLogListener"> * <property name="twitterUsername" value="paymentsystems" /> * <property name="twitterPassword" value="SuperSecretPassword" /> * <property name="tags" value="twitter" /> * <property name="prefix" value="[jPOS]"/> * </log-listener> * */ public class TwitterLogListener implements LogListener, Configurable { private Configuration cfg; private String twitterUsername; private String twitterPassword; private String prefix; private String tags; private String twitterMessage; private int MAX_MESSAGE_SIZE = 140; public TwitterLogListener () { super(); } public synchronized LogEvent log (LogEvent ev) { if (ev.tag != null && tags.indexOf(ev.tag) != -1) { Twitter twitter = new Twitter(twitterUsername,twitterPassword); StringBuilder sb = new StringBuilder(); if (prefix != null) { sb.append (prefix); sb.append (' '); } Iterator iter = ev.payLoad.iterator(); for (int i=0; iter.hasNext(); i++) { if (i>0) sb.append (' '); sb.append (iter.next().toString()); } if (sb.toString().length()>MAX_MESSAGE_SIZE) { twitterMessage = sb.toString().substring(0,MAX_MESSAGE_SIZE); } else { twitterMessage = sb.toString(); } try { twitter.updateStatus(twitterMessage); } catch (TwitterException e) { ev.addMessage ("--- TwitterLogListener error ---"); ev.addMessage (e); } } return ev; } public void setConfiguration (Configuration cfg) throws ConfigurationException { this.cfg = cfg; try { twitterUsername = cfg.get ("twitterUsername"); twitterPassword = cfg.get ("twitterPassword"); tags = cfg.get ("tags", "twitter"); prefix = cfg.get ("prefix", null); } catch (Exception e) { throw new ConfigurationException (e); } } }


