| Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
| ManagedService |
|
| 0.0;0 |
| 1 | /** |
|
| 2 | * |
|
| 3 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
| 4 | * contributor license agreements. See the NOTICE file distributed with |
|
| 5 | * this work for additional information regarding copyright ownership. |
|
| 6 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
| 7 | * (the "License"); you may not use this file except in compliance with |
|
| 8 | * the License. You may obtain a copy of the License at |
|
| 9 | * |
|
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | * |
|
| 12 | * Unless required by applicable law or agreed to in writing, software |
|
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | * See the License for the specific language governing permissions and |
|
| 16 | * limitations under the License. |
|
| 17 | */ |
|
| 18 | package org.apache.camel.management; |
|
| 19 | ||
| 20 | import java.io.IOException; |
|
| 21 | ||
| 22 | import org.apache.camel.Service; |
|
| 23 | import org.apache.camel.impl.ServiceSupport; |
|
| 24 | import org.springframework.jmx.export.annotation.ManagedAttribute; |
|
| 25 | import org.springframework.jmx.export.annotation.ManagedOperation; |
|
| 26 | import org.springframework.jmx.export.annotation.ManagedResource; |
|
| 27 | ||
| 28 | @ManagedResource( |
|
| 29 | description="Managed Service", |
|
| 30 | currencyTimeLimit=15) |
|
| 31 | public class ManagedService { |
|
| 32 | ||
| 33 | private ServiceSupport service; |
|
| 34 | ||
| 35 | 0 | public ManagedService(ServiceSupport service) { |
| 36 | 0 | this.service = service; |
| 37 | 0 | } |
| 38 | ||
| 39 | public Service getService() { |
|
| 40 | 0 | return service; |
| 41 | } |
|
| 42 | ||
| 43 | @ManagedAttribute(description = "Service running state") |
|
| 44 | private boolean isStarted() throws IOException { |
|
| 45 | 0 | return service.isStarted(); |
| 46 | } |
|
| 47 | ||
| 48 | @ManagedOperation(description = "Start Service") |
|
| 49 | public void start() throws IOException { |
|
| 50 | try { |
|
| 51 | 0 | service.start(); |
| 52 | } |
|
| 53 | 0 | catch (Exception e) { |
| 54 | 0 | throw new IOException(e.getMessage()); |
| 55 | 0 | } |
| 56 | 0 | } |
| 57 | ||
| 58 | @ManagedOperation(description = "Stop Service") |
|
| 59 | public void stop() throws IOException { |
|
| 60 | try { |
|
| 61 | 0 | service.stop(); |
| 62 | } |
|
| 63 | 0 | catch (Exception e) { |
| 64 | 0 | throw new IOException(e.getMessage()); |
| 65 | 0 | } |
| 66 | 0 | } |
| 67 | } |