-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API for extracting all bundle keys from all c10n enabled interfaces (…
…issue #12) * Use reflections library to scan for interfaces annotated with @C10NMessages, and apply bundle key extraction, returning the complete set of all keys. * Added C10NTools class, as the main entry point to tooling API * Refactoring * Added test dependency from tools -> core
- Loading branch information
rodionmoiseev
committed
Nov 24, 2012
1 parent
112f37e
commit cd56809
Showing
18 changed files
with
441 additions
and
117 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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,47 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package c10n.tools; | ||
|
||
import c10n.tools.search.C10NBundleKeySearch; | ||
import c10n.tools.search.SearchModule; | ||
|
||
/** | ||
* @author rodion | ||
*/ | ||
public final class C10NTools { | ||
/** | ||
* <p>Creates new bundle key search implementation instance.</p> | ||
* | ||
* @return bundle key search module implementation (not null) | ||
*/ | ||
public static C10NBundleKeySearch bundleKeySearch() { | ||
return bundleKeySearch(""); | ||
} | ||
|
||
/** | ||
* <p>Creates new bundle key search implementation instance.</p> | ||
* | ||
* @param keyPrefix global bundle key prefix to use (not null) | ||
* @return bundle key search module implementation (not null) | ||
*/ | ||
public static C10NBundleKeySearch bundleKeySearch(String keyPrefix) { | ||
return SearchModule.reflectionsBundleKeySearch(keyPrefix); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
tools/src/main/java/c10n/tools/search/C10NBundleKeySearch.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,41 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package c10n.tools.search; | ||
|
||
import c10n.share.utils.C10NBundleKey; | ||
|
||
/** | ||
* <p>Extracts all c10n bundle keys for a given set of | ||
* c10n interface classes.</p> | ||
* | ||
* @author rodion | ||
*/ | ||
public interface C10NBundleKeySearch { | ||
/** | ||
* <p>Retrieve all c10n bundle keys for inspection, from the current classpath. | ||
* Only the packages starting with the given package prefix(es) will be included | ||
* in search results.</p> | ||
* <p>Packages will be searched recursively into sub-packages, for each prefix.</p> | ||
* | ||
* @param packagePrefixes prefixes of packages to search (not null) | ||
* @return a collection of all matching bundle keys (not null) | ||
*/ | ||
Iterable<C10NBundleKey> findAllKeys(String... packagePrefixes); | ||
} |
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
48 changes: 48 additions & 0 deletions
48
tools/src/main/java/c10n/tools/search/DefaultC10NBundleKeySearch.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,48 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package c10n.tools.search; | ||
|
||
import c10n.C10NMessages; | ||
import c10n.share.utils.BundleKeyUtils; | ||
import c10n.share.utils.C10NBundleKey; | ||
import com.google.common.collect.Lists; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author rodion | ||
*/ | ||
class DefaultC10NBundleKeySearch implements C10NBundleKeySearch { | ||
private final C10NInterfaceSearch c10NInterfaceSearch; | ||
private final String keyPrefix; | ||
|
||
DefaultC10NBundleKeySearch(C10NInterfaceSearch c10NInterfaceSearch, String keyPrefix) { | ||
this.c10NInterfaceSearch = c10NInterfaceSearch; | ||
this.keyPrefix = keyPrefix; | ||
} | ||
|
||
@Override | ||
public Iterable<C10NBundleKey> findAllKeys(String... packagePrefixes) { | ||
List<C10NBundleKey> res = Lists.newArrayList(); | ||
Set<Class<?>> c10nInterfaces = c10NInterfaceSearch.find(C10NMessages.class, packagePrefixes); | ||
return BundleKeyUtils.allBundleKeys(keyPrefix, c10nInterfaces); | ||
} | ||
} |
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
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,34 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package c10n.tools; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
|
||
/** | ||
* @author rodion | ||
*/ | ||
@RunWith(Suite.class) | ||
@Suite.SuiteClasses({ | ||
c10n.AllTests.class, | ||
c10n.tools.search.AllTests.class | ||
}) | ||
public class AllTests { | ||
} |
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,34 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package c10n.tools.search; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
|
||
/** | ||
* @author rodion | ||
*/ | ||
@RunWith(Suite.class) | ||
@Suite.SuiteClasses({ | ||
C10NInterfaceSearchTest.class, | ||
DefaultC10NBundleKeySearchTest.class | ||
}) | ||
public class AllTests { | ||
} |
Oops, something went wrong.