Examples of FilterDef


Examples of org.apache.tomcat.util.descriptor.web.FilterDef

    }


    @Override
    public FilterRegistration getFilterRegistration(String filterName) {
        FilterDef filterDef = context.findFilterDef(filterName);
        if (filterDef == null) {
            return null;
        }
        return new ApplicationFilterRegistration(filterDef, context);
    }
View Full Code Here

Examples of org.apache.tomcat.util.descriptor.web.FilterDef

        }
        if (filterName == null) {
            // classname is default filterName as annotation has no name!
            filterName = className;
        }
        FilterDef filterDef = fragment.getFilters().get(filterName);
        FilterMap filterMap = new FilterMap();

        boolean isWebXMLfilterDef;
        if (filterDef == null) {
            filterDef = new FilterDef();
            filterDef.setFilterName(filterName);
            filterDef.setFilterClass(className);
            isWebXMLfilterDef = false;
        } else {
            isWebXMLfilterDef = true;
        }

        boolean urlPatternsSet = false;
        boolean servletNamesSet = false;
        boolean dispatchTypesSet = false;
        String[] urlPatterns = null;

        for (ElementValuePair evp : evps) {
            String name = evp.getNameString();
            if ("value".equals(name) || "urlPatterns".equals(name)) {
                if (urlPatternsSet) {
                    throw new IllegalArgumentException(sm.getString(
                            "contextConfig.urlPatternValue", className));
                }
                urlPatterns = processAnnotationsStringArray(evp.getValue());
                urlPatternsSet = urlPatterns.length > 0;
                for (String urlPattern : urlPatterns) {
                    filterMap.addURLPattern(urlPattern);
                }
            } else if ("servletNames".equals(name)) {
                String[] servletNames = processAnnotationsStringArray(evp
                        .getValue());
                servletNamesSet = servletNames.length > 0;
                for (String servletName : servletNames) {
                    filterMap.addServletName(servletName);
                }
            } else if ("dispatcherTypes".equals(name)) {
                String[] dispatcherTypes = processAnnotationsStringArray(evp
                        .getValue());
                dispatchTypesSet = dispatcherTypes.length > 0;
                for (String dispatcherType : dispatcherTypes) {
                    filterMap.setDispatcher(dispatcherType);
                }
            } else if ("description".equals(name)) {
                if (filterDef.getDescription() == null) {
                    filterDef.setDescription(evp.getValue().stringifyValue());
                }
            } else if ("displayName".equals(name)) {
                if (filterDef.getDisplayName() == null) {
                    filterDef.setDisplayName(evp.getValue().stringifyValue());
                }
            } else if ("largeIcon".equals(name)) {
                if (filterDef.getLargeIcon() == null) {
                    filterDef.setLargeIcon(evp.getValue().stringifyValue());
                }
            } else if ("smallIcon".equals(name)) {
                if (filterDef.getSmallIcon() == null) {
                    filterDef.setSmallIcon(evp.getValue().stringifyValue());
                }
            } else if ("asyncSupported".equals(name)) {
                if (filterDef.getAsyncSupported() == null) {
                    filterDef
                            .setAsyncSupported(evp.getValue().stringifyValue());
                }
            } else if ("initParams".equals(name)) {
                Map<String, String> initParams = processAnnotationWebInitParams(evp
                        .getValue());
                if (isWebXMLfilterDef) {
                    Map<String, String> webXMLInitParams = filterDef
                            .getParameterMap();
                    for (Map.Entry<String, String> entry : initParams
                            .entrySet()) {
                        if (webXMLInitParams.get(entry.getKey()) == null) {
                            filterDef.addInitParameter(entry.getKey(), entry
                                    .getValue());
                        }
                    }
                } else {
                    for (Map.Entry<String, String> entry : initParams
                            .entrySet()) {
                        filterDef.addInitParameter(entry.getKey(), entry
                                .getValue());
                    }
                }

            }
View Full Code Here

Examples of org.apache.tomcat.util.descriptor.web.FilterDef

     */
    @Override
    public FilterDef[] findFilterDefs() {

        synchronized (filterDefs) {
            FilterDef results[] = new FilterDef[filterDefs.size()];
            return (filterDefs.values().toArray(results));
        }

    }
View Full Code Here

Examples of org.apache.tomcat.util.descriptor.web.FilterDef

            throw new IllegalStateException(
                    sm.getString("applicationContext.addFilter.ise",
                            getContextPath()));
        }

        FilterDef filterDef = context.findFilterDef(filterName);

        // Assume a 'complete' FilterRegistration is one that has a class and
        // a name
        if (filterDef == null) {
            filterDef = new FilterDef();
            filterDef.setFilterName(filterName);
            context.addFilterDef(filterDef);
        } else {
            if (filterDef.getFilterName() != null &&
                    filterDef.getFilterClass() != null) {
                return null;
            }
        }

        if (filter == null) {
            filterDef.setFilterClass(filterClass);
        } else {
            filterDef.setFilterClass(filter.getClass().getName());
            filterDef.setFilter(filter);
        }

        return new ApplicationFilterRegistration(filterDef, context);
    }
