You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2015/08/04 12:16:14 UTC
[06/51] [partial] flex-blazeds git commit: Refactored the directory
structure
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/012fad7c/attic/apps/team/WEB-INF/src/features/bootstrapservices/MessagingBootstrapService.java
----------------------------------------------------------------------
diff --git a/attic/apps/team/WEB-INF/src/features/bootstrapservices/MessagingBootstrapService.java b/attic/apps/team/WEB-INF/src/features/bootstrapservices/MessagingBootstrapService.java
index b1a81ac..60f78ba 100755
--- a/attic/apps/team/WEB-INF/src/features/bootstrapservices/MessagingBootstrapService.java
+++ b/attic/apps/team/WEB-INF/src/features/bootstrapservices/MessagingBootstrapService.java
@@ -1,330 +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");
- }
-}
+/*
+ * 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/012fad7c/attic/apps/team/WEB-INF/src/features/bootstrapservices/RemotingBootstrapService.java
----------------------------------------------------------------------
diff --git a/attic/apps/team/WEB-INF/src/features/bootstrapservices/RemotingBootstrapService.java b/attic/apps/team/WEB-INF/src/features/bootstrapservices/RemotingBootstrapService.java
index 4765c8c..8422a17 100755
--- a/attic/apps/team/WEB-INF/src/features/bootstrapservices/RemotingBootstrapService.java
+++ b/attic/apps/team/WEB-INF/src/features/bootstrapservices/RemotingBootstrapService.java
@@ -1,220 +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");
- }
-}
+/*
+ * 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/012fad7c/attic/apps/team/WEB-INF/src/features/messaging/customadapter/CustomActionscriptAdapter.java
----------------------------------------------------------------------
diff --git a/attic/apps/team/WEB-INF/src/features/messaging/customadapter/CustomActionscriptAdapter.java b/attic/apps/team/WEB-INF/src/features/messaging/customadapter/CustomActionscriptAdapter.java
index 28f02ce..c5fa57e 100755
--- a/attic/apps/team/WEB-INF/src/features/messaging/customadapter/CustomActionscriptAdapter.java
+++ b/attic/apps/team/WEB-INF/src/features/messaging/customadapter/CustomActionscriptAdapter.java
@@ -1,96 +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);
- }
-}
+/*
+ * 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/012fad7c/attic/apps/team/WEB-INF/src/features/messaging/serverpush/ServerPushService.java
----------------------------------------------------------------------
diff --git a/attic/apps/team/WEB-INF/src/features/messaging/serverpush/ServerPushService.java b/attic/apps/team/WEB-INF/src/features/messaging/serverpush/ServerPushService.java
index 4acfd37..5f46143 100755
--- a/attic/apps/team/WEB-INF/src/features/messaging/serverpush/ServerPushService.java
+++ b/attic/apps/team/WEB-INF/src/features/messaging/serverpush/ServerPushService.java
@@ -1,130 +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;
- }
- }
+/*
+ * 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/012fad7c/attic/apps/team/WEB-INF/src/features/remoting/AMFConnectionTest.java
----------------------------------------------------------------------
diff --git a/attic/apps/team/WEB-INF/src/features/remoting/AMFConnectionTest.java b/attic/apps/team/WEB-INF/src/features/remoting/AMFConnectionTest.java
index 55c6574..8bf62a5 100755
--- a/attic/apps/team/WEB-INF/src/features/remoting/AMFConnectionTest.java
+++ b/attic/apps/team/WEB-INF/src/features/remoting/AMFConnectionTest.java
@@ -1,76 +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();
- }
- }
-}
+/*
+ * 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/012fad7c/attic/apps/team/WEB-INF/src/features/remoting/EchoService.java
----------------------------------------------------------------------
diff --git a/attic/apps/team/WEB-INF/src/features/remoting/EchoService.java b/attic/apps/team/WEB-INF/src/features/remoting/EchoService.java
index a50712f..818a3ac 100755
--- a/attic/apps/team/WEB-INF/src/features/remoting/EchoService.java
+++ b/attic/apps/team/WEB-INF/src/features/remoting/EchoService.java
@@ -1,130 +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;
- }
- }
-}
-
+/*
+ * 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/012fad7c/attic/apps/team/WEB-INF/src/features/remoting/externalizable/ExternalizableClass.java
----------------------------------------------------------------------
diff --git a/attic/apps/team/WEB-INF/src/features/remoting/externalizable/ExternalizableClass.java b/attic/apps/team/WEB-INF/src/features/remoting/externalizable/ExternalizableClass.java
index 897cb82..c681502 100755
--- a/attic/apps/team/WEB-INF/src/features/remoting/externalizable/ExternalizableClass.java
+++ b/attic/apps/team/WEB-INF/src/features/remoting/externalizable/ExternalizableClass.java
@@ -1,43 +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);
- }
-}
+/*
+ * 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);
+ }
+}