View Javadoc
1   /*
2    * JBoss, Home of Professional Open Source
3    * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
4    * contributors by the @authors tag. See the copyright.txt in the
5    * distribution for a full listing of individual contributors.
6    *
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * http://www.apache.org/licenses/LICENSE-2.0
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.jboss.as.quickstarts.mbeanhelloworld.mbean;
18  
19  import java.util.concurrent.atomic.AtomicLong;
20  import java.util.logging.Logger;
21  
22  /**
23   * Mbean pojo using MXBean interface and declared in jboss-service.xml.
24   * 
25   * @author Jeremie Lagarde
26   * 
27   */
28  public class MXPojoHelloWorld implements IHelloWorldMXBean {
29  
30      private static final Logger log = Logger.getLogger(MXPojoHelloWorld.class.getName());
31  
32      private String welcomeMessage = "Hello";
33      private AtomicLong count = new AtomicLong(0);
34  
35      public long getCount() {
36          return count.get();
37      }
38  
39      public void setWelcomeMessage(String message) {
40          if (message != null && message.trim().length() > 0)
41              welcomeMessage = message;
42      }
43  
44      public String getWelcomeMessage() {
45          return welcomeMessage;
46      }
47  
48      public String sayHello(String name) {
49          count.incrementAndGet();
50          return welcomeMessage + " " + name + "!";
51      }
52  
53      public void start() throws Exception {
54          log.info(" >> MXPojoHelloWorld.start() invoked");
55      }
56  
57      public void stop() throws Exception {
58          log.info(" << MXPojoHelloWorld.stop()  invoked");
59      }
60  
61  }