cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1176568 - in /cxf/trunk: api/src/main/java/org/apache/cxf/endpoint/ distribution/karaf/ distribution/karaf/commands/ distribution/karaf/commands/src/ distribution/karaf/commands/src/main/ distribution/karaf/commands/src/main/java/ distribu...
Date Tue, 27 Sep 2011 19:46:05 GMT
Author: dkulp
Date: Tue Sep 27 19:46:04 2011
New Revision: 1176568

URL: http://svn.apache.org/viewvc?rev=1176568&view=rev
Log:
Add a few Karaf command line things to start/stop/list endpoints that
are running in Karaf
Fix some issues with stoping a Server causing it to completely
unregister.
Add ability to see if a server is stopped or not.
Make sure the Bus is marked RUNNING after the initialization is done.

Added:
    cxf/trunk/distribution/karaf/commands/
    cxf/trunk/distribution/karaf/commands/pom.xml   (with props)
    cxf/trunk/distribution/karaf/commands/src/
    cxf/trunk/distribution/karaf/commands/src/main/
    cxf/trunk/distribution/karaf/commands/src/main/java/
    cxf/trunk/distribution/karaf/commands/src/main/java/org/
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/CXFController.java
      - copied, changed from r1176448, cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/BusState.java
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListBussesCommand.java
  (with props)
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListEndpointsCommand.java
  (with props)
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StartEndpointCommand.java
  (with props)
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StopEndpointCommand.java
  (with props)
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/internal/
    cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/internal/CXFControllerImpl.java
  (with props)
    cxf/trunk/distribution/karaf/commands/src/main/resources/
    cxf/trunk/distribution/karaf/commands/src/main/resources/OSGI-INF/
    cxf/trunk/distribution/karaf/commands/src/main/resources/OSGI-INF/blueprint/
    cxf/trunk/distribution/karaf/commands/src/main/resources/OSGI-INF/blueprint/cxf-karaf-commands.xml
  (with props)
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Server.java
    cxf/trunk/distribution/karaf/features/pom.xml
    cxf/trunk/distribution/karaf/features/src/main/resources/features.xml
    cxf/trunk/distribution/karaf/pom.xml
    cxf/trunk/parent/pom.xml
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/BusState.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
    cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/DummyServer.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Server.java?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Server.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Server.java Tue Sep 27 19:46:04 2011
