You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/04/27 21:49:32 UTC
svn commit: r769132 - in
/incubator/openwebbeans/trunk/samples/guess/src/main:
java/org/apache/webbeans/sample/bindings/
java/org/apache/webbeans/sample/jms/ webapp/ webapp/WEB-INF/
Author: gerdogdu
Date: Mon Apr 27 19:49:32 2009
New Revision: 769132
URL: http://svn.apache.org/viewvc?rev=769132&view=rev
Log:
Adding JMS Sample. It works in the Java EE containers. But not every Java EE containers are tested. To work JMS Sample,
update beans.xml file with related JNDI queue name.
Added:
incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/bindings/JmsBinding.java (with props)
incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/jms/
incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/jms/JmsInjectorBean.java (with props)
incubator/openwebbeans/trunk/samples/guess/src/main/webapp/jms.xhtml (with props)
Modified:
incubator/openwebbeans/trunk/samples/guess/src/main/webapp/WEB-INF/beans.xml
Added: incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/bindings/JmsBinding.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/bindings/JmsBinding.java?rev=769132&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/bindings/JmsBinding.java (added)
+++ incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/bindings/JmsBinding.java Mon Apr 27 19:49:32 2009
@@ -0,0 +1,32 @@
+/*
+ * 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.webbeans.sample.bindings;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@BindingType
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD,ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER})
+public @interface JmsBinding
+{
+
+}
Propchange: incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/bindings/JmsBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/jms/JmsInjectorBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/jms/JmsInjectorBean.java?rev=769132&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/jms/JmsInjectorBean.java (added)
+++ incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/jms/JmsInjectorBean.java Mon Apr 27 19:49:32 2009
@@ -0,0 +1,75 @@
+/*
+ * 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.webbeans.sample.jms;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.jms.JMSException;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+
+import org.apache.webbeans.sample.bindings.JmsBinding;
+
+@RequestScoped
+@Named
+public class JmsInjectorBean
+{
+ private @JmsBinding QueueSender queueSender;
+
+ private @JmsBinding QueueSession queueSession;
+
+ private String text;
+
+ public JmsInjectorBean()
+ {
+
+ }
+
+ public String addMessage()
+ {
+ try
+ {
+ TextMessage message = queueSession.createTextMessage(this.text);
+ queueSender.send(message);
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ /**
+ * @return the text
+ */
+ public String getText()
+ {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text)
+ {
+ this.text = text;
+ }
+
+
+}
Propchange: incubator/openwebbeans/trunk/samples/guess/src/main/java/org/apache/webbeans/sample/jms/JmsInjectorBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/openwebbeans/trunk/samples/guess/src/main/webapp/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/guess/src/main/webapp/WEB-INF/beans.xml?rev=769132&r1=769131&r2=769132&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/samples/guess/src/main/webapp/WEB-INF/beans.xml (original)
+++ incubator/openwebbeans/trunk/samples/guess/src/main/webapp/WEB-INF/beans.xml Mon Apr 27 19:49:32 2009
@@ -18,6 +18,7 @@
under the License.
-->
<WebBeans xmlns="urn:java:ee"
+ xmlns:myapp="urn:java:org.apache.webbeans.sample.bindings"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:java:ee http://java.sun.com/jee/beans-1.0.xsd">
@@ -26,4 +27,11 @@
<Production/>
</Deploy>
+ <Queue>
+ <Resource>
+ <name>queue/A</name>
+ </Resource>
+ <myapp:JmsBinding/>
+ </Queue>
+
</WebBeans>
\ No newline at end of file
Added: incubator/openwebbeans/trunk/samples/guess/src/main/webapp/jms.xhtml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/guess/src/main/webapp/jms.xhtml?rev=769132&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/guess/src/main/webapp/jms.xhtml (added)
+++ incubator/openwebbeans/trunk/samples/guess/src/main/webapp/jms.xhtml Mon Apr 27 19:49:32 2009
@@ -0,0 +1,53 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+
+ 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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<head>
+ <title>OpenWebBeans :: Examples :: JMS Sample</title>
+</head>
+
+<body>
+
+ <div id="container">
+ <div id="content">
+ <h:messages globalOnly="false" showSummary="true" infoStyle="font-weight:bold;"></h:messages>
+
+ <h:form id="form">
+
+ <div style="border:1px solid black;margin: 25px 75px;">
+
+ <h:panelGrid columns="2">
+
+ <h:outputLabel for="text">
+ <h:outputText value="JMS Message Text : "></h:outputText>
+ </h:outputLabel>
+ <h:inputText id="text" value="#{jmsInjectorBean.text}" required="true" requiredMessage="Please give a JMS Message text!"></h:inputText>
+
+ <h:commandButton action="#{jmsInjectorBean.addMessage}" value="Send Message to a Queue"></h:commandButton>
+
+ </h:panelGrid>
+ </div>
+ </h:form>
+ </div>
+
+ </div>
+</body>
+</html>
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/samples/guess/src/main/webapp/jms.xhtml
------------------------------------------------------------------------------
svn:eol-style = native