1.1 Summary of debugging web-controller interface
1. Classes transferred by web and controller must be serialized
Through XML serialization or Jason serialization, most of our current code is serialized through xml, using JAXB architecture.
2. Serialized classes must have default constructors. If there is no override constructor, the default constructor does not need to be displayed and written. If the constructor is overridden, the default constructor must be written.
This is achieved by adding the annotation to the class that needs to be serialized
The @XmlRootElement (name = getBackupDetailRsp) in which the name should be noted that there should be no renaming, typically using the first lowercase letter of the class name.
@XmlAccessorType (XmlAccessType.FIELD)
3. After creating a restservice, beanid of the corresponding implementation class of the service must be added to controller-content.xml
For example:
<beans profile= "persistence-enabled">
<! - REST server - >
<bean id="restServerFactoryBean" class="org.apache.cxf.jaxrs.JAXRS ServerFactoryBean"
Init-method= "create" depends-on= "persistence context">
<property name="address" value="${controller.rest.server.url}"/>
<property name="service beans">
<list> <! - @Cmponents should be placed in com.huawei.hadoop.om.controller.rest.resources-->
<ref bean="cluster resource"/>
</list>
</property>
</bean>
</beans>
<beans profile= "persistence-disabled">
<! - REST server - >
<bean id="restServerFactoryBean" class="org.apache.cxf.jaxrs.JAXRS ServerFactoryBean"
Init-method= "create">
<property name="address" value="${controller.rest.server.url}"/>
<property name="service beans">
<list> <! - @Cmponents should be placed in com.huawei.hadoop.om.controller.rest.resources-->
<ref bean="cluster resource"/>
</list>
</property>
</bean>
</beans>
4. If you have a GET interface, but you pass a parameter, which is a basic type, you need to add @PathParam ("clusterId") int clusterId or @QueryParam before the parameter.