@@ -29,6 +29,8 @@ public interface Server  {
     
     void destroy();
     
+    boolean isStarted();
+    
     Destination getDestination();
     
     Endpoint getEndpoint();

Added: cxf/trunk/distribution/karaf/commands/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/commands/pom.xml?rev=1176568&view=auto
==============================================================================
--- cxf/trunk/distribution/karaf/commands/pom.xml (added)
+++ cxf/trunk/distribution/karaf/commands/pom.xml Tue Sep 27 19:46:04 2011
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You under the Apache License, Version 2.0
+        (the "License"); you may not use this file except in compliance with
+        the License.  You may obtain a copy of the License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+        Unless required by applicable law or agreed to in writing, software
+        distributed under the License is distributed on an "AS IS" BASIS,
+        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+        See the License for the specific language governing permissions and
+        limitations under the License.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.cxf.karaf</groupId>
+        <artifactId>karaf-parent</artifactId>
+        <version>2.5.0-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.cxf.karaf</groupId>
+    <artifactId>cxf-karaf-commands</artifactId>
+    <packaging>bundle</packaging>
+    <name>CXF :: Apache Karaf :: Commands</name>
+    <description>CXF :: Apache Karaf :: Commands</description>
+
+    <dependencies>
+        <!-- cxf -->
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!-- karaf -->
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+            <version>${cxf.karaf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf</groupId>
+            <artifactId>org.apache.karaf.util</artifactId>
+            <version>${cxf.karaf.version}</version>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Import-Package>
+              org.apache.felix.service.command,
+              org.apache.felix.gogo.commands,
+              org.apache.karaf.shell.console,
+              *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: cxf/trunk/distribution/karaf/commands/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/distribution/karaf/commands/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/distribution/karaf/commands/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/CXFController.java
(from r1176448, cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/BusState.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/CXFController.java?p2=cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/CXFController.java&p1=cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/BusState.java&r1=1176448&r2=1176568&rev=1176568&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/BusState.java (original)
+++ cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/CXFController.java
Tue Sep 27 19:46:04 2011
@@ -16,8 +16,20 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.bus;
 
-public enum BusState {
-    INITIAL, RUNNING, SHUTTING_DOWN, SHUTDOWN;
+package org.apache.cxf.karaf.commands;
+
+import java.util.List;
+
+import org.apache.cxf.Bus;
+
+/**
+ * 
+ */
+public interface CXFController {
+
+    List<Bus> getBusses();
+
+    Bus getBus(String name);
+
 }

Added: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListBussesCommand.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListBussesCommand.java?rev=1176568&view=auto
==============================================================================
--- cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListBussesCommand.java
(added)
+++ cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListBussesCommand.java
Tue Sep 27 19:46:04 2011
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.karaf.commands;
+
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.CXFBusImpl;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+/**
+ * 
+ */
+@Command(scope = "cxf", name = "list-busses", description = "Lists all CXF Busses.")
+public class ListBussesCommand extends OsgiCommandSupport {
+    protected static final String HEADER_FORMAT = "%-40s %-20s";
+    protected static final String OUTPUT_FORMAT = "[%-38s] [%-18s]";
+
+    private CXFController cxfController;
+
+    public void setController(CXFController controller) {
+        this.cxfController = controller;
+    }
+
+    protected Object doExecute() throws Exception {
+        List<Bus> busses = cxfController.getBusses();
+        System.out.println(String.format(HEADER_FORMAT, "Name", "State"));
+
+        for (Bus bus : busses) {
+            String state = "";
+            if (bus instanceof CXFBusImpl) {
+                state = ((CXFBusImpl)bus).getState().toString();
+            }
+            System.out.println(String.format(OUTPUT_FORMAT, bus.getId(), state));
+        }
+        return null;
+    }
+}

Propchange: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListBussesCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListBussesCommand.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListEndpointsCommand.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListEndpointsCommand.java?rev=1176568&view=auto
==============================================================================
--- cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListEndpointsCommand.java
(added)
+++ cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListEndpointsCommand.java
Tue Sep 27 19:46:04 2011
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.karaf.commands;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+/**
+ * 
+ */
+@Command(scope = "cxf", name = "list-endpoints", 
+    description = "Lists all CXF Endpoints on a Bus.")
+public class ListEndpointsCommand extends OsgiCommandSupport {
+    protected static final String HEADER_FORMAT = "%-25s %-10s %-60s";
+    protected static final String OUTPUT_FORMAT = "[%-23s] [%-8s] [%-58s]";
+    
+    @Argument(index = 0, name = "bus", 
+        description = "The CXF bus name where to look for the Endpoints", 
+        required = false, multiValued = false)
+    String name;
+    
+    private CXFController cxfController;
+
+    public void setController(CXFController controller) {
+        this.cxfController = controller;
+    }
+
+    protected Object doExecute() throws Exception {
+        List<Bus> busses;
+        if (name == null) {
+            busses = cxfController.getBusses();
+        } else {
+            Bus b = cxfController.getBus(name);
+            if (b != null) {
+                busses = Collections.singletonList(cxfController.getBus(name));
+            } else {
+                busses = Collections.emptyList();
+            }
+        }
+        for (Bus b : busses) {
+            ServerRegistry reg = b.getExtension(ServerRegistry.class);
+            List<Server> servers = reg.getServers();
+            System.out.println(String.format(HEADER_FORMAT, 
+                                             "Name", "State", "Address"));
+            for (Server serv : servers) {
+                String qname = serv.getEndpoint().getEndpointInfo().getName().getLocalPart();
+                String started = serv.isStarted() ? "Started" : "Stopped";
+                String address = serv.getEndpoint().getEndpointInfo().getAddress();
+                System.out.println(String.format(OUTPUT_FORMAT, qname, started, address));
+            }
+        }
+        return null;
+    } 
+}

Propchange: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListEndpointsCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/ListEndpointsCommand.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StartEndpointCommand.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StartEndpointCommand.java?rev=1176568&view=auto
==============================================================================
--- cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StartEndpointCommand.java
(added)
+++ cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StartEndpointCommand.java
Tue Sep 27 19:46:04 2011
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.karaf.commands;
+
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+/**
+ * 
+ */
+@Command(scope = "cxf", name = "start-endpoint", 
+    description = "Starts a CXF Endpoint on a Bus.")
+public class StartEndpointCommand extends OsgiCommandSupport {
+    
+    @Argument(index = 0, name = "bus", 
+        description = "The CXF bus name where to look for the Endpoint", 
+        required = true, multiValued = false)
+    String busName;
+    
+    @Argument(index = 1, name = "endpoint", 
+        description = "The Endpoint name to start", 
+        required = true, multiValued = false)
+    String endpoint;
+    
+    private CXFController cxfController;
+
+    public void setController(CXFController controller) {
+        this.cxfController = controller;
+    }
+
+    protected Object doExecute() throws Exception {
+        Bus b = cxfController.getBus(busName);
+        ServerRegistry reg = b.getExtension(ServerRegistry.class);
+        List<Server> servers = reg.getServers();
+        for (Server serv : servers) {
+            if (endpoint.equals(serv.getEndpoint().getEndpointInfo().getName().getLocalPart()))
{
+                serv.start();
+            }
+        }
+        return null;
+    } 
+}

Propchange: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StartEndpointCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StartEndpointCommand.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StopEndpointCommand.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StopEndpointCommand.java?rev=1176568&view=auto
==============================================================================
--- cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StopEndpointCommand.java
(added)
+++ cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StopEndpointCommand.java
Tue Sep 27 19:46:04 2011
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.karaf.commands;
+
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+/**
+ * 
+ */
+@Command(scope = "cxf", name = "stop-endpoint", 
+    description = "Stops a CXF Endpoint on a Bus.")
+public class StopEndpointCommand extends OsgiCommandSupport {
+    
+    @Argument(index = 0, name = "bus", 
+        description = "The CXF bus name where to look for the Endpoint", 
+        required = true, multiValued = false)
+    String busName;
+    
+    @Argument(index = 1, name = "endpoint", 
+        description = "The Endpoint name to stop", 
+        required = true, multiValued = false)
+    String endpoint;
+    
+    private CXFController cxfController;
+
+    public void setController(CXFController controller) {
+        this.cxfController = controller;
+    }
+
+    protected Object doExecute() throws Exception {
+        Bus b = cxfController.getBus(busName);
+        ServerRegistry reg = b.getExtension(ServerRegistry.class);
+        List<Server> servers = reg.getServers();
+        for (Server serv : servers) {
+            if (endpoint.equals(serv.getEndpoint().getEndpointInfo().getName().getLocalPart()))
{
+                serv.stop();
+            }
+        }
+        return null;
+    } 
+}

Propchange: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StopEndpointCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/StopEndpointCommand.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/internal/CXFControllerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/internal/CXFControllerImpl.java?rev=1176568&view=auto
==============================================================================
--- cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/internal/CXFControllerImpl.java
(added)
+++ cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/internal/CXFControllerImpl.java
Tue Sep 27 19:46:04 2011
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.karaf.commands.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.karaf.commands.CXFController;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+
+/**
+ */
+public class CXFControllerImpl implements CXFController {
+    private static final Logger LOG = LogUtils.getL7dLogger(CXFControllerImpl.class);
+
+    private BundleContext bundleContext;
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    public List<Bus> getBusses() {
+        List<Bus> busses = new ArrayList<Bus>();
+        try {
+            ServiceReference[] references = bundleContext.getServiceReferences(Bus.class.getName(),
null);
+            if (references != null) {
+                for (ServiceReference reference : references) {
+                    if (reference != null) {
+                        Bus bus = (Bus) bundleContext.getService(reference);
+                        if (bus != null) {
+                            busses.add(bus);
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            LOG.log(Level.INFO, "Cannot retrieve the list of CXF Busses.", e);
+        }
+        return busses;
+    }
+
+    public Bus getBus(String name) {
+        try {
+            ServiceReference[] references = bundleContext.getServiceReferences(Bus.class.getName(),
null);
+            if (references != null) {
+                for (ServiceReference reference : references) {
+                    if (reference != null
+                        && name.equals(reference.getProperty("cxf.bus.id"))) {
+                        return (Bus) bundleContext.getService(reference);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            LOG.log(Level.INFO, "Cannot retrieve the CXF Bus.", e);
+            return null;
+        }
+        LOG.log(Level.INFO, "Cannot retrieve the CXF Bus " + name + ".");
+        return null;
+    }
+
+
+
+}

Propchange: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/internal/CXFControllerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/distribution/karaf/commands/src/main/java/org/apache/cxf/karaf/commands/internal/CXFControllerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/distribution/karaf/commands/src/main/resources/OSGI-INF/blueprint/cxf-karaf-commands.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/commands/src/main/resources/OSGI-INF/blueprint/cxf-karaf-commands.xml?rev=1176568&view=auto
==============================================================================
--- cxf/trunk/distribution/karaf/commands/src/main/resources/OSGI-INF/blueprint/cxf-karaf-commands.xml
(added)
+++ cxf/trunk/distribution/karaf/commands/src/main/resources/OSGI-INF/blueprint/cxf-karaf-commands.xml
Tue Sep 27 19:46:04 2011
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
+
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
+        <command name="cxf/list-busses">
+            <action class="org.apache.cxf.karaf.commands.ListBussesCommand">
+                <property name="controller" ref="cxfController"/>
+            </action>
+        </command>
+        <command name="cxf/list-endpoints">
+            <action class="org.apache.cxf.karaf.commands.ListEndpointsCommand">
+                <property name="controller" ref="cxfController"/>
+            </action>
+        </command>
+        <command name="cxf/start-endpoint">
+            <action class="org.apache.cxf.karaf.commands.StartEndpointCommand">
+                <property name="controller" ref="cxfController"/>
+            </action>
+        </command>
+        <command name="cxf/stop-endpoint">
+            <action class="org.apache.cxf.karaf.commands.StopEndpointCommand">
+                <property name="controller" ref="cxfController"/>
+            </action>
+        </command>
+    </command-bundle>
+
+
+    <bean id="cxfController" class="org.apache.cxf.karaf.commands.internal.CXFControllerImpl">
+        <property name="bundleContext" ref="blueprintBundleContext"/>
+    </bean>
+
+</blueprint>
\ No newline at end of file

Propchange: cxf/trunk/distribution/karaf/commands/src/main/resources/OSGI-INF/blueprint/cxf-karaf-commands.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/distribution/karaf/commands/src/main/resources/OSGI-INF/blueprint/cxf-karaf-commands.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/distribution/karaf/commands/src/main/resources/OSGI-INF/blueprint/cxf-karaf-commands.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cxf/trunk/distribution/karaf/features/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/features/pom.xml?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/distribution/karaf/features/pom.xml (original)
+++ cxf/trunk/distribution/karaf/features/pom.xml Tue Sep 27 19:46:04 2011
@@ -72,19 +72,7 @@
             <scope>provided</scope>
         </dependency>
     </dependencies>
-    <repositories>
-        <repository>
-            <id>java.net.maven2</id>
-            <url>http://download.java.net/maven/2</url>
-            <name>java.net maven 2 repo</name>
-            <snapshots>
-                <enabled>false</enabled>
-            </snapshots>
-            <releases>
-                <enabled>true</enabled>
-            </releases>
-        </repository>
-    </repositories>
+
     <build>
         <resources>
             <resource>
@@ -141,7 +129,7 @@
                     <plugin>
                         <groupId>org.apache.karaf.tooling</groupId>
                         <artifactId>features-maven-plugin</artifactId>
-                        <version>${karaf-version}</version>
+                        <version>${cxf.karaf.version}</version>
                         <configuration>
                             <file>${project.build.directory}/classes/features.xml</file>
                             <karafConfig>${project.build.directory}/classes/config.properties</karafConfig>

Modified: cxf/trunk/distribution/karaf/features/src/main/resources/features.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/features/src/main/resources/features.xml?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/distribution/karaf/features/src/main/resources/features.xml (original)
+++ cxf/trunk/distribution/karaf/features/src/main/resources/features.xml Tue Sep 27 19:46:04
2011
@@ -103,6 +103,7 @@
         <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jdom/${cxf.jdom.bundle.version}</bundle>
 
         <bundle>mvn:org.apache.cxf/cxf-bundle/${project.version}</bundle>
+        <bundle>mvn:org.apache.cxf.karaf/cxf-karaf-commands/${project.version}</bundle>
     </feature>
 
 </features>

Modified: cxf/trunk/distribution/karaf/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/karaf/pom.xml?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/distribution/karaf/pom.xml (original)
+++ cxf/trunk/distribution/karaf/pom.xml Tue Sep 27 19:46:04 2011
@@ -34,38 +34,9 @@
     <name>CXF :: Apache Karaf</name>
     <description>CXF :: Apache Karaf</description>
 
-    <properties>
-      <karaf-version>2.2.3</karaf-version>
-    </properties>
-
     <modules>
       <module>features</module>
+      <module>commands</module>
     </modules>
 
-     <repositories>
-          <repository>
-              <id>apache.snapshots</id>
-              <url>http://repository.apache.org/snapshots/</url>
-              <name>Apache Snapshot Repo</name>
-             <snapshots>
-                 <enabled>true</enabled>
-             </snapshots>
-             <releases>
-                 <enabled>false</enabled>
-             </releases>
-         </repository>
-     </repositories>
-    <pluginRepositories>
-         <pluginRepository>
-             <id>apache.snapshots</id>
-             <url>http://repository.apache.org/snapshots/</url>
-             <snapshots>
-                 <enabled>true</enabled>
-             </snapshots>
-             <releases>
-                 <enabled>false</enabled>
-             </releases>
-         </pluginRepository>
-     </pluginRepositories>
-
 </project>

Modified: cxf/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/parent/pom.xml (original)
+++ cxf/trunk/parent/pom.xml Tue Sep 27 19:46:04 2011
@@ -123,6 +123,8 @@
         <!-- various OSGi related versions -->
         <cxf.aries.version>0.3.1</cxf.aries.version>
         <cxf.osgi.version>4.2.0</cxf.osgi.version>
+        <cxf.karaf.version>2.2.4-SNAPSHOT</cxf.karaf.version>
+
         <cxf.pax.logging.version>1.6.0</cxf.pax.logging.version>
         <cxf.felix.framework.version>2.0.5</cxf.felix.framework.version>
         <cxf.felix.configadmin.version>1.2.4</cxf.felix.configadmin.version>

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/BusState.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/BusState.java?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/BusState.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/BusState.java Tue Sep 27 19:46:04 2011
@@ -19,5 +19,5 @@
 package org.apache.cxf.bus;
 
 public enum BusState {
-    INITIAL, RUNNING, SHUTTING_DOWN, SHUTDOWN;
+    INITIAL, INITIALIZING, RUNNING, SHUTTING_DOWN, SHUTDOWN;
 }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java Tue Sep 27 19:46:04
2011
@@ -145,12 +145,7 @@ public class CXFBusImpl extends Abstract
 
     public void run() {
         synchronized (this) {
-            if (state == BusState.RUNNING) {
-                // REVISIT
-                return;
-            }
             state = BusState.RUNNING;
-
             while (state == BusState.RUNNING) {
 
                 try {
@@ -163,9 +158,20 @@ public class CXFBusImpl extends Abstract
     }
 
     public void initialize() {
-        initializeFeatures();
+        setState(BusState.INITIALIZING);
+        doInitializeInternal();
+        
+        BusLifeCycleManager lifeCycleManager = this.getExtension(BusLifeCycleManager.class);
+        if (null != lifeCycleManager) {
+            lifeCycleManager.initComplete();
+        }    
+        setState(BusState.RUNNING);
     }
 
+    protected void doInitializeInternal() {
+        initializeFeatures();
+    }
+    
     protected void initializeFeatures() {
         if (features != null) {
             for (AbstractFeature f : features) {
@@ -208,7 +214,7 @@ public class CXFBusImpl extends Abstract
         BusFactory.clearDefaultBusForAnyThread(this);
     }
 
-    protected BusState getState() {
+    public BusState getState() {
         return state;
     }
 

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
Tue Sep 27 19:46:04 2011
@@ -26,7 +26,6 @@ import org.apache.cxf.binding.BindingFac
 import org.apache.cxf.binding.BindingFactoryManagerImpl;
 import org.apache.cxf.bus.BusState;
 import org.apache.cxf.bus.CXFBusImpl;
-import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.configuration.ConfiguredBeanLocator;
 import org.apache.cxf.configuration.Configurer;
@@ -144,15 +143,9 @@ public class ExtensionManagerBus extends
         this(null, null, Thread.currentThread().getContextClassLoader());
     }
     @Override
-    public void initialize() {
+    public void doInitializeInternal() {
         extensionManager.initialize();
-
-        initializeFeatures();
-
-        BusLifeCycleManager lifeCycleManager = this.getExtension(BusLifeCycleManager.class);
-        if (null != lifeCycleManager) {
-            lifeCycleManager.initComplete();
-        }        
+        super.doInitializeInternal();
     }
     protected void destroyBeans() {
         extensionManager.destroyBeans();

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java Tue Sep 27 19:46:04
2011
@@ -146,6 +146,9 @@ public class ServerImpl implements Serve
     public boolean isStopped() {
         return stopped;
     }
+    public boolean isStarted() {
+        return !stopped;
+    }
 
     public void stop() {
         if (stopped) {
@@ -158,11 +161,6 @@ public class ServerImpl implements Serve
             slcMgr.stopServer(this);
         }
         
-        if (null != serverRegistry) {
-            LOG.fine("unregister the server to serverRegistry ");
-            serverRegistry.unregister(this);
-        }
-
         MessageObserver mo = getDestination().getMessageObserver();
         if (mo instanceof MultipleEndpointObserver) {
             ((MultipleEndpointObserver)mo).getEndpoints().remove(endpoint);
@@ -177,7 +175,12 @@ public class ServerImpl implements Serve
     
     public void destroy() {
         stop();
-        
+
+        if (null != serverRegistry) {
+            LOG.fine("unregister the server to serverRegistry ");
+            serverRegistry.unregister(this);
+        }
+
         if (iMgr != null) {   
             try {
                 iMgr.unregister(mep);

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java Tue Sep
27 19:46:04 2011
@@ -19,8 +19,8 @@
 
 package org.apache.cxf.endpoint;
 
-import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
@@ -33,15 +33,15 @@ import org.apache.cxf.common.injection.N
 @NoJSR250Annotations(unlessNull = "bus")
 public class ServerRegistryImpl implements ServerRegistry, BusLifeCycleListener {
     
-    List<Server> serversList;
+    CopyOnWriteArrayList<Server> serversList;
     Bus bus;
     BusLifeCycleManager lifeCycleManager;
     
     public ServerRegistryImpl() {
-        serversList = new ArrayList<Server>();
+        serversList = new CopyOnWriteArrayList<Server>();
     }
     public ServerRegistryImpl(Bus b) {
-        serversList = new ArrayList<Server>();
+        serversList = new CopyOnWriteArrayList<Server>();
         setBus(b);
     }
 
@@ -62,7 +62,7 @@ public class ServerRegistryImpl implemen
     }
     
     public void register(Server server) {
-        serversList.add(server);        
+        serversList.addIfAbsent(server);        
     }
 
     public void unregister(Server server) {

Modified: cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/DummyServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/DummyServer.java?rev=1176568&r1=1176567&r2=1176568&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/DummyServer.java (original)
+++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/DummyServer.java Tue Sep 27 19:46:04
2011
@@ -54,4 +54,8 @@ public class DummyServer implements Serv
     public MessageObserver getMessageObserver() {
         return null;
     }
+
+    public boolean isStarted() {
+        return false;
+    }
 }



Mime
View raw message