1 16 package org.apache.juddi.registry; 17 18 import java.io.IOException ; 19 import java.io.InputStream ; 20 import java.util.Properties ; 21 22 import javax.servlet.ServletConfig ; 23 import javax.servlet.ServletException ; 24 import javax.servlet.http.HttpServlet ; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 35 public class RegistryServlet extends HttpServlet 36 { 37 private static final String CONFIG_FILE_PROPERTY_NAME = "juddi.propertiesFile"; 39 40 private static final String DEFAULT_PROPERTY_FILE = "/WEB-INF/juddi.properties"; 42 43 private static Log log = LogFactory.getLog(RegistryServlet.class); 45 46 private static RegistryEngine registry = null; 48 49 54 public void init(ServletConfig config) 55 throws ServletException 56 { 57 super.init(config); 58 59 Properties props = new Properties (); 60 61 try 62 { 63 log.info("Loading jUDDI configuration."); 64 65 String propFile = config.getInitParameter(CONFIG_FILE_PROPERTY_NAME); 67 if ((propFile == null) || (propFile.trim().length() == 0)) 68 propFile = DEFAULT_PROPERTY_FILE; 69 70 InputStream is = 71 getServletContext().getResourceAsStream(propFile); 72 73 if (is != null) 74 { 75 log.info("Resources loaded from: "+propFile); 76 77 81 props.load(is); 82 } 83 else 84 { 85 log.warn("Could not locate jUDDI properties '" + propFile + 86 "'. Using defaults."); 87 88 92 props.put(RegistryEngine.PROPNAME_OPERATOR_NAME, 93 RegistryEngine.DEFAULT_OPERATOR_NAME); 94 95 props.put(RegistryEngine.PROPNAME_I18N_LANGUAGE_CODE, 96 RegistryEngine.DEFAULT_I18N_LANGUAGE_CODE); 97 98 props.put(RegistryEngine.PROPNAME_I18N_COUNTRY_CODE, 99 RegistryEngine.DEFAULT_I18N_COUNTRY_CODE); 100 101 props.put(RegistryEngine.PROPNAME_DISCOVERY_URL, 102 RegistryEngine.DEFAULT_DISCOVERY_URL); 103 104 props.put(RegistryEngine.PROPNAME_ADMIN_EMAIL_ADDRESS, 105 RegistryEngine.DEFAULT_ADMIN_EMAIL_ADDRESS); 106 107 props.put(RegistryEngine.PROPNAME_DATASOURCE_NAME, 108 RegistryEngine.DEFAULT_DATASOURCE_NAME); 109 110 props.put(RegistryEngine.PROPNAME_AUTH_CLASS_NAME, 111 RegistryEngine.DEFAULT_AUTH_CLASS_NAME); 112 113 props.put(RegistryEngine.PROPNAME_CRYPTOR_CLASS_NAME, 114 RegistryEngine.DEFAULT_CRYPTOR_CLASS_NAME); 115 116 props.put(RegistryEngine.PROPNAME_DATASTORE_CLASS_NAME, 117 RegistryEngine.DEFAULT_DATASTORE_CLASS_NAME); 118 119 props.put(RegistryEngine.PROPNAME_UUIDGEN_CLASS_NAME, 120 RegistryEngine.DEFAULT_UUIDGEN_CLASS_NAME); 121 122 props.put(RegistryEngine.PROPNAME_VALIDATOR_CLASS_NAME, 123 RegistryEngine.DEFAULT_VALIDATOR_CLASS_NAME); 124 125 props.put(RegistryEngine.PROPNAME_MAX_NAME_ELEMENTS, 126 Integer.toString(RegistryEngine.DEFAULT_MAX_NAME_ELEMENTS)); 127 128 props.put(RegistryEngine.PROPNAME_MAX_NAME_LENGTH, 129 Integer.toString(RegistryEngine.DEFAULT_MAX_NAME_LENGTH)); 130 131 props.put(RegistryEngine.PROPNAME_MAX_MESSAGE_SIZE, 132 Integer.toString(RegistryEngine.DEFAULT_MAX_MESSAGE_SIZE)); 133 134 props.put(RegistryEngine.PROPNAME_MAX_BUSINESS_ENTITIES_PER_USER, 135 Integer.toString(RegistryEngine.DEFAULT_MAX_BUSINESS_ENTITIES_PER_USER)); 136 137 props.put(RegistryEngine.PROPNAME_MAX_BUSINESS_SERVICES_PER_BUSINESS, 138 Integer.toString(RegistryEngine.DEFAULT_MAX_BUSINESS_SERVICES_PER_BUSINESS)); 139 140 props.put(RegistryEngine.PROPNAME_MAX_BINDING_TEMPLATES_PER_SERVICE, 141 Integer.toString(RegistryEngine.DEFAULT_MAX_BINDING_TEMPLATES_PER_SERVICE)); 142 143 props.put(RegistryEngine.PROPNAME_MAX_TMODELS_PER_USER, 144 Integer.toString(RegistryEngine.DEFAULT_MAX_TMODELS_PER_USER)); 145 146 props.put(RegistryEngine.PROPNAME_MAX_ROWS_LIMIT, 147 Integer.toString(RegistryEngine.DEFAULT_MAX_ROWS_LIMIT)); 148 } 149 } 150 catch(IOException ioex) { 151 log.error(ioex.getMessage(),ioex); 152 } 153 154 log.info("Initializing jUDDI components."); 155 156 registry = new RegistryEngine(props); 157 registry.init(); 158 } 159 160 166 public void destroy() 167 { 168 super.destroy(); 169 170 log.info("jUDDI Stopping: Cleaning up existing resources."); 171 172 RegistryEngine registry = RegistryServlet.getRegistry(); 173 if (registry != null) 174 registry.dispose(); 175 } 176 177 180 public static RegistryEngine getRegistry() 181 { 182 return registry; 183 } 184 } | Popular Tags |