Author: almaw
Date: Wed Jun 20 04:48:49 2007
New Revision: 549077

URL: http://svn.apache.org/viewvc?view=rev&rev=549077
Log:
Guice examples

Added:
    
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/
    
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java
   (with props)
    
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.html
   (with props)
    
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.java
   (with props)
    
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/
    
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/IMyService.java
   (with props)
    
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/MyService.java
   (with props)
Modified:
    incubator/wicket/trunk/jdk-1.5/wicket-examples/pom.xml
    
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml
    incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/index.html

Modified: incubator/wicket/trunk/jdk-1.5/wicket-examples/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/pom.xml?view=diff&rev=549077&r1=549076&r2=549077
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/pom.xml (original)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/pom.xml Wed Jun 20 04:48:49 
2007
@@ -44,6 +44,10 @@
                </dependency>
                <dependency>
                        <groupId>org.apache.wicket</groupId>
+                       <artifactId>wicket-guice</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.wicket</groupId>
                        <artifactId>wicket-jmx</artifactId>
                </dependency>
                <dependency>

Added: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java?view=auto&rev=549077
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java
 (added)
+++ 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java
 Wed Jun 20 04:48:49 2007
@@ -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.wicket.examples.guice;
+
+import org.apache.wicket.examples.WicketExampleApplication;
+import org.apache.wicket.guice.GuiceComponentInjector;
+
+/**
+ * Application for Google Guice integration example.
+ * 
+ * @author Jonathan Locke
+ */
+public class GuiceApplication extends WicketExampleApplication
+{
+       /**
+        * @see org.apache.wicket.examples.WicketExampleApplication#init()
+        */
+       @Override
+       protected void init()
+       {
+               addComponentInstantiationListener(new 
GuiceComponentInjector(this));
+       }
+       
+       /**
+        * @see org.apache.wicket.Application#getHomePage()
+        */
+       public Class getHomePage()
+       {
+               return HomePage.class;
+       }
+}

Propchange: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/GuiceApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.html
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.html?view=auto&rev=549077
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.html
 (added)
+++ 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.html
 Wed Jun 20 04:48:49 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml"; >
+<head>
+    <title>Wicket Examples - helloworld</title>
+    <link rel="stylesheet" type="text/css" href="style.css"/>
+</head>
+<body>
+    <span wicket:id="mainNavigation"/>
+    <p>
+    This page uses <a href="http://code.google.com/p/google-guice/";>Google 
Guice</a>.
+    There is a service interface called <code>IMyService</code>, with an 
implementation POJO called <code>MyService</code>.
+    Guice is used to wire the implementation into the <code>Page</code> using 
an <code>@Inject</code> annotation. You can use this
+    annotation on the fields of any <code>Component</code> subclass.    
+    </p>
+    <p>
+    The value of the <code>Label</code> component below will be updated with 
the return value from one of the service's methods when you click the link.
+    </p>
+    <hr />
+    <blockquote>
+    Value: <b wicket:id="message" id="message">Message goes here</b>
+    <br />
+    To update the label above, <a href="#" wicket:id="link">click here</a>.
+    </blockquote>
+    <hr />
+    <p>
+    The wicket-guice project will take care of proxying the injected beans so 
that your pages can be serialized safely.
+    To configure your application for Guice injection, just 
+    </p>
+    
+</body>
+</html>

Propchange: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.java?view=auto&rev=549077
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.java
 (added)
+++ 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.java
 Wed Jun 20 04:48:49 2007
