You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/04/25 07:34:25 UTC
[27/51] [partial] BlazeDS Donation from Adobe Systems Inc
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/WEB-INF/src/features/bootstrapservices/MessagingBootstrapService.java
----------------------------------------------------------------------
diff --git a/apps/team/WEB-INF/src/features/bootstrapservices/MessagingBootstrapService.java b/apps/team/WEB-INF/src/features/bootstrapservices/MessagingBootstrapService.java
new file mode 100755
index 0000000..60f78ba
--- /dev/null
+++ b/apps/team/WEB-INF/src/features/bootstrapservices/MessagingBootstrapService.java
@@ -0,0 +1,330 @@
+/*
+ * 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 features.bootstrapservices;
+
+import java.util.Hashtable;
+
+import flex.messaging.MessageDestination;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.NetworkSettings;
+import flex.messaging.config.ServerSettings;
+import flex.messaging.config.ThrottleSettings;
+import flex.messaging.config.ThrottleSettings.Policy;
+import flex.messaging.services.AbstractBootstrapService;
+import flex.messaging.services.Service;
+import flex.messaging.services.messaging.adapters.JMSAdapter;
+import flex.messaging.services.messaging.adapters.JMSSettings;
+
+/**
+ * This BootstrapService is used to dynamicaly create a Messaging Service along
+ * with its Messaging Destinations without the need for any configuration files.
+ */
+public class MessagingBootstrapService extends AbstractBootstrapService
+{
+
+ /**
+ * Called by the <code>MessageBroker</code> after all of the server
+ * components are created but right before they are started. This is
+ * usually the place to create dynamic components.
+ *
+ * @param id Id of the <code>AbstractBootstrapService</code>.
+ * @param properties Properties for the <code>AbstractBootstrapService</code>.
+ */
+ public void initialize(String id, ConfigMap properties)
+ {
+ Service messagingService = createService();
+ createDestination1(messagingService);
+ createDestination2(messagingService);
+ }
+
+ /**
+ * Called by the <code>MessageBroker</code> as server starts. Useful for
+ * custom code that needs to run after all the components are initialized
+ * and the server is starting up.
+ */
+ public void start()
+ {
+ // No-op.
+ }
+
+ /**
+ * Called by the <code>MessageBroker</code> as server stops. Useful for
+ * custom code that needs to run as the server is shutting down.
+ */
+ public void stop()
+ {
+ // No-op.
+ }
+
+ /*
+ <?xml version="1.0" encoding="UTF-8"?>
+ <service id="message-service" class="flex.messaging.services.MessageService">
+
+ <!-- Example messaging-config.xml -->
+
+ <adapters>
+ <!--
+ id: a unique id specifying the adapter
+ class: the Flex Enterprise class which implements the adapter
+ possible values: flex.messaging.services.messaging.adapters.ActionScriptAdapter
+ flex.messaging.services.messaging.adapters.JMSAdapter
+ coldfusion.flex.CFEventGatewayAdapter
+ default: an optional attribute identifying the adapter to use when none is specified
+ -->
+ <adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
+ <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/>
+ </adapters>
+ */
+ private Service createService()
+ {
+ String serviceId = "messaging-service";
+ String serviceClass = "flex.messaging.services.MessageService";
+ Service messageService = broker.createService(serviceId, serviceClass);
+
+ messageService.registerAdapter("actionscript", "flex.messaging.services.messaging.adapters.ActionScriptAdapter");
+ messageService.registerAdapter("jms", "flex.messaging.services.messaging.adapters.JMSAdapter");
+ messageService.setDefaultAdapter("actionscript");
+
+ return messageService;
+ }
+
+ /*
+ <!-- Example ActionScriptAdapter destination -->
+ <destination id="MyTopic">
+ <properties>
+ <network>
+ <!--
+ Idle time in minutes for a subscriber to receive no messages
+ that triggers it to be automatically unsubscribed.
+ 0 means don't force subscribers to unsubscribe automatically.
+ Default value is 0.
+ -->
+ <subscription-timeout-minutes>0</subscription-timeout-minutes>
+
+ <!--
+ Throttling can be set up destination-wide as well as per-client.
+ The inbound policy may be NONE, ERROR or IGNORE and the outbound policy may be NONE and IGNORE.
+ All throttle frequency values are considered the maximum allowed messages per second.
+ A frequency of 0 disables throttling altogether.
+ -->
+ <throttle-inbound policy="ERROR" max-frequency="0"/>
+ <throttle-outbound policy="IGNORE" max-frequency="0"/>
+ </network>
+
+ <server>
+ <!-- Max number of messages to maintain in memory cache -->
+ <max-cache-size>1000</max-cache-size>
+
+ <!-- message-time-to-live of 0 means live forever -->
+ <message-time-to-live>0</message-time-to-live>
+
+ <!--
+ The subtopic feature lets you divide the messages that a Producer component sends to a destination
+ into specific categories at the destination. You can configure a Consumer component that subscribes to
+ the destination to receive only messages sent to a specific subtopic or set of subtopics. You use
+ wildcard characters (*) to send or receive messages from more than one subtopic. The subtopic-separator
+ element is optional; the default value is period
+ -->
+ <allow-subtopics>true</allow-subtopics>
+ <subtopic-separator>.</subtopic-separator>
+
+ <!--
+ Used to choose the algorithm for routing messages in a cluster.
+ When set to server-to-server (the default), subscriptions are
+ broadcast through the cluster to ensure each server knows which
+ destinations, subtopics, and selector expressions define subscriptions
+ for clients connected to other servers. When a data message
+ arrives, it is then only sent to servers who have clients interested
+ in that message. The other value for this setting "broadcast"
+ will simply broadcast all data messages to all servers. In this
+ mode, subscribe/unsubscribe messages are not sent across the cluster
+ -->
+ <cluster-message-routing>server-to-server</cluster-message-routing>
+ </server>
+ </properties>
+
+ <channels>
+ <!--
+ Set the ref id of the default channels to use as transport for this service.
+ The channel is defined elsewhere using the channel-definition tag.
+ -->
+ <channel ref="my-polling-amf"/>
+ </channels>
+ </destination>
+ */
+ private void createDestination1(Service service)
+ {
+ String destinationId = "MyTopic";
+ MessageDestination destination = (MessageDestination)service.createDestination(destinationId);
+
+ NetworkSettings ns = new NetworkSettings();
+ ns.setSubscriptionTimeoutMinutes(0);
+ ThrottleSettings ts = new ThrottleSettings();
+ ts.setInboundPolicy(Policy.ERROR);
+ ts.setIncomingDestinationFrequency(0);
+ ts.setOutboundPolicy(Policy.IGNORE);
+ ts.setOutgoingDestinationFrequency(0);
+ ns.setThrottleSettings(ts);
+ destination.setNetworkSettings(ns);
+
+ ServerSettings ss = new ServerSettings();
+ ss.setMessageTTL(0);
+ ss.setBroadcastRoutingMode("server-to-server");
+ destination.setServerSettings(ss);
+
+ destination.addChannel("my-polling-amf");
+ }
+
+ /*
+ <!-- Example JMSAdapter destination -->
+ <destination id="MyJMSTopic">
+ <properties>
+ <server>
+ <!-- Optional. Default is false. This option is currently only used by JMS
+ adapter when the destination-type is Topic. In that case, durable JMS
+ consumers will be used by the JMS adapter. Note that this does not
+ guarantee durability between Flex clients and JMS adapter but rather
+ between JMS adapter and JMS server.
+ <durable>false</durable>
+ </server>
+
+ <!-- For specifics on JMS, please reference the Java Message Service specification or your J2EE server documentation -->
+ <jms>
+ <!--
+ This determines whether the adapter is performing topic (pub/sub) or queue (point-to-point) messaging.
+ This element is optional and defaults to Topic.
+
+ <destination-type>Topic</destination-type>
+ -->
+
+ <!--
+ The name of the destination in JMS
+ This element is optional and defaults to the destination id
+
+ <destination-name>FlexTopic</destination-name>
+ -->
+
+ <!--
+ The javax.jms.Message type which the adapter should use for this destination.
+ Supported types: javax.jms.TextMessage, javax.jms.ObjectMessage
+ -->
+ <message-type>javax.jms.TextMessage</message-type>
+
+ <!-- The name of the JMS connection factory in JNDI -->
+ <connection-factory>jms/flex/TopicConnectionFactory</connection-factory>
+
+ <!-- The name of the destination in JNDI -->
+ <destination-jndi-name>jms/topic/flex/simpletopic</destination-jndi-name>
+
+ <!-- The JMS DeliveryMode for producers -->
+ <delivery-mode>NON_PERSISTENT</delivery-mode>
+
+ <!-- The JMS priority for messages sent by Flash producers -->
+ <message-priority>DEFAULT_PRIORITY</message-priority>
+
+ <!--
+ The message acknowledgement mode for the JMS adapter
+ None of these modes require any action on the part of the Flex messaging client.
+ Supported modes:
+ AUTO_ACKNOWLEDGE - the JMS provider client runtime automatically acknowledges the messages
+ DUPS_OK_ACKNOWLEDGE - auto-acknowledgement of the messages is not required
+ CLIENT_ACKNOWLEDGE - the JMS adapter should acknowledge that the message was received
+ -->
+ <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
+
+ <!-- The JMS session transaction mode -->
+ <transacted-sessions>false</transacted-sessions>
+
+ <!--
+ The maximum number of producer proxies that this destination
+ should use when communicating with the JMS Server. The default
+ is 1 which implies all clients using this destinatin will
+ share the same connection to the JMS server.
+ -->
+ <max-producers>1</max-producers>
+
+ <!-- (Optional) JNDI environment. Use when using JMS on a remote JNDI server.
+ Used to specify the JNDI environment to access an external JMS provider.
+ -->
+ <initial-context-environment>
+ <property>
+ <name>Context.SECURITY_PRINCIPAL</name>
+ <value>anonymous</value>
+ </property>
+ <property>
+ <name>Context.SECURITY_CREDENTIALS</name>
+ <value>anonymous</value>
+ </property>
+ <property>
+ <name>Context.PROVIDER_URL</name>
+ <value>http://{server.name}:1856</value>
+ </property>
+ <property>
+ <name>Context.INITIAL_CONTEXT_FACTORY</name>
+ <value>fiorano.jms.runtime.naming.FioranoInitialContextFactory</value>
+ </property>
+ </initial-context-environment>
+ </jms>
+ </properties>
+
+ <channels>
+ <channel ref="my-polling-amf"/>
+ </channels>
+
+ <security>
+ <security-constraint ref="sample-users"/>
+ </security>
+
+ <adapter ref="jms"/>
+ </destination>
+ */
+ private void createDestination2(Service service)
+ {
+ String destinationId = "MyJMSTopic";
+ MessageDestination destination = (MessageDestination)service.createDestination(destinationId);
+
+ ServerSettings ss = new ServerSettings();
+ ss.setDurable(false);
+ destination.setServerSettings(ss);
+
+ String adapterId = "jms";
+ JMSAdapter adapter = (JMSAdapter)destination.createAdapter(adapterId);
+
+ // JMS settings are set at the adapter level
+ JMSSettings jms = new JMSSettings();
+ jms.setDestinationType("Topic");
+ jms.setMessageType("javax.jms.TextMessage");
+ jms.setConnectionFactory("jms/flex/TopicConnectionFactory");
+ jms.setDestinationJNDIName("jms/topic/flex/simpletopic");
+ jms.setDeliveryMode("NON_PERSISTENT");
+ //jms.setMessagePriority(javax.jms.Message.DEFAULT_PRIORITY);
+ jms.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
+ jms.setMaxProducers(1);
+ Hashtable envProps = new Hashtable();
+ envProps.put("Context.SECURITY_PRINCIPAL", "anonymous");
+ envProps.put("Context.SECURITY_CREDENTIALS", "anonymous");
+ envProps.put("Context.PROVIDER_URL", "http://{server.name}:1856");
+ envProps.put("Context.INITIAL_CONTEXT_FACTORY", "fiorano.jms.runtime.naming.FioranoInitialContextFactory");
+ jms.setInitialContextEnvironment(envProps);
+ adapter.setJMSSettings(jms);
+
+ destination.setSecurityConstraint("sample-users");
+
+ destination.addChannel("my-polling-amf");
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/WEB-INF/src/features/bootstrapservices/RemotingBootstrapService.java
----------------------------------------------------------------------
diff --git a/apps/team/WEB-INF/src/features/bootstrapservices/RemotingBootstrapService.java b/apps/team/WEB-INF/src/features/bootstrapservices/RemotingBootstrapService.java
new file mode 100755
index 0000000..8422a17
--- /dev/null
+++ b/apps/team/WEB-INF/src/features/bootstrapservices/RemotingBootstrapService.java
@@ -0,0 +1,220 @@
+/*
+ * 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 features.bootstrapservices;
+
+import flex.messaging.config.ConfigMap;
+import flex.messaging.services.AbstractBootstrapService;
+import flex.messaging.services.Service;
+import flex.messaging.services.remoting.RemotingDestination;
+
+/**
+ * This BootstrapService is used to dynamicaly create a Remoting Service along
+ * with its Remoting Destinations without the need for any configuration files.
+ */
+public class RemotingBootstrapService extends AbstractBootstrapService
+{
+
+ /**
+ * Called by the <code>MessageBroker</code> after all of the server
+ * components are created but right before they are started. This is
+ * usually the place to create dynamic components.
+ *
+ * @param id Id of the <code>AbstractBootstrapService</code>.
+ * @param properties Properties for the <code>AbstractBootstrapService</code>.
+ */
+ public void initialize(String id, ConfigMap properties)
+ {
+ Service remotingService = createService();
+ createDestination1(remotingService);
+ createDestination2(remotingService);
+ createDestination3(remotingService);
+ }
+
+ /**
+ * Called by the <code>MessageBroker</code> as server starts. Useful for
+ * custom code that needs to run after all the components are initialized
+ * and the server is starting up.
+ */
+ public void start()
+ {
+ // No-op.
+ }
+
+ /**
+ * Called by the <code>MessageBroker</code> as server stops. Useful for
+ * custom code that needs to run as the server is shutting down.
+ */
+ public void stop()
+ {
+ // No-op.
+ }
+
+ /*
+ <?xml version="1.0" encoding="UTF-8"?>
+ <service id="remoting-service" class="flex.messaging.services.RemotingService">
+
+ <!-- Example remoting-config.xml -->
+
+ <!--
+ The set of adapters available for this service. A service uses an
+ adapter to handle the implementation specifc details of a
+ destination.
+ -->
+ <adapters>
+ <!--
+ id: A unique id for this adapter-definition. Destinations use this
+ id to select which adapter should be used to process requests.
+ class: The implementation class for the adapter. A single Remoting
+ Service adapter ships with Flex 2:
+ flex.messaging.services.remoting.adapters.JavaAdapter
+ default: An optional boolean attribute identifying the adapter to
+ use when none is specified for a destination.
+ -->
+ <adapter-definition id="java-object"
+ class="flex.messaging.services.remoting.adapters.JavaAdapter"
+ default="true"/>
+ </adapters>
+
+ <!--
+ The set of default channels to use to transport messages to
+ remoting-service destinations.
+ -->
+ <default-channels>
+ <!--
+ ref: A reference to a channel-definition id. Channels are defined
+ in the top level configuration file.
+ -->
+ <channel ref="my-amf"/>
+ <channel ref="my-http"/>
+ </default-channels>
+ */
+ private Service createService()
+ {
+ String serviceId = "remoting-service";
+ String serviceClass = "flex.messaging.services.RemotingService";
+ Service remotingService = broker.createService(serviceId, serviceClass);
+
+ String adapterId = "java-object";
+ String adapterClass = "flex.messaging.services.remoting.adapters.JavaAdapter";
+ remotingService.registerAdapter(adapterId, adapterClass);
+ remotingService.setDefaultAdapter(adapterId);
+
+ remotingService.addDefaultChannel("my-amf");
+ remotingService.addDefaultChannel("my-http");
+
+ return remotingService;
+ }
+
+ /*
+ <!--
+ A simple example.
+
+ This destination uses the default set of channels 'my-amf' and
+ 'my-http', relies on the default adapter configured for this service,
+ 'java-object' (an instance of JavaAdapter), will use the default factory
+ of the JavaAdapter - the flex.messaging.factories.JavaFactory, and
+ POJO instances of the class specified by the source property will be
+ created in the default scope, the 'request' scope.
+ -->
+ <destination id="sample">
+ <properties>
+ <!-- source is the Java class name of the destination -->
+ <source>my.company.SampleService</source>
+ </properties>
+ </destination>
+ */
+ private void createDestination1(Service service)
+ {
+ String destinationId = "sample";
+ RemotingDestination destination = (RemotingDestination)service.createDestination(destinationId);
+ destination.setSource("my.company.SampleService");
+ }
+
+ /*
+ <!--
+ A more complex example.
+
+ A custom factory is used to create instances of the source specified
+ for this destination. Instances will be shared between requests in
+ the same session. This destination also restricts access to
+ authenticated users who are in the 'sampleusers' role.
+ -->
+ <destination id="sampleByFactoryAndSecure">
+ <security>
+ <security-constraint ref="sample-users" />
+ </security>
+ <properties>
+ <!--
+ myJavaFactory is defined in the main configuration file. The
+ source and all other properties are used by the factory to
+ create the java class. Factory instance provides the java class
+ based on the properties provided such as scope.
+ -->
+ <factory>myJavaFactory</factory>
+ <source>my.company.SampleService</source>
+ <!-- Possible scope values are request, session or application. -->
+ <scope>session</scope>
+ </properties>
+ </destination>
+ */
+ private void createDestination2(Service service)
+ {
+ String destinationId = "sampleByFactoryAndSecure";
+ RemotingDestination destination = (RemotingDestination)service.createDestination(destinationId);
+ destination.setSecurityConstraint("sample-users");
+ destination.setFactory("myJavaFactory");
+ destination.setSource("my.company.SampleService");
+ destination.setScope("session");
+ }
+
+ /*
+ <!--
+ A verbose example using child tags.
+ -->
+ <destination id="sampleVerbose">
+ <channels>
+ <channel ref="my-secure-amf" />
+ <channel ref="my-secure-http" />
+ </channels>
+ <adapter ref="java-object" />
+ <security>
+ <security-constraint ref="sample-users" />
+ </security>
+ <properties>
+ <source>my.company.SampleService</source>
+ <scope>session</scope>
+ <factory>myJavaFactory</factory>
+ </properties>
+ </destination>
+ */
+ private void createDestination3(Service service)
+ {
+ String destinationId = "sampleVerbose";
+ RemotingDestination destination = (RemotingDestination)service.createDestination(destinationId);
+ destination.addChannel("my-secure-amf");
+ destination.addChannel("my-secure-http");
+
+ String adapterId = "java-object";
+ destination.createAdapter(adapterId);
+
+ destination.setSecurityConstraint("sample-users");
+ destination.setSource("my.company.SampleService");
+ destination.setScope("session");
+ destination.setFactory("myJavaFactory");
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/WEB-INF/src/features/messaging/customadapter/CustomActionscriptAdapter.java
----------------------------------------------------------------------
diff --git a/apps/team/WEB-INF/src/features/messaging/customadapter/CustomActionscriptAdapter.java b/apps/team/WEB-INF/src/features/messaging/customadapter/CustomActionscriptAdapter.java
new file mode 100755
index 0000000..c5fa57e
--- /dev/null
+++ b/apps/team/WEB-INF/src/features/messaging/customadapter/CustomActionscriptAdapter.java
@@ -0,0 +1,96 @@
+/*
+ * 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 features.messaging.customadapter;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import flex.messaging.MessageClient;
+import flex.messaging.MessageClientListener;
+import flex.messaging.messages.CommandMessage;
+import flex.messaging.services.messaging.adapters.ActionScriptAdapter;
+
+/**
+ * A sample custom adapter that keeps track its own subscriptions.
+ */
+public class CustomActionscriptAdapter extends ActionScriptAdapter implements MessageClientListener
+{
+ /**
+ * Set of subscriptions (clientIds).
+ */
+ private Set<String> clientIds = new HashSet<String>();
+
+ /**
+ * Default constructor adds itself as the MessageClient created listener so
+ * it can get creation notifications as Consumers subscribe (and MessageClients
+ * get created for them on the server).
+ */
+ public CustomActionscriptAdapter()
+ {
+ MessageClient.addMessageClientCreatedListener(this);
+ }
+
+ /**
+ * Manage method is called when Consumer subscribes/unsubscribes.
+ * Override to update the clientIds set.
+ */
+ @Override public Object manage(CommandMessage commandMessage)
+ {
+ int operation = commandMessage.getOperation();
+ String clientId = (String)commandMessage.getClientId();
+ switch (operation)
+ {
+ case CommandMessage.SUBSCRIBE_OPERATION:
+ clientIds.add(clientId);
+ break;
+ case CommandMessage.UNSUBSCRIBE_OPERATION:
+ clientIds.remove(clientId);
+ break;
+ default:
+ break;
+ }
+ return super.manage(commandMessage);
+ }
+
+ /**
+ * Return true, so manage method gets called as Consumer subscribes.
+ */
+ public boolean handlesSubscriptions()
+ {
+ return true;
+ }
+
+ /**
+ * Implements {@link MessageClientListener#messageClientCreated(MessageClient)}
+ */
+ public void messageClientCreated(MessageClient messageClient)
+ {
+ // Add the adapter as MessageClient destroyed listener, so it can get
+ // destruction notifications as the MessageClient gets destroyed due to
+ // Consumer unsubscribe, disconnect, or session invalidation.
+ messageClient.addMessageClientDestroyedListener(this);
+ }
+
+ /**
+ * Implements {@link MessageClientListener#messageClientDestroyed(MessageClient)}
+ */
+ public void messageClientDestroyed(MessageClient messageClient)
+ {
+ String clientId = (String)messageClient.getClientId();
+ clientIds.remove(clientId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/WEB-INF/src/features/messaging/serverpush/ServerPushService.java
----------------------------------------------------------------------
diff --git a/apps/team/WEB-INF/src/features/messaging/serverpush/ServerPushService.java b/apps/team/WEB-INF/src/features/messaging/serverpush/ServerPushService.java
new file mode 100755
index 0000000..5f46143
--- /dev/null
+++ b/apps/team/WEB-INF/src/features/messaging/serverpush/ServerPushService.java
@@ -0,0 +1,130 @@
+/*
+ * 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 features.messaging.serverpush;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import flex.messaging.FlexContext;
+import flex.messaging.MessageBroker;
+import flex.messaging.messages.AsyncMessage;
+import flex.messaging.messages.Message;
+import flex.messaging.util.UUIDUtils;
+
+/**
+ * This class can be used as a remote object by Flex client to start/stop pushing
+ * messages from the server.
+ */
+public class ServerPushService
+{
+ static int INFINITE_RUN = -1;
+
+ ScheduledExecutorService messagePushService;
+ MessageBroker broker;
+ int messageCount;
+ int currentRunCount;
+ int runCount;
+
+ public ServerPushService()
+ {
+ broker = FlexContext.getMessageBroker();
+ }
+
+ /**
+ * Push the specified number of messages per the specified number of millis,
+ * runCount number of times (-1 means indefinitely) to the specified destination.
+ */
+ public void startPush(String destinationId, int numberOfMessages, long numberOfMillis, int runCount)
+ {
+ startPush(destinationId, null, numberOfMessages, numberOfMillis, runCount);
+ }
+
+ /**
+ * Push the specified number of messages per the specified number of millis,
+ * runCount number of times (-1 means indefinitely) to the specified destination
+ * and subtopic.
+ */
+ public void startPush(String destinationId, String subtopic, int numberOfMessages, long numberOfMillis, int runCount)
+ {
+ if (messagePushService == null)
+ messagePushService = Executors.newScheduledThreadPool(10);
+
+ this.runCount = runCount;
+ currentRunCount = 0;
+
+ System.out.println("*** ServerPushService started: sending '" + numberOfMessages
+ + "' messages in '" + numberOfMillis + "ms' to destination '" + destinationId + "'[" + subtopic + "].");
+
+ MessageSenderCallable msc = new MessageSenderCallable(destinationId, subtopic, numberOfMessages, numberOfMillis);
+ messagePushService.schedule(msc, numberOfMillis, TimeUnit.MILLISECONDS);
+ }
+
+ public void stopPush()
+ {
+ if (messagePushService != null)
+ {
+ System.out.println("*** ServerPushService stopped.");
+ messagePushService.shutdown();
+ messagePushService = null;
+ }
+ }
+
+ class MessageSenderCallable implements Callable<Object>
+ {
+ private String destinationId;
+ private int numberOfMessages;
+ private long numberOfMillis;
+ private String subtopic;
+
+ public MessageSenderCallable(String destinationId, String subtopic, int numberOfMessages, long numberOfMillis)
+ {
+ this.destinationId = destinationId;
+ this.numberOfMessages = numberOfMessages;
+ this.numberOfMillis = numberOfMillis;
+ this.subtopic = subtopic;
+ }
+
+ public Object call() throws Exception
+ {
+ for (int i = 0; i < numberOfMessages; i++)
+ {
+ Message message = createMessage();
+ broker.routeMessageToService(message, null);
+ }
+ if (runCount == INFINITE_RUN || ++currentRunCount < runCount)
+ {
+ MessageSenderCallable messageSenderCallable = new MessageSenderCallable(destinationId, subtopic, numberOfMessages, numberOfMillis);
+ messagePushService.schedule(messageSenderCallable, numberOfMillis, TimeUnit.MILLISECONDS);
+ }
+ return null;
+ }
+
+ private Message createMessage()
+ {
+ AsyncMessage msg = new AsyncMessage();
+ msg.setDestination(destinationId);
+ msg.setMessageId(UUIDUtils.createUUID(false));
+ msg.setTimestamp(System.currentTimeMillis());
+ msg.setBody("Foo" + messageCount++);
+ if (subtopic != null)
+ msg.setHeader(AsyncMessage.SUBTOPIC_HEADER_NAME, subtopic);
+ return msg;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/WEB-INF/src/features/remoting/AMFConnectionTest.java
----------------------------------------------------------------------
diff --git a/apps/team/WEB-INF/src/features/remoting/AMFConnectionTest.java b/apps/team/WEB-INF/src/features/remoting/AMFConnectionTest.java
new file mode 100755
index 0000000..8bf62a5
--- /dev/null
+++ b/apps/team/WEB-INF/src/features/remoting/AMFConnectionTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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 features.remoting;
+
+import flex.messaging.io.amf.client.AMFConnection;
+import flex.messaging.io.amf.client.exceptions.ClientStatusException;
+import flex.messaging.io.amf.client.exceptions.ServerStatusException;
+
+/**
+ * An AMFConnection sample that talks to a remoting destination.
+ */
+public class AMFConnectionTest
+{
+ private static final String DEFAULT_URL = "http://localhost:8400/team/messagebroker/amf";
+ private static final String DEFAULT_DESTINATION_ID = "remoting_AMF";
+
+ /**
+ * Given a remote method name, returns the AMF connection call needed using
+ * the default destination id.
+ */
+ private static String getOperationCall(String method)
+ {
+ return DEFAULT_DESTINATION_ID + "." + method;
+ }
+
+ // Not a test, just an example to show how to use AMFConnection.
+ public static void main(String[] args2)
+ {
+ // Create the AMF connection.
+ AMFConnection amfConnection = new AMFConnection();
+
+ // Connect to the remote url.
+ try
+ {
+ amfConnection.connect(DEFAULT_URL);
+ }
+ catch (ClientStatusException cse)
+ {
+ cse.printStackTrace();
+ }
+
+ // Make a remoting call and retrieve the result.
+ try
+ {
+ Object result = amfConnection.call(getOperationCall("echo"), "Foo");
+ System.out.println("Result: " + result);
+ }
+ catch (ClientStatusException cse)
+ {
+ cse.printStackTrace();
+ }
+ catch (ServerStatusException sse)
+ {
+ sse.printStackTrace();
+ }
+ finally
+ {
+ System.out.println("Done");
+ amfConnection.close();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/WEB-INF/src/features/remoting/EchoService.java
----------------------------------------------------------------------
diff --git a/apps/team/WEB-INF/src/features/remoting/EchoService.java b/apps/team/WEB-INF/src/features/remoting/EchoService.java
new file mode 100755
index 0000000..818a3ac
--- /dev/null
+++ b/apps/team/WEB-INF/src/features/remoting/EchoService.java
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ */
+/**
+ * A simple class that simply echoes back the provided text. Used by remoting
+ * samples.
+ */
+package features.remoting;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import features.remoting.externalizable.ExternalizableClass;
+import flex.messaging.io.BeanProxy;
+import flex.messaging.io.PropertyProxyRegistry;
+
+public class EchoService
+{
+ // Making sure the read-only properties of ReadOnly class are serialized
+ // back to the client.
+ static
+ {
+ PropertyProxyRegistry registry = PropertyProxyRegistry.getRegistry();
+ BeanProxy beanProxy = new BeanProxy();
+ beanProxy.setIncludeReadOnly(true);
+ registry.register(ReadOnly.class, beanProxy);
+ }
+
+ public String echo(String text)
+ {
+ return "I received '" + text + "' from you";
+ }
+
+ public int echoInt(int value)
+ {
+ return value;
+ }
+
+ public boolean echoBoolean(boolean value)
+ {
+ return value;
+ }
+
+ public List echoDenseArray(List array)
+ {
+ return array;
+ }
+
+ public Map echoSparseArray(Map array)
+ {
+ return array;
+ }
+
+ public Map echoMap(Map map)
+ {
+ return map;
+ }
+
+ public Map echoDictionary(Map dict)
+ {
+ return dict;
+ }
+
+ public Object echoIntVector(Object vector)
+ {
+ return vector;
+ }
+
+ public Object echoUIntVector(Object vector)
+ {
+ return vector;
+ }
+
+ public Object echoDoubleVector(Object vector)
+ {
+ return vector;
+ }
+
+ public Object echoObjectVector(Object vector)
+ {
+ return vector;
+ }
+
+ public Object echoStringVector(Object vector)
+ {
+ return vector;
+ }
+
+ public ExternalizableClass echoExternalizableClass(ExternalizableClass value)
+ {
+ return value;
+ }
+
+ public ReadOnly echoReadOnly()
+ {
+ ReadOnly ro = new ReadOnly("property1");
+ return ro;
+ }
+
+ // A Class that only has a read-only property.
+ public class ReadOnly
+ {
+ private String property;
+
+ public ReadOnly(String property)
+ {
+ this.property = property;
+ }
+
+ public String getProperty()
+ {
+ return property;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/WEB-INF/src/features/remoting/externalizable/ExternalizableClass.java
----------------------------------------------------------------------
diff --git a/apps/team/WEB-INF/src/features/remoting/externalizable/ExternalizableClass.java b/apps/team/WEB-INF/src/features/remoting/externalizable/ExternalizableClass.java
new file mode 100755
index 0000000..c681502
--- /dev/null
+++ b/apps/team/WEB-INF/src/features/remoting/externalizable/ExternalizableClass.java
@@ -0,0 +1,43 @@
+/*
+ * 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 features.remoting.externalizable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * A simple class that uses Externalizable interface to read and write its properties.
+ */
+public class ExternalizableClass implements Externalizable
+{
+ private String property1;
+ private String property2;
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ property1 = (String)in.readObject();
+ property2 = (String)in.readObject();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeObject(property1);
+ out.writeObject(property2);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/WEB-INF/src/features/runtimeconfig/RuntimeConfigurator.java
----------------------------------------------------------------------
diff --git a/apps/team/WEB-INF/src/features/runtimeconfig/RuntimeConfigurator.java b/apps/team/WEB-INF/src/features/runtimeconfig/RuntimeConfigurator.java
new file mode 100755
index 0000000..ef4b3c3
--- /dev/null
+++ b/apps/team/WEB-INF/src/features/runtimeconfig/RuntimeConfigurator.java
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+/**
+ * A class that is meant to be used by a remoting destination to create destinations
+ * dynamically after server startup. The remoting destination is meant to be
+ * invoked by Flex clients to create dynamic destinations and use them.
+ */
+package features.runtimeconfig;
+
+import flex.messaging.MessageBroker;
+import flex.messaging.MessageDestination;
+import flex.messaging.services.MessageService;
+import flex.messaging.services.messaging.adapters.JMSAdapter;
+import flex.messaging.services.messaging.adapters.JMSSettings;
+
+public class RuntimeConfigurator
+{
+ MessageBroker msgBroker;
+
+ public RuntimeConfigurator()
+ {
+ msgBroker = MessageBroker.getMessageBroker(null);
+ }
+
+ /*
+ <destination id="messaging_AMF_Poll_Runtime" channels="my-amf-poll"/>
+ */
+ public String createMessageDestination()
+ {
+ String serviceId = "message-service";
+ String id = "messaging_AMF_Poll_Runtime";
+
+ MessageService msgService = (MessageService)msgBroker.getService(serviceId);
+ MessageDestination msgDestination = (MessageDestination)msgService.createDestination(id);
+ msgDestination.addChannel("my-amf-poll");
+
+ if (msgService.isStarted())
+ msgDestination.start();
+
+ return "Destination: " + id + " created for Service: " + serviceId;
+ }
+
+ /*
+ <destination id="messaging_AMF_Poll_Runtime" channels="my-amf-poll"/>
+ */
+ public String removeMessageDestination()
+ {
+ String serviceId = "message-service";
+ String id = "messaging_AMF_Poll_Runtime";
+
+ MessageService msgService = (MessageService)msgBroker.getService(serviceId);
+ msgService.removeDestination(id);
+
+ return "Destination: " + id + " removed from Service: " + serviceId;
+ }
+
+ /*
+ <destination id="messaging_AMF_Poll_JMS_Topic_Runtime" channels="my-amf-poll">
+ <adapter ref="jms"/>
+ <properties>
+ <jms>
+ <connection-factory>java:comp/env/jms/flex/TopicConnectionFactory</connection-factory>
+ <destination-type>Topic</destination-type>
+ <destination-jndi-name>java:comp/env/jms/topic/flex/simpletopic</destination-jndi-name>
+ <message-type>javax.jms.TextMessage</message-type>
+ </jms>
+ </properties>
+ </destination>
+ */
+ public String createMessageDestinationWithJMSAdapter()
+ {
+ String serviceId = "message-service";
+ String id = "messaging_AMF_Poll_JMS_Topic_Runtime";
+
+ MessageService msgService = (MessageService)msgBroker.getService(serviceId);
+ MessageDestination msgDestination = (MessageDestination)msgService.createDestination(id);
+ msgDestination.addChannel("my-amf-poll");
+
+ // Use JMSSettings object for the <jms> properties above
+ JMSSettings js = new JMSSettings();
+ js.setConnectionFactory("java:comp/env/jms/flex/TopicConnectionFactory");
+ js.setDestinationType("Topic");
+ js.setMessageType("javax.jms.TextMessage");
+ js.setDestinationJNDIName("java:comp/env/jms/topic/flex/simpletopic");
+
+ JMSAdapter adapter = new JMSAdapter();
+ adapter.setId("jms");
+ adapter.setJMSSettings(js);
+ adapter.setDestination(msgDestination);
+
+ if (msgService.isStarted())
+ msgDestination.start();
+
+ return "Destination: " + id + " created for Service: " + serviceId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/WEB-INF/src/features/validators/deserialization/ClassLoggingDeserializationValidator.java
----------------------------------------------------------------------
diff --git a/apps/team/WEB-INF/src/features/validators/deserialization/ClassLoggingDeserializationValidator.java b/apps/team/WEB-INF/src/features/validators/deserialization/ClassLoggingDeserializationValidator.java
new file mode 100755
index 0000000..2dff3da
--- /dev/null
+++ b/apps/team/WEB-INF/src/features/validators/deserialization/ClassLoggingDeserializationValidator.java
@@ -0,0 +1,127 @@
+/*
+ * 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 features.validators.deserialization;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import flex.messaging.config.ConfigMap;
+import flex.messaging.log.Log;
+import flex.messaging.validators.DeserializationValidator;
+
+/**
+ * This is a sample deserialization validator. It does not perform any real assignment
+ * and creation validations but instead, it keeps track of an internal set of class
+ * types, and when the class type is first encountered, it logs out the type of the class.
+ * One can use this validator to determine what class types are deserialized on the server.
+ */
+public class ClassLoggingDeserializationValidator implements DeserializationValidator
+{
+ //--------------------------------------------------------------------------
+ //
+ // Public Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ public static String LOG_CATEGORY = "Endpoint.Deserialization.Creation";
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Instance level lock for thread-safe state changes.
+ */
+ protected final Object lock = new Object();
+
+ /**
+ * Keeps track of encountered class names.
+ */
+ protected final Set<String> classNames = new HashSet<String>();
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * No assignment validation; simply returns true.
+ *
+ * @param instance The Array or List instance.
+ * @param index The index at which the value is being assigned.
+ * @param value The value that is assigned to the index.
+ * @return True if the assignment is valid.
+ */
+ public boolean validateAssignment(Object instance, int index, Object value)
+ {
+ return true;
+ }
+
+ /**
+ * No assignment validation; simply returns true.
+ *
+ * @param instance The instance with the property that is being assigned a new value.
+ * @param propertyName The name of the property that is being assigned.
+ * @param value The value that the property is being assigned to.
+ * @return True.
+ */
+ public boolean validateAssignment(Object instance, String propertyName, Object value)
+ {
+ return true;
+ }
+
+ /**
+ * No creation validation; simply returns true, but when a class is
+ * encountered the first time an Info level log message is printed
+ * to the Endpoint.Deserialization.Creation category listing the class name.
+ * Registering this validator in a development or test environment allows
+ * all required types used by the application to be captured in the server log,
+ * and this information may be used to configure a <tt>ClassDeserializationValidator</tt>
+ * in the production environment that disallows creation of all non-required types.
+ *
+ * @param c The class that is being created.
+ * @return True.
+ */
+ public boolean validateCreation(Class<?> c)
+ {
+ String className = c == null? null : c.getName();
+ if (className != null)
+ {
+ synchronized(lock)
+ {
+ if (!classNames.contains(className))
+ {
+ if (Log.isInfo())
+ Log.getLogger(LOG_CATEGORY).info(className);
+ classNames.add(className);
+ }
+ }
+ }
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see flex.messaging.FlexConfigurable#initialize(java.lang.String, flex.messaging.config.ConfigMap)
+ */
+ public void initialize(String id, ConfigMap configMap)
+ {
+ // No-op.
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/WEB-INF/src/features/validators/deserialization/TestDeserializationValidator.java
----------------------------------------------------------------------
diff --git a/apps/team/WEB-INF/src/features/validators/deserialization/TestDeserializationValidator.java b/apps/team/WEB-INF/src/features/validators/deserialization/TestDeserializationValidator.java
new file mode 100755
index 0000000..51c790e
--- /dev/null
+++ b/apps/team/WEB-INF/src/features/validators/deserialization/TestDeserializationValidator.java
@@ -0,0 +1,58 @@
+/*
+ * 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 features.validators.deserialization;
+
+import flex.messaging.config.ConfigMap;
+import flex.messaging.validators.DeserializationValidator;
+
+public class TestDeserializationValidator implements DeserializationValidator
+{
+ /**
+ * Simply prints the assignment and always returns true.
+ */
+ public boolean validateAssignment(Object instance, int index, Object value)
+ {
+ System.out.println("validateAssign1: [" + (instance == null? "null" : instance.getClass().getName()) + "," + index + "," + value + "]");
+ return true;
+ }
+
+ /**
+ * Simply prints the assignment and always returns true.
+ */
+ public boolean validateAssignment(Object instance, String propertyName, Object value)
+ {
+ System.out.println("validateAssign2: [" + (instance == null? "null" : instance.getClass().getName()) + "," + propertyName + "," + value + "]");
+ return true;
+ }
+
+ /**
+ * Simply prints the creation and always returns true.
+ */
+ public boolean validateCreation(Class<?> c)
+ {
+ System.out.println("validateCreate: " + (c == null? "null" : c.getName()));
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see flex.messaging.FlexConfigurable#initialize(java.lang.String, flex.messaging.config.ConfigMap)
+ */
+ public void initialize(String id, ConfigMap configMap)
+ {
+ // No-op.
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/build.xml
----------------------------------------------------------------------
diff --git a/apps/team/build.xml b/apps/team/build.xml
new file mode 100755
index 0000000..135d6b9
--- /dev/null
+++ b/apps/team/build.xml
@@ -0,0 +1,198 @@
+<?xml version="1.0"?>
+<!--
+
+ 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.
+
+-->
+
+
+
+<project name="team.war/build.xml" default="main" basedir="../..">
+
+ <property file="${basedir}/build.properties" />
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${env.ANT_HOME}/lib/ant-contrib-1.0b2.jar"/>
+ <property name="team.war" value="${basedir}/apps/team" />
+ <property name="dist.dir" value="${basedir}/dist" />
+ <property name="src.dir" value="${team.war}/WEB-INF/src" />
+ <property name="classes.dir" value="${team.war}/WEB-INF/classes" />
+ <if>
+ <equals arg1="${sdk.version}" arg2="3"/>
+ <then>
+ <property name="template.dir" value="client-side-detection-with-history"/>
+ <property name="war.filename" value="team-sdk3.war"/>
+ </then>
+ <else>
+ <property name="template.dir" value=""/>
+ <property name="war.filename" value="team.war"/>
+ </else>
+ </if>
+
+ <path id="classpath">
+ <fileset dir="${team.war}/WEB-INF/lib" includes="**/*.jar" />
+ <fileset dir="${team.war}/WEB-INF/flex/jars" includes="**/*.jar"/>
+ <pathelement location="${servlet.jar}" />
+ <pathelement location="${jms.jar}"/>
+ </path>
+
+ <target name="main" depends="clean,compile" />
+
+ <target name="prepare">
+ <mkdir dir="${team.war}/WEB-INF/classes" />
+ <mkdir dir="${team.war}/WEB-INF/lib" />
+ <mkdir dir="${team.war}/WEB-INF/src" />
+ </target>
+
+ <target name="copy-resources">
+ <fail unless="local.sdk.lib.dir" message="must specify local.sdk.lib.dir in server/build.properties"/>
+ <fail unless="local.sdk.frameworks.dir" message="must specify local.sdk.frameworks.dir in build.properties"/>
+
+ <!-- copy sdk version sepecific web.xml. this is required for webtier -->
+ <copy todir="${team.war}/WEB-INF">
+ <fileset dir="${qa.dir}/resources/webtier/flex_sdk_${sdk.version}/">
+ <include name="web.xml"/>
+ </fileset>
+ </copy>
+
+ <!-- copy sdk version specific flex-config.xml, air-config.xml and flex-webtier-config.xml -->
+ <copy todir="${team.war}/WEB-INF/flex">
+ <fileset dir="${qa.dir}/resources/webtier/flex_sdk_${sdk.version}" includes="flex-config.xml,air-config.xml,flex-webtier-config.xml"/>
+ </copy>
+
+ <!-- copy to the WEB-INF/flex directory -->
+ <copy todir="${team.war}/WEB-INF/flex">
+ <fileset dir="${local.sdk.frameworks.dir}">
+ <include name="*-manifest.xml" />
+ <include name="flash-unicode-table.xml"/>
+ <include name="flex-sdk-description.xml" />
+ <include name="*.ser"/>
+ <include name="locale/**/*"/>
+ <include name="themes/**/*"/>
+ </fileset>
+ </copy>
+
+ <!-- copy swcs to the WEB-INF/flex/libs directory -->
+ <copy todir="${team.war}/WEB-INF/flex/libs">
+ <fileset dir="${local.sdk.frameworks.dir}/libs" includes="**/*.swc"/>
+ </copy>
+
+ <!-- copy to the lib directory -->
+ <copy todir="${team.war}/WEB-INF/lib">
+ <fileset dir="${basedir}/lib" includes="${webapp.ce.lib},${webtier.lib},${jgroups.jars}" />
+ <fileset dir="${qa.dir}/lib" includes="${axis.jars},${qa-services.jars}"/>
+ </copy>
+
+ <!-- copy to the jars directory -->
+ <copy todir="${team.war}/WEB-INF/flex/jars">
+ <fileset dir="${basedir}/lib" includes="${webtier.jars}"/>
+ </copy>
+
+ <!-- copy to the classes directory -->
+ <copy todir="${team.war}/WEB-INF/classes">
+ <fileset dir="${team.war}/WEB-INF/src">
+ <include name="**/*.xml,**/*.properties" />
+ </fileset>
+ <fileset dir="${basedir}/lib" includes="${webapp.classes}" />
+ </copy>
+
+ <!-- copy template file to the history directory -->
+ <copy todir="${team.war}/history" flatten="true">
+ <fileset dir="${basedir}/templates/${template.dir}" includes="**/*.js,**/*.css,**/historyFrame.html"/>
+ </copy>
+ </target>
+
+ <target name="run-depend" if="src.depend">
+ <echo message="Removing class files that changed and dependent class files." />
+ <depend cache="${classes.dir}" srcdir="${src.dir}" destdir="${classes.dir}" />
+ </target>
+
+ <target name="compile" depends="prepare,run-depend,copy-resources" description="compile">
+ <javac source="1.5" debug="${src.debug}" destdir="${classes.dir}" srcdir="${src.dir}" classpathref="classpath" />
+ </target>
+
+ <target name="package" description=" Creates distribution war file">
+ <mkdir dir="${dist.dir}" />
+ <war file="${dist.dir}/${war.filename}" webxml="${team.war}/WEB-INF/web.xml">
+ <manifest>
+ <attribute name="Sealed" value="${manifest.sealed}" />
+ <attribute name="Implementation-Title" value="${manifest.Implementation-Title} - Team Application" />
+ <attribute name="Implementation-Version" value="${manifest.Implementation-Version}.${build.number}" />
+ <attribute name="Implementation-Vendor" value="${manifest.Implementation-Vendor}" />
+ </manifest>
+ <fileset dir="${team.war}">
+ <exclude name="build.xml" />
+ <exclude name="WEB-INF/src/**/*.java" />
+ <exclude name="WEB-INF/jsp/**/*" />
+ <exclude name="WEB-INF/sessions/**/*" />
+ <!-- This is included in the war task already -->
+ <exclude name="WEB-INF/web.xml" />
+ </fileset>
+ </war>
+ </target>
+
+ <target name="clean" description="--> Removes jars and classes">
+ <delete quiet="true">
+ <fileset dir="${team.war}/WEB-INF/lib" includes="${webapp.ce.lib},${webtier.lib},${jgroups.jars}" />
+ <fileset dir="${team.war}/WEB-INF" includes="web.xml"/>
+ <fileset dir="${team.war}/WEB-INF/flex">
+ <include name="*-manifest.xml" />
+ <include name="air-config.xml"/>
+ <include name="flex-config.xml"/>
+ <include name="flex-webtier-config.xml"/>
+ <include name="flash-unicode-table.xml"/>
+ <include name="flex-sdk-description.xml" />
+ <include name="*.ser"/>
+ <include name="locale/**/*"/>
+ <include name="themes/**/*"/>
+ </fileset>
+ </delete>
+ <delete quiet="true">
+ <fileset dir="${team.war}/WEB-INF/flex/jars" includes="**/*"/>
+ </delete>
+ <delete quiet="true" includeEmptyDirs="true">
+ <fileset dir="${team.war}/WEB-INF/flex/locale" includes="**/*"/>
+ </delete>
+ <delete quiet="true" includeEmptyDirs="true">
+ <fileset dir="${team.war}/WEB-INF/flex/libs" includes="**/*"/>
+ </delete>
+ <delete quiet="true" includeEmptyDirs="true">
+ <fileset dir="${team.war}/WEB-INF/flex" includes="*.ser,cache.dep,*-manifest.xml"/>
+ </delete>
+ <delete quiet="true">
+ <fileset dir="${classes.dir}" includes="**/*.class" />
+ </delete>
+ <delete quiet="true" file="${dist.dir}/${war.filename}" />
+ <delete quiet="true" includeEmptyDirs="true">
+ <fileset dir="${team.war}/history" includes="**/*"/>
+ </delete>
+ <delete quiet="true" dir="${team.war}/history" />
+ <delete quiet="true" dir="${team.war}/WEB-INF/lib" />
+ <delete quiet="true" dir="${team.war}/WEB-INF/classes" />
+ <delete quiet="true" dir="${team.war}/WEB-INF/flex/jars" />
+ <delete quiet="true" dir="${team.war}/WEB-INF/flex/libs" />
+ <delete quiet="true" dir="${team.war}/WEB-INF/flex/locale" />
+ <delete quiet="true" dir="${team.war}/WEB-INF/flex/themes" />
+ </target>
+
+ <target name="generated-clean">
+ <delete includeEmptyDirs="true" quiet="true">
+ <fileset dir="${team.war}" includes="**/generated/*" />
+ </delete>
+ <delete includeEmptyDirs="true" quiet="true">
+ <fileset dir="${team.war}" includes="**/generated" />
+ </delete>
+ </target>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/features/README.txt
----------------------------------------------------------------------
diff --git a/apps/team/features/README.txt b/apps/team/features/README.txt
new file mode 100755
index 0000000..d5160ac
--- /dev/null
+++ b/apps/team/features/README.txt
@@ -0,0 +1,2 @@
+This part of the team application is intended for "Hello World" type of applications
+that showcase different features in the most basic way possible.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/features/ajax/README.txt
----------------------------------------------------------------------
diff --git a/apps/team/features/ajax/README.txt b/apps/team/features/ajax/README.txt
new file mode 100755
index 0000000..3d903db
--- /dev/null
+++ b/apps/team/features/ajax/README.txt
@@ -0,0 +1,3 @@
+Place for sample AJAX apps that use FDMS-Bridge. Before running the apps, make sure you run "ant main" in /resources/fds-ajax-bridge to compile FDMS-bridge and get the latest js and swf files in here.
+
+Double-check that the channels specified in TextMessage.html and TextMessage.mxml exist. The destination should exist as well.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/features/ajax/messaging/TextMessage.html
----------------------------------------------------------------------
diff --git a/apps/team/features/ajax/messaging/TextMessage.html b/apps/team/features/ajax/messaging/TextMessage.html
new file mode 100755
index 0000000..ef529d3
--- /dev/null
+++ b/apps/team/features/ajax/messaging/TextMessage.html
@@ -0,0 +1,88 @@
+<!--
+ 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>
+<head>
+<title>Email Flex Bridge Example</title>
+<style>
+body { margin: 0px;
+ overflow:hidden }
+
+textarea {
+ font-size: 1em;
+}
+</style>
+ <script type="text/javascript" src="../includes/js/FABridge.js"></script>
+ <script type="text/javascript" src="../includes/js/FDMSLib.js"></script>
+</head>
+<body scroll='no' style="font-size:.9em;">
+<script language="javascript">
+ var p;
+ var c;
+
+ function fdmsLibraryReady()
+ {
+ // todo: when is this supposed to be called?
+ // are types available?
+ alert("Library Ready");
+
+ var cs = new ChannelSet();
+ cs.addChannel(new AMFChannel("my-amf-poll", "http://localhost:8400/team/messagebroker/myamfpoll"));
+ //cs.addChannel(new AMFChannel("my-polling-amf", "http://localhost:8100/dev/messagebroker/amfpolling"));
+ //cs.addChannel(new AMFChannel("my-polling-amf", "/dev/messagebroker/amfpolling"));
+
+ p = new Producer();
+ p.setDestination("messaging_AMF_Poll");
+ p.setChannelSet(cs);
+
+ c = new Consumer();
+ c.setDestination("messaging_AMF_Poll");
+ c.addEventListener("message", messageHandler);
+ c.setChannelSet(cs);
+ c.subscribe();
+ }
+
+ function sendChat()
+ {
+ alert("Sending message...");
+
+ var m = new AsyncMessage();
+ var body = "Hello!";
+ m.setBody(body);
+ p.send(m);
+ }
+
+ function messageHandler(event)
+ {
+ alert("messageHandler:" + (typeof(event.getMessage().getBody())) + "," + event.getMessage().getBody());
+ }
+
+</script>
+
+<script>
+ FDMSLibrary.load("../includes/swf/FDMSBridge.swf", fdmsLibraryReady);
+</script>
+
+ <div style="width:1024px">
+ <div style="margin-bottom: 20px;float:left;padding: 20px;">
+ <!-- <button onClick="fesLib_send();return false;">execute</button> -->
+ <button onClick="sendChat();return false;">execute</button>
+</div>
+</div>
+</body>
+
+
+</html>
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/features/ajax/messaging/TextMessage.mxml
----------------------------------------------------------------------
diff --git a/apps/team/features/ajax/messaging/TextMessage.mxml b/apps/team/features/ajax/messaging/TextMessage.mxml
new file mode 100755
index 0000000..1e52de9
--- /dev/null
+++ b/apps/team/features/ajax/messaging/TextMessage.mxml
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<!--
+
+ 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.
+
+-->
+<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
+ creationComplete="initApp()">
+
+ <mx:Panel id="mainPanel" title="TextMessage" height="100%" width="100%"
+ paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
+ <mx:Button label="Execute" click="sendChat()"/>
+ <mx:Button label="Clear" click='output.text = ""'/>
+ <mx:TextArea id="output" width="100%" height="100%"/>
+ </mx:Panel>
+
+ <mx:Script>
+ <![CDATA[
+
+ import mx.messaging.ChannelSet;
+ import mx.messaging.Consumer;
+ import mx.messaging.Producer;
+ import mx.messaging.channels.AMFChannel;
+ import mx.messaging.events.MessageFaultEvent;
+ import mx.messaging.events.MessageEvent;
+ import mx.messaging.messages.AsyncMessage;
+
+ public var producer:Producer;
+ public var consumer:Consumer;
+
+ private function initApp():void
+ {
+ /*
+ var target:TraceTarget = new TraceTarget();
+ target.includeLevel = true;
+ target.filters = ["mx.messaging.*", "mx.rpc.*"];
+ Log.addTarget(target);
+ */
+
+ var cs:ChannelSet = new ChannelSet();
+ cs.addChannel(new AMFChannel("my-amf-poll", "http://localhost:8400/team/messagebroker/myamfpoll"));
+
+ producer = new Producer();
+ // producer.destination = "MyTransientTopic";
+ producer.destination = "messaging_AMF_Poll";
+ producer.channelSet = cs;
+
+ consumer = new Consumer();
+ consumer.destination = "messaging_AMF_Poll";
+ consumer.channelSet = cs;
+ consumer.addEventListener(MessageFaultEvent.FAULT, messageFaultHandler);
+ consumer.addEventListener(MessageEvent.MESSAGE, messageHandler);
+ consumer.subscribe();
+ }
+
+ public function sendChat():void
+ {
+ if (!consumer.subscribed)
+ {
+ output.text += "***Consumer resubscribed \n";
+ consumer.subscribe();
+ }
+ var m:AsyncMessage = new AsyncMessage();
+ var mbody:String = "Hello!";
+ m.body = mbody;
+ producer.send(m);
+ }
+
+ private function messageHandler(event : MessageEvent) : void
+ {
+ output.text += "Consumer received message: "+ event.message.body + "\n";
+ }
+
+ private function messageFaultHandler(event : Object) : void
+ {
+ output.text += "Consumer received fault: " + event.faultString + "\n";
+ }
+
+ ]]>
+ </mx:Script>
+
+</mx:Application>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/features/messaging/cluster/messaging_AMF_Poll_Cluster.mxml
----------------------------------------------------------------------
diff --git a/apps/team/features/messaging/cluster/messaging_AMF_Poll_Cluster.mxml b/apps/team/features/messaging/cluster/messaging_AMF_Poll_Cluster.mxml
new file mode 100755
index 0000000..4f60505
--- /dev/null
+++ b/apps/team/features/messaging/cluster/messaging_AMF_Poll_Cluster.mxml
@@ -0,0 +1,94 @@
+<?xml version="1.0"?>
+<!--
+
+ 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.
+
+-->
+<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
+ creationComplete="creationCompleteHandler();">
+
+ <!-- Before running this test, make sure messaging_AMF_Poll_Cluster is
+ uncommented from messaging-config.xml.
+ -->
+ <mx:Panel id="mainPanel" height="100%" width="100%">
+ <mx:HBox>
+ <mx:Label text="Producer"/>
+ <mx:Button label="Send Foo{counter}" click="sendMessage()"/>
+ <mx:Button label="Disconnect" click="producer.disconnect();" enabled="{producer.connected}"/>
+ <mx:CheckBox label="Connected?" selected="{producer.connected}"/>
+ </mx:HBox>
+ <mx:HBox>
+ <mx:Label text="Consumer"/>
+ <mx:Button label="Subcribe" click="consumer.subscribe();" enabled="{!consumer.subscribed}"/>
+ <mx:Button label="Unsubscribe" click="consumer.unsubscribe();" enabled="{consumer.subscribed}"/>
+ <mx:Button label="Disconnect" click="consumer.disconnect();" enabled="{consumer.connected}"/>
+ <mx:CheckBox label="Connected?" selected="{consumer.connected}"/>
+ <mx:CheckBox label="Subscribed?" selected="{consumer.subscribed}"/>
+ </mx:HBox>
+ <mx:Button label="Clear" click='ta.text = ""'/>
+ <mx:TextArea id="ta" width="100%" height="100%"/>
+ </mx:Panel>
+
+ <mx:Producer id="producer"
+ destination="messaging_AMF_Poll_Cluster"
+ fault="faultHandler(event)"/>
+
+ <mx:Consumer id="consumer"
+ destination="messaging_AMF_Poll_Cluster"
+ fault="faultHandler(event)"
+ message="messageHandler(event)"/>
+
+ <mx:Script>
+ <![CDATA[
+ import mx.messaging.events.MessageFaultEvent;
+ import mx.messaging.events.MessageEvent;
+ import mx.messaging.messages.AsyncMessage;
+ import mx.messaging.Producer;
+ import mx.messaging.Consumer;
+
+ import mx.logging.Log;
+ import mx.logging.targets.TraceTarget;
+
+ [Bindable]
+ public var counter:int = 0;
+
+ private function creationCompleteHandler():void
+ {
+ var target:TraceTarget = new TraceTarget();
+ target.includeLevel = true;
+ target.filters = ["mx.messaging.*", "mx.rpc.*"];
+ Log.addTarget(target);
+ }
+
+ private function sendMessage():void
+ {
+ var msg:AsyncMessage = new AsyncMessage();
+ msg.body = "Foo" + counter++;
+ producer.send(msg);
+ }
+
+ private function messageHandler(event:MessageEvent):void
+ {
+ ta.text += "Consumer received message: "+ event.message.body + "\n";
+ }
+
+ private function faultHandler(event:MessageFaultEvent):void
+ {
+ ta.text += "Received fault: " + event.faultString + "\n";
+ }
+ ]]>
+ </mx:Script>
+</mx:Application>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/apps/team/features/messaging/cluster/messaging_HTTP_Poll_Cluster.mxml
----------------------------------------------------------------------
diff --git a/apps/team/features/messaging/cluster/messaging_HTTP_Poll_Cluster.mxml b/apps/team/features/messaging/cluster/messaging_HTTP_Poll_Cluster.mxml
new file mode 100755
index 0000000..d157261
--- /dev/null
+++ b/apps/team/features/messaging/cluster/messaging_HTTP_Poll_Cluster.mxml
@@ -0,0 +1,94 @@
+<?xml version="1.0"?>
+<!--
+
+ 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.
+
+-->
+<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
+ creationComplete="creationCompleteHandler();">
+
+ <!-- Before running this test, make sure messaging_HTTP_Poll_Cluster is
+ uncommented from messaging-config.xml.
+ -->
+ <mx:Panel id="mainPanel" height="100%" width="100%">
+ <mx:HBox>
+ <mx:Label text="Producer"/>
+ <mx:Button label="Send Foo{counter}" click="sendMessage()"/>
+ <mx:Button label="Disconnect" click="producer.disconnect();" enabled="{producer.connected}"/>
+ <mx:CheckBox label="Connected?" selected="{producer.connected}"/>
+ </mx:HBox>
+ <mx:HBox>
+ <mx:Label text="Consumer"/>
+ <mx:Button label="Subcribe" click="consumer.subscribe();" enabled="{!consumer.subscribed}"/>
+ <mx:Button label="Unsubscribe" click="consumer.unsubscribe();" enabled="{consumer.subscribed}"/>
+ <mx:Button label="Disconnect" click="consumer.disconnect();" enabled="{consumer.connected}"/>
+ <mx:CheckBox label="Connected?" selected="{consumer.connected}"/>
+ <mx:CheckBox label="Subscribed?" selected="{consumer.subscribed}"/>
+ </mx:HBox>
+ <mx:Button label="Clear" click='ta.text = ""'/>
+ <mx:TextArea id="ta" width="100%" height="100%"/>
+ </mx:Panel>
+
+ <mx:Producer id="producer"
+ destination="messaging_HTTP_Poll_Cluster"
+ fault="faultHandler(event)"/>
+
+ <mx:Consumer id="consumer"
+ destination="messaging_HTTP_Poll_Cluster"
+ fault="faultHandler(event)"
+ message="messageHandler(event)"/>
+
+ <mx:Script>
+ <![CDATA[
+ import mx.messaging.events.MessageFaultEvent;
+ import mx.messaging.events.MessageEvent;
+ import mx.messaging.messages.AsyncMessage;
+ import mx.messaging.Producer;
+ import mx.messaging.Consumer;
+
+ import mx.logging.Log;
+ import mx.logging.targets.TraceTarget;
+
+ [Bindable]
+ public var counter:int = 0;
+
+ private function creationCompleteHandler():void
+ {
+ var target:TraceTarget = new TraceTarget();
+ target.includeLevel = true;
+ target.filters = ["mx.messaging.*", "mx.rpc.*"];
+ Log.addTarget(target);
+ }
+
+ private function sendMessage():void
+ {
+ var msg:AsyncMessage = new AsyncMessage();
+ msg.body = "Foo" + counter++;
+ producer.send(msg);
+ }
+
+ private function messageHandler(event:MessageEvent):void
+ {
+ ta.text += "Consumer received message: "+ event.message.body + "\n";
+ }
+
+ private function faultHandler(event:MessageFaultEvent):void
+ {
+ ta.text += "Received fault: " + event.faultString + "\n";
+ }
+ ]]>
+ </mx:Script>
+</mx:Application>
\ No newline at end of file