@Override public SpicyPlate spicyPlate( SpicyContext globalContext, String template ) { NullArgumentException.ensureNotNull( "Global context", globalContext ); NullArgumentException.ensureNotEmpty( "Template", template ); ST st = new ST( template, mark, mark ); return new STSpicyPlate( globalContext, st ); }
@Inject @SuppressWarnings( "CallToThreadStartDuringObjectConstruction" ) public DefaultWorkQueue( @Named( NAME ) String name, @Named( SIZE ) Integer size ) { NullArgumentException.ensureNotEmpty( NAME, true, name ); NullArgumentException.ensureNotZero( SIZE, size ); queue = new LinkedList<RunnableCallbackHolder>(); PooledWorker[] threads = new PooledWorker[ size ]; ThreadGroup threadGroup = new ThreadGroup( name + "WorkQueue" ); for ( int i = 0; i < size; i++ ) { threads[i] = new PooledWorker( threadGroup, name + "Worker-" + i ); threads[i].start(); } }
public static KeyStoreType valueOfTypeString( String typeString ) { NullArgumentException.ensureNotEmpty( "Type String", typeString ); if ( StringValue.JCEKS.equalsIgnoreCase( typeString ) ) { return JCEKS; } if ( StringValue.JKS.equalsIgnoreCase( typeString ) ) { return JKS; } if ( StringValue.PKCS12.equalsIgnoreCase( typeString ) ) { return PKCS12; } if ( StringValue.PKCS11.equalsIgnoreCase( typeString ) ) { return PKCS11; } throw new IllegalArgumentException( "Unsupported KeyStoreType: " + typeString ); }
public CaUriResolver( Reference rootRef, String uri ) { NullArgumentException.ensureNotNull( "rootRef", rootRef ); NullArgumentException.ensureNotEmpty( "uri", uri ); String interestingPath = new Reference( uri ).getPath().replaceAll( "^" + rootRef.getPath() + "/", "" ); String[] splitted = interestingPath.split( "/" ); if ( splitted.length != 2 ) { throw new IllegalArgumentException( "Unable to resolve URI: " + uri ); } clazz = resolveClass( splitted[0] ); identity = splitted[1]; }
@Override public SpicyPlate spicyPlate( SpicyContext globalContext, String template ) { NullArgumentException.ensureNotNull( "Global context", globalContext ); NullArgumentException.ensureNotEmpty( "Template", template ); StringWriter errorWriter = new StringWriter(); try { ScriptContext scriptContext = new SimpleScriptContext(); scriptContext.setErrorWriter( errorWriter ); scriptContext.setAttribute( "__spicy_plates_raw_template", template, ScriptContext.ENGINE_SCOPE ); Object erb = ruby.eval( new InputStreamReader( getClass().getResourceAsStream( "template_reader.rb" ) ), scriptContext ); return new ERubySpicyPlate( ruby, globalContext, erb ); } catch ( ScriptException ex ) { throw new SpicyPlatesFailure( "Unable to create ERB object from template content", ex ).andLogError( "Ruby error output was:\n" + Strings.indent( errorWriter.toString(), 1, " ", "| " ) ); } }