Marcus Schulte etluchs

View InProfile.java
1 2 3 4 5 6
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
@Target({ElementType.TYPE})
public @interface InProfile {
DbProfile value();
}
View DbProfile.java
1 2 3 4 5 6 7 8 9 10
public enum DbProfile {
IN_MEMORY_DB, JEE_DATASOURCE;
public AnnotationLiteral<InProfile> literal(){
return new InProfileLiteral();
}
class InProfileLiteral extends AnnotationLiteral<InProfile> implements InProfile {
 
@Override
View SampleModuleConfigurationSelector.java
1 2 3 4 5
@Produces
public SampleSvc sampleSvc(@Any Instance<SampleSvc> candidates) {
return candidates.select( activeProfile.literal() ).get();
}
View TestParser.scala
1 2 3 4 5 6 7
class TestParser extends JavaTokenParsers with CompletingParser {
 
def propertyPath: Parser[Any] = "name" | ( "child"~opt("."~childProperties) ) | "chunk"
 
def childProperties: Parser[Any] = "name" | "toys" | "tolerance"
 
}
View App.scala
1 2 3 4 5 6 7 8 9 10
object CompletingParserTestApp extends TestParser with App {
println( "Type something and hit enter" );
 
var input = ""
do {
input = readLine();
parseAll( propertyPath, input ) match {
case s : Success[Any] => println ( "valid, parsed as "+ s.get)
case MissingCompletionOrFailure( completions, msg, in)
=> if ( completions.isEmpty )
View CompletingParser.scala
1 2 3 4 5 6 7 8 9
import util.parsing.combinator.RegexParsers
 
 
/**
* A trait to make parsers for string literals return a nice list of possible completions if
* we're at the end of the input.
*
* @author Marcus Schulte
*/
Something went wrong with that request. Please try again.