View Full Code Here

Examples of org.apache.tomcat.util.descriptor.web.FilterDef

    }


    @Override
    public FilterRegistration getFilterRegistration(String filterName) {
        FilterDef filterDef = context.findFilterDef(filterName);
        if (filterDef == null) {
            return null;
        }
        return new ApplicationFilterRegistration(filterDef, context);
    }
View Full Code Here

Examples of org.hibernate.annotations.FilterDef

      entityBinder.addFilter(filterAnn);
    }
  }

  private static void bindFilterDefs(XAnnotatedElement annotatedElement, Mappings mappings) {
    FilterDef defAnn = annotatedElement.getAnnotation( FilterDef.class );
    FilterDefs defsAnn = annotatedElement.getAnnotation( FilterDefs.class );
    if ( defAnn != null ) {
      bindFilterDef( defAnn, mappings );
    }
    if ( defsAnn != null ) {
View Full Code Here

Examples of org.hibernate.annotations.FilterDef

    return classesToProcess;
  }

  private static void bindFilterDefs(XAnnotatedElement annotatedElement, ExtendedMappings mappings) {
    FilterDef defAnn = annotatedElement.getAnnotation( FilterDef.class );
    FilterDefs defsAnn = annotatedElement.getAnnotation( FilterDefs.class );
    if ( defAnn != null ) {
      bindFilterDef( defAnn, mappings );
    }
    if ( defsAnn != null ) {
View Full Code Here

Examples of org.hibernate.search.engine.FilterDef

  private void buildFilters() {
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    if ( filterDefinitions != null && filterDefinitions.size() > 0 ) {
      ChainedFilter chainedFilter = new ChainedFilter();
      for ( FullTextFilterImpl filterDefinition : filterDefinitions.values() ) {
        FilterDef def = searchFactoryImplementor.getFilterDefinition( filterDefinition.getName() );
        Class implClass = def.getImpl();
        Object instance;
        try {
          instance = implClass.newInstance();
        }
        catch (InstantiationException e) {
          throw new SearchException( "Unable to create @FullTextFilterDef: " + def.getImpl(), e );
        }
        catch (IllegalAccessException e) {
          throw new SearchException( "Unable to create @FullTextFilterDef: " + def.getImpl(), e );
        }
        for ( Map.Entry<String, Object> entry : filterDefinition.getParameters().entrySet() ) {
          def.invoke( entry.getKey(), instance, entry.getValue() );
        }
        if ( def.isCache() && def.getKeyMethod() == null && filterDefinition.getParameters().size() > 0 ) {
          throw new SearchException("Filter with parameters and no @Key method: " + filterDefinition.getName() );
        }
        FilterKey key = null;
        if ( def.isCache() ) {
          if ( def.getKeyMethod() == null ) {
            key = new FilterKey( ) {
              public int hashCode() {
                return getImpl().hashCode();
              }

              public boolean equals(Object obj) {
                if ( ! ( obj instanceof FilterKey ) ) return false;
                FilterKey that = (FilterKey) obj;
                return this.getImpl().equals( that.getImpl() );
              }
            };
          }
          else {
            try {
              key = (FilterKey) def.getKeyMethod().invoke( instance );
            }
            catch (IllegalAccessException e) {
              throw new SearchException("Unable to access @Key method: "
                  + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
            }
            catch (InvocationTargetException e) {
              throw new SearchException("Unable to access @Key method: "
                  + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
            }
            catch (ClassCastException e) {
              throw new SearchException("@Key method does not return FilterKey: "
                  + def.getImpl().getName() + "." + def.getKeyMethod().getName() );
            }
          }
          key.setImpl( def.getImpl() );
        }

        Filter filter = def.isCache() ?
            searchFactoryImplementor.getFilterCachingStrategy().getCachedFilter( key ) :
            null;
        if (filter == null) {
          if ( def.getFactoryMethod() != null ) {
            try {
              filter = (Filter) def.getFactoryMethod().invoke( instance );
            }
            catch (IllegalAccessException e) {
              throw new SearchException("Unable to access @Factory method: "
                  + def.getImpl().getName() + "." + def.getFactoryMethod().getName() );
            }
            catch (InvocationTargetException e) {
              throw new SearchException("Unable to access @Factory method: "
                  + def.getImpl().getName() + "." + def.getFactoryMethod().getName() );
            }
            catch (ClassCastException e) {
              throw new SearchException("@Key method does not return a org.apache.lucene.search.Filter class: "
                  + def.getImpl().getName() + "." + def.getFactoryMethod().getName() );
            }
          }
          else {
            try {
              filter = (Filter) instance;
            }
            catch (ClassCastException e) {
              throw new SearchException("@Key method does not return a org.apache.lucene.search.Filter class: "
                  + def.getImpl().getName() + "." + def.getFactoryMethod().getName() );
            }
          }
          if ( def.isCache() ) searchFactoryImplementor.getFilterCachingStrategy().addCachedFilter( key, filter );
        }
        chainedFilter.addFilter( filter );
      }
      if ( filter != null ) chainedFilter.addFilter( filter );
      filter = chainedFilter;
View Full Code Here

Examples of org.hibernate.search.engine.FilterDef

    FullTextFilterImpl filterDefinition = filterDefinitions.get( name );
    if ( filterDefinition != null ) return filterDefinition;

    filterDefinition = new FullTextFilterImpl();
    filterDefinition.setName( name );
    FilterDef filterDef = getSearchFactoryImplementor().getFilterDefinition( name );
    if (filterDef == null) {
      throw new SearchException("Unkown @FullTextFilter: " + name);
    }
    filterDefinitions.put(name, filterDefinition);
    return filterDefinition;
View Full Code Here

Examples of org.hibernate.search.engine.FilterDef

    if ( filterDefinitions.containsKey( defAnn.name() ) ) {
      throw new SearchException("Multiple definition of @FullTextFilterDef.name=" + defAnn.name() + ": "
          + mappedXClass.getName() );
    }

    FilterDef filterDef = new FilterDef(defAnn);
    try {
      filterDef.getImpl().newInstance();
    }
    catch (IllegalAccessException e) {
      throw new SearchException("Unable to create Filter class: " + filterDef.getImpl().getName(), e);
    }
    catch (InstantiationException e) {
      throw new SearchException("Unable to create Filter class: " + filterDef.getImpl().getName(), e);
    }
    for ( Method method : filterDef.getImpl().getMethods() ) {
      if ( method.isAnnotationPresent( Factory.class ) ) {
        if ( filterDef.getFactoryMethod() != null ) {
          throw new SearchException("Multiple @Factory methods found" + defAnn.name() + ": "
              + filterDef.getImpl().getName() + "." + method.getName() );
        }
        if ( !method.isAccessible() ) method.setAccessible( true );
        filterDef.setFactoryMethod( method );
      }
      if ( method.isAnnotationPresent( Key.class ) ) {
        if ( filterDef.getKeyMethod() != null ) {
          throw new SearchException("Multiple @Key methods found" + defAnn.name() + ": "
              + filterDef.getImpl().getName() + "." + method.getName() );
        }
        if ( !method.isAccessible() ) method.setAccessible( true );
        filterDef.setKeyMethod( method );
      }

      String name = method.getName();
      if ( name.startsWith( "set" ) && method.getParameterTypes().length == 1 ) {
        filterDef.addSetter( Introspector.decapitalize( name.substring( 3 ) ), method );
      }
    }
    filterDefinitions.put( defAnn.name(), filterDef );
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.