yooli88

          #

          ManagerFactory

          /*
           * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/ManagerFactory.java,v 1.6 2005/01/18 11:52:08 minhnn Exp $
           * $Author: minhnn $
           * $Revision: 1.6 $
           * $Date: 2005/01/18 11:52:08 $
           *
           * ====================================================================
           *
           * Copyright (C) 2002-2005 by MyVietnam.net
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * as published by the Free Software Foundation; either version 2
           * of the License, or any later version.
           *
           * All copyright notices regarding mvnForum MUST remain intact
           * in the scripts and in the outputted HTML.
           * The "powered by" text/logo with a link back to
           * http://www.mvnForum.com and http://www.MyVietnam.net in the
           * footer of the pages MUST remain visible when the pages
           * are viewed on the internet or intranet.
           *
           * 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 General Public License for more details.
           *
           * You should have received a copy of the GNU General Public License
           * along with this program; if not, write to the Free Software
           * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
           *
           * Support can be obtained from support forums at:
           * http://www.mvnForum.com/mvnforum/index
           *
           * Correspondence and Marketing Questions can be sent to:
           * info@MyVietnam.net
           *
           * @author: Luis Miguel Hernanz <luish@germinus.com>
           * @author: Minh Nguyen  minhnn@MyVietnam.net
           */
          package com.mvnforum;

          import org.apache.commons.logging.Log;
          import org.apache.commons.logging.LogFactory;
          import com.mvnforum.auth.Authenticator;
          import com.mvnforum.auth.OnlineUserFactory;

          /**
           * Instance that returns the right implementation for the different
           * parts of the mvnforum system.
           *
           * @author <a href="luish@germinus.com">Luis Miguel Hernanz</a>
           * @version $Revision: 1.6 $
           */
          // @todo : split this class to new class DAOFactory
          public class ManagerFactory {

              private static Log log = LogFactory.getLog(ManagerFactory.class);

              /**
               * Creates a new <code>ManagerFactory</code> instance.
               */
              protected ManagerFactory() {}

              private static OnlineUserFactory onlineUserFactory = null;
              private static Authenticator authenticator = null;
              private static RequestProcessor requestProcessor = null;

              public static synchronized OnlineUserFactory getOnlineUserFactory() {
                  if (onlineUserFactory == null) {
                      try {
                          Class c = Class.forName(MVNForumFactoryConfig.getOnlineUserFactoryClassName());
                          onlineUserFactory = (OnlineUserFactory) c.newInstance();
                          log.info("onlineUserFactory = " + onlineUserFactory);
                      } catch (Exception e) {
                          log.error("Error returning the online user factory.", e);
                          throw new RuntimeException(e.getMessage());
                      }
                  }
                  return onlineUserFactory;
              }

              public static synchronized Authenticator getAuthenticator() {
                  try {
                      String authenticatorClass = MVNForumFactoryConfig.getAuthenticatorClassName();
                      if ((null != authenticatorClass) && !authenticatorClass.trim().equals("")) {
                          log.debug("Using the authenticator: " + authenticatorClass);
                          if (authenticator == null) {
                              Class c = Class.forName(authenticatorClass);
                              authenticator = (Authenticator) c.newInstance();
                              log.info("authenticator = " + authenticator);
                          }
                          return authenticator;
                      }
                  } catch (Exception e){
                      log.error("Error getting the authentication object", e);
                  }
                  return null;
              }

              public static synchronized RequestProcessor getRequestProcessor() {
                  if (requestProcessor == null) {
                      try {
                          Class c = Class.forName(MVNForumFactoryConfig.getRequestProcessorClassName());
                          requestProcessor = (RequestProcessor) c.newInstance();
                          log.info("requestProcessor = " + requestProcessor);
                      } catch (Exception e) {
                          // This should never happen
                          log.error("Error returning the requestProcessor.", e);
                          throw new RuntimeException(e.getMessage());
                      }
                  }
                  return requestProcessor;
              }
          }

          posted @ 2007-09-11 11:30 迷茫在java的世界里 閱讀(161) | 評論 (0)編輯 收藏

          URLMap

          /*
           * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/URLMap.java,v 1.3 2005/01/18 11:52:08 minhnn Exp $
           * $Author: minhnn $
           * $Revision: 1.3 $
           * $Date: 2005/01/18 11:52:08 $
           *
           * ====================================================================
           *
           * Copyright (C) 2002-2005 by MyVietnam.net
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * as published by the Free Software Foundation; either version 2
           * of the License, or any later version.
           *
           * All copyright notices regarding mvnForum MUST remain intact
           * in the scripts and in the outputted HTML.
           * The "powered by" text/logo with a link back to
           * http://www.mvnForum.com and http://www.MyVietnam.net in the
           * footer of the pages MUST remain visible when the pages
           * are viewed on the internet or intranet.
           *
           * 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 General Public License for more details.
           *
           * You should have received a copy of the GNU General Public License
           * along with this program; if not, write to the Free Software
           * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
           *
           * Support can be obtained from support forums at:
           * http://www.mvnForum.com/mvnforum/index
           *
           * Correspondence and Marketing Questions can be sent to:
           * info@MyVietnam.net
           *
           * @author: Minh Nguyen  minhnn@MyVietnam.net
           * @author: Mai  Nguyen  mai.nh@MyVietnam.net
           */
          package com.mvnforum;

          public class URLMap {
              private String response = null;

              public URLMap() {
              }

              public void setResponse(String newvalue) {
                  response = newvalue;
              }

              public String getResponse() {
                  return response;
              }
          }

          posted @ 2007-09-11 11:29 迷茫在java的世界里 閱讀(177) | 評論 (0)編輯 收藏

          RequestProcessorDefault

          /*
           * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/RequestProcessorDefault.java,v 1.3 2005/01/18 11:52:08 minhnn Exp $
           * $Author: minhnn $
           * $Revision: 1.3 $
           * $Date: 2005/01/18 11:52:08 $
           *
           * ====================================================================
           *
           * Copyright (C) 2002-2005 by MyVietnam.net
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * as published by the Free Software Foundation; either version 2
           * of the License, or any later version.
           *
           * All copyright notices regarding mvnForum MUST remain intact
           * in the scripts and in the outputted HTML.
           * The "powered by" text/logo with a link back to
           * http://www.mvnForum.com and http://www.MyVietnam.net in the
           * footer of the pages MUST remain visible when the pages
           * are viewed on the internet or intranet.
           *
           * 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 General Public License for more details.
           *
           * You should have received a copy of the GNU General Public License
           * along with this program; if not, write to the Free Software
           * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
           *
           * Support can be obtained from support forums at:
           * http://www.mvnForum.com/mvnforum/index
           *
           * Correspondence and Marketing Questions can be sent to:
           * info@MyVietnam.net
           *
           * @author: Luis Miguel Hernanz <luish@germinus.com>
           * @author: Minh Nguyen  minhnn@MyVietnam.net
           */
          package com.mvnforum;

          import java.io.UnsupportedEncodingException;
          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          import org.apache.commons.logging.Log;
          import org.apache.commons.logging.LogFactory;

          /**
           * Empty implementation of the RequestProcessor interface.
           *
           * @author <a href="luish@germinus.com">Luis Miguel Hernanz</a>
           * @version $Revision: 1.3 $
           */
          public class RequestProcessorDefault implements RequestProcessor {

              private static Log log = LogFactory.getLog(RequestProcessorDefault.class);

              /**
               * This is the first method called in the request processing. This
               * method returns always <code>null</code>.
               *
               * @param request a <code>HttpServletRequest</code> value
               * @param response a <code>HttpServletResponse</code> value
               */
              public String preLogin(HttpServletRequest request, HttpServletResponse response) {
                  try {
                      request.setCharacterEncoding("utf-8");
                  } catch (UnsupportedEncodingException e){
                      log.warn("Error setting the character encoding from the request", e);
                  }
                  return null;
              }

              /**
               * The method receives the user request just before the
               * authentication has been checked. This method always returns
               * <code>null</code>.
               *
               * @param request a <code>HttpServletRequest</code> value
               * @param response a <code>HttpServletResponse</code> value
               */
              public String preProcess(HttpServletRequest request, HttpServletResponse response) {
                  return null;
              }

              /**
               * This method is called just before the call to the final request
               * dispatcher forward. This method always returns
               * <code>responseURI</code>.
               *
               * @param request a <code>HttpServletRequest</code> value
               * @param response a <code>HttpServletResponse</code> value
               * @param responseURI the path to which the control will be
               * forwarded after this method has finished.
               */
              public String postProcess(HttpServletRequest request, HttpServletResponse response, String responseURI) {
                  return responseURI;
              }
          }

          posted @ 2007-09-11 11:29 迷茫在java的世界里 閱讀(112) | 評論 (0)編輯 收藏

          RequestProcessor

          /*
           * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/RequestProcessor.java,v 1.3 2005/01/18 11:52:08 minhnn Exp $
           * $Author: minhnn $
           * $Revision: 1.3 $
           * $Date: 2005/01/18 11:52:08 $
           *
           * ====================================================================
           *
           * Copyright (C) 2002-2005 by MyVietnam.net
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * as published by the Free Software Foundation; either version 2
           * of the License, or any later version.
           *
           * All copyright notices regarding mvnForum MUST remain intact
           * in the scripts and in the outputted HTML.
           * The "powered by" text/logo with a link back to
           * http://www.mvnForum.com and http://www.MyVietnam.net in the
           * footer of the pages MUST remain visible when the pages
           * are viewed on the internet or intranet.
           *
           * 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 General Public License for more details.
           *
           * You should have received a copy of the GNU General Public License
           * along with this program; if not, write to the Free Software
           * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
           *
           * Support can be obtained from support forums at:
           * http://www.mvnForum.com/mvnforum/index
           *
           * Correspondence and Marketing Questions can be sent to:
           * info@MyVietnam.net
           *
           * @author: Luis Miguel Hernanz <luish@germinus.com>
           * @author: Minh Nguyen  minhnn@MyVietnam.net
           */
          package com.mvnforum;

          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          /**
           * Interface to hook additional preprocessing to the user request.
           * This interface is meatn as extension points to ease the integration
           * of the forum system with external systems.
           *
           * @author <a href="luish@germinus.com">Luis Miguel Hernanz</a>
           * @version $Revision: 1.3 $
           */
          public interface RequestProcessor {

              /**
               * This is the first method called in the request processing.
               *
               * @param request a <code>HttpServletRequest</code> value
               * @param response a <code>HttpServletResponse</code> value
               * @return the new responseURI to redirect to. The control will be
               * forwarded to this page (if responseURI is an jsp). No furher
               * processing will take place.
               */
              public String preLogin(HttpServletRequest request, HttpServletResponse response);

              /**
               * The method receives teh user request just before the
               * authentication has been checked.
               *
               * @param request a <code>HttpServletRequest</code> value
               * @param response a <code>HttpServletResponse</code> value
               * @return the new responseURI to redirect to.
               */
              public String preProcess(HttpServletRequest request, HttpServletResponse response);

              /**
               * This method is called just before the call to the final request
               * dispatcher forward.
               *
               * @param request a <code>HttpServletRequest</code> value
               * @param response a <code>HttpServletResponse</code> value
               * @param responseURI the path to which the control will be
               * forwarded after this method has finished.
               * @return the new responseURI to redirect to.
               */
              public String postProcess(HttpServletRequest request, HttpServletResponse response, String responseURI);

          }

          posted @ 2007-09-11 11:28 迷茫在java的世界里 閱讀(130) | 評論 (0)編輯 收藏

          MyUtil

          /*
           * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/MyUtil.java,v 1.30 2005/01/29 11:58:09 minhnn Exp $
           * $Author: minhnn $
           * $Revision: 1.30 $
           * $Date: 2005/01/29 11:58:09 $
           *
           * ====================================================================
           *
           * Copyright (C) 2002-2005 by MyVietnam.net
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * as published by the Free Software Foundation; either version 2
           * of the License, or any later version.
           *
           * All copyright notices regarding mvnForum MUST remain intact
           * in the scripts and in the outputted HTML.
           * The "powered by" text/logo with a link back to
           * http://www.mvnForum.com and http://www.MyVietnam.net in the
           * footer of the pages MUST remain visible when the pages
           * are viewed on the internet or intranet.
           *
           * 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 General Public License for more details.
           *
           * You should have received a copy of the GNU General Public License
           * along with this program; if not, write to the Free Software
           * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
           *
           * Support can be obtained from support forums at:
           * http://www.mvnForum.com/mvnforum/index
           *
           * Correspondence and Marketing Questions can be sent to:
           * info@MyVietnam.net
           *
           * @author: Minh Nguyen  minhnn@MyVietnam.net
           * @author: Mai  Nguyen  mai.nh@MyVietnam.net
           */
          package com.mvnforum;

          import java.awt.image.BufferedImage;
          import java.io.*;
          import java.util.*;

          import javax.servlet.ServletContext;
          import javax.servlet.http.*;

          import com.mvnforum.auth.*;
          import com.mvnforum.common.PrivateMessageUtil;
          import com.mvnforum.db.*;
          import com.mvnforum.search.member.MemberIndexer;
          import com.sun.image.codec.jpeg.JPEGCodec;
          import com.sun.image.codec.jpeg.JPEGImageEncoder;
          import net.myvietnam.mvncore.MVNCoreInfo;
          import net.myvietnam.mvncore.exception.*;
          import net.myvietnam.mvncore.filter.*;
          import net.myvietnam.mvncore.util.*;
          import org.apache.commons.logging.Log;
          import org.apache.commons.logging.LogFactory;

          public class MyUtil {

              private static Log log = LogFactory.getLog(MyUtil.class);

              private static RankCache rankCache = RankCache.getInstance();

              public static String filter(String input, boolean enableHTML, boolean enableEmotion,
                                          boolean enableMVNCode, boolean enableNewLine, boolean enableURL) {
                  String output = input;

                  if (enableHTML) {
                      output = EnableHtmlTagFilter.filter(output);
                  } else {
                      output = DisableHtmlTagFilter.filter(output);
                  }

                  if (enableEmotion) {
                      output = EnableEmotionFilter.filter(output, ParamUtil.getContextPath() + MVNForumGlobal.EMOTION_DIR);
                  }

                  if (enableMVNCode) {
                      output = EnableMVNCodeFilter.filter(output);
                  }

                  if (enableNewLine) {
                      output = HtmlNewLineFilter.filter(output);
                  }

                  if (enableURL) {
                      output = URLFilter.filter(output);
                  }
                  return output;
              }

              public static String getMemberTitle(int postCount) {
                  String title = "";
                  try {
                      ArrayList rankBeans = rankCache.getBeans();
                      for (int i = 0; i < rankBeans.size(); i++) {
                          RankBean rankBean = (RankBean)rankBeans.get(i);
                          if (rankBean.getRankMinPosts() <= postCount) {
                              title = EnableMVNCodeFilter.filter(rankBean.getRankTitle());
                          } else {
                              break;
                          }
                      }//for
                  } catch (Exception ex) {
                      log.error("Exception in getMemberTitile", ex);
                  }
                  return title;
              }

              public static String getForumIconName(long lastLogon, long lastPost) {
                  String forumIcon = null;
                  if (lastLogon > lastPost) {// no new post
                      forumIcon = "f_norm_no.gif";
                  } else {// new post
                      forumIcon = "f_norm_new.gif";
                  }
                  return forumIcon;
              }

              public static String getThreadIconName(long lastLogon, long lastPost, int postCount) {
                  String threadIcon = null;
                  if (postCount < MVNForumConfig.getHotTopicThreshold()) {//not hot topic
                      if (lastLogon > lastPost) {// no new post
                          threadIcon = "f_norm_no.gif";
                      } else {// new post
                          threadIcon = "f_norm_new.gif";
                      }
                  } else {// hot topic
                      if (lastLogon > lastPost) {// no new post
                          threadIcon = "f_hot_no.gif";
                      } else {// new post
                          threadIcon = "f_hot_new.gif";
                      }
                  }
                  return threadIcon;
              }

              public static String getThreadStatusName(Locale locale, int threadStatus) {
                  String result = null;
                  switch (threadStatus) {
                  case ThreadBean.THREAD_STATUS_DEFAULT:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.thread.status.normal");
                      break;
                  case ThreadBean.THREAD_STATUS_DISABLED:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.thread.status.disabled");
                      break;
                  case ThreadBean.THREAD_STATUS_LOCKED:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.thread.status.locked");
                      break;
                  case ThreadBean.THREAD_STATUS_CLOSED:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.thread.status.closed");
                      break;
                  default:
                      //throw new AssertionException("Cannot find matching thread status.");
                  }
                  return result;
              }

              public static String getThreadTypeName(Locale locale, int threadType) {
                  String result = "Unknown";
                  switch (threadType) {
                  case ThreadBean.THREAD_TYPE_DEFAULT:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.thread.type.normal_thread");
                      break;
                  case ThreadBean.THREAD_TYPE_STICKY:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.thread.type.sticky_thread");
                      break;
                  case ThreadBean.THREAD_TYPE_FORUM_ANNOUNCEMENT:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.thread.type.announcement_thread");
                      break;
                  case ThreadBean.THREAD_TYPE_GLOBAL_ANNOUNCEMENT:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.thread.type.global_announcement_thread");
                      break;
                  default:
                      //throw new AssertionException("Cannot find matching thread type.");
                  }
                  return result;
              }

              public static String getForumStatusName(Locale locale, int forumStatus) {
                  String result = null;
                  switch (forumStatus) {
                  case ForumBean.FORUM_STATUS_DEFAULT:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.forum.status.normal");
                      break;
                  case ForumBean.FORUM_STATUS_DISABLED:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.forum.status.disabled");
                      break;
                  case ForumBean.FORUM_STATUS_LOCKED:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.forum.status.locked");
                      break;
                  case ForumBean.FORUM_STATUS_CLOSED:
                      result = MVNForumResourceBundle.getString(locale, "mvnforum.common.forum.status.closed");
                      break;
                  default:
                      //throw new AssertionException("Cannot find matching forum status.");
                  }
                  return result;
              }

              public static boolean canViewAnyForumInCategory(int categoryID, MVNForumPermission permission) {
                  try {
                      Collection forumBeans = ForumCache.getInstance().getBeans();
                      for (Iterator iter = forumBeans.iterator(); iter.hasNext(); ) {
                          ForumBean forumBean = (ForumBean)iter.next();
                          if (forumBean.getCategoryID() == categoryID) {
                              if (canViewForum(forumBean, permission)) {
                                  return true;
                              }
                          }
                      }
                  } catch (DatabaseException ex) {
                      log.error("Cannot load the data in table Forum", ex);
                  }
                  return false;
              }

              public static boolean canViewForum(ForumBean forumBean, MVNForumPermission permission) {
                  if (permission.canReadPost(forumBean.getForumID()) &&
                      (forumBean.getForumStatus() != ForumBean.FORUM_STATUS_DISABLED) ) {
                      return true;
                  }
                  return false;
              }

              public static int getViewablePosts(Collection forumBeans, MVNForumPermission permission) {
                  int count = 0;
                  for (Iterator iter = forumBeans.iterator(); iter.hasNext(); ) {
                      ForumBean forumBean = (ForumBean)iter.next();
                      if (canViewForum(forumBean, permission)) {
                          count += forumBean.getForumPostCount();
                      }
                  }
                  return count;
              }

              public static int getViewableThreads(Collection forumBeans, MVNForumPermission permission) {
                  int count = 0;
                  for (Iterator iter = forumBeans.iterator(); iter.hasNext(); ) {
                      ForumBean forumBean = (ForumBean)iter.next();
                      if (canViewForum(forumBean, permission)) {
                          count += forumBean.getForumThreadCount();
                      }
                  }
                  return count;
              }

              public static int getViewableForums(Collection forumBeans, MVNForumPermission permission) {
                  int count = 0;
                  for (Iterator iter = forumBeans.iterator(); iter.hasNext(); ) {
                      ForumBean forumBean = (ForumBean)iter.next();
                      if (canViewForum(forumBean, permission)) {
                          count++;
                      }
                  }
                  return count;
              }

              public static int getViewableCategories(Collection categoryBeans, MVNForumPermission permission) {
                  int count = 0;
                  for (Iterator iter = categoryBeans.iterator(); iter.hasNext(); ) {
                      CategoryBean categoryBean = (CategoryBean)iter.next();
                      if (canViewAnyForumInCategory(categoryBean.getCategoryID(), permission)) {
                          count++;
                      }
                  }
                  return count;
              }

              /**
               * Get the String with a slash character '/' before the locale name
               * @param localeName the user's preferred locale
               * @return the String with a slash character '/' before the locale name if
               *         this locale is configed to support it. Otherwise,
               *         an empty String will be return
               */
              public static String getLocaleNameAndSlash(String localeName) {
                  if ( (localeName == null) || (localeName.length() == 0) ) {
                      return "";
                  }

                  String retValue = "";
                  String[] supportedLocales = MVNForumConfig.getSupportedLocaleNames();

                  if (supportedLocales == null) {
                      log.error("Assertion in MyUtil.getLocaleNameAndSlash. Please check your configuration.");
                      return "";
                  }

                  for (int i = 0; i < supportedLocales.length; i++) {
                      if (localeName.equals(supportedLocales[i])) {
                          retValue = "/" + localeName;
                          break;
                      }
                  }
                  return retValue;
              }

              public static String getCompanyCssPath(CompanyBean companyBean, String contextPath) {
                  String cssPath = null;
                  if (companyBean.getCompanyCss().length() > 0) {
                      cssPath = companyBean.getCompanyCss();
                  } else {
                      // use default company css
                      cssPath = MVNForumGlobal.COMPANY_DEFAULT_CSS_PATH;
                  }
                  return contextPath + cssPath;
              }

              public static String getCompanyLogoPath(CompanyBean companyBean, String contextPath) {
                  String logoPath = null;
                  if (companyBean.getCompanyLogo().length() > 0) {
                      logoPath = companyBean.getCompanyLogo();
                  } else {
                      // use default company logo
                      logoPath = MVNForumGlobal.COMPANY_DEFAULT_LOGO_PATH;
                  }
                  return contextPath + logoPath;
              }

              /**
               * Get the locale from locale name
               * @param localeName : in this format la_CO_VA, eg. en_US
               * @return the locale instance of the localeName
               */
              public static Locale getLocale(String localeName) {
                  // now, find out the 3 elements of a locale: language, country, variant
                  String[] localeElement = StringUtil.getStringArray(localeName, "_");
                  String language = "";
                  String country = "";
                  String variant = "";
                  if (localeElement.length >= 1) {
                      language = localeElement[0];
                  }
                  if (localeElement.length >= 2) {
                      country = localeElement[1];
                  }
                  if (localeElement.length >= 3) {
                      variant = localeElement[2];
                  }
                  return new Locale(language, country, variant);
              }

              public static void ensureCorrectCurrentPassword(HttpServletRequest request)
                  throws BadInputException, AssertionException, DatabaseException, AuthenticationException {

                  OnlineUser onlineUser = OnlineUserManager.getInstance().getOnlineUser(request);
                  OnlineUserFactory onlineUserFactory = ManagerFactory.getOnlineUserFactory();

                  try {
                      if (onlineUser.getAuthenticationType() == OnlineUser.AUTHENTICATION_TYPE_REALM) {
                          onlineUserFactory.ensureCorrectPassword(onlineUser.getMemberName(), OnlineUserManager.PASSWORD_OF_METHOD_REALM, true);
                      } else if (onlineUser.getAuthenticationType() == OnlineUser.AUTHENTICATION_TYPE_CUSTOMIZATION) {
                          if(MVNForumConfig.getEnablePasswordlessAuth()) {
                              // dont need password
                              onlineUserFactory.ensureCorrectPassword(onlineUser.getMemberName(), OnlineUserManager.PASSWORD_OF_METHOD_CUSTOMIZATION, true);
                          } else {
                              // must have password
                              // @todo: implement this case by using Authenticator
                              onlineUserFactory.ensureCorrectPassword(onlineUser.getMemberName(), OnlineUserManager.PASSWORD_OF_METHOD_CUSTOMIZATION, true);
                          }
                      } else {
                          //This user did not login by REALM or CUSTOMIZATION
                          String memberPassword = "";
                          String memberPasswordMD5 = ParamUtil.getParameter(request, "md5pw", false);
                          if (memberPasswordMD5.length() == 0 || (memberPasswordMD5.endsWith("==") == false)) {
                              // md5 is not valid, try to use unencoded password method
                              memberPassword = ParamUtil.getParameterPassword(request, "MemberCurrentMatkhau", 3, 0);
                          }

                          if (memberPassword.length() > 0) {
                              // that is we cannot find the md5 password
                              onlineUserFactory.ensureCorrectPassword(onlineUser.getMemberName(), memberPassword, false);
                          } else {
                              // have the md5, go ahead
                              onlineUserFactory.ensureCorrectPassword(onlineUser.getMemberName(), memberPasswordMD5, true);
                          }
                      }
                  } catch (AuthenticationException e) {
                      Locale locale = I18nUtil.getLocaleInRequest(request);
                      String localizedMessage = MVNForumResourceBundle.getString(locale, "mvncore.exception.BadInputException.wrong_password");
                      throw new BadInputException(localizedMessage);
                      //throw new BadInputException("You have typed the wrong password. Cannot proceed.");
                  }
              }

              public static void writeMvnForumImage(HttpServletRequest request, HttpServletResponse response) throws IOException {

                  BufferedImage image = MVNForumInfo.getImage();
                  OutputStream outputStream = null;
                  try {
                      outputStream = response.getOutputStream();
                      response.setContentType("image/jpeg");

                      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(outputStream);
                      encoder.encode(image);

                      outputStream.flush();
                  } catch (IOException ex) {
                      throw ex;
                  } finally {
                      if (outputStream != null) {
                          try {
                              outputStream.close();
                          } catch (IOException ex) { }
                      }
                  }
              }

              public static void writeMvnCoreImage(HttpServletRequest request, HttpServletResponse response) throws IOException {

                  BufferedImage image = MVNCoreInfo.getImage();
                  OutputStream outputStream = null;
                  try {
                      outputStream = response.getOutputStream();
                      response.setContentType("image/jpeg");

                      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(outputStream);
                      encoder.encode(image);

                      outputStream.flush();
                  } catch (IOException ex) {
                      throw ex;
                  } finally {
                      if (outputStream != null) {
                          try {
                              outputStream.close();
                          } catch (IOException ex) { }
                      }
                  }
              }

              public static void checkClassName(Locale locale, String className, boolean required) throws BadInputException {
                  if (required == false) {
                      if (className.length() == 0) return;
                  }

                  try {
                      Class.forName(className);
                  } catch (ClassNotFoundException ex) {
                      throw new BadInputException("Cannot load class: " + className);
                  }
              }

              public static void saveVNTyperMode(HttpServletRequest request, HttpServletResponse response) {
                  String vnTyperMode = ParamUtil.getParameter(request, "vnselector");
                  if (vnTyperMode.equals("VNI") || vnTyperMode.equals("TELEX") ||
                      vnTyperMode.equals("VIQR") || vnTyperMode.equals("NOVN")) {
                      Cookie typerModeCookie = new Cookie(MVNForumConstant.VN_TYPER_MODE, vnTyperMode);
                      typerModeCookie.setPath("/");
                      response.addCookie(typerModeCookie);
                  }
              }

              public static Hashtable checkMembers(String[] memberNames, Locale locale)
                  throws AssertionException, DatabaseException, BadInputException {

                  Hashtable memberMap = new Hashtable();
                  boolean isFailed = false;
                  StringBuffer missingNames = new StringBuffer(512);

                  for (int i = 0; i < memberNames.length; i++) {
                      int receivedMemberID = -1;
                      String memberName = memberNames[i];
                      StringUtil.checkGoodName(memberName);
                      try {
                          receivedMemberID = DAOFactory.getMemberDAO().getMemberIDFromMemberName(memberName);
                      } catch (ObjectNotFoundException ex) {
                          isFailed = true;
                          if (missingNames.length() > 0) {
                              missingNames.append(", ");
                          }
                          missingNames.append(memberName);
                          continue;
                      }
                      memberMap.put(new Integer(receivedMemberID), memberName);
                  } // end for

                  if (isFailed) { // the receivers does not exist.
                      String localizedMessage = MVNForumResourceBundle.getString(locale, "mvncore.exception.BadInputException.receivers_are_not_members", new Object[] {missingNames});
                      throw new BadInputException(localizedMessage);
                  }
                  return memberMap;
              }
          }

           

          posted @ 2007-09-11 11:27 迷茫在java的世界里 閱讀(276) | 評論 (0)編輯 收藏

          MVNForumResourceBundle

          /*
           * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/MVNForumResourceBundle.java,v 1.6 2005/01/18 11:52:08 minhnn Exp $
           * $Author: minhnn $
           * $Revision: 1.6 $
           * $Date: 2005/01/18 11:52:08 $
           *
           * ====================================================================
           *
           * Copyright (C) 2002-2005 by MyVietnam.net
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * as published by the Free Software Foundation; either version 2
           * of the License, or any later version.
           *
           * All copyright notices regarding mvnForum MUST remain intact
           * in the scripts and in the outputted HTML.
           * The "powered by" text/logo with a link back to
           * http://www.mvnForum.com and http://www.MyVietnam.net in the
           * footer of the pages MUST remain visible when the pages
           * are viewed on the internet or intranet.
           *
           * 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 General Public License for more details.
           *
           * You should have received a copy of the GNU General Public License
           * along with this program; if not, write to the Free Software
           * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
           *
           * Support can be obtained from support forums at:
           * http://www.mvnForum.com/mvnforum/index
           *
           * Correspondence and Marketing Questions can be sent to:
           * info@MyVietnam.net
           *
           * @author: Minh Nguyen  minhnn@MyVietnam.net
           * @author: Pavel Av
           */
          package com.mvnforum;

          import java.util.Locale;
          import java.util.ResourceBundle;

          import net.myvietnam.mvncore.i18n.CacheResourceBundle;

          public class MVNForumResourceBundle {

              private static CacheResourceBundle cacheResourceBundle = new CacheResourceBundle(MVNForumGlobal.RESOURCE_BUNDLE_NAME);

              private MVNForumResourceBundle() {
              }

              public static ResourceBundle getResourceBundle(Locale locale) {
                  return cacheResourceBundle.getResourceBundle(locale);
              }

              public static String getString(Locale locale, String key) {
                  return cacheResourceBundle.getString(locale, key);
              }

              public static String getString(Locale locale, String key, Object[] args) {
                  return cacheResourceBundle.getString(locale, key, args);
              }
          }

          posted @ 2007-09-11 11:26 迷茫在java的世界里 閱讀(145) | 評論 (0)編輯 收藏

          MVNForumInfo

           

          /*
           * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/MVNForumInfo.java,v 1.36.2.2 2005/06/17 17:53:37 minhnn Exp $
           * $Author: minhnn $
           * $Revision: 1.36.2.2 $
           * $Date: 2005/06/17 17:53:37 $
           *
           * ====================================================================
           *
           * Copyright (C) 2002-2005 by MyVietnam.net
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * as published by the Free Software Foundation; either version 2
           * of the License, or any later version.
           *
           * All copyright notices regarding mvnForum MUST remain intact
           * in the scripts and in the outputted HTML.
           * The "powered by" text/logo with a link back to
           * http://www.mvnForum.com and http://www.MyVietnam.net in the
           * footer of the pages MUST remain visible when the pages
           * are viewed on the internet or intranet.
           *
           * 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 General Public License for more details.
           *
           * You should have received a copy of the GNU General Public License
           * along with this program; if not, write to the Free Software
           * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
           *
           * Support can be obtained from support forums at:
           * http://www.mvnForum.com/mvnforum/index
           *
           * Correspondence and Marketing Questions can be sent to:
           * info@MyVietnam.net
           *
           * @author: Minh Nguyen  minhnn@MyVietnam.net
           * @author: Mai  Nguyen  mai.nh@MyVietnam.net
           */
          package com.mvnforum;

          import java.awt.*;
          import java.awt.image.BufferedImage;

          public class MVNForumInfo {

              private MVNForumInfo() {
              }

              private static String PRODUCT_NAME         = "mvnForum";

              private static String PRODUCT_DESC         = "mvnForum 1.0.0 RC4 Update 4";

              private static String PRODUCT_VERSION      = "1.0.0-RC4_04";

              private static String PRODUCT_RELEASE_DATE = "18 June 2005";

              private static String PRODUCT_HOMEPAGE     = "http://www.mvnForum.com";

              public static String getProductName() {
                  return PRODUCT_NAME;
              }

              public static String getProductDesc() {
                  return PRODUCT_DESC;
              }

              public static String getProductVersion() {
                  return PRODUCT_VERSION;
              }

              public static String getProductReleaseDate() {
                  return PRODUCT_RELEASE_DATE;
              }

              public static String getProductHomepage() {
                  return PRODUCT_HOMEPAGE;
              }

              public static BufferedImage getImage() {

                  String str = PRODUCT_VERSION + " on " + PRODUCT_RELEASE_DATE;
                  int IMAGE_WIDTH  = 250;
                  int IMAGE_HEIGHT = 30;

                  BufferedImage bufferedImage = new BufferedImage(IMAGE_WIDTH, IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB);
                  Graphics2D g = bufferedImage.createGraphics();
                  g.setBackground(Color.blue);
                  g.setColor(Color.white);
                  g.draw3DRect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, false);
                  FontMetrics fontMetrics = g.getFontMetrics();
                  int strWidth  = fontMetrics.stringWidth(str);
                  int strHeight = fontMetrics.getAscent() + fontMetrics.getDescent();
                  g.drawString(str, (IMAGE_WIDTH - strWidth) / 2, IMAGE_HEIGHT - ((IMAGE_HEIGHT - strHeight) / 2) - fontMetrics.getDescent());
                  g.dispose(); // free resource
                  return bufferedImage;
              }

          }

          posted @ 2007-09-11 11:22 迷茫在java的世界里| 編輯 收藏

          六章 復用類

                代碼的復用有兩種方法————1就是直接在新類中生成舊有的類的對象 (合成)2是創建一個新的類 這個類會全盤接受舊有的類 并且在不對舊有類修改的前提下 添加新的代碼(繼承)
                合成所使用的方法
                只要把對象的引用reference放到新的類里面就可以了。當primitive數據作為類的成員時候會自動初始化為零,對象的reference也會為null,這時候調用這個reference會拋出nullpoint異常。
             reference的初始化有以下三種方式:
             1 在定義對象的時候。這就意味著在調用構造函數之前,他們已經初始化完畢了。
             2在這個類的構造函數里。
             3在即將使用那個對象之前。如果碰到創建對象的代價很高,或者不是每次都需要創建對象的時候,這種做法就能降低程序的開銷。
                繼承所使用的方法
                繼承的時候 必須使用extends關鍵詞和基類的名字。之后新類就會自動獲得基類的全部成員和方法。繼承不會限定只能使用基類的方法。也可以往派生類里加入新的方法。
                基類的初始化
                當創建一個派生類的對象的時候,這個對象立門還有一個基類的對象。這個對象同基類自己創建的對象沒有任何的差別。只是從外面看來這個對象是被包裹在派生類的對象里面。
                基類的初始化只有一個方法能保證:調用基類的構造函數來進行初始化,只有這樣才能掌握怎樣才能正確地進行初始化的信息和權限。java會讓派生類的構造函數自動地調用基類的構造函數。
                帶參數的構造函數
                調用帶參數的構造函數必須使用super關鍵詞以及合適的參數明確調用基類的構造函數。
                確保進行妥善地清理
                一般情況下java會將需要清理的對象留給垃圾回收器去處理,它不會主動的進行清理。由于不知道垃圾回收器甚么時候啟動,也不知道會不會啟動,所有需要進行清理,就必須明確地寫一個專門干這件事情的方法,為了應付異常,還要將這個方法放入finally子句里面去。不要去調用finalize方法。
                用合成還是繼承
                一般來說,合成用于新類要使用舊類的功能,而不是其接口的場合,也就是說把對象嵌進去,用它來實現新類的功能,但用戶看到的是新類的接口,而不是嵌進去的對象的接口,因此在新類里嵌入private的舊類對象,有時為了讓用戶直接訪問新類的各個組成部分也可以嵌入public的舊類對象。通常都應該將基類的成員數據定義為privite類型。繼承表達的是一種“是(is-a)”關系,合成表達的是“有(has-a)”關系,對于一些需要對外部世界隱藏,但要對它的繼承類開放的基類 可以使用protected來定義那些開放的部分。最好的做法是,將數據成員設成private 的;你應該永遠保留修改底層實現的權利。然后用protected 權限的方法來控制繼承類的訪問權限。
                漸進式的開發
                繼承的優點之一就是,它支持漸進式的開發(incremental develop)。添加新的代碼的時候,不會給老代碼帶來bug;實際上新的bug 全都被圈在新代碼里。通過繼承已有的,已經能正常工作的類,然后再添加一些數據成員和方法(以及重新定義一些原有的方法),你可以不去修改那些可能還有人在用的老代碼,因而也就不會造成bug 了。一旦發現了bug,你就知道它肯定是在新代碼里。相比要去修改老代碼,新代碼會短很多,讀起來也更簡單。繼承實質上是在表達這樣一種關系:“新的類是一種舊的類”。
                上傳
                 繼承最重要的特征不在于它為新類提供了方法,而是它表達了新類同基類之間的關系。這種關系可以被歸納為一句話“新類就是一種原有的類。” (upcasting)”。上傳總是安全的,因為你是把一個較具體的類型轉換成較為一般的類型。也就是說派生類是基類的超集(superset)。它可能會有一些基類所沒有的方法,但是它最少要有基類的方法。在上傳過程中,類的接口只會減小,不會增大。這就是為什么編譯器會允許你不作任何明確的類型轉換或特殊表示就進行上傳的原因了。
                合成還是繼承,再探討
                在判斷該使用合成還是繼承的時候,有一個最簡單的辦法,就是問一下你是不是會把新類上傳給基類。如果你必須上傳,那么繼承就是必須的,如果不需要上傳,那么就該再看看是不是應該用繼承了。
                final 關鍵詞
                final 的三種用途:數據(data),方法(method)和類(class)。
          Final 的數據
                很多編程語言都有通知編譯器“這是段『常量(constant)』 數據”的手段。常量能用于下列兩種情況:
          1. 可以是“編譯時的常量(compile-time constant)”,這樣就再也不能改了。
          2. 也可以是運行時初始化的值,這個值你以后就不想再改了。
          如果是編譯時的常量,編譯器會把常量放到算式里面;這樣編譯的時候就能進行計算,因此也就降低了運行時的開銷。在Java 中這種常量必須是primitive 型的,而且要用final 關鍵詞表示。這種常量的賦值必須在定義的時候進行。
                 一個既是static 又是final 的數據成員會只占據一段內存,并且不可修改。
                當final 不是指primitive,而是用于對象的reference 的時候,意思就有點搞了。對primitive 來說,final 會將這個值定義成常量,但是對于對象的reference 而言,final 的意思則是這個reference 是常量。初始化的時候,一旦將reference 連到了某個對象,那么它就再也不能指別的對象了。但是這個對象本身是可以修改的;Java 沒有提供將某個對象作成常量的方法。(但是你可以自己寫一個類,這樣就能把類當做常量了。)這種局限性也體現在數組上,因為它也是一個對象。
                空白的final 數據 (Blank finals)
                Java 能讓你創建“空白的final 數據(blank finals)”,也就是說把數據成員聲明成final 的,但卻沒給初始化的值。碰到這種情況,你必須先進行初始化,再使用空白的final 數據成員,而且編譯器會強制你這么做。不過,空白的final 數據也提供了一種更為靈活的運用final 關鍵詞方法,比方說,現在對象里的final 數據就能在保持不變性的同時又有所不同了。
                你一定得為final 數據賦值,要么是在定義數據的時候用一個表達式賦值,要么是在構造函數里面進行賦值。為了確保final 數據在使用之前已經進行了初始化,這一要求是強制性的。
                Final 的參數
                Java 允許你在參數表中聲明參數是final 的,這樣參數也編程final了。也就是說,你不能在方法里讓參數reference 指向另一個對象了。
                Final 方法
          使用final 方法的目的有二。第一,為方法上“鎖”,禁止派生類進行修改。這是出于設計考慮。當你希望某個方法的功能,能在繼承過程中被保留下來,并且不被覆寫,就可以使用這個方法。
          第二個原因就是效率。如果方法是final 的,那么編譯器就會把調用轉換成“內聯的(inline)”。當編譯器看到要調用final 方法的時候,它就會(根據判斷)舍棄普通的,“插入方法調用代碼的”編譯機制(將參數壓入棧,然后跳去執行要調用的方法的代碼,再跳回來清空棧,再處理返回值),相反它會用方法本身的拷貝來代替方法的調用。當然如果方法很大,那么程序就會膨脹得很快,于是內聯也不會帶來什么性能的改善,因為這種改善相比程序處理所耗用的時間是微不足道的。Java 的設計者們暗示過,Java 的編譯器有這個功能,可以智能地判斷是不是應該將final 方法做成內聯的。不過,最好還是把效率問題留給編譯器和JVM去處理,而只把final 用于要明確地禁止覆寫的場合。
          final 和private
          private 方法都隱含有final 的意思。由于你不能訪問private 的方法,因此你也不能覆寫它。你可以給private 方法加一個final 修飾符,但是這樣做什么意義也沒有。這個問題有可能會造成混亂,因為即使你覆寫了一個private 方法(它隱含有final 的意思),看上去它還是可以運行的,而且編譯器也不會報錯。
                只有是基類接口里的東西才能被“覆寫”。也就是說,對象應該可以被上傳到基類,然后再調用同一個方法(這一點要到下一章才能講得更清楚。)如果方法是private 的,那它就不屬于基類的接口。它只能算是被類隱藏起來的,正好有著相同的名字的代碼。如果你在派生類里創建了同名的public 或protected,或package 權限的方法,那么它們同基類中可能同名的方法,沒有任何聯系。你并沒有覆寫那個方法,你只是創建了一個新的方法。由于private 方法是無法訪問的,實際上是看不見的,因此這么作除了會影響類的代碼結構,其它什么意義都沒有。
                Final 類
                把整個類都定義成final 的(把final 關鍵詞放到類的定義部分的前面)就等于在宣布,你不會去繼承這個類,你也不允許別人去繼承這個類。換言之,出于類的設計考慮,它再也不需要作修改了,或者從安全角度出發,你不希望它再生出子類。
                注意,final 類的數據可以是final 的,也可以不是final 的,這要由你來決定。無論類是不是final 的,這一條都適用于“將final 用于數據的”場合。但是,由于final 類禁止了繼承,覆寫方法已經不可能了,因此所有的方法都隱含地變成final 了。你可以為final 類的方法加一個final 修飾符,但是這一樣沒什么意義。
                小心使用final
                看來,設計類的時候將方法定義成final 的,會是一個很明智的決定。可能你會覺得沒人會要覆寫你的方法。有時確實是這樣。

          posted @ 2007-06-28 19:20 迷茫在java的世界里 閱讀(188) | 評論 (0)編輯 收藏

          第五章 隱藏實現

                本章主要是介紹如何對代碼進行封裝,并解釋為什么類庫中有些部分會被公之于眾,有些部分被隱藏的起來:類庫創建時保證在不影響類庫使用者代碼的前提下對類庫進行修改和改進,在對類庫進行修改的時候不能刪減現有方法,對于那些只有類內部實現有關的,不應該會使用的部分進行封裝,限制用戶使用這部分代碼,便于類庫創建者對類庫進行修改,這就是java提供的訪問控制符 access specifier ,public protected package private 
                使用import導入一個完整的類或類庫。package的名稱是獨一無二的 ,不要import兩個同名的類否則會引起沖突
                java的訪問控制符:類只能被定義public 或 package(默認的沒有定義訪問控制符的),而類內部數據成員和方法 被定義public的可以被任何類都能訪問,被定義protected的數據成員或方法只能被該類的子類訪問,定義package的數據成員或方法只能被同一目錄下的類訪問,private的成員或方法只能被類的內部數據成員或方法訪問。
                類的訪問權限:每個編譯單元只能有一個public類,只是為了保證每個編譯單元只能有一個公共接口,可以根據需要往這個編譯單元里添加package權限的類,public的類必須和這個編譯單元一樣的文件名      

          posted @ 2007-06-25 18:43 迷茫在java的世界里| 編輯 收藏

          Eclipse與插件(tomcatPlugin Lomboz easyStruts)安裝

          一、安裝準備?

          在進行安裝以前,你應該準備以下軟件:?

          ?軟件:J2se?
          ?版本:1.4.2_04?
          ?官方下載:http://java.sun.com/j2se/1.4.2/download.html?
          ?備注:?
          ??
          ?軟件:Tomcat?
          ?版本:5.0.19?
          ?官方下載:http://www.apache.org/dist/jakarta/?
          ?備注:?
          ??
          ?軟件:Struts?
          ?版本:1.1?
          ?官方下載:http://www.apache.org/dist/jakarta/struts/?
          ?備注:?
          ??
          ?軟件:Eclipse?
          ?版本:2.1.3?
          ?官方下載:http://www.eclipse.org/downloads/index.php?
          ?備注:目前eclipse最新版為eclipse3.0R1?

          ?軟件:EclipseLanguagePack?
          ?版本:2.1.2.1?
          ?官方下載:http://www.eclipse.org/downloads/index.php?
          ?備注:該版本只能漢化eclipse2.1.3及以下版本?

          ?軟件:TomcatPlugin?
          ?版本:2.2.1?
          ?官方下載:http://www.sysdeo.com/eclipse/tomcatPlugin.html?
          ?備注:該版本只能漢化eclipse2.1.3及以下版本?
          ??
          ?軟件:Lomboz?
          ?版本:2.1.3?
          ?官方下載:http://www.objectlearn.com/index.jsp?
          ?備注:該版本只能漢化eclipse2.1.3及以下版本?

          ?軟件:EasyStruts?
          ?版本:0.6.4?
          ?官方下載:http://sourceforge.net/projects/easystruts?
          ?備注:該版本只能漢化eclipse2.1.3及以下版本?
          ??

          以上軟件版本為安裝成功的版本,為了使您的安裝不至于出錯請遵照以上版本準本軟件。?

          hodesoft公司內部員工可以訪問\\192.168.0.23獲取?

          如果要找其他eclipse插件可以去下面這個站點?
          http://www.eclipse-plugins.info?
          ??

          二、JDK安裝?

          1.安裝J2SE-SDK到E:\j2sdk1.4.2?

          ???????部分目錄結構如下:?

          ??????????????E:\j2sdk1.4.2\in?

          ??????????????E:\j2sdk1.4.2\lib?

          ??????????????E:\j2sdk1.4.2\jre?

          ?????????????????????...?

          2.配置環境變量如下:?

          JAVA_HOME?=?E:\j2sdk1.4.2?

          ??????????????PATH?=?%JAVA_HOME%\in;.;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib;?

          ??????????????CLASSPATH?=?.;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib;?

          ??

          三、Tomcat安裝?

          1.解壓jakarta-tomcat-5.0.19.zip到E:\tomcat?

          ???????部分目錄結構如下:?

          ??????????????E:\tomcat\in?

          ??????????????E:\tomcat\conf?

          ??????????????E:\tomcat\webapps?

          ?????????????????????...?

          2.配置環境變量如下:?

          TOMCAT_HOME?=?E:\tomcat?

          ??

          四、Struts安裝?

          1.解壓jakarta-struts-1.1.zip到E:\jakarta-struts-1.1?

          ???????部分目錄結構如下:?

          ??????????????E:\jakarta-struts-1.1\lib?

          ??????????????E:\jakarta-struts-1.1\webapps?

          ?????????????????????...?

          五、Eclipse安裝?

          1.解壓eclipse-SDK-2.1.3-win32.zip到E:\eclipse213?

          ???????部分目錄結構如下:?

          ??????????????E:\eclipse213\features?

          ??????????????E:\eclipse213\plugins?

          ?????????????????????...?

          2.啟動Eclipse,看看安裝是否成功?

          ???????如果啟動不成功,請查看JRE是否安裝?

          3.啟動Eclipse,點擊菜單?windows->preferences?在左邊樹中點擊展開java,選擇Installed?JREs,?

          如果Installed?JREs如下則正確:?

          ?JRE?Type:Standard?VM?
          ?Name:j2sdk1.4.2?
          ?Location:E:\j2sdk1.4.2?


          六、Eclipse漢化?

          1.解壓eclipse2.1.2.1-SDK-win32-LanguagePackFeature.zip到E:\eclipse213下?

          ???????將目錄名eclipse2.1.2.1-SDK-win32-LanguagePackFeature改為eclipse2.1.2.1Language?

          部分目錄結構如下:?

          ??????????????E:\eclipse213\eclipse2.1.2.1Language\eclipse\features?

          ??????????????E:\eclipse213\eclipse2.1.2.1Language\eclipse\plugins?

          ?????????????????????...?

          2.在E:\eclipse213下新建文件夾links,使得文件夾links和文件夾eclipse2.1.2.1Language同級?

          3.在E:\eclipse213\links下新建文件,文件名任取,這里我們命名為language.link,打開此文件,?

          加入?path?=?E:\\eclipse213\\eclipse2.1.2.1Language?

          4.啟動Eclipse,看看漢化是否成功,如不成功請檢查language.link文件中配置信息path?=?

          E:\\eclipse213\\eclipse2.1.2.1Language和漢化文件夾eclipse2.1.2.1Language的安裝路徑是否一?

          致?

          ??

          七、TomcatPlugin安裝?

          1.解壓tomcatPluginV221.zip?

          2.將解壓目錄tomcatPluginV221下文件夾com.sysdeo.eclipse.tomcat_2.2.1復制到eclipse安裝目?

          錄中的plugins目錄中,即E:\eclipse213\plugins?

          3.啟動Eclipse?

          4.啟動后你將看到你的菜單上多了一個下拉項Tomcat,快捷欄里多了三個Tomcat的貓圖表,如?

          果沒有看到,請點擊?窗口->定制透視圖,展開樹結構中的“其它”,選擇“Tomcat”?

          5.點擊?窗口->首選項?

          ???????在左邊樹中點擊tomcat,設置tomcat?version為version?5.x?

          ??????????????????????????????????????????設置tomcat?version為version?5.x?

          ??????????????????????????????????????????設置tomcat-home為E:\tomcat?

          ??????????????????????????????????????????設置perspective?to?switch?when?tomcat?is?started為java?

          在左邊樹中點擊tomcat->JVM?setting,設置JRE為j2sdk1.4.2?

          點擊應用確定?

          6.點擊快捷按鈕“Start?Tomcat”來啟動Tomcat吧?

          ??

          八、Lomboz安裝?

          1.解壓lomboz.213.zip?

          2.將解壓目錄lomboz.213\plugins下文件夾com.objectlearn.jdt.j2ee和com.objectlearn.jdt.j2ee.editors?

          復制到eclipse安裝目錄中的plugins目錄中,即E:\eclipse213\plugins?

          3.啟動Eclipse?

          4.點擊?窗口->首選項?

          ???????在左邊樹中點擊lomboz,設置JDK?tools.jar位置為E:\?j2sdk1.4.2\lib\tools.jar?

          在左邊樹中點擊lomboz->server?definitions,設置Server?Type為Apache?Tomcat?v5.0.x?

          ????????????????????????????設置Application?Server?Directory為E:\tomcat?

          ????????????????????????????設置classpath?Variable?Name為TOMCAT_HOME?

          ????????????????????????????設置classpath?Variable為E:\tomcat?

          點擊應用確定?

          ??

          九、easyStruts安裝?

          1.解壓org.easystruts.eclipse_0.6.4.zip?

          2.將解壓目錄org.easystruts.eclipse_0.6.4下文件夾com.cross.easystruts.eclipse_0.6.4復制到eclipse?

          安裝目錄中的plugins目錄中,即E:\eclipse213\plugins?

          3.啟動Eclipse?

          4.點擊?窗口->首選項?

          ???????在左邊樹中點擊Easy?Struts,選擇struts1.1?

          ADD?JREs如下:?

          struts.jar-E:\jakarta-struts-1.1\lib\struts.jar?

          ADD?TLDs如下:?

          ?????????????????????struts-tiles.tld-E:\jakarta-struts-1.1\lib\struts-tiles.tld?

          ?????????????????????struts-template.tld-E:\jakarta-struts-1.1\lib\struts-template.tld?

          ?????????????????????struts-nested.tld-E:\jakarta-struts-1.1\lib\struts-nested.tld?

          ?????????????????????struts-logic.tld-E:\jakarta-struts-1.1\lib\struts-logic.tld?

          ?????????????????????struts-html.tld-E:\jakarta-struts-1.1\lib\struts-html.tld?

          ?????????????????????struts-bean.tld-E:\jakarta-struts-1.1\lib\struts-bean.tld?

          點擊應用確定?

          posted @ 2006-04-12 20:31 迷茫在java的世界里 閱讀(615) | 評論 (0)編輯 收藏

          僅列出標題
          共3頁: 上一頁 1 2 3 下一頁 
          主站蜘蛛池模板: 沈阳市| 罗甸县| 镇康县| 承德县| 海门市| 深泽县| 汶上县| 临潭县| 高碑店市| 屯昌县| 玉溪市| 宜君县| 资源县| 丰都县| 象州县| 梁平县| 克东县| 沛县| 浑源县| 聂拉木县| 高碑店市| 景泰县| 盐边县| 和龙市| 特克斯县| 乐昌市| 尤溪县| 陇川县| 新巴尔虎左旗| 青阳县| 泽普县| 右玉县| 泌阳县| 衡水市| 武功县| 墨竹工卡县| 新昌县| 双城市| 浙江省| 浦江县| 康平县|