public class StandardHost extends ContainerBase implements Host { /** * The Java class name of the default context configuration class * for deployed web applications. */ private String configClass = "org.apache.catalina.startup.ContextConfig"; /** * The Java class name of the default Context implementation class for * deployed web applications. */ private String contextClass = "org.apache.catalina.core.StandardContext"; }
public class ContextConfig implements LifecycleListener { /** * The set of Authenticators that we know how to configure. The key is * the name of the implemented authentication method, and the value is * the fully qualified Java class name of the corresponding Valve. */ protected static final Properties authenticators; /** * The list of JARs that will be skipped when scanning a web application * for JARs. This means the JAR will not be scanned for web fragments, SCIs, * annotations or classes that match @HandlesTypes. */ private static final Set pluggabilityJarsToSkip = new HashSet();
static { // Load our mapping properties for the standard authenticators Properties props = new Properties(); InputStream is = null; try { //加载Authenticators.properties is = ContextConfig.class.getClassLoader().getResourceAsStream( "org/apache/catalina/startup/Authenticators.properties"); if (is != null) { props.load(is); } } authenticators = props; //Load the list of JARS to skip addJarsToSkip(Constants.DEFAULT_JARS_TO_SKIP); addJarsToSkip(Constants.PLUGGABILITY_JARS_TO_SKIP); } /** * 每个Host的默认web.xml配置缓存 */ protected static final Map hostWebXmlCache = new ConcurrentHashMap(); //当容器生命周期变化时,激发 public void lifecycleEvent(LifecycleEvent event) {
// Identify the context we are associated with try { //获取Context context = (Context) event.getLifecycle(); }
if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) { //开始配置 configureStart(); } else if (event.getType().equals(Lifecycle.BEFORE_START_EVENT)) { beforeStart(); } else if (event.getType().equals(Lifecycle.AFTER_START_EVENT)) { //context设置docBase if (originalDocBase != null) { context.setDocBase(originalDocBase); } } else if (event.getType().equals(Lifecycle.CONFIGURE_STOP_EVENT)) { configureStop(); } else if (event.getType().equals(Lifecycle.AFTER_INIT_EVENT)) { //初始化 init(); } else if (event.getType().equals(Lifecycle.AFTER_DESTROY_EVENT)) { destroy(); } //处理Context的AFTER_INIT_EVENT事件 protected void init() { // Called from StandardContext.init() //创建一个解析Context.xml的Digester Digester contextDigester = createContextDigester(); contextDigester.getParser(); if (log.isDebugEnabled()) log.debug(sm.getString("contextConfig.init")); context.setConfigured(false); ok = true; //解析Context.xml文件 contextConfig(contextDigester); createWebXmlDigester(context.getXmlNamespaceAware(), context.getXmlValidation()); } //获取Context.xml,与Digester关联 protected void contextConfig(Digester digester) {
// Open the default context.xml file, if it exists if( defaultContextXml==null && context instanceof StandardContext ) { defaultContextXml = ((StandardContext)context).getDefaultContextXml(); } // set the default if we don't have any overrides if( defaultContextXml==null ) getDefaultContextXml();
if (!context.getOverride()) { File defaultContextFile = new File(defaultContextXml); if (!defaultContextFile.isAbsolute()) { defaultContextFile =new File(getBaseDir(), defaultContextXml); } if (defaultContextFile.exists()) { try { URL defaultContextUrl = defaultContextFile.toURI().toURL(); processContextConfig(digester, defaultContextUrl); } catch (MalformedURLException e) { log.error(sm.getString( "contextConfig.badUrl", defaultContextFile), e); } }
if ((context instanceof StandardContext) && ((StandardContext) context).getAntiResourceLocking()) {
Host host = (Host) context.getParent(); String appBase = host.getAppBase(); String docBase = context.getDocBase(); originalDocBase = docBase; File docBaseFile = new File(docBase); if (!docBaseFile.isAbsolute()) { File file = new File(appBase); if (!file.isAbsolute()) { file = new File(getBaseDir(), appBase); } docBaseFile = new File(file, docBase); } String path = context.getPath(); ContextName cn = new ContextName(path, context.getWebappVersion()); docBase = cn.getBaseName(); if (originalDocBase.toLowerCase(Locale.ENGLISH).endsWith(".war")) { antiLockingDocBase = new File( System.getProperty("java.io.tmpdir"), deploymentCount++ + "-" + docBase + ".war"); } else { antiLockingDocBase = new File( System.getProperty("java.io.tmpdir"), deploymentCount++ + "-" + docBase); } antiLockingDocBase = antiLockingDocBase.getAbsoluteFile();
if (log.isDebugEnabled()) log.debug("Anti locking context[" + context.getName() + "] setting docBase to " + antiLockingDocBase.getPath());
// Cleanup just in case an old deployment is lying around ExpandWar.delete(antiLockingDocBase); if (ExpandWar.copy(docBaseFile, antiLockingDocBase)) { context.setDocBase(antiLockingDocBase.getPath()); } } }
protected synchronized void configureStart() { // Called from StandardContext.start() if (log.isDebugEnabled()) log.debug(sm.getString("contextConfig.start")); //扫描Web.xml文件,应用到web webConfig(); if (!context.getIgnoreAnnotations()) { //处理Listener,Filter,Servet的class,field,method, //EJB,JSR 250类注解问题,@Resource等注解 applicationAnnotationsConfig(); } if (ok) { //配置安全角色信息 validateSecurityRoles(); } // Configure an authenticator if we need one if (ok) authenticatorConfig(); // Dump the contents of this pipeline if requested if ((log.isDebugEnabled()) && (context instanceof ContainerBase)) { log.debug("Pipeline Configuration:"); Pipeline pipeline = ((ContainerBase) context).getPipeline(); Valve valves[] = null; if (pipeline != null) valves = pipeline.getValves(); if (valves != null) { for (int i = 0; i < valves.length; i++) { log.debug(" " + valves[i].getInfo()); } } log.debug("======================"); } // Make our application available if no problems were encountered if (ok) context.setConfigured(true); else { log.error(sm.getString("contextConfig.unavailable")); context.setConfigured(false); }
// Step 1. Identify all the JARs packaged with the application // If the JARs have a web-fragment.xml it will be parsed at this // point. Map fragments = processJarsForWebFragments(webXml);
// Step 2. Order the fragments. Set orderedFragments = null; orderedFragments = WebXml.orderWebFragments(webXml, fragments, sContext);
// Step 3. Look for ServletContainerInitializer implementations if (ok) { processServletContainerInitializers(); }
if (!webXml.isMetadataComplete() || typeInitializerMap.size() > 0) { // Step 4. Process /WEB-INF/classes for annotations if (ok) { // Hack required by Eclipse's "serve modules without // publishing" feature since this backs WEB-INF/classes by // multiple locations rather than one. NamingEnumeration listBindings = null; try { try { listBindings = context.getResources().listBindings( "/WEB-INF/classes"); } while (listBindings != null && listBindings.hasMoreElements()) { Binding binding = listBindings.nextElement(); if (binding.getObject() instanceof FileDirContext) { File webInfClassDir = new File( ((FileDirContext) binding.getObject()).getDocBase()); processAnnotationsFile(webInfClassDir, webXml, webXml.isMetadataComplete()); } else { String resource = "/WEB-INF/classes/" + binding.getName(); try { URL url = sContext.getResource(resource); processAnnotationsUrl(url, webXml, webXml.isMetadataComplete()); } } } } }
// Step 5. Process JARs for annotations - only need to process // those fragments we are going to use if (ok) { processAnnotations( orderedFragments, webXml.isMetadataComplete()); }
// Cache, if used, is no longer required so clear it javaClassCache.clear(); }
if (!webXml.isMetadataComplete()) { // Step 6. Merge web-fragment.xml files into the main web.xml // file. if (ok) { ok = webXml.merge(orderedFragments); }
// Step 7. Apply global defaults // Have to merge defaults before JSP conversion since defaults // provide JSP servlet definition. webXml.merge(defaults);
// Step 8. Convert explicitly mentioned jsps to servlets if (ok) { convertJsps(webXml); }
// Step 9. Apply merged web.xml to Context if (ok) { webXml.configureContext(context); } } else { webXml.merge(defaults); convertJsps(webXml); webXml.configureContext(context); }
// Step 9a. Make the merged web.xml available to other // components, specifically Jasper, to save those components // from having to re-generate it. // TODO Use a ServletContainerInitializer for Jasper String mergedWebXml = webXml.toXml(); sContext.setAttribute( org.apache.tomcat.util.scan.Constants.MERGED_WEB_XML, mergedWebXml); if (context.getLogEffectiveWebXml()) { log.info("web.xml:\n" + mergedWebXml); }
// Always need to look for static resources // Step 10. Look for static resources packaged in JARs if (ok) { // Spec does not define an order. // Use ordered JARs followed by remaining JARs Set resourceJars = new LinkedHashSet(); for (WebXml fragment : orderedFragments) { resourceJars.add(fragment); } for (WebXml fragment : fragments.values()) { if (!resourceJars.contains(fragment)) { resourceJars.add(fragment); } } processResourceJARs(resourceJars); // See also StandardContext.resourcesStart() for // WEB-INF/classes/META-INF/resources configuration }
// Step 11. Apply the ServletContainerInitializer config to the // context if (ok) { for (Map.Entry Set>> entry : initializerClassMap.entrySet()) { if (entry.getValue().isEmpty()) { context.addServletContainerInitializer( entry.getKey(), null); } else { context.addServletContainerInitializer( entry.getKey(), entry.getValue()); } } } }
// Process the application classes annotations, if it exists. protected void applicationAnnotationsConfig() { long t1=System.currentTimeMillis(); WebAnnotationSet.loadApplicationAnnotations(context); long t2=System.currentTimeMillis(); if (context instanceof StandardContext) { ((StandardContext) context).setStartupTime(t2-t1+ ((StandardContext) context).getStartupTime()); } }
Wrapper wrapper = null; Class> classClass = null; Container[] children = context.findChildren(); for (int i = 0; i < children.length; i++) { if (children[i] instanceof Wrapper) {
wrapper = (Wrapper) children[i]; if (wrapper.getServletClass() == null) { continue; } classClass = Introspection.loadClass(context, wrapper.getServletClass()); if (classClass == null) { continue; } //处理Servet的class,field,method,的注解 loadClassAnnotation(context, classClass); loadFieldsAnnotation(context, classClass); loadMethodsAnnotation(context, classClass); /* Process RunAs annotation which can be only on servlets. * Ref JSR 250, equivalent to the run-as element in * the deployment descriptor */ RunAs annotation = classClass.getAnnotation(RunAs.class); if (annotation != null) { wrapper.setRunAs(annotation.value()); } } }
} //处理Listener的class,field,method,的注解 protected static void loadClassAnnotation(Context context, Class> classClass) { /* Process Resource annotation. * Ref JSR 250 */ { Resource annotation = classClass.getAnnotation(Resource.class); if (annotation != null) { addResource(context, annotation); } } /* Process Resources annotation. * Ref JSR 250 */ { //@Resource Resources annotation = classClass.getAnnotation(Resources.class); if (annotation != null && annotation.value() != null) { for (Resource resource : annotation.value()) { addResource(context, resource); } } } /* Process EJB annotation. * Ref JSR 224, equivalent to the ejb-ref or ejb-local-ref * element in the deployment descriptor. { //@EJB EJB annotation = classClass.getAnnotation(EJB.class); if (annotation != null) {
if ((annotation.mappedName().length() == 0) || annotation.mappedName().equals("Local")) {
} } } */ /* Process WebServiceRef annotation. * Ref JSR 224, equivalent to the service-ref element in * the deployment descriptor. * The service-ref registration is not implemented { //@WebServiceRef WebServiceRef annotation = classClass .getAnnotation(WebServiceRef.class); if (annotation != null) { ContextService service = new ContextService();
/** * Representation of common elements of web.xml and web-fragment.xml. Provides * a repository for parsed data before the elements are merged. * Validation is spread between multiple classes: * The digester checks for structural correctness (eg single login-config) * This class checks for invalid duplicates (eg filter/servlet names) * StandardContext will check validity of values (eg URL formats etc) */ public class WebXml { // context-param // TODO: description (multiple with language) is ignored private Map contextParams = new HashMap(); public void addContextParam(String param, String value) { contextParams.put(param, value); } public Map getContextParams() { return contextParams; }
// filter // TODO: Should support multiple description elements with language // TODO: Should support multiple display-name elements with language // TODO: Should support multiple icon elements // TODO: Description for init-param is ignored private Map filters = new LinkedHashMap(); //添加Filter public void addFilter(FilterDef filter) { if (filters.containsKey(filter.getFilterName())) { // Filter names must be unique within a web(-fragment).xml throw new IllegalArgumentException( sm.getString("webXml.duplicateFilter", filter.getFilterName())); } filters.put(filter.getFilterName(), filter); } public Map getFilters() { return filters; }
// filter-mapping private Set filterMaps = new LinkedHashSet(); private Set filterMappingNames = new HashSet(); //添加FilterMaping public void addFilterMapping(FilterMap filterMap) { filterMaps.add(filterMap); filterMappingNames.add(filterMap.getFilterName()); } public Set getFilterMappings() { return filterMaps; }
// listener // TODO: description (multiple with language) is ignored // TODO: display-name (multiple with language) is ignored // TODO: icon (multiple) is ignored private Set listeners = new LinkedHashSet(); //添加Listeners public void addListener(String className) { listeners.add(className); } public Set getListeners() { return listeners; }
// servlet // TODO: description (multiple with language) is ignored // TODO: display-name (multiple with language) is ignored // TODO: icon (multiple) is ignored // TODO: init-param/description (multiple with language) is ignored // TODO: security-role-ref/description (multiple with language) is ignored private Map servlets = new HashMap(); //添加Servlet public void addServlet(ServletDef servletDef) { servlets.put(servletDef.getServletName(), servletDef); if (overridable) { servletDef.setOverridable(overridable); } } public Map getServlets() { return servlets; }
// servlet-mapping private Map servletMappings = new HashMap(); private Set servletMappingNames = new HashSet(); //添加Servlet-mapping public void addServletMapping(String urlPattern, String servletName) { String oldServletName = servletMappings.put(urlPattern, servletName); if (oldServletName != null) { // Duplicate mapping. As per clarification from the Servlet EG, // deployment should fail. throw new IllegalArgumentException(sm.getString( "webXml.duplicateServletMapping", oldServletName, servletName, urlPattern)); } servletMappingNames.add(servletName); } public Map getServletMappings() { return servletMappings; }
// session-config // Digester will check there is only one of these private SessionConfig sessionConfig = new SessionConfig(); public void setSessionConfig(SessionConfig sessionConfig) { this.sessionConfig = sessionConfig; } public SessionConfig getSessionConfig() { return sessionConfig; }
// mime-mapping private Map mimeMappings = new HashMap(); public void addMimeMapping(String extension, String mimeType) { mimeMappings.put(extension, mimeType); } public Map getMimeMappings() { return mimeMappings; } // welcome-file-list private Set welcomeFiles = new LinkedHashSet(); public void addWelcomeFile(String welcomeFile) { if (replaceWelcomeFiles) { welcomeFiles.clear(); replaceWelcomeFiles = false; } welcomeFiles.add(welcomeFile); } public Set getWelcomeFiles() { return welcomeFiles; }
// error-page private Map errorPages = new HashMap(); public void addErrorPage(ErrorPage errorPage) { errorPages.put(errorPage.getName(), errorPage); } public Map getErrorPages() { return errorPages; }
// Digester will check there is only one jsp-config // jsp-config/taglib or taglib (2.3 and earlier) private Map taglibs = new HashMap(); public void addTaglib(String uri, String location) { if (taglibs.containsKey(uri)) { // Taglib URIs must be unique within a web(-fragment).xml throw new IllegalArgumentException( sm.getString("webXml.duplicateTaglibUri", uri)); } taglibs.put(uri, location); } public Map getTaglibs() { return taglibs; }
// jsp-config/jsp-property-group private Set jspPropertyGroups = new LinkedHashSet(); public void addJspPropertyGroup(JspPropertyGroup propertyGroup) { jspPropertyGroups.add(propertyGroup); } public Set getJspPropertyGroups() { return jspPropertyGroups; }
// security-constraint // TODO: Should support multiple display-name elements with language // TODO: Should support multiple description elements with language private Set securityConstraints = new HashSet(); public void addSecurityConstraint(SecurityConstraint securityConstraint) { securityConstraints.add(securityConstraint); } public Set getSecurityConstraints() { return securityConstraints; }
// login-config // Digester will check there is only one of these private LoginConfig loginConfig = null; public void setLoginConfig(LoginConfig loginConfig) { this.loginConfig = loginConfig; } public LoginConfig getLoginConfig() { return loginConfig; }
// security-role // TODO: description (multiple with language) is ignored private Set securityRoles = new HashSet(); public void addSecurityRole(String securityRole) { securityRoles.add(securityRole); } public Set getSecurityRoles() { return securityRoles; }
// resource-ref // TODO: Should support multiple description elements with language private Map resourceRefs = new HashMap(); public void addResourceRef(ContextResource resourceRef) { if (resourceRefs.containsKey(resourceRef.getName())) { // resource-ref names must be unique within a web(-fragment).xml throw new IllegalArgumentException( sm.getString("webXml.duplicateResourceRef", resourceRef.getName())); } resourceRefs.put(resourceRef.getName(), resourceRef); } public Map getResourceRefs() { return resourceRefs; }
// resource-env-ref // TODO: Should support multiple description elements with language private Map resourceEnvRefs = new HashMap(); public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) { if (resourceEnvRefs.containsKey(resourceEnvRef.getName())) { // resource-env-ref names must be unique within a web(-fragment).xml throw new IllegalArgumentException( sm.getString("webXml.duplicateResourceEnvRef", resourceEnvRef.getName())); } resourceEnvRefs.put(resourceEnvRef.getName(), resourceEnvRef); } public Map getResourceEnvRefs() { return resourceEnvRefs; } }
//处理XML的Digester
public class Digester extends DefaultHandler2 { /** * The parameters stack being utilized by CallMethodRule and * CallParamRule rules. */ protected ArrayStack
public class PC {
/**
* 题目:生产者-消费者。
* 同步访问一个数组Integer[10],生产者不断地往数组放入整数1000,数组满时等待;消费者不断地将数组里面的数置零,数组空时等待。
*/
private static final Integer[] val=new Integer[10];
private static
在oracle连接(join)中使用using关键字
34. View the Exhibit and examine the structure of the ORDERS and ORDER_ITEMS tables.
Evaluate the following SQL statement:
SELECT oi.order_id, product_id, order_date
FRO
If i select like this:
SELECT id FROM users WHERE id IN(3,4,8,1);
This by default will select users in this order
1,3,4,8,
I would like to select them in the same order that i put IN() values so:
$(document).ready(
function() {
var flag = true;
$('#changeform').submit(function() {
var projectScValNull = true;
var s ="";
var parent_id = $("#parent_id").v
Mac 在国外很受欢迎,尤其是在 设计/web开发/IT 人员圈子里。普通用户喜欢 Mac 可以理解,毕竟 Mac 设计美观,简单好用,没有病毒。那么为什么专业人士也对 Mac 情有独钟呢?从个人使用经验来看我想有下面几个原因:
1、Mac OS X 是基于 Unix 的
这一点太重要了,尤其是对开发人员,至少对于我来说很重要,这意味着Unix 下一堆好用的工具都可以随手捡到。如果你是个 wi