liferay5.0 plugins sdk開發現的一個小祕密

等了好久終於等到了5.0的出現,download下來一看,突然發現自已好像啥也不會了,liferay5.0他提倡的是plugins開發方式,tomcat裏面啥也沒有了,鬱悶只好重新deploy了一下,然後配置plugins-sdk自已做了一個簡單的portlet,deploy然後發現ROOT下面啥也沒有,鬱悶極了,日誌到是寫成功了,找了半天發現他deploy到了bin/{jetty.home}下面了,爲什麼會這樣,最初我以爲是那裏配置文件那裏沒有配好,在eclipse裏面search關鍵字jetty.home啥也沒有找到,逼不得已只好去找hot deploy相關代碼,居然讓我發現了liferay的一個小祕密.ServerDetector中
public static String getServerId() {
ServerDetector sd = _instance;

if (sd._serverId == null) {
if (ServerDetector.isGeronimo()) {
sd._serverId = GERONIMO_ID;
}
else if (ServerDetector.isGlassfish()) {
sd._serverId = GLASSFISH_ID;
}
else if (ServerDetector.isJBoss()) {
sd._serverId = JBOSS_ID;
}
else if (ServerDetector.isJOnAS()) {
sd._serverId = JONAS_ID;
}
else if (ServerDetector.isOC4J()) {
sd._serverId = OC4J_ID;
}
else if (ServerDetector.isOrion()) {
sd._serverId = ORION_ID;
}
else if (ServerDetector.isPramati()) {
sd._serverId = PRAMATI_ID;
}
else if (ServerDetector.isResin()) {
sd._serverId = RESIN_ID;
}
else if (ServerDetector.isRexIP()) {
sd._serverId = REXIP_ID;
}
else if (ServerDetector.isSun7()) {
sd._serverId = SUN7_ID;
}
else if (ServerDetector.isSun8()) {
sd._serverId = SUN8_ID;
}
else if (ServerDetector.isWebLogic()) {
sd._serverId = WEBLOGIC_ID;
}
else if (ServerDetector.isWebSphere()) {
sd._serverId = WEBSPHERE_ID;
}

if (ServerDetector.isJetty()) {
if (sd._serverId == null) {
sd._serverId = JETTY_ID;
}
else {
sd._serverId += "-" + JETTY_ID;
}
}
else if (ServerDetector.isTomcat()) {
if (sd._serverId == null) {
sd._serverId = TOMCAT_ID;
}
else {
sd._serverId += "-" + TOMCAT_ID;
}
}

if (_log.isInfoEnabled()) {
_log.info("Detected server " + sd._serverId);
}

if (sd._serverId == null) {
throw new RuntimeException("Server is not supported");
}
}

return sd._serverId;
}jetty的判斷在tomcat的前面,而他做判斷是根據能不能生成不同web server服務器的server.class來判斷你是用的tomcat還是jetty還是其他的.
而plugins-sdk自動生成portlet的時纔有兩名代碼
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
這兩個類本身是不識別的,在portal-src中他是在selenium-server.jar中的,所以我也直接引入了這個包,tomcat中沒有這個包,我直接把他放到了tomcat中去了,而這個包中能找到/org/mortbay/jetty/Server.class這個類,這個就是jetty服務器用的,jetty判斷寫在tomcat之前,自然系統就以爲你用的是jetty服務器.可是爲什麼沒有這個包之前,那其他的類爲什麼能識別這個呢,原來liferay不知道出於什麼目的,在開發中用的是selenium-server.jar這個包,而在真正發佈的時候他用的是commons-logging.jar這個包,其實這本身就是apache的log包,打開selenium-server.jar這個包會發現裏面也包括了commons-logging的內容.所以說解決方法也很簡單,用commons-logging.jar而不要去用selenium-server.jar.
發佈了6 篇原創文章 · 獲贊 0 · 訪問量 2963
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章