Apr 19, 2007
http://www.anothr.comAnothr(哪吒)是基于Skype/Gtalk/MSN的自动订阅投递服务。
用户只需添加Anothr机器人为好友,在机器人对话窗口输入要订阅的博客、新闻、娱乐等网站的RSS地址,就可在Skype/Gtalk/MSN 上第一时间收到最新的网站信息。
偶自己也写了个demo
实现效果:自动定时读取指定rss,判断如果有新的新闻,发送到指定im(gtalk, msn等)上。
有兴趣加gtalk: oneboy.org [at] gmail.com 试试。
每15分钟读取cnbeta上的新闻一次,如果有新的新闻,就会发送到你的gtalk上去。 :)
robot放在自己机器上,如果没反映,可能是没有开机。
借助java丰富的第三方资源,简单的实现了个demo。
用quartz做定时任务,定时N分中读取一次rss。
用roma做rss解析。
用dom4j处理相关配置信息,rss列表、用户(未完成), 最后读取的记录。
用HTMLParser剔除rss中的html代码(未完成)。
用smack向gtalk发送消息。
dreamhost似乎支持java,不知道把这robot放上面会不会有什么限制,有时间试试。
最近公司有任务要做了,估计一段时间不会更新日志了,自己做成demo玩玩还是没有问题。
Apr 19, 2007
joram是
objectweb.org的java开源JMS消息中间件产品,支持JMS1.1,自带的文档和例子比较完整。中文文档比较详细的是
<>这篇,文中介绍了JMS的基本概念及joram的使用方法。
下面记录我在使用过程中遇到的一些问题。
连接远程服务器,在joram中文文档中,使用如下方法连接远程服务器
- Properties pr = new Properties();
-
- pr.put("82.0.176.214","16400");
- Context ictx = new InitialContext(pr);
-
-
- Hashtable prop = new Hashtable();
- prop.put(Context.INITIAL_CONTEXT_FACTORY,"fr.dyade.aaa.jndi2.client.NamingContextFactory");
- prop.put("java.naming.factory.host", host);
- prop.put("java.naming.factory.port", port);
- Context jndiCtx = new InitialContext(prop);
以编程方式启动joram服务器,而不使用命令行方式启动
- AgentServer.main(new String[] { "0", "./s0" });
注意:这种方式启动joram服务器,a3servers.xml文件的目录必须在classpath中。
注注意:假如你的a3servers.xml文件不在classpath中,他会读自己jar包中的a3servers.xml,自带的xml文件中没有配置jndi服务器,如果你碰到在程序中启动服务器,却连接不上jndi,看下是不是这个问题。
我就犯了个错误,将a3servers.xml的文件路径放classpath中去了,而不是这个文件的目录路径,joram找不到我的配置文件,就去读自带的配置文件。造成连接不上jndi,最后还是同事帮偶解决的。
Jan 16, 2007
- 使用ant启动和关闭tomcat,在build.xml中加入下面代码片段
使用这种方法要先设置好环境变量CATALINA_HOME=tomcat的安装路径
如果有时你不想重启整个应用,而只操作tomcat下某一个项目
- <property name="tomcat.home" value="you tomcat home directory here."></property>
-
- <TARGET name="start-tomcat" depends="stop-tomcat">
- <ECHO message="Start Tomcat" />
- <JAVA dir=/bin/ fork="true" jar="/bin/bootstrap.jar">
- <ARG value="start" />
- </JAVA>
- </TARGET>
-
- <TARGET name="stop-tomcat">
- <ECHO message="Stop Tomcat" />
- <JAVA dir=/bin/ fork="true" jar="/bin/bootstrap.jar">
- <ARG value="stop" />
- </JAVA>
- </TARGET>
- 使用ant操作tomcat启动/停止/重新装载(等等)某一项目
(1) 将%TOMCAT_HOME%\server\lib\catalina-ant.jar文件复制到类路径下
(2) 新建tomcatTasks.properties文件
#这些值就是catalina-ant.jar中的类文件,用来扩展ant的功能
start=org.apache.catalina.ant.StartTask
reload=org.apache.catalina.ant.ReloadTask
stop=org.apache.catalina.ant.StopTask
(3) 在build.xml中加入下面代码片段
- <TASKDEF file="tomcatTasks.properties">
- <CLASSPATH>
- <PATHELEMENT path="/server/lib/catalina-ant.jar" />
- </CLASSPATH>
- </TASKDEF>
-
- <TARGET name="启动当前项目">
- <START path="/projectName" password="adminpasswd" username="admin" url="http://localhost:8080/manager" />
- </TARGET>
-
- <TARGET name="重新装载当前项目">
- <RELOAD path="/projectName" password="adminpasswd" username="admin" url="http://localhost:8080/manager" />
- </TARGET>
-
- <TARGET name="停止当前项目">
- <STOP path="/projectName" password="adminpasswd" username="admin" url="http://localhost:8080/manager" />
- </TARGET>
# url就是在默认首页的Tomcat Manager进去的那功能页面
# username/password就是在conf/tomcat-user.xml中配置的用户名密码,注意这个用户要有manager权限
# /projectName就是你是管理的项目的名称
配置好后,就可以使用通过ant脚本来启动,重新装载,停止某一项目了。
Jan 15, 2007
转换tif文件为图像文件可以使用JAI,jimi等包来处理
jimi处理一份39页的tif文件生成png并缩小,使用14秒。
JAI处理同一份文件却用了近60秒。(因该是偶技术问题造成的):-)
jimi处理的主要源码:
- JimiCanvas jCanvas = new JimiCanvas();
- jCanvas.setImagePath(filepath);
-
- Image image = jCanvas.getImage();
-
-
- process(image);
-
- while (jCanvas.hasNextImage()) {
- jCanvas.nextImage();
- image = jCanvas.getImage();
- process(image);
- }
-
- public static void process(Image image) {
- double width = (double) image.getWidth(null);
- double height = (double) image.getHeight(null);
-
- int iWidth = (int) (width * 0.5);
- int iHeight = (int) (height * 0.5);
-
- BufferedImage bi = new BufferedImage(iWidth, iHeight, BufferedImage.TYPE_INT_RGB);
- bi.getGraphics().drawImage(image, 0, 0, iWidth, iHeight, null);
-
- }
Aug 12, 2006
JIRA是 Atlassian 公司开发的一款商业问题跟踪工具(开源项目经过申请可以免费使用,须提交源代码),可以对各种类型的问题进行跟踪管理,包括缺陷、需求变更、评审记录等。
安装及破解过程(MYSQL):
- 下载atlassian-jira-enterprise-3.6.3-standalone.zip版本,其中已经包括tomcat5.x服务器
- 下载mysql,偶使用的是mysql-5.0.22-win32解压版
- 下载mysql jdbc驱动,JIRA默认使用的是hsql。网上有教程说要使用mysql-connector-java-3.1.12-bin.jar版本,偶本机正好有这个版本,没去试别的版本的jdbc驱动会不会出问题
- 下载jira-jars-tomcat5.zip
- 确保JDK1.5环境看安成功,在CMD下java -version试试 :)
- 打开atlassian-jira-enterprise-3.6.3-standalone\atlassian-jira\WEB- INF\classes\entityengine.xml,搜索field-type-name,修改为field-type-name="mysql"
- 将mysql-connector-java-3.1.12-bin.jar拷贝到atlassian-jira-enterprise-3.6.3-standalone\common\lib
- 将jira-jars-tomcat5.zip拷贝到atlassian-jira-enterprise-3.6.3-standalone\common\lib
- 修改atlassian-jira-enterprise-3.6.3-standalone\conf\server.xml,将下面大段修改为:
- <RESOURCE name="jdbc/JiraDS" type="javax.sql.DataSource" password="" username="root"
- url="jdbc:mysql://localhost/jiradbautoReconnect=true&useUnicode=true&characterEncoding=UTF8&mysqlEncoding=utf8"
- maxActive="20" timeBetweenEvictionRunsMillis="5000" minEvictableIdleTimeMillis="4000"
- driverClassName="com.mysql.jdbc.Driver" auth="Container" />
- 运行安装,打开 http://localhost:8080 进行安装
注册机源代码
- import com.atlassian.license.LicensePair;
-
- import java.io.*;
- import java.security.KeyFactory;
- import java.security.Signature;
- import java.security.spec.PKCS8EncodedKeySpec;
-
- public class keygen {
-
- public keygen() {
- }
-
- public static void main(String args[])
- throws IOException {
- try {
- long l = 267L;
- long l1 = System.currentTimeMillis();
- long l2 = System.currentTimeMillis();
- String s = "";
- System.out.println("Keygen for JIRA Enterprise Edition.");
- System.out.print("created by mydaj[ROR].");
- do {
- System.out.print("\nEnter your organization name: ");
- for (int i = System.in.read(); i != 10 && i != 13; i = System.in.read())
- s = s + (char) i;
-
- } while (s == "");
- try {
- PKCS8EncodedKeySpec pkcs8encodedkeyspec = new PKCS8EncodedKeySpec(EncodedPrvKey);
- KeyFactory keyfactory = KeyFactory.getInstance("DSA", "SUN");
- java.security.PrivateKey privatekey = keyfactory.generatePrivate(pkcs8encodedkeyspec);
- String s1 = Long.toString(l, 10);
- s1 = s1 + "^^";
- s1 = s1 + Long.toString(l1, 10);
- s1 = s1 + "^^";
- s1 = s1 + Long.toString(l2, 10);
- s1 = s1 + "^^";
- s1 = s1 + s;
- byte abyte0[] = s1.getBytes();
- Signature signature = Signature.getInstance("SHA1withDSA");
- signature.initSign(privatekey);
- signature.update(abyte0);
- byte abyte1[] = signature.sign();
- LicensePair licensepair = null;
- try {
- licensepair = new LicensePair(abyte0, abyte1);
- }
- catch (Exception exception1) {
- exception1.printStackTrace();
- }
- System.out.println(s1);
- System.out.println("Your license key is: ");
- System.out.println(licensepair.toString());
- }
- catch (Exception exception) {
- exception.printStackTrace();
- }
- }
- catch (IOException ioexception) {
- }
- }
-
- static byte EncodedPrvKey[] = {
- 48, -126, 1, 75, 2, 1, 0, 48, -126, 1,
- 44, 6, 7, 42, -122, 72, -50, 56, 4, 1,
- 48, -126, 1, 31, 2, -127, -127, 0, -3, 127,
- 83, -127, 29, 117, 18, 41, 82, -33, 74, -100,
- 46, -20, -28, -25, -10, 17, -73, 82, 60, -17,
- 68, 0, -61, 30, 63, -128, -74, 81, 38, 105,
- 69, 93, 64, 34, 81, -5, 89, 61, -115, 88,
- -6, -65, -59, -11, -70, 48, -10, -53, -101, 85,
- 108, -41, -127, 59, -128, 29, 52, 111, -14, 102,
- 96, -73, 107, -103, 80, -91, -92, -97, -97, -24,
- 4, 123, 16, 34, -62, 79, -69, -87, -41, -2,
- -73, -58, 27, -8, 59, 87, -25, -58, -88, -90,
- 21, 15, 4, -5, -125, -10, -45, -59, 30, -61,
- 2, 53, 84, 19, 90, 22, -111, 50, -10, 117,
- -13, -82, 43, 97, -41, 42, -17, -14, 34, 3,
- 25, -99, -47, 72, 1, -57, 2, 21, 0, -105,
- 96, 80, -113, 21, 35, 11, -52, -78, -110, -71,
- -126, -94, -21, -124, 11, -16, 88, 28, -11, 2,
- -127, -127, 0, -9, -31, -96, -123, -42, -101, 61,
- -34, -53, -68, -85, 92, 54, -72, 87, -71, 121,
- -108, -81, -69, -6, 58, -22, -126, -7, 87, 76,
- 11, 61, 7, -126, 103, 81, 89, 87, -114, -70,
- -44, 89, 79, -26, 113, 7, 16, -127, -128, -76,
- 73, 22, 113, 35, -24, 76, 40, 22, 19, -73,
- -49, 9, 50, -116, -56, -90, -31, 60, 22, 122,
- -117, 84, 124, -115, 40, -32, -93, -82, 30, 43,
- -77, -90, 117, -111, 110, -93, 127, 11, -6, 33,
- 53, 98, -15, -5, 98, 122, 1, 36, 59, -52,
- -92, -15, -66, -88, 81, -112, -119, -88, -125, -33,
- -31, 90, -27, -97, 6, -110, -117, 102, 94, -128,
- 123, 85, 37, 100, 1, 76, 59, -2, -49, 73,
- 42, 4, 22, 2, 20, 42, 50, -88, 30, 125,
- -37, 118, -50, 20, -82, -63, 0, 8, -36, 106,
- -9, -110, 124, 107, 68
- };
-
- }