Skip to content

Commit

Permalink
Add default logic for service impl
Browse files Browse the repository at this point in the history
  • Loading branch information
markphilpot committed Mar 14, 2017
1 parent c0fc21b commit f730c8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ public void setInfClass(String infClass)

public String getImplClass()
{
return implClass;
if(implClass != null)
{
return implClass;
}
else
{
// Return default by convention
int lastDot = getInfClass().lastIndexOf(".");
return String.format("%s.impl%sImpl", getInfClass().substring(0, lastDot), getInfClass().substring(lastDot));
}
}

public void setImplClass(String implClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,13 @@ private ServiceConfiguration buildConfig()

return config;
}

@Test
public void testConventionFallback()
{
ManagedObjectDescription mod = new ManagedObjectDescription();
mod.setInfClass("com.test.framework.MyService");

assertThat(mod.getImplClass(), is("com.test.framework.impl.MyServiceImpl"));
}
}

0 comments on commit f730c8f

Please sign in to comment.