RepositoryResourceLoader implements ResourceLoader { public ResourceKey createKey( final Object value, final Map factoryKeys ) throws ResourceKeyCreationException { if ( value instanceof String ) { final String valueString = (String) value; if ( valueString.startsWith( getSchema() + SCHEMA_SEPARATOR ) ) { final String path = valueString.substring( getSchema().length() + SCHEMA_SEPARATOR.length() ); return new ResourceKey( getSchema(), path, factoryKeys ); } } return null; } RepositoryResourceLoader(); void setResourceManager( final ResourceManager manager ); ResourceManager getManager(); String getSchema(); ResourceData load( final ResourceKey key ); boolean isSupportedKey( final ResourceKey key ); ResourceKey createKey( final Object value, final Map factoryKeys ); ResourceKey deriveKey( final ResourceKey parent, String path, final Map data ); ResourceKey deserialize( final ResourceKey bundleKey, final String stringKey ); String serialize( final ResourceKey bundleKey, final ResourceKey key ); URL toURL( final ResourceKey key ); boolean isSupportedDeserializer( final String data ); static final String SOLUTION_SCHEMA_NAME; static final String SCHEMA_SEPARATOR; static final String PATH_SEPARATOR; static final String WIN_PATH_SEPARATOR; }
@Test public void testCreateKey() throws Exception { assertNull( rrl.createKey( 0, null ) ); Map<String, Object> keys = new HashMap<String, Object>() {{ put( "key", "value" ); }}; ResourceKey key = rrl.createKey( rrl.SOLUTION_SCHEMA_NAME + rrl.SCHEMA_SEPARATOR, keys ); assertNotNull( key ); assertEquals( rrl.SOLUTION_SCHEMA_NAME, key.getSchema() ); }