code.onehippo.org is currently readonly. We are migrating to code.bloomreach.com, please continue working there on Monday 14/12. See: https://docs.bloomreach.com/display/engineering/GitLab

Commit cd6ab65f authored by Ard Schrijvers's avatar Ard Schrijvers

HSTTWO-3548 Add an example of overriding hst spring addon beans which should...

HSTTWO-3548 Add an example of overriding hst spring addon beans which should work (but currently doesn't). Need to sort out what fails
parent a2619f4f
......@@ -3,6 +3,7 @@
/NOTICE -text
/README.txt -text svneol=unset#text/plain
api/pom.xml -text
api/src/main/java/org/hippoecm/hst/demo/addonmodules/api/InverseOperator.java -text
api/src/main/java/org/hippoecm/hst/demo/addonmodules/api/MatrixOperator.java -text
api/src/main/java/org/hippoecm/hst/demo/addonmodules/api/RandomGenerator.java -text
cms/pom.xml -text
......@@ -10,6 +11,7 @@ cms/src/main/resources/org/hippoecm/frontend/plugins/standardworkflow/new-transl
cms/src/main/resources/org/hippoecm/frontend/plugins/standardworkflow/new-translated-folder-intranet-16.png -text
cms/src/main/webapp/WEB-INF/web.xml -text
components/pom.xml -text
components/src/main/java/org/hippoecm/hst/demo/addonmodules/linearalgebra/MyMatrixOperator.java -text
components/src/main/java/org/hippoecm/hst/demo/beans/BaseBean.java svneol=native#text/plain
components/src/main/java/org/hippoecm/hst/demo/beans/BlockBean.java -text
components/src/main/java/org/hippoecm/hst/demo/beans/CommentBean.java svneol=native#text/plain
......@@ -105,6 +107,7 @@ components/src/main/resources/META-INF/hst-assembly/overrides/event-listeners.xm
components/src/main/resources/META-INF/hst-assembly/overrides/hst-cms-rest.xml -text
components/src/main/resources/META-INF/hst-assembly/overrides/httpsSchemeExample-valve.xml -text svneol=unset#text/plain
components/src/main/resources/META-INF/hst-assembly/overrides/jndi-repository.xml svneol=native#text/plain
components/src/main/resources/META-INF/hst-assembly/overrides/org/hippoecm/hst/demo/addonmodules/linearalgebra/overrideMatrixOperator.xml -text
components/src/main/resources/META-INF/hst-assembly/overrides/page-composer-rest.xml -text svneol=unset#text/plain
components/src/main/resources/META-INF/hst-assembly/overrides/spring-bean-bridge-contact.xml -text
components/src/main/resources/enwiki-20081008-pages-articles.xml.100.top.xml -text svneol=unset#text/plain
......@@ -355,6 +358,7 @@ intranet/src/main/webapp/images/hippo.gif -text
intranet/src/main/webapp/images/onehippo.gif -text
intranet/src/main/webapp/js/html5shiv.js -text
linear-algebra/pom.xml -text
linear-algebra/src/main/java/org/hippoecm/hst/demo/addonmodules/linearalgebra/InverseOperatorImpl.java -text
linear-algebra/src/main/java/org/hippoecm/hst/demo/addonmodules/linearalgebra/MatrixOperatorImpl.java -text
linear-algebra/src/main/resources/META-INF/hst-assembly/addon/module.xml -text
linear-algebra/src/main/resources/META-INF/hst-assembly/addon/org/hippoecm/hst/demo/addonmodules/linearalgebra/base.xml -text
......
/*
* Copyright 2016 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hippoecm.hst.demo.addonmodules.api;
public interface InverseOperator {
double [][] inverse(double[][] matrixData);
MatrixOperator getMatrixOperator();
}
......@@ -30,6 +30,12 @@
<dependencies>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-testsuite-linear-algebra</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
......
package org.hippoecm.hst.demo.addonmodules.linearalgebra;
import org.hippoecm.hst.demo.addonmodules.api.MatrixOperator;
public class MyMatrixOperator implements MatrixOperator{
private MatrixOperator delegatee;
public void MyMatrixOperator() {
this.delegatee = new MatrixOperatorImpl();
}
@Override
public double[][] inverse(final double[][] matrixData) {
return delegatee.inverse(matrixData);
}
@Override
public double[][] multiply(final double[][] matrixData1, final double[][] matrixData2) {
return delegatee.multiply(matrixData1, matrixData2);
}
}
......@@ -20,8 +20,10 @@ import org.hippoecm.hst.component.support.bean.BaseHstComponent;
import org.hippoecm.hst.core.component.HstComponentException;
import org.hippoecm.hst.core.component.HstRequest;
import org.hippoecm.hst.core.component.HstResponse;
import org.hippoecm.hst.demo.addonmodules.api.InverseOperator;
import org.hippoecm.hst.demo.addonmodules.api.MatrixOperator;
import org.hippoecm.hst.demo.addonmodules.api.RandomGenerator;
import org.hippoecm.hst.demo.addonmodules.linearalgebra.MyMatrixOperator;
import org.hippoecm.hst.site.HstServices;
public class Algebra extends BaseHstComponent {
......@@ -34,6 +36,16 @@ public class Algebra extends BaseHstComponent {
RandomGenerator randomGenerator = HstServices.getComponentManager().getComponent("randomGenerator", RANDOM_NUMBERS_MODULE_NAME);
MatrixOperator matrixOperator = HstServices.getComponentManager().getComponent("matrixOperator", LINEAR_ALGEBRA_MODULE_NAME);
if (!(matrixOperator instanceof MyMatrixOperator)) {
throw new AssertionError("matrixOperator is expected to be an instanceof MyMatrixOperator");
}
InverseOperator inverseOperator = HstServices.getComponentManager().getComponent("inverseOperator", LINEAR_ALGEBRA_MODULE_NAME);
if (!(inverseOperator.getMatrixOperator() instanceof MyMatrixOperator)) {
throw new AssertionError("matrixOperator is expected to be an instanceof MyMatrixOperator");
}
double [][] matrixData = new double[2][2];
for (int i = 0; i < 2; i++) {
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
<bean id="matrixOperator" class="org.hippoecm.hst.demo.addonmodules.linearalgebra.MyMatrixOperator"/>
</beans>
package org.hippoecm.hst.demo.addonmodules.linearalgebra;
import org.hippoecm.hst.demo.addonmodules.api.InverseOperator;
import org.hippoecm.hst.demo.addonmodules.api.MatrixOperator;
public class InverseOperatorImpl implements InverseOperator {
private MatrixOperatorImpl matrixOperator;
public void setMatrixOperator(final MatrixOperatorImpl matrixOperator) {
this.matrixOperator = matrixOperator;
}
public double[][] inverse(double[][] matrixData) {
return matrixOperator.inverse(matrixData);
}
@Override
public MatrixOperator getMatrixOperator() {
return matrixOperator;
}
}
......@@ -18,5 +18,6 @@
<name>org.hippoecm.hst.demo.addonmodules.linearalgebra</name>
<config-locations>
<config-location>classpath*:META-INF/hst-assembly/addon/org/hippoecm/hst/demo/addonmodules/linearalgebra/*.xml</config-location>
<config-location>classpath*:META-INF/hst-assembly/addon/overrides/org/hippoecm/hst/demo/addonmodules/linearalgebra/*.xml</config-location>
</config-locations>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
Copyright 2012-2016 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -15,14 +15,14 @@
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/beans/spring-lang-4.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
<bean id="matrixOperator" class="org.hippoecm.hst.demo.addonmodules.linearalgebra.MatrixOperatorImpl">
</bean>
<bean id="inverseOperator" class="org.hippoecm.hst.demo.addonmodules.linearalgebra.InverseOperatorImpl">
<property name="matrixOperator" ref="matrixOperator"/>
</bean>
</beans>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment