001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.servicemix.jbi.management.task;
018    
019    import org.apache.servicemix.jbi.framework.AdminCommandsServiceMBean;
020    import org.apache.tools.ant.Project;
021    
022    /**
023     * List deployed Service Assemblies
024     * 
025     * @version $Revision: 379004 $
026     */
027    public class ListServiceAssembliesTask extends JbiTask {
028    
029        private String state;
030    
031        private String componentName;
032    
033        private String serviceAssemblyName;
034    
035        private String xmlOutput;
036    
037        /**
038         * @return the xmlOutput
039         */
040        public String isXmlOutput() {
041            return xmlOutput;
042        }
043    
044        /**
045         * @param xmlOutput
046         *            the xmlOutput to set
047         */
048        public void setXmlOutput(String xmlOutput) {
049            this.xmlOutput = xmlOutput;
050        }
051    
052        /**
053         * 
054         * @return the state
055         */
056        public String getState() {
057            return state;
058        }
059    
060        /**
061         * 
062         * @param state
063         *            Sets the state
064         */
065        public void setState(String state) {
066            this.state = state;
067        }
068    
069        /**
070         * 
071         * @return the component name
072         */
073        public String getComponentName() {
074            return componentName;
075        }
076    
077        /**
078         * 
079         * @param componentName
080         *            Sets the component name
081         */
082        public void setComponentName(String componentName) {
083            this.componentName = componentName;
084        }
085    
086        /**
087         * 
088         * @return service assembly name
089         */
090        public String getServiceAssemblyName() {
091            return serviceAssemblyName;
092        }
093    
094        /**
095         * 
096         * @param serviceAssemblynname
097         *            Sets the service assembly name
098         */
099        public void setServiceAssemblyName(String serviceAssemblynname) {
100            this.serviceAssemblyName = serviceAssemblynname;
101        }
102    
103        /**
104         * execute the task
105         * 
106         * @throws BuildException
107         */
108        public void doExecute(AdminCommandsServiceMBean acs) throws Exception {
109            String result = acs.listServiceAssemblies(getState(), getComponentName(), getServiceAssemblyName());
110            if (xmlOutput != null) {
111                getProject().setProperty(xmlOutput, result);
112            }
113            log(result, Project.MSG_WARN);
114        }
115    
116    }