Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.codehaus.mojo.gwt.webxml;
  
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
  *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 
 import java.util.Map;
 import java.util.Set;
 
 
The goal is to find classed annotated with com.google.gwt.user.client.rpc.RemoteServiceRelativePath to generated ServletDescriptor

Author(s):
Olivier Lamy
Since:
2.1.0-1
Plexus.component:
role="org.codehaus.mojo.gwt.webxml.ServletAnnotationFinder"
 
 public class ServletAnnotationFinder
     extends AbstractLogEnabled
 {
 
     public ServletAnnotationFinder()
     {
         // no op
     }

    

Parameters:
packageName
Returns:
cannot return null</null>
Throws:
java.io.IOException
 
     public Set<ServletDescriptorfindServletsString packageNameString startPathClassLoader classLoader )
         throws IOException
     {
         Set<ServletDescriptorservlets = new LinkedHashSet<ServletDescriptor>();
         PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver = new PathMatchingResourcePatternResolver(
                                                                                                                            classLoader );
         String patternFinder = .
             + ClassUtils.convertClassNameToResourcePathpackageName ) + "/**/*.class";
 
         Resource[] resources = pathMatchingResourcePatternResolver.getResourcespatternFinder );
         SimpleMetadataReaderFactory simpleMetadataReaderFactory = new SimpleMetadataReaderFactory();
         getLogger().debug"springresource " + resources.length + " for pattern " + patternFinder );
         for ( Resource resource : resources )
         {
             getLogger().debug"springresource " + resource.getFilename() );
             MetadataReader metadataReader = simpleMetadataReaderFactory.getMetadataReaderresource );
 
             if ( metadataReader.getAnnotationMetadata().hasAnnotationRemoteServiceRelativePath.class.getName() ) )
             {
                 Map<StringObjectannotationAttributes = metadataReader.getAnnotationMetadata()
                     .getAnnotationAttributesRemoteServiceRelativePath.class.getName() );
                 getLogger().debug"found RemoteServiceRelativePath annotation for class "
                                        + metadataReader.getClassMetadata().getClassName() );
                 if ( StringUtils.isNotBlankstartPath ) )
                 {
                     StringBuilder path = new StringBuilder();
                     if ( !startPath.startsWith"/" ) )
                     {
                         path.append'/' );
                     }
                     path.appendstartPath );
                     String annotationPathValue = (StringannotationAttributes.get"value" );
                     if ( !annotationPathValue.startsWith"/" ) )
                     {
                         path.append'/' );
                     }
                     path.appendannotationPathValue );
                     ServletDescriptor servletDescriptor = new ServletDescriptorpath.toString(), metadataReader
                         .getClassMetadata().getClassName() );
                    servlets.addservletDescriptor );
                }
                else
                {
                    StringBuilder path = new StringBuilder();
                    String annotationPathValue = (StringannotationAttributes.get"value" );
                    if ( !annotationPathValue.startsWith"/" ) )
                    {
                        path.append'/' );
                    }
                    path.appendannotationPathValue );
                    ServletDescriptor servletDescriptor = new ServletDescriptorpath.toString(), metadataReader
                        .getClassMetadata().getClassName() );
                    servlets.addservletDescriptor );
                }
            }
        }
        return servlets;
    }
New to GrepCode? Check out our FAQ X