cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r814684 - in /cxf/dosgi/trunk: samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/ samples/greeter/impl/src/main/java/org/apache/cxf/dosgi/samples/greeter/impl/ samples/greeter/interface/src/main/java/org/apach...
Date Mon, 14 Sep 2009 15:12:20 GMT
Author: davidb
Date: Mon Sep 14 15:12:19 2009
New Revision: 814684

URL: http://svn.apache.org/viewvc?rev=814684&view=rev
Log:
Enhanced the Greeter Demo to include an API that takes a data object.
The new GreeterService API is as follows:
  public interface GreeterService {
    Map<GreetingPhrase, String> greetMe(String name);
    GreetingPhrase [] greetMe(GreeterData name) throws GreeterException;
  }

where the GreeterData interface is defined as follows:
  public interface GreeterData {
    String getName();
    int getAge();
    boolean isException();
  }

This in response to some questions on the CXF users list around passing data objects.

Added:
    cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDataImpl.java
  (with props)
    cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDialog.java
  (with props)
    cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterData.java
  (with props)
Modified:
    cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/Activator.java
    cxf/dosgi/trunk/samples/greeter/impl/src/main/java/org/apache/cxf/dosgi/samples/greeter/impl/GreeterServiceImpl.java
    cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterService.java
    cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractBasicPublishHookTest.java
    cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractListenerHookServiceListenerTest.java

Modified: cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/Activator.java?rev=814684&r1=814683&r2=814684&view=diff
==============================================================================
--- cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/Activator.java
(original)
+++ cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/Activator.java
Mon Sep 14 15:12:19 2009
@@ -20,8 +20,7 @@
 
 import java.util.Map;
 
-import javax.swing.JOptionPane;
-
+import org.apache.cxf.dosgi.samples.greeter.GreeterData;
 import org.apache.cxf.dosgi.samples.greeter.GreeterException;
 import org.apache.cxf.dosgi.samples.greeter.GreeterService;
 import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
@@ -66,26 +65,37 @@
     private void greeterUI(final BundleContext bc, final GreeterService greeter) {
         while (true) {
             System.out.println("*** Opening greeter client dialog ***");
-            String name = JOptionPane.showInputDialog("Enter name:");
-            if (name == null) {
-                break;
-            } else {
+            Object gd = getGreeterData();
+            if (gd instanceof String) {
+                System.out.println("*** Invoking greeter ***");
+                Map<GreetingPhrase, String> result = greeter.greetMe((String) gd);
+
+                System.out.println("greetMe(\"" + gd + "\") returns:");
+                for (Map.Entry<GreetingPhrase, String> greeting : result.entrySet())
{
+                    System.out.println("  " + greeting.getKey().getPhrase() 
+                            + " " + greeting.getValue());
+                }
+            } else if (gd instanceof GreeterData) {
                 System.out.println("*** Invoking greeter ***");
                 try {
-                    Map<GreetingPhrase, String> result = greeter.greetMe(name);
-    
-                    System.out.println("greetMe(\"" + name + "\") returns:");
-                    for (Map.Entry<GreetingPhrase, String> greeting : result.entrySet())
{
-                        System.out.println("  " + greeting.getKey().getPhrase() 
-                                + " " + greeting.getValue());
+                    GreetingPhrase [] result = greeter.greetMe((GreeterData) gd);
+                    System.out.println("greetMe(\"" + gd + "\") returns:");
+                    for (GreetingPhrase phrase : result) {
+                        System.out.println("  " + phrase.getPhrase());
                     }
                 } catch (GreeterException ex) {
                     System.out.println("GreeterException : " + ex.toString());
-                }
+                }                
             }
         }
     }
 
+    private static Object getGreeterData() {
+        GreeterDialog gd = new GreeterDialog();
+        gd.setVisible(true);
+        return gd.getSelection();
+    }
+
     public void stop(BundleContext bc) throws Exception {
         tracker.close();
     }

Added: cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDataImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDataImpl.java?rev=814684&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDataImpl.java
(added)
+++ cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDataImpl.java
Mon Sep 14 15:12:19 2009
@@ -0,0 +1,45 @@
+/** 
+  * 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.dosgi.samples.greeter.client;
+
+import org.apache.cxf.dosgi.samples.greeter.GreeterData;
+
+public class GreeterDataImpl implements GreeterData {
+    private final String name;
+    private final int age;
+    private final boolean exception;
+        
+    public GreeterDataImpl(String n, int a, boolean b) {
+        name = n;
+        age = a;
+        exception = b;
+    }
+    
+    public String getName() {
+        return name;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public boolean isException() {
+        return exception;
+    }
+}

Propchange: cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDataImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDataImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDialog.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDialog.java?rev=814684&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDialog.java
(added)
+++ cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDialog.java
Mon Sep 14 15:12:19 2009
@@ -0,0 +1,189 @@
+/** 
+  * 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.dosgi.samples.greeter.client;
+
+import java.awt.Component;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class GreeterDialog extends JDialog {
+    private static final long serialVersionUID = 1L;
+    
+    Object selection;
+
+    public GreeterDialog() {
+        super((Frame) null, "Invoke Remote Greeter Service", true);
+        
+        JPanel panel = new JPanel();
+        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));     
+        setContentPane(panel);
+
+        final JRadioButton rb1 = new JRadioButton("invoke: Map<GreetingPhrase, String>
greetMe(String name);");
+        rb1.setSelected(true);
+        rb1.setAlignmentX(Component.LEFT_ALIGNMENT);        
+        panel.add(rb1);
+        
+        final JPanel simplePanel = new JPanel(new GridBagLayout());
+        simplePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+        GridBagConstraints c1 = new GridBagConstraints();
+        
+        rb1.addChangeListener(new ChangeListener() {
+            public void stateChanged(ChangeEvent e) {
+                enablePanel(simplePanel, rb1.isSelected());
+            }
+        });
+        
+        JLabel lb1 = new JLabel("Name: ");
+        c1.weightx = 0.0;
+        c1.gridx = 0;
+        c1.gridy = 0;
+        c1.insets = new Insets(0, 25, 0, 0);
+        c1.anchor = GridBagConstraints.LINE_START;
+        simplePanel.add(lb1, c1);
+        
+        final JTextField tf1 = new JTextField(20);
+        c1.weightx = 0.2;
+        c1.gridx = 1;
+        c1.gridy = 0;
+        c1.insets = new Insets(0, 10, 0, 0);
+        c1.anchor = GridBagConstraints.LINE_START;
+        simplePanel.add(tf1, c1);
+        panel.add(simplePanel);
+
+        panel.add(new JLabel(" ")); // add a spacer
+        
+        final JRadioButton rb2 = new JRadioButton("invoke: GreetingPhrase [] greetMe(GreeterData
data) throws GreeterException;");
+        rb2.setAlignmentX(Component.LEFT_ALIGNMENT);
+        panel.add(rb2);
+        
+        final JPanel complexPanel = new JPanel(new GridBagLayout());
+        complexPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+        GridBagConstraints c2 = new GridBagConstraints();
+
+        rb2.addChangeListener(new ChangeListener() {            
+            public void stateChanged(ChangeEvent e) {
+                enablePanel(complexPanel, rb2.isSelected());
+            }
+        });            
+        
+        JLabel lb2 = new JLabel("Name: ");
+        c2.weightx = 0.0;
+        c2.gridx = 0;
+        c2.gridy = 0;
+        c2.insets = new Insets(0, 25, 0, 0);
+        c2.anchor = GridBagConstraints.LINE_START;
+        complexPanel.add(lb2, c2);
+        
+        final JTextField tf2 = new JTextField(20);
+        c2.weightx = 0.2;
+        c2.gridx = 1;
+        c2.gridy = 0;
+        c2.insets = new Insets(0, 10, 0, 0);
+        c2.anchor = GridBagConstraints.LINE_START;
+        complexPanel.add(tf2, c2);        
+                
+        JLabel lb3 = new JLabel("Age: ");
+        c2.weightx = 0.0;
+        c2.gridx = 0;
+        c2.gridy = 1;
+        c2.insets = new Insets(0, 25, 0, 0);
+        c2.anchor = GridBagConstraints.LINE_START;
+        complexPanel.add(lb3, c2);
+        
+        final JTextField tf3 = new JTextField(7);
+        c2.weightx = 0.2;
+        c2.gridx = 1;
+        c2.gridy = 1;
+        c2.insets = new Insets(0, 10, 0, 0);
+        c2.anchor = GridBagConstraints.LINE_START;
+        complexPanel.add(tf3, c2);
+        
+        final JCheckBox cb1 = new JCheckBox("Throw Exception");
+        c2.weightx = 0.0;
+        c2.gridx = 0;
+        c2.gridy = 2;
+        c2.gridwidth = 2;
+        c2.insets = new Insets(0, 22, 0, 0);
+        c2.anchor = GridBagConstraints.LINE_START;
+        complexPanel.add(cb1, c2);
+
+        panel.add(complexPanel);
+        enablePanel(complexPanel, false);
+        
+        JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER));        
+        buttons.setAlignmentX(Component.LEFT_ALIGNMENT);
+        
+        JButton b1 = new JButton("Invoke");
+        buttons.add(b1);
+        
+        b1.addActionListener(new ActionListener() {            
+            public void actionPerformed(ActionEvent e) {
+                if (rb1.isSelected()) {
+                    selection = tf1.getText();
+                } else {
+                    selection = new GreeterDataImpl(tf2.getText(), new Integer(tf3.getText()),
cb1.isSelected());
+                }                
+                
+                setVisible(false);
+            }
+        });
+        
+        panel.add(buttons);
+        
+        ButtonGroup bg = new ButtonGroup();
+        bg.add(rb1);
+        bg.add(rb2);
+        
+        pack();
+        setLocationRelativeTo(null); // centers frame on screen
+    }
+    
+    public Object getSelection() {
+        return selection;
+    }
+    
+    private static void enablePanel(JPanel panel, boolean b) {
+        for (Component c : panel.getComponents()) {
+            c.setEnabled(b);
+        }
+    }
+
+    public static void main(String ... args) {
+        GreeterDialog gd = new GreeterDialog();
+        gd.setVisible(true);
+        System.exit(0);
+    }
+}

Propchange: cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDialog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/greeter/client/src/main/java/org/apache/cxf/dosgi/samples/greeter/client/GreeterDialog.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/dosgi/trunk/samples/greeter/impl/src/main/java/org/apache/cxf/dosgi/samples/greeter/impl/GreeterServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/greeter/impl/src/main/java/org/apache/cxf/dosgi/samples/greeter/impl/GreeterServiceImpl.java?rev=814684&r1=814683&r2=814684&view=diff
==============================================================================
--- cxf/dosgi/trunk/samples/greeter/impl/src/main/java/org/apache/cxf/dosgi/samples/greeter/impl/GreeterServiceImpl.java
(original)
+++ cxf/dosgi/trunk/samples/greeter/impl/src/main/java/org/apache/cxf/dosgi/samples/greeter/impl/GreeterServiceImpl.java
Mon Sep 14 15:12:19 2009
@@ -21,21 +21,15 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.cxf.dosgi.samples.greeter.GreeterData;
 import org.apache.cxf.dosgi.samples.greeter.GreeterException;
 import org.apache.cxf.dosgi.samples.greeter.GreeterService;
 import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
 
 public class GreeterServiceImpl implements GreeterService {
-
-    private final static String STRANGER_NAME = "Stranger";
-
-    public Map<GreetingPhrase, String> greetMe(String name) throws GreeterException
{
+    public Map<GreetingPhrase, String> greetMe(String name) {
         System.out.println("Invoking: greetMe(" + name + ")");
         
-        if (name.equals(STRANGER_NAME)) {
-            throw new GreeterException(name);
-        }
-
         Map<GreetingPhrase, String> greetings = 
             new HashMap<GreetingPhrase, String>();
         
@@ -48,4 +42,21 @@
         return greetings;
     }
 
+    public GreetingPhrase [] greetMe(GreeterData gd) throws GreeterException {
+        if (gd.isException()) {
+            System.out.println("Throwing custom exception from: greetMe(" + gd.getName()
+ ")");
+            throw new GreeterException(gd.getName());
+        }
+        
+        String details = gd.getName() + "(" + gd.getAge() + ")";
+        System.out.println("Invoking: greetMe(" + details + ")");
+        
+        GreetingPhrase [] greetings = new GreetingPhrase [] {
+            new GreetingPhrase("Howdy " + details),
+            new GreetingPhrase("Hallo " + details),
+            new GreetingPhrase("Ni hao " + details)
+        };
+        
+        return greetings;
+    }
 }

Added: cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterData.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterData.java?rev=814684&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterData.java
(added)
+++ cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterData.java
Mon Sep 14 15:12:19 2009
@@ -0,0 +1,25 @@
+/** 
+  * 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.dosgi.samples.greeter;
+
+public interface GreeterData {
+    String getName();
+    int getAge();
+    boolean isException();
+}

Propchange: cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterData.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterService.java?rev=814684&r1=814683&r2=814684&view=diff
==============================================================================
--- cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterService.java
(original)
+++ cxf/dosgi/trunk/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterService.java
Mon Sep 14 15:12:19 2009
@@ -22,7 +22,6 @@
 
 
 public interface GreeterService {
-
-    Map<GreetingPhrase, String> greetMe(String name) throws GreeterException;
-
+    Map<GreetingPhrase, String> greetMe(String name);
+    GreetingPhrase [] greetMe(GreeterData name) throws GreeterException;
 }

Modified: cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractBasicPublishHookTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractBasicPublishHookTest.java?rev=814684&r1=814683&r2=814684&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractBasicPublishHookTest.java
(original)
+++ cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractBasicPublishHookTest.java
Mon Sep 14 15:12:19 2009
@@ -27,6 +27,7 @@
 import java.util.Map;
 
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.dosgi.samples.greeter.GreeterData;
 import org.apache.cxf.dosgi.samples.greeter.GreeterException;
 import org.apache.cxf.dosgi.samples.greeter.GreeterService;
 import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
@@ -110,11 +111,35 @@
         assertNotNull(greeter);
         
         Map<GreetingPhrase, String> greetings = greeter.greetMe("Fred");
-
         assertEquals("Fred", greetings.get(new GreetingPhrase("Hello")));
         
         try {
-            greeter.greetMe("Stranger");
+            class GreeterDataImpl implements GreeterData {
+                private String name;
+                private int age;
+                private boolean exception;
+
+                GreeterDataImpl(String n, int a, boolean ex) {
+                    name = n;
+                    age = a;
+                    exception = ex;
+                }
+                
+                public String getName() {
+                    return name;
+                }
+
+                public int getAge() {
+                    return age;
+                }
+
+                public boolean isException() {
+                    return exception;
+                }                
+            }
+            
+            GreeterData gd = new GreeterDataImpl("Stranger", 11, true);
+            greeter.greetMe(gd);
             fail("GreeterException has to be thrown");
         } catch (GreeterException ex) {
             assertEquals("Wrong exception message", 

Modified: cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractListenerHookServiceListenerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractListenerHookServiceListenerTest.java?rev=814684&r1=814683&r2=814684&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractListenerHookServiceListenerTest.java
(original)
+++ cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractListenerHookServiceListenerTest.java
Mon Sep 14 15:12:19 2009
@@ -28,6 +28,7 @@
 import java.util.concurrent.FutureTask;
 
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.dosgi.samples.greeter.GreeterData;
 import org.apache.cxf.dosgi.samples.greeter.GreeterException;
 import org.apache.cxf.dosgi.samples.greeter.GreeterService;
 import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
@@ -191,15 +192,8 @@
     }
     
     private class GreeterServiceImpl implements GreeterService {
-
-        private final static String STRANGER_NAME = "Stranger";
-                
-        public Map<GreetingPhrase, String> greetMe(String name) 
-            throws GreeterException {
-
-            if (name.equals(STRANGER_NAME)) {
-                throw new GreeterException(name);
-            }
+        public Map<GreetingPhrase, String> greetMe(String name) {
+            System.out.println("Invoking: greetMe(" + name + ")");
             
             Map<GreetingPhrase, String> greetings = 
                 new HashMap<GreetingPhrase, String>();
@@ -213,7 +207,24 @@
             return greetings;
         }
 
-    } 
+        public GreetingPhrase [] greetMe(GreeterData gd) throws GreeterException {
+            if (gd.isException()) {
+                System.out.println("Throwing custom exception from: greetMe(" + gd.getName()
+ ")");
+                throw new GreeterException(gd.getName());
+            }
+            
+            String details = gd.getName() + "(" + gd.getAge() + ")";
+            System.out.println("Invoking: greetMe(" + details + ")");
+            
+            GreetingPhrase [] greetings = new GreetingPhrase [] {
+                new GreetingPhrase("Howdy " + details),
+                new GreetingPhrase("Hallo " + details),
+                new GreetingPhrase("Ni hao " + details)
+            };
+            
+            return greetings;
+        }
+    }
     
     private Server startServer(String address, Class<?> type, Object impl) {
         ServerFactoryBean factory = new ServerFactoryBean();



Mime
View raw message