[seam-commits] Seam SVN: r11693 - in modules/trunk/remoting: examples/helloworld/src and 10 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Fri Nov 27 14:24:30 EST 2009
Author: shane.bryzak at jboss.com
Date: 2009-11-27 14:24:29 -0500 (Fri, 27 Nov 2009)
New Revision: 11693
Added:
modules/trunk/remoting/examples/helloworld/pom.xml
modules/trunk/remoting/examples/helloworld/src/
modules/trunk/remoting/examples/helloworld/src/main/
modules/trunk/remoting/examples/helloworld/src/main/java/
modules/trunk/remoting/examples/helloworld/src/main/java/org/
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/
modules/trunk/remoting/examples/helloworld/src/main/webapp/
modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/
modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/beans.xml
modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/faces-config.xml
modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/web.xml
Removed:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/RequestHandlerFactory.java
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/BaseRequestHandler.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Call.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/PollHandler.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Remoting.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/SubscriptionHandler.java
Log:
fix compiler errors, example project structure
Added: modules/trunk/remoting/examples/helloworld/pom.xml
===================================================================
--- modules/trunk/remoting/examples/helloworld/pom.xml (rev 0)
+++ modules/trunk/remoting/examples/helloworld/pom.xml 2009-11-27 19:24:29 UTC (rev 11693)
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.seam.examples</groupId>
+ <artifactId>seam-examples-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.jboss.seam.remoting.examples</groupId>
+ <artifactId>remoting-helloworld</artifactId>
+ <packaging>war</packaging>
+ <name>Seam Remoting Examples: Helloworld</name>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>codehaus snapshot repository</id>
+ <url>http://snapshots.repository.codehaus.org/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- <dependency>
+ <groupId>org.jboss.el</groupId>
+ <artifactId>jboss-el</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>-->
+
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>el-impl</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>seam-remoting-helloworld</finalName>
+ </build>
+
+</project>
+
Added: modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/beans.xml
===================================================================
Added: modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/faces-config.xml (rev 0)
+++ modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/faces-config.xml 2009-11-27 19:24:29 UTC (rev 11693)
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<faces-config version="2.0"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
+
+</faces-config>
+
Added: modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/web.xml
===================================================================
--- modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ modules/trunk/remoting/examples/helloworld/src/main/webapp/WEB-INF/web.xml 2009-11-27 19:24:29 UTC (rev 11693)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <display-name>Seam Remoting Helloworld example</display-name>
+
+ <!-- JSF -->
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+
+</web-app>
+
Modified: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/BaseRequestHandler.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/BaseRequestHandler.java 2009-11-27 18:15:35 UTC (rev 11692)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/BaseRequestHandler.java 2009-11-27 19:24:29 UTC (rev 11693)
@@ -3,18 +3,16 @@
import javax.enterprise.inject.spi.BeanManager;
import javax.servlet.ServletContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
*
* @author Shane Bryzak
*/
public abstract class BaseRequestHandler implements RequestHandler
{
- protected BeanManager beanManager;
+ protected static final Logger log = LoggerFactory.getLogger(BaseRequestHandler.class);
- public BaseRequestHandler(BeanManager beanManager)
- {
- this.beanManager = beanManager;
- }
-
public void setServletContext(ServletContext context) {}
}
Modified: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Call.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Call.java 2009-11-27 18:15:35 UTC (rev 11692)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Call.java 2009-11-27 19:24:29 UTC (rev 11693)
@@ -168,17 +168,17 @@
Class type = null;
- if (component.getType().isSessionBean()
- && component.getBusinessInterfaces().size() > 0)
+ if (true) //(component.getType().isSessionBean()
+ //&& component.getBusinessInterfaces().size() > 0)
{
- for (Class c : component.getBusinessInterfaces())
- {
- if (c.isAnnotationPresent(Local.class))
- {
- type = c;
- break;
- }
- }
+ //for (Class c : component.getBusinessInterfaces())
+ //{
+ //if (c.isAnnotationPresent(Local.class))
+ //{
+ //type = c;
+ //break;
+ //}
+ //}
if (type == null)
{
Modified: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java 2009-11-27 18:15:35 UTC (rev 11692)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java 2009-11-27 19:24:29 UTC (rev 11693)
@@ -9,8 +9,8 @@
import java.util.List;
import javax.enterprise.context.Conversation;
-import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -18,8 +18,6 @@
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jboss.seam.remoting.wrapper.Wrapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Unmarshals the calls from an HttpServletRequest, executes them in order and
@@ -30,14 +28,6 @@
public class ExecutionHandler extends BaseRequestHandler implements
RequestHandler
{
- public ExecutionHandler(BeanManager beanManager)
- {
- super(beanManager);
- }
-
- private static final Logger log = LoggerFactory
- .getLogger(ExecutionHandler.class);
-
private static final byte[] HEADER_OPEN = "<header>".getBytes();
private static final byte[] HEADER_CLOSE = "</header>".getBytes();
private static final byte[] CONVERSATION_ID_TAG_OPEN = "<conversationId>"
@@ -48,6 +38,9 @@
private static final byte[] CONTEXT_TAG_OPEN = "<context>".getBytes();
private static final byte[] CONTEXT_TAG_CLOSE = "</context>".getBytes();
+ @Inject BeanManager beanManager;
+ @Inject Conversation conversation;
+
/**
* The entry point for handling a request.
*
@@ -92,17 +85,11 @@
call.execute();
}
- Bean conversationBean = beanManager.getBeans(Conversation.class)
- .iterator().next();
- Conversation conversation = (Conversation) conversationBean
- .create(beanManager.createCreationalContext(conversationBean));
-
// Store the conversation ID in the outgoing context
ctx.setConversationId(conversation.getId());
// Package up the response
marshalResponse(calls, ctx, response.getOutputStream());
-
}
/**
Modified: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java 2009-11-27 18:15:35 UTC (rev 11692)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java 2009-11-27 19:24:29 UTC (rev 11693)
@@ -41,13 +41,8 @@
*/
public class InterfaceGenerator extends BaseRequestHandler implements
RequestHandler
-{
- public InterfaceGenerator(BeanManager beanManager)
- {
- super(beanManager);
- }
-
- private static Logger log = LoggerFactory.getLogger(InterfaceGenerator.class);
+{
+ @Inject BeanManager beanManager;
/**
* Maintain a cache of the accessible fields
@@ -284,20 +279,21 @@
Set<Class> componentTypes = new HashSet<Class>();
- if (bean.getType().isSessionBean()
- && bean.getBusinessInterfaces().size() > 0)
+// if (bean.getType().isSessionBean()
+// && bean.getBusinessInterfaces().size() > 0)
+ if (true)
{
- for (Class c : bean.getBusinessInterfaces())
- {
+ //for (Class c : bean.getBusinessInterfaces())
+ //{
// Use the Local interface
// TODO remove dependency on javax.ejb - iterate through the annotations
// instead and do a string comparison
- if (c.isAnnotationPresent(Local.class))
- {
- componentTypes.add(c);
- break;
- }
- }
+ //if (c.isAnnotationPresent(Local.class))
+ //{
+ //componentTypes.add(c);
+ //break;
+ //}
+ //}
if (componentTypes.isEmpty())
throw new RuntimeException(
@@ -305,11 +301,13 @@
.format(
"Type cannot be determined for component [%s]. Please ensure that it has a local interface.",
bean));
- } else if (bean.getType().equals(ComponentType.ENTITY_BEAN))
+ }
+ else if (false) //(bean.getType().equals(ComponentType.ENTITY_BEAN))
{
appendTypeSource(out, bean.getBeanClass(), types);
return;
- } else if (component.getType().equals(ComponentType.JAVA_BEAN))
+ }
+ else if (false) //(component.getType().equals(ComponentType.JAVA_BEAN))
{
// Check if any of the methods are annotated with @WebRemote, and if so
// treat it as an "action" component instead of a type component
@@ -327,7 +325,8 @@
appendTypeSource(out, bean.getBeanClass(), types);
return;
}
- } else
+ }
+ else
{
componentTypes.add(bean.getBeanClass());
}
Modified: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/PollHandler.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/PollHandler.java 2009-11-27 18:15:35 UTC (rev 11692)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/PollHandler.java 2009-11-27 19:24:29 UTC (rev 11693)
@@ -6,6 +6,7 @@
import java.util.List;
import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.ObjectMessage;
@@ -18,9 +19,8 @@
import org.dom4j.io.SAXReader;
import org.jboss.seam.remoting.messaging.PollError;
import org.jboss.seam.remoting.messaging.PollRequest;
+import org.jboss.seam.remoting.messaging.SubscriptionRegistry;
import org.jboss.seam.remoting.wrapper.Wrapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Handles JMS Message poll requests.
@@ -29,8 +29,6 @@
*/
public class PollHandler extends BaseRequestHandler implements RequestHandler
{
- private static Logger log = LoggerFactory.getLogger(PollHandler.class);
-
private static final byte[] ERRORS_TAG_OPEN_START = "<errors token=\""
.getBytes();
private static final byte[] ERRORS_TAG_OPEN_END = "\">".getBytes();
@@ -52,12 +50,10 @@
private static final byte[] VALUE_TAG_OPEN = "<value>".getBytes();
private static final byte[] VALUE_TAG_CLOSE = "</value>".getBytes();
-
- public PollHandler(BeanManager beanManager)
- {
- super(beanManager);
- }
+ @Inject BeanManager beanManager;
+ @Inject SubscriptionRegistry registry;
+
public void handle(HttpServletRequest request,
final HttpServletResponse response) throws Exception
{
@@ -90,8 +86,8 @@
List<Element> requestElements = env.element("body").elements("poll");
for (Element e : requestElements)
{
- requests.add(new PollRequest(e.attributeValue("token"), Integer
- .parseInt(e.attributeValue("timeout"))));
+ requests.add(new PollRequest(e.attributeValue("token"),
+ Integer.parseInt(e.attributeValue("timeout")), registry));
}
return requests;
Modified: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Remoting.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Remoting.java 2009-11-27 18:15:35 UTC (rev 11692)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Remoting.java 2009-11-27 19:24:29 UTC (rev 11693)
@@ -8,7 +8,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -24,9 +25,16 @@
* @author Shane Bryzak
*
*/
- at ApplicationScoped
public class Remoting extends HttpServlet
{
+ private static final String REQUEST_PATH_EXECUTE = "/execute";
+ private static final String REQUEST_PATH_SUBSCRIPTION = "/subscription";
+ private static final String REQUEST_PATH_POLL = "/poll";
+ private static final String REQUEST_PATH_INTERFACE = "/interface.js";
+
+ @Inject Instance<ExecutionHandler> executionHandlerInstance;
+ @Inject Instance<InterfaceGenerator> interfaceHandlerInstance;
+
public static final int DEFAULT_POLL_TIMEOUT = 10; // 10 seconds
public static final int DEFAULT_POLL_INTERVAL = 1; // 1 second
@@ -166,19 +174,16 @@
public void destroy()
{
- // TODO Auto-generated method stub
}
public ServletConfig getServletConfig()
{
- // TODO Auto-generated method stub
return null;
}
public String getServletInfo()
{
- // TODO Auto-generated method stub
return null;
}
@@ -195,14 +200,16 @@
String pathInfo = request.getPathInfo().substring(
servletConfig.getServletContext().getContextPath().length());
- RequestHandler handler = RequestHandlerFactory.getInstance()
- .getRequestHandler(pathInfo);
- if (handler != null)
+ if (REQUEST_PATH_EXECUTE.equals(pathInfo))
{
- handler.setServletContext(getServletContext());
- handler.handle(request, response);
- } else
+ executionHandlerInstance.get().handle(request, response);
+ }
+ else if (REQUEST_PATH_INTERFACE.equals(pathInfo))
{
+ interfaceHandlerInstance.get().handle(request, response);
+ }
+ else
+ {
Matcher m = pathPattern.matcher(pathInfo);
if (m.matches())
{
Deleted: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/RequestHandlerFactory.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/RequestHandlerFactory.java 2009-11-27 18:15:35 UTC (rev 11692)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/RequestHandlerFactory.java 2009-11-27 19:24:29 UTC (rev 11693)
@@ -1,54 +0,0 @@
-package org.jboss.seam.remoting;
-
-import java.util.Map;
-import java.util.HashMap;
-
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jboss.seam.remoting.messaging.SubscriptionRegistry;
-
-/**
- * Provides request handlers for different request paths.
- *
- * @author Shane Bryzak
- */
- at Singleton
-public class RequestHandlerFactory
-{
- private static final String REQUEST_PATH_EXECUTE = "/execute";
- private static final String REQUEST_PATH_SUBSCRIPTION = "/subscription";
- private static final String REQUEST_PATH_POLL = "/poll";
- private static final String REQUEST_PATH_INTERFACE = "/interface.js";
-
- private Map<String,RequestHandler> handlers = new HashMap<String,RequestHandler>();
-
- @Inject
- private RequestHandlerFactory(BeanManager beanManager)
- {
- registerHandler(REQUEST_PATH_EXECUTE, new ExecutionHandler(beanManager));
- registerHandler(REQUEST_PATH_SUBSCRIPTION, new SubscriptionHandler(beanManager));
- registerHandler(REQUEST_PATH_INTERFACE, new InterfaceGenerator(beanManager));
-
- try
- {
- Class.forName("javax.jms.Message");
- registerHandler(REQUEST_PATH_POLL, new PollHandler(beanManager));
- }
- catch (ClassNotFoundException ex)
- {
- // Don't register PollHandler, swallow the exception
- }
- }
-
- public void registerHandler(String path, RequestHandler handler)
- {
- handlers.put(path, handler);
- }
-
- public RequestHandler getRequestHandler(String path)
- {
- return handlers.get(path);
- }
-}
Modified: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/SubscriptionHandler.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/SubscriptionHandler.java 2009-11-27 18:15:35 UTC (rev 11692)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/SubscriptionHandler.java 2009-11-27 19:24:29 UTC (rev 11693)
@@ -5,7 +5,7 @@
import java.util.ArrayList;
import java.util.List;
-import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -23,11 +23,8 @@
public class SubscriptionHandler extends BaseRequestHandler implements
RequestHandler
{
- public SubscriptionHandler(BeanManager beanManager)
- {
- super(beanManager);
- }
-
+ @Inject SubscriptionRegistry registry;
+
/**
* The entry point for handling a request.
*
@@ -57,7 +54,7 @@
List<Element> elements = body.elements("subscribe");
for (Element e : elements)
{
- requests.add(new SubscriptionRequest(e.attributeValue("topic")));
+ requests.add(new SubscriptionRequest(e.attributeValue("topic"), registry));
}
for (SubscriptionRequest req : requests)
@@ -76,8 +73,7 @@
for (String token : unsubscribeTokens)
{
- RemoteSubscriber subscriber = SubscriptionRegistry.instance()
- .getSubscription(token);
+ RemoteSubscriber subscriber = registry.getSubscription(token);
if (subscriber != null)
{
subscriber.unsubscribe();
More information about the seam-commits
mailing list