Hi

It is a good progress, I think you are on the right path.
Just to see that things are really working, introduce ObjectName and
ManagedComponent JAXB beans which will be initialized from JMX ObjectName
and ManagedComponent JMX objects.

That should be enough for GETs to start working. We will think on which HTTP
verbs to use to start/stop ManageComponents/etc next.

At this stage just try to get the list of  (JAXB) ObjectNames returned and
add another method which will return a specific (JAXB) ManagedComponent
given the query like this:

GET /jaxrsjms/component/{objectname}
or
 GET /jaxrsjms/component?name={objectname}

where {objectname} is one of the returned ObjectNames.

Cheers, Sergey


On Sun, Apr 17, 2011 at 12:54 AM, Travis Roy <dabaip...@hotmail.com> wrote:

>  Hi Sergey:
>
> I think i get stuck at the server's returning. Usually, I define my own
> domain object bound with JAXB annotation, but right now, if I am having this
> class:
>
>  @Path("/jaxrsjmx")
> @Produces("application/xml")
> public class JaxRsJMXServiceImpl implements JaxRsJMXService {
> private static String jmxServerURL =
> "service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi";
> private static MBeanServerConnection mbsc;
> @GET
> @Path("/list")
> public Set<ObjectName> list() throws IOException,
> MalformedObjectNameException, NullPointerException{
> JMXServiceURL url = new JMXServiceURL(jmxServerURL);
>         JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
>         mbsc = jmxc.getMBeanServerConnection();
>         ObjectName queryEndpointName = new ObjectName(ManagementConstants.
> DEFAULT_DOMAIN_NAME  + ":type=Bus.Service.Endpoint,*");
>         Set<ObjectName> endpointNames = 
> CastUtils.cast(mbsc.queryNames(queryEndpointName,
> null));
> return endpointNames;
> }
>
>
> @GET
> @Path("/start")
> public ManagedComponent start(){
> System.out.println("/start");
> return null;
> }
>
>
>
> @GET
> @Path("/stop")
> public ManagedComponent stop(){
> System.out.println("/stop");
> return null;
> }
>
>
> @GET
> @Path("/restart")
> public ManagedComponent restart(){
> System.out.println("/restart");
> return null;
> }
> }
>
> As you can see, this list() function's return is obviously wrong. So far, I
> can't figure out a way to properly return a cxf mbean or a list of mbeans,
> though client can reach the above methods.
> Usually, I have domain object like this
>
>  @XmlRootElement(name = "user")
> public class User {
> private Integer id;
> private String userName;
> private String firstName;
> private String lastName;
> public User(){}
> public User(Integer id, String userName){
> this.id = id;
> this.userName = userName;
> }
> public Integer getId() {
> return id;
> }
> public void setId(Integer id) {
> this.id = id;
> }
> public String getUserName() {
> return userName;
> }
> public void setUserName(String userName) {
> this.userName = userName;
> }
> public String getFirstName() {
> return firstName;
> }
> public void setFirstName(String firstName) {
> this.firstName = firstName;
> }
> public String getLastName() {
> return lastName;
> }
> public void setLastName(String lastName) {
> this.lastName = lastName;
> }
> }
> And I can easily return this 'User' back to client in REST, however, I am
> just guessing how I am able to wrap/apply this pattern on mbeans.
>
> I need your help.
> Thank you very much.
>
> Here is part of my spring context:
>      <import resource="classpath:META-INF/cxf/cxf.xml" />
>     <!-- <import 
> resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
> -->
>     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>     <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>     <import resource=
> "classpath:META-INF/cxf/cxf-extension-ws-security.xml" />
>     <import resource="classpath*:META-INF/cxf/cxf-extension-*.xml" />
>     <!-- Enable message logging using the CXF logging feature -->
>     <cxf:bus>
>         <cxf:features>
>             <cxf:logging/>
>         </cxf:features>
>     </cxf:bus>
>       <bean id="instrumentationManager" class=
> "org.apache.cxf.management.jmx.InstrumentationManagerImpl">
>     <property name="bus" ref="cxf" />
> <property name="enabled" value="true" />
> <property name="JMXServiceURL" value=
> "service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi" />
>   </bean>
>
>
> <!-- Wiring the counter repository -->
>     <bean id="counterRepository" class=
> "org.apache.cxf.management.counters.CounterRepository">
>          <property name="bus" ref="cxf" />
>     </bean>
>
>
>
>
>     <!-- JAX-RS Server -->
>     <jaxrs:server id="userServiceRs" address="/rest">
>         <jaxrs:serviceBeans>
>             <ref bean="userService" />
>             <ref bean="jmxService" />
>          </jaxrs:serviceBeans>
>         <jaxrs:extensionMappings>
>             <entry key="xml" value="application/xml" />
>         </jaxrs:extensionMappings>
>     </jaxrs:server>
>
>     <bean id="userService" class=
> "com.mycompany.ws.service.impl.UserServiceImpl" />
>     <bean id="jmxService" class=
> "com.mycompany.ws.service.impl.JaxRsJMXServiceImpl" />
>
> PS: UserServiceImpl is working totally ok.
>
>
>
> Regards:
> Shenglin Qiu
>
>
>
>
>

Reply via email to