View Javadoc
1 /* 2 * PROJECT : DAR Runtime and Tools 3 * COPYRIGHT : Copyright (C) 1999-2004 tim.stephenson@enableit.org 4 * LICENSE : GNU LESSER GENERAL PUBLIC LICENSE 5 * Version 2.1, February 1999 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 */ 21 package org.enableit.db.darrt.web; 22 23 import java.net.URL; 24 25 import javax.servlet.ServletException; 26 27 import org.apache.log4j.Logger; 28 import org.apache.struts.action.ActionServlet; 29 import org.apache.struts.action.PlugIn; 30 import org.apache.struts.config.ApplicationConfig; 31 import org.enableit.db.darrt.DarHandler; 32 33 34 /*** 35 * Struts <code>PlugIn</code> Wrapper for DarHandler functionality. 36 * 37 * @author $Author: tim $ 38 */ 39 public class DarrtPlugIn implements PlugIn { 40 /*** 41 * The Log4J <code>Logger</code> doing the logging. 42 */ 43 private static Logger logger = Logger.getLogger(DarrtPlugIn.class); 44 45 /*** 46 * CVS info ABOUT this class and its current version 47 */ 48 public static final String ABOUT = "$Id: DarrtPlugIn.java,v 1.6 2004/03/20 05:25:03 tim Exp $"; 49 50 /* 51 * Properties 52 */ 53 54 /*** 55 * <p>The URL of the DAR archive to install.</p> 56 * 57 * <p>It is only valid to specify one of <code>darUrl</code> 58 * and <code>darResource</code>.</p> 59 */ 60 private String darUrl; 61 62 /*** 63 * <p>The resource name of the DAR archive to install.</p> 64 * 65 * <p>It is only valid to specify one of <code>darUrl</code> 66 * and <code>darResource</code>.</p> 67 */ 68 private String darResource; 69 70 /* 71 * Constructors 72 */ 73 74 /*** 75 * Default Constructor. 76 */ 77 public DarrtPlugIn() { 78 } 79 80 /* 81 * Methods 82 */ 83 84 /*** 85 * Get the DAR URL the plugin will be configured from. 86 */ 87 public String getDarUrl() { 88 return this.darUrl; 89 } 90 91 /*** 92 * Set the DAR URL the plugin will be configured from. 93 */ 94 public void setDarUrl(String darUrl) { 95 this.darUrl = darUrl; 96 } 97 98 /*** 99 * Get the DAR resource name the plugin will be configured from. 100 */ 101 public String getDarResource() { 102 return this.darResource; 103 } 104 105 /*** 106 * Set the DAR resource name the plugin will be configured from. 107 */ 108 public void setDarResource(String darResource) { 109 this.darResource = darResource; 110 } 111 112 /*** 113 * Does nothing. 114 */ 115 public void destroy() { 116 } 117 118 /*** 119 * Initialisation used by Struts when runnning inside a web container. 120 */ 121 public void init(ActionServlet actionservlet, 122 ApplicationConfig applicationconfig) 123 throws ServletException { 124 init(); 125 } 126 127 /*** 128 * Base initialisation. 129 */ 130 public void init() { 131 URL url = null; 132 133 try { 134 if (darResource != null) { 135 url = DarrtPlugIn.class.getResource(darResource); 136 } 137 138 if (darUrl != null) { 139 url = new URL(darUrl); 140 } 141 142 DarHandler dh = new DarHandler(); 143 144 dh.install(url); 145 } catch (Exception e) { 146 logger.error("Unable to install DAR: " + e.getMessage()); 147 } 148 } 149 }

This page was automatically generated by Maven