forked from spring-attic/spring-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
STS-3056: improved performance for annotation processing by caching m…
…etadata reading results
- Loading branch information
1 parent
9a0f264
commit 46deebf
Showing
3 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...g/springframework/ide/eclipse/core/java/classreading/CachingJdtMetadataReaderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012 Spring IDE Developers | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Spring IDE Developers - initial API and implementation | ||
*******************************************************************************/ | ||
package org.springframework.ide.eclipse.core.java.classreading; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.eclipse.jdt.core.IJavaProject; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.core.type.classreading.MetadataReader; | ||
import org.springframework.core.type.classreading.MetadataReaderFactory; | ||
|
||
/** | ||
* @author Martin Lippert | ||
* @since 3.2.0 | ||
*/ | ||
public class CachingJdtMetadataReaderFactory implements MetadataReaderFactory { | ||
|
||
private final JdtMetadataReaderFactory factory; | ||
private final Map<String, MetadataReader> cache = new HashMap<String, MetadataReader>(); | ||
|
||
public CachingJdtMetadataReaderFactory(IJavaProject project) { | ||
this.factory = new JdtMetadataReaderFactory(project); | ||
} | ||
|
||
public MetadataReader getMetadataReader(String className) throws IOException { | ||
synchronized(cache) { | ||
if (!cache.containsKey(className)) { | ||
cache.put(className, factory.getMetadataReader(className)); | ||
} | ||
} | ||
|
||
return cache.get(className); | ||
} | ||
|
||
public MetadataReader getMetadataReader(Resource resource) throws IOException { | ||
throw new JdtMetadataReaderException("'getMetadataReader' is not supported"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters