geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r724376 - in /geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main: java/sample/HelloWorldController.java webapp/WEB-INF/web.composite webapp/helloWorld.jsp webapp/page2.jsp
Date Mon, 08 Dec 2008 15:11:16 GMT
Author: vamsic007
Date: Mon Dec  8 07:11:15 2008
New Revision: 724376

URL: http://svn.apache.org/viewvc?rev=724376&view=rev
Log:
Updated the sample to add other allowed annotations.

Modified:
    geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/java/sample/HelloWorldController.java
    geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/WEB-INF/web.composite
    geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/helloWorld.jsp
    geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/page2.jsp

Modified: geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/java/sample/HelloWorldController.java
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/java/sample/HelloWorldController.java?rev=724376&r1=724375&r2=724376&view=diff
==============================================================================
--- geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/java/sample/HelloWorldController.java
(original)
+++ geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/java/sample/HelloWorldController.java
Mon Dec  8 07:11:15 2008
@@ -18,6 +18,10 @@
 */
 package sample;
 
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Property;
 import org.osoa.sca.annotations.Reference;
 
 /**
@@ -26,7 +30,72 @@
 public class HelloWorldController {
 
     @Reference
-    protected Helloworld fservice;
+    protected Helloworld jservice;
+    
+    // Reference name specified in the annotation
+    @Reference(name="jservice2")
+    protected Helloworld ser2;
+    
+    // Reference annotation on setter method
+    private Helloworld ser3;
+    @Reference
+    public void setJservice3(Helloworld service3) {
+        this.ser3 = service3;
+    }
+    
+    /* Test for required */
+    @Reference(required=false)
+    protected Helloworld jservice4;
+    
+    @Reference(required=false)
+    protected Helloworld jservice5;
+    
+    @Reference(required=true)
+    protected Helloworld jservice6;
+
+    @Property
+    protected String jproperty1;
+    
+    // Property name specified in the annotation
+    @Property(name="jproperty2")
+    protected int prop2;
+    
+    // Property annotation on setter method
+    private double prop3;
+    @Property
+    public void setJproperty3(double property3) {
+        this.prop3 = property3;
+    }
+    
+    /* Test for required */
+    @Property(required=false)
+    protected String jproperty4;
+
+    @Property(required=false)
+    protected String jproperty5;
+
+    @Property(required=true)
+    protected String jproperty6;
+    
+    @ComponentName
+    protected String scaComponentName;
+
+    // Annotation on setter method
+    private String scaComponentName1;
+    @ComponentName
+    public void setScaComponentName1(String scaComponentName1) {
+        this.scaComponentName1 = scaComponentName1;
+    }
+    
+    @Context
+    protected ComponentContext componentContext;
+
+    // Annotation on setter method
+    private ComponentContext componentContext1;
+    @Context
+    public void setCompContext(ComponentContext ctx) {
+        componentContext1 = ctx;
+    }
     
     private String name;
     
@@ -45,11 +114,49 @@
      * Method that is backed to a submit button of a form.
      */
     public String send() {
-        if (fservice == null) {
-            name = "fservice is null!";
+        if (jservice == null) {
+            name = "references not injected!";
         } else {
-            name = fservice.sayHello(name);
+            name = prepareMessage(name);
         }
         return "success";
     }
+
+
+    private String prepareMessage(String name) {
+        StringBuffer sb = new StringBuffer();
+        String greeting = jservice.sayHello(name);
+        String greeting2 = ser2.sayHello(name);
+        String greeting3 = ser3.sayHello(name);
+        
+        sb.append("@Reference\n");
+        sb.append("\nInjected into field. \nResult: " + greeting);
+        sb.append("\n\nInjected into field with reference name specified in the annotation.
\nResult: " + greeting2);
+        sb.append("\n\nInjected using setter method. \nResult: " + greeting3);
+        sb.append("\n\nRequired is false. Reference is not specified. "+jservice4);
+        sb.append("\n\nRequired is false. Reference is specified. "+jservice5);
+        sb.append("\n\nRequired is true. Reference is specified. "+jservice6);
+        sb.append("\n--------\n");
+        
+        sb.append("\n@Property\n");
+        sb.append("\nInjected into field: property1 = "+jproperty1);
+        sb.append("\nInjected into field with property name specified in the annotation:
property2 = "+prop2);
+        sb.append("\nInjected using setter method: Property3 = "+prop3);
+        sb.append("\nRequired is false. Property is not specified. "+jproperty4);
+        sb.append("\nRequired is false. Property is specified. "+jproperty5);
+        sb.append("\nRequired is true. Property is specified. "+jproperty6);
+        sb.append("\n--------\n");
+        
+        sb.append("\n@ComponentName\n");
+        sb.append("\nInjected into annotated field: "+scaComponentName);
+        sb.append("\nInjected using annotated method: "+scaComponentName1);
+        sb.append("\n--------\n");
+
+        sb.append("\n@Context\n");
+        sb.append("\nInjected into annotated field: "+componentContext);
+        sb.append("\nInjected using annotated method: "+componentContext1);
+        sb.append("\n--------\n");
+
+        return sb.toString();
+    }
 }

Modified: geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/WEB-INF/web.composite
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/WEB-INF/web.composite?rev=724376&r1=724375&r2=724376&view=diff
==============================================================================
--- geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/WEB-INF/web.composite
(original)
+++ geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/WEB-INF/web.composite
Mon Dec  8 07:11:15 2008
@@ -27,7 +27,19 @@
 
     <component name="helloworldJSFComponent">
         <implementation.web web-uri="helloworld-jsf.war"/>
-        <reference name="fservice" target="HelloworldComponent"/>
+        <reference name="jservice" target="HelloworldComponent"/>
+        <reference name="jservice2" target="HelloworldTeluguComponent"/>
+        <reference name="Jservice3" target="HelloworldFrenchComponent"/>
+        <!-- <reference name="jservice4" target="HelloworldComponent"/> -->
+        <reference name="jservice5" target="HelloworldComponent"/>
+        <reference name="jservice6" target="HelloworldComponent"/>
+        
+        <property name="jproperty1" type="xsd:string">JProp1</property>
+        <property name="jproperty2" type="xsd:int">700</property>
+        <property name="Jproperty3" type="xsd:double">0.007</property>
+        <!-- <property name="jproperty4" type="xsd:string">JProp4</property>
-->
+        <property name="jproperty5" type="xsd:string">JProp5</property>
+        <property name="jproperty6" type="xsd:string">JProp6</property>
     </component>
 </composite>
 

Modified: geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/helloWorld.jsp
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/helloWorld.jsp?rev=724376&r1=724375&r2=724376&view=diff
==============================================================================
--- geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/helloWorld.jsp (original)
+++ geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/helloWorld.jsp Mon
Dec  8 07:11:15 2008
@@ -23,9 +23,10 @@
 <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
 <html>
     <head>
-        <title>Hello World</title>
+        <title>Apache Tuscany Helloworld JSF sample</title>
     </head>
     <body>
+        <h2>Apache Tuscany Helloworld JSF sample</h2>
         <f:view>
             <h:form id="mainForm">
               <h:panelGrid columns="2">

Modified: geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/page2.jsp
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/page2.jsp?rev=724376&r1=724375&r2=724376&view=diff
==============================================================================
--- geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/page2.jsp (original)
+++ geronimo/plugins/tuscany/trunk/samples/helloworld-jsf/src/main/webapp/page2.jsp Mon Dec
 8 07:11:15 2008
@@ -23,12 +23,14 @@
 <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
 <html>
     <head>
-        <title>Hello World</title>
+        <title>Apache Tuscany Helloworld JSF sample</title>
     </head>
     <body>
+        <h2>Apache Tuscany Helloworld JSF sample</h2>
         <f:view>
             <h:form id="mainForm">
-                <h2><h:outputText value="Hello #{helloWorld.name}. We hope you enjoy
Apache MyFaces"/></h2>
+                <h:inputTextarea readonly="true" rows="20" cols="80" value="#{helloWorld.name}"/>
+                <br>
                 <h:commandLink action="back">
                     <h:outputText value="Home"/>
                 </h:commandLink>



Mime
View raw message