http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/UserAgentSettings.java ---------------------------------------------------------------------- diff --git a/modules/core/src/flex/messaging/client/UserAgentSettings.java b/modules/core/src/flex/messaging/client/UserAgentSettings.java old mode 100755 new mode 100644 index e04ef88..217f2c7 --- a/modules/core/src/flex/messaging/client/UserAgentSettings.java +++ b/modules/core/src/flex/messaging/client/UserAgentSettings.java @@ -1,258 +1,258 @@ -/* - * 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 flex.messaging.client; - -/** - * A class to hold user agent specific properties. For example, in streaming - * endpoints, a certain number of bytes need to be written before the - * streaming connection can be used and this value is specific to user agents. - * Similarly, the number of simultaneous connections a session can have is user - * agent specific. - */ -public class UserAgentSettings -{ - /** - * The prefixes of the version token used by various browsers. - */ - public static final String USER_AGENT_ANDROID = "Android"; - public static final String USER_AGENT_CHROME = "Chrome"; - public static final String USER_AGENT_FIREFOX = "Firefox"; - public static final String USER_AGENT_FIREFOX_1 = "Firefox/1"; - public static final String USER_AGENT_FIREFOX_2 = "Firefox/2"; - public static final String USER_AGENT_MSIE = "MSIE"; - public static final String USER_AGENT_MSIE_5 = "MSIE 5"; - public static final String USER_AGENT_MSIE_6 = "MSIE 6"; - public static final String USER_AGENT_MSIE_7 = "MSIE 7"; - public static final String USER_AGENT_OPERA = "Opera"; - public static final String USER_AGENT_OPERA_8 = "Opera 8"; - // Opera 10,11 ship as User Agent Opera/9.8. - public static final String USER_AGENT_OPERA_10 = "Opera/9.8"; - public static final String USER_AGENT_SAFARI = "Safari"; - - /** - * Bytes needed to kickstart the streaming connections for IE. - */ - public static final int KICKSTART_BYTES_MSIE = 2048; - /** - * Bytes needed to kickstart the streaming connections for SAFARI. - */ - public static final int KICKSTART_BYTES_SAFARI = 512; - /** - * Bytes needs to kicksart the streaming connections for Android. - */ - public static final int KICKSTART_BYTES_ANDROID = 4010; - - /** - * The default number of persistent connections per session for various browsers. - */ - private static final int MAX_PERSISTENT_CONNECTIONS_LEGACY = 1; - public static final int MAX_PERSISTENT_CONNECTIONS_DEFAULT = 5; - private static final int MAX_PERSISTENT_CONNECTIONS_OPERA_LEGACY = 3; - private static final int MAX_PERSISTENT_CONNECTIONS_CHROME = MAX_PERSISTENT_CONNECTIONS_DEFAULT; - private static final int MAX_PERSISTENT_CONNECTIONS_FIREFOX = MAX_PERSISTENT_CONNECTIONS_DEFAULT; - private static final int MAX_PERSISTENT_CONNECTIONS_MSIE = MAX_PERSISTENT_CONNECTIONS_DEFAULT; - private static final int MAX_PERSISTENT_CONNECTIONS_OPERA = 7; - private static final int MAX_PERSISTENT_CONNECTIONS_SAFARI = 3; - - private String matchOn; - private int kickstartBytes; - private int maxPersistentConnectionsPerSession = MAX_PERSISTENT_CONNECTIONS_DEFAULT; - - /** - * Static method to retrieve pre-initialized user agents which are as follows: - * - * In Chrome 0, 1, 2, the limit is 6: - * match-on="Chrome" max-persistent-connections-per-session="5" - * - * In Firefox 1, 2, the limit is 2: - * match-on="Firefox" max-persistent-connections-per-session="1" - * - * In Firefox 3, the limit is 6: - * match-on="Firefox/3" max-persistent-connections-per-session="5" - * - * In MSIE 5, 6, 7, the limit is 2 with kickstart bytes of 2K: - * match-on="MSIE" max-persistent-connections-per-session="1" kickstart-bytes="2048" - * - * In MSIE 8, the limit is 6 with kickstart bytes of 2K: - * match-on="MSIE 8" max-persistent-connections-per-session="5" kickstart-bytes="2048" - * - * In Opera 7, 9, the limit is 4: - * match-on="Opera" max-persistent-connections-per-session="3" - * - * In Opera 8, the limit is 8: - * match-on="Opera 8" max-persistent-connections-per-session="7" - * - * In Opera 10, the limit is 8. - * match-on="Opera 10" max-persistent-connections-per-session="7" - * - * In Safari 3, 4, the limit is 4. - * match-on="Safari" max-persistent-connections-per-session="3" - * - * @param matchOn String to use match the agent. - */ - public static UserAgentSettings getAgent(String matchOn) - { - UserAgentSettings userAgent = new UserAgentSettings(); - userAgent.setMatchOn(matchOn); - - if (USER_AGENT_ANDROID.equals(matchOn)) - { - userAgent.setKickstartBytes(KICKSTART_BYTES_ANDROID); - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_SAFARI); - } - if (USER_AGENT_CHROME.equals(matchOn)) - { - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_CHROME); - } - else if (USER_AGENT_FIREFOX.equals(matchOn)) - { - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_FIREFOX); - } - else if (USER_AGENT_FIREFOX_1.equals(matchOn)) - { - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_LEGACY); - } - else if (USER_AGENT_FIREFOX_2.equals(matchOn)) - { - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_LEGACY); - } - else if (USER_AGENT_MSIE.equals(matchOn)) - { - userAgent.setKickstartBytes(KICKSTART_BYTES_MSIE); - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_MSIE); - } - else if (USER_AGENT_MSIE_5.equals(matchOn)) - { - userAgent.setKickstartBytes(KICKSTART_BYTES_MSIE); - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_LEGACY); - } - else if (USER_AGENT_MSIE_6.equals(matchOn)) - { - userAgent.setKickstartBytes(KICKSTART_BYTES_MSIE); - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_LEGACY); - } - else if (USER_AGENT_MSIE_7.equals(matchOn)) - { - userAgent.setKickstartBytes(KICKSTART_BYTES_MSIE); - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_LEGACY); - } - else if (USER_AGENT_OPERA.equals(matchOn)) - { - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_OPERA_LEGACY); - } - else if (USER_AGENT_OPERA_8.equals(matchOn)) - { - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_OPERA); - } - else if (USER_AGENT_OPERA_10.equals(matchOn)) - { - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_OPERA); - } - else if (USER_AGENT_SAFARI.equals(matchOn)) - { - userAgent.setKickstartBytes(KICKSTART_BYTES_SAFARI); - userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_SAFARI); - } - return userAgent; - } - - /** - * Returns the String to use to match the agent. - * - * @return The String to use to match the agent. - */ - public String getMatchOn() - { - return matchOn; - } - - /** - * Sets the String to use to match the agent. - * - * @param matchOn The String to use to match the agent. - */ - public void setMatchOn(String matchOn) - { - this.matchOn = matchOn; - } - - /** - * Returns the number of bytes needed to kickstart the streaming connections - * for the user agent. - * - * @return The number of bytes needed to kickstart the streaming connections - * for the user agent. - */ - public int getKickstartBytes() - { - return kickstartBytes; - } - - /** - * Sets the number of bytes needed to kickstart the streaming connections - * for the user agent. - * - * @param kickstartBytes The number of bytes needed to kickstart the streaming - * connections for the user agent. - */ - public void setKickstartBytes(int kickstartBytes) - { - if (kickstartBytes < 0) - kickstartBytes = 0; - this.kickstartBytes = kickstartBytes; - } - - /** - * @deprecated Use {@link UserAgentSettings#getMaxPersistentConnectionsPerSession()} instead. - */ - public int getMaxStreamingConnectionsPerSession() - { - return getMaxPersistentConnectionsPerSession(); - } - - /** - * @deprecated Use {@link UserAgentSettings#setMaxPersistentConnectionsPerSession(int)} instead. - */ - public void setMaxStreamingConnectionsPerSession(int maxStreamingConnectionsPerSession) - { - setMaxPersistentConnectionsPerSession(maxStreamingConnectionsPerSession); - } - - /** - * Returns the number of simultaneous streaming connections per session - * the user agent supports. - * - * @return The number of streaming connections per session the user agent supports. - */ - public int getMaxPersistentConnectionsPerSession() - { - return maxPersistentConnectionsPerSession; - } - - /** - * Sets the number of simultaneous streaming connections per session - * the user agent supports. - * - * @param maxStreamingConnectionsPerSession The number of simultaneous - * streaming connections per session the user agent supports. - */ - public void setMaxPersistentConnectionsPerSession(int maxStreamingConnectionsPerSession) - { - this.maxPersistentConnectionsPerSession = maxStreamingConnectionsPerSession; - } - -} +/* + * 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 flex.messaging.client; + +/** + * A class to hold user agent specific properties. For example, in streaming + * endpoints, a certain number of bytes need to be written before the + * streaming connection can be used and this value is specific to user agents. + * Similarly, the number of simultaneous connections a session can have is user + * agent specific. + */ +public class UserAgentSettings +{ + /** + * The prefixes of the version token used by various browsers. + */ + public static final String USER_AGENT_ANDROID = "Android"; + public static final String USER_AGENT_CHROME = "Chrome"; + public static final String USER_AGENT_FIREFOX = "Firefox"; + public static final String USER_AGENT_FIREFOX_1 = "Firefox/1"; + public static final String USER_AGENT_FIREFOX_2 = "Firefox/2"; + public static final String USER_AGENT_MSIE = "MSIE"; + public static final String USER_AGENT_MSIE_5 = "MSIE 5"; + public static final String USER_AGENT_MSIE_6 = "MSIE 6"; + public static final String USER_AGENT_MSIE_7 = "MSIE 7"; + public static final String USER_AGENT_OPERA = "Opera"; + public static final String USER_AGENT_OPERA_8 = "Opera 8"; + // Opera 10,11 ship as User Agent Opera/9.8. + public static final String USER_AGENT_OPERA_10 = "Opera/9.8"; + public static final String USER_AGENT_SAFARI = "Safari"; + + /** + * Bytes needed to kickstart the streaming connections for IE. + */ + public static final int KICKSTART_BYTES_MSIE = 2048; + /** + * Bytes needed to kickstart the streaming connections for SAFARI. + */ + public static final int KICKSTART_BYTES_SAFARI = 512; + /** + * Bytes needs to kicksart the streaming connections for Android. + */ + public static final int KICKSTART_BYTES_ANDROID = 4010; + + /** + * The default number of persistent connections per session for various browsers. + */ + private static final int MAX_PERSISTENT_CONNECTIONS_LEGACY = 1; + public static final int MAX_PERSISTENT_CONNECTIONS_DEFAULT = 5; + private static final int MAX_PERSISTENT_CONNECTIONS_OPERA_LEGACY = 3; + private static final int MAX_PERSISTENT_CONNECTIONS_CHROME = MAX_PERSISTENT_CONNECTIONS_DEFAULT; + private static final int MAX_PERSISTENT_CONNECTIONS_FIREFOX = MAX_PERSISTENT_CONNECTIONS_DEFAULT; + private static final int MAX_PERSISTENT_CONNECTIONS_MSIE = MAX_PERSISTENT_CONNECTIONS_DEFAULT; + private static final int MAX_PERSISTENT_CONNECTIONS_OPERA = 7; + private static final int MAX_PERSISTENT_CONNECTIONS_SAFARI = 3; + + private String matchOn; + private int kickstartBytes; + private int maxPersistentConnectionsPerSession = MAX_PERSISTENT_CONNECTIONS_DEFAULT; + + /** + * Static method to retrieve pre-initialized user agents which are as follows: + * + * In Chrome 0, 1, 2, the limit is 6: + * match-on="Chrome" max-persistent-connections-per-session="5" + * + * In Firefox 1, 2, the limit is 2: + * match-on="Firefox" max-persistent-connections-per-session="1" + * + * In Firefox 3, the limit is 6: + * match-on="Firefox/3" max-persistent-connections-per-session="5" + * + * In MSIE 5, 6, 7, the limit is 2 with kickstart bytes of 2K: + * match-on="MSIE" max-persistent-connections-per-session="1" kickstart-bytes="2048" + * + * In MSIE 8, the limit is 6 with kickstart bytes of 2K: + * match-on="MSIE 8" max-persistent-connections-per-session="5" kickstart-bytes="2048" + * + * In Opera 7, 9, the limit is 4: + * match-on="Opera" max-persistent-connections-per-session="3" + * + * In Opera 8, the limit is 8: + * match-on="Opera 8" max-persistent-connections-per-session="7" + * + * In Opera 10, the limit is 8. + * match-on="Opera 10" max-persistent-connections-per-session="7" + * + * In Safari 3, 4, the limit is 4. + * match-on="Safari" max-persistent-connections-per-session="3" + * + * @param matchOn String to use match the agent. + */ + public static UserAgentSettings getAgent(String matchOn) + { + UserAgentSettings userAgent = new UserAgentSettings(); + userAgent.setMatchOn(matchOn); + + if (USER_AGENT_ANDROID.equals(matchOn)) + { + userAgent.setKickstartBytes(KICKSTART_BYTES_ANDROID); + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_SAFARI); + } + if (USER_AGENT_CHROME.equals(matchOn)) + { + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_CHROME); + } + else if (USER_AGENT_FIREFOX.equals(matchOn)) + { + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_FIREFOX); + } + else if (USER_AGENT_FIREFOX_1.equals(matchOn)) + { + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_LEGACY); + } + else if (USER_AGENT_FIREFOX_2.equals(matchOn)) + { + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_LEGACY); + } + else if (USER_AGENT_MSIE.equals(matchOn)) + { + userAgent.setKickstartBytes(KICKSTART_BYTES_MSIE); + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_MSIE); + } + else if (USER_AGENT_MSIE_5.equals(matchOn)) + { + userAgent.setKickstartBytes(KICKSTART_BYTES_MSIE); + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_LEGACY); + } + else if (USER_AGENT_MSIE_6.equals(matchOn)) + { + userAgent.setKickstartBytes(KICKSTART_BYTES_MSIE); + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_LEGACY); + } + else if (USER_AGENT_MSIE_7.equals(matchOn)) + { + userAgent.setKickstartBytes(KICKSTART_BYTES_MSIE); + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_LEGACY); + } + else if (USER_AGENT_OPERA.equals(matchOn)) + { + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_OPERA_LEGACY); + } + else if (USER_AGENT_OPERA_8.equals(matchOn)) + { + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_OPERA); + } + else if (USER_AGENT_OPERA_10.equals(matchOn)) + { + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_OPERA); + } + else if (USER_AGENT_SAFARI.equals(matchOn)) + { + userAgent.setKickstartBytes(KICKSTART_BYTES_SAFARI); + userAgent.setMaxPersistentConnectionsPerSession(MAX_PERSISTENT_CONNECTIONS_SAFARI); + } + return userAgent; + } + + /** + * Returns the String to use to match the agent. + * + * @return The String to use to match the agent. + */ + public String getMatchOn() + { + return matchOn; + } + + /** + * Sets the String to use to match the agent. + * + * @param matchOn The String to use to match the agent. + */ + public void setMatchOn(String matchOn) + { + this.matchOn = matchOn; + } + + /** + * Returns the number of bytes needed to kickstart the streaming connections + * for the user agent. + * + * @return The number of bytes needed to kickstart the streaming connections + * for the user agent. + */ + public int getKickstartBytes() + { + return kickstartBytes; + } + + /** + * Sets the number of bytes needed to kickstart the streaming connections + * for the user agent. + * + * @param kickstartBytes The number of bytes needed to kickstart the streaming + * connections for the user agent. + */ + public void setKickstartBytes(int kickstartBytes) + { + if (kickstartBytes < 0) + kickstartBytes = 0; + this.kickstartBytes = kickstartBytes; + } + + /** + * @deprecated Use {@link UserAgentSettings#getMaxPersistentConnectionsPerSession()} instead. + */ + public int getMaxStreamingConnectionsPerSession() + { + return getMaxPersistentConnectionsPerSession(); + } + + /** + * @deprecated Use {@link UserAgentSettings#setMaxPersistentConnectionsPerSession(int)} instead. + */ + public void setMaxStreamingConnectionsPerSession(int maxStreamingConnectionsPerSession) + { + setMaxPersistentConnectionsPerSession(maxStreamingConnectionsPerSession); + } + + /** + * Returns the number of simultaneous streaming connections per session + * the user agent supports. + * + * @return The number of streaming connections per session the user agent supports. + */ + public int getMaxPersistentConnectionsPerSession() + { + return maxPersistentConnectionsPerSession; + } + + /** + * Sets the number of simultaneous streaming connections per session + * the user agent supports. + * + * @param maxStreamingConnectionsPerSession The number of simultaneous + * streaming connections per session the user agent supports. + */ + public void setMaxPersistentConnectionsPerSession(int maxStreamingConnectionsPerSession) + { + this.maxPersistentConnectionsPerSession = maxStreamingConnectionsPerSession; + } + +}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/package-info.java ---------------------------------------------------------------------- diff --git a/modules/core/src/flex/messaging/client/package-info.java b/modules/core/src/flex/messaging/client/package-info.java old mode 100755 new mode 100644 index e9a5b98..97d5848 --- a/modules/core/src/flex/messaging/client/package-info.java +++ b/modules/core/src/flex/messaging/client/package-info.java @@ -1,18 +1,18 @@ -/* - * 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. - */ - +/* + * 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 flex.messaging.client; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/cluster/BroadcastHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/flex/messaging/cluster/BroadcastHandler.java b/modules/core/src/flex/messaging/cluster/BroadcastHandler.java old mode 100755 new mode 100644 index 7d6f365..c8a5db4 --- a/modules/core/src/flex/messaging/cluster/BroadcastHandler.java +++ b/modules/core/src/flex/messaging/cluster/BroadcastHandler.java @@ -1,45 +1,45 @@ -/* - * 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 flex.messaging.cluster; - -import java.util.List; - -/** - * @exclude - * This interface represents a handler for a message broadcast by a Cluster. - * Clusters broadcast messages across their physical nodes, and when they - * receive those messages they locate a BroadcastHandler capable of handling - * the broadcast. - */ -public interface BroadcastHandler -{ - /** - * Handle the broadcast message. - * - * @param sender sender of the original message - * @param params any parameters need to handle the message - */ - void handleBroadcast(Object sender, List<Object> params); - - /** - * Determine whether this Handler supports a particular operation by name. - * - * @return whether or not this handler supports the named operation - * @param name name of the operation - */ - boolean isSupportedOperation(String name); -} +/* + * 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 flex.messaging.cluster; + +import java.util.List; + +/** + * @exclude + * This interface represents a handler for a message broadcast by a Cluster. + * Clusters broadcast messages across their physical nodes, and when they + * receive those messages they locate a BroadcastHandler capable of handling + * the broadcast. + */ +public interface BroadcastHandler +{ + /** + * Handle the broadcast message. + * + * @param sender sender of the original message + * @param params any parameters need to handle the message + */ + void handleBroadcast(Object sender, List<Object> params); + + /** + * Determine whether this Handler supports a particular operation by name. + * + * @return whether or not this handler supports the named operation + * @param name name of the operation + */ + boolean isSupportedOperation(String name); +} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/cluster/Cluster.java ---------------------------------------------------------------------- diff --git a/modules/core/src/flex/messaging/cluster/Cluster.java b/modules/core/src/flex/messaging/cluster/Cluster.java old mode 100755 new mode 100644 index 789c8a0..506bb19 --- a/modules/core/src/flex/messaging/cluster/Cluster.java +++ b/modules/core/src/flex/messaging/cluster/Cluster.java @@ -1,239 +1,239 @@ -/* - * 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 flex.messaging.cluster; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.w3c.dom.Element; - -import flex.messaging.config.ConfigMap; -import flex.messaging.log.LogCategories; - -/** - * @exclude - * Base interface for cluster implementations. - */ -public abstract class Cluster -{ - /** - * Default log category for clustering. - */ - public static final String LOG_CATEGORY = LogCategories.SERVICE_CLUSTER; - - /** - * Listeners to be notified when a node is removed from the cluster. - */ - List removeNodeListeners = Collections.synchronizedList(new ArrayList()); - - /** - * Cluster properties file. - */ - Element clusterPropertiesFile; - - /** - * Specifies whether or not this is the default cluster. - */ - boolean def; - - /** - * Specifies if this cluster is enabled for URL load balancing. - */ - boolean urlLoadBalancing; - - /** - * Because destinations are the constructs which become clustered, clusters - * are identified by a unique name composed in the format - * "serviceType:destinationId". - * - * @return The unique name for the clustered destination. - * @param serviceType The name of the service for this destination. - * @param destinationName The original name of the destination. - */ - static String getClusterDestinationKey(String serviceType, String destinationName) - { - StringBuffer sb = new StringBuffer(); - sb.append(serviceType); - sb.append(':'); - sb.append(destinationName); - return sb.toString(); - } - - /** - * Add a listener for remove cluster node notification. - * - * @param listener the RemoveNodeListener to add - */ - public void addRemoveNodeListener(RemoveNodeListener listener) - { - removeNodeListeners.add(listener); - } - - /** - * Send notification to remove node listeners that a node has - * been removed from the cluster. - * - * @param address The node that was removed from the cluster. - */ - protected void sendRemoveNodeListener(Object address) - { - synchronized (removeNodeListeners) - { - for (int i = 0; i < removeNodeListeners.size(); i++) - ((RemoveNodeListener)removeNodeListeners.get(i)).removeClusterNode(address); - } - } - - /** - * Initializes the Cluster with id and the map of properties. The default - * implementation is no-op. - * - * @param id The cluster id. - * @param properties The map of properties. - */ - public void initialize(String id, ConfigMap properties) - { - // No-op. - } - - /** - * Returns the cluster properties file. - * - * @return The cluster properties file. - */ - public Element clusterPropertiesFile() - { - return clusterPropertiesFile; - } - - /** - * Sets the cluster properties file. - * - * @param value The cluster properties file. - */ - public void setClusterPropertiesFile(Element value) - { - this.clusterPropertiesFile = value; - } - - /** - * Returns true if this is the default cluster for any destination that does not - * specify a clustered destination. - * - * @return Returns true if this is the default cluster. - */ - public boolean isDefault() - { - return def; - } - - /** - * When true, this is the default cluster for any destination that does not - * specify a clustered destination. - * - * @param d true if this is the default cluster - */ - public void setDefault(boolean d) - { - this.def = d; - } - - /** - * When true, this cluster is enabled for URL load balancing. - * - * @return true if this cluster enabled for load balancing. - */ - public boolean getURLLoadBalancing() - { - return urlLoadBalancing; - } - - /** - * When true, the cluster is enabled for URL load balancing. - * - * @param u the flag to enable the URL load balancing - */ - public void setURLLoadBalancing(boolean u) - { - urlLoadBalancing = u; - } - - /** - * Shutdown the cluster. - */ - public abstract void destroy(); - - /** - * Retrieve a List of Maps, where each Map contains channel id keys - * mapped to endpoint URLs for the given service type and destination name. - * There is exactly one endpoint URL for each - * channel id. This List represents all of the known endpoint URLs - * for all of the channels in the Cluster. - * @param serviceType the service type - * @param destName the destination name - * @return List of maps of channel ids to endpoint URLs for each node in - * the cluster. - */ - public abstract List getAllEndpoints(String serviceType, String destName); - - /** - * Returns a list of all of the nodes of this cluster. - * @return List a list of member IP addresses in the cluster - */ - public abstract List getMemberAddresses(); - - /** - * Returns the local cluster node. - * @return Object the Local Address object - */ - public abstract Object getLocalAddress(); - - /** - * Broadcast a service-related operation, which usually includes a Message as a method parameter. This method - * allows a local service to process a Message and then send the Message to the services on all peer nodes - * so that they may perform the same processing. - * - * @param serviceOperation The operation to broadcast. - * @param params Parameters for the operation. - */ - public abstract void broadcastServiceOperation(String serviceOperation, Object[] params); - - /** - * Send a service-related operation in point-to-point fashion to one and only one member of the cluster. - * This is similar to the broadcastServiceOperation except that this invocation is sent to the first - * node among the cluster members that does not have the local node's address. - * - * @param serviceOperation The operation to send. - * @param params Parameters for the operation. - * @param targetAddress the target address of a remote node in the cluster - */ - public abstract void sendPointToPointServiceOperation(String serviceOperation, Object[] params, Object targetAddress); - - /** - * Add a local endpoint URL for a local channel. After doing so, broadcast the information to - * peers so that they will be aware of the URL. - * <p/> - * @param serviceType the service type of the endpoint - * @param destName the destination name - * @param channelId the Channel ID - * @param endpointUrl the endpoint URL - * @param endpointPort the endpoint port - */ - public abstract void addLocalEndpointForChannel(String serviceType, String destName, - String channelId, String endpointUrl, int endpointPort); -} +/* + * 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 flex.messaging.cluster; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.w3c.dom.Element; + +import flex.messaging.config.ConfigMap; +import flex.messaging.log.LogCategories; + +/** + * @exclude + * Base interface for cluster implementations. + */ +public abstract class Cluster +{ + /** + * Default log category for clustering. + */ + public static final String LOG_CATEGORY = LogCategories.SERVICE_CLUSTER; + + /** + * Listeners to be notified when a node is removed from the cluster. + */ + List removeNodeListeners = Collections.synchronizedList(new ArrayList()); + + /** + * Cluster properties file. + */ + Element clusterPropertiesFile; + + /** + * Specifies whether or not this is the default cluster. + */ + boolean def; + + /** + * Specifies if this cluster is enabled for URL load balancing. + */ + boolean urlLoadBalancing; + + /** + * Because destinations are the constructs which become clustered, clusters + * are identified by a unique name composed in the format + * "serviceType:destinationId". + * + * @return The unique name for the clustered destination. + * @param serviceType The name of the service for this destination. + * @param destinationName The original name of the destination. + */ + static String getClusterDestinationKey(String serviceType, String destinationName) + { + StringBuffer sb = new StringBuffer(); + sb.append(serviceType); + sb.append(':'); + sb.append(destinationName); + return sb.toString(); + } + + /** + * Add a listener for remove cluster node notification. + * + * @param listener the RemoveNodeListener to add + */ + public void addRemoveNodeListener(RemoveNodeListener listener) + { + removeNodeListeners.add(listener); + } + + /** + * Send notification to remove node listeners that a node has + * been removed from the cluster. + * + * @param address The node that was removed from the cluster. + */ + protected void sendRemoveNodeListener(Object address) + { + synchronized (removeNodeListeners) + { + for (int i = 0; i < removeNodeListeners.size(); i++) + ((RemoveNodeListener)removeNodeListeners.get(i)).removeClusterNode(address); + } + } + + /** + * Initializes the Cluster with id and the map of properties. The default + * implementation is no-op. + * + * @param id The cluster id. + * @param properties The map of properties. + */ + public void initialize(String id, ConfigMap properties) + { + // No-op. + } + + /** + * Returns the cluster properties file. + * + * @return The cluster properties file. + */ + public Element clusterPropertiesFile() + { + return clusterPropertiesFile; + } + + /** + * Sets the cluster properties file. + * + * @param value The cluster properties file. + */ + public void setClusterPropertiesFile(Element value) + { + this.clusterPropertiesFile = value; + } + + /** + * Returns true if this is the default cluster for any destination that does not + * specify a clustered destination. + * + * @return Returns true if this is the default cluster. + */ + public boolean isDefault() + { + return def; + } + + /** + * When true, this is the default cluster for any destination that does not + * specify a clustered destination. + * + * @param d true if this is the default cluster + */ + public void setDefault(boolean d) + { + this.def = d; + } + + /** + * When true, this cluster is enabled for URL load balancing. + * + * @return true if this cluster enabled for load balancing. + */ + public boolean getURLLoadBalancing() + { + return urlLoadBalancing; + } + + /** + * When true, the cluster is enabled for URL load balancing. + * + * @param u the flag to enable the URL load balancing + */ + public void setURLLoadBalancing(boolean u) + { + urlLoadBalancing = u; + } + + /** + * Shutdown the cluster. + */ + public abstract void destroy(); + + /** + * Retrieve a List of Maps, where each Map contains channel id keys + * mapped to endpoint URLs for the given service type and destination name. + * There is exactly one endpoint URL for each + * channel id. This List represents all of the known endpoint URLs + * for all of the channels in the Cluster. + * @param serviceType the service type + * @param destName the destination name + * @return List of maps of channel ids to endpoint URLs for each node in + * the cluster. + */ + public abstract List getAllEndpoints(String serviceType, String destName); + + /** + * Returns a list of all of the nodes of this cluster. + * @return List a list of member IP addresses in the cluster + */ + public abstract List getMemberAddresses(); + + /** + * Returns the local cluster node. + * @return Object the Local Address object + */ + public abstract Object getLocalAddress(); + + /** + * Broadcast a service-related operation, which usually includes a Message as a method parameter. This method + * allows a local service to process a Message and then send the Message to the services on all peer nodes + * so that they may perform the same processing. + * + * @param serviceOperation The operation to broadcast. + * @param params Parameters for the operation. + */ + public abstract void broadcastServiceOperation(String serviceOperation, Object[] params); + + /** + * Send a service-related operation in point-to-point fashion to one and only one member of the cluster. + * This is similar to the broadcastServiceOperation except that this invocation is sent to the first + * node among the cluster members that does not have the local node's address. + * + * @param serviceOperation The operation to send. + * @param params Parameters for the operation. + * @param targetAddress the target address of a remote node in the cluster + */ + public abstract void sendPointToPointServiceOperation(String serviceOperation, Object[] params, Object targetAddress); + + /** + * Add a local endpoint URL for a local channel. After doing so, broadcast the information to + * peers so that they will be aware of the URL. + * <p/> + * @param serviceType the service type of the endpoint + * @param destName the destination name + * @param channelId the Channel ID + * @param endpointUrl the endpoint URL + * @param endpointPort the endpoint port + */ + public abstract void addLocalEndpointForChannel(String serviceType, String destName, + String channelId, String endpointUrl, int endpointPort); +} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/cluster/ClusterException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/flex/messaging/cluster/ClusterException.java b/modules/core/src/flex/messaging/cluster/ClusterException.java old mode 100755 new mode 100644 index 824f7c6..a7e1fe2 --- a/modules/core/src/flex/messaging/cluster/ClusterException.java +++ b/modules/core/src/flex/messaging/cluster/ClusterException.java @@ -1,31 +1,31 @@ -/* - * 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 flex.messaging.cluster; - -import flex.messaging.MessageException; - -/** - * @exclude - * Exception type for cluster errors. - */ -public class ClusterException extends MessageException -{ - /** - * Serializable version uid. - */ - static final long serialVersionUID = 1948590697997522770L; -} +/* + * 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 flex.messaging.cluster; + +import flex.messaging.MessageException; + +/** + * @exclude + * Exception type for cluster errors. + */ +public class ClusterException extends MessageException +{ + /** + * Serializable version uid. + */ + static final long serialVersionUID = 1948590697997522770L; +}
