Author: norman.richards(a)jboss.com
Date: 2009-10-02 17:07:07 -0400 (Fri, 02 Oct 2009)
New Revision: 11531
Added:
branches/community/Seam_2_2/src/flex/META-INF/flex/
branches/community/Seam_2_2/src/flex/META-INF/flex/seam-default-services-config.xml
branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/SeamFlexConfigurationManager.java
Modified:
branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/FlexFilter.java
branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/MessageBrokerManager.java
Log:
JBSEAM-4409
Added:
branches/community/Seam_2_2/src/flex/META-INF/flex/seam-default-services-config.xml
===================================================================
--- branches/community/Seam_2_2/src/flex/META-INF/flex/seam-default-services-config.xml
(rev 0)
+++
branches/community/Seam_2_2/src/flex/META-INF/flex/seam-default-services-config.xml 2009-10-02
21:07:07 UTC (rev 11531)
@@ -0,0 +1 @@
+<services-config />
Modified: branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/FlexFilter.java
===================================================================
--- branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/FlexFilter.java 2009-10-02
00:21:26 UTC (rev 11530)
+++ branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/FlexFilter.java 2009-10-02
21:07:07 UTC (rev 11531)
@@ -30,7 +30,7 @@
MessageBrokerManager messageBrokerManager;
List<Class<?>> scanned = new ArrayList<Class<?>>();
-
+
private AnnotationDeploymentHandler annotationDeploymentHandler() {
DeploymentStrategy deployment = (DeploymentStrategy)
Component.getInstance("deploymentStrategy");
@@ -105,10 +105,12 @@
public String getServletName() {
return "FlexServlet";
}
-
- public String getInitParameter(String param) {
- log.info("*** FSC getInitParam " + param);
- return params.get(param);
+
+ public String getInitParameter(String param) {
+ String result = params.get(param);
+
+ log.info("init param " + param + " is " + result);
+ return result;
}
@SuppressWarnings("unchecked")
Modified:
branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/MessageBrokerManager.java
===================================================================
---
branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/MessageBrokerManager.java 2009-10-02
00:21:26 UTC (rev 11530)
+++
branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/MessageBrokerManager.java 2009-10-02
21:07:07 UTC (rev 11531)
@@ -24,9 +24,12 @@
public class MessageBrokerManager
{
+ private static final String SEAM_ENDPOINT = "seam-amf";
+
private static final LogProvider log =
Logging.getLogProvider(MessageBrokerManager.class);
- private static String FLEXDIR = "/WEB-INF/flex/";
+ private static String WAR_CONFIG_PREFIX = "/WEB-INF/flex/";
+ private static String EAR_CONFIG_PREFIX = "/META-INF/flex/seam-default-";
private flex.messaging.MessageBroker broker;
@@ -46,7 +49,7 @@
FlexContext.setThreadLocalObjects(null, null, null, null, null, servletConfig);
ServletLogTarget.setServletContext(servletConfig.getServletContext());
- FlexConfigurationManager configManager = new FlexConfigurationManager();
+ FlexConfigurationManager configManager = new SeamFlexConfigurationManager();
MessagingConfiguration config =
configManager.getMessagingConfiguration(servletConfig);
config.createLogAndTargets();
@@ -56,12 +59,21 @@
// Set the servlet config as thread local
FlexContext.setThreadLocalObjects(null, null, broker, null, null,
servletConfig);
- setupInternalPathResolver(servletConfig.getServletContext());
setInitServletContext(broker, servletConfig.getServletContext());
// Create endpoints, services, security, and logger on the broker based on
configuration
- config.configureBroker(broker);
+ config.configureBroker(broker);
+
+ if (broker.getChannelIds()== null ||
!broker.getChannelIds().contains(SEAM_ENDPOINT)) {
+ log.info("seam-amf endpoint not found. creating...");
+
+ broker.createEndpoint(SEAM_ENDPOINT,
+
"http://{server.name}:{server.port}/{context.root}/messagebroker/seam-amf",
+ "flex.messaging.endpoints.AMFEndpoint");
+ }
+
+
//initialize the httpSessionToFlexSessionMap
synchronized(HttpFlexSession.mapLock)
{
@@ -75,6 +87,8 @@
configManager.reportTokens();
config.reportUnusedProperties();
+
+
// clear the broker and servlet config as this thread is done
FlexContext.clearThreadLocalObjects();
@@ -95,20 +109,8 @@
Reflections.invoke(setMethod, broker, ctx);
}
- private void setupInternalPathResolver(final ServletContext servletContext)
- {
- broker.setInternalPathResolver(
- new flex.messaging.MessageBroker.InternalPathResolver()
- {
- public InputStream resolve(String filename)
- {
- log.info("internal path resolver " + filename);
- return Resources.getResourceAsStream(FLEXDIR + filename,
servletContext);
- }
- }
- );
- }
+
public void destroy()
{
if (broker != null) {
@@ -133,9 +135,12 @@
Endpoint endpoint = findEndpoint(req, res);
log.info("Endpoint: " + endpoint.describeEndpoint());
- endpoint.service(req, res);
- } catch (UnsupportedOperationException ue) {
+ endpoint.service(req, res);
+ } catch (UnsupportedOperationException ue) {
+ ue.printStackTrace();
sendError(res);
+ } catch (RuntimeException e) {
+ e.printStackTrace();
} finally {
FlexContext.clearThreadLocalObjects();
}
@@ -201,6 +206,18 @@
}
+ private RemotingService createRemotingService() {
+ RemotingService remotingService = null;
+
+ remotingService = new RemotingService();
+ remotingService.setId("remoting-service");
+
+ broker.addService(remotingService);
+ log.info("Flex remotingservice not found- creating " + remotingService);
+ return remotingService;
+ }
+
+
private RemotingService findRemotingService() {
return (RemotingService) broker.getServiceByType(RemotingService.class.getName());
}
@@ -213,19 +230,20 @@
private Destination createDestination(String destinationName, String componentName) {
RemotingService remotingService = findRemotingService();
+ if (remotingService==null) {
+ remotingService = createRemotingService();
+ }
RemotingDestination destination =
(RemotingDestination) remotingService.createDestination(destinationName);
destination.setFactory(new FlexSeamFactory(destinationName, componentName));
-
-
+
// configure adapter
registerSeamAdapter(remotingService);
destination.createAdapter(SeamAdapter.SEAM_ADAPTER_ID);
-
- // XXX configure channel?
- // System.out.println("-channels " + destination.getChannels());
+
+ destination.addChannel(SEAM_ENDPOINT);
return destination;
}
Added:
branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/SeamFlexConfigurationManager.java
===================================================================
---
branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/SeamFlexConfigurationManager.java
(rev 0)
+++
branches/community/Seam_2_2/src/flex/org/jboss/seam/flex/SeamFlexConfigurationManager.java 2009-10-02
21:07:07 UTC (rev 11531)
@@ -0,0 +1,36 @@
+package org.jboss.seam.flex;
+
+import java.io.InputStream;
+
+import javax.servlet.ServletConfig;
+
+import org.jboss.seam.util.Resources;
+
+import flex.messaging.config.FlexConfigurationManager;
+import flex.messaging.config.ServletResourceResolver;
+
+public class SeamFlexConfigurationManager
+extends FlexConfigurationManager
+{
+
+ private static final String USER_CONFIG_FILE =
"/WEB-INF/flex/services-config.xml";
+ private static final String SEAM_DEFAULT_CONFIG_FILE =
"/META-INF/flex/seam-default-services-config.xml";
+
+ @Override
+ protected void setupConfigurationPathAndResolver(final ServletConfig config)
+ {
+ configurationPath = USER_CONFIG_FILE;
+
+ if (Resources.getResource(USER_CONFIG_FILE, config.getServletContext()) == null) {
+ configurationPath = SEAM_DEFAULT_CONFIG_FILE;
+ }
+
+ configurationResolver = new ServletResourceResolver(config.getServletContext()) {
+
+ @Override
+ public InputStream getConfigurationFile(String path) {
+ return Resources.getResourceAsStream(path, config.getServletContext());
+ }
+ };
+ }
+}