[Bugfix] fixed not setting new Impl for component, when overridden
- Now when you set a new Impl for a component, then the dependencies are also replaced
This commit is contained in:
parent
4c631ad07f
commit
ee741b5e18
|
@ -452,6 +452,10 @@ public class ConfigurationSaxParser extends DefaultHandler {
|
||||||
if (thisComponentBuilder == null) {
|
if (thisComponentBuilder == null) {
|
||||||
this.componentBuilders.add(otherComponentBuilder);
|
this.componentBuilders.add(otherComponentBuilder);
|
||||||
} else {
|
} else {
|
||||||
|
if (StringHelper.isNotEmpty(otherComponentBuilder.getImpl())) {
|
||||||
|
thisComponentBuilder.setImpl(otherComponentBuilder.getImpl());
|
||||||
|
thisComponentBuilder.setDependencies(otherComponentBuilder.getDependencies());
|
||||||
|
}
|
||||||
thisComponentBuilder.getProperties().putAll(otherComponentBuilder.getProperties());
|
thisComponentBuilder.getProperties().putAll(otherComponentBuilder.getProperties());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -552,6 +556,10 @@ public class ConfigurationSaxParser extends DefaultHandler {
|
||||||
return this.dependencies;
|
return this.dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDependencies(Set<String> dependencies) {
|
||||||
|
this.dependencies = dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
public void addDependency(String dependency) {
|
public void addDependency(String dependency) {
|
||||||
this.dependencies.add(dependency);
|
this.dependencies.add(dependency);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class ConfigurationParserTest {
|
||||||
assertEquals("li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler",
|
assertEquals("li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler",
|
||||||
privilegeHandlerConfiguration.getImpl());
|
privilegeHandlerConfiguration.getImpl());
|
||||||
assertEquals(1, privilegeHandlerConfiguration.getPropertyKeys().size());
|
assertEquals(1, privilegeHandlerConfiguration.getPropertyKeys().size());
|
||||||
|
assertEquals(1, privilegeHandlerConfiguration.getDependencies().size());
|
||||||
assertTrue(privilegeHandlerConfiguration.getDependencies().contains("PersistenceHandler"));
|
assertTrue(privilegeHandlerConfiguration.getDependencies().contains("PersistenceHandler"));
|
||||||
assertEquals("PrivilegeConfig.xml", privilegeHandlerConfiguration.getString("privilegeConfigFile", null));
|
assertEquals("PrivilegeConfig.xml", privilegeHandlerConfiguration.getString("privilegeConfigFile", null));
|
||||||
|
|
||||||
|
@ -178,5 +179,26 @@ public class ConfigurationParserTest {
|
||||||
assertEquals(2, realmHandlerConfiguration.getPropertyKeys().size());
|
assertEquals(2, realmHandlerConfiguration.getPropertyKeys().size());
|
||||||
assertEquals("EMPTY", realmHandlerConfiguration.getString("dataStoreMode", null));
|
assertEquals("EMPTY", realmHandlerConfiguration.getString("dataStoreMode", null));
|
||||||
assertEquals("noob", realmHandlerConfiguration.getString("foo", null));
|
assertEquals("noob", realmHandlerConfiguration.getString("foo", null));
|
||||||
|
|
||||||
|
// <Component>
|
||||||
|
// <name>ServiceHandler</name>
|
||||||
|
// <api>li.strolch.service.api.ServiceHandler</api>
|
||||||
|
// <impl>li.strolch.service.YetAnotherServiceHandler</impl>
|
||||||
|
// <depends>RealmHandler</depends>
|
||||||
|
// <Properties>
|
||||||
|
// <bar>foo</bar>
|
||||||
|
// </Properties>
|
||||||
|
// </Component>
|
||||||
|
ComponentConfiguration serviceHandlerConfiguration = strolchConfiguration
|
||||||
|
.getComponentConfiguration("ServiceHandler");
|
||||||
|
assertNotNull("Should have created a ServiceHandler Configuration", serviceHandlerConfiguration);
|
||||||
|
assertEquals("ServiceHandler", serviceHandlerConfiguration.getName());
|
||||||
|
assertEquals("li.strolch.service.api.ServiceHandler", serviceHandlerConfiguration.getApi());
|
||||||
|
assertEquals("li.strolch.service.YetAnotherServiceHandler", serviceHandlerConfiguration.getImpl());
|
||||||
|
assertEquals(2, serviceHandlerConfiguration.getDependencies().size());
|
||||||
|
assertTrue(serviceHandlerConfiguration.getDependencies().contains("RealmHandler"));
|
||||||
|
assertTrue(serviceHandlerConfiguration.getDependencies().contains("PrivilegeHandler"));
|
||||||
|
assertEquals(1, serviceHandlerConfiguration.getPropertyKeys().size());
|
||||||
|
assertEquals("foo", serviceHandlerConfiguration.getString("bar", null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,17 @@
|
||||||
<foo>noob</foo>
|
<foo>noob</foo>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
|
||||||
|
<Component>
|
||||||
|
<name>ServiceHandler</name>
|
||||||
|
<api>li.strolch.service.api.ServiceHandler</api>
|
||||||
|
<impl>li.strolch.service.YetAnotherServiceHandler</impl>
|
||||||
|
<depends>RealmHandler</depends>
|
||||||
|
<depends>PrivilegeHandler</depends>
|
||||||
|
<Properties>
|
||||||
|
<bar>foo</bar>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
</env>
|
</env>
|
||||||
|
|
||||||
</StrolchConfiguration>
|
</StrolchConfiguration>
|
Loading…
Reference in New Issue