@@ -0,0 +1,67 @@
+/*
+ * 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.wicket.examples.guice;
+
+import org.apache.wicket.examples.WicketExamplePage;
+import org.apache.wicket.examples.guice.service.IMyService;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+
+import com.google.inject.Inject;
+
+
+/**
+ * Everybody's favorite example, modified to use Guice.
+ * 
+ * @author Alastair Maw
+ */
+public class HomePage extends WicketExamplePage
+{
+       @Inject
+       private IMyService service;
+       
+       private String labelValue = "<not yet initialized>";
+       
+       /**
+        * Constructor
+        */
+       public HomePage()
+       {
+               add(new Link("link")
+               {
+                       /**
+                        * @see 
org.apache.wicket.markup.html.link.Link#onClick()
+                        */
+                       @Override
+                       public void onClick()
+                       {
+                               labelValue = service.getHelloWorldText();
+                       }
+               });
+               add(new Label("message", new AbstractReadOnlyModel()
+               {
+               
+                       @Override
+                       public Object getObject()
+                       {
+                               return labelValue;
+                       }
+               
+               }));
+       }
+}
\ No newline at end of file

Propchange: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/HomePage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/IMyService.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/IMyService.java?view=auto&rev=549077
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/IMyService.java
 (added)
+++ 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/IMyService.java
 Wed Jun 20 04:48:49 2007
@@ -0,0 +1,34 @@
+/*
+ * 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.wicket.examples.guice.service;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * Service interface for a simple "Hello World" app.
+ * 
+ * @author Alastair Maw
+ */
[EMAIL PROTECTED](MyService.class)
+public interface IMyService
+{
+       /**
+        * Retrieves the text to say "Hello World".
+        * @return "Hello World"
+        */
+       public String getHelloWorldText();
+}

Propchange: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/IMyService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/MyService.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/MyService.java?view=auto&rev=549077
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/MyService.java
 (added)
+++ 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/MyService.java
 Wed Jun 20 04:48:49 2007
@@ -0,0 +1,35 @@
+/*
+ * 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.wicket.examples.guice.service;
+
+/**
+ * Implementation of IService.
+ * 
+ * @author Alastair Maw
+ */
+public class MyService implements IMyService
+{
+
+       /**
+        * @see 
org.apache.wicket.examples.guice.service.IMyService#getHelloWorldText()
+        */
+       public String getHelloWorldText()
+       {
+               return "Hello World";
+       }
+
+}

Propchange: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/guice/service/MyService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml?view=diff&rev=549077&r1=549076&r2=549077
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml 
(original)
+++ 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml 
Wed Jun 20 04:48:49 2007
@@ -362,6 +362,15 @@
        </filter>
 
        <filter>
+               <filter-name>GuiceApplication</filter-name>
+               
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
+               <init-param>
+            <param-name>applicationClassName</param-name>
+            
<param-value>org.apache.wicket.examples.guice.GuiceApplication</param-value>
+               </init-param>
+       </filter>
+
+       <filter>
                <filter-name>VelocityTemplateApplication</filter-name>
                
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
                <init-param>
@@ -538,6 +547,11 @@
        <filter-mapping>
                <filter-name>SpringExample</filter-name>
         <url-pattern>/spring/*</url-pattern>
+       </filter-mapping>
+
+       <filter-mapping>
+               <filter-name>GuiceApplication</filter-name>
+        <url-pattern>/guice/*</url-pattern>
        </filter-mapping>
 
        <filter-mapping>

Modified: 
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/index.html
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/index.html?view=diff&rev=549077&r1=549076&r2=549077
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/index.html 
(original)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/webapp/index.html 
Wed Jun 20 04:48:49 2007
@@ -49,6 +49,7 @@
                        <tr><td align="right"><a 
href="spring">spring</a></td><td> - Demonstrates integration options with the 
Spring framework.</td></tr>
                        <tr><td align="right"><a 
href="authentication">authentication</a></td><td> - Demonstrates authentication 
for pages.</td></tr>
                        <tr><td align="right"><a 
href="authorization">authorization</a></td><td> - Demonstrates authorization 
for pages and components.</td></tr>
+                       <tr><td align="right"><a 
href="guice">guice</a></td><td> - Integration with the Google Guice IoC 
container.</td></tr>
                        <tr><td align="right"><a 
href="velocity">velocity</a></td><td> - Shows a Velocity panel in 
action.</td></tr>
            </table>
        </ul>


Reply via email to