// Call the next filter if there is one if (pos < n) { ApplicationFilterConfigfilterConfig= filters[pos++]; try { Filterfilter= filterConfig.getFilter();
// We fell off the end of the chain -- call the servlet instance try { if (ApplicationDispatcher.WRAP_SAME_OBJECT) { lastServicedRequest.set(request); lastServicedResponse.set(response); }
// Acquire the filter mappings for this Context StandardContextcontext= (StandardContext) wrapper.getParent(); FilterMap filterMaps[] = context.findFilterMaps();
// If there are no filter mappings, we are done if ((filterMaps == null) || (filterMaps.length == 0)) { return filterChain; }
// Acquire the information we will need to match filter mappings DispatcherTypedispatcher= (DispatcherType) request.getAttribute(Globals.DISPATCHER_TYPE_ATTR);
// Add the relevant path-mapped filters to this filter chain for (FilterMap filterMap : filterMaps) { if (!matchDispatcher(filterMap, dispatcher)) { continue; } if (!matchFiltersURL(filterMap, requestPath)) { continue; } ApplicationFilterConfigfilterConfig= (ApplicationFilterConfig) context.findFilterConfig(filterMap.getFilterName()); if (filterConfig == null) { // FIXME - log configuration problem continue; } filterChain.addFilter(filterConfig); }
// Add filters that match on servlet name second for (FilterMap filterMap : filterMaps) { if (!matchDispatcher(filterMap, dispatcher)) { continue; } if (!matchFiltersServlet(filterMap, servletName)) { continue; } ApplicationFilterConfigfilterConfig= (ApplicationFilterConfig) context.findFilterConfig(filterMap.getFilterName()); if (filterConfig == null) { // FIXME - log configuration problem continue; } filterChain.addFilter(filterConfig); }
// Return the completed filter chain return filterChain; }
filterMaps[]属性是从context执行findFilterMaps方法后所返回的
1 2 3 4
@Override public FilterMap[] findFilterMaps() { return filterMaps.asArray(); }
for (inti=0; i < denyList.length; ++i) { Stringdeny= denyList[i]; if (className.startsWith(deny)) { thrownewJSONException("autoType is not support. " + typeName); } }
public Class<?> checkAutoType(String typeName, Class<?> expectClass) { if (typeName == null) { returnnull; }
finalStringclassName= typeName.replace('$', '.');
if (autoTypeSupport || expectClass != null) { for (inti=0; i < acceptList.length; ++i) { Stringaccept= acceptList[i]; if (className.startsWith(accept)) { return TypeUtils.loadClass(typeName, defaultClassLoader); } }
for (inti=0; i < denyList.length; ++i) { Stringdeny= denyList[i]; if (className.startsWith(deny)) { thrownewJSONException("autoType is not support. " + typeName); } } }
if (clazz != null) { if (expectClass != null && !expectClass.isAssignableFrom(clazz)) { thrownewJSONException("type not match. " + typeName + " -> " + expectClass.getName()); }
return clazz; }
if (!autoTypeSupport) { for (inti=0; i < denyList.length; ++i) { Stringdeny= denyList[i]; if (className.startsWith(deny)) { thrownewJSONException("autoType is not support. " + typeName); } } for (inti=0; i < acceptList.length; ++i) { Stringaccept= acceptList[i]; if (className.startsWith(accept)) { clazz = TypeUtils.loadClass(typeName, defaultClassLoader);
if (ClassLoader.class.isAssignableFrom(clazz) // classloader is danger || DataSource.class.isAssignableFrom(clazz) // dataSource can load jdbc driver ) { thrownewJSONException("autoType is not support. " + typeName); }
if (expectClass != null) { if (expectClass.isAssignableFrom(clazz)) { return clazz; } else { thrownewJSONException("type not match. " + typeName + " -> " + expectClass.getName()); } } }
if (!autoTypeSupport) { thrownewJSONException("autoType is not support. " + typeName); }
// The translet needs to keep a reference to all its auxiliary // class to prevent the GC from collecting them AbstractTranslettranslet= (AbstractTranslet) _class[_transletIndex].newInstance(); translet.postInitialization(); translet.setTemplates(this); translet.setServicesMechnism(_useServicesMechanism); translet.setAllowedProtocols(_accessExternalStylesheet); if (_auxClasses != null) { translet.setAuxiliaryClasses(_auxClasses); }
if (ref != null) { Stringf= ref.getFactoryClassName(); if (f != null) { // if reference identifies a factory, use exclusively
factory = getObjectFactoryFromReference(ref, f); if (factory != null) { return factory.getObjectInstance(ref, name, nameCtx, environment); } // No factory found, so return original refInfo. // Will reach this point if factory class is not in // class path and reference does not contain a URL for it return refInfo;
} else { // if reference has no factory, check for addresses // containing URLs
// Try to use current class loader try { clas = helper.loadClass(factoryName); } catch (ClassNotFoundException e) { // ignore and continue // e.printStackTrace(); } // All other exceptions are passed up.
// Not in class path; try to use codebase String codebase; if (clas == null && (codebase = ref.getFactoryClassLocation()) != null) { try { clas = helper.loadClass(factoryName, codebase); } catch (ClassNotFoundException e) { } }
if (ref != null) { Stringf= ref.getFactoryClassName(); if (f != null) { // if reference identifies a factory, use exclusively
factory = getObjectFactoryFromReference(ref, f); if (factory != null) { return factory.getObjectInstance(ref, name, nameCtx, environment); } // No factory found, so return original refInfo. // Will reach this point if factory class is not in // class path and reference does not contain a URL for it return refInfo;
// Try to use current class loader try { clas = helper.loadClass(factoryName); } catch (ClassNotFoundException e) { // ignore and continue // e.printStackTrace(); } // All other exceptions are passed up.
// Not in class path; try to use codebase String codebase; if (clas == null && (codebase = ref.getFactoryClassLocation()) != null) { try { clas = helper.loadClass(factoryName, codebase); } catch (ClassNotFoundException e) { } }
staticvoidregisterRefs(Endpoint ep, List<LiveRef> refs) { /* * Look up the given endpoint and register the refs with it. * The retrieved entry may get removed from the global endpoint * table before EndpointEntry.registerRefs() is able to acquire * its lock; in this event, it returns false, and we loop and * try again. */ EndpointEntry epEntry; do { epEntry = EndpointEntry.lookup(ep); } while (!epEntry.registerRefs(refs)); }
if (in instanceof ConnectionInputStream) { ConnectionInputStreamstream= (ConnectionInputStream)in; // save ref to send "dirty" call after all args/returns // have been unmarshaled. stream.saveRef(ref); if (isResultStream) { // set flag in stream indicating that remote objects were // unmarshaled. A DGC ack should be sent by the transport. stream.setAckNeeded(); } } else { DGCClient.registerRefs(ep, Arrays.asList(newLiveRef[] { ref })); }
if (in instanceof ConnectionInputStream) { ConnectionInputStreamstream= (ConnectionInputStream)in; // save ref to send "dirty" call after all args/returns // have been unmarshaled. stream.saveRef(ref); if (isResultStream) { // set flag in stream indicating that remote objects were // unmarshaled. A DGC ack should be sent by the transport. stream.setAckNeeded(); } } else { DGCClient.registerRefs(ep, Arrays.asList(newLiveRef[] { ref })); }