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 2014/05/05 22:08:15 UTC
[01/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Repository: flex-blazeds
Updated Branches:
refs/heads/master 5f7c8cf6a -> 4f6a3052e
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/PropertyProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/PropertyProxy.java b/modules/core/src/flex/messaging/io/PropertyProxy.java
old mode 100755
new mode 100644
index f425036..02513f6
--- a/modules/core/src/flex/messaging/io/PropertyProxy.java
+++ b/modules/core/src/flex/messaging/io/PropertyProxy.java
@@ -1,282 +1,282 @@
-/*
- * 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.io;
-
-import java.util.List;
-
-/**
- * A PropertyProxy allows customized serialization and deserialization of complex objects by
- * providing access to each of the steps in the serialization and deserialization process.
- * A serializer asks a PropertyProxy for the class name, traits
- * and properties during serialization. A deserializer asks a PropertyProxy
- * to create a new instance and set property values.
- *
- * Different PropertyProxy implementations may be written for different
- * types of objects such as Map, Dictionary, Enumerable, Throwable,
- * and Beans.
- */
-public interface PropertyProxy extends Cloneable
-{
- /**
- * The default instance managed by this PropertyProxy. The
- * default instance is used for one-type proxied instances.
- *
- * @return The proxied instance.
- */
- Object getDefaultInstance();
-
- /**
- * Sets the default instance managed by this PropertyProxy.
- *
- * @param defaultInstance The default instance.
- */
- void setDefaultInstance(Object defaultInstance);
-
- /**
- * Creates a new instance for the given className. ClassName is the
- * value of the "alias" for the ActionScript class serialized.
- * If the className is invalid an anonymous ASObject is created. If the className is
- * prefixed with ">" an ASObject is created with the type set however
- * a concrete instance is not instantiated.
- * @param className the class to create
- * @return an instance of className
- */
- Object createInstance(String className);
-
- /**
- * The List of property names as Strings that make up the traits
- * of the default instance. These traits determine which properties
- * are to be serialized.
- *
- * @return The set of property names as Strings to be serialized.
- */
- List getPropertyNames();
-
- /**
- * The List of property names as Strings that make up the traits
- * of the given instance. These traits determine which properties
- * are to be serialized.
- *
- * @param instance the object to examine
- * @return List of property names as Strings to be serialized.
- */
- List getPropertyNames(Object instance);
-
- /**
- * Looks up the Class type of the property by name on the default instance.
- * @param propertyName The name of the property.
- * @return The property type.
- */
- Class getType(String propertyName);
-
- /**
- * Looks up the Class type of the property by name on the given instance.
- * @param instance The instance that possesses the property.
- * @param propertyName The name of the property.
- * @return The property type.
- */
- Class getType(Object instance, String propertyName);
-
- /**
- * Looks up the value of the property by name from the default
- * instance.
- *
- * @param propertyName The name of the property.
- * @return The value of the given property.
- */
- Object getValue(String propertyName);
-
- /**
- * Looks up the value of a property by name for the given instance.
- *
- * @param instance The instance that possesses the requested property.
- * @param propertyName The name of the property.
- * @return The value of the given property.
- */
- Object getValue(Object instance, String propertyName);
-
- /**
- * Updates the value of a propery by name for the default instance.
- *
- * @param propertyName the property name
- * @param value the new value
- */
- void setValue(String propertyName, Object value);
-
- /**
- * Updates the value of a property by name for the given instance.
- *
- * @param instance The instance that possesses the requested property.
- * @param propertyName The name of the property to update.
- * @param value The updated value for the property.
- */
- void setValue(Object instance, String propertyName, Object value);
-
- /**
- * This is called after the deserialization of the instance is complete (i.e.
- * after the lastSetValue call. It has the opportunity to return an instance
- * to use to replace the instance returned previously in createInstance.
- * NOTE however that this approach does not support recursive references back to
- * this same object (i.e. if a property of this object refers back to itself).
- * @param instance the instance being deserialized (previously returned from a
- * createInstance call)
- * @return possibly the same instance to use for this object.
- */
- Object instanceComplete(Object instance);
-
- /**
- * Allows an alias to be set for the instance type. By default
- * the classname of the instance is used.
- *
- * @param value The class name alias.
- */
- void setAlias(String value);
-
- /**
- * The class name alias for the default instance.
- *
- * @return The class name alias to be used in serializing the type traits.
- */
- String getAlias();
-
- /**
- * The class name alias for the given instance.
- *
- * @param instance the object to get the alias of.
- * @return The class name alias to be used in serializing the type traits.
- */
- String getAlias(Object instance);
-
- /**
- * Dynamic is a client-only concept for types that allow for arbitrary
- * public properties to be defined at runtime. This setting isn't yet
- * relevant for serialization but can still be set in the Object traits.
- *
- * @param value Whether the client type is expected to be dynamic. This setting
- * is currently not used.
- */
- void setDynamic(boolean value);
-
- /**
- * The trait setting "dynamic" is a client-only concept for types that
- * allow for arbitrary public properties to be defined at runtime.
- * The default is false and it is unlikely that it would need to be set.
- *
- * @return The dynamic client trait setting to be used during serialization of the type.
- */
- boolean isDynamic();
-
- /**
- * Specifies whether the default instance manages its own serialization through the
- * Externalizable interface.
- *
- * @return Whether the default instance implements java.io.Externalizable.
- */
- boolean isExternalizable();
-
- /**
- * Specifies whether the given instance manages its own serialization through the
- * Externalizable interface.
- *
- * @param instance the object to check
- * @return Whether the given instance implements java.io.Externalizable.
- */
- boolean isExternalizable(Object instance);
-
- /**
- * Specifies whether the given instance manages its own serialization through the
- * Externalizable interface. If this property is set to true then the type
- * must implement java.io.Externalizable. Setting this property to false allows an
- * otherwise Externalizable instance to be considered as a normal type for
- * custom serialization.
- *
- * @param value if set to true the instance must implement java.io.Externalizable, otherwise
- * if set to false the proxied type can avoid external serialization
- * for an otherwise Externalizable type.
- */
- void setExternalizable(boolean value);
-
- /**
- * The context holds settings that govern serialization behavior.
- * @return The current serialization context, or a new default instance if undefined.
- */
- SerializationContext getSerializationContext();
-
- /**
- * Sets the context for serialization behavior.
- * @param value the new context
- */
- void setSerializationContext(SerializationContext value);
-
- /**
- * If set to true, read only properties will be included
- * during default serialization. The default is false.
- *
- * @param value whether read only properties should be included.
- */
- void setIncludeReadOnly(boolean value);
-
- /**
- * Determines whether read only properties from the instance should be included
- * during default serialization. The default is false.
- *
- * @return Whether read only properties should be included during default
- * serialization.
- */
- boolean getIncludeReadOnly();
-
- /**
- * A serialization descriptor that provides overrides to the
- * default behavior for selecting properties for serialization. At
- * any given level a list of includes and excludes can be specified.
- * Complex child properties can have their own descriptors specified
- * in a nested manner.
- *
- * @return The serialization descriptor for custom serialization.
- */
- SerializationDescriptor getDescriptor();
-
- /**
- * Allows non-default inclusion/exclusion of properties for
- * serialization.
- *
- * @param descriptor The descriptor to customize property selection for serialization.
- */
- void setDescriptor(SerializationDescriptor descriptor);
-
- /**
- * Returns a copy of the PropertyProxy so that it can be used as a template without
- * modifying/creating global references to instances, descriptors etc.
- *
- * @return A copy of the PropertyProxy.
- */
- Object clone();
-
- /**
- * This is called right before we are about to serialize the supplied instance.
- * You can override this method to serialize an instance which you want to serialize
- * instead of the instance encountered in the object graph. If you return an
- * instance of a different class, we use the PropertyProxyRegistry to get a new
- * proxy for that instance. That proxy is then used during the rest of the serialization.
- * Note that the objects returned from this method should be serialized through their
- * properties. You cannot return a String, Integer or other primitive type.
- *
- * @param instance the instance encountered during AMF serialization
- * @return the instance you want to serialize in its place
- */
- Object getInstanceToSerialize(Object instance);
-}
+/*
+ * 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.io;
+
+import java.util.List;
+
+/**
+ * A PropertyProxy allows customized serialization and deserialization of complex objects by
+ * providing access to each of the steps in the serialization and deserialization process.
+ * A serializer asks a PropertyProxy for the class name, traits
+ * and properties during serialization. A deserializer asks a PropertyProxy
+ * to create a new instance and set property values.
+ *
+ * Different PropertyProxy implementations may be written for different
+ * types of objects such as Map, Dictionary, Enumerable, Throwable,
+ * and Beans.
+ */
+public interface PropertyProxy extends Cloneable
+{
+ /**
+ * The default instance managed by this PropertyProxy. The
+ * default instance is used for one-type proxied instances.
+ *
+ * @return The proxied instance.
+ */
+ Object getDefaultInstance();
+
+ /**
+ * Sets the default instance managed by this PropertyProxy.
+ *
+ * @param defaultInstance The default instance.
+ */
+ void setDefaultInstance(Object defaultInstance);
+
+ /**
+ * Creates a new instance for the given className. ClassName is the
+ * value of the "alias" for the ActionScript class serialized.
+ * If the className is invalid an anonymous ASObject is created. If the className is
+ * prefixed with ">" an ASObject is created with the type set however
+ * a concrete instance is not instantiated.
+ * @param className the class to create
+ * @return an instance of className
+ */
+ Object createInstance(String className);
+
+ /**
+ * The List of property names as Strings that make up the traits
+ * of the default instance. These traits determine which properties
+ * are to be serialized.
+ *
+ * @return The set of property names as Strings to be serialized.
+ */
+ List getPropertyNames();
+
+ /**
+ * The List of property names as Strings that make up the traits
+ * of the given instance. These traits determine which properties
+ * are to be serialized.
+ *
+ * @param instance the object to examine
+ * @return List of property names as Strings to be serialized.
+ */
+ List getPropertyNames(Object instance);
+
+ /**
+ * Looks up the Class type of the property by name on the default instance.
+ * @param propertyName The name of the property.
+ * @return The property type.
+ */
+ Class getType(String propertyName);
+
+ /**
+ * Looks up the Class type of the property by name on the given instance.
+ * @param instance The instance that possesses the property.
+ * @param propertyName The name of the property.
+ * @return The property type.
+ */
+ Class getType(Object instance, String propertyName);
+
+ /**
+ * Looks up the value of the property by name from the default
+ * instance.
+ *
+ * @param propertyName The name of the property.
+ * @return The value of the given property.
+ */
+ Object getValue(String propertyName);
+
+ /**
+ * Looks up the value of a property by name for the given instance.
+ *
+ * @param instance The instance that possesses the requested property.
+ * @param propertyName The name of the property.
+ * @return The value of the given property.
+ */
+ Object getValue(Object instance, String propertyName);
+
+ /**
+ * Updates the value of a propery by name for the default instance.
+ *
+ * @param propertyName the property name
+ * @param value the new value
+ */
+ void setValue(String propertyName, Object value);
+
+ /**
+ * Updates the value of a property by name for the given instance.
+ *
+ * @param instance The instance that possesses the requested property.
+ * @param propertyName The name of the property to update.
+ * @param value The updated value for the property.
+ */
+ void setValue(Object instance, String propertyName, Object value);
+
+ /**
+ * This is called after the deserialization of the instance is complete (i.e.
+ * after the lastSetValue call. It has the opportunity to return an instance
+ * to use to replace the instance returned previously in createInstance.
+ * NOTE however that this approach does not support recursive references back to
+ * this same object (i.e. if a property of this object refers back to itself).
+ * @param instance the instance being deserialized (previously returned from a
+ * createInstance call)
+ * @return possibly the same instance to use for this object.
+ */
+ Object instanceComplete(Object instance);
+
+ /**
+ * Allows an alias to be set for the instance type. By default
+ * the classname of the instance is used.
+ *
+ * @param value The class name alias.
+ */
+ void setAlias(String value);
+
+ /**
+ * The class name alias for the default instance.
+ *
+ * @return The class name alias to be used in serializing the type traits.
+ */
+ String getAlias();
+
+ /**
+ * The class name alias for the given instance.
+ *
+ * @param instance the object to get the alias of.
+ * @return The class name alias to be used in serializing the type traits.
+ */
+ String getAlias(Object instance);
+
+ /**
+ * Dynamic is a client-only concept for types that allow for arbitrary
+ * public properties to be defined at runtime. This setting isn't yet
+ * relevant for serialization but can still be set in the Object traits.
+ *
+ * @param value Whether the client type is expected to be dynamic. This setting
+ * is currently not used.
+ */
+ void setDynamic(boolean value);
+
+ /**
+ * The trait setting "dynamic" is a client-only concept for types that
+ * allow for arbitrary public properties to be defined at runtime.
+ * The default is false and it is unlikely that it would need to be set.
+ *
+ * @return The dynamic client trait setting to be used during serialization of the type.
+ */
+ boolean isDynamic();
+
+ /**
+ * Specifies whether the default instance manages its own serialization through the
+ * Externalizable interface.
+ *
+ * @return Whether the default instance implements java.io.Externalizable.
+ */
+ boolean isExternalizable();
+
+ /**
+ * Specifies whether the given instance manages its own serialization through the
+ * Externalizable interface.
+ *
+ * @param instance the object to check
+ * @return Whether the given instance implements java.io.Externalizable.
+ */
+ boolean isExternalizable(Object instance);
+
+ /**
+ * Specifies whether the given instance manages its own serialization through the
+ * Externalizable interface. If this property is set to true then the type
+ * must implement java.io.Externalizable. Setting this property to false allows an
+ * otherwise Externalizable instance to be considered as a normal type for
+ * custom serialization.
+ *
+ * @param value if set to true the instance must implement java.io.Externalizable, otherwise
+ * if set to false the proxied type can avoid external serialization
+ * for an otherwise Externalizable type.
+ */
+ void setExternalizable(boolean value);
+
+ /**
+ * The context holds settings that govern serialization behavior.
+ * @return The current serialization context, or a new default instance if undefined.
+ */
+ SerializationContext getSerializationContext();
+
+ /**
+ * Sets the context for serialization behavior.
+ * @param value the new context
+ */
+ void setSerializationContext(SerializationContext value);
+
+ /**
+ * If set to true, read only properties will be included
+ * during default serialization. The default is false.
+ *
+ * @param value whether read only properties should be included.
+ */
+ void setIncludeReadOnly(boolean value);
+
+ /**
+ * Determines whether read only properties from the instance should be included
+ * during default serialization. The default is false.
+ *
+ * @return Whether read only properties should be included during default
+ * serialization.
+ */
+ boolean getIncludeReadOnly();
+
+ /**
+ * A serialization descriptor that provides overrides to the
+ * default behavior for selecting properties for serialization. At
+ * any given level a list of includes and excludes can be specified.
+ * Complex child properties can have their own descriptors specified
+ * in a nested manner.
+ *
+ * @return The serialization descriptor for custom serialization.
+ */
+ SerializationDescriptor getDescriptor();
+
+ /**
+ * Allows non-default inclusion/exclusion of properties for
+ * serialization.
+ *
+ * @param descriptor The descriptor to customize property selection for serialization.
+ */
+ void setDescriptor(SerializationDescriptor descriptor);
+
+ /**
+ * Returns a copy of the PropertyProxy so that it can be used as a template without
+ * modifying/creating global references to instances, descriptors etc.
+ *
+ * @return A copy of the PropertyProxy.
+ */
+ Object clone();
+
+ /**
+ * This is called right before we are about to serialize the supplied instance.
+ * You can override this method to serialize an instance which you want to serialize
+ * instead of the instance encountered in the object graph. If you return an
+ * instance of a different class, we use the PropertyProxyRegistry to get a new
+ * proxy for that instance. That proxy is then used during the rest of the serialization.
+ * Note that the objects returned from this method should be serialized through their
+ * properties. You cannot return a String, Integer or other primitive type.
+ *
+ * @param instance the instance encountered during AMF serialization
+ * @return the instance you want to serialize in its place
+ */
+ Object getInstanceToSerialize(Object instance);
+}
[26/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/MessageBrokerServlet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/MessageBrokerServlet.java b/modules/core/src/flex/messaging/MessageBrokerServlet.java
old mode 100755
new mode 100644
index aaa60d8..ea0ddc8
--- a/modules/core/src/flex/messaging/MessageBrokerServlet.java
+++ b/modules/core/src/flex/messaging/MessageBrokerServlet.java
@@ -1,461 +1,461 @@
-/*
- * 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;
-
-import flex.management.MBeanLifecycleManager;
-import flex.management.MBeanServerLocatorFactory;
-import flex.messaging.config.ConfigurationManager;
-import flex.messaging.config.FlexConfigurationManager;
-import flex.messaging.config.MessagingConfiguration;
-import flex.messaging.endpoints.Endpoint;
-import flex.messaging.io.SerializationContext;
-import flex.messaging.io.TypeMarshallingContext;
-import flex.messaging.log.HTTPRequestLog;
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.log.Logger;
-import flex.messaging.log.LoggingHttpServletRequestWrapper;
-import flex.messaging.log.ServletLogTarget;
-import flex.messaging.services.AuthenticationService;
-import flex.messaging.util.ClassUtil;
-import flex.messaging.util.ExceptionUtil;
-import flex.messaging.util.Trace;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.Principal;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * The MessageBrokerServlet bootstraps the MessageBroker,
- * adds endpoints to it, and starts the broker. The servlet
- * also acts as a facade for all http-based endpoints, in that
- * the servlet receives the http request and then delegates to
- * an endpoint that can handle the request's content type. This
- * does not occur for non-http endpoints, such as the rtmp endpoint.
- *
- * @author sneville
- * @see flex.messaging.MessageBroker
- * @exclude
- */
-public class MessageBrokerServlet extends HttpServlet
-{
- static final long serialVersionUID = -5293855229461612246L;
-
- public static final String LOG_CATEGORY_STARTUP_BROKER = LogCategories.STARTUP_MESSAGEBROKER;
- private static final String STRING_UNDEFINED_APPLICATION = "undefined";
-
- private MessageBroker broker;
- private HttpFlexSessionProvider httpFlexSessionProvider;
- private static String FLEXDIR = "/WEB-INF/flex/";
- private boolean log_errors = false;
-
- /**
- * Initializes the servlet in its web container, then creates
- * the MessageBroker and adds Endpoints and Services to that broker.
- * This servlet may keep a reference to an endpoint if it needs to
- * delegate to it in the <code>service</code> method.
- */
- public void init(ServletConfig servletConfig) throws ServletException
- {
- super.init(servletConfig);
-
- // allocate thread local variables
- createThreadLocals();
-
- // Set the servlet config as thread local
- FlexContext.setThreadLocalObjects(null, null, null, null, null, servletConfig);
-
- ServletLogTarget.setServletContext(servletConfig.getServletContext());
-
- ClassLoader loader = getClassLoader();
-
- if ("true".equals(servletConfig.getInitParameter("useContextClassLoader")))
- {
- loader = Thread.currentThread().getContextClassLoader();
- }
-
- // Should we wrap http request for later error logging?
- log_errors = HTTPRequestLog.init(getServletContext());
-
- // Start the broker
- try
- {
- // Get the configuration manager
- ConfigurationManager configManager = loadMessagingConfiguration(servletConfig);
-
- // Load configuration
- MessagingConfiguration config = configManager.getMessagingConfiguration(servletConfig);
-
- // Set up logging system ahead of everything else.
- config.createLogAndTargets();
-
- // Create broker.
- broker = config.createBroker(servletConfig.getInitParameter("messageBrokerId"), loader);
-
- // Set the servlet config as thread local
- FlexContext.setThreadLocalObjects(null, null, broker, null, null, servletConfig);
-
- setupPathResolvers();
-
- // Set initial servlet context on broker
- broker.setServletContext(servletConfig.getServletContext());
-
- Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
- if (Log.isInfo())
- {
- logger.info(VersionInfo.buildMessage());
- }
-
- // Create endpoints, services, security, and logger on the broker based on configuration
- config.configureBroker(broker);
-
- long timeBeforeStartup = 0;
- if (Log.isDebug())
- {
- timeBeforeStartup = System.currentTimeMillis();
- Log.getLogger(LOG_CATEGORY_STARTUP_BROKER).debug("MessageBroker with id '{0}' is starting.",
- new Object[]{broker.getId()});
- }
-
- //initialize the httpSessionToFlexSessionMap
- synchronized(HttpFlexSession.mapLock)
- {
- if (servletConfig.getServletContext().getAttribute(HttpFlexSession.SESSION_MAP) == null)
- servletConfig.getServletContext().setAttribute(HttpFlexSession.SESSION_MAP, new ConcurrentHashMap());
- }
-
- broker.start();
-
- if (Log.isDebug())
- {
- long timeAfterStartup = System.currentTimeMillis();
- Long diffMillis = timeAfterStartup - timeBeforeStartup;
- Log.getLogger(LOG_CATEGORY_STARTUP_BROKER).debug("MessageBroker with id '{0}' is ready (startup time: '{1}' ms)",
- new Object[]{broker.getId(), diffMillis});
- }
-
- // Report replaced tokens
- configManager.reportTokens();
-
- // Report any unused properties.
- config.reportUnusedProperties();
-
- // Setup provider for FlexSessions that wrap underlying J2EE HttpSessions.
- httpFlexSessionProvider = new HttpFlexSessionProvider();
- broker.getFlexSessionManager().registerFlexSessionProvider(HttpFlexSession.class, httpFlexSessionProvider);
-
- // clear the broker and servlet config as this thread is done
- FlexContext.clearThreadLocalObjects();
- }
- catch (Throwable t)
- {
- // On any unhandled exception destroy the broker, log it and rethrow.
- String applicationName = servletConfig.getServletContext().getServletContextName();
- if (applicationName == null)
- applicationName = STRING_UNDEFINED_APPLICATION;
-
- System.err.println("**** MessageBrokerServlet in application '" + applicationName
- + "' failed to initialize due to runtime exception: "
- + ExceptionUtil.exceptionFollowedByRootCausesToString(t));
- destroy();
- // We used to throw UnavailableException, but Weblogic didn't mark the webapp as failed. See bug FBR-237
- throw new ServletException(t);
- }
- }
-
- private void setupPathResolvers()
- {
- setupExternalPathResolver();
- setupInternalPathResolver();
- }
-
- private void setupExternalPathResolver()
- {
- broker.setExternalPathResolver(
- new MessageBroker.PathResolver()
- {
- public InputStream resolve(String filename) throws FileNotFoundException
- {
- return new FileInputStream(new File(filename));
- }
- }
- );
- }
-
- private void setupInternalPathResolver()
- {
- broker.setInternalPathResolver(
- new MessageBroker.InternalPathResolver()
- {
- public InputStream resolve(String filename)
- {
- return getServletContext().getResourceAsStream(FLEXDIR + filename);
- }
- }
- );
- }
-
- private static ConfigurationManager loadMessagingConfiguration(ServletConfig servletConfig)
- {
- ConfigurationManager manager = null;
- Class managerClass;
- String className;
-
- // Check for Custom Configuration Manager Specification
- if (servletConfig != null)
- {
- String p = servletConfig.getInitParameter("services.configuration.manager");
- if (p != null)
- {
- className = p.trim();
- try
- {
- managerClass = ClassUtil.createClass(className);
- manager = (ConfigurationManager)managerClass.newInstance();
- }
- catch (Throwable t)
- {
- if (Trace.config) // Log is not initialized yet.
- Trace.trace("Could not load configuration manager as: " + className);
- }
- }
- }
-
- if (manager == null)
- {
- manager = new FlexConfigurationManager();
- }
-
- return manager;
- }
-
- /**
- * Stops all endpoints in the MessageBroker, giving them a chance
- * to perform any endpoint-specific clean up.
- */
- public void destroy()
- {
- if (broker != null)
- {
- broker.stop();
- if (broker.isManaged())
- {
- MBeanLifecycleManager.unregisterRuntimeMBeans(broker);
- }
- // release static thread locals
- destroyThreadLocals();
- }
- }
-
- /**
- * Handle an incoming request, and delegate to an endpoint based on
- * content type, if appropriate. The content type mappings for endpoints
- * are not externally configurable, and currently the AmfEndpoint
- * is the only delegate.
- */
- public void service(HttpServletRequest req, HttpServletResponse res)
- {
- if (log_errors)
- {
- // Create a wrapper for the request object so we can save the body content
- LoggingHttpServletRequestWrapper wrapper = new LoggingHttpServletRequestWrapper(req);
- req = wrapper;
-
- try
- {
- // Read the body content
- wrapper.doReadBody();
- }
- catch (IOException ignore)
- {
- // ignore, the wrapper will preserve what content we were able to read.
- }
- }
-
- try
- {
- // Update thread locals
- broker.initThreadLocals();
- // Set this first so it is in place for the session creation event. The
- // current session is set by the FlexSession stuff right when it is available.
- // The threadlocal FlexClient is set up during message deserialization in the
- // MessageBrokerFilter.
- FlexContext.setThreadLocalObjects(null, null, broker, req, res, getServletConfig());
-
- HttpFlexSession fs = httpFlexSessionProvider.getOrCreateSession(req);
- Principal principal;
- if(FlexContext.isPerClientAuthentication())
- {
- principal = FlexContext.getUserPrincipal();
- }
- else
- {
- principal = fs.getUserPrincipal();
- }
-
- if (principal == null && req.getHeader("Authorization") != null)
- {
- String encoded = req.getHeader("Authorization");
- if (encoded.indexOf("Basic") > -1)
- {
- encoded = encoded.substring(6); //Basic.length()+1
- try
- {
- ((AuthenticationService)broker.getService(AuthenticationService.ID)).decodeAndLogin(encoded, broker.getLoginManager());
- }
- catch (Exception e)
- {
- if (Log.isDebug())
- Log.getLogger(LogCategories.SECURITY).info("Authentication service could not decode and login: " + e.getMessage());
- }
- }
- }
-
- String contextPath = req.getContextPath();
- String pathInfo = req.getPathInfo();
- String endpointPath = req.getServletPath();
- if (pathInfo != null)
- endpointPath = endpointPath + pathInfo;
-
- Endpoint endpoint;
- try
- {
- endpoint = broker.getEndpoint(endpointPath, contextPath);
- }
- catch (MessageException me)
- {
- if (Log.isInfo())
- Log.getLogger(LogCategories.ENDPOINT_GENERAL).info("Received invalid request for endpoint path '{0}'.", new Object[] {endpointPath});
-
- if (!res.isCommitted())
- {
- try
- {
- res.sendError(HttpServletResponse.SC_NOT_FOUND);
- }
- catch (IOException ignore)
- {}
- }
-
- return;
- }
-
- try
- {
- if (Log.isInfo())
- {
- Log.getLogger(LogCategories.ENDPOINT_GENERAL).info("Channel endpoint {0} received request.",
- new Object[] {endpoint.getId()});
- }
- endpoint.service(req, res);
- }
- catch (UnsupportedOperationException ue)
- {
- if (Log.isInfo())
- {
- Log.getLogger(LogCategories.ENDPOINT_GENERAL).info("Channel endpoint {0} received request for an unsupported operation.",
- new Object[] {endpoint.getId()},
- ue);
- }
-
- if (!res.isCommitted())
- {
- try
- {
- res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- }
- catch (IOException ignore)
- {}
- }
- }
- }
- catch (Throwable t)
- {
- // Final resort catch block as recommended by Fortify as a potential System info leak
- try
- {
- Log.getLogger(LogCategories.ENDPOINT_GENERAL).error("Unexpected error encountered in Message Broker servlet", t);
- res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
- catch (IOException ignore)
- {
- // ignore
- }
-
- }
- finally
- {
- if (log_errors)
- {
- String info = (String) req.getAttribute(HTTPRequestLog.HTTP_ERROR_INFO);
- if (info != null)
- {
- // Log the HttpRequest data
- System.out.println("Exception occurred while processing HTTP request: " + info + ", request details logged in " + HTTPRequestLog.getFileName());
- HTTPRequestLog.outputRequest(info, req);
- }
- }
-
- FlexContext.clearThreadLocalObjects();
- }
- }
-
- /**
- * Hook for subclasses to override the class loader to use for loading user defined classes.
- *
- * @return the class loader for this class
- */
- protected ClassLoader getClassLoader()
- {
- return this.getClass().getClassLoader();
- }
-
- /** @exclude */
- // Call ONLY on servlet startup
- public static void createThreadLocals()
- {
- // allocate static thread local objects
- FlexContext.createThreadLocalObjects();
- SerializationContext.createThreadLocalObjects();
- TypeMarshallingContext.createThreadLocalObjects();
- }
-
- /** @exclude */
- // Call ONLY on servlet shutdown
- protected static void destroyThreadLocals()
- {
- // clear static member variables
- Log.clear();
- MBeanServerLocatorFactory.clear();
-
- // Destroy static thread local objects
- FlexContext.releaseThreadLocalObjects();
- SerializationContext.releaseThreadLocalObjects();
- TypeMarshallingContext.releaseThreadLocalObjects();
- }
-
-}
+/*
+ * 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;
+
+import flex.management.MBeanLifecycleManager;
+import flex.management.MBeanServerLocatorFactory;
+import flex.messaging.config.ConfigurationManager;
+import flex.messaging.config.FlexConfigurationManager;
+import flex.messaging.config.MessagingConfiguration;
+import flex.messaging.endpoints.Endpoint;
+import flex.messaging.io.SerializationContext;
+import flex.messaging.io.TypeMarshallingContext;
+import flex.messaging.log.HTTPRequestLog;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.log.Logger;
+import flex.messaging.log.LoggingHttpServletRequestWrapper;
+import flex.messaging.log.ServletLogTarget;
+import flex.messaging.services.AuthenticationService;
+import flex.messaging.util.ClassUtil;
+import flex.messaging.util.ExceptionUtil;
+import flex.messaging.util.Trace;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.Principal;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * The MessageBrokerServlet bootstraps the MessageBroker,
+ * adds endpoints to it, and starts the broker. The servlet
+ * also acts as a facade for all http-based endpoints, in that
+ * the servlet receives the http request and then delegates to
+ * an endpoint that can handle the request's content type. This
+ * does not occur for non-http endpoints, such as the rtmp endpoint.
+ *
+ * @author sneville
+ * @see flex.messaging.MessageBroker
+ * @exclude
+ */
+public class MessageBrokerServlet extends HttpServlet
+{
+ static final long serialVersionUID = -5293855229461612246L;
+
+ public static final String LOG_CATEGORY_STARTUP_BROKER = LogCategories.STARTUP_MESSAGEBROKER;
+ private static final String STRING_UNDEFINED_APPLICATION = "undefined";
+
+ private MessageBroker broker;
+ private HttpFlexSessionProvider httpFlexSessionProvider;
+ private static String FLEXDIR = "/WEB-INF/flex/";
+ private boolean log_errors = false;
+
+ /**
+ * Initializes the servlet in its web container, then creates
+ * the MessageBroker and adds Endpoints and Services to that broker.
+ * This servlet may keep a reference to an endpoint if it needs to
+ * delegate to it in the <code>service</code> method.
+ */
+ public void init(ServletConfig servletConfig) throws ServletException
+ {
+ super.init(servletConfig);
+
+ // allocate thread local variables
+ createThreadLocals();
+
+ // Set the servlet config as thread local
+ FlexContext.setThreadLocalObjects(null, null, null, null, null, servletConfig);
+
+ ServletLogTarget.setServletContext(servletConfig.getServletContext());
+
+ ClassLoader loader = getClassLoader();
+
+ if ("true".equals(servletConfig.getInitParameter("useContextClassLoader")))
+ {
+ loader = Thread.currentThread().getContextClassLoader();
+ }
+
+ // Should we wrap http request for later error logging?
+ log_errors = HTTPRequestLog.init(getServletContext());
+
+ // Start the broker
+ try
+ {
+ // Get the configuration manager
+ ConfigurationManager configManager = loadMessagingConfiguration(servletConfig);
+
+ // Load configuration
+ MessagingConfiguration config = configManager.getMessagingConfiguration(servletConfig);
+
+ // Set up logging system ahead of everything else.
+ config.createLogAndTargets();
+
+ // Create broker.
+ broker = config.createBroker(servletConfig.getInitParameter("messageBrokerId"), loader);
+
+ // Set the servlet config as thread local
+ FlexContext.setThreadLocalObjects(null, null, broker, null, null, servletConfig);
+
+ setupPathResolvers();
+
+ // Set initial servlet context on broker
+ broker.setServletContext(servletConfig.getServletContext());
+
+ Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
+ if (Log.isInfo())
+ {
+ logger.info(VersionInfo.buildMessage());
+ }
+
+ // Create endpoints, services, security, and logger on the broker based on configuration
+ config.configureBroker(broker);
+
+ long timeBeforeStartup = 0;
+ if (Log.isDebug())
+ {
+ timeBeforeStartup = System.currentTimeMillis();
+ Log.getLogger(LOG_CATEGORY_STARTUP_BROKER).debug("MessageBroker with id '{0}' is starting.",
+ new Object[]{broker.getId()});
+ }
+
+ //initialize the httpSessionToFlexSessionMap
+ synchronized(HttpFlexSession.mapLock)
+ {
+ if (servletConfig.getServletContext().getAttribute(HttpFlexSession.SESSION_MAP) == null)
+ servletConfig.getServletContext().setAttribute(HttpFlexSession.SESSION_MAP, new ConcurrentHashMap());
+ }
+
+ broker.start();
+
+ if (Log.isDebug())
+ {
+ long timeAfterStartup = System.currentTimeMillis();
+ Long diffMillis = timeAfterStartup - timeBeforeStartup;
+ Log.getLogger(LOG_CATEGORY_STARTUP_BROKER).debug("MessageBroker with id '{0}' is ready (startup time: '{1}' ms)",
+ new Object[]{broker.getId(), diffMillis});
+ }
+
+ // Report replaced tokens
+ configManager.reportTokens();
+
+ // Report any unused properties.
+ config.reportUnusedProperties();
+
+ // Setup provider for FlexSessions that wrap underlying J2EE HttpSessions.
+ httpFlexSessionProvider = new HttpFlexSessionProvider();
+ broker.getFlexSessionManager().registerFlexSessionProvider(HttpFlexSession.class, httpFlexSessionProvider);
+
+ // clear the broker and servlet config as this thread is done
+ FlexContext.clearThreadLocalObjects();
+ }
+ catch (Throwable t)
+ {
+ // On any unhandled exception destroy the broker, log it and rethrow.
+ String applicationName = servletConfig.getServletContext().getServletContextName();
+ if (applicationName == null)
+ applicationName = STRING_UNDEFINED_APPLICATION;
+
+ System.err.println("**** MessageBrokerServlet in application '" + applicationName
+ + "' failed to initialize due to runtime exception: "
+ + ExceptionUtil.exceptionFollowedByRootCausesToString(t));
+ destroy();
+ // We used to throw UnavailableException, but Weblogic didn't mark the webapp as failed. See bug FBR-237
+ throw new ServletException(t);
+ }
+ }
+
+ private void setupPathResolvers()
+ {
+ setupExternalPathResolver();
+ setupInternalPathResolver();
+ }
+
+ private void setupExternalPathResolver()
+ {
+ broker.setExternalPathResolver(
+ new MessageBroker.PathResolver()
+ {
+ public InputStream resolve(String filename) throws FileNotFoundException
+ {
+ return new FileInputStream(new File(filename));
+ }
+ }
+ );
+ }
+
+ private void setupInternalPathResolver()
+ {
+ broker.setInternalPathResolver(
+ new MessageBroker.InternalPathResolver()
+ {
+ public InputStream resolve(String filename)
+ {
+ return getServletContext().getResourceAsStream(FLEXDIR + filename);
+ }
+ }
+ );
+ }
+
+ private static ConfigurationManager loadMessagingConfiguration(ServletConfig servletConfig)
+ {
+ ConfigurationManager manager = null;
+ Class managerClass;
+ String className;
+
+ // Check for Custom Configuration Manager Specification
+ if (servletConfig != null)
+ {
+ String p = servletConfig.getInitParameter("services.configuration.manager");
+ if (p != null)
+ {
+ className = p.trim();
+ try
+ {
+ managerClass = ClassUtil.createClass(className);
+ manager = (ConfigurationManager)managerClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ if (Trace.config) // Log is not initialized yet.
+ Trace.trace("Could not load configuration manager as: " + className);
+ }
+ }
+ }
+
+ if (manager == null)
+ {
+ manager = new FlexConfigurationManager();
+ }
+
+ return manager;
+ }
+
+ /**
+ * Stops all endpoints in the MessageBroker, giving them a chance
+ * to perform any endpoint-specific clean up.
+ */
+ public void destroy()
+ {
+ if (broker != null)
+ {
+ broker.stop();
+ if (broker.isManaged())
+ {
+ MBeanLifecycleManager.unregisterRuntimeMBeans(broker);
+ }
+ // release static thread locals
+ destroyThreadLocals();
+ }
+ }
+
+ /**
+ * Handle an incoming request, and delegate to an endpoint based on
+ * content type, if appropriate. The content type mappings for endpoints
+ * are not externally configurable, and currently the AmfEndpoint
+ * is the only delegate.
+ */
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ {
+ if (log_errors)
+ {
+ // Create a wrapper for the request object so we can save the body content
+ LoggingHttpServletRequestWrapper wrapper = new LoggingHttpServletRequestWrapper(req);
+ req = wrapper;
+
+ try
+ {
+ // Read the body content
+ wrapper.doReadBody();
+ }
+ catch (IOException ignore)
+ {
+ // ignore, the wrapper will preserve what content we were able to read.
+ }
+ }
+
+ try
+ {
+ // Update thread locals
+ broker.initThreadLocals();
+ // Set this first so it is in place for the session creation event. The
+ // current session is set by the FlexSession stuff right when it is available.
+ // The threadlocal FlexClient is set up during message deserialization in the
+ // MessageBrokerFilter.
+ FlexContext.setThreadLocalObjects(null, null, broker, req, res, getServletConfig());
+
+ HttpFlexSession fs = httpFlexSessionProvider.getOrCreateSession(req);
+ Principal principal;
+ if(FlexContext.isPerClientAuthentication())
+ {
+ principal = FlexContext.getUserPrincipal();
+ }
+ else
+ {
+ principal = fs.getUserPrincipal();
+ }
+
+ if (principal == null && req.getHeader("Authorization") != null)
+ {
+ String encoded = req.getHeader("Authorization");
+ if (encoded.indexOf("Basic") > -1)
+ {
+ encoded = encoded.substring(6); //Basic.length()+1
+ try
+ {
+ ((AuthenticationService)broker.getService(AuthenticationService.ID)).decodeAndLogin(encoded, broker.getLoginManager());
+ }
+ catch (Exception e)
+ {
+ if (Log.isDebug())
+ Log.getLogger(LogCategories.SECURITY).info("Authentication service could not decode and login: " + e.getMessage());
+ }
+ }
+ }
+
+ String contextPath = req.getContextPath();
+ String pathInfo = req.getPathInfo();
+ String endpointPath = req.getServletPath();
+ if (pathInfo != null)
+ endpointPath = endpointPath + pathInfo;
+
+ Endpoint endpoint;
+ try
+ {
+ endpoint = broker.getEndpoint(endpointPath, contextPath);
+ }
+ catch (MessageException me)
+ {
+ if (Log.isInfo())
+ Log.getLogger(LogCategories.ENDPOINT_GENERAL).info("Received invalid request for endpoint path '{0}'.", new Object[] {endpointPath});
+
+ if (!res.isCommitted())
+ {
+ try
+ {
+ res.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ catch (IOException ignore)
+ {}
+ }
+
+ return;
+ }
+
+ try
+ {
+ if (Log.isInfo())
+ {
+ Log.getLogger(LogCategories.ENDPOINT_GENERAL).info("Channel endpoint {0} received request.",
+ new Object[] {endpoint.getId()});
+ }
+ endpoint.service(req, res);
+ }
+ catch (UnsupportedOperationException ue)
+ {
+ if (Log.isInfo())
+ {
+ Log.getLogger(LogCategories.ENDPOINT_GENERAL).info("Channel endpoint {0} received request for an unsupported operation.",
+ new Object[] {endpoint.getId()},
+ ue);
+ }
+
+ if (!res.isCommitted())
+ {
+ try
+ {
+ res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ }
+ catch (IOException ignore)
+ {}
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ // Final resort catch block as recommended by Fortify as a potential System info leak
+ try
+ {
+ Log.getLogger(LogCategories.ENDPOINT_GENERAL).error("Unexpected error encountered in Message Broker servlet", t);
+ res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
+ catch (IOException ignore)
+ {
+ // ignore
+ }
+
+ }
+ finally
+ {
+ if (log_errors)
+ {
+ String info = (String) req.getAttribute(HTTPRequestLog.HTTP_ERROR_INFO);
+ if (info != null)
+ {
+ // Log the HttpRequest data
+ System.out.println("Exception occurred while processing HTTP request: " + info + ", request details logged in " + HTTPRequestLog.getFileName());
+ HTTPRequestLog.outputRequest(info, req);
+ }
+ }
+
+ FlexContext.clearThreadLocalObjects();
+ }
+ }
+
+ /**
+ * Hook for subclasses to override the class loader to use for loading user defined classes.
+ *
+ * @return the class loader for this class
+ */
+ protected ClassLoader getClassLoader()
+ {
+ return this.getClass().getClassLoader();
+ }
+
+ /** @exclude */
+ // Call ONLY on servlet startup
+ public static void createThreadLocals()
+ {
+ // allocate static thread local objects
+ FlexContext.createThreadLocalObjects();
+ SerializationContext.createThreadLocalObjects();
+ TypeMarshallingContext.createThreadLocalObjects();
+ }
+
+ /** @exclude */
+ // Call ONLY on servlet shutdown
+ protected static void destroyThreadLocals()
+ {
+ // clear static member variables
+ Log.clear();
+ MBeanServerLocatorFactory.clear();
+
+ // Destroy static thread local objects
+ FlexContext.releaseThreadLocalObjects();
+ SerializationContext.releaseThreadLocalObjects();
+ TypeMarshallingContext.releaseThreadLocalObjects();
+ }
+
+}
[36/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/MessageDestinationControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/MessageDestinationControl.java b/modules/core/src/flex/management/runtime/messaging/MessageDestinationControl.java
old mode 100755
new mode 100644
index 2cefc37..f4c16f7
--- a/modules/core/src/flex/management/runtime/messaging/MessageDestinationControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/MessageDestinationControl.java
@@ -1,312 +1,312 @@
-/*
- * 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.management.runtime.messaging;
-
-import java.util.Date;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import flex.management.BaseControl;
-import flex.management.runtime.AdminConsoleTypes;
-import flex.messaging.Destination;
-
-import javax.management.ObjectName;
-
-/**
- * The <code>MessageDestinationControl</code> class is the MBean implementation for
- * monitoring and managing a <code>MessageDestination</code> at runtime.
- *
- * @author shodgson
- */
-public class MessageDestinationControl extends DestinationControl implements
- MessageDestinationControlMBean
-{
- private static final String TYPE = "MessageDestination";
- private ObjectName messageCache;
- private ObjectName throttleManager;
- private ObjectName subscriptionManager;
-
- private AtomicInteger serviceMessageCount = new AtomicInteger(0);
- private Date lastServiceMessageTimestamp;
- private long serviceMessageStart;
- private AtomicInteger serviceCommandCount = new AtomicInteger(0);
- private Date lastServiceCommandTimestamp;
- private long serviceCommandStart;
- private AtomicInteger serviceMessageFromAdapterCount = new AtomicInteger(0);
- private Date lastServiceMessageFromAdapterTimestamp;
- private long serviceMessageFromAdapterStart;
- /**
- * Constructs a new <code>MessageDestinationControl</code> instance.
- *
- * @param destination The destination managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public MessageDestinationControl(Destination destination, BaseControl parent)
- {
- super(destination, parent);
- serviceMessageStart = System.currentTimeMillis();
- serviceCommandStart = serviceMessageStart;
- serviceMessageFromAdapterStart = serviceMessageStart;
- }
-
- protected void onRegistrationComplete()
- {
- String name = this.getObjectName().getCanonicalName();
-
- String[] pollablePerInterval = { "ServiceCommandCount", "ServiceMessageCount",
- "ServiceMessageFromAdapterCount" };
- String[] pollableGeneral = { "ServiceCommandFrequency", "ServiceMessageFrequency",
- "ServiceMessageFromAdapterFrequency", "LastServiceCommandTimestamp",
- "LastServiceMessageTimestamp", "LastServiceMessageFromAdapterTimestamp"};
-
- getRegistrar().registerObjects(
- new int[] {AdminConsoleTypes.DESTINATION_POLLABLE, AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL},
- name, pollablePerInterval);
- getRegistrar().registerObjects(AdminConsoleTypes.DESTINATION_POLLABLE, name,
- pollableGeneral);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getType()
- */
- public String getType()
- {
- return TYPE;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.MessageDestinationControlMBean#getMessageCache()
- */
- public ObjectName getMessageCache()
- {
- return messageCache;
- }
-
- /**
- * Sets the <code>ObjectName</code> for the message cache used by the managed destination.
- *
- * @param value The <code>ObjectName</code> for the message cache.
- */
- public void setMessageCache(ObjectName value)
- {
- messageCache = value;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.MessageDestinationControlMBean#getThrottleManager()
- */
- public ObjectName getThrottleManager()
- {
- return throttleManager;
- }
-
- /**
- * Sets the <code>ObjectName</code> for the throttle manager used by the managed destination.
- *
- * @param value The <code>ObjectName</code> for the throttle manager.
- */
- public void setThrottleManager(ObjectName value)
- {
- throttleManager = value;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.MessageDestinationControlMBean#getSubscriptionManager()
- */
- public ObjectName getSubscriptionManager()
- {
- return subscriptionManager;
- }
-
- /**
- * Sets the <code>ObjectName</code> for the subscription manager used by the managed destination.
- *
- * @param value The <code>ObjectName</code> for the subscription manager.
- */
- public void setSubscriptionManager(ObjectName value)
- {
- subscriptionManager = value;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageCount()
- */
- public Integer getServiceMessageCount()
- {
- return Integer.valueOf(serviceMessageCount.get());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceMessageCount()
- */
- public void resetServiceMessageCount()
- {
- serviceMessageStart = System.currentTimeMillis();
- serviceMessageCount = new AtomicInteger(0);
- lastServiceMessageTimestamp = null;
- }
-
- /**
- * Increments the count of messages serviced.
- */
- public void incrementServiceMessageCount()
- {
- serviceMessageCount.incrementAndGet();
- lastServiceMessageTimestamp = new Date();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceMessageTimestamp()
- */
- public Date getLastServiceMessageTimestamp()
- {
- return lastServiceMessageTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFrequency()
- */
- public Double getServiceMessageFrequency()
- {
- if (serviceMessageCount.get() > 0)
- {
- double runtime = differenceInMinutes(serviceMessageStart, System.currentTimeMillis());
- return new Double(serviceMessageCount.get()/runtime);
- }
- else
- {
- return new Double(0);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceCommandCount()
- */
- public Integer getServiceCommandCount()
- {
- return Integer.valueOf(serviceCommandCount.get());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceCommandCount()
- */
- public void resetServiceCommandCount()
- {
- serviceCommandStart = System.currentTimeMillis();
- serviceCommandCount = new AtomicInteger(0);
- lastServiceCommandTimestamp = null;
- }
-
- /**
- * Increments the count of command messages serviced.
- */
- public void incrementServiceCommandCount()
- {
- serviceCommandCount.incrementAndGet();
- lastServiceCommandTimestamp = new Date();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceCommandTimestamp()
- */
- public Date getLastServiceCommandTimestamp()
- {
- return lastServiceCommandTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceCommandFrequency()
- */
- public Double getServiceCommandFrequency()
- {
- if (serviceCommandCount.get() > 0)
- {
- double runtime = differenceInMinutes(serviceCommandStart, System.currentTimeMillis());
- return new Double(serviceCommandCount.get()/runtime);
- }
- else
- {
- return new Double(0);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFromAdapterCount()
- */
- public Integer getServiceMessageFromAdapterCount()
- {
- return Integer.valueOf(serviceMessageFromAdapterCount.get());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceMessageFromAdapterCount()
- */
- public void resetServiceMessageFromAdapterCount()
- {
- serviceMessageFromAdapterStart = System.currentTimeMillis();
- serviceMessageFromAdapterCount = new AtomicInteger(0);
- lastServiceMessageFromAdapterTimestamp = null;
- }
-
- /**
- * Increments the count of messages from adapters processed.
- */
- public void incrementServiceMessageFromAdapterCount()
- {
- serviceMessageFromAdapterCount.incrementAndGet();
- lastServiceMessageFromAdapterTimestamp = new Date();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceMessageFromAdapterTimestamp()
- */
- public Date getLastServiceMessageFromAdapterTimestamp()
- {
- return lastServiceMessageFromAdapterTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFromAdapterFrequency()
- */
- public Double getServiceMessageFromAdapterFrequency()
- {
- if (serviceMessageFromAdapterCount.get() > 0)
- {
- double runtime = differenceInMinutes(serviceMessageFromAdapterStart, System.currentTimeMillis());
- return new Double(serviceMessageFromAdapterCount.get()/runtime);
- }
- else
- {
- return new Double(0);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package flex.management.runtime.messaging;
+
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.messaging.Destination;
+
+import javax.management.ObjectName;
+
+/**
+ * The <code>MessageDestinationControl</code> class is the MBean implementation for
+ * monitoring and managing a <code>MessageDestination</code> at runtime.
+ *
+ * @author shodgson
+ */
+public class MessageDestinationControl extends DestinationControl implements
+ MessageDestinationControlMBean
+{
+ private static final String TYPE = "MessageDestination";
+ private ObjectName messageCache;
+ private ObjectName throttleManager;
+ private ObjectName subscriptionManager;
+
+ private AtomicInteger serviceMessageCount = new AtomicInteger(0);
+ private Date lastServiceMessageTimestamp;
+ private long serviceMessageStart;
+ private AtomicInteger serviceCommandCount = new AtomicInteger(0);
+ private Date lastServiceCommandTimestamp;
+ private long serviceCommandStart;
+ private AtomicInteger serviceMessageFromAdapterCount = new AtomicInteger(0);
+ private Date lastServiceMessageFromAdapterTimestamp;
+ private long serviceMessageFromAdapterStart;
+ /**
+ * Constructs a new <code>MessageDestinationControl</code> instance.
+ *
+ * @param destination The destination managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public MessageDestinationControl(Destination destination, BaseControl parent)
+ {
+ super(destination, parent);
+ serviceMessageStart = System.currentTimeMillis();
+ serviceCommandStart = serviceMessageStart;
+ serviceMessageFromAdapterStart = serviceMessageStart;
+ }
+
+ protected void onRegistrationComplete()
+ {
+ String name = this.getObjectName().getCanonicalName();
+
+ String[] pollablePerInterval = { "ServiceCommandCount", "ServiceMessageCount",
+ "ServiceMessageFromAdapterCount" };
+ String[] pollableGeneral = { "ServiceCommandFrequency", "ServiceMessageFrequency",
+ "ServiceMessageFromAdapterFrequency", "LastServiceCommandTimestamp",
+ "LastServiceMessageTimestamp", "LastServiceMessageFromAdapterTimestamp"};
+
+ getRegistrar().registerObjects(
+ new int[] {AdminConsoleTypes.DESTINATION_POLLABLE, AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL},
+ name, pollablePerInterval);
+ getRegistrar().registerObjects(AdminConsoleTypes.DESTINATION_POLLABLE, name,
+ pollableGeneral);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getType()
+ */
+ public String getType()
+ {
+ return TYPE;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageDestinationControlMBean#getMessageCache()
+ */
+ public ObjectName getMessageCache()
+ {
+ return messageCache;
+ }
+
+ /**
+ * Sets the <code>ObjectName</code> for the message cache used by the managed destination.
+ *
+ * @param value The <code>ObjectName</code> for the message cache.
+ */
+ public void setMessageCache(ObjectName value)
+ {
+ messageCache = value;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageDestinationControlMBean#getThrottleManager()
+ */
+ public ObjectName getThrottleManager()
+ {
+ return throttleManager;
+ }
+
+ /**
+ * Sets the <code>ObjectName</code> for the throttle manager used by the managed destination.
+ *
+ * @param value The <code>ObjectName</code> for the throttle manager.
+ */
+ public void setThrottleManager(ObjectName value)
+ {
+ throttleManager = value;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageDestinationControlMBean#getSubscriptionManager()
+ */
+ public ObjectName getSubscriptionManager()
+ {
+ return subscriptionManager;
+ }
+
+ /**
+ * Sets the <code>ObjectName</code> for the subscription manager used by the managed destination.
+ *
+ * @param value The <code>ObjectName</code> for the subscription manager.
+ */
+ public void setSubscriptionManager(ObjectName value)
+ {
+ subscriptionManager = value;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageCount()
+ */
+ public Integer getServiceMessageCount()
+ {
+ return Integer.valueOf(serviceMessageCount.get());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceMessageCount()
+ */
+ public void resetServiceMessageCount()
+ {
+ serviceMessageStart = System.currentTimeMillis();
+ serviceMessageCount = new AtomicInteger(0);
+ lastServiceMessageTimestamp = null;
+ }
+
+ /**
+ * Increments the count of messages serviced.
+ */
+ public void incrementServiceMessageCount()
+ {
+ serviceMessageCount.incrementAndGet();
+ lastServiceMessageTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceMessageTimestamp()
+ */
+ public Date getLastServiceMessageTimestamp()
+ {
+ return lastServiceMessageTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFrequency()
+ */
+ public Double getServiceMessageFrequency()
+ {
+ if (serviceMessageCount.get() > 0)
+ {
+ double runtime = differenceInMinutes(serviceMessageStart, System.currentTimeMillis());
+ return new Double(serviceMessageCount.get()/runtime);
+ }
+ else
+ {
+ return new Double(0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceCommandCount()
+ */
+ public Integer getServiceCommandCount()
+ {
+ return Integer.valueOf(serviceCommandCount.get());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceCommandCount()
+ */
+ public void resetServiceCommandCount()
+ {
+ serviceCommandStart = System.currentTimeMillis();
+ serviceCommandCount = new AtomicInteger(0);
+ lastServiceCommandTimestamp = null;
+ }
+
+ /**
+ * Increments the count of command messages serviced.
+ */
+ public void incrementServiceCommandCount()
+ {
+ serviceCommandCount.incrementAndGet();
+ lastServiceCommandTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceCommandTimestamp()
+ */
+ public Date getLastServiceCommandTimestamp()
+ {
+ return lastServiceCommandTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceCommandFrequency()
+ */
+ public Double getServiceCommandFrequency()
+ {
+ if (serviceCommandCount.get() > 0)
+ {
+ double runtime = differenceInMinutes(serviceCommandStart, System.currentTimeMillis());
+ return new Double(serviceCommandCount.get()/runtime);
+ }
+ else
+ {
+ return new Double(0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFromAdapterCount()
+ */
+ public Integer getServiceMessageFromAdapterCount()
+ {
+ return Integer.valueOf(serviceMessageFromAdapterCount.get());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceMessageFromAdapterCount()
+ */
+ public void resetServiceMessageFromAdapterCount()
+ {
+ serviceMessageFromAdapterStart = System.currentTimeMillis();
+ serviceMessageFromAdapterCount = new AtomicInteger(0);
+ lastServiceMessageFromAdapterTimestamp = null;
+ }
+
+ /**
+ * Increments the count of messages from adapters processed.
+ */
+ public void incrementServiceMessageFromAdapterCount()
+ {
+ serviceMessageFromAdapterCount.incrementAndGet();
+ lastServiceMessageFromAdapterTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceMessageFromAdapterTimestamp()
+ */
+ public Date getLastServiceMessageFromAdapterTimestamp()
+ {
+ return lastServiceMessageFromAdapterTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFromAdapterFrequency()
+ */
+ public Double getServiceMessageFromAdapterFrequency()
+ {
+ if (serviceMessageFromAdapterCount.get() > 0)
+ {
+ double runtime = differenceInMinutes(serviceMessageFromAdapterStart, System.currentTimeMillis());
+ return new Double(serviceMessageFromAdapterCount.get()/runtime);
+ }
+ else
+ {
+ return new Double(0);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/MessageDestinationControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/MessageDestinationControlMBean.java b/modules/core/src/flex/management/runtime/messaging/MessageDestinationControlMBean.java
old mode 100755
new mode 100644
index 43da0a7..fa8551e
--- a/modules/core/src/flex/management/runtime/messaging/MessageDestinationControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/MessageDestinationControlMBean.java
@@ -1,155 +1,155 @@
-/*
- * 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.management.runtime.messaging;
-
-import java.io.IOException;
-import java.util.Date;
-
-import javax.management.ObjectName;
-
-
-/**
- * Defines the runtime monitoring and management interface for managed
- * <code>MessageDestination</code>s.
- *
- * @author shodgson
- */
-public interface MessageDestinationControlMBean extends DestinationControlMBean
-{
- /**
- * Returns the <code>ObjectName</code> for the message cache used by the managed
- * destination.
- *
- * @return The <code>ObjectName</code> for the message cache.
- * @throws IOException Throws IOException.
- */
- ObjectName getMessageCache() throws IOException;
-
- /**
- * Returns the <code>ObjectName</code> for the throttle manager used by the
- * managed destination.
- *
- * @return The <code>ObjectName</code> for the throttle manager.
- * @throws IOException Throws IOException.
- */
- ObjectName getThrottleManager() throws IOException;
-
- /**
- * Returns the <code>ObjectName</code> for the subscription manager used
- * by the managed destination.
- *
- * @return The <code>ObjectName</code> for the subscription manager.
- * @throws IOException Throws IOException.
- */
- ObjectName getSubscriptionManager() throws IOException;
-
- /**
- * Returns the number of service message invocations.
- *
- * @return The number of service message invocations.
- * @throws IOException Throws IOException.
- */
- Integer getServiceMessageCount() throws IOException;
-
- /**
- * Resets the count of service message invocations.
- *
- * @throws IOException Throws IOException.
- */
- void resetServiceMessageCount() throws IOException;
-
- /**
- * Returns the timestamp for the most recent service message
- * invocation.
- *
- * @return The timestamp for the most recent service message invocation.
- * @throws IOException Throws IOException.
- */
- Date getLastServiceMessageTimestamp() throws IOException;
-
- /**
- * Returns the number of service message invocations per minute.
- *
- * @return The number of service message invocations per minute.
- * @throws IOException Throws IOException.
- */
- Double getServiceMessageFrequency() throws IOException;
-
- /**
- * Returns the number of service command invocations.
- *
- * @return The number of service command invocations.
- * @throws IOException Throws IOException.
- */
- Integer getServiceCommandCount() throws IOException;
-
- /**
- * Resets the count of service command invocations.
- *
- * @throws IOException Throws IOException.
- */
- void resetServiceCommandCount() throws IOException;
-
- /**
- * Returns the timestamp for the most recent service command invocation.
- *
- * @return The timestamp for the most recent service command invocation.
- * @throws IOException Throws IOException.
- */
- Date getLastServiceCommandTimestamp() throws IOException;
-
- /**
- * Returns the number of service command invocations per minute.
- *
- * @return The number of service command invocations per minute.
- * @throws IOException Throws IOException.
- */
- Double getServiceCommandFrequency() throws IOException;
-
- /**
- * Returns the number of messages from an adapter that the managed service
- * has processed.
- *
- * @return The number of messages from an adapter that the managed service
- * has processed
- * @throws IOException Throws IOException.
- */
- Integer getServiceMessageFromAdapterCount() throws IOException;
-
- /**
- * Resets the count of service message from adapter invocations.
- *
- * @throws IOException Throws IOException.
- */
- void resetServiceMessageFromAdapterCount() throws IOException;
-
- /**
- * Returns the timestamp of the most recent service message from adapter invocation.
- *
- * @return The timestamp of the most recent service message from adapter invocation.
- * @throws IOException Throws IOException.
- */
- Date getLastServiceMessageFromAdapterTimestamp() throws IOException;
-
- /**
- * Returns the number of service message from adapter invocations per minute.
- *
- * @return The number of service message from adapter invocations per minute.
- * @throws IOException Throws IOException.
- */
- Double getServiceMessageFromAdapterFrequency() throws IOException;
-}
+/*
+ * 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.management.runtime.messaging;
+
+import java.io.IOException;
+import java.util.Date;
+
+import javax.management.ObjectName;
+
+
+/**
+ * Defines the runtime monitoring and management interface for managed
+ * <code>MessageDestination</code>s.
+ *
+ * @author shodgson
+ */
+public interface MessageDestinationControlMBean extends DestinationControlMBean
+{
+ /**
+ * Returns the <code>ObjectName</code> for the message cache used by the managed
+ * destination.
+ *
+ * @return The <code>ObjectName</code> for the message cache.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName getMessageCache() throws IOException;
+
+ /**
+ * Returns the <code>ObjectName</code> for the throttle manager used by the
+ * managed destination.
+ *
+ * @return The <code>ObjectName</code> for the throttle manager.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName getThrottleManager() throws IOException;
+
+ /**
+ * Returns the <code>ObjectName</code> for the subscription manager used
+ * by the managed destination.
+ *
+ * @return The <code>ObjectName</code> for the subscription manager.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName getSubscriptionManager() throws IOException;
+
+ /**
+ * Returns the number of service message invocations.
+ *
+ * @return The number of service message invocations.
+ * @throws IOException Throws IOException.
+ */
+ Integer getServiceMessageCount() throws IOException;
+
+ /**
+ * Resets the count of service message invocations.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetServiceMessageCount() throws IOException;
+
+ /**
+ * Returns the timestamp for the most recent service message
+ * invocation.
+ *
+ * @return The timestamp for the most recent service message invocation.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastServiceMessageTimestamp() throws IOException;
+
+ /**
+ * Returns the number of service message invocations per minute.
+ *
+ * @return The number of service message invocations per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getServiceMessageFrequency() throws IOException;
+
+ /**
+ * Returns the number of service command invocations.
+ *
+ * @return The number of service command invocations.
+ * @throws IOException Throws IOException.
+ */
+ Integer getServiceCommandCount() throws IOException;
+
+ /**
+ * Resets the count of service command invocations.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetServiceCommandCount() throws IOException;
+
+ /**
+ * Returns the timestamp for the most recent service command invocation.
+ *
+ * @return The timestamp for the most recent service command invocation.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastServiceCommandTimestamp() throws IOException;
+
+ /**
+ * Returns the number of service command invocations per minute.
+ *
+ * @return The number of service command invocations per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getServiceCommandFrequency() throws IOException;
+
+ /**
+ * Returns the number of messages from an adapter that the managed service
+ * has processed.
+ *
+ * @return The number of messages from an adapter that the managed service
+ * has processed
+ * @throws IOException Throws IOException.
+ */
+ Integer getServiceMessageFromAdapterCount() throws IOException;
+
+ /**
+ * Resets the count of service message from adapter invocations.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetServiceMessageFromAdapterCount() throws IOException;
+
+ /**
+ * Returns the timestamp of the most recent service message from adapter invocation.
+ *
+ * @return The timestamp of the most recent service message from adapter invocation.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastServiceMessageFromAdapterTimestamp() throws IOException;
+
+ /**
+ * Returns the number of service message from adapter invocations per minute.
+ *
+ * @return The number of service message from adapter invocations per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getServiceMessageFromAdapterFrequency() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControl.java b/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControl.java
old mode 100755
new mode 100644
index 70fe26b..6bb1c71
--- a/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControl.java
@@ -1,99 +1,99 @@
-/*
- * 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.management.runtime.messaging.client;
-
-import flex.management.BaseControl;
-import flex.management.runtime.AdminConsoleTypes;
-import flex.messaging.client.FlexClientManager;
-
-/**
- * @author majacobs
- *
- * @exclude
- */
-public class FlexClientManagerControl extends BaseControl implements FlexClientManagerControlMBean
-{
- private FlexClientManager flexClientManager;
-
- public FlexClientManagerControl(BaseControl parent, FlexClientManager manager)
- {
- super(parent);
- flexClientManager = manager;
- }
-
- public void onRegistrationComplete()
- {
- String name = getObjectName().getCanonicalName();
- getRegistrar().registerObject(AdminConsoleTypes.GENERAL_POLLABLE, name, "FlexClientCount");
- }
-
- /* (non-Javadoc)
- * @see flex.management.BaseControl#getId()
- */
- public String getId()
- {
- return flexClientManager.getId();
- }
-
- /* (non-Javadoc)
- * @see flex.management.BaseControl#getType()
- */
- public String getType()
- {
- return flexClientManager.getId();
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientIds()
- */
- public String[] getClientIds()
- {
- return flexClientManager.getClientIds();
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientLastUse(java.lang.String)
- */
- public Long getClientLastUse(String clientId)
- {
- return new Long(flexClientManager.getFlexClient(clientId).getLastUse());
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientSessionCount(java.lang.String)
- */
- public Integer getClientSessionCount(String clientId)
- {
- return new Integer(flexClientManager.getFlexClient(clientId).getSessionCount());
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientSubscriptionCount(java.lang.String)
- */
- public Integer getClientSubscriptionCount(String clientId)
- {
- return new Integer(flexClientManager.getFlexClient(clientId).getSubscriptionCount());
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getFlexClientCount()
- */
- public Integer getFlexClientCount()
- {
- return new Integer(flexClientManager.getFlexClientCount());
- }
-}
+/*
+ * 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.management.runtime.messaging.client;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.messaging.client.FlexClientManager;
+
+/**
+ * @author majacobs
+ *
+ * @exclude
+ */
+public class FlexClientManagerControl extends BaseControl implements FlexClientManagerControlMBean
+{
+ private FlexClientManager flexClientManager;
+
+ public FlexClientManagerControl(BaseControl parent, FlexClientManager manager)
+ {
+ super(parent);
+ flexClientManager = manager;
+ }
+
+ public void onRegistrationComplete()
+ {
+ String name = getObjectName().getCanonicalName();
+ getRegistrar().registerObject(AdminConsoleTypes.GENERAL_POLLABLE, name, "FlexClientCount");
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.BaseControl#getId()
+ */
+ public String getId()
+ {
+ return flexClientManager.getId();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.BaseControl#getType()
+ */
+ public String getType()
+ {
+ return flexClientManager.getId();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientIds()
+ */
+ public String[] getClientIds()
+ {
+ return flexClientManager.getClientIds();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientLastUse(java.lang.String)
+ */
+ public Long getClientLastUse(String clientId)
+ {
+ return new Long(flexClientManager.getFlexClient(clientId).getLastUse());
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientSessionCount(java.lang.String)
+ */
+ public Integer getClientSessionCount(String clientId)
+ {
+ return new Integer(flexClientManager.getFlexClient(clientId).getSessionCount());
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientSubscriptionCount(java.lang.String)
+ */
+ public Integer getClientSubscriptionCount(String clientId)
+ {
+ return new Integer(flexClientManager.getFlexClient(clientId).getSubscriptionCount());
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getFlexClientCount()
+ */
+ public Integer getFlexClientCount()
+ {
+ return new Integer(flexClientManager.getFlexClientCount());
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControlMBean.java b/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControlMBean.java
old mode 100755
new mode 100644
index f56419b..f063259
--- a/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControlMBean.java
@@ -1,70 +1,70 @@
-/*
- * 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.management.runtime.messaging.client;
-
-import java.io.IOException;
-
-import flex.management.BaseControlMBean;
-
-/**
- * Defines the runtime monitoring and management interface for managed flex client managers.
- */
-public interface FlexClientManagerControlMBean extends BaseControlMBean
-{
- /**
- * Returns ids of managed clients.
- *
- * @return An array of client ids.
- * @throws IOException Throws IOException.
- */
- String[] getClientIds() throws IOException;
-
- /**
- * Returns the number of subscriptions for the client with the clientId.
- *
- * @param clientId The client id.
- * @return The number of subscriptions for the client with the cliendId
- * @throws IOException Throws IOException.
- */
- Integer getClientSubscriptionCount(String clientId) throws IOException;
-
- /**
- * Returns the number of sessiosn for the client with the clientId.
- *
- * @param clientId The client id.
- * @return The number of sessions for the client with the cliendId
- * @throws IOException Throws IOException.
- */
- Integer getClientSessionCount(String clientId) throws IOException;
-
- /**
- * Returns the last use by the client with the clientId.
- *
- * @param clientId The client id.
- * @return The last use by the client with the clientId
- * @throws IOException Throws IOException.
- */
- Long getClientLastUse(String clientId) throws IOException;
-
- /**
- * Returns the number of clients.
- *
- * @return The number of clients.
- * @throws IOException Throws IOException.
- */
- Integer getFlexClientCount() throws IOException;
-}
+/*
+ * 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.management.runtime.messaging.client;
+
+import java.io.IOException;
+
+import flex.management.BaseControlMBean;
+
+/**
+ * Defines the runtime monitoring and management interface for managed flex client managers.
+ */
+public interface FlexClientManagerControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns ids of managed clients.
+ *
+ * @return An array of client ids.
+ * @throws IOException Throws IOException.
+ */
+ String[] getClientIds() throws IOException;
+
+ /**
+ * Returns the number of subscriptions for the client with the clientId.
+ *
+ * @param clientId The client id.
+ * @return The number of subscriptions for the client with the cliendId
+ * @throws IOException Throws IOException.
+ */
+ Integer getClientSubscriptionCount(String clientId) throws IOException;
+
+ /**
+ * Returns the number of sessiosn for the client with the clientId.
+ *
+ * @param clientId The client id.
+ * @return The number of sessions for the client with the cliendId
+ * @throws IOException Throws IOException.
+ */
+ Integer getClientSessionCount(String clientId) throws IOException;
+
+ /**
+ * Returns the last use by the client with the clientId.
+ *
+ * @param clientId The client id.
+ * @return The last use by the client with the clientId
+ * @throws IOException Throws IOException.
+ */
+ Long getClientLastUse(String clientId) throws IOException;
+
+ /**
+ * Returns the number of clients.
+ *
+ * @return The number of clients.
+ * @throws IOException Throws IOException.
+ */
+ Integer getFlexClientCount() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/client/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/client/package-info.java b/modules/core/src/flex/management/runtime/messaging/client/package-info.java
old mode 100755
new mode 100644
index e09baf8..713b8b3
--- a/modules/core/src/flex/management/runtime/messaging/client/package-info.java
+++ b/modules/core/src/flex/management/runtime/messaging/client/package-info.java
@@ -1,17 +1,17 @@
-/*
- * 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.management.runtime.messaging.client;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControl.java
old mode 100755
new mode 100644
index f127ba6..88d877b
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControl.java
@@ -1,50 +1,50 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-import flex.management.BaseControl;
-import flex.messaging.endpoints.AMFEndpoint;
-
-/**
- * The <code>AMFEndpointControl</code> class is the MBean implemenation
- * for monitoring and managing an <code>AMFEndpoint</code> at runtime.
- *
- * @author shodgson
- */
-public class AMFEndpointControl extends PollingEndpointControl implements
- AMFEndpointControlMBean
-{
- private static final String TYPE = "AMFEndpoint";
-
- /**
- * Constructs a <code>AMFEndpointControl</code>, assigning managed message
- * endpoint and parent MBean.
- *
- * @param endpoint The <code>AMFEndpoint</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public AMFEndpointControl(AMFEndpoint endpoint, BaseControl parent)
- {
- super(endpoint, parent);
- }
-
- /** {@inheritDoc} */
- public String getType()
- {
- return TYPE;
- }
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.messaging.endpoints.AMFEndpoint;
+
+/**
+ * The <code>AMFEndpointControl</code> class is the MBean implemenation
+ * for monitoring and managing an <code>AMFEndpoint</code> at runtime.
+ *
+ * @author shodgson
+ */
+public class AMFEndpointControl extends PollingEndpointControl implements
+ AMFEndpointControlMBean
+{
+ private static final String TYPE = "AMFEndpoint";
+
+ /**
+ * Constructs a <code>AMFEndpointControl</code>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>AMFEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public AMFEndpointControl(AMFEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getType()
+ {
+ return TYPE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControlMBean.java
old mode 100755
new mode 100644
index 6c221b8..0beb412
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControlMBean.java
@@ -1,28 +1,28 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-
-/**
- * Defines the runtime monitoring and management interface for managed AMF endpoints.
- *
- * @author shodgson
- */
-public interface AMFEndpointControlMBean extends PollingEndpointControlMBean
-{
- // Empty for now.
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+
+/**
+ * Defines the runtime monitoring and management interface for managed AMF endpoints.
+ *
+ * @author shodgson
+ */
+public interface AMFEndpointControlMBean extends PollingEndpointControlMBean
+{
+ // Empty for now.
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControl.java
old mode 100755
new mode 100644
index 2d127ce..6e7e417
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControl.java
@@ -1,241 +1,241 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-import flex.management.BaseControl;
-import flex.management.runtime.AdminConsoleTypes;
-import flex.management.runtime.messaging.MessageBrokerControl;
-import flex.messaging.config.SecurityConstraint;
-import flex.messaging.endpoints.Endpoint;
-
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * The <code>EndpointControl</code> class is the MBean implementation for
- * monitoring and managing an <code>Endpoint</code> at runtime.
- *
- * @author shodgson
- */
-public abstract class EndpointControl extends BaseControl implements EndpointControlMBean
-{
- protected Endpoint endpoint;
- private AtomicInteger serviceMessageCount = new AtomicInteger(0);
- private Date lastServiceMessageTimestamp;
- private long serviceMessageStart;
- private AtomicLong bytesDeserialized = new AtomicLong(0);
- private AtomicLong bytesSerialized = new AtomicLong(0);
-
- /**
- * Constructs an <code>EndpointControl</code>, assigning its managed endpoint and
- * parent MBean.
- *
- * @param endpoint The <code>Endpoint</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public EndpointControl(Endpoint endpoint, BaseControl parent)
- {
- super(parent);
- this.endpoint = endpoint;
- serviceMessageStart = System.currentTimeMillis();
- }
-
-
- protected void onRegistrationComplete()
- {
- String name = this.getObjectName().getCanonicalName();
- String[] generalNames = { "SecurityConstraint"};
- String[] generalPollables = { "ServiceMessageCount", "LastServiceMessageTimestamp", "ServiceMessageFrequency"};
- String[] pollableGraphByInterval = {"BytesDeserialized", "BytesSerialized"};
-
- getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_SCALAR,
- name, generalNames);
- getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_POLLABLE,
- name, generalPollables);
- getRegistrar().registerObjects(new int[] {AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL, AdminConsoleTypes.ENDPOINT_POLLABLE},
- name, pollableGraphByInterval);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getId()
- */
- public String getId()
- {
- return endpoint.getId();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.EndpointControlMBean#isRunning()
- */
- public Boolean isRunning()
- {
- return Boolean.valueOf(endpoint.isStarted());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.EndpointControlMBean#getStartTimestamp()
- */
- public Date getStartTimestamp()
- {
- return startTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.EndpointControlMBean#getServiceMessageCount()
- */
- public Integer getServiceMessageCount()
- {
- return Integer.valueOf(serviceMessageCount.get());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.EndpointControlMBean#resetServiceMessageCount()
- */
- public void resetServiceMessageCount()
- {
- serviceMessageStart = System.currentTimeMillis();
- serviceMessageCount = new AtomicInteger(0);
- lastServiceMessageTimestamp = null;
- }
-
- /**
- * Increments the count of <code>serviceMessage()</code> invocations by the endpoint.
- */
- public void incrementServiceMessageCount()
- {
- serviceMessageCount.incrementAndGet();
- lastServiceMessageTimestamp = new Date();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.EndpointControlMBean#getLastServiceMessageTimestamp()
- */
- public Date getLastServiceMessageTimestamp()
- {
- return lastServiceMessageTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.EndpointControlMBean#getServiceMessageFrequency()
- */
- public Double getServiceMessageFrequency()
- {
- if (serviceMessageCount.get() > 0)
- {
- double runtime = differenceInMinutes(serviceMessageStart, System.currentTimeMillis());
- return new Double(serviceMessageCount.get()/runtime);
- }
- else
- {
- return new Double(0);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.management.MBeanRegistration#preDeregister()
- */
- public void preDeregister() throws Exception
- {
- MessageBrokerControl parent = (MessageBrokerControl)getParentControl();
- parent.removeEndpoint(getObjectName());
- }
-
- public String getURI()
- {
- return endpoint.getUrl();
- }
-
- public String getSecurityConstraint()
- {
- return getSecurityConstraintOf(endpoint);
- }
-
- public static String getSecurityConstraintOf(Endpoint endpoint)
- {
- String result = "None";
-
- SecurityConstraint constraint = endpoint.getSecurityConstraint();
- if (constraint != null)
- {
- String authMethod = constraint.getMethod();
- if (authMethod != null)
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append(authMethod);
-
- List roles = constraint.getRoles();
- if ((roles != null) && !roles.isEmpty())
- {
- buffer.append(':');
- for (int i = 0; i < roles.size(); i++)
- {
- if (i > 0)
- {
- buffer.append(',');
- }
- buffer.append(' ');
- buffer.append(roles.get(i));
- }
- }
- result = buffer.toString();
- }
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.EndpointControlMBean#getBytesDeserialized()
- */
- public Long getBytesDeserialized(){
- return Long.valueOf(bytesDeserialized.get());
- }
-
- /**
- * Increments the count of bytes deserialized by the endpoint.
- * @param currentBytesDeserialized the bytes is deserialized
- */
- public void addToBytesDeserialized(int currentBytesDeserialized) {
- bytesDeserialized.addAndGet(currentBytesDeserialized);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.EndpointControlMBean#getBytesSerialized()
- */
- public Long getBytesSerialized() {
- return Long.valueOf(bytesSerialized.get());
- }
-
- /**
- * Increments the count of bytes serialized by the endpoint.
- * @param currentBytesSerialized the bytes is serialized
- */
- public void addToBytesSerialized(int currentBytesSerialized) {
- bytesSerialized.addAndGet(currentBytesSerialized);
- }
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.management.runtime.messaging.MessageBrokerControl;
+import flex.messaging.config.SecurityConstraint;
+import flex.messaging.endpoints.Endpoint;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * The <code>EndpointControl</code> class is the MBean implementation for
+ * monitoring and managing an <code>Endpoint</code> at runtime.
+ *
+ * @author shodgson
+ */
+public abstract class EndpointControl extends BaseControl implements EndpointControlMBean
+{
+ protected Endpoint endpoint;
+ private AtomicInteger serviceMessageCount = new AtomicInteger(0);
+ private Date lastServiceMessageTimestamp;
+ private long serviceMessageStart;
+ private AtomicLong bytesDeserialized = new AtomicLong(0);
+ private AtomicLong bytesSerialized = new AtomicLong(0);
+
+ /**
+ * Constructs an <code>EndpointControl</code>, assigning its managed endpoint and
+ * parent MBean.
+ *
+ * @param endpoint The <code>Endpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public EndpointControl(Endpoint endpoint, BaseControl parent)
+ {
+ super(parent);
+ this.endpoint = endpoint;
+ serviceMessageStart = System.currentTimeMillis();
+ }
+
+
+ protected void onRegistrationComplete()
+ {
+ String name = this.getObjectName().getCanonicalName();
+ String[] generalNames = { "SecurityConstraint"};
+ String[] generalPollables = { "ServiceMessageCount", "LastServiceMessageTimestamp", "ServiceMessageFrequency"};
+ String[] pollableGraphByInterval = {"BytesDeserialized", "BytesSerialized"};
+
+ getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_SCALAR,
+ name, generalNames);
+ getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_POLLABLE,
+ name, generalPollables);
+ getRegistrar().registerObjects(new int[] {AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL, AdminConsoleTypes.ENDPOINT_POLLABLE},
+ name, pollableGraphByInterval);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getId()
+ */
+ public String getId()
+ {
+ return endpoint.getId();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#isRunning()
+ */
+ public Boolean isRunning()
+ {
+ return Boolean.valueOf(endpoint.isStarted());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getStartTimestamp()
+ */
+ public Date getStartTimestamp()
+ {
+ return startTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getServiceMessageCount()
+ */
+ public Integer getServiceMessageCount()
+ {
+ return Integer.valueOf(serviceMessageCount.get());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#resetServiceMessageCount()
+ */
+ public void resetServiceMessageCount()
+ {
+ serviceMessageStart = System.currentTimeMillis();
+ serviceMessageCount = new AtomicInteger(0);
+ lastServiceMessageTimestamp = null;
+ }
+
+ /**
+ * Increments the count of <code>serviceMessage()</code> invocations by the endpoint.
+ */
+ public void incrementServiceMessageCount()
+ {
+ serviceMessageCount.incrementAndGet();
+ lastServiceMessageTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getLastServiceMessageTimestamp()
+ */
+ public Date getLastServiceMessageTimestamp()
+ {
+ return lastServiceMessageTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getServiceMessageFrequency()
+ */
+ public Double getServiceMessageFrequency()
+ {
+ if (serviceMessageCount.get() > 0)
+ {
+ double runtime = differenceInMinutes(serviceMessageStart, System.currentTimeMillis());
+ return new Double(serviceMessageCount.get()/runtime);
+ }
+ else
+ {
+ return new Double(0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.management.MBeanRegistration#preDeregister()
+ */
+ public void preDeregister() throws Exception
+ {
+ MessageBrokerControl parent = (MessageBrokerControl)getParentControl();
+ parent.removeEndpoint(getObjectName());
+ }
+
+ public String getURI()
+ {
+ return endpoint.getUrl();
+ }
+
+ public String getSecurityConstraint()
+ {
+ return getSecurityConstraintOf(endpoint);
+ }
+
+ public static String getSecurityConstraintOf(Endpoint endpoint)
+ {
+ String result = "None";
+
+ SecurityConstraint constraint = endpoint.getSecurityConstraint();
+ if (constraint != null)
+ {
+ String authMethod = constraint.getMethod();
+ if (authMethod != null)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(authMethod);
+
+ List roles = constraint.getRoles();
+ if ((roles != null) && !roles.isEmpty())
+ {
+ buffer.append(':');
+ for (int i = 0; i < roles.size(); i++)
+ {
+ if (i > 0)
+ {
+ buffer.append(',');
+ }
+ buffer.append(' ');
+ buffer.append(roles.get(i));
+ }
+ }
+ result = buffer.toString();
+ }
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getBytesDeserialized()
+ */
+ public Long getBytesDeserialized(){
+ return Long.valueOf(bytesDeserialized.get());
+ }
+
+ /**
+ * Increments the count of bytes deserialized by the endpoint.
+ * @param currentBytesDeserialized the bytes is deserialized
+ */
+ public void addToBytesDeserialized(int currentBytesDeserialized) {
+ bytesDeserialized.addAndGet(currentBytesDeserialized);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getBytesSerialized()
+ */
+ public Long getBytesSerialized() {
+ return Long.valueOf(bytesSerialized.get());
+ }
+
+ /**
+ * Increments the count of bytes serialized by the endpoint.
+ * @param currentBytesSerialized the bytes is serialized
+ */
+ public void addToBytesSerialized(int currentBytesSerialized) {
+ bytesSerialized.addAndGet(currentBytesSerialized);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControlMBean.java
old mode 100755
new mode 100644
index d0aa61a..8a644ff
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControlMBean.java
@@ -1,113 +1,113 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-import flex.management.BaseControlMBean;
-
-import java.io.IOException;
-import java.util.Date;
-
-/**
- * Defines the runtime monitoring and management interface for managed endpoints.
- *
- * @author shodgson
- */
-public interface EndpointControlMBean extends BaseControlMBean
-{
- /**
- * Returns <code>true</code> if the <code>Endpoint</code> is running.
- *
- * @return <code>true</code> if the <code>Endpoint</code> is running.
- * @throws IOException Throws IOException.
- */
- Boolean isRunning() throws IOException;
-
- /**
- * Returns the start timestamp for the <code>Endpoint</code>.
- *
- * @return The start timestamp for the <code>Endpoint</code>.
- * @throws IOException Throws IOException.
- */
- Date getStartTimestamp() throws IOException;
-
- /**
- * Returns the count of messages decoded by this endpoint and routed to the broker.
- *
- * @return The count of messages decoded by this endpoint and routed to the broker.
- * @throws IOException Throws IOException.
- */
- Integer getServiceMessageCount() throws IOException;
-
- /**
- * Resets the count of service message invocations.
- *
- * @throws IOException Throws IOException.
- */
- void resetServiceMessageCount() throws IOException;
-
- /**
- * Returns the timestamp for the most recent message decoded by this endpoint and
- * routed to the broker.
- *
- * @return The timestamp for the most recent message decoded by this endpoint and
- * routed to the broker.
- * @throws IOException Throws IOException.
- */
- Date getLastServiceMessageTimestamp() throws IOException;
-
- /**
- * Returns the number of service message invocations per minute.
- *
- * @return The number of service message invocations per minute.
- * @throws IOException Throws IOException.
- */
- Double getServiceMessageFrequency() throws IOException;
-
- /**
- * Returns the URI that corresponds to this endpoint.
- *
- * @return The URI that corresponds to this endpoint.
- * @throws IOException Throws IOException.
- */
- String getURI() throws IOException;
-
- /**
- * Returns the security constraint that is associated with this endpoint.
- *
- * @return The security constraint that is associated with this endpoint.
- * @throws IOException Throws IOException.
- */
- String getSecurityConstraint() throws IOException;
-
- /**
- * Returns the total Bytes that have been deserialized by this endpoint
- * during its lifetime.
- *
- * @return total Bytes deserialized.
- * @throws IOException Throws IOException.
- */
- Long getBytesDeserialized() throws IOException;
-
- /**
- * Returns the total Bytes that have been serialized by this endpoint
- * during its lifetime.
- *
- * @return total Bytes serialized.
- * @throws IOException Throws IOException.
- */
- Long getBytesSerialized() throws IOException;
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControlMBean;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Defines the runtime monitoring and management interface for managed endpoints.
+ *
+ * @author shodgson
+ */
+public interface EndpointControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns <code>true</code> if the <code>Endpoint</code> is running.
+ *
+ * @return <code>true</code> if the <code>Endpoint</code> is running.
+ * @throws IOException Throws IOException.
+ */
+ Boolean isRunning() throws IOException;
+
+ /**
+ * Returns the start timestamp for the <code>Endpoint</code>.
+ *
+ * @return The start timestamp for the <code>Endpoint</code>.
+ * @throws IOException Throws IOException.
+ */
+ Date getStartTimestamp() throws IOException;
+
+ /**
+ * Returns the count of messages decoded by this endpoint and routed to the broker.
+ *
+ * @return The count of messages decoded by this endpoint and routed to the broker.
+ * @throws IOException Throws IOException.
+ */
+ Integer getServiceMessageCount() throws IOException;
+
+ /**
+ * Resets the count of service message invocations.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetServiceMessageCount() throws IOException;
+
+ /**
+ * Returns the timestamp for the most recent message decoded by this endpoint and
+ * routed to the broker.
+ *
+ * @return The timestamp for the most recent message decoded by this endpoint and
+ * routed to the broker.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastServiceMessageTimestamp() throws IOException;
+
+ /**
+ * Returns the number of service message invocations per minute.
+ *
+ * @return The number of service message invocations per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getServiceMessageFrequency() throws IOException;
+
+ /**
+ * Returns the URI that corresponds to this endpoint.
+ *
+ * @return The URI that corresponds to this endpoint.
+ * @throws IOException Throws IOException.
+ */
+ String getURI() throws IOException;
+
+ /**
+ * Returns the security constraint that is associated with this endpoint.
+ *
+ * @return The security constraint that is associated with this endpoint.
+ * @throws IOException Throws IOException.
+ */
+ String getSecurityConstraint() throws IOException;
+
+ /**
+ * Returns the total Bytes that have been deserialized by this endpoint
+ * during its lifetime.
+ *
+ * @return total Bytes deserialized.
+ * @throws IOException Throws IOException.
+ */
+ Long getBytesDeserialized() throws IOException;
+
+ /**
+ * Returns the total Bytes that have been serialized by this endpoint
+ * during its lifetime.
+ *
+ * @return total Bytes serialized.
+ * @throws IOException Throws IOException.
+ */
+ Long getBytesSerialized() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControl.java
old mode 100755
new mode 100644
index 6dc52ac..c8024de
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControl.java
@@ -1,50 +1,50 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-import flex.management.BaseControl;
-import flex.messaging.endpoints.HTTPEndpoint;
-
-/**
- * The <code>HTTPEndpointControl</code> class is the MBean implemenation
- * for monitoring and managing a <code>HTTPEndpoint</code> at runtime.
- *
- * @author shodgson
- */
-public class HTTPEndpointControl extends PollingEndpointControl implements
- HTTPEndpointControlMBean
-{
- private static final String TYPE = "HTTPEndpoint";
-
- /**
- * Constructs a <code>HTTPEndpointControl</code>, assigning managed message
- * endpoint and parent MBean.
- *
- * @param endpoint The <code>HTTPEndpoint</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public HTTPEndpointControl(HTTPEndpoint endpoint, BaseControl parent)
- {
- super(endpoint, parent);
- }
-
- /** {@inheritDoc} */
- public String getType()
- {
- return TYPE;
- }
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.messaging.endpoints.HTTPEndpoint;
+
+/**
+ * The <code>HTTPEndpointControl</code> class is the MBean implemenation
+ * for monitoring and managing a <code>HTTPEndpoint</code> at runtime.
+ *
+ * @author shodgson
+ */
+public class HTTPEndpointControl extends PollingEndpointControl implements
+ HTTPEndpointControlMBean
+{
+ private static final String TYPE = "HTTPEndpoint";
+
+ /**
+ * Constructs a <code>HTTPEndpointControl</code>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>HTTPEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public HTTPEndpointControl(HTTPEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getType()
+ {
+ return TYPE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControlMBean.java
old mode 100755
new mode 100644
index fce75d2..055b921
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControlMBean.java
@@ -1,27 +1,27 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-/**
- * Defines the runtime monitoring and management interface for managed HTTP endpoints.
- *
- * @author shodgson
- */
-public interface HTTPEndpointControlMBean extends PollingEndpointControlMBean
-{
- // Empty for now.
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+/**
+ * Defines the runtime monitoring and management interface for managed HTTP endpoints.
+ *
+ * @author shodgson
+ */
+public interface HTTPEndpointControlMBean extends PollingEndpointControlMBean
+{
+ // Empty for now.
+}
[46/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/DestinationSettings.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/DestinationSettings.java b/modules/common/src/flex/messaging/config/DestinationSettings.java
old mode 100755
new mode 100644
index e063147..4c48bf9
--- a/modules/common/src/flex/messaging/config/DestinationSettings.java
+++ b/modules/common/src/flex/messaging/config/DestinationSettings.java
@@ -1,192 +1,192 @@
-/*
- * 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.config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Destinations are configured for a particular <code>Service</code>. A
- * destination's configuration includes an <code>id</code> attribute to provide
- * a public name for clients to use when sending messages.
- * <p>
- * The configuration also specifies which channels are valid to contact the
- * destination, as well as which adapter a service must use to process
- * client messages for this destination and any security constraints that need
- * to be enforced.
- * </p>
- *
- * @see flex.messaging.Destination
- * @author Peter Farland
- * @exclude
- */
-public class DestinationSettings extends PropertiesSettings
-{
- /**
- * @exclude
- */
- public static final String SERVER_ELEMENT = "server";
-
- private final String id;
- private String sourceFile;
- private List channelSettings;
- private AdapterSettings adapterSettings;
- private SecurityConstraint constraint;
-
- /**
- * Used to construct a new set of properties to describe a destination.
- * Note that an identity is required in order for clients to refer to a
- * destination.
- *
- * @param id A string representing the unique identity of this destination.
- */
- public DestinationSettings(String id)
- {
- this.id = id;
- channelSettings = new ArrayList();
- }
-
- /**
- * Gets the unique identity used by clients to target a destination.
- *
- * @return String the destination's id.
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * Internal use only.
- * @exclude
- */
- String getSourceFile()
- {
- return sourceFile;
- }
-
- /**
- * Internal use only.
- * @exclude
- */
- void setSourceFile(String sourceFile)
- {
- this.sourceFile = sourceFile;
- }
-
- /*
- * CHANNEL SETTINGS
- */
-
- /**
- * Adds a channel to the set of channels that should be used to contact
- * this destination. The order in which channels are added is significant
- * (clients use this order to locate an available channel and failover to
- * the next in the list on failure).
- *
- * @param c the <code>ChannelSettings</code> to add to the set of
- * channel definitions for this destination.
- */
- public void addChannelSettings(ChannelSettings c)
- {
- if (c != null)
- {
- channelSettings.add(c);
- }
- }
-
- /**
- * Overrides the set of channels that can be used to contact this
- * destination.
- *
- * @param settings A List of <code>ChannelSettings</code>.
- */
- public void setChannelSettings(List settings)
- {
- channelSettings = settings;
- }
-
- /**
- * Gets the set of channels that can be used to contact this destination.
- *
- * @return a <code>java.util.List</code> of <code>ChannelSetting</code>s
- * describing the channels that can be used to contact this destination.
- */
- public List getChannelSettings()
- {
- return channelSettings;
- }
-
-
- /*
- * SECURITY
- */
-
- /**
- * Gets the <code>SecurityConstraint</code> that will be applied to this
- * destination, or <code>null</code> if no constraint has been registered.
- *
- * @return the <code>SecurityConstraint</code> for this destination.
- */
- public SecurityConstraint getConstraint()
- {
- return constraint;
- }
-
- /**
- * Sets the security constraint to be applied to this destination. Security
- * constraints restrict which clients can contact this destination. Use
- * <code>null</code> to remove an existing constraint.
- *
- * @param sc the <code>SecurityConstraint</code> to apply to this
- * destination.
- */
- public void setConstraint(SecurityConstraint sc)
- {
- constraint = sc;
- }
-
- /*
- * SERVICE ADAPTER
- */
-
- /**
- * Sets the service adapter to be used when the managing service is
- * processing messages bound for this destination.
- *
- * @param a The <code>AdapterSettings</code> that describe the adapter
- * to use for this destination.
- */
- public void setAdapterSettings(AdapterSettings a)
- {
- adapterSettings = a;
- }
-
- /**
- * Gets the adapter to be used for this destination.
- *
- * @return <code>AdapterSettings</code> for this destinations adapter.
- * A <code>null</code> value implies the the default service adapter should
- * be used.
- */
- public AdapterSettings getAdapterSettings()
- {
- return adapterSettings;
- }
-
-
-}
+/*
+ * 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.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Destinations are configured for a particular <code>Service</code>. A
+ * destination's configuration includes an <code>id</code> attribute to provide
+ * a public name for clients to use when sending messages.
+ * <p>
+ * The configuration also specifies which channels are valid to contact the
+ * destination, as well as which adapter a service must use to process
+ * client messages for this destination and any security constraints that need
+ * to be enforced.
+ * </p>
+ *
+ * @see flex.messaging.Destination
+ * @author Peter Farland
+ * @exclude
+ */
+public class DestinationSettings extends PropertiesSettings
+{
+ /**
+ * @exclude
+ */
+ public static final String SERVER_ELEMENT = "server";
+
+ private final String id;
+ private String sourceFile;
+ private List channelSettings;
+ private AdapterSettings adapterSettings;
+ private SecurityConstraint constraint;
+
+ /**
+ * Used to construct a new set of properties to describe a destination.
+ * Note that an identity is required in order for clients to refer to a
+ * destination.
+ *
+ * @param id A string representing the unique identity of this destination.
+ */
+ public DestinationSettings(String id)
+ {
+ this.id = id;
+ channelSettings = new ArrayList();
+ }
+
+ /**
+ * Gets the unique identity used by clients to target a destination.
+ *
+ * @return String the destination's id.
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Internal use only.
+ * @exclude
+ */
+ String getSourceFile()
+ {
+ return sourceFile;
+ }
+
+ /**
+ * Internal use only.
+ * @exclude
+ */
+ void setSourceFile(String sourceFile)
+ {
+ this.sourceFile = sourceFile;
+ }
+
+ /*
+ * CHANNEL SETTINGS
+ */
+
+ /**
+ * Adds a channel to the set of channels that should be used to contact
+ * this destination. The order in which channels are added is significant
+ * (clients use this order to locate an available channel and failover to
+ * the next in the list on failure).
+ *
+ * @param c the <code>ChannelSettings</code> to add to the set of
+ * channel definitions for this destination.
+ */
+ public void addChannelSettings(ChannelSettings c)
+ {
+ if (c != null)
+ {
+ channelSettings.add(c);
+ }
+ }
+
+ /**
+ * Overrides the set of channels that can be used to contact this
+ * destination.
+ *
+ * @param settings A List of <code>ChannelSettings</code>.
+ */
+ public void setChannelSettings(List settings)
+ {
+ channelSettings = settings;
+ }
+
+ /**
+ * Gets the set of channels that can be used to contact this destination.
+ *
+ * @return a <code>java.util.List</code> of <code>ChannelSetting</code>s
+ * describing the channels that can be used to contact this destination.
+ */
+ public List getChannelSettings()
+ {
+ return channelSettings;
+ }
+
+
+ /*
+ * SECURITY
+ */
+
+ /**
+ * Gets the <code>SecurityConstraint</code> that will be applied to this
+ * destination, or <code>null</code> if no constraint has been registered.
+ *
+ * @return the <code>SecurityConstraint</code> for this destination.
+ */
+ public SecurityConstraint getConstraint()
+ {
+ return constraint;
+ }
+
+ /**
+ * Sets the security constraint to be applied to this destination. Security
+ * constraints restrict which clients can contact this destination. Use
+ * <code>null</code> to remove an existing constraint.
+ *
+ * @param sc the <code>SecurityConstraint</code> to apply to this
+ * destination.
+ */
+ public void setConstraint(SecurityConstraint sc)
+ {
+ constraint = sc;
+ }
+
+ /*
+ * SERVICE ADAPTER
+ */
+
+ /**
+ * Sets the service adapter to be used when the managing service is
+ * processing messages bound for this destination.
+ *
+ * @param a The <code>AdapterSettings</code> that describe the adapter
+ * to use for this destination.
+ */
+ public void setAdapterSettings(AdapterSettings a)
+ {
+ adapterSettings = a;
+ }
+
+ /**
+ * Gets the adapter to be used for this destination.
+ *
+ * @return <code>AdapterSettings</code> for this destinations adapter.
+ * A <code>null</code> value implies the the default service adapter should
+ * be used.
+ */
+ public AdapterSettings getAdapterSettings()
+ {
+ return adapterSettings;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/FlexClientSettings.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/FlexClientSettings.java b/modules/common/src/flex/messaging/config/FlexClientSettings.java
old mode 100755
new mode 100644
index 9b24b40..695b274
--- a/modules/common/src/flex/messaging/config/FlexClientSettings.java
+++ b/modules/common/src/flex/messaging/config/FlexClientSettings.java
@@ -1,133 +1,133 @@
-/*
- * 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.config;
-
-/**
- * @exclude
- */
-public class FlexClientSettings extends PropertiesSettings
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs a FlexClientSettings instance.
- */
- public FlexClientSettings()
- {
- // Empty for now.
- }
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- private long timeoutMinutes = -1;
-
- /**
- * Returns the number of minutes before an idle FlexClient is timed out.
- *
- * @return The number of minutes before an idle FlexClient is timed out.
- */
- public long getTimeoutMinutes()
- {
- return timeoutMinutes;
- }
-
- /**
- * Sets the number of minutes before an idle FlexClient is timed out.
- *
- * @param value The number of minutes before an idle FlexClient is timed out.
- */
- public void setTimeoutMinutes(long value)
- {
- timeoutMinutes = value;
- }
-
- private String flexClientOutboundQueueProcessorClassName;
-
- /**
- * Returns the name of the default <code>FlexClientOutboundQueueProcessorClass</code>.
- *
- * @return The the name of the default <code>FlexClientOutboundQueueProcessorClass</code>.
- */
- public String getFlexClientOutboundQueueProcessorClassName()
- {
- return flexClientOutboundQueueProcessorClassName;
- }
-
- /**
- * Sets the name of the default <code>FlexClientOutboundQueueProcessor</code>.
- *
- * @param flexClientOutboundQueueProcessorClassName The name of the default <code>FlexClientOutboundQueueProcessor</code>.
- */
- public void setFlexClientOutboundQueueProcessorClassName(String flexClientOutboundQueueProcessorClassName)
- {
- this.flexClientOutboundQueueProcessorClassName = flexClientOutboundQueueProcessorClassName;
- }
-
- private ConfigMap flexClientOutboundQueueProcessorProperties;
-
- /**
- * Returns the properties for the default <code>FlexClientOutboundQueueProcessor</code>.
- *
- * @return The properties for the default <code>FlexClientOutboundQueueProcessor</code>.
- */
- public ConfigMap getFlexClientOutboundQueueProcessorProperties()
- {
- return flexClientOutboundQueueProcessorProperties;
- }
-
- /**
- * Sets the properties for the default <code>FlexClientOutboundQueueProcessor</code>.
- *
- * @param flexClientOutboundQueueProcessorProperties
- */
- public void setFlexClientOutboundQueueProcessorProperties(ConfigMap flexClientOutboundQueueProcessorProperties)
- {
- this.flexClientOutboundQueueProcessorProperties = flexClientOutboundQueueProcessorProperties;
- }
-
- private int reliableReconnectDurationMillis;
-
- public int getReliableReconnectDurationMillis()
- {
- return reliableReconnectDurationMillis;
- }
-
- public void setReliableReconnectDurationMillis(int value)
- {
- reliableReconnectDurationMillis = value;
- }
-
- private int heartbeatIntervalMillis;
-
- public int getHeartbeatIntervalMillis()
- {
- return heartbeatIntervalMillis;
- }
-
- public void setHeartbeatIntervalMillis(int value)
- {
- heartbeatIntervalMillis = value;
- }
-}
+/*
+ * 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.config;
+
+/**
+ * @exclude
+ */
+public class FlexClientSettings extends PropertiesSettings
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs a FlexClientSettings instance.
+ */
+ public FlexClientSettings()
+ {
+ // Empty for now.
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ private long timeoutMinutes = -1;
+
+ /**
+ * Returns the number of minutes before an idle FlexClient is timed out.
+ *
+ * @return The number of minutes before an idle FlexClient is timed out.
+ */
+ public long getTimeoutMinutes()
+ {
+ return timeoutMinutes;
+ }
+
+ /**
+ * Sets the number of minutes before an idle FlexClient is timed out.
+ *
+ * @param value The number of minutes before an idle FlexClient is timed out.
+ */
+ public void setTimeoutMinutes(long value)
+ {
+ timeoutMinutes = value;
+ }
+
+ private String flexClientOutboundQueueProcessorClassName;
+
+ /**
+ * Returns the name of the default <code>FlexClientOutboundQueueProcessorClass</code>.
+ *
+ * @return The the name of the default <code>FlexClientOutboundQueueProcessorClass</code>.
+ */
+ public String getFlexClientOutboundQueueProcessorClassName()
+ {
+ return flexClientOutboundQueueProcessorClassName;
+ }
+
+ /**
+ * Sets the name of the default <code>FlexClientOutboundQueueProcessor</code>.
+ *
+ * @param flexClientOutboundQueueProcessorClassName The name of the default <code>FlexClientOutboundQueueProcessor</code>.
+ */
+ public void setFlexClientOutboundQueueProcessorClassName(String flexClientOutboundQueueProcessorClassName)
+ {
+ this.flexClientOutboundQueueProcessorClassName = flexClientOutboundQueueProcessorClassName;
+ }
+
+ private ConfigMap flexClientOutboundQueueProcessorProperties;
+
+ /**
+ * Returns the properties for the default <code>FlexClientOutboundQueueProcessor</code>.
+ *
+ * @return The properties for the default <code>FlexClientOutboundQueueProcessor</code>.
+ */
+ public ConfigMap getFlexClientOutboundQueueProcessorProperties()
+ {
+ return flexClientOutboundQueueProcessorProperties;
+ }
+
+ /**
+ * Sets the properties for the default <code>FlexClientOutboundQueueProcessor</code>.
+ *
+ * @param flexClientOutboundQueueProcessorProperties
+ */
+ public void setFlexClientOutboundQueueProcessorProperties(ConfigMap flexClientOutboundQueueProcessorProperties)
+ {
+ this.flexClientOutboundQueueProcessorProperties = flexClientOutboundQueueProcessorProperties;
+ }
+
+ private int reliableReconnectDurationMillis;
+
+ public int getReliableReconnectDurationMillis()
+ {
+ return reliableReconnectDurationMillis;
+ }
+
+ public void setReliableReconnectDurationMillis(int value)
+ {
+ reliableReconnectDurationMillis = value;
+ }
+
+ private int heartbeatIntervalMillis;
+
+ public int getHeartbeatIntervalMillis()
+ {
+ return heartbeatIntervalMillis;
+ }
+
+ public void setHeartbeatIntervalMillis(int value)
+ {
+ heartbeatIntervalMillis = value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/LocalFileResolver.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/LocalFileResolver.java b/modules/common/src/flex/messaging/config/LocalFileResolver.java
old mode 100755
new mode 100644
index c6c99cd..25c6309
--- a/modules/common/src/flex/messaging/config/LocalFileResolver.java
+++ b/modules/common/src/flex/messaging/config/LocalFileResolver.java
@@ -1,203 +1,203 @@
-/*
- * 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.config;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
-/**
- * @exclude
- */
-public class LocalFileResolver implements ConfigurationFileResolver
-{
- public static final int CLIENT = 0;
- public static final int SERVER = 1;
- public static final int LIVECYCLE = 2;
-
- private static final int ERR_MSG_INVALID_PATH_CLIENT = 11106;
- private static final int ERR_MSG_INVALID_PATH_SERVER = 11108;
- private static final int ERR_MSG_INVALID_PATH_LIVECYCLE = 11122;
-
- private Stack configurationPathStack = new Stack();
- int version = CLIENT;
-
- public LocalFileResolver()
- {
- }
-
- public LocalFileResolver(int version)
- {
- this.version = version;
- }
-
- public void setErrorMessage(ConfigurationException e, String path)
- {
- if (version == LIVECYCLE)
- {
- // Invalid location: ''{0}''. Please specify a valid LiveCycle Data Services Configuration file via the LiveCycle Admin UI.
- e.setMessage(ERR_MSG_INVALID_PATH_LIVECYCLE, new Object[] {path});
- }
- else if (version == SERVER)
- {
- // Please specify a valid ''services.configuration.file'' in web.xml. You specified ''{0}''. This is not a valid file system path reachable via the app server and is also not a path to a resource in your J2EE application archive.
- e.setMessage(ERR_MSG_INVALID_PATH_SERVER, new Object[]{path});
- }
- else
- {
- // Please specify a valid <services/> file path in flex-config.xml.
- e.setMessage(ERR_MSG_INVALID_PATH_CLIENT);
- }
- }
-
- public InputStream getConfigurationFile(String path)
- {
- File f = new File(path);
- try
- {
- if (f != null && f.exists() && f.isAbsolute())
- {
- FileInputStream fin = new FileInputStream(f);
- pushConfigurationFile(f.getParent());
- return fin;
- }
- else
- {
- ConfigurationException e = new ConfigurationException();
- setErrorMessage(e, path);
- throw e;
- }
- }
- catch (FileNotFoundException ex)
- {
- ConfigurationException e = new ConfigurationException();
- setErrorMessage(e, path);
- e.setRootCause(ex);
- throw e;
- }
- catch (SecurityException se)
- {
- ConfigurationException e = new ConfigurationException();
- setErrorMessage(e, path);
- e.setRootCause(se);
- throw e;
- }
- }
-
- public InputStream getIncludedFile(String src)
- {
- String path = configurationPathStack.peek() + File.separator + src;
- File f = new File(path);
- try
- {
- if (f != null && f.exists() && f.isAbsolute())
- {
- FileInputStream fin = new FileInputStream(f);
- pushConfigurationFile(f.getParent());
- return fin;
- }
- else
- {
- // Please specify a valid include file. ''{0}'' is invalid.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(11107, new Object[] {path});
- throw e;
- }
- }
- catch (FileNotFoundException ex)
- {
- // Please specify a valid include file. ''{0}'' is invalid.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(11107, new Object[] {path});
- e.setRootCause(ex);
- throw e;
- }
- catch (SecurityException se)
- {
- // Please specify a valid include file. ''{0}'' is invalid.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(11107, new Object[] {path});
- e.setRootCause(se);
- throw e;
- }
- }
-
- public void popIncludedFile()
- {
- configurationPathStack.pop();
- }
-
- /**
- * Returns the list of XML files (denoted by .xml extension) in the directory
- * relative to the current configuration file.
- *
- * @param dir a directory relative to the current configuration file
- * @return a (possibly empty) list of file names
- */
- public List getFiles(String dir)
- {
- List result = new ArrayList();
- File f = new File(configurationPathStack.peek().toString(), dir);
- if (f.exists() && f.isDirectory())
- {
- String[] xmlFiles = f.list(new FilenameFilter()
- {
- public boolean accept(File dir, String name)
- {
- return name.endsWith(".xml");
- }
- });
-
- // prepend the directory to each filename
- for (int i = 0; i < xmlFiles.length; i++)
- {
- String file = xmlFiles[i];
- result.add(dir + File.separator + file);
- }
- return result;
- }
- else
- {
- // Please specify a valid include directory. ''{0}'' is invalid.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(11113, new Object[]{dir});
- throw e;
- }
- }
-
- private void pushConfigurationFile(String topLevelPath)
- {
- configurationPathStack.push(topLevelPath);
- }
-
- public String getIncludedPath(String src)
- {
- return configurationPathStack.peek() + File.separator + src;
- }
-
- public long getIncludedLastModified(String src)
- {
- String path = configurationPathStack.peek() + File.separator + src;
- File f = new File(path);
- return f.lastModified();
- }
+/*
+ * 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.config;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+/**
+ * @exclude
+ */
+public class LocalFileResolver implements ConfigurationFileResolver
+{
+ public static final int CLIENT = 0;
+ public static final int SERVER = 1;
+ public static final int LIVECYCLE = 2;
+
+ private static final int ERR_MSG_INVALID_PATH_CLIENT = 11106;
+ private static final int ERR_MSG_INVALID_PATH_SERVER = 11108;
+ private static final int ERR_MSG_INVALID_PATH_LIVECYCLE = 11122;
+
+ private Stack configurationPathStack = new Stack();
+ int version = CLIENT;
+
+ public LocalFileResolver()
+ {
+ }
+
+ public LocalFileResolver(int version)
+ {
+ this.version = version;
+ }
+
+ public void setErrorMessage(ConfigurationException e, String path)
+ {
+ if (version == LIVECYCLE)
+ {
+ // Invalid location: ''{0}''. Please specify a valid LiveCycle Data Services Configuration file via the LiveCycle Admin UI.
+ e.setMessage(ERR_MSG_INVALID_PATH_LIVECYCLE, new Object[] {path});
+ }
+ else if (version == SERVER)
+ {
+ // Please specify a valid ''services.configuration.file'' in web.xml. You specified ''{0}''. This is not a valid file system path reachable via the app server and is also not a path to a resource in your J2EE application archive.
+ e.setMessage(ERR_MSG_INVALID_PATH_SERVER, new Object[]{path});
+ }
+ else
+ {
+ // Please specify a valid <services/> file path in flex-config.xml.
+ e.setMessage(ERR_MSG_INVALID_PATH_CLIENT);
+ }
+ }
+
+ public InputStream getConfigurationFile(String path)
+ {
+ File f = new File(path);
+ try
+ {
+ if (f != null && f.exists() && f.isAbsolute())
+ {
+ FileInputStream fin = new FileInputStream(f);
+ pushConfigurationFile(f.getParent());
+ return fin;
+ }
+ else
+ {
+ ConfigurationException e = new ConfigurationException();
+ setErrorMessage(e, path);
+ throw e;
+ }
+ }
+ catch (FileNotFoundException ex)
+ {
+ ConfigurationException e = new ConfigurationException();
+ setErrorMessage(e, path);
+ e.setRootCause(ex);
+ throw e;
+ }
+ catch (SecurityException se)
+ {
+ ConfigurationException e = new ConfigurationException();
+ setErrorMessage(e, path);
+ e.setRootCause(se);
+ throw e;
+ }
+ }
+
+ public InputStream getIncludedFile(String src)
+ {
+ String path = configurationPathStack.peek() + File.separator + src;
+ File f = new File(path);
+ try
+ {
+ if (f != null && f.exists() && f.isAbsolute())
+ {
+ FileInputStream fin = new FileInputStream(f);
+ pushConfigurationFile(f.getParent());
+ return fin;
+ }
+ else
+ {
+ // Please specify a valid include file. ''{0}'' is invalid.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(11107, new Object[] {path});
+ throw e;
+ }
+ }
+ catch (FileNotFoundException ex)
+ {
+ // Please specify a valid include file. ''{0}'' is invalid.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(11107, new Object[] {path});
+ e.setRootCause(ex);
+ throw e;
+ }
+ catch (SecurityException se)
+ {
+ // Please specify a valid include file. ''{0}'' is invalid.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(11107, new Object[] {path});
+ e.setRootCause(se);
+ throw e;
+ }
+ }
+
+ public void popIncludedFile()
+ {
+ configurationPathStack.pop();
+ }
+
+ /**
+ * Returns the list of XML files (denoted by .xml extension) in the directory
+ * relative to the current configuration file.
+ *
+ * @param dir a directory relative to the current configuration file
+ * @return a (possibly empty) list of file names
+ */
+ public List getFiles(String dir)
+ {
+ List result = new ArrayList();
+ File f = new File(configurationPathStack.peek().toString(), dir);
+ if (f.exists() && f.isDirectory())
+ {
+ String[] xmlFiles = f.list(new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.endsWith(".xml");
+ }
+ });
+
+ // prepend the directory to each filename
+ for (int i = 0; i < xmlFiles.length; i++)
+ {
+ String file = xmlFiles[i];
+ result.add(dir + File.separator + file);
+ }
+ return result;
+ }
+ else
+ {
+ // Please specify a valid include directory. ''{0}'' is invalid.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(11113, new Object[]{dir});
+ throw e;
+ }
+ }
+
+ private void pushConfigurationFile(String topLevelPath)
+ {
+ configurationPathStack.push(topLevelPath);
+ }
+
+ public String getIncludedPath(String src)
+ {
+ return configurationPathStack.peek() + File.separator + src;
+ }
+
+ public long getIncludedLastModified(String src)
+ {
+ String path = configurationPathStack.peek() + File.separator + src;
+ File f = new File(path);
+ return f.lastModified();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/LoggingSettings.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/LoggingSettings.java b/modules/common/src/flex/messaging/config/LoggingSettings.java
old mode 100755
new mode 100644
index b9b95fe..8c2769e
--- a/modules/common/src/flex/messaging/config/LoggingSettings.java
+++ b/modules/common/src/flex/messaging/config/LoggingSettings.java
@@ -1,47 +1,47 @@
-/*
- * 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.config;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * A log maintains a series of Loggers for each logging category and
- * Targets are established that listen for LogEvents on those Loggers.
- *
- * @author Peter Farland
- * @exclude
- */
-public class LoggingSettings extends PropertiesSettings
-{
- private final List targets;
-
- public LoggingSettings()
- {
- targets = new ArrayList();
- }
-
- public void addTarget(TargetSettings t)
- {
- targets.add(t);
- }
-
- public List getTargets()
- {
- return targets;
- }
-}
+/*
+ * 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.config;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * A log maintains a series of Loggers for each logging category and
+ * Targets are established that listen for LogEvents on those Loggers.
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public class LoggingSettings extends PropertiesSettings
+{
+ private final List targets;
+
+ public LoggingSettings()
+ {
+ targets = new ArrayList();
+ }
+
+ public void addTarget(TargetSettings t)
+ {
+ targets.add(t);
+ }
+
+ public List getTargets()
+ {
+ return targets;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/LoginCommandSettings.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/LoginCommandSettings.java b/modules/common/src/flex/messaging/config/LoginCommandSettings.java
old mode 100755
new mode 100644
index c91a4d7..5b167d4
--- a/modules/common/src/flex/messaging/config/LoginCommandSettings.java
+++ b/modules/common/src/flex/messaging/config/LoginCommandSettings.java
@@ -1,102 +1,102 @@
-/*
- * 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.config;
-
-/**
- * Settings for <code>LoginCommand</code> class.
- *
- * @author esolovey
- * @exclude
- */
-public class LoginCommandSettings
-{
- public static final String SERVER_MATCH_OVERRIDE = "all";
-
- private String className;
- private String server;
- private boolean perClientAuthentication;
-
- /**
- * Create a new <code>LoginCommandSettings</code> instance with default settings.
- */
- public LoginCommandSettings()
- {
- perClientAuthentication = false;
- }
-
- /**
- * Returns the class name associated with the settings.
- *
- * @return The class name.
- */
- public String getClassName()
- {
- return className;
- }
-
- /**
- * Sets the class name associated with the settings.
- *
- * @param className The class name.
- */
- public void setClassName(String className)
- {
- this.className = className;
- }
-
- /**
- * Returns the server name associated with the settings.
- *
- * @return The server name.
- */
- public String getServer()
- {
- return server;
- }
-
- /**
- * Sets the server name associated with the settings.
- *
- * @param server The server name.
- */
- public void setServer(String server)
- {
- this.server = server;
- }
-
- /**
- * Returns whether per client authentication is enabled or not.
- *
- * @return <code>true</code> if per client authentication is enabled;
- * otherwise <code>false</code>.
- */
- public boolean isPerClientAuthentication()
- {
- return perClientAuthentication;
- }
-
- /**
- * Sets whether per client authentication is enabled or not.
- *
- * @param perClientAuthentication <code>true</code> if per client authentication
- * is enabled; otherwise <code>false</code>.
- */
- public void setPerClientAuthentication(boolean perClientAuthentication)
- {
- this.perClientAuthentication = perClientAuthentication;
- }
-}
+/*
+ * 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.config;
+
+/**
+ * Settings for <code>LoginCommand</code> class.
+ *
+ * @author esolovey
+ * @exclude
+ */
+public class LoginCommandSettings
+{
+ public static final String SERVER_MATCH_OVERRIDE = "all";
+
+ private String className;
+ private String server;
+ private boolean perClientAuthentication;
+
+ /**
+ * Create a new <code>LoginCommandSettings</code> instance with default settings.
+ */
+ public LoginCommandSettings()
+ {
+ perClientAuthentication = false;
+ }
+
+ /**
+ * Returns the class name associated with the settings.
+ *
+ * @return The class name.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Sets the class name associated with the settings.
+ *
+ * @param className The class name.
+ */
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+ /**
+ * Returns the server name associated with the settings.
+ *
+ * @return The server name.
+ */
+ public String getServer()
+ {
+ return server;
+ }
+
+ /**
+ * Sets the server name associated with the settings.
+ *
+ * @param server The server name.
+ */
+ public void setServer(String server)
+ {
+ this.server = server;
+ }
+
+ /**
+ * Returns whether per client authentication is enabled or not.
+ *
+ * @return <code>true</code> if per client authentication is enabled;
+ * otherwise <code>false</code>.
+ */
+ public boolean isPerClientAuthentication()
+ {
+ return perClientAuthentication;
+ }
+
+ /**
+ * Sets whether per client authentication is enabled or not.
+ *
+ * @param perClientAuthentication <code>true</code> if per client authentication
+ * is enabled; otherwise <code>false</code>.
+ */
+ public void setPerClientAuthentication(boolean perClientAuthentication)
+ {
+ this.perClientAuthentication = perClientAuthentication;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/PropertiesSettings.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/PropertiesSettings.java b/modules/common/src/flex/messaging/config/PropertiesSettings.java
old mode 100755
new mode 100644
index 8245606..24d870d
--- a/modules/common/src/flex/messaging/config/PropertiesSettings.java
+++ b/modules/common/src/flex/messaging/config/PropertiesSettings.java
@@ -1,100 +1,100 @@
-/*
- * 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.config;
-
-import java.util.List;
-
-/**
- * Holds any child element of the properties section of the services configuration.
- * <p>
- * If a property is a simple element with a text value then it is stored as a String
- * using the element name as the property name. If the same element appears again then
- * the element is converted to a List of values and further occurences are simply added
- * to the List.
- * </p>
- * <p>
- * If a property element has child elements the children are recursively processed
- * and added as a Map.
- * </p>
- *
- * @author Peter Farland
- * @exclude
- */
-public abstract class PropertiesSettings
-{
- protected final ConfigMap properties;
-
- public PropertiesSettings()
- {
- properties = new ConfigMap();
- }
-
- public final void addProperties(ConfigMap p)
- {
- properties.addProperties(p);
- }
-
- public ConfigMap getProperties()
- {
- return properties;
- }
-
- public final String getProperty(String name)
- {
- return getPropertyAsString(name, null);
- }
-
- public final void addProperty(String name, String value)
- {
- properties.addProperty(name, value);
- }
-
- public final void addProperty(String name, ConfigMap value)
- {
- properties.addProperty(name, value);
- }
-
- public final ConfigMap getPropertyAsMap(String name, ConfigMap defaultValue)
- {
- return properties.getPropertyAsMap(name, defaultValue);
- }
-
- public final String getPropertyAsString(String name, String defaultValue)
- {
- return properties.getPropertyAsString(name, defaultValue);
- }
-
- public final List getPropertyAsList(String name, List defaultValue)
- {
- return properties.getPropertyAsList(name, defaultValue);
- }
-
- public final int getPropertyAsInt(String name, int defaultValue)
- {
- return properties.getPropertyAsInt(name, defaultValue);
- }
-
- public final boolean getPropertyAsBoolean(String name, boolean defaultValue)
- {
- return properties.getPropertyAsBoolean(name, defaultValue);
- }
-
- public final long getPropertyAsLong(String name, long defaultValue)
- {
- return properties.getPropertyAsLong(name, defaultValue);
- }
-}
+/*
+ * 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.config;
+
+import java.util.List;
+
+/**
+ * Holds any child element of the properties section of the services configuration.
+ * <p>
+ * If a property is a simple element with a text value then it is stored as a String
+ * using the element name as the property name. If the same element appears again then
+ * the element is converted to a List of values and further occurences are simply added
+ * to the List.
+ * </p>
+ * <p>
+ * If a property element has child elements the children are recursively processed
+ * and added as a Map.
+ * </p>
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public abstract class PropertiesSettings
+{
+ protected final ConfigMap properties;
+
+ public PropertiesSettings()
+ {
+ properties = new ConfigMap();
+ }
+
+ public final void addProperties(ConfigMap p)
+ {
+ properties.addProperties(p);
+ }
+
+ public ConfigMap getProperties()
+ {
+ return properties;
+ }
+
+ public final String getProperty(String name)
+ {
+ return getPropertyAsString(name, null);
+ }
+
+ public final void addProperty(String name, String value)
+ {
+ properties.addProperty(name, value);
+ }
+
+ public final void addProperty(String name, ConfigMap value)
+ {
+ properties.addProperty(name, value);
+ }
+
+ public final ConfigMap getPropertyAsMap(String name, ConfigMap defaultValue)
+ {
+ return properties.getPropertyAsMap(name, defaultValue);
+ }
+
+ public final String getPropertyAsString(String name, String defaultValue)
+ {
+ return properties.getPropertyAsString(name, defaultValue);
+ }
+
+ public final List getPropertyAsList(String name, List defaultValue)
+ {
+ return properties.getPropertyAsList(name, defaultValue);
+ }
+
+ public final int getPropertyAsInt(String name, int defaultValue)
+ {
+ return properties.getPropertyAsInt(name, defaultValue);
+ }
+
+ public final boolean getPropertyAsBoolean(String name, boolean defaultValue)
+ {
+ return properties.getPropertyAsBoolean(name, defaultValue);
+ }
+
+ public final long getPropertyAsLong(String name, long defaultValue)
+ {
+ return properties.getPropertyAsLong(name, defaultValue);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/SecurityConstraint.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/SecurityConstraint.java b/modules/common/src/flex/messaging/config/SecurityConstraint.java
old mode 100755
new mode 100644
index fd18646..0b7638b
--- a/modules/common/src/flex/messaging/config/SecurityConstraint.java
+++ b/modules/common/src/flex/messaging/config/SecurityConstraint.java
@@ -1,123 +1,123 @@
-/*
- * 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.config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Security constraints are used by the login manager to secure access to
- * destinations and endpoints.
- */
-public class SecurityConstraint
-{
- /**
- * String constant for basic authentication.
- */
- public static final String BASIC_AUTH_METHOD = "Basic";
-
- /**
- * String constant for custom authentication.
- */
- public static final String CUSTOM_AUTH_METHOD = "Custom";
-
- private final String id;
- private String method;
- private List roles;
-
- /**
- * Creates an anonymous <code>SecurityConstraint</code> instance.
- */
- public SecurityConstraint()
- {
- this(null);
- }
-
- /**
- * Creates a <code>SecurityConstraint</code> instance with an id.
- *
- * @param id The id of the <code>SecurityConstraint</code> instance.
- */
- public SecurityConstraint(String id)
- {
- this.id = id;
- method = CUSTOM_AUTH_METHOD;
- }
-
- /**
- * Returns a list of roles of the <code>SecurityConstraint</code>.
- *
- * @return List of roles.
- */
- public List getRoles()
- {
- return roles;
- }
-
- /**
- * Adds a role to the list of roles of the <code>SecurityConstraint</code>.
- *
- * @param role New role to add to the list of roles.
- */
- public void addRole(String role)
- {
- if (role == null)
- return;
-
- if (roles == null)
- roles = new ArrayList();
-
- roles.add(role);
- }
-
- /**
- * Returns the id of the <code>SecurityConstraint</code>.
- *
- * @return The id of the <code>SecurityConstraint</code>.
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * Returns the authorization method of the <code>SecurityConstraint</code>.
- *
- * @return Authorization method.
- */
- public String getMethod()
- {
- return method;
- }
-
- /**
- * Sets the authorization method of the <code>SecurityConstraint</code>.
- * Valid values are Basic and Custom.
- *
- * @param method The authentication method to set which can be custom or basic.
- */
- public void setMethod(String method)
- {
- if (method == null)
- return;
-
- if (CUSTOM_AUTH_METHOD.equalsIgnoreCase(method))
- this.method = CUSTOM_AUTH_METHOD;
- else if (BASIC_AUTH_METHOD.equalsIgnoreCase(method))
- this.method = BASIC_AUTH_METHOD;
- }
-}
+/*
+ * 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.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Security constraints are used by the login manager to secure access to
+ * destinations and endpoints.
+ */
+public class SecurityConstraint
+{
+ /**
+ * String constant for basic authentication.
+ */
+ public static final String BASIC_AUTH_METHOD = "Basic";
+
+ /**
+ * String constant for custom authentication.
+ */
+ public static final String CUSTOM_AUTH_METHOD = "Custom";
+
+ private final String id;
+ private String method;
+ private List roles;
+
+ /**
+ * Creates an anonymous <code>SecurityConstraint</code> instance.
+ */
+ public SecurityConstraint()
+ {
+ this(null);
+ }
+
+ /**
+ * Creates a <code>SecurityConstraint</code> instance with an id.
+ *
+ * @param id The id of the <code>SecurityConstraint</code> instance.
+ */
+ public SecurityConstraint(String id)
+ {
+ this.id = id;
+ method = CUSTOM_AUTH_METHOD;
+ }
+
+ /**
+ * Returns a list of roles of the <code>SecurityConstraint</code>.
+ *
+ * @return List of roles.
+ */
+ public List getRoles()
+ {
+ return roles;
+ }
+
+ /**
+ * Adds a role to the list of roles of the <code>SecurityConstraint</code>.
+ *
+ * @param role New role to add to the list of roles.
+ */
+ public void addRole(String role)
+ {
+ if (role == null)
+ return;
+
+ if (roles == null)
+ roles = new ArrayList();
+
+ roles.add(role);
+ }
+
+ /**
+ * Returns the id of the <code>SecurityConstraint</code>.
+ *
+ * @return The id of the <code>SecurityConstraint</code>.
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Returns the authorization method of the <code>SecurityConstraint</code>.
+ *
+ * @return Authorization method.
+ */
+ public String getMethod()
+ {
+ return method;
+ }
+
+ /**
+ * Sets the authorization method of the <code>SecurityConstraint</code>.
+ * Valid values are Basic and Custom.
+ *
+ * @param method The authentication method to set which can be custom or basic.
+ */
+ public void setMethod(String method)
+ {
+ if (method == null)
+ return;
+
+ if (CUSTOM_AUTH_METHOD.equalsIgnoreCase(method))
+ this.method = CUSTOM_AUTH_METHOD;
+ else if (BASIC_AUTH_METHOD.equalsIgnoreCase(method))
+ this.method = BASIC_AUTH_METHOD;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ServiceSettings.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ServiceSettings.java b/modules/common/src/flex/messaging/config/ServiceSettings.java
old mode 100755
new mode 100644
index 3c93759..9b9fad6
--- a/modules/common/src/flex/messaging/config/ServiceSettings.java
+++ b/modules/common/src/flex/messaging/config/ServiceSettings.java
@@ -1,166 +1,166 @@
-/*
- * 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.config;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A service represents a high-level grouping of
- * functionality to which the message broker can
- * delegate messages. Services specify which
- * message types they're interested in and use
- * adapters to carry out a message's for a
- * destination.
- * <p>
- * A service maintains a list of destinations which
- * effectively represents a "whitelist"
- * of actions allowed by that service.
- * </p>
- *
- * @author Peter Farland
- * @exclude
- */
-public class ServiceSettings extends PropertiesSettings
-{
- private final String id;
- private String sourceFile;
- private String className;
-
- private AdapterSettings defaultAdapterSettings;
- private final Map adapterSettings;
- private final List defaultChannels;
- private final Map destinationSettings;
- private SecurityConstraint securityConstraint;
-
- public ServiceSettings(String id)
- {
- this.id = id;
- destinationSettings = new HashMap();
- adapterSettings = new HashMap(2);
- defaultChannels = new ArrayList(4);
- }
-
- public String getId()
- {
- return id;
- }
-
- String getSourceFile()
- {
- return sourceFile;
- }
-
- void setSourceFile(String sourceFile)
- {
- this.sourceFile = sourceFile;
- }
-
- public String getClassName()
- {
- return className;
- }
-
- public void setClassName(String name)
- {
- className = name;
- }
-
- /*
- * SERVER ADAPTERS
- */
- public AdapterSettings getDefaultAdapter()
- {
- return defaultAdapterSettings;
- }
-
- public AdapterSettings getAdapterSettings(String id)
- {
- return (AdapterSettings)adapterSettings.get(id);
- }
-
- public Map getAllAdapterSettings()
- {
- return adapterSettings;
- }
-
- public void addAdapterSettings(AdapterSettings a)
- {
- adapterSettings.put(a.getId(), a);
- if (a.isDefault())
- {
- defaultAdapterSettings = a;
- }
- }
-
- /*
- * DEFAULT CHANNELS
- */
- public void addDefaultChannel(ChannelSettings c)
- {
- defaultChannels.add(c);
- }
-
- public List getDefaultChannels()
- {
- return defaultChannels;
- }
-
- /*
- * DEFAULT SECURITY
- */
-
- /**
- * Gets the <code>SecurityConstraint</code> that will be applied to all
- * destinations of the service, or <code>null</code> if no constraint has
- * been registered.
- *
- * @return the <code>SecurityConstraint</code> for this service.
- */
- public SecurityConstraint getConstraint()
- {
- return securityConstraint;
- }
-
- /**
- * Sets the security constraint to be applied to all destinations of the service.
- * Security constraints restrict which clients can contact this destination. Use
- * <code>null</code> to remove an existing constraint.
- *
- * @param sc the <code>SecurityConstraint</code> to apply to this
- * service.
- */
- public void setConstraint(SecurityConstraint sc)
- {
- securityConstraint = sc;
- }
-
- /*
- * DESTINATIONS
- */
- public Map getDestinationSettings()
- {
- return destinationSettings;
- }
-
- public void addDestinationSettings(DestinationSettings dest)
- {
- destinationSettings.put(dest.getId(), dest);
- }
-}
+/*
+ * 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.config;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A service represents a high-level grouping of
+ * functionality to which the message broker can
+ * delegate messages. Services specify which
+ * message types they're interested in and use
+ * adapters to carry out a message's for a
+ * destination.
+ * <p>
+ * A service maintains a list of destinations which
+ * effectively represents a "whitelist"
+ * of actions allowed by that service.
+ * </p>
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public class ServiceSettings extends PropertiesSettings
+{
+ private final String id;
+ private String sourceFile;
+ private String className;
+
+ private AdapterSettings defaultAdapterSettings;
+ private final Map adapterSettings;
+ private final List defaultChannels;
+ private final Map destinationSettings;
+ private SecurityConstraint securityConstraint;
+
+ public ServiceSettings(String id)
+ {
+ this.id = id;
+ destinationSettings = new HashMap();
+ adapterSettings = new HashMap(2);
+ defaultChannels = new ArrayList(4);
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ String getSourceFile()
+ {
+ return sourceFile;
+ }
+
+ void setSourceFile(String sourceFile)
+ {
+ this.sourceFile = sourceFile;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName(String name)
+ {
+ className = name;
+ }
+
+ /*
+ * SERVER ADAPTERS
+ */
+ public AdapterSettings getDefaultAdapter()
+ {
+ return defaultAdapterSettings;
+ }
+
+ public AdapterSettings getAdapterSettings(String id)
+ {
+ return (AdapterSettings)adapterSettings.get(id);
+ }
+
+ public Map getAllAdapterSettings()
+ {
+ return adapterSettings;
+ }
+
+ public void addAdapterSettings(AdapterSettings a)
+ {
+ adapterSettings.put(a.getId(), a);
+ if (a.isDefault())
+ {
+ defaultAdapterSettings = a;
+ }
+ }
+
+ /*
+ * DEFAULT CHANNELS
+ */
+ public void addDefaultChannel(ChannelSettings c)
+ {
+ defaultChannels.add(c);
+ }
+
+ public List getDefaultChannels()
+ {
+ return defaultChannels;
+ }
+
+ /*
+ * DEFAULT SECURITY
+ */
+
+ /**
+ * Gets the <code>SecurityConstraint</code> that will be applied to all
+ * destinations of the service, or <code>null</code> if no constraint has
+ * been registered.
+ *
+ * @return the <code>SecurityConstraint</code> for this service.
+ */
+ public SecurityConstraint getConstraint()
+ {
+ return securityConstraint;
+ }
+
+ /**
+ * Sets the security constraint to be applied to all destinations of the service.
+ * Security constraints restrict which clients can contact this destination. Use
+ * <code>null</code> to remove an existing constraint.
+ *
+ * @param sc the <code>SecurityConstraint</code> to apply to this
+ * service.
+ */
+ public void setConstraint(SecurityConstraint sc)
+ {
+ securityConstraint = sc;
+ }
+
+ /*
+ * DESTINATIONS
+ */
+ public Map getDestinationSettings()
+ {
+ return destinationSettings;
+ }
+
+ public void addDestinationSettings(DestinationSettings dest)
+ {
+ destinationSettings.put(dest.getId(), dest);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ServicesConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ServicesConfiguration.java b/modules/common/src/flex/messaging/config/ServicesConfiguration.java
old mode 100755
new mode 100644
index 8bc25fc..589c5d7
--- a/modules/common/src/flex/messaging/config/ServicesConfiguration.java
+++ b/modules/common/src/flex/messaging/config/ServicesConfiguration.java
@@ -1,71 +1,71 @@
-/*
- * 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.config;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Base interface for Flex Data Services configuration.
- *
- * Implementations may have different levels of detail
- * based on how much of the configuration is supported.
- *
- * @author pfarland
- * @exclude
- */
-public interface ServicesConfiguration
-{
- /*
- * CHANNEL CONFIGURATION
- */
-
- void addChannelSettings(String id, ChannelSettings settings);
-
- ChannelSettings getChannelSettings(String ref);
-
- Map getAllChannelSettings();
-
- /*
- * DEFAULT CHANNELS CONFIGURATION
- */
- void addDefaultChannel(String id);
-
- List getDefaultChannels();
-
- /*
- * SERVICE CONFIGURATION
- */
-
- void addServiceSettings(ServiceSettings settings);
-
- ServiceSettings getServiceSettings(String id);
-
- List getAllServiceSettings();
-
- /*
- * LOGGING CONFIGURATION
- */
- void setLoggingSettings(LoggingSettings settings);
-
- LoggingSettings getLoggingSettings();
-
- /* CLUSTER CONFIGURATION */
- ClusterSettings getClusterSettings(String clusterId);
-
- ClusterSettings getDefaultCluster();
-}
+/*
+ * 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.config;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Base interface for Flex Data Services configuration.
+ *
+ * Implementations may have different levels of detail
+ * based on how much of the configuration is supported.
+ *
+ * @author pfarland
+ * @exclude
+ */
+public interface ServicesConfiguration
+{
+ /*
+ * CHANNEL CONFIGURATION
+ */
+
+ void addChannelSettings(String id, ChannelSettings settings);
+
+ ChannelSettings getChannelSettings(String ref);
+
+ Map getAllChannelSettings();
+
+ /*
+ * DEFAULT CHANNELS CONFIGURATION
+ */
+ void addDefaultChannel(String id);
+
+ List getDefaultChannels();
+
+ /*
+ * SERVICE CONFIGURATION
+ */
+
+ void addServiceSettings(ServiceSettings settings);
+
+ ServiceSettings getServiceSettings(String id);
+
+ List getAllServiceSettings();
+
+ /*
+ * LOGGING CONFIGURATION
+ */
+ void setLoggingSettings(LoggingSettings settings);
+
+ LoggingSettings getLoggingSettings();
+
+ /* CLUSTER CONFIGURATION */
+ ClusterSettings getClusterSettings(String clusterId);
+
+ ClusterSettings getDefaultCluster();
+}
[44/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/XPathClientConfigurationParser.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/XPathClientConfigurationParser.java b/modules/common/src/flex/messaging/config/XPathClientConfigurationParser.java
old mode 100755
new mode 100644
index 4917135..614c9ae
--- a/modules/common/src/flex/messaging/config/XPathClientConfigurationParser.java
+++ b/modules/common/src/flex/messaging/config/XPathClientConfigurationParser.java
@@ -1,90 +1,90 @@
-/*
- * 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.config;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-/**
- * Uses Sun's JDK 1.5 XPath implementation on a DOM
- * representation of a messaging configuration file.
- * <p>
- * NOTE: Since reference ids are used between elements, certain
- * sections of the document need to be parsed first.
- * </p>
- *
- * @author Peter Farland
- * @exclude
- */
-public class XPathClientConfigurationParser extends ClientConfigurationParser
-{
- private XPath xpath;
-
- protected void initializeExpressionQuery()
- {
- this.xpath = XPathFactory.newInstance().newXPath();
- }
-
- protected Node selectSingleNode(Node source, String expression)
- {
- try
- {
- return (Node) xpath.evaluate(expression, source, XPathConstants.NODE);
- }
- catch (XPathExpressionException expressionException)
- {
- throw wrapException(expressionException);
- }
- }
-
- protected NodeList selectNodeList(Node source, String expression)
- {
- try
- {
- return (NodeList) xpath.evaluate(expression, source, XPathConstants.NODESET);
- }
- catch (XPathExpressionException expressionException)
- {
- throw wrapException(expressionException);
- }
- }
-
- protected Object evaluateExpression(Node source, String expression)
- {
- try
- {
- return xpath.evaluate(expression, source, XPathConstants.STRING);
- }
- catch (XPathExpressionException expressionException)
- {
- throw wrapException(expressionException);
- }
- }
-
- private ConfigurationException wrapException(XPathExpressionException exception)
- {
- ConfigurationException result = new ConfigurationException();
- result.setDetails(PARSER_INTERNAL_ERROR);
- result.setRootCause(exception);
- return result;
- }
-}
+/*
+ * 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.config;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+/**
+ * Uses Sun's JDK 1.5 XPath implementation on a DOM
+ * representation of a messaging configuration file.
+ * <p>
+ * NOTE: Since reference ids are used between elements, certain
+ * sections of the document need to be parsed first.
+ * </p>
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public class XPathClientConfigurationParser extends ClientConfigurationParser
+{
+ private XPath xpath;
+
+ protected void initializeExpressionQuery()
+ {
+ this.xpath = XPathFactory.newInstance().newXPath();
+ }
+
+ protected Node selectSingleNode(Node source, String expression)
+ {
+ try
+ {
+ return (Node) xpath.evaluate(expression, source, XPathConstants.NODE);
+ }
+ catch (XPathExpressionException expressionException)
+ {
+ throw wrapException(expressionException);
+ }
+ }
+
+ protected NodeList selectNodeList(Node source, String expression)
+ {
+ try
+ {
+ return (NodeList) xpath.evaluate(expression, source, XPathConstants.NODESET);
+ }
+ catch (XPathExpressionException expressionException)
+ {
+ throw wrapException(expressionException);
+ }
+ }
+
+ protected Object evaluateExpression(Node source, String expression)
+ {
+ try
+ {
+ return xpath.evaluate(expression, source, XPathConstants.STRING);
+ }
+ catch (XPathExpressionException expressionException)
+ {
+ throw wrapException(expressionException);
+ }
+ }
+
+ private ConfigurationException wrapException(XPathExpressionException exception)
+ {
+ ConfigurationException result = new ConfigurationException();
+ result.setDetails(PARSER_INTERNAL_ERROR);
+ result.setRootCause(exception);
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/errors.properties
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/errors.properties b/modules/common/src/flex/messaging/errors.properties
old mode 100755
new mode 100644
index f76c681..6ff59b0
--- a/modules/common/src/flex/messaging/errors.properties
+++ b/modules/common/src/flex/messaging/errors.properties
@@ -1,432 +1,432 @@
-# 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.
-
-# IMPORTANT: Error messages are now split between two files in BlazeDS and LCDS.
-# This file is for BlazeDS error messages (which can be used by LCDS code as well).
-# LCDS only messages now live in a separate file in the LCDS branch. While editing
-# these files, keep in mind that both files are part of the same numeric sequence.
-#
-# Error and details messages for LocalizedMessageExceptions are stored in the following format:
-# Error message: {number}[-{variant}]={message}
-# Details message: {number}[-{variant}]-details={details}
-#
-# Server error numbers start at 10000.
-#
-# Error numbers are chosen by taking the next available value in a numeric sequence.
-# Each functional component or group of components should claim a unique block of 50
-# numbers to use for error and details messages. If this initial set of 50 values
-# are exhausted, the component should claim the next available block of 50 values for
-# its use. This means that an error-ridden component may well use a disjoint set of
-# error numbers. Here's an example:
-# Feature Error numbers claimed
-# -----------------------------------
-# Security 10050-10099
-# Configuration 10100-10149
-# Security 10150-10199 <- Security exhausted its first block, so it claims the next
-# available block of 50 values for its continued use.
-#
-# Constants to lookup error/details strings by 'number', and optional 'variant',
-# should be defined in the classes that use them. When a class needs to define a new
-# error and/or details string, add the necessary string(s) to this file using the next
-# available numeric value in the corresponding range.
-#
-# The structure of this file should be maintained according to increasing error number. This
-# means that for features that throw many errors, blocks of corresponding message strings
-# won't necessarily be contiguous, but this simplifies identifying the starting value for
-# the next available block of values and simplifies validation that duplicate error numbers
-# are not being used.
-# * Caution: Reusing a property key doesn't generate any error, so watch for typos.
-# The last defined property with a duplicate key clobbers the earlier values.
-
-# 10000-10049: General LocalizedException messages (in MessageBrokerFilter and MessageBroker).
-10000=There was an unhandled failure on the server. {0}
-10001=Null endpoint id arrived on message.
-10002=No such endpoint: {0}
-10003=No configured channel has an endpoint path ''{0}''.
-10004=The supplied destination id is not registered with any service.
-10005=Destination ''{0}'' not accessible over channel ''{1}''.
-10006=Error occurred while attempting to convert an input argument''s type.
-10007=Cannot invoke method ''{0}''.
-10007-0-details=Method ''{0}'' not found.
-10007-1-details={0} arguments were sent but {1} were expected.
-10007-2-details=The expected argument types are ({0}) but the supplied types were ({1}) and converted to ({2}).
-10007-3-details=The expected argument types are ({0}) but the supplied types were ({1}) with none successfully converted.
-10007-4-details=The expected argument types are ({0}) but no arguments were provided.
-10007-5-details=No arguments were expected but the following types were supplied ({0}).
-10008=Cannot create class of type ''{0}''.
-10008-0-details=Type ''{0}'' not found.
-10009=Given type ''{0}'' is not of expected type ''{1}''.
-10010=Unable to create a new instance of type ''{0}''.
-10010-0-details=Types must have a public, no arguments constructor.
-10010-1-details=Interfaces cannot be instantiated.
-10010-2-details=Abstract types cannot be instantiated.
-10010-3-details=Types cannot be instantiated without a public, no arguments constructor.
-10011=A security exception occurred while creating an instance of type ''{0}''.
-10012=An unknown exception occurred while creating an instance of type ''{0}''.
-10013=Invalid target specified. Target must not be null.
-10014=Categories must be at least one character in length.
-10015=Categories can not contain any of the following characters: ''{0}''
-10016=Error for filter ''{0}''. The following characters are not valid: {1}
-10017=Error for filter ''{0}''. ''*'' must be the right most character.
-10018=The server configuration parser requires an instance of MessagingConfiguration.
-10019=The FlexSession is invalid.
-10020=Unknown remote credentials format.
-10021=Failed to get property ''{0}'' on type ''{1}''.
-10022=Failed to set property ''{0}'' on type ''{1}''.
-10023=Property ''{0}'' is not readable on class ''{1}''.
-10024=Property ''{0}'' is not writable on class ''{1}''.
-10025=Property ''{0}'' not found on class ''{1}''.
-10026=Cannot send a null Map key for type ''{0}''.
-10027=The FlexClient is invalid.
-10028=The client has no active subscriptions over endpoint ''{0}''.
-10029=MessageBroker cannot service the message because message has null id.
-10030=Destination ''{0}'' requires FlexClient support which was introduced in version 2.5. Please recompile the client application with an updated client framework.
-10031=LogManager has a null Log reference.
-10032=Session map not initialized for session with id: ''{0}''.
-10033=FlexClient ''{0}'' already has a push listener registered for endpoint ''{1}''.
-10034=Channel endpoint does not support polling.
-10034-details=Client attempted to contact a server endpoint that does not support a polling channel.
-10035=Duplicate HTTP-based FlexSession error: A request for FlexClient ''{0}'' arrived over a new FlexSession ''{1}'', but FlexClient is already associated with FlexSession ''{2}'', therefore it cannot be associated with the new session.
-10036=The client has no active subscriptions over endpoint ''{0}'' but this may be due to mismatched client and server libraries. Old versions of rpc.swc do not handle URL session tokens correctly which may cause this issue. Please ensure that the client application has been compiled using version 3.1 of rpc.swc or newer.
-10037=Invalid request type of ''{0}'' which is not of type flex.messaging.messages.Message.
-10038={0} ''{1}'' cannot service message ''{2}'' in stopped state.
-10039=Cannot create ''{0}'' with null id.
-10040=Cannot create ''{0}'' with id ''{1}''; another ''{0}'' is already registered with the same id.
-
-# 10050-10099: SecurityException messages.
-10050=Invalid login.
-10051=Login required.
-10053=External login command required. Please check your security configuration.
-10054=Cannot re-authenticate in the same session.
-10055=Access denied. User not authorized.
-10056=Login required before authorization can proceed.
-10057=A resource protected by a security constraint ''{0}'' that specifies Basic security was accessed via the ''{1}'' endpoint which does not support HTTP Basic security. Please use custom security or an alternate endpoint.
-10060=Authentication failed.
-10061=No security manager found on this application server. Cannot authenticate.
-10062=Security constraint {0} is not defined.
-10063=It is an error to specify both a security constraint and run-as for a DataService object adapter operation.
-10064=Invalid credential format.
-10065=Cannot use application server authentication together with per client authentication.
-10066=Secure endpoint ''{0}'' must be contacted via a secure protocol.
-10067=SSO Cookie created sessions may only be invalidated by removal of Cookie on the client.
-10068=HTTP endpoint ''{0}'' must be contacted via a HTTP request with proper content type.
-
-# 10100-10149: Server configuration error messages.
-10100=Error initializing configuration parser.
-10101=An internal error occurred while parsing the services configuration.
-10102=Configuration error encountered on line {0}, column {1}: ''{2}''
-10103=The services configuration root element must be ''{0}''.
-10104=Child element ''{0}'' must be specified for element ''{1}''.
-10105=Attribute ''{0}'' must be specified for element ''{1}''.
-10106=Unexpected child element ''{0}'' found in ''{1}'' from file: {2}.
-10107=Unexpected attribute ''{0}'' found in ''{1}'' from file: {2}.
-10108=''{0}'' must occur no more than once for ''{1}''.
-10109={0} not found for reference ''{1}''.
-10110=Invalid {0} id ''{1}''.
-10110-details=An id must be non-empty and not contain any list delimiter characters, i.e. commas, semi-colons or colons.
-10111=Invalid endpoint port ''{0}'' specified for channel definition ''{1}''.
-10112=The {0} root element in file {1} must be ''{2}'' or ''{3}''.
-10113=Duplicate service definition ''{0}''.
-10114=Class not specified for {0} ''{1}''.
-10115=Message type(s) not specified for {0} ''{1}''.
-10116=A default channel was specified without a reference for service ''{0}''.
-10117=Duplicate default adapter ''{0}'' in service ''{1}''. ''{2}'' has already been selected as the default.
-10118=The element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
-10119=Invalid {0} id ''{1}'' for service ''{2}''.
-10120={0} not found for reference ''{1}'' in destination ''{2}''.
-10121=Invalid {0} reference ''{1}'' in destination ''{2}''.
-10122=Duplicate destination ''{0}'' in service ''{1}''.
-10123=Destination ''{0}'' must specify at least one channel.
-10124=Destination ''{0}'' is configured to use an unsupported throttle policy, ''{1}''.
-10125=Invalid channel endpoint class ''{0}'' specified for ''{1}''.
-10126=Invalid logging target class ''{0}''.
-10127=Destination ''{0}'' must specify at least one adapter.
-10128=Cannot add ''{0}'' with null url to the ''{1}''.
-10129={0} token cannot be resolved in the url. Please specify the url completely.
-10129-0={0} token cannot be resolved in the url as the destination was not accessed via HTTP. Please switch to an HTTP based channel or specify the url completely.
-10130={0} token cannot be resolved in the url. Please specify the url completely, using * to indicate all ports.
-10131=Error parsing dynamic URLs.
-10132=Invalid {0} reference ''{1}'' in channel ''{2}''.
-10133=No <keystore-file> property was specified for the secure RTMP channel.
-10134=A <keystore-password> or <keystore-password-file> property must be specified for the secure RTMP channel.
-10135=Secure RTMP endpoints are only supported on Java 1.5 or above.
-10136=Invalid RTMP Endpoint URI: {0}
-10137=MessageBroker already defined from MessageBrokerServlet with init parameter messageBrokerId = ''{0}''
-10138=Unable to create a parser to load messaging configuration.
-10139=The minimum required Java version was not found. Please install JDK 1.4.2_06 or above. Current version is {0}.
-10140=The minimum required Java version was not found. Please install JDK 1.4.2 or above. Current version is {0}.
-10141=This RTMP channel with id ''{0}'' requires that ''websphere-workmanager-jndi-name'' be defined.
-10142=WebSphere RTMP Server failed to find WorkManager at {0}.
-10143=Unable to start WebSphere RTMP Server.
-10144=The RTMP channel bind address, ''{0}'', is not valid.
-10145=The secure RTMP channel could not be constructed: {0}
-10146=The whitelist ip, ''{0}'', is not valid.
-10146-pattern=The whitelist ip pattern, ''{0}'', is not valid.
-10147=The blacklist ip, ''{0}'', is not valid.
-10147-pattern=The blacklist ip pattern, ''{0}'', is not valid.
-10148=The bind address, ''{0}'', is not a defined address for any local network interface.
-10149=Unrecognized tag found in <properties>. Please consult the documentation to determine if the tag is invalid or belongs inside of a different tag: {0}
-10149-pattern-details=''{0}'' in {1} with id: ''{2}'' from file: {3}
-#No more here - continues to 11100-11150 block
-
-# 10150-10199: DataService error messages (in LCDS errors.properties)
-# These two were in DataService error messages block even though they are general server errors, so they are kept here.
-10163=Unable to locate a MessageBroker initialized with server id ''{0}''
-10169=Unexpected multiple values for property ''{0}''.
-
-# 10200-10249: Clustering error messages
-10200=Unable to create a cluster id named {0}.
-10201=Could not create replicated map of cluster nodes for cluster id {0}.
-10202=The cluster library is not available, please configure the destination ''{0}'' for single-host deployment.
-10203=In order to use the channel with a clustered destination, the endpoint for channel ''{0}'' must be a fully-qualified URL.
-10204=Unable to broadcast a replicated service operation to the service peers for cluster id ''{0}''.
-10205=Unable to replicate a service operation received from a broadcast on cluster id ''{0}''.
-10206=A cluster named ''{0}'' already exists. The same cluster id may not be configured more than once.
-10207=The destination ''{0}'' contains a reference to cluster ''{1}'' which does not exist, please check the cluster name.
-10208=The cluster properties file ''{0}'' does not exist.
-10209=The clustered destination ''{0}'' cannot use the channel ''{1}'' because the endpoint URI for the channel contains the token ''{2}''. Token replacement is not supported for clustered destinations when url-load-balancing is true for that destination.
-10210=The cluster implementation does not provide the expected constructor.
-10211=The cluster implementation cannot be instantiated.
-10212=Unable to broadcast a replicated service operation to the service peers for cluster id ''{0}'' because ''{1}'' is not Serializable.
-10213=The cluster properties file ''{0}'' cannot be read.
-10214=Only one cluster tag can have the default=true attribute ''{0}'' and ''{1}'' both have default set to true.
-10215=Default attribute to cluster tag: ''{0}'' must be true or false not: ''{1}''.
-10216=url-load-balancing attribute in cluster tag: ''{0}'' must be true or false not: ''{1}''
-10217=Destination ''{0}'' is referencing an undefined cluster ''{1}''. Please correct your destination configuration and restart.
-10218=Unable to create a cluster id named {0} because the root region could not be found.
-10219=Unable to service an endpoint operation received from a broadcast on cluster id ''{0}''.
-
-# 10300-10349: Serialization error messages
-10300=Error deserializing typed AMF object because the target server type ''{0}'' cannot be found.
-10301=Unknown AMF type ''{0}''.
-10302=Unsupported type found in AMF stream.
-10303=Unexpected object end tag in AMF stream.
-10304=AMF Recordsets are not supported.
-10305=Class ''{0}'' must implement java.io.Externalizable to receive client IExternalizable instances.
-10306=An unhandled error occurred while processing client request(s).
-10307=Error deserializing client message.
-10308=Error serializing response.
-10309=Unsupported RTMP extended command message data format {0}.
-10310=Unsupported AMF version {0}.
-10311=Creation validation for class ''{0}'' failed.
-10312=Assignment validation of the object with type ''{0}'' for the property ''{1}'' failed.
-10313=Assignment validation of the object with type ''{0}'' for the index ''{1}'' failed.
-10314=Error deserializing the string with length ''{0}'', it exceeds the max-string-bytes limit of ''{1}''.
-10315=Error serialization exceeds the max object nest level of ''{0}''.
-10316=Error serialization exceeds the max collection object nest level of ''{0}''.
-
-# 10400-10449: Management error messages
-10400=The specified object name, ''{0}'', is malformed and cannot be used to create an ObjectName instance.
-10401=The MBean, ''{0}'', could not be unregistered because its preDeregister() method threw an exception.
-10402=The MBean, ''{0}'', could not be unregistered because it is not currently registered.
-10403=The MBean, ''{0}'', could not be registered because its preRegister() method threw an exception.
-10404=The MBean, ''{0}'', could not be registered because it is already registered.
-10405=The MBean, ''{0}'', is not compliant and could not be registered.
-10406=An exception was thrown while introspecting the MBean, ''{0}''.
-10407=The MBean, ''{0}'', could not be found.
-10408=An exception was thrown trying to invoke the getMBeanInfo method for the dynamic MBean, ''{0}''.
-10409=The attribute, ''{0}'', was not found in the MBean, ''{1}''.
-10410=The getter for the attribute, ''{0}'', on MBean, ''{1}'', threw an exception.
-10411=A reflection exception was thrown while invoking the getter for the attribute, ''{0}'', on MBean, ''{1}''
-10412=The attribute name to get is null. Please provide a non-null attribute name.
-10413=A reflection exception was thrown while invoking the getAttributes method for the dynamic MBean, ''{0}''
-10414=One of the supplied attribute names is null. Please ensure that all attribute names are not null.
-10415=A reflection exception was thrown while trying to invoke the method, ''{0}'', on MBean, ''{1}''.
-10416=An exception was thrown by the invoked method, ''{0}'', on MBean, ''{1}''.
-10417=An exception was thrown creating MBean, ''{0}''.
-10418=The MBean, ''{0}'', already exists and is registered with the MBean server.
-10419=The MBean class, ''{0}'', is not JMX compliant.
-10420=The preRegister method of the MBean, ''{0}'', threw an exception so the MBean was not registered.
-10421=The preDeregister method of the MBean, ''{0}'', threw an exception so the MBean was not unregistered.
-10422=A reflection exception was thrown while invoking the setter for the attribute, ''{0}'', on MBean, ''{1}''
-10423=The setter for the attribute, ''{0}'', on MBean, ''{1}'', threw an exception.
-10424=The value, ''{0}'', specified for the attribute, ''{1}'', on MBean, ''{2}'', is not valid.
-10425=A reflection exception was thrown while invoking the setAttributes method for the dynamic MBean, ''{0}''
-10426=The MBean, ''{0}'', cannot be registered because the previous MBean with the same name could not be unregistered possibly due to some security setting on the application server. This can be avoided by setting manageable property to false in the configuration file.
-10427=MBeanServerLocator ''{0}'' failed to retrieve MBeanServer.
-10428=The admin console registrar could not be found.
-
-# 10450-10499: Service error messages
-10450=Unable to create service ''{0}'' for ''{1}'' due to the following error: {2}.
-10451=Command forbidden on service ''{0}''.
-10452=Unable to create service ''{0}'' for ''{1}'' due to the following error: class ''{2}'' could not be found in the classpath.
-10453=Unable to create service ''{0}'' for ''{1}'' due to a dependency on commons-logging.jar. To resolve this, copy commons-logging.jar from WEB-INF/flex/jars to WEB-INF/lib or add your desired version of commons-logging.jar to the classpath for this web application.
-10454=The ''{0}'' service can only process messages of type ''{1}''.
-10455=Destination ''{0}'' is not registered with service ''{1}''.
-
-
-# 10500-10549: Data adapter error messages. (in LCDS errors.properties)
-
-# 10550-10599: MessageService error messages.
-10550=The selector expression is not valid: {0}
-10551=Not subscribed to destination ''{0}''.
-10552=Unknown CommandMessage operation: {0}
-10553=Attempt to subscribe or unsubscribe to the subtopic, ''{0}'', on destination, ''{1}'', that does not allow subtopics failed.
-10554=The subtopic, ''{0}'', is not valid.
-10556=The sent message contains a subtopic wildcard, ''{0}'', which is not allowed.
-10557=Your subscribe request to the subtopic, ''{0}'', was denied.
-10558=Your sent message to the subtopic, ''{0}'', was blocked.
-10559=Duplicate subscription. Another client has already subscribed with the clientId, ''{0}''.
-10560=Attempt to subscribe to the subtopic, ''{0}'', on destination, ''{1}'', that does not allow wildcard subtopics failed.
-
-# 10600-10649: Message selector error messages.
-10600=Failed to parse the selector ''{0}''. {1}
-10601=Selector ''{0}'' attempted to match a value using an incompatible data type. Please review your selector expression and ensure that any string values you intend to match are quoted and non-string values are not.
-10602=Matching the selector ''{0}'' generated a parser error. {1}
-
-# 10650 - 10699: Remoting Service error messages.
-10650=Destination ''{0}'' is not registered with the Remoting Service.
-10652=Cannot create session scoped component for destination ''{0}'' because a session is not available.
-10653=Invalid scope setting for remoting destination ''{0}''. Valid options are {1}.
-10654=Invalid class found in attribute-id ''{0}'' for component of scope ''{1}'' for destination ''{2}''. Expected an instance of class: ''{3}'' but found class ''{4}''.
-10656=Error instantiating application scoped instance of type ''{0}'' for destination ''{1}''.
-10657=MessageBroker with server id ''{0}'' does not contain a service with class flex.messaging.services.RemotingService
-10658=The remoting method being configured for remoting destination ''{0}'' must have a non-null name.
-10659=The remoting method ''{0}'' for remoting destination ''{1}'' is attempting to reference security constraint ''{2}'' that is not defined.
-10660=The remoting method ''{0}'' is not defined by the source class for remoting destination ''{1}''.
-
-# 10700 - 10749: HTTP Proxy Service error messages.
-10700=Can't use ''..'' in URLs (security violation).
-10701=A destination that allows multiple domains or ports does not allow authentication.
-10702=The URL specified ''{0}'' is not allowed by the selected destination ''{1}''.
-Dynamic URL is not configured in the whitelist.
-10703=Flex does not allow {0} cookies to be sent in a single request.
-10704=The relative URL ''{0}'' cannot be supported as the request was not made via HTTP.
-10705=A valid target URL was not specified: ''{0}''
-10706=Error sending request
-10706-1-details={0}
-10707=Unknown Host: {0}
-10708={0}
-10708-1-details={0}
-10709=HTTP Proxy response stream was null.
-10710=Cannot stream response to client. Request was not sent via HTTP.
-10711=Error writing response from HTTP Proxy: {0}
-10712=Invalid URL - only HTTP or HTTPS URLs allowed.
-10713=Invalid URL - can''t access HTTPS URLs when accessing proxy via HTTP.
-10714=Cannot support Basic Authentication. Request was not sent via HTTP.
-10715=A disallowed status code was returned - the proxy does not allow BASIC authentication attempts on a web service. Please secure your WSDL or use custom authentication.
-10716=The Flex proxy and the specified endpoint do not have the same domain, and so basic authentication cannot be used. Please set use-custom-auth to true or set remote-username and remote-password services not located on the same domain as the Flex proxy.
-10717=Login required.
-10718=Access denied. User not authorized.
-10719=Invalid HTTP method ''{0}''
-
-# 10750-10799: RTMPS error messages. (in LCDS errors.properties)
-
-# 10800-10849: JMSAdapter error messages.
-10800=A <property> element for the <initial-context-environment> settings for the ''{0}'' destination does not specify both <name> and <value> subelements.
-10801=A <property> element for the <initial-context-environment> settings for the ''{0}'' destination specifies an invalid javax.naming.Context field for its <name>: {1}
-10802=A <property> element for the <initial-context-environment> settings for the ''{0}'' destination specifies an inaccessible javax.naming.Context field for its <name>: {1}
-10803=The <initial-context-environment> settings for the ''{0}'' destination does not include any <property> subelements.
-10804=JMS connection factory of message destinations with JMS Adapters must be specified.
-10805=JMS Adapter destination type must be Topic or Queue.
-# 10806=Client with the id ''{0}'' is not subscribed with the JMS adapter.
-10807=JNDI names for message destinations with JMS Adapters must be specified.
-10808=Invalid Acknowledge Mode ''{0}''. Valid values are AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, and CLIENT_ACKNOWLEDGE.
-10809=Invalid Delivery Mode ''{0}''. Valid values are DEFAULT_DELIVERY_MODE, PERSISTENT, and NON_PERSISTENT.
-10810=The body of the Flex message could not be converted to a Serializable Java Object.
-10811=Unsupported JMS Message Type ''{0}''. Valid values are javax.jms.TextMessage, javax.jms.ObjectMessage, and javax.jms.MapMessage.
-10812=The body of the Flex message could not be converted to a Java Map object.
-10813=JMS queue proxy for JMS destination ''{0}'' has a destination type of ''{1}'' which is not Queue.
-10814=JMS queue proxy for JMS destination ''{0}'' has a connection factory type of ''{1}'' which is not QueueConnectionFactory.
-10815=JMS topic proxy for JMS destination ''{0}'' has a destination type of ''{1}'' which is not Topic.
-10816=JMS topic proxy for JMS destination ''{0}'' has a connection factory type of ''{1}'' which is not TopicConnectionFactory.
-10817=Invalid delivery-settings mode ''{0}''. Valid values are async and sync.
-10818=JMS consumer for JMS destination ''{0}'' is configured to use async message receiver but the application server does not allow ''{1}'' call used in async message receiver. Please switch to sync message receiver.
-10819=JMS topic consumer for JMS destination ''{0}'' is configured to use durable subscriptions but the application server does not permit javax.jms.Connection.setClientID method needed to support durable subscribers. Set durable property to false.
-10820=Client is unsubscribed because its corresponding JMS consumer for JMS destination ''{0}'' encountered an error during message delivery: {1}
-10821=Client is unsubscribed because its corresponding JMS consumer has been removed from the JMS adapter.
-10822=Client is unsubscribed because its corresponding JMS consumer for JMS destination ''{0}'' has been stopped.
-10823=JMS topic consumer for JMS destination ''{0}'' is configured to use durable subscriptions but it does not have a durable subscription name.
-10824=JMS invocation caught exception: {0}.
-# 10850-10899: RTMP error messages. (in LCDS errors.properties)
-
-# 11100-11149: Server configuration error messages. (continuation from 10100-10149 block)
-11100=Invalid channel endpoint URI, {0}, must begin with {1}.
-11101=The factory tag with class ''{0}'' does not implement the flex.messaging.FlexFactory interface.
-11102=An error occurred trying to construct FlexFactory ''{0}''. The underlying cause is: ''{1}''.
-11103=Invalid factory id: ''{1}'' for destination ''{0}''. Look for a factory tag with this id under the factories tag for your configuration.
-11104=Unexpected text ''{0}'' found in ''{1}'' from file: {2}.
-11105=Please specify a valid ''flex.write.path'' in web.xml.
-11106=Please specify a valid <services/> file path in flex-config.xml.
-11107=Please specify a valid include file. ''{0}'' is invalid.
-11108=Please specify a valid ''services.configuration.file'' in web.xml. You specified ''{0}''. This is not a valid file system path reachable via the app server and is also not a path to a resource in your J2EE application archive.
-11109=Could not register endpoint ''{0}'' because its URL, ''{1}'', is already used by endpoint ''{2}''
-11110=Cannot add null ''{0}'' to the ''{1}''
-11111=Cannot add ''{0}'' with null id to the ''{1}''
-11112=Cannot add a {0} with the id ''{1}'' that is already registered with the {2}
-11113=Please specify a valid include directory. ''{0}'' is invalid.
-11114=No adapter with id ''{0}'' is registered with the service ''{1}''.
-11115=Cannot change the ''{0}'' property of a component after startup.
-11116=The ''{0}'' property of a component cannot be null.
-11117=Destination cannot create adapter ''{0}'' without its Service set.
-11118=Factory cannot be returned without ''{0}'' set.
-11119=Cannot add destination with id ''{0}'' to service with id ''{1}'' because another service with id ''{2}'' already has a destination with the same id.
-11120=The services configuration includes a channel-definition ''{0}'' that has an endpoint with a context.root token but a context root has not been defined. Please specify a context-root compiler argument.
-11121=The value of the cluster-message-routing attribute needs to be either the value 'server-to-server' (the default) or 'broadcast'.
-11122=Invalid location: ''{0}''. Please specify a valid LiveCycle Data Services Configuration file via the LiveCycle Admin UI.
-11123=Invalid <timeout-minutes> value ''{0}'' in the <flex-client> configuration section. Please specify a positive value or leave the element undefined in which case flex client instances on the server will be timed out when all associated sessions/connections have shut down.
-11124=Invalid default-security-constraint reference ''{0}'' in service ''{1}''.
-11125=Token ''{0}'' in ''{1}'' was not replaced. Either supply a value to this token with a JVM option or remove it from the configuration.
-11126=Invalid ''{0}'' value, ''{1}'', for ''{2}'' with id ''{3}''.
-11127=Cannot have multiple channels with the same id ''{0}''.
-11128=The endpoint, ''{0}'', is attempting to use a referenced server, ''{1}'', but no shared server is defined with this id.
-11129=The configuration is attempting to use functionality that requires the flex.messaging.services.AdvancedMessagingSupport service to be registered. This includes 'reliable' network settings for destinations, buffer/conflate throttling policies, and adaptive server-to-client message frequency settings.
-11130=Invalid inbound throttle policy ''{0}'' for destination ''{1}''. Valid values are 'NONE', 'ERROR', and 'IGNORE'.
-11131=Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be more than the incoming destination frequency ''{3}''.
-11132=Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be less than the incoming client frequency ''{3}''.
-11133=Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be more than the outgoing destination frequency ''{3}''.
-11134=Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be less than the outgoing client frequency ''{3}''.
-11135=Invalid {0} for destination ''{1}''. {0} cannot be negative.
-11136=Cannot add multiple validators with the same type ''{0}''.
-11137=Invalid <reliable-reconnect-duration-millis> value ''{0}'' in the <flex-client> configuration section. Please specify a positive value or leave the element undefined.
-11138=Failed to add an asynchronous message filter with id ''{0}'' to broker''s filter chain.
-11139=Endpoint ''{0}'' needs to have either class or server-only attribute defined.
-11140=Endpoint ''{0}'' cannot have both class and server-only attribute defined.
-11141=Invalid {0} configuration for endpoint ''{1}''; no urls defined.
-11142=Invalid {0} configuration for endpoint ''{1}''; cannot add empty url.
-11143=Failed to add a synchronous message filter with id ''{0}'' to broker''s filter chain.
-11144=The filter with id ''{0}'' registered within <async-message-filters> does not subclass the asynchronous flex.messaging.filters.BaseAsyncMessageFilter either directly or indirectly.
-11145=The filter with id ''{0}'' registered within <sync-message-filters> does not subclass the synchronous flex.messaging.filters.BaseSyncMessageFilter either directly or indirectly.
-11146=Invalid <heartbeat-interval-millis> value ''{0}'' in the <flex-client> configuration section. Please specify a positive value or leave the element undefined.
-11147=Invalid {0} configuration for endpoint ''{1}''; cannot add url with tokens.
-11148=UUID Generator class is not a valid subclass of ''{0}''.
-11149=Flex Configuration does not allow external entity defined by publicId ''{0}'' and SystemId ''{1}''
-# continued again in the 11400-11449 block
-
-# 11150-11199: license messages (in LCDS errors.properties)
-
-# 11200-11249: Data adapter error messages. (in LCDS errors.properties)
-
-# 11250-11300: SQL assembler error messages. (in LCDS errors.properties)
-
-# 11300-11349: Live Cycle Remoting error messages. (in LCDS errors.properties)
-
-# 11350-11399: WSRP Generation error messages. (in LCDS errors.properties)
-
-# 11400-11449: Server configuration error messages. (continuation from 11100-11149 block)
-11400=Only one validator is allowed to implement DeserializationValidator. ''{0}'' has already been added. ''{1}'' cannot be added as a validator.
-
-# 12000-12499: PDF Services error messages. (in LCDS errors.properties)
-
-# 13000-13499: Collaboration Services error messages.
-
-# 13500-13549: General SSL error messages. (in LCDS errors.properties)
-
-# 13550-13599: General socket server error messages (in LCDS errors.properties)
-
-# 13600-13649: flex.messaging.util.concurrent.Executor and related error messages.
-13600=Cannot create AsyncBeansWorkManagerExecutor because no WorkManager is bound in JNDI under the name ''{0}''.
-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# IMPORTANT: Error messages are now split between two files in BlazeDS and LCDS.
+# This file is for BlazeDS error messages (which can be used by LCDS code as well).
+# LCDS only messages now live in a separate file in the LCDS branch. While editing
+# these files, keep in mind that both files are part of the same numeric sequence.
+#
+# Error and details messages for LocalizedMessageExceptions are stored in the following format:
+# Error message: {number}[-{variant}]={message}
+# Details message: {number}[-{variant}]-details={details}
+#
+# Server error numbers start at 10000.
+#
+# Error numbers are chosen by taking the next available value in a numeric sequence.
+# Each functional component or group of components should claim a unique block of 50
+# numbers to use for error and details messages. If this initial set of 50 values
+# are exhausted, the component should claim the next available block of 50 values for
+# its use. This means that an error-ridden component may well use a disjoint set of
+# error numbers. Here's an example:
+# Feature Error numbers claimed
+# -----------------------------------
+# Security 10050-10099
+# Configuration 10100-10149
+# Security 10150-10199 <- Security exhausted its first block, so it claims the next
+# available block of 50 values for its continued use.
+#
+# Constants to lookup error/details strings by 'number', and optional 'variant',
+# should be defined in the classes that use them. When a class needs to define a new
+# error and/or details string, add the necessary string(s) to this file using the next
+# available numeric value in the corresponding range.
+#
+# The structure of this file should be maintained according to increasing error number. This
+# means that for features that throw many errors, blocks of corresponding message strings
+# won't necessarily be contiguous, but this simplifies identifying the starting value for
+# the next available block of values and simplifies validation that duplicate error numbers
+# are not being used.
+# * Caution: Reusing a property key doesn't generate any error, so watch for typos.
+# The last defined property with a duplicate key clobbers the earlier values.
+
+# 10000-10049: General LocalizedException messages (in MessageBrokerFilter and MessageBroker).
+10000=There was an unhandled failure on the server. {0}
+10001=Null endpoint id arrived on message.
+10002=No such endpoint: {0}
+10003=No configured channel has an endpoint path ''{0}''.
+10004=The supplied destination id is not registered with any service.
+10005=Destination ''{0}'' not accessible over channel ''{1}''.
+10006=Error occurred while attempting to convert an input argument''s type.
+10007=Cannot invoke method ''{0}''.
+10007-0-details=Method ''{0}'' not found.
+10007-1-details={0} arguments were sent but {1} were expected.
+10007-2-details=The expected argument types are ({0}) but the supplied types were ({1}) and converted to ({2}).
+10007-3-details=The expected argument types are ({0}) but the supplied types were ({1}) with none successfully converted.
+10007-4-details=The expected argument types are ({0}) but no arguments were provided.
+10007-5-details=No arguments were expected but the following types were supplied ({0}).
+10008=Cannot create class of type ''{0}''.
+10008-0-details=Type ''{0}'' not found.
+10009=Given type ''{0}'' is not of expected type ''{1}''.
+10010=Unable to create a new instance of type ''{0}''.
+10010-0-details=Types must have a public, no arguments constructor.
+10010-1-details=Interfaces cannot be instantiated.
+10010-2-details=Abstract types cannot be instantiated.
+10010-3-details=Types cannot be instantiated without a public, no arguments constructor.
+10011=A security exception occurred while creating an instance of type ''{0}''.
+10012=An unknown exception occurred while creating an instance of type ''{0}''.
+10013=Invalid target specified. Target must not be null.
+10014=Categories must be at least one character in length.
+10015=Categories can not contain any of the following characters: ''{0}''
+10016=Error for filter ''{0}''. The following characters are not valid: {1}
+10017=Error for filter ''{0}''. ''*'' must be the right most character.
+10018=The server configuration parser requires an instance of MessagingConfiguration.
+10019=The FlexSession is invalid.
+10020=Unknown remote credentials format.
+10021=Failed to get property ''{0}'' on type ''{1}''.
+10022=Failed to set property ''{0}'' on type ''{1}''.
+10023=Property ''{0}'' is not readable on class ''{1}''.
+10024=Property ''{0}'' is not writable on class ''{1}''.
+10025=Property ''{0}'' not found on class ''{1}''.
+10026=Cannot send a null Map key for type ''{0}''.
+10027=The FlexClient is invalid.
+10028=The client has no active subscriptions over endpoint ''{0}''.
+10029=MessageBroker cannot service the message because message has null id.
+10030=Destination ''{0}'' requires FlexClient support which was introduced in version 2.5. Please recompile the client application with an updated client framework.
+10031=LogManager has a null Log reference.
+10032=Session map not initialized for session with id: ''{0}''.
+10033=FlexClient ''{0}'' already has a push listener registered for endpoint ''{1}''.
+10034=Channel endpoint does not support polling.
+10034-details=Client attempted to contact a server endpoint that does not support a polling channel.
+10035=Duplicate HTTP-based FlexSession error: A request for FlexClient ''{0}'' arrived over a new FlexSession ''{1}'', but FlexClient is already associated with FlexSession ''{2}'', therefore it cannot be associated with the new session.
+10036=The client has no active subscriptions over endpoint ''{0}'' but this may be due to mismatched client and server libraries. Old versions of rpc.swc do not handle URL session tokens correctly which may cause this issue. Please ensure that the client application has been compiled using version 3.1 of rpc.swc or newer.
+10037=Invalid request type of ''{0}'' which is not of type flex.messaging.messages.Message.
+10038={0} ''{1}'' cannot service message ''{2}'' in stopped state.
+10039=Cannot create ''{0}'' with null id.
+10040=Cannot create ''{0}'' with id ''{1}''; another ''{0}'' is already registered with the same id.
+
+# 10050-10099: SecurityException messages.
+10050=Invalid login.
+10051=Login required.
+10053=External login command required. Please check your security configuration.
+10054=Cannot re-authenticate in the same session.
+10055=Access denied. User not authorized.
+10056=Login required before authorization can proceed.
+10057=A resource protected by a security constraint ''{0}'' that specifies Basic security was accessed via the ''{1}'' endpoint which does not support HTTP Basic security. Please use custom security or an alternate endpoint.
+10060=Authentication failed.
+10061=No security manager found on this application server. Cannot authenticate.
+10062=Security constraint {0} is not defined.
+10063=It is an error to specify both a security constraint and run-as for a DataService object adapter operation.
+10064=Invalid credential format.
+10065=Cannot use application server authentication together with per client authentication.
+10066=Secure endpoint ''{0}'' must be contacted via a secure protocol.
+10067=SSO Cookie created sessions may only be invalidated by removal of Cookie on the client.
+10068=HTTP endpoint ''{0}'' must be contacted via a HTTP request with proper content type.
+
+# 10100-10149: Server configuration error messages.
+10100=Error initializing configuration parser.
+10101=An internal error occurred while parsing the services configuration.
+10102=Configuration error encountered on line {0}, column {1}: ''{2}''
+10103=The services configuration root element must be ''{0}''.
+10104=Child element ''{0}'' must be specified for element ''{1}''.
+10105=Attribute ''{0}'' must be specified for element ''{1}''.
+10106=Unexpected child element ''{0}'' found in ''{1}'' from file: {2}.
+10107=Unexpected attribute ''{0}'' found in ''{1}'' from file: {2}.
+10108=''{0}'' must occur no more than once for ''{1}''.
+10109={0} not found for reference ''{1}''.
+10110=Invalid {0} id ''{1}''.
+10110-details=An id must be non-empty and not contain any list delimiter characters, i.e. commas, semi-colons or colons.
+10111=Invalid endpoint port ''{0}'' specified for channel definition ''{1}''.
+10112=The {0} root element in file {1} must be ''{2}'' or ''{3}''.
+10113=Duplicate service definition ''{0}''.
+10114=Class not specified for {0} ''{1}''.
+10115=Message type(s) not specified for {0} ''{1}''.
+10116=A default channel was specified without a reference for service ''{0}''.
+10117=Duplicate default adapter ''{0}'' in service ''{1}''. ''{2}'' has already been selected as the default.
+10118=The element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
+10119=Invalid {0} id ''{1}'' for service ''{2}''.
+10120={0} not found for reference ''{1}'' in destination ''{2}''.
+10121=Invalid {0} reference ''{1}'' in destination ''{2}''.
+10122=Duplicate destination ''{0}'' in service ''{1}''.
+10123=Destination ''{0}'' must specify at least one channel.
+10124=Destination ''{0}'' is configured to use an unsupported throttle policy, ''{1}''.
+10125=Invalid channel endpoint class ''{0}'' specified for ''{1}''.
+10126=Invalid logging target class ''{0}''.
+10127=Destination ''{0}'' must specify at least one adapter.
+10128=Cannot add ''{0}'' with null url to the ''{1}''.
+10129={0} token cannot be resolved in the url. Please specify the url completely.
+10129-0={0} token cannot be resolved in the url as the destination was not accessed via HTTP. Please switch to an HTTP based channel or specify the url completely.
+10130={0} token cannot be resolved in the url. Please specify the url completely, using * to indicate all ports.
+10131=Error parsing dynamic URLs.
+10132=Invalid {0} reference ''{1}'' in channel ''{2}''.
+10133=No <keystore-file> property was specified for the secure RTMP channel.
+10134=A <keystore-password> or <keystore-password-file> property must be specified for the secure RTMP channel.
+10135=Secure RTMP endpoints are only supported on Java 1.5 or above.
+10136=Invalid RTMP Endpoint URI: {0}
+10137=MessageBroker already defined from MessageBrokerServlet with init parameter messageBrokerId = ''{0}''
+10138=Unable to create a parser to load messaging configuration.
+10139=The minimum required Java version was not found. Please install JDK 1.4.2_06 or above. Current version is {0}.
+10140=The minimum required Java version was not found. Please install JDK 1.4.2 or above. Current version is {0}.
+10141=This RTMP channel with id ''{0}'' requires that ''websphere-workmanager-jndi-name'' be defined.
+10142=WebSphere RTMP Server failed to find WorkManager at {0}.
+10143=Unable to start WebSphere RTMP Server.
+10144=The RTMP channel bind address, ''{0}'', is not valid.
+10145=The secure RTMP channel could not be constructed: {0}
+10146=The whitelist ip, ''{0}'', is not valid.
+10146-pattern=The whitelist ip pattern, ''{0}'', is not valid.
+10147=The blacklist ip, ''{0}'', is not valid.
+10147-pattern=The blacklist ip pattern, ''{0}'', is not valid.
+10148=The bind address, ''{0}'', is not a defined address for any local network interface.
+10149=Unrecognized tag found in <properties>. Please consult the documentation to determine if the tag is invalid or belongs inside of a different tag: {0}
+10149-pattern-details=''{0}'' in {1} with id: ''{2}'' from file: {3}
+#No more here - continues to 11100-11150 block
+
+# 10150-10199: DataService error messages (in LCDS errors.properties)
+# These two were in DataService error messages block even though they are general server errors, so they are kept here.
+10163=Unable to locate a MessageBroker initialized with server id ''{0}''
+10169=Unexpected multiple values for property ''{0}''.
+
+# 10200-10249: Clustering error messages
+10200=Unable to create a cluster id named {0}.
+10201=Could not create replicated map of cluster nodes for cluster id {0}.
+10202=The cluster library is not available, please configure the destination ''{0}'' for single-host deployment.
+10203=In order to use the channel with a clustered destination, the endpoint for channel ''{0}'' must be a fully-qualified URL.
+10204=Unable to broadcast a replicated service operation to the service peers for cluster id ''{0}''.
+10205=Unable to replicate a service operation received from a broadcast on cluster id ''{0}''.
+10206=A cluster named ''{0}'' already exists. The same cluster id may not be configured more than once.
+10207=The destination ''{0}'' contains a reference to cluster ''{1}'' which does not exist, please check the cluster name.
+10208=The cluster properties file ''{0}'' does not exist.
+10209=The clustered destination ''{0}'' cannot use the channel ''{1}'' because the endpoint URI for the channel contains the token ''{2}''. Token replacement is not supported for clustered destinations when url-load-balancing is true for that destination.
+10210=The cluster implementation does not provide the expected constructor.
+10211=The cluster implementation cannot be instantiated.
+10212=Unable to broadcast a replicated service operation to the service peers for cluster id ''{0}'' because ''{1}'' is not Serializable.
+10213=The cluster properties file ''{0}'' cannot be read.
+10214=Only one cluster tag can have the default=true attribute ''{0}'' and ''{1}'' both have default set to true.
+10215=Default attribute to cluster tag: ''{0}'' must be true or false not: ''{1}''.
+10216=url-load-balancing attribute in cluster tag: ''{0}'' must be true or false not: ''{1}''
+10217=Destination ''{0}'' is referencing an undefined cluster ''{1}''. Please correct your destination configuration and restart.
+10218=Unable to create a cluster id named {0} because the root region could not be found.
+10219=Unable to service an endpoint operation received from a broadcast on cluster id ''{0}''.
+
+# 10300-10349: Serialization error messages
+10300=Error deserializing typed AMF object because the target server type ''{0}'' cannot be found.
+10301=Unknown AMF type ''{0}''.
+10302=Unsupported type found in AMF stream.
+10303=Unexpected object end tag in AMF stream.
+10304=AMF Recordsets are not supported.
+10305=Class ''{0}'' must implement java.io.Externalizable to receive client IExternalizable instances.
+10306=An unhandled error occurred while processing client request(s).
+10307=Error deserializing client message.
+10308=Error serializing response.
+10309=Unsupported RTMP extended command message data format {0}.
+10310=Unsupported AMF version {0}.
+10311=Creation validation for class ''{0}'' failed.
+10312=Assignment validation of the object with type ''{0}'' for the property ''{1}'' failed.
+10313=Assignment validation of the object with type ''{0}'' for the index ''{1}'' failed.
+10314=Error deserializing the string with length ''{0}'', it exceeds the max-string-bytes limit of ''{1}''.
+10315=Error serialization exceeds the max object nest level of ''{0}''.
+10316=Error serialization exceeds the max collection object nest level of ''{0}''.
+
+# 10400-10449: Management error messages
+10400=The specified object name, ''{0}'', is malformed and cannot be used to create an ObjectName instance.
+10401=The MBean, ''{0}'', could not be unregistered because its preDeregister() method threw an exception.
+10402=The MBean, ''{0}'', could not be unregistered because it is not currently registered.
+10403=The MBean, ''{0}'', could not be registered because its preRegister() method threw an exception.
+10404=The MBean, ''{0}'', could not be registered because it is already registered.
+10405=The MBean, ''{0}'', is not compliant and could not be registered.
+10406=An exception was thrown while introspecting the MBean, ''{0}''.
+10407=The MBean, ''{0}'', could not be found.
+10408=An exception was thrown trying to invoke the getMBeanInfo method for the dynamic MBean, ''{0}''.
+10409=The attribute, ''{0}'', was not found in the MBean, ''{1}''.
+10410=The getter for the attribute, ''{0}'', on MBean, ''{1}'', threw an exception.
+10411=A reflection exception was thrown while invoking the getter for the attribute, ''{0}'', on MBean, ''{1}''
+10412=The attribute name to get is null. Please provide a non-null attribute name.
+10413=A reflection exception was thrown while invoking the getAttributes method for the dynamic MBean, ''{0}''
+10414=One of the supplied attribute names is null. Please ensure that all attribute names are not null.
+10415=A reflection exception was thrown while trying to invoke the method, ''{0}'', on MBean, ''{1}''.
+10416=An exception was thrown by the invoked method, ''{0}'', on MBean, ''{1}''.
+10417=An exception was thrown creating MBean, ''{0}''.
+10418=The MBean, ''{0}'', already exists and is registered with the MBean server.
+10419=The MBean class, ''{0}'', is not JMX compliant.
+10420=The preRegister method of the MBean, ''{0}'', threw an exception so the MBean was not registered.
+10421=The preDeregister method of the MBean, ''{0}'', threw an exception so the MBean was not unregistered.
+10422=A reflection exception was thrown while invoking the setter for the attribute, ''{0}'', on MBean, ''{1}''
+10423=The setter for the attribute, ''{0}'', on MBean, ''{1}'', threw an exception.
+10424=The value, ''{0}'', specified for the attribute, ''{1}'', on MBean, ''{2}'', is not valid.
+10425=A reflection exception was thrown while invoking the setAttributes method for the dynamic MBean, ''{0}''
+10426=The MBean, ''{0}'', cannot be registered because the previous MBean with the same name could not be unregistered possibly due to some security setting on the application server. This can be avoided by setting manageable property to false in the configuration file.
+10427=MBeanServerLocator ''{0}'' failed to retrieve MBeanServer.
+10428=The admin console registrar could not be found.
+
+# 10450-10499: Service error messages
+10450=Unable to create service ''{0}'' for ''{1}'' due to the following error: {2}.
+10451=Command forbidden on service ''{0}''.
+10452=Unable to create service ''{0}'' for ''{1}'' due to the following error: class ''{2}'' could not be found in the classpath.
+10453=Unable to create service ''{0}'' for ''{1}'' due to a dependency on commons-logging.jar. To resolve this, copy commons-logging.jar from WEB-INF/flex/jars to WEB-INF/lib or add your desired version of commons-logging.jar to the classpath for this web application.
+10454=The ''{0}'' service can only process messages of type ''{1}''.
+10455=Destination ''{0}'' is not registered with service ''{1}''.
+
+
+# 10500-10549: Data adapter error messages. (in LCDS errors.properties)
+
+# 10550-10599: MessageService error messages.
+10550=The selector expression is not valid: {0}
+10551=Not subscribed to destination ''{0}''.
+10552=Unknown CommandMessage operation: {0}
+10553=Attempt to subscribe or unsubscribe to the subtopic, ''{0}'', on destination, ''{1}'', that does not allow subtopics failed.
+10554=The subtopic, ''{0}'', is not valid.
+10556=The sent message contains a subtopic wildcard, ''{0}'', which is not allowed.
+10557=Your subscribe request to the subtopic, ''{0}'', was denied.
+10558=Your sent message to the subtopic, ''{0}'', was blocked.
+10559=Duplicate subscription. Another client has already subscribed with the clientId, ''{0}''.
+10560=Attempt to subscribe to the subtopic, ''{0}'', on destination, ''{1}'', that does not allow wildcard subtopics failed.
+
+# 10600-10649: Message selector error messages.
+10600=Failed to parse the selector ''{0}''. {1}
+10601=Selector ''{0}'' attempted to match a value using an incompatible data type. Please review your selector expression and ensure that any string values you intend to match are quoted and non-string values are not.
+10602=Matching the selector ''{0}'' generated a parser error. {1}
+
+# 10650 - 10699: Remoting Service error messages.
+10650=Destination ''{0}'' is not registered with the Remoting Service.
+10652=Cannot create session scoped component for destination ''{0}'' because a session is not available.
+10653=Invalid scope setting for remoting destination ''{0}''. Valid options are {1}.
+10654=Invalid class found in attribute-id ''{0}'' for component of scope ''{1}'' for destination ''{2}''. Expected an instance of class: ''{3}'' but found class ''{4}''.
+10656=Error instantiating application scoped instance of type ''{0}'' for destination ''{1}''.
+10657=MessageBroker with server id ''{0}'' does not contain a service with class flex.messaging.services.RemotingService
+10658=The remoting method being configured for remoting destination ''{0}'' must have a non-null name.
+10659=The remoting method ''{0}'' for remoting destination ''{1}'' is attempting to reference security constraint ''{2}'' that is not defined.
+10660=The remoting method ''{0}'' is not defined by the source class for remoting destination ''{1}''.
+
+# 10700 - 10749: HTTP Proxy Service error messages.
+10700=Can't use ''..'' in URLs (security violation).
+10701=A destination that allows multiple domains or ports does not allow authentication.
+10702=The URL specified ''{0}'' is not allowed by the selected destination ''{1}''.
+Dynamic URL is not configured in the whitelist.
+10703=Flex does not allow {0} cookies to be sent in a single request.
+10704=The relative URL ''{0}'' cannot be supported as the request was not made via HTTP.
+10705=A valid target URL was not specified: ''{0}''
+10706=Error sending request
+10706-1-details={0}
+10707=Unknown Host: {0}
+10708={0}
+10708-1-details={0}
+10709=HTTP Proxy response stream was null.
+10710=Cannot stream response to client. Request was not sent via HTTP.
+10711=Error writing response from HTTP Proxy: {0}
+10712=Invalid URL - only HTTP or HTTPS URLs allowed.
+10713=Invalid URL - can''t access HTTPS URLs when accessing proxy via HTTP.
+10714=Cannot support Basic Authentication. Request was not sent via HTTP.
+10715=A disallowed status code was returned - the proxy does not allow BASIC authentication attempts on a web service. Please secure your WSDL or use custom authentication.
+10716=The Flex proxy and the specified endpoint do not have the same domain, and so basic authentication cannot be used. Please set use-custom-auth to true or set remote-username and remote-password services not located on the same domain as the Flex proxy.
+10717=Login required.
+10718=Access denied. User not authorized.
+10719=Invalid HTTP method ''{0}''
+
+# 10750-10799: RTMPS error messages. (in LCDS errors.properties)
+
+# 10800-10849: JMSAdapter error messages.
+10800=A <property> element for the <initial-context-environment> settings for the ''{0}'' destination does not specify both <name> and <value> subelements.
+10801=A <property> element for the <initial-context-environment> settings for the ''{0}'' destination specifies an invalid javax.naming.Context field for its <name>: {1}
+10802=A <property> element for the <initial-context-environment> settings for the ''{0}'' destination specifies an inaccessible javax.naming.Context field for its <name>: {1}
+10803=The <initial-context-environment> settings for the ''{0}'' destination does not include any <property> subelements.
+10804=JMS connection factory of message destinations with JMS Adapters must be specified.
+10805=JMS Adapter destination type must be Topic or Queue.
+# 10806=Client with the id ''{0}'' is not subscribed with the JMS adapter.
+10807=JNDI names for message destinations with JMS Adapters must be specified.
+10808=Invalid Acknowledge Mode ''{0}''. Valid values are AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, and CLIENT_ACKNOWLEDGE.
+10809=Invalid Delivery Mode ''{0}''. Valid values are DEFAULT_DELIVERY_MODE, PERSISTENT, and NON_PERSISTENT.
+10810=The body of the Flex message could not be converted to a Serializable Java Object.
+10811=Unsupported JMS Message Type ''{0}''. Valid values are javax.jms.TextMessage, javax.jms.ObjectMessage, and javax.jms.MapMessage.
+10812=The body of the Flex message could not be converted to a Java Map object.
+10813=JMS queue proxy for JMS destination ''{0}'' has a destination type of ''{1}'' which is not Queue.
+10814=JMS queue proxy for JMS destination ''{0}'' has a connection factory type of ''{1}'' which is not QueueConnectionFactory.
+10815=JMS topic proxy for JMS destination ''{0}'' has a destination type of ''{1}'' which is not Topic.
+10816=JMS topic proxy for JMS destination ''{0}'' has a connection factory type of ''{1}'' which is not TopicConnectionFactory.
+10817=Invalid delivery-settings mode ''{0}''. Valid values are async and sync.
+10818=JMS consumer for JMS destination ''{0}'' is configured to use async message receiver but the application server does not allow ''{1}'' call used in async message receiver. Please switch to sync message receiver.
+10819=JMS topic consumer for JMS destination ''{0}'' is configured to use durable subscriptions but the application server does not permit javax.jms.Connection.setClientID method needed to support durable subscribers. Set durable property to false.
+10820=Client is unsubscribed because its corresponding JMS consumer for JMS destination ''{0}'' encountered an error during message delivery: {1}
+10821=Client is unsubscribed because its corresponding JMS consumer has been removed from the JMS adapter.
+10822=Client is unsubscribed because its corresponding JMS consumer for JMS destination ''{0}'' has been stopped.
+10823=JMS topic consumer for JMS destination ''{0}'' is configured to use durable subscriptions but it does not have a durable subscription name.
+10824=JMS invocation caught exception: {0}.
+# 10850-10899: RTMP error messages. (in LCDS errors.properties)
+
+# 11100-11149: Server configuration error messages. (continuation from 10100-10149 block)
+11100=Invalid channel endpoint URI, {0}, must begin with {1}.
+11101=The factory tag with class ''{0}'' does not implement the flex.messaging.FlexFactory interface.
+11102=An error occurred trying to construct FlexFactory ''{0}''. The underlying cause is: ''{1}''.
+11103=Invalid factory id: ''{1}'' for destination ''{0}''. Look for a factory tag with this id under the factories tag for your configuration.
+11104=Unexpected text ''{0}'' found in ''{1}'' from file: {2}.
+11105=Please specify a valid ''flex.write.path'' in web.xml.
+11106=Please specify a valid <services/> file path in flex-config.xml.
+11107=Please specify a valid include file. ''{0}'' is invalid.
+11108=Please specify a valid ''services.configuration.file'' in web.xml. You specified ''{0}''. This is not a valid file system path reachable via the app server and is also not a path to a resource in your J2EE application archive.
+11109=Could not register endpoint ''{0}'' because its URL, ''{1}'', is already used by endpoint ''{2}''
+11110=Cannot add null ''{0}'' to the ''{1}''
+11111=Cannot add ''{0}'' with null id to the ''{1}''
+11112=Cannot add a {0} with the id ''{1}'' that is already registered with the {2}
+11113=Please specify a valid include directory. ''{0}'' is invalid.
+11114=No adapter with id ''{0}'' is registered with the service ''{1}''.
+11115=Cannot change the ''{0}'' property of a component after startup.
+11116=The ''{0}'' property of a component cannot be null.
+11117=Destination cannot create adapter ''{0}'' without its Service set.
+11118=Factory cannot be returned without ''{0}'' set.
+11119=Cannot add destination with id ''{0}'' to service with id ''{1}'' because another service with id ''{2}'' already has a destination with the same id.
+11120=The services configuration includes a channel-definition ''{0}'' that has an endpoint with a context.root token but a context root has not been defined. Please specify a context-root compiler argument.
+11121=The value of the cluster-message-routing attribute needs to be either the value 'server-to-server' (the default) or 'broadcast'.
+11122=Invalid location: ''{0}''. Please specify a valid LiveCycle Data Services Configuration file via the LiveCycle Admin UI.
+11123=Invalid <timeout-minutes> value ''{0}'' in the <flex-client> configuration section. Please specify a positive value or leave the element undefined in which case flex client instances on the server will be timed out when all associated sessions/connections have shut down.
+11124=Invalid default-security-constraint reference ''{0}'' in service ''{1}''.
+11125=Token ''{0}'' in ''{1}'' was not replaced. Either supply a value to this token with a JVM option or remove it from the configuration.
+11126=Invalid ''{0}'' value, ''{1}'', for ''{2}'' with id ''{3}''.
+11127=Cannot have multiple channels with the same id ''{0}''.
+11128=The endpoint, ''{0}'', is attempting to use a referenced server, ''{1}'', but no shared server is defined with this id.
+11129=The configuration is attempting to use functionality that requires the flex.messaging.services.AdvancedMessagingSupport service to be registered. This includes 'reliable' network settings for destinations, buffer/conflate throttling policies, and adaptive server-to-client message frequency settings.
+11130=Invalid inbound throttle policy ''{0}'' for destination ''{1}''. Valid values are 'NONE', 'ERROR', and 'IGNORE'.
+11131=Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be more than the incoming destination frequency ''{3}''.
+11132=Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be less than the incoming client frequency ''{3}''.
+11133=Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be more than the outgoing destination frequency ''{3}''.
+11134=Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be less than the outgoing client frequency ''{3}''.
+11135=Invalid {0} for destination ''{1}''. {0} cannot be negative.
+11136=Cannot add multiple validators with the same type ''{0}''.
+11137=Invalid <reliable-reconnect-duration-millis> value ''{0}'' in the <flex-client> configuration section. Please specify a positive value or leave the element undefined.
+11138=Failed to add an asynchronous message filter with id ''{0}'' to broker''s filter chain.
+11139=Endpoint ''{0}'' needs to have either class or server-only attribute defined.
+11140=Endpoint ''{0}'' cannot have both class and server-only attribute defined.
+11141=Invalid {0} configuration for endpoint ''{1}''; no urls defined.
+11142=Invalid {0} configuration for endpoint ''{1}''; cannot add empty url.
+11143=Failed to add a synchronous message filter with id ''{0}'' to broker''s filter chain.
+11144=The filter with id ''{0}'' registered within <async-message-filters> does not subclass the asynchronous flex.messaging.filters.BaseAsyncMessageFilter either directly or indirectly.
+11145=The filter with id ''{0}'' registered within <sync-message-filters> does not subclass the synchronous flex.messaging.filters.BaseSyncMessageFilter either directly or indirectly.
+11146=Invalid <heartbeat-interval-millis> value ''{0}'' in the <flex-client> configuration section. Please specify a positive value or leave the element undefined.
+11147=Invalid {0} configuration for endpoint ''{1}''; cannot add url with tokens.
+11148=UUID Generator class is not a valid subclass of ''{0}''.
+11149=Flex Configuration does not allow external entity defined by publicId ''{0}'' and SystemId ''{1}''
+# continued again in the 11400-11449 block
+
+# 11150-11199: license messages (in LCDS errors.properties)
+
+# 11200-11249: Data adapter error messages. (in LCDS errors.properties)
+
+# 11250-11300: SQL assembler error messages. (in LCDS errors.properties)
+
+# 11300-11349: Live Cycle Remoting error messages. (in LCDS errors.properties)
+
+# 11350-11399: WSRP Generation error messages. (in LCDS errors.properties)
+
+# 11400-11449: Server configuration error messages. (continuation from 11100-11149 block)
+11400=Only one validator is allowed to implement DeserializationValidator. ''{0}'' has already been added. ''{1}'' cannot be added as a validator.
+
+# 12000-12499: PDF Services error messages. (in LCDS errors.properties)
+
+# 13000-13499: Collaboration Services error messages.
+
+# 13500-13549: General SSL error messages. (in LCDS errors.properties)
+
+# 13550-13599: General socket server error messages (in LCDS errors.properties)
+
+# 13600-13649: flex.messaging.util.concurrent.Executor and related error messages.
+13600=Cannot create AsyncBeansWorkManagerExecutor because no WorkManager is bound in JNDI under the name ''{0}''.
+
# 13650-13699: General NIO Endpoints error messages (in LCDS errors.properties)
\ No newline at end of file
[16/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/MessagingConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/MessagingConfiguration.java b/modules/core/src/flex/messaging/config/MessagingConfiguration.java
old mode 100755
new mode 100644
index 72237f9..ae5784b
--- a/modules/core/src/flex/messaging/config/MessagingConfiguration.java
+++ b/modules/core/src/flex/messaging/config/MessagingConfiguration.java
@@ -1,1003 +1,1003 @@
-/*
- * 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.config;
-
-import flex.management.ManageableComponent;
-import flex.management.runtime.messaging.endpoints.EndpointControl;
-import flex.messaging.Destination;
-import flex.messaging.FlexComponent;
-import flex.messaging.FlexContext;
-import flex.messaging.MessageBroker;
-import flex.messaging.Server;
-import flex.messaging.client.FlexClientManager;
-import flex.messaging.cluster.ClusterManager;
-import flex.messaging.endpoints.AbstractEndpoint;
-import flex.messaging.endpoints.Endpoint;
-import flex.messaging.endpoints.Endpoint2;
-import flex.messaging.log.Log;
-import flex.messaging.log.Target;
-import flex.messaging.security.LoginCommand;
-import flex.messaging.security.LoginManager;
-import flex.messaging.services.AuthenticationService;
-import flex.messaging.services.Service;
-import flex.messaging.services.ServiceAdapter;
-import flex.messaging.util.ClassUtil;
-import flex.messaging.util.RedeployManager;
-import flex.messaging.util.StringUtils;
-import flex.messaging.util.ToStringPrettyPrinter;
-import flex.messaging.util.UUIDGenerator;
-import flex.messaging.validators.DeserializationValidator;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This object encapsulates settings for a MessageBroker instance.
- * The MessageBroker itself has no knowledge of configuration specifics;
- * instead, this object sets the relevant values on the broker using
- * information which a ConfigurationParser has provided for it.
- *
- * @author Peter Farland
- * @author neville
- * @exclude
- */
-public class MessagingConfiguration implements ServicesConfiguration
-{
- private final String asyncMessageBrokerType = "flex.messaging.AsyncMessageBroker";
- private final String asyncFlexClientManagerType = "flex.messaging.client.AsyncFlexClientManager";
-
- private final Map<String, ChannelSettings> channelSettings;
- private final List<String> defaultChannels;
- private final SecuritySettings securitySettings;
- private final List<ServiceSettings> serviceSettings;
- private final List<SharedServerSettings> sharedServerSettings;
- private LoggingSettings loggingSettings;
- private SystemSettings systemSettings;
- private FlexClientSettings flexClientSettings;
- private final Map<String, ClusterSettings> clusterSettings;
- private final Map<String, FactorySettings> factorySettings;
- private final List<MessageFilterSettings> messageFilterSettings;
- private final Map<String, ValidatorSettings> validatorSettings;
-
- /**
- * Constructor.
- * Construct a MessagingConfiguration object
- * <p/>
- */
- public MessagingConfiguration()
- {
- channelSettings = new HashMap<String, ChannelSettings>();
- defaultChannels = new ArrayList<String>(4);
- clusterSettings = new HashMap<String, ClusterSettings>();
- factorySettings = new HashMap<String, FactorySettings>();
- serviceSettings = new ArrayList<ServiceSettings>();
- sharedServerSettings = new ArrayList<SharedServerSettings>();
- securitySettings = new SecuritySettings();
- messageFilterSettings = new ArrayList<MessageFilterSettings>();
- validatorSettings = new HashMap<String, ValidatorSettings>();
- }
-
- /**
- * Configure the MessageBroker.
- * <p/>
- * @param broker current MessageBroker object
- */
- public void configureBroker(MessageBroker broker)
- {
- boolean async = (broker.getClass().getName().equals(asyncMessageBrokerType));
-
- broker.setChannelSettings(channelSettings);
- broker.setSecuritySettings(securitySettings);
- broker.setSystemSettings(systemSettings);
- broker.setFlexClientSettings(flexClientSettings);
-
- // validators need to come first so that the other code can use them
- createValidators(broker);
-
- createAuthorizationManager(broker);
- createFlexClientManager(broker);
- createRedeployManager(broker);
- createFactories(broker);
-
- if (async)
- createSharedServers(broker);
-
- createEndpoints(broker);
- // Default channels have to be set after endpoints are created.
- broker.setDefaultChannels(defaultChannels);
- prepareClusters(broker);
- createServices(broker);
-
- if (async)
- createMessageFilters(broker);
-
- createUUIDGenerator(broker);
- }
-
- /**
- * Create a MessageBroker object with the Id.
- * <p/>
- * @param id String the MessageBroker Id
- * @param loader the ClassLoader used to load the MessageBroker class
- * @return the created MessageBroker object
- */
- public MessageBroker createBroker(String id, ClassLoader loader)
- {
- // Construct MessageBroker with manageable constructor to avoid loading
- // any JMX classes in case manageable is set to false.
- MessageBroker broker;
- try // Use the AsyncMessageBroker, if possible.
- {
- @SuppressWarnings("unchecked")
- Class<? extends MessageBroker> messageBrokerClass = ClassUtil.createClass(asyncMessageBrokerType, loader);
- Constructor constructor = messageBrokerClass.getConstructor(boolean.class);
- broker = (MessageBroker)constructor.newInstance(systemSettings.isManageable());
- }
- catch (Throwable t) // Otherwise, use the default MessageBroker.
- {
- broker = new MessageBroker(systemSettings.isManageable());
- }
-
- // Initialize MessageBroker.
- broker.setEnforceEndpointValidation(systemSettings.isEnforceEndpointValidation());
- //broker.setManaged(systemSettings.isManageable());
- broker.setId(id);
- broker.setClassLoader(loader);
-
- return broker;
- }
-
- private void createFactories(MessageBroker broker)
- {
- for (Iterator<Map.Entry<String,FactorySettings>> iter=factorySettings.entrySet().iterator(); iter.hasNext(); )
- {
- Map.Entry<String,FactorySettings> entry = iter.next();
- String id = entry.getKey();
- FactorySettings factorySetting = entry.getValue();
- broker.addFactory(id, factorySetting.createFactory(broker.getClassLoader()));
- }
- }
-
- private void createFlexClientManager(MessageBroker broker)
- {
- FlexClientManager flexClientManager = null;
- try // Use the async version, if possible.
- {
- @SuppressWarnings("unchecked")
- Class<? extends FlexClientManager> flexClientManagerClass = ClassUtil.createClass(asyncFlexClientManagerType, broker.getClassLoader());
- Constructor ctor = flexClientManagerClass.getConstructor(broker.getClass());
- flexClientManager = (FlexClientManager)ctor.newInstance(broker);
- }
- catch (Throwable t) // Otherwise, use the default FlexClientManager.
- {
- flexClientManager = new FlexClientManager(broker.isManaged(), broker);
- }
- broker.setFlexClientManager(flexClientManager);
- }
-
- private void createRedeployManager(MessageBroker broker)
- {
- RedeployManager redeployManager = new RedeployManager();
- redeployManager.setEnabled(systemSettings.getRedeployEnabled());
- redeployManager.setWatchInterval(systemSettings.getWatchInterval());
- redeployManager.setTouchFiles(systemSettings.getTouchFiles());
- redeployManager.setWatchFiles(systemSettings.getWatchFiles());
- broker.setRedeployManager(redeployManager);
- }
-
- private void createAuthorizationManager(MessageBroker broker)
- {
- LoginManager loginManager = new LoginManager();
-
- // Create a Login Command for the LoginManager.
- LoginCommand loginCommand = null;
-
- Map loginCommands = securitySettings.getLoginCommands();
-
- // If default Login Command is enabled, use it.
- LoginCommandSettings loginCommandSettings = (LoginCommandSettings)loginCommands.get(LoginCommandSettings.SERVER_MATCH_OVERRIDE);
- if (loginCommandSettings != null)
- {
- loginCommand = initLoginCommand(loginCommandSettings);
- }
- // Otherwise, try a server specific Login Command.
- else
- {
- String serverInfo = securitySettings.getServerInfo();
- loginCommandSettings = (LoginCommandSettings)loginCommands.get(serverInfo);
-
- if (loginCommandSettings != null)
- {
- loginCommand = initLoginCommand(loginCommandSettings);
- }
- else
- {
- // Try a partial match of serverInfo
- serverInfo = serverInfo.toLowerCase();
- for (Iterator iterator = loginCommands.keySet().iterator(); iterator.hasNext();)
- {
- String serverMatch = (String)iterator.next();
- loginCommandSettings = (LoginCommandSettings)loginCommands.get(serverMatch);
-
- if (serverInfo.indexOf(serverMatch.toLowerCase()) != -1)
- {
- // add this match for easier lookup next time around
- loginCommands.put(serverInfo, loginCommandSettings);
- loginCommand = initLoginCommand(loginCommandSettings);
- break;
- }
- }
- }
- }
-
- if (loginCommand == null)
- {
- if (Log.isWarn())
- Log.getLogger(ConfigurationManager.LOG_CATEGORY).warn
- ("No login command was found for '" + securitySettings.getServerInfo()
- + "'. Please ensure that the login-command tag has the correct server attribute value"
- + ", or use 'all' to use the login command regardless of the server.");
- }
- else
- {
- loginManager.setLoginCommand(loginCommand);
- }
-
- if (loginCommandSettings != null)
- loginManager.setPerClientAuthentication(loginCommandSettings.isPerClientAuthentication());
-
- broker.setLoginManager(loginManager);
- }
-
- private LoginCommand initLoginCommand(LoginCommandSettings loginCommandSettings)
- {
- String loginClass = loginCommandSettings.getClassName();
- Class c = ClassUtil.createClass(loginClass,
- FlexContext.getMessageBroker() == null ? null :
- FlexContext.getMessageBroker().getClassLoader());
- LoginCommand loginCommand = (LoginCommand)ClassUtil.createDefaultInstance(c, LoginCommand.class);
-
- return loginCommand;
- }
-
- private void createSharedServers(MessageBroker broker)
- {
- for (SharedServerSettings settings : sharedServerSettings)
- {
- String id = settings.getId();
- String className = settings.getClassName();
- Class serverClass = ClassUtil.createClass(className, broker.getClassLoader());
- FlexComponent server = (FlexComponent)ClassUtil.createDefaultInstance(serverClass, serverClass);
- server.initialize(id, settings.getProperties());
- if (broker.isManaged() && (server instanceof ManageableComponent))
- {
- ManageableComponent manageableServer = (ManageableComponent)server;
- manageableServer.setManaged(true);
- manageableServer.setParent(broker);
- }
-
- // TODO: move this to only AsyncMessageBroker.
- broker.addServer((Server)server);
-
- if (Log.isInfo())
- {
- Log.getLogger(ConfigurationManager.LOG_CATEGORY).info
- ("Server '" + id + "' of type '" + className + "' created.");
- }
- }
- }
-
- private void createEndpoints(MessageBroker broker)
- {
- for (Iterator<String> iter = channelSettings.keySet().iterator(); iter.hasNext();)
- {
- String id = iter.next();
- ChannelSettings chanSettings = channelSettings.get(id);
- String url = chanSettings.getUri();
- String endpointClassName = chanSettings.getEndpointType();
-
- // Create the Endpoint
- Endpoint endpoint = broker.createEndpoint(id, url, endpointClassName);
-
- // Cast to AbstractEndpoint - these are newer properties that post-date the locked Endpoint interface.
- if (endpoint instanceof AbstractEndpoint)
- {
- AbstractEndpoint abstractEndpoint = (AbstractEndpoint)endpoint;
- abstractEndpoint.setRemote(chanSettings.isRemote());
- abstractEndpoint.setServerOnly(chanSettings.getServerOnly());
- }
-
- endpoint.setSecurityConstraint(chanSettings.getConstraint());
- endpoint.setClientType(chanSettings.getClientType());
-
- // Assign referenced server
- String referencedServerId = chanSettings.getServerId();
- if ((referencedServerId != null) && (endpoint instanceof Endpoint2))
- {
- Server server = broker.getServer(referencedServerId);
- if (server == null)
- {
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(11128, new Object[] {chanSettings.getId(), referencedServerId});
- throw ce;
- }
- ((Endpoint2)endpoint).setServer(broker.getServer(referencedServerId));
- }
-
- // Initialize with endpoint properties
- endpoint.initialize(id, chanSettings.getProperties());
-
- if (Log.isInfo())
- {
- String endpointURL = endpoint.getUrl();
- String endpointSecurity = EndpointControl.getSecurityConstraintOf(endpoint);
- if (StringUtils.isEmpty(endpointSecurity))
- endpointSecurity = "None";
- Log.getLogger(ConfigurationManager.LOG_CATEGORY).info
- ("Endpoint '" + id + "' created with security: " +
- endpointSecurity + StringUtils.NEWLINE +
- "at URL: " + endpointURL);
- }
- }
- }
-
- private void createServices(MessageBroker broker)
- {
- //the broker needs its AuthenticationService always
- AuthenticationService authService = new AuthenticationService();
- authService.setMessageBroker(broker);
-
- for (Iterator<ServiceSettings> iter = serviceSettings.iterator(); iter.hasNext();)
- {
- ServiceSettings svcSettings = iter.next();
- String svcId = svcSettings.getId();
- String svcClassName = svcSettings.getClassName();
-
- // Create the Service
- Service service = broker.createService(svcId, svcClassName);
-
- // Service Class Name - not needed in AbstractService
-
- // Initialize with service properties
- service.initialize(svcId, svcSettings.getProperties());
-
- // Default Channels
- for (Iterator chanIter = svcSettings.getDefaultChannels().iterator(); chanIter.hasNext();)
- {
- ChannelSettings chanSettings = (ChannelSettings)chanIter.next();
- service.addDefaultChannel(chanSettings.getId());
- }
-
- // Adapter Definitions
- Map svcAdapterSettings = svcSettings.getAllAdapterSettings();
- for (Iterator asIter = svcAdapterSettings.values().iterator(); asIter.hasNext();)
- {
- AdapterSettings as = (AdapterSettings) asIter.next();
- service.registerAdapter(as.getId(), as.getClassName());
- if (as.isDefault())
- {
- service.setDefaultAdapter(as.getId());
- }
- }
-
- // Destinations
- Map destinationSettings = svcSettings.getDestinationSettings();
- for (Iterator destSettingsIter = destinationSettings.keySet().iterator(); destSettingsIter.hasNext();)
- {
- String destName = (String)destSettingsIter.next();
- DestinationSettings destSettings = (DestinationSettings)destinationSettings.get(destName);
-
- createDestination(destSettings, service, svcSettings);
- }
- }
- }
-
- private void createDestination(DestinationSettings destSettings, Service service, ServiceSettings svcSettings)
- {
- String destId = destSettings.getId();
- Destination destination = service.createDestination(destId);
-
- // Channels
- List chanSettings = destSettings.getChannelSettings();
- if (chanSettings.size() > 0)
- {
- List<String> channelIds = new ArrayList<String>(2);
- for (Iterator iter = chanSettings.iterator(); iter.hasNext();) {
- ChannelSettings cs = (ChannelSettings) iter.next();
- channelIds.add(cs.getId());
- }
- destination.setChannels(channelIds);
- }
-
- // Security
- SecurityConstraint constraint = destSettings.getConstraint();
- destination.setSecurityConstraint(constraint);
-
- // Initialize with service, adapter and destination properties
- destination.initialize(destId, svcSettings.getProperties());
- destination.initialize(destId, destSettings.getAdapterSettings().getProperties());
- destination.initialize(destId, destSettings.getProperties());
-
- // Service Adapter
- createAdapter(destination, destSettings, svcSettings);
- }
-
- private void createAdapter(Destination destination, DestinationSettings destSettings, ServiceSettings svcSettings)
- {
- AdapterSettings adapterSettings = destSettings.getAdapterSettings();
- String adapterId = adapterSettings.getId();
-
- ServiceAdapter adapter = destination.createAdapter(adapterId);
-
- // Initialize with service, adapter and then destination properties
- adapter.initialize(adapterId, svcSettings.getProperties());
- adapter.initialize(adapterId, adapterSettings.getProperties());
- adapter.initialize(adapterId, destSettings.getProperties());
-
- }
-
- /**
- * @exclude
- * Used by the MessageBrokerServlet to set up the singleton Log instance
- * and add any targets defined in the logging configuration.
- * This needs to be invoked ahead of creating and bootstrapping a MessageBroker
- * instance so we're sure to have the logging system running in case the bootstrap
- * process needs to log anything out.
- */
- public void createLogAndTargets()
- {
- if (loggingSettings == null)
- {
- Log.setPrettyPrinterClass(ToStringPrettyPrinter.class.getName());
- return;
- }
-
- Log.createLog();
-
- ConfigMap properties = loggingSettings.getProperties();
-
- // Override default pretty printer for FDS to traverse deep Object graphs
- if (properties.getPropertyAsString("pretty-printer", null) == null)
- {
- Log.setPrettyPrinterClass(ToStringPrettyPrinter.class.getName());
- }
-
- Log.initialize(null, properties);
-
- // Targets
- List targets = loggingSettings.getTargets();
- Iterator it = targets.iterator();
- while (it.hasNext())
- {
- TargetSettings targetSettings = (TargetSettings)it.next();
- String className = targetSettings.getClassName();
-
- Class c = ClassUtil.createClass(className,
- FlexContext.getMessageBroker() == null ? null :
- FlexContext.getMessageBroker().getClassLoader());
- try
- {
- Target target = (Target)c.newInstance();
- target.setLevel(Log.readLevel(targetSettings.getLevel()));
- target.setFilters(targetSettings.getFilters());
- target.initialize(null, targetSettings.getProperties());
- Log.addTarget(target);
- }
- catch (Throwable t)
- {
- // Unwrap to get to the interesting exception
- if (t instanceof InvocationTargetException)
- t = ((InvocationTargetException ) t).getCause();
-
- System.err.println("*** Error setting up logging system");
- t.printStackTrace();
-
- ConfigurationException cx = new ConfigurationException();
- cx.setMessage(10126, new Object[] { className });
- cx.setRootCause(t);
- throw cx;
- }
- }
- }
-
- private void createMessageFilters(MessageBroker broker)
- {
- Class asyncFilterClass = ClassUtil.createClass("flex.messaging.filters.BaseAsyncMessageFilter");
- Class syncFilterClass = ClassUtil.createClass("flex.messaging.filters.BaseSyncMessageFilter");
-
- for (MessageFilterSettings settings : messageFilterSettings)
- {
- String id = settings.getId();
- String className = settings.getClassName();
- Class filterClass = ClassUtil.createClass(className, broker.getClassLoader());
- FlexComponent filter = (FlexComponent)ClassUtil.createDefaultInstance(filterClass, null);
- MessageFilterSettings.FilterType filterType = settings.getFilterType();
- boolean filterIsAsync = filterType == MessageFilterSettings.FilterType.ASYNC;
- // Validate filter is assignable to proper base class.
- if ((filterIsAsync && !asyncFilterClass.isAssignableFrom(filterClass)) ||
- (!filterIsAsync && !syncFilterClass.isAssignableFrom(filterClass)))
- {
- // Filter class is not a valid subclass of either supported base filter type.
- ConfigurationException cx = new ConfigurationException();
- int errorCode = filterIsAsync ? 11144 : 11145;
- cx.setMessage(errorCode, new Object[] {settings.getId()});
- throw cx;
- }
-
- filter.initialize(id, settings.getProperties());
- if (broker.isManaged() && (filter instanceof ManageableComponent))
- {
- ManageableComponent manageableFilter = (ManageableComponent)filter;
- manageableFilter.setManaged(true);
- manageableFilter.setParent(broker);
- }
-
- try
- {
- String methodName = filterIsAsync ? "getAsyncMessageFilterChain" : "getSyncMessageFilterChain";
- Method getMessageFilterChain = broker.getClass().getDeclaredMethod(methodName);
- Object filterChain = getMessageFilterChain.invoke(broker, (Object[])null);
- Class arg = filterIsAsync ? asyncFilterClass : syncFilterClass;
- Method addFilter = filterChain.getClass().getDeclaredMethod("add", arg);
- addFilter.invoke(filterChain, new Object[] {filter});
- }
- catch (Exception e)
- {
- // Hit an unexpected problem adding the filter instance to the broker's async or sync chain.
- ConfigurationException cx = new ConfigurationException();
- int errorCode = filterType == MessageFilterSettings.FilterType.ASYNC ? 11138 : 11143;
- cx.setMessage(errorCode, new Object[] {settings.getId()});
- cx.setRootCause(e);
- throw cx;
- }
-
- if (Log.isInfo())
- {
- Log.getLogger(ConfigurationManager.LOG_CATEGORY).info
- ("MessageFilter '" + id + "' of type '" + className + "' created.");
- }
- }
- }
-
- private void createValidators(MessageBroker broker)
- {
- for (Iterator<ValidatorSettings> iter = validatorSettings.values().iterator(); iter.hasNext(); )
- {
- ValidatorSettings settings = iter.next();
- String className = settings.getClassName();
- String type = settings.getType();
- Class<?> validatorClass = ClassUtil.createClass(className, broker.getClassLoader());
- Class<?> expectedClass = ClassUtil.createClass(type, broker.getClassLoader());
- Object validator = ClassUtil.createDefaultInstance(validatorClass, expectedClass);
- // Only set the DeserializationValidator types for now.
- if (validator instanceof DeserializationValidator)
- {
- // there can only be one deserialization validator, throw an error if there is more than one.
- DeserializationValidator existingValidator = broker.getDeserializationValidator();
- if (existingValidator != null)
- {
- ConfigurationException cx = new ConfigurationException();
- cx.setMessage(11400, new Object[]{existingValidator.getClass().getCanonicalName(), className});
- throw cx;
- }
- DeserializationValidator deserializationValidator = (DeserializationValidator)validator;
- deserializationValidator.initialize(null, settings.getProperties());
- broker.setDeserializationValidator(deserializationValidator);
- if (Log.isInfo())
- {
- Log.getLogger(ConfigurationManager.LOG_CATEGORY).info
- ("DeserializationValidator of type '" + className + "' created.");
- }
- }
- }
- }
-
- private void createUUIDGenerator(MessageBroker broker)
- {
- String className = systemSettings.getUUIDGeneratorClassName();
- if (className == null || className.length() == 0)
- return;
-
- Class uuidGeneratorClass = ClassUtil.createClass(className, broker.getClassLoader());
- if (!UUIDGenerator.class.isAssignableFrom(uuidGeneratorClass))
- {
- // UUID Generator class is not a valid subclass of ''{0}''
- ConfigurationException cx = new ConfigurationException();
- cx.setMessage(11148, new Object[] {UUIDGenerator.class.getName()});
- throw cx;
- }
-
- Object uuidGenerator = ClassUtil.createDefaultInstance(uuidGeneratorClass, UUIDGenerator.class);
- broker.setUUIDGenerator((UUIDGenerator)uuidGenerator);
- }
-
- private void prepareClusters(MessageBroker broker)
- {
- ClusterManager clusterManager = broker.getClusterManager();
- for (Iterator<String> iter=clusterSettings.keySet().iterator(); iter.hasNext(); )
- {
- String clusterId = iter.next();
- ClusterSettings cs = clusterSettings.get(clusterId);
- clusterManager.prepareCluster(cs);
- }
- }
-
- /**
- * Add Shared Server configurations.
- * <p/>
- * @param settings the SharedServerSettings object
- **/
- public void addSharedServerSettings(SharedServerSettings settings)
- {
- sharedServerSettings.add(settings);
- }
-
- /**
- * Add the Channel configurations.
- * <p/>
- * @param id the ChannelSetting Id
- * @param settings the ChannelSettings
- **/
- public void addChannelSettings(String id, ChannelSettings settings)
- {
- channelSettings.put(id, settings);
- }
-
- /**
- * Get the ChannelSettings by Id.
- * <p/>
- * @param id the ChannelSettings Id
- * @return ChannelSettings the Channel settings
- **/
- public ChannelSettings getChannelSettings(String id)
- {
- return channelSettings.get(id);
- }
-
- /**
- * Get all the ChannelSettings.
- * @return Map the Map of all the ChannelSettings, maped by Id
- **/
- public Map getAllChannelSettings()
- {
- return channelSettings;
- }
-
- /**
- * Add the default Channel by Id.
- * <p/>
- * @param id the Channel Id
- **/
- public void addDefaultChannel(String id)
- {
- defaultChannels.add(id);
- }
-
- /**
- * Get the default Channel List.
- * <p/>
- * @return List, the list of default Channels
- **/
- public List getDefaultChannels()
- {
- return defaultChannels;
- }
-
- /**
- * Get the Security Configurations.
- * <p/>
- * @return SecuritySettings current SecuritySettings
- **/
- public SecuritySettings getSecuritySettings()
- {
- return securitySettings;
- }
-
- /**
- * Add Service Configurations.
- * <p/>
- * @param settings the ServiceSettings object
- **/
- public void addServiceSettings(ServiceSettings settings)
- {
- serviceSettings.add(settings);
- }
-
- /**
- * Get ServiceSettings by Id.
- * <p/>
- * @param id the ServiceSettings Id
- * @return ServiceSettings the ServiceSettings object
- **/
- public ServiceSettings getServiceSettings(String id)
- {
- for (Iterator<ServiceSettings> iter = serviceSettings.iterator(); iter.hasNext();)
- {
- ServiceSettings serviceSettings = iter.next();
- if (serviceSettings.getId().equals(id))
- return serviceSettings;
- }
- return null;
- }
-
- /**
- * Get all ServiceSettings.
- * <p/>
- * @return List all the service settings
- **/
- public List getAllServiceSettings()
- {
- return serviceSettings;
- }
-
- /**
- * Get LoggingSettings.
- * <p/>
- * @return LoggingSettings the LoggingSettings object
- **/
- public LoggingSettings getLoggingSettings()
- {
- return loggingSettings;
- }
-
- /**
- * Set LoggingSettings.
- * <p/>
- * @param loggingSettings the LoggingSettings object
- **/
- public void setLoggingSettings(LoggingSettings loggingSettings)
- {
- this.loggingSettings = loggingSettings;
- }
-
- /**
- * Set SystemSettings.
- * <p/>
- * @param ss the SystemSettings object
- **/
- public void setSystemSettings(SystemSettings ss)
- {
- systemSettings = ss;
- }
-
- /**
- * Get SystemSettings.
- * <p/>
- * @return SystemSettings the LoggingSettings object
- **/
- public SystemSettings getSystemSettings()
- {
- return systemSettings;
- }
-
- /**
- * Set FlexClientSettings.
- * <p/>
- * @param value the FlexClientSettings object
- **/
- public void setFlexClientSettings(FlexClientSettings value)
- {
- flexClientSettings = value;
- }
-
- /**
- * Get FlexClientSettings.
- * <p/>
- * @return FlexClientSettings the FlexClientSettings object
- **/
- public FlexClientSettings getFlexClientSettings()
- {
- return flexClientSettings;
- }
-
- /**
- * Add the ClusterSettings.
- * <p/>
- * @param settings the ClusterSettings object
- **/
- public void addClusterSettings(ClusterSettings settings)
- {
- if (settings.isDefault())
- {
- for (Iterator<ClusterSettings> it = clusterSettings.values().iterator(); it.hasNext(); )
- {
- ClusterSettings cs = it.next();
-
- if (cs.isDefault())
- {
- ConfigurationException cx = new ConfigurationException();
- cx.setMessage(10214, new Object[] { settings.getClusterName(), cs.getClusterName() });
- throw cx;
- }
- }
- }
- if (clusterSettings.containsKey(settings.getClusterName()))
- {
- ConfigurationException cx = new ConfigurationException();
- cx.setMessage(10206, new Object[] { settings.getClusterName() });
- throw cx;
- }
- clusterSettings.put(settings.getClusterName(), settings);
- }
-
- /**
- * Get the ClusterSettings object by Id.
- * <p/>
- * @param clusterId the ClusterSettings Id
- * @return ClusterSettings the ClusterSettings object
- **/
- public ClusterSettings getClusterSettings(String clusterId)
- {
- for (Iterator<ClusterSettings> it = clusterSettings.values().iterator(); it.hasNext(); )
- {
- ClusterSettings cs = it.next();
- if (cs.getClusterName() == clusterId)
- return cs; // handle null case
- if (cs.getClusterName() != null && cs.getClusterName().equals(clusterId))
- return cs;
- }
- return null;
- }
-
- /**
- * Get the default ClusterSettings.
- * <p/>
- * @return ClusterSettings the default ClusterSetting object
- **/
- public ClusterSettings getDefaultCluster()
- {
- for (Iterator<ClusterSettings> it = clusterSettings.values().iterator(); it.hasNext(); )
- {
- ClusterSettings cs = it.next();
- if (cs.isDefault())
- return cs;
- }
- return null;
- }
-
- /**
- * Add FactorySettings by Id.
- * <p/>
- * @param id the FactorySettings Id
- * @param settings the FactorySettings object
- **/
- public void addFactorySettings(String id, FactorySettings settings)
- {
- factorySettings.put(id, settings);
- }
-
- /**
- * Add MessageFilterSettings.
- * <p/>
- * @param settings the MessageFilterSettings object
- **/
- public void addMessageFilterSettings(MessageFilterSettings settings)
- {
- messageFilterSettings.add(settings);
- }
-
- /**
- * Add ValidatorSettings.
- * <p/>
- * @param settings the ValidatorSettings object
- **/
- public void addValidatorSettings(ValidatorSettings settings)
- {
- String type = settings.getType();
- if (validatorSettings.containsKey(type))
- {
- // Cannot add multiple validators with the same type ''{0}''
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(11136, new Object[] {type});
- throw ce;
- }
- validatorSettings.put(type, settings);
- }
-
- /**
- * Report unused properties.
- * <p/>
- **/
- public void reportUnusedProperties()
- {
- ArrayList<Object[]> findings = new ArrayList<Object[]>();
-
- Iterator<ServiceSettings> serviceItr = serviceSettings.iterator();
- while (serviceItr.hasNext())
- {
- ServiceSettings serviceSettings = serviceItr.next();
- gatherUnusedProperties(serviceSettings.getId(), serviceSettings.getSourceFile(),
- ConfigurationConstants.SERVICE_ELEMENT, serviceSettings, findings);
- Iterator destinationItr = serviceSettings.getDestinationSettings().values().iterator();
- while (destinationItr.hasNext())
- {
- DestinationSettings destinationSettings = (DestinationSettings) destinationItr.next();
- gatherUnusedProperties(destinationSettings.getId(), destinationSettings.getSourceFile(),
- ConfigurationConstants.DESTINATION_ELEMENT,
- destinationSettings, findings);
-
- AdapterSettings adapterSettings = destinationSettings.getAdapterSettings();
- if (adapterSettings != null)
- {
- gatherUnusedProperties(adapterSettings.getId(), adapterSettings.getSourceFile(),
- ConfigurationConstants.ADAPTER_ELEMENT,
- adapterSettings, findings);
- }
- }
- }
-
- Iterator<ChannelSettings> channelItr = channelSettings.values().iterator();
- while (channelItr.hasNext())
- {
- ChannelSettings channelSettings = channelItr.next();
- // Skip property validation for remote channel-definitions
- if (channelSettings.isRemote())
- continue;
-
- gatherUnusedProperties(channelSettings.getId(), channelSettings.getSourceFile(),
- ConfigurationConstants.CHANNEL_ELEMENT, channelSettings, findings);
- }
-
- Iterator<SharedServerSettings> serverItr = sharedServerSettings.iterator();
- while (serverItr.hasNext())
- {
- SharedServerSettings serverSettings = serverItr.next();
- gatherUnusedProperties(serverSettings.getId(), serverSettings.getSourceFile(),
- ConfigurationConstants.SERVER_ELEMENT, serverSettings, findings);
- }
-
- if (!findings.isEmpty())
- {
- int errorNumber = 10149;
- ConfigurationException exception = new ConfigurationException();
- StringBuffer allDetails = new StringBuffer();
- for (int i = 0; i < findings.size(); i++)
- {
- allDetails.append(StringUtils.NEWLINE);
- allDetails.append(" ");
- exception.setDetails(errorNumber, "pattern", findings.get(i));
- allDetails.append(exception.getDetails());
- exception.setDetails(null);
- }
- exception.setMessage(errorNumber, new Object[] {allDetails});
- throw exception;
- }
- }
-
- private void gatherUnusedProperties
- (String settingsId, String settingsSource, String settingsType,
- PropertiesSettings settings, Collection<Object[]> result)
- {
- List unusedProperties = settings.getProperties().findAllUnusedProperties();
- int size = unusedProperties.size();
- if (size > 0)
- {
- for (int i = 0; i < size; i++)
- {
- String path = (String) unusedProperties.get(i);
- result.add(new Object[] {path, settingsType, settingsId, settingsSource});
- }
- }
- }
-}
+/*
+ * 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.config;
+
+import flex.management.ManageableComponent;
+import flex.management.runtime.messaging.endpoints.EndpointControl;
+import flex.messaging.Destination;
+import flex.messaging.FlexComponent;
+import flex.messaging.FlexContext;
+import flex.messaging.MessageBroker;
+import flex.messaging.Server;
+import flex.messaging.client.FlexClientManager;
+import flex.messaging.cluster.ClusterManager;
+import flex.messaging.endpoints.AbstractEndpoint;
+import flex.messaging.endpoints.Endpoint;
+import flex.messaging.endpoints.Endpoint2;
+import flex.messaging.log.Log;
+import flex.messaging.log.Target;
+import flex.messaging.security.LoginCommand;
+import flex.messaging.security.LoginManager;
+import flex.messaging.services.AuthenticationService;
+import flex.messaging.services.Service;
+import flex.messaging.services.ServiceAdapter;
+import flex.messaging.util.ClassUtil;
+import flex.messaging.util.RedeployManager;
+import flex.messaging.util.StringUtils;
+import flex.messaging.util.ToStringPrettyPrinter;
+import flex.messaging.util.UUIDGenerator;
+import flex.messaging.validators.DeserializationValidator;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This object encapsulates settings for a MessageBroker instance.
+ * The MessageBroker itself has no knowledge of configuration specifics;
+ * instead, this object sets the relevant values on the broker using
+ * information which a ConfigurationParser has provided for it.
+ *
+ * @author Peter Farland
+ * @author neville
+ * @exclude
+ */
+public class MessagingConfiguration implements ServicesConfiguration
+{
+ private final String asyncMessageBrokerType = "flex.messaging.AsyncMessageBroker";
+ private final String asyncFlexClientManagerType = "flex.messaging.client.AsyncFlexClientManager";
+
+ private final Map<String, ChannelSettings> channelSettings;
+ private final List<String> defaultChannels;
+ private final SecuritySettings securitySettings;
+ private final List<ServiceSettings> serviceSettings;
+ private final List<SharedServerSettings> sharedServerSettings;
+ private LoggingSettings loggingSettings;
+ private SystemSettings systemSettings;
+ private FlexClientSettings flexClientSettings;
+ private final Map<String, ClusterSettings> clusterSettings;
+ private final Map<String, FactorySettings> factorySettings;
+ private final List<MessageFilterSettings> messageFilterSettings;
+ private final Map<String, ValidatorSettings> validatorSettings;
+
+ /**
+ * Constructor.
+ * Construct a MessagingConfiguration object
+ * <p/>
+ */
+ public MessagingConfiguration()
+ {
+ channelSettings = new HashMap<String, ChannelSettings>();
+ defaultChannels = new ArrayList<String>(4);
+ clusterSettings = new HashMap<String, ClusterSettings>();
+ factorySettings = new HashMap<String, FactorySettings>();
+ serviceSettings = new ArrayList<ServiceSettings>();
+ sharedServerSettings = new ArrayList<SharedServerSettings>();
+ securitySettings = new SecuritySettings();
+ messageFilterSettings = new ArrayList<MessageFilterSettings>();
+ validatorSettings = new HashMap<String, ValidatorSettings>();
+ }
+
+ /**
+ * Configure the MessageBroker.
+ * <p/>
+ * @param broker current MessageBroker object
+ */
+ public void configureBroker(MessageBroker broker)
+ {
+ boolean async = (broker.getClass().getName().equals(asyncMessageBrokerType));
+
+ broker.setChannelSettings(channelSettings);
+ broker.setSecuritySettings(securitySettings);
+ broker.setSystemSettings(systemSettings);
+ broker.setFlexClientSettings(flexClientSettings);
+
+ // validators need to come first so that the other code can use them
+ createValidators(broker);
+
+ createAuthorizationManager(broker);
+ createFlexClientManager(broker);
+ createRedeployManager(broker);
+ createFactories(broker);
+
+ if (async)
+ createSharedServers(broker);
+
+ createEndpoints(broker);
+ // Default channels have to be set after endpoints are created.
+ broker.setDefaultChannels(defaultChannels);
+ prepareClusters(broker);
+ createServices(broker);
+
+ if (async)
+ createMessageFilters(broker);
+
+ createUUIDGenerator(broker);
+ }
+
+ /**
+ * Create a MessageBroker object with the Id.
+ * <p/>
+ * @param id String the MessageBroker Id
+ * @param loader the ClassLoader used to load the MessageBroker class
+ * @return the created MessageBroker object
+ */
+ public MessageBroker createBroker(String id, ClassLoader loader)
+ {
+ // Construct MessageBroker with manageable constructor to avoid loading
+ // any JMX classes in case manageable is set to false.
+ MessageBroker broker;
+ try // Use the AsyncMessageBroker, if possible.
+ {
+ @SuppressWarnings("unchecked")
+ Class<? extends MessageBroker> messageBrokerClass = ClassUtil.createClass(asyncMessageBrokerType, loader);
+ Constructor constructor = messageBrokerClass.getConstructor(boolean.class);
+ broker = (MessageBroker)constructor.newInstance(systemSettings.isManageable());
+ }
+ catch (Throwable t) // Otherwise, use the default MessageBroker.
+ {
+ broker = new MessageBroker(systemSettings.isManageable());
+ }
+
+ // Initialize MessageBroker.
+ broker.setEnforceEndpointValidation(systemSettings.isEnforceEndpointValidation());
+ //broker.setManaged(systemSettings.isManageable());
+ broker.setId(id);
+ broker.setClassLoader(loader);
+
+ return broker;
+ }
+
+ private void createFactories(MessageBroker broker)
+ {
+ for (Iterator<Map.Entry<String,FactorySettings>> iter=factorySettings.entrySet().iterator(); iter.hasNext(); )
+ {
+ Map.Entry<String,FactorySettings> entry = iter.next();
+ String id = entry.getKey();
+ FactorySettings factorySetting = entry.getValue();
+ broker.addFactory(id, factorySetting.createFactory(broker.getClassLoader()));
+ }
+ }
+
+ private void createFlexClientManager(MessageBroker broker)
+ {
+ FlexClientManager flexClientManager = null;
+ try // Use the async version, if possible.
+ {
+ @SuppressWarnings("unchecked")
+ Class<? extends FlexClientManager> flexClientManagerClass = ClassUtil.createClass(asyncFlexClientManagerType, broker.getClassLoader());
+ Constructor ctor = flexClientManagerClass.getConstructor(broker.getClass());
+ flexClientManager = (FlexClientManager)ctor.newInstance(broker);
+ }
+ catch (Throwable t) // Otherwise, use the default FlexClientManager.
+ {
+ flexClientManager = new FlexClientManager(broker.isManaged(), broker);
+ }
+ broker.setFlexClientManager(flexClientManager);
+ }
+
+ private void createRedeployManager(MessageBroker broker)
+ {
+ RedeployManager redeployManager = new RedeployManager();
+ redeployManager.setEnabled(systemSettings.getRedeployEnabled());
+ redeployManager.setWatchInterval(systemSettings.getWatchInterval());
+ redeployManager.setTouchFiles(systemSettings.getTouchFiles());
+ redeployManager.setWatchFiles(systemSettings.getWatchFiles());
+ broker.setRedeployManager(redeployManager);
+ }
+
+ private void createAuthorizationManager(MessageBroker broker)
+ {
+ LoginManager loginManager = new LoginManager();
+
+ // Create a Login Command for the LoginManager.
+ LoginCommand loginCommand = null;
+
+ Map loginCommands = securitySettings.getLoginCommands();
+
+ // If default Login Command is enabled, use it.
+ LoginCommandSettings loginCommandSettings = (LoginCommandSettings)loginCommands.get(LoginCommandSettings.SERVER_MATCH_OVERRIDE);
+ if (loginCommandSettings != null)
+ {
+ loginCommand = initLoginCommand(loginCommandSettings);
+ }
+ // Otherwise, try a server specific Login Command.
+ else
+ {
+ String serverInfo = securitySettings.getServerInfo();
+ loginCommandSettings = (LoginCommandSettings)loginCommands.get(serverInfo);
+
+ if (loginCommandSettings != null)
+ {
+ loginCommand = initLoginCommand(loginCommandSettings);
+ }
+ else
+ {
+ // Try a partial match of serverInfo
+ serverInfo = serverInfo.toLowerCase();
+ for (Iterator iterator = loginCommands.keySet().iterator(); iterator.hasNext();)
+ {
+ String serverMatch = (String)iterator.next();
+ loginCommandSettings = (LoginCommandSettings)loginCommands.get(serverMatch);
+
+ if (serverInfo.indexOf(serverMatch.toLowerCase()) != -1)
+ {
+ // add this match for easier lookup next time around
+ loginCommands.put(serverInfo, loginCommandSettings);
+ loginCommand = initLoginCommand(loginCommandSettings);
+ break;
+ }
+ }
+ }
+ }
+
+ if (loginCommand == null)
+ {
+ if (Log.isWarn())
+ Log.getLogger(ConfigurationManager.LOG_CATEGORY).warn
+ ("No login command was found for '" + securitySettings.getServerInfo()
+ + "'. Please ensure that the login-command tag has the correct server attribute value"
+ + ", or use 'all' to use the login command regardless of the server.");
+ }
+ else
+ {
+ loginManager.setLoginCommand(loginCommand);
+ }
+
+ if (loginCommandSettings != null)
+ loginManager.setPerClientAuthentication(loginCommandSettings.isPerClientAuthentication());
+
+ broker.setLoginManager(loginManager);
+ }
+
+ private LoginCommand initLoginCommand(LoginCommandSettings loginCommandSettings)
+ {
+ String loginClass = loginCommandSettings.getClassName();
+ Class c = ClassUtil.createClass(loginClass,
+ FlexContext.getMessageBroker() == null ? null :
+ FlexContext.getMessageBroker().getClassLoader());
+ LoginCommand loginCommand = (LoginCommand)ClassUtil.createDefaultInstance(c, LoginCommand.class);
+
+ return loginCommand;
+ }
+
+ private void createSharedServers(MessageBroker broker)
+ {
+ for (SharedServerSettings settings : sharedServerSettings)
+ {
+ String id = settings.getId();
+ String className = settings.getClassName();
+ Class serverClass = ClassUtil.createClass(className, broker.getClassLoader());
+ FlexComponent server = (FlexComponent)ClassUtil.createDefaultInstance(serverClass, serverClass);
+ server.initialize(id, settings.getProperties());
+ if (broker.isManaged() && (server instanceof ManageableComponent))
+ {
+ ManageableComponent manageableServer = (ManageableComponent)server;
+ manageableServer.setManaged(true);
+ manageableServer.setParent(broker);
+ }
+
+ // TODO: move this to only AsyncMessageBroker.
+ broker.addServer((Server)server);
+
+ if (Log.isInfo())
+ {
+ Log.getLogger(ConfigurationManager.LOG_CATEGORY).info
+ ("Server '" + id + "' of type '" + className + "' created.");
+ }
+ }
+ }
+
+ private void createEndpoints(MessageBroker broker)
+ {
+ for (Iterator<String> iter = channelSettings.keySet().iterator(); iter.hasNext();)
+ {
+ String id = iter.next();
+ ChannelSettings chanSettings = channelSettings.get(id);
+ String url = chanSettings.getUri();
+ String endpointClassName = chanSettings.getEndpointType();
+
+ // Create the Endpoint
+ Endpoint endpoint = broker.createEndpoint(id, url, endpointClassName);
+
+ // Cast to AbstractEndpoint - these are newer properties that post-date the locked Endpoint interface.
+ if (endpoint instanceof AbstractEndpoint)
+ {
+ AbstractEndpoint abstractEndpoint = (AbstractEndpoint)endpoint;
+ abstractEndpoint.setRemote(chanSettings.isRemote());
+ abstractEndpoint.setServerOnly(chanSettings.getServerOnly());
+ }
+
+ endpoint.setSecurityConstraint(chanSettings.getConstraint());
+ endpoint.setClientType(chanSettings.getClientType());
+
+ // Assign referenced server
+ String referencedServerId = chanSettings.getServerId();
+ if ((referencedServerId != null) && (endpoint instanceof Endpoint2))
+ {
+ Server server = broker.getServer(referencedServerId);
+ if (server == null)
+ {
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(11128, new Object[] {chanSettings.getId(), referencedServerId});
+ throw ce;
+ }
+ ((Endpoint2)endpoint).setServer(broker.getServer(referencedServerId));
+ }
+
+ // Initialize with endpoint properties
+ endpoint.initialize(id, chanSettings.getProperties());
+
+ if (Log.isInfo())
+ {
+ String endpointURL = endpoint.getUrl();
+ String endpointSecurity = EndpointControl.getSecurityConstraintOf(endpoint);
+ if (StringUtils.isEmpty(endpointSecurity))
+ endpointSecurity = "None";
+ Log.getLogger(ConfigurationManager.LOG_CATEGORY).info
+ ("Endpoint '" + id + "' created with security: " +
+ endpointSecurity + StringUtils.NEWLINE +
+ "at URL: " + endpointURL);
+ }
+ }
+ }
+
+ private void createServices(MessageBroker broker)
+ {
+ //the broker needs its AuthenticationService always
+ AuthenticationService authService = new AuthenticationService();
+ authService.setMessageBroker(broker);
+
+ for (Iterator<ServiceSettings> iter = serviceSettings.iterator(); iter.hasNext();)
+ {
+ ServiceSettings svcSettings = iter.next();
+ String svcId = svcSettings.getId();
+ String svcClassName = svcSettings.getClassName();
+
+ // Create the Service
+ Service service = broker.createService(svcId, svcClassName);
+
+ // Service Class Name - not needed in AbstractService
+
+ // Initialize with service properties
+ service.initialize(svcId, svcSettings.getProperties());
+
+ // Default Channels
+ for (Iterator chanIter = svcSettings.getDefaultChannels().iterator(); chanIter.hasNext();)
+ {
+ ChannelSettings chanSettings = (ChannelSettings)chanIter.next();
+ service.addDefaultChannel(chanSettings.getId());
+ }
+
+ // Adapter Definitions
+ Map svcAdapterSettings = svcSettings.getAllAdapterSettings();
+ for (Iterator asIter = svcAdapterSettings.values().iterator(); asIter.hasNext();)
+ {
+ AdapterSettings as = (AdapterSettings) asIter.next();
+ service.registerAdapter(as.getId(), as.getClassName());
+ if (as.isDefault())
+ {
+ service.setDefaultAdapter(as.getId());
+ }
+ }
+
+ // Destinations
+ Map destinationSettings = svcSettings.getDestinationSettings();
+ for (Iterator destSettingsIter = destinationSettings.keySet().iterator(); destSettingsIter.hasNext();)
+ {
+ String destName = (String)destSettingsIter.next();
+ DestinationSettings destSettings = (DestinationSettings)destinationSettings.get(destName);
+
+ createDestination(destSettings, service, svcSettings);
+ }
+ }
+ }
+
+ private void createDestination(DestinationSettings destSettings, Service service, ServiceSettings svcSettings)
+ {
+ String destId = destSettings.getId();
+ Destination destination = service.createDestination(destId);
+
+ // Channels
+ List chanSettings = destSettings.getChannelSettings();
+ if (chanSettings.size() > 0)
+ {
+ List<String> channelIds = new ArrayList<String>(2);
+ for (Iterator iter = chanSettings.iterator(); iter.hasNext();) {
+ ChannelSettings cs = (ChannelSettings) iter.next();
+ channelIds.add(cs.getId());
+ }
+ destination.setChannels(channelIds);
+ }
+
+ // Security
+ SecurityConstraint constraint = destSettings.getConstraint();
+ destination.setSecurityConstraint(constraint);
+
+ // Initialize with service, adapter and destination properties
+ destination.initialize(destId, svcSettings.getProperties());
+ destination.initialize(destId, destSettings.getAdapterSettings().getProperties());
+ destination.initialize(destId, destSettings.getProperties());
+
+ // Service Adapter
+ createAdapter(destination, destSettings, svcSettings);
+ }
+
+ private void createAdapter(Destination destination, DestinationSettings destSettings, ServiceSettings svcSettings)
+ {
+ AdapterSettings adapterSettings = destSettings.getAdapterSettings();
+ String adapterId = adapterSettings.getId();
+
+ ServiceAdapter adapter = destination.createAdapter(adapterId);
+
+ // Initialize with service, adapter and then destination properties
+ adapter.initialize(adapterId, svcSettings.getProperties());
+ adapter.initialize(adapterId, adapterSettings.getProperties());
+ adapter.initialize(adapterId, destSettings.getProperties());
+
+ }
+
+ /**
+ * @exclude
+ * Used by the MessageBrokerServlet to set up the singleton Log instance
+ * and add any targets defined in the logging configuration.
+ * This needs to be invoked ahead of creating and bootstrapping a MessageBroker
+ * instance so we're sure to have the logging system running in case the bootstrap
+ * process needs to log anything out.
+ */
+ public void createLogAndTargets()
+ {
+ if (loggingSettings == null)
+ {
+ Log.setPrettyPrinterClass(ToStringPrettyPrinter.class.getName());
+ return;
+ }
+
+ Log.createLog();
+
+ ConfigMap properties = loggingSettings.getProperties();
+
+ // Override default pretty printer for FDS to traverse deep Object graphs
+ if (properties.getPropertyAsString("pretty-printer", null) == null)
+ {
+ Log.setPrettyPrinterClass(ToStringPrettyPrinter.class.getName());
+ }
+
+ Log.initialize(null, properties);
+
+ // Targets
+ List targets = loggingSettings.getTargets();
+ Iterator it = targets.iterator();
+ while (it.hasNext())
+ {
+ TargetSettings targetSettings = (TargetSettings)it.next();
+ String className = targetSettings.getClassName();
+
+ Class c = ClassUtil.createClass(className,
+ FlexContext.getMessageBroker() == null ? null :
+ FlexContext.getMessageBroker().getClassLoader());
+ try
+ {
+ Target target = (Target)c.newInstance();
+ target.setLevel(Log.readLevel(targetSettings.getLevel()));
+ target.setFilters(targetSettings.getFilters());
+ target.initialize(null, targetSettings.getProperties());
+ Log.addTarget(target);
+ }
+ catch (Throwable t)
+ {
+ // Unwrap to get to the interesting exception
+ if (t instanceof InvocationTargetException)
+ t = ((InvocationTargetException ) t).getCause();
+
+ System.err.println("*** Error setting up logging system");
+ t.printStackTrace();
+
+ ConfigurationException cx = new ConfigurationException();
+ cx.setMessage(10126, new Object[] { className });
+ cx.setRootCause(t);
+ throw cx;
+ }
+ }
+ }
+
+ private void createMessageFilters(MessageBroker broker)
+ {
+ Class asyncFilterClass = ClassUtil.createClass("flex.messaging.filters.BaseAsyncMessageFilter");
+ Class syncFilterClass = ClassUtil.createClass("flex.messaging.filters.BaseSyncMessageFilter");
+
+ for (MessageFilterSettings settings : messageFilterSettings)
+ {
+ String id = settings.getId();
+ String className = settings.getClassName();
+ Class filterClass = ClassUtil.createClass(className, broker.getClassLoader());
+ FlexComponent filter = (FlexComponent)ClassUtil.createDefaultInstance(filterClass, null);
+ MessageFilterSettings.FilterType filterType = settings.getFilterType();
+ boolean filterIsAsync = filterType == MessageFilterSettings.FilterType.ASYNC;
+ // Validate filter is assignable to proper base class.
+ if ((filterIsAsync && !asyncFilterClass.isAssignableFrom(filterClass)) ||
+ (!filterIsAsync && !syncFilterClass.isAssignableFrom(filterClass)))
+ {
+ // Filter class is not a valid subclass of either supported base filter type.
+ ConfigurationException cx = new ConfigurationException();
+ int errorCode = filterIsAsync ? 11144 : 11145;
+ cx.setMessage(errorCode, new Object[] {settings.getId()});
+ throw cx;
+ }
+
+ filter.initialize(id, settings.getProperties());
+ if (broker.isManaged() && (filter instanceof ManageableComponent))
+ {
+ ManageableComponent manageableFilter = (ManageableComponent)filter;
+ manageableFilter.setManaged(true);
+ manageableFilter.setParent(broker);
+ }
+
+ try
+ {
+ String methodName = filterIsAsync ? "getAsyncMessageFilterChain" : "getSyncMessageFilterChain";
+ Method getMessageFilterChain = broker.getClass().getDeclaredMethod(methodName);
+ Object filterChain = getMessageFilterChain.invoke(broker, (Object[])null);
+ Class arg = filterIsAsync ? asyncFilterClass : syncFilterClass;
+ Method addFilter = filterChain.getClass().getDeclaredMethod("add", arg);
+ addFilter.invoke(filterChain, new Object[] {filter});
+ }
+ catch (Exception e)
+ {
+ // Hit an unexpected problem adding the filter instance to the broker's async or sync chain.
+ ConfigurationException cx = new ConfigurationException();
+ int errorCode = filterType == MessageFilterSettings.FilterType.ASYNC ? 11138 : 11143;
+ cx.setMessage(errorCode, new Object[] {settings.getId()});
+ cx.setRootCause(e);
+ throw cx;
+ }
+
+ if (Log.isInfo())
+ {
+ Log.getLogger(ConfigurationManager.LOG_CATEGORY).info
+ ("MessageFilter '" + id + "' of type '" + className + "' created.");
+ }
+ }
+ }
+
+ private void createValidators(MessageBroker broker)
+ {
+ for (Iterator<ValidatorSettings> iter = validatorSettings.values().iterator(); iter.hasNext(); )
+ {
+ ValidatorSettings settings = iter.next();
+ String className = settings.getClassName();
+ String type = settings.getType();
+ Class<?> validatorClass = ClassUtil.createClass(className, broker.getClassLoader());
+ Class<?> expectedClass = ClassUtil.createClass(type, broker.getClassLoader());
+ Object validator = ClassUtil.createDefaultInstance(validatorClass, expectedClass);
+ // Only set the DeserializationValidator types for now.
+ if (validator instanceof DeserializationValidator)
+ {
+ // there can only be one deserialization validator, throw an error if there is more than one.
+ DeserializationValidator existingValidator = broker.getDeserializationValidator();
+ if (existingValidator != null)
+ {
+ ConfigurationException cx = new ConfigurationException();
+ cx.setMessage(11400, new Object[]{existingValidator.getClass().getCanonicalName(), className});
+ throw cx;
+ }
+ DeserializationValidator deserializationValidator = (DeserializationValidator)validator;
+ deserializationValidator.initialize(null, settings.getProperties());
+ broker.setDeserializationValidator(deserializationValidator);
+ if (Log.isInfo())
+ {
+ Log.getLogger(ConfigurationManager.LOG_CATEGORY).info
+ ("DeserializationValidator of type '" + className + "' created.");
+ }
+ }
+ }
+ }
+
+ private void createUUIDGenerator(MessageBroker broker)
+ {
+ String className = systemSettings.getUUIDGeneratorClassName();
+ if (className == null || className.length() == 0)
+ return;
+
+ Class uuidGeneratorClass = ClassUtil.createClass(className, broker.getClassLoader());
+ if (!UUIDGenerator.class.isAssignableFrom(uuidGeneratorClass))
+ {
+ // UUID Generator class is not a valid subclass of ''{0}''
+ ConfigurationException cx = new ConfigurationException();
+ cx.setMessage(11148, new Object[] {UUIDGenerator.class.getName()});
+ throw cx;
+ }
+
+ Object uuidGenerator = ClassUtil.createDefaultInstance(uuidGeneratorClass, UUIDGenerator.class);
+ broker.setUUIDGenerator((UUIDGenerator)uuidGenerator);
+ }
+
+ private void prepareClusters(MessageBroker broker)
+ {
+ ClusterManager clusterManager = broker.getClusterManager();
+ for (Iterator<String> iter=clusterSettings.keySet().iterator(); iter.hasNext(); )
+ {
+ String clusterId = iter.next();
+ ClusterSettings cs = clusterSettings.get(clusterId);
+ clusterManager.prepareCluster(cs);
+ }
+ }
+
+ /**
+ * Add Shared Server configurations.
+ * <p/>
+ * @param settings the SharedServerSettings object
+ **/
+ public void addSharedServerSettings(SharedServerSettings settings)
+ {
+ sharedServerSettings.add(settings);
+ }
+
+ /**
+ * Add the Channel configurations.
+ * <p/>
+ * @param id the ChannelSetting Id
+ * @param settings the ChannelSettings
+ **/
+ public void addChannelSettings(String id, ChannelSettings settings)
+ {
+ channelSettings.put(id, settings);
+ }
+
+ /**
+ * Get the ChannelSettings by Id.
+ * <p/>
+ * @param id the ChannelSettings Id
+ * @return ChannelSettings the Channel settings
+ **/
+ public ChannelSettings getChannelSettings(String id)
+ {
+ return channelSettings.get(id);
+ }
+
+ /**
+ * Get all the ChannelSettings.
+ * @return Map the Map of all the ChannelSettings, maped by Id
+ **/
+ public Map getAllChannelSettings()
+ {
+ return channelSettings;
+ }
+
+ /**
+ * Add the default Channel by Id.
+ * <p/>
+ * @param id the Channel Id
+ **/
+ public void addDefaultChannel(String id)
+ {
+ defaultChannels.add(id);
+ }
+
+ /**
+ * Get the default Channel List.
+ * <p/>
+ * @return List, the list of default Channels
+ **/
+ public List getDefaultChannels()
+ {
+ return defaultChannels;
+ }
+
+ /**
+ * Get the Security Configurations.
+ * <p/>
+ * @return SecuritySettings current SecuritySettings
+ **/
+ public SecuritySettings getSecuritySettings()
+ {
+ return securitySettings;
+ }
+
+ /**
+ * Add Service Configurations.
+ * <p/>
+ * @param settings the ServiceSettings object
+ **/
+ public void addServiceSettings(ServiceSettings settings)
+ {
+ serviceSettings.add(settings);
+ }
+
+ /**
+ * Get ServiceSettings by Id.
+ * <p/>
+ * @param id the ServiceSettings Id
+ * @return ServiceSettings the ServiceSettings object
+ **/
+ public ServiceSettings getServiceSettings(String id)
+ {
+ for (Iterator<ServiceSettings> iter = serviceSettings.iterator(); iter.hasNext();)
+ {
+ ServiceSettings serviceSettings = iter.next();
+ if (serviceSettings.getId().equals(id))
+ return serviceSettings;
+ }
+ return null;
+ }
+
+ /**
+ * Get all ServiceSettings.
+ * <p/>
+ * @return List all the service settings
+ **/
+ public List getAllServiceSettings()
+ {
+ return serviceSettings;
+ }
+
+ /**
+ * Get LoggingSettings.
+ * <p/>
+ * @return LoggingSettings the LoggingSettings object
+ **/
+ public LoggingSettings getLoggingSettings()
+ {
+ return loggingSettings;
+ }
+
+ /**
+ * Set LoggingSettings.
+ * <p/>
+ * @param loggingSettings the LoggingSettings object
+ **/
+ public void setLoggingSettings(LoggingSettings loggingSettings)
+ {
+ this.loggingSettings = loggingSettings;
+ }
+
+ /**
+ * Set SystemSettings.
+ * <p/>
+ * @param ss the SystemSettings object
+ **/
+ public void setSystemSettings(SystemSettings ss)
+ {
+ systemSettings = ss;
+ }
+
+ /**
+ * Get SystemSettings.
+ * <p/>
+ * @return SystemSettings the LoggingSettings object
+ **/
+ public SystemSettings getSystemSettings()
+ {
+ return systemSettings;
+ }
+
+ /**
+ * Set FlexClientSettings.
+ * <p/>
+ * @param value the FlexClientSettings object
+ **/
+ public void setFlexClientSettings(FlexClientSettings value)
+ {
+ flexClientSettings = value;
+ }
+
+ /**
+ * Get FlexClientSettings.
+ * <p/>
+ * @return FlexClientSettings the FlexClientSettings object
+ **/
+ public FlexClientSettings getFlexClientSettings()
+ {
+ return flexClientSettings;
+ }
+
+ /**
+ * Add the ClusterSettings.
+ * <p/>
+ * @param settings the ClusterSettings object
+ **/
+ public void addClusterSettings(ClusterSettings settings)
+ {
+ if (settings.isDefault())
+ {
+ for (Iterator<ClusterSettings> it = clusterSettings.values().iterator(); it.hasNext(); )
+ {
+ ClusterSettings cs = it.next();
+
+ if (cs.isDefault())
+ {
+ ConfigurationException cx = new ConfigurationException();
+ cx.setMessage(10214, new Object[] { settings.getClusterName(), cs.getClusterName() });
+ throw cx;
+ }
+ }
+ }
+ if (clusterSettings.containsKey(settings.getClusterName()))
+ {
+ ConfigurationException cx = new ConfigurationException();
+ cx.setMessage(10206, new Object[] { settings.getClusterName() });
+ throw cx;
+ }
+ clusterSettings.put(settings.getClusterName(), settings);
+ }
+
+ /**
+ * Get the ClusterSettings object by Id.
+ * <p/>
+ * @param clusterId the ClusterSettings Id
+ * @return ClusterSettings the ClusterSettings object
+ **/
+ public ClusterSettings getClusterSettings(String clusterId)
+ {
+ for (Iterator<ClusterSettings> it = clusterSettings.values().iterator(); it.hasNext(); )
+ {
+ ClusterSettings cs = it.next();
+ if (cs.getClusterName() == clusterId)
+ return cs; // handle null case
+ if (cs.getClusterName() != null && cs.getClusterName().equals(clusterId))
+ return cs;
+ }
+ return null;
+ }
+
+ /**
+ * Get the default ClusterSettings.
+ * <p/>
+ * @return ClusterSettings the default ClusterSetting object
+ **/
+ public ClusterSettings getDefaultCluster()
+ {
+ for (Iterator<ClusterSettings> it = clusterSettings.values().iterator(); it.hasNext(); )
+ {
+ ClusterSettings cs = it.next();
+ if (cs.isDefault())
+ return cs;
+ }
+ return null;
+ }
+
+ /**
+ * Add FactorySettings by Id.
+ * <p/>
+ * @param id the FactorySettings Id
+ * @param settings the FactorySettings object
+ **/
+ public void addFactorySettings(String id, FactorySettings settings)
+ {
+ factorySettings.put(id, settings);
+ }
+
+ /**
+ * Add MessageFilterSettings.
+ * <p/>
+ * @param settings the MessageFilterSettings object
+ **/
+ public void addMessageFilterSettings(MessageFilterSettings settings)
+ {
+ messageFilterSettings.add(settings);
+ }
+
+ /**
+ * Add ValidatorSettings.
+ * <p/>
+ * @param settings the ValidatorSettings object
+ **/
+ public void addValidatorSettings(ValidatorSettings settings)
+ {
+ String type = settings.getType();
+ if (validatorSettings.containsKey(type))
+ {
+ // Cannot add multiple validators with the same type ''{0}''
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(11136, new Object[] {type});
+ throw ce;
+ }
+ validatorSettings.put(type, settings);
+ }
+
+ /**
+ * Report unused properties.
+ * <p/>
+ **/
+ public void reportUnusedProperties()
+ {
+ ArrayList<Object[]> findings = new ArrayList<Object[]>();
+
+ Iterator<ServiceSettings> serviceItr = serviceSettings.iterator();
+ while (serviceItr.hasNext())
+ {
+ ServiceSettings serviceSettings = serviceItr.next();
+ gatherUnusedProperties(serviceSettings.getId(), serviceSettings.getSourceFile(),
+ ConfigurationConstants.SERVICE_ELEMENT, serviceSettings, findings);
+ Iterator destinationItr = serviceSettings.getDestinationSettings().values().iterator();
+ while (destinationItr.hasNext())
+ {
+ DestinationSettings destinationSettings = (DestinationSettings) destinationItr.next();
+ gatherUnusedProperties(destinationSettings.getId(), destinationSettings.getSourceFile(),
+ ConfigurationConstants.DESTINATION_ELEMENT,
+ destinationSettings, findings);
+
+ AdapterSettings adapterSettings = destinationSettings.getAdapterSettings();
+ if (adapterSettings != null)
+ {
+ gatherUnusedProperties(adapterSettings.getId(), adapterSettings.getSourceFile(),
+ ConfigurationConstants.ADAPTER_ELEMENT,
+ adapterSettings, findings);
+ }
+ }
+ }
+
+ Iterator<ChannelSettings> channelItr = channelSettings.values().iterator();
+ while (channelItr.hasNext())
+ {
+ ChannelSettings channelSettings = channelItr.next();
+ // Skip property validation for remote channel-definitions
+ if (channelSettings.isRemote())
+ continue;
+
+ gatherUnusedProperties(channelSettings.getId(), channelSettings.getSourceFile(),
+ ConfigurationConstants.CHANNEL_ELEMENT, channelSettings, findings);
+ }
+
+ Iterator<SharedServerSettings> serverItr = sharedServerSettings.iterator();
+ while (serverItr.hasNext())
+ {
+ SharedServerSettings serverSettings = serverItr.next();
+ gatherUnusedProperties(serverSettings.getId(), serverSettings.getSourceFile(),
+ ConfigurationConstants.SERVER_ELEMENT, serverSettings, findings);
+ }
+
+ if (!findings.isEmpty())
+ {
+ int errorNumber = 10149;
+ ConfigurationException exception = new ConfigurationException();
+ StringBuffer allDetails = new StringBuffer();
+ for (int i = 0; i < findings.size(); i++)
+ {
+ allDetails.append(StringUtils.NEWLINE);
+ allDetails.append(" ");
+ exception.setDetails(errorNumber, "pattern", findings.get(i));
+ allDetails.append(exception.getDetails());
+ exception.setDetails(null);
+ }
+ exception.setMessage(errorNumber, new Object[] {allDetails});
+ throw exception;
+ }
+ }
+
+ private void gatherUnusedProperties
+ (String settingsId, String settingsSource, String settingsType,
+ PropertiesSettings settings, Collection<Object[]> result)
+ {
+ List unusedProperties = settings.getProperties().findAllUnusedProperties();
+ int size = unusedProperties.size();
+ if (size > 0)
+ {
+ for (int i = 0; i < size; i++)
+ {
+ String path = (String) unusedProperties.get(i);
+ result.add(new Object[] {path, settingsType, settingsId, settingsSource});
+ }
+ }
+ }
+}
[51/51] [partial] git commit: FLEX-34306 - [BlazeDS] Make the BlazeDS
build run on Windows machines - Added some mkdir commands to the ANT
Build.java - Did some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
FLEX-34306 - [BlazeDS] Make the BlazeDS build run on Windows machines
- Added some mkdir commands to the ANT Build.java
- Did some fine-tuning to resolve some compile errors
FLEX-34307 - [BlazeDS] Adjust the Maven build to be able to deploy SNAPSHOTs and releases to Apaches Maven repo.
- Adjusted the poms to be able to build and theoretically deploy to Apaches Maven repo.
FLEX-34308 - [BlazeDS] Make all tests run in a Maven build without any need to manually start and deploy BlazeDS to an external Server.
- Moved all tests to a new testsuite module
- Implemented a Utility class (TestServer), which starts an embedded Jetty and deploys the MessageBrokerServlet which is configured to run the needed services.
FLEX-34309 - [BlazeDS] Implement a way to configure a BlazeDS using a configuration stored in the applications Classpath
- Implemented a ClasspathResourceResolver to read a BlazeDS configuration from classpath instead of the filesystem.
- Updated the FlexConfigurationManager to use this ResourceResolver when encountering a config path starting with "classpath:"
Project: http://git-wip-us.apache.org/repos/asf/flex-blazeds/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-blazeds/commit/4f6a3052
Tree: http://git-wip-us.apache.org/repos/asf/flex-blazeds/tree/4f6a3052
Diff: http://git-wip-us.apache.org/repos/asf/flex-blazeds/diff/4f6a3052
Branch: refs/heads/master
Commit: 4f6a3052e1ec6a115ff1b4ce85c2bdb994cbb636
Parents: 5f7c8cf
Author: Christofer Dutz <ch...@c-ware.de>
Authored: Mon May 5 22:07:28 2014 +0200
Committer: Christofer Dutz <ch...@c-ware.de>
Committed: Mon May 5 22:07:28 2014 +0200
----------------------------------------------------------------------
apps/ds-console/build.xml | 6 +-
build.xml | 155 +-
downloads.xml | 6 +-
modules/common/build.xml | 17 +-
modules/common/pom.xml | 2 +-
.../common/src/flex/graphics/ImageSnapshot.java | 294 +-
.../common/src/flex/graphics/package-info.java | 34 +-
.../src/flex/messaging/LocalizedException.java | 758 +--
.../config/AbstractConfigurationParser.java | 1118 ++---
.../flex/messaging/config/AdapterSettings.java | 260 +-
.../ApacheXPathClientConfigurationParser.java | 174 +-
.../flex/messaging/config/ChannelSettings.java | 670 +--
.../messaging/config/ClientConfiguration.java | 384 +-
.../config/ClientConfigurationParser.java | 1904 ++++----
.../flex/messaging/config/ClusterSettings.java | 304 +-
.../src/flex/messaging/config/ConfigMap.java | 942 ++--
.../config/ConfigurationConstants.java | 934 ++--
.../config/ConfigurationException.java | 76 +-
.../config/ConfigurationFileResolver.java | 62 +-
.../messaging/config/ConfigurationParser.java | 62 +-
.../messaging/config/DestinationSettings.java | 384 +-
.../messaging/config/FlexClientSettings.java | 266 +-
.../messaging/config/LocalFileResolver.java | 404 +-
.../flex/messaging/config/LoggingSettings.java | 94 +-
.../messaging/config/LoginCommandSettings.java | 204 +-
.../messaging/config/PropertiesSettings.java | 200 +-
.../messaging/config/SecurityConstraint.java | 246 +-
.../flex/messaging/config/ServiceSettings.java | 332 +-
.../messaging/config/ServicesConfiguration.java | 142 +-
.../messaging/config/ServicesDependencies.java | 1494 +++---
.../flex/messaging/config/TargetSettings.java | 158 +-
.../flex/messaging/config/TokenReplacer.java | 404 +-
.../config/XPathClientConfigurationParser.java | 180 +-
.../common/src/flex/messaging/errors.properties | 862 ++--
.../src/flex/messaging/log/AbstractTarget.java | 536 +--
.../src/flex/messaging/log/ConsoleTarget.java | 84 +-
.../flex/messaging/log/LineFormattedTarget.java | 572 +--
modules/common/src/flex/messaging/log/Log.java | 1408 +++---
.../src/flex/messaging/log/LogCategories.java | 224 +-
.../common/src/flex/messaging/log/LogEvent.java | 232 +-
.../common/src/flex/messaging/log/Logger.java | 804 ++--
.../common/src/flex/messaging/log/Target.java | 224 +-
.../flex/messaging/util/BasicPrettyPrinter.java | 328 +-
.../src/flex/messaging/util/ExceptionUtil.java | 492 +-
.../src/flex/messaging/util/FileUtils.java | 192 +-
.../src/flex/messaging/util/LocaleUtils.java | 116 +-
.../src/flex/messaging/util/ObjectTrace.java | 346 +-
.../flex/messaging/util/PrettyPrintable.java | 60 +-
.../src/flex/messaging/util/PrettyPrinter.java | 60 +-
.../util/PropertyStringResourceLoader.java | 756 +--
.../src/flex/messaging/util/ResourceLoader.java | 210 +-
.../src/flex/messaging/util/StringUtils.java | 428 +-
.../src/flex/messaging/util/UUIDUtils.java | 660 +--
modules/core/build.xml | 109 +-
modules/core/pom.xml | 27 +-
.../core/src/flex/management/BaseControl.java | 1024 ++--
.../src/flex/management/BaseControlMBean.java | 114 +-
.../flex/management/MBeanLifecycleManager.java | 130 +-
.../src/flex/management/MBeanServerLocator.java | 70 +-
.../management/MBeanServerLocatorFactory.java | 248 +-
.../core/src/flex/management/Manageable.java | 110 +-
.../flex/management/ManageableComponent.java | 842 ++--
.../flex/management/ManagementException.java | 64 +-
.../management/PlatformMBeanServerLocator.java | 76 +-
.../core/src/flex/management/jmx/Attribute.java | 126 +-
.../flex/management/jmx/MBeanAttributeInfo.java | 192 +-
.../management/jmx/MBeanConstructorInfo.java | 212 +-
.../core/src/flex/management/jmx/MBeanInfo.java | 372 +-
.../flex/management/jmx/MBeanOperationInfo.java | 238 +-
.../flex/management/jmx/MBeanParameterInfo.java | 146 +-
.../flex/management/jmx/MBeanServerGateway.java | 1818 +++----
.../src/flex/management/jmx/ObjectInstance.java | 134 +-
.../src/flex/management/jmx/ObjectName.java | 198 +-
.../src/flex/management/jmx/package-info.java | 32 +-
.../core/src/flex/management/package-info.java | 32 +-
.../runtime/AdminConsoleDisplayRegistrar.java | 208 +-
.../AdminConsoleDisplayRegistrarMBean.java | 66 +-
.../management/runtime/AdminConsoleTypes.java | 70 +-
.../runtime/messaging/DestinationControl.java | 238 +-
.../messaging/DestinationControlMBean.java | 114 +-
.../runtime/messaging/MessageBrokerControl.java | 594 +--
.../messaging/MessageBrokerControlMBean.java | 264 +-
.../messaging/MessageDestinationControl.java | 624 +--
.../MessageDestinationControlMBean.java | 310 +-
.../client/FlexClientManagerControl.java | 198 +-
.../client/FlexClientManagerControlMBean.java | 140 +-
.../runtime/messaging/client/package-info.java | 32 +-
.../messaging/endpoints/AMFEndpointControl.java | 100 +-
.../endpoints/AMFEndpointControlMBean.java | 56 +-
.../messaging/endpoints/EndpointControl.java | 482 +-
.../endpoints/EndpointControlMBean.java | 226 +-
.../endpoints/HTTPEndpointControl.java | 100 +-
.../endpoints/HTTPEndpointControlMBean.java | 54 +-
.../endpoints/PollingEndpointControl.java | 144 +-
.../endpoints/PollingEndpointControlMBean.java | 90 +-
.../endpoints/StreamingAMFEndpointControl.java | 96 +-
.../StreamingAMFEndpointControlMBean.java | 52 +-
.../endpoints/StreamingEndpointControl.java | 266 +-
.../StreamingEndpointControlMBean.java | 152 +-
.../endpoints/StreamingHTTPEndpointControl.java | 96 +-
.../StreamingHTTPEndpointControlMBean.java | 52 +-
.../messaging/endpoints/package-info.java | 32 +-
.../runtime/messaging/log/LogControl.java | 298 +-
.../runtime/messaging/log/LogControlMBean.java | 160 +-
.../runtime/messaging/log/LogManager.java | 532 +--
.../runtime/messaging/log/package-info.java | 34 +-
.../runtime/messaging/package-info.java | 32 +-
.../services/MessageServiceControl.java | 102 +-
.../services/MessageServiceControlMBean.java | 56 +-
.../services/ServiceAdapterControl.java | 174 +-
.../services/ServiceAdapterControlMBean.java | 94 +-
.../messaging/services/ServiceControl.java | 290 +-
.../messaging/services/ServiceControlMBean.java | 118 +-
.../messaging/SubscriptionManagerControl.java | 258 +-
.../SubscriptionManagerControlMBean.java | 122 +-
.../messaging/ThrottleManagerControl.java | 608 +--
.../messaging/ThrottleManagerControlMBean.java | 358 +-
.../adapters/ActionScriptAdapterControl.java | 100 +-
.../ActionScriptAdapterControlMBean.java | 56 +-
.../messaging/adapters/JMSAdapterControl.java | 238 +-
.../adapters/JMSAdapterControlMBean.java | 170 +-
.../messaging/adapters/package-info.java | 32 +-
.../services/messaging/package-info.java | 34 +-
.../messaging/services/package-info.java | 34 +-
.../flex/management/runtime/package-info.java | 34 +-
.../AbstractConnectionAwareSession.java | 340 +-
.../messaging/AbstractFlexSessionProvider.java | 292 +-
.../flex/messaging/ConnectionAwareSession.java | 126 +-
.../core/src/flex/messaging/Destination.java | 1604 +++----
.../flex/messaging/DestructibleFlexFactory.java | 68 +-
.../src/flex/messaging/FactoryDestination.java | 722 +--
.../src/flex/messaging/FactoryInstance.java | 358 +-
.../core/src/flex/messaging/FlexComponent.java | 96 +-
.../src/flex/messaging/FlexConfigurable.java | 70 +-
.../core/src/flex/messaging/FlexContext.java | 946 ++--
.../core/src/flex/messaging/FlexFactory.java | 174 +-
.../flex/messaging/FlexRemoteCredentials.java | 186 +-
.../core/src/flex/messaging/FlexSession.java | 2124 ++++-----
.../messaging/FlexSessionAttributeListener.java | 94 +-
.../flex/messaging/FlexSessionBindingEvent.java | 228 +-
.../messaging/FlexSessionBindingListener.java | 80 +-
.../messaging/FlexSessionConnectivityEvent.java | 100 +-
.../FlexSessionConnectivityListener.java | 76 +-
.../src/flex/messaging/FlexSessionListener.java | 80 +-
.../src/flex/messaging/FlexSessionManager.java | 598 +--
.../src/flex/messaging/HttpFlexSession.java | 1332 +++---
.../flex/messaging/HttpFlexSessionProvider.java | 188 +-
.../core/src/flex/messaging/MessageBroker.java | 4474 ++++++++---------
.../flex/messaging/MessageBrokerServlet.java | 922 ++--
.../core/src/flex/messaging/MessageClient.java | 2288 ++++-----
.../flex/messaging/MessageClientListener.java | 80 +-
.../src/flex/messaging/MessageDestination.java | 982 ++--
.../src/flex/messaging/MessageException.java | 886 ++--
.../src/flex/messaging/MessageRoutedEvent.java | 108 +-
.../flex/messaging/MessageRoutedListener.java | 70 +-
.../flex/messaging/MessageRoutedNotifier.java | 240 +-
modules/core/src/flex/messaging/Server.java | 70 +-
.../messaging/ServiceValidationListener.java | 58 +-
.../core/src/flex/messaging/VersionInfo.java | 232 +-
.../flex/messaging/client/AsyncPollHandler.java | 62 +-
.../messaging/client/EndpointPushHandler.java | 158 +-
.../messaging/client/EndpointPushNotifier.java | 920 ++--
.../src/flex/messaging/client/FlexClient.java | 4480 +++++++++---------
.../client/FlexClientAttributeListener.java | 94 +-
.../client/FlexClientBindingEvent.java | 230 +-
.../client/FlexClientBindingListener.java | 78 +-
.../messaging/client/FlexClientListener.java | 80 +-
.../messaging/client/FlexClientManager.java | 1038 ++--
.../FlexClientNotSubscribedException.java | 146 +-
.../FlexClientOutboundQueueProcessor.java | 694 +--
.../src/flex/messaging/client/FlushResult.java | 234 +-
.../client/OutboundQueueThrottleManager.java | 536 +--
.../flex/messaging/client/PollFlushResult.java | 194 +-
.../flex/messaging/client/PollWaitListener.java | 80 +-
.../messaging/client/UserAgentSettings.java | 516 +-
.../src/flex/messaging/client/package-info.java | 34 +-
.../messaging/cluster/BroadcastHandler.java | 90 +-
.../src/flex/messaging/cluster/Cluster.java | 478 +-
.../messaging/cluster/ClusterException.java | 62 +-
.../flex/messaging/cluster/ClusterManager.java | 1344 +++---
.../cluster/ClusterMembershipListener.java | 274 +-
.../src/flex/messaging/cluster/ClusterNode.java | 344 +-
.../messaging/cluster/RemoveNodeListener.java | 70 +-
.../flex/messaging/cluster/package-info.java | 36 +-
.../ApacheXPathServerConfigurationParser.java | 178 +-
.../config/ClasspathResourceResolver.java | 52 +
.../messaging/config/ConfigurationManager.java | 80 +-
.../flex/messaging/config/FactorySettings.java | 164 +-
.../config/FlexConfigurationManager.java | 637 ++-
.../messaging/config/MessageFilterSettings.java | 198 +-
.../config/MessagingConfiguration.java | 2006 ++++----
.../flex/messaging/config/NetworkSettings.java | 330 +-
.../flex/messaging/config/SecuritySettings.java | 208 +-
.../config/ServerConfigurationParser.java | 3842 +++++++--------
.../flex/messaging/config/ServerSettings.java | 462 +-
.../config/ServletResourceResolver.java | 312 +-
.../messaging/config/SharedServerSettings.java | 130 +-
.../flex/messaging/config/SystemSettings.java | 600 +--
.../flex/messaging/config/ThrottleSettings.java | 746 +--
.../messaging/config/ValidatorSettings.java | 134 +-
.../config/XPathServerConfigurationParser.java | 188 +-
.../src/flex/messaging/config/package-info.java | 34 +-
.../flex/messaging/endpoints/AMFEndpoint.java | 304 +-
.../messaging/endpoints/AbstractEndpoint.java | 3016 ++++++------
.../messaging/endpoints/BaseHTTPEndpoint.java | 1270 ++---
.../endpoints/BasePollingHTTPEndpoint.java | 1206 ++---
.../endpoints/BaseStreamingHTTPEndpoint.java | 2452 +++++-----
.../endpoints/DuplicateSessionException.java | 162 +-
.../src/flex/messaging/endpoints/Endpoint.java | 380 +-
.../src/flex/messaging/endpoints/Endpoint2.java | 74 +-
.../flex/messaging/endpoints/HTTPEndpoint.java | 370 +-
.../messaging/endpoints/SecureAMFEndpoint.java | 128 +-
.../messaging/endpoints/SecureHTTPEndpoint.java | 128 +-
.../endpoints/SecureStreamingAMFEndpoint.java | 128 +-
.../endpoints/SecureStreamingHTTPEndpoint.java | 128 +-
.../endpoints/StreamingAMFEndpoint.java | 492 +-
.../endpoints/StreamingHTTPEndpoint.java | 476 +-
.../flex/messaging/endpoints/amf/AMFFilter.java | 106 +-
.../endpoints/amf/BatchProcessFilter.java | 146 +-
.../messaging/endpoints/amf/LegacyFilter.java | 678 +--
.../endpoints/amf/MessageBrokerFilter.java | 360 +-
.../endpoints/amf/SerializationFilter.java | 960 ++--
.../messaging/endpoints/amf/SessionFilter.java | 162 +-
.../messaging/endpoints/amf/package-info.java | 34 +-
.../flex/messaging/endpoints/package-info.java | 32 +-
.../flex/messaging/factories/JavaFactory.java | 596 +--
.../factories/JavaFactoryInstance.java | 292 +-
.../flex/messaging/factories/package-info.java | 34 +-
.../src/flex/messaging/io/AbstractProxy.java | 586 +--
.../src/flex/messaging/io/ArrayCollection.java | 330 +-
.../core/src/flex/messaging/io/ArrayList.java | 52 +-
.../core/src/flex/messaging/io/BeanProxy.java | 1880 ++++----
.../core/src/flex/messaging/io/ClassAlias.java | 58 +-
.../flex/messaging/io/ClassAliasRegistry.java | 196 +-
.../src/flex/messaging/io/DictionaryProxy.java | 224 +-
.../flex/messaging/io/ManagedObjectProxy.java | 148 +-
.../core/src/flex/messaging/io/MapProxy.java | 442 +-
.../flex/messaging/io/MessageDeserializer.java | 78 +-
.../flex/messaging/io/MessageIOConstants.java | 108 +-
.../flex/messaging/io/MessageSerializer.java | 78 +-
.../core/src/flex/messaging/io/ObjectProxy.java | 146 +-
.../src/flex/messaging/io/PageableRowSet.java | 186 +-
.../flex/messaging/io/PageableRowSetProxy.java | 314 +-
.../core/src/flex/messaging/io/PagedRowSet.java | 726 +--
.../src/flex/messaging/io/PropertyProxy.java | 564 +--
.../messaging/io/PropertyProxyRegistry.java | 672 +--
.../io/RecoverableSerializationException.java | 72 +-
.../flex/messaging/io/SerializationContext.java | 592 +--
.../messaging/io/SerializationDescriptor.java | 140 +-
.../messaging/io/SerializationException.java | 88 +-
.../flex/messaging/io/SerializationProxy.java | 230 +-
.../src/flex/messaging/io/StatusInfoProxy.java | 590 +--
.../src/flex/messaging/io/ThrowableProxy.java | 80 +-
.../src/flex/messaging/io/TypeMarshaller.java | 86 +-
.../messaging/io/TypeMarshallingContext.java | 482 +-
.../flex/messaging/io/UnknownTypeException.java | 60 +-
.../src/flex/messaging/io/amf/ASObject.java | 228 +-
.../flex/messaging/io/amf/AbstractAmfInput.java | 728 +--
.../messaging/io/amf/AbstractAmfOutput.java | 354 +-
.../flex/messaging/io/amf/ActionContext.java | 474 +-
.../flex/messaging/io/amf/ActionMessage.java | 214 +-
.../messaging/io/amf/ActionMessageInput.java | 210 +-
.../messaging/io/amf/ActionMessageOutput.java | 236 +-
.../src/flex/messaging/io/amf/Amf0Input.java | 1080 ++---
.../src/flex/messaging/io/amf/Amf0Output.java | 1748 +++----
.../src/flex/messaging/io/amf/Amf3Input.java | 2090 ++++----
.../src/flex/messaging/io/amf/Amf3Output.java | 2754 +++++------
.../src/flex/messaging/io/amf/Amf3Types.java | 132 +-
.../core/src/flex/messaging/io/amf/AmfIO.java | 340 +-
.../io/amf/AmfMessageDeserializer.java | 404 +-
.../messaging/io/amf/AmfMessageSerializer.java | 316 +-
.../src/flex/messaging/io/amf/AmfTrace.java | 1152 ++---
.../src/flex/messaging/io/amf/AmfTypes.java | 90 +-
.../src/flex/messaging/io/amf/MessageBody.java | 232 +-
.../flex/messaging/io/amf/MessageHeader.java | 152 +-
.../flex/messaging/io/amf/SerializedObject.java | 196 +-
.../src/flex/messaging/io/amf/TraitsInfo.java | 342 +-
.../messaging/io/amf/client/AMFConnection.java | 1852 ++++----
.../io/amf/client/AMFHeaderProcessor.java | 70 +-
.../exceptions/ClientStatusException.java | 254 +-
.../exceptions/ServerStatusException.java | 188 +-
.../io/amf/client/exceptions/package-info.java | 34 +-
.../messaging/io/amf/client/package-info.java | 34 +-
.../src/flex/messaging/io/amf/package-info.java | 34 +-
.../io/amf/translator/ASTranslator.java | 154 +-
.../io/amf/translator/TranslationException.java | 88 +-
.../translator/decoder/ActionScriptDecoder.java | 262 +-
.../io/amf/translator/decoder/ArrayDecoder.java | 340 +-
.../amf/translator/decoder/BooleanDecoder.java | 118 +-
.../amf/translator/decoder/CalendarDecoder.java | 138 +-
.../translator/decoder/CharacterDecoder.java | 130 +-
.../translator/decoder/CollectionDecoder.java | 326 +-
.../io/amf/translator/decoder/DateDecoder.java | 244 +-
.../amf/translator/decoder/DecoderFactory.java | 756 +--
.../io/amf/translator/decoder/EnumDecoder.java | 140 +-
.../io/amf/translator/decoder/MapDecoder.java | 202 +-
.../amf/translator/decoder/NativeDecoder.java | 60 +-
.../io/amf/translator/decoder/NullDecoder.java | 56 +-
.../amf/translator/decoder/NumberDecoder.java | 300 +-
.../decoder/ReferenceAwareArrayDecoder.java | 232 +-
.../decoder/ReferenceAwareCalendarDecoder.java | 88 +-
.../ReferenceAwareCollectionDecoder.java | 230 +-
.../decoder/ReferenceAwareDateDecoder.java | 92 +-
.../decoder/ReferenceAwareMapDecoder.java | 162 +-
.../ReferenceAwareTypedObjectDecoder.java | 210 +-
.../amf/translator/decoder/StringDecoder.java | 110 +-
.../translator/decoder/TypedObjectDecoder.java | 252 +-
.../io/amf/translator/decoder/package-info.java | 36 +-
.../io/amf/translator/package-info.java | 34 +-
.../src/flex/messaging/io/amfx/AmfxInput.java | 2776 +++++------
.../io/amfx/AmfxMessageDeserializer.java | 682 +--
.../io/amfx/AmfxMessageSerializer.java | 400 +-
.../src/flex/messaging/io/amfx/AmfxOutput.java | 2174 ++++-----
.../src/flex/messaging/io/amfx/AmfxTypes.java | 202 +-
.../flex/messaging/io/amfx/package-info.java | 34 +-
.../src/flex/messaging/io/package-info.java | 34 +-
.../src/flex/messaging/log/HTTPRequestLog.java | 560 +--
.../log/LoggingHttpServletRequestWrapper.java | 374 +-
.../flex/messaging/log/ServletLogTarget.java | 150 +-
.../src/flex/messaging/log/package-info.java | 34 +-
.../messaging/messages/AbstractMessage.java | 1442 +++---
.../messaging/messages/AcknowledgeMessage.java | 194 +-
.../messages/AcknowledgeMessageExt.java | 120 +-
.../flex/messaging/messages/AsyncMessage.java | 338 +-
.../messaging/messages/AsyncMessageExt.java | 116 +-
.../messaging/messages/BatchableMessage.java | 64 +-
.../flex/messaging/messages/CommandMessage.java | 802 ++--
.../messaging/messages/CommandMessageExt.java | 116 +-
.../flex/messaging/messages/ErrorMessage.java | 180 +-
.../flex/messaging/messages/HTTPMessage.java | 276 +-
.../src/flex/messaging/messages/Message.java | 474 +-
.../messages/MessagePerformanceInfo.java | 386 +-
.../messages/MessagePerformanceUtils.java | 830 ++--
.../src/flex/messaging/messages/RPCMessage.java | 164 +-
.../messaging/messages/RemotingMessage.java | 266 +-
.../flex/messaging/messages/SOAPMessage.java | 108 +-
.../flex/messaging/messages/SmallMessage.java | 74 +-
.../flex/messaging/messages/package-info.java | 34 +-
.../core/src/flex/messaging/package-info.java | 34 +-
.../security/AppServerLoginCommand.java | 196 +-
.../flex/messaging/security/LoginCommand.java | 156 +-
.../messaging/security/LoginCommandExt.java | 88 +-
.../flex/messaging/security/LoginManager.java | 808 ++--
.../messaging/security/MessagingSecurity.java | 102 +-
.../messaging/security/PrincipalConverter.java | 68 +-
.../messaging/security/SecurityException.java | 330 +-
.../flex/messaging/security/package-info.java | 32 +-
.../services/AbstractBootstrapService.java | 672 +--
.../messaging/services/AbstractService.java | 1510 +++---
.../messaging/services/AuthenticationEvent.java | 310 +-
.../services/AuthenticationListener.java | 74 +-
.../services/AuthenticationService.java | 536 +--
.../flex/messaging/services/MessageService.java | 2496 +++++-----
.../src/flex/messaging/services/Service.java | 436 +-
.../flex/messaging/services/ServiceAdapter.java | 628 +--
.../messaging/services/ServiceException.java | 170 +-
.../services/messaging/MessageFrequency.java | 218 +-
.../services/messaging/MessagingConstants.java | 118 +-
.../services/messaging/RemoteMessageClient.java | 136 +-
.../messaging/RemoteSubscriptionManager.java | 402 +-
.../services/messaging/SubscriptionManager.java | 1830 +++----
.../messaging/services/messaging/Subtopic.java | 620 +--
.../services/messaging/ThrottleManager.java | 1110 ++---
.../messaging/adapters/ActionScriptAdapter.java | 214 +-
.../adapters/AsyncMessageReceiver.java | 156 +-
.../services/messaging/adapters/JMSAdapter.java | 2228 ++++-----
.../messaging/adapters/JMSConfigConstants.java | 232 +-
.../messaging/adapters/JMSConsumer.java | 928 ++--
.../messaging/adapters/JMSExceptionEvent.java | 104 +-
.../adapters/JMSExceptionListener.java | 66 +-
.../messaging/adapters/JMSMessageEvent.java | 106 +-
.../messaging/adapters/JMSMessageListener.java | 66 +-
.../messaging/adapters/JMSProducer.java | 672 +--
.../services/messaging/adapters/JMSProxy.java | 788 +--
.../messaging/adapters/JMSQueueConsumer.java | 192 +-
.../messaging/adapters/JMSQueueProducer.java | 264 +-
.../messaging/adapters/JMSSettings.java | 1204 ++---
.../messaging/adapters/JMSTopicConsumer.java | 626 +--
.../messaging/adapters/JMSTopicProducer.java | 258 +-
.../messaging/adapters/MessageReceiver.java | 78 +-
.../messaging/adapters/MessagingAdapter.java | 458 +-
.../MessagingSecurityConstraintManager.java | 322 +-
.../messaging/adapters/SyncMessageReceiver.java | 402 +-
.../messaging/adapters/package-info.java | 32 +-
.../services/messaging/package-info.java | 32 +-
.../messaging/selector/JMSSelector.java | 238 +-
.../selector/JMSSelectorException.java | 70 +-
.../messaging/selector/package-info.java | 32 +-
.../flex/messaging/services/package-info.java | 32 +-
.../core/src/flex/messaging/util/Assert.java | 128 +-
.../messaging/util/AssertionFailedError.java | 70 +-
.../core/src/flex/messaging/util/Base64.java | 464 +-
.../core/src/flex/messaging/util/ClassUtil.java | 720 +--
modules/core/src/flex/messaging/util/Diag.jsl | 32 +-
.../src/flex/messaging/util/DoubleUtil.java | 62 +-
.../core/src/flex/messaging/util/DoubleUtil.jsl | 18 +-
modules/core/src/flex/messaging/util/Hex.java | 284 +-
.../core/src/flex/messaging/util/MethodKey.java | 160 +-
.../src/flex/messaging/util/MethodMatcher.java | 1030 ++--
.../flex/messaging/util/RedeployManager.java | 592 +--
.../messaging/util/SettingsReplaceUtil.java | 738 +--
.../messaging/util/TimeoutAbstractObject.java | 354 +-
.../src/flex/messaging/util/TimeoutCapable.java | 132 +-
.../src/flex/messaging/util/TimeoutManager.java | 464 +-
.../messaging/util/ToStringPrettyPrinter.java | 468 +-
modules/core/src/flex/messaging/util/Trace.java | 210 +-
.../src/flex/messaging/util/URLDecoder.java | 254 +-
.../src/flex/messaging/util/URLEncoder.java | 310 +-
.../src/flex/messaging/util/URLEncoderUtil.java | 84 +-
.../src/flex/messaging/util/URLEncoderUtil.jsl | 44 +-
.../src/flex/messaging/util/UUIDGenerator.java | 62 +-
.../flex/messaging/util/UserAgentManager.java | 414 +-
.../src/flex/messaging/util/WatchedObject.java | 144 +-
.../core/src/flex/messaging/util/XMLUtil.java | 280 +-
.../concurrent/DefaultThreadPoolExecutor.java | 320 +-
.../messaging/util/concurrent/Executor.java | 118 +-
.../util/concurrent/FailedExecutionHandler.java | 74 +-
.../messaging/util/concurrent/package-info.java | 34 +-
.../src/flex/messaging/util/package-info.java | 34 +-
.../ClassDeserializationValidator.java | 672 +--
.../validators/DeserializationValidator.java | 112 +-
.../flex/messaging/validators/package-info.java | 34 +-
modules/core/test/src/amf_request.xml | 92 -
.../test/src/amfclient/ClientCustomType.java | 45 -
.../src/flex/messaging/DestinationTest.java | 335 --
.../src/flex/messaging/MessageBrokerTest.java | 351 --
.../messaging/client/FlexClientManagerTest.java | 125 -
.../cluster/SerializationProxyTest.java | 64 -
.../config/ChannelSettingsParseUriTest.java | 197 -
.../config/ConfigurationConfirmation.java | 544 ---
.../config/ConfigurationParserTest.java | 200 -
.../messaging/config/ThrottleSettingsTest.java | 182 -
.../src/flex/messaging/config/services/1a.xml | 37 -
.../src/flex/messaging/config/services/1b.xml | 63 -
.../src/flex/messaging/config/services/1c.xml | 61 -
.../src/flex/messaging/config/services/1d.xml | 93 -
.../src/flex/messaging/config/services/1e.xml | 50 -
.../config/services/1e_adapter_include.xml | 27 -
.../config/services/1e_channel_include.xml | 29 -
.../config/services/1e_constraint_include.xml | 32 -
.../config/services/1e_destination_include.xml | 26 -
.../src/flex/messaging/config/services/1f.xml | 34 -
.../config/services/1f_service_include.xml | 40 -
.../src/flex/messaging/config/services/1g.xml | 26 -
.../src/flex/messaging/config/services/1h.xml | 52 -
.../src/flex/messaging/config/services/1i.xml | 55 -
.../src/flex/messaging/config/services/1j.xml | 40 -
.../messaging/config/services/Confirm1a.java | 54 -
.../messaging/config/services/Confirm1b.java | 87 -
.../messaging/config/services/Confirm1c.java | 99 -
.../messaging/config/services/Confirm1d.java | 112 -
.../messaging/config/services/Confirm1e.java | 41 -
.../messaging/config/services/Confirm1f.java | 39 -
.../messaging/config/services/Confirm1g.java | 46 -
.../messaging/config/services/Confirm1h.java | 46 -
.../messaging/config/services/Confirm1i.java | 41 -
.../messaging/config/services/Confirm1j.java | 39 -
.../services/adapters/1i_adapter_include.xml | 25 -
.../services/channels/1i_channel_include.xml | 27 -
.../constraints/1i_constraint_include.xml | 30 -
.../destinations/1i_destination_include.xml | 29 -
.../services/services/1i_service_include.xml | 42 -
.../messaging/io/amf/AmfDeserializerTest.java | 154 -
.../flex/messaging/io/amf/MessageGenerator.java | 393 --
.../io/amf/client/AMFConnectionTest.java | 758 ---
.../io/amf/client/AMFDataTypeTest.java | 461 --
.../amf/translator/HashReferenceTableTest.java | 280 --
.../translator/StrictReferenceTableTest.java | 152 -
.../AmfDeserializationValidatorTest.java | 165 -
.../io/amfx/AmfxSerializationTest.java | 304 --
.../io/amfx/DeserializationConfirmation.java | 522 --
.../test/src/flex/messaging/io/amfx/amfx.xsd | 139 -
.../src/flex/messaging/io/amfx/amfx_tag/1a.xml | 20 -
.../src/flex/messaging/io/amfx/amfx_tag/1b.xml | 27 -
.../src/flex/messaging/io/amfx/amfx_tag/1c.xml | 24 -
.../messaging/io/amfx/amfx_tag/Confirm1a.java | 42 -
.../messaging/io/amfx/amfx_tag/Confirm1b.java | 54 -
.../messaging/io/amfx/amfx_tag/Confirm1c.java | 43 -
.../src/flex/messaging/io/amfx/array_tag/2a.xml | 30 -
.../src/flex/messaging/io/amfx/array_tag/2b.xml | 39 -
.../src/flex/messaging/io/amfx/array_tag/2c.xml | 33 -
.../src/flex/messaging/io/amfx/array_tag/2d.xml | 43 -
.../src/flex/messaging/io/amfx/array_tag/2e.xml | 26 -
.../src/flex/messaging/io/amfx/array_tag/2f.xml | 40 -
.../src/flex/messaging/io/amfx/array_tag/2g.xml | 28 -
.../src/flex/messaging/io/amfx/array_tag/2h.xml | 29 -
.../src/flex/messaging/io/amfx/array_tag/2i.xml | 42 -
.../src/flex/messaging/io/amfx/array_tag/2j.xml | 24 -
.../src/flex/messaging/io/amfx/array_tag/2k.xml | 28 -
.../src/flex/messaging/io/amfx/array_tag/2l.xml | 28 -
.../messaging/io/amfx/array_tag/Confirm2a.java | 59 -
.../messaging/io/amfx/array_tag/Confirm2b.java | 67 -
.../messaging/io/amfx/array_tag/Confirm2c.java | 62 -
.../messaging/io/amfx/array_tag/Confirm2d.java | 65 -
.../messaging/io/amfx/array_tag/Confirm2e.java | 76 -
.../messaging/io/amfx/array_tag/Confirm2f.java | 96 -
.../messaging/io/amfx/array_tag/Confirm2g.java | 53 -
.../messaging/io/amfx/array_tag/Confirm2h.java | 54 -
.../messaging/io/amfx/array_tag/Confirm2i.java | 74 -
.../messaging/io/amfx/array_tag/Confirm2j.java | 43 -
.../messaging/io/amfx/array_tag/Confirm2k.java | 43 -
.../messaging/io/amfx/array_tag/Confirm2l.java | 44 -
.../src/flex/messaging/io/amfx/body_tag/3a.xml | 22 -
.../src/flex/messaging/io/amfx/body_tag/3b.xml | 24 -
.../src/flex/messaging/io/amfx/body_tag/3c.xml | 44 -
.../src/flex/messaging/io/amfx/body_tag/3d.xml | 25 -
.../messaging/io/amfx/body_tag/Confirm3a.java | 45 -
.../messaging/io/amfx/body_tag/Confirm3b.java | 46 -
.../messaging/io/amfx/body_tag/Confirm3c.java | 66 -
.../messaging/io/amfx/body_tag/Confirm3d.java | 43 -
.../flex/messaging/io/amfx/bytes_tag/16a.xml | 24 -
.../messaging/io/amfx/bytes_tag/Confirm16a.java | 53 -
.../src/flex/messaging/io/amfx/date_tag/4a.xml | 24 -
.../src/flex/messaging/io/amfx/date_tag/4b.xml | 31 -
.../src/flex/messaging/io/amfx/date_tag/4c.xml | 28 -
.../src/flex/messaging/io/amfx/date_tag/4d.xml | 71 -
.../src/flex/messaging/io/amfx/date_tag/4e.xml | 28 -
.../src/flex/messaging/io/amfx/date_tag/4f.xml | 24 -
.../src/flex/messaging/io/amfx/date_tag/4g.xml | 24 -
.../messaging/io/amfx/date_tag/Confirm4a.java | 48 -
.../messaging/io/amfx/date_tag/Confirm4b.java | 54 -
.../messaging/io/amfx/date_tag/Confirm4c.java | 57 -
.../messaging/io/amfx/date_tag/Confirm4d.java | 57 -
.../messaging/io/amfx/date_tag/Confirm4e.java | 84 -
.../messaging/io/amfx/date_tag/Confirm4f.java | 48 -
.../messaging/io/amfx/date_tag/Confirm4g.java | 43 -
.../flex/messaging/io/amfx/double_tag/5a.xml | 24 -
.../flex/messaging/io/amfx/double_tag/5b.xml | 70 -
.../flex/messaging/io/amfx/double_tag/5c.xml | 37 -
.../flex/messaging/io/amfx/double_tag/5d.xml | 71 -
.../flex/messaging/io/amfx/double_tag/5e.xml | 24 -
.../flex/messaging/io/amfx/double_tag/5f.xml | 24 -
.../flex/messaging/io/amfx/double_tag/5g.xml | 24 -
.../flex/messaging/io/amfx/double_tag/5h.xml | 24 -
.../messaging/io/amfx/double_tag/Confirm5a.java | 46 -
.../messaging/io/amfx/double_tag/Confirm5b.java | 61 -
.../messaging/io/amfx/double_tag/Confirm5c.java | 55 -
.../messaging/io/amfx/double_tag/Confirm5d.java | 60 -
.../messaging/io/amfx/double_tag/Confirm5e.java | 43 -
.../messaging/io/amfx/double_tag/Confirm5f.java | 43 -
.../messaging/io/amfx/double_tag/Confirm5g.java | 43 -
.../messaging/io/amfx/double_tag/Confirm5h.java | 43 -
.../src/flex/messaging/io/amfx/false_tag/6a.xml | 24 -
.../src/flex/messaging/io/amfx/false_tag/6b.xml | 31 -
.../src/flex/messaging/io/amfx/false_tag/6c.xml | 28 -
.../src/flex/messaging/io/amfx/false_tag/6d.xml | 36 -
.../messaging/io/amfx/false_tag/Confirm6a.java | 46 -
.../messaging/io/amfx/false_tag/Confirm6b.java | 52 -
.../messaging/io/amfx/false_tag/Confirm6c.java | 55 -
.../messaging/io/amfx/false_tag/Confirm6d.java | 56 -
.../flex/messaging/io/amfx/header_tag/7a.xml | 22 -
.../flex/messaging/io/amfx/header_tag/7b.xml | 24 -
.../flex/messaging/io/amfx/header_tag/7c.xml | 41 -
.../flex/messaging/io/amfx/header_tag/7d.xml | 25 -
.../messaging/io/amfx/header_tag/Confirm7a.java | 46 -
.../messaging/io/amfx/header_tag/Confirm7b.java | 48 -
.../messaging/io/amfx/header_tag/Confirm7c.java | 72 -
.../messaging/io/amfx/header_tag/Confirm7d.java | 43 -
.../src/flex/messaging/io/amfx/int_tag/8a.xml | 24 -
.../src/flex/messaging/io/amfx/int_tag/8b.xml | 38 -
.../src/flex/messaging/io/amfx/int_tag/8c.xml | 37 -
.../src/flex/messaging/io/amfx/int_tag/8d.xml | 71 -
.../src/flex/messaging/io/amfx/int_tag/8e.xml | 24 -
.../src/flex/messaging/io/amfx/int_tag/8f.xml | 24 -
.../src/flex/messaging/io/amfx/int_tag/8g.xml | 24 -
.../messaging/io/amfx/int_tag/Confirm8a.java | 46 -
.../messaging/io/amfx/int_tag/Confirm8b.java | 53 -
.../messaging/io/amfx/int_tag/Confirm8c.java | 55 -
.../messaging/io/amfx/int_tag/Confirm8d.java | 60 -
.../messaging/io/amfx/int_tag/Confirm8e.java | 43 -
.../messaging/io/amfx/int_tag/Confirm8f.java | 43 -
.../messaging/io/amfx/int_tag/Confirm8g.java | 43 -
.../src/flex/messaging/io/amfx/null_tag/9a.xml | 24 -
.../src/flex/messaging/io/amfx/null_tag/9b.xml | 31 -
.../src/flex/messaging/io/amfx/null_tag/9c.xml | 28 -
.../src/flex/messaging/io/amfx/null_tag/9d.xml | 36 -
.../messaging/io/amfx/null_tag/Confirm9a.java | 46 -
.../messaging/io/amfx/null_tag/Confirm9b.java | 52 -
.../messaging/io/amfx/null_tag/Confirm9c.java | 55 -
.../messaging/io/amfx/null_tag/Confirm9d.java | 56 -
.../flex/messaging/io/amfx/object_tag/10a.xml | 41 -
.../flex/messaging/io/amfx/object_tag/10b.xml | 56 -
.../flex/messaging/io/amfx/object_tag/10c.xml | 49 -
.../flex/messaging/io/amfx/object_tag/10d.xml | 38 -
.../io/amfx/object_tag/Confirm10a.java | 57 -
.../io/amfx/object_tag/Confirm10b.java | 74 -
.../io/amfx/object_tag/Confirm10c.java | 101 -
.../io/amfx/object_tag/Confirm10d.java | 93 -
.../flex/messaging/io/amfx/string_tag/11a.xml | 24 -
.../flex/messaging/io/amfx/string_tag/11b.xml | 31 -
.../flex/messaging/io/amfx/string_tag/11c.xml | 28 -
.../flex/messaging/io/amfx/string_tag/11d.xml | 71 -
.../flex/messaging/io/amfx/string_tag/11e.xml | 28 -
.../flex/messaging/io/amfx/string_tag/11f.xml | 30 -
.../flex/messaging/io/amfx/string_tag/11g.xml | 28 -
.../flex/messaging/io/amfx/string_tag/11h.xml | 31 -
.../flex/messaging/io/amfx/string_tag/11i.xml | 24 -
.../flex/messaging/io/amfx/string_tag/11j.xml | 24 -
.../io/amfx/string_tag/Confirm11a.java | 46 -
.../io/amfx/string_tag/Confirm11b.java | 52 -
.../io/amfx/string_tag/Confirm11c.java | 55 -
.../io/amfx/string_tag/Confirm11d.java | 60 -
.../io/amfx/string_tag/Confirm11e.java | 82 -
.../io/amfx/string_tag/Confirm11f.java | 94 -
.../io/amfx/string_tag/Confirm11g.java | 55 -
.../io/amfx/string_tag/Confirm11h.java | 43 -
.../io/amfx/string_tag/Confirm11i.java | 46 -
.../io/amfx/string_tag/Confirm11j.java | 46 -
.../io/amfx/testtypes/Bleu_dAuvergne.java | 51 -
.../messaging/io/amfx/testtypes/Cheese.java | 33 -
.../messaging/io/amfx/testtypes/CowCheese.java | 34 -
.../messaging/io/amfx/testtypes/EweCheese.java | 33 -
.../messaging/io/amfx/testtypes/Roquefort.java | 50 -
.../flex/messaging/io/amfx/traits_tag/12a.xml | 35 -
.../flex/messaging/io/amfx/traits_tag/12b.xml | 47 -
.../io/amfx/traits_tag/Confirm12a.java | 55 -
.../io/amfx/traits_tag/Confirm12b.java | 71 -
.../src/flex/messaging/io/amfx/true_tag/13a.xml | 24 -
.../src/flex/messaging/io/amfx/true_tag/13b.xml | 31 -
.../src/flex/messaging/io/amfx/true_tag/13c.xml | 28 -
.../src/flex/messaging/io/amfx/true_tag/13d.xml | 36 -
.../messaging/io/amfx/true_tag/Confirm13a.java | 46 -
.../messaging/io/amfx/true_tag/Confirm13b.java | 52 -
.../messaging/io/amfx/true_tag/Confirm13c.java | 55 -
.../messaging/io/amfx/true_tag/Confirm13d.java | 56 -
.../messaging/io/amfx/undefined_tag/14a.xml | 24 -
.../messaging/io/amfx/undefined_tag/14b.xml | 31 -
.../messaging/io/amfx/undefined_tag/14c.xml | 28 -
.../messaging/io/amfx/undefined_tag/14d.xml | 36 -
.../io/amfx/undefined_tag/Confirm14a.java | 46 -
.../io/amfx/undefined_tag/Confirm14b.java | 52 -
.../io/amfx/undefined_tag/Confirm14c.java | 55 -
.../io/amfx/undefined_tag/Confirm14d.java | 56 -
.../src/flex/messaging/io/amfx/xml_tag/15a.xml | 30 -
.../src/flex/messaging/io/amfx/xml_tag/15b.xml | 30 -
.../messaging/io/amfx/xml_tag/Confirm15a.java | 65 -
.../messaging/io/amfx/xml_tag/Confirm15b.java | 64 -
.../test/src/flex/messaging/log/LogTest.java | 165 -
.../test/src/flex/messaging/log/LoggerTest.java | 165 -
.../src/flex/messaging/log/TestingTarget.java | 47 -
.../messaging/services/AbstractServiceTest.java | 367 --
.../messaging/services/ServiceAdapterTest.java | 120 -
.../services/http/SettingsReplaceUtilTest.java | 229 -
.../services/messaging/SubtopicTest.java | 119 -
.../src/flex/messaging/util/Basae64Test.java | 80 -
.../test/src/flex/messaging/util/HexTest.java | 88 -
.../src/flex/messaging/util/UUIDUtilTest.java | 162 -
.../DefaultThreadPoolExecutorTest.java | 167 -
.../macromedia/qa/metrics/AbstractDatabase.java | 545 ---
.../test/src/macromedia/qa/metrics/Build.java | 120 -
.../test/src/macromedia/qa/metrics/Metric.java | 128 -
.../macromedia/qa/metrics/MetricsDatabase.java | 237 -
.../macromedia/qa/metrics/MetricsManager.java | 166 -
.../src/macromedia/qa/metrics/Persistable.java | 178 -
.../test/src/macromedia/qa/metrics/Project.java | 119 -
.../test/src/macromedia/qa/metrics/Run.java | 143 -
.../test/src/macromedia/qa/metrics/Value.java | 134 -
.../test/src/macromedia/util/UnitTrace.java | 29 -
.../src/regression/DoNotDeleteUntilFile.txt | 0
modules/opt/build.xml | 65 +-
modules/opt/pom.xml | 6 +-
modules/opt/poms/jrun/pom.xml | 2 +-
modules/opt/poms/oracle/pom.xml | 4 +-
modules/opt/poms/tomcat4/pom.xml | 2 +-
modules/opt/poms/tomcat6/pom.xml | 2 +-
modules/opt/poms/tomcat7/pom.xml | 2 +-
modules/opt/poms/weblogic/pom.xml | 2 +-
modules/opt/poms/websphere/pom.xml | 2 +-
modules/pom.xml | 5 +-
modules/proxy/build.xml | 21 +-
modules/proxy/pom.xml | 2 +-
modules/remoting/build.xml | 23 +-
modules/remoting/pom.xml | 2 +-
modules/sdk/build.xml | 147 +-
modules/testsuite/pom.xml | 85 +
.../test/java/amfclient/ClientCustomType.java | 45 +
.../java/flex/messaging/DestinationTest.java | 335 ++
.../java/flex/messaging/MessageBrokerTest.java | 351 ++
.../messaging/client/FlexClientManagerTest.java | 125 +
.../cluster/SerializationProxyTest.java | 64 +
.../config/ChannelSettingsParseUriTest.java | 197 +
.../config/ConfigurationConfirmation.java | 544 +++
.../config/ConfigurationParserTest.java | 200 +
.../messaging/config/ThrottleSettingsTest.java | 182 +
.../java/flex/messaging/config/services/1a.xml | 37 +
.../java/flex/messaging/config/services/1b.xml | 63 +
.../java/flex/messaging/config/services/1c.xml | 61 +
.../java/flex/messaging/config/services/1d.xml | 93 +
.../java/flex/messaging/config/services/1e.xml | 50 +
.../config/services/1e_adapter_include.xml | 27 +
.../config/services/1e_channel_include.xml | 29 +
.../config/services/1e_constraint_include.xml | 32 +
.../config/services/1e_destination_include.xml | 26 +
.../java/flex/messaging/config/services/1f.xml | 34 +
.../config/services/1f_service_include.xml | 40 +
.../java/flex/messaging/config/services/1g.xml | 26 +
.../java/flex/messaging/config/services/1h.xml | 52 +
.../java/flex/messaging/config/services/1i.xml | 55 +
.../java/flex/messaging/config/services/1j.xml | 40 +
.../messaging/config/services/Confirm1a.java | 54 +
.../messaging/config/services/Confirm1b.java | 87 +
.../messaging/config/services/Confirm1c.java | 99 +
.../messaging/config/services/Confirm1d.java | 112 +
.../messaging/config/services/Confirm1e.java | 41 +
.../messaging/config/services/Confirm1f.java | 39 +
.../messaging/config/services/Confirm1g.java | 46 +
.../messaging/config/services/Confirm1h.java | 46 +
.../messaging/config/services/Confirm1i.java | 41 +
.../messaging/config/services/Confirm1j.java | 39 +
.../services/adapters/1i_adapter_include.xml | 25 +
.../services/channels/1i_channel_include.xml | 27 +
.../constraints/1i_constraint_include.xml | 30 +
.../destinations/1i_destination_include.xml | 29 +
.../services/services/1i_service_include.xml | 42 +
.../messaging/io/amf/AmfDeserializerTest.java | 154 +
.../flex/messaging/io/amf/MessageGenerator.java | 393 ++
.../io/amf/client/AMFConnectionTest.java | 779 +++
.../io/amf/client/AMFDataTypeTest.java | 478 ++
.../amf/translator/HashReferenceTableTest.java | 281 ++
.../translator/StrictReferenceTableTest.java | 153 +
.../AmfDeserializationValidatorTest.java | 165 +
.../io/amfx/AmfxSerializationTest.java | 304 ++
.../io/amfx/DeserializationConfirmation.java | 522 ++
.../messaging/io/amfx/amfx_tag/Confirm1a.java | 42 +
.../messaging/io/amfx/amfx_tag/Confirm1b.java | 54 +
.../messaging/io/amfx/amfx_tag/Confirm1c.java | 43 +
.../messaging/io/amfx/array_tag/Confirm2a.java | 59 +
.../messaging/io/amfx/array_tag/Confirm2b.java | 67 +
.../messaging/io/amfx/array_tag/Confirm2c.java | 62 +
.../messaging/io/amfx/array_tag/Confirm2d.java | 65 +
.../messaging/io/amfx/array_tag/Confirm2e.java | 76 +
.../messaging/io/amfx/array_tag/Confirm2f.java | 96 +
.../messaging/io/amfx/array_tag/Confirm2g.java | 53 +
.../messaging/io/amfx/array_tag/Confirm2h.java | 54 +
.../messaging/io/amfx/array_tag/Confirm2i.java | 74 +
.../messaging/io/amfx/array_tag/Confirm2j.java | 43 +
.../messaging/io/amfx/array_tag/Confirm2k.java | 43 +
.../messaging/io/amfx/array_tag/Confirm2l.java | 44 +
.../messaging/io/amfx/body_tag/Confirm3a.java | 45 +
.../messaging/io/amfx/body_tag/Confirm3b.java | 46 +
.../messaging/io/amfx/body_tag/Confirm3c.java | 66 +
.../messaging/io/amfx/body_tag/Confirm3d.java | 43 +
.../messaging/io/amfx/bytes_tag/Confirm16a.java | 53 +
.../messaging/io/amfx/date_tag/Confirm4a.java | 48 +
.../messaging/io/amfx/date_tag/Confirm4b.java | 54 +
.../messaging/io/amfx/date_tag/Confirm4c.java | 57 +
.../messaging/io/amfx/date_tag/Confirm4d.java | 57 +
.../messaging/io/amfx/date_tag/Confirm4e.java | 84 +
.../messaging/io/amfx/date_tag/Confirm4f.java | 48 +
.../messaging/io/amfx/date_tag/Confirm4g.java | 43 +
.../messaging/io/amfx/double_tag/Confirm5a.java | 46 +
.../messaging/io/amfx/double_tag/Confirm5b.java | 61 +
.../messaging/io/amfx/double_tag/Confirm5c.java | 55 +
.../messaging/io/amfx/double_tag/Confirm5d.java | 60 +
.../messaging/io/amfx/double_tag/Confirm5e.java | 43 +
.../messaging/io/amfx/double_tag/Confirm5f.java | 43 +
.../messaging/io/amfx/double_tag/Confirm5g.java | 43 +
.../messaging/io/amfx/double_tag/Confirm5h.java | 43 +
.../messaging/io/amfx/false_tag/Confirm6a.java | 46 +
.../messaging/io/amfx/false_tag/Confirm6b.java | 52 +
.../messaging/io/amfx/false_tag/Confirm6c.java | 55 +
.../messaging/io/amfx/false_tag/Confirm6d.java | 56 +
.../messaging/io/amfx/header_tag/Confirm7a.java | 46 +
.../messaging/io/amfx/header_tag/Confirm7b.java | 48 +
.../messaging/io/amfx/header_tag/Confirm7c.java | 72 +
.../messaging/io/amfx/header_tag/Confirm7d.java | 43 +
.../messaging/io/amfx/int_tag/Confirm8a.java | 46 +
.../messaging/io/amfx/int_tag/Confirm8b.java | 53 +
.../messaging/io/amfx/int_tag/Confirm8c.java | 55 +
.../messaging/io/amfx/int_tag/Confirm8d.java | 60 +
.../messaging/io/amfx/int_tag/Confirm8e.java | 43 +
.../messaging/io/amfx/int_tag/Confirm8f.java | 43 +
.../messaging/io/amfx/int_tag/Confirm8g.java | 43 +
.../messaging/io/amfx/null_tag/Confirm9a.java | 46 +
.../messaging/io/amfx/null_tag/Confirm9b.java | 52 +
.../messaging/io/amfx/null_tag/Confirm9c.java | 55 +
.../messaging/io/amfx/null_tag/Confirm9d.java | 56 +
.../io/amfx/object_tag/Confirm10a.java | 57 +
.../io/amfx/object_tag/Confirm10b.java | 74 +
.../io/amfx/object_tag/Confirm10c.java | 101 +
.../io/amfx/object_tag/Confirm10d.java | 93 +
.../io/amfx/string_tag/Confirm11a.java | 46 +
.../io/amfx/string_tag/Confirm11b.java | 52 +
.../io/amfx/string_tag/Confirm11c.java | 55 +
.../io/amfx/string_tag/Confirm11d.java | 60 +
.../io/amfx/string_tag/Confirm11e.java | 82 +
.../io/amfx/string_tag/Confirm11f.java | 94 +
.../io/amfx/string_tag/Confirm11g.java | 55 +
.../io/amfx/string_tag/Confirm11h.java | 43 +
.../io/amfx/string_tag/Confirm11i.java | 46 +
.../io/amfx/string_tag/Confirm11j.java | 46 +
.../io/amfx/testtypes/Bleu_dAuvergne.java | 51 +
.../messaging/io/amfx/testtypes/Cheese.java | 33 +
.../messaging/io/amfx/testtypes/CowCheese.java | 34 +
.../messaging/io/amfx/testtypes/EweCheese.java | 33 +
.../messaging/io/amfx/testtypes/Roquefort.java | 50 +
.../io/amfx/traits_tag/Confirm12a.java | 55 +
.../io/amfx/traits_tag/Confirm12b.java | 71 +
.../messaging/io/amfx/true_tag/Confirm13a.java | 46 +
.../messaging/io/amfx/true_tag/Confirm13b.java | 52 +
.../messaging/io/amfx/true_tag/Confirm13c.java | 55 +
.../messaging/io/amfx/true_tag/Confirm13d.java | 56 +
.../io/amfx/undefined_tag/Confirm14a.java | 46 +
.../io/amfx/undefined_tag/Confirm14b.java | 52 +
.../io/amfx/undefined_tag/Confirm14c.java | 55 +
.../io/amfx/undefined_tag/Confirm14d.java | 56 +
.../messaging/io/amfx/xml_tag/Confirm15a.java | 65 +
.../messaging/io/amfx/xml_tag/Confirm15b.java | 64 +
.../test/java/flex/messaging/log/LogTest.java | 178 +
.../java/flex/messaging/log/LoggerTest.java | 165 +
.../java/flex/messaging/log/TestingTarget.java | 47 +
.../messaging/services/AbstractServiceTest.java | 367 ++
.../messaging/services/ServiceAdapterTest.java | 120 +
.../services/http/SettingsReplaceUtilTest.java | 229 +
.../services/messaging/SubtopicTest.java | 119 +
.../java/flex/messaging/util/Basae64Test.java | 80 +
.../test/java/flex/messaging/util/HexTest.java | 88 +
.../java/flex/messaging/util/TestServer.java | 96 +
.../java/flex/messaging/util/UUIDUtilTest.java | 162 +
.../DefaultThreadPoolExecutorTest.java | 167 +
.../macromedia/qa/metrics/AbstractDatabase.java | 545 +++
.../test/java/macromedia/qa/metrics/Build.java | 120 +
.../test/java/macromedia/qa/metrics/Metric.java | 128 +
.../macromedia/qa/metrics/MetricsDatabase.java | 237 +
.../macromedia/qa/metrics/MetricsManager.java | 166 +
.../java/macromedia/qa/metrics/Persistable.java | 178 +
.../java/macromedia/qa/metrics/Project.java | 119 +
.../test/java/macromedia/qa/metrics/Run.java | 143 +
.../test/java/macromedia/qa/metrics/Value.java | 134 +
.../test/java/macromedia/util/UnitTrace.java | 29 +
.../java/regression/DoNotDeleteUntilFile.txt | 0
.../amfclient/AMFConnectionTestService.java | 122 +
.../remoting/amfclient/ServerCustomType.java | 45 +
.../resources/WEB-INF/flex/remoting-config.xml | 58 +
.../resources/WEB-INF/flex/services-config.xml | 49 +
.../src/test/resources/amf_request.xml | 92 +
.../resources/flex/messaging/io/amfx/amfx.xsd | 139 +
.../flex/messaging/io/amfx/amfx_tag/1a.xml | 20 +
.../flex/messaging/io/amfx/amfx_tag/1b.xml | 27 +
.../flex/messaging/io/amfx/amfx_tag/1c.xml | 24 +
.../flex/messaging/io/amfx/array_tag/2a.xml | 30 +
.../flex/messaging/io/amfx/array_tag/2b.xml | 39 +
.../flex/messaging/io/amfx/array_tag/2c.xml | 33 +
.../flex/messaging/io/amfx/array_tag/2d.xml | 43 +
.../flex/messaging/io/amfx/array_tag/2e.xml | 26 +
.../flex/messaging/io/amfx/array_tag/2f.xml | 40 +
.../flex/messaging/io/amfx/array_tag/2g.xml | 28 +
.../flex/messaging/io/amfx/array_tag/2h.xml | 29 +
.../flex/messaging/io/amfx/array_tag/2i.xml | 42 +
.../flex/messaging/io/amfx/array_tag/2j.xml | 24 +
.../flex/messaging/io/amfx/array_tag/2k.xml | 28 +
.../flex/messaging/io/amfx/array_tag/2l.xml | 28 +
.../flex/messaging/io/amfx/body_tag/3a.xml | 22 +
.../flex/messaging/io/amfx/body_tag/3b.xml | 24 +
.../flex/messaging/io/amfx/body_tag/3c.xml | 44 +
.../flex/messaging/io/amfx/body_tag/3d.xml | 25 +
.../flex/messaging/io/amfx/bytes_tag/16a.xml | 24 +
.../flex/messaging/io/amfx/date_tag/4a.xml | 24 +
.../flex/messaging/io/amfx/date_tag/4b.xml | 31 +
.../flex/messaging/io/amfx/date_tag/4c.xml | 28 +
.../flex/messaging/io/amfx/date_tag/4d.xml | 71 +
.../flex/messaging/io/amfx/date_tag/4e.xml | 28 +
.../flex/messaging/io/amfx/date_tag/4f.xml | 24 +
.../flex/messaging/io/amfx/date_tag/4g.xml | 24 +
.../flex/messaging/io/amfx/double_tag/5a.xml | 24 +
.../flex/messaging/io/amfx/double_tag/5b.xml | 70 +
.../flex/messaging/io/amfx/double_tag/5c.xml | 37 +
.../flex/messaging/io/amfx/double_tag/5d.xml | 71 +
.../flex/messaging/io/amfx/double_tag/5e.xml | 24 +
.../flex/messaging/io/amfx/double_tag/5f.xml | 24 +
.../flex/messaging/io/amfx/double_tag/5g.xml | 24 +
.../flex/messaging/io/amfx/double_tag/5h.xml | 24 +
.../flex/messaging/io/amfx/false_tag/6a.xml | 24 +
.../flex/messaging/io/amfx/false_tag/6b.xml | 31 +
.../flex/messaging/io/amfx/false_tag/6c.xml | 28 +
.../flex/messaging/io/amfx/false_tag/6d.xml | 36 +
.../flex/messaging/io/amfx/header_tag/7a.xml | 22 +
.../flex/messaging/io/amfx/header_tag/7b.xml | 24 +
.../flex/messaging/io/amfx/header_tag/7c.xml | 41 +
.../flex/messaging/io/amfx/header_tag/7d.xml | 25 +
.../flex/messaging/io/amfx/int_tag/8a.xml | 24 +
.../flex/messaging/io/amfx/int_tag/8b.xml | 38 +
.../flex/messaging/io/amfx/int_tag/8c.xml | 37 +
.../flex/messaging/io/amfx/int_tag/8d.xml | 71 +
.../flex/messaging/io/amfx/int_tag/8e.xml | 24 +
.../flex/messaging/io/amfx/int_tag/8f.xml | 24 +
.../flex/messaging/io/amfx/int_tag/8g.xml | 24 +
.../flex/messaging/io/amfx/null_tag/9a.xml | 24 +
.../flex/messaging/io/amfx/null_tag/9b.xml | 31 +
.../flex/messaging/io/amfx/null_tag/9c.xml | 28 +
.../flex/messaging/io/amfx/null_tag/9d.xml | 36 +
.../flex/messaging/io/amfx/object_tag/10a.xml | 41 +
.../flex/messaging/io/amfx/object_tag/10b.xml | 56 +
.../flex/messaging/io/amfx/object_tag/10c.xml | 49 +
.../flex/messaging/io/amfx/object_tag/10d.xml | 38 +
.../flex/messaging/io/amfx/string_tag/11a.xml | 24 +
.../flex/messaging/io/amfx/string_tag/11b.xml | 31 +
.../flex/messaging/io/amfx/string_tag/11c.xml | 28 +
.../flex/messaging/io/amfx/string_tag/11d.xml | 71 +
.../flex/messaging/io/amfx/string_tag/11e.xml | 28 +
.../flex/messaging/io/amfx/string_tag/11f.xml | 30 +
.../flex/messaging/io/amfx/string_tag/11g.xml | 28 +
.../flex/messaging/io/amfx/string_tag/11h.xml | 31 +
.../flex/messaging/io/amfx/string_tag/11i.xml | 24 +
.../flex/messaging/io/amfx/string_tag/11j.xml | 24 +
.../flex/messaging/io/amfx/traits_tag/12a.xml | 35 +
.../flex/messaging/io/amfx/traits_tag/12b.xml | 47 +
.../flex/messaging/io/amfx/true_tag/13a.xml | 24 +
.../flex/messaging/io/amfx/true_tag/13b.xml | 31 +
.../flex/messaging/io/amfx/true_tag/13c.xml | 28 +
.../flex/messaging/io/amfx/true_tag/13d.xml | 36 +
.../messaging/io/amfx/undefined_tag/14a.xml | 24 +
.../messaging/io/amfx/undefined_tag/14b.xml | 31 +
.../messaging/io/amfx/undefined_tag/14c.xml | 28 +
.../messaging/io/amfx/undefined_tag/14d.xml | 36 +
.../flex/messaging/io/amfx/xml_tag/15a.xml | 30 +
.../flex/messaging/io/amfx/xml_tag/15b.xml | 30 +
qa/apps/qa-manual/build.xml | 25 +-
qa/apps/qa-regress/build.xml | 23 +-
qa/resources/webtier/build.xml | 4 +-
920 files changed, 102527 insertions(+), 102087 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/apps/ds-console/build.xml
----------------------------------------------------------------------
diff --git a/apps/ds-console/build.xml b/apps/ds-console/build.xml
index 7923ff8..844583e 100755
--- a/apps/ds-console/build.xml
+++ b/apps/ds-console/build.xml
@@ -47,6 +47,7 @@
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${ant-contrib.jar}"/>
<target name="prepare">
+ <mkdir dir="${ds-console.war}/WEB-INF/src"/>
<mkdir dir="${ds-console.war}/WEB-INF/lib"/>
<mkdir dir="${ds-console.war}/WEB-INF/classes"/>
</target>
@@ -62,7 +63,7 @@
<!-- copy to the classes directory -->
<copy todir="${ds-console.war}/WEB-INF/classes">
- <fileset dir="${ds-console.war}/WEB-INF/src">
+ <fileset dir="${ds-console.war}/WEB-INF/src" erroronmissingdir="false">
<include name="**/*.xml"/>
</fileset>
<fileset dir="${basedir}/lib" includes="${webapp.classes}" />
@@ -75,13 +76,14 @@
</target>
<target name="compile" depends="prepare,run-depend,copy-resources" description="compile">
+ <mkdir dir="${src.dir}"/>
<javac source="1.4" debug="${src.debug}" destdir="${classes.dir}" srcdir="${src.dir}" classpathref="classpath"/>
</target>
<target name="compile-swf" >
<delete file="${ds-console.war}/${application.file}.swf"/>
- <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/lib/flexTasks.jar" />
+ <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<property name="FLEX_HOME" value="${basedir}"/>
<mxmlc file="${application.dir}/${application.file}.mxml"
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 61d1abc..fa95942 100755
--- a/build.xml
+++ b/build.xml
@@ -46,73 +46,74 @@ Each of the main targets for the modules will call clean themselves before proce
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${ant-contrib.jar}"/>
<property name="tmp.dir" value="${basedir}/packagetemp/temp" />
- <property name="local.sdk.dir" value="resources/flex_sdk" />
+ <property name="local.sdk.dir" value="resources/flex_sdk" />
- <property name="env.FLEX_HOME" value="${basedir}/../flex-sdk"/>
- <!-- set FLEX_HOME from environment if not already set -->
- <property name="FLEX_HOME" value="${env.FLEX_HOME}"/>
-
- <target name="check-env"
- depends="check-flex-home, load-more-properties, check-playerglobal-home" />
-
- <target name="check-flex-home" unless="flexhome.exists"
- description="Check FLEX_HOME for both a directory and a file">
-
- <echo message="FLEX_HOME is ${env.FLEX_HOME}"/>
-
- <available file="${env.FLEX_HOME}"
- type="dir"
- property="FLEX_HOME.set"/>
-
- <fail message="The environment variable FLEX_HOME is not set to a directory"
- unless="FLEX_HOME.set"/>
-
- <property name="flex-sdk-description.xml"
- value="${env.FLEX_HOME}/flex-sdk-description.xml"/>
-
- <available file="${flex-sdk-description.xml}"
- type="file"
- property="flex-sdk-description.xml.exists"/>
-
- <fail message="The file ${flex-sdk-description.xml} does not exist"
- unless="flex-sdk-description.xml"/>
-
- </target>
-
- <target name="load-more-properties"
- description="load the FLEX_HOME/build.properties to pick up playerglobal.version">
- <property file="${FLEX_HOME}/build.properties" />
- </target>
-
- <target name="check-playerglobal-home" unless="playerglobal.swc.exists"
- description="Check PLAYERGLOBAL_HOME for both a directory and a swc file">
-
- <echo message="PLAYERGLOBAL_HOME is ${env.PLAYERGLOBAL_HOME}"/>
- <echo message="playerglobal.version is ${playerglobal.version}"/>
-
- <available file="${env.PLAYERGLOBAL_HOME}"
- type="dir"
- property="PLAYERGLOBAL_HOME.set"/>
-
- <fail message="The environment variable PLAYERGLOBAL_HOME is not set to a directory"
- unless="PLAYERGLOBAL_HOME.set"/>
-
- <property name="playerglobal.swc"
- value="${env.PLAYERGLOBAL_HOME}/${playerglobal.version}/playerglobal.swc"/>
-
- <available file="${playerglobal.swc}"
- type="file"
- property="playerglobal.swc.exists"/>
-
- <fail message="The file ${playerglobal.swc} does not exist"
- unless="playerglobal.swc.exists"/>
-
- <echo message="playerglobal.swc is ${playerglobal.swc}"/>
- </target>
-
- <target name="thirdparty-downloads" unless="no.thirdparty-downloads" description="Downloads all the required thirdparty code.">
- <ant antfile="${basedir}/downloads.xml" dir="${basedir}"/>
- </target>
+ <property name="env.FLEX_HOME" value="${basedir}/../flex-sdk"/>
+ <!-- set FLEX_HOME from environment if not already set -->
+ <property name="FLEX_HOME" value="${env.FLEX_HOME}"/>
+ <property name="ANT_HOME" value="${env.ANT_HOME}"/>
+
+ <target name="check-env"
+ depends="check-flex-home, load-more-properties, check-playerglobal-home" />
+
+ <target name="check-flex-home" unless="flexhome.exists"
+ description="Check FLEX_HOME for both a directory and a file">
+
+ <echo message="FLEX_HOME is ${env.FLEX_HOME}"/>
+
+ <available file="${env.FLEX_HOME}"
+ type="dir"
+ property="FLEX_HOME.set"/>
+
+ <fail message="The environment variable FLEX_HOME is not set to a directory"
+ unless="FLEX_HOME.set"/>
+
+ <property name="flex-sdk-description.xml"
+ value="${env.FLEX_HOME}/flex-sdk-description.xml"/>
+
+ <available file="${flex-sdk-description.xml}"
+ type="file"
+ property="flex-sdk-description.xml.exists"/>
+
+ <fail message="The file ${flex-sdk-description.xml} does not exist"
+ unless="flex-sdk-description.xml"/>
+
+ </target>
+
+ <target name="load-more-properties"
+ description="load the FLEX_HOME/build.properties to pick up playerglobal.version">
+ <property file="${FLEX_HOME}/build.properties" />
+ </target>
+
+ <target name="check-playerglobal-home" unless="playerglobal.swc.exists"
+ description="Check PLAYERGLOBAL_HOME for both a directory and a swc file">
+
+ <echo message="PLAYERGLOBAL_HOME is ${env.PLAYERGLOBAL_HOME}"/>
+ <echo message="playerglobal.version is ${playerglobal.version}"/>
+
+ <available file="${env.PLAYERGLOBAL_HOME}"
+ type="dir"
+ property="PLAYERGLOBAL_HOME.set"/>
+
+ <fail message="The environment variable PLAYERGLOBAL_HOME is not set to a directory"
+ unless="PLAYERGLOBAL_HOME.set"/>
+
+ <property name="playerglobal.swc"
+ value="${env.PLAYERGLOBAL_HOME}/${playerglobal.version}/playerglobal.swc"/>
+
+ <available file="${playerglobal.swc}"
+ type="file"
+ property="playerglobal.swc.exists"/>
+
+ <fail message="The file ${playerglobal.swc} does not exist"
+ unless="playerglobal.swc.exists"/>
+
+ <echo message="playerglobal.swc is ${playerglobal.swc}"/>
+ </target>
+
+ <target name="thirdparty-downloads" unless="no.thirdparty-downloads" description="Downloads all the required thirdparty code.">
+ <ant antfile="${basedir}/downloads.xml" dir="${basedir}"/>
+ </target>
<target name="main" depends="check-env,clean,thirdparty-downloads,sdk,webtier,common,core,proxy,remoting,opt,apps,createMMSFile" description="full build">
<tstamp>
@@ -624,7 +625,7 @@ Each of the main targets for the modules will call clean themselves before proce
<ant antfile="${basedir}/modules/opt/build.xml" target="clean"/>
<ant antfile="${basedir}/apps/blazeds/build.xml" target="clean"/>
<ant antfile="${basedir}/apps/blazeds-spring/build.xml" target="clean"/>
- <ant antfile="${basedir}/apps/ds-console/build.xml" target="clean"/>
+ <ant antfile="${basedir}/apps/ds-console/build.xml" target="clean"/>
<ant antfile="${basedir}/apps/samples/build.xml" target="clean"/>
<ant antfile="${basedir}/apps/samples-spring/build.xml" target="clean"/>
<ant antfile="${basedir}/apps/team/build.xml" target="clean"/>
@@ -632,24 +633,24 @@ Each of the main targets for the modules will call clean themselves before proce
<ant antfile="${basedir}/qa/apps/qa-manual/build.xml" target="clean"/>
<ant antfile="${basedir}/qa/apps/qa-regress/build.xml" target="clean"/>
<ant antfile="${basedir}/qa/resources/webtier/build.xml" target="clean"/>
- <ant antfile="${basedir}/qa/src/build.xml" target="clean"/>
+ <ant antfile="${basedir}/qa/src/build.xml" target="clean"/>
<delete>
<fileset dir="." includes="TEST-*.xml"/>
</delete>
- <delete quiet="true" dir="${basedir}/dist"/>
- <delete quiet="true" dir="${basedir}/sampledb" includes="hsqldb.jar"/>
- <delete quiet="true" dir="${basedir}/templates"/>
+ <delete quiet="true" dir="${basedir}/dist"/>
+ <delete quiet="true" dir="${basedir}/sampledb" includes="hsqldb.jar"/>
+ <delete quiet="true" dir="${basedir}/templates"/>
<delete>
<fileset dir="resources/clustering" includes="{jgroups.jars},jgroups-LICENSE.txt" />
</delete>
</target>
- <target name="super-clean" depends="thirdparty-clean,clean" description="Cleans everything including thirdparty downloads."/>
-
- <target name="thirdparty-clean" unless="no.thirdparty-clean" description="Removes all thirdparty downloads.">
- <ant antfile="${basedir}/downloads.xml" target="clean" dir="${basedir}"/>
- </target>
-
+ <target name="super-clean" depends="thirdparty-clean,clean" description="Cleans everything including thirdparty downloads."/>
+
+ <target name="thirdparty-clean" unless="no.thirdparty-clean" description="Removes all thirdparty downloads.">
+ <ant antfile="${basedir}/downloads.xml" target="clean" dir="${basedir}"/>
+ </target>
+
<target name="generated-clean">
<delete includeEmptyDirs="true" quiet="true">
<fileset dir="${basedir}/apps" includes="**/generated/*" />
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/downloads.xml
----------------------------------------------------------------------
diff --git a/downloads.xml b/downloads.xml
index bfc93dd..ada58e8 100644
--- a/downloads.xml
+++ b/downloads.xml
@@ -520,7 +520,8 @@
</target>
<target name="download-mx4j-java" unless="mx4j.zip.exists">
- <get src="http://repo1.maven.org/maven2/mx4j/mx4j-jmx/1.1.1/mx4j-jmx-1.1.1.jar"
+ <mkdir dir="${modules.opt.lib.dir}"/>
+ <get src="http://repo1.maven.org/maven2/mx4j/mx4j-jmx/1.1.1/mx4j-jmx-1.1.1.jar"
dest="${modules.opt.lib.dir}/mx4j-jmx.jar"
verbose="false"/>
</target>
@@ -539,6 +540,7 @@
</target>
<target name="download-cat708-java" unless="cat708.zip.exists">
+ <mkdir dir="${modules.opt.lib.dir}"/>
<get src="http://repo1.maven.org/maven2/org/apache/tomcat/tomcat-catalina/7.0.8/tomcat-catalina-7.0.8.jar"
dest="${modules.opt.lib.dir}/catalina-708.jar"
verbose="false"/>
@@ -560,6 +562,7 @@
<include name="**/*"/>
</patternset>
</unzip>
+ <mkdir dir="${modules.opt.lib.dir}"/>
<copy file="${download.dir}/cat4150/jakarta-tomcat-4.0.6/server/lib/catalina.jar" toFile="${modules.opt.lib.dir}/catalina-4150.jar"/>
</target>
@@ -584,6 +587,7 @@
</target>
<target name="download-cat-java" unless="cat.zip.exists">
+ <mkdir dir="${modules.opt.lib.dir}"/>
<get src="http://repo1.maven.org/maven2/org/apache/tomcat/catalina/6.0.26/catalina-6.0.26.jar"
dest="${modules.opt.lib.dir}/catalina.jar"
verbose="false"/>
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/build.xml
----------------------------------------------------------------------
diff --git a/modules/common/build.xml b/modules/common/build.xml
index 0f3e4ec..8ef6c38 100755
--- a/modules/common/build.xml
+++ b/modules/common/build.xml
@@ -21,9 +21,9 @@
<!-- properties -->
<property file="${basedir}/build.properties"/>
- <property name="module.dir" value="${basedir}/modules/common"/>
-
<property name="lib.dir" value="${basedir}/lib"/>
+
+ <property name="module.dir" value="${basedir}/modules/common"/>
<property name="module.lib.dir" location="${module.dir}/lib"/>
<property name="module.src" value="${module.dir}/src"/>
<property name="module.classes" value="${module.dir}/classes"/>
@@ -36,7 +36,7 @@
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
- <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<target name="main" depends="clean,prepare,run-depend,jar" description="cleans and runs the full build"/>
@@ -54,16 +54,14 @@
<target name="compile" depends="prepare" description="compile">
<javac target="1.4" source="1.4" debug="${src.debug}" destdir="${module.classes}" srcdir="${module.src}"
includes="**/*.java" classpathref="classpath"/>
- <echo file="${module.classes}/flex/messaging/version.properties" append="false">build=${build.number}</echo>
+ <echo file="${module.classes}/flex/messaging/version.properties" append="false">build=${build.number}</echo>
</target>
<!-- jar containing messaging common infrastructure -->
<target name="jar" depends="compile">
-
<copy todir="${module.classes}/flex/messaging" overwrite="true">
<fileset dir="${module.src}/flex/messaging" includes="*.properties"/>
</copy>
-
<jar destfile="${module.jar}" basedir="${module.classes}">
<include name="flex/**"/>
<exclude name=".dependency-info/**"/>
@@ -74,11 +72,9 @@
<attribute name="Implementation-Vendor" value="${manifest.Implementation-Vendor}"/>
</manifest>
</jar>
-
<delete failonerror="false">
<fileset dir="${module.classes}/flex/messaging" includes="*.properties"/>
</delete>
-
</target>
<target name="clean" description="clean">
@@ -89,9 +85,8 @@
<exclude name="dependencies.txt"/>
<exclude name=".dependency-info/**"/>
</fileset>
- </delete>
- <delete quiet="true" dir="${module.classes}"/>
-
+ </delete>
+ <delete quiet="true" dir="${module.classes}"/>
</target>
</project>
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/pom.xml
----------------------------------------------------------------------
diff --git a/modules/common/pom.xml b/modules/common/pom.xml
index 83a4777..096a5e2 100755
--- a/modules/common/pom.xml
+++ b/modules/common/pom.xml
@@ -23,7 +23,7 @@ limitations under the License.
<parent>
<groupId>org.apache.flex.blazeds</groupId>
<artifactId>blazeds</artifactId>
- <version>4.6.0.0-SNAPSHOT</version>
+ <version>4.7.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/graphics/ImageSnapshot.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/graphics/ImageSnapshot.java b/modules/common/src/flex/graphics/ImageSnapshot.java
old mode 100755
new mode 100644
index cc4498a..1dc97f0
--- a/modules/common/src/flex/graphics/ImageSnapshot.java
+++ b/modules/common/src/flex/graphics/ImageSnapshot.java
@@ -1,147 +1,147 @@
-/*
- * 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.graphics;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * This class corresponds to mx.graphics.ImageSnapshot on the client. Clients may choose
- * to capture images and send them to the server via a RemoteObject call. The PDF generation
- * feature of LCDS may then be used to generate PDF's from these images.
- *
- */
-public class ImageSnapshot extends HashMap
-{
- private static final long serialVersionUID = 7914317354403674061L;
-
- /**
- * Default constructor.
- */
- public ImageSnapshot()
- {
- }
-
- private Map properties;
- private String contentType;
- private byte[] data;
- private int height;
- private int width;
-
- /**
- * The content type for the image encoding format that was used to capture
- * this snapshot.
- *
- * @return content type of this image
- */
- public String getContentType()
- {
- return contentType;
- }
-
- /**
- * Sets content type of this snapshot.
- *
- * @param value content type
- */
- public void setContentType(String value)
- {
- contentType = value;
- }
-
- /**
- * The encoded data representing the image snapshot.
- *
- * @return encoded image data
- */
- public byte[] getData()
- {
- return data;
- }
-
- /**
- * Set the encoded data representing the image snapshot.
- *
- * @param value byte array of image data
- */
- public void setData(byte[] value)
- {
- data = value;
- }
-
- /**
- * The image height in pixels.
- *
- * @return image height in pixels
- */
- public int getHeight()
- {
- return height;
- }
-
- /**
- * Set image height in pixels.
- *
- * @param value image height in pixels.
- */
- public void setHeight(int value)
- {
- height = value;
- }
-
- /**
- * Additional properties of the image.
- *
- * @return a map containing the dynamically set properties on this snapshot
- */
- public Map getProperties()
- {
- return properties;
- }
-
- /**
- * Sets the map of dynamic properties for this snapshot.
- *
- * @param value map containing dynamic properties for this snapshot
- */
- public void setProperties(Map value)
- {
- properties = value;
- }
-
- /**
- * The image width in pixels.
- *
- * @return width in pixels
- */
- public int getWidth()
- {
- return width;
- }
-
- /**
- * Set width in pixels.
- *
- * @param value width in pixels.
- */
- public void setWidth(int value)
- {
- width = value;
- }
-
-}
+/*
+ * 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.graphics;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class corresponds to mx.graphics.ImageSnapshot on the client. Clients may choose
+ * to capture images and send them to the server via a RemoteObject call. The PDF generation
+ * feature of LCDS may then be used to generate PDF's from these images.
+ *
+ */
+public class ImageSnapshot extends HashMap
+{
+ private static final long serialVersionUID = 7914317354403674061L;
+
+ /**
+ * Default constructor.
+ */
+ public ImageSnapshot()
+ {
+ }
+
+ private Map properties;
+ private String contentType;
+ private byte[] data;
+ private int height;
+ private int width;
+
+ /**
+ * The content type for the image encoding format that was used to capture
+ * this snapshot.
+ *
+ * @return content type of this image
+ */
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ /**
+ * Sets content type of this snapshot.
+ *
+ * @param value content type
+ */
+ public void setContentType(String value)
+ {
+ contentType = value;
+ }
+
+ /**
+ * The encoded data representing the image snapshot.
+ *
+ * @return encoded image data
+ */
+ public byte[] getData()
+ {
+ return data;
+ }
+
+ /**
+ * Set the encoded data representing the image snapshot.
+ *
+ * @param value byte array of image data
+ */
+ public void setData(byte[] value)
+ {
+ data = value;
+ }
+
+ /**
+ * The image height in pixels.
+ *
+ * @return image height in pixels
+ */
+ public int getHeight()
+ {
+ return height;
+ }
+
+ /**
+ * Set image height in pixels.
+ *
+ * @param value image height in pixels.
+ */
+ public void setHeight(int value)
+ {
+ height = value;
+ }
+
+ /**
+ * Additional properties of the image.
+ *
+ * @return a map containing the dynamically set properties on this snapshot
+ */
+ public Map getProperties()
+ {
+ return properties;
+ }
+
+ /**
+ * Sets the map of dynamic properties for this snapshot.
+ *
+ * @param value map containing dynamic properties for this snapshot
+ */
+ public void setProperties(Map value)
+ {
+ properties = value;
+ }
+
+ /**
+ * The image width in pixels.
+ *
+ * @return width in pixels
+ */
+ public int getWidth()
+ {
+ return width;
+ }
+
+ /**
+ * Set width in pixels.
+ *
+ * @param value width in pixels.
+ */
+ public void setWidth(int value)
+ {
+ width = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/graphics/package-info.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/graphics/package-info.java b/modules/common/src/flex/graphics/package-info.java
old mode 100755
new mode 100644
index dcec8c8..87093bf
--- a/modules/common/src/flex/graphics/package-info.java
+++ b/modules/common/src/flex/graphics/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.graphics;
\ No newline at end of file
[41/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/LocaleUtils.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/LocaleUtils.java b/modules/common/src/flex/messaging/util/LocaleUtils.java
old mode 100755
new mode 100644
index e398971..17cd80d
--- a/modules/common/src/flex/messaging/util/LocaleUtils.java
+++ b/modules/common/src/flex/messaging/util/LocaleUtils.java
@@ -1,58 +1,58 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package flex.messaging.util;
-
-import java.util.Locale;
-
-/**
- * @exclude
- */
-public class LocaleUtils
-{
- /**
- * Builds a <code>Locale</code> instance from the passed string. If the string
- * is <code>null</code> this method will return the default locale for the JVM.
- *
- * @param locale The locale as a string.
- * @return The Locale instance built from the passed string.
- */
- public static Locale buildLocale(String locale)
- {
- if (locale == null)
- {
- return Locale.getDefault();
- }
- else
- {
- int index = locale.indexOf('_');
- if (index == -1)
- {
- return new Locale(locale);
- }
- String language = locale.substring(0, index);
- String rest = locale.substring(index + 1);
- index = rest.indexOf('_');
- if (index == -1)
- {
- return new Locale(language, rest);
- }
- String country = rest.substring(0, index);
- rest = rest.substring(index + 1);
- return new Locale(language, country, rest);
- }
- }
-}
+/*
+ * 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.util;
+
+import java.util.Locale;
+
+/**
+ * @exclude
+ */
+public class LocaleUtils
+{
+ /**
+ * Builds a <code>Locale</code> instance from the passed string. If the string
+ * is <code>null</code> this method will return the default locale for the JVM.
+ *
+ * @param locale The locale as a string.
+ * @return The Locale instance built from the passed string.
+ */
+ public static Locale buildLocale(String locale)
+ {
+ if (locale == null)
+ {
+ return Locale.getDefault();
+ }
+ else
+ {
+ int index = locale.indexOf('_');
+ if (index == -1)
+ {
+ return new Locale(locale);
+ }
+ String language = locale.substring(0, index);
+ String rest = locale.substring(index + 1);
+ index = rest.indexOf('_');
+ if (index == -1)
+ {
+ return new Locale(language, rest);
+ }
+ String country = rest.substring(0, index);
+ rest = rest.substring(index + 1);
+ return new Locale(language, country, rest);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/ObjectTrace.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/ObjectTrace.java b/modules/common/src/flex/messaging/util/ObjectTrace.java
old mode 100755
new mode 100644
index 6477086..c7ebb34
--- a/modules/common/src/flex/messaging/util/ObjectTrace.java
+++ b/modules/common/src/flex/messaging/util/ObjectTrace.java
@@ -1,173 +1,173 @@
-/*
- * 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.util;
-
-import flex.messaging.log.Log;
-
-/**
- * Simple utility to trace an Object graph out to a StringBuffer.
- *
- * Note that new lines are NOT added after the individual values
- * in complex type properties.
- *
- * @exclude
- */
-public class ObjectTrace
-{
-
-
- /* This boolean is used for suppressing debug output for selected properties.
- * The logger will check this before printing a property.
- */
- public boolean nextElementExclude;
-
- public ObjectTrace()
- {
- buffer = new StringBuffer(4096);
- }
-
- public ObjectTrace(int bufferSize)
- {
- buffer = new StringBuffer(bufferSize);
- }
-
- public String toString()
- {
- return buffer.toString();
- }
-
- public void write(Object o)
- {
- if (m_nested <= 0)
- buffer.append(indentString());
-
- buffer.append(String.valueOf(o));
- }
-
- public void writeNull()
- {
- if (m_nested <= 0)
- buffer.append(indentString());
-
- buffer.append("null");
- }
-
- public void writeRef(int ref)
- {
- if (m_nested <= 0)
- buffer.append(indentString());
-
- buffer.append("(Ref #").append(ref).append(")");
- }
-
- public void writeString(String s)
- {
- if (m_nested <= 0)
- buffer.append(indentString());
-
- buffer.append("\"").append(s).append("\"");
- }
-
- public void startArray(String header)
- {
- if (header != null && header.length() > 0)
- {
- if (m_nested <= 0)
- buffer.append(indentString());
-
- buffer.append(header).append(newLine);
- }
-
- m_indent++;
- m_nested++;
- }
-
- public void arrayElement(int index)
- {
- buffer.append(indentString()).append("[").append(index).append("] = ");
- }
-
- public void endArray()
- {
- m_indent--;
- m_nested--;
- }
-
- public void startObject(String header)
- {
- if (header != null && header.length() > 0)
- {
- if (m_nested <= 0)
- buffer.append(indentString());
-
- buffer.append(header).append(newLine);
- }
-
- m_indent++;
- m_nested++;
- }
-
- public void namedElement(String name)
- {
- if (Log.isExcludedProperty(name))
- {
- nextElementExclude = true;
- }
-
- buffer.append(indentString()).append(name).append(" = ");
- }
-
- public void endObject()
- {
- m_indent--;
- m_nested--;
- }
-
- public void newLine()
- {
- boolean alreadyPadded = false;
- int length = buffer.length();
-
- if (length > 3)
- {
- String tail = buffer.substring(length - 3, length - 1); //Get last two chars in buffer
- alreadyPadded = tail.equals(newLine);
- }
-
- if (!alreadyPadded)
- buffer.append(newLine);
- }
-
- /**
- * Uses the static member, m_indent to create a string of spaces of
- * the appropriate indentation.
- */
- protected String indentString()
- {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < m_indent; ++i)
- {
- sb.append(" ");
- }
- return sb.toString();
- }
-
- protected StringBuffer buffer;
- protected int m_indent;
- protected int m_nested;
- public static String newLine = StringUtils.NEWLINE;
-}
+/*
+ * 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.util;
+
+import flex.messaging.log.Log;
+
+/**
+ * Simple utility to trace an Object graph out to a StringBuffer.
+ *
+ * Note that new lines are NOT added after the individual values
+ * in complex type properties.
+ *
+ * @exclude
+ */
+public class ObjectTrace
+{
+
+
+ /* This boolean is used for suppressing debug output for selected properties.
+ * The logger will check this before printing a property.
+ */
+ public boolean nextElementExclude;
+
+ public ObjectTrace()
+ {
+ buffer = new StringBuffer(4096);
+ }
+
+ public ObjectTrace(int bufferSize)
+ {
+ buffer = new StringBuffer(bufferSize);
+ }
+
+ public String toString()
+ {
+ return buffer.toString();
+ }
+
+ public void write(Object o)
+ {
+ if (m_nested <= 0)
+ buffer.append(indentString());
+
+ buffer.append(String.valueOf(o));
+ }
+
+ public void writeNull()
+ {
+ if (m_nested <= 0)
+ buffer.append(indentString());
+
+ buffer.append("null");
+ }
+
+ public void writeRef(int ref)
+ {
+ if (m_nested <= 0)
+ buffer.append(indentString());
+
+ buffer.append("(Ref #").append(ref).append(")");
+ }
+
+ public void writeString(String s)
+ {
+ if (m_nested <= 0)
+ buffer.append(indentString());
+
+ buffer.append("\"").append(s).append("\"");
+ }
+
+ public void startArray(String header)
+ {
+ if (header != null && header.length() > 0)
+ {
+ if (m_nested <= 0)
+ buffer.append(indentString());
+
+ buffer.append(header).append(newLine);
+ }
+
+ m_indent++;
+ m_nested++;
+ }
+
+ public void arrayElement(int index)
+ {
+ buffer.append(indentString()).append("[").append(index).append("] = ");
+ }
+
+ public void endArray()
+ {
+ m_indent--;
+ m_nested--;
+ }
+
+ public void startObject(String header)
+ {
+ if (header != null && header.length() > 0)
+ {
+ if (m_nested <= 0)
+ buffer.append(indentString());
+
+ buffer.append(header).append(newLine);
+ }
+
+ m_indent++;
+ m_nested++;
+ }
+
+ public void namedElement(String name)
+ {
+ if (Log.isExcludedProperty(name))
+ {
+ nextElementExclude = true;
+ }
+
+ buffer.append(indentString()).append(name).append(" = ");
+ }
+
+ public void endObject()
+ {
+ m_indent--;
+ m_nested--;
+ }
+
+ public void newLine()
+ {
+ boolean alreadyPadded = false;
+ int length = buffer.length();
+
+ if (length > 3)
+ {
+ String tail = buffer.substring(length - 3, length - 1); //Get last two chars in buffer
+ alreadyPadded = tail.equals(newLine);
+ }
+
+ if (!alreadyPadded)
+ buffer.append(newLine);
+ }
+
+ /**
+ * Uses the static member, m_indent to create a string of spaces of
+ * the appropriate indentation.
+ */
+ protected String indentString()
+ {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < m_indent; ++i)
+ {
+ sb.append(" ");
+ }
+ return sb.toString();
+ }
+
+ protected StringBuffer buffer;
+ protected int m_indent;
+ protected int m_nested;
+ public static String newLine = StringUtils.NEWLINE;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/PrettyPrintable.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/PrettyPrintable.java b/modules/common/src/flex/messaging/util/PrettyPrintable.java
old mode 100755
new mode 100644
index 3c2933b..1a41aac
--- a/modules/common/src/flex/messaging/util/PrettyPrintable.java
+++ b/modules/common/src/flex/messaging/util/PrettyPrintable.java
@@ -1,30 +1,30 @@
-/*
- * 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.util;
-
-/**
- * Allows an Object to customize how it is pretty printed in
- * logging/debugging output.
- *
- * @exclude
- */
-public interface PrettyPrintable
-{
- String toStringHeader();
-
- String toStringCustomProperty(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.util;
+
+/**
+ * Allows an Object to customize how it is pretty printed in
+ * logging/debugging output.
+ *
+ * @exclude
+ */
+public interface PrettyPrintable
+{
+ String toStringHeader();
+
+ String toStringCustomProperty(String name);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/PrettyPrinter.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/PrettyPrinter.java b/modules/common/src/flex/messaging/util/PrettyPrinter.java
old mode 100755
new mode 100644
index c4e86c0..1f169db
--- a/modules/common/src/flex/messaging/util/PrettyPrinter.java
+++ b/modules/common/src/flex/messaging/util/PrettyPrinter.java
@@ -1,30 +1,30 @@
-/*
- * 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.util;
-
-/**
- * Implementations convert Object graphs to Strings for
- * logging and debugging.
- *
- * @exclude
- */
-public interface PrettyPrinter
-{
- String prettify(Object o);
-
- Object copy();
-}
+/*
+ * 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.util;
+
+/**
+ * Implementations convert Object graphs to Strings for
+ * logging and debugging.
+ *
+ * @exclude
+ */
+public interface PrettyPrinter
+{
+ String prettify(Object o);
+
+ Object copy();
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/PropertyStringResourceLoader.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/PropertyStringResourceLoader.java b/modules/common/src/flex/messaging/util/PropertyStringResourceLoader.java
old mode 100755
new mode 100644
index 39f571d..eeacd25
--- a/modules/common/src/flex/messaging/util/PropertyStringResourceLoader.java
+++ b/modules/common/src/flex/messaging/util/PropertyStringResourceLoader.java
@@ -1,379 +1,379 @@
-/*
- * 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.util;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-
-import flex.messaging.log.Log;
-import flex.messaging.log.Logger;
-import flex.messaging.log.LogCategories;
-
-/**
- * Implementation of <code>ResourceLoader</code> that loads string resources
- * from property files.
- * <p>
- * This class uses <code>MessageFormat</code> to perform substitutions
- * within parameterized strings.
- * </p>
- *
- * @author Seth Hodgson
- * @see MessageFormat
- * @exclude
- */
-public class PropertyStringResourceLoader implements ResourceLoader
-{
- // The property file bundle that contains localized error strings for BlazeDS.
- public static final String PROPERTY_BUNDLE = "flex/messaging/errors";
-
- // The property file bundle that contains localized error strings for BlazeDS
- // code specific to vendors (eg. LoginCommands for specific application serves)
- public static final String VENDORS_BUNDLE = "flex/messaging/vendors";
-
- // The property file bundle that contains localized error strings for LCDS.
- public static final String LCDS_PROPERTY_BUNDLE = "flex/data/errors";
-
- // The category to write log entries under.
- private static final String LOG_CATEGORY = LogCategories.RESOURCE;
-
- // The property bundle names to use in string lookups.
- private String[] propertyBundles;
-
- // The default FDS locale.
- private Locale defaultLocale;
-
- // The set of locales that have strings loaded.
- private Set loadedLocales = new TreeSet();
-
- // A map of all loaded strings.
- private Map strings = new HashMap();
-
- // The logger for this instance.
- private Logger logger;
-
- /**
- * Constructs a <code>PropertyStringResourceLoader</code> using the default
- * property bundles specified by the <code>PROPERTY_BUNDLE</code> and
- * <code>LCDS_PROPERTY_BUNDLE</code> fields.
- */
- public PropertyStringResourceLoader()
- {
- this(new String[] {PROPERTY_BUNDLE, LCDS_PROPERTY_BUNDLE});
- }
-
- /**
- * Constructs a <code>PropertyStringResourceLoader</code> that will use the
- * specified property bundle to use for string lookups.
- *
- * @param propertyBundle The property bundles to use for lookups.
- */
- public PropertyStringResourceLoader(String propertyBundle)
- {
- this(new String[] {propertyBundle});
- }
-
- /**
- * Constructs a <code>PropertyStringResourceLoader</code> that will use the
- * specified property bundles to use for string lookups.
- *
- * @param propertyBundles The list of the property bundles to use for lookups.
- */
- public PropertyStringResourceLoader(String[] propertyBundles)
- {
- this.propertyBundles = propertyBundles;
- logger = Log.getLogger(LOG_CATEGORY);
- }
-
- // Implements flex.messaging.util.ResourceLoader.init; inherits javadoc specification.
- public void init(Map properties)
- {}
-
- // Implements flex.messaging.util.ResourceLoader.getString; inherits javadoc specification.
- public String getString(String key)
- {
- return getString(key, null, null);
- }
-
- // Implements flex.messaging.util.ResourceLoader.getString; inherits javadoc specification.
- public String getString(String key, Object[] arguments)
- {
- return getString(key, null, arguments);
- }
-
- // Implements flex.messaging.util.ResourceLoader.getString; inherits javadoc specification.
- public String getString(String key, Locale locale)
- {
- return getString(key, locale, null);
- }
-
- // Implements flex.messaging.util.ResourceLoader.getString; inherits javadoc specification.
- public String getString(String key, Locale locale, Object[] arguments)
- {
- synchronized(strings)
- {
- if (defaultLocale == null)
- {
- defaultLocale = getDefaultLocale();
- }
- }
- String value = null;
- String stringKey = null;
- String localeKey = (locale != null) ?
- generateLocaleKey(locale) :
- generateLocaleKey(defaultLocale);
- String originalStringKey = generateStringKey(key, localeKey);
- int trimIndex = 0;
-
- /*
- * Attempt to get a string for the target locale - fail back to less specific
- * versions of the locale.
- */
- while (true)
- {
- loadStrings(localeKey);
- stringKey = generateStringKey(key, localeKey);
- synchronized(strings)
- {
- value = (String) strings.get(stringKey);
- if (value != null)
- {
- if (!stringKey.equals(originalStringKey))
- {
- strings.put(originalStringKey, value);
- }
- return substituteArguments(value, arguments);
- }
- }
- trimIndex = localeKey.lastIndexOf('_');
- if (trimIndex != -1)
- {
- localeKey = localeKey.substring(0, trimIndex);
- }
- else
- {
- break;
- }
- }
-
- /*
- * Attempt to get the string in our default locale if it is
- * different than the requested locale.
- */
- if ((locale != null) && (!locale.equals(defaultLocale)))
- {
- localeKey = generateLocaleKey(defaultLocale);
- stringKey = generateStringKey(key, localeKey);
- synchronized(strings)
- {
- value = (String) strings.get(stringKey);
- if (value != null)
- {
- strings.put(originalStringKey, value);
- return substituteArguments(value, arguments);
- }
- }
- }
-
- // As a last resort, try to get a non-locale-specific string.
- loadStrings("");
- stringKey = generateStringKey(key, "");
- synchronized(strings)
- {
- value = (String) strings.get(stringKey);
- if (value != null)
- {
- strings.put(originalStringKey, value);
- return substituteArguments(value, arguments);
- }
- }
-
- // No string is available. Return a formatted missing string value.
- return ("???" + key + "???");
- }
-
- /**
- * Sets the default locale to be used when locating resources. The
- * string will be converted into a Locale.
- *
- * @param locale The default locale to be used.
- */
- public void setDefaultLocale(String locale)
- {
- defaultLocale = LocaleUtils.buildLocale(locale);
- }
-
- /**
- * Sets the default locale to be used when locating resources.
- *
- * @param locale The default locale to be used.
- */
- public void setDefaultLocale(Locale locale)
- {
- defaultLocale = locale;
- }
-
- /**
- * The default locale to be used when locating resources.
- * @return Locale the default Locale object
- */
- public Locale getDefaultLocale()
- {
- if (defaultLocale == null)
- defaultLocale = Locale.getDefault();
-
- return defaultLocale;
- }
-
- /**
- * Loads localized strings for the specified locale from a property file.
- *
- * @param localeKey The locale to load strings for.
- */
- protected synchronized void loadStrings(String localeKey)
- {
- if (loadedLocales.contains(localeKey))
- {
- return;
- }
-
- if (propertyBundles != null)
- {
- for (int i = 0; i < propertyBundles.length; i++)
- {
- String propertyBundle = propertyBundles[i];
- loadProperties(localeKey, propertyBundle);
- }
- }
- }
-
- protected InputStream loadFile(String filename)
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- InputStream stream = loader.getResourceAsStream(filename);
-
- // Try the properties file in our classloader too - just in case
- if (stream == null)
- {
- stream = PropertyStringResourceLoader.class.getClassLoader().getResourceAsStream(filename);
- }
-
- return stream;
- }
-
- // Helper method for loadStrings.
- protected void loadProperties(String localeKey, String propertyBundle)
- {
- // Build the path to the target property file.
- String filename = propertyBundle;
- if (localeKey.length() > 0)
- {
- filename += "_" + localeKey;
- }
- filename += ".properties";
- // Load the property file.
- InputStream stream = loadFile(filename);
-
- Properties props = new Properties();
- if (stream != null)
- {
- try
- {
- props.load(stream);
- }
- catch (IOException ioe)
- {
- logger.warn("There was a problem reading the string resource property file '" + filename + "' stream.", ioe);
- }
- catch (IllegalArgumentException iae)
- {
- logger.warn("The string resource property file '" + filename + "' contains a malformed Unicode escape sequence.", iae);
- }
- finally
- {
- try
- {
- stream.close();
- }
- catch (IOException ioe)
- {
- logger.warn("The string resource property file '" + filename + "' stream failed to close.", ioe);
- }
- }
- }
- else
- {
- logger.warn("The class loader could not locate the string resource property file '" + filename + "'. This may not be an issue if a property file is available for a less specific locale or the default locale.");
- }
- // Move strings into string cache.
- if (props.size() > 0)
- {
- synchronized(strings)
- {
- Iterator iter = props.keySet().iterator();
- while (iter.hasNext())
- {
- String key = (String) iter.next();
- strings.put(generateStringKey(key, localeKey), props.getProperty(key));
- }
- }
- }
- }
-
- /**
- * Generates a locale cache key.
- *
- * @param locale The locale to generate a cache key for.
- * @return The generated cache key.
- */
- private String generateLocaleKey(Locale locale)
- {
- return (locale == null) ? "" : locale.toString();
- }
-
- /**
- * Generates a cache key for a string resource.
- *
- * @param key The string to generate a cache key for.
- * @param locale The locale to retrieve the string for.
- * @return The generated cache key for the string resource.
- */
- private String generateStringKey(String key, String locale)
- {
- return (key + "-" + locale);
- }
-
- /**
- * Substitutes the specified arguments into a parameterized string.
- *
- * @param parameterized The string containing parameter tokens for substitution.
- * @param arguments The arguments to substitute into the parameterized string.
- * @return The resulting substituted string.
- */
- private String substituteArguments(String parameterized, Object[] arguments)
- {
- return MessageFormat.format(parameterized, arguments).trim();
- }
-
+/*
+ * 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.util;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
+
+import flex.messaging.log.Log;
+import flex.messaging.log.Logger;
+import flex.messaging.log.LogCategories;
+
+/**
+ * Implementation of <code>ResourceLoader</code> that loads string resources
+ * from property files.
+ * <p>
+ * This class uses <code>MessageFormat</code> to perform substitutions
+ * within parameterized strings.
+ * </p>
+ *
+ * @author Seth Hodgson
+ * @see MessageFormat
+ * @exclude
+ */
+public class PropertyStringResourceLoader implements ResourceLoader
+{
+ // The property file bundle that contains localized error strings for BlazeDS.
+ public static final String PROPERTY_BUNDLE = "flex/messaging/errors";
+
+ // The property file bundle that contains localized error strings for BlazeDS
+ // code specific to vendors (eg. LoginCommands for specific application serves)
+ public static final String VENDORS_BUNDLE = "flex/messaging/vendors";
+
+ // The property file bundle that contains localized error strings for LCDS.
+ public static final String LCDS_PROPERTY_BUNDLE = "flex/data/errors";
+
+ // The category to write log entries under.
+ private static final String LOG_CATEGORY = LogCategories.RESOURCE;
+
+ // The property bundle names to use in string lookups.
+ private String[] propertyBundles;
+
+ // The default FDS locale.
+ private Locale defaultLocale;
+
+ // The set of locales that have strings loaded.
+ private Set loadedLocales = new TreeSet();
+
+ // A map of all loaded strings.
+ private Map strings = new HashMap();
+
+ // The logger for this instance.
+ private Logger logger;
+
+ /**
+ * Constructs a <code>PropertyStringResourceLoader</code> using the default
+ * property bundles specified by the <code>PROPERTY_BUNDLE</code> and
+ * <code>LCDS_PROPERTY_BUNDLE</code> fields.
+ */
+ public PropertyStringResourceLoader()
+ {
+ this(new String[] {PROPERTY_BUNDLE, LCDS_PROPERTY_BUNDLE});
+ }
+
+ /**
+ * Constructs a <code>PropertyStringResourceLoader</code> that will use the
+ * specified property bundle to use for string lookups.
+ *
+ * @param propertyBundle The property bundles to use for lookups.
+ */
+ public PropertyStringResourceLoader(String propertyBundle)
+ {
+ this(new String[] {propertyBundle});
+ }
+
+ /**
+ * Constructs a <code>PropertyStringResourceLoader</code> that will use the
+ * specified property bundles to use for string lookups.
+ *
+ * @param propertyBundles The list of the property bundles to use for lookups.
+ */
+ public PropertyStringResourceLoader(String[] propertyBundles)
+ {
+ this.propertyBundles = propertyBundles;
+ logger = Log.getLogger(LOG_CATEGORY);
+ }
+
+ // Implements flex.messaging.util.ResourceLoader.init; inherits javadoc specification.
+ public void init(Map properties)
+ {}
+
+ // Implements flex.messaging.util.ResourceLoader.getString; inherits javadoc specification.
+ public String getString(String key)
+ {
+ return getString(key, null, null);
+ }
+
+ // Implements flex.messaging.util.ResourceLoader.getString; inherits javadoc specification.
+ public String getString(String key, Object[] arguments)
+ {
+ return getString(key, null, arguments);
+ }
+
+ // Implements flex.messaging.util.ResourceLoader.getString; inherits javadoc specification.
+ public String getString(String key, Locale locale)
+ {
+ return getString(key, locale, null);
+ }
+
+ // Implements flex.messaging.util.ResourceLoader.getString; inherits javadoc specification.
+ public String getString(String key, Locale locale, Object[] arguments)
+ {
+ synchronized(strings)
+ {
+ if (defaultLocale == null)
+ {
+ defaultLocale = getDefaultLocale();
+ }
+ }
+ String value = null;
+ String stringKey = null;
+ String localeKey = (locale != null) ?
+ generateLocaleKey(locale) :
+ generateLocaleKey(defaultLocale);
+ String originalStringKey = generateStringKey(key, localeKey);
+ int trimIndex = 0;
+
+ /*
+ * Attempt to get a string for the target locale - fail back to less specific
+ * versions of the locale.
+ */
+ while (true)
+ {
+ loadStrings(localeKey);
+ stringKey = generateStringKey(key, localeKey);
+ synchronized(strings)
+ {
+ value = (String) strings.get(stringKey);
+ if (value != null)
+ {
+ if (!stringKey.equals(originalStringKey))
+ {
+ strings.put(originalStringKey, value);
+ }
+ return substituteArguments(value, arguments);
+ }
+ }
+ trimIndex = localeKey.lastIndexOf('_');
+ if (trimIndex != -1)
+ {
+ localeKey = localeKey.substring(0, trimIndex);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ /*
+ * Attempt to get the string in our default locale if it is
+ * different than the requested locale.
+ */
+ if ((locale != null) && (!locale.equals(defaultLocale)))
+ {
+ localeKey = generateLocaleKey(defaultLocale);
+ stringKey = generateStringKey(key, localeKey);
+ synchronized(strings)
+ {
+ value = (String) strings.get(stringKey);
+ if (value != null)
+ {
+ strings.put(originalStringKey, value);
+ return substituteArguments(value, arguments);
+ }
+ }
+ }
+
+ // As a last resort, try to get a non-locale-specific string.
+ loadStrings("");
+ stringKey = generateStringKey(key, "");
+ synchronized(strings)
+ {
+ value = (String) strings.get(stringKey);
+ if (value != null)
+ {
+ strings.put(originalStringKey, value);
+ return substituteArguments(value, arguments);
+ }
+ }
+
+ // No string is available. Return a formatted missing string value.
+ return ("???" + key + "???");
+ }
+
+ /**
+ * Sets the default locale to be used when locating resources. The
+ * string will be converted into a Locale.
+ *
+ * @param locale The default locale to be used.
+ */
+ public void setDefaultLocale(String locale)
+ {
+ defaultLocale = LocaleUtils.buildLocale(locale);
+ }
+
+ /**
+ * Sets the default locale to be used when locating resources.
+ *
+ * @param locale The default locale to be used.
+ */
+ public void setDefaultLocale(Locale locale)
+ {
+ defaultLocale = locale;
+ }
+
+ /**
+ * The default locale to be used when locating resources.
+ * @return Locale the default Locale object
+ */
+ public Locale getDefaultLocale()
+ {
+ if (defaultLocale == null)
+ defaultLocale = Locale.getDefault();
+
+ return defaultLocale;
+ }
+
+ /**
+ * Loads localized strings for the specified locale from a property file.
+ *
+ * @param localeKey The locale to load strings for.
+ */
+ protected synchronized void loadStrings(String localeKey)
+ {
+ if (loadedLocales.contains(localeKey))
+ {
+ return;
+ }
+
+ if (propertyBundles != null)
+ {
+ for (int i = 0; i < propertyBundles.length; i++)
+ {
+ String propertyBundle = propertyBundles[i];
+ loadProperties(localeKey, propertyBundle);
+ }
+ }
+ }
+
+ protected InputStream loadFile(String filename)
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ InputStream stream = loader.getResourceAsStream(filename);
+
+ // Try the properties file in our classloader too - just in case
+ if (stream == null)
+ {
+ stream = PropertyStringResourceLoader.class.getClassLoader().getResourceAsStream(filename);
+ }
+
+ return stream;
+ }
+
+ // Helper method for loadStrings.
+ protected void loadProperties(String localeKey, String propertyBundle)
+ {
+ // Build the path to the target property file.
+ String filename = propertyBundle;
+ if (localeKey.length() > 0)
+ {
+ filename += "_" + localeKey;
+ }
+ filename += ".properties";
+ // Load the property file.
+ InputStream stream = loadFile(filename);
+
+ Properties props = new Properties();
+ if (stream != null)
+ {
+ try
+ {
+ props.load(stream);
+ }
+ catch (IOException ioe)
+ {
+ logger.warn("There was a problem reading the string resource property file '" + filename + "' stream.", ioe);
+ }
+ catch (IllegalArgumentException iae)
+ {
+ logger.warn("The string resource property file '" + filename + "' contains a malformed Unicode escape sequence.", iae);
+ }
+ finally
+ {
+ try
+ {
+ stream.close();
+ }
+ catch (IOException ioe)
+ {
+ logger.warn("The string resource property file '" + filename + "' stream failed to close.", ioe);
+ }
+ }
+ }
+ else
+ {
+ logger.warn("The class loader could not locate the string resource property file '" + filename + "'. This may not be an issue if a property file is available for a less specific locale or the default locale.");
+ }
+ // Move strings into string cache.
+ if (props.size() > 0)
+ {
+ synchronized(strings)
+ {
+ Iterator iter = props.keySet().iterator();
+ while (iter.hasNext())
+ {
+ String key = (String) iter.next();
+ strings.put(generateStringKey(key, localeKey), props.getProperty(key));
+ }
+ }
+ }
+ }
+
+ /**
+ * Generates a locale cache key.
+ *
+ * @param locale The locale to generate a cache key for.
+ * @return The generated cache key.
+ */
+ private String generateLocaleKey(Locale locale)
+ {
+ return (locale == null) ? "" : locale.toString();
+ }
+
+ /**
+ * Generates a cache key for a string resource.
+ *
+ * @param key The string to generate a cache key for.
+ * @param locale The locale to retrieve the string for.
+ * @return The generated cache key for the string resource.
+ */
+ private String generateStringKey(String key, String locale)
+ {
+ return (key + "-" + locale);
+ }
+
+ /**
+ * Substitutes the specified arguments into a parameterized string.
+ *
+ * @param parameterized The string containing parameter tokens for substitution.
+ * @param arguments The arguments to substitute into the parameterized string.
+ * @return The resulting substituted string.
+ */
+ private String substituteArguments(String parameterized, Object[] arguments)
+ {
+ return MessageFormat.format(parameterized, arguments).trim();
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/ResourceLoader.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/ResourceLoader.java b/modules/common/src/flex/messaging/util/ResourceLoader.java
old mode 100755
new mode 100644
index 0ea39b0..334c177
--- a/modules/common/src/flex/messaging/util/ResourceLoader.java
+++ b/modules/common/src/flex/messaging/util/ResourceLoader.java
@@ -1,105 +1,105 @@
-/*
- * 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.util;
-
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * The root interface for classes that provide access to localized resources.
- *
- * @author Seth Hodgson
- * @exclude
- */
-public interface ResourceLoader
-{
- /**
- * Initializes the <code>ResourceLoader</code> using the specified properties.
- *
- * @param properties The initialization properties.
- */
- void init(Map properties);
-
- /**
- * Sets the default locale to be used when locating resources. The
- * string will be converted into a Locale.
- *
- * @param locale The default locale to be used.
- */
- void setDefaultLocale(String locale);
-
- /**
- * Sets the default locale to be used when locating resources.
- *
- * @param locale The default locale to be used.
- */
- void setDefaultLocale(Locale locale);
-
- /**
- * The default locale to be used when locating resources.
- *
- * @return The default locale.
- */
- Locale getDefaultLocale();
-
- /**
- * Gets a string for the given key.
- *
- * @param key The key for the target string.
- * @return The string for the given key.
- */
- String getString(String key);
-
- /**
- * Gets a parameterized string for the given key and substitutes
- * the parameters using the passed array of arguments.
- *
- * @param key The key for the target string.
- * @param arguments The arguments to substitute into the parameterized string.
- * @return The substituted string for the given key.
- * @exception IllegalArgumentException If the parameterized string is invalid,
- * or if an argument in the <code>arguments</code> array
- * is not of the type expected by the format element(s)
- * that use it.
- */
- String getString(String key, Object[] arguments);
-
- /**
- * Gets a string for the given key and locale.
- *
- * @param key The key for the target string.
- * @param locale The target locale for the string.
- * @return The localized string for the given key.
- */
- String getString(String key, Locale locale);
-
- /**
- * Gets a parameterized string for the given key and locale and substitutes the
- * parameters using the passed array of arguments.
- *
- * @param key The key for the target string.
- * @param locale The target locale for the string.
- * @param arguments The arguments to substitute into the parameterized string.
- * @return The substituted localized string for the given key.
- * @exception IllegalArgumentException If the parameterized string is invalid,
- * or if an argument in the <code>arguments</code> array
- * is not of the type expected by the format element(s)
- * that use it.
- */
- String getString(String key, Locale locale, Object[] arguments);
-
-}
+/*
+ * 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.util;
+
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * The root interface for classes that provide access to localized resources.
+ *
+ * @author Seth Hodgson
+ * @exclude
+ */
+public interface ResourceLoader
+{
+ /**
+ * Initializes the <code>ResourceLoader</code> using the specified properties.
+ *
+ * @param properties The initialization properties.
+ */
+ void init(Map properties);
+
+ /**
+ * Sets the default locale to be used when locating resources. The
+ * string will be converted into a Locale.
+ *
+ * @param locale The default locale to be used.
+ */
+ void setDefaultLocale(String locale);
+
+ /**
+ * Sets the default locale to be used when locating resources.
+ *
+ * @param locale The default locale to be used.
+ */
+ void setDefaultLocale(Locale locale);
+
+ /**
+ * The default locale to be used when locating resources.
+ *
+ * @return The default locale.
+ */
+ Locale getDefaultLocale();
+
+ /**
+ * Gets a string for the given key.
+ *
+ * @param key The key for the target string.
+ * @return The string for the given key.
+ */
+ String getString(String key);
+
+ /**
+ * Gets a parameterized string for the given key and substitutes
+ * the parameters using the passed array of arguments.
+ *
+ * @param key The key for the target string.
+ * @param arguments The arguments to substitute into the parameterized string.
+ * @return The substituted string for the given key.
+ * @exception IllegalArgumentException If the parameterized string is invalid,
+ * or if an argument in the <code>arguments</code> array
+ * is not of the type expected by the format element(s)
+ * that use it.
+ */
+ String getString(String key, Object[] arguments);
+
+ /**
+ * Gets a string for the given key and locale.
+ *
+ * @param key The key for the target string.
+ * @param locale The target locale for the string.
+ * @return The localized string for the given key.
+ */
+ String getString(String key, Locale locale);
+
+ /**
+ * Gets a parameterized string for the given key and locale and substitutes the
+ * parameters using the passed array of arguments.
+ *
+ * @param key The key for the target string.
+ * @param locale The target locale for the string.
+ * @param arguments The arguments to substitute into the parameterized string.
+ * @return The substituted localized string for the given key.
+ * @exception IllegalArgumentException If the parameterized string is invalid,
+ * or if an argument in the <code>arguments</code> array
+ * is not of the type expected by the format element(s)
+ * that use it.
+ */
+ String getString(String key, Locale locale, Object[] arguments);
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/StringUtils.java b/modules/common/src/flex/messaging/util/StringUtils.java
old mode 100755
new mode 100644
index 7eca7e6..8ed9720
--- a/modules/common/src/flex/messaging/util/StringUtils.java
+++ b/modules/common/src/flex/messaging/util/StringUtils.java
@@ -1,214 +1,214 @@
-/*
- * 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.util;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-/**
- * @exclude
- */
-public class StringUtils
-{
- /**
- * The String to use for an OS specific line separator.
- */
- public static final String NEWLINE = System.getProperty("line.separator");
-
- public static String substitute(String str, String from, String to)
- {
- if (from == null || from.equals("") || to == null)
- return str;
-
- int index = str.indexOf(from);
-
- if (index == -1)
- return str;
-
- StringBuffer buf = new StringBuffer(str.length());
- int lastIndex = 0;
-
- while (index != -1)
- {
- buf.append(str.substring(lastIndex, index));
- buf.append(to);
- lastIndex = index + from.length();
- index = str.indexOf(from, lastIndex);
- }
-
- // add in last chunk
- buf.append(str.substring(lastIndex));
-
- return buf.toString();
- }
-
- public static boolean findMatchWithWildcard(char[] src, char[] pat)
- {
- if (src == null || pat == null)
- return false;
-
- // we consider an empty pattern to be a don't-match-anything pattern
- if (pat.length == 0)
- return false;
-
- if (src.length == 0)
- return (pat.length == 0 || (pat.length == 1 && (pat[0] == '*' || pat[0] == '?')));
-
- boolean star = false;
-
- int srcLen = src.length;
- int patLen = pat.length;
- int srcIdx = 0;
- int patIdx = 0;
-
- for (; srcIdx < srcLen; srcIdx++)
- {
- if (patIdx == patLen)
- {
- if (patLen < (srcLen - srcIdx))
- patIdx = 0; //Start the search again
- else
- return false;
- }
-
- char s = src[srcIdx];
- char m = pat[patIdx];
-
- switch (m)
- {
- case '*':
- // star on the end
- if (patIdx == pat.length - 1)
- return true;
- star = true;
- ++patIdx;
- break;
-
- case '?':
- ++patIdx;
- break;
-
- default:
- if (s != m)
- {
- if (!star)
- {
- if (patLen < (srcLen - srcIdx))
- patIdx = 0; //Start the search again
- else
- return false;
- }
- }
- else
- {
- star = false;
- ++patIdx;
- }
- break;
- }
- }
-
- if (patIdx < patLen)
- {
- //read off the rest of the pattern and make sure it's all wildcard
- for (; patIdx < patLen; patLen++)
- {
- if (pat[patIdx] != '*')
- {
- return false;
- }
- }
- return true;
- }
-
-
- return !star;
- }
-
- /**
- * Returns a prettified version of the XML, with indentations and
- * linefeeds. Returns the original string if there was an error.
- * @param xml the xml string
- * @return String the prettified xml string
- */
- public static String prettifyXML(String xml)
- {
- String result = xml;
- try
- {
- StringReader reader = new StringReader(xml);
- StringWriter writer = new StringWriter();
- Transformer transformer =
- TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.transform
- (new StreamSource(reader), new StreamResult(writer));
- writer.close();
-
- result = writer.toString();
- }
- catch (TransformerFactoryConfigurationError error)
- {
- // Ignore.
- }
- catch (TransformerException error)
- {
- // Ignore.
- }
- catch (IOException error)
- {
- // Ignore.
- }
- return result;
- }
-
- /**
- * Returns a prettified version of the string, or the original
- * string if the operation is not possible.
- * @param string the string to check
- * @return String the prettified string
- */
- public static String prettifyString(String string)
- {
- String result = string;
- if (string.startsWith("<?xml"))
- {
- result = prettifyXML(string);
- }
- return result;
- }
-
- /**
- * Returns true if a string is null or empty.
- * @param string the String to check
- * @return boolean true if the string is an empty string
- */
- public static boolean isEmpty(String string)
- {
- return string == null || string.length() == 0;
- }
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package flex.messaging.util;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+/**
+ * @exclude
+ */
+public class StringUtils
+{
+ /**
+ * The String to use for an OS specific line separator.
+ */
+ public static final String NEWLINE = System.getProperty("line.separator");
+
+ public static String substitute(String str, String from, String to)
+ {
+ if (from == null || from.equals("") || to == null)
+ return str;
+
+ int index = str.indexOf(from);
+
+ if (index == -1)
+ return str;
+
+ StringBuffer buf = new StringBuffer(str.length());
+ int lastIndex = 0;
+
+ while (index != -1)
+ {
+ buf.append(str.substring(lastIndex, index));
+ buf.append(to);
+ lastIndex = index + from.length();
+ index = str.indexOf(from, lastIndex);
+ }
+
+ // add in last chunk
+ buf.append(str.substring(lastIndex));
+
+ return buf.toString();
+ }
+
+ public static boolean findMatchWithWildcard(char[] src, char[] pat)
+ {
+ if (src == null || pat == null)
+ return false;
+
+ // we consider an empty pattern to be a don't-match-anything pattern
+ if (pat.length == 0)
+ return false;
+
+ if (src.length == 0)
+ return (pat.length == 0 || (pat.length == 1 && (pat[0] == '*' || pat[0] == '?')));
+
+ boolean star = false;
+
+ int srcLen = src.length;
+ int patLen = pat.length;
+ int srcIdx = 0;
+ int patIdx = 0;
+
+ for (; srcIdx < srcLen; srcIdx++)
+ {
+ if (patIdx == patLen)
+ {
+ if (patLen < (srcLen - srcIdx))
+ patIdx = 0; //Start the search again
+ else
+ return false;
+ }
+
+ char s = src[srcIdx];
+ char m = pat[patIdx];
+
+ switch (m)
+ {
+ case '*':
+ // star on the end
+ if (patIdx == pat.length - 1)
+ return true;
+ star = true;
+ ++patIdx;
+ break;
+
+ case '?':
+ ++patIdx;
+ break;
+
+ default:
+ if (s != m)
+ {
+ if (!star)
+ {
+ if (patLen < (srcLen - srcIdx))
+ patIdx = 0; //Start the search again
+ else
+ return false;
+ }
+ }
+ else
+ {
+ star = false;
+ ++patIdx;
+ }
+ break;
+ }
+ }
+
+ if (patIdx < patLen)
+ {
+ //read off the rest of the pattern and make sure it's all wildcard
+ for (; patIdx < patLen; patLen++)
+ {
+ if (pat[patIdx] != '*')
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ return !star;
+ }
+
+ /**
+ * Returns a prettified version of the XML, with indentations and
+ * linefeeds. Returns the original string if there was an error.
+ * @param xml the xml string
+ * @return String the prettified xml string
+ */
+ public static String prettifyXML(String xml)
+ {
+ String result = xml;
+ try
+ {
+ StringReader reader = new StringReader(xml);
+ StringWriter writer = new StringWriter();
+ Transformer transformer =
+ TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ transformer.transform
+ (new StreamSource(reader), new StreamResult(writer));
+ writer.close();
+
+ result = writer.toString();
+ }
+ catch (TransformerFactoryConfigurationError error)
+ {
+ // Ignore.
+ }
+ catch (TransformerException error)
+ {
+ // Ignore.
+ }
+ catch (IOException error)
+ {
+ // Ignore.
+ }
+ return result;
+ }
+
+ /**
+ * Returns a prettified version of the string, or the original
+ * string if the operation is not possible.
+ * @param string the string to check
+ * @return String the prettified string
+ */
+ public static String prettifyString(String string)
+ {
+ String result = string;
+ if (string.startsWith("<?xml"))
+ {
+ result = prettifyXML(string);
+ }
+ return result;
+ }
+
+ /**
+ * Returns true if a string is null or empty.
+ * @param string the String to check
+ * @return boolean true if the string is an empty string
+ */
+ public static boolean isEmpty(String string)
+ {
+ return string == null || string.length() == 0;
+ }
+}
+
[20/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/FlexClientOutboundQueueProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/FlexClientOutboundQueueProcessor.java b/modules/core/src/flex/messaging/client/FlexClientOutboundQueueProcessor.java
old mode 100755
new mode 100644
index 059c3ef..8a5b399
--- a/modules/core/src/flex/messaging/client/FlexClientOutboundQueueProcessor.java
+++ b/modules/core/src/flex/messaging/client/FlexClientOutboundQueueProcessor.java
@@ -1,347 +1,347 @@
-/*
- * 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;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import flex.messaging.Destination;
-import flex.messaging.MessageClient;
-import flex.messaging.MessageDestination;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.messages.Message;
-import flex.messaging.services.messaging.ThrottleManager;
-import flex.messaging.services.messaging.ThrottleManager.ThrottleResult;
-import flex.messaging.services.messaging.ThrottleManager.ThrottleResult.Result;
-
-/**
- * The base FlexClientOutboundQueueProcessor implementation used if a custom implementation is not
- * specified. Its behavior is very simple. It adds all new messages in order to the tail
- * of the outbound queue and flushes all queued messages to the network as quickly as possible.
- * It also handles the outbound client-level throttling specified at the destination level.
- *
- * @author shodgson
- */
-public class FlexClientOutboundQueueProcessor
-{
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * The associated FlexClient.
- */
- private FlexClient client;
-
- /**
- * The last MessageClient messages were flushed to. This is mainly for faster
- * lookup.
- */
- private MessageClient lastMessageClient;
-
- /**
- * The associated endpoint's Id.
- */
- private String endpointId;
-
- /**
- * Manages throttling of outbound client level messages.
- */
- protected OutboundQueueThrottleManager outboundQueueThrottleManager;
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * Stores the Id for the outbound queue's endpoint.
- *
- * @param value The Id for the outbound queue's endpoint.
- */
- public void setEndpointId(String value)
- {
- endpointId = value;
- }
-
- /**
- * Returns the Id for the outbound queue's endpoint.
- *
- * @return The Id for the outbound queue's endpoint.
- */
- public String getEndpointId()
- {
- return endpointId;
- }
-
- /**
- * @exclude
- * Sets the associated FlexClient.
- *
- * @param value The associated FlexClient.
- */
- public void setFlexClient(FlexClient value)
- {
- client = value;
- }
-
- /**
- * Returns the associated FlexClient.
- *
- * @return The associated FlexClient.
- */
- public FlexClient getFlexClient()
- {
- return client;
- }
-
- /**
- * Returns the outbound queue throttle manager, or null if one does not exist.
- *
- * @return The outbound queue throttle manager.
- */
- public OutboundQueueThrottleManager getOutboundQueueThrottleManager()
- {
- return outboundQueueThrottleManager;
- }
-
- /**
- * Utility method to initialize (if necessary) and return an outbound queue
- * throttle manager.
- *
- * @return The outbound queue throttle manager.
- */
- public OutboundQueueThrottleManager getOrCreateOutboundQueueThrottleManager()
- {
- if (outboundQueueThrottleManager == null)
- outboundQueueThrottleManager = new OutboundQueueThrottleManager(this);
- return outboundQueueThrottleManager;
- }
-
- /**
- * No-op; this default implementation doesn't require custom initialization.
- * Subclasses may override to process any custom initialization properties that have been
- * defined in the server configuration.
- *
- * @param properties A ConfigMap containing any custom initialization properties.
- */
- public void initialize(ConfigMap properties) {}
-
- /**
- * Always adds a new message to the tail of the queue.
- *
- * @param outboundQueue The queue of outbound messages.
- * @param message The new message to add to the queue.
- */
- public void add(List<Message> outboundQueue, Message message)
- {
- outboundQueue.add(message);
- }
-
- /**
- * Always empties the queue and returns all messages to be sent to the client.
- *
- * @param outboundQueue The queue of outbound messages.
- * @return A FlushResult containing the messages that have been removed from the outbound queue
- * to be written to the network and a wait time for the next flush of the outbound queue
- * that is the default for the underlying Channel/Endpoint.
- */
- public FlushResult flush(List<Message> outboundQueue)
- {
- return flush(null /* no client distinction */, outboundQueue);
- }
-
- /**
- * Removes all messages in the queue targeted to this specific MessageClient subscription(s) and
- * returns them to be sent to the client.
- * Overrides should be careful to only return messages for the specified MessageClient.
- *
- * @param messageClient The specific MessageClient to return messages for.
- * @param outboundQueue The queue of outbound messages.
- * @return A FlushResult containing the messages that have been removed from the outbound queue
- * to be written to the network for this MessageClient.
- */
- public FlushResult flush(MessageClient messageClient, List<Message> outboundQueue)
- {
- FlushResult flushResult = new FlushResult();
- List<Message> messagesToFlush = null;
-
- for (Iterator<Message> iter = outboundQueue.iterator(); iter.hasNext();)
- {
- Message message = iter.next();
- if (messageClient == null || (message.getClientId().equals(messageClient.getClientId())))
- {
- if (isMessageExpired(message)) // Don't flush expired messages.
- {
- iter.remove();
- continue;
- }
-
- messageClient = messageClient == null? getMessageClient(message) : messageClient;
-
- // First, apply the destination level outbound throttling.
- ThrottleResult throttleResult = throttleOutgoingDestinationLevel(messageClient, message, false);
- Result result = throttleResult.getResult();
-
- // No destination level throttling; check destination-client level throttling.
- if (Result.OK == result)
- {
- throttleResult = throttleOutgoingClientLevel(messageClient, message, false);
- result = throttleResult.getResult();
- // If no throttling, simply add the message to the list.
- if (Result.OK == result)
- {
- updateMessageFrequencyOutgoing(messageClient, message);
- if (messagesToFlush == null)
- messagesToFlush = new ArrayList<Message>();
- messagesToFlush.add(message);
- }
- // In rest of the policies (which is NONE), simply don't
- // add the message to the list.
- }
- iter.remove();
- }
- }
-
- flushResult.setMessages(messagesToFlush);
- return flushResult;
- }
-
- /**
- * Utility method to test whether a message has expired or not.
- * Messages with a timeToLive value that is shorter than the timespan from the message's
- * timestamp up to the current system time will cause this method to return true.
- * If there are expired messages in the outbound queue, flush implementations
- * should use this helper method to only process and return messages that have
- * not yet expired.
- *
- * @param message The message to test for expiration.
- *
- * @return true if the message has a timeToLive value that has expired; otherwise false.
- */
- public boolean isMessageExpired(Message message)
- {
- return (message.getTimeToLive() > 0 && (System.currentTimeMillis() - message.getTimestamp()) >= message.getTimeToLive());
- }
-
- /**
- * Attempts to throttle the outgoing message at the destination level.
- *
- * @param msgClient The client the message is intended for.
- * @param message The message to consider to throttle.
- * @param buffered Whether the message has already been buffered. In that case,
- * parts of regular throttling code is skipped.
- * @return The result of throttling attempt.
- */
- protected ThrottleResult throttleOutgoingDestinationLevel(MessageClient msgClient, Message message, boolean buffered)
- {
- ThrottleManager throttleManager = getThrottleManager(msgClient);
- if (throttleManager != null)
- {
- // In already buffered messages, don't use ThrottleManager#throttleOutgoingMessage
- // to avoid regular throttling handling as the message has already been buffered.
- if (buffered)
- return throttleManager.throttleDestinationLevel(message, false /*incoming*/);
-
- // Otherwise, regular throttling.
- return throttleManager.throttleOutgoingMessage(message);
- }
- return new ThrottleResult(); // Otherwise, return OK result.
- }
-
- /**
- * Attempts to throttle the outgoing message at the destination-client level.
- *
- * @param msgClient The client the message is intended for.
- * @param message The message to consider to throttle.
- * @param buffered Whether the message has already been buffered. In that case,
- * parts of regular throttling code is skipped.
- * @return The result of throttling attempt.
- */
- protected ThrottleResult throttleOutgoingClientLevel(MessageClient msgClient, Message message, boolean buffered)
- {
- if (outboundQueueThrottleManager != null) // Means client level throttling enabled.
- {
- ThrottleResult throttleResult = outboundQueueThrottleManager.throttleOutgoingClientLevel(message);
- if (!buffered)
- {
- ThrottleManager throttleManager = getThrottleManager(msgClient);
- if (throttleManager != null)
- throttleManager.handleOutgoingThrottleResult(message, throttleResult, true /*isClientLevel*/);
- }
- return throttleResult;
- }
- return new ThrottleResult(); // Otherwise, return OK result.
- }
-
- /**
- * Returns the message client that the message is intended to.
- *
- * @param message The message.
- * @return The message client that the message is intended to.
- */
- protected MessageClient getMessageClient(Message message)
- {
- // First try using the cached message client.
- if (lastMessageClient != null && message.getClientId().equals(lastMessageClient.getClientId()))
- {
- return lastMessageClient;
- }
- else // Go ahead with the lookup.
- {
- lastMessageClient = client.getMessageClient((String)message.getClientId());
- return lastMessageClient;
- }
- }
-
- /**
- * Returns the throttle manager associated with the destination the message
- * is intended to.
- *
- * @param msgClient The message client; it can be null.
- * @return The throttle manager.
- */
- protected ThrottleManager getThrottleManager(MessageClient msgClient)
- {
- Destination destination = msgClient != null? msgClient.getDestination() : null;
- return (destination != null && destination instanceof MessageDestination)?
- ((MessageDestination)destination).getThrottleManager() : null;
- }
-
- /**
- * Updates the outgoing message's message frequency.
- *
- * @param msgClient The MessageClient that might have been passed to the flush; it can be null.
- * @param message The message.
- */
- protected void updateMessageFrequencyOutgoing(MessageClient msgClient, Message message)
- {
- // Update the destination level message frequency.
- ThrottleManager throttleManager = getThrottleManager(msgClient);
- if (throttleManager != null)
- throttleManager.updateMessageFrequencyDestinationLevel(false /*incoming*/);
-
- // Update the client level message frequency.
- if (outboundQueueThrottleManager != null)
- outboundQueueThrottleManager.updateMessageFrequencyOutgoingClientLevel(message);
- }
-}
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import flex.messaging.Destination;
+import flex.messaging.MessageClient;
+import flex.messaging.MessageDestination;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.messages.Message;
+import flex.messaging.services.messaging.ThrottleManager;
+import flex.messaging.services.messaging.ThrottleManager.ThrottleResult;
+import flex.messaging.services.messaging.ThrottleManager.ThrottleResult.Result;
+
+/**
+ * The base FlexClientOutboundQueueProcessor implementation used if a custom implementation is not
+ * specified. Its behavior is very simple. It adds all new messages in order to the tail
+ * of the outbound queue and flushes all queued messages to the network as quickly as possible.
+ * It also handles the outbound client-level throttling specified at the destination level.
+ *
+ * @author shodgson
+ */
+public class FlexClientOutboundQueueProcessor
+{
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The associated FlexClient.
+ */
+ private FlexClient client;
+
+ /**
+ * The last MessageClient messages were flushed to. This is mainly for faster
+ * lookup.
+ */
+ private MessageClient lastMessageClient;
+
+ /**
+ * The associated endpoint's Id.
+ */
+ private String endpointId;
+
+ /**
+ * Manages throttling of outbound client level messages.
+ */
+ protected OutboundQueueThrottleManager outboundQueueThrottleManager;
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @exclude
+ * Stores the Id for the outbound queue's endpoint.
+ *
+ * @param value The Id for the outbound queue's endpoint.
+ */
+ public void setEndpointId(String value)
+ {
+ endpointId = value;
+ }
+
+ /**
+ * Returns the Id for the outbound queue's endpoint.
+ *
+ * @return The Id for the outbound queue's endpoint.
+ */
+ public String getEndpointId()
+ {
+ return endpointId;
+ }
+
+ /**
+ * @exclude
+ * Sets the associated FlexClient.
+ *
+ * @param value The associated FlexClient.
+ */
+ public void setFlexClient(FlexClient value)
+ {
+ client = value;
+ }
+
+ /**
+ * Returns the associated FlexClient.
+ *
+ * @return The associated FlexClient.
+ */
+ public FlexClient getFlexClient()
+ {
+ return client;
+ }
+
+ /**
+ * Returns the outbound queue throttle manager, or null if one does not exist.
+ *
+ * @return The outbound queue throttle manager.
+ */
+ public OutboundQueueThrottleManager getOutboundQueueThrottleManager()
+ {
+ return outboundQueueThrottleManager;
+ }
+
+ /**
+ * Utility method to initialize (if necessary) and return an outbound queue
+ * throttle manager.
+ *
+ * @return The outbound queue throttle manager.
+ */
+ public OutboundQueueThrottleManager getOrCreateOutboundQueueThrottleManager()
+ {
+ if (outboundQueueThrottleManager == null)
+ outboundQueueThrottleManager = new OutboundQueueThrottleManager(this);
+ return outboundQueueThrottleManager;
+ }
+
+ /**
+ * No-op; this default implementation doesn't require custom initialization.
+ * Subclasses may override to process any custom initialization properties that have been
+ * defined in the server configuration.
+ *
+ * @param properties A ConfigMap containing any custom initialization properties.
+ */
+ public void initialize(ConfigMap properties) {}
+
+ /**
+ * Always adds a new message to the tail of the queue.
+ *
+ * @param outboundQueue The queue of outbound messages.
+ * @param message The new message to add to the queue.
+ */
+ public void add(List<Message> outboundQueue, Message message)
+ {
+ outboundQueue.add(message);
+ }
+
+ /**
+ * Always empties the queue and returns all messages to be sent to the client.
+ *
+ * @param outboundQueue The queue of outbound messages.
+ * @return A FlushResult containing the messages that have been removed from the outbound queue
+ * to be written to the network and a wait time for the next flush of the outbound queue
+ * that is the default for the underlying Channel/Endpoint.
+ */
+ public FlushResult flush(List<Message> outboundQueue)
+ {
+ return flush(null /* no client distinction */, outboundQueue);
+ }
+
+ /**
+ * Removes all messages in the queue targeted to this specific MessageClient subscription(s) and
+ * returns them to be sent to the client.
+ * Overrides should be careful to only return messages for the specified MessageClient.
+ *
+ * @param messageClient The specific MessageClient to return messages for.
+ * @param outboundQueue The queue of outbound messages.
+ * @return A FlushResult containing the messages that have been removed from the outbound queue
+ * to be written to the network for this MessageClient.
+ */
+ public FlushResult flush(MessageClient messageClient, List<Message> outboundQueue)
+ {
+ FlushResult flushResult = new FlushResult();
+ List<Message> messagesToFlush = null;
+
+ for (Iterator<Message> iter = outboundQueue.iterator(); iter.hasNext();)
+ {
+ Message message = iter.next();
+ if (messageClient == null || (message.getClientId().equals(messageClient.getClientId())))
+ {
+ if (isMessageExpired(message)) // Don't flush expired messages.
+ {
+ iter.remove();
+ continue;
+ }
+
+ messageClient = messageClient == null? getMessageClient(message) : messageClient;
+
+ // First, apply the destination level outbound throttling.
+ ThrottleResult throttleResult = throttleOutgoingDestinationLevel(messageClient, message, false);
+ Result result = throttleResult.getResult();
+
+ // No destination level throttling; check destination-client level throttling.
+ if (Result.OK == result)
+ {
+ throttleResult = throttleOutgoingClientLevel(messageClient, message, false);
+ result = throttleResult.getResult();
+ // If no throttling, simply add the message to the list.
+ if (Result.OK == result)
+ {
+ updateMessageFrequencyOutgoing(messageClient, message);
+ if (messagesToFlush == null)
+ messagesToFlush = new ArrayList<Message>();
+ messagesToFlush.add(message);
+ }
+ // In rest of the policies (which is NONE), simply don't
+ // add the message to the list.
+ }
+ iter.remove();
+ }
+ }
+
+ flushResult.setMessages(messagesToFlush);
+ return flushResult;
+ }
+
+ /**
+ * Utility method to test whether a message has expired or not.
+ * Messages with a timeToLive value that is shorter than the timespan from the message's
+ * timestamp up to the current system time will cause this method to return true.
+ * If there are expired messages in the outbound queue, flush implementations
+ * should use this helper method to only process and return messages that have
+ * not yet expired.
+ *
+ * @param message The message to test for expiration.
+ *
+ * @return true if the message has a timeToLive value that has expired; otherwise false.
+ */
+ public boolean isMessageExpired(Message message)
+ {
+ return (message.getTimeToLive() > 0 && (System.currentTimeMillis() - message.getTimestamp()) >= message.getTimeToLive());
+ }
+
+ /**
+ * Attempts to throttle the outgoing message at the destination level.
+ *
+ * @param msgClient The client the message is intended for.
+ * @param message The message to consider to throttle.
+ * @param buffered Whether the message has already been buffered. In that case,
+ * parts of regular throttling code is skipped.
+ * @return The result of throttling attempt.
+ */
+ protected ThrottleResult throttleOutgoingDestinationLevel(MessageClient msgClient, Message message, boolean buffered)
+ {
+ ThrottleManager throttleManager = getThrottleManager(msgClient);
+ if (throttleManager != null)
+ {
+ // In already buffered messages, don't use ThrottleManager#throttleOutgoingMessage
+ // to avoid regular throttling handling as the message has already been buffered.
+ if (buffered)
+ return throttleManager.throttleDestinationLevel(message, false /*incoming*/);
+
+ // Otherwise, regular throttling.
+ return throttleManager.throttleOutgoingMessage(message);
+ }
+ return new ThrottleResult(); // Otherwise, return OK result.
+ }
+
+ /**
+ * Attempts to throttle the outgoing message at the destination-client level.
+ *
+ * @param msgClient The client the message is intended for.
+ * @param message The message to consider to throttle.
+ * @param buffered Whether the message has already been buffered. In that case,
+ * parts of regular throttling code is skipped.
+ * @return The result of throttling attempt.
+ */
+ protected ThrottleResult throttleOutgoingClientLevel(MessageClient msgClient, Message message, boolean buffered)
+ {
+ if (outboundQueueThrottleManager != null) // Means client level throttling enabled.
+ {
+ ThrottleResult throttleResult = outboundQueueThrottleManager.throttleOutgoingClientLevel(message);
+ if (!buffered)
+ {
+ ThrottleManager throttleManager = getThrottleManager(msgClient);
+ if (throttleManager != null)
+ throttleManager.handleOutgoingThrottleResult(message, throttleResult, true /*isClientLevel*/);
+ }
+ return throttleResult;
+ }
+ return new ThrottleResult(); // Otherwise, return OK result.
+ }
+
+ /**
+ * Returns the message client that the message is intended to.
+ *
+ * @param message The message.
+ * @return The message client that the message is intended to.
+ */
+ protected MessageClient getMessageClient(Message message)
+ {
+ // First try using the cached message client.
+ if (lastMessageClient != null && message.getClientId().equals(lastMessageClient.getClientId()))
+ {
+ return lastMessageClient;
+ }
+ else // Go ahead with the lookup.
+ {
+ lastMessageClient = client.getMessageClient((String)message.getClientId());
+ return lastMessageClient;
+ }
+ }
+
+ /**
+ * Returns the throttle manager associated with the destination the message
+ * is intended to.
+ *
+ * @param msgClient The message client; it can be null.
+ * @return The throttle manager.
+ */
+ protected ThrottleManager getThrottleManager(MessageClient msgClient)
+ {
+ Destination destination = msgClient != null? msgClient.getDestination() : null;
+ return (destination != null && destination instanceof MessageDestination)?
+ ((MessageDestination)destination).getThrottleManager() : null;
+ }
+
+ /**
+ * Updates the outgoing message's message frequency.
+ *
+ * @param msgClient The MessageClient that might have been passed to the flush; it can be null.
+ * @param message The message.
+ */
+ protected void updateMessageFrequencyOutgoing(MessageClient msgClient, Message message)
+ {
+ // Update the destination level message frequency.
+ ThrottleManager throttleManager = getThrottleManager(msgClient);
+ if (throttleManager != null)
+ throttleManager.updateMessageFrequencyDestinationLevel(false /*incoming*/);
+
+ // Update the client level message frequency.
+ if (outboundQueueThrottleManager != null)
+ outboundQueueThrottleManager.updateMessageFrequencyOutgoingClientLevel(message);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/FlushResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/FlushResult.java b/modules/core/src/flex/messaging/client/FlushResult.java
old mode 100755
new mode 100644
index 6dd8cad..ab400fa
--- a/modules/core/src/flex/messaging/client/FlushResult.java
+++ b/modules/core/src/flex/messaging/client/FlushResult.java
@@ -1,117 +1,117 @@
-/*
- * 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;
-
-import java.util.List;
-
-import flex.messaging.messages.Message;
-
-/**
- * Stores the messages that should be written to the network as a result of a flush
- * invocation on a FlexClient's outbound queue.
- */
-public class FlushResult
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs a <tt>FlushResult</tt> instance to return from a
- * flush invocation on a FlexClient's outbound queue.
- * This instance stores the list of messages to write over the network to
- * the client as well as an optional wait time in milliseconds for when the
- * next flush should be invoked.
- */
- public FlushResult() {}
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // messages
- //----------------------------------
-
- private List<Message> messages;
-
- /**
- * Returns the messages to write to the network for this flush invocation.
- * This list may be null, in which case no messages are written.
- *
- * @return The messages to write to the network for this flush invocation.
- */
- public List<Message> getMessages()
- {
- return messages;
- }
-
- /**
- * Sets the messages to write to the network for this flush invocation.
- *
- * @param value The messages to write to the network for this flush invocation.
- */
- public void setMessages(List<Message> value)
- {
- messages = value;
- }
-
- //----------------------------------
- // nextFlushWaitTimeMillis
- //----------------------------------
-
- private int nextFlushWaitTimeMillis = 0;
-
- /**
- * Returns the wait time in milliseconds for when the next flush invocation should occur.
- * If this value is 0, the default, a delayed flush is not scheduled and the next flush will
- * depend upon the underlying Channel/Endpoint.
- * For client-side polling Channels the next flush invocation will happen when the client sends
- * its next poll request at its regular interval.
- * For client-side Channels that support direct writes to the client a flush invocation is triggered
- * when the next message is added to the outbound queue.
- *
- * @return The wait time in milliseconds before flush is next invoked. A value of 0, the default,
- * indicates that the default flush behavior for the underlying Channel/Endpoint should be
- * used.
- */
- public int getNextFlushWaitTimeMillis()
- {
- return nextFlushWaitTimeMillis;
- }
-
- /**
- * Sets the wait time in milliseconds for when the next flush invocation should occur.
- * If this value is 0, the default, a delayed flush is not scheduled and the next flush will
- * depend upon the underlying Channel/Endpoint.
- * For client-side polling Channels the next flush invocation will happen when the client sends
- * its next poll request at its regular interval.
- * For client-side Channels that support direct writes to the client a flush invocation is triggered
- * when the next message is added to the outbound queue.
- * Negative value assignments are treated as 0.
- *
- * @param value The wait time in milliseconds before flush will be invoked.
- */
- public void setNextFlushWaitTimeMillis(int value)
- {
- nextFlushWaitTimeMillis = (value < 1) ? 0 : value;
- }
-}
+/*
+ * 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;
+
+import java.util.List;
+
+import flex.messaging.messages.Message;
+
+/**
+ * Stores the messages that should be written to the network as a result of a flush
+ * invocation on a FlexClient's outbound queue.
+ */
+public class FlushResult
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs a <tt>FlushResult</tt> instance to return from a
+ * flush invocation on a FlexClient's outbound queue.
+ * This instance stores the list of messages to write over the network to
+ * the client as well as an optional wait time in milliseconds for when the
+ * next flush should be invoked.
+ */
+ public FlushResult() {}
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // messages
+ //----------------------------------
+
+ private List<Message> messages;
+
+ /**
+ * Returns the messages to write to the network for this flush invocation.
+ * This list may be null, in which case no messages are written.
+ *
+ * @return The messages to write to the network for this flush invocation.
+ */
+ public List<Message> getMessages()
+ {
+ return messages;
+ }
+
+ /**
+ * Sets the messages to write to the network for this flush invocation.
+ *
+ * @param value The messages to write to the network for this flush invocation.
+ */
+ public void setMessages(List<Message> value)
+ {
+ messages = value;
+ }
+
+ //----------------------------------
+ // nextFlushWaitTimeMillis
+ //----------------------------------
+
+ private int nextFlushWaitTimeMillis = 0;
+
+ /**
+ * Returns the wait time in milliseconds for when the next flush invocation should occur.
+ * If this value is 0, the default, a delayed flush is not scheduled and the next flush will
+ * depend upon the underlying Channel/Endpoint.
+ * For client-side polling Channels the next flush invocation will happen when the client sends
+ * its next poll request at its regular interval.
+ * For client-side Channels that support direct writes to the client a flush invocation is triggered
+ * when the next message is added to the outbound queue.
+ *
+ * @return The wait time in milliseconds before flush is next invoked. A value of 0, the default,
+ * indicates that the default flush behavior for the underlying Channel/Endpoint should be
+ * used.
+ */
+ public int getNextFlushWaitTimeMillis()
+ {
+ return nextFlushWaitTimeMillis;
+ }
+
+ /**
+ * Sets the wait time in milliseconds for when the next flush invocation should occur.
+ * If this value is 0, the default, a delayed flush is not scheduled and the next flush will
+ * depend upon the underlying Channel/Endpoint.
+ * For client-side polling Channels the next flush invocation will happen when the client sends
+ * its next poll request at its regular interval.
+ * For client-side Channels that support direct writes to the client a flush invocation is triggered
+ * when the next message is added to the outbound queue.
+ * Negative value assignments are treated as 0.
+ *
+ * @param value The wait time in milliseconds before flush will be invoked.
+ */
+ public void setNextFlushWaitTimeMillis(int value)
+ {
+ nextFlushWaitTimeMillis = (value < 1) ? 0 : value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/OutboundQueueThrottleManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/OutboundQueueThrottleManager.java b/modules/core/src/flex/messaging/client/OutboundQueueThrottleManager.java
old mode 100755
new mode 100644
index e81a249..24a66d0
--- a/modules/core/src/flex/messaging/client/OutboundQueueThrottleManager.java
+++ b/modules/core/src/flex/messaging/client/OutboundQueueThrottleManager.java
@@ -1,269 +1,269 @@
-/*
- * 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;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-import flex.messaging.MessageClient.SubscriptionInfo;
-import flex.messaging.config.ThrottleSettings.Policy;
-import flex.messaging.log.Log;
-import flex.messaging.messages.Message;
-import flex.messaging.services.messaging.MessageFrequency;
-import flex.messaging.services.messaging.ThrottleManager;
-import flex.messaging.services.messaging.ThrottleManager.ThrottleResult;
-import flex.messaging.util.StringUtils;
-
-
-/**
- * Used to keep track of and limit outbound message rates of a single FlexClient queue.
- * An outbound FlexClient queue can contain messages from multiple MessageClients
- * across multiple destinations. It can also contain messages for multiple
- * subscriptions (for each subtopic/selector) across the same destination for
- * the same MessageClient.
- */
-public class OutboundQueueThrottleManager
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs a default outbound queue throttle manager.
- *
- * @param processor The outbound queue processor that is using this throttle manager.
- */
- public OutboundQueueThrottleManager(FlexClientOutboundQueueProcessor processor)
- {
- destinationFrequencies = new ConcurrentHashMap<String, DestinationFrequency>();
- this.processor = processor;
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Map of destination id and destination message frequencies.
- */
- protected final ConcurrentHashMap<String, DestinationFrequency> destinationFrequencies;
-
- /**
- * The parent queue processor of the throttle manager.
- */
- protected final FlexClientOutboundQueueProcessor processor;
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Registers the destination with the outbound throttle manager.
- *
- * @param destinationId The id of the destination.
- * @param outboundMaxClientFrequency The outbound max-client-frequency specified
- * at the destination.
- * @param outboundPolicy The outbound throttle policy specified at the destination.
- */
- public void registerDestination(String destinationId, int outboundMaxClientFrequency, Policy outboundPolicy)
- {
- DestinationFrequency frequency = destinationFrequencies.get(destinationId);
- if (frequency == null)
- {
- frequency = new DestinationFrequency(outboundMaxClientFrequency, outboundPolicy);
- destinationFrequencies.putIfAbsent(destinationId, frequency);
- }
- }
-
- /**
- * Registers the subscription of a client talking to a destination with the
- * specified subscription info.
- *
- * @param destinationId The destination id.
- * @param si The subscription information.
- */
- public void registerSubscription(String destinationId, SubscriptionInfo si)
- {
- DestinationFrequency frequency = destinationFrequencies.get(destinationId);
- frequency.logMaxFrequencyDuringRegistration(frequency.outboundMaxClientFrequency, si);
- }
-
- /**
- * Unregisters the subscription.
- *
- * @param destinationId The destination id.
- * @param si The subscription information.
- */
- public void unregisterSubscription(String destinationId, SubscriptionInfo si)
- {
- unregisterDestination(destinationId);
- }
-
- /**
- * Unregisters all subscriptions of the client under the specified destination.
- *
- * @param destinationId The destination id.
- */
- public void unregisterAllSubscriptions(String destinationId)
- {
- unregisterDestination(destinationId);
- }
-
- /**
- * Attempts to throttle the outgoing message.
- *
- * @param message The message to consider to throttle.
- * @return True if the message was throttled; otherwise false.
- */
- public ThrottleResult throttleOutgoingClientLevel(Message message)
- {
- String destinationId = message.getDestination();
- if (isDestinationRegistered(destinationId))
- {
- DestinationFrequency frequency = destinationFrequencies.get(message.getDestination());
- int maxFrequency = frequency.getMaxFrequency(message); // Limit to check against.
- MessageFrequency messageFrequency = frequency.getMessageFrequency(message); // Message rate of the client.
- if (messageFrequency != null)
- {
- ThrottleResult result = messageFrequency.checkLimit(maxFrequency, frequency.outboundPolicy);
- return result;
- }
- }
- return new ThrottleResult(); // Otherwise, return OK result.
- }
-
- /**
- * Updates the outgoing client level message frequency of the message.
- *
- * @param message The message.
- */
- public void updateMessageFrequencyOutgoingClientLevel(Message message)
- {
- String destinationId = message.getDestination();
- if (isDestinationRegistered(destinationId))
- {
- DestinationFrequency frequency = destinationFrequencies.get(message.getDestination());
- MessageFrequency messageFrequency = frequency.getMessageFrequency(message);
- if (messageFrequency != null)
- messageFrequency.updateMessageFrequency();
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Determines whether the destination has been registered or not.
- *
- * @param destinationId The destination id.
- * @return True if the destination with the specified id has been registered.
- */
- protected boolean isDestinationRegistered(String destinationId)
- {
- return destinationFrequencies.containsKey(destinationId);
- }
-
- /**
- * Unregisters the destination from the outbound throttle manager.
- *
- * @param destinationId The id of the destination.
- */
- protected void unregisterDestination(String destinationId)
- {
- if (isDestinationRegistered(destinationId))
- destinationFrequencies.remove(destinationId);
- }
-
- //--------------------------------------------------------------------------
- //
- // Inner Classes
- //
- //--------------------------------------------------------------------------
-
- /**
- * Used to keep track of max-client-frequency and outgoing throttle policy
- * specified at the destination. It also keeps track of outbound message
- * rates of all MessageClient subscriptions across the destination.
- */
- class DestinationFrequency
- {
- protected final int outboundMaxClientFrequency; // destination specified client limit.
- protected final MessageFrequency outboundClientFrequency;
- protected final Policy outboundPolicy; // destination specified policy.
-
- /**
- * Default constructor.
- *
- * @param outboundMaxClientFrequency The outbound throttling max-client-frequency of the destination.
- * @param outboundPolicy The outbound throttling policy of the destination.
- */
- DestinationFrequency(int outboundMaxClientFrequency, Policy outboundPolicy)
- {
- this.outboundMaxClientFrequency = outboundMaxClientFrequency;
- this.outboundPolicy = outboundPolicy;
- outboundClientFrequency = new MessageFrequency(outboundMaxClientFrequency);
- }
-
- /**
- * Returns the max-client-frequency for the subscription the message is
- * intended for (which is simply the max-client-frequency specified at
- * the destination).
- *
- * @param message The message.
- *
- * @return The max-frequency for the subscription.
- */
- int getMaxFrequency(Message message)
- {
- return outboundMaxClientFrequency;
- }
-
- /**
- * Given a subscription the message is intended to, returns the message
- * rate frequency for that subscription.
- *
- * @param message The message.
- * @return The message frequency for the subscription, if it exists; otherwise null.
- */
- MessageFrequency getMessageFrequency(Message message)
- {
- return outboundClientFrequency;
- }
-
- /**
- * Utility function to log the maxFrequency being used during subscription.
- *
- * @param maxFrequency The maxFrequency to log.
- */
- void logMaxFrequencyDuringRegistration(int maxFrequency, SubscriptionInfo si)
- {
- if (Log.isDebug())
- Log.getLogger(ThrottleManager.LOG_CATEGORY).debug("Outbound queue throttle manager for FlexClient '"
- + processor.getFlexClient().getId() + "' is using '" + maxFrequency
- + "' as the throttling limit for its subscription: "
- + StringUtils.NEWLINE + si);
- }
- }
+/*
+ * 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;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+import flex.messaging.MessageClient.SubscriptionInfo;
+import flex.messaging.config.ThrottleSettings.Policy;
+import flex.messaging.log.Log;
+import flex.messaging.messages.Message;
+import flex.messaging.services.messaging.MessageFrequency;
+import flex.messaging.services.messaging.ThrottleManager;
+import flex.messaging.services.messaging.ThrottleManager.ThrottleResult;
+import flex.messaging.util.StringUtils;
+
+
+/**
+ * Used to keep track of and limit outbound message rates of a single FlexClient queue.
+ * An outbound FlexClient queue can contain messages from multiple MessageClients
+ * across multiple destinations. It can also contain messages for multiple
+ * subscriptions (for each subtopic/selector) across the same destination for
+ * the same MessageClient.
+ */
+public class OutboundQueueThrottleManager
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs a default outbound queue throttle manager.
+ *
+ * @param processor The outbound queue processor that is using this throttle manager.
+ */
+ public OutboundQueueThrottleManager(FlexClientOutboundQueueProcessor processor)
+ {
+ destinationFrequencies = new ConcurrentHashMap<String, DestinationFrequency>();
+ this.processor = processor;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Map of destination id and destination message frequencies.
+ */
+ protected final ConcurrentHashMap<String, DestinationFrequency> destinationFrequencies;
+
+ /**
+ * The parent queue processor of the throttle manager.
+ */
+ protected final FlexClientOutboundQueueProcessor processor;
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Registers the destination with the outbound throttle manager.
+ *
+ * @param destinationId The id of the destination.
+ * @param outboundMaxClientFrequency The outbound max-client-frequency specified
+ * at the destination.
+ * @param outboundPolicy The outbound throttle policy specified at the destination.
+ */
+ public void registerDestination(String destinationId, int outboundMaxClientFrequency, Policy outboundPolicy)
+ {
+ DestinationFrequency frequency = destinationFrequencies.get(destinationId);
+ if (frequency == null)
+ {
+ frequency = new DestinationFrequency(outboundMaxClientFrequency, outboundPolicy);
+ destinationFrequencies.putIfAbsent(destinationId, frequency);
+ }
+ }
+
+ /**
+ * Registers the subscription of a client talking to a destination with the
+ * specified subscription info.
+ *
+ * @param destinationId The destination id.
+ * @param si The subscription information.
+ */
+ public void registerSubscription(String destinationId, SubscriptionInfo si)
+ {
+ DestinationFrequency frequency = destinationFrequencies.get(destinationId);
+ frequency.logMaxFrequencyDuringRegistration(frequency.outboundMaxClientFrequency, si);
+ }
+
+ /**
+ * Unregisters the subscription.
+ *
+ * @param destinationId The destination id.
+ * @param si The subscription information.
+ */
+ public void unregisterSubscription(String destinationId, SubscriptionInfo si)
+ {
+ unregisterDestination(destinationId);
+ }
+
+ /**
+ * Unregisters all subscriptions of the client under the specified destination.
+ *
+ * @param destinationId The destination id.
+ */
+ public void unregisterAllSubscriptions(String destinationId)
+ {
+ unregisterDestination(destinationId);
+ }
+
+ /**
+ * Attempts to throttle the outgoing message.
+ *
+ * @param message The message to consider to throttle.
+ * @return True if the message was throttled; otherwise false.
+ */
+ public ThrottleResult throttleOutgoingClientLevel(Message message)
+ {
+ String destinationId = message.getDestination();
+ if (isDestinationRegistered(destinationId))
+ {
+ DestinationFrequency frequency = destinationFrequencies.get(message.getDestination());
+ int maxFrequency = frequency.getMaxFrequency(message); // Limit to check against.
+ MessageFrequency messageFrequency = frequency.getMessageFrequency(message); // Message rate of the client.
+ if (messageFrequency != null)
+ {
+ ThrottleResult result = messageFrequency.checkLimit(maxFrequency, frequency.outboundPolicy);
+ return result;
+ }
+ }
+ return new ThrottleResult(); // Otherwise, return OK result.
+ }
+
+ /**
+ * Updates the outgoing client level message frequency of the message.
+ *
+ * @param message The message.
+ */
+ public void updateMessageFrequencyOutgoingClientLevel(Message message)
+ {
+ String destinationId = message.getDestination();
+ if (isDestinationRegistered(destinationId))
+ {
+ DestinationFrequency frequency = destinationFrequencies.get(message.getDestination());
+ MessageFrequency messageFrequency = frequency.getMessageFrequency(message);
+ if (messageFrequency != null)
+ messageFrequency.updateMessageFrequency();
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Determines whether the destination has been registered or not.
+ *
+ * @param destinationId The destination id.
+ * @return True if the destination with the specified id has been registered.
+ */
+ protected boolean isDestinationRegistered(String destinationId)
+ {
+ return destinationFrequencies.containsKey(destinationId);
+ }
+
+ /**
+ * Unregisters the destination from the outbound throttle manager.
+ *
+ * @param destinationId The id of the destination.
+ */
+ protected void unregisterDestination(String destinationId)
+ {
+ if (isDestinationRegistered(destinationId))
+ destinationFrequencies.remove(destinationId);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Inner Classes
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Used to keep track of max-client-frequency and outgoing throttle policy
+ * specified at the destination. It also keeps track of outbound message
+ * rates of all MessageClient subscriptions across the destination.
+ */
+ class DestinationFrequency
+ {
+ protected final int outboundMaxClientFrequency; // destination specified client limit.
+ protected final MessageFrequency outboundClientFrequency;
+ protected final Policy outboundPolicy; // destination specified policy.
+
+ /**
+ * Default constructor.
+ *
+ * @param outboundMaxClientFrequency The outbound throttling max-client-frequency of the destination.
+ * @param outboundPolicy The outbound throttling policy of the destination.
+ */
+ DestinationFrequency(int outboundMaxClientFrequency, Policy outboundPolicy)
+ {
+ this.outboundMaxClientFrequency = outboundMaxClientFrequency;
+ this.outboundPolicy = outboundPolicy;
+ outboundClientFrequency = new MessageFrequency(outboundMaxClientFrequency);
+ }
+
+ /**
+ * Returns the max-client-frequency for the subscription the message is
+ * intended for (which is simply the max-client-frequency specified at
+ * the destination).
+ *
+ * @param message The message.
+ *
+ * @return The max-frequency for the subscription.
+ */
+ int getMaxFrequency(Message message)
+ {
+ return outboundMaxClientFrequency;
+ }
+
+ /**
+ * Given a subscription the message is intended to, returns the message
+ * rate frequency for that subscription.
+ *
+ * @param message The message.
+ * @return The message frequency for the subscription, if it exists; otherwise null.
+ */
+ MessageFrequency getMessageFrequency(Message message)
+ {
+ return outboundClientFrequency;
+ }
+
+ /**
+ * Utility function to log the maxFrequency being used during subscription.
+ *
+ * @param maxFrequency The maxFrequency to log.
+ */
+ void logMaxFrequencyDuringRegistration(int maxFrequency, SubscriptionInfo si)
+ {
+ if (Log.isDebug())
+ Log.getLogger(ThrottleManager.LOG_CATEGORY).debug("Outbound queue throttle manager for FlexClient '"
+ + processor.getFlexClient().getId() + "' is using '" + maxFrequency
+ + "' as the throttling limit for its subscription: "
+ + StringUtils.NEWLINE + si);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/PollFlushResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/PollFlushResult.java b/modules/core/src/flex/messaging/client/PollFlushResult.java
old mode 100755
new mode 100644
index fe4a76d..dc8e33b
--- a/modules/core/src/flex/messaging/client/PollFlushResult.java
+++ b/modules/core/src/flex/messaging/client/PollFlushResult.java
@@ -1,97 +1,97 @@
-/*
- * 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;
-
-/**
- * Extends <tt>FlushResult</tt> and adds additional properties for controlling
- * client polling behavior.
- */
-public class PollFlushResult extends FlushResult
-{
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // avoidBusyPolling
- //----------------------------------
-
- private boolean avoidBusyPolling;
-
- /**
- * Indicates whether the handling of this result should attempt to avoid
- * potential busy-polling cycles.
- * This will be set to <code>true</code> in the case of two clients that are both
- * long-polling the server over the same session.
- *
- * @return <code>true</code> if the handling of this result should attempt to avoid potential
- * busy-polling cycles.
- */
- public boolean isAvoidBusyPolling()
- {
- return avoidBusyPolling;
- }
-
- /**
- * Set to <code>true</code> to signal that handling for this result should attempt to avoid
- * potential busy-polling cycles.
- *
- * @param value <code>true</code> to signal that handling for this result should attempt to
- * avoid potential busy-polling cycles.
- */
- public void setAvoidBusyPolling(boolean value)
- {
- avoidBusyPolling = value;
- }
-
- //----------------------------------
- // clientProcessingSuppressed
- //----------------------------------
-
- private boolean clientProcessingSuppressed;
-
- /**
- * Indicates whether client processing of this result should be
- * suppressed.
- * This should be <code>true</code> for results generated for poll requests
- * that arrive while a long-poll request from the same client is being serviced
- * to avoid a busy polling cycle.
- *
- * @return <code>true</code> if client processing of this result should be suppressed;
- * otherwise <code>false</code>.
- */
- public boolean isClientProcessingSuppressed()
- {
- return clientProcessingSuppressed;
- }
-
- /**
- * Set to <code>true</code> to suppress client processing of this result.
- * Default is <code>false</code>.
- * This should be set to <code>true</code> for results generated for poll requests
- * that arrive while a long-poll request from the same client is being serviced
- * to avoid a busy polling cycle.
- *
- * @param value <code>true</code> to suppress client processing of the result.
- */
- public void setClientProcessingSuppressed(boolean value)
- {
- clientProcessingSuppressed = value;
- }
-}
+/*
+ * 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;
+
+/**
+ * Extends <tt>FlushResult</tt> and adds additional properties for controlling
+ * client polling behavior.
+ */
+public class PollFlushResult extends FlushResult
+{
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // avoidBusyPolling
+ //----------------------------------
+
+ private boolean avoidBusyPolling;
+
+ /**
+ * Indicates whether the handling of this result should attempt to avoid
+ * potential busy-polling cycles.
+ * This will be set to <code>true</code> in the case of two clients that are both
+ * long-polling the server over the same session.
+ *
+ * @return <code>true</code> if the handling of this result should attempt to avoid potential
+ * busy-polling cycles.
+ */
+ public boolean isAvoidBusyPolling()
+ {
+ return avoidBusyPolling;
+ }
+
+ /**
+ * Set to <code>true</code> to signal that handling for this result should attempt to avoid
+ * potential busy-polling cycles.
+ *
+ * @param value <code>true</code> to signal that handling for this result should attempt to
+ * avoid potential busy-polling cycles.
+ */
+ public void setAvoidBusyPolling(boolean value)
+ {
+ avoidBusyPolling = value;
+ }
+
+ //----------------------------------
+ // clientProcessingSuppressed
+ //----------------------------------
+
+ private boolean clientProcessingSuppressed;
+
+ /**
+ * Indicates whether client processing of this result should be
+ * suppressed.
+ * This should be <code>true</code> for results generated for poll requests
+ * that arrive while a long-poll request from the same client is being serviced
+ * to avoid a busy polling cycle.
+ *
+ * @return <code>true</code> if client processing of this result should be suppressed;
+ * otherwise <code>false</code>.
+ */
+ public boolean isClientProcessingSuppressed()
+ {
+ return clientProcessingSuppressed;
+ }
+
+ /**
+ * Set to <code>true</code> to suppress client processing of this result.
+ * Default is <code>false</code>.
+ * This should be set to <code>true</code> for results generated for poll requests
+ * that arrive while a long-poll request from the same client is being serviced
+ * to avoid a busy polling cycle.
+ *
+ * @param value <code>true</code> to suppress client processing of the result.
+ */
+ public void setClientProcessingSuppressed(boolean value)
+ {
+ clientProcessingSuppressed = value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/PollWaitListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/PollWaitListener.java b/modules/core/src/flex/messaging/client/PollWaitListener.java
old mode 100755
new mode 100644
index ae4b820..7978e6f
--- a/modules/core/src/flex/messaging/client/PollWaitListener.java
+++ b/modules/core/src/flex/messaging/client/PollWaitListener.java
@@ -1,40 +1,40 @@
-/*
- * 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;
-
-/**
- * Used alongside invocations of <code>FlexClient.pollWithWait()</code> to allow calling code to
- * maintain a record of the Objects being used to place waited poll requests into a wait
- * state. This can be used to break the threads out of their wait state separately from the
- * internal waited poll handling within <code>FlexClient</code>.
- */
-public interface PollWaitListener
-{
- /**
- * Hook method invoked directly before a wait begins.
- *
- * @param notifier The <tt>Object</tt> being used to <code>wait()/notify()</code>.
- */
- void waitStart(Object notifier);
-
- /**
- * Hook method invoked directly after a wait completes.
- *
- * @param notifier The <tt>Object</tt> being used to <code>wait()/notify()</code>.
- */
- void waitEnd(Object notifier);
-}
+/*
+ * 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;
+
+/**
+ * Used alongside invocations of <code>FlexClient.pollWithWait()</code> to allow calling code to
+ * maintain a record of the Objects being used to place waited poll requests into a wait
+ * state. This can be used to break the threads out of their wait state separately from the
+ * internal waited poll handling within <code>FlexClient</code>.
+ */
+public interface PollWaitListener
+{
+ /**
+ * Hook method invoked directly before a wait begins.
+ *
+ * @param notifier The <tt>Object</tt> being used to <code>wait()/notify()</code>.
+ */
+ void waitStart(Object notifier);
+
+ /**
+ * Hook method invoked directly after a wait completes.
+ *
+ * @param notifier The <tt>Object</tt> being used to <code>wait()/notify()</code>.
+ */
+ void waitEnd(Object notifier);
+}
[06/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/StreamingHTTPEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/StreamingHTTPEndpoint.java b/modules/core/src/flex/messaging/endpoints/StreamingHTTPEndpoint.java
old mode 100755
new mode 100644
index aadf1ba..a5e1c66
--- a/modules/core/src/flex/messaging/endpoints/StreamingHTTPEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/StreamingHTTPEndpoint.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.endpoints;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-
-import flex.management.runtime.messaging.endpoints.StreamingHTTPEndpointControl;
-import flex.messaging.MessageBroker;
-import flex.messaging.endpoints.amf.AMFFilter;
-import flex.messaging.endpoints.amf.BatchProcessFilter;
-import flex.messaging.endpoints.amf.MessageBrokerFilter;
-import flex.messaging.endpoints.amf.SerializationFilter;
-import flex.messaging.endpoints.amf.SessionFilter;
-import flex.messaging.io.MessageIOConstants;
-import flex.messaging.io.TypeMarshallingContext;
-import flex.messaging.io.amfx.AmfxOutput;
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.messages.Message;
-
-/**
- * Extension to the HTTPEndpoint to support streaming HTTP connections to connected
- * clients.
- * Each streaming connection managed by this endpoint consumes one of the request
- * handler threads provided by the servlet container, so it is not highly scalable
- * but offers performance advantages over client polling for clients receiving a steady,
- * rapid stream of pushed messages.
- * This endpoint does not support polling clients and will fault any poll requests
- * that are received. To support polling clients use HTTPEndpoint instead.
- */
-public class StreamingHTTPEndpoint extends BaseStreamingHTTPEndpoint
-{
- //--------------------------------------------------------------------------
- //
- // Public Constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * The log category for this endpoint.
- */
- public static final String LOG_CATEGORY = LogCategories.ENDPOINT_STREAMING_HTTP;
-
- //--------------------------------------------------------------------------
- //
- // Constructors
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>StreamingHTTPEndpoint</code>.
- */
- public StreamingHTTPEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>StreamingHTTPEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>StreamingHTTPEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public StreamingHTTPEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Create default filter chain or return current one if already present.
- */
- @Override protected AMFFilter createFilterChain()
- {
- AMFFilter serializationFilter = new SerializationFilter(getLogCategory());
- AMFFilter batchFilter = new BatchProcessFilter();
- AMFFilter sessionFilter = sessionRewritingEnabled? new SessionFilter() : null;
- AMFFilter messageBrokerFilter = new MessageBrokerFilter(this);
-
- serializationFilter.setNext(batchFilter);
- if (sessionFilter != null)
- {
- batchFilter.setNext(sessionFilter);
- sessionFilter.setNext(messageBrokerFilter);
- }
- else
- {
- batchFilter.setNext(messageBrokerFilter);
- }
-
- return serializationFilter;
- }
-
- /**
- * Returns MessageIOConstants.XML_CONTENT_TYPE.
- */
- @Override protected String getResponseContentType()
- {
- return MessageIOConstants.XML_CONTENT_TYPE;
- }
-
- /**
- * Returns the log category of the endpoint.
- *
- * @return The log category of the endpoint.
- */
- @Override protected String getLogCategory()
- {
- return LOG_CATEGORY;
- }
-
- /**
- * Used internally for performance information gathering; not intended for
- * public use. Serializes the message in AMFX format and returns the size
- * of the serialized message.
- *
- * @param message Message to get the size for.
- *
- * @return The size of the message after message is serialized.
- */
- @Override protected long getMessageSizeForPerformanceInfo(Message message)
- {
- AmfxOutput amfxOut = new AmfxOutput(serializationContext);
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- DataOutputStream dataOutStream = new DataOutputStream(outStream);
- amfxOut.setOutputStream(dataOutStream);
- try
- {
- amfxOut.writeObject(message);
- }
- catch (IOException e)
- {
- if (Log.isDebug())
- log.debug("MPI exception while retrieving the size of the serialized message: " + e.toString());
- }
- return dataOutStream.size();
- }
-
- /**
- * Returns the deserializer class name used by the endpoint.
- *
- * @return The deserializer class name used by the endpoint.
- */
- @Override protected String getDeserializerClassName()
- {
- return "flex.messaging.io.amfx.AmfxMessageDeserializer";
- }
-
- /**
- * Returns the serializer class name used by the endpoint.
- *
- * @return The serializer class name used by the endpoint.
- */
- @Override protected String getSerializerClassName()
- {
- return "flex.messaging.io.amfx.AmfxMessageSerializer";
- }
-
- /**
- * Invoked automatically to allow the <code>StreamingHTTPEndpoint</code> to setup its
- * corresponding MBean control.
- *
- * @param broker The <code>MessageBroker</code> that manages this
- * <code>StreamingHTTPEndpoint</code>.
- */
- @Override protected void setupEndpointControl(MessageBroker broker)
- {
- controller = new StreamingHTTPEndpointControl(this, broker.getControl());
- controller.register();
- setControl(controller);
- }
-
- /**
- * Helper method invoked by the endpoint request handler thread cycling in wait-notify.
- * Serializes messages and streams each to the client as a response chunk using streamChunk().
- *
- * @param messages The messages to serialize and push to the client.
- * @param os The output stream the chunk will be written to.
- * @param response The HttpServletResponse, used to flush the chunk to the client.
- */
- @Override protected void streamMessages(List messages, ServletOutputStream os, HttpServletResponse response) throws IOException
- {
- if (messages == null || messages.isEmpty())
- return;
-
- // Serialize each message as a separate chunk of bytes.
- TypeMarshallingContext.setTypeMarshaller(getTypeMarshaller());
- for (Iterator iter = messages.iterator(); iter.hasNext();)
- {
- Message message = (Message)iter.next();
- addPerformanceInfo(message);
-
- message = convertPushMessageToSmall(message);
-
- if (Log.isDebug())
- log.debug("Endpoint with id '" + getId() + "' is streaming message: " + message);
-
- AmfxOutput amfxOut = new AmfxOutput(serializationContext);
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- DataOutputStream dataOutStream = new DataOutputStream(outStream);
- amfxOut.setOutputStream(dataOutStream);
-
- amfxOut.writeObject(message);
- dataOutStream.flush();
- byte[] messageBytes = outStream.toByteArray();
- streamChunk(messageBytes, os, response);
-
- if (isManaged())
- ((StreamingHTTPEndpointControl)controller).incrementPushCount();
- }
- TypeMarshallingContext.setTypeMarshaller(null);
- }
+/*
+ * 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.endpoints;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import flex.management.runtime.messaging.endpoints.StreamingHTTPEndpointControl;
+import flex.messaging.MessageBroker;
+import flex.messaging.endpoints.amf.AMFFilter;
+import flex.messaging.endpoints.amf.BatchProcessFilter;
+import flex.messaging.endpoints.amf.MessageBrokerFilter;
+import flex.messaging.endpoints.amf.SerializationFilter;
+import flex.messaging.endpoints.amf.SessionFilter;
+import flex.messaging.io.MessageIOConstants;
+import flex.messaging.io.TypeMarshallingContext;
+import flex.messaging.io.amfx.AmfxOutput;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.messages.Message;
+
+/**
+ * Extension to the HTTPEndpoint to support streaming HTTP connections to connected
+ * clients.
+ * Each streaming connection managed by this endpoint consumes one of the request
+ * handler threads provided by the servlet container, so it is not highly scalable
+ * but offers performance advantages over client polling for clients receiving a steady,
+ * rapid stream of pushed messages.
+ * This endpoint does not support polling clients and will fault any poll requests
+ * that are received. To support polling clients use HTTPEndpoint instead.
+ */
+public class StreamingHTTPEndpoint extends BaseStreamingHTTPEndpoint
+{
+ //--------------------------------------------------------------------------
+ //
+ // Public Constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The log category for this endpoint.
+ */
+ public static final String LOG_CATEGORY = LogCategories.ENDPOINT_STREAMING_HTTP;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructors
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>StreamingHTTPEndpoint</code>.
+ */
+ public StreamingHTTPEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>StreamingHTTPEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>StreamingHTTPEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public StreamingHTTPEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Create default filter chain or return current one if already present.
+ */
+ @Override protected AMFFilter createFilterChain()
+ {
+ AMFFilter serializationFilter = new SerializationFilter(getLogCategory());
+ AMFFilter batchFilter = new BatchProcessFilter();
+ AMFFilter sessionFilter = sessionRewritingEnabled? new SessionFilter() : null;
+ AMFFilter messageBrokerFilter = new MessageBrokerFilter(this);
+
+ serializationFilter.setNext(batchFilter);
+ if (sessionFilter != null)
+ {
+ batchFilter.setNext(sessionFilter);
+ sessionFilter.setNext(messageBrokerFilter);
+ }
+ else
+ {
+ batchFilter.setNext(messageBrokerFilter);
+ }
+
+ return serializationFilter;
+ }
+
+ /**
+ * Returns MessageIOConstants.XML_CONTENT_TYPE.
+ */
+ @Override protected String getResponseContentType()
+ {
+ return MessageIOConstants.XML_CONTENT_TYPE;
+ }
+
+ /**
+ * Returns the log category of the endpoint.
+ *
+ * @return The log category of the endpoint.
+ */
+ @Override protected String getLogCategory()
+ {
+ return LOG_CATEGORY;
+ }
+
+ /**
+ * Used internally for performance information gathering; not intended for
+ * public use. Serializes the message in AMFX format and returns the size
+ * of the serialized message.
+ *
+ * @param message Message to get the size for.
+ *
+ * @return The size of the message after message is serialized.
+ */
+ @Override protected long getMessageSizeForPerformanceInfo(Message message)
+ {
+ AmfxOutput amfxOut = new AmfxOutput(serializationContext);
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ DataOutputStream dataOutStream = new DataOutputStream(outStream);
+ amfxOut.setOutputStream(dataOutStream);
+ try
+ {
+ amfxOut.writeObject(message);
+ }
+ catch (IOException e)
+ {
+ if (Log.isDebug())
+ log.debug("MPI exception while retrieving the size of the serialized message: " + e.toString());
+ }
+ return dataOutStream.size();
+ }
+
+ /**
+ * Returns the deserializer class name used by the endpoint.
+ *
+ * @return The deserializer class name used by the endpoint.
+ */
+ @Override protected String getDeserializerClassName()
+ {
+ return "flex.messaging.io.amfx.AmfxMessageDeserializer";
+ }
+
+ /**
+ * Returns the serializer class name used by the endpoint.
+ *
+ * @return The serializer class name used by the endpoint.
+ */
+ @Override protected String getSerializerClassName()
+ {
+ return "flex.messaging.io.amfx.AmfxMessageSerializer";
+ }
+
+ /**
+ * Invoked automatically to allow the <code>StreamingHTTPEndpoint</code> to setup its
+ * corresponding MBean control.
+ *
+ * @param broker The <code>MessageBroker</code> that manages this
+ * <code>StreamingHTTPEndpoint</code>.
+ */
+ @Override protected void setupEndpointControl(MessageBroker broker)
+ {
+ controller = new StreamingHTTPEndpointControl(this, broker.getControl());
+ controller.register();
+ setControl(controller);
+ }
+
+ /**
+ * Helper method invoked by the endpoint request handler thread cycling in wait-notify.
+ * Serializes messages and streams each to the client as a response chunk using streamChunk().
+ *
+ * @param messages The messages to serialize and push to the client.
+ * @param os The output stream the chunk will be written to.
+ * @param response The HttpServletResponse, used to flush the chunk to the client.
+ */
+ @Override protected void streamMessages(List messages, ServletOutputStream os, HttpServletResponse response) throws IOException
+ {
+ if (messages == null || messages.isEmpty())
+ return;
+
+ // Serialize each message as a separate chunk of bytes.
+ TypeMarshallingContext.setTypeMarshaller(getTypeMarshaller());
+ for (Iterator iter = messages.iterator(); iter.hasNext();)
+ {
+ Message message = (Message)iter.next();
+ addPerformanceInfo(message);
+
+ message = convertPushMessageToSmall(message);
+
+ if (Log.isDebug())
+ log.debug("Endpoint with id '" + getId() + "' is streaming message: " + message);
+
+ AmfxOutput amfxOut = new AmfxOutput(serializationContext);
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ DataOutputStream dataOutStream = new DataOutputStream(outStream);
+ amfxOut.setOutputStream(dataOutStream);
+
+ amfxOut.writeObject(message);
+ dataOutStream.flush();
+ byte[] messageBytes = outStream.toByteArray();
+ streamChunk(messageBytes, os, response);
+
+ if (isManaged())
+ ((StreamingHTTPEndpointControl)controller).incrementPushCount();
+ }
+ TypeMarshallingContext.setTypeMarshaller(null);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/amf/AMFFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/amf/AMFFilter.java b/modules/core/src/flex/messaging/endpoints/amf/AMFFilter.java
old mode 100755
new mode 100644
index b0f035e..9871adb
--- a/modules/core/src/flex/messaging/endpoints/amf/AMFFilter.java
+++ b/modules/core/src/flex/messaging/endpoints/amf/AMFFilter.java
@@ -1,53 +1,53 @@
-/*
- * 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.endpoints.amf;
-
-import flex.messaging.io.amf.ActionContext;
-
-import java.io.IOException;
-
-/**
- * Filters perform pre- and post-processing duties on the ActionContext,
- * which contains the message/invocation as well as conextual information
- * about it, following the standard pipe-and-filter design pattern.
- *
- * @author PS Neville
- */
-public abstract class AMFFilter
-{
- protected AMFFilter next;
-
- public AMFFilter()
- {
- }
-
- public void setNext(AMFFilter next)
- {
- this.next = next;
- }
-
- public AMFFilter getNext()
- {
- return next;
- }
-
- /**
- * The core business method.
- */
- public abstract void invoke(final ActionContext context) throws IOException;
-
-}
+/*
+ * 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.endpoints.amf;
+
+import flex.messaging.io.amf.ActionContext;
+
+import java.io.IOException;
+
+/**
+ * Filters perform pre- and post-processing duties on the ActionContext,
+ * which contains the message/invocation as well as conextual information
+ * about it, following the standard pipe-and-filter design pattern.
+ *
+ * @author PS Neville
+ */
+public abstract class AMFFilter
+{
+ protected AMFFilter next;
+
+ public AMFFilter()
+ {
+ }
+
+ public void setNext(AMFFilter next)
+ {
+ this.next = next;
+ }
+
+ public AMFFilter getNext()
+ {
+ return next;
+ }
+
+ /**
+ * The core business method.
+ */
+ public abstract void invoke(final ActionContext context) throws IOException;
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/amf/BatchProcessFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/amf/BatchProcessFilter.java b/modules/core/src/flex/messaging/endpoints/amf/BatchProcessFilter.java
old mode 100755
new mode 100644
index 423a7ed..8a3b694
--- a/modules/core/src/flex/messaging/endpoints/amf/BatchProcessFilter.java
+++ b/modules/core/src/flex/messaging/endpoints/amf/BatchProcessFilter.java
@@ -1,73 +1,73 @@
-/*
- * 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.endpoints.amf;
-
-import flex.messaging.io.amf.ActionContext;
-import flex.messaging.io.amf.MessageBody;
-import flex.messaging.io.MessageIOConstants;
-import flex.messaging.io.RecoverableSerializationException;
-
-/**
- * Filter that breaks down the batched message buffer into individual invocations.
- *
- * @author PS Neville
- */
-public class BatchProcessFilter extends AMFFilter
-{
- public BatchProcessFilter()
- {
- }
-
- public void invoke(final ActionContext context)
- {
- // Process each action in the body
- int bodyCount = context.getRequestMessage().getBodyCount();
-
- // Report batch size in Debug mode
- //gateway.getLogger().logDebug("Processing batch of " + bodyCount + " request(s)");
-
- for (context.setMessageNumber(0); context.getMessageNumber() < bodyCount; context.incrementMessageNumber())
- {
- try
- {
- // create the response body
- MessageBody responseBody = new MessageBody();
- responseBody.setTargetURI(context.getRequestMessageBody().getResponseURI());
-
- // append the response body to the output message
- context.getResponseMessage().addBody(responseBody);
-
- //Check that deserialized message body data type was valid. If not, skip this message.
- Object o = context.getRequestMessageBody().getData();
-
- if (o != null && o instanceof RecoverableSerializationException)
- {
- context.getResponseMessageBody().setData(((RecoverableSerializationException)o).createErrorMessage());
- context.getResponseMessageBody().setReplyMethod(MessageIOConstants.STATUS_METHOD);
- continue;
- }
-
- // invoke next filter in the chain
- next.invoke(context);
- }
- catch (Exception e)
- {
- // continue invoking on next message body despite error
- }
- }
- }
-}
+/*
+ * 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.endpoints.amf;
+
+import flex.messaging.io.amf.ActionContext;
+import flex.messaging.io.amf.MessageBody;
+import flex.messaging.io.MessageIOConstants;
+import flex.messaging.io.RecoverableSerializationException;
+
+/**
+ * Filter that breaks down the batched message buffer into individual invocations.
+ *
+ * @author PS Neville
+ */
+public class BatchProcessFilter extends AMFFilter
+{
+ public BatchProcessFilter()
+ {
+ }
+
+ public void invoke(final ActionContext context)
+ {
+ // Process each action in the body
+ int bodyCount = context.getRequestMessage().getBodyCount();
+
+ // Report batch size in Debug mode
+ //gateway.getLogger().logDebug("Processing batch of " + bodyCount + " request(s)");
+
+ for (context.setMessageNumber(0); context.getMessageNumber() < bodyCount; context.incrementMessageNumber())
+ {
+ try
+ {
+ // create the response body
+ MessageBody responseBody = new MessageBody();
+ responseBody.setTargetURI(context.getRequestMessageBody().getResponseURI());
+
+ // append the response body to the output message
+ context.getResponseMessage().addBody(responseBody);
+
+ //Check that deserialized message body data type was valid. If not, skip this message.
+ Object o = context.getRequestMessageBody().getData();
+
+ if (o != null && o instanceof RecoverableSerializationException)
+ {
+ context.getResponseMessageBody().setData(((RecoverableSerializationException)o).createErrorMessage());
+ context.getResponseMessageBody().setReplyMethod(MessageIOConstants.STATUS_METHOD);
+ continue;
+ }
+
+ // invoke next filter in the chain
+ next.invoke(context);
+ }
+ catch (Exception e)
+ {
+ // continue invoking on next message body despite error
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/amf/LegacyFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/amf/LegacyFilter.java b/modules/core/src/flex/messaging/endpoints/amf/LegacyFilter.java
old mode 100755
new mode 100644
index f7c1347..626f369
--- a/modules/core/src/flex/messaging/endpoints/amf/LegacyFilter.java
+++ b/modules/core/src/flex/messaging/endpoints/amf/LegacyFilter.java
@@ -1,339 +1,339 @@
-/*
- * 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.endpoints.amf;
-
-import flex.messaging.endpoints.BaseHTTPEndpoint;
-import flex.messaging.io.amf.ASObject;
-import flex.messaging.io.amf.ActionContext;
-import flex.messaging.io.amf.MessageBody;
-import flex.messaging.io.amf.MessageHeader;
-import flex.messaging.messages.Message;
-import flex.messaging.messages.RemotingMessage;
-import flex.messaging.messages.ErrorMessage;
-
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.lang.reflect.Array;
-
-/**
- * AMF Headers are of limited use because the apply to the entire AMF packet, which
- * may contain a batch of several requests.
- * <p>
- * Rather than relying on the Flash Player team to change the AMF specification,
- * Flex 1.5 introduced the concept of a Message Envelope that allowed them to provide
- * message level headers that apply to a single request body.
- * </p>
- * <p>
- * Essentially they introduced one more layer of indirection with an ASObject of type "Envelope"
- * that had two properties:<br />
- * - <i>headers</i>, which was an array of Header structures<br />
- * - <i>body</i>, which was the actual data of the request (typically an array of arguments)
- * </p>
- * <p>
- * To save space on the wire, a Header structure was simply an array. The first element was
- * the header name as a String, and was the only required field. The second element, a boolean,
- * indicated whether the header must be understood. The third element, any Object, represented
- * the header value, if required.
- * </p>
- *
- * @author Peter Farland
- */
-public class LegacyFilter extends AMFFilter
-{
- public static final String LEGACY_ENVELOPE_FLAG_KEY = "_flag";
- public static final String LEGACY_ENVELOPE_FLAG_VALUE = "Envelope";
- public static final String LEGACY_SECURITY_HEADER_NAME = "Credentials";
- public static final String LEGACY_SECURITY_PRINCIPAL = "userid";
- public static final String LEGACY_SECURITY_CREDENTIALS = "password";
-
- private BaseHTTPEndpoint endpoint;
-
- public LegacyFilter(BaseHTTPEndpoint endpoint)
- {
- this.endpoint = endpoint;
- }
-
- public void invoke(final ActionContext context) throws IOException
- {
- MessageBody requestBody = context.getRequestMessageBody();
- context.setLegacy(true);
-
- // Parameters are usually sent as an AMF Array
- Object data = requestBody.getData();
- List newParams = null;
-
- // Check whether we're a new Flex 2.0 Messaging request
- if (data != null)
- {
- if (data.getClass().isArray())
- {
- int paramLength = Array.getLength(data);
- if (paramLength == 1)
- {
- Object obj = Array.get(data, 0);
- if (obj != null && obj instanceof Message)
- {
- context.setLegacy(false);
- newParams = new ArrayList();
- newParams.add(obj);
- }
- }
-
- // It was not a Flex 2.0 Message, but we have an array, use its contents as our params
- if (newParams == null)
- {
- newParams = new ArrayList();
- for (int i = 0; i < paramLength; i++)
- {
- try
- {
- newParams.add(Array.get(data, i));
- }
- catch (Throwable t)
- {
- }
- }
- }
- }
- else if (data instanceof List)
- {
- List paramList = (List)data;
- if (paramList.size() == 1)
- {
- Object obj = paramList.get(0);
- if (obj != null && obj instanceof Message)
- {
- context.setLegacy(false);
- newParams = new ArrayList();
- newParams.add(obj);
- }
- }
-
- // It was not a Flex 2.0 Message, but we have a list, so use it as our params
- if (newParams == null)
- {
- newParams = (List)data;
- }
- }
- }
-
- // We still haven't found any lists of params, so create one with
- // whatever data we have.
- if (newParams == null)
- {
- newParams = new ArrayList();
- newParams.add(data);
-
- }
-
- if (context.isLegacy())
- {
- newParams = legacyRequest(context, newParams);
- }
-
- requestBody.setData(newParams);
-
-
- next.invoke(context);
-
-
- if (context.isLegacy())
- {
- MessageBody responseBody = context.getResponseMessageBody();
- Object response = responseBody.getData();
-
- if (response instanceof ErrorMessage)
- {
- ErrorMessage error = (ErrorMessage)response;
- ASObject aso = new ASObject();
- aso.put("message", error.faultString);
- aso.put("code", error.faultCode);
- aso.put("details", error.faultDetail);
- aso.put("rootCause", error.rootCause);
- response = aso;
- }
- else if (response instanceof Message)
- {
- response = ((Message)response).getBody();
- }
- responseBody.setData(response);
- }
- }
-
- private List legacyRequest(ActionContext context, List oldParams)
- {
- List newParams = new ArrayList(1);
- Map headerMap = new HashMap();
- Object body = oldParams;
- Message message = null;
- MessageBody requestBody = context.getRequestMessageBody();
-
- // Legacy Packet Security
- List packetHeaders = context.getRequestMessage().getHeaders();
- packetCredentials(packetHeaders, headerMap);
-
-
- // Legacy Body
- if (oldParams.size() == 1)
- {
- Object obj = oldParams.get(0);
-
- if (obj != null && obj instanceof ASObject)
- {
- ASObject aso = (ASObject)obj;
-
- // Unwrap legacy Flex 1.5 Envelope type
- if (isEnvelope(aso))
- {
- body = aso.get("data");
-
- // Envelope level headers
- Object h = aso.get("headers");
- if (h != null && h instanceof List)
- {
- readEnvelopeHeaders((List)h, headerMap);
- envelopeCredentials(headerMap);
- }
- }
- }
- }
-
- // Convert legacy body into a RemotingMessage
- message = createMessage(requestBody, body, headerMap);
- newParams.add(message);
- return newParams;
- }
-
- private boolean isEnvelope(ASObject aso)
- {
- String flag = null;
- Object f = aso.get(LEGACY_ENVELOPE_FLAG_KEY);
- if (f != null && f instanceof String)
- flag = (String)f;
-
- if (flag != null && flag.equalsIgnoreCase(LEGACY_ENVELOPE_FLAG_VALUE))
- {
- return true;
- }
-
- return false;
- }
-
-
- private RemotingMessage createMessage(MessageBody messageBody, Object body, Map headerMap)
- {
- RemotingMessage remotingMessage = new RemotingMessage();
- // Assigning an empty String, MessageBroker expects non-null messageId.
- remotingMessage.setMessageId("");
- remotingMessage.setBody(body);
- remotingMessage.setHeaders(headerMap);
-
- // Decode legacy target URI into destination.operation
- String targetURI = messageBody.getTargetURI();
-
- int dotIndex = targetURI.lastIndexOf(".");
- if (dotIndex > 0)
- {
- String destination = targetURI.substring(0, dotIndex);
- remotingMessage.setDestination(destination);
- }
-
- if (targetURI.length() > dotIndex)
- {
- String operation = targetURI.substring(dotIndex + 1);
- remotingMessage.setOperation(operation);
- }
-
- return remotingMessage;
- }
-
-
- private Map readEnvelopeHeaders(List headers, Map headerMap)
- {
- int count = headers.size();
-
- for (int i = 0; i < count; i++)
- {
- Object obj = headers.get(i);
-
- //We currently expect a plain old AS Array
- if (obj != null && obj instanceof List)
- {
- List h = (List)obj;
-
- Object name = null;
- //Object mustUnderstand = null;
- Object data = null;
-
- int numFields = h.size();
-
- //The array must have exactly three (3) fields
- if (numFields == 3)
- {
- name = h.get(0);
-
- if (name != null && name instanceof String)
- {
- //mustUnderstand = h.get(1);
- data = h.get(2);
- headerMap.put(name, data);
- }
- }
- }
- }
-
- return headerMap;
- }
-
- private void envelopeCredentials(Map headers)
- {
- // Process Legacy Security Credentials
- Object obj = headers.get(LEGACY_SECURITY_HEADER_NAME);
- if (obj != null && obj instanceof ASObject)
- {
- ASObject header = (ASObject)obj;
- String principal = (String)header.get(LEGACY_SECURITY_PRINCIPAL);
- Object credentials = header.get(LEGACY_SECURITY_CREDENTIALS);
- endpoint.getMessageBroker().getLoginManager().login(principal, credentials.toString());
- }
- headers.remove(LEGACY_SECURITY_HEADER_NAME);
- }
-
- private void packetCredentials(List packetHeaders, Map headers)
- {
- if (packetHeaders.size() > 0)
- {
- for (Iterator iter = packetHeaders.iterator(); iter.hasNext();)
- {
- MessageHeader header = (MessageHeader)iter.next();
- if (header.getName().equals(LEGACY_SECURITY_HEADER_NAME))
- {
- Map loginInfo = (Map)header.getData();
- String principal = loginInfo.get(LEGACY_SECURITY_PRINCIPAL).toString();
- Object credentials = loginInfo.get(LEGACY_SECURITY_CREDENTIALS);
- endpoint.getMessageBroker().getLoginManager().login(principal, credentials.toString());
- break;
- }
- }
- }
- }
-}
+/*
+ * 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.endpoints.amf;
+
+import flex.messaging.endpoints.BaseHTTPEndpoint;
+import flex.messaging.io.amf.ASObject;
+import flex.messaging.io.amf.ActionContext;
+import flex.messaging.io.amf.MessageBody;
+import flex.messaging.io.amf.MessageHeader;
+import flex.messaging.messages.Message;
+import flex.messaging.messages.RemotingMessage;
+import flex.messaging.messages.ErrorMessage;
+
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.lang.reflect.Array;
+
+/**
+ * AMF Headers are of limited use because the apply to the entire AMF packet, which
+ * may contain a batch of several requests.
+ * <p>
+ * Rather than relying on the Flash Player team to change the AMF specification,
+ * Flex 1.5 introduced the concept of a Message Envelope that allowed them to provide
+ * message level headers that apply to a single request body.
+ * </p>
+ * <p>
+ * Essentially they introduced one more layer of indirection with an ASObject of type "Envelope"
+ * that had two properties:<br />
+ * - <i>headers</i>, which was an array of Header structures<br />
+ * - <i>body</i>, which was the actual data of the request (typically an array of arguments)
+ * </p>
+ * <p>
+ * To save space on the wire, a Header structure was simply an array. The first element was
+ * the header name as a String, and was the only required field. The second element, a boolean,
+ * indicated whether the header must be understood. The third element, any Object, represented
+ * the header value, if required.
+ * </p>
+ *
+ * @author Peter Farland
+ */
+public class LegacyFilter extends AMFFilter
+{
+ public static final String LEGACY_ENVELOPE_FLAG_KEY = "_flag";
+ public static final String LEGACY_ENVELOPE_FLAG_VALUE = "Envelope";
+ public static final String LEGACY_SECURITY_HEADER_NAME = "Credentials";
+ public static final String LEGACY_SECURITY_PRINCIPAL = "userid";
+ public static final String LEGACY_SECURITY_CREDENTIALS = "password";
+
+ private BaseHTTPEndpoint endpoint;
+
+ public LegacyFilter(BaseHTTPEndpoint endpoint)
+ {
+ this.endpoint = endpoint;
+ }
+
+ public void invoke(final ActionContext context) throws IOException
+ {
+ MessageBody requestBody = context.getRequestMessageBody();
+ context.setLegacy(true);
+
+ // Parameters are usually sent as an AMF Array
+ Object data = requestBody.getData();
+ List newParams = null;
+
+ // Check whether we're a new Flex 2.0 Messaging request
+ if (data != null)
+ {
+ if (data.getClass().isArray())
+ {
+ int paramLength = Array.getLength(data);
+ if (paramLength == 1)
+ {
+ Object obj = Array.get(data, 0);
+ if (obj != null && obj instanceof Message)
+ {
+ context.setLegacy(false);
+ newParams = new ArrayList();
+ newParams.add(obj);
+ }
+ }
+
+ // It was not a Flex 2.0 Message, but we have an array, use its contents as our params
+ if (newParams == null)
+ {
+ newParams = new ArrayList();
+ for (int i = 0; i < paramLength; i++)
+ {
+ try
+ {
+ newParams.add(Array.get(data, i));
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ }
+ }
+ else if (data instanceof List)
+ {
+ List paramList = (List)data;
+ if (paramList.size() == 1)
+ {
+ Object obj = paramList.get(0);
+ if (obj != null && obj instanceof Message)
+ {
+ context.setLegacy(false);
+ newParams = new ArrayList();
+ newParams.add(obj);
+ }
+ }
+
+ // It was not a Flex 2.0 Message, but we have a list, so use it as our params
+ if (newParams == null)
+ {
+ newParams = (List)data;
+ }
+ }
+ }
+
+ // We still haven't found any lists of params, so create one with
+ // whatever data we have.
+ if (newParams == null)
+ {
+ newParams = new ArrayList();
+ newParams.add(data);
+
+ }
+
+ if (context.isLegacy())
+ {
+ newParams = legacyRequest(context, newParams);
+ }
+
+ requestBody.setData(newParams);
+
+
+ next.invoke(context);
+
+
+ if (context.isLegacy())
+ {
+ MessageBody responseBody = context.getResponseMessageBody();
+ Object response = responseBody.getData();
+
+ if (response instanceof ErrorMessage)
+ {
+ ErrorMessage error = (ErrorMessage)response;
+ ASObject aso = new ASObject();
+ aso.put("message", error.faultString);
+ aso.put("code", error.faultCode);
+ aso.put("details", error.faultDetail);
+ aso.put("rootCause", error.rootCause);
+ response = aso;
+ }
+ else if (response instanceof Message)
+ {
+ response = ((Message)response).getBody();
+ }
+ responseBody.setData(response);
+ }
+ }
+
+ private List legacyRequest(ActionContext context, List oldParams)
+ {
+ List newParams = new ArrayList(1);
+ Map headerMap = new HashMap();
+ Object body = oldParams;
+ Message message = null;
+ MessageBody requestBody = context.getRequestMessageBody();
+
+ // Legacy Packet Security
+ List packetHeaders = context.getRequestMessage().getHeaders();
+ packetCredentials(packetHeaders, headerMap);
+
+
+ // Legacy Body
+ if (oldParams.size() == 1)
+ {
+ Object obj = oldParams.get(0);
+
+ if (obj != null && obj instanceof ASObject)
+ {
+ ASObject aso = (ASObject)obj;
+
+ // Unwrap legacy Flex 1.5 Envelope type
+ if (isEnvelope(aso))
+ {
+ body = aso.get("data");
+
+ // Envelope level headers
+ Object h = aso.get("headers");
+ if (h != null && h instanceof List)
+ {
+ readEnvelopeHeaders((List)h, headerMap);
+ envelopeCredentials(headerMap);
+ }
+ }
+ }
+ }
+
+ // Convert legacy body into a RemotingMessage
+ message = createMessage(requestBody, body, headerMap);
+ newParams.add(message);
+ return newParams;
+ }
+
+ private boolean isEnvelope(ASObject aso)
+ {
+ String flag = null;
+ Object f = aso.get(LEGACY_ENVELOPE_FLAG_KEY);
+ if (f != null && f instanceof String)
+ flag = (String)f;
+
+ if (flag != null && flag.equalsIgnoreCase(LEGACY_ENVELOPE_FLAG_VALUE))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+
+ private RemotingMessage createMessage(MessageBody messageBody, Object body, Map headerMap)
+ {
+ RemotingMessage remotingMessage = new RemotingMessage();
+ // Assigning an empty String, MessageBroker expects non-null messageId.
+ remotingMessage.setMessageId("");
+ remotingMessage.setBody(body);
+ remotingMessage.setHeaders(headerMap);
+
+ // Decode legacy target URI into destination.operation
+ String targetURI = messageBody.getTargetURI();
+
+ int dotIndex = targetURI.lastIndexOf(".");
+ if (dotIndex > 0)
+ {
+ String destination = targetURI.substring(0, dotIndex);
+ remotingMessage.setDestination(destination);
+ }
+
+ if (targetURI.length() > dotIndex)
+ {
+ String operation = targetURI.substring(dotIndex + 1);
+ remotingMessage.setOperation(operation);
+ }
+
+ return remotingMessage;
+ }
+
+
+ private Map readEnvelopeHeaders(List headers, Map headerMap)
+ {
+ int count = headers.size();
+
+ for (int i = 0; i < count; i++)
+ {
+ Object obj = headers.get(i);
+
+ //We currently expect a plain old AS Array
+ if (obj != null && obj instanceof List)
+ {
+ List h = (List)obj;
+
+ Object name = null;
+ //Object mustUnderstand = null;
+ Object data = null;
+
+ int numFields = h.size();
+
+ //The array must have exactly three (3) fields
+ if (numFields == 3)
+ {
+ name = h.get(0);
+
+ if (name != null && name instanceof String)
+ {
+ //mustUnderstand = h.get(1);
+ data = h.get(2);
+ headerMap.put(name, data);
+ }
+ }
+ }
+ }
+
+ return headerMap;
+ }
+
+ private void envelopeCredentials(Map headers)
+ {
+ // Process Legacy Security Credentials
+ Object obj = headers.get(LEGACY_SECURITY_HEADER_NAME);
+ if (obj != null && obj instanceof ASObject)
+ {
+ ASObject header = (ASObject)obj;
+ String principal = (String)header.get(LEGACY_SECURITY_PRINCIPAL);
+ Object credentials = header.get(LEGACY_SECURITY_CREDENTIALS);
+ endpoint.getMessageBroker().getLoginManager().login(principal, credentials.toString());
+ }
+ headers.remove(LEGACY_SECURITY_HEADER_NAME);
+ }
+
+ private void packetCredentials(List packetHeaders, Map headers)
+ {
+ if (packetHeaders.size() > 0)
+ {
+ for (Iterator iter = packetHeaders.iterator(); iter.hasNext();)
+ {
+ MessageHeader header = (MessageHeader)iter.next();
+ if (header.getName().equals(LEGACY_SECURITY_HEADER_NAME))
+ {
+ Map loginInfo = (Map)header.getData();
+ String principal = loginInfo.get(LEGACY_SECURITY_PRINCIPAL).toString();
+ Object credentials = loginInfo.get(LEGACY_SECURITY_CREDENTIALS);
+ endpoint.getMessageBroker().getLoginManager().login(principal, credentials.toString());
+ break;
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/amf/MessageBrokerFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/amf/MessageBrokerFilter.java b/modules/core/src/flex/messaging/endpoints/amf/MessageBrokerFilter.java
old mode 100755
new mode 100644
index 5ceefc9..d8288f3
--- a/modules/core/src/flex/messaging/endpoints/amf/MessageBrokerFilter.java
+++ b/modules/core/src/flex/messaging/endpoints/amf/MessageBrokerFilter.java
@@ -1,180 +1,180 @@
-/*
- * 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.endpoints.amf;
-
-import flex.messaging.FlexContext;
-import flex.messaging.FlexSession;
-import flex.messaging.MessageException;
-import flex.messaging.endpoints.AbstractEndpoint;
-import flex.messaging.io.MessageIOConstants;
-import flex.messaging.io.amf.ActionContext;
-import flex.messaging.io.amf.MessageBody;
-import flex.messaging.messages.CommandMessage;
-import flex.messaging.messages.ErrorMessage;
-import flex.messaging.messages.Message;
-import flex.messaging.messages.MessagePerformanceUtils;
-import flex.messaging.services.MessageService;
-import flex.messaging.util.StringUtils;
-import flex.messaging.log.LogCategories;
-import flex.messaging.log.Log;
-import flex.messaging.util.ExceptionUtil;
-import flex.messaging.util.UUIDUtils;
-
-import java.util.List;
-import java.lang.reflect.Array;
-
-/**
- * A simple bridge between the encoding/decoding functionality of
- * the AMF endpoint and the MessageBroker: this last filter in the
- * chain returns the message to the MessageBroker, which will then
- * locate the correct service to handle the message.
- */
-public class MessageBrokerFilter extends AMFFilter
-{
- private static final int UNHANDLED_ERROR = 10000;
- static final String LOG_CATEGORY = LogCategories.MESSAGE_GENERAL;
-
- protected AbstractEndpoint endpoint;
-
- public MessageBrokerFilter(AbstractEndpoint endpoint)
- {
- this.endpoint = endpoint;
- }
-
- public void invoke(final ActionContext context)
- {
- MessageBody request = context.getRequestMessageBody();
- MessageBody response = context.getResponseMessageBody();
-
- Message inMessage = request.getDataAsMessage();
-
- Object outMessage = null;
-
- String replyMethodName = MessageIOConstants.STATUS_METHOD;
-
- try
- {
- // Lookup or create the correct FlexClient.
- endpoint.setupFlexClient(inMessage);
-
- // Assign a clientId if necessary.
- // We don't need to assign clientIds to general poll requests.
- if (inMessage.getClientId() == null &&
- (!(inMessage instanceof CommandMessage) || ((CommandMessage)inMessage).getOperation() != CommandMessage.POLL_OPERATION))
- {
- Object clientId = UUIDUtils.createUUID();
- inMessage.setClientId(clientId);
- }
-
- // Messages received via the AMF channel can be batched (by NetConnection on the client) and
- // we must not put the handler thread into a poll-wait state if a poll command message is followed by
- // or preceeded by other messages in the batch; the request-response loop must complete without waiting.
- // If the poll command is the only message in the batch it's ok to wait.
- // If it isn't ok to wait, tag the poll message with a header that short-circuits any potential poll-wait.
- if (inMessage instanceof CommandMessage)
- {
- CommandMessage command = (CommandMessage)inMessage;
- if ((command.getOperation() == CommandMessage.POLL_OPERATION) && (context.getRequestMessage().getBodyCount() != 1))
- command.setHeader(CommandMessage.SUPPRESS_POLL_WAIT_HEADER, Boolean.TRUE);
- }
-
- // If MPI is enabled update the MPI metrics on the object referred to by the context
- // and the messages
- if (context.isMPIenabled())
- MessagePerformanceUtils.setupMPII(context, inMessage);
-
- // Service the message.
- outMessage = endpoint.serviceMessage(inMessage);
-
- // if processing of the message resulted in an error, set up context and reply method accordingly
- if (outMessage instanceof ErrorMessage)
- {
- context.setStatus(MessageIOConstants.STATUS_ERR);
- replyMethodName = MessageIOConstants.STATUS_METHOD;
- }
- else
- {
- replyMethodName = MessageIOConstants.RESULT_METHOD;
- }
- }
- catch (MessageException e)
- {
- context.setStatus(MessageIOConstants.STATUS_ERR);
- replyMethodName = MessageIOConstants.STATUS_METHOD;
-
- outMessage = e.createErrorMessage();
- ((ErrorMessage)outMessage).setCorrelationId(inMessage.getMessageId());
- ((ErrorMessage)outMessage).setDestination(inMessage.getDestination());
- ((ErrorMessage)outMessage).setClientId(inMessage.getClientId());
-
- e.logAtHingePoint(inMessage, (ErrorMessage)outMessage, null /* Use default message intros */);
- }
- catch (Throwable t)
- {
- // Handle any uncaught failures. The normal exception path on the server
- // is to throw MessageExceptions which are handled in the catch block above,
- // so if that was skipped we have an overlooked or serious problem.
- context.setStatus(MessageIOConstants.STATUS_ERR);
- replyMethodName = MessageIOConstants.STATUS_METHOD;
-
- String lmeMessage = t.getMessage();
- if (lmeMessage == null)
- lmeMessage = t.getClass().getName();
-
- MessageException lme = new MessageException();
- lme.setMessage(UNHANDLED_ERROR, new Object[] {lmeMessage});
-
- outMessage = lme.createErrorMessage();
- ((ErrorMessage)outMessage).setCorrelationId(inMessage.getMessageId());
- ((ErrorMessage)outMessage).setDestination(inMessage.getDestination());
- ((ErrorMessage)outMessage).setClientId(inMessage.getClientId());
-
- if (Log.isError())
- {
- Log.getLogger(LOG_CATEGORY).error("Unhandled error when processing a message: " +
- t.toString() + StringUtils.NEWLINE +
- " incomingMessage: " + inMessage + StringUtils.NEWLINE +
- " errorReply: " + outMessage + StringUtils.NEWLINE +
- ExceptionUtil.exceptionFollowedByRootCausesToString(t) + StringUtils.NEWLINE);
- }
- }
- finally
- {
- // If MPI is enabled update the MPI metrics on the object referred to by the context
- // and the messages
- if (context.isRecordMessageSizes() || context.isRecordMessageTimes())
- {
- MessagePerformanceUtils.updateOutgoingMPI(context, inMessage, outMessage);
- }
-
- // If our channel-endpoint combination supports small messages, and
- // if we know the current protocol version supports small messages,
- // try to replace the message...
- FlexSession session = FlexContext.getFlexSession();
- if (session != null && session.useSmallMessages()
- && !context.isLegacy()
- && context.getVersion() >= MessageIOConstants.AMF3
- && outMessage instanceof Message)
- {
- outMessage = endpoint.convertToSmallMessage((Message)outMessage);
- }
-
- response.setReplyMethod(replyMethodName);
- response.setData(outMessage);
- }
- }
-}
+/*
+ * 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.endpoints.amf;
+
+import flex.messaging.FlexContext;
+import flex.messaging.FlexSession;
+import flex.messaging.MessageException;
+import flex.messaging.endpoints.AbstractEndpoint;
+import flex.messaging.io.MessageIOConstants;
+import flex.messaging.io.amf.ActionContext;
+import flex.messaging.io.amf.MessageBody;
+import flex.messaging.messages.CommandMessage;
+import flex.messaging.messages.ErrorMessage;
+import flex.messaging.messages.Message;
+import flex.messaging.messages.MessagePerformanceUtils;
+import flex.messaging.services.MessageService;
+import flex.messaging.util.StringUtils;
+import flex.messaging.log.LogCategories;
+import flex.messaging.log.Log;
+import flex.messaging.util.ExceptionUtil;
+import flex.messaging.util.UUIDUtils;
+
+import java.util.List;
+import java.lang.reflect.Array;
+
+/**
+ * A simple bridge between the encoding/decoding functionality of
+ * the AMF endpoint and the MessageBroker: this last filter in the
+ * chain returns the message to the MessageBroker, which will then
+ * locate the correct service to handle the message.
+ */
+public class MessageBrokerFilter extends AMFFilter
+{
+ private static final int UNHANDLED_ERROR = 10000;
+ static final String LOG_CATEGORY = LogCategories.MESSAGE_GENERAL;
+
+ protected AbstractEndpoint endpoint;
+
+ public MessageBrokerFilter(AbstractEndpoint endpoint)
+ {
+ this.endpoint = endpoint;
+ }
+
+ public void invoke(final ActionContext context)
+ {
+ MessageBody request = context.getRequestMessageBody();
+ MessageBody response = context.getResponseMessageBody();
+
+ Message inMessage = request.getDataAsMessage();
+
+ Object outMessage = null;
+
+ String replyMethodName = MessageIOConstants.STATUS_METHOD;
+
+ try
+ {
+ // Lookup or create the correct FlexClient.
+ endpoint.setupFlexClient(inMessage);
+
+ // Assign a clientId if necessary.
+ // We don't need to assign clientIds to general poll requests.
+ if (inMessage.getClientId() == null &&
+ (!(inMessage instanceof CommandMessage) || ((CommandMessage)inMessage).getOperation() != CommandMessage.POLL_OPERATION))
+ {
+ Object clientId = UUIDUtils.createUUID();
+ inMessage.setClientId(clientId);
+ }
+
+ // Messages received via the AMF channel can be batched (by NetConnection on the client) and
+ // we must not put the handler thread into a poll-wait state if a poll command message is followed by
+ // or preceeded by other messages in the batch; the request-response loop must complete without waiting.
+ // If the poll command is the only message in the batch it's ok to wait.
+ // If it isn't ok to wait, tag the poll message with a header that short-circuits any potential poll-wait.
+ if (inMessage instanceof CommandMessage)
+ {
+ CommandMessage command = (CommandMessage)inMessage;
+ if ((command.getOperation() == CommandMessage.POLL_OPERATION) && (context.getRequestMessage().getBodyCount() != 1))
+ command.setHeader(CommandMessage.SUPPRESS_POLL_WAIT_HEADER, Boolean.TRUE);
+ }
+
+ // If MPI is enabled update the MPI metrics on the object referred to by the context
+ // and the messages
+ if (context.isMPIenabled())
+ MessagePerformanceUtils.setupMPII(context, inMessage);
+
+ // Service the message.
+ outMessage = endpoint.serviceMessage(inMessage);
+
+ // if processing of the message resulted in an error, set up context and reply method accordingly
+ if (outMessage instanceof ErrorMessage)
+ {
+ context.setStatus(MessageIOConstants.STATUS_ERR);
+ replyMethodName = MessageIOConstants.STATUS_METHOD;
+ }
+ else
+ {
+ replyMethodName = MessageIOConstants.RESULT_METHOD;
+ }
+ }
+ catch (MessageException e)
+ {
+ context.setStatus(MessageIOConstants.STATUS_ERR);
+ replyMethodName = MessageIOConstants.STATUS_METHOD;
+
+ outMessage = e.createErrorMessage();
+ ((ErrorMessage)outMessage).setCorrelationId(inMessage.getMessageId());
+ ((ErrorMessage)outMessage).setDestination(inMessage.getDestination());
+ ((ErrorMessage)outMessage).setClientId(inMessage.getClientId());
+
+ e.logAtHingePoint(inMessage, (ErrorMessage)outMessage, null /* Use default message intros */);
+ }
+ catch (Throwable t)
+ {
+ // Handle any uncaught failures. The normal exception path on the server
+ // is to throw MessageExceptions which are handled in the catch block above,
+ // so if that was skipped we have an overlooked or serious problem.
+ context.setStatus(MessageIOConstants.STATUS_ERR);
+ replyMethodName = MessageIOConstants.STATUS_METHOD;
+
+ String lmeMessage = t.getMessage();
+ if (lmeMessage == null)
+ lmeMessage = t.getClass().getName();
+
+ MessageException lme = new MessageException();
+ lme.setMessage(UNHANDLED_ERROR, new Object[] {lmeMessage});
+
+ outMessage = lme.createErrorMessage();
+ ((ErrorMessage)outMessage).setCorrelationId(inMessage.getMessageId());
+ ((ErrorMessage)outMessage).setDestination(inMessage.getDestination());
+ ((ErrorMessage)outMessage).setClientId(inMessage.getClientId());
+
+ if (Log.isError())
+ {
+ Log.getLogger(LOG_CATEGORY).error("Unhandled error when processing a message: " +
+ t.toString() + StringUtils.NEWLINE +
+ " incomingMessage: " + inMessage + StringUtils.NEWLINE +
+ " errorReply: " + outMessage + StringUtils.NEWLINE +
+ ExceptionUtil.exceptionFollowedByRootCausesToString(t) + StringUtils.NEWLINE);
+ }
+ }
+ finally
+ {
+ // If MPI is enabled update the MPI metrics on the object referred to by the context
+ // and the messages
+ if (context.isRecordMessageSizes() || context.isRecordMessageTimes())
+ {
+ MessagePerformanceUtils.updateOutgoingMPI(context, inMessage, outMessage);
+ }
+
+ // If our channel-endpoint combination supports small messages, and
+ // if we know the current protocol version supports small messages,
+ // try to replace the message...
+ FlexSession session = FlexContext.getFlexSession();
+ if (session != null && session.useSmallMessages()
+ && !context.isLegacy()
+ && context.getVersion() >= MessageIOConstants.AMF3
+ && outMessage instanceof Message)
+ {
+ outMessage = endpoint.convertToSmallMessage((Message)outMessage);
+ }
+
+ response.setReplyMethod(replyMethodName);
+ response.setData(outMessage);
+ }
+ }
+}
[47/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ClusterSettings.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ClusterSettings.java b/modules/common/src/flex/messaging/config/ClusterSettings.java
old mode 100755
new mode 100644
index 6505bbe..15edfe3
--- a/modules/common/src/flex/messaging/config/ClusterSettings.java
+++ b/modules/common/src/flex/messaging/config/ClusterSettings.java
@@ -1,152 +1,152 @@
-/*
- * 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.config;
-
-/**
- * @exclude
- */
-public class ClusterSettings extends PropertiesSettings
-{
- public static final String CLUSTER_ELEMENT = "cluster";
- public static final String REF_ATTR = "ref";
- public static final String SHARED_BACKEND_ATTR = "shared-backend";
- public static final String DEFAULT_ELEMENT = "default";
- public static final String URL_LOAD_BALANCING = "url-load-balancing";
- public static final String IMPLEMENTATION_CLASS = "class";
-
- public static final String JGROUPS_CLUSTER = "flex.messaging.cluster.JGroupsCluster";
-
- private String clusterName;
- private String propsFileName;
- private String implementationClass;
- private boolean def;
- private boolean urlLoadBalancing;
-
- /**
- * Creates a new <code>ClusterSettings</code> with default settings.
- */
- public ClusterSettings()
- {
- def = false;
- urlLoadBalancing = true;
- implementationClass = JGROUPS_CLUSTER;
- }
-
- /**
- * Returns the name of the cluster.
- *
- * @return The name of the cluster.
- */
- public String getClusterName()
- {
- return clusterName;
- }
-
- /**
- * Sets the name of the cluster.
- *
- * @param clusterName The name of the cluster.
- */
- public void setClusterName(String clusterName)
- {
- this.clusterName = clusterName;
- }
-
- /**
- * Returns whether the cluster is default or not.
- *
- * @return <code>true</code> is the cluster is default; otherwise <code>false</code>.
- */
- public boolean isDefault()
- {
- return def;
- }
-
- /**
- * Sets whether the cluster is default or not.
- *
- * @param def <code>true</code> is the cluster is default; otherwise <code>false</code>.
- */
- public void setDefault(boolean def)
- {
- this.def = def;
- }
-
- /**
- * Returns the properties file of the cluster.
- *
- * @return The properties file of the cluster.
- */
- public String getPropsFileName()
- {
- return propsFileName;
- }
-
- /**
- * Sets the properties file of the cluster.
- *
- * @param propsFileName The properties file of the cluster.
- */
- public void setPropsFileName(String propsFileName)
- {
- this.propsFileName = propsFileName;
- }
-
- /**
- * Returns whether url load balancing is enabled or not.
- *
- * @return <code>true</code> if the url load balancing is enabled; otherwise <code>false</code>.
- */
- public boolean getURLLoadBalancing()
- {
- return urlLoadBalancing;
- }
-
- /**
- * Sets whether url load balancing is enabled or not.
- *
- * @param ulb <code>true</code> if the url load balancing is enabled; otherwise <code>false</code>.
- */
- public void setURLLoadBalancing(boolean ulb)
- {
- urlLoadBalancing = ulb;
- }
-
- /**
- * Sets the name of the cluster implementation class.
- * The default is 'flex.messaging.cluster.JGroupsCluster'.
- *
- * @param className
- * @exclude
- */
- public void setImplementationClass(String className)
- {
- this.implementationClass = className;
- }
-
- /**
- * Get the name of the cluster implementation class.
- * The class must support the flex.messaging.cluster.Cluster interface.
- *
- * @return The implementation class name.
- * @exclude
- */
- public String getImplementationClass()
- {
- return implementationClass;
- }
-}
+/*
+ * 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.config;
+
+/**
+ * @exclude
+ */
+public class ClusterSettings extends PropertiesSettings
+{
+ public static final String CLUSTER_ELEMENT = "cluster";
+ public static final String REF_ATTR = "ref";
+ public static final String SHARED_BACKEND_ATTR = "shared-backend";
+ public static final String DEFAULT_ELEMENT = "default";
+ public static final String URL_LOAD_BALANCING = "url-load-balancing";
+ public static final String IMPLEMENTATION_CLASS = "class";
+
+ public static final String JGROUPS_CLUSTER = "flex.messaging.cluster.JGroupsCluster";
+
+ private String clusterName;
+ private String propsFileName;
+ private String implementationClass;
+ private boolean def;
+ private boolean urlLoadBalancing;
+
+ /**
+ * Creates a new <code>ClusterSettings</code> with default settings.
+ */
+ public ClusterSettings()
+ {
+ def = false;
+ urlLoadBalancing = true;
+ implementationClass = JGROUPS_CLUSTER;
+ }
+
+ /**
+ * Returns the name of the cluster.
+ *
+ * @return The name of the cluster.
+ */
+ public String getClusterName()
+ {
+ return clusterName;
+ }
+
+ /**
+ * Sets the name of the cluster.
+ *
+ * @param clusterName The name of the cluster.
+ */
+ public void setClusterName(String clusterName)
+ {
+ this.clusterName = clusterName;
+ }
+
+ /**
+ * Returns whether the cluster is default or not.
+ *
+ * @return <code>true</code> is the cluster is default; otherwise <code>false</code>.
+ */
+ public boolean isDefault()
+ {
+ return def;
+ }
+
+ /**
+ * Sets whether the cluster is default or not.
+ *
+ * @param def <code>true</code> is the cluster is default; otherwise <code>false</code>.
+ */
+ public void setDefault(boolean def)
+ {
+ this.def = def;
+ }
+
+ /**
+ * Returns the properties file of the cluster.
+ *
+ * @return The properties file of the cluster.
+ */
+ public String getPropsFileName()
+ {
+ return propsFileName;
+ }
+
+ /**
+ * Sets the properties file of the cluster.
+ *
+ * @param propsFileName The properties file of the cluster.
+ */
+ public void setPropsFileName(String propsFileName)
+ {
+ this.propsFileName = propsFileName;
+ }
+
+ /**
+ * Returns whether url load balancing is enabled or not.
+ *
+ * @return <code>true</code> if the url load balancing is enabled; otherwise <code>false</code>.
+ */
+ public boolean getURLLoadBalancing()
+ {
+ return urlLoadBalancing;
+ }
+
+ /**
+ * Sets whether url load balancing is enabled or not.
+ *
+ * @param ulb <code>true</code> if the url load balancing is enabled; otherwise <code>false</code>.
+ */
+ public void setURLLoadBalancing(boolean ulb)
+ {
+ urlLoadBalancing = ulb;
+ }
+
+ /**
+ * Sets the name of the cluster implementation class.
+ * The default is 'flex.messaging.cluster.JGroupsCluster'.
+ *
+ * @param className
+ * @exclude
+ */
+ public void setImplementationClass(String className)
+ {
+ this.implementationClass = className;
+ }
+
+ /**
+ * Get the name of the cluster implementation class.
+ * The class must support the flex.messaging.cluster.Cluster interface.
+ *
+ * @return The implementation class name.
+ * @exclude
+ */
+ public String getImplementationClass()
+ {
+ return implementationClass;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ConfigMap.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ConfigMap.java b/modules/common/src/flex/messaging/config/ConfigMap.java
old mode 100755
new mode 100644
index ae76667..f882c46
--- a/modules/common/src/flex/messaging/config/ConfigMap.java
+++ b/modules/common/src/flex/messaging/config/ConfigMap.java
@@ -1,471 +1,471 @@
-/*
- * 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.config;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * The ConfigMap class is a helper implementation of Map that makes it easier
- * to handle properties that can appear one or more times. If a property is set
- * more than once, it is converted to a List and added as another property
- * rather than replacing the existing property. It also provides utility APIs
- * for getting properties from the Map, cast to a certain type and allows a
- * default to be specified in the event that the property is missing.
- *
- * @author Peter Farland
- */
-public class ConfigMap extends LinkedHashMap
-{
- /**
- * This number was generated using the 'serialver' command line tool.
- * This number should remain consistent with the version used by
- * ColdFusion to communicate with the message broker over RMI.
- */
- private static final long serialVersionUID = 8913604659150919550L;
-
- /**
- * This error is thrown when a property unexpectedly contains multiple values.
- */
- private static final int UNEXPECTED_MULTIPLE_VALUES = 10169;
-
- /**
- * An *undocumented* system property can be used to revert to legacy config property handling:
- * Legacy behavior - config property values were not trimmed, retaining leading/trailing whitespace which
- * proved problematic for customers.
- * New default behavior - config property values are trimmed.
- */
- private static final String SYSPROPNAME_TRIM_CONFIG_PROPERTY_VALUES = "flex.trim-config-property-values";
- private static final boolean TRIM_CONFIG_PROPERTY_VALUES = Boolean.valueOf(System.getProperty(SYSPROPNAME_TRIM_CONFIG_PROPERTY_VALUES, "true")).booleanValue();
-
- /**
- * Map to keep track of accessed properties.
- */
- private HashSet accessedKeys = new HashSet();
-
- /**
- * Constructs an empty <code>ConfigMap</code> with the default initial
- * capacity of 10.
- */
- public ConfigMap()
- {
- super();
- }
-
- /**
- * Constructs a new <code>ConfigMap</code> with the initial
- * capacity specified.
- *
- * @param initialCapacity the initial capacity.
- */
- public ConfigMap(int initialCapacity)
- {
- super(initialCapacity);
- }
-
- /**
- * Constructs a new <code>ConfigMap</code> and copies the values
- * from the supplied map to this map.
- *
- * @param m a <code>ConfigMap</code> whose properties are to be added to
- * this <code>ConfigMap</code>.
- */
- public ConfigMap(ConfigMap m)
- {
- this();
- addProperties(m);
- }
-
- /**
- * Adds all properties from a map to this map.
- *
- * @param p a <code>ConfigMap</code> whose properties are to be added to
- * this <code>ConfigMap</code>.
- */
- public void addProperties(ConfigMap p)
- {
- Iterator it = p.entrySet().iterator();
- while (it.hasNext())
- {
- Map.Entry entry = (Map.Entry) it.next();
- Object key = entry.getKey();
- Object value = entry.getValue();
- if (value instanceof ValueList)
- {
- addProperties(key, (ValueList) value);
- }
- else
- {
- addPropertyLogic(key, value);
- }
- }
- }
-
- /**
- * Helper method to add a list of values under a key.
- *
- * @param key The key to add the values under.
- * @param values The list of values to add.
- */
- private void addProperties(Object key, ValueList values)
- {
- ValueList list = getValueList(key);
- if (list == null)
- {
- put(key, values.clone());
- }
- else
- {
- list.addAll(values);
- }
- }
-
- /**
- * Helper method to add a value under a key.
- *
- * @param key The key to add the value under.
- * @param value The value to add.
- */
- private void addPropertyLogic(Object key, Object value)
- {
- ValueList list = getValueList(key);
- if (list == null)
- {
- put(key, value);
- }
- else
- {
- list.add(value);
- }
- }
-
- private static class ValueList extends ArrayList
- {
- /**
- * Serial version id.
- */
- static final long serialVersionUID = -5637755312744414675L;
- }
-
- /**
- * Given a key, returns a list of values associated with that key.
- *
- * @param key The key.
- * @return A list of values associated with the key.
- */
- private ValueList getValueList(Object key)
- {
- ValueList list;
- Object old = super.get(key);
- if (old instanceof ValueList)
- {
- list = (ValueList) old;
- }
- else if (old != null)
- {
- list = new ValueList();
- list.add(old);
- put(key, list);
- }
- else
- {
- list = null;
- }
- return list;
- }
-
- /**
- * Adds a <code>String</code> value to this map for the given property
- * name.
- *
- * @param name the property name
- * @param value the property value
- */
- public void addProperty(String name, String value)
- {
- addPropertyLogic(name, TRIM_CONFIG_PROPERTY_VALUES && value != null ? value.trim() : value);
- }
-
- /**
- * Adds a <code>ConfigMap</code> value to this map for the given property
- * name.
- *
- * @param name the property name
- * @param value the property value
- */
- public void addProperty(String name, ConfigMap value)
- {
- addPropertyLogic(name, value);
- }
-
- /**
- * Gets the set of property names contained in this map.
- *
- * @return a <code>Set</code> of property name <code>String</code>s.
- */
- public Set propertyNames()
- {
- return keySet();
- }
-
- /**
- * Sets a property name as allowed without needing to access the property
- * value. This marks a property as allowed for validation purposes.
- *
- * @param name the property name to allow
- */
- public void allowProperty(String name)
- {
- accessedKeys.add(name);
- }
-
- /**
- * Gets the value for the given property name. Also records that this
- * property was accessed.
- *
- * @param name the property name
- * @return the value for the property, or null if property does not exist
- * in this map.
- */
- public Object get(Object name)
- {
- accessedKeys.add(name);
- return super.get(name);
- }
-
- /**
- * Helper method to get the property with the specified name as a string if possible.
- *
- * @param name The property name.
- * @return The property object.
- */
- private Object getSinglePropertyOrFail(Object name)
- {
- Object result = get(name);
- if (result instanceof ValueList)
- {
- ConfigurationException exception = new ConfigurationException();
- exception.setMessage
- (UNEXPECTED_MULTIPLE_VALUES, new Object[] {name});
- throw exception;
- }
- return result;
- }
-
- /**
- * Gets the property with the specified name as a string if possible.
- *
- * @param name The property name.
- * @return The property name.
- */
- public String getProperty(String name)
- {
- return getPropertyAsString(name, null);
- }
-
- /**
- * Gets the property with the specified name as a ConfigMap if possible,
- * or returns the default value if the property is undefined.
- * <p/>
- * @param name the property name
- * @param defaultValue the default value
- * @return ConfigMap the ConfigMap object of the property
- */
- public ConfigMap getPropertyAsMap(String name, ConfigMap defaultValue)
- {
- Object prop = getSinglePropertyOrFail(name);
- if (prop instanceof ConfigMap)
- {
- return (ConfigMap)prop;
- }
- return defaultValue;
- }
-
- /**
- * Gets the property with the specified name as a String if possible,
- * or returns the default value if the property is undefined.
- * <p/>
- * @param name the property name
- * @param defaultValue the default value
- * @return String the String value of the property
- */
- public String getPropertyAsString(String name, String defaultValue)
- {
- Object prop = getSinglePropertyOrFail(name);
- if (prop instanceof String)
- {
- return (String)prop;
- }
- return defaultValue;
- }
-
- /**
- * Gets a property (or set of properties) as a List. If only one
- * property exists it is added as the only entry to a new List.
- *
- * @param name the property name
- * @param defaultValue the value to return if the property is not found
- * @return the value for the property as a List if it exists in this map,
- * otherwise the defaultValue is returned.
- */
- public List getPropertyAsList(String name, List defaultValue)
- {
- Object prop = get(name);
- if (prop != null)
- {
- if (prop instanceof List)
- {
- return (List) prop;
- }
- else
- {
- List list = new ArrayList();
- list.add(prop);
- return list;
- }
- }
- return defaultValue;
- }
-
- /**
- * Gets the property with the specified name as a boolean if possible,
- * or returns the default value if the property is undefined.
- * <p/>
- * @param name the property name
- * @param defaultValue the default value
- * @return boolean the boolean value of the property
- */
- public boolean getPropertyAsBoolean(String name, boolean defaultValue)
- {
- Object prop = getSinglePropertyOrFail(name);
- if (prop instanceof String)
- {
- return Boolean.valueOf((String)prop).booleanValue();
- }
- return defaultValue;
- }
-
- /**
- * Gets the property with the specified name as an int if possible,
- * or returns the default value if the property is undefined.
- * <p/>
- * @param name the property name
- * @param defaultValue the default value
- * @return int the int value of the property
- */
- public int getPropertyAsInt(String name, int defaultValue)
- {
- Object prop = getSinglePropertyOrFail(name);
- if (prop instanceof String)
- {
- try
- {
- return Integer.parseInt((String)prop);
- }
- catch (NumberFormatException ex)
- {
- }
- }
- return defaultValue;
- }
-
- /**
- * Gets the property with the specified name as a long if possible,
- * or returns the default value if the property is undefined.
- * <p/>
- * @param name the property name
- * @param defaultValue the default value
- * @return long the long value of the property
- */
- public long getPropertyAsLong(String name, long defaultValue)
- {
- Object prop = getSinglePropertyOrFail(name);
- if (prop instanceof String)
- {
- try
- {
- return Long.parseLong((String)prop);
- }
- catch (NumberFormatException ex)
- {
- }
- }
- return defaultValue;
- }
-
- /**
- * Returns a list of qualified property names that have not been accessed
- * by one of the get*() methods.
- * <p/>
- * @return List a list of unused properties
- */
- public List findAllUnusedProperties()
- {
- List result = new ArrayList();
- findUnusedProperties("", true, result);
- return result;
- }
-
- /**
- * Gathers a collection of properties that exist in the map but have not
- * been explicitly accessed nor marked as allowed. This list is helpful
- * in validating a set of properties as one can detect those that are
- * unknown or unexpected.
- *
- * @param parentPath Used to track the depth of property in a potential
- * hierarchy of <code>ConfigMap</code>s.
- * @param recurse Whether sub maps should be recursively searched.
- * @param result the collection of unused properties in this map.
- */
- public void findUnusedProperties
- (String parentPath, boolean recurse, Collection result)
- {
- Iterator itr = entrySet().iterator();
- while (itr.hasNext())
- {
- Map.Entry entry = (Map.Entry) itr.next();
- Object key = entry.getKey();
- String currentPath = parentPath + '/' + String.valueOf(key);
- if (!accessedKeys.contains(key))
- {
- result.add(currentPath);
- }
- else if (recurse)
- {
- Object value = entry.getValue();
- List values = value instanceof List ?
- (List) value : Collections.singletonList(value);
- for (int i = 0; i < values.size(); i++)
- {
- Object child = values.get(i);
- if (child instanceof ConfigMap)
- {
- ((ConfigMap) child).findUnusedProperties
- (currentPath, recurse, result);
- }
- }
- }
- }
- }
-}
+/*
+ * 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.config;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The ConfigMap class is a helper implementation of Map that makes it easier
+ * to handle properties that can appear one or more times. If a property is set
+ * more than once, it is converted to a List and added as another property
+ * rather than replacing the existing property. It also provides utility APIs
+ * for getting properties from the Map, cast to a certain type and allows a
+ * default to be specified in the event that the property is missing.
+ *
+ * @author Peter Farland
+ */
+public class ConfigMap extends LinkedHashMap
+{
+ /**
+ * This number was generated using the 'serialver' command line tool.
+ * This number should remain consistent with the version used by
+ * ColdFusion to communicate with the message broker over RMI.
+ */
+ private static final long serialVersionUID = 8913604659150919550L;
+
+ /**
+ * This error is thrown when a property unexpectedly contains multiple values.
+ */
+ private static final int UNEXPECTED_MULTIPLE_VALUES = 10169;
+
+ /**
+ * An *undocumented* system property can be used to revert to legacy config property handling:
+ * Legacy behavior - config property values were not trimmed, retaining leading/trailing whitespace which
+ * proved problematic for customers.
+ * New default behavior - config property values are trimmed.
+ */
+ private static final String SYSPROPNAME_TRIM_CONFIG_PROPERTY_VALUES = "flex.trim-config-property-values";
+ private static final boolean TRIM_CONFIG_PROPERTY_VALUES = Boolean.valueOf(System.getProperty(SYSPROPNAME_TRIM_CONFIG_PROPERTY_VALUES, "true")).booleanValue();
+
+ /**
+ * Map to keep track of accessed properties.
+ */
+ private HashSet accessedKeys = new HashSet();
+
+ /**
+ * Constructs an empty <code>ConfigMap</code> with the default initial
+ * capacity of 10.
+ */
+ public ConfigMap()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new <code>ConfigMap</code> with the initial
+ * capacity specified.
+ *
+ * @param initialCapacity the initial capacity.
+ */
+ public ConfigMap(int initialCapacity)
+ {
+ super(initialCapacity);
+ }
+
+ /**
+ * Constructs a new <code>ConfigMap</code> and copies the values
+ * from the supplied map to this map.
+ *
+ * @param m a <code>ConfigMap</code> whose properties are to be added to
+ * this <code>ConfigMap</code>.
+ */
+ public ConfigMap(ConfigMap m)
+ {
+ this();
+ addProperties(m);
+ }
+
+ /**
+ * Adds all properties from a map to this map.
+ *
+ * @param p a <code>ConfigMap</code> whose properties are to be added to
+ * this <code>ConfigMap</code>.
+ */
+ public void addProperties(ConfigMap p)
+ {
+ Iterator it = p.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ Object key = entry.getKey();
+ Object value = entry.getValue();
+ if (value instanceof ValueList)
+ {
+ addProperties(key, (ValueList) value);
+ }
+ else
+ {
+ addPropertyLogic(key, value);
+ }
+ }
+ }
+
+ /**
+ * Helper method to add a list of values under a key.
+ *
+ * @param key The key to add the values under.
+ * @param values The list of values to add.
+ */
+ private void addProperties(Object key, ValueList values)
+ {
+ ValueList list = getValueList(key);
+ if (list == null)
+ {
+ put(key, values.clone());
+ }
+ else
+ {
+ list.addAll(values);
+ }
+ }
+
+ /**
+ * Helper method to add a value under a key.
+ *
+ * @param key The key to add the value under.
+ * @param value The value to add.
+ */
+ private void addPropertyLogic(Object key, Object value)
+ {
+ ValueList list = getValueList(key);
+ if (list == null)
+ {
+ put(key, value);
+ }
+ else
+ {
+ list.add(value);
+ }
+ }
+
+ private static class ValueList extends ArrayList
+ {
+ /**
+ * Serial version id.
+ */
+ static final long serialVersionUID = -5637755312744414675L;
+ }
+
+ /**
+ * Given a key, returns a list of values associated with that key.
+ *
+ * @param key The key.
+ * @return A list of values associated with the key.
+ */
+ private ValueList getValueList(Object key)
+ {
+ ValueList list;
+ Object old = super.get(key);
+ if (old instanceof ValueList)
+ {
+ list = (ValueList) old;
+ }
+ else if (old != null)
+ {
+ list = new ValueList();
+ list.add(old);
+ put(key, list);
+ }
+ else
+ {
+ list = null;
+ }
+ return list;
+ }
+
+ /**
+ * Adds a <code>String</code> value to this map for the given property
+ * name.
+ *
+ * @param name the property name
+ * @param value the property value
+ */
+ public void addProperty(String name, String value)
+ {
+ addPropertyLogic(name, TRIM_CONFIG_PROPERTY_VALUES && value != null ? value.trim() : value);
+ }
+
+ /**
+ * Adds a <code>ConfigMap</code> value to this map for the given property
+ * name.
+ *
+ * @param name the property name
+ * @param value the property value
+ */
+ public void addProperty(String name, ConfigMap value)
+ {
+ addPropertyLogic(name, value);
+ }
+
+ /**
+ * Gets the set of property names contained in this map.
+ *
+ * @return a <code>Set</code> of property name <code>String</code>s.
+ */
+ public Set propertyNames()
+ {
+ return keySet();
+ }
+
+ /**
+ * Sets a property name as allowed without needing to access the property
+ * value. This marks a property as allowed for validation purposes.
+ *
+ * @param name the property name to allow
+ */
+ public void allowProperty(String name)
+ {
+ accessedKeys.add(name);
+ }
+
+ /**
+ * Gets the value for the given property name. Also records that this
+ * property was accessed.
+ *
+ * @param name the property name
+ * @return the value for the property, or null if property does not exist
+ * in this map.
+ */
+ public Object get(Object name)
+ {
+ accessedKeys.add(name);
+ return super.get(name);
+ }
+
+ /**
+ * Helper method to get the property with the specified name as a string if possible.
+ *
+ * @param name The property name.
+ * @return The property object.
+ */
+ private Object getSinglePropertyOrFail(Object name)
+ {
+ Object result = get(name);
+ if (result instanceof ValueList)
+ {
+ ConfigurationException exception = new ConfigurationException();
+ exception.setMessage
+ (UNEXPECTED_MULTIPLE_VALUES, new Object[] {name});
+ throw exception;
+ }
+ return result;
+ }
+
+ /**
+ * Gets the property with the specified name as a string if possible.
+ *
+ * @param name The property name.
+ * @return The property name.
+ */
+ public String getProperty(String name)
+ {
+ return getPropertyAsString(name, null);
+ }
+
+ /**
+ * Gets the property with the specified name as a ConfigMap if possible,
+ * or returns the default value if the property is undefined.
+ * <p/>
+ * @param name the property name
+ * @param defaultValue the default value
+ * @return ConfigMap the ConfigMap object of the property
+ */
+ public ConfigMap getPropertyAsMap(String name, ConfigMap defaultValue)
+ {
+ Object prop = getSinglePropertyOrFail(name);
+ if (prop instanceof ConfigMap)
+ {
+ return (ConfigMap)prop;
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Gets the property with the specified name as a String if possible,
+ * or returns the default value if the property is undefined.
+ * <p/>
+ * @param name the property name
+ * @param defaultValue the default value
+ * @return String the String value of the property
+ */
+ public String getPropertyAsString(String name, String defaultValue)
+ {
+ Object prop = getSinglePropertyOrFail(name);
+ if (prop instanceof String)
+ {
+ return (String)prop;
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Gets a property (or set of properties) as a List. If only one
+ * property exists it is added as the only entry to a new List.
+ *
+ * @param name the property name
+ * @param defaultValue the value to return if the property is not found
+ * @return the value for the property as a List if it exists in this map,
+ * otherwise the defaultValue is returned.
+ */
+ public List getPropertyAsList(String name, List defaultValue)
+ {
+ Object prop = get(name);
+ if (prop != null)
+ {
+ if (prop instanceof List)
+ {
+ return (List) prop;
+ }
+ else
+ {
+ List list = new ArrayList();
+ list.add(prop);
+ return list;
+ }
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Gets the property with the specified name as a boolean if possible,
+ * or returns the default value if the property is undefined.
+ * <p/>
+ * @param name the property name
+ * @param defaultValue the default value
+ * @return boolean the boolean value of the property
+ */
+ public boolean getPropertyAsBoolean(String name, boolean defaultValue)
+ {
+ Object prop = getSinglePropertyOrFail(name);
+ if (prop instanceof String)
+ {
+ return Boolean.valueOf((String)prop).booleanValue();
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Gets the property with the specified name as an int if possible,
+ * or returns the default value if the property is undefined.
+ * <p/>
+ * @param name the property name
+ * @param defaultValue the default value
+ * @return int the int value of the property
+ */
+ public int getPropertyAsInt(String name, int defaultValue)
+ {
+ Object prop = getSinglePropertyOrFail(name);
+ if (prop instanceof String)
+ {
+ try
+ {
+ return Integer.parseInt((String)prop);
+ }
+ catch (NumberFormatException ex)
+ {
+ }
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Gets the property with the specified name as a long if possible,
+ * or returns the default value if the property is undefined.
+ * <p/>
+ * @param name the property name
+ * @param defaultValue the default value
+ * @return long the long value of the property
+ */
+ public long getPropertyAsLong(String name, long defaultValue)
+ {
+ Object prop = getSinglePropertyOrFail(name);
+ if (prop instanceof String)
+ {
+ try
+ {
+ return Long.parseLong((String)prop);
+ }
+ catch (NumberFormatException ex)
+ {
+ }
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Returns a list of qualified property names that have not been accessed
+ * by one of the get*() methods.
+ * <p/>
+ * @return List a list of unused properties
+ */
+ public List findAllUnusedProperties()
+ {
+ List result = new ArrayList();
+ findUnusedProperties("", true, result);
+ return result;
+ }
+
+ /**
+ * Gathers a collection of properties that exist in the map but have not
+ * been explicitly accessed nor marked as allowed. This list is helpful
+ * in validating a set of properties as one can detect those that are
+ * unknown or unexpected.
+ *
+ * @param parentPath Used to track the depth of property in a potential
+ * hierarchy of <code>ConfigMap</code>s.
+ * @param recurse Whether sub maps should be recursively searched.
+ * @param result the collection of unused properties in this map.
+ */
+ public void findUnusedProperties
+ (String parentPath, boolean recurse, Collection result)
+ {
+ Iterator itr = entrySet().iterator();
+ while (itr.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) itr.next();
+ Object key = entry.getKey();
+ String currentPath = parentPath + '/' + String.valueOf(key);
+ if (!accessedKeys.contains(key))
+ {
+ result.add(currentPath);
+ }
+ else if (recurse)
+ {
+ Object value = entry.getValue();
+ List values = value instanceof List ?
+ (List) value : Collections.singletonList(value);
+ for (int i = 0; i < values.size(); i++)
+ {
+ Object child = values.get(i);
+ if (child instanceof ConfigMap)
+ {
+ ((ConfigMap) child).findUnusedProperties
+ (currentPath, recurse, result);
+ }
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ConfigurationConstants.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ConfigurationConstants.java b/modules/common/src/flex/messaging/config/ConfigurationConstants.java
old mode 100755
new mode 100644
index d2357dd..2310a66
--- a/modules/common/src/flex/messaging/config/ConfigurationConstants.java
+++ b/modules/common/src/flex/messaging/config/ConfigurationConstants.java
@@ -1,467 +1,467 @@
-/*
- * 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.config;
-
-/**
- * @exclude
- */
-public interface ConfigurationConstants
-{
- String CONTEXT_PATH_TOKEN = "{context.root}";
- String CONTEXT_PATH_ALT_TOKEN = "{context-root}";
- String SLASH_CONTEXT_PATH_TOKEN = "/{context.root}";
- String EMPTY_STRING = "";
- String TRUE_STRING = "true";
- String FALSE_STRING = "false";
- String SERVER_NAME_TOKEN = "{server.name}";
- String SERVER_PORT_TOKEN = "{server.port}";
-
- // ELEMENTS
-
- // Top Level
- String SERVICES_CONFIG_ELEMENT = "services-config";
-
- // Services
- String SERVICES_ELEMENT = "services";
- String SERVICE_ELEMENT = "service";
- String SERVICE_INCLUDE_ELEMENT = "service-include";
-
- String SRC_ATTR = "file-path";
- String DIRECTORY_ATTR = "directory-path";
- String ID_ATTR = "id";
- String CLASS_ATTR = "class";
- String PER_CLIENT_AUTH="per-client-authentication";
- String MESSAGE_TYPES_ATTR = "messageTypes";
-
- String PROPERTIES_ELEMENT = "properties";
-
- String METADATA_ELEMENT = "metadata";
-
- String ADAPTERS_ELEMENT = "adapters";
- String ADAPTER_DEFINITION_ELEMENT = "adapter-definition";
- String ADAPTER_INCLUDE_ELEMENT = "adapter-include";
- String DEFAULT_ATTR = "default";
-
- String DEFAULT_CHANNELS_ELEMENT = "default-channels";
- String CHANNEL_ELEMENT = "channel";
- String REF_ATTR = "ref";
-
- String DEFAULT_SECURITY_CONSTRAINT_ELEMENT = "default-security-constraint";
-
- String DESTINATION_ELEMENT = "destination";
- String DESTINATIONS_ELEMENT = "destinations";
- String DESTINATION_INCLUDE_ELEMENT = "destination-include";
- String ADAPTER_ELEMENT = "adapter";
- String ADAPTER_ATTR = "adapter";
- String CHANNELS_ATTR = "channels";
- String SECURITY_CONSTRAINT_ELEMENT = "security-constraint";
- String SECURITY_CONSTRAINT_ATTR = "security-constraint";
- String SECURITY_CONSTRAINTS_ELEMENT = "security-constraints"; // for includes only
-
- // Security
- String SECURITY_ELEMENT = "security";
- String SECURITY_CONSTRAINT_DEFINITION_ELEMENT = "security-constraint";
- String CONSTRAINT_INCLUDE_ELEMENT = "constraint-include";
- String AUTH_METHOD_ELEMENT = "auth-method";
- String ROLES_ELEMENT = "roles";
- String ROLE_ELEMENT = "role";
- String LOGIN_COMMAND_ELEMENT = "login-command";
- String SERVER_ATTR = "server";
- String RECREATE_HTTPSESSION_AFTER_LOGIN_ELEMENT = "recreate-httpsession-after-login";
-
- // SocketServers
- String SERVERS_ELEMENT = "servers";
- String SERVER_ELEMENT = "server";
- String IP_ADDRESS_PATTERN = "ip-address-pattern";
-
- // Channels
- String CHANNELS_ELEMENT = "channels";
- String CHANNEL_DEFINITION_ELEMENT = "channel-definition";
- String CHANNEL_INCLUDE_ELEMENT = "channel-include";
- String REMOTE_ATTR = "remote";
- String SERVER_ONLY_ATTR = "server-only";
- String ENDPOINT_ELEMENT = "endpoint";
- // Deprecated, use URL_ATTR instead.
- String URI_ATTR = "uri";
- String URL_ATTR = "url";
- String POLLING_ENABLED_ELEMENT = "polling-enabled";
- String POLLING_INTERVAL_MILLIS_ELEMENT = "polling-interval-millis";
- String PIGGYBACKING_ENABLED_ELEMENT = "piggybacking-enabled";
- String LOGIN_AFTER_DISCONNECT_ELEMENT = "login-after-disconnect";
- String RECORD_MESSAGE_SIZES_ELEMENT = "record-message-sizes";
- String RECORD_MESSAGE_TIMES_ELEMENT = "record-message-times";
- String SERIALIZATION_ELEMENT = "serialization";
- String ENABLE_SMALL_MESSAGES_ELEMENT = "enable-small-messages";
- // Deprecated, use POLLING_INTERVAL_MILLIS_ELEMENT instead.
- String POLLING_INTERVAL_SECONDS_ELEMENT = "polling-interval-seconds";
- String CONNECT_TIMEOUT_SECONDS_ELEMENT = "connect-timeout-seconds";
- String CLIENT_LOAD_BALANCING_ELEMENT = "client-load-balancing";
- String REQUEST_TIMEOUT_SECONDS_ELEMENT = "request-timeout-seconds";
-
- // Clusters
- String CLUSTERS_ELEMENT = "clusters";
- String CLUSTER_DEFINITION_ELEMENT = "cluster";
- String CLUSTER_PROPERTIES_ATTR = "properties";
-
- // Logging
- String LOGGING_ELEMENT = "logging";
- String TARGET_ELEMENT = "target";
- String FILTERS_ELEMENT = "filters";
- String PATTERN_ELEMENT = "pattern";
- String LEVEL_ATTR = "level";
-
- // System
- String SYSTEM_ELEMENT = "system";
- String ENFORCE_ENDOINT_VALIDATION ="enforce-endpoint-validation";
- String LOCALE_ELEMENT = "locale";
- String MANAGEABLE_ELEMENT = "manageable";
- String DEFAULT_LOCALE_ELEMENT = "default-locale";
- String REDEPLOY_ELEMENT = "redeploy";
- String ENABLED_ELEMENT = "enabled";
- String WATCH_INTERVAL_ELEMENT = "watch-interval";
- String WATCH_FILE_ELEMENT = "watch-file";
- String TOUCH_FILE_ELEMENT = "touch-file";
- String FACTORIES_ELEMENT = "factories";
- String FACTORY_ELEMENT = "factory";
- String UUID_GENERATOR_ELEMENT = "uuid-generator";
- String DOTNET_FRAMEWORK_VERSION = "dotnet-framework-version";
-
- // FlexClient
- String FLEX_CLIENT_ELEMENT = "flex-client";
- String FLEX_CLIENT_TIMEOUT_MINUTES_ELEMENT = "timeout-minutes";
- String FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_ELEMENT = "flex-client-outbound-queue-processor";
- String ADAPTIVE_FREQUENCY = "adaptive-frequency";
- String FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS = "reliable-reconnect-duration-millis";
- String FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS = "heartbeat-interval-millis";
-
- // Message filters
- String ASYNC_MESSAGE_FILTERS_ELEMENT = "async-message-filters";
- String SYNC_MESSAGE_FILTERS_ELEMENT = "sync-message-filters";
- String FILTER_ELEMENT = "filter";
-
- // Validators
- String VALIDATORS_ELEMENT = "validators";
- String VALIDATOR_ELEMENT = "validator";
- String TYPE_ATTR = "type";
-
- // CHILD ELEMENTS
-
- // Top Level
- String[] SERVICES_CONFIG_CHILDREN = {
- SERVICES_ELEMENT, SECURITY_ELEMENT, SERVERS_ELEMENT, CHANNELS_ELEMENT, LOGGING_ELEMENT,
- SYSTEM_ELEMENT, CLUSTERS_ELEMENT, FACTORIES_ELEMENT, FLEX_CLIENT_ELEMENT,
- ASYNC_MESSAGE_FILTERS_ELEMENT, SYNC_MESSAGE_FILTERS_ELEMENT, VALIDATORS_ELEMENT
- };
-
- // Services
- String[] SERVICES_CHILDREN = {
- SERVICE_ELEMENT, SERVICE_INCLUDE_ELEMENT, DEFAULT_CHANNELS_ELEMENT
- };
-
- String[] SERVICE_INCLUDE_CHILDREN = {
- SRC_ATTR, DIRECTORY_ATTR
- };
-
- String[] SERVICE_CHILDREN = {
- ID_ATTR, CLASS_ATTR, MESSAGE_TYPES_ATTR, PROPERTIES_ELEMENT,
- ADAPTERS_ELEMENT, DEFAULT_CHANNELS_ELEMENT, DEFAULT_SECURITY_CONSTRAINT_ELEMENT,
- DESTINATION_INCLUDE_ELEMENT, DESTINATION_ELEMENT
- };
-
- String[] SERVICE_REQ_CHILDREN = {
- ID_ATTR, CLASS_ATTR
- };
-
- String[] ADAPTER_DEFINITION_CHILDREN = {
- ID_ATTR, CLASS_ATTR, DEFAULT_ATTR, PROPERTIES_ELEMENT
- };
-
- String[] ADAPTER_DEFINITION_REQ_CHILDREN = {
- ID_ATTR, CLASS_ATTR
- };
-
- String[] DESTINATION_INCLUDE_CHILDREN = {
- SRC_ATTR, DIRECTORY_ATTR
- };
-
- String[] ADAPTERS_CHILDREN = {
- ADAPTER_DEFINITION_ELEMENT, ADAPTER_INCLUDE_ELEMENT
- };
-
- String[] ADAPTER_INCLUDE_CHILDREN = {
- SRC_ATTR, DIRECTORY_ATTR
- };
-
- String[] DEFAULT_CHANNELS_CHILDREN = {
- CHANNEL_ELEMENT
- };
-
- String[] FLEX_CLIENT_CHILDREN = {
- FLEX_CLIENT_TIMEOUT_MINUTES_ELEMENT, FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_ELEMENT,
- ADAPTIVE_FREQUENCY, FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS, FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS
- };
-
- String[] FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_REQ_CHILDREN = {
- CLASS_ATTR
- };
-
- // Security
- String[] SECURITY_CHILDREN = {
- SECURITY_CONSTRAINT_DEFINITION_ELEMENT, LOGIN_COMMAND_ELEMENT, RECREATE_HTTPSESSION_AFTER_LOGIN_ELEMENT,
- CONSTRAINT_INCLUDE_ELEMENT
- };
-
- String[] EMBEDDED_SECURITY_CHILDREN = {
- SECURITY_CONSTRAINT_DEFINITION_ELEMENT
- };
-
- String[] SECURITY_CONSTRAINT_DEFINITION_CHILDREN = {
- REF_ATTR, ID_ATTR, AUTH_METHOD_ELEMENT, ROLES_ELEMENT
- };
-
- String[] ROLES_CHILDREN = {
- ROLE_ELEMENT
- };
-
- String[] LOGIN_COMMAND_CHILDREN = {
- SERVER_ATTR, CLASS_ATTR, PER_CLIENT_AUTH
- };
-
- String[] LOGIN_COMMAND_REQ_CHILDREN = {
- SERVER_ATTR, CLASS_ATTR
- };
-
- String[] SECURITY_CONSTRAINTS_CHILDREN = {
- SECURITY_CONSTRAINT_ELEMENT
- };
-
- String[] CONSTRAINT_INCLUDE_CHILDREN = {
- SRC_ATTR, DIRECTORY_ATTR
- };
-
- // Servers
- String[] SERVERS_CHILDREN = {SERVER_ELEMENT};
-
- String[] SERVER_REQ_CHILDREN = {
- ID_ATTR, CLASS_ATTR
- };
-
- String [] SERVER_CHILDREN = {
- ID_ATTR, CLASS_ATTR, PROPERTIES_ELEMENT
- };
-
- // Channels
- String[] CHANNELS_CHILDREN = {
- CHANNEL_DEFINITION_ELEMENT, CHANNEL_INCLUDE_ELEMENT
- };
-
- String[] CHANNEL_DEFINITION_REQ_CHILDREN = {
- ENDPOINT_ELEMENT, ID_ATTR
- };
-
- String[] CHANNEL_DEFINITION_CHILDREN = {
- ENDPOINT_ELEMENT, PROPERTIES_ELEMENT, SECURITY_ELEMENT, SERVER_ELEMENT,
- SECURITY_CONSTRAINT_ATTR, CLASS_ATTR, ID_ATTR, REMOTE_ATTR, SERVER_ONLY_ATTR
- };
-
- String[] CHANNEL_DEFINITION_SERVER_REQ_CHILDREN = {
- REF_ATTR
- };
-
- String[] CHANNEL_INCLUDE_CHILDREN = {
- SRC_ATTR, DIRECTORY_ATTR
- };
-
- String[] ENDPOINT_CHILDREN = {
- URI_ATTR, URL_ATTR, CLASS_ATTR
- };
-
- String[] DESTINATION_REQ_CHILDREN = {
- ID_ATTR
- };
-
- String[] DESTINATION_CHILDREN = {
- ID_ATTR, PROPERTIES_ELEMENT, CHANNELS_ELEMENT, SECURITY_ELEMENT, ADAPTER_ELEMENT,
- CHANNELS_ATTR, ADAPTER_ATTR, SECURITY_CONSTRAINT_ATTR
- };
-
- String[] DESTINATIONS_CHILDREN = {
- DESTINATION_ELEMENT
- };
-
- String[] DESTINATION_ATTR = {
- ID_ATTR, PROPERTIES_ELEMENT, CHANNELS_ELEMENT, ADAPTER_ELEMENT,
- CHANNELS_ATTR, ADAPTER_ATTR, SECURITY_CONSTRAINT_ATTR
- };
-
- String[] DESTINATION_CHANNEL_REQ_CHILDREN = {
- REF_ATTR
- };
-
- String[] DESTINATION_CHANNELS_CHILDREN = {
- CHANNEL_ELEMENT
- };
-
- String[] DESTINATION_ADAPTER_CHILDREN = {
- REF_ATTR
- };
-
- // Clustering
- String[] CLUSTERING_CHILDREN = {
- CLUSTER_DEFINITION_ELEMENT
- };
-
- String[] CLUSTER_DEFINITION_CHILDREN = {
- ID_ATTR, CLUSTER_PROPERTIES_ATTR
- };
-
- // Logging
-
- String[] LOGGING_CHILDREN = {
- PROPERTIES_ELEMENT, LEVEL_ATTR, TARGET_ELEMENT,
- };
-
- String[] TARGET_CHILDREN = {
- CLASS_ATTR, LEVEL_ATTR, PROPERTIES_ELEMENT, FILTERS_ELEMENT
- };
-
- String[] TARGET_REQ_CHILDREN = {
- CLASS_ATTR
- };
-
- String[] FILTERS_CHILDREN = {
- PATTERN_ELEMENT
- };
-
- // System
-
- String[] SYSTEM_CHILDREN = {
- LOCALE_ELEMENT, ENFORCE_ENDOINT_VALIDATION, REDEPLOY_ELEMENT, MANAGEABLE_ELEMENT, UUID_GENERATOR_ELEMENT, DOTNET_FRAMEWORK_VERSION
- };
-
- String[] REDEPLOY_CHILDREN = {
- ENABLED_ELEMENT, WATCH_INTERVAL_ELEMENT, WATCH_FILE_ELEMENT, TOUCH_FILE_ELEMENT
- };
-
- String[] LOCALE_CHILDREN = {
- DEFAULT_LOCALE_ELEMENT
- };
-
- // Factories
- String[] FACTORIES_CHILDREN = {
- FACTORY_ELEMENT
- };
-
- String[] FACTORY_REQ_CHILDREN = {
- ID_ATTR, CLASS_ATTR
- };
-
- // Message filters
- String[] ASYNC_MESSAGE_FILTERS_ELEMENT_CHILDREN = {
- FILTER_ELEMENT
- };
-
- String[] SYNC_MESSAGE_FILTERS_ELEMENT_CHILDREN = {
- FILTER_ELEMENT
- };
-
- String[] FILTER_CHILDREN = {
- ID_ATTR, CLASS_ATTR, PROPERTIES_ELEMENT
- };
-
- String[] FILTER_REQ_CHILDREN = {
- ID_ATTR, CLASS_ATTR
- };
-
- // UUID Generator
- String[] UUID_GENERATOR_REQ_CHILDREN = {
- CLASS_ATTR
- };
-
- // Validators
- String[] VALIDATORS_CHILDREN = {
- VALIDATOR_ELEMENT
- };
-
- String[] VALIDATOR_CHILDREN = {
- CLASS_ATTR, TYPE_ATTR, PROPERTIES_ELEMENT
- };
-
- String[] VALIDATOR_REQ_CHILDREN = {
- CLASS_ATTR
- };
-
- // UTILS
- String LIST_DELIMITERS = ",;:";
-
- // TOKEN REPLACEMENT
- String UNKNOWN_SOURCE_FILE = "uknown file";
-
-
- // EXCEPTION MESSAGES
-
- int PARSER_INIT_ERROR = 10100;
- int PARSER_INTERNAL_ERROR = 10101;
- int XML_PARSER_ERROR = 10102;
- int INVALID_SERVICES_ROOT = 10103;
- int MISSING_ELEMENT = 10104;
- int MISSING_ATTRIBUTE = 10105;
- int UNEXPECTED_ELEMENT = 10106;
- int UNEXPECTED_ATTRIBUTE = 10107;
- int TOO_MANY_OCCURRENCES = 10108;
- int REF_NOT_FOUND = 10109;
- int INVALID_ID = 10110;
- int INVALID_ENDPOINT_PORT = 10111;
- int INVALID_INCLUDE_ROOT = 10112;
- int DUPLICATE_SERVICE_ERROR = 10113;
- int CLASS_NOT_SPECIFIED = 10114;
- int INVALID_DEFAULT_CHANNEL = 10116;
- int DUPLICATE_DEFAULT_ADAPTER = 10117;
- int MISSING_INCLUDE_ATTRIBUTES = 10118;
- int INVALID_ID_IN_SERVICE = 10119;
- int REF_NOT_FOUND_IN_DEST = 10120;
- int INVALID_REF_IN_DEST = 10121;
- int DUPLICATE_DESTINATION_ERROR = 10122;
- int DEST_NEEDS_CHANNEL = 10123;
- int DEST_NEEDS_ADAPTER = 10127;
- int REF_NOT_FOUND_IN_CHANNEL = 10132;
- int UNEXPECTED_TEXT = 11104;
-
- int NULL_COMPONENT = 11110;
- int NULL_COMPONENT_ID = 11111;
- int DUPLICATE_COMPONENT_ID = 11112;
- int UNREGISTERED_ADAPTER = 11114;
- int DUPLICATE_DEST_ID = 11119;
-
- int UNDEFINED_CONTEXT_ROOT = 11120;
- int INVALID_FLEX_CLIENT_TIMEOUT = 11123;
- int INVALID_SECURITY_CONSTRAINT_REF = 11124;
- int IRREPLACABLE_TOKEN = 11125;
- int INVALID_VALUE_FOR_PROPERTY_OF_COMPONENT_WITH_ID = 11126;
- int DUPLICATE_CHANNEL_ERROR = 11127;
- int INVALID_FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS = 11137;
- int INVALID_FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS = 11146;
-
- int REQUIRE_ADVANCED_MESSAGING_SUPPORT = 11129;
- int CLASS_OR_SERVER_ONLY_ERROR = 11139;
- int CLASS_AND_SERVER_ONLY_ERROR = 11140;
- int ERR_MSG_EMPTY_CLIENT_LOAD_BALANCING_ELEMENT = 11141;
- int ERR_MSG_EMTPY_CLIENT_LOAD_BALACNING_URL = 11142;
- int ERR_MSG_CLIENT_LOAD_BALANCING_URL_WITH_TOKEN = 11147;
-
- int EXTERNAL_ENTITY_NOT_ALLOW = 11149;
-}
+/*
+ * 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.config;
+
+/**
+ * @exclude
+ */
+public interface ConfigurationConstants
+{
+ String CONTEXT_PATH_TOKEN = "{context.root}";
+ String CONTEXT_PATH_ALT_TOKEN = "{context-root}";
+ String SLASH_CONTEXT_PATH_TOKEN = "/{context.root}";
+ String EMPTY_STRING = "";
+ String TRUE_STRING = "true";
+ String FALSE_STRING = "false";
+ String SERVER_NAME_TOKEN = "{server.name}";
+ String SERVER_PORT_TOKEN = "{server.port}";
+
+ // ELEMENTS
+
+ // Top Level
+ String SERVICES_CONFIG_ELEMENT = "services-config";
+
+ // Services
+ String SERVICES_ELEMENT = "services";
+ String SERVICE_ELEMENT = "service";
+ String SERVICE_INCLUDE_ELEMENT = "service-include";
+
+ String SRC_ATTR = "file-path";
+ String DIRECTORY_ATTR = "directory-path";
+ String ID_ATTR = "id";
+ String CLASS_ATTR = "class";
+ String PER_CLIENT_AUTH="per-client-authentication";
+ String MESSAGE_TYPES_ATTR = "messageTypes";
+
+ String PROPERTIES_ELEMENT = "properties";
+
+ String METADATA_ELEMENT = "metadata";
+
+ String ADAPTERS_ELEMENT = "adapters";
+ String ADAPTER_DEFINITION_ELEMENT = "adapter-definition";
+ String ADAPTER_INCLUDE_ELEMENT = "adapter-include";
+ String DEFAULT_ATTR = "default";
+
+ String DEFAULT_CHANNELS_ELEMENT = "default-channels";
+ String CHANNEL_ELEMENT = "channel";
+ String REF_ATTR = "ref";
+
+ String DEFAULT_SECURITY_CONSTRAINT_ELEMENT = "default-security-constraint";
+
+ String DESTINATION_ELEMENT = "destination";
+ String DESTINATIONS_ELEMENT = "destinations";
+ String DESTINATION_INCLUDE_ELEMENT = "destination-include";
+ String ADAPTER_ELEMENT = "adapter";
+ String ADAPTER_ATTR = "adapter";
+ String CHANNELS_ATTR = "channels";
+ String SECURITY_CONSTRAINT_ELEMENT = "security-constraint";
+ String SECURITY_CONSTRAINT_ATTR = "security-constraint";
+ String SECURITY_CONSTRAINTS_ELEMENT = "security-constraints"; // for includes only
+
+ // Security
+ String SECURITY_ELEMENT = "security";
+ String SECURITY_CONSTRAINT_DEFINITION_ELEMENT = "security-constraint";
+ String CONSTRAINT_INCLUDE_ELEMENT = "constraint-include";
+ String AUTH_METHOD_ELEMENT = "auth-method";
+ String ROLES_ELEMENT = "roles";
+ String ROLE_ELEMENT = "role";
+ String LOGIN_COMMAND_ELEMENT = "login-command";
+ String SERVER_ATTR = "server";
+ String RECREATE_HTTPSESSION_AFTER_LOGIN_ELEMENT = "recreate-httpsession-after-login";
+
+ // SocketServers
+ String SERVERS_ELEMENT = "servers";
+ String SERVER_ELEMENT = "server";
+ String IP_ADDRESS_PATTERN = "ip-address-pattern";
+
+ // Channels
+ String CHANNELS_ELEMENT = "channels";
+ String CHANNEL_DEFINITION_ELEMENT = "channel-definition";
+ String CHANNEL_INCLUDE_ELEMENT = "channel-include";
+ String REMOTE_ATTR = "remote";
+ String SERVER_ONLY_ATTR = "server-only";
+ String ENDPOINT_ELEMENT = "endpoint";
+ // Deprecated, use URL_ATTR instead.
+ String URI_ATTR = "uri";
+ String URL_ATTR = "url";
+ String POLLING_ENABLED_ELEMENT = "polling-enabled";
+ String POLLING_INTERVAL_MILLIS_ELEMENT = "polling-interval-millis";
+ String PIGGYBACKING_ENABLED_ELEMENT = "piggybacking-enabled";
+ String LOGIN_AFTER_DISCONNECT_ELEMENT = "login-after-disconnect";
+ String RECORD_MESSAGE_SIZES_ELEMENT = "record-message-sizes";
+ String RECORD_MESSAGE_TIMES_ELEMENT = "record-message-times";
+ String SERIALIZATION_ELEMENT = "serialization";
+ String ENABLE_SMALL_MESSAGES_ELEMENT = "enable-small-messages";
+ // Deprecated, use POLLING_INTERVAL_MILLIS_ELEMENT instead.
+ String POLLING_INTERVAL_SECONDS_ELEMENT = "polling-interval-seconds";
+ String CONNECT_TIMEOUT_SECONDS_ELEMENT = "connect-timeout-seconds";
+ String CLIENT_LOAD_BALANCING_ELEMENT = "client-load-balancing";
+ String REQUEST_TIMEOUT_SECONDS_ELEMENT = "request-timeout-seconds";
+
+ // Clusters
+ String CLUSTERS_ELEMENT = "clusters";
+ String CLUSTER_DEFINITION_ELEMENT = "cluster";
+ String CLUSTER_PROPERTIES_ATTR = "properties";
+
+ // Logging
+ String LOGGING_ELEMENT = "logging";
+ String TARGET_ELEMENT = "target";
+ String FILTERS_ELEMENT = "filters";
+ String PATTERN_ELEMENT = "pattern";
+ String LEVEL_ATTR = "level";
+
+ // System
+ String SYSTEM_ELEMENT = "system";
+ String ENFORCE_ENDOINT_VALIDATION ="enforce-endpoint-validation";
+ String LOCALE_ELEMENT = "locale";
+ String MANAGEABLE_ELEMENT = "manageable";
+ String DEFAULT_LOCALE_ELEMENT = "default-locale";
+ String REDEPLOY_ELEMENT = "redeploy";
+ String ENABLED_ELEMENT = "enabled";
+ String WATCH_INTERVAL_ELEMENT = "watch-interval";
+ String WATCH_FILE_ELEMENT = "watch-file";
+ String TOUCH_FILE_ELEMENT = "touch-file";
+ String FACTORIES_ELEMENT = "factories";
+ String FACTORY_ELEMENT = "factory";
+ String UUID_GENERATOR_ELEMENT = "uuid-generator";
+ String DOTNET_FRAMEWORK_VERSION = "dotnet-framework-version";
+
+ // FlexClient
+ String FLEX_CLIENT_ELEMENT = "flex-client";
+ String FLEX_CLIENT_TIMEOUT_MINUTES_ELEMENT = "timeout-minutes";
+ String FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_ELEMENT = "flex-client-outbound-queue-processor";
+ String ADAPTIVE_FREQUENCY = "adaptive-frequency";
+ String FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS = "reliable-reconnect-duration-millis";
+ String FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS = "heartbeat-interval-millis";
+
+ // Message filters
+ String ASYNC_MESSAGE_FILTERS_ELEMENT = "async-message-filters";
+ String SYNC_MESSAGE_FILTERS_ELEMENT = "sync-message-filters";
+ String FILTER_ELEMENT = "filter";
+
+ // Validators
+ String VALIDATORS_ELEMENT = "validators";
+ String VALIDATOR_ELEMENT = "validator";
+ String TYPE_ATTR = "type";
+
+ // CHILD ELEMENTS
+
+ // Top Level
+ String[] SERVICES_CONFIG_CHILDREN = {
+ SERVICES_ELEMENT, SECURITY_ELEMENT, SERVERS_ELEMENT, CHANNELS_ELEMENT, LOGGING_ELEMENT,
+ SYSTEM_ELEMENT, CLUSTERS_ELEMENT, FACTORIES_ELEMENT, FLEX_CLIENT_ELEMENT,
+ ASYNC_MESSAGE_FILTERS_ELEMENT, SYNC_MESSAGE_FILTERS_ELEMENT, VALIDATORS_ELEMENT
+ };
+
+ // Services
+ String[] SERVICES_CHILDREN = {
+ SERVICE_ELEMENT, SERVICE_INCLUDE_ELEMENT, DEFAULT_CHANNELS_ELEMENT
+ };
+
+ String[] SERVICE_INCLUDE_CHILDREN = {
+ SRC_ATTR, DIRECTORY_ATTR
+ };
+
+ String[] SERVICE_CHILDREN = {
+ ID_ATTR, CLASS_ATTR, MESSAGE_TYPES_ATTR, PROPERTIES_ELEMENT,
+ ADAPTERS_ELEMENT, DEFAULT_CHANNELS_ELEMENT, DEFAULT_SECURITY_CONSTRAINT_ELEMENT,
+ DESTINATION_INCLUDE_ELEMENT, DESTINATION_ELEMENT
+ };
+
+ String[] SERVICE_REQ_CHILDREN = {
+ ID_ATTR, CLASS_ATTR
+ };
+
+ String[] ADAPTER_DEFINITION_CHILDREN = {
+ ID_ATTR, CLASS_ATTR, DEFAULT_ATTR, PROPERTIES_ELEMENT
+ };
+
+ String[] ADAPTER_DEFINITION_REQ_CHILDREN = {
+ ID_ATTR, CLASS_ATTR
+ };
+
+ String[] DESTINATION_INCLUDE_CHILDREN = {
+ SRC_ATTR, DIRECTORY_ATTR
+ };
+
+ String[] ADAPTERS_CHILDREN = {
+ ADAPTER_DEFINITION_ELEMENT, ADAPTER_INCLUDE_ELEMENT
+ };
+
+ String[] ADAPTER_INCLUDE_CHILDREN = {
+ SRC_ATTR, DIRECTORY_ATTR
+ };
+
+ String[] DEFAULT_CHANNELS_CHILDREN = {
+ CHANNEL_ELEMENT
+ };
+
+ String[] FLEX_CLIENT_CHILDREN = {
+ FLEX_CLIENT_TIMEOUT_MINUTES_ELEMENT, FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_ELEMENT,
+ ADAPTIVE_FREQUENCY, FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS, FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS
+ };
+
+ String[] FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_REQ_CHILDREN = {
+ CLASS_ATTR
+ };
+
+ // Security
+ String[] SECURITY_CHILDREN = {
+ SECURITY_CONSTRAINT_DEFINITION_ELEMENT, LOGIN_COMMAND_ELEMENT, RECREATE_HTTPSESSION_AFTER_LOGIN_ELEMENT,
+ CONSTRAINT_INCLUDE_ELEMENT
+ };
+
+ String[] EMBEDDED_SECURITY_CHILDREN = {
+ SECURITY_CONSTRAINT_DEFINITION_ELEMENT
+ };
+
+ String[] SECURITY_CONSTRAINT_DEFINITION_CHILDREN = {
+ REF_ATTR, ID_ATTR, AUTH_METHOD_ELEMENT, ROLES_ELEMENT
+ };
+
+ String[] ROLES_CHILDREN = {
+ ROLE_ELEMENT
+ };
+
+ String[] LOGIN_COMMAND_CHILDREN = {
+ SERVER_ATTR, CLASS_ATTR, PER_CLIENT_AUTH
+ };
+
+ String[] LOGIN_COMMAND_REQ_CHILDREN = {
+ SERVER_ATTR, CLASS_ATTR
+ };
+
+ String[] SECURITY_CONSTRAINTS_CHILDREN = {
+ SECURITY_CONSTRAINT_ELEMENT
+ };
+
+ String[] CONSTRAINT_INCLUDE_CHILDREN = {
+ SRC_ATTR, DIRECTORY_ATTR
+ };
+
+ // Servers
+ String[] SERVERS_CHILDREN = {SERVER_ELEMENT};
+
+ String[] SERVER_REQ_CHILDREN = {
+ ID_ATTR, CLASS_ATTR
+ };
+
+ String [] SERVER_CHILDREN = {
+ ID_ATTR, CLASS_ATTR, PROPERTIES_ELEMENT
+ };
+
+ // Channels
+ String[] CHANNELS_CHILDREN = {
+ CHANNEL_DEFINITION_ELEMENT, CHANNEL_INCLUDE_ELEMENT
+ };
+
+ String[] CHANNEL_DEFINITION_REQ_CHILDREN = {
+ ENDPOINT_ELEMENT, ID_ATTR
+ };
+
+ String[] CHANNEL_DEFINITION_CHILDREN = {
+ ENDPOINT_ELEMENT, PROPERTIES_ELEMENT, SECURITY_ELEMENT, SERVER_ELEMENT,
+ SECURITY_CONSTRAINT_ATTR, CLASS_ATTR, ID_ATTR, REMOTE_ATTR, SERVER_ONLY_ATTR
+ };
+
+ String[] CHANNEL_DEFINITION_SERVER_REQ_CHILDREN = {
+ REF_ATTR
+ };
+
+ String[] CHANNEL_INCLUDE_CHILDREN = {
+ SRC_ATTR, DIRECTORY_ATTR
+ };
+
+ String[] ENDPOINT_CHILDREN = {
+ URI_ATTR, URL_ATTR, CLASS_ATTR
+ };
+
+ String[] DESTINATION_REQ_CHILDREN = {
+ ID_ATTR
+ };
+
+ String[] DESTINATION_CHILDREN = {
+ ID_ATTR, PROPERTIES_ELEMENT, CHANNELS_ELEMENT, SECURITY_ELEMENT, ADAPTER_ELEMENT,
+ CHANNELS_ATTR, ADAPTER_ATTR, SECURITY_CONSTRAINT_ATTR
+ };
+
+ String[] DESTINATIONS_CHILDREN = {
+ DESTINATION_ELEMENT
+ };
+
+ String[] DESTINATION_ATTR = {
+ ID_ATTR, PROPERTIES_ELEMENT, CHANNELS_ELEMENT, ADAPTER_ELEMENT,
+ CHANNELS_ATTR, ADAPTER_ATTR, SECURITY_CONSTRAINT_ATTR
+ };
+
+ String[] DESTINATION_CHANNEL_REQ_CHILDREN = {
+ REF_ATTR
+ };
+
+ String[] DESTINATION_CHANNELS_CHILDREN = {
+ CHANNEL_ELEMENT
+ };
+
+ String[] DESTINATION_ADAPTER_CHILDREN = {
+ REF_ATTR
+ };
+
+ // Clustering
+ String[] CLUSTERING_CHILDREN = {
+ CLUSTER_DEFINITION_ELEMENT
+ };
+
+ String[] CLUSTER_DEFINITION_CHILDREN = {
+ ID_ATTR, CLUSTER_PROPERTIES_ATTR
+ };
+
+ // Logging
+
+ String[] LOGGING_CHILDREN = {
+ PROPERTIES_ELEMENT, LEVEL_ATTR, TARGET_ELEMENT,
+ };
+
+ String[] TARGET_CHILDREN = {
+ CLASS_ATTR, LEVEL_ATTR, PROPERTIES_ELEMENT, FILTERS_ELEMENT
+ };
+
+ String[] TARGET_REQ_CHILDREN = {
+ CLASS_ATTR
+ };
+
+ String[] FILTERS_CHILDREN = {
+ PATTERN_ELEMENT
+ };
+
+ // System
+
+ String[] SYSTEM_CHILDREN = {
+ LOCALE_ELEMENT, ENFORCE_ENDOINT_VALIDATION, REDEPLOY_ELEMENT, MANAGEABLE_ELEMENT, UUID_GENERATOR_ELEMENT, DOTNET_FRAMEWORK_VERSION
+ };
+
+ String[] REDEPLOY_CHILDREN = {
+ ENABLED_ELEMENT, WATCH_INTERVAL_ELEMENT, WATCH_FILE_ELEMENT, TOUCH_FILE_ELEMENT
+ };
+
+ String[] LOCALE_CHILDREN = {
+ DEFAULT_LOCALE_ELEMENT
+ };
+
+ // Factories
+ String[] FACTORIES_CHILDREN = {
+ FACTORY_ELEMENT
+ };
+
+ String[] FACTORY_REQ_CHILDREN = {
+ ID_ATTR, CLASS_ATTR
+ };
+
+ // Message filters
+ String[] ASYNC_MESSAGE_FILTERS_ELEMENT_CHILDREN = {
+ FILTER_ELEMENT
+ };
+
+ String[] SYNC_MESSAGE_FILTERS_ELEMENT_CHILDREN = {
+ FILTER_ELEMENT
+ };
+
+ String[] FILTER_CHILDREN = {
+ ID_ATTR, CLASS_ATTR, PROPERTIES_ELEMENT
+ };
+
+ String[] FILTER_REQ_CHILDREN = {
+ ID_ATTR, CLASS_ATTR
+ };
+
+ // UUID Generator
+ String[] UUID_GENERATOR_REQ_CHILDREN = {
+ CLASS_ATTR
+ };
+
+ // Validators
+ String[] VALIDATORS_CHILDREN = {
+ VALIDATOR_ELEMENT
+ };
+
+ String[] VALIDATOR_CHILDREN = {
+ CLASS_ATTR, TYPE_ATTR, PROPERTIES_ELEMENT
+ };
+
+ String[] VALIDATOR_REQ_CHILDREN = {
+ CLASS_ATTR
+ };
+
+ // UTILS
+ String LIST_DELIMITERS = ",;:";
+
+ // TOKEN REPLACEMENT
+ String UNKNOWN_SOURCE_FILE = "uknown file";
+
+
+ // EXCEPTION MESSAGES
+
+ int PARSER_INIT_ERROR = 10100;
+ int PARSER_INTERNAL_ERROR = 10101;
+ int XML_PARSER_ERROR = 10102;
+ int INVALID_SERVICES_ROOT = 10103;
+ int MISSING_ELEMENT = 10104;
+ int MISSING_ATTRIBUTE = 10105;
+ int UNEXPECTED_ELEMENT = 10106;
+ int UNEXPECTED_ATTRIBUTE = 10107;
+ int TOO_MANY_OCCURRENCES = 10108;
+ int REF_NOT_FOUND = 10109;
+ int INVALID_ID = 10110;
+ int INVALID_ENDPOINT_PORT = 10111;
+ int INVALID_INCLUDE_ROOT = 10112;
+ int DUPLICATE_SERVICE_ERROR = 10113;
+ int CLASS_NOT_SPECIFIED = 10114;
+ int INVALID_DEFAULT_CHANNEL = 10116;
+ int DUPLICATE_DEFAULT_ADAPTER = 10117;
+ int MISSING_INCLUDE_ATTRIBUTES = 10118;
+ int INVALID_ID_IN_SERVICE = 10119;
+ int REF_NOT_FOUND_IN_DEST = 10120;
+ int INVALID_REF_IN_DEST = 10121;
+ int DUPLICATE_DESTINATION_ERROR = 10122;
+ int DEST_NEEDS_CHANNEL = 10123;
+ int DEST_NEEDS_ADAPTER = 10127;
+ int REF_NOT_FOUND_IN_CHANNEL = 10132;
+ int UNEXPECTED_TEXT = 11104;
+
+ int NULL_COMPONENT = 11110;
+ int NULL_COMPONENT_ID = 11111;
+ int DUPLICATE_COMPONENT_ID = 11112;
+ int UNREGISTERED_ADAPTER = 11114;
+ int DUPLICATE_DEST_ID = 11119;
+
+ int UNDEFINED_CONTEXT_ROOT = 11120;
+ int INVALID_FLEX_CLIENT_TIMEOUT = 11123;
+ int INVALID_SECURITY_CONSTRAINT_REF = 11124;
+ int IRREPLACABLE_TOKEN = 11125;
+ int INVALID_VALUE_FOR_PROPERTY_OF_COMPONENT_WITH_ID = 11126;
+ int DUPLICATE_CHANNEL_ERROR = 11127;
+ int INVALID_FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS = 11137;
+ int INVALID_FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS = 11146;
+
+ int REQUIRE_ADVANCED_MESSAGING_SUPPORT = 11129;
+ int CLASS_OR_SERVER_ONLY_ERROR = 11139;
+ int CLASS_AND_SERVER_ONLY_ERROR = 11140;
+ int ERR_MSG_EMPTY_CLIENT_LOAD_BALANCING_ELEMENT = 11141;
+ int ERR_MSG_EMTPY_CLIENT_LOAD_BALACNING_URL = 11142;
+ int ERR_MSG_CLIENT_LOAD_BALANCING_URL_WITH_TOKEN = 11147;
+
+ int EXTERNAL_ENTITY_NOT_ALLOW = 11149;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ConfigurationException.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ConfigurationException.java b/modules/common/src/flex/messaging/config/ConfigurationException.java
old mode 100755
new mode 100644
index beb154f..b2bfc09
--- a/modules/common/src/flex/messaging/config/ConfigurationException.java
+++ b/modules/common/src/flex/messaging/config/ConfigurationException.java
@@ -1,38 +1,38 @@
-/*
- * 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.config;
-
-import flex.messaging.LocalizedException;
-
-/**
- * The server throws this exception type on encountering
- * errors while parsing the configuration. Other classes
- * may also throw this exception type during initialization
- * in the event that the configuration settings used to
- * initialize the component was invalid.
- *
- * @author Peter Farland
- */
-public class ConfigurationException extends LocalizedException
-{
- /**
- * This number was generated using the 'serialver' command line tool.
- * This number should remain consistent with the version used by
- * ColdFusion to communicate with the message broker over RMI.
- */
- private static final long serialVersionUID = -6999307106348525358L;
-}
+/*
+ * 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.config;
+
+import flex.messaging.LocalizedException;
+
+/**
+ * The server throws this exception type on encountering
+ * errors while parsing the configuration. Other classes
+ * may also throw this exception type during initialization
+ * in the event that the configuration settings used to
+ * initialize the component was invalid.
+ *
+ * @author Peter Farland
+ */
+public class ConfigurationException extends LocalizedException
+{
+ /**
+ * This number was generated using the 'serialver' command line tool.
+ * This number should remain consistent with the version used by
+ * ColdFusion to communicate with the message broker over RMI.
+ */
+ private static final long serialVersionUID = -6999307106348525358L;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ConfigurationFileResolver.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ConfigurationFileResolver.java b/modules/common/src/flex/messaging/config/ConfigurationFileResolver.java
old mode 100755
new mode 100644
index 09ef098..60beebf
--- a/modules/common/src/flex/messaging/config/ConfigurationFileResolver.java
+++ b/modules/common/src/flex/messaging/config/ConfigurationFileResolver.java
@@ -1,32 +1,32 @@
-/*
- * 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.config;
-
-import java.io.InputStream;
-import java.util.List;
-
-/**
- * @exclude
- */
-public interface ConfigurationFileResolver
-{
- InputStream getConfigurationFile(String path);
- InputStream getIncludedFile(String path);
- void popIncludedFile();
-
- List getFiles(String dir);
+/*
+ * 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.config;
+
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * @exclude
+ */
+public interface ConfigurationFileResolver
+{
+ InputStream getConfigurationFile(String path);
+ InputStream getIncludedFile(String path);
+ void popIncludedFile();
+
+ List getFiles(String dir);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ConfigurationParser.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ConfigurationParser.java b/modules/common/src/flex/messaging/config/ConfigurationParser.java
old mode 100755
new mode 100644
index 90ae9c6..a6c8be3
--- a/modules/common/src/flex/messaging/config/ConfigurationParser.java
+++ b/modules/common/src/flex/messaging/config/ConfigurationParser.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.config;
-
-/**
- * Configuration parser for Flex Data Services. The parser reads in
- * a configuration file and populates a ServicesConfiguration instance.
- *
- * @author pfarland
- * @exclude
- */
-public interface ConfigurationParser
-{
- void parse(String path, ConfigurationFileResolver fileResolver, ServicesConfiguration config);
-
- void reportTokens();
-}
+/*
+ * 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.config;
+
+/**
+ * Configuration parser for Flex Data Services. The parser reads in
+ * a configuration file and populates a ServicesConfiguration instance.
+ *
+ * @author pfarland
+ * @exclude
+ */
+public interface ConfigurationParser
+{
+ void parse(String path, ConfigurationFileResolver fileResolver, ServicesConfiguration config);
+
+ void reportTokens();
+}
[23/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/Server.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/Server.java b/modules/core/src/flex/messaging/Server.java
old mode 100755
new mode 100644
index 3022fe6..dd6bf25
--- a/modules/core/src/flex/messaging/Server.java
+++ b/modules/core/src/flex/messaging/Server.java
@@ -1,35 +1,35 @@
-/*
- * 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;
-
-/**
- * The interface for a shared server instance that may be associated with a
- * <tt>MessageBroker</tt> and used by endpoints.
- */
-public interface Server extends FlexComponent
-{
- /**
- * Returns the id for the server.
- * Endpoints can lookup server instances that have been associated with a <tt>MessageBroker</tt> using {@link MessageBroker#getServer(String)}.
- */
- String getId();
-
- /**
- * Sets the id for the server.
- */
- void setId(String value);
-}
+/*
+ * 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;
+
+/**
+ * The interface for a shared server instance that may be associated with a
+ * <tt>MessageBroker</tt> and used by endpoints.
+ */
+public interface Server extends FlexComponent
+{
+ /**
+ * Returns the id for the server.
+ * Endpoints can lookup server instances that have been associated with a <tt>MessageBroker</tt> using {@link MessageBroker#getServer(String)}.
+ */
+ String getId();
+
+ /**
+ * Sets the id for the server.
+ */
+ void setId(String value);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/ServiceValidationListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/ServiceValidationListener.java b/modules/core/src/flex/messaging/ServiceValidationListener.java
old mode 100755
new mode 100644
index 4cecbd7..cb08fe1
--- a/modules/core/src/flex/messaging/ServiceValidationListener.java
+++ b/modules/core/src/flex/messaging/ServiceValidationListener.java
@@ -1,30 +1,30 @@
-/*
- * 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;
-
-/**
- * @exclude
- */
-public interface ServiceValidationListener
-{
- /**
- * This method gets called before any other processing of the describeServices method.
- * It allows a hook for external systems that need to update the service destinations at runtime.
- */
- void validateServices();
- void validateDestination(String destination);
+/*
+ * 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;
+
+/**
+ * @exclude
+ */
+public interface ServiceValidationListener
+{
+ /**
+ * This method gets called before any other processing of the describeServices method.
+ * It allows a hook for external systems that need to update the service destinations at runtime.
+ */
+ void validateServices();
+ void validateDestination(String destination);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/VersionInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/VersionInfo.java b/modules/core/src/flex/messaging/VersionInfo.java
old mode 100755
new mode 100644
index 4ff2cc6..8275f60
--- a/modules/core/src/flex/messaging/VersionInfo.java
+++ b/modules/core/src/flex/messaging/VersionInfo.java
@@ -1,116 +1,116 @@
-/*
- * 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;
-
-import flex.messaging.util.StringUtils;
-
-
-/**
- * Class representing the build version of Data Services.
- *
- *@exclude
- */
-public class VersionInfo
-{
- //Cache this info as it should not change during the time class is loaded
- public static String BUILD_MESSAGE;
- public static String BUILD_NUMBER_STRING;
- public static String BUILD_TITLE;
- public static long BUILD_NUMBER;
-
- private static final String LCDS_CLASS = "flex.data.DataService";
-
- public static String buildMessage()
- {
- if (BUILD_MESSAGE == null)
- {
- try
- {
- //Ensure we've parsed build info
- getBuild();
-
- if (StringUtils.isEmpty(BUILD_NUMBER_STRING))
- {
- BUILD_MESSAGE = BUILD_TITLE;
- }
- else
- {
- BUILD_MESSAGE = BUILD_TITLE + ": " + BUILD_NUMBER_STRING;
- }
- }
- catch (Throwable t)
- {
- BUILD_MESSAGE = BUILD_TITLE +": information unavailable";
- }
- }
-
- return BUILD_MESSAGE;
- }
-
- public static long getBuildAsLong()
- {
- if (BUILD_NUMBER == 0)
- {
- getBuild();
-
- if (BUILD_NUMBER_STRING != null && !BUILD_NUMBER_STRING.equals(""))
- {
- try
- {
- BUILD_NUMBER = Long.parseLong(BUILD_NUMBER_STRING);
- }
- catch (NumberFormatException nfe)
- {
- // ignore, just return 0
- }
- }
- }
-
- return BUILD_NUMBER;
- }
-
- public static String getBuild()
- {
- if (BUILD_NUMBER_STRING == null)
- {
- Class classToUseForManifest;
-
- try
- {
- classToUseForManifest = Class.forName(LCDS_CLASS);
- }
- catch (ClassNotFoundException e)
- {
- classToUseForManifest = VersionInfo.class;
- }
-
- try
- {
- BUILD_NUMBER_STRING = "";
- Package pack = classToUseForManifest.getPackage();
- BUILD_NUMBER_STRING = pack.getImplementationVersion();
- BUILD_TITLE = pack.getImplementationTitle();
- }
- catch (Throwable t)
- {
- // ignore, just return empty string
- }
- }
-
- return BUILD_NUMBER_STRING;
- }
-}
+/*
+ * 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;
+
+import flex.messaging.util.StringUtils;
+
+
+/**
+ * Class representing the build version of Data Services.
+ *
+ *@exclude
+ */
+public class VersionInfo
+{
+ //Cache this info as it should not change during the time class is loaded
+ public static String BUILD_MESSAGE;
+ public static String BUILD_NUMBER_STRING;
+ public static String BUILD_TITLE;
+ public static long BUILD_NUMBER;
+
+ private static final String LCDS_CLASS = "flex.data.DataService";
+
+ public static String buildMessage()
+ {
+ if (BUILD_MESSAGE == null)
+ {
+ try
+ {
+ //Ensure we've parsed build info
+ getBuild();
+
+ if (StringUtils.isEmpty(BUILD_NUMBER_STRING))
+ {
+ BUILD_MESSAGE = BUILD_TITLE;
+ }
+ else
+ {
+ BUILD_MESSAGE = BUILD_TITLE + ": " + BUILD_NUMBER_STRING;
+ }
+ }
+ catch (Throwable t)
+ {
+ BUILD_MESSAGE = BUILD_TITLE +": information unavailable";
+ }
+ }
+
+ return BUILD_MESSAGE;
+ }
+
+ public static long getBuildAsLong()
+ {
+ if (BUILD_NUMBER == 0)
+ {
+ getBuild();
+
+ if (BUILD_NUMBER_STRING != null && !BUILD_NUMBER_STRING.equals(""))
+ {
+ try
+ {
+ BUILD_NUMBER = Long.parseLong(BUILD_NUMBER_STRING);
+ }
+ catch (NumberFormatException nfe)
+ {
+ // ignore, just return 0
+ }
+ }
+ }
+
+ return BUILD_NUMBER;
+ }
+
+ public static String getBuild()
+ {
+ if (BUILD_NUMBER_STRING == null)
+ {
+ Class classToUseForManifest;
+
+ try
+ {
+ classToUseForManifest = Class.forName(LCDS_CLASS);
+ }
+ catch (ClassNotFoundException e)
+ {
+ classToUseForManifest = VersionInfo.class;
+ }
+
+ try
+ {
+ BUILD_NUMBER_STRING = "";
+ Package pack = classToUseForManifest.getPackage();
+ BUILD_NUMBER_STRING = pack.getImplementationVersion();
+ BUILD_TITLE = pack.getImplementationTitle();
+ }
+ catch (Throwable t)
+ {
+ // ignore, just return empty string
+ }
+ }
+
+ return BUILD_NUMBER_STRING;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/AsyncPollHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/AsyncPollHandler.java b/modules/core/src/flex/messaging/client/AsyncPollHandler.java
old mode 100755
new mode 100644
index 64573e3..2817419
--- a/modules/core/src/flex/messaging/client/AsyncPollHandler.java
+++ b/modules/core/src/flex/messaging/client/AsyncPollHandler.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.client;
-
-/**
- * Defines the interface to handle asynchronous poll results.
- */
-public interface AsyncPollHandler
-{
- /**
- * Invoked by the <tt>FlexClient</tt> when an asynchronous poll result is available.
- *
- * @param flushResult The flush result containing messages to return in the poll response and
- * an optional wait time before the client should issue its next poll.
- */
- void asyncPollComplete(FlushResult flushResult);
-}
+/*
+ * 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;
+
+/**
+ * Defines the interface to handle asynchronous poll results.
+ */
+public interface AsyncPollHandler
+{
+ /**
+ * Invoked by the <tt>FlexClient</tt> when an asynchronous poll result is available.
+ *
+ * @param flushResult The flush result containing messages to return in the poll response and
+ * an optional wait time before the client should issue its next poll.
+ */
+ void asyncPollComplete(FlushResult flushResult);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/EndpointPushHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/EndpointPushHandler.java b/modules/core/src/flex/messaging/client/EndpointPushHandler.java
old mode 100755
new mode 100644
index a043cb7..8e9c19e
--- a/modules/core/src/flex/messaging/client/EndpointPushHandler.java
+++ b/modules/core/src/flex/messaging/client/EndpointPushHandler.java
@@ -1,79 +1,79 @@
-/*
- * 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;
-
-import java.util.List;
-
-import flex.messaging.MessageClient;
-import flex.messaging.messages.Message;
-
-/**
- * Defines the interface for a handler that may be registered by an endpoint with a <tt>FlexClient</tt> in order
- * to push messages to a connected client.
- */
-public interface EndpointPushHandler
-{
- /**
- * Invoked to shut down the handler.
- * It may be invoked by the endpoint when the underlying connection it manages to the client closes,
- * or by the <tt>FlexClient</tt> if it is invalidated.
- * The implementation of this method should release any resources, and should not attempt to notify the
- * client of an explicit disconnect.
- *
- * @see #close(boolean)
- */
- void close();
-
- /**
- * Invoked to shut down the handler.
- * It may be invoked by the endpoint when the underlying connection it manages to the client closes,
- * or by the <tt>FlexClient</tt> if it is invalidated.
- * The implementation of this method should release any resources, and may attempt to notify the client
- * Channel that it has been disconnected in order to suppress automatic reconnect behavior.
- *
- * @param disconnectChannel True to attempt to notify the client of an explicit disconnect in order to
- * suppress automatic reconnect behavior.
- */
- void close(boolean disconnectChannel);
-
- /**
- * Invoked by the <tt>FlexClient</tt> when it has messages to push to
- * the client.
- *
- * @param messagesToPush The list of messages to push.
- */
- void pushMessages(List<Message> messagesToPush);
-
- /**
- * Invoked to notify the handler that the <tt>MessageClient</tt> subscription is using this handler.
- * If subscriptions should be invalidated if the handler is closed, it should retain references to
- * all registered <tt>MessageClient</tt> instances and invalidate them when it closes.
- *
- * @param messageClient The <tt>MessageClient</tt> subscription using this handler.
- */
- void registerMessageClient(MessageClient messageClient);
-
- /**
- * Invoked to notify the handler that a <tt>MessageClient</tt> subscription that was using it has
- * been invalidated.
- * If the handler is tracking the set of <tt>MessageClient</tt> instances that are using it, the handler should
- * remove the instance from its set.
- *
- * @param messageClient The <tt>MessageClient</tt> subscription no longer using this handler.
- */
- void unregisterMessageClient(MessageClient messageClient);
-}
+/*
+ * 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;
+
+import java.util.List;
+
+import flex.messaging.MessageClient;
+import flex.messaging.messages.Message;
+
+/**
+ * Defines the interface for a handler that may be registered by an endpoint with a <tt>FlexClient</tt> in order
+ * to push messages to a connected client.
+ */
+public interface EndpointPushHandler
+{
+ /**
+ * Invoked to shut down the handler.
+ * It may be invoked by the endpoint when the underlying connection it manages to the client closes,
+ * or by the <tt>FlexClient</tt> if it is invalidated.
+ * The implementation of this method should release any resources, and should not attempt to notify the
+ * client of an explicit disconnect.
+ *
+ * @see #close(boolean)
+ */
+ void close();
+
+ /**
+ * Invoked to shut down the handler.
+ * It may be invoked by the endpoint when the underlying connection it manages to the client closes,
+ * or by the <tt>FlexClient</tt> if it is invalidated.
+ * The implementation of this method should release any resources, and may attempt to notify the client
+ * Channel that it has been disconnected in order to suppress automatic reconnect behavior.
+ *
+ * @param disconnectChannel True to attempt to notify the client of an explicit disconnect in order to
+ * suppress automatic reconnect behavior.
+ */
+ void close(boolean disconnectChannel);
+
+ /**
+ * Invoked by the <tt>FlexClient</tt> when it has messages to push to
+ * the client.
+ *
+ * @param messagesToPush The list of messages to push.
+ */
+ void pushMessages(List<Message> messagesToPush);
+
+ /**
+ * Invoked to notify the handler that the <tt>MessageClient</tt> subscription is using this handler.
+ * If subscriptions should be invalidated if the handler is closed, it should retain references to
+ * all registered <tt>MessageClient</tt> instances and invalidate them when it closes.
+ *
+ * @param messageClient The <tt>MessageClient</tt> subscription using this handler.
+ */
+ void registerMessageClient(MessageClient messageClient);
+
+ /**
+ * Invoked to notify the handler that a <tt>MessageClient</tt> subscription that was using it has
+ * been invalidated.
+ * If the handler is tracking the set of <tt>MessageClient</tt> instances that are using it, the handler should
+ * remove the instance from its set.
+ *
+ * @param messageClient The <tt>MessageClient</tt> subscription no longer using this handler.
+ */
+ void unregisterMessageClient(MessageClient messageClient);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/EndpointPushNotifier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/EndpointPushNotifier.java b/modules/core/src/flex/messaging/client/EndpointPushNotifier.java
old mode 100755
new mode 100644
index 925f7e1..151699e
--- a/modules/core/src/flex/messaging/client/EndpointPushNotifier.java
+++ b/modules/core/src/flex/messaging/client/EndpointPushNotifier.java
@@ -1,461 +1,461 @@
-/*
- * 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;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import flex.messaging.FlexContext;
-import flex.messaging.FlexSession;
-import flex.messaging.FlexSessionListener;
-import flex.messaging.MessageClient;
-import flex.messaging.MessageClientListener;
-import flex.messaging.endpoints.BaseStreamingHTTPEndpoint;
-import flex.messaging.endpoints.Endpoint;
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.messages.AsyncMessage;
-import flex.messaging.messages.CommandMessage;
-import flex.messaging.util.TimeoutAbstractObject;
-import flex.messaging.util.UUIDUtils;
-
-/**
- * @exclude
- * Instances of this class are used by endpoints that support streaming
- * outbound data to connected clients when the client is not polling and
- * the FlexSession representing the connection does not support push directly.
- * This generally requires that the client and endpoint establish a separate,
- * physical connection for pushed data that is part of a larger, logical
- * connection/session.
- * <p>
- * When the endpoint establishes this physical streaming connection it will
- * create an instance of this class, register it with the FlexClient and then
- * wait on the public <code>pushNeeded</code> condition variable.
- * When data arrives to push to the remote client, the FlexClient will queue it
- * with this notifier instance and the waiting endpoint will be notified.
- * The endpoint will retrieve the queued messages from the notifier instance and will
- * stream them to the client and then go back into a wait state on the
- * <code>pushNeeded</code> condition variable.
- * </p><p>
- * Note that this implementation is based upon <code>Object.wait()</code>; it is not a
- * non-blocking implementation.
- * </p>
- */
-public class EndpointPushNotifier extends TimeoutAbstractObject implements EndpointPushHandler, FlexSessionListener, MessageClientListener
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs a PushNotifier instance.
- *
- * @param endpoint The endpoint that will use this notifier.
- * @param flexClient The FlexClient that will use this notifier.
- */
- public EndpointPushNotifier(Endpoint endpoint, FlexClient flexClient)
- {
- notifierId = UUIDUtils.createUUID(false /* doesn't need to be secure */);
- this.endpoint = endpoint;
- this.flexClient = flexClient;
- flexClient.registerEndpointPushHandler(this, endpoint.getId());
- flexSession = FlexContext.getFlexSession();
- if (flexSession != null)
- flexSession.addSessionDestroyedListener(this);
- invalidateMessageClientOnStreamingClose = (endpoint instanceof BaseStreamingHTTPEndpoint)?
- ((BaseStreamingHTTPEndpoint)endpoint).isInvalidateMessageClientOnStreamingClose() : false;
- updateLastUse(); // Initialize last use timestamp to construct time.
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * The condition variable that the endpoint waits on for pushed data to arrive.
- */
- public final Object pushNeeded = new Object();
-
- //--------------------------------------------------------------------------
- //
- // Private Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Flag indicating whether the notifier has been closed/shut down.
- * This is used to signal a waiting endpoint that it should break out of its
- * wait loop and close its streaming connection.
- */
- private volatile boolean closed;
-
- /**
- * Flag indicating that the notifier has started closing; used to allow only
- * one thread to execute the close() logic and delay flipping closed to true
- * to allow any final messages to be streamed to the client before the endpoint
- * using the notifier breaks out of its wait/notify loop and terminates the
- * streaming connection.
- */
- private volatile boolean closing;
-
- /**
- * The number of minutes a client can remain idle before the server
- * times the notifier out.
- */
- private int idleTimeoutMinutes;
-
- /**
- * Whether to invalidate the message-client when the streaming connection is closed.
- */
- private final boolean invalidateMessageClientOnStreamingClose;
-
- /**
- * The endpoint that uses this notifier.
- */
- private final Endpoint endpoint;
-
- /**
- * The FlexClient this notifier is associated with.
- */
- private final FlexClient flexClient;
-
- /**
- * The FlexSession this notifier is associated with.
- */
- private final FlexSession flexSession;
-
- /**
- * Lock for instance-level synchronization.
- */
- private final Object lock = new Object();
-
- /**
- * Log category used by the notifier. Initialized to ENDPOINT_GENERAL but
- * endpoints using this notifier should set it to their own log categories.
- */
- private String logCategory = LogCategories.ENDPOINT_GENERAL;
-
- /**
- * Queue of messages that the FlexClient will populate and the endpoint will drain to
- * stream to the client.
- */
- private List<AsyncMessage> messages;
-
- /**
- * List of MessageClient subscriptions using this endpoint push notifier.
- * When this notifier is closed, any associated subscriptions need to be invalidated.
- */
- private final CopyOnWriteArrayList<MessageClient> messageClients = new CopyOnWriteArrayList<MessageClient>();
-
- /**
- * Unique identifier for this instance.
- */
- private final String notifierId;
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Moves this notifier to a closed state, notifying any listeners,
- * associated subscriptions and waiting endpoints.
- * Does not attempt to notify the client Channel of the disconnect thereby allowing
- * automatic reconnect processing to run.
- */
- public void close()
- {
- close(false);
- }
-
- /**
- * Moves this notifier to a closed state, notifying any listeners,
- * associated subscriptions and waiting endpoints.
- * Attempts to notify the client Channel of an explicit disconnect, thereby suppressing
- * automatic reconnect processing.
- *
- * @param disconnectChannel True to attempt to notify the client Channel of the disconnect
- * and suppress automatic reconnect processing.
- */
- public void close(boolean disconnectChannel)
- {
- synchronized (lock)
- {
- if (closed || closing)
- return;
-
- closing = true;
- }
-
- cancelTimeout();
-
- if (flexSession != null)
- flexSession.removeSessionDestroyedListener(this);
-
- // Shut down flow of further messages to this notifier.
- flexClient.unregisterEndpointPushHandler(this, endpoint.getId());
-
- // Push a disconnect command down to the client to suppress automatic reconnect.
- if (disconnectChannel)
- {
- ArrayList<AsyncMessage> list = new ArrayList<AsyncMessage>(1);
- CommandMessage disconnect = new CommandMessage(CommandMessage.DISCONNECT_OPERATION);
- list.add(disconnect);
- pushMessages(list);
- }
-
- // Invalidate associated subscriptions; this doesn't attempt to notify the client.
- // Any client subscriptions made over this endpoint will be automatically invalidated
- // on the client when it receives its channel disconnect event.
- if (invalidateMessageClientOnStreamingClose)
- {
- for (Iterator<MessageClient> iter = messageClients.iterator() ; iter.hasNext();)
- iter.next().invalidate();
- }
-
- // Move to final closed state; after this we need to notify one last time to stream
- // any final messages to the client and allow the endpoint to shut down its streaming
- // connection.
- synchronized (lock)
- {
- closed = true;
- closing = false;
- }
- synchronized (pushNeeded)
- {
- pushNeeded.notifyAll();
- }
- }
-
- /**
- * Returns any messages available to push to the client, and removes them
- * from this notifier.
- * Notified endpoints should invoke this method to retrieve messages, stream them
- * to the client and then re-enter the wait state.
- * This method acquires a lock on <code>pushNeeded</code>.
- *
- * @return The messages to push to the client.
- */
- public List<AsyncMessage> drainMessages()
- {
- synchronized (pushNeeded)
- {
- List<AsyncMessage> messagesToPush = messages;
- messages = null;
- return messagesToPush;
- }
- }
-
- /**
- * Returns whether the notifier has closed; used to break the endpoint's wait cycle.
- *
- * @return True if the notifier has closed; otherwise false.
- */
- public boolean isClosed()
- {
- return closed;
- }
-
- /**
- * Returns the endpoint that is using this notifier.
- *
- * @return The endpoint using this notifier.
- */
- public Endpoint getEndpoint()
- {
- return endpoint;
- }
-
- /**
- * Returns the idle timeout minutes used by the notifier.
- *
- * @return The idle timeout minutes used by the notifier.
- */
- public int getIdleTimeoutMinutes()
- {
- return idleTimeoutMinutes;
- }
-
- /**
- * Sets the idle timeout minutes used by the notifier.
- *
- * @param idleTimeoutMinutes The idle timeout minutes used by the notifier.
- */
- public void setIdleTimeoutMinutes(int idleTimeoutMinutes)
- {
- this.idleTimeoutMinutes = idleTimeoutMinutes;
- }
-
- /**
- * Returns the log category used by this notifier.
- *
- * @return The log category used by this notifier.
- */
- public String getLogCategory()
- {
- return logCategory;
- }
-
- /**
- * Sets the log category used by this notifier. Endpoints using this notifier
- * should set it to their own log categories.
- *
- * @param logCategory The log category for the notifier to use.
- */
- public void setLogCategory(String logCategory)
- {
- this.logCategory = logCategory;
- }
-
- /**
- * Returns the unique id for this notifier.
- *
- * @return The unique id for this notifier.
- */
- public String getNotifierId()
- {
- return notifierId;
- }
-
- /**
- * @exclude
- * Implements TimeoutCapable.
- * Determine the time, in milliseconds, that this object is allowed to idle
- * before having its timeout method invoked.
- */
- public long getTimeoutPeriod()
- {
- return (idleTimeoutMinutes * 60 * 1000);
- }
-
- /**
- * @exclude
- */
- public void messageClientCreated(MessageClient messageClient)
- {
- // No-op.
- }
-
- /**
- * @exclude
- */
- public void messageClientDestroyed(MessageClient messageClient)
- {
- unregisterMessageClient(messageClient);
- }
-
- /**
- * Used by FlexClient to push messages to the endpoint.
- * This method will automatically notify a waiting endpoint, if one exists
- * and it acquires a lock on <code>pushNeeded</code>.
- *
- * @param messages The messages to push to the client.
- */
- public void pushMessages(List messagesToPush)
- {
- if (!messagesToPush.isEmpty())
- {
- synchronized (pushNeeded)
- {
- // Push these straight on through; notify immediately.
- if (messages == null)
- messages = messagesToPush;
- else
- messages.addAll(messagesToPush);
-
- // If the notifier isn't closing, notify; otherwise just add and the close will
- // notify once it completes.
- if (!closing)
- pushNeeded.notifyAll();
- }
- }
- }
-
- /**
- * Registers a MessageClient subscription that depends on this notifier.
- *
- * @param messageClient A MessageClient that depends on this notifier.
- */
- public void registerMessageClient(MessageClient messageClient)
- {
- if (messageClient != null)
- {
- if (messageClients.addIfAbsent(messageClient))
- messageClient.addMessageClientDestroyedListener(this);
- }
- }
-
- /**
- * Handle session creation events. This handler is a no-op because the notifier
- * is only concerned with its associated session's destruction.
- *
- * @param flexSession The newly created FlexSession.
- */
- public void sessionCreated(FlexSession flexSession)
- {
- // No-op.
- }
-
- /**
- * Handle session destruction events. This will be invoked when the notifier's
- * associated session is invalidated, and this will trigger the notifier to close.
- *
- * @param flexSession The FlexSession being invalidated.
- */
- public void sessionDestroyed(FlexSession flexSession)
- {
- if (Log.isInfo())
- Log.getLogger(logCategory).info("Endpoint with id '" + endpoint.getId() + "' is closing"
- + " a streaming connection for the FlexClient with id '" + flexClient.getId() + "'"
- + " since its associated session has been destroyed.");
- close(true /* disconnect client Channel */);
- }
-
- /**
- * @exclude
- * Implements TimeoutCapable.
- * Inform the object that it has timed out.
- */
- public void timeout()
- {
- if (Log.isInfo())
- Log.getLogger(logCategory).info("Endpoint with id '" + endpoint.getId() + "' is timing out"
- + " a streaming connection for the FlexClient with id '" + flexClient.getId() + "'");
- close(true /* disconnect client Channel */);
- }
-
- /**
- * Unregisters a MessageClient subscription that depended on this notifier.
- *
- * @param messageClient A MessageClient that depended on this notifier.
- */
- public void unregisterMessageClient(MessageClient messageClient)
- {
- if (messageClient != null)
- {
- messageClient.removeMessageClientDestroyedListener(this);
- messageClients.remove(messageClient);
- }
- }
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import flex.messaging.FlexContext;
+import flex.messaging.FlexSession;
+import flex.messaging.FlexSessionListener;
+import flex.messaging.MessageClient;
+import flex.messaging.MessageClientListener;
+import flex.messaging.endpoints.BaseStreamingHTTPEndpoint;
+import flex.messaging.endpoints.Endpoint;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.messages.AsyncMessage;
+import flex.messaging.messages.CommandMessage;
+import flex.messaging.util.TimeoutAbstractObject;
+import flex.messaging.util.UUIDUtils;
+
+/**
+ * @exclude
+ * Instances of this class are used by endpoints that support streaming
+ * outbound data to connected clients when the client is not polling and
+ * the FlexSession representing the connection does not support push directly.
+ * This generally requires that the client and endpoint establish a separate,
+ * physical connection for pushed data that is part of a larger, logical
+ * connection/session.
+ * <p>
+ * When the endpoint establishes this physical streaming connection it will
+ * create an instance of this class, register it with the FlexClient and then
+ * wait on the public <code>pushNeeded</code> condition variable.
+ * When data arrives to push to the remote client, the FlexClient will queue it
+ * with this notifier instance and the waiting endpoint will be notified.
+ * The endpoint will retrieve the queued messages from the notifier instance and will
+ * stream them to the client and then go back into a wait state on the
+ * <code>pushNeeded</code> condition variable.
+ * </p><p>
+ * Note that this implementation is based upon <code>Object.wait()</code>; it is not a
+ * non-blocking implementation.
+ * </p>
+ */
+public class EndpointPushNotifier extends TimeoutAbstractObject implements EndpointPushHandler, FlexSessionListener, MessageClientListener
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs a PushNotifier instance.
+ *
+ * @param endpoint The endpoint that will use this notifier.
+ * @param flexClient The FlexClient that will use this notifier.
+ */
+ public EndpointPushNotifier(Endpoint endpoint, FlexClient flexClient)
+ {
+ notifierId = UUIDUtils.createUUID(false /* doesn't need to be secure */);
+ this.endpoint = endpoint;
+ this.flexClient = flexClient;
+ flexClient.registerEndpointPushHandler(this, endpoint.getId());
+ flexSession = FlexContext.getFlexSession();
+ if (flexSession != null)
+ flexSession.addSessionDestroyedListener(this);
+ invalidateMessageClientOnStreamingClose = (endpoint instanceof BaseStreamingHTTPEndpoint)?
+ ((BaseStreamingHTTPEndpoint)endpoint).isInvalidateMessageClientOnStreamingClose() : false;
+ updateLastUse(); // Initialize last use timestamp to construct time.
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The condition variable that the endpoint waits on for pushed data to arrive.
+ */
+ public final Object pushNeeded = new Object();
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Flag indicating whether the notifier has been closed/shut down.
+ * This is used to signal a waiting endpoint that it should break out of its
+ * wait loop and close its streaming connection.
+ */
+ private volatile boolean closed;
+
+ /**
+ * Flag indicating that the notifier has started closing; used to allow only
+ * one thread to execute the close() logic and delay flipping closed to true
+ * to allow any final messages to be streamed to the client before the endpoint
+ * using the notifier breaks out of its wait/notify loop and terminates the
+ * streaming connection.
+ */
+ private volatile boolean closing;
+
+ /**
+ * The number of minutes a client can remain idle before the server
+ * times the notifier out.
+ */
+ private int idleTimeoutMinutes;
+
+ /**
+ * Whether to invalidate the message-client when the streaming connection is closed.
+ */
+ private final boolean invalidateMessageClientOnStreamingClose;
+
+ /**
+ * The endpoint that uses this notifier.
+ */
+ private final Endpoint endpoint;
+
+ /**
+ * The FlexClient this notifier is associated with.
+ */
+ private final FlexClient flexClient;
+
+ /**
+ * The FlexSession this notifier is associated with.
+ */
+ private final FlexSession flexSession;
+
+ /**
+ * Lock for instance-level synchronization.
+ */
+ private final Object lock = new Object();
+
+ /**
+ * Log category used by the notifier. Initialized to ENDPOINT_GENERAL but
+ * endpoints using this notifier should set it to their own log categories.
+ */
+ private String logCategory = LogCategories.ENDPOINT_GENERAL;
+
+ /**
+ * Queue of messages that the FlexClient will populate and the endpoint will drain to
+ * stream to the client.
+ */
+ private List<AsyncMessage> messages;
+
+ /**
+ * List of MessageClient subscriptions using this endpoint push notifier.
+ * When this notifier is closed, any associated subscriptions need to be invalidated.
+ */
+ private final CopyOnWriteArrayList<MessageClient> messageClients = new CopyOnWriteArrayList<MessageClient>();
+
+ /**
+ * Unique identifier for this instance.
+ */
+ private final String notifierId;
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Moves this notifier to a closed state, notifying any listeners,
+ * associated subscriptions and waiting endpoints.
+ * Does not attempt to notify the client Channel of the disconnect thereby allowing
+ * automatic reconnect processing to run.
+ */
+ public void close()
+ {
+ close(false);
+ }
+
+ /**
+ * Moves this notifier to a closed state, notifying any listeners,
+ * associated subscriptions and waiting endpoints.
+ * Attempts to notify the client Channel of an explicit disconnect, thereby suppressing
+ * automatic reconnect processing.
+ *
+ * @param disconnectChannel True to attempt to notify the client Channel of the disconnect
+ * and suppress automatic reconnect processing.
+ */
+ public void close(boolean disconnectChannel)
+ {
+ synchronized (lock)
+ {
+ if (closed || closing)
+ return;
+
+ closing = true;
+ }
+
+ cancelTimeout();
+
+ if (flexSession != null)
+ flexSession.removeSessionDestroyedListener(this);
+
+ // Shut down flow of further messages to this notifier.
+ flexClient.unregisterEndpointPushHandler(this, endpoint.getId());
+
+ // Push a disconnect command down to the client to suppress automatic reconnect.
+ if (disconnectChannel)
+ {
+ ArrayList<AsyncMessage> list = new ArrayList<AsyncMessage>(1);
+ CommandMessage disconnect = new CommandMessage(CommandMessage.DISCONNECT_OPERATION);
+ list.add(disconnect);
+ pushMessages(list);
+ }
+
+ // Invalidate associated subscriptions; this doesn't attempt to notify the client.
+ // Any client subscriptions made over this endpoint will be automatically invalidated
+ // on the client when it receives its channel disconnect event.
+ if (invalidateMessageClientOnStreamingClose)
+ {
+ for (Iterator<MessageClient> iter = messageClients.iterator() ; iter.hasNext();)
+ iter.next().invalidate();
+ }
+
+ // Move to final closed state; after this we need to notify one last time to stream
+ // any final messages to the client and allow the endpoint to shut down its streaming
+ // connection.
+ synchronized (lock)
+ {
+ closed = true;
+ closing = false;
+ }
+ synchronized (pushNeeded)
+ {
+ pushNeeded.notifyAll();
+ }
+ }
+
+ /**
+ * Returns any messages available to push to the client, and removes them
+ * from this notifier.
+ * Notified endpoints should invoke this method to retrieve messages, stream them
+ * to the client and then re-enter the wait state.
+ * This method acquires a lock on <code>pushNeeded</code>.
+ *
+ * @return The messages to push to the client.
+ */
+ public List<AsyncMessage> drainMessages()
+ {
+ synchronized (pushNeeded)
+ {
+ List<AsyncMessage> messagesToPush = messages;
+ messages = null;
+ return messagesToPush;
+ }
+ }
+
+ /**
+ * Returns whether the notifier has closed; used to break the endpoint's wait cycle.
+ *
+ * @return True if the notifier has closed; otherwise false.
+ */
+ public boolean isClosed()
+ {
+ return closed;
+ }
+
+ /**
+ * Returns the endpoint that is using this notifier.
+ *
+ * @return The endpoint using this notifier.
+ */
+ public Endpoint getEndpoint()
+ {
+ return endpoint;
+ }
+
+ /**
+ * Returns the idle timeout minutes used by the notifier.
+ *
+ * @return The idle timeout minutes used by the notifier.
+ */
+ public int getIdleTimeoutMinutes()
+ {
+ return idleTimeoutMinutes;
+ }
+
+ /**
+ * Sets the idle timeout minutes used by the notifier.
+ *
+ * @param idleTimeoutMinutes The idle timeout minutes used by the notifier.
+ */
+ public void setIdleTimeoutMinutes(int idleTimeoutMinutes)
+ {
+ this.idleTimeoutMinutes = idleTimeoutMinutes;
+ }
+
+ /**
+ * Returns the log category used by this notifier.
+ *
+ * @return The log category used by this notifier.
+ */
+ public String getLogCategory()
+ {
+ return logCategory;
+ }
+
+ /**
+ * Sets the log category used by this notifier. Endpoints using this notifier
+ * should set it to their own log categories.
+ *
+ * @param logCategory The log category for the notifier to use.
+ */
+ public void setLogCategory(String logCategory)
+ {
+ this.logCategory = logCategory;
+ }
+
+ /**
+ * Returns the unique id for this notifier.
+ *
+ * @return The unique id for this notifier.
+ */
+ public String getNotifierId()
+ {
+ return notifierId;
+ }
+
+ /**
+ * @exclude
+ * Implements TimeoutCapable.
+ * Determine the time, in milliseconds, that this object is allowed to idle
+ * before having its timeout method invoked.
+ */
+ public long getTimeoutPeriod()
+ {
+ return (idleTimeoutMinutes * 60 * 1000);
+ }
+
+ /**
+ * @exclude
+ */
+ public void messageClientCreated(MessageClient messageClient)
+ {
+ // No-op.
+ }
+
+ /**
+ * @exclude
+ */
+ public void messageClientDestroyed(MessageClient messageClient)
+ {
+ unregisterMessageClient(messageClient);
+ }
+
+ /**
+ * Used by FlexClient to push messages to the endpoint.
+ * This method will automatically notify a waiting endpoint, if one exists
+ * and it acquires a lock on <code>pushNeeded</code>.
+ *
+ * @param messages The messages to push to the client.
+ */
+ public void pushMessages(List messagesToPush)
+ {
+ if (!messagesToPush.isEmpty())
+ {
+ synchronized (pushNeeded)
+ {
+ // Push these straight on through; notify immediately.
+ if (messages == null)
+ messages = messagesToPush;
+ else
+ messages.addAll(messagesToPush);
+
+ // If the notifier isn't closing, notify; otherwise just add and the close will
+ // notify once it completes.
+ if (!closing)
+ pushNeeded.notifyAll();
+ }
+ }
+ }
+
+ /**
+ * Registers a MessageClient subscription that depends on this notifier.
+ *
+ * @param messageClient A MessageClient that depends on this notifier.
+ */
+ public void registerMessageClient(MessageClient messageClient)
+ {
+ if (messageClient != null)
+ {
+ if (messageClients.addIfAbsent(messageClient))
+ messageClient.addMessageClientDestroyedListener(this);
+ }
+ }
+
+ /**
+ * Handle session creation events. This handler is a no-op because the notifier
+ * is only concerned with its associated session's destruction.
+ *
+ * @param flexSession The newly created FlexSession.
+ */
+ public void sessionCreated(FlexSession flexSession)
+ {
+ // No-op.
+ }
+
+ /**
+ * Handle session destruction events. This will be invoked when the notifier's
+ * associated session is invalidated, and this will trigger the notifier to close.
+ *
+ * @param flexSession The FlexSession being invalidated.
+ */
+ public void sessionDestroyed(FlexSession flexSession)
+ {
+ if (Log.isInfo())
+ Log.getLogger(logCategory).info("Endpoint with id '" + endpoint.getId() + "' is closing"
+ + " a streaming connection for the FlexClient with id '" + flexClient.getId() + "'"
+ + " since its associated session has been destroyed.");
+ close(true /* disconnect client Channel */);
+ }
+
+ /**
+ * @exclude
+ * Implements TimeoutCapable.
+ * Inform the object that it has timed out.
+ */
+ public void timeout()
+ {
+ if (Log.isInfo())
+ Log.getLogger(logCategory).info("Endpoint with id '" + endpoint.getId() + "' is timing out"
+ + " a streaming connection for the FlexClient with id '" + flexClient.getId() + "'");
+ close(true /* disconnect client Channel */);
+ }
+
+ /**
+ * Unregisters a MessageClient subscription that depended on this notifier.
+ *
+ * @param messageClient A MessageClient that depended on this notifier.
+ */
+ public void unregisterMessageClient(MessageClient messageClient)
+ {
+ if (messageClient != null)
+ {
+ messageClient.removeMessageClientDestroyedListener(this);
+ messageClients.remove(messageClient);
+ }
+ }
}
\ No newline at end of file
[32/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/Destination.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/Destination.java b/modules/core/src/flex/messaging/Destination.java
old mode 100755
new mode 100644
index f1a7d1c..312e371
--- a/modules/core/src/flex/messaging/Destination.java
+++ b/modules/core/src/flex/messaging/Destination.java
@@ -1,802 +1,802 @@
-/*
- * 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;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import flex.management.ManageableComponent;
-import flex.management.runtime.messaging.services.ServiceControl;
-import flex.messaging.log.LogCategories;
-import flex.messaging.log.Log;
-import flex.messaging.services.Service;
-import flex.messaging.services.ServiceAdapter;
-import flex.messaging.util.ClassUtil;
-import flex.messaging.cluster.ClusterManager;
-import flex.messaging.config.ClusterSettings;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.ConfigurationConstants;
-import flex.messaging.config.ConfigurationException;
-import flex.messaging.config.NetworkSettings;
-import flex.messaging.config.SecurityConstraint;
-/**
- * The <code>Destination</code> class is a source and sink for messages sent through
- * a service destination and uses an adapter to process messages.
- */
-public class Destination extends ManageableComponent implements java.io.Serializable
-{
- static final long serialVersionUID = -977001797620881435L;
-
- /** Default log category for <code>Destination</code>. */
- public static final String LOG_CATEGORY = LogCategories.SERVICE_GENERAL;
-
- /** Hard coded id for the push destination */
- public static final String PUSH_DESTINATION_ID = "_DS_PUSH_";
-
- // Errors
- private static final int NO_SERVICE = 11117;
-
- // Destination's properties
- protected ServiceAdapter adapter;
- protected List<String> channelIds;
- protected NetworkSettings networkSettings;
- protected SecurityConstraint securityConstraint;
- protected String securityConstraintRef;
- protected HashMap<String, Object> extraProperties;
- protected boolean initialized;
- protected boolean clustered;
- protected boolean clusteredCalculated;
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>Destination</code> instance.
- */
- public Destination()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>Destination</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>Destination</code>
- * is manageable; otherwise <code>false</code>.
- */
- public Destination(boolean enableManagement)
- {
- super(enableManagement);
-
- networkSettings = new NetworkSettings();
- }
-
- //--------------------------------------------------------------------------
- //
- // Initialize, validate, start, and stop methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes the <code>Destination</code> with the properties.
- * If subclasses override, they must call <code>super.initialize()</code>.
- *
- * @param id The id of the destination.
- * @param properties Properties for the destination.
- */
- @Override
- public void initialize(String id, ConfigMap properties)
- {
- super.initialize(id, properties);
-
- if (properties == null || properties.size() == 0)
- {
- initialized = true;
- return;
- }
-
- ConfigMap network = properties.getPropertyAsMap(NetworkSettings.NETWORK_ELEMENT, null);
-
- if (network != null)
- {
- networkSettings.setReliable(network.getPropertyAsBoolean(NetworkSettings.RELIABLE_ELEMENT, false));
-
- ConfigMap clusterInfo = network.getPropertyAsMap(ClusterSettings.CLUSTER_ELEMENT, null);
- if (clusterInfo != null)
- {
- // Mark these as used so we do not get warnings about them.
- network.allowProperty(ClusterSettings.CLUSTER_ELEMENT);
- clusterInfo.allowProperty(ClusterSettings.REF_ATTR);
- clusterInfo.allowProperty(ClusterSettings.SHARED_BACKEND_ATTR);
-
- String clusterId = clusterInfo.getPropertyAsString(ClusterSettings.REF_ATTR, null);
- String coordinatorPolicy = clusterInfo.getPropertyAsString(ClusterSettings.SHARED_BACKEND_ATTR, null);
- if (coordinatorPolicy != null)
- networkSettings.setSharedBackend(Boolean.valueOf(coordinatorPolicy));
-
- networkSettings.setClusterId(clusterId);
- }
- }
-
- initialized = true;
- }
-
- /**
- * Returns whether or not the destination has been initialized.
- *
- * @return True, if the destination has been initialized.
- */
- public boolean isInitialized()
- {
- return initialized;
- }
-
- /**
- * Verifies that the <code>Destination</code> is in valid state before
- * it is started. If subclasses override, they must call <code>super.validate()</code>.
- */
- @Override
- protected void validate()
- {
- if (isValid())
- return;
-
- super.validate();
-
- if (getAdapter() == null)
- {
- String defaultAdapterId = getService().getDefaultAdapter();
- if (defaultAdapterId != null)
- {
- createAdapter(defaultAdapterId);
- }
- else
- {
- invalidate();
- // Destination '{id}' must specify at least one adapter.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.DEST_NEEDS_ADAPTER, new Object[]{getId()});
- throw ex;
- }
- }
-
- if (channelIds != null)
- {
- List<String> brokerChannelIds = getService().getMessageBroker().getChannelIds();
- for (Iterator<String> iter = channelIds.iterator(); iter.hasNext();)
- {
- String id = iter.next();
- if (brokerChannelIds == null || !brokerChannelIds.contains(id))
- {
- iter.remove();
- if (Log.isWarn())
- {
- Log.getLogger(getLogCategory()).warn("No channel with id '{0}' is known by the MessageBroker." +
- " Removing the channel.",
- new Object[]{id});
- }
- }
- }
- }
-
- // Set the default channels if needed
- if (channelIds == null)
- {
- List<String> defaultChannelIds = getService().getDefaultChannels();
- if (defaultChannelIds != null && defaultChannelIds.size() > 0)
- {
- setChannels(defaultChannelIds);
- }
- else
- {
- invalidate();
- // Destination '{id}' must specify at least one channel.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.DEST_NEEDS_CHANNEL, new Object[]{getId()});
- throw ex;
- }
- }
-
- MessageBroker broker = getService().getMessageBroker();
-
- // Validate the security constraint
- if (securityConstraint == null && securityConstraintRef != null)
- {
- securityConstraint = broker.getSecurityConstraint(securityConstraintRef);
- // No need to throw an error as MessageBroker automatically throws
- // an error if no such constraint exists
- }
-
- ClusterManager cm = broker.getClusterManager();
-
- // Set clustering if needed
- if (getNetworkSettings().getClusterId() != null || cm.getDefaultClusterId() != null)
- {
- cm.clusterDestination(this);
- }
- }
-
- /**
- * Starts the destination if its associated <code>Service</code> is started
- * and if the destination is not already running. The default implementation
- * of this method starts the adapter of the destination. If subclasses
- * override, they must call <code>super.start()</code>.
- */
- @Override
- public void start()
- {
- if (isStarted())
- {
- // Needed for adapters added after startup.
- getAdapter().start();
- return;
- }
-
- // Check if the Service is started
- Service service = getService();
- if (!service.isStarted())
- {
- if (Log.isWarn())
- {
- Log.getLogger(getLogCategory()).warn("Destination with id '{0}' cannot be started" +
- " when its Service with id '{1}' is not started.",
- new Object[]{getId(), service.getId()});
- }
- return;
- }
-
- // Set up management
- if (isManaged() && service.isManaged())
- {
- setupDestinationControl(service);
- ServiceControl controller = (ServiceControl)service.getControl();
- if (getControl() != null)
- controller.addDestination(getControl().getObjectName());
- }
-
- super.start();
-
- getAdapter().start();
- }
-
- /**
- * The default implementation of this method stops all of the adapters
- * of the destination.
- * If subclasses override, they must call <code>super.stop()</code>.
- *
- */
- @Override
- public void stop()
- {
- if (!isStarted())
- return;
-
- getAdapter().stop();
-
- super.stop();
-
- // Remove management
- if (isManaged() && getService().isManaged())
- {
- if (getControl() != null)
- {
- getControl().unregister();
- setControl(null);
- }
- setManaged(false);
- }
-
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Getters and Setters for Destination properties
- //
- //--------------------------------------------------------------------------
-
- /**
- * Returns the <code>ServiceAdapter</code> for the <code>Destination</code>.
- *
- * @return The <code>ServiceAdapter</code> for the <code>Destination</code>.
- */
- public ServiceAdapter getAdapter()
- {
- return adapter;
- }
-
- /**
- * Creates a <code>ServiceAdapter</code> instance, sets its id, sets it manageable
- * if the <code>Destination</code> that created it is manageable,
- * and set its <code>Destination</code> to the <code>Destination</code> that
- * created it.
- *
- * In order to use this method, <code>Destination</code> should have an assigned
- * <code>Service</code> and the id provided for the adapter should already
- * be registered with the <code>Service</code>.
- *
- * @param id The id of the <code>ServiceAdapter</code>.
- * @return The <code>ServiceAdapter</code> instanced created.
- */
- public ServiceAdapter createAdapter(String id)
- {
- if (getService() == null)
- {
- // Destination cannot create adapter '{0}' without its Service set.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(NO_SERVICE, new Object[]{id});
- throw ex;
- }
- Map<String, String> adapterClasses = getService().getRegisteredAdapters();
- if (!adapterClasses.containsKey(id))
- {
- // No adapter with id '{0}' is registered with the service '{1}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.UNREGISTERED_ADAPTER, new Object[]{id, getService().getId()});
- throw ex;
- }
-
- String adapterClassName = adapterClasses.get(id);
- Class<?> adapterClass = ClassUtil.createClass(adapterClassName,
- FlexContext.getMessageBroker() == null ?
- null : FlexContext.getMessageBroker().getClassLoader());
-
- ServiceAdapter adapter = (ServiceAdapter)ClassUtil.createDefaultInstance(adapterClass, ServiceAdapter.class);
- adapter.setId(id);
- adapter.setManaged(isManaged());
- adapter.setDestination(this);
-
- return adapter;
- }
-
- /**
- * Sets the <code>ServiceAdapter</code> of the <code>Destination</code>.
- *
- * <code>ServiceAdapter</code> needs to be started if the <code>Destination</code>
- * is already running.
- *
- * @param adapter The adapter for the destination.
- */
- public void setAdapter(ServiceAdapter adapter)
- {
- if (getAdapter() == adapter) // No need to reset the adapter.
- return;
-
- if (adapter == null)
- {
- removeAdapter();
- return;
- }
-
- addAdapter(adapter);
- }
-
- /**
- * Used by setAdapter and it removes the old adapter of the destination
- * and adds the new adapter.
- *
- * @param adapter The adapter for the destination.
- */
- private void addAdapter(ServiceAdapter adapter)
- {
- removeAdapter();
-
- this.adapter = adapter;
-
- if (adapter.getDestination() == null || adapter.getDestination() != this)
- adapter.setDestination(this);
- }
-
- /**
- * Used by setAdapter and addAdapter. It removes the current adapter
- * of the destination
- */
- private void removeAdapter()
- {
- ServiceAdapter adapter = getAdapter();
- if (adapter != null)
- {
- adapter.stop();
- }
- this.adapter = null;
- }
-
-
- /**
- * The destination may be not clustered at all, may be clustered for channel failover and
- * destination sharing, or it may be clustered for channel failover and also have a
- * common backend, such as a common database or backend clustered JMS topic.
- * If the destination is clustered and has a common backend to coordinate the cluster,
- * this method returns true; otherwise it return false. Note that this method returns
- * <code>false</code> if the <code>Destination</code> is not runnning.
- *
- * @return <code>true</code> if the clustered <code>Destination</code> shares a common backend;
- * otherwise <code>false</code>.
- */
- public boolean isBackendShared()
- {
- if (!isStarted())
- return false;
-
- ClusterManager clm = getService().getMessageBroker().getClusterManager();
- return clm.isBackendShared(getService().getClass().getName(), getId());
- }
-
- /**
- * Returns the list of channel ids of the <code>Destination</code>.
- *
- * @return The list of channel ids of the <code>Destination</code>.
- */
- public List<String> getChannels()
- {
- return channelIds;
- }
-
- /**
- * Adds a channel to the list of channels known by the <code>Destination</code>.
- * <code>MessageBroker</code> has to know the channel. Otherwise, the channel
- * is not added to the list.
- *
- * @param id The id of the channel.
- */
- public void addChannel(String id)
- {
- if (channelIds == null)
- channelIds = new ArrayList<String>();
- else if (channelIds.contains(id))
- return;
-
- if (isStarted())
- {
- List<String> brokerChannelIds = getService().getMessageBroker().getChannelIds();
- if (brokerChannelIds == null || !brokerChannelIds.contains(id))
- {
- if (Log.isWarn())
- {
- Log.getLogger(getLogCategory()).warn("No channel with id '{0}' is known by the MessageBroker." +
- " Not adding the channel.",
- new Object[]{id});
- }
- return;
- }
- }
- // Either message broker knows about the channel, or destination is not
- // running and channel will be checked before startup during validate
- channelIds.add(id);
- }
-
- /**
- * Removes the channel from the list of channels for the <code>Destination</code>.
- *
- * @param id The id of the channel.
- * @return <code>true</code> if the list contained the channel id.
- */
- public boolean removeChannel(String id)
- {
- return channelIds != null && channelIds.remove(id);
- }
-
- /**
- * Sets the channel list of the <code>Destination</code>.
- * <code>MessageBroker</code> has to know the channels, otherwise they
- * are not added to the list.
- *
- * @param ids List of channel ids.
- */
- public void setChannels(List<String> ids)
- {
- if (ids != null && isStarted())
- {
- List<String> brokerChannelIds = getService().getMessageBroker().getChannelIds();
- for (Iterator<String> iter = ids.iterator(); iter.hasNext();)
- {
- String id = iter.next();
- if (brokerChannelIds == null || !brokerChannelIds.contains(id))
- {
- iter.remove();
- if (Log.isWarn())
- {
- Log.getLogger(getLogCategory()).warn("No channel with id '{0}' is known by the MessageBroker." +
- " Not adding the channel.",
- new Object[]{id});
- }
- }
- }
- }
- // Otherwise, channels will be checked before startup during validate
- channelIds = ids;
- }
-
- /**
- * The destination may be not clustered at all, may be clustered for channel failover
- * only, or it may be clustered for channel failover and also have shared back ends.
- * If the destination is clustered, regardless of whether or not it relies on a shared
- * back end for cluster configuration, this method returns true. Note that this method
- * returns <code>false</code> if the <code>Destination</code> is not runnning.
- *
- * @return <code>true</code> if the <code>Destination</code> is clustered; otherwise <code>false</code>.
- */
- public boolean isClustered()
- {
- if (!isStarted())
- return false;
-
- if (!clusteredCalculated)
- {
- ClusterManager clm = getService().getMessageBroker().getClusterManager();
- clustered = clm.isDestinationClustered(getService().getClass().getName(), getId());
- clusteredCalculated = true;
- }
- return clustered;
- }
-
- /**
- * Sets the id of the <code>Destination</code>. If the <code>Destination</code>
- * has a <code>Service</code> assigned, it also updates the id in the
- * <code>Service</code>.
- *
- * @param id The id of the <code>Destination</code>.
- */
- @Override
- public void setId(String id)
- {
- String oldId = getId();
-
- super.setId(id);
-
- // Update the destination id in the service and MessageBroker
- Service service = getService();
- if (service != null)
- {
- service.removeDestination(oldId);
- service.addDestination(this);
- }
- }
-
- /**
- * Get the <code>NetworkSettings</code> of the <code>Destination</code>.
- *
- * @return The <code>NetworkSettings</code> of the <code>Destination</code>.
- */
- public NetworkSettings getNetworkSettings()
- {
- return networkSettings;
- }
-
- /**
- * Set the <code>NetworkSettings</code> of the <code>Destination</code>.
- *
- * @param networkSettings The <code>NetworkSettings</code> of the <code>Destination</code>.
- */
- public void setNetworkSettings(NetworkSettings networkSettings)
- {
- this.networkSettings = networkSettings;
- }
-
- /**
- * Returns the <code>Service</code> managing this <code>Destination</code>.
- *
- * @return The <code>Service</code> managing this <code>Destination</code>.
- */
- public Service getService()
- {
- return (Service)getParent();
- }
-
- /**
- * Sets the <code>Service</code> managing this <code>Destination</code>.
- * Removes the <code>Destination</code> from the old service
- * (if there was one) and adds to the list of destination in the new service.
- *
- * @param service The <code>Service</code> managing this <code>Destination</code>.
- */
- public void setService(Service service)
- {
- Service oldService = getService();
-
- setParent(service);
-
- if (oldService != null)
- oldService.removeDestination(getId());
-
- // Add the destination to the service if needed
- if (service.getDestination(getId()) != this)
- service.addDestination(this);
- }
-
- /**
- * Returns the Java class name for the <code>Service</code> managing this
- * <code>Destination</code>. Returns null if there is no <code>Service</code>
- * assigned to the <code>Destination</code> yet.
- *
- * @return The Java class name for the <code>Service</code> manageing this <code>Destination</code>.
- */
- public String getServiceType()
- {
- Service service = getService();
- return service != null? service.getClass().getName() : null;
- }
-
- /**
- * Returns the <code>SecurityConstraint</code> of the <code>Destination</code>.
- * <code>SecurityConstraint</code> is constructed as the <code>Destination</code>
- * starts up. Therefore, this could return null even if the <code>SecurityConstraint</code>
- * reference is set but <code>Destination</code> is not started yet.
- *
- * @return The <code>SecurityConstraint</code> of the <code>Destination</code>.
- */
- public SecurityConstraint getSecurityConstraint()
- {
- return securityConstraint;
- }
-
- /**
- * Sets the <code>SecurityConstraint</code> of the <code>Destination</code>.
- *
- * @param securityConstraint The <code>SecurityConstraint</code> of the <code>Destination</code>.
- */
- public void setSecurityConstraint(SecurityConstraint securityConstraint)
- {
- this.securityConstraint = securityConstraint;
- }
-
- /**
- * Sets the <code>SecurityConstraint</code> reference of the <code>Destination</code>.
- * <code>MessageBroker</code> has to know the <code>SecurityConstraint</code>
- * reference. Note that <code>getSecurityConstraint</code> can return null
- * if the reference is set but the <code>Destination</code> is not started yet.
- *
- * @param ref <code>SecurityConstraint</code> reference.
- */
- public void setSecurityConstraint(String ref)
- {
- if (isStarted())
- {
- MessageBroker msgBroker = getService().getMessageBroker();
- securityConstraint = msgBroker.getSecurityConstraint(ref);
- // No need to throw an error as MessageBroker automatically throws
- // an error if no such constraint exists
- }
- securityConstraintRef = ref;
- }
-
- //--------------------------------------------------------------------------
- //
- // Other public APIs
- //
- //--------------------------------------------------------------------------
-
- /**
- * Calls {@link Destination#describeDestination(boolean)} with true boolean value.
- *
- * @return A <tt>ConfigMap</tt> of destination properties that the client needs.
- * @see flex.messaging.Destination#describeDestination(boolean)
- */
- public ConfigMap describeDestination()
- {
- return describeDestination(true);
- }
-
- /**
- * Returns a <tt>ConfigMap</tt> of destination properties that the client
- * needs. Subclasses can add additional properties to <tt>super.describeDestination(boolean)</tt>,
- * or return null if they don't want their properties to be sent to the client.
- *
- * @param onlyReliable Determines whether only reliable destination configuration should be returned.
- * @return A <tt>ConfigMap</tt> of destination properties that the client needs.
- */
- public ConfigMap describeDestination(boolean onlyReliable)
- {
- boolean reliable = networkSettings != null && networkSettings.isReliable();
- if (onlyReliable && !reliable)
- return null;
-
- ConfigMap destinationConfig = new ConfigMap();
- destinationConfig.addProperty(ConfigurationConstants.ID_ATTR, getId());
-
- // Include network settings if reliability for the destination is enabled.
- if (reliable)
- {
- ConfigMap properties = new ConfigMap();
- ConfigMap network = new ConfigMap();
-
- ConfigMap reliableMap = new ConfigMap();
- // Adding as a value rather than attribute to the parent
- reliableMap.addProperty(ConfigurationConstants.EMPTY_STRING, Boolean.toString(networkSettings.isReliable()));
-
- network.addProperty(NetworkSettings.RELIABLE_ELEMENT, reliableMap);
- properties.addProperty(NetworkSettings.NETWORK_ELEMENT, network);
-
- destinationConfig.addProperty(ConfigurationConstants.PROPERTIES_ELEMENT, properties);
- }
-
- ConfigMap channelsConfig = new ConfigMap();
- for (String id : channelIds)
- {
- ConfigMap channelConfig = new ConfigMap();
- channelConfig.addProperty(ConfigurationConstants.REF_ATTR, id);
- channelsConfig.addProperty(ConfigurationConstants.CHANNEL_ELEMENT, channelConfig);
- }
-
- if (channelsConfig.size() > 0)
- destinationConfig.addProperty(ConfigurationConstants.CHANNELS_ELEMENT, channelsConfig);
-
- return destinationConfig;
- }
-
- /**
- * Method for setting an extra property for the destination at runtime.
- *
- * @param name The name of the property.
- * @param value The value of the property.
- */
- public void addExtraProperty(String name, Object value)
- {
- if (extraProperties == null)
- {
- extraProperties = new HashMap<String, Object>();
- }
-
- extraProperties.put(name, value);
- }
-
- /**
- * Method for getting an extra property at runtime.
- *
- * @param name The name of the property.
- * @return The value of the property or null if the property does not exist.
- */
- public Object getExtraProperty(String name)
- {
- return extraProperties != null? extraProperties.get(name) : null;
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected/private APIs
- //
- //--------------------------------------------------------------------------
-
- /**
- * Returns the log category of the <code>Destination</code>. Subclasses
- * can override to provide a more specific log category.
- *
- * @return The log category.
- */
- @Override
- protected String getLogCategory()
- {
- return LOG_CATEGORY;
- }
-
- /**
- * Invoked automatically to allow the <code>Destination</code> to setup its corresponding
- * MBean control. Subclasses should override to setup and register their MBean control.
- *
- * @param service The <code>Service</code> that manages this <code>Destination</code>.
- */
- protected void setupDestinationControl(Service service)
- {
- // Manageable subclasses should override this template method.
- setManaged(false);
- }
-}
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import flex.management.ManageableComponent;
+import flex.management.runtime.messaging.services.ServiceControl;
+import flex.messaging.log.LogCategories;
+import flex.messaging.log.Log;
+import flex.messaging.services.Service;
+import flex.messaging.services.ServiceAdapter;
+import flex.messaging.util.ClassUtil;
+import flex.messaging.cluster.ClusterManager;
+import flex.messaging.config.ClusterSettings;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.ConfigurationConstants;
+import flex.messaging.config.ConfigurationException;
+import flex.messaging.config.NetworkSettings;
+import flex.messaging.config.SecurityConstraint;
+/**
+ * The <code>Destination</code> class is a source and sink for messages sent through
+ * a service destination and uses an adapter to process messages.
+ */
+public class Destination extends ManageableComponent implements java.io.Serializable
+{
+ static final long serialVersionUID = -977001797620881435L;
+
+ /** Default log category for <code>Destination</code>. */
+ public static final String LOG_CATEGORY = LogCategories.SERVICE_GENERAL;
+
+ /** Hard coded id for the push destination */
+ public static final String PUSH_DESTINATION_ID = "_DS_PUSH_";
+
+ // Errors
+ private static final int NO_SERVICE = 11117;
+
+ // Destination's properties
+ protected ServiceAdapter adapter;
+ protected List<String> channelIds;
+ protected NetworkSettings networkSettings;
+ protected SecurityConstraint securityConstraint;
+ protected String securityConstraintRef;
+ protected HashMap<String, Object> extraProperties;
+ protected boolean initialized;
+ protected boolean clustered;
+ protected boolean clusteredCalculated;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>Destination</code> instance.
+ */
+ public Destination()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>Destination</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>Destination</code>
+ * is manageable; otherwise <code>false</code>.
+ */
+ public Destination(boolean enableManagement)
+ {
+ super(enableManagement);
+
+ networkSettings = new NetworkSettings();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Initialize, validate, start, and stop methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes the <code>Destination</code> with the properties.
+ * If subclasses override, they must call <code>super.initialize()</code>.
+ *
+ * @param id The id of the destination.
+ * @param properties Properties for the destination.
+ */
+ @Override
+ public void initialize(String id, ConfigMap properties)
+ {
+ super.initialize(id, properties);
+
+ if (properties == null || properties.size() == 0)
+ {
+ initialized = true;
+ return;
+ }
+
+ ConfigMap network = properties.getPropertyAsMap(NetworkSettings.NETWORK_ELEMENT, null);
+
+ if (network != null)
+ {
+ networkSettings.setReliable(network.getPropertyAsBoolean(NetworkSettings.RELIABLE_ELEMENT, false));
+
+ ConfigMap clusterInfo = network.getPropertyAsMap(ClusterSettings.CLUSTER_ELEMENT, null);
+ if (clusterInfo != null)
+ {
+ // Mark these as used so we do not get warnings about them.
+ network.allowProperty(ClusterSettings.CLUSTER_ELEMENT);
+ clusterInfo.allowProperty(ClusterSettings.REF_ATTR);
+ clusterInfo.allowProperty(ClusterSettings.SHARED_BACKEND_ATTR);
+
+ String clusterId = clusterInfo.getPropertyAsString(ClusterSettings.REF_ATTR, null);
+ String coordinatorPolicy = clusterInfo.getPropertyAsString(ClusterSettings.SHARED_BACKEND_ATTR, null);
+ if (coordinatorPolicy != null)
+ networkSettings.setSharedBackend(Boolean.valueOf(coordinatorPolicy));
+
+ networkSettings.setClusterId(clusterId);
+ }
+ }
+
+ initialized = true;
+ }
+
+ /**
+ * Returns whether or not the destination has been initialized.
+ *
+ * @return True, if the destination has been initialized.
+ */
+ public boolean isInitialized()
+ {
+ return initialized;
+ }
+
+ /**
+ * Verifies that the <code>Destination</code> is in valid state before
+ * it is started. If subclasses override, they must call <code>super.validate()</code>.
+ */
+ @Override
+ protected void validate()
+ {
+ if (isValid())
+ return;
+
+ super.validate();
+
+ if (getAdapter() == null)
+ {
+ String defaultAdapterId = getService().getDefaultAdapter();
+ if (defaultAdapterId != null)
+ {
+ createAdapter(defaultAdapterId);
+ }
+ else
+ {
+ invalidate();
+ // Destination '{id}' must specify at least one adapter.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(ConfigurationConstants.DEST_NEEDS_ADAPTER, new Object[]{getId()});
+ throw ex;
+ }
+ }
+
+ if (channelIds != null)
+ {
+ List<String> brokerChannelIds = getService().getMessageBroker().getChannelIds();
+ for (Iterator<String> iter = channelIds.iterator(); iter.hasNext();)
+ {
+ String id = iter.next();
+ if (brokerChannelIds == null || !brokerChannelIds.contains(id))
+ {
+ iter.remove();
+ if (Log.isWarn())
+ {
+ Log.getLogger(getLogCategory()).warn("No channel with id '{0}' is known by the MessageBroker." +
+ " Removing the channel.",
+ new Object[]{id});
+ }
+ }
+ }
+ }
+
+ // Set the default channels if needed
+ if (channelIds == null)
+ {
+ List<String> defaultChannelIds = getService().getDefaultChannels();
+ if (defaultChannelIds != null && defaultChannelIds.size() > 0)
+ {
+ setChannels(defaultChannelIds);
+ }
+ else
+ {
+ invalidate();
+ // Destination '{id}' must specify at least one channel.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(ConfigurationConstants.DEST_NEEDS_CHANNEL, new Object[]{getId()});
+ throw ex;
+ }
+ }
+
+ MessageBroker broker = getService().getMessageBroker();
+
+ // Validate the security constraint
+ if (securityConstraint == null && securityConstraintRef != null)
+ {
+ securityConstraint = broker.getSecurityConstraint(securityConstraintRef);
+ // No need to throw an error as MessageBroker automatically throws
+ // an error if no such constraint exists
+ }
+
+ ClusterManager cm = broker.getClusterManager();
+
+ // Set clustering if needed
+ if (getNetworkSettings().getClusterId() != null || cm.getDefaultClusterId() != null)
+ {
+ cm.clusterDestination(this);
+ }
+ }
+
+ /**
+ * Starts the destination if its associated <code>Service</code> is started
+ * and if the destination is not already running. The default implementation
+ * of this method starts the adapter of the destination. If subclasses
+ * override, they must call <code>super.start()</code>.
+ */
+ @Override
+ public void start()
+ {
+ if (isStarted())
+ {
+ // Needed for adapters added after startup.
+ getAdapter().start();
+ return;
+ }
+
+ // Check if the Service is started
+ Service service = getService();
+ if (!service.isStarted())
+ {
+ if (Log.isWarn())
+ {
+ Log.getLogger(getLogCategory()).warn("Destination with id '{0}' cannot be started" +
+ " when its Service with id '{1}' is not started.",
+ new Object[]{getId(), service.getId()});
+ }
+ return;
+ }
+
+ // Set up management
+ if (isManaged() && service.isManaged())
+ {
+ setupDestinationControl(service);
+ ServiceControl controller = (ServiceControl)service.getControl();
+ if (getControl() != null)
+ controller.addDestination(getControl().getObjectName());
+ }
+
+ super.start();
+
+ getAdapter().start();
+ }
+
+ /**
+ * The default implementation of this method stops all of the adapters
+ * of the destination.
+ * If subclasses override, they must call <code>super.stop()</code>.
+ *
+ */
+ @Override
+ public void stop()
+ {
+ if (!isStarted())
+ return;
+
+ getAdapter().stop();
+
+ super.stop();
+
+ // Remove management
+ if (isManaged() && getService().isManaged())
+ {
+ if (getControl() != null)
+ {
+ getControl().unregister();
+ setControl(null);
+ }
+ setManaged(false);
+ }
+
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Getters and Setters for Destination properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns the <code>ServiceAdapter</code> for the <code>Destination</code>.
+ *
+ * @return The <code>ServiceAdapter</code> for the <code>Destination</code>.
+ */
+ public ServiceAdapter getAdapter()
+ {
+ return adapter;
+ }
+
+ /**
+ * Creates a <code>ServiceAdapter</code> instance, sets its id, sets it manageable
+ * if the <code>Destination</code> that created it is manageable,
+ * and set its <code>Destination</code> to the <code>Destination</code> that
+ * created it.
+ *
+ * In order to use this method, <code>Destination</code> should have an assigned
+ * <code>Service</code> and the id provided for the adapter should already
+ * be registered with the <code>Service</code>.
+ *
+ * @param id The id of the <code>ServiceAdapter</code>.
+ * @return The <code>ServiceAdapter</code> instanced created.
+ */
+ public ServiceAdapter createAdapter(String id)
+ {
+ if (getService() == null)
+ {
+ // Destination cannot create adapter '{0}' without its Service set.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(NO_SERVICE, new Object[]{id});
+ throw ex;
+ }
+ Map<String, String> adapterClasses = getService().getRegisteredAdapters();
+ if (!adapterClasses.containsKey(id))
+ {
+ // No adapter with id '{0}' is registered with the service '{1}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(ConfigurationConstants.UNREGISTERED_ADAPTER, new Object[]{id, getService().getId()});
+ throw ex;
+ }
+
+ String adapterClassName = adapterClasses.get(id);
+ Class<?> adapterClass = ClassUtil.createClass(adapterClassName,
+ FlexContext.getMessageBroker() == null ?
+ null : FlexContext.getMessageBroker().getClassLoader());
+
+ ServiceAdapter adapter = (ServiceAdapter)ClassUtil.createDefaultInstance(adapterClass, ServiceAdapter.class);
+ adapter.setId(id);
+ adapter.setManaged(isManaged());
+ adapter.setDestination(this);
+
+ return adapter;
+ }
+
+ /**
+ * Sets the <code>ServiceAdapter</code> of the <code>Destination</code>.
+ *
+ * <code>ServiceAdapter</code> needs to be started if the <code>Destination</code>
+ * is already running.
+ *
+ * @param adapter The adapter for the destination.
+ */
+ public void setAdapter(ServiceAdapter adapter)
+ {
+ if (getAdapter() == adapter) // No need to reset the adapter.
+ return;
+
+ if (adapter == null)
+ {
+ removeAdapter();
+ return;
+ }
+
+ addAdapter(adapter);
+ }
+
+ /**
+ * Used by setAdapter and it removes the old adapter of the destination
+ * and adds the new adapter.
+ *
+ * @param adapter The adapter for the destination.
+ */
+ private void addAdapter(ServiceAdapter adapter)
+ {
+ removeAdapter();
+
+ this.adapter = adapter;
+
+ if (adapter.getDestination() == null || adapter.getDestination() != this)
+ adapter.setDestination(this);
+ }
+
+ /**
+ * Used by setAdapter and addAdapter. It removes the current adapter
+ * of the destination
+ */
+ private void removeAdapter()
+ {
+ ServiceAdapter adapter = getAdapter();
+ if (adapter != null)
+ {
+ adapter.stop();
+ }
+ this.adapter = null;
+ }
+
+
+ /**
+ * The destination may be not clustered at all, may be clustered for channel failover and
+ * destination sharing, or it may be clustered for channel failover and also have a
+ * common backend, such as a common database or backend clustered JMS topic.
+ * If the destination is clustered and has a common backend to coordinate the cluster,
+ * this method returns true; otherwise it return false. Note that this method returns
+ * <code>false</code> if the <code>Destination</code> is not runnning.
+ *
+ * @return <code>true</code> if the clustered <code>Destination</code> shares a common backend;
+ * otherwise <code>false</code>.
+ */
+ public boolean isBackendShared()
+ {
+ if (!isStarted())
+ return false;
+
+ ClusterManager clm = getService().getMessageBroker().getClusterManager();
+ return clm.isBackendShared(getService().getClass().getName(), getId());
+ }
+
+ /**
+ * Returns the list of channel ids of the <code>Destination</code>.
+ *
+ * @return The list of channel ids of the <code>Destination</code>.
+ */
+ public List<String> getChannels()
+ {
+ return channelIds;
+ }
+
+ /**
+ * Adds a channel to the list of channels known by the <code>Destination</code>.
+ * <code>MessageBroker</code> has to know the channel. Otherwise, the channel
+ * is not added to the list.
+ *
+ * @param id The id of the channel.
+ */
+ public void addChannel(String id)
+ {
+ if (channelIds == null)
+ channelIds = new ArrayList<String>();
+ else if (channelIds.contains(id))
+ return;
+
+ if (isStarted())
+ {
+ List<String> brokerChannelIds = getService().getMessageBroker().getChannelIds();
+ if (brokerChannelIds == null || !brokerChannelIds.contains(id))
+ {
+ if (Log.isWarn())
+ {
+ Log.getLogger(getLogCategory()).warn("No channel with id '{0}' is known by the MessageBroker." +
+ " Not adding the channel.",
+ new Object[]{id});
+ }
+ return;
+ }
+ }
+ // Either message broker knows about the channel, or destination is not
+ // running and channel will be checked before startup during validate
+ channelIds.add(id);
+ }
+
+ /**
+ * Removes the channel from the list of channels for the <code>Destination</code>.
+ *
+ * @param id The id of the channel.
+ * @return <code>true</code> if the list contained the channel id.
+ */
+ public boolean removeChannel(String id)
+ {
+ return channelIds != null && channelIds.remove(id);
+ }
+
+ /**
+ * Sets the channel list of the <code>Destination</code>.
+ * <code>MessageBroker</code> has to know the channels, otherwise they
+ * are not added to the list.
+ *
+ * @param ids List of channel ids.
+ */
+ public void setChannels(List<String> ids)
+ {
+ if (ids != null && isStarted())
+ {
+ List<String> brokerChannelIds = getService().getMessageBroker().getChannelIds();
+ for (Iterator<String> iter = ids.iterator(); iter.hasNext();)
+ {
+ String id = iter.next();
+ if (brokerChannelIds == null || !brokerChannelIds.contains(id))
+ {
+ iter.remove();
+ if (Log.isWarn())
+ {
+ Log.getLogger(getLogCategory()).warn("No channel with id '{0}' is known by the MessageBroker." +
+ " Not adding the channel.",
+ new Object[]{id});
+ }
+ }
+ }
+ }
+ // Otherwise, channels will be checked before startup during validate
+ channelIds = ids;
+ }
+
+ /**
+ * The destination may be not clustered at all, may be clustered for channel failover
+ * only, or it may be clustered for channel failover and also have shared back ends.
+ * If the destination is clustered, regardless of whether or not it relies on a shared
+ * back end for cluster configuration, this method returns true. Note that this method
+ * returns <code>false</code> if the <code>Destination</code> is not runnning.
+ *
+ * @return <code>true</code> if the <code>Destination</code> is clustered; otherwise <code>false</code>.
+ */
+ public boolean isClustered()
+ {
+ if (!isStarted())
+ return false;
+
+ if (!clusteredCalculated)
+ {
+ ClusterManager clm = getService().getMessageBroker().getClusterManager();
+ clustered = clm.isDestinationClustered(getService().getClass().getName(), getId());
+ clusteredCalculated = true;
+ }
+ return clustered;
+ }
+
+ /**
+ * Sets the id of the <code>Destination</code>. If the <code>Destination</code>
+ * has a <code>Service</code> assigned, it also updates the id in the
+ * <code>Service</code>.
+ *
+ * @param id The id of the <code>Destination</code>.
+ */
+ @Override
+ public void setId(String id)
+ {
+ String oldId = getId();
+
+ super.setId(id);
+
+ // Update the destination id in the service and MessageBroker
+ Service service = getService();
+ if (service != null)
+ {
+ service.removeDestination(oldId);
+ service.addDestination(this);
+ }
+ }
+
+ /**
+ * Get the <code>NetworkSettings</code> of the <code>Destination</code>.
+ *
+ * @return The <code>NetworkSettings</code> of the <code>Destination</code>.
+ */
+ public NetworkSettings getNetworkSettings()
+ {
+ return networkSettings;
+ }
+
+ /**
+ * Set the <code>NetworkSettings</code> of the <code>Destination</code>.
+ *
+ * @param networkSettings The <code>NetworkSettings</code> of the <code>Destination</code>.
+ */
+ public void setNetworkSettings(NetworkSettings networkSettings)
+ {
+ this.networkSettings = networkSettings;
+ }
+
+ /**
+ * Returns the <code>Service</code> managing this <code>Destination</code>.
+ *
+ * @return The <code>Service</code> managing this <code>Destination</code>.
+ */
+ public Service getService()
+ {
+ return (Service)getParent();
+ }
+
+ /**
+ * Sets the <code>Service</code> managing this <code>Destination</code>.
+ * Removes the <code>Destination</code> from the old service
+ * (if there was one) and adds to the list of destination in the new service.
+ *
+ * @param service The <code>Service</code> managing this <code>Destination</code>.
+ */
+ public void setService(Service service)
+ {
+ Service oldService = getService();
+
+ setParent(service);
+
+ if (oldService != null)
+ oldService.removeDestination(getId());
+
+ // Add the destination to the service if needed
+ if (service.getDestination(getId()) != this)
+ service.addDestination(this);
+ }
+
+ /**
+ * Returns the Java class name for the <code>Service</code> managing this
+ * <code>Destination</code>. Returns null if there is no <code>Service</code>
+ * assigned to the <code>Destination</code> yet.
+ *
+ * @return The Java class name for the <code>Service</code> manageing this <code>Destination</code>.
+ */
+ public String getServiceType()
+ {
+ Service service = getService();
+ return service != null? service.getClass().getName() : null;
+ }
+
+ /**
+ * Returns the <code>SecurityConstraint</code> of the <code>Destination</code>.
+ * <code>SecurityConstraint</code> is constructed as the <code>Destination</code>
+ * starts up. Therefore, this could return null even if the <code>SecurityConstraint</code>
+ * reference is set but <code>Destination</code> is not started yet.
+ *
+ * @return The <code>SecurityConstraint</code> of the <code>Destination</code>.
+ */
+ public SecurityConstraint getSecurityConstraint()
+ {
+ return securityConstraint;
+ }
+
+ /**
+ * Sets the <code>SecurityConstraint</code> of the <code>Destination</code>.
+ *
+ * @param securityConstraint The <code>SecurityConstraint</code> of the <code>Destination</code>.
+ */
+ public void setSecurityConstraint(SecurityConstraint securityConstraint)
+ {
+ this.securityConstraint = securityConstraint;
+ }
+
+ /**
+ * Sets the <code>SecurityConstraint</code> reference of the <code>Destination</code>.
+ * <code>MessageBroker</code> has to know the <code>SecurityConstraint</code>
+ * reference. Note that <code>getSecurityConstraint</code> can return null
+ * if the reference is set but the <code>Destination</code> is not started yet.
+ *
+ * @param ref <code>SecurityConstraint</code> reference.
+ */
+ public void setSecurityConstraint(String ref)
+ {
+ if (isStarted())
+ {
+ MessageBroker msgBroker = getService().getMessageBroker();
+ securityConstraint = msgBroker.getSecurityConstraint(ref);
+ // No need to throw an error as MessageBroker automatically throws
+ // an error if no such constraint exists
+ }
+ securityConstraintRef = ref;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Other public APIs
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Calls {@link Destination#describeDestination(boolean)} with true boolean value.
+ *
+ * @return A <tt>ConfigMap</tt> of destination properties that the client needs.
+ * @see flex.messaging.Destination#describeDestination(boolean)
+ */
+ public ConfigMap describeDestination()
+ {
+ return describeDestination(true);
+ }
+
+ /**
+ * Returns a <tt>ConfigMap</tt> of destination properties that the client
+ * needs. Subclasses can add additional properties to <tt>super.describeDestination(boolean)</tt>,
+ * or return null if they don't want their properties to be sent to the client.
+ *
+ * @param onlyReliable Determines whether only reliable destination configuration should be returned.
+ * @return A <tt>ConfigMap</tt> of destination properties that the client needs.
+ */
+ public ConfigMap describeDestination(boolean onlyReliable)
+ {
+ boolean reliable = networkSettings != null && networkSettings.isReliable();
+ if (onlyReliable && !reliable)
+ return null;
+
+ ConfigMap destinationConfig = new ConfigMap();
+ destinationConfig.addProperty(ConfigurationConstants.ID_ATTR, getId());
+
+ // Include network settings if reliability for the destination is enabled.
+ if (reliable)
+ {
+ ConfigMap properties = new ConfigMap();
+ ConfigMap network = new ConfigMap();
+
+ ConfigMap reliableMap = new ConfigMap();
+ // Adding as a value rather than attribute to the parent
+ reliableMap.addProperty(ConfigurationConstants.EMPTY_STRING, Boolean.toString(networkSettings.isReliable()));
+
+ network.addProperty(NetworkSettings.RELIABLE_ELEMENT, reliableMap);
+ properties.addProperty(NetworkSettings.NETWORK_ELEMENT, network);
+
+ destinationConfig.addProperty(ConfigurationConstants.PROPERTIES_ELEMENT, properties);
+ }
+
+ ConfigMap channelsConfig = new ConfigMap();
+ for (String id : channelIds)
+ {
+ ConfigMap channelConfig = new ConfigMap();
+ channelConfig.addProperty(ConfigurationConstants.REF_ATTR, id);
+ channelsConfig.addProperty(ConfigurationConstants.CHANNEL_ELEMENT, channelConfig);
+ }
+
+ if (channelsConfig.size() > 0)
+ destinationConfig.addProperty(ConfigurationConstants.CHANNELS_ELEMENT, channelsConfig);
+
+ return destinationConfig;
+ }
+
+ /**
+ * Method for setting an extra property for the destination at runtime.
+ *
+ * @param name The name of the property.
+ * @param value The value of the property.
+ */
+ public void addExtraProperty(String name, Object value)
+ {
+ if (extraProperties == null)
+ {
+ extraProperties = new HashMap<String, Object>();
+ }
+
+ extraProperties.put(name, value);
+ }
+
+ /**
+ * Method for getting an extra property at runtime.
+ *
+ * @param name The name of the property.
+ * @return The value of the property or null if the property does not exist.
+ */
+ public Object getExtraProperty(String name)
+ {
+ return extraProperties != null? extraProperties.get(name) : null;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected/private APIs
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns the log category of the <code>Destination</code>. Subclasses
+ * can override to provide a more specific log category.
+ *
+ * @return The log category.
+ */
+ @Override
+ protected String getLogCategory()
+ {
+ return LOG_CATEGORY;
+ }
+
+ /**
+ * Invoked automatically to allow the <code>Destination</code> to setup its corresponding
+ * MBean control. Subclasses should override to setup and register their MBean control.
+ *
+ * @param service The <code>Service</code> that manages this <code>Destination</code>.
+ */
+ protected void setupDestinationControl(Service service)
+ {
+ // Manageable subclasses should override this template method.
+ setManaged(false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/DestructibleFlexFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/DestructibleFlexFactory.java b/modules/core/src/flex/messaging/DestructibleFlexFactory.java
old mode 100755
new mode 100644
index 2fec7ea..d9c6a1e
--- a/modules/core/src/flex/messaging/DestructibleFlexFactory.java
+++ b/modules/core/src/flex/messaging/DestructibleFlexFactory.java
@@ -1,34 +1,34 @@
-/*
- * 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;
-
-/**
- * Implementors of <code>FlexFactory</code> should also implement this interface
- * if their factory has custom destruction behavior.
- */
-public interface DestructibleFlexFactory
-{
- /**
- * This method is called when a component that uses this factory is removed.
- * This method gives the factory a chance to clean up resources that may have
- * been allocated for the component and may now be ready for destruction.
- *
- * @param instanceInfo The FactoryInstance to be destroyed
- *
- */
- void destroyFactoryInstance(FactoryInstance instanceInfo);
-}
+/*
+ * 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;
+
+/**
+ * Implementors of <code>FlexFactory</code> should also implement this interface
+ * if their factory has custom destruction behavior.
+ */
+public interface DestructibleFlexFactory
+{
+ /**
+ * This method is called when a component that uses this factory is removed.
+ * This method gives the factory a chance to clean up resources that may have
+ * been allocated for the component and may now be ready for destruction.
+ *
+ * @param instanceInfo The FactoryInstance to be destroyed
+ *
+ */
+ void destroyFactoryInstance(FactoryInstance instanceInfo);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FactoryDestination.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FactoryDestination.java b/modules/core/src/flex/messaging/FactoryDestination.java
old mode 100755
new mode 100644
index 74e18be..2857e3c
--- a/modules/core/src/flex/messaging/FactoryDestination.java
+++ b/modules/core/src/flex/messaging/FactoryDestination.java
@@ -1,361 +1,361 @@
-/*
- * 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;
-
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.ConfigurationException;
-import flex.messaging.log.Log;
-
-public abstract class FactoryDestination extends Destination
-{
- private static final String FACTORY = "factory";
- private static final String DEFAULT_FACTORY = "java";
-
- // Errors
- private static int INVALID_FACTORY = 11103;
- private static int FACTORY_CANNOT_BE_RETURNED = 11118;
-
- // FactoryDestination's properties
- private FlexFactory factory;
- private String source;
- private String scope = FlexFactory.SCOPE_REQUEST;
-
- // FactoryDestination internal
- private String factoryId = DEFAULT_FACTORY;
- private FactoryInstance factoryInstance;
- private ConfigMap factoryProperties;
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>FactoryDestination</code> instance.
- */
- public FactoryDestination()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>FactoryDestination</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>FactoryDestination</code>
- * is manageable; otherwise <code>false</code>.
- */
- public FactoryDestination(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Initialize, validate, start, and stop methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes the <code>FactoryDestination</code> with the properties.
- * @param id the factory id
- * @param properties Properties for the <code>FactoryDestination</code>.
- */
- public void initialize(String id, ConfigMap properties)
- {
- super.initialize(id, properties);
-
- if (properties == null || properties.size() == 0)
- return;
-
- // Need to cache this for later. TODO: We shouldn't need to do this.
- factoryProperties = properties;
-
- factoryId = properties.getPropertyAsString(FACTORY, factoryId);
- scope = properties.getPropertyAsString(FlexFactory.SCOPE, scope);
- source = properties.getPropertyAsString(FlexFactory.SOURCE, source);
-
- if (source == null)
- source = getId();
-
- if (factory != null)
- factory.initialize(getId(), factoryProperties);
- }
-
- /**
- * Verifies that the <code>FactoryDestination</code> is in valid state before
- * it is started.
- */
- protected void validate()
- {
- if (isValid())
- return;
-
- super.validate();
-
- if (factory == null)
- {
- if (factoryId == null)
- {
- factoryId = DEFAULT_FACTORY;
- }
- MessageBroker broker = getService().getMessageBroker();
- FlexFactory f = broker.getFactory(factoryId);
- if (f == null)
- {
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_FACTORY, new Object[] {getId(), factoryId});
- throw ex;
- }
- factory = f;
- }
-
- if (scope == null)
- scope = FlexFactory.SCOPE_REQUEST;
-
- if (source == null)
- source = getId();
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Getters and Setters for Destination properties
- //
- //--------------------------------------------------------------------------
-
- /**
- * Returns the factory of the <code>FactoryDestination</code>. Before a valid
- * <code>FlexFactory</code> can be returned, <code>MessageBroker</code> and
- * hence <code>Service</code> of the <code>Destination</code> has to be set.
- * @return FlexFactory the FlexFactory object
- */
- public FlexFactory getFactory()
- {
- if (factory == null)
- {
- if (factoryId == null)
- {
- factoryId = DEFAULT_FACTORY;
- }
- if (getService() == null)
- {
- // Factory cannot be returned without ''{0}'' set.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(FACTORY_CANNOT_BE_RETURNED, new Object[] {"Service"});
- throw ex;
- }
- if (getService().getMessageBroker() == null)
- {
- // Factory cannot be returned without ''{0}'' set.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(FACTORY_CANNOT_BE_RETURNED, new Object[] {"MessageBroker"});
- throw ex;
- }
- MessageBroker broker = getService().getMessageBroker();
- FlexFactory f = broker.getFactory(factoryId);
- if (f == null)
- {
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_FACTORY, new Object[] {getId(), factoryId});
- throw ex;
- }
- factory = f;
- }
- return factory;
- }
-
- /**
- * Sets the factory of the <code>FactoryDestination</code>.
- * <code>MessageBroker</code> has to know the factory before it can be
- * assigned to the destination.
- *
- * @param id The id of the factory.
- */
- public void setFactory(String id)
- {
- if (isStarted())
- {
- MessageBroker broker = getService().getMessageBroker();
- FlexFactory factory = broker.getFactory(id);
- if (factory == null)
- {
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_FACTORY, new Object[] {getId(), factory});
- throw ex;
- }
- setFactory(factory);
- }
- factoryId = id;
- }
-
- /**
- * Sets the factory of the <code>FactoryDestination</code>.
- *
- * @param factory the FlexFactory object
- */
- public void setFactory(FlexFactory factory)
- {
- this.factory = factory;
- }
-
- /**
- * Returns the <code>FactoryInstance</code>. <code>FactoryInstance</code>
- * stores configuration state used for retrieving an instance from
- * the factory. This needs to be called after calling <code>setSource</code>
- * and <code>setScope</code> methods.
- * @return FactoryInstance current FactoryInstance object
- */
- public FactoryInstance getFactoryInstance()
- {
- // This is needed for HibernateAssembler
- return getFactoryInstance(factoryProperties);
- }
-
- /**
- * Returns a <code>FactoryInstance</code> using the properties passed in.
- *
- * @param properties Properties to be used while creating the <code>FactoryInstance</code>.
- */
- private FactoryInstance getFactoryInstance(ConfigMap properties)
- {
- // Automatically create a factory instance if not already set
- if (factoryInstance == null)
- factoryInstance = createFactoryInstance(properties);
-
- return factoryInstance;
- }
-
- /**
- * Creates a factory instance using the properties passed in.
- *
- * @param properties Properties to be used while creating the <code>FactoryInstance</code>.
- */
- private FactoryInstance createFactoryInstance(ConfigMap properties)
- {
- if (properties == null)
- properties = new ConfigMap();
-
- properties.put(FlexFactory.SOURCE, source);
- properties.put(FlexFactory.SCOPE, scope);
- FactoryInstance factoryInstance = getFactory().createFactoryInstance(getId(), properties);
- return factoryInstance;
- }
-
- /**
- * Returns the scope of the <code>FactoryDestination</code>.
- *
- * @return scope of the <code>FactoryDestination</code>.
- */
- public String getScope()
- {
- return scope;
- }
-
- /**
- * Sets the scope of the <code>FactoryDestination</code> that is used
- * in <code>FactoryInstance</code> creation. Scope cannot be changed to and
- * from application scope once <code>FactoryInstance</code> is initialized.
- *
- * @param scope the scope
- */
- public void setScope(String scope)
- {
- if (factoryInstance != null)
- {
- if (FlexFactory.SCOPE_APPLICATION.equals(this.scope)
- && !FlexFactory.SCOPE_APPLICATION.equals(scope))
- {
- if (Log.isWarn())
- Log.getLogger(getLogCategory()).warn(
- "Current scope is "+FlexFactory.SCOPE_APPLICATION
- +" and it cannot be changed to "+scope
- +" once factory instance is initialized.");
- return;
- }
- else if (!FlexFactory.SCOPE_APPLICATION.equals(this.scope)
- && FlexFactory.SCOPE_APPLICATION.equals(scope))
- {
- if (Log.isWarn())
- Log.getLogger(getLogCategory()).warn(
- "Current scope is "+this.scope
- +" and it cannot be changed to "+FlexFactory.SCOPE_APPLICATION
- +" once factory instance is initialized.");
- return;
- }
- factoryInstance.setScope(scope);
- }
- this.scope = scope;
- }
-
- /**
- * Gets the source of the <code>FactoryDestination</code>.
- *
- * @return the source of the <code>FactoryDestination</code>.
- */
- public String getSource()
- {
- return source;
- }
-
- /**
- * Sets the source of the <code>FactoryDestination</code> that is used
- * in <code>FactoryInstance</code> creation. Source cannot be changed once
- * <code>FactoryInstance</code> is initialized and the scope is application.
- *
- * @param source the source string
- */
- public void setSource(String source)
- {
- if (factoryInstance != null)
- {
- if (FlexFactory.SCOPE_APPLICATION.equals(scope))
- {
- if (Log.isWarn())
- Log.getLogger(getLogCategory()).warn(
- "Source of the destination cannot be changed once "
- + "factory instance is already initialized and it has "
- + FlexFactory.SCOPE_APPLICATION +" scope");
- return;
- }
- factoryInstance.setSource(source);
- }
- this.source = source;
- }
-
- /**
- * This method first calls stop on its superclass <code>Destination</code> and then
- * removes any assemblers from the ServletContext or Session that are ready for removal.
- * If an assembler is only used by a single destination (attribute-id==destination-id) then
- * it is removed. If an assembler is shared across destinations, (attribute-id<>destination-id)
- * then it is only removed if its reference count (maintained in <code>MessageBroker</code>) is
- * down to zero
- */
- public void stop()
- {
- if (isStarted())
- {
- super.stop();
- // destroy factory instance to free up resources
- if (factory != null && (factory instanceof DestructibleFlexFactory))
- ((DestructibleFlexFactory)factory).destroyFactoryInstance(factoryInstance);
- }
- else
- {
- super.stop();
- }
- }
-}
+/*
+ * 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;
+
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.ConfigurationException;
+import flex.messaging.log.Log;
+
+public abstract class FactoryDestination extends Destination
+{
+ private static final String FACTORY = "factory";
+ private static final String DEFAULT_FACTORY = "java";
+
+ // Errors
+ private static int INVALID_FACTORY = 11103;
+ private static int FACTORY_CANNOT_BE_RETURNED = 11118;
+
+ // FactoryDestination's properties
+ private FlexFactory factory;
+ private String source;
+ private String scope = FlexFactory.SCOPE_REQUEST;
+
+ // FactoryDestination internal
+ private String factoryId = DEFAULT_FACTORY;
+ private FactoryInstance factoryInstance;
+ private ConfigMap factoryProperties;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>FactoryDestination</code> instance.
+ */
+ public FactoryDestination()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>FactoryDestination</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>FactoryDestination</code>
+ * is manageable; otherwise <code>false</code>.
+ */
+ public FactoryDestination(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Initialize, validate, start, and stop methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes the <code>FactoryDestination</code> with the properties.
+ * @param id the factory id
+ * @param properties Properties for the <code>FactoryDestination</code>.
+ */
+ public void initialize(String id, ConfigMap properties)
+ {
+ super.initialize(id, properties);
+
+ if (properties == null || properties.size() == 0)
+ return;
+
+ // Need to cache this for later. TODO: We shouldn't need to do this.
+ factoryProperties = properties;
+
+ factoryId = properties.getPropertyAsString(FACTORY, factoryId);
+ scope = properties.getPropertyAsString(FlexFactory.SCOPE, scope);
+ source = properties.getPropertyAsString(FlexFactory.SOURCE, source);
+
+ if (source == null)
+ source = getId();
+
+ if (factory != null)
+ factory.initialize(getId(), factoryProperties);
+ }
+
+ /**
+ * Verifies that the <code>FactoryDestination</code> is in valid state before
+ * it is started.
+ */
+ protected void validate()
+ {
+ if (isValid())
+ return;
+
+ super.validate();
+
+ if (factory == null)
+ {
+ if (factoryId == null)
+ {
+ factoryId = DEFAULT_FACTORY;
+ }
+ MessageBroker broker = getService().getMessageBroker();
+ FlexFactory f = broker.getFactory(factoryId);
+ if (f == null)
+ {
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_FACTORY, new Object[] {getId(), factoryId});
+ throw ex;
+ }
+ factory = f;
+ }
+
+ if (scope == null)
+ scope = FlexFactory.SCOPE_REQUEST;
+
+ if (source == null)
+ source = getId();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Getters and Setters for Destination properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns the factory of the <code>FactoryDestination</code>. Before a valid
+ * <code>FlexFactory</code> can be returned, <code>MessageBroker</code> and
+ * hence <code>Service</code> of the <code>Destination</code> has to be set.
+ * @return FlexFactory the FlexFactory object
+ */
+ public FlexFactory getFactory()
+ {
+ if (factory == null)
+ {
+ if (factoryId == null)
+ {
+ factoryId = DEFAULT_FACTORY;
+ }
+ if (getService() == null)
+ {
+ // Factory cannot be returned without ''{0}'' set.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(FACTORY_CANNOT_BE_RETURNED, new Object[] {"Service"});
+ throw ex;
+ }
+ if (getService().getMessageBroker() == null)
+ {
+ // Factory cannot be returned without ''{0}'' set.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(FACTORY_CANNOT_BE_RETURNED, new Object[] {"MessageBroker"});
+ throw ex;
+ }
+ MessageBroker broker = getService().getMessageBroker();
+ FlexFactory f = broker.getFactory(factoryId);
+ if (f == null)
+ {
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_FACTORY, new Object[] {getId(), factoryId});
+ throw ex;
+ }
+ factory = f;
+ }
+ return factory;
+ }
+
+ /**
+ * Sets the factory of the <code>FactoryDestination</code>.
+ * <code>MessageBroker</code> has to know the factory before it can be
+ * assigned to the destination.
+ *
+ * @param id The id of the factory.
+ */
+ public void setFactory(String id)
+ {
+ if (isStarted())
+ {
+ MessageBroker broker = getService().getMessageBroker();
+ FlexFactory factory = broker.getFactory(id);
+ if (factory == null)
+ {
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_FACTORY, new Object[] {getId(), factory});
+ throw ex;
+ }
+ setFactory(factory);
+ }
+ factoryId = id;
+ }
+
+ /**
+ * Sets the factory of the <code>FactoryDestination</code>.
+ *
+ * @param factory the FlexFactory object
+ */
+ public void setFactory(FlexFactory factory)
+ {
+ this.factory = factory;
+ }
+
+ /**
+ * Returns the <code>FactoryInstance</code>. <code>FactoryInstance</code>
+ * stores configuration state used for retrieving an instance from
+ * the factory. This needs to be called after calling <code>setSource</code>
+ * and <code>setScope</code> methods.
+ * @return FactoryInstance current FactoryInstance object
+ */
+ public FactoryInstance getFactoryInstance()
+ {
+ // This is needed for HibernateAssembler
+ return getFactoryInstance(factoryProperties);
+ }
+
+ /**
+ * Returns a <code>FactoryInstance</code> using the properties passed in.
+ *
+ * @param properties Properties to be used while creating the <code>FactoryInstance</code>.
+ */
+ private FactoryInstance getFactoryInstance(ConfigMap properties)
+ {
+ // Automatically create a factory instance if not already set
+ if (factoryInstance == null)
+ factoryInstance = createFactoryInstance(properties);
+
+ return factoryInstance;
+ }
+
+ /**
+ * Creates a factory instance using the properties passed in.
+ *
+ * @param properties Properties to be used while creating the <code>FactoryInstance</code>.
+ */
+ private FactoryInstance createFactoryInstance(ConfigMap properties)
+ {
+ if (properties == null)
+ properties = new ConfigMap();
+
+ properties.put(FlexFactory.SOURCE, source);
+ properties.put(FlexFactory.SCOPE, scope);
+ FactoryInstance factoryInstance = getFactory().createFactoryInstance(getId(), properties);
+ return factoryInstance;
+ }
+
+ /**
+ * Returns the scope of the <code>FactoryDestination</code>.
+ *
+ * @return scope of the <code>FactoryDestination</code>.
+ */
+ public String getScope()
+ {
+ return scope;
+ }
+
+ /**
+ * Sets the scope of the <code>FactoryDestination</code> that is used
+ * in <code>FactoryInstance</code> creation. Scope cannot be changed to and
+ * from application scope once <code>FactoryInstance</code> is initialized.
+ *
+ * @param scope the scope
+ */
+ public void setScope(String scope)
+ {
+ if (factoryInstance != null)
+ {
+ if (FlexFactory.SCOPE_APPLICATION.equals(this.scope)
+ && !FlexFactory.SCOPE_APPLICATION.equals(scope))
+ {
+ if (Log.isWarn())
+ Log.getLogger(getLogCategory()).warn(
+ "Current scope is "+FlexFactory.SCOPE_APPLICATION
+ +" and it cannot be changed to "+scope
+ +" once factory instance is initialized.");
+ return;
+ }
+ else if (!FlexFactory.SCOPE_APPLICATION.equals(this.scope)
+ && FlexFactory.SCOPE_APPLICATION.equals(scope))
+ {
+ if (Log.isWarn())
+ Log.getLogger(getLogCategory()).warn(
+ "Current scope is "+this.scope
+ +" and it cannot be changed to "+FlexFactory.SCOPE_APPLICATION
+ +" once factory instance is initialized.");
+ return;
+ }
+ factoryInstance.setScope(scope);
+ }
+ this.scope = scope;
+ }
+
+ /**
+ * Gets the source of the <code>FactoryDestination</code>.
+ *
+ * @return the source of the <code>FactoryDestination</code>.
+ */
+ public String getSource()
+ {
+ return source;
+ }
+
+ /**
+ * Sets the source of the <code>FactoryDestination</code> that is used
+ * in <code>FactoryInstance</code> creation. Source cannot be changed once
+ * <code>FactoryInstance</code> is initialized and the scope is application.
+ *
+ * @param source the source string
+ */
+ public void setSource(String source)
+ {
+ if (factoryInstance != null)
+ {
+ if (FlexFactory.SCOPE_APPLICATION.equals(scope))
+ {
+ if (Log.isWarn())
+ Log.getLogger(getLogCategory()).warn(
+ "Source of the destination cannot be changed once "
+ + "factory instance is already initialized and it has "
+ + FlexFactory.SCOPE_APPLICATION +" scope");
+ return;
+ }
+ factoryInstance.setSource(source);
+ }
+ this.source = source;
+ }
+
+ /**
+ * This method first calls stop on its superclass <code>Destination</code> and then
+ * removes any assemblers from the ServletContext or Session that are ready for removal.
+ * If an assembler is only used by a single destination (attribute-id==destination-id) then
+ * it is removed. If an assembler is shared across destinations, (attribute-id<>destination-id)
+ * then it is only removed if its reference count (maintained in <code>MessageBroker</code>) is
+ * down to zero
+ */
+ public void stop()
+ {
+ if (isStarted())
+ {
+ super.stop();
+ // destroy factory instance to free up resources
+ if (factory != null && (factory instanceof DestructibleFlexFactory))
+ ((DestructibleFlexFactory)factory).destroyFactoryInstance(factoryInstance);
+ }
+ else
+ {
+ super.stop();
+ }
+ }
+}
[34/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/ServiceAdapterControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/ServiceAdapterControl.java b/modules/core/src/flex/management/runtime/messaging/services/ServiceAdapterControl.java
old mode 100755
new mode 100644
index 2870c96..3d90e97
--- a/modules/core/src/flex/management/runtime/messaging/services/ServiceAdapterControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/ServiceAdapterControl.java
@@ -1,87 +1,87 @@
-/*
- * 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.management.runtime.messaging.services;
-
-import java.util.Date;
-
-import flex.management.BaseControl;
-import flex.management.runtime.messaging.DestinationControl;
-import flex.messaging.services.ServiceAdapter;
-
-/**
- * The <code>ServiceAdapterControl</code> class is the base MBean implementation
- * for monitoring and managing a <code>ServiceAdapter</code> at runtime.
- *
- * @author shodgson
- */
-public abstract class ServiceAdapterControl extends BaseControl implements
- ServiceAdapterControlMBean
-{
- protected ServiceAdapter serviceAdapter;
-
- /**
- * Constructs a <code>ServiceAdapterControl</code>, assigning its id, managed service
- * adapter and parent MBean.
- *
- * @param serviceAdapter The <code>ServiceAdapter</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public ServiceAdapterControl(ServiceAdapter serviceAdapter, BaseControl parent)
- {
- super(parent);
- this.serviceAdapter = serviceAdapter;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getId()
- */
- public String getId()
- {
- return serviceAdapter.getId();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ServiceAdapterControlMBean#isRunning()
- */
- public Boolean isRunning()
- {
- return Boolean.valueOf(serviceAdapter.isStarted());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ServiceAdapterControlMBean#getStartTimestamp()
- */
- public Date getStartTimestamp()
- {
- return startTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.management.MBeanRegistration#preDeregister()
- */
- public void preDeregister() throws Exception
- {
- DestinationControl parent = (DestinationControl)getParentControl();
- parent.setAdapter(null);
-
- super.preDeregister();
- }
-}
+/*
+ * 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.management.runtime.messaging.services;
+
+import java.util.Date;
+
+import flex.management.BaseControl;
+import flex.management.runtime.messaging.DestinationControl;
+import flex.messaging.services.ServiceAdapter;
+
+/**
+ * The <code>ServiceAdapterControl</code> class is the base MBean implementation
+ * for monitoring and managing a <code>ServiceAdapter</code> at runtime.
+ *
+ * @author shodgson
+ */
+public abstract class ServiceAdapterControl extends BaseControl implements
+ ServiceAdapterControlMBean
+{
+ protected ServiceAdapter serviceAdapter;
+
+ /**
+ * Constructs a <code>ServiceAdapterControl</code>, assigning its id, managed service
+ * adapter and parent MBean.
+ *
+ * @param serviceAdapter The <code>ServiceAdapter</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public ServiceAdapterControl(ServiceAdapter serviceAdapter, BaseControl parent)
+ {
+ super(parent);
+ this.serviceAdapter = serviceAdapter;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getId()
+ */
+ public String getId()
+ {
+ return serviceAdapter.getId();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ServiceAdapterControlMBean#isRunning()
+ */
+ public Boolean isRunning()
+ {
+ return Boolean.valueOf(serviceAdapter.isStarted());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ServiceAdapterControlMBean#getStartTimestamp()
+ */
+ public Date getStartTimestamp()
+ {
+ return startTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.management.MBeanRegistration#preDeregister()
+ */
+ public void preDeregister() throws Exception
+ {
+ DestinationControl parent = (DestinationControl)getParentControl();
+ parent.setAdapter(null);
+
+ super.preDeregister();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/ServiceAdapterControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/ServiceAdapterControlMBean.java b/modules/core/src/flex/management/runtime/messaging/services/ServiceAdapterControlMBean.java
old mode 100755
new mode 100644
index eb21b65..064944b
--- a/modules/core/src/flex/management/runtime/messaging/services/ServiceAdapterControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/ServiceAdapterControlMBean.java
@@ -1,47 +1,47 @@
-/*
- * 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.management.runtime.messaging.services;
-
-import java.io.IOException;
-import java.util.Date;
-
-import flex.management.BaseControlMBean;
-
-/**
- * Defines the runtime monitoring and management interface for service adapters.
- *
- * @author shodgson
- */
-public interface ServiceAdapterControlMBean extends BaseControlMBean
-{
- /**
- * Returns <code>true</code> if the <code>ServiceAdapter</code> is running.
- *
- * @return <code>true</code> if the <code>ServiceAdapter</code> is running.
- * @throws IOException Throws IOException.
- */
- Boolean isRunning() throws IOException;
-
- /**
- * Returns the start timestamp for the <code>ServiceAdapter</code>.
- *
- * @return The start timestamp for the <code>ServiceAdapter</code>.
- * @throws IOException Throws IOException.
- */
- Date getStartTimestamp() throws IOException;
-
-}
+/*
+ * 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.management.runtime.messaging.services;
+
+import java.io.IOException;
+import java.util.Date;
+
+import flex.management.BaseControlMBean;
+
+/**
+ * Defines the runtime monitoring and management interface for service adapters.
+ *
+ * @author shodgson
+ */
+public interface ServiceAdapterControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns <code>true</code> if the <code>ServiceAdapter</code> is running.
+ *
+ * @return <code>true</code> if the <code>ServiceAdapter</code> is running.
+ * @throws IOException Throws IOException.
+ */
+ Boolean isRunning() throws IOException;
+
+ /**
+ * Returns the start timestamp for the <code>ServiceAdapter</code>.
+ *
+ * @return The start timestamp for the <code>ServiceAdapter</code>.
+ * @throws IOException Throws IOException.
+ */
+ Date getStartTimestamp() throws IOException;
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/ServiceControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/ServiceControl.java b/modules/core/src/flex/management/runtime/messaging/services/ServiceControl.java
old mode 100755
new mode 100644
index b804728..76623af
--- a/modules/core/src/flex/management/runtime/messaging/services/ServiceControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/ServiceControl.java
@@ -1,145 +1,145 @@
-/*
- * 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.management.runtime.messaging.services;
-
-import flex.management.BaseControl;
-import flex.management.runtime.messaging.MessageBrokerControl;
-import flex.messaging.Destination;
-import flex.messaging.services.Service;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.management.ObjectName;
-
-/**
- * The <code>ServiceControl</code> class is the MBean implementation for
- * monitoring and managing a <code>Service</code> at runtime.
- *
- * @author shodgson
- */
-public abstract class ServiceControl extends BaseControl implements ServiceControlMBean
-{
- protected Service service;
- private List destinations;
-
- /**
- * Constructs a <code>ServiceControl</code>, assigning its id, managed service and
- * parent MBean.
- *
- * @param service The <code>Service</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public ServiceControl(Service service, BaseControl parent)
- {
- super(parent);
- this.service = service;
- destinations = new ArrayList();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getId()
- */
- public String getId()
- {
- return service.getId();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ServiceControlMBean#isRunning()
- */
- public Boolean isRunning()
- {
- return Boolean.valueOf(service.isStarted());
- }
-
-
- /**
- * Adds the <code>ObjectName</code> of a destination registered with the managed service.
- *
- * @param value The <code>ObjectName</code> of a destination registered with the managed service.
- */
- public void addDestination(ObjectName value)
- {
- destinations.add(value);
- }
-
- /**
- * Removes the <code>ObjectName</code> of a destination registered with the managed service.
- *
- * @param value The <code>ObjectName</code> of a destination registered with the managed service.
- */
- public void removeDestination(ObjectName value)
- {
- destinations.remove(value);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ServiceControlMBean#getDestinations()
- */
- public ObjectName[] getDestinations()
- {
- int size = destinations.size();
- ObjectName[] destinationNames = new ObjectName[size];
- for (int i = 0; i < size; ++i)
- {
- destinationNames[i] = (ObjectName)destinations.get(i);
- }
- return destinationNames;
- }
-
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ServiceControlMBean#getStartTimestamp()
- */
- public Date getStartTimestamp()
- {
- return startTimestamp;
- }
-
-
- /*
- * (non-Javadoc)
- * @see javax.management.MBeanRegistration#preDeregister()
- */
- public void preDeregister() throws Exception
- {
- MessageBrokerControl parent = (MessageBrokerControl)getParentControl();
- parent.removeService(getObjectName());
-
- // Unregister destinations of the service
- for (Iterator iter = service.getDestinations().values().iterator(); iter.hasNext();) {
- Destination child = (Destination) iter.next();
- if (child.getControl() != null)
- {
- child.getControl().unregister();
- child.setControl(null);
- child.setManaged(false);
- }
-
- }
-
- super.preDeregister();
- }
-
-}
+/*
+ * 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.management.runtime.messaging.services;
+
+import flex.management.BaseControl;
+import flex.management.runtime.messaging.MessageBrokerControl;
+import flex.messaging.Destination;
+import flex.messaging.services.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.ObjectName;
+
+/**
+ * The <code>ServiceControl</code> class is the MBean implementation for
+ * monitoring and managing a <code>Service</code> at runtime.
+ *
+ * @author shodgson
+ */
+public abstract class ServiceControl extends BaseControl implements ServiceControlMBean
+{
+ protected Service service;
+ private List destinations;
+
+ /**
+ * Constructs a <code>ServiceControl</code>, assigning its id, managed service and
+ * parent MBean.
+ *
+ * @param service The <code>Service</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public ServiceControl(Service service, BaseControl parent)
+ {
+ super(parent);
+ this.service = service;
+ destinations = new ArrayList();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getId()
+ */
+ public String getId()
+ {
+ return service.getId();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ServiceControlMBean#isRunning()
+ */
+ public Boolean isRunning()
+ {
+ return Boolean.valueOf(service.isStarted());
+ }
+
+
+ /**
+ * Adds the <code>ObjectName</code> of a destination registered with the managed service.
+ *
+ * @param value The <code>ObjectName</code> of a destination registered with the managed service.
+ */
+ public void addDestination(ObjectName value)
+ {
+ destinations.add(value);
+ }
+
+ /**
+ * Removes the <code>ObjectName</code> of a destination registered with the managed service.
+ *
+ * @param value The <code>ObjectName</code> of a destination registered with the managed service.
+ */
+ public void removeDestination(ObjectName value)
+ {
+ destinations.remove(value);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ServiceControlMBean#getDestinations()
+ */
+ public ObjectName[] getDestinations()
+ {
+ int size = destinations.size();
+ ObjectName[] destinationNames = new ObjectName[size];
+ for (int i = 0; i < size; ++i)
+ {
+ destinationNames[i] = (ObjectName)destinations.get(i);
+ }
+ return destinationNames;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ServiceControlMBean#getStartTimestamp()
+ */
+ public Date getStartTimestamp()
+ {
+ return startTimestamp;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see javax.management.MBeanRegistration#preDeregister()
+ */
+ public void preDeregister() throws Exception
+ {
+ MessageBrokerControl parent = (MessageBrokerControl)getParentControl();
+ parent.removeService(getObjectName());
+
+ // Unregister destinations of the service
+ for (Iterator iter = service.getDestinations().values().iterator(); iter.hasNext();) {
+ Destination child = (Destination) iter.next();
+ if (child.getControl() != null)
+ {
+ child.getControl().unregister();
+ child.setControl(null);
+ child.setManaged(false);
+ }
+
+ }
+
+ super.preDeregister();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/ServiceControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/ServiceControlMBean.java b/modules/core/src/flex/management/runtime/messaging/services/ServiceControlMBean.java
old mode 100755
new mode 100644
index 370c08f..afc6bb5
--- a/modules/core/src/flex/management/runtime/messaging/services/ServiceControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/ServiceControlMBean.java
@@ -1,59 +1,59 @@
-/*
- * 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.management.runtime.messaging.services;
-
-import flex.management.BaseControlMBean;
-
-import java.io.IOException;
-import java.util.Date;
-import javax.management.ObjectName;
-
-/**
- * Defines the runtime monitoring and management interface for managed services.
- *
- * @author shodgson
- */
-public interface ServiceControlMBean extends BaseControlMBean
-{
-
- /**
- * Returns <code>true</code> if the <code>Service</code> is running.
- *
- * @return <code>true</code> if the <code>Service</code> is running.
- * @throws IOException Throws IOException.
- */
- Boolean isRunning() throws IOException;
-
-
- /**
- * Returns the start timestamp for the <code>Service</code>.
- *
- * @return The start timestamp for the <code>Service</code>.
- * @throws IOException Throws IOException.
- */
- Date getStartTimestamp() throws IOException;
-
- /**
- * Returns the <code>ObjectName</code>s of all destinations registered with the
- * managed service.
- *
- * @return The <code>ObjectName</code>s of all destinations registered with the
- * managed service.
- * @throws IOException Throws IOException.
- */
- ObjectName[] getDestinations() throws IOException;
-}
+/*
+ * 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.management.runtime.messaging.services;
+
+import flex.management.BaseControlMBean;
+
+import java.io.IOException;
+import java.util.Date;
+import javax.management.ObjectName;
+
+/**
+ * Defines the runtime monitoring and management interface for managed services.
+ *
+ * @author shodgson
+ */
+public interface ServiceControlMBean extends BaseControlMBean
+{
+
+ /**
+ * Returns <code>true</code> if the <code>Service</code> is running.
+ *
+ * @return <code>true</code> if the <code>Service</code> is running.
+ * @throws IOException Throws IOException.
+ */
+ Boolean isRunning() throws IOException;
+
+
+ /**
+ * Returns the start timestamp for the <code>Service</code>.
+ *
+ * @return The start timestamp for the <code>Service</code>.
+ * @throws IOException Throws IOException.
+ */
+ Date getStartTimestamp() throws IOException;
+
+ /**
+ * Returns the <code>ObjectName</code>s of all destinations registered with the
+ * managed service.
+ *
+ * @return The <code>ObjectName</code>s of all destinations registered with the
+ * managed service.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName[] getDestinations() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/messaging/SubscriptionManagerControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/messaging/SubscriptionManagerControl.java b/modules/core/src/flex/management/runtime/messaging/services/messaging/SubscriptionManagerControl.java
old mode 100755
new mode 100644
index 598732b..c7640ad
--- a/modules/core/src/flex/management/runtime/messaging/services/messaging/SubscriptionManagerControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/messaging/SubscriptionManagerControl.java
@@ -1,129 +1,129 @@
-/*
- * 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.management.runtime.messaging.services.messaging;
-
-import flex.management.BaseControl;
-import flex.messaging.MessageClient;
-import flex.messaging.services.messaging.SubscriptionManager;
-
-import java.util.Set;
-
-/**
- * The <code>SubscriptionManagerControl</code> class is the MBean implementation for
- * monitoring and managing a <code>SubscriptionManager</code> at runtime.
- *
- * @author shodgson
- */
-public class SubscriptionManagerControl extends BaseControl implements
- SubscriptionManagerControlMBean
-{
- private SubscriptionManager subscriptionManager;
-
- /**
- * Constructs a new <code>SubscriptionManagerControl</code> instance, assigning its
- * backing <code>SubscriptionManager</code>.
- *
- * @param subscriptionManager The <code>SubscriptionManager</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public SubscriptionManagerControl(SubscriptionManager subscriptionManager, BaseControl parent)
- {
- super(parent);
- this.subscriptionManager = subscriptionManager;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getId()
- */
- public String getId()
- {
- return subscriptionManager.getId();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getType()
- */
- public String getType()
- {
- return SubscriptionManager.TYPE;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.SubscriptionManagerControlMBean#getSubscriberCount()
- */
- public Integer getSubscriberCount()
- {
- Set subscriberIds = subscriptionManager.getSubscriberIds();
- if (subscriberIds != null)
- {
- return new Integer(subscriberIds.size());
- }
- else
- {
- return new Integer(0);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.SubscriptionManagerControlMBean#getSubscriberIds()
- */
- public String[] getSubscriberIds()
- {
- Set subscriberIds = subscriptionManager.getSubscriberIds();
- if (subscriberIds != null)
- {
- String[] ids = new String[subscriberIds.size()];
- return (String[])subscriberIds.toArray(ids);
- }
- else
- {
- return new String[0];
- }
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.SubscriptionManagerControlMBean#removeSubscriber(java.lang.String)
- */
- public void removeSubscriber(String subscriberId)
- {
- MessageClient subscriber = subscriptionManager.getSubscriber(subscriberId);
- if (subscriber != null)
- {
- subscriptionManager.removeSubscriber(subscriber);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.SubscriptionManagerControlMBean#removeAllSubscribers()
- */
- public void removeAllSubscribers()
- {
- String[] subscriberIds = getSubscriberIds();
- int length = subscriberIds.length;
- for (int i = 0; i < length; ++i)
- {
- removeSubscriber(subscriberIds[i]);
- }
- }
-
-}
+/*
+ * 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.management.runtime.messaging.services.messaging;
+
+import flex.management.BaseControl;
+import flex.messaging.MessageClient;
+import flex.messaging.services.messaging.SubscriptionManager;
+
+import java.util.Set;
+
+/**
+ * The <code>SubscriptionManagerControl</code> class is the MBean implementation for
+ * monitoring and managing a <code>SubscriptionManager</code> at runtime.
+ *
+ * @author shodgson
+ */
+public class SubscriptionManagerControl extends BaseControl implements
+ SubscriptionManagerControlMBean
+{
+ private SubscriptionManager subscriptionManager;
+
+ /**
+ * Constructs a new <code>SubscriptionManagerControl</code> instance, assigning its
+ * backing <code>SubscriptionManager</code>.
+ *
+ * @param subscriptionManager The <code>SubscriptionManager</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public SubscriptionManagerControl(SubscriptionManager subscriptionManager, BaseControl parent)
+ {
+ super(parent);
+ this.subscriptionManager = subscriptionManager;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getId()
+ */
+ public String getId()
+ {
+ return subscriptionManager.getId();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getType()
+ */
+ public String getType()
+ {
+ return SubscriptionManager.TYPE;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.SubscriptionManagerControlMBean#getSubscriberCount()
+ */
+ public Integer getSubscriberCount()
+ {
+ Set subscriberIds = subscriptionManager.getSubscriberIds();
+ if (subscriberIds != null)
+ {
+ return new Integer(subscriberIds.size());
+ }
+ else
+ {
+ return new Integer(0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.SubscriptionManagerControlMBean#getSubscriberIds()
+ */
+ public String[] getSubscriberIds()
+ {
+ Set subscriberIds = subscriptionManager.getSubscriberIds();
+ if (subscriberIds != null)
+ {
+ String[] ids = new String[subscriberIds.size()];
+ return (String[])subscriberIds.toArray(ids);
+ }
+ else
+ {
+ return new String[0];
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.SubscriptionManagerControlMBean#removeSubscriber(java.lang.String)
+ */
+ public void removeSubscriber(String subscriberId)
+ {
+ MessageClient subscriber = subscriptionManager.getSubscriber(subscriberId);
+ if (subscriber != null)
+ {
+ subscriptionManager.removeSubscriber(subscriber);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.SubscriptionManagerControlMBean#removeAllSubscribers()
+ */
+ public void removeAllSubscribers()
+ {
+ String[] subscriberIds = getSubscriberIds();
+ int length = subscriberIds.length;
+ for (int i = 0; i < length; ++i)
+ {
+ removeSubscriber(subscriberIds[i]);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/messaging/SubscriptionManagerControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/messaging/SubscriptionManagerControlMBean.java b/modules/core/src/flex/management/runtime/messaging/services/messaging/SubscriptionManagerControlMBean.java
old mode 100755
new mode 100644
index f0b7f5f..7745b19
--- a/modules/core/src/flex/management/runtime/messaging/services/messaging/SubscriptionManagerControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/messaging/SubscriptionManagerControlMBean.java
@@ -1,61 +1,61 @@
-/*
- * 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.management.runtime.messaging.services.messaging;
-
-import java.io.IOException;
-
-import flex.management.BaseControlMBean;
-
-/**
- * Defines the runtime monitoring and management interface for
- * <code>SubscriptionManager</code>s.
- *
- * @author shodgson
- */
-public interface SubscriptionManagerControlMBean extends BaseControlMBean
-{
- /**
- * Returns the count of active subscribers.
- *
- * @return The count of active subscribers.
- * @throws IOException Throws IOException.
- */
- Integer getSubscriberCount() throws IOException;
-
- /**
- * Returns the ids for all active subscribers.
- *
- * @return The ids for all active subscribers.
- * @throws IOException Throws IOException.
- */
- String[] getSubscriberIds() throws IOException;
-
- /**
- * Unsubscribes the target subscriber.
- *
- * @param subscriberId The id for the subscriber to unsubscribe.
- * @throws IOException Throws IOException.
- */
- void removeSubscriber(String subscriberId) throws IOException;
-
- /**
- * Unsubscribes all active subscribers.
- *
- * @throws IOException Throws IOException.
- */
- void removeAllSubscribers() throws IOException;
-}
+/*
+ * 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.management.runtime.messaging.services.messaging;
+
+import java.io.IOException;
+
+import flex.management.BaseControlMBean;
+
+/**
+ * Defines the runtime monitoring and management interface for
+ * <code>SubscriptionManager</code>s.
+ *
+ * @author shodgson
+ */
+public interface SubscriptionManagerControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns the count of active subscribers.
+ *
+ * @return The count of active subscribers.
+ * @throws IOException Throws IOException.
+ */
+ Integer getSubscriberCount() throws IOException;
+
+ /**
+ * Returns the ids for all active subscribers.
+ *
+ * @return The ids for all active subscribers.
+ * @throws IOException Throws IOException.
+ */
+ String[] getSubscriberIds() throws IOException;
+
+ /**
+ * Unsubscribes the target subscriber.
+ *
+ * @param subscriberId The id for the subscriber to unsubscribe.
+ * @throws IOException Throws IOException.
+ */
+ void removeSubscriber(String subscriberId) throws IOException;
+
+ /**
+ * Unsubscribes all active subscribers.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void removeAllSubscribers() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/messaging/ThrottleManagerControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/messaging/ThrottleManagerControl.java b/modules/core/src/flex/management/runtime/messaging/services/messaging/ThrottleManagerControl.java
old mode 100755
new mode 100644
index 485e780..4bceff7
--- a/modules/core/src/flex/management/runtime/messaging/services/messaging/ThrottleManagerControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/messaging/ThrottleManagerControl.java
@@ -1,304 +1,304 @@
-/*
- * 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.management.runtime.messaging.services.messaging;
-
-import flex.management.BaseControl;
-import flex.management.runtime.AdminConsoleTypes;
-import flex.messaging.services.messaging.ThrottleManager;
-
-import java.util.Date;
-
-/**
- * The <code>ThrottleManagerControl</code> class is the MBean implementation for
- * monitoring and managing a <code>ThrottleManager</code> at runtime.
- *
- * @author shodgson
- */
-public class ThrottleManagerControl extends BaseControl implements
- ThrottleManagerControlMBean
-{
- private ThrottleManager throttleManager;
- private long clientIncomingMessageThrottleStart;
- private int clientIncomingMessageThrottleCount;
- private Date lastClientIncomingMessageThrottleTimestamp;
- private long clientOutgoingMessageThrottleStart;
- private int clientOutgoingMessageThrottleCount;
- private Date lastClientOutgoingMessageThrottleTimestamp;
- private long destinationIncomingMessageThrottleStart;
- private int destinationIncomingMessageThrottleCount;
- private Date lastDestinationIncomingMessageThrottleTimestamp;
- private long destinationOutgoingMessageThrottleStart;
- private int destinationOutgoingMessageThrottleCount;
- private Date lastDestinationOutgoingMessageThrottleTimestamp;
-
- /**
- * Constructs a new <code>ThrottleManagerControl</code> instance, assigning its
- * backing <code>ThrottleManager</code>.
- *
- * @param throttleManager The <code>ThrottleManager</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public ThrottleManagerControl(ThrottleManager throttleManager, BaseControl parent)
- {
- super(parent);
- this.throttleManager = throttleManager;
- clientIncomingMessageThrottleStart = System.currentTimeMillis();
- clientOutgoingMessageThrottleStart = clientIncomingMessageThrottleStart;
- destinationIncomingMessageThrottleStart = clientIncomingMessageThrottleStart;
- destinationOutgoingMessageThrottleStart = clientIncomingMessageThrottleStart;
- }
-
- @Override
- protected void onRegistrationComplete()
- {
- String name = this.getObjectName().getCanonicalName();
- String[] attributes = {
- "ClientIncomingMessageThrottleCount", "ClientIncomingMessageThrottleFrequency",
- "ClientOutgoingMessageThrottleCount", "ClientOutgoingMessageThrottleFrequency",
- "DestinationIncomingMessageThrottleCount", "DestinationIncomingMessageThrottleFrequency",
- "DestinationOutgoingMessageThrottleCount", "DestinationOutgoingMessageThrottleFrequency",
- "LastClientIncomingMessageThrottleTimestamp", "LastClientOutgoingMessageThrottleTimestamp",
- "LastDestinationIncomingMessageThrottleTimestamp", "LastDestinationOutgoingMessageThrottleTimestamp"
- };
-
- getRegistrar().registerObjects(AdminConsoleTypes.DESTINATION_POLLABLE, name, attributes);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getId()
- */
- @Override
- public String getId()
- {
- return throttleManager.getId();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getType()
- */
- @Override
- public String getType()
- {
- return ThrottleManager.TYPE;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getClientIncomingMessageThrottleCount()
- */
- public Integer getClientIncomingMessageThrottleCount()
- {
- return Integer.valueOf(clientIncomingMessageThrottleCount);
- }
-
- /**
- * Increments the count of throttled incoming client messages.
- */
- public void incrementClientIncomingMessageThrottleCount()
- {
- ++clientIncomingMessageThrottleCount;
- lastClientIncomingMessageThrottleTimestamp = new Date();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#resetClientIncomingMessageThrottleCount()
- */
- public void resetClientIncomingMessageThrottleCount()
- {
- clientIncomingMessageThrottleStart = System.currentTimeMillis();
- clientIncomingMessageThrottleCount = 0;
- lastClientIncomingMessageThrottleTimestamp = null;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getLastClientIncomingMessageThrottleTimestamp()
- */
- public Date getLastClientIncomingMessageThrottleTimestamp()
- {
- return lastClientIncomingMessageThrottleTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getClientIncomingMessageThrottleFrequency()
- */
- public Double getClientIncomingMessageThrottleFrequency()
- {
- if (clientIncomingMessageThrottleCount > 0)
- {
- double runtime = differenceInMinutes(clientIncomingMessageThrottleStart, System.currentTimeMillis());
- return new Double(clientIncomingMessageThrottleCount/runtime);
- }
- return new Double(0);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getClientOutgoingMessageThrottleCount()
- */
- public Integer getClientOutgoingMessageThrottleCount()
- {
- return Integer.valueOf(clientOutgoingMessageThrottleCount);
- }
-
- /**
- * Increments the count of throttled outgoing client messages.
- */
- public void incrementClientOutgoingMessageThrottleCount()
- {
- ++clientOutgoingMessageThrottleCount;
- lastClientOutgoingMessageThrottleTimestamp = new Date();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#resetClientOutgoingMessageThrottleCount()
- */
- public void resetClientOutgoingMessageThrottleCount()
- {
- clientOutgoingMessageThrottleStart = System.currentTimeMillis();
- clientOutgoingMessageThrottleCount = 0;
- lastClientOutgoingMessageThrottleTimestamp = null;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getLastClientOutgoingMessageThrottleTimestamp()
- */
- public Date getLastClientOutgoingMessageThrottleTimestamp()
- {
- return lastClientOutgoingMessageThrottleTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getClientOutgoingMessageThrottleFrequency()
- */
- public Double getClientOutgoingMessageThrottleFrequency()
- {
- if (clientOutgoingMessageThrottleCount > 0)
- {
- double runtime = differenceInMinutes(clientOutgoingMessageThrottleStart, System.currentTimeMillis());
- return new Double(clientOutgoingMessageThrottleCount/runtime);
- }
- return new Double(0);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getDestinationIncomingMessageThrottleCount()
- */
- public Integer getDestinationIncomingMessageThrottleCount()
- {
- return Integer.valueOf(destinationIncomingMessageThrottleCount);
- }
-
- /**
- * Increments the count of throttled incoming destination messages.
- */
- public void incrementDestinationIncomingMessageThrottleCount()
- {
- ++destinationIncomingMessageThrottleCount;
- lastDestinationIncomingMessageThrottleTimestamp = new Date();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#resetDestinationIncomingMessageThrottleCount()
- */
- public void resetDestinationIncomingMessageThrottleCount()
- {
- destinationIncomingMessageThrottleStart = System.currentTimeMillis();
- destinationIncomingMessageThrottleCount = 0;
- lastDestinationIncomingMessageThrottleTimestamp = null;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getLastDestinationIncomingMessageThrottleTimestamp()
- */
- public Date getLastDestinationIncomingMessageThrottleTimestamp()
- {
- return lastDestinationIncomingMessageThrottleTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getDestinationIncomingMessageThrottleFrequency()
- */
- public Double getDestinationIncomingMessageThrottleFrequency()
- {
- if (destinationIncomingMessageThrottleCount > 0)
- {
- double runtime = differenceInMinutes(destinationIncomingMessageThrottleStart, System.currentTimeMillis());
- return new Double(destinationIncomingMessageThrottleCount/runtime);
- }
- return new Double(0);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getDestinationOutgoingMessageThrottleCount()
- */
- public Integer getDestinationOutgoingMessageThrottleCount()
- {
- return Integer.valueOf(destinationOutgoingMessageThrottleCount);
- }
-
- /**
- * Increments the count of throttled outgoing destination messages.
- */
- public void incrementDestinationOutgoingMessageThrottleCount()
- {
- ++destinationOutgoingMessageThrottleCount;
- lastDestinationOutgoingMessageThrottleTimestamp = new Date();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#resetDestinationOutgoingMessageThrottleCount()
- */
- public void resetDestinationOutgoingMessageThrottleCount()
- {
- destinationOutgoingMessageThrottleStart = System.currentTimeMillis();
- destinationOutgoingMessageThrottleCount = 0;
- lastDestinationOutgoingMessageThrottleTimestamp = null;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.ThrottleManagerControlMBean#getLastDestinationOutgoingMessageThrottleTimestamp()
- */
- public Date getLastDestinationOutgoingMessageThrottleTimestamp()
- {
- return lastDestinationOutgoingMessageThrottleTimestamp;
- }
-
- public Double getDestinationOutgoingMessageThrottleFrequency()
- {
- if (destinationOutgoingMessageThrottleCount > 0)
- {
- double runtime = differenceInMinutes(destinationOutgoingMessageThrottleStart, System.currentTimeMillis());
- return new Double(destinationOutgoingMessageThrottleCount/runtime);
- }
- return new Double(0);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package flex.management.runtime.messaging.services.messaging;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.messaging.services.messaging.ThrottleManager;
+
+import java.util.Date;
+
+/**
+ * The <code>ThrottleManagerControl</code> class is the MBean implementation for
+ * monitoring and managing a <code>ThrottleManager</code> at runtime.
+ *
+ * @author shodgson
+ */
+public class ThrottleManagerControl extends BaseControl implements
+ ThrottleManagerControlMBean
+{
+ private ThrottleManager throttleManager;
+ private long clientIncomingMessageThrottleStart;
+ private int clientIncomingMessageThrottleCount;
+ private Date lastClientIncomingMessageThrottleTimestamp;
+ private long clientOutgoingMessageThrottleStart;
+ private int clientOutgoingMessageThrottleCount;
+ private Date lastClientOutgoingMessageThrottleTimestamp;
+ private long destinationIncomingMessageThrottleStart;
+ private int destinationIncomingMessageThrottleCount;
+ private Date lastDestinationIncomingMessageThrottleTimestamp;
+ private long destinationOutgoingMessageThrottleStart;
+ private int destinationOutgoingMessageThrottleCount;
+ private Date lastDestinationOutgoingMessageThrottleTimestamp;
+
+ /**
+ * Constructs a new <code>ThrottleManagerControl</code> instance, assigning its
+ * backing <code>ThrottleManager</code>.
+ *
+ * @param throttleManager The <code>ThrottleManager</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public ThrottleManagerControl(ThrottleManager throttleManager, BaseControl parent)
+ {
+ super(parent);
+ this.throttleManager = throttleManager;
+ clientIncomingMessageThrottleStart = System.currentTimeMillis();
+ clientOutgoingMessageThrottleStart = clientIncomingMessageThrottleStart;
+ destinationIncomingMessageThrottleStart = clientIncomingMessageThrottleStart;
+ destinationOutgoingMessageThrottleStart = clientIncomingMessageThrottleStart;
+ }
+
+ @Override
+ protected void onRegistrationComplete()
+ {
+ String name = this.getObjectName().getCanonicalName();
+ String[] attributes = {
+ "ClientIncomingMessageThrottleCount", "ClientIncomingMessageThrottleFrequency",
+ "ClientOutgoingMessageThrottleCount", "ClientOutgoingMessageThrottleFrequency",
+ "DestinationIncomingMessageThrottleCount", "DestinationIncomingMessageThrottleFrequency",
+ "DestinationOutgoingMessageThrottleCount", "DestinationOutgoingMessageThrottleFrequency",
+ "LastClientIncomingMessageThrottleTimestamp", "LastClientOutgoingMessageThrottleTimestamp",
+ "LastDestinationIncomingMessageThrottleTimestamp", "LastDestinationOutgoingMessageThrottleTimestamp"
+ };
+
+ getRegistrar().registerObjects(AdminConsoleTypes.DESTINATION_POLLABLE, name, attributes);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getId()
+ */
+ @Override
+ public String getId()
+ {
+ return throttleManager.getId();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return ThrottleManager.TYPE;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getClientIncomingMessageThrottleCount()
+ */
+ public Integer getClientIncomingMessageThrottleCount()
+ {
+ return Integer.valueOf(clientIncomingMessageThrottleCount);
+ }
+
+ /**
+ * Increments the count of throttled incoming client messages.
+ */
+ public void incrementClientIncomingMessageThrottleCount()
+ {
+ ++clientIncomingMessageThrottleCount;
+ lastClientIncomingMessageThrottleTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#resetClientIncomingMessageThrottleCount()
+ */
+ public void resetClientIncomingMessageThrottleCount()
+ {
+ clientIncomingMessageThrottleStart = System.currentTimeMillis();
+ clientIncomingMessageThrottleCount = 0;
+ lastClientIncomingMessageThrottleTimestamp = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getLastClientIncomingMessageThrottleTimestamp()
+ */
+ public Date getLastClientIncomingMessageThrottleTimestamp()
+ {
+ return lastClientIncomingMessageThrottleTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getClientIncomingMessageThrottleFrequency()
+ */
+ public Double getClientIncomingMessageThrottleFrequency()
+ {
+ if (clientIncomingMessageThrottleCount > 0)
+ {
+ double runtime = differenceInMinutes(clientIncomingMessageThrottleStart, System.currentTimeMillis());
+ return new Double(clientIncomingMessageThrottleCount/runtime);
+ }
+ return new Double(0);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getClientOutgoingMessageThrottleCount()
+ */
+ public Integer getClientOutgoingMessageThrottleCount()
+ {
+ return Integer.valueOf(clientOutgoingMessageThrottleCount);
+ }
+
+ /**
+ * Increments the count of throttled outgoing client messages.
+ */
+ public void incrementClientOutgoingMessageThrottleCount()
+ {
+ ++clientOutgoingMessageThrottleCount;
+ lastClientOutgoingMessageThrottleTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#resetClientOutgoingMessageThrottleCount()
+ */
+ public void resetClientOutgoingMessageThrottleCount()
+ {
+ clientOutgoingMessageThrottleStart = System.currentTimeMillis();
+ clientOutgoingMessageThrottleCount = 0;
+ lastClientOutgoingMessageThrottleTimestamp = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getLastClientOutgoingMessageThrottleTimestamp()
+ */
+ public Date getLastClientOutgoingMessageThrottleTimestamp()
+ {
+ return lastClientOutgoingMessageThrottleTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getClientOutgoingMessageThrottleFrequency()
+ */
+ public Double getClientOutgoingMessageThrottleFrequency()
+ {
+ if (clientOutgoingMessageThrottleCount > 0)
+ {
+ double runtime = differenceInMinutes(clientOutgoingMessageThrottleStart, System.currentTimeMillis());
+ return new Double(clientOutgoingMessageThrottleCount/runtime);
+ }
+ return new Double(0);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getDestinationIncomingMessageThrottleCount()
+ */
+ public Integer getDestinationIncomingMessageThrottleCount()
+ {
+ return Integer.valueOf(destinationIncomingMessageThrottleCount);
+ }
+
+ /**
+ * Increments the count of throttled incoming destination messages.
+ */
+ public void incrementDestinationIncomingMessageThrottleCount()
+ {
+ ++destinationIncomingMessageThrottleCount;
+ lastDestinationIncomingMessageThrottleTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#resetDestinationIncomingMessageThrottleCount()
+ */
+ public void resetDestinationIncomingMessageThrottleCount()
+ {
+ destinationIncomingMessageThrottleStart = System.currentTimeMillis();
+ destinationIncomingMessageThrottleCount = 0;
+ lastDestinationIncomingMessageThrottleTimestamp = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getLastDestinationIncomingMessageThrottleTimestamp()
+ */
+ public Date getLastDestinationIncomingMessageThrottleTimestamp()
+ {
+ return lastDestinationIncomingMessageThrottleTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getDestinationIncomingMessageThrottleFrequency()
+ */
+ public Double getDestinationIncomingMessageThrottleFrequency()
+ {
+ if (destinationIncomingMessageThrottleCount > 0)
+ {
+ double runtime = differenceInMinutes(destinationIncomingMessageThrottleStart, System.currentTimeMillis());
+ return new Double(destinationIncomingMessageThrottleCount/runtime);
+ }
+ return new Double(0);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getDestinationOutgoingMessageThrottleCount()
+ */
+ public Integer getDestinationOutgoingMessageThrottleCount()
+ {
+ return Integer.valueOf(destinationOutgoingMessageThrottleCount);
+ }
+
+ /**
+ * Increments the count of throttled outgoing destination messages.
+ */
+ public void incrementDestinationOutgoingMessageThrottleCount()
+ {
+ ++destinationOutgoingMessageThrottleCount;
+ lastDestinationOutgoingMessageThrottleTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#resetDestinationOutgoingMessageThrottleCount()
+ */
+ public void resetDestinationOutgoingMessageThrottleCount()
+ {
+ destinationOutgoingMessageThrottleStart = System.currentTimeMillis();
+ destinationOutgoingMessageThrottleCount = 0;
+ lastDestinationOutgoingMessageThrottleTimestamp = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.ThrottleManagerControlMBean#getLastDestinationOutgoingMessageThrottleTimestamp()
+ */
+ public Date getLastDestinationOutgoingMessageThrottleTimestamp()
+ {
+ return lastDestinationOutgoingMessageThrottleTimestamp;
+ }
+
+ public Double getDestinationOutgoingMessageThrottleFrequency()
+ {
+ if (destinationOutgoingMessageThrottleCount > 0)
+ {
+ double runtime = differenceInMinutes(destinationOutgoingMessageThrottleStart, System.currentTimeMillis());
+ return new Double(destinationOutgoingMessageThrottleCount/runtime);
+ }
+ return new Double(0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/messaging/ThrottleManagerControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/messaging/ThrottleManagerControlMBean.java b/modules/core/src/flex/management/runtime/messaging/services/messaging/ThrottleManagerControlMBean.java
old mode 100755
new mode 100644
index d28337c..d2a5983
--- a/modules/core/src/flex/management/runtime/messaging/services/messaging/ThrottleManagerControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/messaging/ThrottleManagerControlMBean.java
@@ -1,179 +1,179 @@
-/*
- * 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.management.runtime.messaging.services.messaging;
-
-import flex.management.BaseControlMBean;
-
-import java.io.IOException;
-import java.util.Date;
-
-/**
- * Defines the runtime monitoring and management interface for
- * <code>ThrottleManager</code>s.
- *
- * @author shodgson
- */
-public interface ThrottleManagerControlMBean extends BaseControlMBean
-{
- /**
- * Returns the number of incoming client messages that have been
- * throttled.
- *
- * @return The number of incoming client messages that have been
- * throttled.
- * @throws IOException Throws IOException.
- */
- Integer getClientIncomingMessageThrottleCount() throws IOException;
-
- /**
- * Resets the number of throttled incoming client messages to 0.
- *
- * @throws IOException Throws IOException.
- */
- void resetClientIncomingMessageThrottleCount() throws IOException;
-
- /**
- * Returns the timestamp when an incoming client message was
- * most recently throttled.
- *
- * @return The timestamp when an incoming client message was
- * most recently throttled.
- * @throws IOException Throws IOException.
- */
- Date getLastClientIncomingMessageThrottleTimestamp() throws IOException;
-
- /**
- * Returns the number of incoming client messages that have been
- * throttled per minute.
- *
- * @return The number of incoming client messages that have been
- * throttled per minute.
- * @throws IOException Throws IOException.
- */
- Double getClientIncomingMessageThrottleFrequency() throws IOException;
-
- /**
- * Returns the number of outgoing client messages that have been
- * throttled.
- *
- * @return The number of outgoing client messages that have been
- * throttled.
- * @throws IOException Throws IOException.
- */
- Integer getClientOutgoingMessageThrottleCount() throws IOException;
-
- /**
- * Resets the number of throttled outgoing client messages to 0.
- *
- * @throws IOException Throws IOException.
- */
- void resetClientOutgoingMessageThrottleCount() throws IOException;
-
- /**
- * Returns the timestamp when an outgoing client message was most
- * recently throttled.
- *
- * @return The timestamp when an outgoing client message was most
- * recently throttled.
- * @throws IOException Throws IOException.
- */
- Date getLastClientOutgoingMessageThrottleTimestamp() throws IOException;
-
- /**
- * Returns the number of outgoing client messages that have been
- * throttled per minute.
- *
- * @return The number of outgoing client messages that have been
- * throttled per minute.
- * @throws IOException Throws IOException.
- */
- Double getClientOutgoingMessageThrottleFrequency() throws IOException;
-
- /**
- * Returns the number of incoming destination messages that have
- * been throttled.
- *
- * @return The number of incoming destination messages that have
- * been throttled.
- * @throws IOException Throws IOException.
- */
- Integer getDestinationIncomingMessageThrottleCount() throws IOException;
-
- /**
- * Resets the number of throttled incoming destination messages to 0.
- *
- * @throws IOException Throws IOException.
- */
- void resetDestinationIncomingMessageThrottleCount() throws IOException;
-
- /**
- * Returns the timestamp when an incoming destination message was
- * most recently throttled.
- *
- * @return The timestamp when an incoming destination message was
- * most recently throttled.
- * @throws IOException Throws IOException.
- */
- Date getLastDestinationIncomingMessageThrottleTimestamp() throws IOException;
-
- /**
- * Returns the number of incoming destination messages that have
- * been throttled per minute.
- *
- * @return The number of incoming destination messages that have
- * been throttled per minute.
- * @throws IOException Throws IOException.
- */
- Double getDestinationIncomingMessageThrottleFrequency() throws IOException;
-
- /**
- * Returns the number of outgoing destination messages that have
- * been throttled.
- *
- * @return The number of outgoing destination messages that have
- * been throttled.
- * @throws IOException Throws IOException.
- */
- Integer getDestinationOutgoingMessageThrottleCount() throws IOException;
-
- /**
- * Resets the number of throttled outgoing destination messages to 0.
- *
- * @throws IOException Throws IOException.
- */
- void resetDestinationOutgoingMessageThrottleCount() throws IOException;
-
- /**
- * Returns the timestamp when an outgoing destination message was
- * most recently throttled.
- *
- * @return The timestamp when an outgoing destination message was
- * most recently throttled.
- * @throws IOException Throws IOException.
- */
- Date getLastDestinationOutgoingMessageThrottleTimestamp() throws IOException;
-
- /**
- * Returns the number of outgoing destination messages that have been
- * throttled per minute.
- *
- * @return The number of outgoing destination messages that have been
- * throttled per minute.
- * @throws IOException Throws IOException.
- */
- Double getDestinationOutgoingMessageThrottleFrequency() throws IOException;
-}
+/*
+ * 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.management.runtime.messaging.services.messaging;
+
+import flex.management.BaseControlMBean;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Defines the runtime monitoring and management interface for
+ * <code>ThrottleManager</code>s.
+ *
+ * @author shodgson
+ */
+public interface ThrottleManagerControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns the number of incoming client messages that have been
+ * throttled.
+ *
+ * @return The number of incoming client messages that have been
+ * throttled.
+ * @throws IOException Throws IOException.
+ */
+ Integer getClientIncomingMessageThrottleCount() throws IOException;
+
+ /**
+ * Resets the number of throttled incoming client messages to 0.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetClientIncomingMessageThrottleCount() throws IOException;
+
+ /**
+ * Returns the timestamp when an incoming client message was
+ * most recently throttled.
+ *
+ * @return The timestamp when an incoming client message was
+ * most recently throttled.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastClientIncomingMessageThrottleTimestamp() throws IOException;
+
+ /**
+ * Returns the number of incoming client messages that have been
+ * throttled per minute.
+ *
+ * @return The number of incoming client messages that have been
+ * throttled per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getClientIncomingMessageThrottleFrequency() throws IOException;
+
+ /**
+ * Returns the number of outgoing client messages that have been
+ * throttled.
+ *
+ * @return The number of outgoing client messages that have been
+ * throttled.
+ * @throws IOException Throws IOException.
+ */
+ Integer getClientOutgoingMessageThrottleCount() throws IOException;
+
+ /**
+ * Resets the number of throttled outgoing client messages to 0.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetClientOutgoingMessageThrottleCount() throws IOException;
+
+ /**
+ * Returns the timestamp when an outgoing client message was most
+ * recently throttled.
+ *
+ * @return The timestamp when an outgoing client message was most
+ * recently throttled.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastClientOutgoingMessageThrottleTimestamp() throws IOException;
+
+ /**
+ * Returns the number of outgoing client messages that have been
+ * throttled per minute.
+ *
+ * @return The number of outgoing client messages that have been
+ * throttled per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getClientOutgoingMessageThrottleFrequency() throws IOException;
+
+ /**
+ * Returns the number of incoming destination messages that have
+ * been throttled.
+ *
+ * @return The number of incoming destination messages that have
+ * been throttled.
+ * @throws IOException Throws IOException.
+ */
+ Integer getDestinationIncomingMessageThrottleCount() throws IOException;
+
+ /**
+ * Resets the number of throttled incoming destination messages to 0.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetDestinationIncomingMessageThrottleCount() throws IOException;
+
+ /**
+ * Returns the timestamp when an incoming destination message was
+ * most recently throttled.
+ *
+ * @return The timestamp when an incoming destination message was
+ * most recently throttled.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastDestinationIncomingMessageThrottleTimestamp() throws IOException;
+
+ /**
+ * Returns the number of incoming destination messages that have
+ * been throttled per minute.
+ *
+ * @return The number of incoming destination messages that have
+ * been throttled per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getDestinationIncomingMessageThrottleFrequency() throws IOException;
+
+ /**
+ * Returns the number of outgoing destination messages that have
+ * been throttled.
+ *
+ * @return The number of outgoing destination messages that have
+ * been throttled.
+ * @throws IOException Throws IOException.
+ */
+ Integer getDestinationOutgoingMessageThrottleCount() throws IOException;
+
+ /**
+ * Resets the number of throttled outgoing destination messages to 0.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetDestinationOutgoingMessageThrottleCount() throws IOException;
+
+ /**
+ * Returns the timestamp when an outgoing destination message was
+ * most recently throttled.
+ *
+ * @return The timestamp when an outgoing destination message was
+ * most recently throttled.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastDestinationOutgoingMessageThrottleTimestamp() throws IOException;
+
+ /**
+ * Returns the number of outgoing destination messages that have been
+ * throttled per minute.
+ *
+ * @return The number of outgoing destination messages that have been
+ * throttled per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getDestinationOutgoingMessageThrottleFrequency() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/ActionScriptAdapterControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/ActionScriptAdapterControl.java b/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/ActionScriptAdapterControl.java
old mode 100755
new mode 100644
index b1342c8..597f0b0
--- a/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/ActionScriptAdapterControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/ActionScriptAdapterControl.java
@@ -1,50 +1,50 @@
-/*
- * 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.management.runtime.messaging.services.messaging.adapters;
-
-import flex.messaging.services.messaging.adapters.ActionScriptAdapter;
-import flex.management.BaseControl;
-import flex.management.runtime.messaging.services.ServiceAdapterControl;
-
-/**
- * The <code>ActionScriptAdapterControl</code> class is the MBean implemenation
- * for monitoring and managing <code>ActionScriptAdapter</code>s at runtime.
- */
-public class ActionScriptAdapterControl extends ServiceAdapterControl implements ActionScriptAdapterControlMBean
-{
- private static final String TYPE = "ActionScriptAdapter";
-
- /**
- * Constructs a <code>ActionScriptAdapterControl</code>, assigning its id, managed
- * <code>ActionScriptAdapter</code> and parent MBean.
- *
- * @param serviceAdapter The <code>ActionScriptAdapter</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public ActionScriptAdapterControl(ActionScriptAdapter serviceAdapter, BaseControl parent)
- {
- super(serviceAdapter, parent);
- }
-
- /** {@inheritDoc} */
- public String getType()
- {
- return TYPE;
- }
-
-
-}
+/*
+ * 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.management.runtime.messaging.services.messaging.adapters;
+
+import flex.messaging.services.messaging.adapters.ActionScriptAdapter;
+import flex.management.BaseControl;
+import flex.management.runtime.messaging.services.ServiceAdapterControl;
+
+/**
+ * The <code>ActionScriptAdapterControl</code> class is the MBean implemenation
+ * for monitoring and managing <code>ActionScriptAdapter</code>s at runtime.
+ */
+public class ActionScriptAdapterControl extends ServiceAdapterControl implements ActionScriptAdapterControlMBean
+{
+ private static final String TYPE = "ActionScriptAdapter";
+
+ /**
+ * Constructs a <code>ActionScriptAdapterControl</code>, assigning its id, managed
+ * <code>ActionScriptAdapter</code> and parent MBean.
+ *
+ * @param serviceAdapter The <code>ActionScriptAdapter</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public ActionScriptAdapterControl(ActionScriptAdapter serviceAdapter, BaseControl parent)
+ {
+ super(serviceAdapter, parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getType()
+ {
+ return TYPE;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/ActionScriptAdapterControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/ActionScriptAdapterControlMBean.java b/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/ActionScriptAdapterControlMBean.java
old mode 100755
new mode 100644
index 9f7dd9a..6c7f534
--- a/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/ActionScriptAdapterControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/ActionScriptAdapterControlMBean.java
@@ -1,28 +1,28 @@
-/*
- * 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.management.runtime.messaging.services.messaging.adapters;
-
-import flex.management.runtime.messaging.services.ServiceAdapterControlMBean;
-
-/**
- * Defines the runtime monitoring and management interface for managed
- * ActionScript messaging adapters.
- */
-public interface ActionScriptAdapterControlMBean extends ServiceAdapterControlMBean
-{
- // empty for now
-}
+/*
+ * 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.management.runtime.messaging.services.messaging.adapters;
+
+import flex.management.runtime.messaging.services.ServiceAdapterControlMBean;
+
+/**
+ * Defines the runtime monitoring and management interface for managed
+ * ActionScript messaging adapters.
+ */
+public interface ActionScriptAdapterControlMBean extends ServiceAdapterControlMBean
+{
+ // empty for now
+}
[35/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControl.java
old mode 100755
new mode 100644
index 7cdbb74..de4db0f
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControl.java
@@ -1,72 +1,72 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-import flex.management.BaseControl;
-import flex.management.runtime.AdminConsoleTypes;
-import flex.messaging.endpoints.BasePollingHTTPEndpoint;
-
-/**
- * The <tt>PollingEndpointControl</tt> class is the base MBean implementation
- * for monitoring and managing a <tt>BasePollingHTTPEndpoint</tt> at runtime.
- */
-public abstract class PollingEndpointControl extends EndpointControl implements
- PollingEndpointControlMBean
-{
- /**
- * Constructs a <tt>PollingEndpointControl</tt>, assigning managed message
- * endpoint and parent MBean.
- *
- * @param endpoint The <code>BasePollingHTTPEndpoint</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public PollingEndpointControl(BasePollingHTTPEndpoint endpoint, BaseControl parent)
- {
- super(endpoint, parent);
- }
-
- protected void onRegistrationComplete()
- {
- super.onRegistrationComplete();
-
- String name = this.getObjectName().getCanonicalName();
- String[] generalPollables = {"WaitingPollRequestsCount"};
-
- getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_POLLABLE, name, generalPollables);
- getRegistrar().registerObject(AdminConsoleTypes.ENDPOINT_SCALAR, name, "MaxWaitingPollRequests");
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.endpoints.PollingEndpointControlMBean#getMaxWaitingPollRequests()
- */
- public Integer getMaxWaitingPollRequests()
- {
- int maxWaitingPollRequests = ((BasePollingHTTPEndpoint)endpoint).getMaxWaitingPollRequests();
- return new Integer(maxWaitingPollRequests);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.endpoints.PollingEndpointControlMBean#getWaitingPollRequestsCount()
- */
- public Integer getWaitingPollRequestsCount()
- {
- int waitingPollRequestsCount = ((BasePollingHTTPEndpoint)endpoint).getWaitingPollRequestsCount();
- return new Integer(waitingPollRequestsCount);
- }
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.messaging.endpoints.BasePollingHTTPEndpoint;
+
+/**
+ * The <tt>PollingEndpointControl</tt> class is the base MBean implementation
+ * for monitoring and managing a <tt>BasePollingHTTPEndpoint</tt> at runtime.
+ */
+public abstract class PollingEndpointControl extends EndpointControl implements
+ PollingEndpointControlMBean
+{
+ /**
+ * Constructs a <tt>PollingEndpointControl</tt>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>BasePollingHTTPEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public PollingEndpointControl(BasePollingHTTPEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ protected void onRegistrationComplete()
+ {
+ super.onRegistrationComplete();
+
+ String name = this.getObjectName().getCanonicalName();
+ String[] generalPollables = {"WaitingPollRequestsCount"};
+
+ getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_POLLABLE, name, generalPollables);
+ getRegistrar().registerObject(AdminConsoleTypes.ENDPOINT_SCALAR, name, "MaxWaitingPollRequests");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.PollingEndpointControlMBean#getMaxWaitingPollRequests()
+ */
+ public Integer getMaxWaitingPollRequests()
+ {
+ int maxWaitingPollRequests = ((BasePollingHTTPEndpoint)endpoint).getMaxWaitingPollRequests();
+ return new Integer(maxWaitingPollRequests);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.PollingEndpointControlMBean#getWaitingPollRequestsCount()
+ */
+ public Integer getWaitingPollRequestsCount()
+ {
+ int waitingPollRequestsCount = ((BasePollingHTTPEndpoint)endpoint).getWaitingPollRequestsCount();
+ return new Integer(waitingPollRequestsCount);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControlMBean.java
old mode 100755
new mode 100644
index 016b276..2c30b49
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControlMBean.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.management.runtime.messaging.endpoints;
-
-import java.io.IOException;
-
-/**
- * Defines the runtime monitoring and management interface for managed polling
- * endpoints.
- */
-public interface PollingEndpointControlMBean extends EndpointControlMBean
-{
- /**
- * Returns the maximum number of server poll response threads that will be
- * waiting for messages to arrive for clients.
- *
- * @return The maximum number of server poll response threads that will be
- * waiting for messages to arrive for clients.
- * @throws IOException Throws IOException.
- */
- Integer getMaxWaitingPollRequests() throws IOException;
-
- /**
- * Returns the number of request threads that are currently in the wait state
- * (including those on their way into or out of it).
- *
- * @return The number of request threads that are currently in the wait state.
- * @throws IOException Throws IOException.
- */
- Integer getWaitingPollRequestsCount() throws IOException;
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+import java.io.IOException;
+
+/**
+ * Defines the runtime monitoring and management interface for managed polling
+ * endpoints.
+ */
+public interface PollingEndpointControlMBean extends EndpointControlMBean
+{
+ /**
+ * Returns the maximum number of server poll response threads that will be
+ * waiting for messages to arrive for clients.
+ *
+ * @return The maximum number of server poll response threads that will be
+ * waiting for messages to arrive for clients.
+ * @throws IOException Throws IOException.
+ */
+ Integer getMaxWaitingPollRequests() throws IOException;
+
+ /**
+ * Returns the number of request threads that are currently in the wait state
+ * (including those on their way into or out of it).
+ *
+ * @return The number of request threads that are currently in the wait state.
+ * @throws IOException Throws IOException.
+ */
+ Integer getWaitingPollRequestsCount() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControl.java
old mode 100755
new mode 100644
index 15b29bc..00d7022
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControl.java
@@ -1,48 +1,48 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-import flex.management.BaseControl;
-import flex.messaging.endpoints.StreamingAMFEndpoint;
-
-/**
- * The <code>StreamingAMFEndpointControl</code> class is the MBean implemenation
- * for monitoring and managing an <code>StreamingAMFEndpoint</code> at runtime.
- */
-public class StreamingAMFEndpointControl extends StreamingEndpointControl implements
- StreamingAMFEndpointControlMBean
-{
- private static final String TYPE = "StreamingAMFEndpoint";
-
- /**
- * Constructs a <code>StreamingAMFEndpointControl</code>, assigning managed message
- * endpoint and parent MBean.
- *
- * @param endpoint The <code>StreamingAMFEndpoint</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public StreamingAMFEndpointControl(StreamingAMFEndpoint endpoint, BaseControl parent)
- {
- super(endpoint, parent);
- }
-
- /** {@inheritDoc} */
- public String getType()
- {
- return TYPE;
- }
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.messaging.endpoints.StreamingAMFEndpoint;
+
+/**
+ * The <code>StreamingAMFEndpointControl</code> class is the MBean implemenation
+ * for monitoring and managing an <code>StreamingAMFEndpoint</code> at runtime.
+ */
+public class StreamingAMFEndpointControl extends StreamingEndpointControl implements
+ StreamingAMFEndpointControlMBean
+{
+ private static final String TYPE = "StreamingAMFEndpoint";
+
+ /**
+ * Constructs a <code>StreamingAMFEndpointControl</code>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>StreamingAMFEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public StreamingAMFEndpointControl(StreamingAMFEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getType()
+ {
+ return TYPE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControlMBean.java
old mode 100755
new mode 100644
index fffa29b..32d05b9
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControlMBean.java
@@ -1,26 +1,26 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-/**
- * Defines the runtime monitoring and management interface for managed streaming
- * AMF endpoints.
- */
-public interface StreamingAMFEndpointControlMBean extends StreamingEndpointControlMBean
-{
- // Empty for now
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+/**
+ * Defines the runtime monitoring and management interface for managed streaming
+ * AMF endpoints.
+ */
+public interface StreamingAMFEndpointControlMBean extends StreamingEndpointControlMBean
+{
+ // Empty for now
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControl.java
old mode 100755
new mode 100644
index 1d50bb8..b3cdc64
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControl.java
@@ -1,133 +1,133 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-import java.util.Date;
-
-import flex.management.BaseControl;
-import flex.management.runtime.AdminConsoleTypes;
-import flex.messaging.endpoints.BaseStreamingHTTPEndpoint;
-
-/**
- * The <code>StreamingEndpointControl</code> class is the base MBean implementation
- * for monitoring and managing a <code>BaseStreamingHTTPEndpoint</code> at runtime.
- */
-public abstract class StreamingEndpointControl extends EndpointControl implements
- StreamingEndpointControlMBean
-{
- private int pushCount;
- private Date lastPushTimeStamp;
- private long pushStart;
-
- /**
- * Constructs a <code>StreamingEndpointControl</code>, assigning managed message
- * endpoint and parent MBean.
- *
- * @param endpoint The <code>BaseStreamingHTTPEndpoint</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public StreamingEndpointControl(BaseStreamingHTTPEndpoint endpoint, BaseControl parent)
- {
- super(endpoint, parent);
- }
-
- protected void onRegistrationComplete()
- {
- super.onRegistrationComplete();
-
- String name = this.getObjectName().getCanonicalName();
- String[] generalPollables = { "LastPushTimestamp", "PushCount", "PushFrequency", "StreamingClientsCount"};
-
- getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_POLLABLE, name, generalPollables);
- getRegistrar().registerObject(AdminConsoleTypes.ENDPOINT_SCALAR, name, "MaxStreamingClients");
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getMaxStreamingClients()
- */
- public Integer getMaxStreamingClients()
- {
- int maxStreamingClientsCount = ((BaseStreamingHTTPEndpoint)endpoint).getMaxStreamingClients();
- return new Integer(maxStreamingClientsCount);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getPushCount()
- */
- public Integer getPushCount()
- {
- return new Integer(pushCount);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#resetPushCount()
- */
- public void resetPushCount()
- {
- pushStart = System.currentTimeMillis();
- pushCount = 0;
- lastPushTimeStamp = null;
- }
-
- /**
- * Increments the count of messages pushed by the endpoint.
- */
- public void incrementPushCount()
- {
- ++pushCount;
- lastPushTimeStamp = new Date();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getLastPushTimestamp()
- */
- public Date getLastPushTimestamp()
- {
- return lastPushTimeStamp;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getPushFrequency()
- */
- public Double getPushFrequency()
- {
- if (pushCount > 0)
- {
- double runtime = differenceInMinutes(pushStart, System.currentTimeMillis());
- return new Double(pushCount/runtime);
- }
- else
- {
- return new Double(0);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#isRunning()
- */
- public Integer getStreamingClientsCount()
- {
- int streamingClientsCount = ((BaseStreamingHTTPEndpoint)endpoint).getStreamingClientsCount();
- return new Integer(streamingClientsCount);
- }
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+import java.util.Date;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.messaging.endpoints.BaseStreamingHTTPEndpoint;
+
+/**
+ * The <code>StreamingEndpointControl</code> class is the base MBean implementation
+ * for monitoring and managing a <code>BaseStreamingHTTPEndpoint</code> at runtime.
+ */
+public abstract class StreamingEndpointControl extends EndpointControl implements
+ StreamingEndpointControlMBean
+{
+ private int pushCount;
+ private Date lastPushTimeStamp;
+ private long pushStart;
+
+ /**
+ * Constructs a <code>StreamingEndpointControl</code>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>BaseStreamingHTTPEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public StreamingEndpointControl(BaseStreamingHTTPEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ protected void onRegistrationComplete()
+ {
+ super.onRegistrationComplete();
+
+ String name = this.getObjectName().getCanonicalName();
+ String[] generalPollables = { "LastPushTimestamp", "PushCount", "PushFrequency", "StreamingClientsCount"};
+
+ getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_POLLABLE, name, generalPollables);
+ getRegistrar().registerObject(AdminConsoleTypes.ENDPOINT_SCALAR, name, "MaxStreamingClients");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getMaxStreamingClients()
+ */
+ public Integer getMaxStreamingClients()
+ {
+ int maxStreamingClientsCount = ((BaseStreamingHTTPEndpoint)endpoint).getMaxStreamingClients();
+ return new Integer(maxStreamingClientsCount);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getPushCount()
+ */
+ public Integer getPushCount()
+ {
+ return new Integer(pushCount);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#resetPushCount()
+ */
+ public void resetPushCount()
+ {
+ pushStart = System.currentTimeMillis();
+ pushCount = 0;
+ lastPushTimeStamp = null;
+ }
+
+ /**
+ * Increments the count of messages pushed by the endpoint.
+ */
+ public void incrementPushCount()
+ {
+ ++pushCount;
+ lastPushTimeStamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getLastPushTimestamp()
+ */
+ public Date getLastPushTimestamp()
+ {
+ return lastPushTimeStamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getPushFrequency()
+ */
+ public Double getPushFrequency()
+ {
+ if (pushCount > 0)
+ {
+ double runtime = differenceInMinutes(pushStart, System.currentTimeMillis());
+ return new Double(pushCount/runtime);
+ }
+ else
+ {
+ return new Double(0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#isRunning()
+ */
+ public Integer getStreamingClientsCount()
+ {
+ int streamingClientsCount = ((BaseStreamingHTTPEndpoint)endpoint).getStreamingClientsCount();
+ return new Integer(streamingClientsCount);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControlMBean.java
old mode 100755
new mode 100644
index 69c6409..b8c684e
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControlMBean.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 flex.management.runtime.messaging.endpoints;
-
-import java.io.IOException;
-import java.util.Date;
-
-/**
- * Defines the runtime monitoring and management interface for managed streaming
- * endpoints.
- */
-public interface StreamingEndpointControlMBean extends EndpointControlMBean
-{
- /**
- * Returns the maximum number of clients that will be allowed to establish
- * a streaming HTTP connection with the endpoint.
- *
- * @return The maximum number of clients that will be allowed to establish
- * a streaming HTTP connection with the endpoint.
- * @throws IOException Throws IOException.
- */
- Integer getMaxStreamingClients() throws IOException;
-
- /**
- * Returns the count of push invocations.
- *
- * @return The count of push invocations.
- * @throws IOException Throws IOException.
- */
- Integer getPushCount() throws IOException;
-
- /**
- * Resets the count of push invocations.
- *
- * @throws IOException Throws IOException.
- */
- void resetPushCount() throws IOException;
-
- /**
- * Returns the timestamp for the most recent push invocation.
- *
- * @return The timestamp for the most recent push invocation.
- * @throws IOException Throws IOException.
- */
- Date getLastPushTimestamp() throws IOException;
-
- /**
- * Returns the number of push invocations per minute.
- *
- * @return The number of push invocations per minute.
- * @throws IOException Throws IOException.
- */
- Double getPushFrequency() throws IOException;
-
- /**
- * Returns the the number of clients that are currently in the streaming state.
- *
- * @return The number of clients that are currently in the streaming state.
- * @throws IOException Throws IOException.
- */
- Integer getStreamingClientsCount() throws IOException;
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Defines the runtime monitoring and management interface for managed streaming
+ * endpoints.
+ */
+public interface StreamingEndpointControlMBean extends EndpointControlMBean
+{
+ /**
+ * Returns the maximum number of clients that will be allowed to establish
+ * a streaming HTTP connection with the endpoint.
+ *
+ * @return The maximum number of clients that will be allowed to establish
+ * a streaming HTTP connection with the endpoint.
+ * @throws IOException Throws IOException.
+ */
+ Integer getMaxStreamingClients() throws IOException;
+
+ /**
+ * Returns the count of push invocations.
+ *
+ * @return The count of push invocations.
+ * @throws IOException Throws IOException.
+ */
+ Integer getPushCount() throws IOException;
+
+ /**
+ * Resets the count of push invocations.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetPushCount() throws IOException;
+
+ /**
+ * Returns the timestamp for the most recent push invocation.
+ *
+ * @return The timestamp for the most recent push invocation.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastPushTimestamp() throws IOException;
+
+ /**
+ * Returns the number of push invocations per minute.
+ *
+ * @return The number of push invocations per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getPushFrequency() throws IOException;
+
+ /**
+ * Returns the the number of clients that are currently in the streaming state.
+ *
+ * @return The number of clients that are currently in the streaming state.
+ * @throws IOException Throws IOException.
+ */
+ Integer getStreamingClientsCount() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControl.java
old mode 100755
new mode 100644
index 1ce6d5d..a103b95
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControl.java
@@ -1,48 +1,48 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-import flex.management.BaseControl;
-import flex.messaging.endpoints.StreamingHTTPEndpoint;
-
-/**
- * The <code>StreamingHTTPEndpointControl</code> class is the MBean implemenation
- * for monitoring and managing a <code>StreamingHTTPEndpoint</code> at runtime.
- */
-public class StreamingHTTPEndpointControl extends StreamingEndpointControl implements
- StreamingHTTPEndpointControlMBean
-{
- private static final String TYPE = "StreamingHTTPEndpoint";
-
- /**
- * Constructs a <code>StreamingHTTPEndpointControl</code>, assigning managed message
- * endpoint and parent MBean.
- *
- * @param endpoint The <code>StreamingHTTPEndpoint</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public StreamingHTTPEndpointControl(StreamingHTTPEndpoint endpoint, BaseControl parent)
- {
- super(endpoint, parent);
- }
-
- /** {@inheritDoc} */
- public String getType()
- {
- return TYPE;
- }
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.messaging.endpoints.StreamingHTTPEndpoint;
+
+/**
+ * The <code>StreamingHTTPEndpointControl</code> class is the MBean implemenation
+ * for monitoring and managing a <code>StreamingHTTPEndpoint</code> at runtime.
+ */
+public class StreamingHTTPEndpointControl extends StreamingEndpointControl implements
+ StreamingHTTPEndpointControlMBean
+{
+ private static final String TYPE = "StreamingHTTPEndpoint";
+
+ /**
+ * Constructs a <code>StreamingHTTPEndpointControl</code>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>StreamingHTTPEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public StreamingHTTPEndpointControl(StreamingHTTPEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getType()
+ {
+ return TYPE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControlMBean.java
old mode 100755
new mode 100644
index 449253a..f17cb85
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControlMBean.java
@@ -1,26 +1,26 @@
-/*
- * 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.management.runtime.messaging.endpoints;
-
-/**
- * Defines the runtime monitoring and management interface for managed streaming
- * HTTP endpoints.
- */
-public interface StreamingHTTPEndpointControlMBean extends StreamingEndpointControlMBean
-{
- // Empty for now
-}
+/*
+ * 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.management.runtime.messaging.endpoints;
+
+/**
+ * Defines the runtime monitoring and management interface for managed streaming
+ * HTTP endpoints.
+ */
+public interface StreamingHTTPEndpointControlMBean extends StreamingEndpointControlMBean
+{
+ // Empty for now
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/endpoints/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/package-info.java b/modules/core/src/flex/management/runtime/messaging/endpoints/package-info.java
old mode 100755
new mode 100644
index c04121d..0936f70
--- a/modules/core/src/flex/management/runtime/messaging/endpoints/package-info.java
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/package-info.java
@@ -1,17 +1,17 @@
-/*
- * 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.management.runtime.messaging.endpoints;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/log/LogControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/log/LogControl.java b/modules/core/src/flex/management/runtime/messaging/log/LogControl.java
old mode 100755
new mode 100644
index ab26864..3fdbbde
--- a/modules/core/src/flex/management/runtime/messaging/log/LogControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/log/LogControl.java
@@ -1,149 +1,149 @@
-/*
- * 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.management.runtime.messaging.log;
-
-import flex.management.BaseControl;
-import flex.messaging.log.AbstractTarget;
-import flex.messaging.log.Log;
-import flex.messaging.log.Target;
-
-/**
- * The <code>LogControl</code> class is the MBean implemenation
- * for monitoring and managing a <code>Log</code> at runtime through the <code>LogManager</code>.
- * @author majacobs
- *
- */
-public class LogControl extends BaseControl implements
- LogControlMBean
-{
-
- private static final String TYPE = "Log"; // The type registered with the mbean server
- private LogManager logManager; // Reference to the LogManager which interfaces with Log
-
-
- /**
- * Creates the mbean and registers it with the mbean server.
- *
- * @param parent BaseControl
- * @param manager A reference to the LogManager
- */
- public LogControl(BaseControl parent, LogManager manager)
- {
- super(parent);
- this.logManager = manager;
- register();
- }
-
-
- /**
- * Sets the logging level for the target associated with the unique ID searchId.
- * @param searchId the search ID
- * @param level the log level
- */
- public void changeTargetLevel(String searchId, String level)
- {
- Target selectedTarget = Log.getTarget(searchId);
- if (selectedTarget != null)
- {
- selectedTarget.setLevel(new Short(level).shortValue());
- }
- }
-
- /* (non-Javadoc)
- * @see flex.management.BaseControl#getId()
- */
- public String getId()
- {
- return logManager.getId();
- }
-
- /* (non-Javadoc)
- * @see flex.management.BaseControl#getType()
- */
- public String getType()
- {
- return TYPE;
- }
-
- /**
- * Return a string array of the loggers.
- * @return a string array of loggers
- */
- public String[] getLoggers()
- {
- return logManager.getLoggers();
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.log.LogControlMBean#getTargets()
- */
- public String[] getTargets()
- {
- return logManager.getTargetIds();
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.log.LogControlMBean#addFilterForTarget(java.lang.String, java.lang.String)
- */
- public void addFilterForTarget(String targetId, String filter)
- {
- AbstractTarget target = (AbstractTarget) logManager.getTarget(targetId);
-
- if (target != null && logManager.checkFilter(filter))
- target.addFilter(filter);
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.log.LogControlMBean#getTargetFilters(java.lang.String)
- */
- public String[] getTargetFilters(String targetId)
- {
- return logManager.getTargetFilters(targetId);
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.log.LogControlMBean#removeFilterForTarget(java.lang.String, java.lang.String)
- */
- public void removeFilterForTarget(String targetId, String filter)
- {
- AbstractTarget target = (AbstractTarget) logManager.getTarget(targetId);
-
- if (target != null && target.containsFilter(filter))
- target.removeFilter(filter);
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.log.LogControlMBean#getCategories()
- */
- public String[] getCategories()
- {
- return (String[]) logManager.getCategories().toArray(new String[0]);
- }
-
-
- public Integer getTargetLevel(String searchId)
- {
- AbstractTarget target = (AbstractTarget) logManager.getTarget(searchId);
-
- if (target != null)
- {
- return new Integer(target.getLevel());
- } else
- return new Integer(-1);
- }
-
-}
+/*
+ * 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.management.runtime.messaging.log;
+
+import flex.management.BaseControl;
+import flex.messaging.log.AbstractTarget;
+import flex.messaging.log.Log;
+import flex.messaging.log.Target;
+
+/**
+ * The <code>LogControl</code> class is the MBean implemenation
+ * for monitoring and managing a <code>Log</code> at runtime through the <code>LogManager</code>.
+ * @author majacobs
+ *
+ */
+public class LogControl extends BaseControl implements
+ LogControlMBean
+{
+
+ private static final String TYPE = "Log"; // The type registered with the mbean server
+ private LogManager logManager; // Reference to the LogManager which interfaces with Log
+
+
+ /**
+ * Creates the mbean and registers it with the mbean server.
+ *
+ * @param parent BaseControl
+ * @param manager A reference to the LogManager
+ */
+ public LogControl(BaseControl parent, LogManager manager)
+ {
+ super(parent);
+ this.logManager = manager;
+ register();
+ }
+
+
+ /**
+ * Sets the logging level for the target associated with the unique ID searchId.
+ * @param searchId the search ID
+ * @param level the log level
+ */
+ public void changeTargetLevel(String searchId, String level)
+ {
+ Target selectedTarget = Log.getTarget(searchId);
+ if (selectedTarget != null)
+ {
+ selectedTarget.setLevel(new Short(level).shortValue());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.BaseControl#getId()
+ */
+ public String getId()
+ {
+ return logManager.getId();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.BaseControl#getType()
+ */
+ public String getType()
+ {
+ return TYPE;
+ }
+
+ /**
+ * Return a string array of the loggers.
+ * @return a string array of loggers
+ */
+ public String[] getLoggers()
+ {
+ return logManager.getLoggers();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.log.LogControlMBean#getTargets()
+ */
+ public String[] getTargets()
+ {
+ return logManager.getTargetIds();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.log.LogControlMBean#addFilterForTarget(java.lang.String, java.lang.String)
+ */
+ public void addFilterForTarget(String targetId, String filter)
+ {
+ AbstractTarget target = (AbstractTarget) logManager.getTarget(targetId);
+
+ if (target != null && logManager.checkFilter(filter))
+ target.addFilter(filter);
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.log.LogControlMBean#getTargetFilters(java.lang.String)
+ */
+ public String[] getTargetFilters(String targetId)
+ {
+ return logManager.getTargetFilters(targetId);
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.log.LogControlMBean#removeFilterForTarget(java.lang.String, java.lang.String)
+ */
+ public void removeFilterForTarget(String targetId, String filter)
+ {
+ AbstractTarget target = (AbstractTarget) logManager.getTarget(targetId);
+
+ if (target != null && target.containsFilter(filter))
+ target.removeFilter(filter);
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.log.LogControlMBean#getCategories()
+ */
+ public String[] getCategories()
+ {
+ return (String[]) logManager.getCategories().toArray(new String[0]);
+ }
+
+
+ public Integer getTargetLevel(String searchId)
+ {
+ AbstractTarget target = (AbstractTarget) logManager.getTarget(searchId);
+
+ if (target != null)
+ {
+ return new Integer(target.getLevel());
+ } else
+ return new Integer(-1);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/log/LogControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/log/LogControlMBean.java b/modules/core/src/flex/management/runtime/messaging/log/LogControlMBean.java
old mode 100755
new mode 100644
index b4b129f..762c895
--- a/modules/core/src/flex/management/runtime/messaging/log/LogControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/log/LogControlMBean.java
@@ -1,80 +1,80 @@
-/*
- * 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.management.runtime.messaging.log;
-
-import flex.management.BaseControlMBean;
-
-
-/**
- * Defines the exposed properties and operations of the LogControl.
- */
-public interface LogControlMBean extends BaseControlMBean
-{
- /**
- * Returns the array of log targets.
- *
- * @return The array of log targets.
- */
- String[] getTargets();
-
- /**
- * Returns the array of log target filters.
- *
- * @param targetId The target id.
- * @return The array of log target filters.
- */
- String[] getTargetFilters(String targetId);
-
- /**
- * Returns the array of log categories.
- *
- * @return The array of log categories.
- */
- String[] getCategories();
-
- /**
- * Returns the target level.
- *
- * @param targetId The target id.
- * @return The target level.
- */
- Integer getTargetLevel(String targetId);
-
- /**
- * Changes the target level.
- *
- * @param targetId The target id.
- * @param level The target level.
- */
- void changeTargetLevel(String targetId, String level);
-
- /**
- * Adds a filter for the target.
- *
- * @param filter The filter.
- * @param targetId The target id.
- */
- void addFilterForTarget(String filter, String targetId);
-
- /**
- * Removes a filter from the target.
- *
- * @param filter The filter.
- * @param targetId The target id.
- */
- void removeFilterForTarget(String filter, String targetId);
-}
+/*
+ * 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.management.runtime.messaging.log;
+
+import flex.management.BaseControlMBean;
+
+
+/**
+ * Defines the exposed properties and operations of the LogControl.
+ */
+public interface LogControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns the array of log targets.
+ *
+ * @return The array of log targets.
+ */
+ String[] getTargets();
+
+ /**
+ * Returns the array of log target filters.
+ *
+ * @param targetId The target id.
+ * @return The array of log target filters.
+ */
+ String[] getTargetFilters(String targetId);
+
+ /**
+ * Returns the array of log categories.
+ *
+ * @return The array of log categories.
+ */
+ String[] getCategories();
+
+ /**
+ * Returns the target level.
+ *
+ * @param targetId The target id.
+ * @return The target level.
+ */
+ Integer getTargetLevel(String targetId);
+
+ /**
+ * Changes the target level.
+ *
+ * @param targetId The target id.
+ * @param level The target level.
+ */
+ void changeTargetLevel(String targetId, String level);
+
+ /**
+ * Adds a filter for the target.
+ *
+ * @param filter The filter.
+ * @param targetId The target id.
+ */
+ void addFilterForTarget(String filter, String targetId);
+
+ /**
+ * Removes a filter from the target.
+ *
+ * @param filter The filter.
+ * @param targetId The target id.
+ */
+ void removeFilterForTarget(String filter, String targetId);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/log/LogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/log/LogManager.java b/modules/core/src/flex/management/runtime/messaging/log/LogManager.java
old mode 100755
new mode 100644
index d6b72bc..d9c40fc
--- a/modules/core/src/flex/management/runtime/messaging/log/LogManager.java
+++ b/modules/core/src/flex/management/runtime/messaging/log/LogManager.java
@@ -1,266 +1,266 @@
-/*
- * 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.management.runtime.messaging.log;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.lang.reflect.Field;
-
-import flex.management.ManageableComponent;
-import flex.messaging.config.ConfigurationException;
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.log.Target;
-
-
-/**
- * The LogManager is an interface between the Log and the LogControl which exists
- * because Log lives in the common package, so it cannot extend ManageableComponent itself,
- * which is necessary for a class to be exposed through MBeans.
- *
- * @author majacobs
- *
- */
-public class LogManager extends ManageableComponent
-{
-
- private static final String LOG_CATEGORY = LogCategories.CONFIGURATION; // Log category used by LogManager (ManageableComponent)
- private static final int NULL_LOG_REF_EXCEPTION = 10031;
-
- private Log log;
- private String ID = "log";
- private CategoryManager categoryManager;
- private LogControl controller;
-
- private boolean isSetup;
-
- /**
- * Public constructor required by ManageableComponent.
- */
- public LogManager()
- {
- this(true);
- }
-
- public LogManager(boolean enableManagement)
- {
- super(enableManagement);
- setId(ID);
-
- categoryManager = new CategoryManager();
-
- }
-
-
- public void setupLogControl()
- {
- if (!isSetup)
- {
- controller = new LogControl(getParent().getControl(), this);
- setControl(controller);
- controller.register();
- isSetup = true;
- }
- }
-
- public void stop()
- {
- if (!isStarted())
- {
- return;
- }
-
-
- super.stop();
-
- // Remove management
- if (isManaged())
- {
- if (getControl() != null)
- {
- getControl().unregister();
- setControl(null);
- }
- setManaged(false);
- }
- }
-
- public void setLog(Log logInstance)
- {
- log = logInstance;
- }
-
- /* (non-Javadoc)
- * @see flex.management.ManageableComponent#getLogCategory()
- */
- protected String getLogCategory()
- {
- return LOG_CATEGORY;
- }
-
- /**
- * Gets the Loggers as a string array.
- * @return a String array
- */
- public String[] getLoggers()
- {
- return log.getLoggers();
- }
-
- /**
- * Gets the Target IDs.
- * @return a string array
- */
- public String[] getTargetIds()
- {
- return (String[]) Log.getTargetMap().keySet().toArray(new String[0]);
- }
-
- /**
- * Get a Target for a targetId.
- *
- * @param targetId the target ID
- * @return the target from the Log, or null if it is not found
- */
- public Target getTarget(String targetId)
- {
- return (Target) Log.getTargetMap().get(targetId);
- }
-
- /**
- * Gets the filters for a given target.
- * @param targetId the target ID
- * @return a string array
- */
- public String[] getTargetFilters(String targetId)
- {
-
- Target target = getTarget(targetId);
-
- if (target == null)
- return new String[0];
-
- List filterObjects = target.getFilters();
- String[] filters = new String[filterObjects.size()];
- for (int i = 0; i < filterObjects.size(); i++)
- {
- filters[i] = (String)filterObjects.get(i);
- }
-
- return filters;
- }
-
- /**
- * Check whether a filter is valid.
- * @param filter the filter string to check
- * @return whether the category exists in LogCategories
- */
- public boolean checkFilter(String filter)
- {
- return categoryManager.checkFilter(filter);
- }
-
- /**
- * Return a list of categories in LogCategories.
- * @return the list of categories in LogCategories
- */
- public List getCategories()
- {
- return categoryManager.getCategories();
- }
-
- protected void validate()
- {
- if (isValid())
- return;
-
- super.validate();
-
- if (log == null)
- {
- invalidate();
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(NULL_LOG_REF_EXCEPTION, new Object[]{});
- throw ex;
- }
-
- }
-
- /**
- * This private class keeps track of what categories exist in LogCategories by implementing
- * LogCategories and reflecting the interface's properties.
- *
- * @author majacobs
- *
- */
- private class CategoryManager implements LogCategories
- {
- private List categories;
-
- /**
- * Construct an ArrayList for each category in the reflected public properties
- * Note this will be incorrect if additional public properties are added to this class
- * or to the interface LogCategories.
- */
- public CategoryManager()
- {
- categories = new ArrayList();
-
- Field[] categoryFields = this.getClass().getFields();
- for (int i = 0; i < categoryFields.length; i++)
- {
- try
- {
- categories.add((String)categoryFields[i].get(this));
- }
- catch (IllegalAccessException iae)
- {
- // Illegal Access on reflection
- }
- }
- }
-
-
- /**
- * Check if any categories match with the filter (the filter is valid or not).
- * @param filter the filter string to check
- * @return whether the filter is valid (with or without a trailing .*)
- */
- public boolean checkFilter(String filter)
- {
-
- for (int i = 0; i < categories.size(); i++)
- {
- if (Log.checkFilterToCategory((String)filter, (String)categories.get(i)))
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return a list of log categories.
- * @return List a list of the categories
- */
- public List getCategories()
- {
- return Collections.unmodifiableList(new ArrayList(categories));
- }
- }
-}
+/*
+ * 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.management.runtime.messaging.log;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.lang.reflect.Field;
+
+import flex.management.ManageableComponent;
+import flex.messaging.config.ConfigurationException;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.log.Target;
+
+
+/**
+ * The LogManager is an interface between the Log and the LogControl which exists
+ * because Log lives in the common package, so it cannot extend ManageableComponent itself,
+ * which is necessary for a class to be exposed through MBeans.
+ *
+ * @author majacobs
+ *
+ */
+public class LogManager extends ManageableComponent
+{
+
+ private static final String LOG_CATEGORY = LogCategories.CONFIGURATION; // Log category used by LogManager (ManageableComponent)
+ private static final int NULL_LOG_REF_EXCEPTION = 10031;
+
+ private Log log;
+ private String ID = "log";
+ private CategoryManager categoryManager;
+ private LogControl controller;
+
+ private boolean isSetup;
+
+ /**
+ * Public constructor required by ManageableComponent.
+ */
+ public LogManager()
+ {
+ this(true);
+ }
+
+ public LogManager(boolean enableManagement)
+ {
+ super(enableManagement);
+ setId(ID);
+
+ categoryManager = new CategoryManager();
+
+ }
+
+
+ public void setupLogControl()
+ {
+ if (!isSetup)
+ {
+ controller = new LogControl(getParent().getControl(), this);
+ setControl(controller);
+ controller.register();
+ isSetup = true;
+ }
+ }
+
+ public void stop()
+ {
+ if (!isStarted())
+ {
+ return;
+ }
+
+
+ super.stop();
+
+ // Remove management
+ if (isManaged())
+ {
+ if (getControl() != null)
+ {
+ getControl().unregister();
+ setControl(null);
+ }
+ setManaged(false);
+ }
+ }
+
+ public void setLog(Log logInstance)
+ {
+ log = logInstance;
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.ManageableComponent#getLogCategory()
+ */
+ protected String getLogCategory()
+ {
+ return LOG_CATEGORY;
+ }
+
+ /**
+ * Gets the Loggers as a string array.
+ * @return a String array
+ */
+ public String[] getLoggers()
+ {
+ return log.getLoggers();
+ }
+
+ /**
+ * Gets the Target IDs.
+ * @return a string array
+ */
+ public String[] getTargetIds()
+ {
+ return (String[]) Log.getTargetMap().keySet().toArray(new String[0]);
+ }
+
+ /**
+ * Get a Target for a targetId.
+ *
+ * @param targetId the target ID
+ * @return the target from the Log, or null if it is not found
+ */
+ public Target getTarget(String targetId)
+ {
+ return (Target) Log.getTargetMap().get(targetId);
+ }
+
+ /**
+ * Gets the filters for a given target.
+ * @param targetId the target ID
+ * @return a string array
+ */
+ public String[] getTargetFilters(String targetId)
+ {
+
+ Target target = getTarget(targetId);
+
+ if (target == null)
+ return new String[0];
+
+ List filterObjects = target.getFilters();
+ String[] filters = new String[filterObjects.size()];
+ for (int i = 0; i < filterObjects.size(); i++)
+ {
+ filters[i] = (String)filterObjects.get(i);
+ }
+
+ return filters;
+ }
+
+ /**
+ * Check whether a filter is valid.
+ * @param filter the filter string to check
+ * @return whether the category exists in LogCategories
+ */
+ public boolean checkFilter(String filter)
+ {
+ return categoryManager.checkFilter(filter);
+ }
+
+ /**
+ * Return a list of categories in LogCategories.
+ * @return the list of categories in LogCategories
+ */
+ public List getCategories()
+ {
+ return categoryManager.getCategories();
+ }
+
+ protected void validate()
+ {
+ if (isValid())
+ return;
+
+ super.validate();
+
+ if (log == null)
+ {
+ invalidate();
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(NULL_LOG_REF_EXCEPTION, new Object[]{});
+ throw ex;
+ }
+
+ }
+
+ /**
+ * This private class keeps track of what categories exist in LogCategories by implementing
+ * LogCategories and reflecting the interface's properties.
+ *
+ * @author majacobs
+ *
+ */
+ private class CategoryManager implements LogCategories
+ {
+ private List categories;
+
+ /**
+ * Construct an ArrayList for each category in the reflected public properties
+ * Note this will be incorrect if additional public properties are added to this class
+ * or to the interface LogCategories.
+ */
+ public CategoryManager()
+ {
+ categories = new ArrayList();
+
+ Field[] categoryFields = this.getClass().getFields();
+ for (int i = 0; i < categoryFields.length; i++)
+ {
+ try
+ {
+ categories.add((String)categoryFields[i].get(this));
+ }
+ catch (IllegalAccessException iae)
+ {
+ // Illegal Access on reflection
+ }
+ }
+ }
+
+
+ /**
+ * Check if any categories match with the filter (the filter is valid or not).
+ * @param filter the filter string to check
+ * @return whether the filter is valid (with or without a trailing .*)
+ */
+ public boolean checkFilter(String filter)
+ {
+
+ for (int i = 0; i < categories.size(); i++)
+ {
+ if (Log.checkFilterToCategory((String)filter, (String)categories.get(i)))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Return a list of log categories.
+ * @return List a list of the categories
+ */
+ public List getCategories()
+ {
+ return Collections.unmodifiableList(new ArrayList(categories));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/log/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/log/package-info.java b/modules/core/src/flex/management/runtime/messaging/log/package-info.java
old mode 100755
new mode 100644
index 37d55e8..a3e940b
--- a/modules/core/src/flex/management/runtime/messaging/log/package-info.java
+++ b/modules/core/src/flex/management/runtime/messaging/log/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.management.runtime.messaging.log;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/package-info.java b/modules/core/src/flex/management/runtime/messaging/package-info.java
old mode 100755
new mode 100644
index 8331825..c87a5f5
--- a/modules/core/src/flex/management/runtime/messaging/package-info.java
+++ b/modules/core/src/flex/management/runtime/messaging/package-info.java
@@ -1,17 +1,17 @@
-/*
- * 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.management.runtime.messaging;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/MessageServiceControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/MessageServiceControl.java b/modules/core/src/flex/management/runtime/messaging/services/MessageServiceControl.java
old mode 100755
new mode 100644
index ad89011..70dea22
--- a/modules/core/src/flex/management/runtime/messaging/services/MessageServiceControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/MessageServiceControl.java
@@ -1,51 +1,51 @@
-/*
- * 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.management.runtime.messaging.services;
-
-import flex.management.BaseControl;
-import flex.messaging.services.MessageService;
-
-/**
- * The <code>MessageServiceControl</code> class is the MBean implemenation
- * for monitoring and managing a <code>MessageService</code> at runtime.
- *
- * @author shodgson
- */
-public class MessageServiceControl extends ServiceControl implements
- MessageServiceControlMBean
-{
- private static final String TYPE = "MessageService";
-
- /**
- * Constructs a <code>MessageServiceControl</code>, assigning its id, managed
- * message service and parent MBean.
- *
- * @param service The <code>MessageService</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public MessageServiceControl(MessageService service, BaseControl parent)
- {
- super(service, parent);
- }
-
- /** {@inheritDoc} */
- public String getType()
- {
- return TYPE;
- }
-
-}
+/*
+ * 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.management.runtime.messaging.services;
+
+import flex.management.BaseControl;
+import flex.messaging.services.MessageService;
+
+/**
+ * The <code>MessageServiceControl</code> class is the MBean implemenation
+ * for monitoring and managing a <code>MessageService</code> at runtime.
+ *
+ * @author shodgson
+ */
+public class MessageServiceControl extends ServiceControl implements
+ MessageServiceControlMBean
+{
+ private static final String TYPE = "MessageService";
+
+ /**
+ * Constructs a <code>MessageServiceControl</code>, assigning its id, managed
+ * message service and parent MBean.
+ *
+ * @param service The <code>MessageService</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public MessageServiceControl(MessageService service, BaseControl parent)
+ {
+ super(service, parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getType()
+ {
+ return TYPE;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/MessageServiceControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/MessageServiceControlMBean.java b/modules/core/src/flex/management/runtime/messaging/services/MessageServiceControlMBean.java
old mode 100755
new mode 100644
index 8e7916d..ce010bf
--- a/modules/core/src/flex/management/runtime/messaging/services/MessageServiceControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/MessageServiceControlMBean.java
@@ -1,28 +1,28 @@
-/*
- * 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.management.runtime.messaging.services;
-
-
-/**
- * Defines the runtime monitoring and management interface for managed message services.
- *
- * @author shodgson
- */
-public interface MessageServiceControlMBean extends ServiceControlMBean
-{
- // Empty for now.
-}
+/*
+ * 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.management.runtime.messaging.services;
+
+
+/**
+ * Defines the runtime monitoring and management interface for managed message services.
+ *
+ * @author shodgson
+ */
+public interface MessageServiceControlMBean extends ServiceControlMBean
+{
+ // Empty for now.
+}
[09/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/BasePollingHTTPEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/BasePollingHTTPEndpoint.java b/modules/core/src/flex/messaging/endpoints/BasePollingHTTPEndpoint.java
old mode 100755
new mode 100644
index a469d6c..70f1318
--- a/modules/core/src/flex/messaging/endpoints/BasePollingHTTPEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/BasePollingHTTPEndpoint.java
@@ -1,603 +1,603 @@
-/*
- * 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.endpoints;
-
-import flex.messaging.FlexContext;
-import flex.messaging.FlexSession;
-import flex.messaging.client.FlexClient;
-import flex.messaging.client.FlushResult;
-import flex.messaging.client.PollFlushResult;
-import flex.messaging.client.PollWaitListener;
-import flex.messaging.client.UserAgentSettings;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.ConfigurationConstants;
-import flex.messaging.log.Log;
-import flex.messaging.messages.CommandMessage;
-import flex.messaging.util.UserAgentManager;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Base class for HTTP-based endpoints that support regular polling and long polling,
- * which means placing request threads that are polling for messages into a wait
- * state until messages are available for delivery or the configurable wait interval
- * is reached.
- */
-public abstract class BasePollingHTTPEndpoint extends BaseHTTPEndpoint implements PollWaitListener
-{
- //--------------------------------------------------------------------------
- //
- // Private Static Constants
- //
- //--------------------------------------------------------------------------
-
- private static final String POLLING_ENABLED = "polling-enabled";
- private static final String POLLING_INTERVAL_MILLIS = "polling-interval-millis";
- private static final String POLLING_INTERVAL_SECONDS = "polling-interval-seconds"; // Deprecated configuration option.
- private static final String MAX_WAITING_POLL_REQUESTS = "max-waiting-poll-requests";
- private static final String WAIT_INTERVAL_MILLIS = "wait-interval-millis";
- private static final String CLIENT_WAIT_INTERVAL_MILLIS = "client-wait-interval-millis";
- // Force clients that exceed the long-poll limit to wait at least this long between poll requests.
- // This matches the default polling interval defined in the client PollingChannel.
- private static final int DEFAULT_WAIT_FOR_EXCESS_POLL_WAIT_CLIENTS = 3000;
-
- // User Agent based settings manager
- private UserAgentManager userAgentManager = new UserAgentManager();
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>BasePollingHTTPEndpoint</code>.
- */
- public BasePollingHTTPEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs an <code>BasePollingHTTPEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>BasePollingHTTPEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public BasePollingHTTPEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Initialize, validate, start, and stop methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes the <code>Endpoint</code> with the properties.
- * If subclasses override this method, they must call <code>super.initialize()</code>.
- *
- * @param id The ID of the <code>Endpoint</code>.
- * @param properties Properties for the <code>Endpoint</code>.
- */
- @Override
- public void initialize(String id, ConfigMap properties)
- {
- super.initialize(id, properties);
-
- if (properties == null || properties.size() == 0)
- {
- // Initialize default user agent manager settings.
- UserAgentManager.setupUserAgentManager(null, userAgentManager);
-
- return; // Nothing else to initialize.
- }
-
- // General poll props.
- pollingEnabled = properties.getPropertyAsBoolean(POLLING_ENABLED, false);
- pollingIntervalMillis = properties.getPropertyAsLong(POLLING_INTERVAL_MILLIS, -1);
- long pollingIntervalSeconds = properties.getPropertyAsLong(POLLING_INTERVAL_SECONDS, -1); // Deprecated
- if (pollingIntervalSeconds > -1)
- pollingIntervalMillis = pollingIntervalSeconds * 1000;
-
- // Piggybacking props.
- piggybackingEnabled = properties.getPropertyAsBoolean(ConfigurationConstants.PIGGYBACKING_ENABLED_ELEMENT, false);
-
- // HTTP poll wait props.
- maxWaitingPollRequests = properties.getPropertyAsInt(MAX_WAITING_POLL_REQUESTS, 0);
- waitInterval = properties.getPropertyAsLong(WAIT_INTERVAL_MILLIS, 0);
- clientWaitInterval = properties.getPropertyAsInt(CLIENT_WAIT_INTERVAL_MILLIS, 0);
-
- // User Agent props.
- UserAgentManager.setupUserAgentManager(properties, userAgentManager);
-
- // Set initial state for the canWait flag based on whether we allow waits or not.
- if (maxWaitingPollRequests > 0 && (waitInterval == -1 || waitInterval > 0))
- {
- waitEnabled = true;
- canWait = true;
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * This flag is volatile to allow for consistent reads across thread without
- * needing to pay the cost for a synchronized lock for each read.
- */
- private volatile boolean canWait;
-
- /**
- * Used to synchronize sets and gets to the number of waiting clients.
- */
- protected final Object lock = new Object();
-
- /**
- * Set when properties are handled; used as a shortcut for logging to determine whether this
- * instance attempts to put request threads in a wait state or not.
- */
- private boolean waitEnabled;
-
- /**
- * A count of the number of request threads that are currently in the wait state (including
- * those on their way into or out of it).
- */
- protected int waitingPollRequestsCount;
-
- /**
- * A Map(notification Object for a waited request thread, Boolean.TRUE).
- */
- private ConcurrentHashMap currentWaitedRequests;
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // clientWaitInterval
- //----------------------------------
-
- protected int clientWaitInterval = 0;
-
- /**
- * Retrieves the number of milliseconds the client will wait after receiving a response for
- * a poll with server wait before it issues its next poll request.
- * A value of zero or less causes the client to use its default polling interval (based on the
- * channel's polling-interval-millis configuration) and this value is ignored.
- * A value greater than zero will cause the client to wait for the specified interval before
- * issuing its next poll request with a value of 1 triggering an immediate poll from the client
- * as soon as a waited poll response is received.
- * @return The client wait interval.
- */
- public int getClientWaitInterval()
- {
- return clientWaitInterval;
- }
-
- /**
- * Sets the number of milliseconds a client will wait after receiving a response for a poll
- * with server wait before it issues its next poll request.
- * A value of zero or less causes the client to use its default polling interval (based on the
- * channel's polling-interval-millis configuration) and this value is ignored.
- * A value greater than zero will cause the client to wait for the specified interval before
- * issuing its next poll request with a value of 1 triggering an immediate poll from the client
- * as soon as a waited poll response is received.
- * This property does not effect polling clients that poll the server without a server wait.
- *
- * @param value The number of milliseconds a client will wait before issuing its next poll when the
- * server is configured to wait.
- */
- public void setClientWaitInterval(int value)
- {
- clientWaitInterval = value;
- }
-
- //----------------------------------
- // maxWaitingPollRequests
- //----------------------------------
-
- protected int maxWaitingPollRequests = 0;
-
- /**
- * Retrieves the maximum number of server poll response threads that will be
- * waiting for messages to arrive for clients.
- * @return The maximum number of waiting poll requests.
- */
- public int getMaxWaitingPollRequests()
- {
- return maxWaitingPollRequests;
- }
-
- /**
- * Sets the maximum number of server poll response threads that will be
- * waiting for messages to arrive for clients.
- *
- * @param maxWaitingPollRequests The maximum number of server poll response threads
- * that will be waiting for messages to arrive for the client.
- */
- public void setMaxWaitingPollRequests(int maxWaitingPollRequests)
- {
- this.maxWaitingPollRequests = maxWaitingPollRequests;
- if (maxWaitingPollRequests > 0 && (waitInterval == -1 || waitInterval > 0))
- {
- waitEnabled = true;
- canWait = (waitingPollRequestsCount < maxWaitingPollRequests);
- }
- }
-
- //----------------------------------
- // pollingEnabled
- //----------------------------------
-
- /**
- * @exclude
- * This is a property used on the client.
- */
- protected boolean piggybackingEnabled;
-
- //----------------------------------
- // pollingEnabled
- //----------------------------------
-
- /**
- * @exclude
- * This is a property used on the client.
- */
- protected boolean pollingEnabled;
-
- //----------------------------------
- // pollingIntervalMillis
- //----------------------------------
-
- /**
- * @exclude
- * This is a property used on the client.
- */
- protected long pollingIntervalMillis = -1;
-
- //----------------------------------
- // waitInterval
- //----------------------------------
-
- protected long waitInterval = 0;
-
- /**
- * Retrieves the number of milliseconds the server poll response thread will be
- * waiting for messages to arrive for the client.
- * @return The wait interval.
- */
- public long getWaitInterval()
- {
- return waitInterval;
- }
-
- /**
- * Sets the number of milliseconds the server poll response thread will be
- * waiting for messages to arrive for the client.
- *
- * @param waitInterval The number of milliseconds the server poll response thread will be
- * waiting for messages to arrive for the client.
- */
- public void setWaitInterval(long waitInterval)
- {
- this.waitInterval = waitInterval;
- if (maxWaitingPollRequests > 0 && (waitInterval == -1 || waitInterval > 0))
- {
- waitEnabled = true;
- canWait = (waitingPollRequestsCount < maxWaitingPollRequests);
- }
- }
-
- //----------------------------------
- // waitingPollRequestsCount
- //----------------------------------
-
- /**
- * Retrieves the count of the number of request threads that are currently in the wait state
- * (including those on their way into or out of it).
- *
- * @return The count of the number of request threads that are currently in the wait state.
- */
- public int getWaitingPollRequestsCount()
- {
- return waitingPollRequestsCount;
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * Returns a <code>ConfigMap</code> of endpoint properties that the client
- * needs. This includes properties from <code>super.describeEndpoint</code>
- * and additional <code>BaseHTTPEndpoint</code> specific properties under
- * "properties" key.
- */
- @Override
- public ConfigMap describeEndpoint()
- {
- ConfigMap endpointConfig = super.describeEndpoint();
-
- boolean createdProperties = false;
- ConfigMap properties = endpointConfig.getPropertyAsMap(PROPERTIES_ELEMENT, null);
- if (properties == null)
- {
- properties = new ConfigMap();
- createdProperties = true;
- }
-
- if (pollingEnabled)
- {
- ConfigMap pollingEnabled = new ConfigMap();
- // Adding as a value rather than attribute to the parent
- pollingEnabled.addProperty(EMPTY_STRING, TRUE_STRING);
- properties.addProperty(POLLING_ENABLED, pollingEnabled);
- }
-
- if (pollingIntervalMillis > -1)
- {
- ConfigMap pollingInterval = new ConfigMap();
- // Adding as a value rather than attribute to the parent
- pollingInterval.addProperty(EMPTY_STRING, String.valueOf(pollingIntervalMillis));
- properties.addProperty(POLLING_INTERVAL_MILLIS, pollingInterval);
- }
-
- if (piggybackingEnabled)
- {
- ConfigMap piggybackingEnabled = new ConfigMap();
- // Adding as a value rather than attribute to the parent
- piggybackingEnabled.addProperty(EMPTY_STRING, String.valueOf(piggybackingEnabled));
- properties.addProperty(ConfigurationConstants.PIGGYBACKING_ENABLED_ELEMENT, piggybackingEnabled);
- }
-
- if (createdProperties && properties.size() > 0)
- endpointConfig.addProperty(ConfigurationConstants.PROPERTIES_ELEMENT, properties);
-
- return endpointConfig;
- }
-
- /**
- * Sets up monitoring of waited poll requests so they can be notified and exit when the
- * endpoint stops.
- *
- * @see flex.messaging.endpoints.AbstractEndpoint#start()
- */
- @Override
- public void start()
- {
- if (isStarted())
- return;
-
- super.start();
-
- currentWaitedRequests = new ConcurrentHashMap();
- }
-
- /**
- * Ensures that no poll requests in a wait state are left un-notified when the endpoint stops.
- *
- * @see flex.messaging.endpoints.AbstractEndpoint#stop()
- */
- @Override
- public void stop()
- {
- if (!isStarted())
- return;
-
- // Notify any currently waiting polls.
- for (Object notifier : currentWaitedRequests.keySet())
- {
- synchronized (notifier)
- {
- notifier.notifyAll(); // Break any current waits.
- }
- }
- currentWaitedRequests = null;
-
- super.stop();
- }
-
- /**
- * (non-Javaodc)
- * @see flex.messaging.client.PollWaitListener#waitStart(Object)
- */
- public void waitStart(Object notifier)
- {
- currentWaitedRequests.put(notifier, Boolean.TRUE);
- }
-
- /**
- * (non-Javaodc)
- * @see flex.messaging.client.PollWaitListener#waitEnd(Object)
- */
- public void waitEnd(Object notifier)
- {
- if (currentWaitedRequests != null)
- currentWaitedRequests.remove(notifier);
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Overrides the base poll handling to support optionally putting Http request handling threads
- * into a wait state until messages are available to be delivered in the poll response or a timeout is reached.
- * The number of threads that may be put in a wait state is bounded by <code>max-waiting-poll-requests</code>
- * and waits will only be attempted if the canWait flag that is based on the <code>max-waiting-poll-requests</code>
- * and the specified <code>wait-interval</code> is true.
- *
- * @param flexClient The FlexClient that issued the poll request.
- * @param pollCommand The poll command from the client.
- * @return The flush info used to build the poll response.
- */
- @Override
- protected FlushResult handleFlexClientPoll(FlexClient flexClient, CommandMessage pollCommand)
- {
- FlushResult flushResult = null;
- if (canWait && !pollCommand.headerExists(CommandMessage.SUPPRESS_POLL_WAIT_HEADER))
- {
- FlexSession session = FlexContext.getFlexSession();
- // If canWait is true it means we currently have less than the max number of allowed waiting threads.
-
- // We need to protect writes/reads to the wait count with the endpoint's lock.
- // Also, we have to be careful to handle the case where two threads get to this point when only
- // one wait spot remains; one thread will win and the other needs to revert to a non-waitable poll.
- boolean thisThreadCanWait;
- synchronized (lock)
- {
- ++waitingPollRequestsCount;
- if (waitingPollRequestsCount == maxWaitingPollRequests)
- {
- thisThreadCanWait = true; // This thread got the last wait spot.
- canWait = false;
- }
- else if (waitingPollRequestsCount > maxWaitingPollRequests)
- {
- thisThreadCanWait = false; // This thread was beaten out for the last spot.
- --waitingPollRequestsCount; // Decrement the count because we're not going to try a poll with wait.
- canWait = false; // All the wait spots are currently occupied so prevent further attempts for now.
- }
- else
- {
- // We haven't hit the limit yet, allow this thread to wait.
- thisThreadCanWait = true;
- }
- }
-
- // Check the max waiting connections per session count
- if (thisThreadCanWait)
- {
- String userAgentValue = FlexContext.getHttpRequest().getHeader(UserAgentManager.USER_AGENT_HEADER_NAME);
- UserAgentSettings agentSettings = userAgentManager.match(userAgentValue);
- synchronized(session)
- {
- if (agentSettings != null)
- session.maxConnectionsPerSession = agentSettings.getMaxPersistentConnectionsPerSession();
-
- ++session.streamingConnectionsCount;
- if (session.maxConnectionsPerSession == FlexSession.MAX_CONNECTIONS_PER_SESSION_UNLIMITED
- || session.streamingConnectionsCount <= session.maxConnectionsPerSession)
- {
- thisThreadCanWait = true; // We haven't hit the limit yet, allow the wait.
- }
- else // (session.streamingConnectionsCount > session.maxConnectionsPerSession)
- {
- thisThreadCanWait = false; // no more from this client
- --session.streamingConnectionsCount;
- }
- }
-
- if (!thisThreadCanWait)
- {
- // Decrement the waiting poll count, since this poll isn't going to wait.
- synchronized (lock)
- {
- --waitingPollRequestsCount;
- if (waitingPollRequestsCount < maxWaitingPollRequests)
- canWait = true;
- }
- if (Log.isDebug())
- {
- log.debug("Max long-polling requests per session limit (" + session.maxConnectionsPerSession + ") has been reached, this poll won't wait.");
- }
- }
-
- }
-
- if (thisThreadCanWait)
- {
- if (Log.isDebug())
- log.debug("Number of waiting threads for endpoint with id '"+ getId() +"' is " + waitingPollRequestsCount + ".");
-
- try
- {
- flushResult = flexClient.pollWithWait(getId(), FlexContext.getFlexSession(), this, waitInterval);
- if (flushResult != null)
- {
- // Prevent busy-polling due to multiple clients sharing a session and swapping each other out too quickly.
- if ((flushResult instanceof PollFlushResult) && ((PollFlushResult)flushResult).isAvoidBusyPolling() && (flushResult.getNextFlushWaitTimeMillis() < DEFAULT_WAIT_FOR_EXCESS_POLL_WAIT_CLIENTS))
- {
- // Force the client polling interval to match the default defined in the client PollingChannel.
- flushResult.setNextFlushWaitTimeMillis(DEFAULT_WAIT_FOR_EXCESS_POLL_WAIT_CLIENTS);
- }
- else if ((clientWaitInterval > 0) && (flushResult.getNextFlushWaitTimeMillis() == 0))
- {
- // If the FlushResult doesn't specify it's own flush wait time, use the configured clientWaitInterval if defined.
- flushResult.setNextFlushWaitTimeMillis(clientWaitInterval);
- }
- }
- }
- finally
- {
- // We're done waiting so decrement the count of waiting threads and update the canWait flag if necessary
- synchronized (lock)
- {
- --waitingPollRequestsCount;
- if (waitingPollRequestsCount < maxWaitingPollRequests)
- canWait = true;
- }
- synchronized (session)
- {
- --session.streamingConnectionsCount;
- }
-
- if (Log.isDebug())
- log.debug("Number of waiting threads for endpoint with id '"+ getId() +"' is " + waitingPollRequestsCount + ".");
- }
- }
- }
- else if (Log.isDebug() && waitEnabled)
- {
- if (pollCommand.headerExists(CommandMessage.SUPPRESS_POLL_WAIT_HEADER))
- log.debug("Suppressing poll wait for this request because it is part of a batch of messages to process.");
- else
- log.debug("Max waiting poll requests limit '" + maxWaitingPollRequests + "' has been reached for endpoint '" + getId() + "'. FlexClient with id '"+ flexClient.getId() + "' will poll with no wait.");
- }
-
- // If we weren't able to do a poll with wait above for any reason just run the base poll handling logic.
- if (flushResult == null)
- {
- flushResult = super.handleFlexClientPoll(flexClient, pollCommand);
- // If this is an excess poll request that we couldn't wait on, make sure the client doesn't poll the endpoint too aggressively.
- // In this case, force a client wait to match the default polling interval defined in the client PollingChannel.
- if ( waitEnabled && (pollingIntervalMillis < DEFAULT_WAIT_FOR_EXCESS_POLL_WAIT_CLIENTS))
- {
- if (flushResult == null)
- {
- flushResult = new FlushResult();
- }
- flushResult.setNextFlushWaitTimeMillis(DEFAULT_WAIT_FOR_EXCESS_POLL_WAIT_CLIENTS);
- }
- }
-
- return flushResult;
- }
-}
+/*
+ * 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.endpoints;
+
+import flex.messaging.FlexContext;
+import flex.messaging.FlexSession;
+import flex.messaging.client.FlexClient;
+import flex.messaging.client.FlushResult;
+import flex.messaging.client.PollFlushResult;
+import flex.messaging.client.PollWaitListener;
+import flex.messaging.client.UserAgentSettings;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.ConfigurationConstants;
+import flex.messaging.log.Log;
+import flex.messaging.messages.CommandMessage;
+import flex.messaging.util.UserAgentManager;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Base class for HTTP-based endpoints that support regular polling and long polling,
+ * which means placing request threads that are polling for messages into a wait
+ * state until messages are available for delivery or the configurable wait interval
+ * is reached.
+ */
+public abstract class BasePollingHTTPEndpoint extends BaseHTTPEndpoint implements PollWaitListener
+{
+ //--------------------------------------------------------------------------
+ //
+ // Private Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ private static final String POLLING_ENABLED = "polling-enabled";
+ private static final String POLLING_INTERVAL_MILLIS = "polling-interval-millis";
+ private static final String POLLING_INTERVAL_SECONDS = "polling-interval-seconds"; // Deprecated configuration option.
+ private static final String MAX_WAITING_POLL_REQUESTS = "max-waiting-poll-requests";
+ private static final String WAIT_INTERVAL_MILLIS = "wait-interval-millis";
+ private static final String CLIENT_WAIT_INTERVAL_MILLIS = "client-wait-interval-millis";
+ // Force clients that exceed the long-poll limit to wait at least this long between poll requests.
+ // This matches the default polling interval defined in the client PollingChannel.
+ private static final int DEFAULT_WAIT_FOR_EXCESS_POLL_WAIT_CLIENTS = 3000;
+
+ // User Agent based settings manager
+ private UserAgentManager userAgentManager = new UserAgentManager();
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>BasePollingHTTPEndpoint</code>.
+ */
+ public BasePollingHTTPEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs an <code>BasePollingHTTPEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>BasePollingHTTPEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public BasePollingHTTPEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Initialize, validate, start, and stop methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes the <code>Endpoint</code> with the properties.
+ * If subclasses override this method, they must call <code>super.initialize()</code>.
+ *
+ * @param id The ID of the <code>Endpoint</code>.
+ * @param properties Properties for the <code>Endpoint</code>.
+ */
+ @Override
+ public void initialize(String id, ConfigMap properties)
+ {
+ super.initialize(id, properties);
+
+ if (properties == null || properties.size() == 0)
+ {
+ // Initialize default user agent manager settings.
+ UserAgentManager.setupUserAgentManager(null, userAgentManager);
+
+ return; // Nothing else to initialize.
+ }
+
+ // General poll props.
+ pollingEnabled = properties.getPropertyAsBoolean(POLLING_ENABLED, false);
+ pollingIntervalMillis = properties.getPropertyAsLong(POLLING_INTERVAL_MILLIS, -1);
+ long pollingIntervalSeconds = properties.getPropertyAsLong(POLLING_INTERVAL_SECONDS, -1); // Deprecated
+ if (pollingIntervalSeconds > -1)
+ pollingIntervalMillis = pollingIntervalSeconds * 1000;
+
+ // Piggybacking props.
+ piggybackingEnabled = properties.getPropertyAsBoolean(ConfigurationConstants.PIGGYBACKING_ENABLED_ELEMENT, false);
+
+ // HTTP poll wait props.
+ maxWaitingPollRequests = properties.getPropertyAsInt(MAX_WAITING_POLL_REQUESTS, 0);
+ waitInterval = properties.getPropertyAsLong(WAIT_INTERVAL_MILLIS, 0);
+ clientWaitInterval = properties.getPropertyAsInt(CLIENT_WAIT_INTERVAL_MILLIS, 0);
+
+ // User Agent props.
+ UserAgentManager.setupUserAgentManager(properties, userAgentManager);
+
+ // Set initial state for the canWait flag based on whether we allow waits or not.
+ if (maxWaitingPollRequests > 0 && (waitInterval == -1 || waitInterval > 0))
+ {
+ waitEnabled = true;
+ canWait = true;
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * This flag is volatile to allow for consistent reads across thread without
+ * needing to pay the cost for a synchronized lock for each read.
+ */
+ private volatile boolean canWait;
+
+ /**
+ * Used to synchronize sets and gets to the number of waiting clients.
+ */
+ protected final Object lock = new Object();
+
+ /**
+ * Set when properties are handled; used as a shortcut for logging to determine whether this
+ * instance attempts to put request threads in a wait state or not.
+ */
+ private boolean waitEnabled;
+
+ /**
+ * A count of the number of request threads that are currently in the wait state (including
+ * those on their way into or out of it).
+ */
+ protected int waitingPollRequestsCount;
+
+ /**
+ * A Map(notification Object for a waited request thread, Boolean.TRUE).
+ */
+ private ConcurrentHashMap currentWaitedRequests;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // clientWaitInterval
+ //----------------------------------
+
+ protected int clientWaitInterval = 0;
+
+ /**
+ * Retrieves the number of milliseconds the client will wait after receiving a response for
+ * a poll with server wait before it issues its next poll request.
+ * A value of zero or less causes the client to use its default polling interval (based on the
+ * channel's polling-interval-millis configuration) and this value is ignored.
+ * A value greater than zero will cause the client to wait for the specified interval before
+ * issuing its next poll request with a value of 1 triggering an immediate poll from the client
+ * as soon as a waited poll response is received.
+ * @return The client wait interval.
+ */
+ public int getClientWaitInterval()
+ {
+ return clientWaitInterval;
+ }
+
+ /**
+ * Sets the number of milliseconds a client will wait after receiving a response for a poll
+ * with server wait before it issues its next poll request.
+ * A value of zero or less causes the client to use its default polling interval (based on the
+ * channel's polling-interval-millis configuration) and this value is ignored.
+ * A value greater than zero will cause the client to wait for the specified interval before
+ * issuing its next poll request with a value of 1 triggering an immediate poll from the client
+ * as soon as a waited poll response is received.
+ * This property does not effect polling clients that poll the server without a server wait.
+ *
+ * @param value The number of milliseconds a client will wait before issuing its next poll when the
+ * server is configured to wait.
+ */
+ public void setClientWaitInterval(int value)
+ {
+ clientWaitInterval = value;
+ }
+
+ //----------------------------------
+ // maxWaitingPollRequests
+ //----------------------------------
+
+ protected int maxWaitingPollRequests = 0;
+
+ /**
+ * Retrieves the maximum number of server poll response threads that will be
+ * waiting for messages to arrive for clients.
+ * @return The maximum number of waiting poll requests.
+ */
+ public int getMaxWaitingPollRequests()
+ {
+ return maxWaitingPollRequests;
+ }
+
+ /**
+ * Sets the maximum number of server poll response threads that will be
+ * waiting for messages to arrive for clients.
+ *
+ * @param maxWaitingPollRequests The maximum number of server poll response threads
+ * that will be waiting for messages to arrive for the client.
+ */
+ public void setMaxWaitingPollRequests(int maxWaitingPollRequests)
+ {
+ this.maxWaitingPollRequests = maxWaitingPollRequests;
+ if (maxWaitingPollRequests > 0 && (waitInterval == -1 || waitInterval > 0))
+ {
+ waitEnabled = true;
+ canWait = (waitingPollRequestsCount < maxWaitingPollRequests);
+ }
+ }
+
+ //----------------------------------
+ // pollingEnabled
+ //----------------------------------
+
+ /**
+ * @exclude
+ * This is a property used on the client.
+ */
+ protected boolean piggybackingEnabled;
+
+ //----------------------------------
+ // pollingEnabled
+ //----------------------------------
+
+ /**
+ * @exclude
+ * This is a property used on the client.
+ */
+ protected boolean pollingEnabled;
+
+ //----------------------------------
+ // pollingIntervalMillis
+ //----------------------------------
+
+ /**
+ * @exclude
+ * This is a property used on the client.
+ */
+ protected long pollingIntervalMillis = -1;
+
+ //----------------------------------
+ // waitInterval
+ //----------------------------------
+
+ protected long waitInterval = 0;
+
+ /**
+ * Retrieves the number of milliseconds the server poll response thread will be
+ * waiting for messages to arrive for the client.
+ * @return The wait interval.
+ */
+ public long getWaitInterval()
+ {
+ return waitInterval;
+ }
+
+ /**
+ * Sets the number of milliseconds the server poll response thread will be
+ * waiting for messages to arrive for the client.
+ *
+ * @param waitInterval The number of milliseconds the server poll response thread will be
+ * waiting for messages to arrive for the client.
+ */
+ public void setWaitInterval(long waitInterval)
+ {
+ this.waitInterval = waitInterval;
+ if (maxWaitingPollRequests > 0 && (waitInterval == -1 || waitInterval > 0))
+ {
+ waitEnabled = true;
+ canWait = (waitingPollRequestsCount < maxWaitingPollRequests);
+ }
+ }
+
+ //----------------------------------
+ // waitingPollRequestsCount
+ //----------------------------------
+
+ /**
+ * Retrieves the count of the number of request threads that are currently in the wait state
+ * (including those on their way into or out of it).
+ *
+ * @return The count of the number of request threads that are currently in the wait state.
+ */
+ public int getWaitingPollRequestsCount()
+ {
+ return waitingPollRequestsCount;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @exclude
+ * Returns a <code>ConfigMap</code> of endpoint properties that the client
+ * needs. This includes properties from <code>super.describeEndpoint</code>
+ * and additional <code>BaseHTTPEndpoint</code> specific properties under
+ * "properties" key.
+ */
+ @Override
+ public ConfigMap describeEndpoint()
+ {
+ ConfigMap endpointConfig = super.describeEndpoint();
+
+ boolean createdProperties = false;
+ ConfigMap properties = endpointConfig.getPropertyAsMap(PROPERTIES_ELEMENT, null);
+ if (properties == null)
+ {
+ properties = new ConfigMap();
+ createdProperties = true;
+ }
+
+ if (pollingEnabled)
+ {
+ ConfigMap pollingEnabled = new ConfigMap();
+ // Adding as a value rather than attribute to the parent
+ pollingEnabled.addProperty(EMPTY_STRING, TRUE_STRING);
+ properties.addProperty(POLLING_ENABLED, pollingEnabled);
+ }
+
+ if (pollingIntervalMillis > -1)
+ {
+ ConfigMap pollingInterval = new ConfigMap();
+ // Adding as a value rather than attribute to the parent
+ pollingInterval.addProperty(EMPTY_STRING, String.valueOf(pollingIntervalMillis));
+ properties.addProperty(POLLING_INTERVAL_MILLIS, pollingInterval);
+ }
+
+ if (piggybackingEnabled)
+ {
+ ConfigMap piggybackingEnabled = new ConfigMap();
+ // Adding as a value rather than attribute to the parent
+ piggybackingEnabled.addProperty(EMPTY_STRING, String.valueOf(piggybackingEnabled));
+ properties.addProperty(ConfigurationConstants.PIGGYBACKING_ENABLED_ELEMENT, piggybackingEnabled);
+ }
+
+ if (createdProperties && properties.size() > 0)
+ endpointConfig.addProperty(ConfigurationConstants.PROPERTIES_ELEMENT, properties);
+
+ return endpointConfig;
+ }
+
+ /**
+ * Sets up monitoring of waited poll requests so they can be notified and exit when the
+ * endpoint stops.
+ *
+ * @see flex.messaging.endpoints.AbstractEndpoint#start()
+ */
+ @Override
+ public void start()
+ {
+ if (isStarted())
+ return;
+
+ super.start();
+
+ currentWaitedRequests = new ConcurrentHashMap();
+ }
+
+ /**
+ * Ensures that no poll requests in a wait state are left un-notified when the endpoint stops.
+ *
+ * @see flex.messaging.endpoints.AbstractEndpoint#stop()
+ */
+ @Override
+ public void stop()
+ {
+ if (!isStarted())
+ return;
+
+ // Notify any currently waiting polls.
+ for (Object notifier : currentWaitedRequests.keySet())
+ {
+ synchronized (notifier)
+ {
+ notifier.notifyAll(); // Break any current waits.
+ }
+ }
+ currentWaitedRequests = null;
+
+ super.stop();
+ }
+
+ /**
+ * (non-Javaodc)
+ * @see flex.messaging.client.PollWaitListener#waitStart(Object)
+ */
+ public void waitStart(Object notifier)
+ {
+ currentWaitedRequests.put(notifier, Boolean.TRUE);
+ }
+
+ /**
+ * (non-Javaodc)
+ * @see flex.messaging.client.PollWaitListener#waitEnd(Object)
+ */
+ public void waitEnd(Object notifier)
+ {
+ if (currentWaitedRequests != null)
+ currentWaitedRequests.remove(notifier);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Overrides the base poll handling to support optionally putting Http request handling threads
+ * into a wait state until messages are available to be delivered in the poll response or a timeout is reached.
+ * The number of threads that may be put in a wait state is bounded by <code>max-waiting-poll-requests</code>
+ * and waits will only be attempted if the canWait flag that is based on the <code>max-waiting-poll-requests</code>
+ * and the specified <code>wait-interval</code> is true.
+ *
+ * @param flexClient The FlexClient that issued the poll request.
+ * @param pollCommand The poll command from the client.
+ * @return The flush info used to build the poll response.
+ */
+ @Override
+ protected FlushResult handleFlexClientPoll(FlexClient flexClient, CommandMessage pollCommand)
+ {
+ FlushResult flushResult = null;
+ if (canWait && !pollCommand.headerExists(CommandMessage.SUPPRESS_POLL_WAIT_HEADER))
+ {
+ FlexSession session = FlexContext.getFlexSession();
+ // If canWait is true it means we currently have less than the max number of allowed waiting threads.
+
+ // We need to protect writes/reads to the wait count with the endpoint's lock.
+ // Also, we have to be careful to handle the case where two threads get to this point when only
+ // one wait spot remains; one thread will win and the other needs to revert to a non-waitable poll.
+ boolean thisThreadCanWait;
+ synchronized (lock)
+ {
+ ++waitingPollRequestsCount;
+ if (waitingPollRequestsCount == maxWaitingPollRequests)
+ {
+ thisThreadCanWait = true; // This thread got the last wait spot.
+ canWait = false;
+ }
+ else if (waitingPollRequestsCount > maxWaitingPollRequests)
+ {
+ thisThreadCanWait = false; // This thread was beaten out for the last spot.
+ --waitingPollRequestsCount; // Decrement the count because we're not going to try a poll with wait.
+ canWait = false; // All the wait spots are currently occupied so prevent further attempts for now.
+ }
+ else
+ {
+ // We haven't hit the limit yet, allow this thread to wait.
+ thisThreadCanWait = true;
+ }
+ }
+
+ // Check the max waiting connections per session count
+ if (thisThreadCanWait)
+ {
+ String userAgentValue = FlexContext.getHttpRequest().getHeader(UserAgentManager.USER_AGENT_HEADER_NAME);
+ UserAgentSettings agentSettings = userAgentManager.match(userAgentValue);
+ synchronized(session)
+ {
+ if (agentSettings != null)
+ session.maxConnectionsPerSession = agentSettings.getMaxPersistentConnectionsPerSession();
+
+ ++session.streamingConnectionsCount;
+ if (session.maxConnectionsPerSession == FlexSession.MAX_CONNECTIONS_PER_SESSION_UNLIMITED
+ || session.streamingConnectionsCount <= session.maxConnectionsPerSession)
+ {
+ thisThreadCanWait = true; // We haven't hit the limit yet, allow the wait.
+ }
+ else // (session.streamingConnectionsCount > session.maxConnectionsPerSession)
+ {
+ thisThreadCanWait = false; // no more from this client
+ --session.streamingConnectionsCount;
+ }
+ }
+
+ if (!thisThreadCanWait)
+ {
+ // Decrement the waiting poll count, since this poll isn't going to wait.
+ synchronized (lock)
+ {
+ --waitingPollRequestsCount;
+ if (waitingPollRequestsCount < maxWaitingPollRequests)
+ canWait = true;
+ }
+ if (Log.isDebug())
+ {
+ log.debug("Max long-polling requests per session limit (" + session.maxConnectionsPerSession + ") has been reached, this poll won't wait.");
+ }
+ }
+
+ }
+
+ if (thisThreadCanWait)
+ {
+ if (Log.isDebug())
+ log.debug("Number of waiting threads for endpoint with id '"+ getId() +"' is " + waitingPollRequestsCount + ".");
+
+ try
+ {
+ flushResult = flexClient.pollWithWait(getId(), FlexContext.getFlexSession(), this, waitInterval);
+ if (flushResult != null)
+ {
+ // Prevent busy-polling due to multiple clients sharing a session and swapping each other out too quickly.
+ if ((flushResult instanceof PollFlushResult) && ((PollFlushResult)flushResult).isAvoidBusyPolling() && (flushResult.getNextFlushWaitTimeMillis() < DEFAULT_WAIT_FOR_EXCESS_POLL_WAIT_CLIENTS))
+ {
+ // Force the client polling interval to match the default defined in the client PollingChannel.
+ flushResult.setNextFlushWaitTimeMillis(DEFAULT_WAIT_FOR_EXCESS_POLL_WAIT_CLIENTS);
+ }
+ else if ((clientWaitInterval > 0) && (flushResult.getNextFlushWaitTimeMillis() == 0))
+ {
+ // If the FlushResult doesn't specify it's own flush wait time, use the configured clientWaitInterval if defined.
+ flushResult.setNextFlushWaitTimeMillis(clientWaitInterval);
+ }
+ }
+ }
+ finally
+ {
+ // We're done waiting so decrement the count of waiting threads and update the canWait flag if necessary
+ synchronized (lock)
+ {
+ --waitingPollRequestsCount;
+ if (waitingPollRequestsCount < maxWaitingPollRequests)
+ canWait = true;
+ }
+ synchronized (session)
+ {
+ --session.streamingConnectionsCount;
+ }
+
+ if (Log.isDebug())
+ log.debug("Number of waiting threads for endpoint with id '"+ getId() +"' is " + waitingPollRequestsCount + ".");
+ }
+ }
+ }
+ else if (Log.isDebug() && waitEnabled)
+ {
+ if (pollCommand.headerExists(CommandMessage.SUPPRESS_POLL_WAIT_HEADER))
+ log.debug("Suppressing poll wait for this request because it is part of a batch of messages to process.");
+ else
+ log.debug("Max waiting poll requests limit '" + maxWaitingPollRequests + "' has been reached for endpoint '" + getId() + "'. FlexClient with id '"+ flexClient.getId() + "' will poll with no wait.");
+ }
+
+ // If we weren't able to do a poll with wait above for any reason just run the base poll handling logic.
+ if (flushResult == null)
+ {
+ flushResult = super.handleFlexClientPoll(flexClient, pollCommand);
+ // If this is an excess poll request that we couldn't wait on, make sure the client doesn't poll the endpoint too aggressively.
+ // In this case, force a client wait to match the default polling interval defined in the client PollingChannel.
+ if ( waitEnabled && (pollingIntervalMillis < DEFAULT_WAIT_FOR_EXCESS_POLL_WAIT_CLIENTS))
+ {
+ if (flushResult == null)
+ {
+ flushResult = new FlushResult();
+ }
+ flushResult.setNextFlushWaitTimeMillis(DEFAULT_WAIT_FOR_EXCESS_POLL_WAIT_CLIENTS);
+ }
+ }
+
+ return flushResult;
+ }
+}
[02/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/ManagedObjectProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/ManagedObjectProxy.java b/modules/core/src/flex/messaging/io/ManagedObjectProxy.java
old mode 100755
new mode 100644
index 9e17ad2..02072f3
--- a/modules/core/src/flex/messaging/io/ManagedObjectProxy.java
+++ b/modules/core/src/flex/messaging/io/ManagedObjectProxy.java
@@ -1,74 +1,74 @@
-/*
- * 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.io;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Iterator;
-
-/**
- * @exclude
- */
-public class ManagedObjectProxy extends ObjectProxy
-{
- static final long serialVersionUID = 255140415084514484L;
-
- public ManagedObjectProxy()
- {
- super();
- }
-
- public ManagedObjectProxy(int initialCapacity)
- {
- super(initialCapacity);
- }
-
- public ManagedObjectProxy(int initialCapacity, float loadFactor)
- {
- super(initialCapacity, loadFactor);
- }
-
- public void writeExternal(ObjectOutput out) throws IOException
- {
- int count = this.size();
- out.writeInt(count);
-
- // TODO: QUESTION: Jeff, We could copy the client approach to check a destination
- // for lazy associations to exclude them from serialization.
-
- Iterator it = keySet().iterator();
- while (it.hasNext())
- {
- Object key = it.next();
- out.writeObject(key);
- out.writeObject(get(key));
- }
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- int count = in.readInt();
-
- for (int i = 0; i < count; i++)
- {
- Object key = in.readObject();
- Object value = in.readObject();
- put(key, value);
- }
- }
-}
+/*
+ * 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.io;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Iterator;
+
+/**
+ * @exclude
+ */
+public class ManagedObjectProxy extends ObjectProxy
+{
+ static final long serialVersionUID = 255140415084514484L;
+
+ public ManagedObjectProxy()
+ {
+ super();
+ }
+
+ public ManagedObjectProxy(int initialCapacity)
+ {
+ super(initialCapacity);
+ }
+
+ public ManagedObjectProxy(int initialCapacity, float loadFactor)
+ {
+ super(initialCapacity, loadFactor);
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ int count = this.size();
+ out.writeInt(count);
+
+ // TODO: QUESTION: Jeff, We could copy the client approach to check a destination
+ // for lazy associations to exclude them from serialization.
+
+ Iterator it = keySet().iterator();
+ while (it.hasNext())
+ {
+ Object key = it.next();
+ out.writeObject(key);
+ out.writeObject(get(key));
+ }
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ int count = in.readInt();
+
+ for (int i = 0; i < count; i++)
+ {
+ Object key = in.readObject();
+ Object value = in.readObject();
+ put(key, value);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/MapProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/MapProxy.java b/modules/core/src/flex/messaging/io/MapProxy.java
old mode 100755
new mode 100644
index 42eb894..d5d889d
--- a/modules/core/src/flex/messaging/io/MapProxy.java
+++ b/modules/core/src/flex/messaging/io/MapProxy.java
@@ -1,221 +1,221 @@
-/*
- * 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.io;
-
-import flex.messaging.MessageException;
-import flex.messaging.log.Log;
-import flex.messaging.log.Logger;
-import flex.messaging.util.ClassUtil;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Proxies serialization of a Map and considers all keys as String based property
- * names. Additionally, bean properties from the instance are also included and
- * override any Map entries with the same key name.
- *
- * @author Peter Farland
- */
-public class MapProxy extends BeanProxy
-{
- static final long serialVersionUID = 7857999941099335210L;
-
- private static final int NULL_KEY_ERROR = 10026;
-
- /**
- * Constructor
- */
- public MapProxy()
- {
- super();
- //dynamic = true;
- }
-
- /**
- * Construct with a default instance type.
- * @param defaultInstance defines the alias if provided
- */
- public MapProxy(Object defaultInstance)
- {
- super(defaultInstance);
- //dynamic = true;
- }
-
- /** {@inheritDoc} */
- @Override
- public List getPropertyNames(Object instance)
- {
- if (instance == null)
- return null;
-
- List propertyNames = null;
- List excludes = null;
-
- if (descriptor != null)
- {
- excludes = descriptor.getExcludesForInstance(instance);
- if (excludes == null) // For compatibility with older implementations
- excludes = descriptor.getExcludes();
- }
-
- // Add all Map keys as properties
- if (instance instanceof Map)
- {
- Map map = (Map)instance;
-
- if (map.size() > 0)
- {
- propertyNames = new ArrayList(map.size());
- SerializationContext context = getSerializationContext();
-
- Iterator it = map.keySet().iterator();
- while (it.hasNext())
- {
- Object key = it.next();
- if (key != null)
- {
- if (excludes != null && excludes.contains(key))
- continue;
-
- propertyNames.add(key.toString());
- }
- else
- {
- // Log null key errors
- if (Log.isWarn() && context.logPropertyErrors)
- {
- Logger log = Log.getLogger(LOG_CATEGORY);
- log.warn("Cannot send a null Map key for type {0}.",
- new Object[] {map.getClass().getName()});
- }
-
- if (!context.ignorePropertyErrors)
- {
- // Cannot send a null Map key for type {0}.
- MessageException ex = new MessageException();
- ex.setMessage(NULL_KEY_ERROR, new Object[] {map.getClass().getName()});
- throw ex;
- }
- }
- }
- }
- }
-
- // Then, check for bean properties
- List beanProperties = super.getPropertyNames(instance);
- if (beanProperties != null)
- {
- if (propertyNames == null)
- propertyNames = beanProperties;
- else
- propertyNames.addAll(beanProperties);
- }
-
- return propertyNames;
- }
-
- /** {@inheritDoc} */
- @Override
- public Object getValue(Object instance, String propertyName)
- {
- if (instance == null || propertyName == null)
- return null;
-
- Object value = null;
-
- // First, check for bean property
- BeanProperty bp = getBeanProperty(instance, propertyName);
- if (bp != null)
- value = super.getBeanValue(instance, bp);
-
- // Then check for Map entry
- if (value == null && instance instanceof Map)
- value = getMapValue((Map)instance, propertyName);
-
- return value;
- }
-
- /** {@inheritDoc} */
- @Override
- public void setValue(Object instance, String propertyName, Object value)
- {
- if (instance == null || propertyName == null)
- return;
-
- Map props = getBeanProperties(instance);
- if (props.containsKey(propertyName))
- {
- super.setValue(instance, propertyName, value);
- }
- else if (instance instanceof Map)
- {
- ClassUtil.validateAssignment(instance, propertyName, value);
- ((Map)instance).put(propertyName, value);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- protected boolean ignorePropertyErrors(SerializationContext context)
- {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- protected boolean logPropertyErrors(SerializationContext context)
- {
- return false;
- }
-
- /**
- * Return the classname of the instance, including ASObject types.
- * If the instance is a Map and is in the java.util package, we return null.
- * @param instance the object to find the class name of
- * @return the class name of the object.
- */
- @Override
- protected String getClassName(Object instance)
- {
- return (instance != null && instance instanceof Map
- && instance.getClass().getName().startsWith("java.util."))?
- null : super.getClassName(instance);
- }
-
- /**
- * Given a map and a property name, returns the value keyed under that property
- * name but instead of depending on {@link Map#get(Object)}, propertyName
- * is compared against key#toString. This is due to the fact that propertyNames
- * are always stored as Strings.
- *
- * @param map The Map to check against.
- * @param propertyName The property name to check for.
- * @return The value keyed under property name or null if it does not exist.
- */
- protected Object getMapValue(Map map, String propertyName)
- {
- for (Object entry : map.entrySet())
- {
- Object key = ((Map.Entry) entry).getKey();
- if (key.toString().equals(propertyName))
- return ((Map.Entry) entry).getValue();
- }
- return null;
- }
-}
+/*
+ * 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.io;
+
+import flex.messaging.MessageException;
+import flex.messaging.log.Log;
+import flex.messaging.log.Logger;
+import flex.messaging.util.ClassUtil;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Proxies serialization of a Map and considers all keys as String based property
+ * names. Additionally, bean properties from the instance are also included and
+ * override any Map entries with the same key name.
+ *
+ * @author Peter Farland
+ */
+public class MapProxy extends BeanProxy
+{
+ static final long serialVersionUID = 7857999941099335210L;
+
+ private static final int NULL_KEY_ERROR = 10026;
+
+ /**
+ * Constructor
+ */
+ public MapProxy()
+ {
+ super();
+ //dynamic = true;
+ }
+
+ /**
+ * Construct with a default instance type.
+ * @param defaultInstance defines the alias if provided
+ */
+ public MapProxy(Object defaultInstance)
+ {
+ super(defaultInstance);
+ //dynamic = true;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public List getPropertyNames(Object instance)
+ {
+ if (instance == null)
+ return null;
+
+ List propertyNames = null;
+ List excludes = null;
+
+ if (descriptor != null)
+ {
+ excludes = descriptor.getExcludesForInstance(instance);
+ if (excludes == null) // For compatibility with older implementations
+ excludes = descriptor.getExcludes();
+ }
+
+ // Add all Map keys as properties
+ if (instance instanceof Map)
+ {
+ Map map = (Map)instance;
+
+ if (map.size() > 0)
+ {
+ propertyNames = new ArrayList(map.size());
+ SerializationContext context = getSerializationContext();
+
+ Iterator it = map.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object key = it.next();
+ if (key != null)
+ {
+ if (excludes != null && excludes.contains(key))
+ continue;
+
+ propertyNames.add(key.toString());
+ }
+ else
+ {
+ // Log null key errors
+ if (Log.isWarn() && context.logPropertyErrors)
+ {
+ Logger log = Log.getLogger(LOG_CATEGORY);
+ log.warn("Cannot send a null Map key for type {0}.",
+ new Object[] {map.getClass().getName()});
+ }
+
+ if (!context.ignorePropertyErrors)
+ {
+ // Cannot send a null Map key for type {0}.
+ MessageException ex = new MessageException();
+ ex.setMessage(NULL_KEY_ERROR, new Object[] {map.getClass().getName()});
+ throw ex;
+ }
+ }
+ }
+ }
+ }
+
+ // Then, check for bean properties
+ List beanProperties = super.getPropertyNames(instance);
+ if (beanProperties != null)
+ {
+ if (propertyNames == null)
+ propertyNames = beanProperties;
+ else
+ propertyNames.addAll(beanProperties);
+ }
+
+ return propertyNames;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Object getValue(Object instance, String propertyName)
+ {
+ if (instance == null || propertyName == null)
+ return null;
+
+ Object value = null;
+
+ // First, check for bean property
+ BeanProperty bp = getBeanProperty(instance, propertyName);
+ if (bp != null)
+ value = super.getBeanValue(instance, bp);
+
+ // Then check for Map entry
+ if (value == null && instance instanceof Map)
+ value = getMapValue((Map)instance, propertyName);
+
+ return value;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setValue(Object instance, String propertyName, Object value)
+ {
+ if (instance == null || propertyName == null)
+ return;
+
+ Map props = getBeanProperties(instance);
+ if (props.containsKey(propertyName))
+ {
+ super.setValue(instance, propertyName, value);
+ }
+ else if (instance instanceof Map)
+ {
+ ClassUtil.validateAssignment(instance, propertyName, value);
+ ((Map)instance).put(propertyName, value);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected boolean ignorePropertyErrors(SerializationContext context)
+ {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected boolean logPropertyErrors(SerializationContext context)
+ {
+ return false;
+ }
+
+ /**
+ * Return the classname of the instance, including ASObject types.
+ * If the instance is a Map and is in the java.util package, we return null.
+ * @param instance the object to find the class name of
+ * @return the class name of the object.
+ */
+ @Override
+ protected String getClassName(Object instance)
+ {
+ return (instance != null && instance instanceof Map
+ && instance.getClass().getName().startsWith("java.util."))?
+ null : super.getClassName(instance);
+ }
+
+ /**
+ * Given a map and a property name, returns the value keyed under that property
+ * name but instead of depending on {@link Map#get(Object)}, propertyName
+ * is compared against key#toString. This is due to the fact that propertyNames
+ * are always stored as Strings.
+ *
+ * @param map The Map to check against.
+ * @param propertyName The property name to check for.
+ * @return The value keyed under property name or null if it does not exist.
+ */
+ protected Object getMapValue(Map map, String propertyName)
+ {
+ for (Object entry : map.entrySet())
+ {
+ Object key = ((Map.Entry) entry).getKey();
+ if (key.toString().equals(propertyName))
+ return ((Map.Entry) entry).getValue();
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/MessageDeserializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/MessageDeserializer.java b/modules/core/src/flex/messaging/io/MessageDeserializer.java
old mode 100755
new mode 100644
index c9d0e96..9329edd
--- a/modules/core/src/flex/messaging/io/MessageDeserializer.java
+++ b/modules/core/src/flex/messaging/io/MessageDeserializer.java
@@ -1,39 +1,39 @@
-/*
- * 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.io;
-
-import flex.messaging.io.amf.ActionMessage;
-import flex.messaging.io.amf.ActionContext;
-import flex.messaging.io.amf.AmfTrace;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * An interface to allow for either AMF or AMFX based deserializers
- * to process requests.
- *
- * @author Peter Farland
- */
-public interface MessageDeserializer
-{
- void initialize(SerializationContext context, InputStream in, AmfTrace trace);
-
- void readMessage(ActionMessage m, ActionContext context) throws ClassNotFoundException, IOException;
-
- Object readObject() throws ClassNotFoundException, IOException;
-}
+/*
+ * 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.io;
+
+import flex.messaging.io.amf.ActionMessage;
+import flex.messaging.io.amf.ActionContext;
+import flex.messaging.io.amf.AmfTrace;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An interface to allow for either AMF or AMFX based deserializers
+ * to process requests.
+ *
+ * @author Peter Farland
+ */
+public interface MessageDeserializer
+{
+ void initialize(SerializationContext context, InputStream in, AmfTrace trace);
+
+ void readMessage(ActionMessage m, ActionContext context) throws ClassNotFoundException, IOException;
+
+ Object readObject() throws ClassNotFoundException, IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/MessageIOConstants.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/MessageIOConstants.java b/modules/core/src/flex/messaging/io/MessageIOConstants.java
old mode 100755
new mode 100644
index 76095e8..245efec
--- a/modules/core/src/flex/messaging/io/MessageIOConstants.java
+++ b/modules/core/src/flex/messaging/io/MessageIOConstants.java
@@ -1,54 +1,54 @@
-/*
- * 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.io;
-
-/**
- * @exclude
- */
-public interface MessageIOConstants
-{
- int AMF0 = 0;
- int AMF1 = 1; // There is no AMF1 but FMS uses it for some reason, hence special casing.
- int AMF3 = 3;
- Double AMF3_INFO_PROPERTY = new Double(3);
-
- String CONTENT_TYPE_XML = "text/xml; charset=utf-8";
- String AMF_CONTENT_TYPE = "application/x-amf";
- String CONTENT_TYPE_PLAIN = "text/plain";
- String XML_CONTENT_TYPE = "application/xml";
-
- String RESULT_METHOD = "/onResult";
- String STATUS_METHOD = "/onStatus";
-
- int STATUS_OK = 0;
- int STATUS_ERR = 1;
- int STATUS_NOTAMF = 2;
-
- String SECURITY_HEADER_NAME = "Credentials";
- String SECURITY_PRINCIPAL = "userid";
- String SECURITY_CREDENTIALS = "password";
-
- String URL_APPEND_HEADER = "AppendToGatewayUrl";
- String SERVICE_TYPE_HEADER = "ServiceType";
-
- String REMOTE_CLASS_FIELD = "_remoteClass";
- String SUPPORT_REMOTE_CLASS = "SupportRemoteClass";
- String SUPPORT_DATES_BY_REFERENCE = "SupportDatesByReference";
-
- String METHOD_POST = "POST";
- String HEADER_SOAP_ACTION = "SOAPAction";
-}
+/*
+ * 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.io;
+
+/**
+ * @exclude
+ */
+public interface MessageIOConstants
+{
+ int AMF0 = 0;
+ int AMF1 = 1; // There is no AMF1 but FMS uses it for some reason, hence special casing.
+ int AMF3 = 3;
+ Double AMF3_INFO_PROPERTY = new Double(3);
+
+ String CONTENT_TYPE_XML = "text/xml; charset=utf-8";
+ String AMF_CONTENT_TYPE = "application/x-amf";
+ String CONTENT_TYPE_PLAIN = "text/plain";
+ String XML_CONTENT_TYPE = "application/xml";
+
+ String RESULT_METHOD = "/onResult";
+ String STATUS_METHOD = "/onStatus";
+
+ int STATUS_OK = 0;
+ int STATUS_ERR = 1;
+ int STATUS_NOTAMF = 2;
+
+ String SECURITY_HEADER_NAME = "Credentials";
+ String SECURITY_PRINCIPAL = "userid";
+ String SECURITY_CREDENTIALS = "password";
+
+ String URL_APPEND_HEADER = "AppendToGatewayUrl";
+ String SERVICE_TYPE_HEADER = "ServiceType";
+
+ String REMOTE_CLASS_FIELD = "_remoteClass";
+ String SUPPORT_REMOTE_CLASS = "SupportRemoteClass";
+ String SUPPORT_DATES_BY_REFERENCE = "SupportDatesByReference";
+
+ String METHOD_POST = "POST";
+ String HEADER_SOAP_ACTION = "SOAPAction";
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/MessageSerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/MessageSerializer.java b/modules/core/src/flex/messaging/io/MessageSerializer.java
old mode 100755
new mode 100644
index bcec06d..6ce3b38
--- a/modules/core/src/flex/messaging/io/MessageSerializer.java
+++ b/modules/core/src/flex/messaging/io/MessageSerializer.java
@@ -1,39 +1,39 @@
-/*
- * 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.io;
-
-import flex.messaging.io.amf.ActionMessage;
-import flex.messaging.io.amf.AmfTrace;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @author Peter Farland
- *
- * @exclude
- */
-public interface MessageSerializer
-{
- void setVersion(int value);
-
- void initialize(SerializationContext context, OutputStream out, AmfTrace trace);
-
- void writeMessage(ActionMessage m) throws IOException;
-
- void writeObject(Object value) throws IOException;
-}
+/*
+ * 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.io;
+
+import flex.messaging.io.amf.ActionMessage;
+import flex.messaging.io.amf.AmfTrace;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author Peter Farland
+ *
+ * @exclude
+ */
+public interface MessageSerializer
+{
+ void setVersion(int value);
+
+ void initialize(SerializationContext context, OutputStream out, AmfTrace trace);
+
+ void writeMessage(ActionMessage m) throws IOException;
+
+ void writeObject(Object value) throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/ObjectProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/ObjectProxy.java b/modules/core/src/flex/messaging/io/ObjectProxy.java
old mode 100755
new mode 100644
index e5e4393..35fc9b3
--- a/modules/core/src/flex/messaging/io/ObjectProxy.java
+++ b/modules/core/src/flex/messaging/io/ObjectProxy.java
@@ -1,73 +1,73 @@
-/*
- * 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.io;
-
-import java.io.Externalizable;
-import java.io.ObjectInput;
-import java.io.IOException;
-import java.io.ObjectOutput;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * Flex's ObjectProxy class allows an anonymous, dynamic ActionScript Object
- * to be bindable and report change events. Since ObjectProxy only wraps
- * the ActionScript Object type we can map the class to a java.util.HashMap on the
- * server, since the user would expect this type to be deserialized as a
- * java.util.HashMap as it is...
- *
- * @author Peter Farland
- */
-public class ObjectProxy extends HashMap implements Externalizable
-{
- static final long serialVersionUID = 6978936573135117900L;
-
- public ObjectProxy()
- {
- super();
- }
-
- public ObjectProxy(int initialCapacity)
- {
- super(initialCapacity);
- }
-
- public ObjectProxy(int initialCapacity, float loadFactor)
- {
- super(initialCapacity, loadFactor);
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- Object value = in.readObject();
- if (value instanceof Map)
- {
- putAll((Map)value);
- }
- }
-
- public void writeExternal(ObjectOutput out) throws IOException
- {
- // We can't output "this" to the serializer as it would
- // cause a loop back to writeExternal as this is an Externalizable
- // implementation itself!
-
- Map map = new HashMap();
- map.putAll(this);
- out.writeObject(map);
- }
-}
+/*
+ * 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.io;
+
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Flex's ObjectProxy class allows an anonymous, dynamic ActionScript Object
+ * to be bindable and report change events. Since ObjectProxy only wraps
+ * the ActionScript Object type we can map the class to a java.util.HashMap on the
+ * server, since the user would expect this type to be deserialized as a
+ * java.util.HashMap as it is...
+ *
+ * @author Peter Farland
+ */
+public class ObjectProxy extends HashMap implements Externalizable
+{
+ static final long serialVersionUID = 6978936573135117900L;
+
+ public ObjectProxy()
+ {
+ super();
+ }
+
+ public ObjectProxy(int initialCapacity)
+ {
+ super(initialCapacity);
+ }
+
+ public ObjectProxy(int initialCapacity, float loadFactor)
+ {
+ super(initialCapacity, loadFactor);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ Object value = in.readObject();
+ if (value instanceof Map)
+ {
+ putAll((Map)value);
+ }
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ // We can't output "this" to the serializer as it would
+ // cause a loop back to writeExternal as this is an Externalizable
+ // implementation itself!
+
+ Map map = new HashMap();
+ map.putAll(this);
+ out.writeObject(map);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/PageableRowSet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/PageableRowSet.java b/modules/core/src/flex/messaging/io/PageableRowSet.java
old mode 100755
new mode 100644
index 1a6f4dd..672b127
--- a/modules/core/src/flex/messaging/io/PageableRowSet.java
+++ b/modules/core/src/flex/messaging/io/PageableRowSet.java
@@ -1,93 +1,93 @@
-/*
- * 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.io;
-
-import java.sql.SQLException;
-import java.util.Map;
-
-/**
- * Implementations of this class are recoginized by the serialization filter
- * as result sets that are pageable. A pageable result set is a server side
- * cache of a query result (that implements java.sql.ResultSet) and is
- * typically stored in the session object. Users can request a subset of
- * data from the object given that they know it's id.
- *
- * @author Mark Sheppard
- * @author Peter Farland
- * @see javax.sql.RowSet
- */
-public interface PageableRowSet
-{
- /**
- * Constants for getRecords map keys.
- */
- String PAGE = "Page";
- String CURSOR = "Cursor";
-
- /**
- * List the column names of the result set.
- *
- * @return String[] An array of the column names as strings, as ordered
- * by the result set provider's column number assignment.
- */
- String[] getColumnNames() throws SQLException;
-
- /**
- * Use this method to get a subset of records.
- * A map is returned with two fields, the first being the
- * row number the data page started from, and the second
- * being the array of arrays for the actual data page.
- * @param startIndex the start index of the records
- * @param count the total count
- * @return Map Contains two fields, the page's row index and the actual data array.
- */
- Map getRecords(int startIndex, int count) throws SQLException;
-
- /**
- * Get the total number of rows in the result set
- * @return int The total number of rows in the result set.
- */
- int getRowCount();
-
- /**
- * If this function returns a number >= the total number of records in the recordset,
- * then the recordset should be simply returned to the client in full. However,
- * if it is < the total size, then this object itself is saved in Session data,
- * and tagged with a unique ID.
- * @return int the initial download count
- */
- int getInitialDownloadCount();
-
-
- /**
- * Get the paged result ID.
- * @return String This paged result's (universally unique) id.
- */
- String getID();
-
- /**
- * Get the name of the service that manages the pages
- * @return String The name of the service that will manage this paged result.
- */
- String getServiceName();
-
- /**
- * Set the name of the service that manages the pages.
- * @param serviceName Update the name of the service that manages the pages for this query.
- */
- void setServicename(String serviceName);
-}
+/*
+ * 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.io;
+
+import java.sql.SQLException;
+import java.util.Map;
+
+/**
+ * Implementations of this class are recoginized by the serialization filter
+ * as result sets that are pageable. A pageable result set is a server side
+ * cache of a query result (that implements java.sql.ResultSet) and is
+ * typically stored in the session object. Users can request a subset of
+ * data from the object given that they know it's id.
+ *
+ * @author Mark Sheppard
+ * @author Peter Farland
+ * @see javax.sql.RowSet
+ */
+public interface PageableRowSet
+{
+ /**
+ * Constants for getRecords map keys.
+ */
+ String PAGE = "Page";
+ String CURSOR = "Cursor";
+
+ /**
+ * List the column names of the result set.
+ *
+ * @return String[] An array of the column names as strings, as ordered
+ * by the result set provider's column number assignment.
+ */
+ String[] getColumnNames() throws SQLException;
+
+ /**
+ * Use this method to get a subset of records.
+ * A map is returned with two fields, the first being the
+ * row number the data page started from, and the second
+ * being the array of arrays for the actual data page.
+ * @param startIndex the start index of the records
+ * @param count the total count
+ * @return Map Contains two fields, the page's row index and the actual data array.
+ */
+ Map getRecords(int startIndex, int count) throws SQLException;
+
+ /**
+ * Get the total number of rows in the result set
+ * @return int The total number of rows in the result set.
+ */
+ int getRowCount();
+
+ /**
+ * If this function returns a number >= the total number of records in the recordset,
+ * then the recordset should be simply returned to the client in full. However,
+ * if it is < the total size, then this object itself is saved in Session data,
+ * and tagged with a unique ID.
+ * @return int the initial download count
+ */
+ int getInitialDownloadCount();
+
+
+ /**
+ * Get the paged result ID.
+ * @return String This paged result's (universally unique) id.
+ */
+ String getID();
+
+ /**
+ * Get the name of the service that manages the pages
+ * @return String The name of the service that will manage this paged result.
+ */
+ String getServiceName();
+
+ /**
+ * Set the name of the service that manages the pages.
+ * @param serviceName Update the name of the service that manages the pages for this query.
+ */
+ void setServicename(String serviceName);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/PageableRowSetProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/PageableRowSetProxy.java b/modules/core/src/flex/messaging/io/PageableRowSetProxy.java
old mode 100755
new mode 100644
index c973881..3fa7948
--- a/modules/core/src/flex/messaging/io/PageableRowSetProxy.java
+++ b/modules/core/src/flex/messaging/io/PageableRowSetProxy.java
@@ -1,157 +1,157 @@
-/*
- * 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.io;
-
-import flex.messaging.MessageException;
-
-import javax.sql.RowSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A wrapped PageableRowSet instance requires custom serialization so this
- * legacy type has been made to fit the PropertyProxy interface.
- *
- * TODO: This proxy is similar to features made possible with Externalizable
- * so PageableRowSet/RecordSet should be moved to an Externalizable
- * implementation.
- *
- * @author Peter Farland
- */
-public class PageableRowSetProxy extends AbstractProxy
-{
- static final long serialVersionUID = 1121859941216924326L;
-
- public static final int HUGE_PAGE_SIZE = Integer.MAX_VALUE;
-
- /**
- * AS Object Type Name.
- */
- public static final String AS_TYPE_NAME = "RecordSet";
-
- public static final Integer RECORD_SET_VERSION = new Integer(1);
-
- /**
- * ActionScript (AS) Object Key Names.
- */
- public static final String TOTAL_COUNT = "totalCount";
- public static final String COLUMN_NAMES = "columnNames";
- public static final String INITIAL_DATA = "initialData";
- public static final String SERVICE_NAME = "serviceName";
- public static final String SERVER_INFO = "serverInfo";
- public static final String VERSION = "version";
- public static final String CURSOR = "cursor";
- public static final String ID = "id";
-
- public static final List propertyNameCache = new ArrayList();
- static
- {
- propertyNameCache.add(SERVER_INFO);
- }
-
- public PageableRowSetProxy()
- {
- super(null);
- alias = AS_TYPE_NAME;
- }
-
- public PageableRowSetProxy(RowSet defaultInstance)
- {
- super(defaultInstance);
- alias = AS_TYPE_NAME;
- }
-
- public PageableRowSetProxy(PageableRowSet defaultInstance)
- {
- super(defaultInstance);
- alias = AS_TYPE_NAME;
- }
-
- public String getAlias(Object instance)
- {
- return AS_TYPE_NAME;
- }
-
- public List getPropertyNames(Object instance)
- {
- return propertyNameCache;
- }
-
- public Class getType(Object instance, String propertyName)
- {
- if (SERVER_INFO.equals(propertyName))
- {
- return HashMap.class;
- }
- else
- {
- return null;
- }
- }
-
- public Object getValue(Object instance, String propertyName)
- {
- Object value = null;
-
- if (instance instanceof RowSet)
- {
- //Wrap in PageableRowSet just for its utility methods and don't create an id.
- instance = new PagedRowSet((RowSet)instance, HUGE_PAGE_SIZE, false);
- }
-
- if (instance instanceof PageableRowSet)
- {
- PageableRowSet prs = (PageableRowSet)instance;
-
- if (SERVER_INFO.equals(propertyName))
- {
- try
- {
- HashMap serverInfo = new HashMap();
- serverInfo.put(ID, prs.getID());
-
- Map pageInfo = prs.getRecords(1, prs.getInitialDownloadCount());
-
- serverInfo.put(TOTAL_COUNT, new Integer(prs.getRowCount()));
- serverInfo.put(INITIAL_DATA, pageInfo.get(PageableRowSet.PAGE)); //Array of Arrays - the first page returned
- serverInfo.put(CURSOR, pageInfo.get(PageableRowSet.CURSOR)); //Integer
- serverInfo.put(SERVICE_NAME, prs.getServiceName());
- serverInfo.put(COLUMN_NAMES, prs.getColumnNames());
- serverInfo.put(VERSION, RECORD_SET_VERSION);
- value = serverInfo;
- }
- catch (SQLException ex)
- {
- MessageException e = new MessageException();
- e.setMessage("Error encountered serializing RowSet.");
- e.setRootCause(ex);
- throw e;
- }
- }
- }
-
- return value;
- }
-
- public void setValue(Object instance, String propertyName, Object value)
- {
- // Client-to-server not supported
- }
-}
+/*
+ * 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.io;
+
+import flex.messaging.MessageException;
+
+import javax.sql.RowSet;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A wrapped PageableRowSet instance requires custom serialization so this
+ * legacy type has been made to fit the PropertyProxy interface.
+ *
+ * TODO: This proxy is similar to features made possible with Externalizable
+ * so PageableRowSet/RecordSet should be moved to an Externalizable
+ * implementation.
+ *
+ * @author Peter Farland
+ */
+public class PageableRowSetProxy extends AbstractProxy
+{
+ static final long serialVersionUID = 1121859941216924326L;
+
+ public static final int HUGE_PAGE_SIZE = Integer.MAX_VALUE;
+
+ /**
+ * AS Object Type Name.
+ */
+ public static final String AS_TYPE_NAME = "RecordSet";
+
+ public static final Integer RECORD_SET_VERSION = new Integer(1);
+
+ /**
+ * ActionScript (AS) Object Key Names.
+ */
+ public static final String TOTAL_COUNT = "totalCount";
+ public static final String COLUMN_NAMES = "columnNames";
+ public static final String INITIAL_DATA = "initialData";
+ public static final String SERVICE_NAME = "serviceName";
+ public static final String SERVER_INFO = "serverInfo";
+ public static final String VERSION = "version";
+ public static final String CURSOR = "cursor";
+ public static final String ID = "id";
+
+ public static final List propertyNameCache = new ArrayList();
+ static
+ {
+ propertyNameCache.add(SERVER_INFO);
+ }
+
+ public PageableRowSetProxy()
+ {
+ super(null);
+ alias = AS_TYPE_NAME;
+ }
+
+ public PageableRowSetProxy(RowSet defaultInstance)
+ {
+ super(defaultInstance);
+ alias = AS_TYPE_NAME;
+ }
+
+ public PageableRowSetProxy(PageableRowSet defaultInstance)
+ {
+ super(defaultInstance);
+ alias = AS_TYPE_NAME;
+ }
+
+ public String getAlias(Object instance)
+ {
+ return AS_TYPE_NAME;
+ }
+
+ public List getPropertyNames(Object instance)
+ {
+ return propertyNameCache;
+ }
+
+ public Class getType(Object instance, String propertyName)
+ {
+ if (SERVER_INFO.equals(propertyName))
+ {
+ return HashMap.class;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Object getValue(Object instance, String propertyName)
+ {
+ Object value = null;
+
+ if (instance instanceof RowSet)
+ {
+ //Wrap in PageableRowSet just for its utility methods and don't create an id.
+ instance = new PagedRowSet((RowSet)instance, HUGE_PAGE_SIZE, false);
+ }
+
+ if (instance instanceof PageableRowSet)
+ {
+ PageableRowSet prs = (PageableRowSet)instance;
+
+ if (SERVER_INFO.equals(propertyName))
+ {
+ try
+ {
+ HashMap serverInfo = new HashMap();
+ serverInfo.put(ID, prs.getID());
+
+ Map pageInfo = prs.getRecords(1, prs.getInitialDownloadCount());
+
+ serverInfo.put(TOTAL_COUNT, new Integer(prs.getRowCount()));
+ serverInfo.put(INITIAL_DATA, pageInfo.get(PageableRowSet.PAGE)); //Array of Arrays - the first page returned
+ serverInfo.put(CURSOR, pageInfo.get(PageableRowSet.CURSOR)); //Integer
+ serverInfo.put(SERVICE_NAME, prs.getServiceName());
+ serverInfo.put(COLUMN_NAMES, prs.getColumnNames());
+ serverInfo.put(VERSION, RECORD_SET_VERSION);
+ value = serverInfo;
+ }
+ catch (SQLException ex)
+ {
+ MessageException e = new MessageException();
+ e.setMessage("Error encountered serializing RowSet.");
+ e.setRootCause(ex);
+ throw e;
+ }
+ }
+ }
+
+ return value;
+ }
+
+ public void setValue(Object instance, String propertyName, Object value)
+ {
+ // Client-to-server not supported
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/PagedRowSet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/PagedRowSet.java b/modules/core/src/flex/messaging/io/PagedRowSet.java
old mode 100755
new mode 100644
index 8dfd2e6..06bc0e9
--- a/modules/core/src/flex/messaging/io/PagedRowSet.java
+++ b/modules/core/src/flex/messaging/io/PagedRowSet.java
@@ -1,363 +1,363 @@
-/*
- * 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.io;
-
-import flex.messaging.util.UUIDUtils;
-
-import javax.sql.RowSet;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A wrapper for a RowSet to make it pageable. This technique is recommended
- * if the RowSet is 'too big' to download all at once, AND the developer's
- * client-side code is capable of dealing with non-fully-populated recordsets,
- * that is, ActionScript RecordSets which are missing some of their data.
- *
- * @author Mark Sheppard
- * @author Peter Farland
- * @version 1.0
- */
-public class PagedRowSet implements PageableRowSet
-{
- private RowSet rowSet;
- private String[] colNames;
- private int pageSize = 50; //Default to 50 records a page
- private int colCount = 0;
- private int rowCount = 0;
-
- private String id = null;
- private String serviceName = null;
-
- /**
- * Pageable Rowset Service Name.
- */
- public static final String DEFAULT_PAGING_SERVICE_NAME = "PageableRowSetCache";
-
-
- /**
- * Constructor
- * <p>
- * Creates a UUID for this object. Format: `XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
- * </p>
- *
- * @param r The RowSet to be paged.
- * @param p The initial page size.
- */
- public PagedRowSet(RowSet r, int p)
- {
- serviceName = DEFAULT_PAGING_SERVICE_NAME;
- rowSet = r;
- pageSize = p;
- id = UUIDUtils.createUUID();
- init();
- }
-
- /**
- * Allows the unique id generation of the RowSet to be toggled.
- * @see #PagedRowSet(RowSet, int)
- *
- * @param r the row set
- * @param p the page size
- * @param createID should we create an id?
- */
- public PagedRowSet(RowSet r, int p, boolean createID)
- {
- serviceName = DEFAULT_PAGING_SERVICE_NAME;
- rowSet = r;
- pageSize = p;
- if (createID)
- {
- id = UUIDUtils.createUUID();
- }
- init();
- }
-
- private void init()
- {
- if (rowSet != null)
- {
- //Initialize columns
- initColumns();
-
- //Initialize records
- initRecords();
- }
- else
- {
- colNames = new String[0];
- }
- }
-
-
- private synchronized void initColumns()
- {
- try
- {
- ResultSetMetaData rsmd = rowSet.getMetaData();
- if (rsmd != null)
- {
- colCount = rsmd.getColumnCount();
- }
- }
- catch (SQLException ex)
- {
- colCount = 0;
- }
- }
-
-
- private synchronized void initRecords()
- {
- //Determine rs size
- if (rowSet != null)
- {
- try
- {
- int currentIndex = rowSet.getRow();
-
- //Go to the end and get that row number
- if (rowSet.last())
- {
- rowCount = rowSet.getRow();
- }
-
- //Put the cursor back
- if (currentIndex > 0)
- {
- rowSet.absolute(currentIndex);
- }
- else
- {
- rowSet.beforeFirst();
- }
- }
- catch (SQLException ex)
- {
- //TODO: Decide whether if absolute() not be supported, try first() as a last resort??
- try
- {
- rowSet.first();
- }
- catch (SQLException se)
- {
- //we won't try anymore.
- }
- }
- }
- }
-
-
- /**
- * List the column names of the result set.
- *
- * @return String[] An array of the column names as strings, as ordered
- * by the result set provider's column number assignment.
- */
- public synchronized String[] getColumnNames()
- {
- // Cache the column names lookup
- if (colNames == null)
- {
- try
- {
- //Ensure column count is initialized
- if (colCount == 0)
- {
- initColumns();
- }
-
- colNames = new String[colCount];
-
- for (int i = 0; i < colCount; i++)
- {
- //Note: column numbers start at 1
- colNames[i] = rowSet.getMetaData().getColumnName(i + 1);
- }
- }
- catch (SQLException ex)
- {
- colNames = new String[0];
- }
- }
-
- // Create a copy
- String[] ret = new String[colNames.length];
- System.arraycopy(colNames, 0, ret, 0, colNames.length);
- return ret;
- }
-
-
- /**
- * Use this method to get a map of the index used to start the data page,
- * and an array of arrays of the actual data page itself.
- *
- * @param startIndex starting index
- * @param count how many records to return
- * @return Map A map with two fields, the index of the row to start the page, and an array of
- * arrays for the actual data page.
- * @throws SQLException if unable to get data from the rowset
- */
- public synchronized Map getRecords(int startIndex, int count) throws SQLException
- {
- List aRecords = new ArrayList(); //Don't initialize with count as it could be Integer.MAX_VALUE
-
- //Ensure column count is initialized
- if (colCount == 0)
- {
- initColumns();
- }
-
- //Starting index cannot be less than 1
- if (startIndex < 1)
- startIndex = 1;
-
- //Populate the page, moving cursor to index
- if (rowSet.absolute(startIndex))
- {
- //Loop over the result set for the count specified
- for (int i = 0; i < count; i++)
- {
- boolean hasNext;
-
- List row;
-
- if (colCount > 0)
- {
- row = new ArrayList(rowCount + 1);
- //Loop over columns to create an array for the row
- for (int j = 1; j <= colCount; j++)
- {
- Object data = rowSet.getObject(j);
- if (data instanceof Clob)
- {
- Clob clob = (Clob) data;
- row.add(clob.getSubString(0, (int) clob.length()));
- }
- else if (data instanceof Blob)
- {
- Blob blob = (Blob) data;
- byte[] bytes = blob.getBytes(1, (int) blob.length());
- row.add(bytes);
- }
- else
- row.add(data);
- }
- }
- else //HACK: Handle any ColdFusion Query Objects that have no column metadata!
- {
- row = new ArrayList();
-
- try
- {
- //Get as many columns as possible to build the row
- //Stop on error or the first null column returned.
- for (int j = 1; j <= 50; j++)
- {
- Object o = rowSet.getObject(j);
- if (o != null)
- {
- row.add(o);
- }
- else
- {
- break;
- }
- }
- }
- catch (SQLException ex)
- {
- //Stop looking and just add the row.
- }
- }
-
- aRecords.add(row.toArray());
-
- hasNext = rowSet.next();
-
- //Cursor beyond last row, stop!
- if (!hasNext)
- {
- break;
- }
- }
- }
-
- Map result = new HashMap(2);
- result.put(PAGE, aRecords.toArray());
- result.put(CURSOR, Integer.valueOf(startIndex));
-
- return result;
- }
-
- /**
- * Get the row count.
- *
- * @return int The total number of rows in the result set.
- */
- public int getRowCount()
- {
- return rowCount;
- }
-
- /**
- * If this function returns a number >= the total number of rows in the result set,
- * then the result set should be simply returned to the client in full. However,
- * if it is < the total size, then this object itself is saved in Session data,
- * and tagged with a unique ID.
- *
- * @return the page size
- */
- public int getInitialDownloadCount()
- {
- return pageSize;
- }
-
- /**
- * Return the id of this row set.
- * @return the id
- */
- public String getID()
- {
- return id;
- }
-
- /**
- * Get the service name.
- *
- * @return String The name of the service that will manage this paged result.
- */
- public String getServiceName()
- {
- return serviceName;
- }
-
- /**
- * Set the service name.
- *
- * @param serviceName Update the name of the service that manages the pages for this query.
- */
- public void setServicename(String serviceName)
- {
- this.serviceName = serviceName;
- }
-}
+/*
+ * 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.io;
+
+import flex.messaging.util.UUIDUtils;
+
+import javax.sql.RowSet;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A wrapper for a RowSet to make it pageable. This technique is recommended
+ * if the RowSet is 'too big' to download all at once, AND the developer's
+ * client-side code is capable of dealing with non-fully-populated recordsets,
+ * that is, ActionScript RecordSets which are missing some of their data.
+ *
+ * @author Mark Sheppard
+ * @author Peter Farland
+ * @version 1.0
+ */
+public class PagedRowSet implements PageableRowSet
+{
+ private RowSet rowSet;
+ private String[] colNames;
+ private int pageSize = 50; //Default to 50 records a page
+ private int colCount = 0;
+ private int rowCount = 0;
+
+ private String id = null;
+ private String serviceName = null;
+
+ /**
+ * Pageable Rowset Service Name.
+ */
+ public static final String DEFAULT_PAGING_SERVICE_NAME = "PageableRowSetCache";
+
+
+ /**
+ * Constructor
+ * <p>
+ * Creates a UUID for this object. Format: `XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
+ * </p>
+ *
+ * @param r The RowSet to be paged.
+ * @param p The initial page size.
+ */
+ public PagedRowSet(RowSet r, int p)
+ {
+ serviceName = DEFAULT_PAGING_SERVICE_NAME;
+ rowSet = r;
+ pageSize = p;
+ id = UUIDUtils.createUUID();
+ init();
+ }
+
+ /**
+ * Allows the unique id generation of the RowSet to be toggled.
+ * @see #PagedRowSet(RowSet, int)
+ *
+ * @param r the row set
+ * @param p the page size
+ * @param createID should we create an id?
+ */
+ public PagedRowSet(RowSet r, int p, boolean createID)
+ {
+ serviceName = DEFAULT_PAGING_SERVICE_NAME;
+ rowSet = r;
+ pageSize = p;
+ if (createID)
+ {
+ id = UUIDUtils.createUUID();
+ }
+ init();
+ }
+
+ private void init()
+ {
+ if (rowSet != null)
+ {
+ //Initialize columns
+ initColumns();
+
+ //Initialize records
+ initRecords();
+ }
+ else
+ {
+ colNames = new String[0];
+ }
+ }
+
+
+ private synchronized void initColumns()
+ {
+ try
+ {
+ ResultSetMetaData rsmd = rowSet.getMetaData();
+ if (rsmd != null)
+ {
+ colCount = rsmd.getColumnCount();
+ }
+ }
+ catch (SQLException ex)
+ {
+ colCount = 0;
+ }
+ }
+
+
+ private synchronized void initRecords()
+ {
+ //Determine rs size
+ if (rowSet != null)
+ {
+ try
+ {
+ int currentIndex = rowSet.getRow();
+
+ //Go to the end and get that row number
+ if (rowSet.last())
+ {
+ rowCount = rowSet.getRow();
+ }
+
+ //Put the cursor back
+ if (currentIndex > 0)
+ {
+ rowSet.absolute(currentIndex);
+ }
+ else
+ {
+ rowSet.beforeFirst();
+ }
+ }
+ catch (SQLException ex)
+ {
+ //TODO: Decide whether if absolute() not be supported, try first() as a last resort??
+ try
+ {
+ rowSet.first();
+ }
+ catch (SQLException se)
+ {
+ //we won't try anymore.
+ }
+ }
+ }
+ }
+
+
+ /**
+ * List the column names of the result set.
+ *
+ * @return String[] An array of the column names as strings, as ordered
+ * by the result set provider's column number assignment.
+ */
+ public synchronized String[] getColumnNames()
+ {
+ // Cache the column names lookup
+ if (colNames == null)
+ {
+ try
+ {
+ //Ensure column count is initialized
+ if (colCount == 0)
+ {
+ initColumns();
+ }
+
+ colNames = new String[colCount];
+
+ for (int i = 0; i < colCount; i++)
+ {
+ //Note: column numbers start at 1
+ colNames[i] = rowSet.getMetaData().getColumnName(i + 1);
+ }
+ }
+ catch (SQLException ex)
+ {
+ colNames = new String[0];
+ }
+ }
+
+ // Create a copy
+ String[] ret = new String[colNames.length];
+ System.arraycopy(colNames, 0, ret, 0, colNames.length);
+ return ret;
+ }
+
+
+ /**
+ * Use this method to get a map of the index used to start the data page,
+ * and an array of arrays of the actual data page itself.
+ *
+ * @param startIndex starting index
+ * @param count how many records to return
+ * @return Map A map with two fields, the index of the row to start the page, and an array of
+ * arrays for the actual data page.
+ * @throws SQLException if unable to get data from the rowset
+ */
+ public synchronized Map getRecords(int startIndex, int count) throws SQLException
+ {
+ List aRecords = new ArrayList(); //Don't initialize with count as it could be Integer.MAX_VALUE
+
+ //Ensure column count is initialized
+ if (colCount == 0)
+ {
+ initColumns();
+ }
+
+ //Starting index cannot be less than 1
+ if (startIndex < 1)
+ startIndex = 1;
+
+ //Populate the page, moving cursor to index
+ if (rowSet.absolute(startIndex))
+ {
+ //Loop over the result set for the count specified
+ for (int i = 0; i < count; i++)
+ {
+ boolean hasNext;
+
+ List row;
+
+ if (colCount > 0)
+ {
+ row = new ArrayList(rowCount + 1);
+ //Loop over columns to create an array for the row
+ for (int j = 1; j <= colCount; j++)
+ {
+ Object data = rowSet.getObject(j);
+ if (data instanceof Clob)
+ {
+ Clob clob = (Clob) data;
+ row.add(clob.getSubString(0, (int) clob.length()));
+ }
+ else if (data instanceof Blob)
+ {
+ Blob blob = (Blob) data;
+ byte[] bytes = blob.getBytes(1, (int) blob.length());
+ row.add(bytes);
+ }
+ else
+ row.add(data);
+ }
+ }
+ else //HACK: Handle any ColdFusion Query Objects that have no column metadata!
+ {
+ row = new ArrayList();
+
+ try
+ {
+ //Get as many columns as possible to build the row
+ //Stop on error or the first null column returned.
+ for (int j = 1; j <= 50; j++)
+ {
+ Object o = rowSet.getObject(j);
+ if (o != null)
+ {
+ row.add(o);
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ catch (SQLException ex)
+ {
+ //Stop looking and just add the row.
+ }
+ }
+
+ aRecords.add(row.toArray());
+
+ hasNext = rowSet.next();
+
+ //Cursor beyond last row, stop!
+ if (!hasNext)
+ {
+ break;
+ }
+ }
+ }
+
+ Map result = new HashMap(2);
+ result.put(PAGE, aRecords.toArray());
+ result.put(CURSOR, Integer.valueOf(startIndex));
+
+ return result;
+ }
+
+ /**
+ * Get the row count.
+ *
+ * @return int The total number of rows in the result set.
+ */
+ public int getRowCount()
+ {
+ return rowCount;
+ }
+
+ /**
+ * If this function returns a number >= the total number of rows in the result set,
+ * then the result set should be simply returned to the client in full. However,
+ * if it is < the total size, then this object itself is saved in Session data,
+ * and tagged with a unique ID.
+ *
+ * @return the page size
+ */
+ public int getInitialDownloadCount()
+ {
+ return pageSize;
+ }
+
+ /**
+ * Return the id of this row set.
+ * @return the id
+ */
+ public String getID()
+ {
+ return id;
+ }
+
+ /**
+ * Get the service name.
+ *
+ * @return String The name of the service that will manage this paged result.
+ */
+ public String getServiceName()
+ {
+ return serviceName;
+ }
+
+ /**
+ * Set the service name.
+ *
+ * @param serviceName Update the name of the service that manages the pages for this query.
+ */
+ public void setServicename(String serviceName)
+ {
+ this.serviceName = serviceName;
+ }
+}
[08/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/BaseStreamingHTTPEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/BaseStreamingHTTPEndpoint.java b/modules/core/src/flex/messaging/endpoints/BaseStreamingHTTPEndpoint.java
old mode 100755
new mode 100644
index c1d5071..ece3144
--- a/modules/core/src/flex/messaging/endpoints/BaseStreamingHTTPEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/BaseStreamingHTTPEndpoint.java
@@ -1,1226 +1,1226 @@
-/*
- * 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.endpoints;
-
-import flex.messaging.FlexContext;
-import flex.messaging.FlexSession;
-import flex.messaging.HttpFlexSession;
-import flex.messaging.MessageException;
-import flex.messaging.client.EndpointPushNotifier;
-import flex.messaging.client.FlexClient;
-import flex.messaging.client.FlushResult;
-import flex.messaging.client.UserAgentSettings;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.log.Log;
-import flex.messaging.messages.AcknowledgeMessage;
-import flex.messaging.messages.AsyncMessage;
-import flex.messaging.messages.CommandMessage;
-import flex.messaging.messages.Message;
-import flex.messaging.messages.MessagePerformanceInfo;
-import flex.messaging.messages.MessagePerformanceUtils;
-import flex.messaging.util.TimeoutManager;
-import flex.messaging.util.UserAgentManager;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ThreadFactory;
-
-/**
- * Base class for HTTP-based endpoints that support streaming HTTP connections to
- * connected clients.
- * Each streaming connection managed by this endpoint consumes one of the request
- * handler threads provided by the servlet container, so it is not highly scalable
- * but offers performance advantages over client polling for clients receiving
- * a steady, rapid stream of pushed messages.
- * This endpoint does not support polling clients and will fault any poll requests
- * that are received. To support polling clients use subclasses of
- * BaseHTTPEndpoint instead.
- */
-public abstract class BaseStreamingHTTPEndpoint extends BaseHTTPEndpoint
-{
- //--------------------------------------------------------------------------
- //
- // Private Static Constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * This token is used in chunked HTTP responses frequently so initialize it statically for general use.
- */
- private static final byte[] CRLF_BYTES = {(byte)13, (byte)10};
-
- /**
- * This token is used for the terminal chunk within a chunked response.
- */
- private static final byte ZERO_BYTE = (byte)48;
-
- /**
- * This token is used to signal that a chunk of data should be skipped by the client.
- */
- private static final byte NULL_BYTE = (byte)0;
-
- /**
- * Parameter name for 'command' passed in a request for a new streaming connection.
- */
- private static final String COMMAND_PARAM_NAME = "command";
-
- /**
- * This is the token at the end of the HTTP request line that indicates that it is
- * a stream connection that should be held open to push data back to the client,
- * as opposed to a regular request-response message.
- */
- private static final String OPEN_COMMAND = "open";
-
- /**
- * This is the token at the end of the HTTP request line that indicates that it is
- * a stream connection that should be closed.
- */
- private static final String CLOSE_COMMAND = "close";
-
- /**
- * Parameter name for the stream ID; passed with commands for an existing streaming connection.
- */
- private static final String STREAM_ID_PARAM_NAME = "streamId";
-
- /**
- * Constant for HTTP/1.0.
- */
- private static final String HTTP_1_0 = "HTTP/1.0";
-
- /**
- * Thread name suffix for request threads that are servicing a pinned open streaming connection.
- */
- private static final String STREAMING_THREAD_NAME_EXTENSION = "-in-streaming-mode";
-
- /**
- * Configuration constants.
- */
- private static final String PROPERTY_CONNECTION_IDLE_TIMEOUT_MINUTES = "connection-idle-timeout-minutes";
- private static final String PROPERTY_LEGACY_CONNECTION_IDLE_TIMEOUT_MINUTES = "idle-timeout-minutes";
- private static final String MAX_STREAMING_CLIENTS = "max-streaming-clients";
- private static final String SERVER_TO_CLIENT_HEARTBEAT_MILLIS = "server-to-client-heartbeat-millis";
- private static final String PROPERTY_INVALIDATE_MESSAGECLIENT_ON_STREAMING_CLOSE = "invalidate-messageclient-on-streaming-close";
-
- /**
- * Defaults.
- */
- private static final boolean DEFAULT_INVALIDATE_MESSAGECLIENT_ON_STREAMING_CLOSE = false;
- private static final int DEFAULT_SERVER_TO_CLIENT_HEARTBEAT_MILLIS = 5000;
- private static final int DEFAULT_MAX_STREAMING_CLIENTS = 10;
-
- /**
- * Errors.
- */
- public static final String POLL_NOT_SUPPORTED_CODE = "Server.PollNotSupported";
- public static final int POLL_NOT_SUPPORTED_MESSAGE = 10034;
-
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>BaseStreamingHTTPEndpoint</code>.
- */
- public BaseStreamingHTTPEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs an <code>BaseStreamingHTTPEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>BaseStreamingHTTPEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public BaseStreamingHTTPEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Initialize, validate, start, and stop methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes the <code>Endpoint</code> with the properties.
- * If subclasses override this method, they must call <code>super.initialize()</code>.
- *
- * @param id The ID of the <code>Endpoint</code>.
- * @param properties Properties for the <code>Endpoint</code>.
- */
- @Override
- public void initialize(String id, ConfigMap properties)
- {
- super.initialize(id, properties);
-
- if (properties == null || properties.size() == 0)
- {
- // Initialize default user agent manager settings.
- UserAgentManager.setupUserAgentManager(null, userAgentManager);
-
- return; // Nothing else to initialize.
- }
-
- // The interval that the server will check if the client is still available.
- serverToClientHeartbeatMillis = properties.getPropertyAsLong(SERVER_TO_CLIENT_HEARTBEAT_MILLIS, DEFAULT_SERVER_TO_CLIENT_HEARTBEAT_MILLIS);
- setServerToClientHeartbeatMillis(serverToClientHeartbeatMillis);
-
- setInvalidateMessageClientOnStreamingClose(properties.getPropertyAsBoolean(PROPERTY_INVALIDATE_MESSAGECLIENT_ON_STREAMING_CLOSE, DEFAULT_INVALIDATE_MESSAGECLIENT_ON_STREAMING_CLOSE));
-
- // Number of minutes a client can remain idle before the server times the connection out.
- int connectionIdleTimeoutMinutes = properties.getPropertyAsInt(PROPERTY_CONNECTION_IDLE_TIMEOUT_MINUTES, getConnectionIdleTimeoutMinutes());
- if (connectionIdleTimeoutMinutes != 0)
- {
- setConnectionIdleTimeoutMinutes(connectionIdleTimeoutMinutes);
- }
- else
- {
- connectionIdleTimeoutMinutes = properties.getPropertyAsInt(PROPERTY_LEGACY_CONNECTION_IDLE_TIMEOUT_MINUTES, getConnectionIdleTimeoutMinutes());
- if (connectionIdleTimeoutMinutes != 0)
- setConnectionIdleTimeoutMinutes(connectionIdleTimeoutMinutes);
- }
-
- // User-agent configuration for kick-start bytes and max streaming connections per session.
- UserAgentManager.setupUserAgentManager(properties, userAgentManager);
-
- // Maximum number of clients allowed to have streaming HTTP connections with the endpoint.
- maxStreamingClients = properties.getPropertyAsInt(MAX_STREAMING_CLIENTS, DEFAULT_MAX_STREAMING_CLIENTS);
-
- // Set initial state for the canWait flag based on whether we allow waits or not.
- canStream = (maxStreamingClients > 0);
- }
-
-
- @Override
- public void start()
- {
- if (isStarted())
- return;
-
- super.start();
-
- if (connectionIdleTimeoutMinutes > 0)
- {
- pushNotifierTimeoutManager = new TimeoutManager(new ThreadFactory()
- {
- int counter = 1;
- public synchronized Thread newThread(Runnable runnable)
- {
- Thread t = new Thread(runnable);
- t.setName(getId() + "-StreamingConnectionTimeoutThread-" + counter++);
- return t;
- }
- });
- }
-
- currentStreamingRequests = new ConcurrentHashMap<String, EndpointPushNotifier>();
- }
-
- /**
- * (non-JavaDoc)
- * @see flex.messaging.endpoints.AbstractEndpoint#stop()
- */
- @Override
- public void stop()
- {
- if (!isStarted())
- return;
-
- // Shutdown the timeout manager for streaming connections cleanly.
- if (pushNotifierTimeoutManager != null)
- {
- pushNotifierTimeoutManager.shutdown();
- pushNotifierTimeoutManager = null;
- }
-
- // Shutdown any currently open streaming connections.
- for (EndpointPushNotifier notifier : currentStreamingRequests.values())
- notifier.close();
-
- currentStreamingRequests = null;
-
- super.stop();
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Used to synchronize sets and gets to the number of streaming clients.
- */
- protected final Object lock = new Object();
-
- /**
- * Used to keep track of the mapping between user agent match strings and
- * the bytes needed to kickstart their streaming connections.
- */
- protected UserAgentManager userAgentManager = new UserAgentManager();
-
- /**
- * This flag is volatile to allow for consistent reads across thread without
- * needing to pay the cost for a synchronized lock for each read.
- */
- private volatile boolean canStream = true;
-
- /**
- * Manages timing out EndpointPushNotifier instances.
- */
- private volatile TimeoutManager pushNotifierTimeoutManager;
-
- /**
- * A Map(EndpointPushNotifier, Boolean.TRUE) containing all currently open streaming notifiers
- * for this endpoint.
- * Used for clean shutdown.
- */
- private ConcurrentHashMap<String, EndpointPushNotifier> currentStreamingRequests;
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //------------------------------------------
- // invalidateMessageClientOnStreamingClose
- //-----------------------------------------
-
- private volatile boolean invalidateMessageClientOnStreamingClose = DEFAULT_INVALIDATE_MESSAGECLIENT_ON_STREAMING_CLOSE;
-
- /**
- * Returns whether invalidate-messageclient-on-streaming-close is enabled.
- * See {@link BaseStreamingHTTPEndpoint#setInvalidateMessageClientOnStreamingClose(boolean)}
- * for details.
- *
- * @return <code>true</code> if the invalidate-messageclient-on-streaming-close is enabled, <code>false</code> otherwise.
- */
- public boolean isInvalidateMessageClientOnStreamingClose()
- {
- return invalidateMessageClientOnStreamingClose;
- }
-
- /**
- * Sets the invalidate-messageclient-on-streaming close property. If enabled,
- * when the streaming connection is closed for whatever reason (for example, the client is gone),
- * the client's associated MessageClient on the server is invalidated immediately.
- * This is useful in scenarios where there is a constant stream of messages, the client is gone,
- * and the streaming connection is closed, but the session has not timed out on the server yet.
- * In that case, enabling this property will prevent messages accumulating on the session on behalf
- * of the MessageClient that will invalidate.
- * <p>
- * Important: Do not enable this property when reliable messaging is used, otherwise
- * reliable reconnect attempts will not happen correctly.</p>
- *
- * @param value The property value.
- */
- public void setInvalidateMessageClientOnStreamingClose(boolean value)
- {
- invalidateMessageClientOnStreamingClose = value;
- }
-
- //----------------------------------
- // serverToClientHeartbeatMillis
- //----------------------------------
-
- private long serverToClientHeartbeatMillis = DEFAULT_SERVER_TO_CLIENT_HEARTBEAT_MILLIS;
-
- /**
- * Retrieves the number of milliseconds the server will wait before writing a
- * single <code>null</code> byte to the streaming connection, to ensure the client is
- * still available.
- * @return The server-to-client heartbeat time in milliseconds.
- */
- public long getServerToClientHeartbeatMillis()
- {
- return serverToClientHeartbeatMillis;
- }
-
- /**
- * Retrieves the number of milliseconds the server will wait before writing a
- * single <code>null</code> byte to the streaming connection to ensure the client is
- * still available when there are no new messages for the client.
- * A non-positive value means the server will wait forever for new messages and
- * it will not write the <code>null</code> byte to determine if the client is available.
- * @param serverToClientHeartbeatMillis The server-to-client heartbeat time in milliseconds.
- */
- public void setServerToClientHeartbeatMillis(long serverToClientHeartbeatMillis)
- {
- if (serverToClientHeartbeatMillis < 0)
- serverToClientHeartbeatMillis = 0;
- this.serverToClientHeartbeatMillis = serverToClientHeartbeatMillis;
- }
-
- //----------------------------------
- // connectionIdleTimeoutMinutes
- //----------------------------------
-
- private int connectionIdleTimeoutMinutes = 0;
-
- /**
- * Retrieves the number of minutes a client can remain idle before the server
- * times the connection out. The default value is 0, indicating that connections
- * will not be timed out and must be closed by the client or server, either explicitly
- * or by either process terminating.
- *
- * @return The number of minutes a client can remain idle before the server
- * times the connection out.
- */
- public int getConnectionIdleTimeoutMinutes()
- {
- return connectionIdleTimeoutMinutes;
- }
-
- /**
- * Sets the number of minutes a client can remain idle before the server
- * times the connection out. A value of 0 or below indicates that
- * connections will not be timed out.
- *
- * @param value The number of minutes a client can remain idle
- * before the server times the connection out.
- */
- public void setConnectionIdleTimeoutMinutes(int value)
- {
- if (value < 0)
- value = 0;
-
- this.connectionIdleTimeoutMinutes = value;
- }
-
- /**
- * (non-JavaDoc)
- * @deprecated Use {@link BaseStreamingHTTPEndpoint#getConnectionIdleTimeoutMinutes()} instead.
- */
- public int getIdleTimeoutMinutes()
- {
- return getConnectionIdleTimeoutMinutes();
- }
-
- /**
- * (non-JavaDoc)
- * @deprecated Use {@link BaseStreamingHTTPEndpoint#setConnectionIdleTimeoutMinutes(int)} instead.
- */
- public void setIdleTimeoutMinutes(int value)
- {
- setConnectionIdleTimeoutMinutes(value);
- }
-
- //----------------------------------
- // maxStreamingClients
- //----------------------------------
-
- private int maxStreamingClients = DEFAULT_MAX_STREAMING_CLIENTS;
-
- /**
- * Retrieves the maximum number of clients that will be allowed to establish
- * a streaming HTTP connection with the endpoint.
- *
- * @return The maximum number of clients that will be allowed to establish
- * a streaming HTTP connection with the endpoint.
- */
- public int getMaxStreamingClients()
- {
- return maxStreamingClients;
- }
-
- /**
- * Sets the maximum number of clients that will be allowed to establish
- * a streaming HTTP connection with the server.
- *
- * @param maxStreamingClients The maximum number of clients that will be allowed
- * to establish a streaming HTTP connection with the server.
- */
- public void setMaxStreamingClients(int maxStreamingClients)
- {
- this.maxStreamingClients = maxStreamingClients;
- canStream = (streamingClientsCount < maxStreamingClients);
- }
-
- //----------------------------------
- // streamingClientsCount
- //----------------------------------
-
- protected int streamingClientsCount;
-
- /**
- * Retrieves the the number of clients that are currently in the streaming state.
- *
- * @return The number of clients that are currently in the streaming state.
- */
- public int getStreamingClientsCount()
- {
- return streamingClientsCount;
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Handles HTTP requests targetting this endpoint.
- * Two types or requests are supported. If the request is a regular request-response AMF/AMFX
- * message it is handled by the base logic in BaseHTTPEndpoint.service. However, if it is a
- * request to open a streaming HTTP connection to the client this endpoint performs some
- * validation checks and then holds the connection open to stream data back to the client
- * over.
- *
- * @param req The original servlet request.
- * @param res The active servlet response.
- */
- @Override
- public void service(HttpServletRequest req, HttpServletResponse res)
- {
- String command = req.getParameter(COMMAND_PARAM_NAME);
- if (command != null)
- serviceStreamingRequest(req, res);
- else // Let BaseHTTPEndpoint logic handle regular request-response messaging.
- super.service(req, res);
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * If the message has MPI enabled, this method adds all the needed performance
- * headers to the message.
- *
- * @param message Message to add performance headers to.
- */
- protected void addPerformanceInfo(Message message)
- {
- MessagePerformanceInfo mpiOriginal = getMPI(message);
- if (mpiOriginal == null)
- return;
-
- MessagePerformanceInfo mpip = (MessagePerformanceInfo)mpiOriginal.clone();
- try
- {
- // Set the original message info as the pushed causer info.
- MessagePerformanceUtils.setMPIP(message, mpip);
- MessagePerformanceUtils.setMPII(message, null);
- }
- catch (Exception e)
- {
- if (Log.isDebug())
- log.debug("MPI exception while streaming the message: " + e.toString());
- }
-
- // Overhead only used when MPI is enabled for sizing
- MessagePerformanceInfo mpio = new MessagePerformanceInfo();
- if (mpip.recordMessageTimes)
- {
- mpio.sendTime = System.currentTimeMillis();
- mpio.infoType = "OUT";
- }
- mpio.pushedFlag = true;
- MessagePerformanceUtils.setMPIO(message, mpio);
-
- // If MPI sizing information is enabled serialize again so that we know size
- if (mpip.recordMessageSizes)
- {
- try
- {
- // Each subclass serializes the message in their own format to
- // get the message size for the MPIO.
- long serializationOverhead = System.currentTimeMillis();
- mpio.messageSize = getMessageSizeForPerformanceInfo(message);
-
- // Set serialization overhead to the time calculated during serialization above
- if (mpip.recordMessageTimes)
- {
- serializationOverhead = System.currentTimeMillis() - serializationOverhead;
- mpip.addToOverhead(serializationOverhead);
- mpiOriginal.addToOverhead(serializationOverhead);
- mpio.sendTime = System.currentTimeMillis();
- }
- }
- catch(Exception e)
- {
- log.debug("MPI exception while streaming the message: " + e.toString());
- }
- }
- }
-
- /**
- * Utility method to convert streamed push messages to their small versions
- * if the channel-endpoint combination supports small messages.
- *
- * @param message The regular message.
- * @return The small message if the message has a small version, or regular message
- * if it doesn't .
- */
- protected Message convertPushMessageToSmall(Message message)
- {
- FlexSession session = FlexContext.getFlexSession();
- if (session != null && session.useSmallMessages())
- return convertToSmallMessage(message);
- return message;
- }
-
- /**
- * Used internally for performance information gathering; not intended for
- * public use. The default implementation of this method returns zero.
- * Subclasses should overwrite if they want to accurately report message
- * size information in performance information gathering.
- *
- * @param message Message to get the size for.
- *
- * @return The size of the message after message is serialized.
- */
- protected long getMessageSizeForPerformanceInfo(Message message)
- {
- return 0;
- }
-
- /**
- * This streaming endpoint does not support polling clients.
- *
- * @param flexClient The FlexClient that issued the poll request.
- * @param pollCommand The poll command from the client.
- * @return The flush info used to build the poll response.
- */
- @Override
- protected FlushResult handleFlexClientPoll(FlexClient flexClient, CommandMessage pollCommand)
- {
- MessageException me = new MessageException();
- me.setMessage(POLL_NOT_SUPPORTED_MESSAGE);
- me.setDetails(POLL_NOT_SUPPORTED_MESSAGE);
- me.setCode(POLL_NOT_SUPPORTED_CODE);
- throw me;
- }
-
- /**
- * Handles streaming connection open command sent by the FlexClient.
- *
- * @param req The <code>HttpServletRequest</code> to service.
- * @param res The <code>HttpServletResponse</code> to be used in case an error
- * has to be sent back.
- * @param flexClient FlexClient that requested the streaming connection.
- */
- protected void handleFlexClientStreamingOpenRequest(HttpServletRequest req, HttpServletResponse res, FlexClient flexClient)
- {
- FlexSession session = FlexContext.getFlexSession();
- if (canStream && session.canStream)
- {
- // If canStream/session.canStream is true it means we currently have
- // less than the max number of allowed streaming threads, per endpoint/session.
-
- // We need to protect writes/reads to the stream count with the endpoint's lock.
- // Also, we have to be careful to handle the case where two threads get to this point when only
- // one streaming spot remains; one thread will win and the other needs to fault.
- boolean thisThreadCanStream;
- synchronized (lock)
- {
- ++streamingClientsCount;
- if (streamingClientsCount == maxStreamingClients)
- {
- thisThreadCanStream = true; // This thread got the last spot.
- canStream = false;
- }
- else if (streamingClientsCount > maxStreamingClients)
- {
- thisThreadCanStream = false; // This thread was beaten out for the last spot.
- --streamingClientsCount; // Decrement the count because we're not going to grant the streaming right to the client.
- }
- else
- {
- // We haven't hit the limit yet, allow this thread to stream.
- thisThreadCanStream = true;
- }
- }
-
- // If the thread cannot wait due to endpoint streaming connection
- // limit, inform the client and return.
- if (!thisThreadCanStream)
- {
- String errorMessage = "Endpoint with id '" + getId() + "' cannot grant streaming connection to FlexClient with id '"
- + flexClient.getId() + "' because " + MAX_STREAMING_CLIENTS + " limit of '"
- + maxStreamingClients + "' has been reached.";
- if (Log.isError())
- log.error(errorMessage);
- try
- {
- errorMessage = "Endpoint with id '" + getId() + "' cannot grant streaming connection to FlexClient with id '"
- + flexClient.getId() + "' because " + MAX_STREAMING_CLIENTS + " limit has been reached.";
- res.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, errorMessage);
- }
- catch (IOException ignore)
- {}
- return;
- }
-
- // Setup for specific user agents.
- byte[] kickStartBytesToStream = null;
- String userAgentValue = req.getHeader(UserAgentManager.USER_AGENT_HEADER_NAME);
- UserAgentSettings agentSettings = userAgentManager.match(userAgentValue);
- if (agentSettings != null)
- {
- synchronized (session)
- {
- session.maxConnectionsPerSession = agentSettings.getMaxPersistentConnectionsPerSession();
- }
-
- int kickStartBytes = agentSettings.getKickstartBytes();
- if (kickStartBytes > 0)
- {
- // Determine the minimum number of actual bytes that need to be sent to
- // kickstart, taking into account transfer-encoding overhead.
- try
- {
- int chunkLengthHeaderSize = Integer.toHexString(kickStartBytes).getBytes("ASCII").length;
- int chunkOverhead = chunkLengthHeaderSize + 4; // 4 for the 2 wrapping CRLF tokens.
- int minimumKickstartBytes = kickStartBytes - chunkOverhead;
- kickStartBytesToStream = new byte[(minimumKickstartBytes > 0) ? minimumKickstartBytes :
- kickStartBytes];
- }
- catch (UnsupportedEncodingException ignore)
- {
- kickStartBytesToStream = new byte[kickStartBytes];
- }
- Arrays.fill(kickStartBytesToStream, NULL_BYTE);
- }
- }
-
- // Now, check with the session before granting the streaming connection.
- synchronized(session)
- {
- ++session.streamingConnectionsCount;
- if (session.maxConnectionsPerSession == FlexSession.MAX_CONNECTIONS_PER_SESSION_UNLIMITED)
- {
- thisThreadCanStream = true;
- }
- else if (session.streamingConnectionsCount == session.maxConnectionsPerSession)
- {
- thisThreadCanStream = true; // This thread got the last spot in the session.
- session.canStream = false;
- }
- else if (session.streamingConnectionsCount > session.maxConnectionsPerSession)
- {
- thisThreadCanStream = false; // This thread was beaten out for the last spot.
- --session.streamingConnectionsCount;
- synchronized(lock)
- {
- // Decrement the endpoint count because we're not going to grant the streaming right to the client.
- --streamingClientsCount;
- }
- }
- else
- {
- // We haven't hit the limit yet, allow this thread to stream.
- thisThreadCanStream = true;
- }
- }
-
- // If the thread cannot wait due to session streaming connection
- // limit, inform the client and return.
- if (!thisThreadCanStream)
- {
- if (Log.isError())
- log.error("Endpoint with id '" + getId() + "' cannot grant streaming connection to FlexClient with id '"
- + flexClient.getId() + "' because " + UserAgentManager.MAX_PERSISTENT_CONNECTIONS_PER_SESSION + " limit of '" + session.maxConnectionsPerSession
- + ((agentSettings != null) ? "' for user-agent '" + agentSettings.getMatchOn() + "'" : "") + " has been reached." );
- try
- {
- // Return an HTTP status code 400.
- String errorMessage = "The server cannot grant streaming connection to this client because limit has been reached.";
- res.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, errorMessage);
- }
- catch (IOException ignore)
- {
- // NOWARN
- }
- return;
- }
-
- Thread currentThread = Thread.currentThread();
- String threadName = currentThread.getName();
- EndpointPushNotifier notifier = null;
- boolean suppressIOExceptionLogging = false; // Used to suppress logging for IO exception.
- try
- {
- currentThread.setName(threadName + STREAMING_THREAD_NAME_EXTENSION);
-
- // Open and commit response headers and get output stream.
- if (addNoCacheHeaders)
- addNoCacheHeaders(req, res);
- res.setContentType(getResponseContentType());
- res.setHeader("Connection", "close");
- res.setHeader("Transfer-Encoding", "chunked");
- ServletOutputStream os = res.getOutputStream();
- res.flushBuffer();
-
- // If kickstart-bytes are specified, stream them.
- if (kickStartBytesToStream != null)
- {
- if (Log.isDebug())
- log.debug("Endpoint with id '" + getId() + "' is streaming " + kickStartBytesToStream.length
- + " bytes (not counting chunk encoding overhead) to kick-start the streaming connection for FlexClient with id '"
- + flexClient.getId() + "'.");
-
- streamChunk(kickStartBytesToStream, os, res);
- }
-
- // Setup serialization and type marshalling contexts
- setThreadLocals();
-
- // Activate streaming helper for this connection.
- // Watch out for duplicate stream issues.
- try
- {
- notifier = new EndpointPushNotifier(this, flexClient);
- }
- catch (MessageException me)
- {
- if (me.getNumber() == 10033) // It's a duplicate stream request from the same FlexClient. Leave the current stream in place and fault this.
- {
- if (Log.isWarn())
- log.warn("Endpoint with id '" + getId() + "' received a duplicate streaming connection request from, FlexClient with id '"
- + flexClient.getId() + "'. Faulting request.");
-
- // Rollback counters and send an error response.
- synchronized (lock)
- {
- --streamingClientsCount;
- canStream = (streamingClientsCount < maxStreamingClients);
- synchronized (session)
- {
- --session.streamingConnectionsCount;
- session.canStream = (session.maxConnectionsPerSession == FlexSession.MAX_CONNECTIONS_PER_SESSION_UNLIMITED
- || session.streamingConnectionsCount < session.maxConnectionsPerSession);
- }
- }
- try
- {
- res.sendError(HttpServletResponse.SC_BAD_REQUEST);
- }
- catch (IOException ignore)
- {
- // NOWARN
- }
- return; // Exit early.
- }
- }
- if (connectionIdleTimeoutMinutes > 0)
- notifier.setIdleTimeoutMinutes(connectionIdleTimeoutMinutes);
- notifier.setLogCategory(getLogCategory());
- monitorTimeout(notifier);
- currentStreamingRequests.put(notifier.getNotifierId(), notifier);
-
- // Push down an acknowledgement for the 'connect' request containing the unique id for this specific stream.
- AcknowledgeMessage connectAck = new AcknowledgeMessage();
- connectAck.setBody(notifier.getNotifierId());
- connectAck.setCorrelationId(BaseStreamingHTTPEndpoint.OPEN_COMMAND);
- ArrayList toPush = new ArrayList(1);
- toPush.add(connectAck);
- streamMessages(toPush, os, res);
-
- // Output session level streaming count.
- if (Log.isDebug())
- Log.getLogger(FlexSession.FLEX_SESSION_LOG_CATEGORY).info("Number of streaming clients for FlexSession with id '"+ session.getId() +"' is " + session.streamingConnectionsCount + ".");
-
- // Output endpoint level streaming count.
- if (Log.isDebug())
- log.debug("Number of streaming clients for endpoint with id '"+ getId() +"' is " + streamingClientsCount + ".");
-
- // And cycle in a wait-notify loop with the aid of the helper until it
- // is closed, we're interrupted or the act of streaming data to the client fails.
- while (!notifier.isClosed())
- {
- try
- {
- // Drain any messages that might have been accumulated
- // while the previous drain was being processed.
- List<AsyncMessage> messages = null;
- synchronized (notifier.pushNeeded)
- {
- messages = notifier.drainMessages();
- }
- streamMessages(messages, os, res);
-
- synchronized (notifier.pushNeeded)
- {
- notifier.pushNeeded.wait(serverToClientHeartbeatMillis);
-
- messages = notifier.drainMessages();
- }
- // If there are no messages to send to the client, send an null
- // byte as a heartbeat to make sure the client is still valid.
- if (messages == null && serverToClientHeartbeatMillis > 0)
- {
- try
- {
- os.write(NULL_BYTE);
- res.flushBuffer();
- }
- catch (IOException e)
- {
- if (Log.isWarn())
- log.warn("Endpoint with id '" + getId() + "' is closing the streaming connection to FlexClient with id '"
- + flexClient.getId() + "' because endpoint encountered a socket write error" +
- ", possibly due to an unresponsive FlexClient.", e);
- break; // Exit the wait loop.
- }
- }
- // Otherwise stream the messages to the client.
- else
- {
- // Update the last time notifier was used to drain messages.
- // Important for idle timeout detection.
- notifier.updateLastUse();
-
- streamMessages(messages, os, res);
- }
- }
- catch (InterruptedException e)
- {
- if (Log.isWarn())
- log.warn("Streaming thread '" + threadName + "' for endpoint with id '" + getId() + "' has been interrupted and the streaming connection will be closed.");
- os.close();
- break; // Exit the wait loop.
- }
-
- // Update the FlexClient last use time to prevent FlexClient from
- // timing out when the client is still subscribed. It is important
- // to do this outside synchronized(notifier.pushNeeded) to avoid
- // thread deadlock!
- flexClient.updateLastUse();
- }
- if (Log.isDebug())
- log.debug("Streaming thread '" + threadName + "' for endpoint with id '" + getId() + "' is releasing connection and returning to the request handler pool.");
- suppressIOExceptionLogging = true;
- // Terminate the response.
- streamChunk(null, os, res);
- }
- catch (IOException e)
- {
- if (Log.isWarn() && !suppressIOExceptionLogging)
- log.warn("Streaming thread '" + threadName + "' for endpoint with id '" + getId() + "' is closing connection due to an IO error.", e);
- }
- finally
- {
- currentThread.setName(threadName);
-
- // We're done so decrement the counts for streaming threads,
- // and update the canStream flag if necessary.
- synchronized (lock)
- {
- --streamingClientsCount;
- canStream = (streamingClientsCount < maxStreamingClients);
- synchronized (session)
- {
- --session.streamingConnectionsCount;
- session.canStream = (session.maxConnectionsPerSession == FlexSession.MAX_CONNECTIONS_PER_SESSION_UNLIMITED
- || session.streamingConnectionsCount < session.maxConnectionsPerSession);
- }
- }
-
- if (notifier != null && currentStreamingRequests != null)
- {
- currentStreamingRequests.remove(notifier.getNotifierId());
- notifier.close();
- }
-
- // Output session level streaming count.
- if (Log.isDebug())
- Log.getLogger(FlexSession.FLEX_SESSION_LOG_CATEGORY).info("Number of streaming clients for FlexSession with id '"+ session.getId() +"' is " + session.streamingConnectionsCount + ".");
-
- // Output endpoint level streaming count.
- if (Log.isDebug())
- log.debug("Number of streaming clients for endpoint with id '"+ getId() +"' is " + streamingClientsCount + ".");
- }
- }
- // Otherwise, client's streaming connection open request could not be granted.
- else
- {
- if (Log.isError())
- {
- String logString = null;
- if (!canStream)
- {
- logString = "Endpoint with id '" + getId() + "' cannot grant streaming connection to FlexClient with id '"
- + flexClient.getId() + "' because " + MAX_STREAMING_CLIENTS + " limit of '"
- + maxStreamingClients + "' has been reached.";
- }
- else if (!session.canStream)
- {
- logString = "Endpoint with id '" + getId() + "' cannot grant streaming connection to FlexClient with id '"
- + flexClient.getId() + "' because " + UserAgentManager.MAX_STREAMING_CONNECTIONS_PER_SESSION + " limit of '"
- + session.maxConnectionsPerSession + "' has been reached.";
- }
- if (logString != null)
- log.error(logString);
- }
-
- try
- {
- // Return an HTTP status code 400 to indicate that client request can't be processed.
- String errorMessage = null;
- if (!canStream)
- {
- errorMessage = "Endpoint with id '" + getId() + "' cannot grant streaming connection to FlexClient with id '"
- + flexClient.getId() + "' because " + MAX_STREAMING_CLIENTS + " limit has been reached.";
- }
- else if (!session.canStream)
- {
- errorMessage = "Endpoint with id '" + getId() + "' cannot grant streaming connection to FlexClient with id '"
- + flexClient.getId() + "' because " + UserAgentManager.MAX_STREAMING_CONNECTIONS_PER_SESSION + " limit has been reached.";
- }
- res.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, errorMessage);
- }
- catch (IOException ignore)
- {}
- }
- }
-
- /**
- * Handles streaming connection close command sent by the FlexClient.
- *
- * @param req The <code>HttpServletRequest</code> to service.
- * @param res The <code>HttpServletResponse</code> to be used in case an error
- * has to be sent back.
- * @param flexClient FlexClient that requested the streaming connection.
- * @param streamId The id for the stream to close.
- */
- protected void handleFlexClientStreamingCloseRequest(HttpServletRequest req, HttpServletResponse res, FlexClient flexClient, String streamId)
- {
- if (streamId != null)
- {
- EndpointPushNotifier notifier = (EndpointPushNotifier)flexClient.getEndpointPushHandler(getId());
- if ((notifier != null) && notifier.getNotifierId().equals(streamId))
- notifier.close();
- }
- }
-
- /**
- * Service streaming connection commands.
- *
- * @param req The <code>HttpServletRequest</code> to service.
- * @param res The <code>HttpServletResponse</code> to be used in case an error
- * has to be sent back.
- */
- protected void serviceStreamingRequest(HttpServletRequest req, HttpServletResponse res)
- {
- // If this is a request for a streaming connection, make sure it's for a valid FlexClient
- // and that the FlexSession doesn't already have a streaming connection open.
- // Streaming requests are POSTs (to help prevent the possibility of caching) that carry the
- // following parameters:
- // command - Indicating a custom command for the endpoint; currently 'open' to request a new
- // streaming connection be opened, and 'close' to request the streaming connection
- // to close.
- // version - Indicates the streaming connection 'version' to use; it's here for backward comp. support
- // if we need to change how commands are handled in a future product release.
- // DSId - The FlexClient id value that uniquely identifies the swf making the request.
- String command = req.getParameter(COMMAND_PARAM_NAME);
-
- // Only HTTP 1.1 is supported, disallow HTTP 1.0.
- if (req.getProtocol().equals(HTTP_1_0))
- {
- if (Log.isError())
- log.error("Endpoint with id '" + getId() + "' cannot service the streaming request made with " +
- " HTTP 1.0. Only HTTP 1.1 is supported.");
-
- try
- {
- // Return an HTTP status code 400 to indicate that the client's request was syntactically invalid (bad command).
- res.sendError(HttpServletResponse.SC_BAD_REQUEST);
- }
- catch (IOException ignore)
- {}
- return; // Abort further server processing.
- }
-
- if (!(command.equals(OPEN_COMMAND) || command.equals(CLOSE_COMMAND)))
- {
- if (Log.isError())
- log.error("Endpoint with id '" + getId() + "' cannot service the streaming request as the supplied command '"
- + command + "' is invalid.");
-
- try
- {
- // Return an HTTP status code 400 to indicate that the client's request was syntactically invalid (bad command).
- res.sendError(HttpServletResponse.SC_BAD_REQUEST);
- }
- catch (IOException ignore)
- {}
- return; // Abort further server processing.
- }
-
- String flexClientId = req.getParameter(Message.FLEX_CLIENT_ID_HEADER);
- if (flexClientId == null)
- {
- if (Log.isError())
- log.error("Endpoint with id '" + getId() + "' cannot service the streaming request as no FlexClient id"
- + " has been supplied in the request.");
-
- try
- {
- // Return an HTTP status code 400 to indicate that the client's request was syntactically invalid (missing id).
- res.sendError(HttpServletResponse.SC_BAD_REQUEST);
- }
- catch (IOException ignore)
- {}
- return; // Abort further server processing.
- }
-
- // Validate that the provided FlexClient id exists and is associated with the current session.
- // We don't do this validation with CLOSE_COMMAND because CLOSE_COMMAND can come in on a
- // different session. For example, when the session expires due to timeout, the streaming client
- // using that session sends a CLOSE_COMMAND on a new session to let the server know to clean client's
- // corresponding server constructs. In that case, server already knows that session has expired so
- // we can simply omit this validation.
- FlexClient flexClient = null;
- List<FlexClient> flexClients = FlexContext.getFlexSession().getFlexClients();
- boolean validFlexClientId = false;
- for (Iterator<FlexClient> iter = flexClients.iterator(); iter.hasNext();)
- {
- flexClient = iter.next();
- if (flexClient.getId().equals(flexClientId) && flexClient.isValid())
- {
- validFlexClientId = true;
- break;
- }
- }
- if (!command.equals(CLOSE_COMMAND) && !validFlexClientId)
- {
- if (Log.isError())
- log.error("Endpoint with id '" + getId() + "' cannot service the streaming request as either the supplied"
- + " FlexClient id '" + flexClientId + " is not valid, or the FlexClient with that id is not valid.");
-
- try
- {
- // Return an HTTP status code 400 to indicate that the client's request was syntactically invalid (invalid id).
- res.sendError(HttpServletResponse.SC_BAD_REQUEST);
- }
- catch (IOException ignore)
- {}
- return; // Abort further server processing.
- }
-
- // If a close command is received and we don't have any flex clients registered simply invalidate
- // the Flex Session. This will take care of the Flex Session that got created when the MB servlet
- // was processing the CLOSE request.
- if (command.equals(CLOSE_COMMAND) && flexClients.size() == 0)
- {
- FlexSession flexSession = FlexContext.getFlexSession();
- if (flexSession instanceof HttpFlexSession)
- {
- ((HttpFlexSession)flexSession).invalidate(false);
- }
- return;
- }
-
- if (flexClient != null)
- {
- if (command.equals(OPEN_COMMAND))
- handleFlexClientStreamingOpenRequest(req, res, flexClient);
- else if (command.equals(CLOSE_COMMAND))
- handleFlexClientStreamingCloseRequest(req, res, flexClient, req.getParameter(STREAM_ID_PARAM_NAME));
- }
- }
-
- /**
- * Helper method to write a chunk of bytes to the output stream in an HTTP
- * "Transfer-Encoding: chunked" format.
- * If the bytes array is null or empty, a terminal chunk will be written to
- * signal the end of the response.
- * Once the chunk is written to the output stream, the stream will be flushed immediately (no buffering).
- *
- * @param bytes The array of bytes to write as a chunk in the response; or if null, the signal to write the final chunk to complete the response.
- * @param os The output stream the chunk will be written to.
- * @param response The HttpServletResponse, used to flush the chunk to the client.
- *
- * @throws IOException if writing the chunk to the output stream fails.
- */
- protected void streamChunk(byte[] bytes, ServletOutputStream os, HttpServletResponse response) throws IOException
- {
- if ((bytes != null) && (bytes.length > 0))
- {
- byte[] chunkLength = Integer.toHexString(bytes.length).getBytes("ASCII");
- os.write(chunkLength);
- os.write(CRLF_BYTES);
- os.write(bytes);
- os.write(CRLF_BYTES);
- response.flushBuffer();
- }
- else // Send final 'EOF' chunk for the response.
- {
- os.write(ZERO_BYTE);
- os.write(CRLF_BYTES);
- response.flushBuffer();
- }
- }
-
- /**
- * Helper method invoked by the endpoint request handler thread cycling in wait-notify.
- * Serializes messages and streams each to the client as a response chunk using streamChunk().
- *
- * @param messages The messages to serialize and push to the client.
- * @param os The output stream the chunk will be written to.
- * @param response The HttpServletResponse, used to flush the chunk to the client.
- */
- protected abstract void streamMessages(List messages, ServletOutputStream os, HttpServletResponse response) throws IOException;
-
- /**
- * Given a message, returns the MessagePerformanceInfo object if the message
- * performance gathering is enabled, returns null otherwise.
- *
- * @param message The message.
- * @return MessagePerformanceInfo if the message performance gathering is enabled,
- * null otherwise.
- */
- protected MessagePerformanceInfo getMPI(Message message)
- {
- return (isRecordMessageSizes() || isRecordMessageTimes())?
- MessagePerformanceUtils.getMPII(message) : null;
- }
-
- //--------------------------------------------------------------------------
- //
- // Private methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Utility method used at EndpointPushNotifier construction to monitor it for timeout.
- *
- * @param notifier The EndpointPushNotifier to monitor.
- */
- private void monitorTimeout(EndpointPushNotifier notifier)
- {
- if (pushNotifierTimeoutManager != null)
- pushNotifierTimeoutManager.scheduleTimeout(notifier);
- }
-}
+/*
+ * 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.endpoints;
+
+import flex.messaging.FlexContext;
+import flex.messaging.FlexSession;
+import flex.messaging.HttpFlexSession;
+import flex.messaging.MessageException;
+import flex.messaging.client.EndpointPushNotifier;
+import flex.messaging.client.FlexClient;
+import flex.messaging.client.FlushResult;
+import flex.messaging.client.UserAgentSettings;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.log.Log;
+import flex.messaging.messages.AcknowledgeMessage;
+import flex.messaging.messages.AsyncMessage;
+import flex.messaging.messages.CommandMessage;
+import flex.messaging.messages.Message;
+import flex.messaging.messages.MessagePerformanceInfo;
+import flex.messaging.messages.MessagePerformanceUtils;
+import flex.messaging.util.TimeoutManager;
+import flex.messaging.util.UserAgentManager;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * Base class for HTTP-based endpoints that support streaming HTTP connections to
+ * connected clients.
+ * Each streaming connection managed by this endpoint consumes one of the request
+ * handler threads provided by the servlet container, so it is not highly scalable
+ * but offers performance advantages over client polling for clients receiving
+ * a steady, rapid stream of pushed messages.
+ * This endpoint does not support polling clients and will fault any poll requests
+ * that are received. To support polling clients use subclasses of
+ * BaseHTTPEndpoint instead.
+ */
+public abstract class BaseStreamingHTTPEndpoint extends BaseHTTPEndpoint
+{
+ //--------------------------------------------------------------------------
+ //
+ // Private Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * This token is used in chunked HTTP responses frequently so initialize it statically for general use.
+ */
+ private static final byte[] CRLF_BYTES = {(byte)13, (byte)10};
+
+ /**
+ * This token is used for the terminal chunk within a chunked response.
+ */
+ private static final byte ZERO_BYTE = (byte)48;
+
+ /**
+ * This token is used to signal that a chunk of data should be skipped by the client.
+ */
+ private static final byte NULL_BYTE = (byte)0;
+
+ /**
+ * Parameter name for 'command' passed in a request for a new streaming connection.
+ */
+ private static final String COMMAND_PARAM_NAME = "command";
+
+ /**
+ * This is the token at the end of the HTTP request line that indicates that it is
+ * a stream connection that should be held open to push data back to the client,
+ * as opposed to a regular request-response message.
+ */
+ private static final String OPEN_COMMAND = "open";
+
+ /**
+ * This is the token at the end of the HTTP request line that indicates that it is
+ * a stream connection that should be closed.
+ */
+ private static final String CLOSE_COMMAND = "close";
+
+ /**
+ * Parameter name for the stream ID; passed with commands for an existing streaming connection.
+ */
+ private static final String STREAM_ID_PARAM_NAME = "streamId";
+
+ /**
+ * Constant for HTTP/1.0.
+ */
+ private static final String HTTP_1_0 = "HTTP/1.0";
+
+ /**
+ * Thread name suffix for request threads that are servicing a pinned open streaming connection.
+ */
+ private static final String STREAMING_THREAD_NAME_EXTENSION = "-in-streaming-mode";
+
+ /**
+ * Configuration constants.
+ */
+ private static final String PROPERTY_CONNECTION_IDLE_TIMEOUT_MINUTES = "connection-idle-timeout-minutes";
+ private static final String PROPERTY_LEGACY_CONNECTION_IDLE_TIMEOUT_MINUTES = "idle-timeout-minutes";
+ private static final String MAX_STREAMING_CLIENTS = "max-streaming-clients";
+ private static final String SERVER_TO_CLIENT_HEARTBEAT_MILLIS = "server-to-client-heartbeat-millis";
+ private static final String PROPERTY_INVALIDATE_MESSAGECLIENT_ON_STREAMING_CLOSE = "invalidate-messageclient-on-streaming-close";
+
+ /**
+ * Defaults.
+ */
+ private static final boolean DEFAULT_INVALIDATE_MESSAGECLIENT_ON_STREAMING_CLOSE = false;
+ private static final int DEFAULT_SERVER_TO_CLIENT_HEARTBEAT_MILLIS = 5000;
+ private static final int DEFAULT_MAX_STREAMING_CLIENTS = 10;
+
+ /**
+ * Errors.
+ */
+ public static final String POLL_NOT_SUPPORTED_CODE = "Server.PollNotSupported";
+ public static final int POLL_NOT_SUPPORTED_MESSAGE = 10034;
+
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>BaseStreamingHTTPEndpoint</code>.
+ */
+ public BaseStreamingHTTPEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs an <code>BaseStreamingHTTPEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>BaseStreamingHTTPEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public BaseStreamingHTTPEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Initialize, validate, start, and stop methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes the <code>Endpoint</code> with the properties.
+ * If subclasses override this method, they must call <code>super.initialize()</code>.
+ *
+ * @param id The ID of the <code>Endpoint</code>.
+ * @param properties Properties for the <code>Endpoint</code>.
+ */
+ @Override
+ public void initialize(String id, ConfigMap properties)
+ {
+ super.initialize(id, properties);
+
+ if (properties == null || properties.size() == 0)
+ {
+ // Initialize default user agent manager settings.
+ UserAgentManager.setupUserAgentManager(null, userAgentManager);
+
+ return; // Nothing else to initialize.
+ }
+
+ // The interval that the server will check if the client is still available.
+ serverToClientHeartbeatMillis = properties.getPropertyAsLong(SERVER_TO_CLIENT_HEARTBEAT_MILLIS, DEFAULT_SERVER_TO_CLIENT_HEARTBEAT_MILLIS);
+ setServerToClientHeartbeatMillis(serverToClientHeartbeatMillis);
+
+ setInvalidateMessageClientOnStreamingClose(properties.getPropertyAsBoolean(PROPERTY_INVALIDATE_MESSAGECLIENT_ON_STREAMING_CLOSE, DEFAULT_INVALIDATE_MESSAGECLIENT_ON_STREAMING_CLOSE));
+
+ // Number of minutes a client can remain idle before the server times the connection out.
+ int connectionIdleTimeoutMinutes = properties.getPropertyAsInt(PROPERTY_CONNECTION_IDLE_TIMEOUT_MINUTES, getConnectionIdleTimeoutMinutes());
+ if (connectionIdleTimeoutMinutes != 0)
+ {
+ setConnectionIdleTimeoutMinutes(connectionIdleTimeoutMinutes);
+ }
+ else
+ {
+ connectionIdleTimeoutMinutes = properties.getPropertyAsInt(PROPERTY_LEGACY_CONNECTION_IDLE_TIMEOUT_MINUTES, getConnectionIdleTimeoutMinutes());
+ if (connectionIdleTimeoutMinutes != 0)
+ setConnectionIdleTimeoutMinutes(connectionIdleTimeoutMinutes);
+ }
+
+ // User-agent configuration for kick-start bytes and max streaming connections per session.
+ UserAgentManager.setupUserAgentManager(properties, userAgentManager);
+
+ // Maximum number of clients allowed to have streaming HTTP connections with the endpoint.
+ maxStreamingClients = properties.getPropertyAsInt(MAX_STREAMING_CLIENTS, DEFAULT_MAX_STREAMING_CLIENTS);
+
+ // Set initial state for the canWait flag based on whether we allow waits or not.
+ canStream = (maxStreamingClients > 0);
+ }
+
+
+ @Override
+ public void start()
+ {
+ if (isStarted())
+ return;
+
+ super.start();
+
+ if (connectionIdleTimeoutMinutes > 0)
+ {
+ pushNotifierTimeoutManager = new TimeoutManager(new ThreadFactory()
+ {
+ int counter = 1;
+ public synchronized Thread newThread(Runnable runnable)
+ {
+ Thread t = new Thread(runnable);
+ t.setName(getId() + "-StreamingConnectionTimeoutThread-" + counter++);
+ return t;
+ }
+ });
+ }
+
+ currentStreamingRequests = new ConcurrentHashMap<String, EndpointPushNotifier>();
+ }
+
+ /**
+ * (non-JavaDoc)
+ * @see flex.messaging.endpoints.AbstractEndpoint#stop()
+ */
+ @Override
+ public void stop()
+ {
+ if (!isStarted())
+ return;
+
+ // Shutdown the timeout manager for streaming connections cleanly.
+ if (pushNotifierTimeoutManager != null)
+ {
+ pushNotifierTimeoutManager.shutdown();
+ pushNotifierTimeoutManager = null;
+ }
+
+ // Shutdown any currently open streaming connections.
+ for (EndpointPushNotifier notifier : currentStreamingRequests.values())
+ notifier.close();
+
+ currentStreamingRequests = null;
+
+ super.stop();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Used to synchronize sets and gets to the number of streaming clients.
+ */
+ protected final Object lock = new Object();
+
+ /**
+ * Used to keep track of the mapping between user agent match strings and
+ * the bytes needed to kickstart their streaming connections.
+ */
+ protected UserAgentManager userAgentManager = new UserAgentManager();
+
+ /**
+ * This flag is volatile to allow for consistent reads across thread without
+ * needing to pay the cost for a synchronized lock for each read.
+ */
+ private volatile boolean canStream = true;
+
+ /**
+ * Manages timing out EndpointPushNotifier instances.
+ */
+ private volatile TimeoutManager pushNotifierTimeoutManager;
+
+ /**
+ * A Map(EndpointPushNotifier, Boolean.TRUE) containing all currently open streaming notifiers
+ * for this endpoint.
+ * Used for clean shutdown.
+ */
+ private ConcurrentHashMap<String, EndpointPushNotifier> currentStreamingRequests;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //------------------------------------------
+ // invalidateMessageClientOnStreamingClose
+ //-----------------------------------------
+
+ private volatile boolean invalidateMessageClientOnStreamingClose = DEFAULT_INVALIDATE_MESSAGECLIENT_ON_STREAMING_CLOSE;
+
+ /**
+ * Returns whether invalidate-messageclient-on-streaming-close is enabled.
+ * See {@link BaseStreamingHTTPEndpoint#setInvalidateMessageClientOnStreamingClose(boolean)}
+ * for details.
+ *
+ * @return <code>true</code> if the invalidate-messageclient-on-streaming-close is enabled, <code>false</code> otherwise.
+ */
+ public boolean isInvalidateMessageClientOnStreamingClose()
+ {
+ return invalidateMessageClientOnStreamingClose;
+ }
+
+ /**
+ * Sets the invalidate-messageclient-on-streaming close property. If enabled,
+ * when the streaming connection is closed for whatever reason (for example, the client is gone),
+ * the client's associated MessageClient on the server is invalidated immediately.
+ * This is useful in scenarios where there is a constant stream of messages, the client is gone,
+ * and the streaming connection is closed, but the session has not timed out on the server yet.
+ * In that case, enabling this property will prevent messages accumulating on the session on behalf
+ * of the MessageClient that will invalidate.
+ * <p>
+ * Important: Do not enable this property when reliable messaging is used, otherwise
+ * reliable reconnect attempts will not happen correctly.</p>
+ *
+ * @param value The property value.
+ */
+ public void setInvalidateMessageClientOnStreamingClose(boolean value)
+ {
+ invalidateMessageClientOnStreamingClose = value;
+ }
+
+ //----------------------------------
+ // serverToClientHeartbeatMillis
+ //----------------------------------
+
+ private long serverToClientHeartbeatMillis = DEFAULT_SERVER_TO_CLIENT_HEARTBEAT_MILLIS;
+
+ /**
+ * Retrieves the number of milliseconds the server will wait before writing a
+ * single <code>null</code> byte to the streaming connection, to ensure the client is
+ * still available.
+ * @return The server-to-client heartbeat time in milliseconds.
+ */
+ public long getServerToClientHeartbeatMillis()
+ {
+ return serverToClientHeartbeatMillis;
+ }
+
+ /**
+ * Retrieves the number of milliseconds the server will wait before writing a
+ * single <code>null</code> byte to the streaming connection to ensure the client is
+ * still available when there are no new messages for the client.
+ * A non-positive value means the server will wait forever for new messages and
+ * it will not write the <code>null</code> byte to determine if the client is available.
+ * @param serverToClientHeartbeatMillis The server-to-client heartbeat time in milliseconds.
+ */
+ public void setServerToClientHeartbeatMillis(long serverToClientHeartbeatMillis)
+ {
+ if (serverToClientHeartbeatMillis < 0)
+ serverToClientHeartbeatMillis = 0;
+ this.serverToClientHeartbeatMillis = serverToClientHeartbeatMillis;
+ }
+
+ //----------------------------------
+ // connectionIdleTimeoutMinutes
+ //----------------------------------
+
+ private int connectionIdleTimeoutMinutes = 0;
+
+ /**
+ * Retrieves the number of minutes a client can remain idle before the server
+ * times the connection out. The default value is 0, indicating that connections
+ * will not be timed out and must be closed by the client or server, either explicitly
+ * or by either process terminating.
+ *
+ * @return The number of minutes a client can remain idle before the server
+ * times the connection out.
+ */
+ public int getConnectionIdleTimeoutMinutes()
+ {
+ return connectionIdleTimeoutMinutes;
+ }
+
+ /**
+ * Sets the number of minutes a client can remain idle before the server
+ * times the connection out. A value of 0 or below indicates that
+ * connections will not be timed out.
+ *
+ * @param value The number of minutes a client can remain idle
+ * before the server times the connection out.
+ */
+ public void setConnectionIdleTimeoutMinutes(int value)
+ {
+ if (value < 0)
+ value = 0;
+
+ this.connectionIdleTimeoutMinutes = value;
+ }
+
+ /**
+ * (non-JavaDoc)
+ * @deprecated Use {@link BaseStreamingHTTPEndpoint#getConnectionIdleTimeoutMinutes()} instead.
+ */
+ public int getIdleTimeoutMinutes()
+ {
+ return getConnectionIdleTimeoutMinutes();
+ }
+
+ /**
+ * (non-JavaDoc)
+ * @deprecated Use {@link BaseStreamingHTTPEndpoint#setConnectionIdleTimeoutMinutes(int)} instead.
+ */
+ public void setIdleTimeoutMinutes(int value)
+ {
+ setConnectionIdleTimeoutMinutes(value);
+ }
+
+ //----------------------------------
+ // maxStreamingClients
+ //----------------------------------
+
+ private int maxStreamingClients = DEFAULT_MAX_STREAMING_CLIENTS;
+
+ /**
+ * Retrieves the maximum number of clients that will be allowed to establish
+ * a streaming HTTP connection with the endpoint.
+ *
+ * @return The maximum number of clients that will be allowed to establish
+ * a streaming HTTP connection with the endpoint.
+ */
+ public int getMaxStreamingClients()
+ {
+ return maxStreamingClients;
+ }
+
+ /**
+ * Sets the maximum number of clients that will be allowed to establish
+ * a streaming HTTP connection with the server.
+ *
+ * @param maxStreamingClients The maximum number of clients that will be allowed
+ * to establish a streaming HTTP connection with the server.
+ */
+ public void setMaxStreamingClients(int maxStreamingClients)
+ {
+ this.maxStreamingClients = maxStreamingClients;
+ canStream = (streamingClientsCount < maxStreamingClients);
+ }
+
+ //----------------------------------
+ // streamingClientsCount
+ //----------------------------------
+
+ protected int streamingClientsCount;
+
+ /**
+ * Retrieves the the number of clients that are currently in the streaming state.
+ *
+ * @return The number of clients that are currently in the streaming state.
+ */
+ public int getStreamingClientsCount()
+ {
+ return streamingClientsCount;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Handles HTTP requests targetting this endpoint.
+ * Two types or requests are supported. If the request is a regular request-response AMF/AMFX
+ * message it is handled by the base logic in BaseHTTPEndpoint.service. However, if it is a
+ * request to open a streaming HTTP connection to the client this endpoint performs some
+ * validation checks and then holds the connection open to stream data back to the client
+ * over.
+ *
+ * @param req The original servlet request.
+ * @param res The active servlet response.
+ */
+ @Override
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ {
+ String command = req.getParameter(COMMAND_PARAM_NAME);
+ if (command != null)
+ serviceStreamingRequest(req, res);
+ else // Let BaseHTTPEndpoint logic handle regular request-response messaging.
+ super.service(req, res);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * If the message has MPI enabled, this method adds all the needed performance
+ * headers to the message.
+ *
+ * @param message Message to add performance headers to.
+ */
+ protected void addPerformanceInfo(Message message)
+ {
+ MessagePerformanceInfo mpiOriginal = getMPI(message);
+ if (mpiOriginal == null)
+ return;
+
+ MessagePerformanceInfo mpip = (MessagePerformanceInfo)mpiOriginal.clone();
+ try
+ {
+ // Set the original message info as the pushed causer info.
+ MessagePerformanceUtils.setMPIP(message, mpip);
+ MessagePerformanceUtils.setMPII(message, null);
+ }
+ catch (Exception e)
+ {
+ if (Log.isDebug())
+ log.debug("MPI exception while streaming the message: " + e.toString());
+ }
+
+ // Overhead only used when MPI is enabled for sizing
+ MessagePerformanceInfo mpio = new MessagePerformanceInfo();
+ if (mpip.recordMessageTimes)
+ {
+ mpio.sendTime = System.currentTimeMillis();
+ mpio.infoType = "OUT";
+ }
+ mpio.pushedFlag = true;
+ MessagePerformanceUtils.setMPIO(message, mpio);
+
+ // If MPI sizing information is enabled serialize again so that we know size
+ if (mpip.recordMessageSizes)
+ {
+ try
+ {
+ // Each subclass serializes the message in their own format to
+ // get the message size for the MPIO.
+ long serializationOverhead = System.currentTimeMillis();
+ mpio.messageSize = getMessageSizeForPerformanceInfo(message);
+
+ // Set serialization overhead to the time calculated during serialization above
+ if (mpip.recordMessageTimes)
+ {
+ serializationOverhead = System.currentTimeMillis() - serializationOverhead;
+ mpip.addToOverhead(serializationOverhead);
+ mpiOriginal.addToOverhead(serializationOverhead);
+ mpio.sendTime = System.currentTimeMillis();
+ }
+ }
+ catch(Exception e)
+ {
+ log.debug("MPI exception while streaming the message: " + e.toString());
+ }
+ }
+ }
+
+ /**
+ * Utility method to convert streamed push messages to their small versions
+ * if the channel-endpoint combination supports small messages.
+ *
+ * @param message The regular message.
+ * @return The small message if the message has a small version, or regular message
+ * if it doesn't .
+ */
+ protected Message convertPushMessageToSmall(Message message)
+ {
+ FlexSession session = FlexContext.getFlexSession();
+ if (session != null && session.useSmallMessages())
+ return convertToSmallMessage(message);
+ return message;
+ }
+
+ /**
+ * Used internally for performance information gathering; not intended for
+ * public use. The default implementation of this method returns zero.
+ * Subclasses should overwrite if they want to accurately report message
+ * size information in performance information gathering.
+ *
+ * @param message Message to get the size for.
+ *
+ * @return The size of the message after message is serialized.
+ */
+ protected long getMessageSizeForPerformanceInfo(Message message)
+ {
+ return 0;
+ }
+
+ /**
+ * This streaming endpoint does not support polling clients.
+ *
+ * @param flexClient The FlexClient that issued the poll request.
+ * @param pollCommand The poll command from the client.
+ * @return The flush info used to build the poll response.
+ */
+ @Override
+ protected FlushResult handleFlexClientPoll(FlexClient flexClient, CommandMessage pollCommand)
+ {
+ MessageException me = new MessageException();
+ me.setMessage(POLL_NOT_SUPPORTED_MESSAGE);
+ me.setDetails(POLL_NOT_SUPPORTED_MESSAGE);
+ me.setCode(POLL_NOT_SUPPORTED_CODE);
+ throw me;
+ }
+
+ /**
+ * Handles streaming connection open command sent by the FlexClient.
+ *
+ * @param req The <code>HttpServletRequest</code> to service.
+ * @param res The <code>HttpServletResponse</code> to be used in case an error
+ * has to be sent back.
+ * @param flexClient FlexClient that requested the streaming connection.
+ */
+ protected void handleFlexClientStreamingOpenRequest(HttpServletRequest req, HttpServletResponse res, FlexClient flexClient)
+ {
+ FlexSession session = FlexContext.getFlexSession();
+ if (canStream && session.canStream)
+ {
+ // If canStream/session.canStream is true it means we currently have
+ // less than the max number of allowed streaming threads, per endpoint/session.
+
+ // We need to protect writes/reads to the stream count with the endpoint's lock.
+ // Also, we have to be careful to handle the case where two threads get to this point when only
+ // one streaming spot remains; one thread will win and the other needs to fault.
+ boolean thisThreadCanStream;
+ synchronized (lock)
+ {
+ ++streamingClientsCount;
+ if (streamingClientsCount == maxStreamingClients)
+ {
+ thisThreadCanStream = true; // This thread got the last spot.
+ canStream = false;
+ }
+ else if (streamingClientsCount > maxStreamingClients)
+ {
+ thisThreadCanStream = false; // This thread was beaten out for the last spot.
+ --streamingClientsCount; // Decrement the count because we're not going to grant the streaming right to the client.
+ }
+ else
+ {
+ // We haven't hit the limit yet, allow this thread to stream.
+ thisThreadCanStream = true;
+ }
+ }
+
+ // If the thread cannot wait due to endpoint streaming connection
+ // limit, inform the client and return.
+ if (!thisThreadCanStream)
+ {
+ String errorMessage = "Endpoint with id '" + getId() + "' cannot grant streaming connection to FlexClient with id '"
+ + flexClient.getId() + "' because " + MAX_STREAMING_CLIENTS + " limit of '"
+ + maxStreamingClients + "' has been reached.";
+ if (Log.isError())
+ log.error(errorMessage);
+ try
+ {
+ errorMessage = "Endpoint with id '" + getId() + "' cannot grant streaming connection to FlexClient with id '"
+ + flexClient.getId() + "' because " + MAX_STREAMING_CLIENTS + " limit has been reached.";
+ res.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, errorMessage);
+ }
+ catch (IOException ignore)
+ {}
+ return;
+ }
+
+ // Setup for specific user agents.
+ byte[] kickStartBytesToStream = null;
+ String userAgentValue = req.getHeader(UserAgentManager.USER_AGENT_HEADER_NAME);
+ UserAgentSettings agentSettings = userAgentManager.match(userAgentValue);
+ if (agentSettings != null)
+ {
+ synchronized (session)
+ {
+ session.maxConnectionsPerSession = agentSettings.getMaxPersistentConnectionsPerSession();
+ }
+
+ int kickStartBytes = agentSettings.getKickstartBytes();
+ if (kickStartBytes > 0)
+ {
+ // Determine the minimum number of actual bytes that need to be sent to
+ // kickstart, taking into account transfer-encoding overhead.
+ try
+ {
+ int chunkLengthHeaderSize = Integer.toHexString(kickStartBytes).getBytes("ASCII").length;
+ int chunkOverhead = chunkLengthHeaderSize + 4; // 4 for the 2 wrapping CRLF tokens.
+ int minimumKickstartBytes = kickStartBytes - chunkOverhead;
+ kickStartBytesToStream = new byte[(minimumKickstartBytes > 0) ? minimumKickstartBytes :
+ kickStartBytes];
+ }
+ catch (UnsupportedEncodingException ignore)
+ {
+ kickStartBytesToStream = new byte[kickStartBytes];
+ }
+ Arrays.fill(kickStartBytesToStream, NULL_BYTE);
+ }
+ }
+
+ // Now, check with the session before granting the streaming connection.
+ synchronized(session)
+ {
+ ++session.streamingConnectionsCount;
+ if (session.maxConnectionsPerSession == FlexSession.MAX_CONNECTIONS_PER_SESSION_UNLIMITED)
+ {
+ thisThreadCanStream = true;
+ }
+ else if (session.streamingConnectionsCount == session.maxConnectionsPerSession)
+ {
+ thisThreadCanStream = true; // This thread got the last spot in the session.
+ session.canStream = false;
+ }
+ else if (session.streamingConnectionsCount > session.maxConnectionsPerSession)
+ {
+ thisThreadCanStream = false; // This thread was beaten out for the last spot.
+ --session.streamingConnectionsCount;
+ synchronized(lock)
+ {
+ // Decrement the endpoint count because we're not going to grant the streaming right to the client.
+ --streamingClientsCount;
+ }
+ }
+ else
+ {
+ // We haven't hit the limit yet, allow this thread to stream.
+ thisThreadCanStream = true;
+ }
+ }
+
+ // If the thread cannot wait due to session streaming connection
+ // limit, inform the client and return.
+ if (!thisThreadCanStream)
+ {
+ if (Log.isError())
+ log.error("Endpoint with id '" + getId() + "' cannot grant streaming connection to FlexClient with id '"
+ + flexClient.getId() + "' because " + UserAgentManager.MAX_PERSISTENT_CONNECTIONS_PER_SESSION + " limit of '" + session.maxConnectionsPerSession
+ + ((agentSettings != null) ? "' for user-agent '" + agentSettings.getMatchOn() + "'" : "") + " has been reached." );
+ try
+ {
+ // Return an HTTP status code 400.
+ String errorMessage = "The server cannot grant streaming connection to this client because limit has been reached.";
+ res.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, errorMessage);
+ }
+ catch (IOException ignore)
+ {
+ // NOWARN
+ }
+ return;
+ }
+
+ Thread currentThread = Thread.currentThread();
+ String threadName = currentThread.getName();
+ EndpointPushNotifier notifier = null;
+ boolean suppressIOExceptionLogging = false; // Used to suppress logging for IO exception.
+ try
+ {
+ currentThread.setName(threadName + STREAMING_THREAD_NAME_EXTENSION);
+
+ // Open and commit response headers and get output stream.
+ if (addNoCacheHeaders)
+ addNoCacheHeaders(req, res);
+ res.setContentType(getResponseContentType());
+ res.setHeader("Connection", "close");
+ res.setHeader("Transfer-Encoding", "chunked");
+ ServletOutputStream os = res.getOutputStream();
+ res.flushBuffer();
+
+ // If kickstart-bytes are specified, stream them.
+ if (kickStartBytesToStream != null)
+ {
+ if (Log.isDebug())
+ log.debug("Endpoint with id '
<TRUNCATED>
[37/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/jmx/ObjectName.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/jmx/ObjectName.java b/modules/core/src/flex/management/jmx/ObjectName.java
old mode 100755
new mode 100644
index 2c3356e..04ffa18
--- a/modules/core/src/flex/management/jmx/ObjectName.java
+++ b/modules/core/src/flex/management/jmx/ObjectName.java
@@ -1,99 +1,99 @@
-/*
- * 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.management.jmx;
-
-import java.util.Hashtable;
-import javax.management.MalformedObjectNameException;
-
-/**
- * Remotable ObjectName representation that complies with Flash serialization requirements.
- * This class is JMX 1.1 compliant.
- *
- * @author shodgson
- */
-public class ObjectName
-{
- /**
- * String representation of the list of key properties sorted in lexical order.
- */
- public String canonicalKeyPropertyListString;
-
- /**
- * Canonical form of the name with properties sorted in lexical order.
- */
- public String canonicalName;
-
- /**
- * The domain part of the object name.
- */
- public String domain;
-
- /**
- * A Hashtable containing key-property pairs.
- */
- public Hashtable keyPropertyList;
-
- /**
- * String representation of the key properties.
- */
- public String keyPropertyListString;
-
- /**
- * Indicates whether the object name is a pattern.
- */
- public boolean pattern;
-
- /**
- * Indicates whether the object name is a pattern on key properties.
- */
- public boolean propertyPattern;
-
- /**
- * Constructs an empty <code>ObjectName</code> instance.
- */
- public ObjectName()
- {}
-
- /**
- * Constructs a <code>ObjectName</code> instance based upon a
- * <code>javax.management.ObjectName</code> instance.
- *
- * @param objectName The JMX <code>ObjectName</code> instance to base this instance on.
- */
- public ObjectName(javax.management.ObjectName objectName)
- {
- canonicalKeyPropertyListString = objectName.getCanonicalKeyPropertyListString();
- canonicalName = objectName.getCanonicalName();
- domain = objectName.getDomain();
- keyPropertyList = objectName.getKeyPropertyList();
- keyPropertyListString = objectName.getKeyPropertyListString();
- pattern = objectName.isPattern();
- propertyPattern = objectName.isPropertyPattern();
- }
-
- /**
- * Utility method to convert this <code>ObjectName</code> to a
- * <code>javax.management.ObjectName</code> instance.
- *
- * @return A JMX <code>ObjectName</code> based upon this instance.
- */
- public javax.management.ObjectName toObjectName() throws MalformedObjectNameException
- {
- return new javax.management.ObjectName(domain, keyPropertyList);
- }
-
-}
+/*
+ * 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.management.jmx;
+
+import java.util.Hashtable;
+import javax.management.MalformedObjectNameException;
+
+/**
+ * Remotable ObjectName representation that complies with Flash serialization requirements.
+ * This class is JMX 1.1 compliant.
+ *
+ * @author shodgson
+ */
+public class ObjectName
+{
+ /**
+ * String representation of the list of key properties sorted in lexical order.
+ */
+ public String canonicalKeyPropertyListString;
+
+ /**
+ * Canonical form of the name with properties sorted in lexical order.
+ */
+ public String canonicalName;
+
+ /**
+ * The domain part of the object name.
+ */
+ public String domain;
+
+ /**
+ * A Hashtable containing key-property pairs.
+ */
+ public Hashtable keyPropertyList;
+
+ /**
+ * String representation of the key properties.
+ */
+ public String keyPropertyListString;
+
+ /**
+ * Indicates whether the object name is a pattern.
+ */
+ public boolean pattern;
+
+ /**
+ * Indicates whether the object name is a pattern on key properties.
+ */
+ public boolean propertyPattern;
+
+ /**
+ * Constructs an empty <code>ObjectName</code> instance.
+ */
+ public ObjectName()
+ {}
+
+ /**
+ * Constructs a <code>ObjectName</code> instance based upon a
+ * <code>javax.management.ObjectName</code> instance.
+ *
+ * @param objectName The JMX <code>ObjectName</code> instance to base this instance on.
+ */
+ public ObjectName(javax.management.ObjectName objectName)
+ {
+ canonicalKeyPropertyListString = objectName.getCanonicalKeyPropertyListString();
+ canonicalName = objectName.getCanonicalName();
+ domain = objectName.getDomain();
+ keyPropertyList = objectName.getKeyPropertyList();
+ keyPropertyListString = objectName.getKeyPropertyListString();
+ pattern = objectName.isPattern();
+ propertyPattern = objectName.isPropertyPattern();
+ }
+
+ /**
+ * Utility method to convert this <code>ObjectName</code> to a
+ * <code>javax.management.ObjectName</code> instance.
+ *
+ * @return A JMX <code>ObjectName</code> based upon this instance.
+ */
+ public javax.management.ObjectName toObjectName() throws MalformedObjectNameException
+ {
+ return new javax.management.ObjectName(domain, keyPropertyList);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/jmx/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/jmx/package-info.java b/modules/core/src/flex/management/jmx/package-info.java
old mode 100755
new mode 100644
index 638bdf6..fa47d96
--- a/modules/core/src/flex/management/jmx/package-info.java
+++ b/modules/core/src/flex/management/jmx/package-info.java
@@ -1,17 +1,17 @@
-/*
- * 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.management.jmx;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/package-info.java b/modules/core/src/flex/management/package-info.java
old mode 100755
new mode 100644
index 814e6ef..46ac51b
--- a/modules/core/src/flex/management/package-info.java
+++ b/modules/core/src/flex/management/package-info.java
@@ -1,17 +1,17 @@
-/*
- * 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.management;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/AdminConsoleDisplayRegistrar.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/AdminConsoleDisplayRegistrar.java b/modules/core/src/flex/management/runtime/AdminConsoleDisplayRegistrar.java
old mode 100755
new mode 100644
index 222aafa..dd85000
--- a/modules/core/src/flex/management/runtime/AdminConsoleDisplayRegistrar.java
+++ b/modules/core/src/flex/management/runtime/AdminConsoleDisplayRegistrar.java
@@ -1,104 +1,104 @@
-/*
- * 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.management.runtime;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import flex.management.BaseControl;
-
-/**
- * @exclude
- */
-public class AdminConsoleDisplayRegistrar extends BaseControl implements AdminConsoleDisplayRegistrarMBean
-{
- public static final String ID = "AdminConsoleDisplay";
-
- private HashMap registeredExposedObjects;
-
- public AdminConsoleDisplayRegistrar(BaseControl parent)
- {
- super(parent);
- registeredExposedObjects = new HashMap();
- register();
- }
-
- public void registerObject(int type, String beanName, String propertyName)
- {
- Object objects = registeredExposedObjects.get(new Integer(type));
- if (objects != null)
- {
- ((ArrayList)objects).add(beanName + ":" + propertyName);
- }
- else
- {
- if (type < 1)
- return;
-
- objects = new ArrayList();
- ((ArrayList)objects).add(beanName + ":" + propertyName);
- registeredExposedObjects.put(new Integer(type), objects);
- }
- }
-
- public void registerObjects(int type, String beanName, String[] propertyNames)
- {
- for (int i = 0; i < propertyNames.length; i++)
- {
- registerObject(type, beanName, propertyNames[i]);
- }
- }
-
- public void registerObjects(int[] types, String beanName, String[] propertyNames)
- {
- for (int j = 0; j < types.length; j++)
- {
- registerObjects(types[j], beanName, propertyNames);
- }
- }
-
- public Integer[] getSupportedTypes() throws IOException
- {
- Object[] array = registeredExposedObjects.keySet().toArray();
- Integer[] types = new Integer[array.length];
- for (int i = 0; i < array.length; i++)
- {
- types[i] = (Integer)array[i];
- }
- return types;
- }
-
- public String[] listForType(int type) throws IOException
- {
- Object list = registeredExposedObjects.get(new Integer(type));
-
- return (list != null) ? (String[]) ((ArrayList)list).toArray(new String[0]) : new String[0];
- }
-
- public String getId()
- {
- return ID;
- }
-
- public String getType()
- {
- return ID;
- }
-
-
-}
+/*
+ * 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.management.runtime;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import flex.management.BaseControl;
+
+/**
+ * @exclude
+ */
+public class AdminConsoleDisplayRegistrar extends BaseControl implements AdminConsoleDisplayRegistrarMBean
+{
+ public static final String ID = "AdminConsoleDisplay";
+
+ private HashMap registeredExposedObjects;
+
+ public AdminConsoleDisplayRegistrar(BaseControl parent)
+ {
+ super(parent);
+ registeredExposedObjects = new HashMap();
+ register();
+ }
+
+ public void registerObject(int type, String beanName, String propertyName)
+ {
+ Object objects = registeredExposedObjects.get(new Integer(type));
+ if (objects != null)
+ {
+ ((ArrayList)objects).add(beanName + ":" + propertyName);
+ }
+ else
+ {
+ if (type < 1)
+ return;
+
+ objects = new ArrayList();
+ ((ArrayList)objects).add(beanName + ":" + propertyName);
+ registeredExposedObjects.put(new Integer(type), objects);
+ }
+ }
+
+ public void registerObjects(int type, String beanName, String[] propertyNames)
+ {
+ for (int i = 0; i < propertyNames.length; i++)
+ {
+ registerObject(type, beanName, propertyNames[i]);
+ }
+ }
+
+ public void registerObjects(int[] types, String beanName, String[] propertyNames)
+ {
+ for (int j = 0; j < types.length; j++)
+ {
+ registerObjects(types[j], beanName, propertyNames);
+ }
+ }
+
+ public Integer[] getSupportedTypes() throws IOException
+ {
+ Object[] array = registeredExposedObjects.keySet().toArray();
+ Integer[] types = new Integer[array.length];
+ for (int i = 0; i < array.length; i++)
+ {
+ types[i] = (Integer)array[i];
+ }
+ return types;
+ }
+
+ public String[] listForType(int type) throws IOException
+ {
+ Object list = registeredExposedObjects.get(new Integer(type));
+
+ return (list != null) ? (String[]) ((ArrayList)list).toArray(new String[0]) : new String[0];
+ }
+
+ public String getId()
+ {
+ return ID;
+ }
+
+ public String getType()
+ {
+ return ID;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/AdminConsoleDisplayRegistrarMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/AdminConsoleDisplayRegistrarMBean.java b/modules/core/src/flex/management/runtime/AdminConsoleDisplayRegistrarMBean.java
old mode 100755
new mode 100644
index cc12ffb..fd10182
--- a/modules/core/src/flex/management/runtime/AdminConsoleDisplayRegistrarMBean.java
+++ b/modules/core/src/flex/management/runtime/AdminConsoleDisplayRegistrarMBean.java
@@ -1,33 +1,33 @@
-/*
- * 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.management.runtime;
-
-import java.io.IOException;
-
-import flex.management.BaseControlMBean;
-
-/**
- * @exclude
- */
-public interface AdminConsoleDisplayRegistrarMBean extends BaseControlMBean
-{
-
- Integer[] getSupportedTypes() throws IOException;
-
- String[] listForType(int type) throws IOException;
-
-}
+/*
+ * 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.management.runtime;
+
+import java.io.IOException;
+
+import flex.management.BaseControlMBean;
+
+/**
+ * @exclude
+ */
+public interface AdminConsoleDisplayRegistrarMBean extends BaseControlMBean
+{
+
+ Integer[] getSupportedTypes() throws IOException;
+
+ String[] listForType(int type) throws IOException;
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/AdminConsoleTypes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/AdminConsoleTypes.java b/modules/core/src/flex/management/runtime/AdminConsoleTypes.java
old mode 100755
new mode 100644
index a6a113a..a63085d
--- a/modules/core/src/flex/management/runtime/AdminConsoleTypes.java
+++ b/modules/core/src/flex/management/runtime/AdminConsoleTypes.java
@@ -1,35 +1,35 @@
-/*
- * 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.management.runtime;
-
-/**
- * The interface defines a number of constants for admin console types.
- */
-public interface AdminConsoleTypes
-{
- static final int GENERAL_SERVER = 1;
- static final int GENERAL_POLLABLE = 2;
- static final int GENERAL_OPERATION = 3;
-
- static final int GRAPH_BY_POLL_INTERVAL = 50;
-
- static final int ENDPOINT_SCALAR = 100;
- static final int ENDPOINT_POLLABLE = 101;
-
- static final int DESTINATION_GENERAL = 150;
- static final int DESTINATION_POLLABLE = 151;
-}
+/*
+ * 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.management.runtime;
+
+/**
+ * The interface defines a number of constants for admin console types.
+ */
+public interface AdminConsoleTypes
+{
+ static final int GENERAL_SERVER = 1;
+ static final int GENERAL_POLLABLE = 2;
+ static final int GENERAL_OPERATION = 3;
+
+ static final int GRAPH_BY_POLL_INTERVAL = 50;
+
+ static final int ENDPOINT_SCALAR = 100;
+ static final int ENDPOINT_POLLABLE = 101;
+
+ static final int DESTINATION_GENERAL = 150;
+ static final int DESTINATION_POLLABLE = 151;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/DestinationControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/DestinationControl.java b/modules/core/src/flex/management/runtime/messaging/DestinationControl.java
old mode 100755
new mode 100644
index a83a6f7..ce15acc
--- a/modules/core/src/flex/management/runtime/messaging/DestinationControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/DestinationControl.java
@@ -1,119 +1,119 @@
-/*
- * 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.management.runtime.messaging;
-
-import java.util.Date;
-
-import flex.management.BaseControl;
-import flex.management.runtime.messaging.services.ServiceControl;
-import flex.messaging.Destination;
-import flex.messaging.services.ServiceAdapter;
-
-import javax.management.ObjectName;
-
-/**
- * The <code>DestinationControl</code> class is the MBean implementation for
- * monitoring and managing a <code>Destination</code> at runtime.
- *
- * @author shodgson
- */
-public abstract class DestinationControl extends BaseControl implements
- DestinationControlMBean
-{
- protected Destination destination;
- private ObjectName adapter;
-
- /**
- * Constructs a new <code>DestinationControl</code> instance.
- *
- * @param destination The <code>Destination</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public DestinationControl(Destination destination, BaseControl parent)
- {
- super(parent);
- this.destination = destination;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getId()
- */
- public String getId()
- {
- return destination.getId();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.DestinationControlMBean#getAdapter()
- */
- public ObjectName getAdapter()
- {
- return adapter;
- }
-
- /**
- * Sets the <code>ObjectName</code> for the adapter associated with the managed destination.
- *
- * @param value The <code>ObjectName</code> for the adapter.
- */
- public void setAdapter(ObjectName value)
- {
- adapter = value;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.DestinationControlMBean#isRunning()
- */
- public Boolean isRunning()
- {
- return Boolean.valueOf(destination.isStarted());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.DestinationControlMBean#getStartTimestamp()
- */
- public Date getStartTimestamp()
- {
- return startTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.management.MBeanRegistration#preDeregister()
- */
- public void preDeregister() throws Exception
- {
- ServiceControl parent = (ServiceControl)getParentControl();
- parent.removeDestination(getObjectName());
-
- // Unregister adapter of the destination
- ServiceAdapter child = destination.getAdapter();
- if (child.getControl() != null)
- {
- child.getControl().unregister();
- child.setControl(null);
- child.setManaged(false);
- }
-
- super.preDeregister();
- }
-
-}
+/*
+ * 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.management.runtime.messaging;
+
+import java.util.Date;
+
+import flex.management.BaseControl;
+import flex.management.runtime.messaging.services.ServiceControl;
+import flex.messaging.Destination;
+import flex.messaging.services.ServiceAdapter;
+
+import javax.management.ObjectName;
+
+/**
+ * The <code>DestinationControl</code> class is the MBean implementation for
+ * monitoring and managing a <code>Destination</code> at runtime.
+ *
+ * @author shodgson
+ */
+public abstract class DestinationControl extends BaseControl implements
+ DestinationControlMBean
+{
+ protected Destination destination;
+ private ObjectName adapter;
+
+ /**
+ * Constructs a new <code>DestinationControl</code> instance.
+ *
+ * @param destination The <code>Destination</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public DestinationControl(Destination destination, BaseControl parent)
+ {
+ super(parent);
+ this.destination = destination;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getId()
+ */
+ public String getId()
+ {
+ return destination.getId();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.DestinationControlMBean#getAdapter()
+ */
+ public ObjectName getAdapter()
+ {
+ return adapter;
+ }
+
+ /**
+ * Sets the <code>ObjectName</code> for the adapter associated with the managed destination.
+ *
+ * @param value The <code>ObjectName</code> for the adapter.
+ */
+ public void setAdapter(ObjectName value)
+ {
+ adapter = value;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.DestinationControlMBean#isRunning()
+ */
+ public Boolean isRunning()
+ {
+ return Boolean.valueOf(destination.isStarted());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.DestinationControlMBean#getStartTimestamp()
+ */
+ public Date getStartTimestamp()
+ {
+ return startTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.management.MBeanRegistration#preDeregister()
+ */
+ public void preDeregister() throws Exception
+ {
+ ServiceControl parent = (ServiceControl)getParentControl();
+ parent.removeDestination(getObjectName());
+
+ // Unregister adapter of the destination
+ ServiceAdapter child = destination.getAdapter();
+ if (child.getControl() != null)
+ {
+ child.getControl().unregister();
+ child.setControl(null);
+ child.setManaged(false);
+ }
+
+ super.preDeregister();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/DestinationControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/DestinationControlMBean.java b/modules/core/src/flex/management/runtime/messaging/DestinationControlMBean.java
old mode 100755
new mode 100644
index acc1399..daea55a
--- a/modules/core/src/flex/management/runtime/messaging/DestinationControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/DestinationControlMBean.java
@@ -1,57 +1,57 @@
-/*
- * 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.management.runtime.messaging;
-
-import flex.management.BaseControlMBean;
-
-import java.io.IOException;
-import java.util.Date;
-
-import javax.management.ObjectName;
-
-/**
- * Defines the runtime monitoring and management interface for managed destinations.
- *
- * @author shodgson
- */
-public interface DestinationControlMBean extends BaseControlMBean
-{
- /**
- * Returns the <code>ObjectName</code> for the adapter associated with this
- * managed destination.
- *
- * @return The <code>ObjectName</code> for the adapter.
- * @throws IOException Throws IOException.
- */
- ObjectName getAdapter() throws IOException;;
-
- /**
- * Returns <code>true</code> if the <code>Destination</code> is running.
- *
- * @return <code>true</code> if the <code>Destination</code> is running.
- * @throws IOException Throws IOException.
- */
- Boolean isRunning() throws IOException;
-
- /**
- * Returns the start timestamp for the <code>Destination</code>.
- *
- * @return The start timestamp for the <code>Destination</code>.
- * @throws IOException Throws IOException.
- */
- Date getStartTimestamp() throws IOException;
-}
+/*
+ * 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.management.runtime.messaging;
+
+import flex.management.BaseControlMBean;
+
+import java.io.IOException;
+import java.util.Date;
+
+import javax.management.ObjectName;
+
+/**
+ * Defines the runtime monitoring and management interface for managed destinations.
+ *
+ * @author shodgson
+ */
+public interface DestinationControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns the <code>ObjectName</code> for the adapter associated with this
+ * managed destination.
+ *
+ * @return The <code>ObjectName</code> for the adapter.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName getAdapter() throws IOException;;
+
+ /**
+ * Returns <code>true</code> if the <code>Destination</code> is running.
+ *
+ * @return <code>true</code> if the <code>Destination</code> is running.
+ * @throws IOException Throws IOException.
+ */
+ Boolean isRunning() throws IOException;
+
+ /**
+ * Returns the start timestamp for the <code>Destination</code>.
+ *
+ * @return The start timestamp for the <code>Destination</code>.
+ * @throws IOException Throws IOException.
+ */
+ Date getStartTimestamp() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/MessageBrokerControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/MessageBrokerControl.java b/modules/core/src/flex/management/runtime/messaging/MessageBrokerControl.java
old mode 100755
new mode 100644
index 6b8c5a5..dab4ff9
--- a/modules/core/src/flex/management/runtime/messaging/MessageBrokerControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/MessageBrokerControl.java
@@ -1,297 +1,297 @@
-/*
- * 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.management.runtime.messaging;
-
-import flex.management.BaseControl;
-import flex.management.runtime.AdminConsoleDisplayRegistrar;
-import flex.management.runtime.AdminConsoleTypes;
-import flex.messaging.MessageBroker;
-import flex.messaging.endpoints.AMFEndpoint;
-import flex.messaging.endpoints.AbstractEndpoint;
-import flex.messaging.endpoints.Endpoint;
-import flex.messaging.endpoints.HTTPEndpoint;
-import flex.messaging.endpoints.StreamingAMFEndpoint;
-import flex.messaging.endpoints.StreamingHTTPEndpoint;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.List;
-import java.util.ArrayList;
-
-import javax.management.ObjectName;
-
-/**
- * The <code>MessageBrokerControl</code> class is the MBean implemenation for monitoring
- * and managing a <code>MessageBroker</code> at runtime.
- *
- * @author shodgson
- * @author majacobs
- */
-public class MessageBrokerControl extends BaseControl implements MessageBrokerControlMBean
-{
- private static final Object classMutex = new Object();
- private static final String TYPE = "MessageBroker";
- private static int instanceCount = 0;
- private String id;
- private MessageBroker broker;
- private List endpointNames;
- private List amfEndpoints;
- private List httpEndpoints;
- private List enterpriseEndpoints;
- private List streamingAmfEndpoints;
- private List streamingHttpEndpoints;
- private List services;
-
- /**
- * Constructs a new <code>MessageBrokerControl</code> instance, assigning its
- * backing <code>MessageBroker</code>.
- *
- * @param broker The <code>MessageBroker</code> managed by this MBean.
- */
- public MessageBrokerControl(MessageBroker broker)
- {
- super(null);
- this.broker = broker;
- endpointNames = new ArrayList();
- amfEndpoints = new ArrayList();
- httpEndpoints = new ArrayList();
- enterpriseEndpoints = new ArrayList();
- streamingAmfEndpoints = new ArrayList();
- streamingHttpEndpoints = new ArrayList();
- services = new ArrayList();
- synchronized (classMutex)
- {
- id = TYPE + ++instanceCount;
- }
-
- setRegistrar(new AdminConsoleDisplayRegistrar(this));
- }
-
- protected void onRegistrationComplete()
- {
- String name = this.getObjectName().getCanonicalName();
- getRegistrar().registerObject(AdminConsoleTypes.GENERAL_POLLABLE, name, "FlexSessionCount");
- getRegistrar().registerObjects(new int[] {AdminConsoleTypes.GENERAL_POLLABLE, AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL },
- name, new String[] {"AMFThroughput", "HTTPThroughput", "EnterpriseThroughput"});
-
- getRegistrar().registerObject(AdminConsoleTypes.GENERAL_SERVER, name, "MaxFlexSessionsInCurrentHour");
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getId()
- */
- public String getId()
- {
- return id;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getType()
- */
- public String getType()
- {
- return TYPE;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.MessageBrokerControlMBean#isRunning()
- */
- public Boolean isRunning()
- {
- return Boolean.valueOf(broker.isStarted());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.MessageBrokerControlMBean#getStartTimestamp()
- */
- public Date getStartTimestamp()
- {
- return startTimestamp;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.MessageBrokerControlMBean#getEndpoints()
- */
- public ObjectName[] getEndpoints() throws IOException
- {
- int size = endpointNames.size();
- ObjectName[] endpointNameObjects = new ObjectName[size];
- for (int i = 0; i < size; ++i)
- {
- endpointNameObjects[i] = (ObjectName)endpointNames.get(i);
- }
- return endpointNameObjects;
- }
-
- /**
- * Adds an <code>Endpoint</code> for an endpoint registered with the backing <code>MessageBroker</code>.
- *
- * @param value The endpoint <code>Endpoint</code>.
- */
- public void addEndpoint(Endpoint value)
- {
- if (value instanceof AMFEndpoint)
- amfEndpoints.add(value);
- else if (value instanceof HTTPEndpoint)
- httpEndpoints.add(value);
- else if (value instanceof StreamingAMFEndpoint)
- streamingAmfEndpoints.add(value);
- else if (value instanceof StreamingHTTPEndpoint)
- streamingHttpEndpoints.add(value);
- else
- enterpriseEndpoints.add(value);
-
- endpointNames.add(value.getControl().getObjectName());
- }
-
- /**
- * Removes an <code>ObjectName</code> for an endpoint registered with the backing <code>MessageBroker</code>.
- *
- * @param value The endpoint <code>ObjectName</code>.
- */
- public void removeEndpoint(ObjectName value)
- {
- endpointNames.remove(value);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.MessageBrokerControlMBean#getServices()
- */
- public ObjectName[] getServices() throws IOException
- {
- int size = services.size();
- ObjectName[] serviceNames = new ObjectName[size];
- for (int i = 0; i < size; ++i)
- {
- serviceNames[i] = (ObjectName)services.get(i);
- }
- return serviceNames;
- }
-
- /**
- * Adds an <code>ObjectName</code> for a service registered with the backing <code>MessageBroker</code>.
- *
- * @param value The service <code>ObjectName</code>.
- */
- public void addService(ObjectName value)
- {
- services.add(value);
- }
-
- /**
- * Removes an <code>ObjectName</code> for a service registered with the backing <code>MessageBroker</code>.
- *
- * @param value The service <code>ObjectName</code>.
- */
- public void removeService(ObjectName value)
- {
- services.remove(value);
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.MessageBrokerControlMBean#getFlexSessionCount()
- */
- public Integer getFlexSessionCount()
- {
- return broker.getFlexSessionManager().getFlexSessionCount();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.MessageBrokerControlMBean#getMaxFlexSessionsInCurrentHour()
- */
- public Integer getMaxFlexSessionsInCurrentHour()
- {
- return broker.getFlexSessionManager().getMaxFlexSessionsInCurrentHour();
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getRTMPConnectionCount()
- */
- public Integer getEnterpriseConnectionCount() throws IOException
- {
- int connections = 0;
- /*
- for (int i = 0; i < rtmpEndpoints.size(); i++)
- {
- connections += (((RTMPEndpoint)rtmpEndpoints.get(i)).getConnectionCount());
- }
- */
- return new Integer(connections);
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getAMFThroughput()
- */
- public Long getAMFThroughput() throws IOException
- {
- return new Long(calculateEndpointThroughput(amfEndpoints));
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getHTTPThroughput()
- */
- public Long getHTTPThroughput() throws IOException
- {
- return new Long(calculateEndpointThroughput(httpEndpoints));
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getRTMPThroughput()
- */
- public Long getEnterpriseThroughput() throws IOException
- {
- return new Long(calculateEndpointThroughput(enterpriseEndpoints));
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getStreamingAMFThroughput()
- */
- public Long getStreamingAMFThroughput() throws IOException
- {
- return new Long(calculateEndpointThroughput(streamingAmfEndpoints));
- }
-
- /* (non-Javadoc)
- * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getStreamingHTTPThroughput()
- */
- public Long getStreamingHTTPThroughput() throws IOException
- {
- return new Long(calculateEndpointThroughput(streamingHttpEndpoints));
- }
-
- private long calculateEndpointThroughput(List endpoints)
- {
- long throughput = 0;
-
- for (int i = 0; i < endpoints.size(); i++)
- {
- // This method shouldn't be used with Lists containing objects that are not AbstractEndpoints
- if (endpoints.get(i) instanceof AbstractEndpoint)
- throughput += ((AbstractEndpoint)endpoints.get(i)).getThroughput();
- }
-
- return throughput;
- }
-}
+/*
+ * 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.management.runtime.messaging;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleDisplayRegistrar;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.messaging.MessageBroker;
+import flex.messaging.endpoints.AMFEndpoint;
+import flex.messaging.endpoints.AbstractEndpoint;
+import flex.messaging.endpoints.Endpoint;
+import flex.messaging.endpoints.HTTPEndpoint;
+import flex.messaging.endpoints.StreamingAMFEndpoint;
+import flex.messaging.endpoints.StreamingHTTPEndpoint;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+import java.util.ArrayList;
+
+import javax.management.ObjectName;
+
+/**
+ * The <code>MessageBrokerControl</code> class is the MBean implemenation for monitoring
+ * and managing a <code>MessageBroker</code> at runtime.
+ *
+ * @author shodgson
+ * @author majacobs
+ */
+public class MessageBrokerControl extends BaseControl implements MessageBrokerControlMBean
+{
+ private static final Object classMutex = new Object();
+ private static final String TYPE = "MessageBroker";
+ private static int instanceCount = 0;
+ private String id;
+ private MessageBroker broker;
+ private List endpointNames;
+ private List amfEndpoints;
+ private List httpEndpoints;
+ private List enterpriseEndpoints;
+ private List streamingAmfEndpoints;
+ private List streamingHttpEndpoints;
+ private List services;
+
+ /**
+ * Constructs a new <code>MessageBrokerControl</code> instance, assigning its
+ * backing <code>MessageBroker</code>.
+ *
+ * @param broker The <code>MessageBroker</code> managed by this MBean.
+ */
+ public MessageBrokerControl(MessageBroker broker)
+ {
+ super(null);
+ this.broker = broker;
+ endpointNames = new ArrayList();
+ amfEndpoints = new ArrayList();
+ httpEndpoints = new ArrayList();
+ enterpriseEndpoints = new ArrayList();
+ streamingAmfEndpoints = new ArrayList();
+ streamingHttpEndpoints = new ArrayList();
+ services = new ArrayList();
+ synchronized (classMutex)
+ {
+ id = TYPE + ++instanceCount;
+ }
+
+ setRegistrar(new AdminConsoleDisplayRegistrar(this));
+ }
+
+ protected void onRegistrationComplete()
+ {
+ String name = this.getObjectName().getCanonicalName();
+ getRegistrar().registerObject(AdminConsoleTypes.GENERAL_POLLABLE, name, "FlexSessionCount");
+ getRegistrar().registerObjects(new int[] {AdminConsoleTypes.GENERAL_POLLABLE, AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL },
+ name, new String[] {"AMFThroughput", "HTTPThroughput", "EnterpriseThroughput"});
+
+ getRegistrar().registerObject(AdminConsoleTypes.GENERAL_SERVER, name, "MaxFlexSessionsInCurrentHour");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getId()
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getType()
+ */
+ public String getType()
+ {
+ return TYPE;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageBrokerControlMBean#isRunning()
+ */
+ public Boolean isRunning()
+ {
+ return Boolean.valueOf(broker.isStarted());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageBrokerControlMBean#getStartTimestamp()
+ */
+ public Date getStartTimestamp()
+ {
+ return startTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageBrokerControlMBean#getEndpoints()
+ */
+ public ObjectName[] getEndpoints() throws IOException
+ {
+ int size = endpointNames.size();
+ ObjectName[] endpointNameObjects = new ObjectName[size];
+ for (int i = 0; i < size; ++i)
+ {
+ endpointNameObjects[i] = (ObjectName)endpointNames.get(i);
+ }
+ return endpointNameObjects;
+ }
+
+ /**
+ * Adds an <code>Endpoint</code> for an endpoint registered with the backing <code>MessageBroker</code>.
+ *
+ * @param value The endpoint <code>Endpoint</code>.
+ */
+ public void addEndpoint(Endpoint value)
+ {
+ if (value instanceof AMFEndpoint)
+ amfEndpoints.add(value);
+ else if (value instanceof HTTPEndpoint)
+ httpEndpoints.add(value);
+ else if (value instanceof StreamingAMFEndpoint)
+ streamingAmfEndpoints.add(value);
+ else if (value instanceof StreamingHTTPEndpoint)
+ streamingHttpEndpoints.add(value);
+ else
+ enterpriseEndpoints.add(value);
+
+ endpointNames.add(value.getControl().getObjectName());
+ }
+
+ /**
+ * Removes an <code>ObjectName</code> for an endpoint registered with the backing <code>MessageBroker</code>.
+ *
+ * @param value The endpoint <code>ObjectName</code>.
+ */
+ public void removeEndpoint(ObjectName value)
+ {
+ endpointNames.remove(value);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageBrokerControlMBean#getServices()
+ */
+ public ObjectName[] getServices() throws IOException
+ {
+ int size = services.size();
+ ObjectName[] serviceNames = new ObjectName[size];
+ for (int i = 0; i < size; ++i)
+ {
+ serviceNames[i] = (ObjectName)services.get(i);
+ }
+ return serviceNames;
+ }
+
+ /**
+ * Adds an <code>ObjectName</code> for a service registered with the backing <code>MessageBroker</code>.
+ *
+ * @param value The service <code>ObjectName</code>.
+ */
+ public void addService(ObjectName value)
+ {
+ services.add(value);
+ }
+
+ /**
+ * Removes an <code>ObjectName</code> for a service registered with the backing <code>MessageBroker</code>.
+ *
+ * @param value The service <code>ObjectName</code>.
+ */
+ public void removeService(ObjectName value)
+ {
+ services.remove(value);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageBrokerControlMBean#getFlexSessionCount()
+ */
+ public Integer getFlexSessionCount()
+ {
+ return broker.getFlexSessionManager().getFlexSessionCount();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageBrokerControlMBean#getMaxFlexSessionsInCurrentHour()
+ */
+ public Integer getMaxFlexSessionsInCurrentHour()
+ {
+ return broker.getFlexSessionManager().getMaxFlexSessionsInCurrentHour();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getRTMPConnectionCount()
+ */
+ public Integer getEnterpriseConnectionCount() throws IOException
+ {
+ int connections = 0;
+ /*
+ for (int i = 0; i < rtmpEndpoints.size(); i++)
+ {
+ connections += (((RTMPEndpoint)rtmpEndpoints.get(i)).getConnectionCount());
+ }
+ */
+ return new Integer(connections);
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getAMFThroughput()
+ */
+ public Long getAMFThroughput() throws IOException
+ {
+ return new Long(calculateEndpointThroughput(amfEndpoints));
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getHTTPThroughput()
+ */
+ public Long getHTTPThroughput() throws IOException
+ {
+ return new Long(calculateEndpointThroughput(httpEndpoints));
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getRTMPThroughput()
+ */
+ public Long getEnterpriseThroughput() throws IOException
+ {
+ return new Long(calculateEndpointThroughput(enterpriseEndpoints));
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getStreamingAMFThroughput()
+ */
+ public Long getStreamingAMFThroughput() throws IOException
+ {
+ return new Long(calculateEndpointThroughput(streamingAmfEndpoints));
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getStreamingHTTPThroughput()
+ */
+ public Long getStreamingHTTPThroughput() throws IOException
+ {
+ return new Long(calculateEndpointThroughput(streamingHttpEndpoints));
+ }
+
+ private long calculateEndpointThroughput(List endpoints)
+ {
+ long throughput = 0;
+
+ for (int i = 0; i < endpoints.size(); i++)
+ {
+ // This method shouldn't be used with Lists containing objects that are not AbstractEndpoints
+ if (endpoints.get(i) instanceof AbstractEndpoint)
+ throughput += ((AbstractEndpoint)endpoints.get(i)).getThroughput();
+ }
+
+ return throughput;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/MessageBrokerControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/MessageBrokerControlMBean.java b/modules/core/src/flex/management/runtime/messaging/MessageBrokerControlMBean.java
old mode 100755
new mode 100644
index a209c4b..3bb02b0
--- a/modules/core/src/flex/management/runtime/messaging/MessageBrokerControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/MessageBrokerControlMBean.java
@@ -1,132 +1,132 @@
-/*
- * 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.management.runtime.messaging;
-
-import flex.management.BaseControlMBean;
-
-import java.io.IOException;
-import java.util.Date;
-import javax.management.ObjectName;
-
-/**
- * Defines the runtime monitoring and management interface for managed <code>MessageBroker</code>s.
- *
- * @author shodgson
- */
-public interface MessageBrokerControlMBean extends BaseControlMBean
-{
- /**
- * Returns <code>true</code> if the <code>MessageBroker</code> is running.
- *
- * @return <code>true</code> if the <code>MessageBroker</code> is running.
- * @throws IOException Throws IOException.
- */
- Boolean isRunning() throws IOException;
-
- /**
- * Returns the start timestamp for the <code>MessageBroker</code>.
- *
- * @return The start timestamp for the <code>MessageBroker</code>.
- * @throws IOException Throws IOException.
- */
- Date getStartTimestamp() throws IOException;
-
- /**
- * Returns the <code>ObjectName</code>s for endpoints that are registered with the
- * managed <code>MessageBroker</code>.
- *
- * @return The <code>ObjectName</code>s for endpoints registered with the managed <code>MessageBroker</code>.
- * @throws IOException Throws IOException.
- */
- ObjectName[] getEndpoints() throws IOException;
-
- /**
- * Returns the <code>ObjectName</code>s for services that are registered with the
- * managed <code>MessageBroker</code>.
- *
- * @return The <code>ObjectName</code>s for services registered with the managed <code>MessageBroker</code>.
- * @throws IOException Throws IOException.
- */
- ObjectName[] getServices() throws IOException;
-
- /**
- * Returns Flex session count for the <code>MessageBroker</code>.
- *
- * @return Flex session count for the <code>MessageBroker</code>.
- * @throws IOException Throws IOException.
- */
- Integer getFlexSessionCount() throws IOException;
-
- /**
- * Returns the maximum concurrent Flex session count for the
- * <code>MessageBroker</code> in the current hour.
- *
- * @return The maximum concurrent Flex session count for the
- * <code>MessageBroker</code> over the course of the last hour.
- * @throws IOException Throws IOException.
- */
- Integer getMaxFlexSessionsInCurrentHour() throws IOException;
-
- /**
- * Returns the number of Enterprise Connections across all
- * Enterprise Endpoints.
- *
- * @return The number of Enterprise Connections
- * @throws IOException Throws IOException.
- */
- Integer getEnterpriseConnectionCount() throws IOException;
-
- /**
- * Returns the total number of bytes passing through all AMF endpoints.
- *
- * @return The total number of bytes passing through all AMF endpoints.
- * @throws IOException Throws IOException.
- */
- Long getAMFThroughput() throws IOException;
-
- /**
- * Returns the total number of bytes passing through all HTTP endpoints.
- *
- * @return The total number of bytes passing through all HTTP endpoints.
- * @throws IOException Throws IOException.
- */
- Long getHTTPThroughput() throws IOException;
-
- /**
- * Returns the total number of bytes passing through all Enterprise endpoints.
- *
- * @return The total number of bytes passing through all Enterprise endpoints.
- * @throws IOException Throws IOException.
- */
- Long getEnterpriseThroughput() throws IOException;
-
- /**
- * Returns the total number of bytes passing through all streaming AMF endpoints.
- *
- * @return The total number of bytes passing through all streaming AMF endpoints.
- * @throws IOException Throws IOException.
- */
- Long getStreamingAMFThroughput() throws IOException;
-
- /**
- * Returns the total number of bytes passing through all streaming HTTP endpoints.
- *
- * @return The total number of bytes passing through all streaming HTTP endpoints.
- * @throws IOException Throws IOException.
- */
- Long getStreamingHTTPThroughput() throws IOException;
-}
+/*
+ * 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.management.runtime.messaging;
+
+import flex.management.BaseControlMBean;
+
+import java.io.IOException;
+import java.util.Date;
+import javax.management.ObjectName;
+
+/**
+ * Defines the runtime monitoring and management interface for managed <code>MessageBroker</code>s.
+ *
+ * @author shodgson
+ */
+public interface MessageBrokerControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns <code>true</code> if the <code>MessageBroker</code> is running.
+ *
+ * @return <code>true</code> if the <code>MessageBroker</code> is running.
+ * @throws IOException Throws IOException.
+ */
+ Boolean isRunning() throws IOException;
+
+ /**
+ * Returns the start timestamp for the <code>MessageBroker</code>.
+ *
+ * @return The start timestamp for the <code>MessageBroker</code>.
+ * @throws IOException Throws IOException.
+ */
+ Date getStartTimestamp() throws IOException;
+
+ /**
+ * Returns the <code>ObjectName</code>s for endpoints that are registered with the
+ * managed <code>MessageBroker</code>.
+ *
+ * @return The <code>ObjectName</code>s for endpoints registered with the managed <code>MessageBroker</code>.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName[] getEndpoints() throws IOException;
+
+ /**
+ * Returns the <code>ObjectName</code>s for services that are registered with the
+ * managed <code>MessageBroker</code>.
+ *
+ * @return The <code>ObjectName</code>s for services registered with the managed <code>MessageBroker</code>.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName[] getServices() throws IOException;
+
+ /**
+ * Returns Flex session count for the <code>MessageBroker</code>.
+ *
+ * @return Flex session count for the <code>MessageBroker</code>.
+ * @throws IOException Throws IOException.
+ */
+ Integer getFlexSessionCount() throws IOException;
+
+ /**
+ * Returns the maximum concurrent Flex session count for the
+ * <code>MessageBroker</code> in the current hour.
+ *
+ * @return The maximum concurrent Flex session count for the
+ * <code>MessageBroker</code> over the course of the last hour.
+ * @throws IOException Throws IOException.
+ */
+ Integer getMaxFlexSessionsInCurrentHour() throws IOException;
+
+ /**
+ * Returns the number of Enterprise Connections across all
+ * Enterprise Endpoints.
+ *
+ * @return The number of Enterprise Connections
+ * @throws IOException Throws IOException.
+ */
+ Integer getEnterpriseConnectionCount() throws IOException;
+
+ /**
+ * Returns the total number of bytes passing through all AMF endpoints.
+ *
+ * @return The total number of bytes passing through all AMF endpoints.
+ * @throws IOException Throws IOException.
+ */
+ Long getAMFThroughput() throws IOException;
+
+ /**
+ * Returns the total number of bytes passing through all HTTP endpoints.
+ *
+ * @return The total number of bytes passing through all HTTP endpoints.
+ * @throws IOException Throws IOException.
+ */
+ Long getHTTPThroughput() throws IOException;
+
+ /**
+ * Returns the total number of bytes passing through all Enterprise endpoints.
+ *
+ * @return The total number of bytes passing through all Enterprise endpoints.
+ * @throws IOException Throws IOException.
+ */
+ Long getEnterpriseThroughput() throws IOException;
+
+ /**
+ * Returns the total number of bytes passing through all streaming AMF endpoints.
+ *
+ * @return The total number of bytes passing through all streaming AMF endpoints.
+ * @throws IOException Throws IOException.
+ */
+ Long getStreamingAMFThroughput() throws IOException;
+
+ /**
+ * Returns the total number of bytes passing through all streaming HTTP endpoints.
+ *
+ * @return The total number of bytes passing through all streaming HTTP endpoints.
+ * @throws IOException Throws IOException.
+ */
+ Long getStreamingHTTPThroughput() throws IOException;
+}
[40/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/UUIDUtils.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/UUIDUtils.java b/modules/common/src/flex/messaging/util/UUIDUtils.java
old mode 100755
new mode 100644
index 8df82e3..9fd3c57
--- a/modules/common/src/flex/messaging/util/UUIDUtils.java
+++ b/modules/common/src/flex/messaging/util/UUIDUtils.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 flex.messaging.util;
-
-import java.util.Random;
-import java.util.UUID;
-
-public class UUIDUtils
-{
- private static Random _weakRand = new Random();
-
- /**
- * The spec indicates that our time value should be based on 100 nano
- * second increments but our time granularity is in milliseconds.
- * The spec also says we can approximate the time by doing an increment
- * when we dole out new ids in the same millisecond. We can fit 10,000
- * 100 nanos into a single millisecond.
- */
- private static final int MAX_IDS_PER_MILLI = 10000;
-
- /**
- * Any given time-of-day value can only be used once; remember the last used
- * value so we don't reuse them.
- * <p>NOTE: this algorithm assumes the clock will not be turned back.
- */
- private static long lastUsedTOD = 0;
- /** Counter to use when we need more than one id in the same millisecond. */
- private static int numIdsThisMilli = 0;
-
- /** Hex digits, used for padding UUID strings with random characters. */
- private static final String alphaNum = "0123456789ABCDEF";
-
- /** 4 bits per hex character. */
- private static final int BITS_PER_DIGIT = 4;
-
- private static final int BITS_PER_INT = 32;
- private static final int BITS_PER_LONG = 64;
- private static final int DIGITS_PER_INT = BITS_PER_INT / BITS_PER_DIGIT;
- private static final int DIGITS_PER_LONG = BITS_PER_LONG / BITS_PER_DIGIT;
-
- /**
- * @private
- */
- private static char[] UPPER_DIGITS = new char[] {
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
- };
-
- /**
- * Private constructor to prevent instances from being created.
- */
- private UUIDUtils()
- {
- }
-
- /**
- *
- * Use the createUUID function when you need a unique string that you will
- * use as a persistent identifier in a distributed environment. To a very
- * high degree of certainty, this function returns a unique value; no other
- * invocation on the same or any other system should return the same value.
- *
- * @return a Universally Unique Identifier (UUID)
- * Proper Format: `XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
- * where `X' stands for a hexadecimal digit (0-9 or A-F).
- */
- public static String createUUID()
- {
- return createUUID(false);
- }
-
- public static String createUUID(boolean secure) throws Error
- {
- Random rand = _weakRand;
- if (secure)
- throw new Error("Secure UUIDs not implemented");
-
- StringBuffer s = new StringBuffer(36);
-
- appendHexString(uniqueTOD(), false, 11, s);
-
- // Just use random padding characters, but ensure that the high bit
- // is set to eliminate chances of collision with an IEEE 802 address.
- s.append( alphaNum.charAt( rand.nextInt(16) | 8 ) );
-
- // Add random padding characters.
- appendRandomHexChars(32 - s.length(), rand, s);
-
- //insert dashes in proper position. so the format matches CF
- s.insert(8,"-");
- s.insert(13,"-");
- s.insert(18,"-");
- s.insert(23,"-");
-
- return s.toString();
- }
-
- /**
- * Converts a 128-bit UID encoded as a byte[] to a String representation.
- * The format matches that generated by createUID. If a suitable byte[]
- * is not provided, null is returned.
- *
- * @param ba byte[] 16 bytes in length representing a 128-bit UID.
- *
- * @return String representation of the UID, or null if an invalid
- * byte[] is provided.
- */
- public static String fromByteArray(byte[] ba)
- {
- if (ba == null || ba.length != 16)
- return null;
-
- StringBuffer result = new StringBuffer(36);
- for (int i = 0; i < 16; i++)
- {
- if (i == 4 || i == 6 || i == 8 || i == 10)
- result.append('-');
-
- result.append(UPPER_DIGITS[(ba[i] & 0xF0) >>> 4]);
- result.append(UPPER_DIGITS[(ba[i] & 0x0F)]);
- }
- return result.toString();
- }
-
-
- /**
- * A utility method to check whether a String value represents a
- * correctly formatted UID value. UID values are expected to be
- * in the format generated by createUID(), implying that only
- * capitalized A-F characters in addition to 0-9 digits are
- * supported.
- *
- * @param uid The value to test whether it is formatted as a UID.
- *
- * @return Returns true if the value is formatted as a UID.
- */
- public static boolean isUID(String uid)
- {
- if (uid == null || uid.length() != 36)
- return false;
-
- char[] chars = uid.toCharArray();
- for (int i = 0; i < 36; i++)
- {
- char c = chars[i];
-
- // Check for correctly placed hyphens
- if (i == 8 || i == 13 || i == 18 || i == 23)
- {
- if (c != '-')
- return false;
- }
- // We allow capital alpha-numeric hex digits only
- else if (c < 48 || c > 70 || (c > 57 && c < 65))
- {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Converts a UID formatted String to a byte[]. The UID must be in the
- * format generated by createUID, otherwise null is returned.
- *
- * @param uid String representing a 128-bit UID.
- *
- * @return byte[] 16 bytes in length representing the 128-bits of the
- * UID or null if the uid could not be converted.
- */
- public static byte[] toByteArray(String uid)
- {
- if (!isUID(uid))
- return null;
-
- byte[] result = new byte[16];
- char[] chars = uid.toCharArray();
- int r = 0;
-
- for (int i = 0; i < chars.length; i++)
- {
- if (chars[i] == '-')
- continue;
- int h1 = Character.digit(chars[i], 16);
- i++;
- int h2 = Character.digit(chars[i], 16);
- result[r++] = (byte)(((h1 << 4) | h2) & 0xFF);
- }
- return result;
- }
-
- private static void appendRandomHexChars(int n, Random rand, StringBuffer result)
- {
- int digitsPerInt = DIGITS_PER_INT;
- while (n > 0)
- {
- int digitsToUse = Math.min(n, digitsPerInt);
- n -= digitsToUse;
- appendHexString(rand.nextInt(), true, digitsToUse, result);
- }
- }
-
- private static void appendHexString
- (long value, boolean prependZeroes, int nLeastSignificantDigits,
- StringBuffer result)
- {
- int bitsPerDigit = BITS_PER_DIGIT;
-
- long mask = (1L << bitsPerDigit) - 1;
-
- if (nLeastSignificantDigits < DIGITS_PER_LONG)
- {
- // Clear the bits that we don't care about.
- value &= (1L << (bitsPerDigit * nLeastSignificantDigits)) - 1;
- }
-
- // Reorder the sequence so that the first set of bits will become the
- // last set of bits.
- int i = 0;
- long reorderedValue = 0;
- if (value == 0)
- {
- // One zero is dumped.
- i++;
- }
- else
- {
- do
- {
- reorderedValue = (reorderedValue << bitsPerDigit) | (value & mask);
- value >>>= bitsPerDigit;
- i++;
- } while (value != 0);
- }
-
- if (prependZeroes)
- {
- for (int j = nLeastSignificantDigits - i; j > 0; j--)
- {
- result.append('0');
- }
- }
-
-
- // Dump the reordered sequence, with the most significant character
- // first.
- for (; i > 0; i--)
- {
- result.append(alphaNum.charAt((int) (reorderedValue & mask)));
- reorderedValue >>>= bitsPerDigit;
- }
- }
-
- private static String createInsecureUUID()
- {
- StringBuffer s = new StringBuffer(36);
-
- appendHexString(uniqueTOD(), false, 11, s);
-
- // Just use random padding characters, but ensure that the high bit
- // is set to eliminate chances of collision with an IEEE 802 address.
- s.append( alphaNum.charAt( _weakRand.nextInt(16) | 8 ) );
-
- // Add random padding characters.
- appendRandomHexChars(32 - s.length(), _weakRand, s);
-
- //insert dashes in proper position. so the format matches CF
- s.insert(8,"-");
- s.insert(13,"-");
- s.insert(18,"-");
- s.insert(23,"-");
-
- return s.toString();
- }
-
- /**
- * @return a time value, unique for calls to this method loaded by the same classloader.
- */
- private static synchronized long uniqueTOD()
- {
- long currentTOD = System.currentTimeMillis();
-
- // Clock was set back... do not hang in this case waiting to catch up.
- // Instead, rely on the random number part to differentiate the ids.
- if (currentTOD < lastUsedTOD)
- lastUsedTOD = currentTOD;
-
- if (currentTOD == lastUsedTOD)
- {
- numIdsThisMilli++;
- /*
- * Fall back to the old technique of sleeping if we allocate
- * too many ids in one time interval.
- */
- if (numIdsThisMilli >= MAX_IDS_PER_MILLI)
- {
- while ( currentTOD == lastUsedTOD )
- {
- try { Thread.sleep(1); } catch ( Exception interrupt ) { /* swallow, wake up */ }
- currentTOD = System.currentTimeMillis();
- }
- lastUsedTOD = currentTOD;
- numIdsThisMilli = 0;
- }
- }
- else
- {
- // We have a new TOD, reset the counter
- lastUsedTOD = currentTOD;
- numIdsThisMilli = 0;
- }
-
- return lastUsedTOD * MAX_IDS_PER_MILLI + (long)numIdsThisMilli;
- }
-}
+/*
+ * 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.util;
+
+import java.util.Random;
+import java.util.UUID;
+
+public class UUIDUtils
+{
+ private static Random _weakRand = new Random();
+
+ /**
+ * The spec indicates that our time value should be based on 100 nano
+ * second increments but our time granularity is in milliseconds.
+ * The spec also says we can approximate the time by doing an increment
+ * when we dole out new ids in the same millisecond. We can fit 10,000
+ * 100 nanos into a single millisecond.
+ */
+ private static final int MAX_IDS_PER_MILLI = 10000;
+
+ /**
+ * Any given time-of-day value can only be used once; remember the last used
+ * value so we don't reuse them.
+ * <p>NOTE: this algorithm assumes the clock will not be turned back.
+ */
+ private static long lastUsedTOD = 0;
+ /** Counter to use when we need more than one id in the same millisecond. */
+ private static int numIdsThisMilli = 0;
+
+ /** Hex digits, used for padding UUID strings with random characters. */
+ private static final String alphaNum = "0123456789ABCDEF";
+
+ /** 4 bits per hex character. */
+ private static final int BITS_PER_DIGIT = 4;
+
+ private static final int BITS_PER_INT = 32;
+ private static final int BITS_PER_LONG = 64;
+ private static final int DIGITS_PER_INT = BITS_PER_INT / BITS_PER_DIGIT;
+ private static final int DIGITS_PER_LONG = BITS_PER_LONG / BITS_PER_DIGIT;
+
+ /**
+ * @private
+ */
+ private static char[] UPPER_DIGITS = new char[] {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
+ };
+
+ /**
+ * Private constructor to prevent instances from being created.
+ */
+ private UUIDUtils()
+ {
+ }
+
+ /**
+ *
+ * Use the createUUID function when you need a unique string that you will
+ * use as a persistent identifier in a distributed environment. To a very
+ * high degree of certainty, this function returns a unique value; no other
+ * invocation on the same or any other system should return the same value.
+ *
+ * @return a Universally Unique Identifier (UUID)
+ * Proper Format: `XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
+ * where `X' stands for a hexadecimal digit (0-9 or A-F).
+ */
+ public static String createUUID()
+ {
+ return createUUID(false);
+ }
+
+ public static String createUUID(boolean secure) throws Error
+ {
+ Random rand = _weakRand;
+ if (secure)
+ throw new Error("Secure UUIDs not implemented");
+
+ StringBuffer s = new StringBuffer(36);
+
+ appendHexString(uniqueTOD(), false, 11, s);
+
+ // Just use random padding characters, but ensure that the high bit
+ // is set to eliminate chances of collision with an IEEE 802 address.
+ s.append( alphaNum.charAt( rand.nextInt(16) | 8 ) );
+
+ // Add random padding characters.
+ appendRandomHexChars(32 - s.length(), rand, s);
+
+ //insert dashes in proper position. so the format matches CF
+ s.insert(8,"-");
+ s.insert(13,"-");
+ s.insert(18,"-");
+ s.insert(23,"-");
+
+ return s.toString();
+ }
+
+ /**
+ * Converts a 128-bit UID encoded as a byte[] to a String representation.
+ * The format matches that generated by createUID. If a suitable byte[]
+ * is not provided, null is returned.
+ *
+ * @param ba byte[] 16 bytes in length representing a 128-bit UID.
+ *
+ * @return String representation of the UID, or null if an invalid
+ * byte[] is provided.
+ */
+ public static String fromByteArray(byte[] ba)
+ {
+ if (ba == null || ba.length != 16)
+ return null;
+
+ StringBuffer result = new StringBuffer(36);
+ for (int i = 0; i < 16; i++)
+ {
+ if (i == 4 || i == 6 || i == 8 || i == 10)
+ result.append('-');
+
+ result.append(UPPER_DIGITS[(ba[i] & 0xF0) >>> 4]);
+ result.append(UPPER_DIGITS[(ba[i] & 0x0F)]);
+ }
+ return result.toString();
+ }
+
+
+ /**
+ * A utility method to check whether a String value represents a
+ * correctly formatted UID value. UID values are expected to be
+ * in the format generated by createUID(), implying that only
+ * capitalized A-F characters in addition to 0-9 digits are
+ * supported.
+ *
+ * @param uid The value to test whether it is formatted as a UID.
+ *
+ * @return Returns true if the value is formatted as a UID.
+ */
+ public static boolean isUID(String uid)
+ {
+ if (uid == null || uid.length() != 36)
+ return false;
+
+ char[] chars = uid.toCharArray();
+ for (int i = 0; i < 36; i++)
+ {
+ char c = chars[i];
+
+ // Check for correctly placed hyphens
+ if (i == 8 || i == 13 || i == 18 || i == 23)
+ {
+ if (c != '-')
+ return false;
+ }
+ // We allow capital alpha-numeric hex digits only
+ else if (c < 48 || c > 70 || (c > 57 && c < 65))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Converts a UID formatted String to a byte[]. The UID must be in the
+ * format generated by createUID, otherwise null is returned.
+ *
+ * @param uid String representing a 128-bit UID.
+ *
+ * @return byte[] 16 bytes in length representing the 128-bits of the
+ * UID or null if the uid could not be converted.
+ */
+ public static byte[] toByteArray(String uid)
+ {
+ if (!isUID(uid))
+ return null;
+
+ byte[] result = new byte[16];
+ char[] chars = uid.toCharArray();
+ int r = 0;
+
+ for (int i = 0; i < chars.length; i++)
+ {
+ if (chars[i] == '-')
+ continue;
+ int h1 = Character.digit(chars[i], 16);
+ i++;
+ int h2 = Character.digit(chars[i], 16);
+ result[r++] = (byte)(((h1 << 4) | h2) & 0xFF);
+ }
+ return result;
+ }
+
+ private static void appendRandomHexChars(int n, Random rand, StringBuffer result)
+ {
+ int digitsPerInt = DIGITS_PER_INT;
+ while (n > 0)
+ {
+ int digitsToUse = Math.min(n, digitsPerInt);
+ n -= digitsToUse;
+ appendHexString(rand.nextInt(), true, digitsToUse, result);
+ }
+ }
+
+ private static void appendHexString
+ (long value, boolean prependZeroes, int nLeastSignificantDigits,
+ StringBuffer result)
+ {
+ int bitsPerDigit = BITS_PER_DIGIT;
+
+ long mask = (1L << bitsPerDigit) - 1;
+
+ if (nLeastSignificantDigits < DIGITS_PER_LONG)
+ {
+ // Clear the bits that we don't care about.
+ value &= (1L << (bitsPerDigit * nLeastSignificantDigits)) - 1;
+ }
+
+ // Reorder the sequence so that the first set of bits will become the
+ // last set of bits.
+ int i = 0;
+ long reorderedValue = 0;
+ if (value == 0)
+ {
+ // One zero is dumped.
+ i++;
+ }
+ else
+ {
+ do
+ {
+ reorderedValue = (reorderedValue << bitsPerDigit) | (value & mask);
+ value >>>= bitsPerDigit;
+ i++;
+ } while (value != 0);
+ }
+
+ if (prependZeroes)
+ {
+ for (int j = nLeastSignificantDigits - i; j > 0; j--)
+ {
+ result.append('0');
+ }
+ }
+
+
+ // Dump the reordered sequence, with the most significant character
+ // first.
+ for (; i > 0; i--)
+ {
+ result.append(alphaNum.charAt((int) (reorderedValue & mask)));
+ reorderedValue >>>= bitsPerDigit;
+ }
+ }
+
+ private static String createInsecureUUID()
+ {
+ StringBuffer s = new StringBuffer(36);
+
+ appendHexString(uniqueTOD(), false, 11, s);
+
+ // Just use random padding characters, but ensure that the high bit
+ // is set to eliminate chances of collision with an IEEE 802 address.
+ s.append( alphaNum.charAt( _weakRand.nextInt(16) | 8 ) );
+
+ // Add random padding characters.
+ appendRandomHexChars(32 - s.length(), _weakRand, s);
+
+ //insert dashes in proper position. so the format matches CF
+ s.insert(8,"-");
+ s.insert(13,"-");
+ s.insert(18,"-");
+ s.insert(23,"-");
+
+ return s.toString();
+ }
+
+ /**
+ * @return a time value, unique for calls to this method loaded by the same classloader.
+ */
+ private static synchronized long uniqueTOD()
+ {
+ long currentTOD = System.currentTimeMillis();
+
+ // Clock was set back... do not hang in this case waiting to catch up.
+ // Instead, rely on the random number part to differentiate the ids.
+ if (currentTOD < lastUsedTOD)
+ lastUsedTOD = currentTOD;
+
+ if (currentTOD == lastUsedTOD)
+ {
+ numIdsThisMilli++;
+ /*
+ * Fall back to the old technique of sleeping if we allocate
+ * too many ids in one time interval.
+ */
+ if (numIdsThisMilli >= MAX_IDS_PER_MILLI)
+ {
+ while ( currentTOD == lastUsedTOD )
+ {
+ try { Thread.sleep(1); } catch ( Exception interrupt ) { /* swallow, wake up */ }
+ currentTOD = System.currentTimeMillis();
+ }
+ lastUsedTOD = currentTOD;
+ numIdsThisMilli = 0;
+ }
+ }
+ else
+ {
+ // We have a new TOD, reset the counter
+ lastUsedTOD = currentTOD;
+ numIdsThisMilli = 0;
+ }
+
+ return lastUsedTOD * MAX_IDS_PER_MILLI + (long)numIdsThisMilli;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/build.xml
----------------------------------------------------------------------
diff --git a/modules/core/build.xml b/modules/core/build.xml
index 8812542..9053766 100755
--- a/modules/core/build.xml
+++ b/modules/core/build.xml
@@ -21,26 +21,17 @@
<!-- properties -->
<property file="${basedir}/build.properties"/>
- <property name="module.dir" value="${basedir}/modules/core"/>
- <property name="test.dir" value="${module.dir}/test/src"/>
-
- <!-- to exclude tests, add test.excludes to local.properties -->
- <property file="${test.dir}/local.properties"/>
- <!-- Set up feature to can run subset of tests -->
- <property file="${qa.dir}/features/${feature}.properties" /> <!-- includes only feature -->
- <property file="${qa.dir}/features/full.properties" /> <!-- includes all filesets -->
-
<property name="lib.dir" value="${basedir}/lib"/>
- <property name="module.lib.dir" location="${module.dir}/lib"/>
+
+ <property name="module.dir" value="${basedir}/modules/core"/>
+ <property name="module.lib.dir" location="${module.dir}/lib"/>
<property name="tomcat.lib.dir" location="${basedir}/servers/apache-tomcat-6.0.29/lib" />
<property name="module.src" value="${module.dir}/src"/>
<property name="module.classes" value="${module.dir}/classes"/>
<property name="module.jar" value="${lib.dir}/flex-messaging-core.jar"/>
- <property name="module.test.src" value="${module.dir}/test/src"/>
- <property name="module.test.classes" value="${module.dir}/test/classes"/>
<property name="module.dist.dir" value="${basedir}/dist/source"/>
- <property name="common.src" value="${basedir}/modules/common/src"/>
+ <property name="common.src" value="${basedir}/modules/common/src"/>
<property name="remoting.src" value="${basedir}/modules/remoting/src"/>
<property name="proxy.src" value="${basedir}/modules/proxy/src"/>
<property name="opt.src" value="${basedir}/modules/opt/src"/>
@@ -49,14 +40,9 @@
<!-- j2ee apis required to compile -->
<path id="classpath">
- <fileset dir="${lib.dir}" includes="**/*.jar"/>
- <fileset dir="${module.lib.dir}" includes="**/*.jar"/>
- <fileset dir="${tomcat.lib.dir}" includes="**/*.jar"/>
- </path>
-
- <path id="test.classpath">
- <fileset dir="${lib.dir}" includes="**/*.jar" excludes="adt.jar" />
- <pathelement location="${module.test.classes}"/>
+ <fileset dir="${lib.dir}" erroronmissingdir="false" includes="**/*.jar"/>
+ <fileset dir="${module.lib.dir}" erroronmissingdir="false" includes="**/*.jar"/>
+ <fileset dir="${tomcat.lib.dir}" erroronmissingdir="false" includes="**/*.jar"/>
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
@@ -81,9 +67,8 @@
<exclude name="flex/messaging/cluster/JGroupsCluster.java" />
<exclude name="flex/messaging/cluster/ClusterNode.java" />
<exclude name="flex/messaging/cluster/ClusterMembershipListener.java" />
- </javac>
+ </javac>
<echo file="${module.classes}/flex/messaging/version.properties" append="false">build=${build.number}</echo>
-
<copy todir="${module.classes}/flex/messaging" overwrite="true">
<fileset dir="${module.src}/flex/messaging" includes="*.properties"/>
</copy>
@@ -107,7 +92,6 @@
<!-- jar containing messaging core infrastructure -->
<target name="jar" depends="compile,compile-jgroups">
-
<jar destfile="${module.jar}" basedir="${module.classes}">
<include name="AdobeInfo.xml"/>
<include name="flex/management/**"/>
@@ -121,11 +105,9 @@
<attribute name="Implementation-Vendor" value="${manifest.Implementation-Vendor}"/>
</manifest>
</jar>
-
<delete failonerror="false">
<fileset dir="${module.classes}/flex/messaging" includes="*.properties"/>
</delete>
-
</target>
<target name="clean" description="clean">
@@ -137,81 +119,14 @@
<exclude name=".dependency-info/**"/>
</fileset>
</delete>
- <delete dir="${module.test.classes}" failonerror="false" includeEmptyDirs="true"/>
- <delete dir="${module.classes}" failonerror="false" includeEmptyDirs="true"/>
- </target>
-
- <!-- only run unit tests if junit present -->
- <condition property="junit.available">
- <available file="${junit.jar}" />
- </condition>
-
- <target name="startserver" description="Start Tomcat Server">
- <ant antfile="${basedir}/build.xml" target="startserver"/>
- </target>
-
- <target name="stopserver" description="Stop Tomcat Server">
- <ant antfile="${basedir}/build.xml" target="stopserver"/>
- </target>
-
- <target name="waitforAppserverToStart">
- <ant antfile="${basedir}/build.xml" target="waitforAppserverToStart"/>
- </target>
-
- <target name="unit" depends="startserver, waitforAppserverToStart, runtests, stopserver, check-test-results" description="runs unit tests">
- <if>
- <not>
- <equals arg1="${junit.available}" arg2="true"/>
- </not>
- <then>
- <echo>Unit test can not be run as junit.jar was not found in ${ant.home}/lib. See http://www.junit.org</echo>
- </then>
- </if>
- </target>
-
- <target name="compile-tests" if="junit.available">
- <echo message="Compiling test code..."/>
- <mkdir dir="${module.test.classes}"/>
-
- <javac srcdir="${module.test.src}" destdir="${module.test.classes}" debug="true">
- <classpath refid="classpath"/>
- </javac>
-
- <copy todir="${module.test.classes}">
- <fileset dir="${module.test.src}" includes="**/*.xml,**/*.xsd"/>
- </copy>
- </target>
-
- <target name="runtests" depends="compile-tests" if="junit.available">
- <junit printsummary="yes" dir="${test.dir}" fork="yes" maxmemory="1024m" timeout="90000" showoutput="yes"
- haltonerror="false"
- haltonfailure="false"
- failureproperty="test-failed">
- <sysproperty key="royale.home" value="${basedir}"/>
- <classpath refid="test.classpath"/>
- <formatter type="xml" usefile="true"/>
- <batchtest fork="yes">
- <fileset dir="${module.test.src}"
- includes="${junit.core.includes}"
- excludes="${junit.core.excludes}"/>
- </batchtest>
- </junit>
- </target>
-
- <!-- If one of more unit tests fail, runtests sets unit-test-failed property
- which gets checked by this target and reported
- -->
- <target name="check-test-results">
- <fail if="test-failed" message="One or more unit tests failed."/>
+ <delete dir="${module.classes}" failonerror="false" includeEmptyDirs="true"/>
</target>
<target name="javadoc">
-
<path id="javadoc.classpath">
<path refid="classpath"/>
<fileset dir="${basedir}/modules/opt/lib" includes="*.jar" excludes="catalina-708.jar"/>
</path>
-
<mkdir dir="${basedir}/docs"/>
<mkdir dir="${basedir}/docs/api"/>
<javadoc
@@ -236,9 +151,9 @@
<group title="Configuration APIs" packages="flex.messaging.config:flex.messaging.security"/>
<group title="Management APIs" packages="flex.management, flex.management.jmx, flex.management.runtime.*"/>
<link offline="false" href="http://java.sun.com/j2se/1.5.0/docs/api/" packagelistLoc="C:\tmp"/>
-</javadoc>
- <zip destfile="${basedir}/docs/javadoc.zip" basedir="${basedir}/docs/api" />
-</target>
+ </javadoc>
+ <zip destfile="${basedir}/docs/javadoc.zip" basedir="${basedir}/docs/api" />
+ </target>
</project>
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 00bb179..d4654d5 100755
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -23,7 +23,7 @@ limitations under the License.
<parent>
<groupId>org.apache.flex.blazeds</groupId>
<artifactId>blazeds</artifactId>
- <version>4.6.0.0-SNAPSHOT</version>
+ <version>4.7.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -64,27 +64,18 @@ limitations under the License.
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.2</version>
- <scope>test</scope>
- </dependency>
+ <!-- needed in order to build the ExcludeDoclet -->
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>tools</artifactId>
+ <version>jdk-version</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
- <testSourceDirectory>test/src</testSourceDirectory>
- <testResources>
- <testResource>
- <directory>test/src</directory>
- <includes>
- <include>**/*.xml</include>
- <include>**/*.xsd</include>
- </includes>
- </testResource>
- </testResources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/BaseControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/BaseControl.java b/modules/core/src/flex/management/BaseControl.java
old mode 100755
new mode 100644
index 321649f..5877286
--- a/modules/core/src/flex/management/BaseControl.java
+++ b/modules/core/src/flex/management/BaseControl.java
@@ -1,512 +1,512 @@
-/*
- * 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.management;
-
-import flex.management.runtime.AdminConsoleDisplayRegistrar;
-import flex.messaging.FlexContext;
-
-import java.util.Date;
-import java.util.List;
-import java.util.ArrayList;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MalformedObjectNameException;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.servlet.ServletConfig;
-
-/**
- * The implementation of the <code>BaseControlMBean</code> interface. This
- * abstract class provides the core functionality that all Flex control MBeans
- * require.
- * <p>
- * Defining concrete implementations of <code>getId()</code> and
- * <code>getType()</code> are left to subclasses, but this base class does
- * provide access to the parent MBean for each instance. This class also
- * implements the <code>MBeanRegistration</code> interface, and it
- * automatically stores a reference to the MBean server in each instance upon
- * registration. Subclasses may choose to override none, any, or all of the
- * methods defined by the <code>MBeanRegistration</code> interface, but any
- * overrides should be sure to invoke the overridden method with a call to their
- * superclass.
- * </p><p>
- * The <code>register()</code> method provides a simple and consistent way to
- * register instances with the MBean server, and the
- * <code>getObjectName()</code> method gaurantees consistent, well-formed
- * <code>ObjectName</code>s for all MBean instances.</p>
- *
- * @author shodgson
- */
-public abstract class BaseControl implements BaseControlMBean,
- MBeanRegistration
-{
- /**
- * The prefix used for the domain part of control MBean names.
- */
- public static final String DOMAIN_PREFIX = "flex.runtime";
- private static final int MALFORMED_OBJECTNAME = 10400;
- private static final int UNREG_EXCEPTION = 10401;
- private static final int UNREG_NOTFOUND = 10402;
- private static final int REG_EXCEPTION = 10403;
- private static final int REG_ALREADYEXISTS = 10404;
- private static final int REG_NOTCOMPLIANT = 10405;
- private static final int DISABLE_MANAGEMENT = 10426;
-
- protected Date startTimestamp;
- private BaseControl parent;
- private ObjectName objectName;
- private ObjectName registeredObjectName;
- private MBeanServer server;
- private boolean registered = false;
-
- private AdminConsoleDisplayRegistrar registrar;
-
- // Implements flex.management.BaseControlMBean.getId; inherits javadoc
- // specification.
- public abstract String getId();
-
- // Implements flex.management.BaseControlMBean.getType; inherits javadoc
- // specification.
- public abstract String getType();
-
- // Implements flex.management.BaseControlMBean.getParent; inherits javadoc
- // specification.
- public final ObjectName getParent()
- {
- return (parent != null) ? parent.getObjectName() : null;
- }
-
- /**
- * Returns an identifier for the application that hosts the component that
- * this control manages.
- *
- * @return An identifier for the application that hosts the component this
- * control manages.
- */
- public String getApplicationId()
- {
- String id = null;
- // Our base implementation attempts to use the current servlet context
- // name as our application identifier.
- ServletConfig config = FlexContext.getServletConfig();
- if (config != null)
- {
- id = config.getServletContext().getServletContextName();
- }
- return (id != null) ? id.replace(":", "") : "";
- }
-
- /**
- * Set the register object.
- * @param registar the registrar to set
- */
- protected void setRegistrar(AdminConsoleDisplayRegistrar registrar)
- {
- this.registrar = registrar;
- }
-
- /**
- * Return the registar object.
- * @return the registrar
- */
- public AdminConsoleDisplayRegistrar getRegistrar()
- {
- if ((parent == null) && (this.registrar == null))
- {
- return new AdminConsoleDisplayRegistrar(null);
- }
-
- return (this.registrar != null) ? this.registrar : parent.getRegistrar();
- }
-
- /**
- * Constructs a <code>BaseControl</code> instance that references its
- * parent; the parent may be null for root control MBeans.
- *
- * @param parent The parent <code>BaseControl</code> for this instance or
- * null if this instance is the root of a control hierarchy.
- */
- public BaseControl(BaseControl parent)
- {
- this.parent = parent;
- }
-
- /**
- * Returns the parent <code>BaseControl</code> of this instance.
- *
- * @return The parent <code>BaseControl</code>.
- */
- public final BaseControl getParentControl()
- {
- return parent;
- }
-
- /**
- * The <code>MBeanServer</code> that this instance is registered with. If
- * this instance has not been registered this method returns
- * <code>null</code>.
- *
- * @return The <code>MBeanServer</code> that this instance is registered
- * with.
- */
- public final MBeanServer getMBeanServer()
- {
- return server;
- }
-
- /**
- * Registers this instance with the MBean server.
- *
- * It may throw ManagementException If an <code>MBeanRegistrationException</code>
- * or <code>InstanceAlreadyExistsException</code> is thrown while
- * registering this MBean, the typed exception is wrapped in a
- * runtime <code>ManagementException</code> and rethrown.
- */
- public final void register()
- {
- if (!registered)
- {
- MBeanServer server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer();
- ObjectName name = getObjectName();
- try
- {
- if (server.isRegistered(name))
- {
- server.unregisterMBean(name);
- }
-
- registeredObjectName = server.registerMBean(this, name).getObjectName();
- registered = true;
- onRegistrationComplete();
-
- }
- catch (ManagementException me)
- {
- throw me;
- }
- catch (MBeanRegistrationException mre)
- {
- // Rethrow with useful message if this ever happens.
- ManagementException me = new ManagementException();
- me.setMessage(REG_EXCEPTION, new Object[] {name.toString()});
- me.setRootCause(mre);
- throw me;
- }
- catch (InstanceAlreadyExistsException iaee)
- {
- // If registration is not working at all, inform the user that
- // they may
- // work around the issue by disabling management (no MBeans will
- // be registered).
- if (!server.isRegistered(name))
- {
- ManagementException me = new ManagementException();
- me.setMessage(DISABLE_MANAGEMENT, new Object[] {name.toString()});
- throw me;
- }
- else
- {
- // Rethrow with useful message if this ever happens.
- ManagementException me = new ManagementException();
- me.setMessage(REG_ALREADYEXISTS, new Object[] {name.toString()});
- throw me;
- }
- }
- catch (NotCompliantMBeanException ncme)
- {
- // Rethrow with useful message if this ever happens.
- ManagementException me = new ManagementException();
- me.setMessage(REG_NOTCOMPLIANT, new Object[] {name.toString()});
- throw me;
- }
- catch (InstanceNotFoundException infe)
- {
- // Rethrow with useful message if this ever happens.
- ManagementException me = new ManagementException();
- me.setMessage(UNREG_NOTFOUND, new Object[] {name.toString()});
- throw me;
- }
- }
- }
-
- /**
- * This method is called after the MBean has been registered and after the
- * MBean server has returned the registeredObjectName. Classes that need
- * access to the actual Object name should override this method rather than
- * the postRegister method.
- */
- protected void onRegistrationComplete()
- {
-
- }
-
- /**
- * Unregisters this instance from the MBean server if it has been registered
- * previously.
- */
- public final void unregister()
- {
- if (registered)
- {
- // This method may be called when the JVM is being unloaded, so if
- // our
- // external error strings are loaded as missing, fall back to
- // hard-coded
- // strings.
- try
- {
- if (server.isRegistered(registeredObjectName))
- {
- server.unregisterMBean(registeredObjectName);
- }
-
- registeredObjectName = null;
- registered = false;
- }
- catch (ManagementException me)
- {
- throw me;
- }
- catch (MBeanRegistrationException mre)
- {
- // Rethrow with useful message if this ever happens.
- ManagementException me = new ManagementException();
- me.setMessage(UNREG_EXCEPTION, new Object[] {registeredObjectName.toString()});
- if (me.getMessage().indexOf(Integer.toString(UNREG_EXCEPTION)) != -1)
- {
- me.setMessage("The MBean named, '" + registeredObjectName.toString() + "', could not be unregistered because its preDeregister() method threw an exception.");
- }
- me.setRootCause(mre);
- throw me;
- }
- catch (InstanceNotFoundException infe)
- {
- // Rethrow with useful message if this ever happens.
- ManagementException me = new ManagementException();
- me.setMessage(UNREG_NOTFOUND, new Object[] {registeredObjectName.toString()});
- if (me.getMessage().indexOf(Integer.toString(UNREG_NOTFOUND)) != -1)
- {
- me.setMessage("The MBean named, '" + registeredObjectName.toString() + "', could not be unregistered because it is not currently registered.");
- }
- throw me;
- }
- }
- }
-
- /**
- * Returns the <code>ObjectName</code> for this instance, according to the
- * following format:
- * <code>{domain}[&#46;{appId}]:type={type}[&#44;{parent type}={parent id}]*[&#44;server={server}]&#63;&#44;id={id}</code>.
- * <ul>
- * <li><code>domain</code>: The domain specified by the DOMAIN_PREFIX
- * constant followed by the application identifier if one is available.</li>
- * <li><code>type</code>: The short type name of the resource managed by
- * the MBean.<br /> - The <code>MessageBrokerControlMBean</code> manages
- * the <code>flex.messaging.MessageBroker</code> so:
- * <code>type=MessageBroker</code> </li>
- * <li><code>id</code>: The id value for the resource managed by this
- * MBean. If no name or id is available on the resource, an id will be
- * fabricated according to this strategy:<br />
- * <em>id = {type} + N</em> (where N is a numeric increment for instances
- * of this type) </li>
- * <li>* optional containment keys</li>
- * </ul>
- * The runtime MBean model is hierarchical, with all MBeans ultimately
- * contained by the root <code>MessageBrokerControlMBean</code>. The
- * <code>ObjectName</code>s used for these MBeans describe this
- * containment in the following fashion. First, the 'type' key for a
- * contained MBean indicates the containment hierarchy for the bean. So, the
- * <code>ObjectName</code> for an <code>RTMPEndpointControlMBean</code>
- * would be: <code>type=MessageBroker.RTMPEndpoint</code><br />
- * In addition to the hierarchical 'type' key, the full
- * <code>ObjectName</code> for this <code>RTMPEndpointControlMBean</code>
- * also contains a containment key:
- * <code>MessageBroker=MessageBroker1</code><br />
- * Optional containment keys have the format:
- * <em>{parent type}={parent name}</em>. A containment key is added for
- * each ancestor up to the root of the hierarchy and these keys allow the
- * <code>ObjectName</code> for any MBean instance to fully describe its
- * specific location in the hierarchy. To complete the example, the full
- * <code>ObjectName</code> for the example
- * <code>RTMPEndpointControlMBean</code> would be:
- * <code>flex:type=MessageBroker.RTMPEndpoint,MessageBroker=MessageBroker1,id=RTMPEndpoint1</code>
- * <p>
- * If the MBean is registered with the MBean server, this method returns the
- * <code>ObjectName</code> that the MBean was registered under and this
- * value may contain additional key-value pairs injected by the container or
- * MBean server.
- * </p>
- *
- * @return The <code>ObjectName</code> for this instance.
- */
- public final ObjectName getObjectName()
- {
- if (registered)
- return registeredObjectName;
-
- if (objectName == null)
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append(DOMAIN_PREFIX);
- String appId = getApplicationId();
- if (appId != null && appId.length() > 0)
- {
- buffer.append('.');
- buffer.append(appId);
- }
- buffer.append(":type=");
- // Build hierarchical type value.
- List types = new ArrayList();
- List ids = new ArrayList();
- types.add(getType());
- ids.add(getId());
- BaseControl ancestor = parent;
- while (ancestor != null)
- {
- types.add(ancestor.getType());
- ids.add(ancestor.getId());
- ancestor = ancestor.getParentControl();
- }
- for (int i = types.size() - 1; i >= 0; --i)
- {
- buffer.append((String)types.get(i));
- if (i > 0)
- {
- buffer.append('.');
- }
- }
- buffer.append(',');
- // Add containment keys.
- for (int i = ids.size() - 1; i >= 1; --i)
- {
- buffer.append((String)types.get(i));
- buffer.append('=');
- buffer.append((String)ids.get(i));
- buffer.append(',');
- }
- buffer.append("id=");
- buffer.append(getId());
- String name = buffer.toString();
- // TODO: Seth: add server identifier key if we're running in a
- // cluster?
- try
- {
- objectName = new ObjectName(name);
- }
- catch (MalformedObjectNameException mone)
- {
- // Rethrow with useful message if this ever happens.
- ManagementException me = new ManagementException();
- me.setMessage(MALFORMED_OBJECTNAME, new Object[] {name});
- throw me;
- }
- }
- return objectName;
- }
-
- /**
- * Implements <code>javax.management.MBeanRegistration.preRegister</code>.
- * Allows the MBean to perform any operations it needs before being
- * registered in the MBean server. This base implementation stores a
- * reference to the MBean server that may be accessed via
- * <code>getMBeanServer()</code>. If subclasses override, they must call
- * <code>super.preRegister()</code>.
- *
- * @param server The Mbean server in which the MBean will be registered.
- * @param name The object name of the MBean.
- * @return The name the MBean will be registered under.
- * @throws Exception when the process failed
- */
- public ObjectName preRegister(MBeanServer server, ObjectName name)
- throws Exception
- {
- this.server = server;
- return (name == null) ? getObjectName() : name;
- }
-
- /**
- * Implements <code>javax.management.MBeanRegistration.postRegister</code>.
- * Allows the MBean to perform any operations needed after having been
- * registered in the MBean server or after the registration has failed. This
- * base implementation is a no-op that may be overridden.
- *
- * @param registrationDone Indicates whether or not the MBean was
- * successfully registered in the MBean server.
- */
- public void postRegister(Boolean registrationDone)
- {
- // No-op.
- }
-
- /**
- * Implements <code>javax.management.MBeanRegistration.preDeregister</code>.
- * Allows the MBean to perform any operations needed after having been
- * unregistered in the MBean server. This base implementation is a no-op
- * that may be overridden.
- * @throws Exception when the process failed
- */
- public void preDeregister() throws Exception
- {
- // No-op.
- }
-
- /**
- * Implements <code>javax.management.MBeanRegistration.postDeregister</code>.
- * Allows the MBean to perform any operations it needs before being
- * unregistered by the MBean server. This base implementation is a no-op
- * that may be overridden.
- */
- public void postDeregister()
- {
- // No-op.
- }
-
- /**
- * Sets the start timestamp for the managed component.
- *
- * @param value The start timestamp for the managed component.
- */
- public void setStartTimestamp(Date value)
- {
- startTimestamp = value;
- }
-
- /**
- * @exclude Returns the difference between a start and end timestamps in
- * minutes. Differences of less than one minute are rounded up to
- * one minute to avoid frequency calculations reporting infinite
- * message frequencies.
- * @param startTime The start timestamp in milliseconds.
- * @param endTime The end timestamp in milliseconds.
- * @return The difference between a start and end timestamps in minutes.
- */
- protected double differenceInMinutes(long startTime, long endTime)
- {
- double minutes = (endTime - startTime) / 60000d;
- if (minutes > 1d)
- {
- return minutes;
- }
- else
- {
- return 1d;
- }
- }
-}
+/*
+ * 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.management;
+
+import flex.management.runtime.AdminConsoleDisplayRegistrar;
+import flex.messaging.FlexContext;
+
+import java.util.Date;
+import java.util.List;
+import java.util.ArrayList;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MalformedObjectNameException;
+import javax.management.MBeanRegistration;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.servlet.ServletConfig;
+
+/**
+ * The implementation of the <code>BaseControlMBean</code> interface. This
+ * abstract class provides the core functionality that all Flex control MBeans
+ * require.
+ * <p>
+ * Defining concrete implementations of <code>getId()</code> and
+ * <code>getType()</code> are left to subclasses, but this base class does
+ * provide access to the parent MBean for each instance. This class also
+ * implements the <code>MBeanRegistration</code> interface, and it
+ * automatically stores a reference to the MBean server in each instance upon
+ * registration. Subclasses may choose to override none, any, or all of the
+ * methods defined by the <code>MBeanRegistration</code> interface, but any
+ * overrides should be sure to invoke the overridden method with a call to their
+ * superclass.
+ * </p><p>
+ * The <code>register()</code> method provides a simple and consistent way to
+ * register instances with the MBean server, and the
+ * <code>getObjectName()</code> method gaurantees consistent, well-formed
+ * <code>ObjectName</code>s for all MBean instances.</p>
+ *
+ * @author shodgson
+ */
+public abstract class BaseControl implements BaseControlMBean,
+ MBeanRegistration
+{
+ /**
+ * The prefix used for the domain part of control MBean names.
+ */
+ public static final String DOMAIN_PREFIX = "flex.runtime";
+ private static final int MALFORMED_OBJECTNAME = 10400;
+ private static final int UNREG_EXCEPTION = 10401;
+ private static final int UNREG_NOTFOUND = 10402;
+ private static final int REG_EXCEPTION = 10403;
+ private static final int REG_ALREADYEXISTS = 10404;
+ private static final int REG_NOTCOMPLIANT = 10405;
+ private static final int DISABLE_MANAGEMENT = 10426;
+
+ protected Date startTimestamp;
+ private BaseControl parent;
+ private ObjectName objectName;
+ private ObjectName registeredObjectName;
+ private MBeanServer server;
+ private boolean registered = false;
+
+ private AdminConsoleDisplayRegistrar registrar;
+
+ // Implements flex.management.BaseControlMBean.getId; inherits javadoc
+ // specification.
+ public abstract String getId();
+
+ // Implements flex.management.BaseControlMBean.getType; inherits javadoc
+ // specification.
+ public abstract String getType();
+
+ // Implements flex.management.BaseControlMBean.getParent; inherits javadoc
+ // specification.
+ public final ObjectName getParent()
+ {
+ return (parent != null) ? parent.getObjectName() : null;
+ }
+
+ /**
+ * Returns an identifier for the application that hosts the component that
+ * this control manages.
+ *
+ * @return An identifier for the application that hosts the component this
+ * control manages.
+ */
+ public String getApplicationId()
+ {
+ String id = null;
+ // Our base implementation attempts to use the current servlet context
+ // name as our application identifier.
+ ServletConfig config = FlexContext.getServletConfig();
+ if (config != null)
+ {
+ id = config.getServletContext().getServletContextName();
+ }
+ return (id != null) ? id.replace(":", "") : "";
+ }
+
+ /**
+ * Set the register object.
+ * @param registar the registrar to set
+ */
+ protected void setRegistrar(AdminConsoleDisplayRegistrar registrar)
+ {
+ this.registrar = registrar;
+ }
+
+ /**
+ * Return the registar object.
+ * @return the registrar
+ */
+ public AdminConsoleDisplayRegistrar getRegistrar()
+ {
+ if ((parent == null) && (this.registrar == null))
+ {
+ return new AdminConsoleDisplayRegistrar(null);
+ }
+
+ return (this.registrar != null) ? this.registrar : parent.getRegistrar();
+ }
+
+ /**
+ * Constructs a <code>BaseControl</code> instance that references its
+ * parent; the parent may be null for root control MBeans.
+ *
+ * @param parent The parent <code>BaseControl</code> for this instance or
+ * null if this instance is the root of a control hierarchy.
+ */
+ public BaseControl(BaseControl parent)
+ {
+ this.parent = parent;
+ }
+
+ /**
+ * Returns the parent <code>BaseControl</code> of this instance.
+ *
+ * @return The parent <code>BaseControl</code>.
+ */
+ public final BaseControl getParentControl()
+ {
+ return parent;
+ }
+
+ /**
+ * The <code>MBeanServer</code> that this instance is registered with. If
+ * this instance has not been registered this method returns
+ * <code>null</code>.
+ *
+ * @return The <code>MBeanServer</code> that this instance is registered
+ * with.
+ */
+ public final MBeanServer getMBeanServer()
+ {
+ return server;
+ }
+
+ /**
+ * Registers this instance with the MBean server.
+ *
+ * It may throw ManagementException If an <code>MBeanRegistrationException</code>
+ * or <code>InstanceAlreadyExistsException</code> is thrown while
+ * registering this MBean, the typed exception is wrapped in a
+ * runtime <code>ManagementException</code> and rethrown.
+ */
+ public final void register()
+ {
+ if (!registered)
+ {
+ MBeanServer server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer();
+ ObjectName name = getObjectName();
+ try
+ {
+ if (server.isRegistered(name))
+ {
+ server.unregisterMBean(name);
+ }
+
+ registeredObjectName = server.registerMBean(this, name).getObjectName();
+ registered = true;
+ onRegistrationComplete();
+
+ }
+ catch (ManagementException me)
+ {
+ throw me;
+ }
+ catch (MBeanRegistrationException mre)
+ {
+ // Rethrow with useful message if this ever happens.
+ ManagementException me = new ManagementException();
+ me.setMessage(REG_EXCEPTION, new Object[] {name.toString()});
+ me.setRootCause(mre);
+ throw me;
+ }
+ catch (InstanceAlreadyExistsException iaee)
+ {
+ // If registration is not working at all, inform the user that
+ // they may
+ // work around the issue by disabling management (no MBeans will
+ // be registered).
+ if (!server.isRegistered(name))
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(DISABLE_MANAGEMENT, new Object[] {name.toString()});
+ throw me;
+ }
+ else
+ {
+ // Rethrow with useful message if this ever happens.
+ ManagementException me = new ManagementException();
+ me.setMessage(REG_ALREADYEXISTS, new Object[] {name.toString()});
+ throw me;
+ }
+ }
+ catch (NotCompliantMBeanException ncme)
+ {
+ // Rethrow with useful message if this ever happens.
+ ManagementException me = new ManagementException();
+ me.setMessage(REG_NOTCOMPLIANT, new Object[] {name.toString()});
+ throw me;
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ // Rethrow with useful message if this ever happens.
+ ManagementException me = new ManagementException();
+ me.setMessage(UNREG_NOTFOUND, new Object[] {name.toString()});
+ throw me;
+ }
+ }
+ }
+
+ /**
+ * This method is called after the MBean has been registered and after the
+ * MBean server has returned the registeredObjectName. Classes that need
+ * access to the actual Object name should override this method rather than
+ * the postRegister method.
+ */
+ protected void onRegistrationComplete()
+ {
+
+ }
+
+ /**
+ * Unregisters this instance from the MBean server if it has been registered
+ * previously.
+ */
+ public final void unregister()
+ {
+ if (registered)
+ {
+ // This method may be called when the JVM is being unloaded, so if
+ // our
+ // external error strings are loaded as missing, fall back to
+ // hard-coded
+ // strings.
+ try
+ {
+ if (server.isRegistered(registeredObjectName))
+ {
+ server.unregisterMBean(registeredObjectName);
+ }
+
+ registeredObjectName = null;
+ registered = false;
+ }
+ catch (ManagementException me)
+ {
+ throw me;
+ }
+ catch (MBeanRegistrationException mre)
+ {
+ // Rethrow with useful message if this ever happens.
+ ManagementException me = new ManagementException();
+ me.setMessage(UNREG_EXCEPTION, new Object[] {registeredObjectName.toString()});
+ if (me.getMessage().indexOf(Integer.toString(UNREG_EXCEPTION)) != -1)
+ {
+ me.setMessage("The MBean named, '" + registeredObjectName.toString() + "', could not be unregistered because its preDeregister() method threw an exception.");
+ }
+ me.setRootCause(mre);
+ throw me;
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ // Rethrow with useful message if this ever happens.
+ ManagementException me = new ManagementException();
+ me.setMessage(UNREG_NOTFOUND, new Object[] {registeredObjectName.toString()});
+ if (me.getMessage().indexOf(Integer.toString(UNREG_NOTFOUND)) != -1)
+ {
+ me.setMessage("The MBean named, '" + registeredObjectName.toString() + "', could not be unregistered because it is not currently registered.");
+ }
+ throw me;
+ }
+ }
+ }
+
+ /**
+ * Returns the <code>ObjectName</code> for this instance, according to the
+ * following format:
+ * <code>{domain}[&#46;{appId}]:type={type}[&#44;{parent type}={parent id}]*[&#44;server={server}]&#63;&#44;id={id}</code>.
+ * <ul>
+ * <li><code>domain</code>: The domain specified by the DOMAIN_PREFIX
+ * constant followed by the application identifier if one is available.</li>
+ * <li><code>type</code>: The short type name of the resource managed by
+ * the MBean.<br /> - The <code>MessageBrokerControlMBean</code> manages
+ * the <code>flex.messaging.MessageBroker</code> so:
+ * <code>type=MessageBroker</code> </li>
+ * <li><code>id</code>: The id value for the resource managed by this
+ * MBean. If no name or id is available on the resource, an id will be
+ * fabricated according to this strategy:<br />
+ * <em>id = {type} + N</em> (where N is a numeric increment for instances
+ * of this type) </li>
+ * <li>* optional containment keys</li>
+ * </ul>
+ * The runtime MBean model is hierarchical, with all MBeans ultimately
+ * contained by the root <code>MessageBrokerControlMBean</code>. The
+ * <code>ObjectName</code>s used for these MBeans describe this
+ * containment in the following fashion. First, the 'type' key for a
+ * contained MBean indicates the containment hierarchy for the bean. So, the
+ * <code>ObjectName</code> for an <code>RTMPEndpointControlMBean</code>
+ * would be: <code>type=MessageBroker.RTMPEndpoint</code><br />
+ * In addition to the hierarchical 'type' key, the full
+ * <code>ObjectName</code> for this <code>RTMPEndpointControlMBean</code>
+ * also contains a containment key:
+ * <code>MessageBroker=MessageBroker1</code><br />
+ * Optional containment keys have the format:
+ * <em>{parent type}={parent name}</em>. A containment key is added for
+ * each ancestor up to the root of the hierarchy and these keys allow the
+ * <code>ObjectName</code> for any MBean instance to fully describe its
+ * specific location in the hierarchy. To complete the example, the full
+ * <code>ObjectName</code> for the example
+ * <code>RTMPEndpointControlMBean</code> would be:
+ * <code>flex:type=MessageBroker.RTMPEndpoint,MessageBroker=MessageBroker1,id=RTMPEndpoint1</code>
+ * <p>
+ * If the MBean is registered with the MBean server, this method returns the
+ * <code>ObjectName</code> that the MBean was registered under and this
+ * value may contain additional key-value pairs injected by the container or
+ * MBean server.
+ * </p>
+ *
+ * @return The <code>ObjectName</code> for this instance.
+ */
+ public final ObjectName getObjectName()
+ {
+ if (registered)
+ return registeredObjectName;
+
+ if (objectName == null)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(DOMAIN_PREFIX);
+ String appId = getApplicationId();
+ if (appId != null && appId.length() > 0)
+ {
+ buffer.append('.');
+ buffer.append(appId);
+ }
+ buffer.append(":type=");
+ // Build hierarchical type value.
+ List types = new ArrayList();
+ List ids = new ArrayList();
+ types.add(getType());
+ ids.add(getId());
+ BaseControl ancestor = parent;
+ while (ancestor != null)
+ {
+ types.add(ancestor.getType());
+ ids.add(ancestor.getId());
+ ancestor = ancestor.getParentControl();
+ }
+ for (int i = types.size() - 1; i >= 0; --i)
+ {
+ buffer.append((String)types.get(i));
+ if (i > 0)
+ {
+ buffer.append('.');
+ }
+ }
+ buffer.append(',');
+ // Add containment keys.
+ for (int i = ids.size() - 1; i >= 1; --i)
+ {
+ buffer.append((String)types.get(i));
+ buffer.append('=');
+ buffer.append((String)ids.get(i));
+ buffer.append(',');
+ }
+ buffer.append("id=");
+ buffer.append(getId());
+ String name = buffer.toString();
+ // TODO: Seth: add server identifier key if we're running in a
+ // cluster?
+ try
+ {
+ objectName = new ObjectName(name);
+ }
+ catch (MalformedObjectNameException mone)
+ {
+ // Rethrow with useful message if this ever happens.
+ ManagementException me = new ManagementException();
+ me.setMessage(MALFORMED_OBJECTNAME, new Object[] {name});
+ throw me;
+ }
+ }
+ return objectName;
+ }
+
+ /**
+ * Implements <code>javax.management.MBeanRegistration.preRegister</code>.
+ * Allows the MBean to perform any operations it needs before being
+ * registered in the MBean server. This base implementation stores a
+ * reference to the MBean server that may be accessed via
+ * <code>getMBeanServer()</code>. If subclasses override, they must call
+ * <code>super.preRegister()</code>.
+ *
+ * @param server The Mbean server in which the MBean will be registered.
+ * @param name The object name of the MBean.
+ * @return The name the MBean will be registered under.
+ * @throws Exception when the process failed
+ */
+ public ObjectName preRegister(MBeanServer server, ObjectName name)
+ throws Exception
+ {
+ this.server = server;
+ return (name == null) ? getObjectName() : name;
+ }
+
+ /**
+ * Implements <code>javax.management.MBeanRegistration.postRegister</code>.
+ * Allows the MBean to perform any operations needed after having been
+ * registered in the MBean server or after the registration has failed. This
+ * base implementation is a no-op that may be overridden.
+ *
+ * @param registrationDone Indicates whether or not the MBean was
+ * successfully registered in the MBean server.
+ */
+ public void postRegister(Boolean registrationDone)
+ {
+ // No-op.
+ }
+
+ /**
+ * Implements <code>javax.management.MBeanRegistration.preDeregister</code>.
+ * Allows the MBean to perform any operations needed after having been
+ * unregistered in the MBean server. This base implementation is a no-op
+ * that may be overridden.
+ * @throws Exception when the process failed
+ */
+ public void preDeregister() throws Exception
+ {
+ // No-op.
+ }
+
+ /**
+ * Implements <code>javax.management.MBeanRegistration.postDeregister</code>.
+ * Allows the MBean to perform any operations it needs before being
+ * unregistered by the MBean server. This base implementation is a no-op
+ * that may be overridden.
+ */
+ public void postDeregister()
+ {
+ // No-op.
+ }
+
+ /**
+ * Sets the start timestamp for the managed component.
+ *
+ * @param value The start timestamp for the managed component.
+ */
+ public void setStartTimestamp(Date value)
+ {
+ startTimestamp = value;
+ }
+
+ /**
+ * @exclude Returns the difference between a start and end timestamps in
+ * minutes. Differences of less than one minute are rounded up to
+ * one minute to avoid frequency calculations reporting infinite
+ * message frequencies.
+ * @param startTime The start timestamp in milliseconds.
+ * @param endTime The end timestamp in milliseconds.
+ * @return The difference between a start and end timestamps in minutes.
+ */
+ protected double differenceInMinutes(long startTime, long endTime)
+ {
+ double minutes = (endTime - startTime) / 60000d;
+ if (minutes > 1d)
+ {
+ return minutes;
+ }
+ else
+ {
+ return 1d;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/BaseControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/BaseControlMBean.java b/modules/core/src/flex/management/BaseControlMBean.java
old mode 100755
new mode 100644
index 09ab6fe..3d3f2fd
--- a/modules/core/src/flex/management/BaseControlMBean.java
+++ b/modules/core/src/flex/management/BaseControlMBean.java
@@ -1,57 +1,57 @@
-/*
- * 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.management;
-
-import java.io.IOException;
-import javax.management.ObjectName;
-
-/**
- * The base MBean interface for management beans that control aspects of
- * Flex behavior on the server.
- *
- * @author shodgson
- */
-public interface BaseControlMBean
-{
- /**
- * Returns the id for this MBean. This is the value that is set for the
- * <code>id</code> key in the <code>ObjectName</code> for this MBean.
- *
- * @return The MBean instance id.
- * @throws IOException Throws IOException.
- */
- String getId() throws IOException;
-
- /**
- * Returns the type for this MBean. This is the value that is set for the
- * <code>type</code> key in the <code>ObjectName</code> for this MBean.
- *
- * @return The MBean instance type.
- * @throws IOException Throws IOException.
- */
- String getType() throws IOException;
-
- /**
- * Returns the parent for this MBean. The value is the <code>ObjectName</code>
- * for the parent MBean that conceptually contains this MBean instance. If no
- * parent exists, this method returns <code>null</code>.
- *
- * @return The <code>ObjectName</code> for the parent of this MBean instance.
- * @throws IOException Throws IOException.
- */
- ObjectName getParent() throws IOException;
-}
+/*
+ * 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.management;
+
+import java.io.IOException;
+import javax.management.ObjectName;
+
+/**
+ * The base MBean interface for management beans that control aspects of
+ * Flex behavior on the server.
+ *
+ * @author shodgson
+ */
+public interface BaseControlMBean
+{
+ /**
+ * Returns the id for this MBean. This is the value that is set for the
+ * <code>id</code> key in the <code>ObjectName</code> for this MBean.
+ *
+ * @return The MBean instance id.
+ * @throws IOException Throws IOException.
+ */
+ String getId() throws IOException;
+
+ /**
+ * Returns the type for this MBean. This is the value that is set for the
+ * <code>type</code> key in the <code>ObjectName</code> for this MBean.
+ *
+ * @return The MBean instance type.
+ * @throws IOException Throws IOException.
+ */
+ String getType() throws IOException;
+
+ /**
+ * Returns the parent for this MBean. The value is the <code>ObjectName</code>
+ * for the parent MBean that conceptually contains this MBean instance. If no
+ * parent exists, this method returns <code>null</code>.
+ *
+ * @return The <code>ObjectName</code> for the parent of this MBean instance.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName getParent() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/MBeanLifecycleManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/MBeanLifecycleManager.java b/modules/core/src/flex/management/MBeanLifecycleManager.java
old mode 100755
new mode 100644
index 4bbfea9..164f8c4
--- a/modules/core/src/flex/management/MBeanLifecycleManager.java
+++ b/modules/core/src/flex/management/MBeanLifecycleManager.java
@@ -1,65 +1,65 @@
-/*
- * 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.management;
-
-import flex.messaging.MessageBroker;
-
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-/**
- * Helper class for managing MBean lifecycles externally from the core server
- * components where necessary.
- *
- * @author shodgson
- */
-public class MBeanLifecycleManager
-{
- /**
- * Unregisters all runtime MBeans that are registered in the same domain as the
- * MessageBrokerControl for the target MessageBroker.
- *
- * @param broker The MessageBroker component that has been stopped.
- */
- public static void unregisterRuntimeMBeans(MessageBroker broker)
- {
- MBeanServer server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer();
- ObjectName brokerMBean = broker.getControl().getObjectName();
- String domain = brokerMBean.getDomain();
- try
- {
- ObjectName pattern = new ObjectName(domain + ":*");
- Set names = server.queryNames(pattern, null);
- Iterator iter = names.iterator();
- while (iter.hasNext())
- {
- ObjectName on = (ObjectName)iter.next();
- server.unregisterMBean(on);
- }
- }
- catch (Exception e)
- {
- // We're generally unregistering these during shutdown (possibly JVM shutdown)
- // so there's nothing to really do here because we aren't guaranteed access to
- // resources like system log files, localized messaging, etc.
- }
- }
-
-}
+/*
+ * 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.management;
+
+import flex.messaging.MessageBroker;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Helper class for managing MBean lifecycles externally from the core server
+ * components where necessary.
+ *
+ * @author shodgson
+ */
+public class MBeanLifecycleManager
+{
+ /**
+ * Unregisters all runtime MBeans that are registered in the same domain as the
+ * MessageBrokerControl for the target MessageBroker.
+ *
+ * @param broker The MessageBroker component that has been stopped.
+ */
+ public static void unregisterRuntimeMBeans(MessageBroker broker)
+ {
+ MBeanServer server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer();
+ ObjectName brokerMBean = broker.getControl().getObjectName();
+ String domain = brokerMBean.getDomain();
+ try
+ {
+ ObjectName pattern = new ObjectName(domain + ":*");
+ Set names = server.queryNames(pattern, null);
+ Iterator iter = names.iterator();
+ while (iter.hasNext())
+ {
+ ObjectName on = (ObjectName)iter.next();
+ server.unregisterMBean(on);
+ }
+ }
+ catch (Exception e)
+ {
+ // We're generally unregistering these during shutdown (possibly JVM shutdown)
+ // so there's nothing to really do here because we aren't guaranteed access to
+ // resources like system log files, localized messaging, etc.
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/MBeanServerLocator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/MBeanServerLocator.java b/modules/core/src/flex/management/MBeanServerLocator.java
old mode 100755
new mode 100644
index af3676f..bf34c97
--- a/modules/core/src/flex/management/MBeanServerLocator.java
+++ b/modules/core/src/flex/management/MBeanServerLocator.java
@@ -1,35 +1,35 @@
-/*
- * 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.management;
-
-import javax.management.MBeanServer;
-
-/**
- * Interface for classes that locate MBeanServers to register MBeans with.
- *
- * @author shodgson
- */
-public interface MBeanServerLocator
-{
- /**
- * Returns the MBeanServer to register our management MBeans with.
- *
- * @return The MBeanServer to register our management MBeans with.
- */
- MBeanServer getMBeanServer();
-
-}
+/*
+ * 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.management;
+
+import javax.management.MBeanServer;
+
+/**
+ * Interface for classes that locate MBeanServers to register MBeans with.
+ *
+ * @author shodgson
+ */
+public interface MBeanServerLocator
+{
+ /**
+ * Returns the MBeanServer to register our management MBeans with.
+ *
+ * @return The MBeanServer to register our management MBeans with.
+ */
+ MBeanServer getMBeanServer();
+
+}
[07/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/DuplicateSessionException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/DuplicateSessionException.java b/modules/core/src/flex/messaging/endpoints/DuplicateSessionException.java
old mode 100755
new mode 100644
index 692dac2..a1700c1
--- a/modules/core/src/flex/messaging/endpoints/DuplicateSessionException.java
+++ b/modules/core/src/flex/messaging/endpoints/DuplicateSessionException.java
@@ -1,81 +1,81 @@
-/*
- * 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.endpoints;
-
-import flex.messaging.MessageException;
-import flex.messaging.log.LogEvent;
-
-/**
- * Exception class used to indicate duplicate client sessions were detected.
- */
-public class DuplicateSessionException extends MessageException
-{
- /**
- * @exclude
- */
- public static final String DUPLICATE_SESSION_DETECTED_CODE = "Server.Processing.DuplicateSessionDetected";
-
- /**
- * @exclude
- */
- private static final long serialVersionUID = -741704726700619666L;
-
- //--------------------------------------------------------------------------
- //
- // Constructors
- //
- //--------------------------------------------------------------------------
-
- /**
- * Default constructor.
- * Sets the code to a default value of <code>DUPLICATE_SESSION_DETECTED_CODE</code>.
- */
- public DuplicateSessionException()
- {
- setCode(DUPLICATE_SESSION_DETECTED_CODE);
- }
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // preferredLogLevel
- //----------------------------------
-
- /**
- * Override to log at the DEBUG level.
- */
- @Override public short getPreferredLogLevel()
- {
- return LogEvent.DEBUG;
- }
-
- //----------------------------------
- // logStackTraceEnabled
- //----------------------------------
-
- /**
- * Override to suppress stack trace logging.
- */
- @Override public boolean isLogStackTraceEnabled()
- {
- return false;
- }
-}
+/*
+ * 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.endpoints;
+
+import flex.messaging.MessageException;
+import flex.messaging.log.LogEvent;
+
+/**
+ * Exception class used to indicate duplicate client sessions were detected.
+ */
+public class DuplicateSessionException extends MessageException
+{
+ /**
+ * @exclude
+ */
+ public static final String DUPLICATE_SESSION_DETECTED_CODE = "Server.Processing.DuplicateSessionDetected";
+
+ /**
+ * @exclude
+ */
+ private static final long serialVersionUID = -741704726700619666L;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructors
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Default constructor.
+ * Sets the code to a default value of <code>DUPLICATE_SESSION_DETECTED_CODE</code>.
+ */
+ public DuplicateSessionException()
+ {
+ setCode(DUPLICATE_SESSION_DETECTED_CODE);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // preferredLogLevel
+ //----------------------------------
+
+ /**
+ * Override to log at the DEBUG level.
+ */
+ @Override public short getPreferredLogLevel()
+ {
+ return LogEvent.DEBUG;
+ }
+
+ //----------------------------------
+ // logStackTraceEnabled
+ //----------------------------------
+
+ /**
+ * Override to suppress stack trace logging.
+ */
+ @Override public boolean isLogStackTraceEnabled()
+ {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/Endpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/Endpoint.java b/modules/core/src/flex/messaging/endpoints/Endpoint.java
old mode 100755
new mode 100644
index 72069c4..da86ce1
--- a/modules/core/src/flex/messaging/endpoints/Endpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/Endpoint.java
@@ -1,190 +1,190 @@
-/*
- * 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.endpoints;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import flex.management.Manageable;
-import flex.messaging.MessageBroker;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.SecurityConstraint;
-
-/**
- * An endpoint receives messages from clients and decodes them,
- * then sends them on to a MessageBroker for routing to a service.
- * The endpoint also encodes messages and delivers them to clients.
- * Endpoints are specific to a message format and network transport,
- * and are defined by the named URI path on which they are located.
- *
- * @author neville
- */
-public interface Endpoint extends Manageable
-{
- /**
- * Initializes the endpoint with an ID and properties.
- *
- * @param id The ID of the endpoint.
- * @param properties Properties of the endpoint.
- */
- void initialize(String id, ConfigMap properties);
-
- /**
- * Start the endpoint. The MethodBroker invokes this
- * method in order to set the endpoint up for sending and receiving
- * messages from Flash clients.
- *
- */
- void start();
-
- /**
- * Determines whether the endpoint is started.
- *
- * @return <code>true</code> if the endpoint is started; <code>false</code> otherwise.
- */
- boolean isStarted();
-
- /**
- * Stop and destroy the endpoint. The MethodBroker invokes
- * this method in order to stop the endpoint from sending
- * and receiving messages from Flash clients.
- *
- */
- void stop();
-
- /**
- * Retrieves the corresponding client channel type for the endpoint.
- *
- * @return The corresponding client channel type for the endpoint.
- */
- String getClientType();
-
- /**
- * Sets the corresponding client channel type for the endpoint.
- *
- * @param clientType The corresponding client channel type for the endpoint.
- */
- void setClientType(String clientType);
-
- /**
- * Retrieves the endpoint properties the client needs.
- * @return The endpoint properties the client needs.
- */
- ConfigMap describeEndpoint();
-
- /**
- * All endpoints are referenceable by an ID that is unique among
- * all the endpoints registered to a single broker instance.
- * @return The endpoint ID.
- */
- String getId();
-
- /**
- * All endpoints are referenceable by an ID that is unique among
- * all the endpoints registered to a single broker instance. The id
- * is set through this method, usually through parsed configuration.
- * <p/>
- * @param id The endpoint ID.
- */
- void setId(String id);
-
- /**
- * All endpoints must be managed by a single MessageBroker,
- * and must be capable of returning a reference to that broker.
- * This broker reference is used when the endpoint wishes to
- * send a message to one of the broker's services.
- *
- * @return broker The MessageBroker instance which manages this endpoint.
- */
- MessageBroker getMessageBroker();
-
- /**
- * Sets the <code>MessageBroker</code> of the endpoint.
- *
- * @param broker the message broker object
- */
- void setMessageBroker(MessageBroker broker);
-
- /**
- * Retrieves the highest messaging version currently available via this
- * endpoint.
- * @return The messaging version number.
- */
- double getMessagingVersion();
-
- /** @exclude **/
- String getParsedUrl(String contextPath);
-
- /**
- * Retrieves the port of the URL of the endpoint.
- *
- * @return The port of the URL of the endpoint.
- */
- int getPort();
-
- /**
- * Specifies whether this protocol requires the secure HTTPS protocol.
- * @return <code>true</code> if the endpoint is a secure endpoint, <code>false</code> otherwise.
- */
- boolean isSecure();
-
- /**
- * Retrieves the security constraint of the endpoint.
- *
- * @return The security constraint of the endpoint.
- */
- SecurityConstraint getSecurityConstraint();
-
- /**
- * Sets the security constraint of the endpoint.
- *
- * @param constraint The security constraint of the endpoint.
- */
- void setSecurityConstraint(SecurityConstraint constraint);
-
- /**
- * Responds to HTTP-based messages published by a client. Endpoints which
- * do not support access over HTTP should throw an UnsupportedOperationException
- * in the implementation of htis method.
- * <p/>
- * @param req The HttpServletRequest object.
- * @param res The HttpServletResponse object.
- */
- void service(HttpServletRequest req, HttpServletResponse res);
-
- /**
- * Retrieves the URL of the endpoint.
- *
- * @return The URL of the endpoint.
- */
- String getUrl();
-
- /**
- * Sets the URL of the endpoint.
- *
- * @param url The URL of the endpoint.
- */
- void setUrl(String url);
-
- /**
- * @exclude
- * Returns the url of the endpoint parsed for the client.
- *
- * @return The url of the endpoint parsed for the client.
- */
- String getUrlForClient();
-}
+/*
+ * 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.endpoints;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import flex.management.Manageable;
+import flex.messaging.MessageBroker;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.SecurityConstraint;
+
+/**
+ * An endpoint receives messages from clients and decodes them,
+ * then sends them on to a MessageBroker for routing to a service.
+ * The endpoint also encodes messages and delivers them to clients.
+ * Endpoints are specific to a message format and network transport,
+ * and are defined by the named URI path on which they are located.
+ *
+ * @author neville
+ */
+public interface Endpoint extends Manageable
+{
+ /**
+ * Initializes the endpoint with an ID and properties.
+ *
+ * @param id The ID of the endpoint.
+ * @param properties Properties of the endpoint.
+ */
+ void initialize(String id, ConfigMap properties);
+
+ /**
+ * Start the endpoint. The MethodBroker invokes this
+ * method in order to set the endpoint up for sending and receiving
+ * messages from Flash clients.
+ *
+ */
+ void start();
+
+ /**
+ * Determines whether the endpoint is started.
+ *
+ * @return <code>true</code> if the endpoint is started; <code>false</code> otherwise.
+ */
+ boolean isStarted();
+
+ /**
+ * Stop and destroy the endpoint. The MethodBroker invokes
+ * this method in order to stop the endpoint from sending
+ * and receiving messages from Flash clients.
+ *
+ */
+ void stop();
+
+ /**
+ * Retrieves the corresponding client channel type for the endpoint.
+ *
+ * @return The corresponding client channel type for the endpoint.
+ */
+ String getClientType();
+
+ /**
+ * Sets the corresponding client channel type for the endpoint.
+ *
+ * @param clientType The corresponding client channel type for the endpoint.
+ */
+ void setClientType(String clientType);
+
+ /**
+ * Retrieves the endpoint properties the client needs.
+ * @return The endpoint properties the client needs.
+ */
+ ConfigMap describeEndpoint();
+
+ /**
+ * All endpoints are referenceable by an ID that is unique among
+ * all the endpoints registered to a single broker instance.
+ * @return The endpoint ID.
+ */
+ String getId();
+
+ /**
+ * All endpoints are referenceable by an ID that is unique among
+ * all the endpoints registered to a single broker instance. The id
+ * is set through this method, usually through parsed configuration.
+ * <p/>
+ * @param id The endpoint ID.
+ */
+ void setId(String id);
+
+ /**
+ * All endpoints must be managed by a single MessageBroker,
+ * and must be capable of returning a reference to that broker.
+ * This broker reference is used when the endpoint wishes to
+ * send a message to one of the broker's services.
+ *
+ * @return broker The MessageBroker instance which manages this endpoint.
+ */
+ MessageBroker getMessageBroker();
+
+ /**
+ * Sets the <code>MessageBroker</code> of the endpoint.
+ *
+ * @param broker the message broker object
+ */
+ void setMessageBroker(MessageBroker broker);
+
+ /**
+ * Retrieves the highest messaging version currently available via this
+ * endpoint.
+ * @return The messaging version number.
+ */
+ double getMessagingVersion();
+
+ /** @exclude **/
+ String getParsedUrl(String contextPath);
+
+ /**
+ * Retrieves the port of the URL of the endpoint.
+ *
+ * @return The port of the URL of the endpoint.
+ */
+ int getPort();
+
+ /**
+ * Specifies whether this protocol requires the secure HTTPS protocol.
+ * @return <code>true</code> if the endpoint is a secure endpoint, <code>false</code> otherwise.
+ */
+ boolean isSecure();
+
+ /**
+ * Retrieves the security constraint of the endpoint.
+ *
+ * @return The security constraint of the endpoint.
+ */
+ SecurityConstraint getSecurityConstraint();
+
+ /**
+ * Sets the security constraint of the endpoint.
+ *
+ * @param constraint The security constraint of the endpoint.
+ */
+ void setSecurityConstraint(SecurityConstraint constraint);
+
+ /**
+ * Responds to HTTP-based messages published by a client. Endpoints which
+ * do not support access over HTTP should throw an UnsupportedOperationException
+ * in the implementation of htis method.
+ * <p/>
+ * @param req The HttpServletRequest object.
+ * @param res The HttpServletResponse object.
+ */
+ void service(HttpServletRequest req, HttpServletResponse res);
+
+ /**
+ * Retrieves the URL of the endpoint.
+ *
+ * @return The URL of the endpoint.
+ */
+ String getUrl();
+
+ /**
+ * Sets the URL of the endpoint.
+ *
+ * @param url The URL of the endpoint.
+ */
+ void setUrl(String url);
+
+ /**
+ * @exclude
+ * Returns the url of the endpoint parsed for the client.
+ *
+ * @return The url of the endpoint parsed for the client.
+ */
+ String getUrlForClient();
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/Endpoint2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/Endpoint2.java b/modules/core/src/flex/messaging/endpoints/Endpoint2.java
old mode 100755
new mode 100644
index 26f47ee..8f10ebe
--- a/modules/core/src/flex/messaging/endpoints/Endpoint2.java
+++ b/modules/core/src/flex/messaging/endpoints/Endpoint2.java
@@ -1,37 +1,37 @@
-/*
- * 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.endpoints;
-
-import flex.messaging.Server;
-
-/**
- * Extension interface for <tt>Endpoint</tt> that adds support for a
- * referenced <tt>Server</tt> that the endpoint may use.
- */
-public interface Endpoint2 extends Endpoint
-{
- /**
- * Retrieves the <tt>Server</tt> that the endpoint is using; <code>null</code> if
- * no server has been assigned.
- */
- Server getServer();
-
- /**
- * Sets the <tt>Server</tt> that the endpoint will use.
- */
- void setServer(Server server);
-}
+/*
+ * 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.endpoints;
+
+import flex.messaging.Server;
+
+/**
+ * Extension interface for <tt>Endpoint</tt> that adds support for a
+ * referenced <tt>Server</tt> that the endpoint may use.
+ */
+public interface Endpoint2 extends Endpoint
+{
+ /**
+ * Retrieves the <tt>Server</tt> that the endpoint is using; <code>null</code> if
+ * no server has been assigned.
+ */
+ Server getServer();
+
+ /**
+ * Sets the <tt>Server</tt> that the endpoint will use.
+ */
+ void setServer(Server server);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/HTTPEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/HTTPEndpoint.java b/modules/core/src/flex/messaging/endpoints/HTTPEndpoint.java
old mode 100755
new mode 100644
index 6cbe951..82e358f
--- a/modules/core/src/flex/messaging/endpoints/HTTPEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/HTTPEndpoint.java
@@ -1,185 +1,185 @@
-/*
- * 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.endpoints;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import flex.management.runtime.messaging.endpoints.HTTPEndpointControl;
-import flex.messaging.MessageBroker;
-import flex.messaging.endpoints.amf.AMFFilter;
-import flex.messaging.endpoints.amf.BatchProcessFilter;
-import flex.messaging.endpoints.amf.MessageBrokerFilter;
-import flex.messaging.endpoints.amf.SerializationFilter;
-import flex.messaging.endpoints.amf.SessionFilter;
-import flex.messaging.io.MessageIOConstants;
-import flex.messaging.log.LogCategories;
-import flex.messaging.messages.Message;
-import flex.messaging.security.SecurityException;
-
-/**
- * This class replaces Flex 1.5's ProxyServlet by splitting
- * the proxy's functionality into two pieces. Requests for proxied HTTP
- * content can now be sent using a message type via any channel.
- * The message broker directs requests to the appropriate service,
- * in Flex 1.5 terms, the Proxy Service. The response from the proxy
- * request is streamed back to the client.
- *
- */
-public class HTTPEndpoint extends BasePollingHTTPEndpoint
-{
- public static final String LOG_CATEGORY = LogCategories.ENDPOINT_HTTP;
-
- private static final int IMPROPER_CONTENT_TYPE = 10068;
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>HTTPEndpoint</code>.
- */
- public HTTPEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>HTTPEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>HTTPEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public HTTPEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- /**
- * Currently this override is a no-op to disable small messages over HTTP
- * endpoints.
- */
- @Override public Message convertToSmallMessage(Message message)
- {
- return message;
- }
-
- /**
- * Overrides to check the request content type is application/xml.
- *
- * @param req The servlet request.
- * @param res The servlet response.
- */
- @Override public void service(HttpServletRequest req, HttpServletResponse res)
- {
- String contentType = req.getContentType();
- boolean xmlContentType = contentType == null || contentType.equals(MessageIOConstants.XML_CONTENT_TYPE);
- if (!xmlContentType)
- {
- // HTTP endpoint ''{0}'' must be contacted via a HTTP request with proper content type.
- SecurityException se = new SecurityException();
- se.setMessage(IMPROPER_CONTENT_TYPE, new Object[]{id});
- throw se;
- }
-
- super.service(req, res);
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected/Private Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Create default filter chain or return current one if already present.
- */
- @Override protected AMFFilter createFilterChain()
- {
- AMFFilter serializationFilter = new SerializationFilter(getLogCategory());
- AMFFilter batchFilter = new BatchProcessFilter();
- AMFFilter sessionFilter = sessionRewritingEnabled? new SessionFilter() : null;
- AMFFilter messageBrokerFilter = new MessageBrokerFilter(this);
-
- serializationFilter.setNext(batchFilter);
- if (sessionFilter != null)
- {
- batchFilter.setNext(sessionFilter);
- sessionFilter.setNext(messageBrokerFilter);
- }
- else
- {
- batchFilter.setNext(messageBrokerFilter);
- }
-
- return serializationFilter;
- }
-
- /**
- * Returns MessageIOConstants.XML_CONTENT_TYPE.
- */
- @Override protected String getResponseContentType()
- {
- return MessageIOConstants.XML_CONTENT_TYPE;
- }
-
- /**
- * Returns the log category of the endpoint.
- *
- * @return The log category of the endpoint.
- */
- @Override protected String getLogCategory()
- {
- return LOG_CATEGORY;
- }
-
- /**
- * Returns the deserializer class name used by the endpoint.
- *
- * @return The deserializer class name used by the endpoint.
- */
- @Override protected String getDeserializerClassName()
- {
- return "flex.messaging.io.amfx.AmfxMessageDeserializer";
- }
-
- /**
- * Returns the serializer class name used by the endpoint.
- *
- * @return The serializer class name used by the endpoint.
- */
- @Override protected String getSerializerClassName()
- {
- return "flex.messaging.io.amfx.AmfxMessageSerializer";
- }
-
- /**
- * Invoked automatically to allow the <code>HTTPEndpoint</code> to setup its
- * corresponding MBean control.
- *
- * @param broker The <code>MessageBroker</code> that manages this
- * <code>HTTPEndpoint</code>.
- */
- @Override protected void setupEndpointControl(MessageBroker broker)
- {
- controller = new HTTPEndpointControl(this, broker.getControl());
- controller.register();
- setControl(controller);
- }
-}
+/*
+ * 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.endpoints;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import flex.management.runtime.messaging.endpoints.HTTPEndpointControl;
+import flex.messaging.MessageBroker;
+import flex.messaging.endpoints.amf.AMFFilter;
+import flex.messaging.endpoints.amf.BatchProcessFilter;
+import flex.messaging.endpoints.amf.MessageBrokerFilter;
+import flex.messaging.endpoints.amf.SerializationFilter;
+import flex.messaging.endpoints.amf.SessionFilter;
+import flex.messaging.io.MessageIOConstants;
+import flex.messaging.log.LogCategories;
+import flex.messaging.messages.Message;
+import flex.messaging.security.SecurityException;
+
+/**
+ * This class replaces Flex 1.5's ProxyServlet by splitting
+ * the proxy's functionality into two pieces. Requests for proxied HTTP
+ * content can now be sent using a message type via any channel.
+ * The message broker directs requests to the appropriate service,
+ * in Flex 1.5 terms, the Proxy Service. The response from the proxy
+ * request is streamed back to the client.
+ *
+ */
+public class HTTPEndpoint extends BasePollingHTTPEndpoint
+{
+ public static final String LOG_CATEGORY = LogCategories.ENDPOINT_HTTP;
+
+ private static final int IMPROPER_CONTENT_TYPE = 10068;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>HTTPEndpoint</code>.
+ */
+ public HTTPEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>HTTPEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>HTTPEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public HTTPEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ /**
+ * Currently this override is a no-op to disable small messages over HTTP
+ * endpoints.
+ */
+ @Override public Message convertToSmallMessage(Message message)
+ {
+ return message;
+ }
+
+ /**
+ * Overrides to check the request content type is application/xml.
+ *
+ * @param req The servlet request.
+ * @param res The servlet response.
+ */
+ @Override public void service(HttpServletRequest req, HttpServletResponse res)
+ {
+ String contentType = req.getContentType();
+ boolean xmlContentType = contentType == null || contentType.equals(MessageIOConstants.XML_CONTENT_TYPE);
+ if (!xmlContentType)
+ {
+ // HTTP endpoint ''{0}'' must be contacted via a HTTP request with proper content type.
+ SecurityException se = new SecurityException();
+ se.setMessage(IMPROPER_CONTENT_TYPE, new Object[]{id});
+ throw se;
+ }
+
+ super.service(req, res);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected/Private Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Create default filter chain or return current one if already present.
+ */
+ @Override protected AMFFilter createFilterChain()
+ {
+ AMFFilter serializationFilter = new SerializationFilter(getLogCategory());
+ AMFFilter batchFilter = new BatchProcessFilter();
+ AMFFilter sessionFilter = sessionRewritingEnabled? new SessionFilter() : null;
+ AMFFilter messageBrokerFilter = new MessageBrokerFilter(this);
+
+ serializationFilter.setNext(batchFilter);
+ if (sessionFilter != null)
+ {
+ batchFilter.setNext(sessionFilter);
+ sessionFilter.setNext(messageBrokerFilter);
+ }
+ else
+ {
+ batchFilter.setNext(messageBrokerFilter);
+ }
+
+ return serializationFilter;
+ }
+
+ /**
+ * Returns MessageIOConstants.XML_CONTENT_TYPE.
+ */
+ @Override protected String getResponseContentType()
+ {
+ return MessageIOConstants.XML_CONTENT_TYPE;
+ }
+
+ /**
+ * Returns the log category of the endpoint.
+ *
+ * @return The log category of the endpoint.
+ */
+ @Override protected String getLogCategory()
+ {
+ return LOG_CATEGORY;
+ }
+
+ /**
+ * Returns the deserializer class name used by the endpoint.
+ *
+ * @return The deserializer class name used by the endpoint.
+ */
+ @Override protected String getDeserializerClassName()
+ {
+ return "flex.messaging.io.amfx.AmfxMessageDeserializer";
+ }
+
+ /**
+ * Returns the serializer class name used by the endpoint.
+ *
+ * @return The serializer class name used by the endpoint.
+ */
+ @Override protected String getSerializerClassName()
+ {
+ return "flex.messaging.io.amfx.AmfxMessageSerializer";
+ }
+
+ /**
+ * Invoked automatically to allow the <code>HTTPEndpoint</code> to setup its
+ * corresponding MBean control.
+ *
+ * @param broker The <code>MessageBroker</code> that manages this
+ * <code>HTTPEndpoint</code>.
+ */
+ @Override protected void setupEndpointControl(MessageBroker broker)
+ {
+ controller = new HTTPEndpointControl(this, broker.getControl());
+ controller.register();
+ setControl(controller);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/SecureAMFEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/SecureAMFEndpoint.java b/modules/core/src/flex/messaging/endpoints/SecureAMFEndpoint.java
old mode 100755
new mode 100644
index 3a22ac8..7b3a44f
--- a/modules/core/src/flex/messaging/endpoints/SecureAMFEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/SecureAMFEndpoint.java
@@ -1,64 +1,64 @@
-/*
- * 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.endpoints;
-
-/**
- * Secure version of AMFEndpoint.
- */
-public class SecureAMFEndpoint extends AMFEndpoint
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>SecureAMFEndpoint</code>.
- */
- public SecureAMFEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>SecureAMFEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>SecureAMFEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public SecureAMFEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Determines whether the endpoint is secure.
- *
- * @return <code>true</code> if the endpoint is secure, <code>false</code> otherwise.
- */
- public boolean isSecure()
- {
- return true;
- }
-}
+/*
+ * 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.endpoints;
+
+/**
+ * Secure version of AMFEndpoint.
+ */
+public class SecureAMFEndpoint extends AMFEndpoint
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>SecureAMFEndpoint</code>.
+ */
+ public SecureAMFEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>SecureAMFEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>SecureAMFEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public SecureAMFEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Determines whether the endpoint is secure.
+ *
+ * @return <code>true</code> if the endpoint is secure, <code>false</code> otherwise.
+ */
+ public boolean isSecure()
+ {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/SecureHTTPEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/SecureHTTPEndpoint.java b/modules/core/src/flex/messaging/endpoints/SecureHTTPEndpoint.java
old mode 100755
new mode 100644
index 04aaa22..1f08a63
--- a/modules/core/src/flex/messaging/endpoints/SecureHTTPEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/SecureHTTPEndpoint.java
@@ -1,64 +1,64 @@
-/*
- * 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.endpoints;
-
-/**
- * Secure version of HTTPEndpoint.
- */
-public class SecureHTTPEndpoint extends HTTPEndpoint
-{
- //--------------------------------------------------------------------------
- //
- // Constructors
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>SecureHTTPEndpoint</code>.
- */
- public SecureHTTPEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>SecureHTTPEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>SecureHTTPEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public SecureHTTPEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Determines whether the endpoint is secure.
- *
- * @return <code>true</code> if the endpoint is secure, <code>false</code> otherwise.
- */
- public boolean isSecure()
- {
- return true;
- }
-}
+/*
+ * 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.endpoints;
+
+/**
+ * Secure version of HTTPEndpoint.
+ */
+public class SecureHTTPEndpoint extends HTTPEndpoint
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructors
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>SecureHTTPEndpoint</code>.
+ */
+ public SecureHTTPEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>SecureHTTPEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>SecureHTTPEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public SecureHTTPEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Determines whether the endpoint is secure.
+ *
+ * @return <code>true</code> if the endpoint is secure, <code>false</code> otherwise.
+ */
+ public boolean isSecure()
+ {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/SecureStreamingAMFEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/SecureStreamingAMFEndpoint.java b/modules/core/src/flex/messaging/endpoints/SecureStreamingAMFEndpoint.java
old mode 100755
new mode 100644
index a60e29c..dd38d97
--- a/modules/core/src/flex/messaging/endpoints/SecureStreamingAMFEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/SecureStreamingAMFEndpoint.java
@@ -1,64 +1,64 @@
-/*
- * 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.endpoints;
-
-/**
- * Secure version of StreamingAMFEndpoint.
- */
-public class SecureStreamingAMFEndpoint extends StreamingAMFEndpoint
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>SecureStreamingAMFEndpoint</code>.
- */
- public SecureStreamingAMFEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>SecureStreamingAMFEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>SecureStreamingAMFEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public SecureStreamingAMFEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Determines whether the endpoint is secure.
- *
- * @return <code>true</code> if the endpoint is secure, <code>false</code> otherwise.
- */
- public boolean isSecure()
- {
- return true;
- }
-}
+/*
+ * 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.endpoints;
+
+/**
+ * Secure version of StreamingAMFEndpoint.
+ */
+public class SecureStreamingAMFEndpoint extends StreamingAMFEndpoint
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>SecureStreamingAMFEndpoint</code>.
+ */
+ public SecureStreamingAMFEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>SecureStreamingAMFEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>SecureStreamingAMFEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public SecureStreamingAMFEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Determines whether the endpoint is secure.
+ *
+ * @return <code>true</code> if the endpoint is secure, <code>false</code> otherwise.
+ */
+ public boolean isSecure()
+ {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/SecureStreamingHTTPEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/SecureStreamingHTTPEndpoint.java b/modules/core/src/flex/messaging/endpoints/SecureStreamingHTTPEndpoint.java
old mode 100755
new mode 100644
index 957f22d..d053a4d
--- a/modules/core/src/flex/messaging/endpoints/SecureStreamingHTTPEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/SecureStreamingHTTPEndpoint.java
@@ -1,64 +1,64 @@
-/*
- * 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.endpoints;
-
-/**
- * Secure version of StreamingHTTPEndpoint.
- */
-public class SecureStreamingHTTPEndpoint extends StreamingHTTPEndpoint
-{
- //--------------------------------------------------------------------------
- //
- // Constructors
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>SecureStreamingHTTPEndpoint</code>.
- */
- public SecureStreamingHTTPEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>SecureStreamingHTTPEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>SecureHTTPEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public SecureStreamingHTTPEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Determines whether the endpoint is secure.
- *
- * @return <code>true</code> if the endpoint is secure, <code>false</code> otherwise.
- */
- public boolean isSecure()
- {
- return true;
- }
-}
+/*
+ * 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.endpoints;
+
+/**
+ * Secure version of StreamingHTTPEndpoint.
+ */
+public class SecureStreamingHTTPEndpoint extends StreamingHTTPEndpoint
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructors
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>SecureStreamingHTTPEndpoint</code>.
+ */
+ public SecureStreamingHTTPEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>SecureStreamingHTTPEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>SecureHTTPEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public SecureStreamingHTTPEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Determines whether the endpoint is secure.
+ *
+ * @return <code>true</code> if the endpoint is secure, <code>false</code> otherwise.
+ */
+ public boolean isSecure()
+ {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/StreamingAMFEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/StreamingAMFEndpoint.java b/modules/core/src/flex/messaging/endpoints/StreamingAMFEndpoint.java
old mode 100755
new mode 100644
index c9411e0..7c5e02a
--- a/modules/core/src/flex/messaging/endpoints/StreamingAMFEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/StreamingAMFEndpoint.java
@@ -1,247 +1,247 @@
-/*
- * 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.endpoints;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-
-import flex.management.runtime.messaging.endpoints.StreamingAMFEndpointControl;
-import flex.messaging.MessageBroker;
-import flex.messaging.endpoints.amf.AMFFilter;
-import flex.messaging.endpoints.amf.BatchProcessFilter;
-import flex.messaging.endpoints.amf.LegacyFilter;
-import flex.messaging.endpoints.amf.MessageBrokerFilter;
-import flex.messaging.endpoints.amf.SerializationFilter;
-import flex.messaging.endpoints.amf.SessionFilter;
-import flex.messaging.io.MessageIOConstants;
-import flex.messaging.io.TypeMarshallingContext;
-import flex.messaging.io.amf.Amf3Output;
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.messages.Message;
-
-/**
- * Extension to the AMFEndpoint to support streaming HTTP connections to connected
- * clients.
- * Each streaming connection managed by this endpoint consumes one of the request
- * handler threads provided by the servlet container, so it is not highly scalable
- * but offers performance advantages over client polling for clients receiving a steady,
- * rapid stream of pushed messages.
- * This endpoint does not support polling clients and will fault any poll requests
- * that are received. To support polling clients use AMFEndpoint instead.
- */
-public class StreamingAMFEndpoint extends BaseStreamingHTTPEndpoint
-{
- //--------------------------------------------------------------------------
- //
- // Public Static Constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * The log category for this endpoint.
- */
- public static final String LOG_CATEGORY = LogCategories.ENDPOINT_STREAMING_AMF;
-
- //--------------------------------------------------------------------------
- //
- // Private Static Constants
- //
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- //
- // Constructors
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>StreamingAMFEndpoint</code>.
- */
- public StreamingAMFEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>StreamingAMFEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>StreamingAMFEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public StreamingAMFEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Create the gateway filters that transform action requests
- * and responses.
- */
- @Override protected AMFFilter createFilterChain()
- {
- AMFFilter serializationFilter = new SerializationFilter(getLogCategory());
- AMFFilter batchFilter = new BatchProcessFilter();
- AMFFilter sessionFilter = sessionRewritingEnabled? new SessionFilter() : null;
- AMFFilter envelopeFilter = new LegacyFilter(this);
- AMFFilter messageBrokerFilter = new MessageBrokerFilter(this);
-
- serializationFilter.setNext(batchFilter);
- if (sessionFilter != null)
- {
- batchFilter.setNext(sessionFilter);
- sessionFilter.setNext(envelopeFilter);
- }
- else
- {
- batchFilter.setNext(envelopeFilter);
- }
- envelopeFilter.setNext(messageBrokerFilter);
-
- return serializationFilter;
- }
-
- /**
- * Returns MessageIOConstants.AMF_CONTENT_TYPE.
- */
- @Override protected String getResponseContentType()
- {
- return MessageIOConstants.AMF_CONTENT_TYPE;
- }
-
- /**
- * Returns the log category of the endpoint.
- *
- * @return The log category of the endpoint.
- */
- @Override protected String getLogCategory()
- {
- return LOG_CATEGORY;
- }
-
- /**
- * Used internally for performance information gathering; not intended for
- * public use. Serializes the message in AMF format and returns the size of
- * the serialized message.
- *
- * @param message Message to get the size for.
- *
- * @return The size of the message after message is serialized.
- */
- @Override protected long getMessageSizeForPerformanceInfo(Message message)
- {
- Amf3Output amfOut = new Amf3Output(serializationContext);
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- DataOutputStream dataOutStream = new DataOutputStream(outStream);
- amfOut.setOutputStream(dataOutStream);
- try
- {
- amfOut.writeObject(message);
- }
- catch (IOException e)
- {
- if (Log.isDebug())
- log.debug("MPI exception while retrieving the size of the serialized message: " + e.toString());
- }
- return dataOutStream.size();
- }
-
- /**
- * Returns the deserializer class name used by the endpoint.
- *
- * @return The deserializer class name used by the endpoint.
- */
- @Override protected String getDeserializerClassName()
- {
- return "flex.messaging.io.amf.AmfMessageDeserializer";
- }
-
- /**
- * Returns the serializer class name used by the endpoint.
- *
- * @return The serializer class name used by the endpoint.
- */
- @Override protected String getSerializerClassName()
- {
- return "flex.messaging.io.amf.AmfMessageSerializer";
- }
-
- /**
- * Invoked automatically to allow the <code>StreamingAMFEndpoint</code> to setup its
- * corresponding MBean control.
- *
- * @param broker The <code>MessageBroker</code> that manages this
- * <code>StreamingAMFEndpoint</code>.
- */
- @Override protected void setupEndpointControl(MessageBroker broker)
- {
- controller = new StreamingAMFEndpointControl(this, broker.getControl());
- controller.register();
- setControl(controller);
- }
-
- /**
- * Helper method invoked by the endpoint request handler thread cycling in wait-notify.
- * Serializes messages and streams each to the client as a response chunk using streamChunk().
- *
- * @param messages The messages to serialize and push to the client.
- * @param os The output stream the chunk will be written to.
- * @param response The HttpServletResponse, used to flush the chunk to the client.
- */
- @Override protected void streamMessages(List messages, ServletOutputStream os, HttpServletResponse response) throws IOException
- {
- if (messages == null || messages.isEmpty())
- return;
-
- // Serialize each message as a separate chunk of bytes.
- TypeMarshallingContext.setTypeMarshaller(getTypeMarshaller());
- for (Iterator iter = messages.iterator(); iter.hasNext();)
- {
- Message message = (Message)iter.next();
- addPerformanceInfo(message);
- message = convertPushMessageToSmall(message);
- if (Log.isDebug())
- log.debug("Endpoint with id '" + getId() + "' is streaming message: " + message);
-
- Amf3Output amfOut = new Amf3Output(serializationContext);
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- DataOutputStream dataOutStream = new DataOutputStream(outStream);
- amfOut.setOutputStream(dataOutStream);
-
- amfOut.writeObject(message);
- dataOutStream.flush();
- byte[] messageBytes = outStream.toByteArray();
- streamChunk(messageBytes, os, response);
-
- if (isManaged())
- ((StreamingAMFEndpointControl)controller).incrementPushCount();
- }
- TypeMarshallingContext.setTypeMarshaller(null);
- }
+/*
+ * 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.endpoints;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import flex.management.runtime.messaging.endpoints.StreamingAMFEndpointControl;
+import flex.messaging.MessageBroker;
+import flex.messaging.endpoints.amf.AMFFilter;
+import flex.messaging.endpoints.amf.BatchProcessFilter;
+import flex.messaging.endpoints.amf.LegacyFilter;
+import flex.messaging.endpoints.amf.MessageBrokerFilter;
+import flex.messaging.endpoints.amf.SerializationFilter;
+import flex.messaging.endpoints.amf.SessionFilter;
+import flex.messaging.io.MessageIOConstants;
+import flex.messaging.io.TypeMarshallingContext;
+import flex.messaging.io.amf.Amf3Output;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.messages.Message;
+
+/**
+ * Extension to the AMFEndpoint to support streaming HTTP connections to connected
+ * clients.
+ * Each streaming connection managed by this endpoint consumes one of the request
+ * handler threads provided by the servlet container, so it is not highly scalable
+ * but offers performance advantages over client polling for clients receiving a steady,
+ * rapid stream of pushed messages.
+ * This endpoint does not support polling clients and will fault any poll requests
+ * that are received. To support polling clients use AMFEndpoint instead.
+ */
+public class StreamingAMFEndpoint extends BaseStreamingHTTPEndpoint
+{
+ //--------------------------------------------------------------------------
+ //
+ // Public Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The log category for this endpoint.
+ */
+ public static final String LOG_CATEGORY = LogCategories.ENDPOINT_STREAMING_AMF;
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructors
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>StreamingAMFEndpoint</code>.
+ */
+ public StreamingAMFEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>StreamingAMFEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>StreamingAMFEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public StreamingAMFEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Create the gateway filters that transform action requests
+ * and responses.
+ */
+ @Override protected AMFFilter createFilterChain()
+ {
+ AMFFilter serializationFilter = new SerializationFilter(getLogCategory());
+ AMFFilter batchFilter = new BatchProcessFilter();
+ AMFFilter sessionFilter = sessionRewritingEnabled? new SessionFilter() : null;
+ AMFFilter envelopeFilter = new LegacyFilter(this);
+ AMFFilter messageBrokerFilter = new MessageBrokerFilter(this);
+
+ serializationFilter.setNext(batchFilter);
+ if (sessionFilter != null)
+ {
+ batchFilter.setNext(sessionFilter);
+ sessionFilter.setNext(envelopeFilter);
+ }
+ else
+ {
+ batchFilter.setNext(envelopeFilter);
+ }
+ envelopeFilter.setNext(messageBrokerFilter);
+
+ return serializationFilter;
+ }
+
+ /**
+ * Returns MessageIOConstants.AMF_CONTENT_TYPE.
+ */
+ @Override protected String getResponseContentType()
+ {
+ return MessageIOConstants.AMF_CONTENT_TYPE;
+ }
+
+ /**
+ * Returns the log category of the endpoint.
+ *
+ * @return The log category of the endpoint.
+ */
+ @Override protected String getLogCategory()
+ {
+ return LOG_CATEGORY;
+ }
+
+ /**
+ * Used internally for performance information gathering; not intended for
+ * public use. Serializes the message in AMF format and returns the size of
+ * the serialized message.
+ *
+ * @param message Message to get the size for.
+ *
+ * @return The size of the message after message is serialized.
+ */
+ @Override protected long getMessageSizeForPerformanceInfo(Message message)
+ {
+ Amf3Output amfOut = new Amf3Output(serializationContext);
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ DataOutputStream dataOutStream = new DataOutputStream(outStream);
+ amfOut.setOutputStream(dataOutStream);
+ try
+ {
+ amfOut.writeObject(message);
+ }
+ catch (IOException e)
+ {
+ if (Log.isDebug())
+ log.debug("MPI exception while retrieving the size of the serialized message: " + e.toString());
+ }
+ return dataOutStream.size();
+ }
+
+ /**
+ * Returns the deserializer class name used by the endpoint.
+ *
+ * @return The deserializer class name used by the endpoint.
+ */
+ @Override protected String getDeserializerClassName()
+ {
+ return "flex.messaging.io.amf.AmfMessageDeserializer";
+ }
+
+ /**
+ * Returns the serializer class name used by the endpoint.
+ *
+ * @return The serializer class name used by the endpoint.
+ */
+ @Override protected String getSerializerClassName()
+ {
+ return "flex.messaging.io.amf.AmfMessageSerializer";
+ }
+
+ /**
+ * Invoked automatically to allow the <code>StreamingAMFEndpoint</code> to setup its
+ * corresponding MBean control.
+ *
+ * @param broker The <code>MessageBroker</code> that manages this
+ * <code>StreamingAMFEndpoint</code>.
+ */
+ @Override protected void setupEndpointControl(MessageBroker broker)
+ {
+ controller = new StreamingAMFEndpointControl(this, broker.getControl());
+ controller.register();
+ setControl(controller);
+ }
+
+ /**
+ * Helper method invoked by the endpoint request handler thread cycling in wait-notify.
+ * Serializes messages and streams each to the client as a response chunk using streamChunk().
+ *
+ * @param messages The messages to serialize and push to the client.
+ * @param os The output stream the chunk will be written to.
+ * @param response The HttpServletResponse, used to flush the chunk to the client.
+ */
+ @Override protected void streamMessages(List messages, ServletOutputStream os, HttpServletResponse response) throws IOException
+ {
+ if (messages == null || messages.isEmpty())
+ return;
+
+ // Serialize each message as a separate chunk of bytes.
+ TypeMarshallingContext.setTypeMarshaller(getTypeMarshaller());
+ for (Iterator iter = messages.iterator(); iter.hasNext();)
+ {
+ Message message = (Message)iter.next();
+ addPerformanceInfo(message);
+ message = convertPushMessageToSmall(message);
+ if (Log.isDebug())
+ log.debug("Endpoint with id '" + getId() + "' is streaming message: " + message);
+
+ Amf3Output amfOut = new Amf3Output(serializationContext);
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ DataOutputStream dataOutStream = new DataOutputStream(outStream);
+ amfOut.setOutputStream(dataOutStream);
+
+ amfOut.writeObject(message);
+ dataOutStream.flush();
+ byte[] messageBytes = outStream.toByteArray();
+ streamChunk(messageBytes, os, response);
+
+ if (isManaged())
+ ((StreamingAMFEndpointControl)controller).incrementPushCount();
+ }
+ TypeMarshallingContext.setTypeMarshaller(null);
+ }
}
\ No newline at end of file
[05/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/amf/SerializationFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/amf/SerializationFilter.java b/modules/core/src/flex/messaging/endpoints/amf/SerializationFilter.java
old mode 100755
new mode 100644
index 77c5838..c15ab89
--- a/modules/core/src/flex/messaging/endpoints/amf/SerializationFilter.java
+++ b/modules/core/src/flex/messaging/endpoints/amf/SerializationFilter.java
@@ -1,480 +1,480 @@
-/*
- * 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.endpoints.amf;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-
-import javax.servlet.http.HttpServletRequest;
-
-import flex.messaging.FlexContext;
-import flex.messaging.MessageException;
-import flex.messaging.io.MessageDeserializer;
-import flex.messaging.io.MessageIOConstants;
-import flex.messaging.io.MessageSerializer;
-import flex.messaging.io.SerializationContext;
-import flex.messaging.io.SerializationException;
-import flex.messaging.io.amf.ASObject;
-import flex.messaging.io.amf.ActionContext;
-import flex.messaging.io.amf.ActionMessage;
-import flex.messaging.io.amf.AmfTrace;
-import flex.messaging.io.amf.MessageBody;
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.log.Logger;
-import flex.messaging.messages.ErrorMessage;
-import flex.messaging.messages.Message;
-import flex.messaging.messages.MessagePerformanceInfo;
-import flex.messaging.util.ExceptionUtil;
-import flex.messaging.util.StringUtils;
-
-
-/**
- * Filter for serializing and deserializing action messages.
- */
-public class SerializationFilter extends AMFFilter
-{
- //--------------------------------------------------------------------------
- //
- // Private Static Constants
- //
- //--------------------------------------------------------------------------
-
- private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
-
- // Error codes.
- private static final int UNHANDLED_ERROR = 10306;
- private static final int REQUEST_ERROR = 10307;
- private static final int RESPONSE_ERROR = 10308;
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs a <tt>SerializationFilter</tt>.
- *
- * @param logCategory Log category to use in logging. If <code>null</code>, the default values is <code>Endpoint.General</code>.
- */
- public SerializationFilter(String logCategory)
- {
- if (logCategory == null)
- logCategory = LogCategories.ENDPOINT_GENERAL;
- logger = Log.getLogger(logCategory);
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Used to log serialization/deserialization messages.
- */
- private Logger logger;
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- @Override
- public void invoke(final ActionContext context) throws IOException
- {
- boolean success = false;
-
- // Additional AMF packet tracing is enabled only at the debug logging level
- // and only if there's a target listening for it.
- AmfTrace debugTrace = Log.isDebug() && logger.hasTarget()? new AmfTrace() : null;
-
- // Create an empty ActionMessage object to hold our response
- context.setResponseMessage(new ActionMessage());
- SerializationContext sc = SerializationContext.getSerializationContext();
-
- try
- {
- // Deserialize the input stream into an "ActionMessage" object.
- MessageDeserializer deserializer = sc.newMessageDeserializer();
-
- // Set up the deserialization context
- HttpServletRequest req = FlexContext.getHttpRequest();
- InputStream in = req.getInputStream();
-
- // Determine whether the request is coming from a Javascript client.
- // If so, convert stream from UTF-8 to raw hex before AMF deserialization.
- String contentType = req.getContentType();
- boolean jsClient = (contentType != null && contentType.startsWith(MessageIOConstants.CONTENT_TYPE_PLAIN));
- if (jsClient)
- {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- BufferedReader reader = new BufferedReader(new InputStreamReader(in, UTF8_CHARSET));
- int currentByte = -1;
- while ((currentByte = reader.read()) != -1)
- {
- if (currentByte == 256)
- currentByte = 0;
- outputStream.write(currentByte);
- }
-
- if (outputStream.size() > 0)
- in = new ByteArrayInputStream(outputStream.toByteArray());
- }
-
- deserializer.initialize(sc, in, debugTrace);
-
- // record the length of the input stream for performance metrics
- int reqLen = FlexContext.getHttpRequest().getContentLength();
- context.setDeserializedBytes(reqLen);
-
- // set up the incoming MPI info if it is enabled
- if(context.isMPIenabled())
- {
- MessagePerformanceInfo mpi = new MessagePerformanceInfo();
- mpi.recordMessageSizes = context.isRecordMessageSizes();
- mpi.recordMessageTimes = context.isRecordMessageTimes();
- if(context.isRecordMessageTimes())
- mpi.receiveTime = System.currentTimeMillis();
- if(context.isRecordMessageSizes())
- mpi.messageSize =reqLen;
-
- context.setMPII(mpi);
- }
-
- ActionMessage m = new ActionMessage();
- context.setRequestMessage(m);
- deserializer.readMessage(m, context);
- success = true;
- }
- catch (Throwable t)
- {
- handleDeserializationException(context, t, logger);
- }
- finally
- {
- // Use the same ActionMessage version for the response
- ActionMessage respMsg = context.getResponseMessage();
- respMsg.setVersion(context.getVersion());
-
- if (debugTrace != null)
- logger.debug(debugTrace.toString());
- }
-
- try
- {
- if (success)
- {
- next.invoke(context);
- }
- }
- catch (Throwable t)
- {
- unhandledError(context, t);
- }
- finally
- {
- // serialize output
- if (context.getStatus() != MessageIOConstants.STATUS_NOTAMF)
- {
- ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
- ActionMessage respMesg = context.getResponseMessage();
-
- // Additional AMF packet tracing is enabled only at the debug logging level
- // and only if there's a target listening for it.
- debugTrace = Log.isDebug() && logger.hasTarget()? new AmfTrace() : null;
-
- try
- {
- // overhead calculation is only necessary when MPI is enabled
- long serializationOverhead=0;
- if(context.isRecordMessageTimes())
- {
- // set server send time
- context.getMPIO().sendTime = System.currentTimeMillis();
- if(context.isRecordMessageSizes())
- serializationOverhead = System.currentTimeMillis();
- }
- MessageSerializer serializer = sc.newMessageSerializer();
- serializer.initialize(sc, outBuffer, debugTrace);
- serializer.writeMessage(respMesg);
-
- // keep track of serializes bytes for performance metrics
- context.setSerializedBytes(outBuffer.size());
-
- // serialized message again after adding info if mpio with sizing is enabled
- if(context.isRecordMessageSizes())
- {
- try
- {
- context.getMPIO().messageSize = outBuffer.size();
-
- // reset server send time
- if(context.isRecordMessageTimes())
- {
- serializationOverhead = System.currentTimeMillis() - serializationOverhead;
- context.getMPIO().addToOverhead(serializationOverhead);
- context.getMPIO().sendTime = System.currentTimeMillis();
- }
-
- // reserialize the message now that info has been added
- outBuffer = new ByteArrayOutputStream();
- respMesg = context.getResponseMessage();
- serializer.initialize(sc, outBuffer, debugTrace);
- serializer.writeMessage(respMesg);
- }
- catch(Exception e)
- {
- if (Log.isDebug())
- logger.debug("MPI set up error: " + e.toString());
- }
- }
- context.setResponseOutput(outBuffer);
- }
- catch (Exception e)
- {
- handleSerializationException(sc, context, e, logger);
- }
- finally
- {
- if (debugTrace != null)
- logger.debug(debugTrace.toString());
- }
- }
- }
- }
-
- /**
- * This static method provides a common way for deserialization errors to be
- * handled. It attempts to provide the client with useful information about
- * deserialization failure.
- *
- * @param actionContext The action context.
- * @param t The throwable that needs to be handled.
- * @param logger The logger to which to log messages.
- * @throws IOException
- */
- public static void handleDeserializationException(ActionContext actionContext, Throwable t, Logger logger) throws IOException
- {
- if (t instanceof EOFException)
- {
- actionContext.setStatus(MessageIOConstants.STATUS_NOTAMF);
- }
- else if (t instanceof IOException)
- {
- if (Log.isDebug())
- logger.debug("IOException reading message - client closed socket before sending the message?");
-
- throw (IOException)t;
- }
- else
- {
- actionContext.setStatus(MessageIOConstants.STATUS_ERR);
-
- // Create a single message body to hold the error
- MessageBody responseBody = new MessageBody();
- if (actionContext.getMessageNumber() < actionContext.getRequestMessage().getBodyCount())
- responseBody.setTargetURI(actionContext.getRequestMessageBody().getResponseURI());
-
- // If the message couldn't be deserialized enough to know the version, set the current version here
- if (actionContext.getVersion() == 0)
- actionContext.setVersion(ActionMessage.CURRENT_VERSION);
-
- // append the response body to the output message
- actionContext.getResponseMessage().addBody(responseBody);
-
- String message;
- MessageException methodResult;
- if (t instanceof MessageException)
- {
- methodResult = (MessageException)t;
- message = methodResult.getMessage();
- }
- else
- {
- //Error deserializing client message.
- methodResult = new SerializationException();
- methodResult.setMessage(REQUEST_ERROR);
- methodResult.setRootCause(t);
- message = methodResult.getMessage();
- }
- responseBody.setData(methodResult.createErrorMessage());
- responseBody.setReplyMethod(MessageIOConstants.STATUS_METHOD);
-
- if (Log.isError())
- logger.error(message + StringUtils.NEWLINE + ExceptionUtil.toString(t));
- }
-
- }
-
- /**
- * This static method provides a common way for serialization errors to be
- * handled. It attempts to provide the client with useful information about
- * the serialization failure. When there is a serialization failure, there is
- * no way to tell which response failed serialization, so it adds a new response
- * with the serialization failure for each of the corresponding requests.
- *
- * @param serializer The serializer that generated the error.
- * @param serializationContext The serialization context.
- * @param actionContext The action context.
- * @param t The throwable that needs to be handled.
- * @param logger The logger to which to log error messages.
- */
- public static void handleSerializationException(SerializationContext serializationContext,
- ActionContext actionContext, Throwable t, Logger logger)
- {
- ActionMessage responseMessage = new ActionMessage();
- actionContext.setResponseMessage(responseMessage);
-
- int bodyCount = actionContext.getRequestMessage().getBodyCount();
- for (actionContext.setMessageNumber(0); actionContext.getMessageNumber() < bodyCount; actionContext.incrementMessageNumber())
- {
- MessageBody responseBody = new MessageBody();
- responseBody.setTargetURI(actionContext.getRequestMessageBody().getResponseURI());
- actionContext.getResponseMessage().addBody(responseBody);
-
- Object methodResult;
-
- if (t instanceof MessageException)
- {
- methodResult = ((MessageException)t).createErrorMessage();
- }
- else
- {
- String message = "An error occurred while serializing server response(s).";
- if (t.getMessage() != null)
- {
- message = t.getMessage();
- if (message == null)
- message = t.toString();
- }
-
- methodResult = new MessageException(message, t).createErrorMessage();
- }
-
- if (actionContext.isLegacy())
- {
- if (methodResult instanceof ErrorMessage)
- {
- ErrorMessage error = (ErrorMessage)methodResult;
- ASObject aso = new ASObject();
- aso.put("message", error.faultString);
- aso.put("code", error.faultCode);
- aso.put("details", error.faultDetail);
- aso.put("rootCause", error.rootCause);
- methodResult = aso;
- }
- else if (methodResult instanceof Message)
- {
- methodResult = ((Message)methodResult).getBody();
- }
- }
- else
- {
- try
- {
- Message inMessage = actionContext.getRequestMessageBody().getDataAsMessage();
- if (inMessage.getClientId() != null)
- ((ErrorMessage)methodResult).setClientId(inMessage.getClientId().toString());
-
- if (inMessage.getMessageId() != null)
- {
- ((ErrorMessage)methodResult).setCorrelationId(inMessage.getMessageId());
- ((ErrorMessage)methodResult).setDestination(inMessage.getDestination());
- }
- }
- catch (MessageException ignore){}
- }
-
- responseBody.setData(methodResult);
- responseBody.setReplyMethod(MessageIOConstants.STATUS_METHOD);
- }
-
- if (Log.isError() && logger != null)
- logger.error("Exception occurred during serialization: " + ExceptionUtil.toString(t));
-
- // Serialize the error messages
- ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
- AmfTrace debugTrace = Log.isDebug() && logger.hasTarget()? new AmfTrace() : null;
- MessageSerializer serializer = serializationContext.newMessageSerializer();
- serializer.initialize(serializationContext, outBuffer, debugTrace);
-
- try
- {
- serializer.writeMessage(actionContext.getResponseMessage());
- actionContext.setResponseOutput(outBuffer);
- }
- catch (IOException e)
- {
- //Error serializing response
- MessageException ex = new MessageException();
- ex.setMessage(RESPONSE_ERROR);
- ex.setRootCause(e);
- throw ex;
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * An unhandled error happened somewhere between the SerializationFilter and the
- * ErrorFilter... we ignore all request bodies and attempt to send back a single response
- * body to the client. It will not make it back to a custom responder, but the NetConnection
- * Debugger will show the event.
- */
- private void unhandledError(ActionContext context, Throwable t)
- {
- ActionMessage responseMessage = new ActionMessage();
- context.setResponseMessage(responseMessage);
-
- MessageBody responseBody = new MessageBody();
- responseBody.setTargetURI(context.getRequestMessageBody().getResponseURI());
-
- context.getResponseMessage().addBody(responseBody);
-
- MessageException methodResult;
-
- if (t instanceof MessageException)
- {
- methodResult = (MessageException)t;
- }
- else
- {
- // An unhandled error occurred while processing client request(s).
- methodResult = new SerializationException();
- methodResult.setMessage(UNHANDLED_ERROR);
- methodResult.setRootCause(t);
- }
-
- responseBody.setData(methodResult);
- responseBody.setReplyMethod(MessageIOConstants.STATUS_METHOD);
-
- logger.info(t.getMessage());
- }
-}
+/*
+ * 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.endpoints.amf;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+
+import javax.servlet.http.HttpServletRequest;
+
+import flex.messaging.FlexContext;
+import flex.messaging.MessageException;
+import flex.messaging.io.MessageDeserializer;
+import flex.messaging.io.MessageIOConstants;
+import flex.messaging.io.MessageSerializer;
+import flex.messaging.io.SerializationContext;
+import flex.messaging.io.SerializationException;
+import flex.messaging.io.amf.ASObject;
+import flex.messaging.io.amf.ActionContext;
+import flex.messaging.io.amf.ActionMessage;
+import flex.messaging.io.amf.AmfTrace;
+import flex.messaging.io.amf.MessageBody;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.log.Logger;
+import flex.messaging.messages.ErrorMessage;
+import flex.messaging.messages.Message;
+import flex.messaging.messages.MessagePerformanceInfo;
+import flex.messaging.util.ExceptionUtil;
+import flex.messaging.util.StringUtils;
+
+
+/**
+ * Filter for serializing and deserializing action messages.
+ */
+public class SerializationFilter extends AMFFilter
+{
+ //--------------------------------------------------------------------------
+ //
+ // Private Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
+
+ // Error codes.
+ private static final int UNHANDLED_ERROR = 10306;
+ private static final int REQUEST_ERROR = 10307;
+ private static final int RESPONSE_ERROR = 10308;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs a <tt>SerializationFilter</tt>.
+ *
+ * @param logCategory Log category to use in logging. If <code>null</code>, the default values is <code>Endpoint.General</code>.
+ */
+ public SerializationFilter(String logCategory)
+ {
+ if (logCategory == null)
+ logCategory = LogCategories.ENDPOINT_GENERAL;
+ logger = Log.getLogger(logCategory);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Used to log serialization/deserialization messages.
+ */
+ private Logger logger;
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ @Override
+ public void invoke(final ActionContext context) throws IOException
+ {
+ boolean success = false;
+
+ // Additional AMF packet tracing is enabled only at the debug logging level
+ // and only if there's a target listening for it.
+ AmfTrace debugTrace = Log.isDebug() && logger.hasTarget()? new AmfTrace() : null;
+
+ // Create an empty ActionMessage object to hold our response
+ context.setResponseMessage(new ActionMessage());
+ SerializationContext sc = SerializationContext.getSerializationContext();
+
+ try
+ {
+ // Deserialize the input stream into an "ActionMessage" object.
+ MessageDeserializer deserializer = sc.newMessageDeserializer();
+
+ // Set up the deserialization context
+ HttpServletRequest req = FlexContext.getHttpRequest();
+ InputStream in = req.getInputStream();
+
+ // Determine whether the request is coming from a Javascript client.
+ // If so, convert stream from UTF-8 to raw hex before AMF deserialization.
+ String contentType = req.getContentType();
+ boolean jsClient = (contentType != null && contentType.startsWith(MessageIOConstants.CONTENT_TYPE_PLAIN));
+ if (jsClient)
+ {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in, UTF8_CHARSET));
+ int currentByte = -1;
+ while ((currentByte = reader.read()) != -1)
+ {
+ if (currentByte == 256)
+ currentByte = 0;
+ outputStream.write(currentByte);
+ }
+
+ if (outputStream.size() > 0)
+ in = new ByteArrayInputStream(outputStream.toByteArray());
+ }
+
+ deserializer.initialize(sc, in, debugTrace);
+
+ // record the length of the input stream for performance metrics
+ int reqLen = FlexContext.getHttpRequest().getContentLength();
+ context.setDeserializedBytes(reqLen);
+
+ // set up the incoming MPI info if it is enabled
+ if(context.isMPIenabled())
+ {
+ MessagePerformanceInfo mpi = new MessagePerformanceInfo();
+ mpi.recordMessageSizes = context.isRecordMessageSizes();
+ mpi.recordMessageTimes = context.isRecordMessageTimes();
+ if(context.isRecordMessageTimes())
+ mpi.receiveTime = System.currentTimeMillis();
+ if(context.isRecordMessageSizes())
+ mpi.messageSize =reqLen;
+
+ context.setMPII(mpi);
+ }
+
+ ActionMessage m = new ActionMessage();
+ context.setRequestMessage(m);
+ deserializer.readMessage(m, context);
+ success = true;
+ }
+ catch (Throwable t)
+ {
+ handleDeserializationException(context, t, logger);
+ }
+ finally
+ {
+ // Use the same ActionMessage version for the response
+ ActionMessage respMsg = context.getResponseMessage();
+ respMsg.setVersion(context.getVersion());
+
+ if (debugTrace != null)
+ logger.debug(debugTrace.toString());
+ }
+
+ try
+ {
+ if (success)
+ {
+ next.invoke(context);
+ }
+ }
+ catch (Throwable t)
+ {
+ unhandledError(context, t);
+ }
+ finally
+ {
+ // serialize output
+ if (context.getStatus() != MessageIOConstants.STATUS_NOTAMF)
+ {
+ ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
+ ActionMessage respMesg = context.getResponseMessage();
+
+ // Additional AMF packet tracing is enabled only at the debug logging level
+ // and only if there's a target listening for it.
+ debugTrace = Log.isDebug() && logger.hasTarget()? new AmfTrace() : null;
+
+ try
+ {
+ // overhead calculation is only necessary when MPI is enabled
+ long serializationOverhead=0;
+ if(context.isRecordMessageTimes())
+ {
+ // set server send time
+ context.getMPIO().sendTime = System.currentTimeMillis();
+ if(context.isRecordMessageSizes())
+ serializationOverhead = System.currentTimeMillis();
+ }
+ MessageSerializer serializer = sc.newMessageSerializer();
+ serializer.initialize(sc, outBuffer, debugTrace);
+ serializer.writeMessage(respMesg);
+
+ // keep track of serializes bytes for performance metrics
+ context.setSerializedBytes(outBuffer.size());
+
+ // serialized message again after adding info if mpio with sizing is enabled
+ if(context.isRecordMessageSizes())
+ {
+ try
+ {
+ context.getMPIO().messageSize = outBuffer.size();
+
+ // reset server send time
+ if(context.isRecordMessageTimes())
+ {
+ serializationOverhead = System.currentTimeMillis() - serializationOverhead;
+ context.getMPIO().addToOverhead(serializationOverhead);
+ context.getMPIO().sendTime = System.currentTimeMillis();
+ }
+
+ // reserialize the message now that info has been added
+ outBuffer = new ByteArrayOutputStream();
+ respMesg = context.getResponseMessage();
+ serializer.initialize(sc, outBuffer, debugTrace);
+ serializer.writeMessage(respMesg);
+ }
+ catch(Exception e)
+ {
+ if (Log.isDebug())
+ logger.debug("MPI set up error: " + e.toString());
+ }
+ }
+ context.setResponseOutput(outBuffer);
+ }
+ catch (Exception e)
+ {
+ handleSerializationException(sc, context, e, logger);
+ }
+ finally
+ {
+ if (debugTrace != null)
+ logger.debug(debugTrace.toString());
+ }
+ }
+ }
+ }
+
+ /**
+ * This static method provides a common way for deserialization errors to be
+ * handled. It attempts to provide the client with useful information about
+ * deserialization failure.
+ *
+ * @param actionContext The action context.
+ * @param t The throwable that needs to be handled.
+ * @param logger The logger to which to log messages.
+ * @throws IOException
+ */
+ public static void handleDeserializationException(ActionContext actionContext, Throwable t, Logger logger) throws IOException
+ {
+ if (t instanceof EOFException)
+ {
+ actionContext.setStatus(MessageIOConstants.STATUS_NOTAMF);
+ }
+ else if (t instanceof IOException)
+ {
+ if (Log.isDebug())
+ logger.debug("IOException reading message - client closed socket before sending the message?");
+
+ throw (IOException)t;
+ }
+ else
+ {
+ actionContext.setStatus(MessageIOConstants.STATUS_ERR);
+
+ // Create a single message body to hold the error
+ MessageBody responseBody = new MessageBody();
+ if (actionContext.getMessageNumber() < actionContext.getRequestMessage().getBodyCount())
+ responseBody.setTargetURI(actionContext.getRequestMessageBody().getResponseURI());
+
+ // If the message couldn't be deserialized enough to know the version, set the current version here
+ if (actionContext.getVersion() == 0)
+ actionContext.setVersion(ActionMessage.CURRENT_VERSION);
+
+ // append the response body to the output message
+ actionContext.getResponseMessage().addBody(responseBody);
+
+ String message;
+ MessageException methodResult;
+ if (t instanceof MessageException)
+ {
+ methodResult = (MessageException)t;
+ message = methodResult.getMessage();
+ }
+ else
+ {
+ //Error deserializing client message.
+ methodResult = new SerializationException();
+ methodResult.setMessage(REQUEST_ERROR);
+ methodResult.setRootCause(t);
+ message = methodResult.getMessage();
+ }
+ responseBody.setData(methodResult.createErrorMessage());
+ responseBody.setReplyMethod(MessageIOConstants.STATUS_METHOD);
+
+ if (Log.isError())
+ logger.error(message + StringUtils.NEWLINE + ExceptionUtil.toString(t));
+ }
+
+ }
+
+ /**
+ * This static method provides a common way for serialization errors to be
+ * handled. It attempts to provide the client with useful information about
+ * the serialization failure. When there is a serialization failure, there is
+ * no way to tell which response failed serialization, so it adds a new response
+ * with the serialization failure for each of the corresponding requests.
+ *
+ * @param serializer The serializer that generated the error.
+ * @param serializationContext The serialization context.
+ * @param actionContext The action context.
+ * @param t The throwable that needs to be handled.
+ * @param logger The logger to which to log error messages.
+ */
+ public static void handleSerializationException(SerializationContext serializationContext,
+ ActionContext actionContext, Throwable t, Logger logger)
+ {
+ ActionMessage responseMessage = new ActionMessage();
+ actionContext.setResponseMessage(responseMessage);
+
+ int bodyCount = actionContext.getRequestMessage().getBodyCount();
+ for (actionContext.setMessageNumber(0); actionContext.getMessageNumber() < bodyCount; actionContext.incrementMessageNumber())
+ {
+ MessageBody responseBody = new MessageBody();
+ responseBody.setTargetURI(actionContext.getRequestMessageBody().getResponseURI());
+ actionContext.getResponseMessage().addBody(responseBody);
+
+ Object methodResult;
+
+ if (t instanceof MessageException)
+ {
+ methodResult = ((MessageException)t).createErrorMessage();
+ }
+ else
+ {
+ String message = "An error occurred while serializing server response(s).";
+ if (t.getMessage() != null)
+ {
+ message = t.getMessage();
+ if (message == null)
+ message = t.toString();
+ }
+
+ methodResult = new MessageException(message, t).createErrorMessage();
+ }
+
+ if (actionContext.isLegacy())
+ {
+ if (methodResult instanceof ErrorMessage)
+ {
+ ErrorMessage error = (ErrorMessage)methodResult;
+ ASObject aso = new ASObject();
+ aso.put("message", error.faultString);
+ aso.put("code", error.faultCode);
+ aso.put("details", error.faultDetail);
+ aso.put("rootCause", error.rootCause);
+ methodResult = aso;
+ }
+ else if (methodResult instanceof Message)
+ {
+ methodResult = ((Message)methodResult).getBody();
+ }
+ }
+ else
+ {
+ try
+ {
+ Message inMessage = actionContext.getRequestMessageBody().getDataAsMessage();
+ if (inMessage.getClientId() != null)
+ ((ErrorMessage)methodResult).setClientId(inMessage.getClientId().toString());
+
+ if (inMessage.getMessageId() != null)
+ {
+ ((ErrorMessage)methodResult).setCorrelationId(inMessage.getMessageId());
+ ((ErrorMessage)methodResult).setDestination(inMessage.getDestination());
+ }
+ }
+ catch (MessageException ignore){}
+ }
+
+ responseBody.setData(methodResult);
+ responseBody.setReplyMethod(MessageIOConstants.STATUS_METHOD);
+ }
+
+ if (Log.isError() && logger != null)
+ logger.error("Exception occurred during serialization: " + ExceptionUtil.toString(t));
+
+ // Serialize the error messages
+ ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
+ AmfTrace debugTrace = Log.isDebug() && logger.hasTarget()? new AmfTrace() : null;
+ MessageSerializer serializer = serializationContext.newMessageSerializer();
+ serializer.initialize(serializationContext, outBuffer, debugTrace);
+
+ try
+ {
+ serializer.writeMessage(actionContext.getResponseMessage());
+ actionContext.setResponseOutput(outBuffer);
+ }
+ catch (IOException e)
+ {
+ //Error serializing response
+ MessageException ex = new MessageException();
+ ex.setMessage(RESPONSE_ERROR);
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * An unhandled error happened somewhere between the SerializationFilter and the
+ * ErrorFilter... we ignore all request bodies and attempt to send back a single response
+ * body to the client. It will not make it back to a custom responder, but the NetConnection
+ * Debugger will show the event.
+ */
+ private void unhandledError(ActionContext context, Throwable t)
+ {
+ ActionMessage responseMessage = new ActionMessage();
+ context.setResponseMessage(responseMessage);
+
+ MessageBody responseBody = new MessageBody();
+ responseBody.setTargetURI(context.getRequestMessageBody().getResponseURI());
+
+ context.getResponseMessage().addBody(responseBody);
+
+ MessageException methodResult;
+
+ if (t instanceof MessageException)
+ {
+ methodResult = (MessageException)t;
+ }
+ else
+ {
+ // An unhandled error occurred while processing client request(s).
+ methodResult = new SerializationException();
+ methodResult.setMessage(UNHANDLED_ERROR);
+ methodResult.setRootCause(t);
+ }
+
+ responseBody.setData(methodResult);
+ responseBody.setReplyMethod(MessageIOConstants.STATUS_METHOD);
+
+ logger.info(t.getMessage());
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/amf/SessionFilter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/amf/SessionFilter.java b/modules/core/src/flex/messaging/endpoints/amf/SessionFilter.java
old mode 100755
new mode 100644
index 4d56df9..a8b36cb
--- a/modules/core/src/flex/messaging/endpoints/amf/SessionFilter.java
+++ b/modules/core/src/flex/messaging/endpoints/amf/SessionFilter.java
@@ -1,81 +1,81 @@
-/*
- * 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.endpoints.amf;
-
-import flex.messaging.FlexContext;
-import flex.messaging.io.amf.ActionContext;
-import flex.messaging.io.amf.MessageHeader;
-import flex.messaging.io.MessageIOConstants;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * This filter detects whether a request URL is decorated with a ;jessionid token
- * in the event that the client does not support cookies. In that case, an AppendToGatewayUrl
- * header with jsessionid as its value is added to the response message.
- */
-public class SessionFilter extends AMFFilter
-{
- public SessionFilter()
- {
- }
-
- public void invoke(final ActionContext context) throws IOException
- {
- next.invoke(context);
-
- try
- {
- HttpServletRequest request = FlexContext.getHttpRequest();
- HttpServletResponse response = FlexContext.getHttpResponse();
-
- StringBuffer reqURL = request.getRequestURL();
-
- if (reqURL != null)
- {
- if (request.getQueryString() != null)
- reqURL.append('?').append(request.getQueryString());
-
- String oldFullURL = reqURL.toString().trim();
- String encFullURL = response.encodeURL(oldFullURL).trim();
-
- String sessionSuffix = null;
-
- // It's ok to lower case here as URLs must be in ASCII
- int pos = encFullURL.toLowerCase().indexOf(";jsessionid");
- if (pos > 0)
- {
- StringBuffer sb = new StringBuffer();
- sb.append(encFullURL.substring(pos));
- sessionSuffix = sb.toString();
- }
-
- if (sessionSuffix != null && oldFullURL.indexOf(sessionSuffix) < 0)
- {
- context.getResponseMessage().addHeader(new MessageHeader(MessageIOConstants.URL_APPEND_HEADER, true /*mustUnderstand*/, sessionSuffix));
- }
- }
- }
- catch (Throwable t)
- {
- //Nothing more we can do... don't send 'URL Append' AMF header.
- }
- }
-}
+/*
+ * 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.endpoints.amf;
+
+import flex.messaging.FlexContext;
+import flex.messaging.io.amf.ActionContext;
+import flex.messaging.io.amf.MessageHeader;
+import flex.messaging.io.MessageIOConstants;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * This filter detects whether a request URL is decorated with a ;jessionid token
+ * in the event that the client does not support cookies. In that case, an AppendToGatewayUrl
+ * header with jsessionid as its value is added to the response message.
+ */
+public class SessionFilter extends AMFFilter
+{
+ public SessionFilter()
+ {
+ }
+
+ public void invoke(final ActionContext context) throws IOException
+ {
+ next.invoke(context);
+
+ try
+ {
+ HttpServletRequest request = FlexContext.getHttpRequest();
+ HttpServletResponse response = FlexContext.getHttpResponse();
+
+ StringBuffer reqURL = request.getRequestURL();
+
+ if (reqURL != null)
+ {
+ if (request.getQueryString() != null)
+ reqURL.append('?').append(request.getQueryString());
+
+ String oldFullURL = reqURL.toString().trim();
+ String encFullURL = response.encodeURL(oldFullURL).trim();
+
+ String sessionSuffix = null;
+
+ // It's ok to lower case here as URLs must be in ASCII
+ int pos = encFullURL.toLowerCase().indexOf(";jsessionid");
+ if (pos > 0)
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append(encFullURL.substring(pos));
+ sessionSuffix = sb.toString();
+ }
+
+ if (sessionSuffix != null && oldFullURL.indexOf(sessionSuffix) < 0)
+ {
+ context.getResponseMessage().addHeader(new MessageHeader(MessageIOConstants.URL_APPEND_HEADER, true /*mustUnderstand*/, sessionSuffix));
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ //Nothing more we can do... don't send 'URL Append' AMF header.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/amf/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/amf/package-info.java b/modules/core/src/flex/messaging/endpoints/amf/package-info.java
old mode 100755
new mode 100644
index 40f3816..5428732
--- a/modules/core/src/flex/messaging/endpoints/amf/package-info.java
+++ b/modules/core/src/flex/messaging/endpoints/amf/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.endpoints.amf;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/package-info.java b/modules/core/src/flex/messaging/endpoints/package-info.java
old mode 100755
new mode 100644
index 6226945..f47eb5b
--- a/modules/core/src/flex/messaging/endpoints/package-info.java
+++ b/modules/core/src/flex/messaging/endpoints/package-info.java
@@ -1,17 +1,17 @@
-/*
- * 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.endpoints;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/factories/JavaFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/factories/JavaFactory.java b/modules/core/src/flex/messaging/factories/JavaFactory.java
old mode 100755
new mode 100644
index 32baab3..8cd2057
--- a/modules/core/src/flex/messaging/factories/JavaFactory.java
+++ b/modules/core/src/flex/messaging/factories/JavaFactory.java
@@ -1,298 +1,298 @@
-/*
- * 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.factories;
-
-import flex.messaging.FlexFactory;
-import flex.messaging.DestructibleFlexFactory;
-import flex.messaging.FlexSession;
-import flex.messaging.FlexContext;
-import flex.messaging.FactoryInstance;
-import flex.messaging.MessageBroker;
-import flex.messaging.FlexSessionListener;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.ConfigurationException;
-import flex.messaging.services.ServiceException;
-
-import flex.messaging.config.ConfigurationManager;
-import flex.messaging.log.Log;
-import flex.messaging.util.StringUtils;
-import flex.messaging.util.ExceptionUtil;
-
-import javax.servlet.ServletContext;
-
-/**
- * This class implements the FlexFactory interface to constructs Flex messaging
- * components. The JavaFactory uses the class name, specified as the source
- * attribute to determine the class for instances. The scope attribute can be one of
- * session, application or request to determine its lifecycle. If you
- * use application or session, you can specify the optional attribute-id
- * parameter to control the name of the key for storing the component. Two destinations
- * using the same attribute-id will use the same component. The component is stored
- * in the ServletContext (for application scoped components) and in the
- * session (for session scoped components) so you can use these components in your
- * JSP as well.
- *
- * @author Jeff Vroom
- */
-public class JavaFactory implements FlexFactory, DestructibleFlexFactory
-{
- private static final String ATTRIBUTE_ID = "attribute-id";
-
- private static final int SINGLETON_ERROR = 10656;
- private static final int SESSION_NOT_FOUND = 10652;
- private static final int INVALID_CLASS_FOUND = 10654;
-
- /**
- * @exclude
- * Default constructor
- */
- public JavaFactory()
- {
- }
-
- /**
- * This method can be used to provide additional configuration parameters
- * for the initializing this factory instance itself.
- */
- public void initialize(String id, ConfigMap configMap) {}
-
- /**
- * This method is called when we initialize the definition of an instance which
- * will be looked up by this factory. It should validate that the properties
- * supplied are valid to define an instance. Any valid properties used for
- * this configuration must be accessed to avoid warnings about unused
- * configuration elements. If your factory is only used for application
- * scoped components, you do not need to implement this method as the lookup
- * method itself can be used to validate its configuration.
- */
- public FactoryInstance createFactoryInstance(String id, ConfigMap properties)
- {
- JavaFactoryInstance instance = new JavaFactoryInstance(this, id, properties);
-
- if (properties == null)
- {
- // Use destination id as the default attribute id to prevent unwanted sharing.
- instance.setSource(instance.getId());
- instance.setScope(SCOPE_REQUEST);
- instance.setAttributeId(id);
- }
- else
- {
- instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId()));
- instance.setScope(properties.getPropertyAsString(SCOPE, SCOPE_REQUEST));
- // Use destination id as the default attribute id to prevent unwanted sharing.
- instance.setAttributeId(properties.getPropertyAsString(ATTRIBUTE_ID, id));
- }
-
- if (instance.getScope().equalsIgnoreCase(SCOPE_APPLICATION))
- {
- try
- {
- MessageBroker mb = FlexContext.getMessageBroker();
- ServletContext ctx = mb != null? mb.getServletContext() : null;
- if (ctx == null) // Should not be the case; just in case.
- return instance;
-
- synchronized (ctx)
- {
- Object inst = ctx.getAttribute(instance.getAttributeId());
- if (inst == null)
- {
- inst = instance.createInstance();
- ctx.setAttribute(instance.getAttributeId(), inst);
- }
- else
- {
- Class configuredClass = instance.getInstanceClass();
- Class instClass = inst.getClass();
- if (configuredClass != instClass &&
- !configuredClass.isAssignableFrom(instClass))
- {
- ServiceException e = new ServiceException();
- e.setMessage(INVALID_CLASS_FOUND, new Object[] {
- instance.getAttributeId(), "application", instance.getId(),
- instance.getInstanceClass(), inst.getClass()});
- e.setCode("Server.Processing");
- throw e;
- }
- }
- instance.applicationInstance = inst;
-
- // increment attribute-id reference count on MB
- mb.incrementAttributeIdRefCount(instance.getAttributeId());
- }
- }
- catch (Throwable t)
- {
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(SINGLETON_ERROR, new Object[] { instance.getSource(), id });
- ex.setRootCause(t);
-
- if (Log.isError())
- Log.getLogger(ConfigurationManager.LOG_CATEGORY).error(ex.getMessage() + StringUtils.NEWLINE + ExceptionUtil.toString(t));
-
- throw ex;
- }
- }
- else if(instance.getScope().equalsIgnoreCase(SCOPE_SESSION))
- {
- // increment attribute-id reference count on MB for Session scoped instances
- MessageBroker mb = FlexContext.getMessageBroker();
- if (mb != null)
- mb.incrementAttributeIdRefCount(instance.getAttributeId());
- }
- return instance;
- }
-
- /**
- * Returns the instance specified by the source
- * and properties arguments. For the factory, this may mean
- * constructing a new instance, optionally registering it in some other
- * name space such as the session or JNDI, and then returning it
- * or it may mean creating a new instance and returning it.
- * This method is called for each request to operate on the
- * given item by the system so it should be relatively efficient.
- * <p>
- * If your factory does not support the scope property, it report an error
- * if scope is supplied in the properties for this instance.
- * </p>
- *
- * @param inst the FactoryInstance to lookup.
- * @return the constructed and initialized component for this factory instance.
- */
- public Object lookup(FactoryInstance inst)
- {
- JavaFactoryInstance factoryInstance = (JavaFactoryInstance) inst;
- Object instance;
-
- if (factoryInstance.getScope().equalsIgnoreCase(SCOPE_APPLICATION))
- {
- instance = factoryInstance.applicationInstance;
- }
- else if (factoryInstance.getScope().equalsIgnoreCase(SCOPE_SESSION))
- {
- // See if an instance already exists in this http session first
- FlexSession session = FlexContext.getFlexSession();
- if (session != null)
- {
- instance = session.getAttribute(factoryInstance.getAttributeId());
- if (instance != null)
- {
- Class configuredClass = factoryInstance.getInstanceClass();
- Class instClass = instance.getClass();
- if (configuredClass != instClass &&
- !configuredClass.isAssignableFrom(instClass))
- {
- ServiceException e = new ServiceException();
- e.setMessage(INVALID_CLASS_FOUND, new Object[] {
- factoryInstance.getAttributeId(),
- "session",
- factoryInstance.getId(),
- factoryInstance.getInstanceClass(), instance.getClass()});
- e.setCode("Server.Processing");
- throw e;
- }
- }
- else
- {
- // none exists - create it the first time for each session
- instance = factoryInstance.createInstance();
- session.setAttribute(factoryInstance.getAttributeId(), instance);
- }
- }
- else
- instance = null;
-
- if (instance == null)
- {
- ServiceException e = new ServiceException();
- e.setMessage(SESSION_NOT_FOUND, new Object[] {factoryInstance.getId()});
- e.setCode("Server.Processing");
- throw e;
- }
- }
- else
- {
- instance = factoryInstance.createInstance();
- }
- return instance;
- }
-
- /**
- * This method is called when a component using this factory is being destroyed.
- * When appropriate, it frees up resources that were used by the factory instance
- * and are no longer needed
- *
- * @param inst The FactoryInstance to be cleaned up
- */
- public void destroyFactoryInstance(FactoryInstance inst)
- {
- JavaFactoryInstance factoryInstance = (JavaFactoryInstance) inst;
-
- // if we are stopping a destination with an Application or Session scoped assembler, we may
- // have to remove the assembler from the ServletContext or Session
- if (factoryInstance != null)
- {
- MessageBroker mb = FlexContext.getMessageBroker();
- String attributeId = factoryInstance.getAttributeId();
-
- if (FlexFactory.SCOPE_APPLICATION.equals(factoryInstance.getScope()))
- {
- ServletContext ctx = mb.getServletContext();
- if (ctx == null) // Should never be the case, but just in case.
- return;
-
- synchronized (ctx)
- {
- // remove from ServletContext if reference count is zero
- int refCount = (mb != null) ? mb.decrementAttributeIdRefCount(attributeId) : 0;
- if (refCount <= 0)
- {
- // remove assembler from servlet context
- ctx.removeAttribute(attributeId);
- }
- }
- }
- else if (FlexFactory.SCOPE_SESSION.equals(factoryInstance.getScope()))
- {
- FlexSession session = FlexContext.getFlexSession();
-
- // if this is being stopped during runtime config, we should have a session available to us
- // However, if this is being stopped on MessageBroker shutdown, we will not have a session
- // but do not need to worry about clean up in that case as the entire session will be cleaned up
- if (session == null)
- return;
-
- // remove from Session if reference count is zero
- int refCount = (mb != null) ? mb.decrementAttributeIdRefCount(attributeId) : 0;
- if (refCount <= 0)
- {
- // remove assembler from servlet context
- session.removeAttribute(attributeId);
- }
- }
-
- // Remove this instance from Session created listeners
- // Only helps if listener was created by the factory, but this is common (aka assembler classes)
- if (factoryInstance.applicationInstance instanceof FlexSessionListener)
- {
- FlexSession.removeSessionCreatedListener((FlexSessionListener) factoryInstance.applicationInstance);
- }
- }
- }
-}
-
+/*
+ * 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.factories;
+
+import flex.messaging.FlexFactory;
+import flex.messaging.DestructibleFlexFactory;
+import flex.messaging.FlexSession;
+import flex.messaging.FlexContext;
+import flex.messaging.FactoryInstance;
+import flex.messaging.MessageBroker;
+import flex.messaging.FlexSessionListener;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.ConfigurationException;
+import flex.messaging.services.ServiceException;
+
+import flex.messaging.config.ConfigurationManager;
+import flex.messaging.log.Log;
+import flex.messaging.util.StringUtils;
+import flex.messaging.util.ExceptionUtil;
+
+import javax.servlet.ServletContext;
+
+/**
+ * This class implements the FlexFactory interface to constructs Flex messaging
+ * components. The JavaFactory uses the class name, specified as the source
+ * attribute to determine the class for instances. The scope attribute can be one of
+ * session, application or request to determine its lifecycle. If you
+ * use application or session, you can specify the optional attribute-id
+ * parameter to control the name of the key for storing the component. Two destinations
+ * using the same attribute-id will use the same component. The component is stored
+ * in the ServletContext (for application scoped components) and in the
+ * session (for session scoped components) so you can use these components in your
+ * JSP as well.
+ *
+ * @author Jeff Vroom
+ */
+public class JavaFactory implements FlexFactory, DestructibleFlexFactory
+{
+ private static final String ATTRIBUTE_ID = "attribute-id";
+
+ private static final int SINGLETON_ERROR = 10656;
+ private static final int SESSION_NOT_FOUND = 10652;
+ private static final int INVALID_CLASS_FOUND = 10654;
+
+ /**
+ * @exclude
+ * Default constructor
+ */
+ public JavaFactory()
+ {
+ }
+
+ /**
+ * This method can be used to provide additional configuration parameters
+ * for the initializing this factory instance itself.
+ */
+ public void initialize(String id, ConfigMap configMap) {}
+
+ /**
+ * This method is called when we initialize the definition of an instance which
+ * will be looked up by this factory. It should validate that the properties
+ * supplied are valid to define an instance. Any valid properties used for
+ * this configuration must be accessed to avoid warnings about unused
+ * configuration elements. If your factory is only used for application
+ * scoped components, you do not need to implement this method as the lookup
+ * method itself can be used to validate its configuration.
+ */
+ public FactoryInstance createFactoryInstance(String id, ConfigMap properties)
+ {
+ JavaFactoryInstance instance = new JavaFactoryInstance(this, id, properties);
+
+ if (properties == null)
+ {
+ // Use destination id as the default attribute id to prevent unwanted sharing.
+ instance.setSource(instance.getId());
+ instance.setScope(SCOPE_REQUEST);
+ instance.setAttributeId(id);
+ }
+ else
+ {
+ instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId()));
+ instance.setScope(properties.getPropertyAsString(SCOPE, SCOPE_REQUEST));
+ // Use destination id as the default attribute id to prevent unwanted sharing.
+ instance.setAttributeId(properties.getPropertyAsString(ATTRIBUTE_ID, id));
+ }
+
+ if (instance.getScope().equalsIgnoreCase(SCOPE_APPLICATION))
+ {
+ try
+ {
+ MessageBroker mb = FlexContext.getMessageBroker();
+ ServletContext ctx = mb != null? mb.getServletContext() : null;
+ if (ctx == null) // Should not be the case; just in case.
+ return instance;
+
+ synchronized (ctx)
+ {
+ Object inst = ctx.getAttribute(instance.getAttributeId());
+ if (inst == null)
+ {
+ inst = instance.createInstance();
+ ctx.setAttribute(instance.getAttributeId(), inst);
+ }
+ else
+ {
+ Class configuredClass = instance.getInstanceClass();
+ Class instClass = inst.getClass();
+ if (configuredClass != instClass &&
+ !configuredClass.isAssignableFrom(instClass))
+ {
+ ServiceException e = new ServiceException();
+ e.setMessage(INVALID_CLASS_FOUND, new Object[] {
+ instance.getAttributeId(), "application", instance.getId(),
+ instance.getInstanceClass(), inst.getClass()});
+ e.setCode("Server.Processing");
+ throw e;
+ }
+ }
+ instance.applicationInstance = inst;
+
+ // increment attribute-id reference count on MB
+ mb.incrementAttributeIdRefCount(instance.getAttributeId());
+ }
+ }
+ catch (Throwable t)
+ {
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(SINGLETON_ERROR, new Object[] { instance.getSource(), id });
+ ex.setRootCause(t);
+
+ if (Log.isError())
+ Log.getLogger(ConfigurationManager.LOG_CATEGORY).error(ex.getMessage() + StringUtils.NEWLINE + ExceptionUtil.toString(t));
+
+ throw ex;
+ }
+ }
+ else if(instance.getScope().equalsIgnoreCase(SCOPE_SESSION))
+ {
+ // increment attribute-id reference count on MB for Session scoped instances
+ MessageBroker mb = FlexContext.getMessageBroker();
+ if (mb != null)
+ mb.incrementAttributeIdRefCount(instance.getAttributeId());
+ }
+ return instance;
+ }
+
+ /**
+ * Returns the instance specified by the source
+ * and properties arguments. For the factory, this may mean
+ * constructing a new instance, optionally registering it in some other
+ * name space such as the session or JNDI, and then returning it
+ * or it may mean creating a new instance and returning it.
+ * This method is called for each request to operate on the
+ * given item by the system so it should be relatively efficient.
+ * <p>
+ * If your factory does not support the scope property, it report an error
+ * if scope is supplied in the properties for this instance.
+ * </p>
+ *
+ * @param inst the FactoryInstance to lookup.
+ * @return the constructed and initialized component for this factory instance.
+ */
+ public Object lookup(FactoryInstance inst)
+ {
+ JavaFactoryInstance factoryInstance = (JavaFactoryInstance) inst;
+ Object instance;
+
+ if (factoryInstance.getScope().equalsIgnoreCase(SCOPE_APPLICATION))
+ {
+ instance = factoryInstance.applicationInstance;
+ }
+ else if (factoryInstance.getScope().equalsIgnoreCase(SCOPE_SESSION))
+ {
+ // See if an instance already exists in this http session first
+ FlexSession session = FlexContext.getFlexSession();
+ if (session != null)
+ {
+ instance = session.getAttribute(factoryInstance.getAttributeId());
+ if (instance != null)
+ {
+ Class configuredClass = factoryInstance.getInstanceClass();
+ Class instClass = instance.getClass();
+ if (configuredClass != instClass &&
+ !configuredClass.isAssignableFrom(instClass))
+ {
+ ServiceException e = new ServiceException();
+ e.setMessage(INVALID_CLASS_FOUND, new Object[] {
+ factoryInstance.getAttributeId(),
+ "session",
+ factoryInstance.getId(),
+ factoryInstance.getInstanceClass(), instance.getClass()});
+ e.setCode("Server.Processing");
+ throw e;
+ }
+ }
+ else
+ {
+ // none exists - create it the first time for each session
+ instance = factoryInstance.createInstance();
+ session.setAttribute(factoryInstance.getAttributeId(), instance);
+ }
+ }
+ else
+ instance = null;
+
+ if (instance == null)
+ {
+ ServiceException e = new ServiceException();
+ e.setMessage(SESSION_NOT_FOUND, new Object[] {factoryInstance.getId()});
+ e.setCode("Server.Processing");
+ throw e;
+ }
+ }
+ else
+ {
+ instance = factoryInstance.createInstance();
+ }
+ return instance;
+ }
+
+ /**
+ * This method is called when a component using this factory is being destroyed.
+ * When appropriate, it frees up resources that were used by the factory instance
+ * and are no longer needed
+ *
+ * @param inst The FactoryInstance to be cleaned up
+ */
+ public void destroyFactoryInstance(FactoryInstance inst)
+ {
+ JavaFactoryInstance factoryInstance = (JavaFactoryInstance) inst;
+
+ // if we are stopping a destination with an Application or Session scoped assembler, we may
+ // have to remove the assembler from the ServletContext or Session
+ if (factoryInstance != null)
+ {
+ MessageBroker mb = FlexContext.getMessageBroker();
+ String attributeId = factoryInstance.getAttributeId();
+
+ if (FlexFactory.SCOPE_APPLICATION.equals(factoryInstance.getScope()))
+ {
+ ServletContext ctx = mb.getServletContext();
+ if (ctx == null) // Should never be the case, but just in case.
+ return;
+
+ synchronized (ctx)
+ {
+ // remove from ServletContext if reference count is zero
+ int refCount = (mb != null) ? mb.decrementAttributeIdRefCount(attributeId) : 0;
+ if (refCount <= 0)
+ {
+ // remove assembler from servlet context
+ ctx.removeAttribute(attributeId);
+ }
+ }
+ }
+ else if (FlexFactory.SCOPE_SESSION.equals(factoryInstance.getScope()))
+ {
+ FlexSession session = FlexContext.getFlexSession();
+
+ // if this is being stopped during runtime config, we should have a session available to us
+ // However, if this is being stopped on MessageBroker shutdown, we will not have a session
+ // but do not need to worry about clean up in that case as the entire session will be cleaned up
+ if (session == null)
+ return;
+
+ // remove from Session if reference count is zero
+ int refCount = (mb != null) ? mb.decrementAttributeIdRefCount(attributeId) : 0;
+ if (refCount <= 0)
+ {
+ // remove assembler from servlet context
+ session.removeAttribute(attributeId);
+ }
+ }
+
+ // Remove this instance from Session created listeners
+ // Only helps if listener was created by the factory, but this is common (aka assembler classes)
+ if (factoryInstance.applicationInstance instanceof FlexSessionListener)
+ {
+ FlexSession.removeSessionCreatedListener((FlexSessionListener) factoryInstance.applicationInstance);
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/factories/JavaFactoryInstance.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/factories/JavaFactoryInstance.java b/modules/core/src/flex/messaging/factories/JavaFactoryInstance.java
old mode 100755
new mode 100644
index 5619dae..9131aa0
--- a/modules/core/src/flex/messaging/factories/JavaFactoryInstance.java
+++ b/modules/core/src/flex/messaging/factories/JavaFactoryInstance.java
@@ -1,146 +1,146 @@
-/*
- * 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.factories;
-
-import flex.messaging.Destination;
-import flex.messaging.FactoryInstance;
-import flex.messaging.FlexConfigurable;
-import flex.messaging.FlexContext;
-import flex.messaging.FlexFactory;
-import flex.messaging.FlexSession;
-import flex.messaging.MessageBroker;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.util.ClassUtil;
-
-/**
- * This class is used by the <code>JavaFactory</code> to store the configuration
- * for an instance created by the <code>JavaFactory</code>. There is one of these for
- * each destination currently since only destinations create these components.
- *
- * @see flex.messaging.factories.JavaFactory
- */
-
-public class JavaFactoryInstance extends FactoryInstance
-{
- Object applicationInstance = null;
- Class javaClass = null;
- String attributeId;
-
- /**
- * Constructs a <code>JavaFactoryInstance</code>, assigning its factory, id,
- * and properties.
- *
- * @param factory The <code>JavaFactory</code> that created this instance.
- * @param id The id for the <code>JavaFactoryInstance</code>.
- * @param properties The properties for the <code>JavaFactoryInstance</code>.
- */
- public JavaFactoryInstance(JavaFactory factory, String id, ConfigMap properties)
- {
- super(factory, id, properties);
- }
-
- /**
- * Sets the attribute id for the <code>JavaFactoryInstance</code>.
- *
- * @param attributeId The attribute id for the <code>JavaFactoryInstance</code>.
- */
- public void setAttributeId(String attributeId)
- {
- this.attributeId = attributeId;
- }
-
- /**
- * Returns the attribute id for the <code>JavaFactoryInstance</code>.
- *
- * @return attributeId The attribute id for the <code>JavaFactoryInstance</code>.
- */
- public String getAttributeId()
- {
- return attributeId;
- }
-
- /**
- * Sets the instance class to null, in addition to updating the
- * <code>source</code> property.
- */
- @Override public void setSource(String source)
- {
- super.setSource(source);
- if (javaClass != null)
- javaClass = null;
- }
-
- /**
- * Creates an instance from specified <code>source</code> and initializes
- * the instance if it is of <code>FlexConfigurable</code> type.
- *
- * @return the instance
- */
- public Object createInstance()
- {
- Object inst = ClassUtil.createDefaultInstance(getInstanceClass(), null);
-
- MessageBroker mb = FlexContext.getMessageBroker();
- if (mb != null)
- {
- Destination destination = mb.getRegisteredDestination(getId());
- if (destination != null && destination.isInitialized())
- {
- if (inst instanceof FlexConfigurable)
- ((FlexConfigurable) inst).initialize(getId(), getProperties());
- }
- }
-
- return inst;
- }
-
- /**
- * Creates an instance class from specified <code>source</code>.
- */
- @Override public Class getInstanceClass()
- {
- if (javaClass == null)
- javaClass = ClassUtil.createClass(getSource(),
- FlexContext.getMessageBroker() == null ? this.getClass().getClassLoader() :
- FlexContext.getMessageBroker().getClassLoader());
-
- return javaClass;
- }
-
- /**
- * Updates the session so that these values get replicated to other nodes
- * in the cluster. Possibly we should make this configurable?
- */
- @Override public void operationComplete(Object instance)
- {
- if (getScope().equalsIgnoreCase(FlexFactory.SCOPE_SESSION))
- {
- FlexSession session = FlexContext.getFlexSession();
- if (session != null && session.isValid())
- {
- session.setAttribute(getAttributeId(), instance);
- }
- }
- }
-
- /** @exclude **/
- @Override public String toString()
- {
- return "JavaFactory instance for id=" + getId() + " source=" + getSource() + " scope=" + getScope();
- }
-}
+/*
+ * 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.factories;
+
+import flex.messaging.Destination;
+import flex.messaging.FactoryInstance;
+import flex.messaging.FlexConfigurable;
+import flex.messaging.FlexContext;
+import flex.messaging.FlexFactory;
+import flex.messaging.FlexSession;
+import flex.messaging.MessageBroker;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.util.ClassUtil;
+
+/**
+ * This class is used by the <code>JavaFactory</code> to store the configuration
+ * for an instance created by the <code>JavaFactory</code>. There is one of these for
+ * each destination currently since only destinations create these components.
+ *
+ * @see flex.messaging.factories.JavaFactory
+ */
+
+public class JavaFactoryInstance extends FactoryInstance
+{
+ Object applicationInstance = null;
+ Class javaClass = null;
+ String attributeId;
+
+ /**
+ * Constructs a <code>JavaFactoryInstance</code>, assigning its factory, id,
+ * and properties.
+ *
+ * @param factory The <code>JavaFactory</code> that created this instance.
+ * @param id The id for the <code>JavaFactoryInstance</code>.
+ * @param properties The properties for the <code>JavaFactoryInstance</code>.
+ */
+ public JavaFactoryInstance(JavaFactory factory, String id, ConfigMap properties)
+ {
+ super(factory, id, properties);
+ }
+
+ /**
+ * Sets the attribute id for the <code>JavaFactoryInstance</code>.
+ *
+ * @param attributeId The attribute id for the <code>JavaFactoryInstance</code>.
+ */
+ public void setAttributeId(String attributeId)
+ {
+ this.attributeId = attributeId;
+ }
+
+ /**
+ * Returns the attribute id for the <code>JavaFactoryInstance</code>.
+ *
+ * @return attributeId The attribute id for the <code>JavaFactoryInstance</code>.
+ */
+ public String getAttributeId()
+ {
+ return attributeId;
+ }
+
+ /**
+ * Sets the instance class to null, in addition to updating the
+ * <code>source</code> property.
+ */
+ @Override public void setSource(String source)
+ {
+ super.setSource(source);
+ if (javaClass != null)
+ javaClass = null;
+ }
+
+ /**
+ * Creates an instance from specified <code>source</code> and initializes
+ * the instance if it is of <code>FlexConfigurable</code> type.
+ *
+ * @return the instance
+ */
+ public Object createInstance()
+ {
+ Object inst = ClassUtil.createDefaultInstance(getInstanceClass(), null);
+
+ MessageBroker mb = FlexContext.getMessageBroker();
+ if (mb != null)
+ {
+ Destination destination = mb.getRegisteredDestination(getId());
+ if (destination != null && destination.isInitialized())
+ {
+ if (inst instanceof FlexConfigurable)
+ ((FlexConfigurable) inst).initialize(getId(), getProperties());
+ }
+ }
+
+ return inst;
+ }
+
+ /**
+ * Creates an instance class from specified <code>source</code>.
+ */
+ @Override public Class getInstanceClass()
+ {
+ if (javaClass == null)
+ javaClass = ClassUtil.createClass(getSource(),
+ FlexContext.getMessageBroker() == null ? this.getClass().getClassLoader() :
+ FlexContext.getMessageBroker().getClassLoader());
+
+ return javaClass;
+ }
+
+ /**
+ * Updates the session so that these values get replicated to other nodes
+ * in the cluster. Possibly we should make this configurable?
+ */
+ @Override public void operationComplete(Object instance)
+ {
+ if (getScope().equalsIgnoreCase(FlexFactory.SCOPE_SESSION))
+ {
+ FlexSession session = FlexContext.getFlexSession();
+ if (session != null && session.isValid())
+ {
+ session.setAttribute(getAttributeId(), instance);
+ }
+ }
+ }
+
+ /** @exclude **/
+ @Override public String toString()
+ {
+ return "JavaFactory instance for id=" + getId() + " source=" + getSource() + " scope=" + getScope();
+ }
+}
[27/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/MessageBroker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/MessageBroker.java b/modules/core/src/flex/messaging/MessageBroker.java
old mode 100755
new mode 100644
index ebe628a..7e501c7
--- a/modules/core/src/flex/messaging/MessageBroker.java
+++ b/modules/core/src/flex/messaging/MessageBroker.java
@@ -1,2237 +1,2237 @@
-/*
- * 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;
-
-import flex.management.ManageableComponent;
-import flex.management.runtime.messaging.MessageBrokerControl;
-import flex.management.runtime.messaging.log.LogManager;
-import flex.messaging.client.FlexClient;
-import flex.messaging.client.FlexClientManager;
-import flex.messaging.cluster.ClusterManager;
-import flex.messaging.config.ChannelSettings;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.ConfigurationConstants;
-import flex.messaging.config.ConfigurationException;
-import flex.messaging.config.ConfigurationManager;
-import flex.messaging.config.FlexClientSettings;
-import flex.messaging.config.SecurityConstraint;
-import flex.messaging.config.SecuritySettings;
-import flex.messaging.config.SystemSettings;
-import flex.messaging.endpoints.AbstractEndpoint;
-import flex.messaging.endpoints.Endpoint;
-import flex.messaging.endpoints.Endpoint2;
-import flex.messaging.factories.JavaFactory;
-import flex.messaging.io.BeanProxy;
-import flex.messaging.io.PropertyProxyRegistry;
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.messages.AbstractMessage;
-import flex.messaging.messages.AcknowledgeMessage;
-import flex.messaging.messages.AsyncMessage;
-import flex.messaging.messages.CommandMessage;
-import flex.messaging.messages.Message;
-import flex.messaging.security.LoginManager;
-import flex.messaging.security.SecurityException;
-import flex.messaging.services.AbstractService;
-import flex.messaging.services.Service;
-import flex.messaging.services.ServiceException;
-import flex.messaging.services.messaging.ThrottleManager;
-import flex.messaging.util.Base64;
-import flex.messaging.util.ClassUtil;
-import flex.messaging.util.ExceptionUtil;
-import flex.messaging.util.RedeployManager;
-import flex.messaging.util.StringUtils;
-import flex.messaging.util.UUIDGenerator;
-import flex.messaging.util.UUIDUtils;
-import flex.messaging.validators.DeserializationValidator;
-
-import javax.servlet.ServletContext;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * The MessageBroker is the hub of message traffic. It has a number of endpoints which send and
- * receive messages over the network, and it has a number of
- * services that are message destinations. The broker routes
- * decoded messages received by endpoints to services based
- * on the service destination specified in each message.
- * The broker also has a means of pushing messages back through
- * endpoints to clients.
- */
-public class MessageBroker extends ManageableComponent
-{
- //--------------------------------------------------------------------------
- //
- // Public Static Constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * Id that the AuthenticationService uses to register itself with the broker.
- */
- public static final String AUTHENTICATION_SERVICE_ID = "authentication-service";
-
- /**
- * Localized error messages for <code>MessageBroker</code>.
- */
- public static final int ERR_MSG_NO_SERVICE_FOR_DEST = 10004;
- public static final int ERR_MSG_DESTINATION_UNACCESSIBLE = 10005;
- public static final int ERR_MSG_UNKNOWN_REMOTE_CREDENTIALS_FORMAT = 10020;
- public static final int ERR_MSG_NULL_MESSAGE_ID = 10029;
- public static final int ERR_MSG_CANNOT_SERVICE_STOPPED = 10038;
- public static final int ERR_MSG_NULL_ENDPOINT_URL = 10128;
- public static final int ERR_MSG_SERVICE_CMD_NOT_SUPPORTED = 10451;
- public static final int ERR_MSG_URI_ALREADY_REGISTERED = 11109;
-
- /**
- * Log category for <code>MessageBroker</code>.
- */
- public static final String LOG_CATEGORY = LogCategories.MESSAGE_GENERAL;
-
- /**
- * Log category that captures startup information for broker's destinations.
- */
- public static final String LOG_CATEGORY_STARTUP_SERVICE = LogCategories.STARTUP_SERVICE;
-
- /** @exclude */
- public static final String TYPE = "MessageBroker";
-
- //--------------------------------------------------------------------------
- //
- // Package Protected Static Constants
- //
- //--------------------------------------------------------------------------
- /** The default message broker id when one is not specified in web.xml. */
- public static final String DEFAULT_BROKER_ID = "__default__";
-
- /** A map of currently available message brokers indexed by message broker id. */
- static final Map<String, MessageBroker> messageBrokers = new HashMap<String, MessageBroker>();
-
- //--------------------------------------------------------------------------
- //
- // Private Static Constants
- //
- //--------------------------------------------------------------------------
-
- private static final String LOG_MANAGER_ID = "log";
- private static final Integer INTEGER_ONE = 1;
- private static final String MESSAGEBROKER = "MessageBroker";
- private static final String ENDPOINT = "Endpoint";
- private static final String SERVICE = "Service";
-
- //--------------------------------------------------------------------------
- //
- // Constructors
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * Create a MessageBroker. This constructor will
- * establish collections for routers, endpoints,
- * and services.
- */
- public MessageBroker()
- {
- this(true, null);
- }
-
- /** @exclude */
- public MessageBroker(boolean enableManagement)
- {
- this(enableManagement, null);
- }
-
- /** @exclude */
- public MessageBroker(boolean enableManagement, String mbid)
- {
- this(enableManagement, mbid, MessageBroker.class.getClassLoader());
- }
-
- /** @exclude */
- public MessageBroker(boolean enableManagement, String mbid, ClassLoader loader)
- {
- super(enableManagement);
- classLoader = loader;
- attributes = new ConcurrentHashMap<String, Object>();
- destinationToService = new ConcurrentHashMap<String, String>();
- endpoints = new LinkedHashMap<String, Endpoint>();
- services = new LinkedHashMap<String, Service>();
- servers = new LinkedHashMap<String, Server>();
- factories = new HashMap<String, FlexFactory>();
- registeredEndpoints = new HashMap<String, String>();
-
- // Add the built-in java factory
- addFactory("java", new JavaFactory());
-
- setId(mbid);
-
- log = Log.createLog();
-
- clusterManager = new ClusterManager(this);
- systemSettings = new SystemSettings();
-
- if (isManaged())
- {
- controller = new MessageBrokerControl(this);
- controller.register();
- setControl(controller);
-
- logManager = new LogManager();
- logManager.setLog(log);
- logManager.setParent(this);
- logManager.setupLogControl();
- logManager.initialize(LOG_MANAGER_ID, null);
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- private Map<String, Object> attributes;
- /**
- * Map of attribute ids of Application or Session level scoped destination assemblers
- * to the number of active destinations referring to.
- */
- private final Map<String, Integer> attributeIdRefCounts = new HashMap<String, Integer>();
- private Map<String, ChannelSettings> channelSettings;
- private ClassLoader classLoader;
- private ClusterManager clusterManager;
- private MessageBrokerControl controller;
- private List<String> defaultChannels;
- private DeserializationValidator deserializationValidator;
- private Map<String, String> destinationToService; // destiantionId to serviceId map.
- private Map<String, Endpoint> endpoints;
- private boolean enforceEndpointValidation;
- private Map<String, FlexFactory> factories;
- private FlexClientManager flexClientManager;
- private FlexClientSettings flexClientSettings;
- private FlexSessionManager flexSessionManager;
- private PathResolver externalPathResolver;
- private InternalPathResolver internalPathResolver;
- private Log log;
- private LogManager logManager;
- private LoginManager loginManager;
- private RedeployManager redeployManager;
- private Map<String, String> registeredEndpoints;
- private SecuritySettings securitySettings;
- private Map<String, Service> services;
- private Map<String, Server> servers;
- private final ConcurrentHashMap<String, ServiceValidationListener> serviceValidationListeners = new ConcurrentHashMap<String, ServiceValidationListener>();
- private ServletContext servletContext;
- private SystemSettings systemSettings;
- private Class<? extends ThrottleManager> throttleManagerClass = ThrottleManager.class; // The default ThrottleManager class.
- private UUIDGenerator uuidGenerator;
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Sets the id of the <code>MessageBroker</code>. If id is null, uses the
- * default broker id.
- *
- * @exclude
- */
- @Override public void setId(String id)
- {
- if (id == null)
- id = DEFAULT_BROKER_ID;
-
- super.setId(id);
- }
-
- /**
- * Retrieves a message broker with the supplied id. This is defined via
- * the servlet init parameter messageBrokerId. If no messageBrokerId is supplied, pass
- * in a null value for the id parameter.
- *
- * In case null is passed, the method tries to lookup the broker from current FlexContext.
- * If not available, it uses default ID to lookup the message broker.
- *
- * @param id The id of the message broker to retrieve.
- * @return The <code>MessageBroker</code> for the supplied id.
- */
- public static MessageBroker getMessageBroker(String id)
- {
- if (id == null)
- {
- // If available, return the broker from FlexContext
- MessageBroker broker = FlexContext.getMessageBroker();
- if (broker != null)
- {
- return broker;
- }
-
- id = DEFAULT_BROKER_ID;
- }
-
- return messageBrokers.get(id);
- }
-
- /**
- * Start the message broker's endpoints and services.
- * @exclude
- */
- @Override public void start()
- {
- if (isStarted())
- return;
-
- /*
- * J2EE can be a real pain in terms of getting the right class loader so dump out
- * some detailed info about what is going on.
- */
- if (Log.isDebug())
- {
- StringBuffer sb = new StringBuffer(100);
- if (classLoader == MessageBroker.class.getClassLoader())
- sb.append(" the MessageBroker's class loader");
- if (classLoader == Thread.currentThread().getContextClassLoader())
- {
- if (sb.length() > 0) sb.append(" and");
- sb.append(" the context class loader");
- }
- if (sb.length() == 0)
- sb.append(" not the context or the message broker's class loader");
- Log.getLogger(LogCategories.CONFIGURATION).debug(
- "MessageBroker id: " + getId() + " classLoader is:" +
- sb.toString() + " (" + "classLoader " + ClassUtil.classLoaderToString(classLoader));
- }
-
- // Catch any startup errors and log using our log machinery, then rethrow to trigger shutdown.
- try
- {
- // MessageBroker doesn't call super.start() because it doesn't need the
- // usual validation that other components need
- setStarted(true);
-
- registerMessageBroker();
- if (flexClientManager == null)
- {
- flexClientManager = new FlexClientManager(isManaged(), this);
- }
- flexClientManager.start();
- flexSessionManager = new FlexSessionManager(isManaged(), this);
- flexSessionManager.start();
- if (systemSettings == null)
- {
- systemSettings = new SystemSettings();
- }
- startServices();
- loginManager.start();
- startEndpoints();
- startServers();
- redeployManager.start();
- }
- catch (Exception e)
- {
- if (Log.isError())
- Log.getLogger(LogCategories.CONFIGURATION).error("MessageBroker failed to start: " + ExceptionUtil.exceptionFollowedByRootCausesToString(e));
-
- // Rethrow.
- throw new RuntimeException(e.getMessage(), e);
- }
- }
-
- /**
- * Stop the broker's endpoints, clusters, and services.
- * @exclude
- */
- @Override public void stop()
- {
- if (!isStarted())
- return;
-
- if (Log.isDebug())
- Log.getLogger(LogCategories.CONFIGURATION).debug("MessageBroker stopping: " + getId());
-
- serviceValidationListeners.clear();
-
- flexSessionManager.stop();
- flexClientManager.stop();
- stopServers();
- stopEndpoints();
-
- // set this MB in FlexContext as it is needed for reference counts in destination stopping
- FlexContext.setThreadLocalMessageBroker(this);
- stopServices();
- FlexContext.setThreadLocalMessageBroker(null);
-
- if (loginManager != null)
- loginManager.stop();
- try
- {
- if (redeployManager != null)
- redeployManager.stop();
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- }
- clusterManager.destroyClusters();
-
- super.stop();
- unRegisterMessageBroker();
-
- // clear static proxy caches
- BeanProxy.clear();
- PropertyProxyRegistry.release();
-
- // clear system settings
- systemSettings.clear();
- systemSettings = null;
-
- if (Log.isDebug())
- Log.getLogger(LogCategories.CONFIGURATION).debug("MessageBroker stopped: " + getId());
- }
-
- /**
- * Returns an <tt>Iterator</tt> containing the current names that attributes have been bound
- * to the <tt>MessageBroker</tt> under.
- * Use {@link #getAttribute(String)} to retrieve an attribute value.
- *
- * @return An iterator containing the current names of the attributes.
- */
- public Iterator<String> getAttributeNames()
- {
- return attributes.keySet().iterator();
- }
-
- /**
- * Returns the attribute value bound to the <tt>MessageBroker</tt> under the provided name.
- *
- * @param name The attribute name.
- * @return Object the attribute object
- */
- public Object getAttribute(String name)
- {
- return attributes.get(name);
- }
-
- /**
- * Binds an attribute value to the <tt>MessageBroker</tt> under the provided name.
- *
- * @param name The attribute name.
- * @param value The attribute value.
- */
- public void setAttribute(String name, Object value)
- {
- if (value == null)
- removeAttribute(name);
- else
- attributes.put(name, value);
- }
-
- /**
- * Removes the attribute with the given name from the <tt>MessageBroker</tt>.
- *
- * @param name The attribute name.
- */
- public void removeAttribute(String name)
- {
- attributes.remove(name);
- }
-
- /**
- * Returns the deserialization validator of the <tt>MessageBroker</tt> or null
- * if none exists.
- *
- * @return The deserialization validator of the <tt>MessageBroker</tt> or null
- * if none exists.
- */
- public DeserializationValidator getDeserializationValidator()
- {
- return deserializationValidator;
- }
-
- /**
- * Sets the deserialization validator of the <tt>MessageBroker</tt>.
- *
- * @param deserializationValidator The deserialization validator.
- */
- public void setDeserializationValidator(DeserializationValidator deserializationValidator)
- {
- this.deserializationValidator = deserializationValidator;
- }
-
- public void setExternalPathResolver(PathResolver externalPathResolver)
- {
- this.externalPathResolver = externalPathResolver;
- }
-
- /** @exclude */
- public void setInternalPathResolver(InternalPathResolver internalPathResolver)
- {
- this.internalPathResolver = internalPathResolver;
- }
-
- /** @exclude */
- public InputStream resolveExternalPath(String filename) throws IOException
- {
- return externalPathResolver.resolve(filename);
- }
-
- /** @exclude */
- public InputStream resolveInternalPath(String filename) throws IOException
- {
- return internalPathResolver.resolve(filename);
- }
-
- /** @exclude */
- public interface PathResolver
- {
- InputStream resolve(String filename) throws IOException;
- }
-
- /**
- * This interface is being kept for backwards compatibility.
- * @exclude
- */
- public interface InternalPathResolver extends PathResolver
- {
- // No-op.
- }
-
- /** @exclude */
- public ClusterManager getClusterManager()
- {
- return clusterManager;
- }
-
- /**
- * @exclude
- * Add a <code>Server</code> to the broker's collection.
- *
- * @param server <code>Server</code> to be added.
- */
- public void addServer(Server server)
- {
- if (server == null)
- {
- // Cannot add null ''{0}'' to the ''{1}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.NULL_COMPONENT, new Object[]{"Server", MESSAGEBROKER});
- throw ex;
- }
-
- String id = server.getId();
-
- if (id == null)
- {
- // Cannot add ''{0}'' with null id to the ''{1}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.NULL_COMPONENT_ID, new Object[]{"Server", MESSAGEBROKER});
- throw ex;
- }
-
- // No need to add if server is already added
- Server currentServer = getServer(id);
- if (currentServer == server)
- return;
-
- // Do not allow servers with the same id
- if (currentServer != null)
- {
- // Cannot add a ''{0}'' with the id ''{1}'' that is already registered with the ''{2}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.DUPLICATE_COMPONENT_ID, new Object[]{"Server", id, MESSAGEBROKER});
- throw ex;
- }
-
- servers.put(id, server);
- }
-
- /**
- * @exclude
- * Returns the <code>Server</code> with the specified id.
- *
- * @param id The id of the <code>Server</code>/
- * @return The <code>Server</code> with the specified id or null if no
- * <code>Server</code> with the id exists.
- */
- public Server getServer(String id)
- {
- return servers.get(id);
- }
-
- /**
- * @exclude
- * Stops and removes the <code>Server</code> from the set of shared servers managed by the <code>MessageBroker</code>.
- *
- * @param id The id of the <code>Server</code> to remove.
- * @return <code>Server</code> that has been removed or <code>null</code> if it doesn't exist.
- */
- public Server removeServer(String id)
- {
- Server server = servers.get(id);
- if (server != null)
- {
- server.stop();
- servers.remove(id);
- }
- return server;
- }
-
- /**
- * @exclude
- * Creates an <code>Endpoint</code> instance, sets its id and url.
- * It further sets the endpoint manageable if the <code>MessageBroker</code>
- * is manageable, and assigns its <code>MessageBroker</code> to the
- * <code>MessageBroker</code> that created it.
- *
- * @param id The id of the endpoint.
- * @param url The url of the endpoint.
- * @param className The class name of the endpoint.
- *
- * @return The created <code>Endpoint</code> instance.
- */
- public Endpoint createEndpoint(String id, String url, String className)
- {
- Class endpointClass = ClassUtil.createClass(className, getClassLoader());
-
- Endpoint endpoint = (Endpoint)ClassUtil.createDefaultInstance(endpointClass, Endpoint.class);
- endpoint.setId(id);
- endpoint.setUrl(url);
- endpoint.setManaged(isManaged());
- endpoint.setMessageBroker(this);
-
- return endpoint;
- }
-
- /**
- * @exclude
- * Add an endpoint to the broker's collection. Broker will accept the endpoint
- * to be added only if the endpoint is not null, it does not have null id or
- * url, and it does not have the same id or url as another endpoint.
- *
- * @param endpoint Endpoint to be added.
- */
- public void addEndpoint(Endpoint endpoint)
- {
- if (endpoint == null)
- {
- // Cannot add null ''{0}'' to the ''{1}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.NULL_COMPONENT, new Object[]{ENDPOINT, MESSAGEBROKER});
- throw ex;
- }
-
- String id = endpoint.getId();
-
- if (id == null)
- {
- // Cannot add ''{0}'' with null id to the ''{1}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.NULL_COMPONENT_ID, new Object[]{ENDPOINT, MESSAGEBROKER});
- throw ex;
- }
-
- // No need to add if endpoint is already added
- if (getEndpoint(id) == endpoint)
- return;
-
- // Do not allow endpoints with the same id
- if (getEndpoint(id) != null)
- {
- // Cannot add a ''{0}'' with the id ''{1}'' that is already registered with the ''{2}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.DUPLICATE_COMPONENT_ID, new Object[]{ENDPOINT, id, MESSAGEBROKER});
- throw ex;
- }
-
- // Add the endpoint only if its url is not null and it is not registered
- // by another channel
- checkEndpointUrl(id, endpoint.getUrl());
-
- // Finally add the endpoint to endpoints map
- endpoints.put(id, endpoint);
- }
-
- /**
- * @exclude
- * Returns the <code>Endpoint</code> with the specified id.
- *
- * @param id The id of the <code>Endpoint</code>/
- * @return The <code>Endpoint</code> with the specified id or null if no
- * <code>Endpoint</code> with the id exists.
- */
- public Endpoint getEndpoint(String id)
- {
- return endpoints.get(id);
- }
-
- /**
- * @exclude
- * Retrieve the map of all endpoints in this broker.
- */
- public Map<String, Endpoint> getEndpoints()
- {
- return endpoints;
- }
-
- /**
- * @exclude
- * Retrieve an endpoint based on a requested URL path. Two endpoints should not be
- * registered to the same path.
- */
- public Endpoint getEndpoint(String path, String contextPath)
- {
- for (String id : endpoints.keySet())
- {
- Endpoint e = endpoints.get(id);
-
- if (matchEndpoint(path, contextPath, e))
- {
- return e;
- }
- }
- MessageException lme = new MessageException();
- lme.setMessage(10003, new Object[] {path});
- throw lme;
- }
-
- /**
- * @exclude
- * Removes an endpoint from the <code>MessageBroker</code>.
- *
- * @param id The id of the endpoint.
- * @return The removed endpoint.
- */
- public Endpoint removeEndpoint(String id)
- {
- Endpoint endpoint = getEndpoint(id);
- if (endpoint != null)
- {
- endpoint.stop();
- endpoints.remove(id);
- }
- return endpoint;
- }
-
- /**
- * Returns whether the endpoint validation is enforced on the server, regardless
- * of whether client requested endpoint validation or not.
- *
- * @return True if the endpoint validation is enforced on the server, regardless
- * of whether client requested endpoint validation or not.
- */
- public boolean isEnforceEndpointValidation()
- {
- return enforceEndpointValidation;
- }
-
- /**
- * Sets whether the endpoint validation is enforced on the server, regardless
- * of whether client requested endpoint validation or not.
- *
- * @param enforceEndpointValidation The endpoint validation flag.
- */
- public void setEnforceEndpointValidation(boolean enforceEndpointValidation)
- {
- this.enforceEndpointValidation = enforceEndpointValidation;
- }
-
- /**
- * Returns the <code>FlexFactory</code> with the specified id.
- *
- * @param id The id of the <code>FlexFactory</code>.
- * @return The <code>FlexFactory</code> with the specified id or null if no
- * factory with the id exists.
- */
- public FlexFactory getFactory(String id)
- {
- return factories.get(id);
- }
-
- /**
- * Returns the map of <code>FlexFactory</code> instances.
- *
- * @return The map of <code>FlexFactory</code> instances.
- */
- public Map<String, FlexFactory> getFactories()
- {
- return factories;
- }
-
- /**
- * Registers a factory with the <code>MessageBroker</code>.
- *
- * @param id The id of the factory.
- * @param factory <code>FlexFactory</code> instance.
- */
- public void addFactory(String id, FlexFactory factory)
- {
- if (id == null)
- {
- // Cannot add ''{0}'' with null id to the ''{1}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.NULL_COMPONENT_ID, new Object[]{"FlexFactory", MESSAGEBROKER});
- throw ex;
- }
- // No need to add if factory is already added
- if (getFactory(id) == factory)
- {
- return;
- }
- // Do not allow multiple factories with the same id
- if (getFactory(id) != null)
- {
- // Cannot add a ''{0}'' with the id ''{1}'' that is already registered with the ''{2}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.DUPLICATE_COMPONENT_ID, new Object[]{"FlexFactory", id, MESSAGEBROKER});
- throw ex;
- }
- factories.put(id, factory);
- }
-
- /**
- * Removes the <code>FlexFactory</code> from the list of factories known
- * by the <code>MessageBroker</code>.
- *
- * @param id The id of the <code>FlexFactory</code>.
- * @return <code>FlexFactory</code> that has been removed.
- */
- public FlexFactory removeFactory(String id)
- {
- FlexFactory factory = getFactory(id);
- if (factory != null)
- {
- factories.remove(id);
- }
- return factory;
- }
-
- /**
- * Returns the <code>Service</code> with the specified id.
- *
- * @param id The id of the <code>Service</code>/
- * @return The <code>Service</code> with the specified id or null if no
- * <code>Service</code> with the id exists.
- */
- public Service getService(String id)
- {
- return services.get(id);
- }
-
- /**
- * Return a service of the specific type.
- * The current list of services is searched for the specified class name.
- * If there is no service of the specified type, null is returned.
- * If there is more than one service of the same type it is undefined which instance is returned.
- * If more than one service of a specific type is configured,
- * callers should use {@link #getService(String)} and provide the service id of the specific service,
- * or {@link #getServices()} to get access to the map of all registered services.
- *
- * @param type the fully qualified class name of the service implementation.
- * @return a service or null if not found.
- */
- public Service getServiceByType(String type)
- {
- for (Service svc : services.values())
- {
- if (svc.getClass().getName().equals(type))
- {
- return svc;
- }
- }
- return null;
- }
-
- /**
- * Returns the Map of <code>Service</code> instances.
- *
- * @return The Map of <code>Service</code> instances.
- */
- public Map<String, Service> getServices()
- {
- return services;
- }
-
- /**
- * Returns a <tt>ConfigMap</tt> of service and channel properties that the client
- * needs.
- *
- * @param endpoint Endpoint used to filter the destinations of the service;
- * no filtering is done if the endpoint is null.
- * @return ConfigMap of server properties.
- */
- public ConfigMap describeServices(Endpoint endpoint)
- {
- return describeServices(endpoint, true);
- }
-
- /**
- * @exclude
- * Returns a <tt>ConfigMap</tt> of service and channel properties that the client
- * needs.
- * The <tt>allDestinations</tt> flag controls whether configuration for all
- * destinations or only reliable client destinations is returned.
- *
- * @param endpoint Endpoint used to filter the destinations of the service.
- * No filtering is done if the endpoint is null.
- * @param onlyReliable When false, configuration for all destinations is
- * returned instead of only reliable destinations.
- * @return ConfigMap of service properties.
- */
- public ConfigMap describeServices(Endpoint endpoint, boolean onlyReliable)
- {
- // Let the service validation listeners know about the configuration change.
- if (!serviceValidationListeners.isEmpty())
- {
- for (Enumeration<ServiceValidationListener> iter = serviceValidationListeners.elements(); iter.hasMoreElements();)
- iter.nextElement().validateServices();
- }
-
- ConfigMap servicesConfig = new ConfigMap();
-
- // Keep track of channel ids as we encounter them so we can generate
- // the channel properties that might be needed by the client.
- ArrayList<String> channelIds = new ArrayList<String>();
- if (endpoint == null)
- {
- for (Endpoint endpointToAdd: getEndpoints().values())
- channelIds.add(endpointToAdd.getId());
- }
- else
- {
- channelIds.add(endpoint.getId());
- }
-
- if (defaultChannels != null)
- {
- ConfigMap defaultChannelsMap = new ConfigMap();
- for (Object defaultChannel : defaultChannels)
- {
- String id = (String) defaultChannel;
- ConfigMap channelConfig = new ConfigMap();
- channelConfig.addProperty(ConfigurationConstants.REF_ATTR, id);
- defaultChannelsMap.addProperty(ConfigurationConstants.CHANNEL_ELEMENT, channelConfig);
- if (!channelIds.contains(id))
- channelIds.add(id);
- }
- if (defaultChannelsMap.size() > 0)
- servicesConfig.addProperty(ConfigurationConstants.DEFAULT_CHANNELS_ELEMENT, defaultChannelsMap);
- }
-
- for (Service service : services.values())
- {
- ConfigMap serviceConfig = service instanceof AbstractService?
- ((AbstractService)service).describeService(endpoint, onlyReliable) : service.describeService(endpoint);
- if (serviceConfig != null && serviceConfig.size() > 0)
- servicesConfig.addProperty(ConfigurationConstants.SERVICE_ELEMENT, serviceConfig);
- }
-
- // Need to send channel properties again in case the client didn't
- // compile in services-config.xml and hence doesn't have channels section
- // of the configuration - but only if channel/endpoint is not tagged as "remote"!
- ConfigMap channels = new ConfigMap();
- for (String id : channelIds)
- {
- Endpoint currentEndpoint = getEndpoint(id);
- if (currentEndpoint instanceof AbstractEndpoint && ((AbstractEndpoint)currentEndpoint).isRemote())
- {
- continue; // Client already has configuration for "remote" endpoint by other means.
- }
-
- ConfigMap channel = currentEndpoint.describeEndpoint();
- if (channel != null && channel.size() > 0)
- channels.addProperty(ConfigurationConstants.CHANNEL_ELEMENT, channel);
- }
- if (channels.size() > 0)
- servicesConfig.addProperty(ConfigurationConstants.CHANNELS_ELEMENT, channels);
-
- if (Log.isDebug())
- Log.getLogger(ConfigurationManager.LOG_CATEGORY).debug(
- "Returning service description for endpoint: " +
- (endpoint == null? "all" : endpoint.getId()) + " config: " + servicesConfig);
-
- return servicesConfig;
- }
-
- /**
- * Add a listener for the describeServices callback. The describeServices listener
- * is called before any execution of the describeServices method.
- *
- * @param id Identifier of the listener to add
- * @param listener The listener callback
- */
- public void addServiceValidationListener(String id, ServiceValidationListener listener)
- {
- if (listener != null)
- {
- serviceValidationListeners.putIfAbsent(id, listener);
- }
- }
-
- /**
- * Returns an <tt>Iterator</tt> for all <tt>ServiceValidationListeners</tt> currently
- * registered with the broker.
- *
- * @return An <tt>Iterator</tt> for all registered <tt>ServiceValidationListeners</tt>.
- */
- public Iterator<ServiceValidationListener> getServiceValidationListenerIterator()
- {
- return serviceValidationListeners.values().iterator();
- }
-
- /**
- * Remove a listener from the describeServices callback.
- *
- * @param id Identifier of the listener to remove
- */
- public void removeServiceValidationListener(String id)
- {
- if (serviceValidationListeners.containsKey(id))
- {
- serviceValidationListeners.remove(id);
- }
- }
-
- /**
- * Creates a <code>Service</code> instance, sets its id, sets it manageable
- * if the <code>MessageBroker</code> that created it is manageable,
- * and sets its <code>MessageBroker</code> to the <code>MessageBroker</code> that
- * created it.
- *
- * @param id The id of the <code>Service</code>.
- * @param className The class name of the <code>Service</code>.
- *
- * @return The <code>Service</code> instanced created.
- */
- public Service createService(String id, String className)
- {
- Class svcClass = ClassUtil.createClass(className, getClassLoader());
-
- Service service = (Service)ClassUtil.createDefaultInstance(svcClass, Service.class);
- service.setId(id);
- service.setManaged(isManaged());
- service.setMessageBroker(this);
-
- return service;
- }
-
- /**
- * Add a message type -to- service mapping to the broker's collection.
- * When the broker attempts to route a message to a service, it finds the first
- * service capable of handling the message type.
- *
- * Note that <code>Service</code> cannot be null, it cannot have a null
- * id, and it cannot have the same id or type of a <code>Service</code>
- * already registered with the <code>MessageBroker</code>.
- *
- * <code>Service</code> needs to be started if the <code>MessageBroker</code>
- * is already running.
- *
- * @param service The service instance used to handle the messages
- *
- */
- public void addService(Service service)
- {
- if (service == null)
- {
- // Cannot add null ''{0}'' to the ''{1}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.NULL_COMPONENT, new Object[]{SERVICE, MESSAGEBROKER});
- throw ex;
- }
-
- String id = service.getId();
-
- if (id == null)
- {
- // Cannot add ''{0}'' with null id to the ''{1}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.NULL_COMPONENT_ID, new Object[]{SERVICE, MESSAGEBROKER});
- throw ex;
- }
- // No need to add if service is already added
- if (getService(id) == service)
- {
- return;
- }
- // Do not allow multiple services with the same id
- if (getService(id) != null)
- {
- // Cannot add a ''{0}'' with the id ''{1}'' that is already registered with the ''{2}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.DUPLICATE_COMPONENT_ID, new Object[]{SERVICE, id, MESSAGEBROKER});
- throw ex;
- }
- // Not supposed to have multiple services of the same type; warn about it
- // but still allow it.
- String type = service.getClass().getName();
- if (getServiceByType(type) != null && Log.isWarn())
- Log.getLogger(LOG_CATEGORY).warn("Adding a service type '{0}' that is already registered with the MessageBroker",
- new Object[]{type});
-
-
- services.put(id, service);
-
- if (service.getMessageBroker() == null || service.getMessageBroker() != this)
- {
- service.setMessageBroker(this);
- }
- }
-
- /**
- * Removes the <code>Service</code> from the list of services known
- * by the <code>MessageBroker</code>.
- *
- * @param id The id of the <code>Service</code>.
- * @return Previous <code>Service</code> associated with the id.
- */
- public Service removeService(String id)
- {
- Service service = getService(id);
- if (service != null)
- {
- service.stop();
- services.remove(id);
- }
- return service;
- }
-
- /**
- * Returns the logger of the <code>MessageBroker</code>.
- *
- * @return Logger of the <code>MessageBroker</code>.
- */
- public Log getLog()
- {
- return log;
- }
-
- /** @exclude */
- public LogManager getLogManager()
- {
- return logManager;
- }
-
- /** @exclude */
- public LoginManager getLoginManager()
- {
- return loginManager;
- }
-
- /** @exclude */
- public void setLoginManager(LoginManager loginManager)
- {
- if (this.loginManager != null && this.loginManager.isStarted())
- this.loginManager.stop();
-
- this.loginManager = loginManager;
-
- if (isStarted())
- loginManager.start();
- }
-
- /** @exclude */
- public FlexClientManager getFlexClientManager()
- {
- return flexClientManager;
- }
-
- /** @exclude */
- public void setFlexClientManager(FlexClientManager value)
- {
- flexClientManager = value;
- }
-
- /** @exclude */
- public FlexSessionManager getFlexSessionManager()
- {
- return flexSessionManager;
- }
-
- /** @exclude */
- public void setFlexSessionManager(FlexSessionManager value)
- {
- flexSessionManager = value;
- }
-
- /** @exclude **/
- public RedeployManager getRedeployManager()
- {
- return redeployManager;
- }
-
- /** @exclude */
- public void setRedeployManager(RedeployManager redeployManager)
- {
- if (this.redeployManager != null && this.redeployManager.isStarted())
- this.redeployManager.stop();
-
- this.redeployManager = redeployManager;
-
- if (isStarted())
- redeployManager.start();
- }
-
- /** @exclude */
- public Class<? extends ThrottleManager> getThrottleManagerClass()
- {
- return throttleManagerClass;
- }
-
- /** @exclude */
- public void setThrottleManagerClass(Class<? extends ThrottleManager> throttleManagerClass)
- {
- this.throttleManagerClass = throttleManagerClass;
- }
-
- /**
- * Returns a UUID either from the UUID generator assigned to <tt>MessageBroker</tt>,
- * or from the <tt>UUIDUtils#createUUID</tt> if there is no assigned UUID generator.
- *
- * @return String the UUID.
- */
- public String createUUID()
- {
- return uuidGenerator != null? uuidGenerator.createUUID() : UUIDUtils.createUUID();
- }
-
- /**
- * Returns the custom <tt>UUIDGenerator</tt> used by the <tt>MessageBroker</tt>
- * for NIO-HTTP session cookie value and <tt>FlexClient</tt> id generation or null if
- * the default UUID generator, <tt>UUIDUtils</tt>, is being used.
- *
- * @return The custom <tt>UUIDGenerator</tt> used by <tt>MessageBroker</tt> or null.
- */
- public UUIDGenerator getUUIDGenerator()
- {
- return uuidGenerator;
- }
-
-
- /**
- * Sets the custom <tt>UUIDGenerator</tt> used by the <tt>MessageBroker</tt>
- * for NIO-HTTP session cookie value and <tt>FlexClient</tt> id generation.
- *
- * @param value The custom <tt>UUIDGenerator</tt>.
- */
- public void setUUIDGenerator(UUIDGenerator value)
- {
- uuidGenerator = value;
- }
-
- /**
- * Returns the list of channel ids known to the <code>MessageBroker</code>.
- *
- * @return The list of channel ids.
- */
- public List<String> getChannelIds()
- {
- return (endpoints != null && endpoints.size() != 0)? new ArrayList<String>(endpoints.keySet()) : null;
- }
-
- /** @exclude */
- public ChannelSettings getChannelSettings(String ref)
- {
- return channelSettings.get(ref);
- }
-
- /** @exclude */
- public Map<String, ChannelSettings> getAllChannelSettings()
- {
- return channelSettings;
- }
-
- /** @exclude */
- public void setChannelSettings(Map<String, ChannelSettings> channelSettings)
- {
- this.channelSettings = channelSettings;
- }
-
- /**
- * Returns the default channel ids of the MessageBroker. If a service
- * specifies its own list of channels it overrides these defaults.
- *
- * @return Default channel ids of the MessageBroker.
- */
- public List<String> getDefaultChannels()
- {
- return defaultChannels;
- }
-
- /**
- * Adds the channel id to the list of default channel ids.
- *
- * @param id The id of the channel to add to the list of default channel ids.
- */
- public void addDefaultChannel(String id)
- {
- if (defaultChannels == null)
- defaultChannels = new ArrayList<String>();
- else if (defaultChannels.contains(id))
- return;
-
- List<String> channelIds = getChannelIds();
- if (channelIds == null || !channelIds.contains(id))
- {
- // No channel with id ''{0}'' is known by the MessageBroker.
- if (Log.isWarn())
- {
- Log.getLogger(LOG_CATEGORY).warn("No channel with id '{0}' is known by the MessageBroker." +
- " Not adding the channel.",
- new Object[]{id});
- }
- return;
- }
- defaultChannels.add(id);
- }
-
- /**
- * Sets the default channel ids of the MessageBroker.
- *
- * @param ids Default channel ids of the MessageBroker.
- */
- public void setDefaultChannels(List<String> ids)
- {
- if (ids != null)
- {
- List<String> channelIds = getChannelIds();
- for (Iterator<String> iter = ids.iterator(); iter.hasNext();)
- {
- String id = iter.next();
- if (channelIds == null || !channelIds.contains(id))
- {
- iter.remove();
- if (Log.isWarn())
- {
- Log.getLogger(LOG_CATEGORY).warn("No channel with id '{0}' is known by the MessageBroker." +
- " Not adding the channel.",
- new Object[]{id});
- }
- }
- }
- }
- defaultChannels = ids;
- }
-
- /**
- * Removes the channel id from the list of default channel ids.
- *
- * @param id The id of the channel to remove from the list of default channel ids.
- * @return <code>true</code> if the list contained the channel id.
- */
- public boolean removeDefaultChannel(String id)
- {
- return defaultChannels != null && defaultChannels.remove(id);
- }
-
- /**
- * Returns the <code>SecurityConstraint</code> with the indicated
- * reference id.
- *
- * @param ref The reference of the <code>SecurityConstraint</code>
- * @return The <code>SecurityConstraint</code> with the indicated reference id.
- */
- public SecurityConstraint getSecurityConstraint(String ref)
- {
- return getSecuritySettings().getConstraint(ref);
- }
-
- /** @exclude */
- public ServletContext getServletContext()
- {
- return servletContext;
- }
-
- /** @exclude */
- public SecuritySettings getSecuritySettings()
- {
- return securitySettings;
- }
-
- /** @exclude */
- public void setSecuritySettings(SecuritySettings securitySettings)
- {
- this.securitySettings = securitySettings;
- }
-
- /** @exclude */
- public SystemSettings getSystemSettings()
- {
- return systemSettings;
- }
-
- /** @exclude */
- public void setSystemSettings(SystemSettings l)
- {
- systemSettings = l;
- }
-
- /** @exclude */
- public FlexClientSettings getFlexClientSettings()
- {
- return flexClientSettings;
- }
-
- /** @exclude */
- public void setFlexClientSettings(FlexClientSettings value)
- {
- flexClientSettings = value;
- }
-
- /** @exclude */
- public void initThreadLocals()
- {
- // No thread-locals anymore, so no-op.
- }
-
- /**
- * You can call this method in order to send a message from your code into
- * the message routing system. The message is routed to a service that
- * is defined to handle messages of this type. Once the service is identified,
- * the destination property of the message is used to find a destination
- * configured for that service. The adapter defined for that destination
- * is used to handle the message.
- *
- * @param message The message to be routed to a service
- * @param endpoint This can identify the endpoint that is sending the message
- * but it is currently not used so you may pass in null.
- * @return <code>AcknowledgeMessage</code> with result.
- */
- public AcknowledgeMessage routeMessageToService(Message message, Endpoint endpoint)
- {
- // Make sure message has a messageId
- checkMessageId(message);
-
- Object serviceResult = null;
- boolean serviced = false;
- Service service = null;
- String destId = message.getDestination();
- try
- {
- String serviceId = destId != null ? destinationToService.get(destId) : null;
-
- if ((serviceId == null) && (destId != null) && (!serviceValidationListeners.isEmpty()))
- {
- for (Enumeration<ServiceValidationListener> iter = serviceValidationListeners.elements(); iter.hasMoreElements();)
- {
- iter.nextElement().validateDestination(destId);
- }
- serviceId = destinationToService.get(destId);
- }
-
- if (serviceId != null)
- {
- service = services.get(serviceId);
- serviced = true;
- Destination destination = service.getDestination(destId);
- inspectOperation(message, destination);
- // Remove the validate endpoint header if it was set.
- if (message.headerExists(Message.VALIDATE_ENDPOINT_HEADER))
- message.getHeaders().remove(Message.VALIDATE_ENDPOINT_HEADER);
-
- if (Log.isDebug())
- Log.getLogger(getLogCategory(message)).debug(
- "Before invoke service: " + service.getId() + StringUtils.NEWLINE +
- " incomingMessage: " + message + StringUtils.NEWLINE);
-
- extractRemoteCredentials(service, message);
- serviceResult = service.serviceMessage(message);
- }
-
- if (!serviced)
- {
- MessageException lme = new MessageException();
- // The supplied destination id is not registered with any service.
- lme.setMessage(ERR_MSG_NO_SERVICE_FOR_DEST);
- throw lme;
- }
-
- if (Log.isDebug())
- {
- String debugServiceResult = Log.getPrettyPrinter().prettify(serviceResult);
- Log.getLogger(getLogCategory(message)).debug(
- "After invoke service: " + service.getId() + StringUtils.NEWLINE +
- " reply: " + debugServiceResult + StringUtils.NEWLINE);
- }
-
- AcknowledgeMessage ack;
- if (serviceResult instanceof AcknowledgeMessage)
- {
- // service will return an ack if they need to transform it in some
- // service-specific way (paging is an example)
- ack = (AcknowledgeMessage)serviceResult;
- }
- else
- {
- // most services will return a result of some sort, possibly null,
- // and expect the broker to compose a message to deliver it
- ack = new AcknowledgeMessage();
- ack.setBody(serviceResult);
- }
- ack.setCorrelationId(message.getMessageId());
- ack.setClientId(message.getClientId());
- return ack;
- }
- catch (MessageException exc)
- {
- exc.logAtHingePoint(message,
- null, /* No outbound error message at this point. */
- "Exception when invoking service '" + (service == null ? "(none)" : service.getId()) + "': ");
-
- throw exc;
- }
- catch (RuntimeException exc)
- {
- Log.getLogger(LogCategories.MESSAGE_GENERAL).error(
- "Exception when invoking service: " +
- (service == null ? "(none)" : service.getId()) +
- StringUtils.NEWLINE +
- " with message: " + message + StringUtils.NEWLINE +
- ExceptionUtil.exceptionFollowedByRootCausesToString(exc) + StringUtils.NEWLINE);
-
- throw exc;
- }
- catch (Error exc)
- {
- Log.getLogger(LogCategories.MESSAGE_GENERAL).error(
- "Error when invoking service: " +
- (service == null ? "(none)" : service.getId()) +
- StringUtils.NEWLINE +
- " with message: " + message + StringUtils.NEWLINE +
- ExceptionUtil.exceptionFollowedByRootCausesToString(exc) + StringUtils.NEWLINE);
-
- throw exc;
- }
-
- }
-
- /** @exclude */
- public AsyncMessage routeCommandToService(CommandMessage command, Endpoint endpoint)
- {
- // Make sure command has a messageId
- checkMessageId(command);
-
- String destId = command.getDestination();
-
- AsyncMessage replyMessage;
- Service service;
- String serviceId;
- Object commandResult = null;
- boolean serviced = false;
- boolean recreateHttpFlexSessionAfterLogin = false;
-
- // Forward login and logout commands to AuthenticationService
- int operation = command.getOperation();
- if (operation == CommandMessage.LOGIN_OPERATION || operation == CommandMessage.LOGOUT_OPERATION)
- {
- serviceId = AUTHENTICATION_SERVICE_ID;
- recreateHttpFlexSessionAfterLogin = securitySettings.isRecreateHttpSessionAfterLogin()
- && operation == CommandMessage.LOGIN_OPERATION && FlexContext.getFlexSession() instanceof HttpFlexSession;
- }
- else
- {
- serviceId = destId != null? destinationToService.get(destId) : null;
- }
-
- service = serviceId != null? services.get(serviceId) : null;
- if (service != null)
- {
- // Before passing the message to the service, need to check
- // the security constraints.
- Destination destination = service.getDestination(destId);
- if (destination != null)
- inspectOperation(command, destination);
-
- try
- {
- extractRemoteCredentials(service, command);
- commandResult = service.serviceCommand(command);
- serviced = true;
- }
- catch (UnsupportedOperationException e)
- {
- ServiceException se = new ServiceException();
- se.setMessage(ERR_MSG_SERVICE_CMD_NOT_SUPPORTED, new Object[] {service.getClass().getName()});
- throw se;
- }
- catch (SecurityException se)
- {
- // when a LOGIN message causes a security exception, we want to continue processing here
- // to allow metadata to be sent to clients communicating with runtime destinations.
- // The result will be an error message with a login fault message as well as the metadata
- if (AUTHENTICATION_SERVICE_ID.equals(serviceId))
- {
- commandResult = se.createErrorMessage();
- if (Log.isDebug())
- Log.getLogger(LOG_CATEGORY).debug("Security error for message: " +
- se.toString() + StringUtils.NEWLINE +
- " incomingMessage: " + command + StringUtils.NEWLINE +
- " errorReply: " + commandResult);
- serviced = true;
- }
- else
- {
- throw se;
- }
- }
- }
-
- if (recreateHttpFlexSessionAfterLogin)
- recreateHttpFlexSessionAfterLogin();
-
- if (commandResult == null)
- {
- replyMessage = new AcknowledgeMessage();
- }
- else if (commandResult instanceof AsyncMessage)
- {
- replyMessage = (AsyncMessage)commandResult;
- }
- else
- {
- replyMessage = new AcknowledgeMessage();
- replyMessage.setBody(commandResult);
- }
-
- // Update the replyMessage body with server configuration if the
- // operation is ping or login and make sure to return the FlexClient Id value.
- if (command.getOperation() == CommandMessage.CLIENT_PING_OPERATION
- || command.getOperation() == CommandMessage.LOGIN_OPERATION)
- {
- boolean needsConfig = false;
- if (command.getHeader(CommandMessage.NEEDS_CONFIG_HEADER) != null)
- needsConfig = ((Boolean)(command.getHeader(CommandMessage.NEEDS_CONFIG_HEADER)));
-
- // Send configuration information only if the client requested.
- if (needsConfig)
- {
- ConfigMap serverConfig = describeServices(endpoint);
- if (serverConfig.size() > 0)
- replyMessage.setBody(serverConfig);
- }
-
- // Record the features available over this endpoint
- double msgVersion = endpoint.getMessagingVersion();
- if (msgVersion > 0)
- replyMessage.setHeader(CommandMessage.MESSAGING_VERSION, new Double(msgVersion));
-
- // Record the flex client ID
- FlexClient flexClient = FlexContext.getFlexClient();
- if (flexClient != null)
- replyMessage.setHeader(Message.FLEX_CLIENT_ID_HEADER, flexClient.getId());
- }
- else if (!serviced)
- {
- MessageException lme = new MessageException();
- // The supplied destination id is not registered with any service..
- lme.setMessage(ERR_MSG_NO_SERVICE_FOR_DEST);
- throw lme;
- }
-
- replyMessage.setCorrelationId(command.getMessageId());
- replyMessage.setClientId(command.getClientId());
- if (replyMessage.getBody() instanceof java.util.List)
- {
- replyMessage.setBody(((List) replyMessage.getBody()).toArray());
- }
-
- if (Log.isDebug())
- Log.getLogger(getLogCategory(command)).debug(
- "Executed command: " +
- (service == null ? "(default service)" : "service=" +
- service.getId()) + StringUtils.NEWLINE +
- " commandMessage: " + command + StringUtils.NEWLINE +
- " replyMessage: " + replyMessage + StringUtils.NEWLINE);
-
- return replyMessage;
- }
-
- /**
- * Services call this method in order to send a message
- * to a FlexClient.
- *
- * @exclude
- */
- public void routeMessageToMessageClient(Message message, MessageClient messageClient)
- {
- // Make sure message has a messageId
- checkMessageId(message);
-
- // Route the message and the MessageClient (subscription) to the FlexClient to
- // queue the message for delivery to the remote client.
- // Reset the thread local FlexClient and FlexSession to be specific to the client
- // we're pushing to, and then reset the context back to its original request handling state.
- FlexClient requestFlexClient = FlexContext.getFlexClient();
- FlexSession requestFlexSession = FlexContext.getFlexSession();
-
- FlexClient pushFlexClient = messageClient.getFlexClient();
- FlexContext.setThreadLocalFlexClient(pushFlexClient);
- FlexContext.setThreadLocalSession(null); // Null because we don't have a currently active endpoint for the push client.
- try
- {
- pushFlexClient.push(message, messageClient);
- }
- finally // Reset thread locals.
- {
- FlexContext.setThreadLocalFlexClient(requestFlexClient);
- FlexContext.setThreadLocalSession(requestFlexSession);
- }
- }
-
- /**
- * @exclude
- * Check that the destination permits access over the endpoint, the security
- * constraint of the destination permits the operation, and the service and
- * the destination the message is targeting are running,
- *
- * @param message The incoming message.
- * @param destination The destination to check against.
- */
- public void inspectOperation(Message message, Destination destination)
- {
- inspectChannel(message, destination);
- loginManager.checkConstraint(destination.getSecurityConstraint());
-
- Service service = destination.getService();
- if (!service.isStarted())
- {
- // {0} ''{1}'' cannot service message ''{2}'' in stopped state.
- MessageException me = new MessageException();
- me.setMessage(ERR_MSG_CANNOT_SERVICE_STOPPED, new Object[]{SERVICE, service.getId(), message.getMessageId()});
- throw me;
- }
-
- if (!destination.isStarted())
- {
- // {0} ''{1}'' cannot service message ''{2}'' in stopped state.
- MessageException me = new MessageException();
- me.setMessage(ERR_MSG_CANNOT_SERVICE_STOPPED, new Object[]{"Destination", destination.getId(), message.getMessageId()});
- throw me;
- }
- }
-
- /**
- * @exclude
- * Verify that this destination permits access over this endpoint.
- *
- * @param message The incoming message.
- * @param destination The destination to check against.
- */
- public void inspectChannel(Message message, Destination destination)
- {
- if (!enforceEndpointValidation && message.getHeader(Message.VALIDATE_ENDPOINT_HEADER) == null)
- return;
-
- String messageChannel = (String)message.getHeader(Message.ENDPOINT_HEADER);
- for (String channelId : destination.getChannels())
- {
- if (channelId.equals(messageChannel))
- return;
- }
- MessageException lme = new MessageException();
- lme.setMessage(ERR_MSG_DESTINATION_UNACCESSIBLE, new Object[] {destination.getId(), messageChannel});
- throw lme;
- }
-
- /**
- * @exclude
- * Returns the logging category to use for a given message.
- */
- public String getLogCategory(Message message)
- {
- if (message instanceof AbstractMessage)
- return ((AbstractMessage) message).logCategory();
- return LogCategories.MESSAGE_GENERAL;
- }
-
- /**
- * This is the class loader used by the system to load user defined classes.
- *
- * @return <code>ClassLoader</code> the system should use to load user defined classes.
- */
- public ClassLoader getClassLoader()
- {
- return classLoader;
- }
-
- /**
- * @exclude
- * Sets the class loader used by the system to load user defined classes.
- *
- * @param classLoader The class loader used by the system to loader user defiend classes.
- */
- public void setClassLoader(ClassLoader classLoader)
- {
- this.classLoader = classLoader;
- }
-
- /**
- * @exclude
- * Used internally by AbstractService to check existence of destination and service id
- * mapping in the destinationToService map.
- *
- * @return True if the destination is already registered.
- */
- public boolean isDestinationRegistered(String destId, String svcId, boolean throwException)
- {
- // Do not allow multiple destinations with the same id across services
- if (destinationToService.containsKey(destId))
- {
- if (throwException)
- {
- // Cannot add destination with id ''{0}'' to service with id ''{1}'' because another service with id ''{2}'' already has a destination with the same id.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.DUPLICATE_DEST_ID, new Object[]{destId, svcId, destinationToService.get(destId)});
- throw ex;
- }
- return true;
- }
- return false;
- }
-
- /**
- * @exclude
- * Used internally by AbstractService to add destination and service id
- * mapping to destinationToService map.
- *
- * @param destId Destination id.
- * @param svcId Service id.
- */
- public void registerDestination(String destId, String svcId)
- {
- // Do not allow multiple destinations with the same id across services
- if (destinationToService.containsKey(destId))
- {
- // Cannot add destination with id ''{0}'' to service with id ''{1}'' because another service with id ''{2}'' already has a destination with the same id.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ConfigurationConstants.DUPLICATE_DEST_ID, new Object[]{destId, svcId, destinationToService.get(destId)});
- throw ex;
- }
- destinationToService.put(destId, svcId);
- }
-
- /**
- * @exclude
- * Used internally by AbstractService to remove destination and service id
- * mapping from destinationToService map.
- *
- * @param destId Destination id.
- */
- public void unregisterDestination(String destId)
- {
- destinationToService.remove(destId);
- }
-
- /**
- * @exclude
- * Looks up and returns a destination by id; removing the need to know which service
- * a destination is registered for.
- *
- * @param destId Destination id.
- */
- public Destination getRegisteredDestination(String destId)
- {
- String serviceId = destId != null? destinationToService.get(destId) : null;
- return serviceId != null? getService(serviceId).getDestination(destId) : null;
- }
-
- /**
- * Increments the count of destinations actively using an Application or Session
- * level scoped assembler identified by the passed in attributeId.
- *
- * @param attributeId Attribute id for the session or application-scoped object.
- */
- public void incrementAttributeIdRefCount(String attributeId)
- {
- synchronized (attributeIdRefCounts)
- {
- Integer currentCount = attributeIdRefCounts.get(attributeId);
- if (currentCount == null)
- attributeIdRefCounts.put(attributeId, INTEGER_ONE);
- else
- attributeIdRefCounts.put(attributeId, currentCount + 1);
- }
- }
-
- /**
- * Decrements the count of destinations actively using an Application or Session
- * level scoped assembler identified by the passed in attributeId.
- *
- * @param attributeId Attribute id for the session or application-scoped object.
- * @return in the attribute ID ref count after decrement
- */
- public int decrementAttributeIdRefCount(String attributeId)
- {
- synchronized (attributeIdRefCounts)
- {
- Integer currentCount = attributeIdRefCounts.get(attributeId);
- if (currentCount == null)
- return 0;
-
- int newValue = currentCount -1 ;
- attributeIdRefCounts.put(attributeId, newValue);
- return newValue;
- }
- }
-
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * Utility method to make sure that message has an assigned messageId.
- */
- protected void checkMessageId(Message message)
- {
- if (message.getMessageId() == null)
- {
- MessageException lme = new MessageException();
- lme.setMessage(ERR_MSG_NULL_MESSAGE_ID);
- throw lme;
- }
- }
-
- /**
- * @exclude
- * Check the headers for the message for the RemoteCredentials.
- *
- * @param service
- * @param message
- */
- protected void extractRemoteCredentials(Service service, Message message)
- {
- if (!message.headerExists(Message.REMOTE_CREDENTIALS_HEADER))
- return;
-
- boolean setting = false;
- String username = null;
- String credentials = null;
- if (message.getHeader(Message.REMOTE_CREDENTIALS_HEADER) instanceof String)
- {
- String encoded = (String)message.getHeader(Message.REMOTE_CREDENTIALS_HEADER);
- if (encoded.length() > 0) //empty string is clearing the credentials
- {
- setting = true;
- Base64.Decoder decoder = new Base64.Decoder();
- decoder.decode(encoded);
- byte[] decodedBytes = decoder.drain();
- String decoded;
-
- String charset = (String)message.getHeader(Message.REMOTE_CREDENTIALS_CHARSET_HEADER);
- if (charset != null)
- {
- try
- {
- decoded = new String(decodedBytes, charset);
- }
- catch (UnsupportedEncodingException ex)
- {
- MessageException lme = new MessageException();
- lme.setMessage(ERR_MSG_UNKNOWN_REMOTE_CREDENTIALS_FORMAT);
- throw lme;
- }
- }
- else
- {
- decoded = new String(decodedBytes);
- }
-
- int colon = decoded.indexOf(':');
- if (colon > 0 && colon < decoded.length() - 1)
- {
- username = decoded.substring(0, colon);
- credentials = decoded.substring(colon + 1);
- }
- }
- }
- else
- {
- MessageException lme = new MessageException();
- lme.setMessage(ERR_MSG_UNKNOWN_REMOTE_CREDENTIALS_FORMAT);
- throw lme;
- }
-
- if (setting)
- {
- FlexContext.getFlexSession().putRemoteCredentials(
- new FlexRemoteCredentials(service.getId(),
- message.getDestination(), username, credentials));
- }
- else
- {
- FlexContext.getFlexSession().clearRemoteCredentials(service.getId(),
- message.getDestination());
- }
- }
-
- @Override
- protected String getLogCategory()
- {
- return LOG_CATEGORY;
- }
-
- /** @exclude */
- public void setServletContext(ServletContext servletContext)
- {
- this.servletContext = servletContext;
- }
-
- /**
- * @exclude
- * This method was added so that Spring-BlazeDS Integration 1.0.2 works with latest BlazeDS binaries
- * Internally, this method simply invokes the setServletContext(...) method
- */
- protected void setInitServletContext(ServletContext servletContext)
- {
- setServletContext(servletContext);
- }
-
- protected void recreateHttpFlexSessionAfterLogin()
- {
- FlexSession currentHttpFlexSession = FlexContext.getFlexSession();
- Principal principal = currentHttpFlexSession.getUserPrincipal();
- currentHttpFlexSession.invalidate(); // This will recreate a new session.
-
- FlexSession newHttpFlexSession = FlexContext.getFlexSession();
- newHttpFlexSession.setUserPrincipal(principal);
- }
-
- /**
- * Start all of the broker's endpoints.
- *
- * @exclude
- */
- protected void startEndpoints()
- {
- for (Endpoint endpoint : endpoints.values())
- {
- if (endpoint instanceof AbstractEndpoint && ((AbstractEndpoint)endpoint).isRemote())
- continue; // Local representation of remote endpoints are not started.
- endpoint.start();
- }
- }
-
- /**
- * Stop all of the broker's endpoints.
- *
- * @exclude
- */
- protected void stopEndpoints()
- {
- for (Endpoint endpoint : endpoints.values())
- {
- if (endpoint instanceof AbstractEndpoint && ((AbstractEndpoint)endpoint).isRemote())
- continue; // Local representation of remote endpoints are not stopped.
- endpoint.stop();
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- */
- private void checkEndpointUrl(String id, String endpointUrl)
- {
- // Do not allow endpoints with null url property.
- if (endpointUrl == null)
- {
- // Cannot add ''{0}'' with null url to the ''{1}''
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(ERR_MSG_NULL_ENDPOINT_URL, new Object[]{ENDPOINT, MESSAGEBROKER});
- throw ex;
- }
-
- String parsedEndpointURI = ChannelSettings.removeTokens(endpointUrl);
-
- // first check the original URI
- if (registeredEndpoints.containsKey(parsedEndpointURI))
- {
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(ERR_MSG_URI_ALREADY_REGISTERED, new Object[] {id, parsedEndpointURI,
- registeredEndpoints.get(parsedEndpointURI)});
- throw ce;
- }
-
- // add the original URI to the registered endpoints map
- registeredEndpoints.put(parsedEndpointURI, id);
-
- // also need to check the URI without the context root
- int nextSlash = parsedEndpointURI.indexOf('/', 1);
- if (nextSlash > 0)
- {
- String parsedEndpointURI2 = parsedEndpointURI.substring(nextSlash);
- if (registeredEndpoints.containsKey(parsedEndpointURI2))
- {
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(ERR_MSG_URI_ALREADY_REGISTERED, new Object[] {
- parsedEndpointURI2, id,
- registeredEndpoints.get(parsedEndpointURI2) });
- throw ce;
- }
- registeredEndpoints.put(parsedEndpointURI2, id);
- }
- }
-
- /**
- * @exclude
- * Matches the current "servlet + pathinfo" to a list of channels registered
- * in the services configuration file, independent of context root.
- *
- * @param path The Servlet mapping and PathInfo of the current request
- * @param contextPath The web application context root (or empty string for default root)
- * @param endpoint The endpoint to be matched
- * @return whether the current request matches a registered endpoint URI
- *
- */
- private boolean matchEndpoint(String path, String contextPath, Endpoint endpoint)
- {
- boolean match = false;
- String channelEndpoint = endpoint.getParsedUrl(contextPath);
-
- if (path.endsWith("/"))
- {
- path = path.substring(0, path.length() - 1);
- }
-
- if (path.equalsIgnoreCase(channelEndpoint))
- {
- match = true;
- }
-
- return match;
- }
-
- private void registerMessageBroker()
- {
- String mbid = getId();
-
- synchronized (messageBrokers)
- {
- if (messageBrokers.get(mbid) != null)
- {
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(10137, new Object[] {getId() == null ? "(no value supplied)" : mbid});
- throw ce;
- }
- messageBrokers.put(mbid, this);
- }
- }
-
- private void unRegisterMessageBroker()
- {
- String mbid = getId();
-
- synchronized (messageBrokers)
- {
- messageBrokers.remove(mbid);
- }
- }
-
- /**
- * Start all of the broker's shared servers.
- */
- private void startServers()
- {
- for (Server server : servers.values())
- {
- // Validate that the server is actually referenced by an endpoint; if not, warn.
- boolean serverIsReferenced = false;
- for (Endpoint endpoint : endpoints.values())
- {
- if (endpoint instanceof Endpoint2 && server.equals(((Endpoint2)endpoint).getServer()))
- {
- serverIsReferenced = true;
- break;
- }
- }
-
- if (!serverIsReferenced && Log.isWarn())
- Log.getLogger(LogCategories.CONFIGURATION).warn("Server '" + server.getId() + "' is not referenced by any endpoints.");
-
- server.start();
- }
- }
-
- /**
- * Stop all the broker's shared servers.
- */
- private void stopServers()
- {
- for (Server server : servers.values())
- server.stop();
- }
-
- /**
- * Start all of the broker's services.
- *
- * @exclude
- */
- private void startServices()
- {
- for (Service svc : services.values() )
- {
- long timeBeforeStartup = 0;
- if (Log.isDebug())
- {
- timeBeforeStartup = System.currentTimeMillis();
- Log.getLogger(LOG_CATEGORY_STARTUP_SERVICE).debug("Service with id '{0}' is starting.",
- new Object[]{svc.getId()});
- }
-
- svc.start();
-
- if (Log.isDebug())
- {
- long timeAfterStartup = System.currentTimeMillis();
- Long diffMillis = timeAfterStartup - timeBeforeStartup;
- Log.getLogger(LOG_CATEGORY_STARTUP_SERVICE).debug("Service with id '{0}' is ready (startup time: '{1}' ms)",
- new Object[]{svc.getId(), diffMillis});
- }
- }
- }
-
- /**
- * Stop all of the broker's services.
- *
- * @exclude
- */
- private void stopServices()
- {
- for (Service svc : services.values())
- svc.stop();
- }
-}
+/*
+ * 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;
+
+import flex.management.ManageableComponent;
+import flex.management.runtime.messaging.MessageBrokerControl;
+import flex.management.runtime.messaging.log.LogManager;
+import flex.messaging.client.FlexClient;
+import flex.messaging.client.FlexClientManager;
+import flex.messaging.cluster.ClusterManager;
+import flex.messaging.config.ChannelSettings;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.ConfigurationConstants;
+import flex.messaging.config.ConfigurationException;
+import flex.messaging.config.ConfigurationManager;
+import flex.messaging.config.FlexClientSettings;
+import flex.messaging.config.SecurityConstraint;
+import flex.messaging.config.SecuritySettings;
+import flex.messaging.config.SystemSettings;
+import flex.messaging.endpoints.AbstractEndpoint;
+import flex.messaging.endpoints.Endpoint;
+import flex.messaging.endpoints.Endpoint2;
+import flex.messaging.factories.JavaFactory;
+import flex.messaging.io.BeanProxy;
+import flex.messaging.io.PropertyProxyRegistry;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.messages.AbstractMessage;
+import flex.messaging.messages.AcknowledgeMessage;
+import flex.messaging.messages.AsyncMessage;
+import flex.messaging.messages.CommandMessage;
+import flex.messaging.messages.Message;
+import flex.messaging.security.LoginManager;
+import flex.messaging.security.SecurityException;
+import flex.messaging.services.AbstractService;
+import flex.messaging.services.Service;
+import flex.messaging.services.ServiceException;
+import flex.messaging.services.messaging.ThrottleManager;
+import flex.messaging.util.Base64;
+import flex.messaging.util.ClassUtil;
+import flex.messaging.util.ExceptionUtil;
+import flex.messaging.util.RedeployManager;
+import flex.messaging.util.StringUtils;
+import flex.messaging.util.UUIDGenerator;
+import flex.messaging.util.UUIDUtils;
+import flex.messaging.validators.DeserializationValidator;
+
+import javax.servlet.ServletContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * The MessageBroker is the hub of message traffic. It has a number of endpoints which send and
+ * receive messages over the network, and it has a number of
+ * services that are message destinations. The broker routes
+ * decoded messages received by endpoints to services based
+ * on the service destination specified in each message.
+ * The broker also has a means of pushing messages back through
+ * endpoints to clients.
+ */
+public class MessageBroker extends ManageableComponent
+{
+ //--------------------------------------------------------------------------
+ //
+ // Public Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Id that the AuthenticationService uses to register itself with the broker.
+ */
+ public static final String AUTHENTICATION_SERVICE_ID = "authentication-service";
+
+ /**
+ * Localized error messages for <code>MessageBroker</code>.
+ */
+ public static final int ERR_MSG_NO_SERVICE_FOR_DEST = 10004;
+ public static final int ERR_MSG_DESTINATION_UNACCESSIBLE = 10005;
+ public static final int ERR_MSG_UNKNOWN_REMOTE_CREDENTIALS_FORMAT = 10020;
+ public static final int ERR_MSG_NULL_MESSAGE_ID = 10029;
+ public static final int ERR_MSG_CANNOT_SERVICE_STOPPED = 10038;
+ public static final int ERR_MSG_NULL_ENDPOINT_URL = 10128;
+ public static final int ERR_MSG_SERVICE_CMD_NOT_SUPPORTED = 10451;
+ public static final int ERR_MSG_URI_ALREADY_REGISTERED = 11109;
+
+ /**
+ * Log category for <code>MessageBroker</code>.
+ */
+ public static final String LOG_CATEGORY = LogCategories.MESSAGE_GENERAL;
+
+ /**
+ * Log category that captures startup information for broker's destinations.
+ */
+ public static final String LOG_CATEGORY_STARTUP_SERVICE = LogCategories.STARTUP_SERVICE;
+
+ /** @exclude */
+ public static final String TYPE = "MessageBroker";
+
+ //--------------------------------------------------------------------------
+ //
+ // Package Protected Static Constants
+ //
+ //--------------------------------------------------------------------------
+ /** The default message broker id when one is not specified in web.xml. */
+ public static final String DEFAULT_BROKER_ID = "__default__";
+
+ /** A map of currently available message brokers indexed by message broker id. */
+ static final Map<String, MessageBroker> messageBrokers = new HashMap<String, MessageBroker>();
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ private static final String LOG_MANAGER_ID = "log";
+ private static final Integer INTEGER_ONE = 1;
+ private static final String MESSAGEBROKER = "MessageBroker";
+ private static final String ENDPOINT = "Endpoint";
+ private static final String SERVICE = "Service";
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructors
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @exclude
+ * Create a MessageBroker. This constructor will
+ * establish collections for routers, endpoints,
+ * and services.
+ */
+ public MessageBroker()
+ {
+ this(true, null);
+ }
+
+ /** @exclude */
+ public MessageBroker(boolean enableManagement)
+ {
+ this(enableManagement, null);
+ }
+
+ /** @exclude */
+ public MessageBroker(boolean enableManagement, String mbid)
+ {
+ this(enableManagement, mbid, MessageBroker.class.getClassLoader());
+ }
+
+ /** @exclude */
+ public MessageBroker(boolean enableManagement, String mbid, ClassLoader loader)
+ {
+ super(enableManagement);
+ classLoader = loader;
+ attributes = new ConcurrentHashMap<String, Obje
<TRUNCATED>
[04/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/factories/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/factories/package-info.java b/modules/core/src/flex/messaging/factories/package-info.java
old mode 100755
new mode 100644
index b0ff376..3ce0139
--- a/modules/core/src/flex/messaging/factories/package-info.java
+++ b/modules/core/src/flex/messaging/factories/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.factories;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/AbstractProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/AbstractProxy.java b/modules/core/src/flex/messaging/io/AbstractProxy.java
old mode 100755
new mode 100644
index 709611e..6d86da9
--- a/modules/core/src/flex/messaging/io/AbstractProxy.java
+++ b/modules/core/src/flex/messaging/io/AbstractProxy.java
@@ -1,294 +1,294 @@
-/*
- * 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.io;
-
-import java.util.List;
-import java.io.Externalizable;
-import java.io.Serializable;
-
-import flex.messaging.MessageException;
-import flex.messaging.io.amf.ASObject;
-import flex.messaging.log.LogCategories;
-import flex.messaging.log.Log;
-import flex.messaging.log.Logger;
-import flex.messaging.util.ClassUtil;
-
-/**
- * Simple abstract implementation of PropertyProxy's common properties. Specific
- * sub-classes need to provide the full implementation focusing on the retrieval
- * of the instance traits or "list of properties" and a specific value for
- * a given property name.
- *
- * @see flex.messaging.io.PropertyProxy
- * @exclude
- */
-public abstract class AbstractProxy implements PropertyProxy, Serializable
-{
- protected Object defaultInstance;
- protected String alias;
- protected boolean dynamic;
- protected boolean externalizable;
- protected boolean includeReadOnly;
- protected SerializationDescriptor descriptor;
- protected SerializationContext context;
-
- protected static final String LOG_CATEGORY = LogCategories.ENDPOINT_TYPE;
- private static final int CONVERSION_ERROR = 10006;
-
- protected AbstractProxy(Object defaultInstance)
- {
- this.defaultInstance = defaultInstance;
- if (defaultInstance != null)
- alias = defaultInstance.getClass().getName();
- }
-
- /** {@inheritDoc} */
- public Object getDefaultInstance()
- {
- return defaultInstance;
- }
-
- /** {@inheritDoc} */
- public void setDefaultInstance(Object instance)
- {
- defaultInstance = instance;
- }
-
- /**
- * A utility method which returns the Class from the given Class name
- * using the current type context's class loader.
- *
- * @param className the class name.
- * @return a Class object for the named class.
- */
- public static Class getClassFromClassName(String className)
- {
- TypeMarshallingContext typeContext = TypeMarshallingContext.getTypeMarshallingContext();
- return ClassUtil.createClass(className, typeContext.getClassLoader());
- }
-
- /**
- * A utility method which creates an instance from a given class name. It assumes
- * the class has a zero arg constructor.
- * @param className the class name
- * for a type that is missing on the server, instead of throwing a server resource not found
- * exception.
- * @return the instance of the named class.
- */
- public static Object createInstanceFromClassName(String className)
- {
- Class<?> desiredClass = getClassFromClassName(className);
- return ClassUtil.createDefaultInstance(desiredClass, null, true /*validate*/);
- }
-
- /** {@inheritDoc} */
- public Object createInstance(String className)
- {
- Object instance;
-
- if (className == null || className.length() == 0)
- {
- instance = ClassUtil.createDefaultInstance(ASObject.class, null, true /*validate*/);
- }
- else if (className.startsWith(">")) // Handle [RemoteClass] (no server alias)
- {
- instance = ClassUtil.createDefaultInstance(ASObject.class, null, true /*validate*/);
- ((ASObject)instance).setType(className);
- }
- else
- {
- if (getSerializationContext().instantiateTypes || className.startsWith("flex."))
- return createInstanceFromClassName(className);
-
- // Just return type info with an ASObject...
- instance = ClassUtil.createDefaultInstance(ASObject.class, null, true /*validate*/);
- ((ASObject)instance).setType(className);
- }
- return instance;
- }
-
- /** {@inheritDoc} */
- public List getPropertyNames()
- {
- return getPropertyNames(getDefaultInstance());
- }
-
- /** {@inheritDoc} */
- public Class getType(String propertyName)
- {
- return getType(getDefaultInstance(), propertyName);
- }
-
- /** {@inheritDoc} */
- public Object getValue(String propertyName)
- {
- return getValue(getDefaultInstance(), propertyName);
- }
-
- /** {@inheritDoc} */
- public void setValue(String propertyName, Object value)
- {
- setValue(getDefaultInstance(), propertyName, value);
- }
-
- /** {@inheritDoc} */
- public void setAlias(String value)
- {
- alias = value;
- }
-
- /** {@inheritDoc} */
- public String getAlias()
- {
- return alias;
- }
-
- /** {@inheritDoc} */
- public void setDynamic(boolean value)
- {
- dynamic = value;
- }
-
- /** {@inheritDoc} */
- public boolean isDynamic()
- {
- return dynamic;
- }
-
- /** {@inheritDoc} */
- public boolean isExternalizable()
- {
- return externalizable;
- }
-
- /** {@inheritDoc} */
- public void setExternalizable(boolean value)
- {
- externalizable = value;
- }
-
- /** {@inheritDoc} */
- public boolean isExternalizable(Object instance)
- {
- return instance instanceof Externalizable;
- }
-
- /** {@inheritDoc} */
- public SerializationContext getSerializationContext()
- {
- return context == null? SerializationContext.getSerializationContext() : context;
- }
-
- /** {@inheritDoc} */
- public void setSerializationContext(SerializationContext value)
- {
- context = value;
- }
-
- /** {@inheritDoc} */
- public void setIncludeReadOnly(boolean value)
- {
- includeReadOnly = value;
- }
-
- /** {@inheritDoc} */
- public boolean getIncludeReadOnly()
- {
- if (includeReadOnly)
- {
- return true;
- }
- return getSerializationContext().includeReadOnly;
- }
-
- /** {@inheritDoc} */
- public SerializationDescriptor getDescriptor()
- {
- return descriptor;
- }
-
- /** {@inheritDoc} */
- public void setDescriptor(SerializationDescriptor descriptor)
- {
- this.descriptor = descriptor;
- }
-
- /**
- * This is called after the serialization finishes. We return the same object
- * here... this is an opportunity to replace the instance we use once we have
- * gathered all of the state into a temporary object.
- * @param instance current instance
- * @return Object the instance after complete serialization
- */
- public Object instanceComplete(Object instance)
- {
- return instance;
- }
-
- /**
- * Returns the instance to serialize in place of the supplied instance.
- * @param instance the instance to serialize
- * @return Object the instance
- */
- public Object getInstanceToSerialize(Object instance)
- {
- return instance;
- }
-
- /** {@inheritDoc} */
- @Override
- public Object clone()
- {
- try
- {
- AbstractProxy clonedProxy= (AbstractProxy) super.clone();
- clonedProxy.setCloneFieldsFrom(this);
- return clonedProxy;
- }
- catch (CloneNotSupportedException e)
- {
- if (Log.isError())
- {
- Logger log = Log.getLogger(LOG_CATEGORY);
- log.error("Failed to clone a property proxy: " + toString());
- }
- MessageException ex = new MessageException();
- ex.setMessage(CONVERSION_ERROR);
- throw ex;
- }
- }
-
- /**
- * A string including the default instance, class and descriptor info.
- * @return debug string.
- */
- @Override
- public String toString()
- {
- if (defaultInstance != null)
- return "[Proxy(inst=" + defaultInstance + ") proxyClass=" + getClass() + " descriptor=" + descriptor + "]";
- return "[Proxy(proxyClass=" + getClass() + " descriptor=" + descriptor + "]";
- }
-
- protected void setCloneFieldsFrom(AbstractProxy source)
- {
- setDescriptor(source.getDescriptor());
- setDefaultInstance(source.getDefaultInstance());
- context = source.context;
- includeReadOnly = source.includeReadOnly;
- }
+/*
+ * 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.io;
+
+import java.util.List;
+import java.io.Externalizable;
+import java.io.Serializable;
+
+import flex.messaging.MessageException;
+import flex.messaging.io.amf.ASObject;
+import flex.messaging.log.LogCategories;
+import flex.messaging.log.Log;
+import flex.messaging.log.Logger;
+import flex.messaging.util.ClassUtil;
+
+/**
+ * Simple abstract implementation of PropertyProxy's common properties. Specific
+ * sub-classes need to provide the full implementation focusing on the retrieval
+ * of the instance traits or "list of properties" and a specific value for
+ * a given property name.
+ *
+ * @see flex.messaging.io.PropertyProxy
+ * @exclude
+ */
+public abstract class AbstractProxy implements PropertyProxy, Serializable
+{
+ protected Object defaultInstance;
+ protected String alias;
+ protected boolean dynamic;
+ protected boolean externalizable;
+ protected boolean includeReadOnly;
+ protected SerializationDescriptor descriptor;
+ protected SerializationContext context;
+
+ protected static final String LOG_CATEGORY = LogCategories.ENDPOINT_TYPE;
+ private static final int CONVERSION_ERROR = 10006;
+
+ protected AbstractProxy(Object defaultInstance)
+ {
+ this.defaultInstance = defaultInstance;
+ if (defaultInstance != null)
+ alias = defaultInstance.getClass().getName();
+ }
+
+ /** {@inheritDoc} */
+ public Object getDefaultInstance()
+ {
+ return defaultInstance;
+ }
+
+ /** {@inheritDoc} */
+ public void setDefaultInstance(Object instance)
+ {
+ defaultInstance = instance;
+ }
+
+ /**
+ * A utility method which returns the Class from the given Class name
+ * using the current type context's class loader.
+ *
+ * @param className the class name.
+ * @return a Class object for the named class.
+ */
+ public static Class getClassFromClassName(String className)
+ {
+ TypeMarshallingContext typeContext = TypeMarshallingContext.getTypeMarshallingContext();
+ return ClassUtil.createClass(className, typeContext.getClassLoader());
+ }
+
+ /**
+ * A utility method which creates an instance from a given class name. It assumes
+ * the class has a zero arg constructor.
+ * @param className the class name
+ * for a type that is missing on the server, instead of throwing a server resource not found
+ * exception.
+ * @return the instance of the named class.
+ */
+ public static Object createInstanceFromClassName(String className)
+ {
+ Class<?> desiredClass = getClassFromClassName(className);
+ return ClassUtil.createDefaultInstance(desiredClass, null, true /*validate*/);
+ }
+
+ /** {@inheritDoc} */
+ public Object createInstance(String className)
+ {
+ Object instance;
+
+ if (className == null || className.length() == 0)
+ {
+ instance = ClassUtil.createDefaultInstance(ASObject.class, null, true /*validate*/);
+ }
+ else if (className.startsWith(">")) // Handle [RemoteClass] (no server alias)
+ {
+ instance = ClassUtil.createDefaultInstance(ASObject.class, null, true /*validate*/);
+ ((ASObject)instance).setType(className);
+ }
+ else
+ {
+ if (getSerializationContext().instantiateTypes || className.startsWith("flex."))
+ return createInstanceFromClassName(className);
+
+ // Just return type info with an ASObject...
+ instance = ClassUtil.createDefaultInstance(ASObject.class, null, true /*validate*/);
+ ((ASObject)instance).setType(className);
+ }
+ return instance;
+ }
+
+ /** {@inheritDoc} */
+ public List getPropertyNames()
+ {
+ return getPropertyNames(getDefaultInstance());
+ }
+
+ /** {@inheritDoc} */
+ public Class getType(String propertyName)
+ {
+ return getType(getDefaultInstance(), propertyName);
+ }
+
+ /** {@inheritDoc} */
+ public Object getValue(String propertyName)
+ {
+ return getValue(getDefaultInstance(), propertyName);
+ }
+
+ /** {@inheritDoc} */
+ public void setValue(String propertyName, Object value)
+ {
+ setValue(getDefaultInstance(), propertyName, value);
+ }
+
+ /** {@inheritDoc} */
+ public void setAlias(String value)
+ {
+ alias = value;
+ }
+
+ /** {@inheritDoc} */
+ public String getAlias()
+ {
+ return alias;
+ }
+
+ /** {@inheritDoc} */
+ public void setDynamic(boolean value)
+ {
+ dynamic = value;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isDynamic()
+ {
+ return dynamic;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isExternalizable()
+ {
+ return externalizable;
+ }
+
+ /** {@inheritDoc} */
+ public void setExternalizable(boolean value)
+ {
+ externalizable = value;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isExternalizable(Object instance)
+ {
+ return instance instanceof Externalizable;
+ }
+
+ /** {@inheritDoc} */
+ public SerializationContext getSerializationContext()
+ {
+ return context == null? SerializationContext.getSerializationContext() : context;
+ }
+
+ /** {@inheritDoc} */
+ public void setSerializationContext(SerializationContext value)
+ {
+ context = value;
+ }
+
+ /** {@inheritDoc} */
+ public void setIncludeReadOnly(boolean value)
+ {
+ includeReadOnly = value;
+ }
+
+ /** {@inheritDoc} */
+ public boolean getIncludeReadOnly()
+ {
+ if (includeReadOnly)
+ {
+ return true;
+ }
+ return getSerializationContext().includeReadOnly;
+ }
+
+ /** {@inheritDoc} */
+ public SerializationDescriptor getDescriptor()
+ {
+ return descriptor;
+ }
+
+ /** {@inheritDoc} */
+ public void setDescriptor(SerializationDescriptor descriptor)
+ {
+ this.descriptor = descriptor;
+ }
+
+ /**
+ * This is called after the serialization finishes. We return the same object
+ * here... this is an opportunity to replace the instance we use once we have
+ * gathered all of the state into a temporary object.
+ * @param instance current instance
+ * @return Object the instance after complete serialization
+ */
+ public Object instanceComplete(Object instance)
+ {
+ return instance;
+ }
+
+ /**
+ * Returns the instance to serialize in place of the supplied instance.
+ * @param instance the instance to serialize
+ * @return Object the instance
+ */
+ public Object getInstanceToSerialize(Object instance)
+ {
+ return instance;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Object clone()
+ {
+ try
+ {
+ AbstractProxy clonedProxy= (AbstractProxy) super.clone();
+ clonedProxy.setCloneFieldsFrom(this);
+ return clonedProxy;
+ }
+ catch (CloneNotSupportedException e)
+ {
+ if (Log.isError())
+ {
+ Logger log = Log.getLogger(LOG_CATEGORY);
+ log.error("Failed to clone a property proxy: " + toString());
+ }
+ MessageException ex = new MessageException();
+ ex.setMessage(CONVERSION_ERROR);
+ throw ex;
+ }
+ }
+
+ /**
+ * A string including the default instance, class and descriptor info.
+ * @return debug string.
+ */
+ @Override
+ public String toString()
+ {
+ if (defaultInstance != null)
+ return "[Proxy(inst=" + defaultInstance + ") proxyClass=" + getClass() + " descriptor=" + descriptor + "]";
+ return "[Proxy(proxyClass=" + getClass() + " descriptor=" + descriptor + "]";
+ }
+
+ protected void setCloneFieldsFrom(AbstractProxy source)
+ {
+ setDescriptor(source.getDescriptor());
+ setDefaultInstance(source.getDefaultInstance());
+ context = source.context;
+ includeReadOnly = source.includeReadOnly;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/ArrayCollection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/ArrayCollection.java b/modules/core/src/flex/messaging/io/ArrayCollection.java
old mode 100755
new mode 100644
index d733c05..dd74e6d
--- a/modules/core/src/flex/messaging/io/ArrayCollection.java
+++ b/modules/core/src/flex/messaging/io/ArrayCollection.java
@@ -1,165 +1,165 @@
-/*
- * 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.io;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * Used to map to client mx.collections.ArrayCollection to java.util.Lists in Java.
- */
-public class ArrayCollection extends ArrayList implements Externalizable
-{
- private static final long serialVersionUID = 8037277879661457358L;
-
- private SerializationDescriptor descriptor = null;
-
- /**
- * Default constructor.
- */
- public ArrayCollection()
- {
- super();
- }
-
- /**
- * Creates an <tt>ArrayCollection</tt> with the supplied collection.
- *
- * @param c Collection.
- */
- public ArrayCollection(Collection c)
- {
- super(c);
- }
-
- /**
- * Creates <tt>ArrayCollection</tt> with the supllied inital capacity.
- *
- * @param initialCapacity The initial capacity.
- */
- public ArrayCollection(int initialCapacity)
- {
- super(initialCapacity);
- }
-
- /**
- * Returns the backing Array of the <tt>ArrayCollection</tt>.
- *
- * @return The backing Array.
- */
- public Object[] getSource()
- {
- return toArray();
- }
-
- /**
- * Sets the serialization descriptor.
- *
- * @param desc The serialization descriptor.
- */
- public void setDescriptor(SerializationDescriptor desc)
- {
- this.descriptor = desc;
- }
-
- /**
- * Sets the source with the supplied Array.
- *
- * @param s The source Array.
- */
- public void setSource(Object[] s)
- {
- if (s == null)
- {
- clear();
- return;
- }
-
- if (size() > 0)
- clear();
-
- for (int i = 0; i < s.length; i++)
- add(s[i]);
- }
-
- /**
- * Sets the sources with the supplied Collection.
- *
- * @param s The source Collection.
- */
- public void setSource(Collection s)
- {
- addAll(s);
- }
-
- /**
- * Implements {@link Externalizable#readExternal(ObjectInput)}
- *
- * @param input The object input.
- */
- public void readExternal(ObjectInput input) throws IOException, ClassNotFoundException
- {
- Object s = input.readObject();
- if (s instanceof Collection)
- s = ((Collection)s).toArray();
- Object[] source = (Object[])s;
- setSource(source);
- }
-
- /**
- * Implements {@link Externalizable#writeExternal(ObjectOutput)}
- *
- * @param output The object output.
- */
- public void writeExternal(ObjectOutput output) throws IOException
- {
- if (descriptor == null)
- {
- output.writeObject(getSource());
- return;
- }
-
- Object[] source = getSource();
- if (source == null)
- {
- output.writeObject(null);
- return;
- }
-
- for (int i = 0; i < source.length; i++)
- {
- Object item = source[i];
- if (item == null)
- {
- source[i] = null;
- }
- else
- {
- PropertyProxy proxy = PropertyProxyRegistry.getProxy(item);
- proxy = (PropertyProxy)proxy.clone();
- proxy.setDescriptor(descriptor);
- proxy.setDefaultInstance(item);
- source[i] = proxy;
- }
- }
- output.writeObject(source);
- }
-}
+/*
+ * 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.io;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Used to map to client mx.collections.ArrayCollection to java.util.Lists in Java.
+ */
+public class ArrayCollection extends ArrayList implements Externalizable
+{
+ private static final long serialVersionUID = 8037277879661457358L;
+
+ private SerializationDescriptor descriptor = null;
+
+ /**
+ * Default constructor.
+ */
+ public ArrayCollection()
+ {
+ super();
+ }
+
+ /**
+ * Creates an <tt>ArrayCollection</tt> with the supplied collection.
+ *
+ * @param c Collection.
+ */
+ public ArrayCollection(Collection c)
+ {
+ super(c);
+ }
+
+ /**
+ * Creates <tt>ArrayCollection</tt> with the supllied inital capacity.
+ *
+ * @param initialCapacity The initial capacity.
+ */
+ public ArrayCollection(int initialCapacity)
+ {
+ super(initialCapacity);
+ }
+
+ /**
+ * Returns the backing Array of the <tt>ArrayCollection</tt>.
+ *
+ * @return The backing Array.
+ */
+ public Object[] getSource()
+ {
+ return toArray();
+ }
+
+ /**
+ * Sets the serialization descriptor.
+ *
+ * @param desc The serialization descriptor.
+ */
+ public void setDescriptor(SerializationDescriptor desc)
+ {
+ this.descriptor = desc;
+ }
+
+ /**
+ * Sets the source with the supplied Array.
+ *
+ * @param s The source Array.
+ */
+ public void setSource(Object[] s)
+ {
+ if (s == null)
+ {
+ clear();
+ return;
+ }
+
+ if (size() > 0)
+ clear();
+
+ for (int i = 0; i < s.length; i++)
+ add(s[i]);
+ }
+
+ /**
+ * Sets the sources with the supplied Collection.
+ *
+ * @param s The source Collection.
+ */
+ public void setSource(Collection s)
+ {
+ addAll(s);
+ }
+
+ /**
+ * Implements {@link Externalizable#readExternal(ObjectInput)}
+ *
+ * @param input The object input.
+ */
+ public void readExternal(ObjectInput input) throws IOException, ClassNotFoundException
+ {
+ Object s = input.readObject();
+ if (s instanceof Collection)
+ s = ((Collection)s).toArray();
+ Object[] source = (Object[])s;
+ setSource(source);
+ }
+
+ /**
+ * Implements {@link Externalizable#writeExternal(ObjectOutput)}
+ *
+ * @param output The object output.
+ */
+ public void writeExternal(ObjectOutput output) throws IOException
+ {
+ if (descriptor == null)
+ {
+ output.writeObject(getSource());
+ return;
+ }
+
+ Object[] source = getSource();
+ if (source == null)
+ {
+ output.writeObject(null);
+ return;
+ }
+
+ for (int i = 0; i < source.length; i++)
+ {
+ Object item = source[i];
+ if (item == null)
+ {
+ source[i] = null;
+ }
+ else
+ {
+ PropertyProxy proxy = PropertyProxyRegistry.getProxy(item);
+ proxy = (PropertyProxy)proxy.clone();
+ proxy.setDescriptor(descriptor);
+ proxy.setDefaultInstance(item);
+ source[i] = proxy;
+ }
+ }
+ output.writeObject(source);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/ArrayList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/ArrayList.java b/modules/core/src/flex/messaging/io/ArrayList.java
old mode 100755
new mode 100644
index 5f39738..6c5c383
--- a/modules/core/src/flex/messaging/io/ArrayList.java
+++ b/modules/core/src/flex/messaging/io/ArrayList.java
@@ -16,29 +16,29 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package flex.messaging.io;
-
-import java.util.Collection;
-
-/**
- * @exclude
- */
-public class ArrayList extends ArrayCollection
-{
- private static final long serialVersionUID = -2976024728140087328L;
-
- public ArrayList()
- {
- super();
- }
-
- public ArrayList(Collection c)
- {
- super(c);
- }
-
- public ArrayList(int initialCapacity)
- {
- super(initialCapacity);
- }
-}
+package flex.messaging.io;
+
+import java.util.Collection;
+
+/**
+ * @exclude
+ */
+public class ArrayList extends ArrayCollection
+{
+ private static final long serialVersionUID = -2976024728140087328L;
+
+ public ArrayList()
+ {
+ super();
+ }
+
+ public ArrayList(Collection c)
+ {
+ super(c);
+ }
+
+ public ArrayList(int initialCapacity)
+ {
+ super(initialCapacity);
+ }
+}
[50/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/LocalizedException.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/LocalizedException.java b/modules/common/src/flex/messaging/LocalizedException.java
old mode 100755
new mode 100644
index d1967d3..4cc80d8
--- a/modules/common/src/flex/messaging/LocalizedException.java
+++ b/modules/common/src/flex/messaging/LocalizedException.java
@@ -1,379 +1,379 @@
-/*
- * 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;
-
-import java.util.Locale;
-
-import flex.messaging.util.PropertyStringResourceLoader;
-import flex.messaging.util.ResourceLoader;
-
-/**
- * The LocalizedException class is the base class for server
- * exceptions that use localized error message and details strings. This class overloads
- * <code>setMessage</code> and <code>setDetails</code> to support passing an error
- * number and an optional message variant that is used to look up a localized error
- * message or details string using a <code>ResourceLoader</code>. These methods also
- * set the number property of the exception instance.
- * <p>
- * The various overloads optionally support specifying a target locale as well as
- * arguments to substitute into the localized string if it is parameterized.
- * </p><p>
- * Localized error message and details strings are stored in the flex.messaging.errors
- * resource bundle. Entries must have the following format.
- * <ul>
- * <li>Error message: {number}[-{variant}]={message}</li>
- * <li>Error details: {number}[-{variant}]-details={details}</li>
- * </ul>
- * </p>
- *
- * @see ResourceLoader
- */
-public class LocalizedException extends RuntimeException
-{
- /** @exclude - transient, the resourceLoader for localized strings doesn't need to serialize. */
- protected transient ResourceLoader resourceLoader;
- /** @exclude */
- protected int number;
- /** @exclude */
- protected String message;
- /** @exclude */
- protected String details;
- /** @exclude */
- protected Throwable rootCause;
-
- /**
- * This number was generated using the 'serialver' command line tool.
- * This number should remain consistent with the version used by
- * ColdFusion to communicate with the message broker over RMI.
- */
- private static final long serialVersionUID = 7980539484335065853L;
-
- /**
- * Create a LocalizedException with the default ResourceLoader.
- */
- public LocalizedException()
- {
- super();
- }
-
- /**
- * Create a LocalizedException that will use the specified
- * ResourceLoader.
- *
- * @param resourceLoader The resource loader to use.
- */
- public LocalizedException(ResourceLoader resourceLoader)
- {
- this.resourceLoader = resourceLoader;
- }
-
- /**
- * Returns the exception details.
- *
- * @return The exception details.
- */
- public String getDetails()
- {
- return details;
- }
-
- /**
- * Sets the exception details.
- *
- * @param details The exception details.
- */
- public void setDetails(String details)
- {
- this.details = details;
- }
-
- /**
- * Sets the message property to a localized string based on error number.
- *
- * @param number The error number for this exception instance.
- */
- public void setMessage(int number)
- {
- setMessage(number, null, null, null);
- }
-
- /**
- * Sets the message property to a localized string based on error number and target locale.
- *
- * @param number The error number for this exception instance.
- * @param locale The target locale for error message lookup.
- */
- public void setMessage(int number, Locale locale)
- {
- setMessage(number, null, locale, null);
- }
-
- /**
- * Sets the message property to a localized string based on error number.
- * The passed arguments are substituted into the parameterized error message string.
- *
- * @param number The error number for this exception instance.
- * @param arguments The arguments to substitute into the error message.
- */
- public void setMessage(int number, Object[] arguments)
- {
- setMessage(number, null, null, arguments);
- }
-
- /**
- * Sets the message property to a localized string based on error number and variant.
- *
- * @param number The error number for this exception instance.
- * @param variant The variant of the error message for this instance.
- */
- public void setMessage(int number, String variant)
- {
- setMessage(number, variant, null, null);
- }
-
- /**
- * Sets the message property to a localized string based on error number, variant
- * and target locale.
- *
- * @param number The error number for this exception instance.
- * @param variant The variant of the error message for this instance.
- * @param locale The target locale for error message lookup.
- */
- public void setMessage(int number, String variant, Locale locale)
- {
- setMessage(number, variant, locale, null);
- }
-
- /**
- * Sets the message property to a localized string based on error number and variant.
- * The passed arguments are substituted into the parameterized error message string.
- *
- * @param number The error number for this exception instance.
- * @param variant The varient of the error message for this instance.
- * @param arguments The arguments to substitute into the error message.
- */
- public void setMessage(int number, String variant, Object[] arguments)
- {
- setMessage(number, variant, null, arguments);
- }
-
- /**
- * Sets the message property to a localized string based on error number, variant and
- * target locale. The passed arguments are substituted into the parameterized error
- * message string.
- *
- * @param number The error number for this exception instance.
- * @param variant The variant of the error message for this instance.
- * @param locale The target locale for error message lookup.
- * @param arguments The arguments to substitute into the error message.
- */
- public void setMessage(int number, String variant, Locale locale, Object[] arguments)
- {
- setNumber(number);
- ResourceLoader resources = getResourceLoader();
- setMessage(resources.getString(generateFullKey(number, variant), locale, arguments));
- }
-
- /**
- * Returns the exception message.
- *
- * @return The exception message.
- */
- public String getMessage()
- {
- return message;
- }
-
- /**
- * Sets the exception message.
- *
- * @param message The exception message.
- */
- public void setMessage(String message)
- {
- this.message = message;
- }
-
- /**
- * Sets the localized exception number.
- *
- * @param number The localized exception number.
- */
- public void setNumber(int number)
- {
- this.number = number;
- }
-
- /**
- * Returns the localized exception number.
- *
- * @return The localized exception number.
- */
- public int getNumber()
- {
- return number;
- }
-
- /**
- * Sets the details property to a localized string based on error number.
- *
- * @param number The error number to lookup details for.
- */
- public void setDetails(int number)
- {
- setDetails(number, null, null, null);
- }
-
- /**
- * Sets the details property to a localized string based on error number and variant.
- *
- * @param number The error number to lookup details for.
- * @param variant The variant of the details string to lookup.
- */
- public void setDetails(int number, String variant)
- {
- setDetails(number, variant, null, null);
- }
-
- /**
- * Sets the details property to a localized string based on error number, variant
- * and target locale.
- *
- * @param number The error number to lookup details for.
- * @param variant The variant of the details string to lookup.
- * @param locale The target locale for the lookup.
- */
- public void setDetails(int number, String variant, Locale locale)
- {
- setDetails(number, variant, locale, null);
- }
-
- /**
- * Sets the details property to a localized string based on error number and variant.
- * The passed arguments are substituted into the parameterized error details string.
- *
- * @param number The error number to lookup details for.
- * @param variant The variant of the details string to lookup.
- * @param arguments The arguments to substitute into the details string.
- */
- public void setDetails(int number, String variant, Object[] arguments)
- {
- setDetails(number, variant, null, arguments);
- }
-
-
- /**
- * Sets the details property to a localized string based on error number, variant,
- * and target locale. The passed arguments are substituted into the parameterized error
- * details string.
- *
- * @param number The error number to lookup a localized details string for.
- * @param variant The variant of the details string to lookup.
- * @param locale The target locale for the lookup.
- * @param arguments The arguments to substitute into the details string.
- */
- public void setDetails(int number, String variant, Locale locale, Object[] arguments)
- {
- setNumber(number);
- ResourceLoader resources = getResourceLoader();
- setDetails(resources.getString(generateDetailsKey(number, variant), locale, arguments));
- }
-
- /**
- * Returns the root cause for this exception.
- *
- * @return The root cause for this exception.
- */
- public Throwable getRootCause()
- {
- return rootCause;
- }
-
- /**
- * Sets the root cause for this exception.
- *
- * @param cause The root cause for this exception.
- */
- public void setRootCause(Throwable cause)
- {
- rootCause = cause;
- // Assign through to the base cause property to include it in general stack traces.
- initCause(cause);
- }
-
- /**
- * Returns the <code>ResourceLoader</code> used to load localized strings.
- *
- * @return The <code>ResourceLoader</code> used to load localized strings.
- */
- protected ResourceLoader getResourceLoader()
- {
- if (resourceLoader == null)
- resourceLoader = new PropertyStringResourceLoader();
-
- return resourceLoader;
- }
-
- /**
- * Generates the full key to lookup a localized error message based on an error number
- * and an optional variant followed by a "-details" suffix. If the variant is null, the
- * lookup key is the error number.
- *
- * @param number The error number.
- * @param variant The variant of the error message.
- * @return The full lookup key for a localized error message.
- */
- private String generateFullKey(int number, String variant)
- {
- return (variant != null) ? (number + "-" + variant) : String.valueOf(number);
- }
-
- /**
- * Generates the full key to lookup a localized details string based on an error number
- * and an optional variant followed by a "-details" suffix. If the variant is null, the
- * lookup key is the error number followed by a "-details" suffix.
- *
- * @param number The error number.
- * @param variant The variant of the details message.
- * @return The full lookup key for a localized details message.
- */
- private String generateDetailsKey(int number, String variant)
- {
- return (generateFullKey(number, variant) + "-details");
- }
-
- /**
- * Returns a string represenation of the exception.
- *
- * @return A string representation of the exception.
- */
- public String toString()
- {
- String result = super.toString();
- if (details != null)
- {
- StringBuffer buffer = new StringBuffer(result);
- if (!result.endsWith("."))
- {
- buffer.append(".");
- }
- buffer.append(' ').append(details);
- result = buffer.toString();
- }
- return result;
- }
-}
+/*
+ * 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;
+
+import java.util.Locale;
+
+import flex.messaging.util.PropertyStringResourceLoader;
+import flex.messaging.util.ResourceLoader;
+
+/**
+ * The LocalizedException class is the base class for server
+ * exceptions that use localized error message and details strings. This class overloads
+ * <code>setMessage</code> and <code>setDetails</code> to support passing an error
+ * number and an optional message variant that is used to look up a localized error
+ * message or details string using a <code>ResourceLoader</code>. These methods also
+ * set the number property of the exception instance.
+ * <p>
+ * The various overloads optionally support specifying a target locale as well as
+ * arguments to substitute into the localized string if it is parameterized.
+ * </p><p>
+ * Localized error message and details strings are stored in the flex.messaging.errors
+ * resource bundle. Entries must have the following format.
+ * <ul>
+ * <li>Error message: {number}[-{variant}]={message}</li>
+ * <li>Error details: {number}[-{variant}]-details={details}</li>
+ * </ul>
+ * </p>
+ *
+ * @see ResourceLoader
+ */
+public class LocalizedException extends RuntimeException
+{
+ /** @exclude - transient, the resourceLoader for localized strings doesn't need to serialize. */
+ protected transient ResourceLoader resourceLoader;
+ /** @exclude */
+ protected int number;
+ /** @exclude */
+ protected String message;
+ /** @exclude */
+ protected String details;
+ /** @exclude */
+ protected Throwable rootCause;
+
+ /**
+ * This number was generated using the 'serialver' command line tool.
+ * This number should remain consistent with the version used by
+ * ColdFusion to communicate with the message broker over RMI.
+ */
+ private static final long serialVersionUID = 7980539484335065853L;
+
+ /**
+ * Create a LocalizedException with the default ResourceLoader.
+ */
+ public LocalizedException()
+ {
+ super();
+ }
+
+ /**
+ * Create a LocalizedException that will use the specified
+ * ResourceLoader.
+ *
+ * @param resourceLoader The resource loader to use.
+ */
+ public LocalizedException(ResourceLoader resourceLoader)
+ {
+ this.resourceLoader = resourceLoader;
+ }
+
+ /**
+ * Returns the exception details.
+ *
+ * @return The exception details.
+ */
+ public String getDetails()
+ {
+ return details;
+ }
+
+ /**
+ * Sets the exception details.
+ *
+ * @param details The exception details.
+ */
+ public void setDetails(String details)
+ {
+ this.details = details;
+ }
+
+ /**
+ * Sets the message property to a localized string based on error number.
+ *
+ * @param number The error number for this exception instance.
+ */
+ public void setMessage(int number)
+ {
+ setMessage(number, null, null, null);
+ }
+
+ /**
+ * Sets the message property to a localized string based on error number and target locale.
+ *
+ * @param number The error number for this exception instance.
+ * @param locale The target locale for error message lookup.
+ */
+ public void setMessage(int number, Locale locale)
+ {
+ setMessage(number, null, locale, null);
+ }
+
+ /**
+ * Sets the message property to a localized string based on error number.
+ * The passed arguments are substituted into the parameterized error message string.
+ *
+ * @param number The error number for this exception instance.
+ * @param arguments The arguments to substitute into the error message.
+ */
+ public void setMessage(int number, Object[] arguments)
+ {
+ setMessage(number, null, null, arguments);
+ }
+
+ /**
+ * Sets the message property to a localized string based on error number and variant.
+ *
+ * @param number The error number for this exception instance.
+ * @param variant The variant of the error message for this instance.
+ */
+ public void setMessage(int number, String variant)
+ {
+ setMessage(number, variant, null, null);
+ }
+
+ /**
+ * Sets the message property to a localized string based on error number, variant
+ * and target locale.
+ *
+ * @param number The error number for this exception instance.
+ * @param variant The variant of the error message for this instance.
+ * @param locale The target locale for error message lookup.
+ */
+ public void setMessage(int number, String variant, Locale locale)
+ {
+ setMessage(number, variant, locale, null);
+ }
+
+ /**
+ * Sets the message property to a localized string based on error number and variant.
+ * The passed arguments are substituted into the parameterized error message string.
+ *
+ * @param number The error number for this exception instance.
+ * @param variant The varient of the error message for this instance.
+ * @param arguments The arguments to substitute into the error message.
+ */
+ public void setMessage(int number, String variant, Object[] arguments)
+ {
+ setMessage(number, variant, null, arguments);
+ }
+
+ /**
+ * Sets the message property to a localized string based on error number, variant and
+ * target locale. The passed arguments are substituted into the parameterized error
+ * message string.
+ *
+ * @param number The error number for this exception instance.
+ * @param variant The variant of the error message for this instance.
+ * @param locale The target locale for error message lookup.
+ * @param arguments The arguments to substitute into the error message.
+ */
+ public void setMessage(int number, String variant, Locale locale, Object[] arguments)
+ {
+ setNumber(number);
+ ResourceLoader resources = getResourceLoader();
+ setMessage(resources.getString(generateFullKey(number, variant), locale, arguments));
+ }
+
+ /**
+ * Returns the exception message.
+ *
+ * @return The exception message.
+ */
+ public String getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * Sets the exception message.
+ *
+ * @param message The exception message.
+ */
+ public void setMessage(String message)
+ {
+ this.message = message;
+ }
+
+ /**
+ * Sets the localized exception number.
+ *
+ * @param number The localized exception number.
+ */
+ public void setNumber(int number)
+ {
+ this.number = number;
+ }
+
+ /**
+ * Returns the localized exception number.
+ *
+ * @return The localized exception number.
+ */
+ public int getNumber()
+ {
+ return number;
+ }
+
+ /**
+ * Sets the details property to a localized string based on error number.
+ *
+ * @param number The error number to lookup details for.
+ */
+ public void setDetails(int number)
+ {
+ setDetails(number, null, null, null);
+ }
+
+ /**
+ * Sets the details property to a localized string based on error number and variant.
+ *
+ * @param number The error number to lookup details for.
+ * @param variant The variant of the details string to lookup.
+ */
+ public void setDetails(int number, String variant)
+ {
+ setDetails(number, variant, null, null);
+ }
+
+ /**
+ * Sets the details property to a localized string based on error number, variant
+ * and target locale.
+ *
+ * @param number The error number to lookup details for.
+ * @param variant The variant of the details string to lookup.
+ * @param locale The target locale for the lookup.
+ */
+ public void setDetails(int number, String variant, Locale locale)
+ {
+ setDetails(number, variant, locale, null);
+ }
+
+ /**
+ * Sets the details property to a localized string based on error number and variant.
+ * The passed arguments are substituted into the parameterized error details string.
+ *
+ * @param number The error number to lookup details for.
+ * @param variant The variant of the details string to lookup.
+ * @param arguments The arguments to substitute into the details string.
+ */
+ public void setDetails(int number, String variant, Object[] arguments)
+ {
+ setDetails(number, variant, null, arguments);
+ }
+
+
+ /**
+ * Sets the details property to a localized string based on error number, variant,
+ * and target locale. The passed arguments are substituted into the parameterized error
+ * details string.
+ *
+ * @param number The error number to lookup a localized details string for.
+ * @param variant The variant of the details string to lookup.
+ * @param locale The target locale for the lookup.
+ * @param arguments The arguments to substitute into the details string.
+ */
+ public void setDetails(int number, String variant, Locale locale, Object[] arguments)
+ {
+ setNumber(number);
+ ResourceLoader resources = getResourceLoader();
+ setDetails(resources.getString(generateDetailsKey(number, variant), locale, arguments));
+ }
+
+ /**
+ * Returns the root cause for this exception.
+ *
+ * @return The root cause for this exception.
+ */
+ public Throwable getRootCause()
+ {
+ return rootCause;
+ }
+
+ /**
+ * Sets the root cause for this exception.
+ *
+ * @param cause The root cause for this exception.
+ */
+ public void setRootCause(Throwable cause)
+ {
+ rootCause = cause;
+ // Assign through to the base cause property to include it in general stack traces.
+ initCause(cause);
+ }
+
+ /**
+ * Returns the <code>ResourceLoader</code> used to load localized strings.
+ *
+ * @return The <code>ResourceLoader</code> used to load localized strings.
+ */
+ protected ResourceLoader getResourceLoader()
+ {
+ if (resourceLoader == null)
+ resourceLoader = new PropertyStringResourceLoader();
+
+ return resourceLoader;
+ }
+
+ /**
+ * Generates the full key to lookup a localized error message based on an error number
+ * and an optional variant followed by a "-details" suffix. If the variant is null, the
+ * lookup key is the error number.
+ *
+ * @param number The error number.
+ * @param variant The variant of the error message.
+ * @return The full lookup key for a localized error message.
+ */
+ private String generateFullKey(int number, String variant)
+ {
+ return (variant != null) ? (number + "-" + variant) : String.valueOf(number);
+ }
+
+ /**
+ * Generates the full key to lookup a localized details string based on an error number
+ * and an optional variant followed by a "-details" suffix. If the variant is null, the
+ * lookup key is the error number followed by a "-details" suffix.
+ *
+ * @param number The error number.
+ * @param variant The variant of the details message.
+ * @return The full lookup key for a localized details message.
+ */
+ private String generateDetailsKey(int number, String variant)
+ {
+ return (generateFullKey(number, variant) + "-details");
+ }
+
+ /**
+ * Returns a string represenation of the exception.
+ *
+ * @return A string representation of the exception.
+ */
+ public String toString()
+ {
+ String result = super.toString();
+ if (details != null)
+ {
+ StringBuffer buffer = new StringBuffer(result);
+ if (!result.endsWith("."))
+ {
+ buffer.append(".");
+ }
+ buffer.append(' ').append(details);
+ result = buffer.toString();
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/AbstractConfigurationParser.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/AbstractConfigurationParser.java b/modules/common/src/flex/messaging/config/AbstractConfigurationParser.java
old mode 100755
new mode 100644
index 98fcfce..820f7ea
--- a/modules/common/src/flex/messaging/config/AbstractConfigurationParser.java
+++ b/modules/common/src/flex/messaging/config/AbstractConfigurationParser.java
@@ -1,559 +1,559 @@
-/*
- * 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.config;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import flex.messaging.util.FileUtils;
-
-/**
- * Provides a common base for DOM / XPath based ConfigurationParsers.
- *
- * @author Peter Farland
- * @exclude
- */
-public abstract class AbstractConfigurationParser implements ConfigurationParser, ConfigurationConstants, EntityResolver
-{
- protected ServicesConfiguration config;
- protected DocumentBuilder docBuilder;
- protected ConfigurationFileResolver fileResolver;
- protected TokenReplacer tokenReplacer;
-
- private Map fileByDocument = new HashMap();
-
- protected AbstractConfigurationParser()
- {
- initializeDocumentBuilder();
- tokenReplacer = new TokenReplacer();
- }
-
- /**
- * Parse the configurations in the configuration file.
- * <p/>
- * @param path the configuration file path
- * @param fileResolver the ConfigurationFileResolver object
- * @param config the ServicesConfiguration object
- **/
- public void parse(String path, ConfigurationFileResolver fileResolver, ServicesConfiguration config)
- {
- this.config = config;
- this.fileResolver = fileResolver;
- Document doc = loadDocument(path, fileResolver.getConfigurationFile(path));
- initializeExpressionQuery();
- parseTopLevelConfig(doc);
- }
-
- /**
- * Report Tokens.
- * <p/>
- **/
- public void reportTokens()
- {
- tokenReplacer.reportTokens();
- }
-
- protected void initializeDocumentBuilder()
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setIgnoringComments(true);
- factory.setIgnoringElementContentWhitespace(true);
-
- try
- {
- docBuilder = factory.newDocumentBuilder();
- docBuilder.setEntityResolver(this);
- }
- catch (ParserConfigurationException ex)
- {
- // Error initializing configuration parser.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(PARSER_INIT_ERROR);
- e.setRootCause(ex);
- throw e;
- }
- }
-
- protected Document loadDocument(String path, InputStream in)
- {
- try
- {
- Document doc;
-
- if (!in.markSupported())
- in = new BufferedInputStream(in);
-
- // Consume UTF-8 Byte Order Mark (BOM). The InputStream must support mark()
- // as FileUtils.consumeBOM sets a mark for 3 bytes in order to check for a BOM.
- String encoding = FileUtils.consumeBOM(in, null);
- if (FileUtils.UTF_8.equals(encoding) || FileUtils.UTF_16.equals(encoding))
- {
- InputSource inputSource = new InputSource(in);
- inputSource.setEncoding(encoding);
- doc = docBuilder.parse(inputSource);
- }
- else
- {
- doc = docBuilder.parse(in);
- }
-
- addFileByDocument(path, doc);
- doc.getDocumentElement().normalize();
- return doc;
- }
- catch (SAXParseException ex)
- {
- Integer line = new Integer(ex.getLineNumber());
- Integer col = new Integer(ex.getColumnNumber());
- String message = ex.getMessage();
-
- // Configuration error on line {line}, column {col}: '{message}'
- ConfigurationException e = new ConfigurationException();
- e.setMessage(XML_PARSER_ERROR, new Object[]{line, col, message});
- e.setRootCause(ex);
- throw e;
- }
- catch (SAXException ex)
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(ex.getMessage());
- e.setRootCause(ex);
- throw e;
- }
- catch (IOException ex)
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(ex.getMessage());
- e.setRootCause(ex);
- throw e;
- }
- }
-
- protected void addFileByDocument(String path, Node node)
- {
- String shortPath = path;
- if (shortPath != null && ((shortPath.indexOf('/') != -1) || (shortPath.indexOf("\\") != -1)) )
- {
- int start = 0;
- start = shortPath.lastIndexOf('/');
- if (start == -1)
- {
- start = shortPath.lastIndexOf("\\");
- }
- shortPath = path.substring(start + 1);
- }
- fileByDocument.put(node, shortPath);
- }
-
- protected String getSourceFileOf(Node node)
- {
- return (String)fileByDocument.get(node.getOwnerDocument());
- }
-
- protected abstract void parseTopLevelConfig(Document doc);
-
- protected abstract void initializeExpressionQuery();
- protected abstract Node selectSingleNode(Node source, String expression);
- protected abstract NodeList selectNodeList(Node source, String expression);
- protected abstract Object evaluateExpression(Node source, String expression);
-
- /**
- * Recursively processes all child elements for each of the properties in the provided
- * node list.
- * <p>
- * If a property is a simple element with a text value then it is stored as a String
- * using the element name as the property name. If the same element appears again then
- * the element is converted to a List of values and further occurences are simply added
- * to the List.
- * </p>
- * <p>
- * If a property element has child elements the children are recursively processed
- * and added as a Map.
- * </p>
- * <p>
- * The sourceFileName argument is used as a parameter for token replacement in order
- * to generate a meaningful error message when a token is failed to be replaced.
- * </p>
- * @param properties the NodeList object
- * @return ConfigMap the ConfigMap object
- */
- public ConfigMap properties(NodeList properties)
- {
- return properties(properties, ConfigurationConstants.UNKNOWN_SOURCE_FILE);
- }
-
- /**
- * Recursively processes all child elements for each of the properties in the provided
- * node list.
- * <p/>
- * @param properties the NodeList object
- * @param sourceFileName the source file name
- * @return ConfigMap the ConfigMap object
- */
- public ConfigMap properties(NodeList properties, String sourceFileName)
- {
- int length = properties.getLength();
- ConfigMap map = new ConfigMap(length);
-
- for (int p = 0; p < length; p++)
- {
- Node prop = properties.item(p);
- String propName = prop.getNodeName();
-
- if (propName != null)
- {
- propName = propName.trim();
- if (prop.getNodeType() == Node.ELEMENT_NODE)
- {
- NodeList attributes = selectNodeList(prop, "@*");
- NodeList children = selectNodeList(prop, "*");
- if (children.getLength() > 0 || attributes.getLength() > 0)
- {
- ConfigMap childMap = new ConfigMap();
-
- if (children.getLength() > 0)
- childMap.addProperties(properties(children, sourceFileName));
-
- if (attributes.getLength() > 0)
- childMap.addProperties(properties(attributes, sourceFileName));
-
- map.addProperty(propName, childMap);
- }
- else
- {
- // replace tokens before setting property
- tokenReplacer.replaceToken(prop, sourceFileName);
- String propValue = evaluateExpression(prop, ".").toString();
- map.addProperty(propName, propValue);
- }
- }
- else
- {
- // replace tokens before setting property
- tokenReplacer.replaceToken(prop, sourceFileName);
- map.addProperty(propName, prop.getNodeValue());
- }
- }
- }
-
- return map;
- }
-
- /**
- * Get the item value by name if the item is present in the current node as attribute or child element.
- * <p/>
- * @param node the current Node object
- * @param name item name
- * @return String the value of item
- **/
- public String getAttributeOrChildElement(Node node, String name)
- {
- String attr = evaluateExpression(node, "@" + name).toString().trim();
- if (attr.length() == 0)
- {
- attr = evaluateExpression(node, name).toString().trim();
- }
- return attr;
- }
-
- /**
- * Check whether the required items are present in the current node as child elements.
- * <p/>
- * @param node the current Node object
- * @param allowed the String array of the allowed items
- **/
- public void allowedChildElements(Node node, String[] allowed)
- {
- NodeList children = selectNodeList(node, "*");
-
- String unexpected = unexpected(children, allowed);
- if (unexpected != null)
- {
- // Unexpected child element '{0}' found in '{1}'.
- ConfigurationException ex = new ConfigurationException();
- Object[] args = {unexpected, node.getNodeName(), getSourceFilename(node)};
- ex.setMessage(UNEXPECTED_ELEMENT, args);
- throw ex;
- }
-
- NodeList textNodes = selectNodeList(node, "text()");
- for (int i = 0; i < textNodes.getLength(); i++)
- {
- String text = evaluateExpression(textNodes.item(i), ".").toString().trim();
- if (text.length() > 0)
- {
- //Unexpected text '{0}' found in '{1}'.
- ConfigurationException ex = new ConfigurationException();
- Object[] args = {text, node.getNodeName(), getSourceFilename(node)};
- ex.setMessage(UNEXPECTED_TEXT, args);
- throw ex;
- }
- }
- }
-
- /**
- * Check whether the required items are present in the current node as attributes.
- * <p/>
- * @param node the current Node object
- * @param allowed the String array of the allowed items
- **/
-
- public void allowedAttributes(Node node, String[] allowed)
- {
- NodeList attributes = selectNodeList(node, "@*");
- String unexpectedAttribute = unexpected(attributes, allowed);
- if (unexpectedAttribute != null)
- {
- //Unexpected attribute '{0}' found in '{1}'.
- ConfigurationException ex = new ConfigurationException();
- Object[] args =
- {unexpectedAttribute, node.getNodeName(), getSourceFilename(node)};
- ex.setMessage(UNEXPECTED_ATTRIBUTE, args);
- throw ex;
- }
- }
-
- private String getSourceFilename(Node node)
- {
- return getSourceFileOf(node);
- }
-
- /**
- * Check whether the allowed items are present in the current node as elements or attributes.
- * <p/>
- * @param node the current Node object
- * @param allowed the String array of the allowed items
- **/
-
- public void allowedAttributesOrElements(Node node, String[] allowed)
- {
- allowedAttributes(node, allowed);
- allowedChildElements(node, allowed);
- }
-
- /**
- * Check whether the required items are present in the current node as elements or attributes.
- * <p/>
- * @param node the current Node object
- * @param required the String array of the required items
- **/
- public void requiredAttributesOrElements(Node node, String[] required)
- {
- String nodeName = node.getNodeName();
- NodeList attributes = selectNodeList(node, "@*");
-
- List list = new ArrayList();
- for (int i = 0; i < required.length; i++)
- {
- list.add(required[i]);
- }
-
- String missingAttribute = null;
-
- do
- {
- missingAttribute = required(attributes, list);
- if (missingAttribute != null)
- {
- Node child = selectSingleNode(node, missingAttribute);
- if (child != null)
- {
- list.remove(missingAttribute);
- }
- else
- {
- // Attribute '{0}' must be specified for element '{1}'
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(MISSING_ATTRIBUTE, new Object[]{missingAttribute, nodeName});
- throw ex;
- }
- }
- }
- while (missingAttribute != null && list.size() > 0);
- }
-
- /**
- * Check whether the required items are present in the current node (Child elements).
- * <p/>
- * @param node the current Node object
- * @param required the String array of the required items
- **/
- public void requiredChildElements(Node node, String[] required)
- {
- String nodeName = node.getNodeName();
- NodeList children = selectNodeList(node, "*");
-
- List list = new ArrayList();
- for (int i = 0; i < required.length; i++)
- {
- list.add(required[i]);
- }
-
- String missing = required(children, list);
- if (missing != null)
- {
- // Child element '{0}' must be specified for element '{1}'
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(MISSING_ELEMENT, new Object[]{missing, nodeName});
- throw ex;
- }
- }
-
- /**
- * Check whether there is any unexpected item in the node list object.
- * <p/>
- * @param attributes the current NodeList object
- * @param allowed, the String array of allowed items
- * @return Name of the first unexpected item from the list of allowed attributes, or null if all
- * items present were allowed.
- **/
- public String unexpected(NodeList attributes, String[] allowed)
- {
- for (int i = 0; i < attributes.getLength(); i++)
- {
- Node attrib = attributes.item(i);
- String attribName = attrib.getNodeName();
- boolean match = false;
-
- for (int j = 0; j < allowed.length; j++)
- {
- String a = allowed[j];
- if (a.equals(attribName))
- {
- match = true;
- break;
- }
- }
-
- if (!match)
- {
- return attribName;
- }
-
- // Go ahead and replace tokens in node values.
- tokenReplacer.replaceToken(attrib, getSourceFilename(attrib));
- }
-
- return null;
- }
-
- /**
- * Check whether all the required items are present in the node list.
- * @param attributes the NodeList object
- * @param required a list of required items
- * @return Name of the first missing item from the list of required attributes, or null if all required
- * items were present.
- **/
- public String required(NodeList attributes, List required)
- {
- for (int i = 0; i < required.size(); i++)
- {
- boolean found = false;
- String req = (String)required.get(i);
-
- Node attrib = null;
- for (int j = 0; j < attributes.getLength(); j++)
- {
- attrib = attributes.item(j);
- String attribName = attrib.getNodeName();
-
- if (req.equals(attribName))
- {
- found = true;
- break;
- }
- }
-
- if (!found)
- {
- return req;
- }
-
- // Go ahead and replace tokens in node values.
- tokenReplacer.replaceToken(attrib, getSourceFilename(attrib));
-
- }
-
- return null;
- }
-
-
- /**
- * Tests whether a configuration element's id is a valid
- * identifier. An id must be a String that is not null,
- * greater than 0 characters in length and not contain
- * any of the list delimiter characters, i.e. commas,
- * semi-colons or colons.
- * @param id the Id String
- * @return boolean true if the id string is valid identification
- * @see ConfigurationConstants#LIST_DELIMITERS
- */
- public static boolean isValidID(String id)
- {
- if (id != null && id.length() > 0 && id.length() < 256)
- {
- char[] chars = id.toCharArray();
- for (int i = 0; i < chars.length; i++)
- {
- char c = chars[i];
- if (LIST_DELIMITERS.indexOf(c) != -1)
- {
- return false;
- }
- }
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Implement {@link org.xml.sax.EntityResolver#resolveEntity(String, String)}.
- *
- * Flex Configuration does not need or use external entities, so disallow external entities
- * to prevent external entity injection attacks.
- * @param publicId the public Id
- * @param systemId the system Id
- * @throws SAXException, IOException when the parsing process failed with exceptions
- * @return InputSource the InputSource object
- */
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
- {
- // Flex Configuration does not allow external entity defined by publicId {0} and SystemId {1}
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(EXTERNAL_ENTITY_NOT_ALLOW, new Object[] { publicId, systemId });
- throw ex;
- }
-}
+/*
+ * 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.config;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import flex.messaging.util.FileUtils;
+
+/**
+ * Provides a common base for DOM / XPath based ConfigurationParsers.
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public abstract class AbstractConfigurationParser implements ConfigurationParser, ConfigurationConstants, EntityResolver
+{
+ protected ServicesConfiguration config;
+ protected DocumentBuilder docBuilder;
+ protected ConfigurationFileResolver fileResolver;
+ protected TokenReplacer tokenReplacer;
+
+ private Map fileByDocument = new HashMap();
+
+ protected AbstractConfigurationParser()
+ {
+ initializeDocumentBuilder();
+ tokenReplacer = new TokenReplacer();
+ }
+
+ /**
+ * Parse the configurations in the configuration file.
+ * <p/>
+ * @param path the configuration file path
+ * @param fileResolver the ConfigurationFileResolver object
+ * @param config the ServicesConfiguration object
+ **/
+ public void parse(String path, ConfigurationFileResolver fileResolver, ServicesConfiguration config)
+ {
+ this.config = config;
+ this.fileResolver = fileResolver;
+ Document doc = loadDocument(path, fileResolver.getConfigurationFile(path));
+ initializeExpressionQuery();
+ parseTopLevelConfig(doc);
+ }
+
+ /**
+ * Report Tokens.
+ * <p/>
+ **/
+ public void reportTokens()
+ {
+ tokenReplacer.reportTokens();
+ }
+
+ protected void initializeDocumentBuilder()
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setIgnoringComments(true);
+ factory.setIgnoringElementContentWhitespace(true);
+
+ try
+ {
+ docBuilder = factory.newDocumentBuilder();
+ docBuilder.setEntityResolver(this);
+ }
+ catch (ParserConfigurationException ex)
+ {
+ // Error initializing configuration parser.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(PARSER_INIT_ERROR);
+ e.setRootCause(ex);
+ throw e;
+ }
+ }
+
+ protected Document loadDocument(String path, InputStream in)
+ {
+ try
+ {
+ Document doc;
+
+ if (!in.markSupported())
+ in = new BufferedInputStream(in);
+
+ // Consume UTF-8 Byte Order Mark (BOM). The InputStream must support mark()
+ // as FileUtils.consumeBOM sets a mark for 3 bytes in order to check for a BOM.
+ String encoding = FileUtils.consumeBOM(in, null);
+ if (FileUtils.UTF_8.equals(encoding) || FileUtils.UTF_16.equals(encoding))
+ {
+ InputSource inputSource = new InputSource(in);
+ inputSource.setEncoding(encoding);
+ doc = docBuilder.parse(inputSource);
+ }
+ else
+ {
+ doc = docBuilder.parse(in);
+ }
+
+ addFileByDocument(path, doc);
+ doc.getDocumentElement().normalize();
+ return doc;
+ }
+ catch (SAXParseException ex)
+ {
+ Integer line = new Integer(ex.getLineNumber());
+ Integer col = new Integer(ex.getColumnNumber());
+ String message = ex.getMessage();
+
+ // Configuration error on line {line}, column {col}: '{message}'
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(XML_PARSER_ERROR, new Object[]{line, col, message});
+ e.setRootCause(ex);
+ throw e;
+ }
+ catch (SAXException ex)
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(ex.getMessage());
+ e.setRootCause(ex);
+ throw e;
+ }
+ catch (IOException ex)
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(ex.getMessage());
+ e.setRootCause(ex);
+ throw e;
+ }
+ }
+
+ protected void addFileByDocument(String path, Node node)
+ {
+ String shortPath = path;
+ if (shortPath != null && ((shortPath.indexOf('/') != -1) || (shortPath.indexOf("\\") != -1)) )
+ {
+ int start = 0;
+ start = shortPath.lastIndexOf('/');
+ if (start == -1)
+ {
+ start = shortPath.lastIndexOf("\\");
+ }
+ shortPath = path.substring(start + 1);
+ }
+ fileByDocument.put(node, shortPath);
+ }
+
+ protected String getSourceFileOf(Node node)
+ {
+ return (String)fileByDocument.get(node.getOwnerDocument());
+ }
+
+ protected abstract void parseTopLevelConfig(Document doc);
+
+ protected abstract void initializeExpressionQuery();
+ protected abstract Node selectSingleNode(Node source, String expression);
+ protected abstract NodeList selectNodeList(Node source, String expression);
+ protected abstract Object evaluateExpression(Node source, String expression);
+
+ /**
+ * Recursively processes all child elements for each of the properties in the provided
+ * node list.
+ * <p>
+ * If a property is a simple element with a text value then it is stored as a String
+ * using the element name as the property name. If the same element appears again then
+ * the element is converted to a List of values and further occurences are simply added
+ * to the List.
+ * </p>
+ * <p>
+ * If a property element has child elements the children are recursively processed
+ * and added as a Map.
+ * </p>
+ * <p>
+ * The sourceFileName argument is used as a parameter for token replacement in order
+ * to generate a meaningful error message when a token is failed to be replaced.
+ * </p>
+ * @param properties the NodeList object
+ * @return ConfigMap the ConfigMap object
+ */
+ public ConfigMap properties(NodeList properties)
+ {
+ return properties(properties, ConfigurationConstants.UNKNOWN_SOURCE_FILE);
+ }
+
+ /**
+ * Recursively processes all child elements for each of the properties in the provided
+ * node list.
+ * <p/>
+ * @param properties the NodeList object
+ * @param sourceFileName the source file name
+ * @return ConfigMap the ConfigMap object
+ */
+ public ConfigMap properties(NodeList properties, String sourceFileName)
+ {
+ int length = properties.getLength();
+ ConfigMap map = new ConfigMap(length);
+
+ for (int p = 0; p < length; p++)
+ {
+ Node prop = properties.item(p);
+ String propName = prop.getNodeName();
+
+ if (propName != null)
+ {
+ propName = propName.trim();
+ if (prop.getNodeType() == Node.ELEMENT_NODE)
+ {
+ NodeList attributes = selectNodeList(prop, "@*");
+ NodeList children = selectNodeList(prop, "*");
+ if (children.getLength() > 0 || attributes.getLength() > 0)
+ {
+ ConfigMap childMap = new ConfigMap();
+
+ if (children.getLength() > 0)
+ childMap.addProperties(properties(children, sourceFileName));
+
+ if (attributes.getLength() > 0)
+ childMap.addProperties(properties(attributes, sourceFileName));
+
+ map.addProperty(propName, childMap);
+ }
+ else
+ {
+ // replace tokens before setting property
+ tokenReplacer.replaceToken(prop, sourceFileName);
+ String propValue = evaluateExpression(prop, ".").toString();
+ map.addProperty(propName, propValue);
+ }
+ }
+ else
+ {
+ // replace tokens before setting property
+ tokenReplacer.replaceToken(prop, sourceFileName);
+ map.addProperty(propName, prop.getNodeValue());
+ }
+ }
+ }
+
+ return map;
+ }
+
+ /**
+ * Get the item value by name if the item is present in the current node as attribute or child element.
+ * <p/>
+ * @param node the current Node object
+ * @param name item name
+ * @return String the value of item
+ **/
+ public String getAttributeOrChildElement(Node node, String name)
+ {
+ String attr = evaluateExpression(node, "@" + name).toString().trim();
+ if (attr.length() == 0)
+ {
+ attr = evaluateExpression(node, name).toString().trim();
+ }
+ return attr;
+ }
+
+ /**
+ * Check whether the required items are present in the current node as child elements.
+ * <p/>
+ * @param node the current Node object
+ * @param allowed the String array of the allowed items
+ **/
+ public void allowedChildElements(Node node, String[] allowed)
+ {
+ NodeList children = selectNodeList(node, "*");
+
+ String unexpected = unexpected(children, allowed);
+ if (unexpected != null)
+ {
+ // Unexpected child element '{0}' found in '{1}'.
+ ConfigurationException ex = new ConfigurationException();
+ Object[] args = {unexpected, node.getNodeName(), getSourceFilename(node)};
+ ex.setMessage(UNEXPECTED_ELEMENT, args);
+ throw ex;
+ }
+
+ NodeList textNodes = selectNodeList(node, "text()");
+ for (int i = 0; i < textNodes.getLength(); i++)
+ {
+ String text = evaluateExpression(textNodes.item(i), ".").toString().trim();
+ if (text.length() > 0)
+ {
+ //Unexpected text '{0}' found in '{1}'.
+ ConfigurationException ex = new ConfigurationException();
+ Object[] args = {text, node.getNodeName(), getSourceFilename(node)};
+ ex.setMessage(UNEXPECTED_TEXT, args);
+ throw ex;
+ }
+ }
+ }
+
+ /**
+ * Check whether the required items are present in the current node as attributes.
+ * <p/>
+ * @param node the current Node object
+ * @param allowed the String array of the allowed items
+ **/
+
+ public void allowedAttributes(Node node, String[] allowed)
+ {
+ NodeList attributes = selectNodeList(node, "@*");
+ String unexpectedAttribute = unexpected(attributes, allowed);
+ if (unexpectedAttribute != null)
+ {
+ //Unexpected attribute '{0}' found in '{1}'.
+ ConfigurationException ex = new ConfigurationException();
+ Object[] args =
+ {unexpectedAttribute, node.getNodeName(), getSourceFilename(node)};
+ ex.setMessage(UNEXPECTED_ATTRIBUTE, args);
+ throw ex;
+ }
+ }
+
+ private String getSourceFilename(Node node)
+ {
+ return getSourceFileOf(node);
+ }
+
+ /**
+ * Check whether the allowed items are present in the current node as elements or attributes.
+ * <p/>
+ * @param node the current Node object
+ * @param allowed the String array of the allowed items
+ **/
+
+ public void allowedAttributesOrElements(Node node, String[] allowed)
+ {
+ allowedAttributes(node, allowed);
+ allowedChildElements(node, allowed);
+ }
+
+ /**
+ * Check whether the required items are present in the current node as elements or attributes.
+ * <p/>
+ * @param node the current Node object
+ * @param required the String array of the required items
+ **/
+ public void requiredAttributesOrElements(Node node, String[] required)
+ {
+ String nodeName = node.getNodeName();
+ NodeList attributes = selectNodeList(node, "@*");
+
+ List list = new ArrayList();
+ for (int i = 0; i < required.length; i++)
+ {
+ list.add(required[i]);
+ }
+
+ String missingAttribute = null;
+
+ do
+ {
+ missingAttribute = required(attributes, list);
+ if (missingAttribute != null)
+ {
+ Node child = selectSingleNode(node, missingAttribute);
+ if (child != null)
+ {
+ list.remove(missingAttribute);
+ }
+ else
+ {
+ // Attribute '{0}' must be specified for element '{1}'
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(MISSING_ATTRIBUTE, new Object[]{missingAttribute, nodeName});
+ throw ex;
+ }
+ }
+ }
+ while (missingAttribute != null && list.size() > 0);
+ }
+
+ /**
+ * Check whether the required items are present in the current node (Child elements).
+ * <p/>
+ * @param node the current Node object
+ * @param required the String array of the required items
+ **/
+ public void requiredChildElements(Node node, String[] required)
+ {
+ String nodeName = node.getNodeName();
+ NodeList children = selectNodeList(node, "*");
+
+ List list = new ArrayList();
+ for (int i = 0; i < required.length; i++)
+ {
+ list.add(required[i]);
+ }
+
+ String missing = required(children, list);
+ if (missing != null)
+ {
+ // Child element '{0}' must be specified for element '{1}'
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(MISSING_ELEMENT, new Object[]{missing, nodeName});
+ throw ex;
+ }
+ }
+
+ /**
+ * Check whether there is any unexpected item in the node list object.
+ * <p/>
+ * @param attributes the current NodeList object
+ * @param allowed, the String array of allowed items
+ * @return Name of the first unexpected item from the list of allowed attributes, or null if all
+ * items present were allowed.
+ **/
+ public String unexpected(NodeList attributes, String[] allowed)
+ {
+ for (int i = 0; i < attributes.getLength(); i++)
+ {
+ Node attrib = attributes.item(i);
+ String attribName = attrib.getNodeName();
+ boolean match = false;
+
+ for (int j = 0; j < allowed.length; j++)
+ {
+ String a = allowed[j];
+ if (a.equals(attribName))
+ {
+ match = true;
+ break;
+ }
+ }
+
+ if (!match)
+ {
+ return attribName;
+ }
+
+ // Go ahead and replace tokens in node values.
+ tokenReplacer.replaceToken(attrib, getSourceFilename(attrib));
+ }
+
+ return null;
+ }
+
+ /**
+ * Check whether all the required items are present in the node list.
+ * @param attributes the NodeList object
+ * @param required a list of required items
+ * @return Name of the first missing item from the list of required attributes, or null if all required
+ * items were present.
+ **/
+ public String required(NodeList attributes, List required)
+ {
+ for (int i = 0; i < required.size(); i++)
+ {
+ boolean found = false;
+ String req = (String)required.get(i);
+
+ Node attrib = null;
+ for (int j = 0; j < attributes.getLength(); j++)
+ {
+ attrib = attributes.item(j);
+ String attribName = attrib.getNodeName();
+
+ if (req.equals(attribName))
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ return req;
+ }
+
+ // Go ahead and replace tokens in node values.
+ tokenReplacer.replaceToken(attrib, getSourceFilename(attrib));
+
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Tests whether a configuration element's id is a valid
+ * identifier. An id must be a String that is not null,
+ * greater than 0 characters in length and not contain
+ * any of the list delimiter characters, i.e. commas,
+ * semi-colons or colons.
+ * @param id the Id String
+ * @return boolean true if the id string is valid identification
+ * @see ConfigurationConstants#LIST_DELIMITERS
+ */
+ public static boolean isValidID(String id)
+ {
+ if (id != null && id.length() > 0 && id.length() < 256)
+ {
+ char[] chars = id.toCharArray();
+ for (int i = 0; i < chars.length; i++)
+ {
+ char c = chars[i];
+ if (LIST_DELIMITERS.indexOf(c) != -1)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Implement {@link org.xml.sax.EntityResolver#resolveEntity(String, String)}.
+ *
+ * Flex Configuration does not need or use external entities, so disallow external entities
+ * to prevent external entity injection attacks.
+ * @param publicId the public Id
+ * @param systemId the system Id
+ * @throws SAXException, IOException when the parsing process failed with exceptions
+ * @return InputSource the InputSource object
+ */
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+ {
+ // Flex Configuration does not allow external entity defined by publicId {0} and SystemId {1}
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(EXTERNAL_ENTITY_NOT_ALLOW, new Object[] { publicId, systemId });
+ throw ex;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/AdapterSettings.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/AdapterSettings.java b/modules/common/src/flex/messaging/config/AdapterSettings.java
old mode 100755
new mode 100644
index 8d53ff2..0881f4f
--- a/modules/common/src/flex/messaging/config/AdapterSettings.java
+++ b/modules/common/src/flex/messaging/config/AdapterSettings.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 flex.messaging.config;
-
-/**
- * A service must register the adapters that it will use
- * to process messages. Each destination selects an adapter
- * that processes the request by referring to it by id.
- * <p>
- * Adapters can also be configured with initialization
- * properties.
- * </p>
- *
- * @see flex.messaging.services.ServiceAdapter
- * @author Peter Farland
- * @exclude
- */
-public class AdapterSettings extends PropertiesSettings
-{
- private final String id;
- private String sourceFile;
- private String className;
- private boolean defaultAdapter;
-
- /**
- * Used to construct a new set of properties to describe an adapter. Note
- * that an identity is required in order for destinations to refer to this
- * adapter.
- *
- * @param id the <code>String</code> representing the unique identity for
- * this adapter.
- */
- public AdapterSettings(String id)
- {
- super();
- this.id = id;
- }
-
- /**
- * The identity that destinations will refer to when assigning and adapter.
- *
- * @return the adapter identity as a <code>String</code>.
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * Gets the name of the Java class implementation for this adapter.
- *
- * @return String The name of the adapter implementation.
- * @see flex.messaging.services.ServiceAdapter
- */
- public String getClassName()
- {
- return className;
- }
-
- /**
- * Sets name of the Java class implementation for this adapter. The
- * implementation is resolved from the current classpath and must extend
- * <code>flex.messaging.services.ServiceAdapter</code>.
- *
- * @param name the <code>String</code>
- */
- public void setClassName(String name)
- {
- className = name;
- }
-
- /**
- * Returns a boolean flag that determines whether this adapter is the
- * default for a service's destinations. Only one default adapter can be
- * set for a given service.
- *
- * @return boolean true if this adapter is the default.
- */
- public boolean isDefault()
- {
- return defaultAdapter;
- }
-
- /**
- * Sets a flag to determine whether an adapter will be used as the default
- * (for example, in the event that a destination did not specify an adapter
- * explicitly).
- *
- * Only one default can be set for a given service.
- *
- * @param b a <code>boolean</code> flag, true if this adapter should be
- * used as the default for the service.
- */
- public void setDefault(boolean b)
- {
- defaultAdapter = b;
- }
-
- /**
- * Internal use only.
- * @exclude
- */
- String getSourceFile()
- {
- return sourceFile;
- }
-
- /**
- * Internal use only.
- * @exclude
- */
- void setSourceFile(String file)
- {
- this.sourceFile = file;
- }
-}
+/*
+ * 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.config;
+
+/**
+ * A service must register the adapters that it will use
+ * to process messages. Each destination selects an adapter
+ * that processes the request by referring to it by id.
+ * <p>
+ * Adapters can also be configured with initialization
+ * properties.
+ * </p>
+ *
+ * @see flex.messaging.services.ServiceAdapter
+ * @author Peter Farland
+ * @exclude
+ */
+public class AdapterSettings extends PropertiesSettings
+{
+ private final String id;
+ private String sourceFile;
+ private String className;
+ private boolean defaultAdapter;
+
+ /**
+ * Used to construct a new set of properties to describe an adapter. Note
+ * that an identity is required in order for destinations to refer to this
+ * adapter.
+ *
+ * @param id the <code>String</code> representing the unique identity for
+ * this adapter.
+ */
+ public AdapterSettings(String id)
+ {
+ super();
+ this.id = id;
+ }
+
+ /**
+ * The identity that destinations will refer to when assigning and adapter.
+ *
+ * @return the adapter identity as a <code>String</code>.
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Gets the name of the Java class implementation for this adapter.
+ *
+ * @return String The name of the adapter implementation.
+ * @see flex.messaging.services.ServiceAdapter
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Sets name of the Java class implementation for this adapter. The
+ * implementation is resolved from the current classpath and must extend
+ * <code>flex.messaging.services.ServiceAdapter</code>.
+ *
+ * @param name the <code>String</code>
+ */
+ public void setClassName(String name)
+ {
+ className = name;
+ }
+
+ /**
+ * Returns a boolean flag that determines whether this adapter is the
+ * default for a service's destinations. Only one default adapter can be
+ * set for a given service.
+ *
+ * @return boolean true if this adapter is the default.
+ */
+ public boolean isDefault()
+ {
+ return defaultAdapter;
+ }
+
+ /**
+ * Sets a flag to determine whether an adapter will be used as the default
+ * (for example, in the event that a destination did not specify an adapter
+ * explicitly).
+ *
+ * Only one default can be set for a given service.
+ *
+ * @param b a <code>boolean</code> flag, true if this adapter should be
+ * used as the default for the service.
+ */
+ public void setDefault(boolean b)
+ {
+ defaultAdapter = b;
+ }
+
+ /**
+ * Internal use only.
+ * @exclude
+ */
+ String getSourceFile()
+ {
+ return sourceFile;
+ }
+
+ /**
+ * Internal use only.
+ * @exclude
+ */
+ void setSourceFile(String file)
+ {
+ this.sourceFile = file;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ApacheXPathClientConfigurationParser.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ApacheXPathClientConfigurationParser.java b/modules/common/src/flex/messaging/config/ApacheXPathClientConfigurationParser.java
old mode 100755
new mode 100644
index 6ad4468..c9590ad
--- a/modules/common/src/flex/messaging/config/ApacheXPathClientConfigurationParser.java
+++ b/modules/common/src/flex/messaging/config/ApacheXPathClientConfigurationParser.java
@@ -1,87 +1,87 @@
-/*
- * 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.config;
-
-import org.apache.xpath.CachedXPathAPI;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import javax.xml.transform.TransformerException;
-
-/**
- * Uses Apache XPath on a DOM representation of a messaging configuration
- * file.
- * <p>
- * NOTE: Since reference ids are used between elements, certain
- * sections of the document need to be parsed first.
- * </p>
- *
- * @author Peter Farland
- * @exclude
- */
-public class ApacheXPathClientConfigurationParser extends ClientConfigurationParser
-{
- private CachedXPathAPI xpath;
-
- protected void initializeExpressionQuery()
- {
- this.xpath = new CachedXPathAPI();
- }
-
- protected Node selectSingleNode(Node source, String expression)
- {
- try
- {
- return xpath.selectSingleNode(source, expression);
- }
- catch (TransformerException transformerException)
- {
- throw wrapException(transformerException);
- }
- }
-
- protected NodeList selectNodeList(Node source, String expression)
- {
- try
- {
- return xpath.selectNodeList(source, expression);
- }
- catch (TransformerException transformerException)
- {
- throw wrapException(transformerException);
- }
- }
-
- protected Object evaluateExpression(Node source, String expression)
- {
- try
- {
- return xpath.eval(source, expression);
- }
- catch (TransformerException transformerException)
- {
- throw wrapException(transformerException);
- }
- }
-
- private ConfigurationException wrapException(TransformerException exception)
- {
- ConfigurationException result = new ConfigurationException();
- result.setDetails(PARSER_INTERNAL_ERROR);
- result.setRootCause(exception);
- return result;
- }
-}
+/*
+ * 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.config;
+
+import org.apache.xpath.CachedXPathAPI;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import javax.xml.transform.TransformerException;
+
+/**
+ * Uses Apache XPath on a DOM representation of a messaging configuration
+ * file.
+ * <p>
+ * NOTE: Since reference ids are used between elements, certain
+ * sections of the document need to be parsed first.
+ * </p>
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public class ApacheXPathClientConfigurationParser extends ClientConfigurationParser
+{
+ private CachedXPathAPI xpath;
+
+ protected void initializeExpressionQuery()
+ {
+ this.xpath = new CachedXPathAPI();
+ }
+
+ protected Node selectSingleNode(Node source, String expression)
+ {
+ try
+ {
+ return xpath.selectSingleNode(source, expression);
+ }
+ catch (TransformerException transformerException)
+ {
+ throw wrapException(transformerException);
+ }
+ }
+
+ protected NodeList selectNodeList(Node source, String expression)
+ {
+ try
+ {
+ return xpath.selectNodeList(source, expression);
+ }
+ catch (TransformerException transformerException)
+ {
+ throw wrapException(transformerException);
+ }
+ }
+
+ protected Object evaluateExpression(Node source, String expression)
+ {
+ try
+ {
+ return xpath.eval(source, expression);
+ }
+ catch (TransformerException transformerException)
+ {
+ throw wrapException(transformerException);
+ }
+ }
+
+ private ConfigurationException wrapException(TransformerException exception)
+ {
+ ConfigurationException result = new ConfigurationException();
+ result.setDetails(PARSER_INTERNAL_ERROR);
+ result.setRootCause(exception);
+ return result;
+ }
+}
[48/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ClientConfigurationParser.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ClientConfigurationParser.java b/modules/common/src/flex/messaging/config/ClientConfigurationParser.java
old mode 100755
new mode 100644
index 75950ca..bd1a5ab
--- a/modules/common/src/flex/messaging/config/ClientConfigurationParser.java
+++ b/modules/common/src/flex/messaging/config/ClientConfigurationParser.java
@@ -1,952 +1,952 @@
-/*
- * 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.config;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * A special mxmlc compiler specific implentation of the configuration
- * parser for JDK 1.4. Only a small subset of the configuration is
- * processed to generate the information that the client needs at runtime,
- * such as channel definitions and service destination properties.
- *
- * @author Peter Farland
- * @exclude
- */
-public abstract class ClientConfigurationParser extends AbstractConfigurationParser
-{
- protected void parseTopLevelConfig(Document doc)
- {
- Node root = selectSingleNode(doc, "/" + SERVICES_CONFIG_ELEMENT);
-
- if (root != null)
- {
- // Validation
- allowedChildElements(root, SERVICES_CONFIG_CHILDREN);
-
- // Channels (parse before services)
- channelsSection(root);
-
- // Services
- services(root);
-
- // Clustering
- clusters(root);
-
- // FlexClient
- flexClient(root);
- }
- }
-
- private void channelsSection(Node root)
- {
- Node channelsNode = selectSingleNode(root, CHANNELS_ELEMENT);
- if (channelsNode != null)
- {
- // Validation
- allowedAttributesOrElements(channelsNode, CHANNELS_CHILDREN);
-
- NodeList channels = selectNodeList(channelsNode, CHANNEL_DEFINITION_ELEMENT);
- for (int i = 0; i < channels.getLength(); i++)
- {
- Node channel = channels.item(i);
- channelDefinition(channel);
- }
- NodeList includes = selectNodeList(channelsNode, CHANNEL_INCLUDE_ELEMENT);
- for (int i = 0; i < includes.getLength(); i++)
- {
- Node include = includes.item(i);
- channelInclude(include);
- }
- }
- }
-
- private void channelDefinition(Node channel)
- {
- // Validation
- requiredAttributesOrElements(channel, CHANNEL_DEFINITION_REQ_CHILDREN);
- allowedAttributesOrElements(channel, CHANNEL_DEFINITION_CHILDREN);
-
- String id = getAttributeOrChildElement(channel, ID_ATTR).trim();
- if (isValidID(id))
- {
- // Don't allow multiple channels with the same id
- if (config.getChannelSettings(id) != null)
- {
- // Cannot have multiple channels with the same id ''{0}''.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(DUPLICATE_CHANNEL_ERROR, new Object[]{id});
- throw e;
- }
-
- ChannelSettings channelSettings = new ChannelSettings(id);
-
- // Endpoint
- Node endpoint = selectSingleNode(channel, ENDPOINT_ELEMENT);
- if (endpoint != null)
- {
- // Endpoint Validation
- allowedAttributesOrElements(endpoint, ENDPOINT_CHILDREN);
-
- // The url attribute may also be specified by the deprecated uri attribute
- String uri = getAttributeOrChildElement(endpoint, URL_ATTR);
- if (uri == null || EMPTY_STRING.equals(uri))
- uri = getAttributeOrChildElement(endpoint, URI_ATTR);
- channelSettings.setUri(uri);
-
- config.addChannelSettings(id, channelSettings);
- }
-
- channelServerOnlyAttribute(channel, channelSettings);
-
- // Add the channel properties that the client needs namely polling-enabled,
- // polling-interval-millis, piggybacking-enabled, login-after-disconnect,
- // record-message-sizes, record-message-times, connect-timeout-seconds,
- // polling-interval-seconds (deprecated), and client-load-balancing.
- addProperty(channel, channelSettings, POLLING_ENABLED_ELEMENT);
- addProperty(channel, channelSettings, POLLING_INTERVAL_MILLIS_ELEMENT);
- addProperty(channel, channelSettings, PIGGYBACKING_ENABLED_ELEMENT);
- addProperty(channel, channelSettings, LOGIN_AFTER_DISCONNECT_ELEMENT);
- addProperty(channel, channelSettings, RECORD_MESSAGE_SIZES_ELEMENT);
- addProperty(channel, channelSettings, RECORD_MESSAGE_TIMES_ELEMENT);
- addProperty(channel, channelSettings, CONNECT_TIMEOUT_SECONDS_ELEMENT);
- addProperty(channel, channelSettings, POLLING_INTERVAL_SECONDS_ELEMENT); // deprecated.
- addProperty(channel, channelSettings, CLIENT_LOAD_BALANCING_ELEMENT);
- addProperty(channel, channelSettings, REQUEST_TIMEOUT_SECONDS_ELEMENT);
-
- // enable-small-messages.
- NodeList properties = selectNodeList(channel, PROPERTIES_ELEMENT + "/" + SERIALIZATION_ELEMENT);
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(channel));
- ConfigMap serialization = map.getPropertyAsMap(SERIALIZATION_ELEMENT, null);
- if (serialization != null)
- {
- // enable-small-messages.
- String enableSmallMessages = serialization.getProperty(ENABLE_SMALL_MESSAGES_ELEMENT);
- if (enableSmallMessages != null)
- {
- ConfigMap clientMap = new ConfigMap();
- clientMap.addProperty(ENABLE_SMALL_MESSAGES_ELEMENT, enableSmallMessages);
- channelSettings.addProperty(SERIALIZATION_ELEMENT, clientMap);
- }
- }
- }
- }
- else
- {
- // Invalid {CHANNEL_DEFINITION_ELEMENT} id '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_ID, new Object[]{CHANNEL_DEFINITION_ELEMENT, id});
- String details = "An id must be non-empty and not contain any list delimiter characters, i.e. commas, semi-colons or colons.";
- ex.setDetails(details);
- throw ex;
- }
- }
-
- private void channelServerOnlyAttribute(Node channel, ChannelSettings channelSettings)
- {
- String clientType = getAttributeOrChildElement(channel, CLASS_ATTR);
- clientType = clientType.length() > 0? clientType : null;
-
- String serverOnlyString = getAttributeOrChildElement(channel, SERVER_ONLY_ATTR);
- boolean serverOnly = serverOnlyString.length() > 0 && Boolean.valueOf(serverOnlyString).booleanValue();
-
- if (clientType == null && !serverOnly) // None set.
- {
- String url = channelSettings.getUri();
- boolean serverOnlyProtocol = (url.startsWith("samfsocket") || url.startsWith("amfsocket") || url.startsWith("ws"));
- if (!serverOnlyProtocol)
- {
- // Endpoint ''{0}'' needs to have either class or server-only attribute defined.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(CLASS_OR_SERVER_ONLY_ERROR, new Object[]{channelSettings.getId()});
- throw ce;
- }
- channelSettings.setServerOnly(true);
- }
- else if (clientType != null && serverOnly) // Both set.
- {
- // Endpoint ''{0}'' cannot have both class and server-only attribute defined.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(CLASS_AND_SERVER_ONLY_ERROR, new Object[]{channelSettings.getId()});
- throw ce;
- }
- else // One of them set.
- {
- if (serverOnly)
- channelSettings.setServerOnly(true);
- else
- channelSettings.setClientType(clientType);
- }
- }
-
- private void addProperty(Node channel, ChannelSettings channelSettings, String property)
- {
- NodeList properties = selectNodeList(channel, PROPERTIES_ELEMENT + "/" + property);
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(channel));
- if (CLIENT_LOAD_BALANCING_ELEMENT.equals(property))
- {
- ConfigMap clientLoadBalancingMap = map.getPropertyAsMap(CLIENT_LOAD_BALANCING_ELEMENT, null);
- if (clientLoadBalancingMap == null)
- {
- // Invalid {0} configuration for endpoint ''{1}''; no urls defined.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(ERR_MSG_EMPTY_CLIENT_LOAD_BALANCING_ELEMENT, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, channelSettings.getId()});
- throw ce;
- }
- List urls = clientLoadBalancingMap.getPropertyAsList(URL_ATTR, null);
- addClientLoadBalancingUrls(urls, channelSettings.getId());
- }
- channelSettings.addProperties(map);
- }
- }
-
- // Add client load balancing urls after necessary validation checks.
- private void addClientLoadBalancingUrls(List urls, String endpointId)
- {
- if (urls == null || urls.isEmpty())
- {
- // Invalid {0} configuration for endpoint ''{1}''; no urls defined.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(ERR_MSG_EMPTY_CLIENT_LOAD_BALANCING_ELEMENT, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, endpointId});
- throw ce;
- }
-
- Set clientLoadBalancingUrls = new HashSet();
- for (Iterator iterator = urls.iterator(); iterator.hasNext();)
- {
- String url = (String) iterator.next();
- if (url == null || url.length() == 0)
- {
- // Invalid {0} configuration for endpoint ''{1}''; cannot add empty url.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(ERR_MSG_EMTPY_CLIENT_LOAD_BALACNING_URL, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, endpointId});
- throw ce;
- }
-
- if (TokenReplacer.containsTokens(url))
- {
- // Invalid {0} configuration for endpoint ''{1}''; cannot add url with tokens.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(ERR_MSG_CLIENT_LOAD_BALANCING_URL_WITH_TOKEN, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, endpointId});
- throw ce;
- }
-
- if (clientLoadBalancingUrls.contains(url))
- iterator.remove();
- else
- clientLoadBalancingUrls.add(url);
- }
-
- }
-
- private void channelInclude(Node channelInclude)
- {
- // Validation
- allowedAttributesOrElements(channelInclude, CHANNEL_INCLUDE_CHILDREN);
-
- String src = getAttributeOrChildElement(channelInclude, SRC_ATTR);
- String dir = getAttributeOrChildElement(channelInclude, DIRECTORY_ATTR);
- if (src.length() > 0)
- {
- channelIncludeFile(src);
- }
- else if (dir.length() > 0)
- {
- channelIncludeDirectory(dir);
- }
- else
- {
- // The include element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{channelInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
- throw ex;
- }
- }
-
- private void channelIncludeFile(String src)
- {
- Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
- if (fileResolver instanceof LocalFileResolver)
- {
- LocalFileResolver local = (LocalFileResolver)fileResolver;
- ((ClientConfiguration)config).addConfigPath(local.getIncludedPath(src), local.getIncludedLastModified(src));
- }
-
- doc.getDocumentElement().normalize();
-
- // Check for multiple channels in a single file.
- Node channelsNode = selectSingleNode(doc, CHANNELS_ELEMENT);
- if (channelsNode != null)
- {
- allowedChildElements(channelsNode, CHANNELS_CHILDREN);
- NodeList channels = selectNodeList(channelsNode, CHANNEL_DEFINITION_ELEMENT);
- for (int a = 0; a < channels.getLength(); a++)
- {
- Node service = channels.item(a);
- channelDefinition(service);
- }
- fileResolver.popIncludedFile();
- }
- else // Check for single channel in the file.
- {
- Node channel = selectSingleNode(doc, "/" + CHANNEL_DEFINITION_ELEMENT);
- if (channel != null)
- {
- channelDefinition(channel);
- fileResolver.popIncludedFile();
- }
- else
- {
- // The {0} root element in file {1} must be '{CHANNELS_ELEMENT}' or '{CHANNEL_ELEMENT}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{CHANNEL_INCLUDE_ELEMENT, src, CHANNELS_ELEMENT, CHANNEL_DEFINITION_ELEMENT});
- throw ex;
- }
- }
- }
-
- private void channelIncludeDirectory(String dir)
- {
- List files = fileResolver.getFiles(dir);
- for (int i = 0; i < files.size(); i++)
- {
- String src = (String) files.get(i);
- channelIncludeFile(src);
- }
- }
-
- private void services(Node root)
- {
- Node servicesNode = selectSingleNode(root, SERVICES_ELEMENT);
- if (servicesNode != null)
- {
- // Validation
- allowedChildElements(servicesNode, SERVICES_CHILDREN);
-
- // Default Channels for the application
- Node defaultChannels = selectSingleNode(servicesNode, DEFAULT_CHANNELS_ELEMENT);
- if (defaultChannels != null)
- {
- allowedChildElements(defaultChannels, DEFAULT_CHANNELS_CHILDREN);
- NodeList channels = selectNodeList(defaultChannels, CHANNEL_ELEMENT);
- for (int c = 0; c < channels.getLength(); c++)
- {
- Node chan = channels.item(c);
- allowedAttributes(chan, new String[] {REF_ATTR});
- defaultChannel(chan);
- }
- }
-
- // Service Includes
- NodeList services = selectNodeList(servicesNode, SERVICE_INCLUDE_ELEMENT);
- for (int i = 0; i < services.getLength(); i++)
- {
- Node service = services.item(i);
- serviceInclude(service);
- }
-
- // Service
- services = selectNodeList(servicesNode, SERVICE_ELEMENT);
- for (int i = 0; i < services.getLength(); i++)
- {
- Node service = services.item(i);
- service(service);
- }
- }
- }
-
- private void clusters(Node root)
- {
- Node clusteringNode = selectSingleNode(root, CLUSTERS_ELEMENT);
- if (clusteringNode != null)
- {
- allowedAttributesOrElements(clusteringNode, CLUSTERING_CHILDREN);
-
- NodeList clusters = selectNodeList(clusteringNode, CLUSTER_DEFINITION_ELEMENT);
- for (int i = 0; i < clusters.getLength(); i++)
- {
- Node cluster = clusters.item(i);
- requiredAttributesOrElements(cluster, CLUSTER_DEFINITION_CHILDREN);
- String clusterName = getAttributeOrChildElement(cluster, ID_ATTR);
- if (isValidID(clusterName))
- {
- String propsFileName = getAttributeOrChildElement(cluster, CLUSTER_PROPERTIES_ATTR);
- ClusterSettings clusterSettings = new ClusterSettings();
- clusterSettings.setClusterName(clusterName);
- clusterSettings.setPropsFileName(propsFileName);
- String defaultValue = getAttributeOrChildElement(cluster, ClusterSettings.DEFAULT_ELEMENT);
- if (defaultValue != null && defaultValue.length() > 0)
- {
- if (defaultValue.equalsIgnoreCase("true"))
- clusterSettings.setDefault(true);
- else if (!defaultValue.equalsIgnoreCase("false"))
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(10215, new Object[] {clusterName, defaultValue});
- throw e;
- }
- }
- String ulb = getAttributeOrChildElement(cluster, ClusterSettings.URL_LOAD_BALANCING);
- if (ulb != null && ulb.length() > 0)
- {
- if (ulb.equalsIgnoreCase("false"))
- clusterSettings.setURLLoadBalancing(false);
- else if (!ulb.equalsIgnoreCase("true"))
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(10216, new Object[] {clusterName, ulb});
- throw e;
- }
- }
- ((ClientConfiguration)config).addClusterSettings(clusterSettings);
- }
- }
- }
- }
-
- private void serviceInclude(Node serviceInclude)
- {
- // Validation
- allowedAttributesOrElements(serviceInclude, SERVICE_INCLUDE_CHILDREN);
-
- String src = getAttributeOrChildElement(serviceInclude, SRC_ATTR);
- String dir = getAttributeOrChildElement(serviceInclude, DIRECTORY_ATTR);
- if (src.length() > 0)
- {
- serviceIncludeFile(src);
- }
- else if (dir.length() > 0)
- {
- serviceIncludeDirectory(dir);
- }
- else
- {
- // The include element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{serviceInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
- throw ex;
- }
- }
-
- private void serviceIncludeFile(String src)
- {
- Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
- if (fileResolver instanceof LocalFileResolver)
- {
- LocalFileResolver local = (LocalFileResolver)fileResolver;
- ((ClientConfiguration)config).addConfigPath(local.getIncludedPath(src), local.getIncludedLastModified(src));
- }
-
- doc.getDocumentElement().normalize();
-
- // Check for multiple services defined in file.
- Node servicesNode = selectSingleNode(doc, SERVICES_ELEMENT);
- if (servicesNode != null)
- {
- allowedChildElements(servicesNode, SERVICES_CHILDREN);
- NodeList services = selectNodeList(servicesNode, SERVICES_ELEMENT);
- for (int a = 0; a < services.getLength(); a++)
- {
- Node service = services.item(a);
- service(service);
- }
- fileResolver.popIncludedFile();
- }
- else // Check for single service in file.
- {
- Node service = selectSingleNode(doc, "/" + SERVICE_ELEMENT);
- if (service != null)
- {
- service(service);
- fileResolver.popIncludedFile();
- }
- else
- {
- // The {0} root element in file {1} must be ''{2}'' or ''{3}''.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{SERVICE_INCLUDE_ELEMENT, src, SERVICES_ELEMENT, SERVICE_ELEMENT});
- throw ex;
- }
- }
- }
-
- private void serviceIncludeDirectory(String dir)
- {
- List files = fileResolver.getFiles(dir);
- for (int i = 0; i < files.size(); i++)
- {
- String src = (String) files.get(i);
- serviceIncludeFile(src);
- }
- }
-
- private void service(Node service)
- {
- // Validation
- requiredAttributesOrElements(service, SERVICE_REQ_CHILDREN);
- allowedAttributesOrElements(service, SERVICE_CHILDREN);
-
- String id = getAttributeOrChildElement(service, ID_ATTR);
- if (isValidID(id))
- {
- ServiceSettings serviceSettings = config.getServiceSettings(id);
- if (serviceSettings == null)
- {
- serviceSettings = new ServiceSettings(id);
- // Service Properties
- NodeList properties = selectNodeList(service, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(service));
- serviceSettings.addProperties(map);
- }
- config.addServiceSettings(serviceSettings);
- }
- else
- {
- // Duplicate service definition '{0}'.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(DUPLICATE_SERVICE_ERROR, new Object[]{id});
- throw e;
- }
-
- // Service Class Name
- String className = getAttributeOrChildElement(service, CLASS_ATTR);
- if (className.length() > 0)
- {
- serviceSettings.setClassName(className);
- }
- else
- {
- // Class not specified for {SERVICE_ELEMENT} '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(CLASS_NOT_SPECIFIED, new Object[]{SERVICE_ELEMENT, id});
- throw ex;
- }
-
- //Service Message Types - deprecated
-
- // Default Channels
- Node defaultChannels = selectSingleNode(service, DEFAULT_CHANNELS_ELEMENT);
- if (defaultChannels != null)
- {
- allowedChildElements(defaultChannels, DEFAULT_CHANNELS_CHILDREN);
- NodeList channels = selectNodeList(defaultChannels, CHANNEL_ELEMENT);
- for (int c = 0; c < channels.getLength(); c++)
- {
- Node chan = channels.item(c);
- allowedAttributes(chan, new String[] {REF_ATTR});
- defaultChannel(chan, serviceSettings);
- }
- }
- // Fall back on application's default channels
- else if (config.getDefaultChannels().size() > 0)
- {
- for (Iterator iter = config.getDefaultChannels().iterator(); iter.hasNext();)
- {
- String channelId = (String)iter.next();
- ChannelSettings channel = config.getChannelSettings(channelId);
- serviceSettings.addDefaultChannel(channel);
- }
- }
-
- // Destinations
- NodeList list = selectNodeList(service, DESTINATION_ELEMENT);
- for (int i = 0; i < list.getLength(); i++)
- {
- Node dest = list.item(i);
- destination(dest, serviceSettings);
- }
-
- // Destination Includes
- list = selectNodeList(service, DESTINATION_INCLUDE_ELEMENT);
- for (int i = 0; i < list.getLength(); i++)
- {
- Node dest = list.item(i);
- destinationInclude(dest, serviceSettings);
- }
- }
- else
- {
- //Invalid {SERVICE_ELEMENT} id '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_ID, new Object[]{SERVICE_ELEMENT, id});
- throw ex;
- }
- }
-
- /**
- * Flex application can declare default channels for its services. If a
- * service specifies its own list of channels it overrides these defaults.
- * <p>
- * <default-channels><br />
- * ;<channel ref="channel-id" /><br />
- * <default-channels>
- * </p>
- * @param chan the channel node
- */
- private void defaultChannel(Node chan)
- {
- String ref = getAttributeOrChildElement(chan, REF_ATTR);
-
- if (ref.length() > 0)
- {
- ChannelSettings channel = config.getChannelSettings(ref);
- if (channel != null)
- {
- config.addDefaultChannel(channel.getId());
- }
- else
- {
- // {0} not found for reference '{1}'
- ConfigurationException e = new ConfigurationException();
- e.setMessage(REF_NOT_FOUND, new Object[]{CHANNEL_ELEMENT, ref});
- throw e;
- }
- }
- else
- {
- //A default channel was specified without a reference for service '{0}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_DEFAULT_CHANNEL, new Object[]{"MessageBroker"});
- throw ex;
- }
- }
-
- /**
- * A service can declare default channels for its destinations. If a destination
- * specifies its own list of channels it overrides these defaults.
- * <p>
- * <default-channels><br />
- * <channel ref="channel-id" /><br />
- * <default-channels>
- * </p>
- * @param chan the channel node
- * @param serviceSettings service settings
- */
- private void defaultChannel(Node chan, ServiceSettings serviceSettings)
- {
- String ref = getAttributeOrChildElement(chan, REF_ATTR).trim();
-
- if (ref.length() > 0)
- {
- ChannelSettings channel = config.getChannelSettings(ref);
- if (channel != null)
- {
- serviceSettings.addDefaultChannel(channel);
- }
- else
- {
- // {0} not found for reference '{1}'
- ConfigurationException e = new ConfigurationException();
- e.setMessage(REF_NOT_FOUND, new Object[]{CHANNEL_ELEMENT, ref});
- throw e;
- }
- }
- else
- {
- //A default channel was specified without a reference for service '{0}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_DEFAULT_CHANNEL, new Object[]{serviceSettings.getId()});
- throw ex;
- }
- }
-
- private void destinationInclude(Node destInclude, ServiceSettings serviceSettings)
- {
- // Validation
- allowedAttributesOrElements(destInclude, DESTINATION_INCLUDE_CHILDREN);
-
- String src = getAttributeOrChildElement(destInclude, SRC_ATTR);
- String dir = getAttributeOrChildElement(destInclude, DIRECTORY_ATTR);
- if (src.length() > 0)
- {
- destinationIncludeFile(serviceSettings, src);
- }
- else if (dir.length() > 0)
- {
- destinationIncludeDirectory(serviceSettings, dir);
- }
- else
- {
- // The include element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{destInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
- throw ex;
- }
- }
-
- private void destinationIncludeDirectory(ServiceSettings serviceSettings, String dir)
- {
- List files = fileResolver.getFiles(dir);
- for (int i = 0; i < files.size(); i++)
- {
- String src = (String) files.get(i);
- destinationIncludeFile(serviceSettings, src);
- }
- }
-
- private void destinationIncludeFile(ServiceSettings serviceSettings, String src)
- {
- Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
- if (fileResolver instanceof LocalFileResolver)
- {
- LocalFileResolver local = (LocalFileResolver)fileResolver;
- ((ClientConfiguration)config).addConfigPath(local.getIncludedPath(src), local.getIncludedLastModified(src));
- }
-
- doc.getDocumentElement().normalize();
-
- // Check for multiple destination defined in file.
- Node destinationsNode = selectSingleNode(doc, DESTINATIONS_ELEMENT);
- if (destinationsNode != null)
- {
- allowedChildElements(destinationsNode, DESTINATIONS_CHILDREN);
- NodeList destinations = selectNodeList(destinationsNode, DESTINATION_ELEMENT);
- for (int a = 0; a < destinations.getLength(); a++)
- {
- Node dest = destinations.item(a);
- destination(dest, serviceSettings);
- }
- fileResolver.popIncludedFile();
- }
- else // Check for single destination definition.
- {
- Node dest = selectSingleNode(doc, "/" + DESTINATION_ELEMENT);
- if (dest != null)
- {
- destination(dest, serviceSettings);
- fileResolver.popIncludedFile();
- }
- else
- {
- // The {0} root element in file {1} must be ''{2}'' or ''{3}''.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{DESTINATION_INCLUDE_ELEMENT, src, DESTINATIONS_ELEMENT, DESTINATION_ELEMENT});
- throw ex;
- }
- }
- }
-
- private void destination(Node dest, ServiceSettings serviceSettings)
- {
- // Validation
- requiredAttributesOrElements(dest, DESTINATION_REQ_CHILDREN);
- allowedAttributes(dest, DESTINATION_ATTR);
- allowedChildElements(dest, DESTINATION_CHILDREN);
-
- String serviceId = serviceSettings.getId();
-
- DestinationSettings destinationSettings;
- String id = getAttributeOrChildElement(dest, ID_ATTR);
- if (isValidID(id))
- {
- destinationSettings = (DestinationSettings)serviceSettings.getDestinationSettings().get(id);
- if (destinationSettings != null)
- {
- // Duplicate destination definition '{id}' in service '{serviceId}'.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(DUPLICATE_DESTINATION_ERROR, new Object[]{id, serviceId});
- throw e;
- }
-
- destinationSettings = new DestinationSettings(id);
- serviceSettings.addDestinationSettings(destinationSettings);
- }
- else
- {
- //Invalid {DESTINATION_ELEMENT} id '{id}' for service '{serviceId}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_ID_IN_SERVICE, new Object[]{DESTINATION_ELEMENT, id, serviceId});
- throw ex;
- }
-
- // Destination Properties
- NodeList properties = selectNodeList(dest, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(dest));
- destinationSettings.addProperties(map);
- }
-
- // Channels
- destinationChannels(dest, destinationSettings, serviceSettings);
-
- }
-
- private void destinationChannels(Node dest, DestinationSettings destinationSettings, ServiceSettings serviceSettings)
- {
- String destId = destinationSettings.getId();
-
- // Channels attribute
- String channelsList = evaluateExpression(dest, "@" + CHANNELS_ATTR).toString().trim();
- if (channelsList.length() > 0)
- {
- StringTokenizer st = new StringTokenizer(channelsList, LIST_DELIMITERS);
- while (st.hasMoreTokens())
- {
- String ref = st.nextToken().trim();
- ChannelSettings channel = config.getChannelSettings(ref);
- if (channel != null)
- {
- destinationSettings.addChannelSettings(channel);
- }
- else
- {
- // {CHANNEL_ELEMENT} not found for reference '{ref}' in destination '{destId}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(REF_NOT_FOUND_IN_DEST, new Object[]{CHANNEL_ELEMENT, ref, destId});
- throw ex;
- }
- }
- }
- else
- {
- // Channels element
- Node channelsNode = selectSingleNode(dest, CHANNELS_ELEMENT);
- if (channelsNode != null)
- {
- allowedChildElements
- (channelsNode, DESTINATION_CHANNELS_CHILDREN);
- NodeList channels = selectNodeList(channelsNode, CHANNEL_ELEMENT);
- if (channels.getLength() > 0)
- {
- for (int c = 0; c < channels.getLength(); c++)
- {
- Node chan = channels.item(c);
-
- // Validation
- requiredAttributesOrElements(chan, DESTINATION_CHANNEL_REQ_CHILDREN);
-
- String ref = getAttributeOrChildElement(chan, REF_ATTR).trim();
- if (ref.length() > 0)
- {
- ChannelSettings channel = config.getChannelSettings(ref);
- if (channel != null)
- {
- destinationSettings.addChannelSettings(channel);
- }
- else
- {
- // {CHANNEL_ELEMENT} not found for reference '{ref}' in destination '{destId}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(REF_NOT_FOUND_IN_DEST, new Object[]{CHANNEL_ELEMENT, ref, destId});
- throw ex;
- }
- }
- else
- {
- //Invalid {0} ref '{1}' in destination '{2}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_REF_IN_DEST, new Object[]{CHANNEL_ELEMENT, ref, destId});
- throw ex;
- }
- }
- }
- }
- else
- {
- // Finally, we fall back to the service's default channels
- List defaultChannels = serviceSettings.getDefaultChannels();
- Iterator it = defaultChannels.iterator();
- while (it.hasNext())
- {
- ChannelSettings channel = (ChannelSettings)it.next();
- destinationSettings.addChannelSettings(channel);
- }
- }
- }
-
- if (destinationSettings.getChannelSettings().size() <= 0)
- {
- // Destination '{id}' must specify at least one channel.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(DEST_NEEDS_CHANNEL, new Object[]{destId});
- throw ex;
- }
- }
-
- private void flexClient(Node root)
- {
- Node flexClient = selectSingleNode(root, FLEX_CLIENT_ELEMENT);
- if (flexClient != null)
- {
- FlexClientSettings flexClientSettings = new FlexClientSettings();
- // Reliable reconnect duration millis
- String reliableReconnectDurationMillis = getAttributeOrChildElement(flexClient, FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS);
- if (reliableReconnectDurationMillis.length() > 0)
- {
- try
- {
- int millis = Integer.parseInt(reliableReconnectDurationMillis);
- if (millis < 0)
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(INVALID_FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS, new Object[]{reliableReconnectDurationMillis});
- throw e;
- }
- flexClientSettings.setReliableReconnectDurationMillis(millis);
- }
- catch (NumberFormatException nfe)
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(INVALID_FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS, new Object[]{reliableReconnectDurationMillis});
- throw e;
- }
- }
- else
- {
- flexClientSettings.setReliableReconnectDurationMillis(0); // Default is 0.
- }
- // heartbeat interval millis
- String heartbeatIntervalMillis = getAttributeOrChildElement(flexClient, FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS);
- if (heartbeatIntervalMillis.length() > 0)
- {
- try
- {
- int millis = Integer.parseInt(heartbeatIntervalMillis);
- if (millis < 0)
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(INVALID_FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS, new Object[] {heartbeatIntervalMillis});
- throw e;
- }
- flexClientSettings.setHeartbeatIntervalMillis(millis);
- }
- catch (NumberFormatException nfe)
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(INVALID_FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS, new Object[] {heartbeatIntervalMillis});
- throw e;
- }
- }
- ((ClientConfiguration)config).setFlexClientSettings(flexClientSettings);
- }
- }
-}
+/*
+ * 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.config;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A special mxmlc compiler specific implentation of the configuration
+ * parser for JDK 1.4. Only a small subset of the configuration is
+ * processed to generate the information that the client needs at runtime,
+ * such as channel definitions and service destination properties.
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public abstract class ClientConfigurationParser extends AbstractConfigurationParser
+{
+ protected void parseTopLevelConfig(Document doc)
+ {
+ Node root = selectSingleNode(doc, "/" + SERVICES_CONFIG_ELEMENT);
+
+ if (root != null)
+ {
+ // Validation
+ allowedChildElements(root, SERVICES_CONFIG_CHILDREN);
+
+ // Channels (parse before services)
+ channelsSection(root);
+
+ // Services
+ services(root);
+
+ // Clustering
+ clusters(root);
+
+ // FlexClient
+ flexClient(root);
+ }
+ }
+
+ private void channelsSection(Node root)
+ {
+ Node channelsNode = selectSingleNode(root, CHANNELS_ELEMENT);
+ if (channelsNode != null)
+ {
+ // Validation
+ allowedAttributesOrElements(channelsNode, CHANNELS_CHILDREN);
+
+ NodeList channels = selectNodeList(channelsNode, CHANNEL_DEFINITION_ELEMENT);
+ for (int i = 0; i < channels.getLength(); i++)
+ {
+ Node channel = channels.item(i);
+ channelDefinition(channel);
+ }
+ NodeList includes = selectNodeList(channelsNode, CHANNEL_INCLUDE_ELEMENT);
+ for (int i = 0; i < includes.getLength(); i++)
+ {
+ Node include = includes.item(i);
+ channelInclude(include);
+ }
+ }
+ }
+
+ private void channelDefinition(Node channel)
+ {
+ // Validation
+ requiredAttributesOrElements(channel, CHANNEL_DEFINITION_REQ_CHILDREN);
+ allowedAttributesOrElements(channel, CHANNEL_DEFINITION_CHILDREN);
+
+ String id = getAttributeOrChildElement(channel, ID_ATTR).trim();
+ if (isValidID(id))
+ {
+ // Don't allow multiple channels with the same id
+ if (config.getChannelSettings(id) != null)
+ {
+ // Cannot have multiple channels with the same id ''{0}''.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(DUPLICATE_CHANNEL_ERROR, new Object[]{id});
+ throw e;
+ }
+
+ ChannelSettings channelSettings = new ChannelSettings(id);
+
+ // Endpoint
+ Node endpoint = selectSingleNode(channel, ENDPOINT_ELEMENT);
+ if (endpoint != null)
+ {
+ // Endpoint Validation
+ allowedAttributesOrElements(endpoint, ENDPOINT_CHILDREN);
+
+ // The url attribute may also be specified by the deprecated uri attribute
+ String uri = getAttributeOrChildElement(endpoint, URL_ATTR);
+ if (uri == null || EMPTY_STRING.equals(uri))
+ uri = getAttributeOrChildElement(endpoint, URI_ATTR);
+ channelSettings.setUri(uri);
+
+ config.addChannelSettings(id, channelSettings);
+ }
+
+ channelServerOnlyAttribute(channel, channelSettings);
+
+ // Add the channel properties that the client needs namely polling-enabled,
+ // polling-interval-millis, piggybacking-enabled, login-after-disconnect,
+ // record-message-sizes, record-message-times, connect-timeout-seconds,
+ // polling-interval-seconds (deprecated), and client-load-balancing.
+ addProperty(channel, channelSettings, POLLING_ENABLED_ELEMENT);
+ addProperty(channel, channelSettings, POLLING_INTERVAL_MILLIS_ELEMENT);
+ addProperty(channel, channelSettings, PIGGYBACKING_ENABLED_ELEMENT);
+ addProperty(channel, channelSettings, LOGIN_AFTER_DISCONNECT_ELEMENT);
+ addProperty(channel, channelSettings, RECORD_MESSAGE_SIZES_ELEMENT);
+ addProperty(channel, channelSettings, RECORD_MESSAGE_TIMES_ELEMENT);
+ addProperty(channel, channelSettings, CONNECT_TIMEOUT_SECONDS_ELEMENT);
+ addProperty(channel, channelSettings, POLLING_INTERVAL_SECONDS_ELEMENT); // deprecated.
+ addProperty(channel, channelSettings, CLIENT_LOAD_BALANCING_ELEMENT);
+ addProperty(channel, channelSettings, REQUEST_TIMEOUT_SECONDS_ELEMENT);
+
+ // enable-small-messages.
+ NodeList properties = selectNodeList(channel, PROPERTIES_ELEMENT + "/" + SERIALIZATION_ELEMENT);
+ if (properties.getLength() > 0)
+ {
+ ConfigMap map = properties(properties, getSourceFileOf(channel));
+ ConfigMap serialization = map.getPropertyAsMap(SERIALIZATION_ELEMENT, null);
+ if (serialization != null)
+ {
+ // enable-small-messages.
+ String enableSmallMessages = serialization.getProperty(ENABLE_SMALL_MESSAGES_ELEMENT);
+ if (enableSmallMessages != null)
+ {
+ ConfigMap clientMap = new ConfigMap();
+ clientMap.addProperty(ENABLE_SMALL_MESSAGES_ELEMENT, enableSmallMessages);
+ channelSettings.addProperty(SERIALIZATION_ELEMENT, clientMap);
+ }
+ }
+ }
+ }
+ else
+ {
+ // Invalid {CHANNEL_DEFINITION_ELEMENT} id '{id}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_ID, new Object[]{CHANNEL_DEFINITION_ELEMENT, id});
+ String details = "An id must be non-empty and not contain any list delimiter characters, i.e. commas, semi-colons or colons.";
+ ex.setDetails(details);
+ throw ex;
+ }
+ }
+
+ private void channelServerOnlyAttribute(Node channel, ChannelSettings channelSettings)
+ {
+ String clientType = getAttributeOrChildElement(channel, CLASS_ATTR);
+ clientType = clientType.length() > 0? clientType : null;
+
+ String serverOnlyString = getAttributeOrChildElement(channel, SERVER_ONLY_ATTR);
+ boolean serverOnly = serverOnlyString.length() > 0 && Boolean.valueOf(serverOnlyString).booleanValue();
+
+ if (clientType == null && !serverOnly) // None set.
+ {
+ String url = channelSettings.getUri();
+ boolean serverOnlyProtocol = (url.startsWith("samfsocket") || url.startsWith("amfsocket") || url.startsWith("ws"));
+ if (!serverOnlyProtocol)
+ {
+ // Endpoint ''{0}'' needs to have either class or server-only attribute defined.
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(CLASS_OR_SERVER_ONLY_ERROR, new Object[]{channelSettings.getId()});
+ throw ce;
+ }
+ channelSettings.setServerOnly(true);
+ }
+ else if (clientType != null && serverOnly) // Both set.
+ {
+ // Endpoint ''{0}'' cannot have both class and server-only attribute defined.
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(CLASS_AND_SERVER_ONLY_ERROR, new Object[]{channelSettings.getId()});
+ throw ce;
+ }
+ else // One of them set.
+ {
+ if (serverOnly)
+ channelSettings.setServerOnly(true);
+ else
+ channelSettings.setClientType(clientType);
+ }
+ }
+
+ private void addProperty(Node channel, ChannelSettings channelSettings, String property)
+ {
+ NodeList properties = selectNodeList(channel, PROPERTIES_ELEMENT + "/" + property);
+ if (properties.getLength() > 0)
+ {
+ ConfigMap map = properties(properties, getSourceFileOf(channel));
+ if (CLIENT_LOAD_BALANCING_ELEMENT.equals(property))
+ {
+ ConfigMap clientLoadBalancingMap = map.getPropertyAsMap(CLIENT_LOAD_BALANCING_ELEMENT, null);
+ if (clientLoadBalancingMap == null)
+ {
+ // Invalid {0} configuration for endpoint ''{1}''; no urls defined.
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(ERR_MSG_EMPTY_CLIENT_LOAD_BALANCING_ELEMENT, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, channelSettings.getId()});
+ throw ce;
+ }
+ List urls = clientLoadBalancingMap.getPropertyAsList(URL_ATTR, null);
+ addClientLoadBalancingUrls(urls, channelSettings.getId());
+ }
+ channelSettings.addProperties(map);
+ }
+ }
+
+ // Add client load balancing urls after necessary validation checks.
+ private void addClientLoadBalancingUrls(List urls, String endpointId)
+ {
+ if (urls == null || urls.isEmpty())
+ {
+ // Invalid {0} configuration for endpoint ''{1}''; no urls defined.
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(ERR_MSG_EMPTY_CLIENT_LOAD_BALANCING_ELEMENT, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, endpointId});
+ throw ce;
+ }
+
+ Set clientLoadBalancingUrls = new HashSet();
+ for (Iterator iterator = urls.iterator(); iterator.hasNext();)
+ {
+ String url = (String) iterator.next();
+ if (url == null || url.length() == 0)
+ {
+ // Invalid {0} configuration for endpoint ''{1}''; cannot add empty url.
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(ERR_MSG_EMTPY_CLIENT_LOAD_BALACNING_URL, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, endpointId});
+ throw ce;
+ }
+
+ if (TokenReplacer.containsTokens(url))
+ {
+ // Invalid {0} configuration for endpoint ''{1}''; cannot add url with tokens.
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(ERR_MSG_CLIENT_LOAD_BALANCING_URL_WITH_TOKEN, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, endpointId});
+ throw ce;
+ }
+
+ if (clientLoadBalancingUrls.contains(url))
+ iterator.remove();
+ else
+ clientLoadBalancingUrls.add(url);
+ }
+
+ }
+
+ private void channelInclude(Node channelInclude)
+ {
+ // Validation
+ allowedAttributesOrElements(channelInclude, CHANNEL_INCLUDE_CHILDREN);
+
+ String src = getAttributeOrChildElement(channelInclude, SRC_ATTR);
+ String dir = getAttributeOrChildElement(channelInclude, DIRECTORY_ATTR);
+ if (src.length() > 0)
+ {
+ channelIncludeFile(src);
+ }
+ else if (dir.length() > 0)
+ {
+ channelIncludeDirectory(dir);
+ }
+ else
+ {
+ // The include element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{channelInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
+ throw ex;
+ }
+ }
+
+ private void channelIncludeFile(String src)
+ {
+ Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
+ if (fileResolver instanceof LocalFileResolver)
+ {
+ LocalFileResolver local = (LocalFileResolver)fileResolver;
+ ((ClientConfiguration)config).addConfigPath(local.getIncludedPath(src), local.getIncludedLastModified(src));
+ }
+
+ doc.getDocumentElement().normalize();
+
+ // Check for multiple channels in a single file.
+ Node channelsNode = selectSingleNode(doc, CHANNELS_ELEMENT);
+ if (channelsNode != null)
+ {
+ allowedChildElements(channelsNode, CHANNELS_CHILDREN);
+ NodeList channels = selectNodeList(channelsNode, CHANNEL_DEFINITION_ELEMENT);
+ for (int a = 0; a < channels.getLength(); a++)
+ {
+ Node service = channels.item(a);
+ channelDefinition(service);
+ }
+ fileResolver.popIncludedFile();
+ }
+ else // Check for single channel in the file.
+ {
+ Node channel = selectSingleNode(doc, "/" + CHANNEL_DEFINITION_ELEMENT);
+ if (channel != null)
+ {
+ channelDefinition(channel);
+ fileResolver.popIncludedFile();
+ }
+ else
+ {
+ // The {0} root element in file {1} must be '{CHANNELS_ELEMENT}' or '{CHANNEL_ELEMENT}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{CHANNEL_INCLUDE_ELEMENT, src, CHANNELS_ELEMENT, CHANNEL_DEFINITION_ELEMENT});
+ throw ex;
+ }
+ }
+ }
+
+ private void channelIncludeDirectory(String dir)
+ {
+ List files = fileResolver.getFiles(dir);
+ for (int i = 0; i < files.size(); i++)
+ {
+ String src = (String) files.get(i);
+ channelIncludeFile(src);
+ }
+ }
+
+ private void services(Node root)
+ {
+ Node servicesNode = selectSingleNode(root, SERVICES_ELEMENT);
+ if (servicesNode != null)
+ {
+ // Validation
+ allowedChildElements(servicesNode, SERVICES_CHILDREN);
+
+ // Default Channels for the application
+ Node defaultChannels = selectSingleNode(servicesNode, DEFAULT_CHANNELS_ELEMENT);
+ if (defaultChannels != null)
+ {
+ allowedChildElements(defaultChannels, DEFAULT_CHANNELS_CHILDREN);
+ NodeList channels = selectNodeList(defaultChannels, CHANNEL_ELEMENT);
+ for (int c = 0; c < channels.getLength(); c++)
+ {
+ Node chan = channels.item(c);
+ allowedAttributes(chan, new String[] {REF_ATTR});
+ defaultChannel(chan);
+ }
+ }
+
+ // Service Includes
+ NodeList services = selectNodeList(servicesNode, SERVICE_INCLUDE_ELEMENT);
+ for (int i = 0; i < services.getLength(); i++)
+ {
+ Node service = services.item(i);
+ serviceInclude(service);
+ }
+
+ // Service
+ services = selectNodeList(servicesNode, SERVICE_ELEMENT);
+ for (int i = 0; i < services.getLength(); i++)
+ {
+ Node service = services.item(i);
+ service(service);
+ }
+ }
+ }
+
+ private void clusters(Node root)
+ {
+ Node clusteringNode = selectSingleNode(root, CLUSTERS_ELEMENT);
+ if (clusteringNode != null)
+ {
+ allowedAttributesOrElements(clusteringNode, CLUSTERING_CHILDREN);
+
+ NodeList clusters = selectNodeList(clusteringNode, CLUSTER_DEFINITION_ELEMENT);
+ for (int i = 0; i < clusters.getLength(); i++)
+ {
+ Node cluster = clusters.item(i);
+ requiredAttributesOrElements(cluster, CLUSTER_DEFINITION_CHILDREN);
+ String clusterName = getAttributeOrChildElement(cluster, ID_ATTR);
+ if (isValidID(clusterName))
+ {
+ String propsFileName = getAttributeOrChildElement(cluster, CLUSTER_PROPERTIES_ATTR);
+ ClusterSettings clusterSettings = new ClusterSettings();
+ clusterSettings.setClusterName(clusterName);
+ clusterSettings.setPropsFileName(propsFileName);
+ String defaultValue = getAttributeOrChildElement(cluster, ClusterSettings.DEFAULT_ELEMENT);
+ if (defaultValue != null && defaultValue.length() > 0)
+ {
+ if (defaultValue.equalsIgnoreCase("true"))
+ clusterSettings.setDefault(true);
+ else if (!defaultValue.equalsIgnoreCase("false"))
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(10215, new Object[] {clusterName, defaultValue});
+ throw e;
+ }
+ }
+ String ulb = getAttributeOrChildElement(cluster, ClusterSettings.URL_LOAD_BALANCING);
+ if (ulb != null && ulb.length() > 0)
+ {
+ if (ulb.equalsIgnoreCase("false"))
+ clusterSettings.setURLLoadBalancing(false);
+ else if (!ulb.equalsIgnoreCase("true"))
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(10216, new Object[] {clusterName, ulb});
+ throw e;
+ }
+ }
+ ((ClientConfiguration)config).addClusterSettings(clusterSettings);
+ }
+ }
+ }
+ }
+
+ private void serviceInclude(Node serviceInclude)
+ {
+ // Validation
+ allowedAttributesOrElements(serviceInclude, SERVICE_INCLUDE_CHILDREN);
+
+ String src = getAttributeOrChildElement(serviceInclude, SRC_ATTR);
+ String dir = getAttributeOrChildElement(serviceInclude, DIRECTORY_ATTR);
+ if (src.length() > 0)
+ {
+ serviceIncludeFile(src);
+ }
+ else if (dir.length() > 0)
+ {
+ serviceIncludeDirectory(dir);
+ }
+ else
+ {
+ // The include element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{serviceInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
+ throw ex;
+ }
+ }
+
+ private void serviceIncludeFile(String src)
+ {
+ Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
+ if (fileResolver instanceof LocalFileResolver)
+ {
+ LocalFileResolver local = (LocalFileResolver)fileResolver;
+ ((ClientConfiguration)config).addConfigPath(local.getIncludedPath(src), local.getIncludedLastModified(src));
+ }
+
+ doc.getDocumentElement().normalize();
+
+ // Check for multiple services defined in file.
+ Node servicesNode = selectSingleNode(doc, SERVICES_ELEMENT);
+ if (servicesNode != null)
+ {
+ allowedChildElements(servicesNode, SERVICES_CHILDREN);
+ NodeList services = selectNodeList(servicesNode, SERVICES_ELEMENT);
+ for (int a = 0; a < services.getLength(); a++)
+ {
+ Node service = services.item(a);
+ service(service);
+ }
+ fileResolver.popIncludedFile();
+ }
+ else // Check for single service in file.
+ {
+ Node service = selectSingleNode(doc, "/" + SERVICE_ELEMENT);
+ if (service != null)
+ {
+ service(service);
+ fileResolver.popIncludedFile();
+ }
+ else
+ {
+ // The {0} root element in file {1} must be ''{2}'' or ''{3}''.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{SERVICE_INCLUDE_ELEMENT, src, SERVICES_ELEMENT, SERVICE_ELEMENT});
+ throw ex;
+ }
+ }
+ }
+
+ private void serviceIncludeDirectory(String dir)
+ {
+ List files = fileResolver.getFiles(dir);
+ for (int i = 0; i < files.size(); i++)
+ {
+ String src = (String) files.get(i);
+ serviceIncludeFile(src);
+ }
+ }
+
+ private void service(Node service)
+ {
+ // Validation
+ requiredAttributesOrElements(service, SERVICE_REQ_CHILDREN);
+ allowedAttributesOrElements(service, SERVICE_CHILDREN);
+
+ String id = getAttributeOrChildElement(service, ID_ATTR);
+ if (isValidID(id))
+ {
+ ServiceSettings serviceSettings = config.getServiceSettings(id);
+ if (serviceSettings == null)
+ {
+ serviceSettings = new ServiceSettings(id);
+ // Service Properties
+ NodeList properties = selectNodeList(service, PROPERTIES_ELEMENT + "/*");
+ if (properties.getLength() > 0)
+ {
+ ConfigMap map = properties(properties, getSourceFileOf(service));
+ serviceSettings.addProperties(map);
+ }
+ config.addServiceSettings(serviceSettings);
+ }
+ else
+ {
+ // Duplicate service definition '{0}'.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(DUPLICATE_SERVICE_ERROR, new Object[]{id});
+ throw e;
+ }
+
+ // Service Class Name
+ String className = getAttributeOrChildElement(service, CLASS_ATTR);
+ if (className.length() > 0)
+ {
+ serviceSettings.setClassName(className);
+ }
+ else
+ {
+ // Class not specified for {SERVICE_ELEMENT} '{id}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(CLASS_NOT_SPECIFIED, new Object[]{SERVICE_ELEMENT, id});
+ throw ex;
+ }
+
+ //Service Message Types - deprecated
+
+ // Default Channels
+ Node defaultChannels = selectSingleNode(service, DEFAULT_CHANNELS_ELEMENT);
+ if (defaultChannels != null)
+ {
+ allowedChildElements(defaultChannels, DEFAULT_CHANNELS_CHILDREN);
+ NodeList channels = selectNodeList(defaultChannels, CHANNEL_ELEMENT);
+ for (int c = 0; c < channels.getLength(); c++)
+ {
+ Node chan = channels.item(c);
+ allowedAttributes(chan, new String[] {REF_ATTR});
+ defaultChannel(chan, serviceSettings);
+ }
+ }
+ // Fall back on application's default channels
+ else if (config.getDefaultChannels().size() > 0)
+ {
+ for (Iterator iter = config.getDefaultChannels().iterator(); iter.hasNext();)
+ {
+ String channelId = (String)iter.next();
+ ChannelSettings channel = config.getChannelSettings(channelId);
+ serviceSettings.addDefaultChannel(channel);
+ }
+ }
+
+ // Destinations
+ NodeList list = selectNodeList(service, DESTINATION_ELEMENT);
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node dest = list.item(i);
+ destination(dest, serviceSettings);
+ }
+
+ // Destination Includes
+ list = selectNodeList(service, DESTINATION_INCLUDE_ELEMENT);
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node dest = list.item(i);
+ destinationInclude(dest, serviceSettings);
+ }
+ }
+ else
+ {
+ //Invalid {SERVICE_ELEMENT} id '{id}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_ID, new Object[]{SERVICE_ELEMENT, id});
+ throw ex;
+ }
+ }
+
+ /**
+ * Flex application can declare default channels for its services. If a
+ * service specifies its own list of channels it overrides these defaults.
+ * <p>
+ * <default-channels><br />
+ * ;<channel ref="channel-id" /><br />
+ * <default-channels>
+ * </p>
+ * @param chan the channel node
+ */
+ private void defaultChannel(Node chan)
+ {
+ String ref = getAttributeOrChildElement(chan, REF_ATTR);
+
+ if (ref.length() > 0)
+ {
+ ChannelSettings channel = config.getChannelSettings(ref);
+ if (channel != null)
+ {
+ config.addDefaultChannel(channel.getId());
+ }
+ else
+ {
+ // {0} not found for reference '{1}'
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(REF_NOT_FOUND, new Object[]{CHANNEL_ELEMENT, ref});
+ throw e;
+ }
+ }
+ else
+ {
+ //A default channel was specified without a reference for service '{0}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_DEFAULT_CHANNEL, new Object[]{"MessageBroker"});
+ throw ex;
+ }
+ }
+
+ /**
+ * A service can declare default channels for its destinations. If a destination
+ * specifies its own list of channels it overrides these defaults.
+ * <p>
+ * <default-channels><br />
+ * <channel ref="channel-id" /><br />
+ * <default-channels>
+ * </p>
+ * @param chan the channel node
+ * @param serviceSettings service settings
+ */
+ private void defaultChannel(Node chan, ServiceSettings serviceSettings)
+ {
+ String ref = getAttributeOrChildElement(chan, REF_ATTR).trim();
+
+ if (ref.length() > 0)
+ {
+ ChannelSettings channel = config.getChannelSettings(ref);
+ if (channel != null)
+ {
+ serviceSettings.addDefaultChannel(channel);
+ }
+ else
+ {
+ // {0} not found for reference '{1}'
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(REF_NOT_FOUND, new Object[]{CHANNEL_ELEMENT, ref});
+ throw e;
+ }
+ }
+ else
+ {
+ //A default channel was specified without a reference for service '{0}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_DEFAULT_CHANNEL, new Object[]{serviceSettings.getId()});
+ throw ex;
+ }
+ }
+
+ private void destinationInclude(Node destInclude, ServiceSettings serviceSettings)
+ {
+ // Validation
+ allowedAttributesOrElements(destInclude, DESTINATION_INCLUDE_CHILDREN);
+
+ String src = getAttributeOrChildElement(destInclude, SRC_ATTR);
+ String dir = getAttributeOrChildElement(destInclude, DIRECTORY_ATTR);
+ if (src.length() > 0)
+ {
+ destinationIncludeFile(serviceSettings, src);
+ }
+ else if (dir.length() > 0)
+ {
+ destinationIncludeDirectory(serviceSettings, dir);
+ }
+ else
+ {
+ // The include element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{destInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
+ throw ex;
+ }
+ }
+
+ private void destinationIncludeDirectory(ServiceSettings serviceSettings, String dir)
+ {
+ List files = fileResolver.getFiles(dir);
+ for (int i = 0; i < files.size(); i++)
+ {
+ String src = (String) files.get(i);
+ destinationIncludeFile(serviceSettings, src);
+ }
+ }
+
+ private void destinationIncludeFile(ServiceSettings serviceSettings, String src)
+ {
+ Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
+ if (fileResolver instanceof LocalFileResolver)
+ {
+ LocalFileResolver local = (LocalFileResolver)fileResolver;
+ ((ClientConfiguration)config).addConfigPath(local.getIncludedPath(src), local.getIncludedLastModified(src));
+ }
+
+ doc.getDocumentElement().normalize();
+
+ // Check for multiple destination defined in file.
+ Node destinationsNode = selectSingleNode(doc, DESTINATIONS_ELEMENT);
+ if (destinationsNode != null)
+ {
+ allowedChildElements(destinationsNode, DESTINATIONS_CHILDREN);
+ NodeList destinations = selectNodeList(destinationsNode, DESTINATION_ELEMENT);
+ for (int a = 0; a < destinations.getLength(); a++)
+ {
+ Node dest = destinations.item(a);
+ destination(dest, serviceSettings);
+ }
+ fileResolver.popIncludedFile();
+ }
+ else // Check for single destination definition.
+ {
+ Node dest = selectSingleNode(doc, "/" + DESTINATION_ELEMENT);
+ if (dest != null)
+ {
+ destination(dest, serviceSettings);
+ fileResolver.popIncludedFile();
+ }
+ else
+ {
+ // The {0} root element in file {1} must be ''{2}'' or ''{3}''.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{DESTINATION_INCLUDE_ELEMENT, src, DESTINATIONS_ELEMENT, DESTINATION_ELEMENT});
+ throw ex;
+ }
+ }
+ }
+
+ private void destination(Node dest, ServiceSettings serviceSettings)
+ {
+ // Validation
+ requiredAttributesOrElements(dest, DESTINATION_REQ_CHILDREN);
+ allowedAttributes(dest, DESTINATION_ATTR);
+ allowedChildElements(dest, DESTINATION_CHILDREN);
+
+ String serviceId = serviceSettings.getId();
+
+ DestinationSettings destinationSettings;
+ String id = getAttributeOrChildElement(dest, ID_ATTR);
+ if (isValidID(id))
+ {
+ destinationSettings = (DestinationSettings)serviceSettings.getDestinationSettings().get(id);
+ if (destinationSettings != null)
+ {
+ // Duplicate destination definition '{id}' in service '{serviceId}'.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(DUPLICATE_DESTINATION_ERROR, new Object[]{id, serviceId});
+ throw e;
+ }
+
+ destinationSettings = new DestinationSettings(id);
+ serviceSettings.addDestinationSettings(destinationSettings);
+ }
+ else
+ {
+ //Invalid {DESTINATION_ELEMENT} id '{id}' for service '{serviceId}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_ID_IN_SERVICE, new Object[]{DESTINATION_ELEMENT, id, serviceId});
+ throw ex;
+ }
+
+ // Destination Properties
+ NodeList properties = selectNodeList(dest, PROPERTIES_ELEMENT + "/*");
+ if (properties.getLength() > 0)
+ {
+ ConfigMap map = properties(properties, getSourceFileOf(dest));
+ destinationSettings.addProperties(map);
+ }
+
+ // Channels
+ destinationChannels(dest, destinationSettings, serviceSettings);
+
+ }
+
+ private void destinationChannels(Node dest, DestinationSettings destinationSettings, ServiceSettings serviceSettings)
+ {
+ String destId = destinationSettings.getId();
+
+ // Channels attribute
+ String channelsList = evaluateExpression(dest, "@" + CHANNELS_ATTR).toString().trim();
+ if (channelsList.length() > 0)
+ {
+ StringTokenizer st = new StringTokenizer(channelsList, LIST_DELIMITERS);
+ while (st.hasMoreTokens())
+ {
+ String ref = st.nextToken().trim();
+ ChannelSettings channel = config.getChannelSettings(ref);
+ if (channel != null)
+ {
+ destinationSettings.addChannelSettings(channel);
+ }
+ else
+ {
+ // {CHANNEL_ELEMENT} not found for reference '{ref}' in destination '{destId}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(REF_NOT_FOUND_IN_DEST, new Object[]{CHANNEL_ELEMENT, ref, destId});
+ throw ex;
+ }
+ }
+ }
+ else
+ {
+ // Channels element
+ Node channelsNode = selectSingleNode(dest, CHANNELS_ELEMENT);
+ if (channelsNode != null)
+ {
+ allowedChildElements
+ (channelsNode, DESTINATION_CHANNELS_CHILDREN);
+ NodeList channels = selectNodeList(channelsNode, CHANNEL_ELEMENT);
+ if (channels.getLength() > 0)
+ {
+ for (int c = 0; c < channels.getLength(); c++)
+ {
+ Node chan = channels.item(c);
+
+ // Validation
+ requiredAttributesOrElements(chan, DESTINATION_CHANNEL_REQ_CHILDREN);
+
+ String ref = getAttributeOrChildElement(chan, REF_ATTR).trim();
+ if (ref.length() > 0)
+ {
+ ChannelSettings channel = config.getChannelSettings(ref);
+ if (channel != null)
+ {
+ destinationSettings.addChannelSettings(channel);
+ }
+ else
+ {
+ // {CHANNEL_ELEMENT} not found for reference '{ref}' in destination '{destId}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(REF_NOT_FOUND_IN_DEST, new Object[]{CHANNEL_ELEMENT, ref, destId});
+ throw ex;
+ }
+ }
+ else
+ {
+ //Invalid {0} ref '{1}' in destination '{2}'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_REF_IN_DEST, new Object[]{CHANNEL_ELEMENT, ref, destId});
+ throw ex;
+ }
+ }
+ }
+ }
+ else
+ {
+ // Finally, we fall back to the service's default channels
+ List defaultChannels = serviceSettings.getDefaultChannels();
+ Iterator it = defaultChannels.iterator();
+ while (it.hasNext())
+ {
+ ChannelSettings channel = (ChannelSettings)it.next();
+ destinationSettings.addChannelSettings(channel);
+ }
+ }
+ }
+
+ if (destinationSettings.getChannelSettings().size() <= 0)
+ {
+ // Destination '{id}' must specify at least one channel.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(DEST_NEEDS_CHANNEL, new Object[]{destId});
+ throw ex;
+ }
+ }
+
+ private void flexClient(Node root)
+ {
+ Node flexClient = selectSingleNode(root, FLEX_CLIENT_ELEMENT);
+ if (flexClient != null)
+ {
+ FlexClientSettings flexClientSettings = new FlexClientSettings();
+ // Reliable reconnect duration millis
+ String reliableReconnectDurationMillis = getAttributeOrChildElement(flexClient, FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS);
+ if (reliableReconnectDurationMillis.length() > 0)
+ {
+ try
+ {
+ int millis = Integer.parseInt(reliableReconnectDurationMillis);
+ if (millis < 0)
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(INVALID_FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS, new Object[]{reliableReconnectDurationMillis});
+ throw e;
+ }
+ flexClientSettings.setReliableReconnectDurationMillis(millis);
+ }
+ catch (NumberFormatException nfe)
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(INVALID_FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS, new Object[]{reliableReconnectDurationMillis});
+ throw e;
+ }
+ }
+ else
+ {
+ flexClientSettings.setReliableReconnectDurationMillis(0); // Default is 0.
+ }
+ // heartbeat interval millis
+ String heartbeatIntervalMillis = getAttributeOrChildElement(flexClient, FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS);
+ if (heartbeatIntervalMillis.length() > 0)
+ {
+ try
+ {
+ int millis = Integer.parseInt(heartbeatIntervalMillis);
+ if (millis < 0)
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(INVALID_FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS, new Object[] {heartbeatIntervalMillis});
+ throw e;
+ }
+ flexClientSettings.setHeartbeatIntervalMillis(millis);
+ }
+ catch (NumberFormatException nfe)
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(INVALID_FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS, new Object[] {heartbeatIntervalMillis});
+ throw e;
+ }
+ }
+ ((ClientConfiguration)config).setFlexClientSettings(flexClientSettings);
+ }
+ }
+}
[14/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/ServerConfigurationParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/ServerConfigurationParser.java b/modules/core/src/flex/messaging/config/ServerConfigurationParser.java
old mode 100755
new mode 100644
index d71abb4..128b115
--- a/modules/core/src/flex/messaging/config/ServerConfigurationParser.java
+++ b/modules/core/src/flex/messaging/config/ServerConfigurationParser.java
@@ -1,1921 +1,1921 @@
-/*
- * 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.config;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.StringTokenizer;
-
-import flex.messaging.config.ThrottleSettings.Policy;
-import flex.messaging.util.LocaleUtils;
-
-/**
- * Processes DOM representation of a messaging configuration file.
- * <p>
- * Note: Since reference ids are used between elements, certain
- * sections of the document need to be parsed first.
- * </p>
- *
- * @author Peter Farland
- * @exclude
- */
-public abstract class ServerConfigurationParser extends AbstractConfigurationParser
-{
- /**
- * Used to verify that advanced messaging support has been registered if necessary.
- * If other configuration requires it, but it was not registered a ConfigurationException is thrown.
- */
- private boolean verifyAdvancedMessagingSupport = false;
- private boolean advancedMessagingSupportRegistered = false;
-
- @Override
- protected void parseTopLevelConfig(Document doc)
- {
- Node root = selectSingleNode(doc, "/" + SERVICES_CONFIG_ELEMENT);
-
- if (root != null)
- {
- allowedChildElements(root, SERVICES_CONFIG_CHILDREN);
-
- securitySection(root); // Parse security before channels.
-
- serversSection(root);
-
- channelsSection(root);
-
- services(root);
-
- clusters(root);
-
- logging(root);
-
- system(root);
-
- flexClient(root);
-
- factories(root);
-
- messageFilters(root);
-
- validators(root);
-
- // Validate that any dependencies on advanced messaging support can be satisified at runtime.
- if (verifyAdvancedMessagingSupport && !advancedMessagingSupportRegistered)
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(REQUIRE_ADVANCED_MESSAGING_SUPPORT);
- throw e;
- }
- }
- else
- {
- // The services configuration root element must be '{SERVICES_CONFIG_ELEMENT}'.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(INVALID_SERVICES_ROOT, new Object[]{SERVICES_CONFIG_ELEMENT});
- throw e;
- }
- }
-
- private void clusters(Node root)
- {
- Node clusteringNode = selectSingleNode(root, CLUSTERS_ELEMENT);
- if (clusteringNode != null)
- {
- allowedAttributesOrElements(clusteringNode, CLUSTERING_CHILDREN);
-
- NodeList clusters = selectNodeList(clusteringNode, CLUSTER_DEFINITION_ELEMENT);
- for (int i = 0; i < clusters.getLength(); i++)
- {
- Node cluster = clusters.item(i);
- requiredAttributesOrElements(cluster, CLUSTER_DEFINITION_CHILDREN);
- String clusterName = getAttributeOrChildElement(cluster, ID_ATTR);
- if (!isValidID(clusterName))
- continue;
-
- String propsFileName = getAttributeOrChildElement(cluster, CLUSTER_PROPERTIES_ATTR);
- ClusterSettings clusterSettings = new ClusterSettings();
- clusterSettings.setClusterName(clusterName);
- clusterSettings.setPropsFileName(propsFileName);
- String className = getAttributeOrChildElement(cluster, CLASS_ATTR);
- if (className != null && className.length() > 0)
- clusterSettings.setImplementationClass(className);
-
- String defaultValue = getAttributeOrChildElement(cluster, ClusterSettings.DEFAULT_ELEMENT);
- if (defaultValue != null && defaultValue.length() > 0)
- {
- if (defaultValue.equalsIgnoreCase(TRUE_STRING))
- clusterSettings.setDefault(true);
- else if (!defaultValue.equalsIgnoreCase(FALSE_STRING))
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(10215, new Object[] {clusterName, defaultValue});
- throw e;
- }
- }
- String ulb = getAttributeOrChildElement(cluster, ClusterSettings.URL_LOAD_BALANCING);
- if (ulb != null && ulb.length() > 0)
- {
- if (ulb.equalsIgnoreCase(FALSE_STRING))
- {
- clusterSettings.setURLLoadBalancing(false);
- }
- else if (!ulb.equalsIgnoreCase(TRUE_STRING))
- {
- ConfigurationException e = new ConfigurationException();
- e.setMessage(10216, new Object[] {clusterName, ulb});
- throw e;
- }
- }
-
- NodeList properties = selectNodeList(cluster, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(cluster));
- clusterSettings.addProperties(map);
- }
-
- ((MessagingConfiguration)config).addClusterSettings(clusterSettings);
-
- }
- }
- }
-
-
- private void securitySection(Node root)
- {
- Node security = selectSingleNode(root, SECURITY_ELEMENT);
-
- if (security == null)
- return;
-
- allowedChildElements(security, SECURITY_CHILDREN);
-
- NodeList list = selectNodeList(security, SECURITY_CONSTRAINT_DEFINITION_ELEMENT);
- for (int i = 0; i < list.getLength(); i++)
- {
- Node constraint = list.item(i);
- securityConstraint(constraint, false);
- }
-
- list = selectNodeList(security, CONSTRAINT_INCLUDE_ELEMENT);
- for (int i = 0; i < list.getLength(); i++)
- {
- Node include = list.item(i);
- securityConstraintInclude(include);
- }
-
- list = selectNodeList(security, LOGIN_COMMAND_ELEMENT);
- for (int i = 0; i < list.getLength(); i++)
- {
- Node login = list.item(i);
- LoginCommandSettings loginCommandSettings= new LoginCommandSettings();
- requiredAttributesOrElements(login, LOGIN_COMMAND_REQ_CHILDREN);
- allowedAttributesOrElements(login, LOGIN_COMMAND_CHILDREN);
-
- String server = getAttributeOrChildElement(login, SERVER_ATTR);
- if (server.length() == 0)
- {
- // Attribute '{SERVER_ATTR}' must be specified for element '{LOGIN_COMMAND_ELEMENT}'
- ConfigurationException e = new ConfigurationException();
- e.setMessage(MISSING_ATTRIBUTE, new Object[]{SERVER_ATTR, LOGIN_COMMAND_ELEMENT});
- throw e;
- }
- loginCommandSettings.setServer(server);
-
- String loginClass = getAttributeOrChildElement(login, CLASS_ATTR);
- if (loginClass.length() == 0)
- {
- // Attribute '{CLASS_ATTR}' must be specified for element '{LOGIN_COMMAND_ELEMENT}'
- ConfigurationException e = new ConfigurationException();
- e.setMessage(MISSING_ATTRIBUTE, new Object[]{CLASS_ATTR, LOGIN_COMMAND_ELEMENT});
- throw e;
- }
- loginCommandSettings.setClassName(loginClass);
-
- boolean isPerClientAuth = Boolean.valueOf(getAttributeOrChildElement(login, PER_CLIENT_AUTH));
- loginCommandSettings.setPerClientAuthentication(isPerClientAuth);
-
- ((MessagingConfiguration)config).getSecuritySettings().addLoginCommandSettings(loginCommandSettings);
- }
-
- boolean recreateHttpSessionAfterLogin = Boolean.valueOf(getAttributeOrChildElement(security, RECREATE_HTTPSESSION_AFTER_LOGIN_ELEMENT));
- ((MessagingConfiguration)config).getSecuritySettings().setRecreateHttpSessionAfterLogin(recreateHttpSessionAfterLogin);
- }
-
- private SecurityConstraint securityConstraint(Node constraint, boolean inline)
- {
- SecurityConstraint sc;
-
- // Validation
- allowedAttributesOrElements(constraint, SECURITY_CONSTRAINT_DEFINITION_CHILDREN);
-
- // Constraint by reference
- String ref = getAttributeOrChildElement(constraint, REF_ATTR);
- if (ref.length() > 0)
- {
- allowedAttributesOrElements(constraint, new String[] {REF_ATTR});
-
- sc = ((MessagingConfiguration)config).getSecuritySettings().getConstraint(ref);
- if (sc == null)
- {
- // {SECURITY_CONSTRAINT_DEFINITION_ELEMENT} not found for reference '{ref}'.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(REF_NOT_FOUND, new Object[]{SECURITY_CONSTRAINT_DEFINITION_ELEMENT, ref});
- throw e;
- }
- }
- else
- {
- // New security constraint
- String id = getAttributeOrChildElement(constraint, ID_ATTR);
-
- // If not inline, we must have a valid id to register the constraint!
- if (inline)
- {
- sc = new SecurityConstraint("");
- }
- else if (isValidID(id))
- {
- sc = new SecurityConstraint(id);
- ((MessagingConfiguration)config).getSecuritySettings().addConstraint(sc);
- }
- else
- {
- //Invalid {SECURITY_CONSTRAINT_DEFINITION_ELEMENT} id '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_ID, new Object[]{SECURITY_CONSTRAINT_DEFINITION_ELEMENT, id});
- ex.setDetails(INVALID_ID);
- throw ex;
- }
-
- // Authentication Method
- String method = getAttributeOrChildElement(constraint, AUTH_METHOD_ELEMENT);
- sc.setMethod(method);
-
- // Roles
- Node rolesNode = selectSingleNode(constraint, ROLES_ELEMENT);
- if (rolesNode != null)
- {
- allowedChildElements(rolesNode, ROLES_CHILDREN);
- NodeList roles = selectNodeList(rolesNode, ROLE_ELEMENT);
- for (int r = 0; r < roles.getLength(); r++)
- {
- Node roleNode = roles.item(r);
- String role = evaluateExpression(roleNode, ".").toString().trim();
- if (role.length() > 0)
- {
- sc.addRole(role);
- }
- }
- }
- }
-
- return sc;
- }
-
- private void securityConstraintInclude(Node constraintInclude)
- {
- // Validation
- allowedAttributesOrElements(constraintInclude, CONSTRAINT_INCLUDE_CHILDREN);
-
- String src = getAttributeOrChildElement(constraintInclude, SRC_ATTR);
- String dir = getAttributeOrChildElement(constraintInclude, DIRECTORY_ATTR);
- if (src.length() > 0)
- {
- constraintIncludeFile(src);
- }
- else if (dir.length() > 0)
- {
- constraintIncludeDirectory(dir);
- }
- else
- {
- // The include element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{constraintInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
- throw ex;
- }
- }
-
- private void constraintIncludeFile(String src)
- {
- Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
- doc.getDocumentElement().normalize();
-
- // Check for <security-constraints> wrapping more than one definition
- Node servicesNode = selectSingleNode(doc, SECURITY_CONSTRAINTS_ELEMENT);
- if (servicesNode != null)
- {
- allowedChildElements(servicesNode, SECURITY_CONSTRAINTS_CHILDREN);
- NodeList constraints = selectNodeList(servicesNode, SECURITY_CONSTRAINT_ELEMENT);
- for (int a = 0; a < constraints.getLength(); a++)
- {
- Node constraint = constraints.item(a);
- securityConstraint(constraint, false);
- }
- fileResolver.popIncludedFile();
- }
- else // Check for single <security-constraint>
- {
- Node constraint = selectSingleNode(doc, "/" + SECURITY_CONSTRAINT_ELEMENT);
- if (constraint != null)
- {
- securityConstraint(constraint, false);
- fileResolver.popIncludedFile();
- }
- else
- {
- // The {0} root element in file {1} must be ''{2}'' or ''{3}''.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{CONSTRAINT_INCLUDE_ELEMENT, src, SECURITY_CONSTRAINTS_ELEMENT, SECURITY_CONSTRAINT_ELEMENT});
- throw ex;
- }
- }
- }
-
- private void constraintIncludeDirectory(String dir)
- {
- List files = fileResolver.getFiles(dir);
- for (int i = 0; i < files.size(); i++)
- {
- String src = (String) files.get(i);
- constraintIncludeFile(src);
- }
- }
-
- private void serversSection(Node root)
- {
- // Only MessagingConfiguration supports the servers element configuration.
- // The general ServicesConfiguration interface does not.
- if (!(config instanceof MessagingConfiguration))
- return;
-
- Node serversNode = selectSingleNode(root, SERVERS_ELEMENT);
- if (serversNode != null)
- {
- // Validation
- allowedAttributesOrElements(serversNode, SERVERS_CHILDREN);
-
- NodeList servers = selectNodeList(serversNode, SERVER_ELEMENT);
- for (int i = 0; i < servers.getLength(); i++)
- {
- Node server = servers.item(i);
- serverDefinition(server);
- }
- }
- }
-
- private void serverDefinition(Node server)
- {
- // Validation
- requiredAttributesOrElements(server, SERVER_REQ_CHILDREN);
- allowedAttributesOrElements(server, SERVER_CHILDREN);
-
- String id = getAttributeOrChildElement(server, ID_ATTR);
- if (isValidID(id))
- {
- SharedServerSettings settings = new SharedServerSettings();
- settings.setId(id);
- settings.setSourceFile(getSourceFileOf(server));
- String className = getAttributeOrChildElement(server, CLASS_ATTR);
- if (className.length() > 0)
- {
- settings.setClassName(className);
- // Custom server properties.
- NodeList properties = selectNodeList(server, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(server));
- settings.addProperties(map);
- }
- ((MessagingConfiguration)config).addSharedServerSettings(settings);
- }
- else
- {
- // Class not specified for {MESSAGE_FILTER_ELEMENT} '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(CLASS_NOT_SPECIFIED, new Object[]{SERVER_ELEMENT, id});
- throw ex;
- }
- }
- }
-
- private void channelsSection(Node root)
- {
- Node channelsNode = selectSingleNode(root, CHANNELS_ELEMENT);
- if (channelsNode != null)
- {
- // Validation
- allowedAttributesOrElements(channelsNode, CHANNELS_CHILDREN);
-
- NodeList channels = selectNodeList(channelsNode, CHANNEL_DEFINITION_ELEMENT);
- for (int i = 0; i < channels.getLength(); i++)
- {
- Node channel = channels.item(i);
- channelDefinition(channel);
- }
-
- NodeList includes = selectNodeList(channelsNode, CHANNEL_INCLUDE_ELEMENT);
- for (int i = 0; i < includes.getLength(); i++)
- {
- Node include = includes.item(i);
- channelInclude(include);
- }
- }
- }
-
- private void channelDefinition(Node channel)
- {
- // Validation
- requiredAttributesOrElements(channel, CHANNEL_DEFINITION_REQ_CHILDREN);
- allowedAttributesOrElements(channel, CHANNEL_DEFINITION_CHILDREN);
-
- String id = getAttributeOrChildElement(channel, ID_ATTR);
- if (isValidID(id))
- {
- // Don't allow multiple channels with the same id
- if (config.getChannelSettings(id) != null)
- {
- // Cannot have multiple channels with the same id ''{0}''.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(DUPLICATE_CHANNEL_ERROR, new Object[]{id});
- throw e;
- }
-
- ChannelSettings channelSettings = new ChannelSettings(id);
- channelSettings.setSourceFile(getSourceFileOf(channel));
-
- // Note whether the channel-definition was for a remote endpoint
- String remote = getAttributeOrChildElement(channel, REMOTE_ATTR);
- channelSettings.setRemote(Boolean.valueOf(remote));
-
- // Endpoint
- Node endpoint = selectSingleNode(channel, ENDPOINT_ELEMENT);
- if (endpoint != null)
- {
- // Endpoint Validation
- allowedAttributesOrElements(endpoint, ENDPOINT_CHILDREN);
-
- String type = getAttributeOrChildElement(endpoint, CLASS_ATTR);
- channelSettings.setEndpointType(type);
-
- // The url attribute may also be specified by the deprecated uri attribute
- String uri = getAttributeOrChildElement(endpoint, URL_ATTR);
- if (uri == null || EMPTY_STRING.equals(uri))
- uri = getAttributeOrChildElement(endpoint, URI_ATTR);
- channelSettings.setUri(uri);
-
- config.addChannelSettings(id, channelSettings);
- }
-
- channelServerOnlyAttribute(channel, channelSettings);
-
- // Server reference
- Node server = selectSingleNode(channel, SERVER_ELEMENT);
- if (server != null)
- {
- requiredAttributesOrElements(server, CHANNEL_DEFINITION_SERVER_REQ_CHILDREN);
-
- String serverId = getAttributeOrChildElement(server, REF_ATTR);
- channelSettings.setServerId(serverId);
- }
-
- // Channel Properties
- NodeList properties = selectNodeList(channel, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(channel));
- channelSettings.addProperties(map);
-
- // Sniff for adaptive-frequency under flex-client-queue-processor hich requires advanced messaging support.
- if (!verifyAdvancedMessagingSupport)
- {
- ConfigMap outboundQueueProcessor = map.getPropertyAsMap(FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_ELEMENT, null);
- if (outboundQueueProcessor != null)
- {
- // Flex client queue processor properties
- ConfigMap queueProcessorProperties = outboundQueueProcessor.getPropertyAsMap(PROPERTIES_ELEMENT, null);
- if (queueProcessorProperties != null)
- {
- // Sniff for adaptive-frequency which requires advanced messaging support.
- boolean adaptiveFrequency = queueProcessorProperties.getPropertyAsBoolean(ADAPTIVE_FREQUENCY, false);
- if (adaptiveFrequency)
- verifyAdvancedMessagingSupport = true;
- }
- }
- }
- }
-
- // Channel Security
-
- // Security-constraint short-cut attribute
- String ref = evaluateExpression(channel, "@" + SECURITY_CONSTRAINT_ATTR).toString().trim();
- if (ref.length() > 0)
- {
- SecurityConstraint sc = ((MessagingConfiguration)config).getSecuritySettings().getConstraint(ref);
- if (sc != null)
- {
- channelSettings.setConstraint(sc);
- }
- else
- {
- // {SECURITY_CONSTRAINT_ELEMENT} not found for reference '{ref}' in channel '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(REF_NOT_FOUND_IN_CHANNEL, new Object[]{SECURITY_CONSTRAINT_ATTR, ref, id});
- throw ex;
- }
- }
- else
- {
- // Inline security element
- Node security = selectSingleNode(channel, SECURITY_ELEMENT);
- if (security != null)
- {
- allowedChildElements(security, EMBEDDED_SECURITY_CHILDREN);
- Node constraint = selectSingleNode(security, SECURITY_CONSTRAINT_ELEMENT);
- if (constraint != null)
- {
- SecurityConstraint sc = securityConstraint(constraint, true);
- channelSettings.setConstraint(sc);
- }
- }
- }
- }
- else
- {
- // Invalid {CHANNEL_DEFINITION_ELEMENT} id '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_ID, new Object[]{CHANNEL_DEFINITION_ELEMENT, id});
- ex.setDetails(INVALID_ID);
- throw ex;
- }
- }
-
- private void channelServerOnlyAttribute(Node channel, ChannelSettings channelSettings)
- {
- String clientType = getAttributeOrChildElement(channel, CLASS_ATTR);
- clientType = clientType.length() > 0? clientType : null;
-
- String serverOnlyString = getAttributeOrChildElement(channel, SERVER_ONLY_ATTR);
- boolean serverOnly = serverOnlyString.length() > 0? Boolean.valueOf(serverOnlyString) : false;
-
- if (clientType == null && !serverOnly) // None set.
- {
- String url = channelSettings.getUri();
- boolean serverOnlyProtocol = (url.startsWith("samfsocket") || url.startsWith("amfsocket") || url.startsWith("ws"));
- if (!serverOnlyProtocol)
- {
- // Endpoint ''{0}'' needs to have either class or server-only attribute defined.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(CLASS_OR_SERVER_ONLY_ERROR, new Object[]{channelSettings.getId()});
- throw ce;
- }
- channelSettings.setServerOnly(true);
- }
- else if (clientType != null && serverOnly) // Both set.
- {
- // Endpoint ''{0}'' cannot have both class and server-only attribute defined.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(CLASS_AND_SERVER_ONLY_ERROR, new Object[]{channelSettings.getId()});
- throw ce;
- }
- else // One of them set.
- {
- if (serverOnly)
- channelSettings.setServerOnly(true);
- else
- channelSettings.setClientType(clientType);
- }
- }
-
- private void channelInclude(Node channelInclude)
- {
- // Validation
- allowedAttributesOrElements(channelInclude, CHANNEL_INCLUDE_CHILDREN);
-
- String src = getAttributeOrChildElement(channelInclude, SRC_ATTR);
- String dir = getAttributeOrChildElement(channelInclude, DIRECTORY_ATTR);
- if (src.length() > 0)
- {
- channelIncludeFile(src);
- }
- else if (dir.length() > 0)
- {
- channelIncludeDirectory(dir);
- }
- else
- {
- // The include element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{channelInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
- throw ex;
- }
- }
-
- private void channelIncludeFile(String src)
- {
- Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
- doc.getDocumentElement().normalize();
-
- // Check for multiple channels in a single file.
- Node channelsNode = selectSingleNode(doc, CHANNELS_ELEMENT);
- if (channelsNode != null)
- {
- allowedChildElements(channelsNode, CHANNELS_CHILDREN);
- NodeList channels = selectNodeList(channelsNode, CHANNEL_DEFINITION_ELEMENT);
- for (int a = 0; a < channels.getLength(); a++)
- {
- Node service = channels.item(a);
- channelDefinition(service);
- }
- fileResolver.popIncludedFile();
- }
- else // Check for single channel in the file.
- {
- Node channel = selectSingleNode(doc, "/" + CHANNEL_DEFINITION_ELEMENT);
- if (channel != null)
- {
- channelDefinition(channel);
- fileResolver.popIncludedFile();
- }
- else
- {
- // The {0} root element in file {1} must be '{CHANNELS_ELEMENT}' or '{CHANNEL_ELEMENT}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{CHANNEL_INCLUDE_ELEMENT, src, CHANNELS_ELEMENT, CHANNEL_DEFINITION_ELEMENT});
- throw ex;
- }
- }
- }
-
- private void channelIncludeDirectory(String dir)
- {
- List files = fileResolver.getFiles(dir);
- for (int i = 0; i < files.size(); i++)
- {
- String src = (String) files.get(i);
- channelIncludeFile(src);
- }
- }
-
- private void services(Node root)
- {
- Node servicesNode = selectSingleNode(root, SERVICES_ELEMENT);
- if (servicesNode != null)
- {
- // Validation
- allowedChildElements(servicesNode, SERVICES_CHILDREN);
-
- // Default Channels for the application
- Node defaultChannels = selectSingleNode(servicesNode, DEFAULT_CHANNELS_ELEMENT);
- if (defaultChannels != null)
- {
- allowedChildElements(defaultChannels, DEFAULT_CHANNELS_CHILDREN);
- NodeList channels = selectNodeList(defaultChannels, CHANNEL_ELEMENT);
- for (int c = 0; c < channels.getLength(); c++)
- {
- Node chan = channels.item(c);
- allowedAttributes(chan, new String[] {REF_ATTR});
- defaultChannel(chan);
- }
- }
-
- // Service Includes
- NodeList services = selectNodeList(servicesNode, SERVICE_INCLUDE_ELEMENT);
- for (int i = 0; i < services.getLength(); i++)
- {
- Node service = services.item(i);
- serviceInclude(service);
- }
-
- // Service
- services = selectNodeList(servicesNode, SERVICE_ELEMENT);
- for (int i = 0; i < services.getLength(); i++)
- {
- Node service = services.item(i);
- service(service);
- }
- }
- }
-
- private void serviceInclude(Node serviceInclude)
- {
- // Validation
- allowedAttributesOrElements(serviceInclude, SERVICE_INCLUDE_CHILDREN);
-
- String src = getAttributeOrChildElement(serviceInclude, SRC_ATTR);
- String dir = getAttributeOrChildElement(serviceInclude, DIRECTORY_ATTR);
- if (src.length() > 0)
- {
- serviceIncludeFile(src);
- }
- else if (dir.length() > 0)
- {
- serviceIncludeDirectory(dir);
- }
- else
- {
- // The include element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{serviceInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
- throw ex;
- }
- }
-
- private void serviceIncludeFile(String src)
- {
- Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
- doc.getDocumentElement().normalize();
-
- // Check for multiple services defined in a <services> tag
- Node servicesNode = selectSingleNode(doc, SERVICES_ELEMENT);
- if (servicesNode != null)
- {
- allowedChildElements(servicesNode, SERVICES_CHILDREN);
- NodeList services = selectNodeList(servicesNode, SERVICE_ELEMENT);
- for (int a = 0; a < services.getLength(); a++)
- {
- Node service = services.item(a);
- service(service);
- }
- fileResolver.popIncludedFile();
- }
- else // Check for single <service> definition.
- {
- Node service = selectSingleNode(doc, "/" + SERVICE_ELEMENT);
- if (service != null)
- {
- service(service);
- fileResolver.popIncludedFile();
- }
- else
- {
- // The {0} root element in file {1} must be ''{2}'' or ''{3}''.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{SERVICE_INCLUDE_ELEMENT, src, SERVICES_ELEMENT, SERVICE_ELEMENT});
- throw ex;
- }
- }
- }
-
- private void serviceIncludeDirectory(String dir)
- {
- List files = fileResolver.getFiles(dir);
- for (int i = 0; i < files.size(); i++)
- {
- String src = (String) files.get(i);
- serviceIncludeFile(src);
- }
- }
-
- private void service(Node service)
- {
- // Validation
- requiredAttributesOrElements(service, SERVICE_REQ_CHILDREN);
- allowedAttributesOrElements(service, SERVICE_CHILDREN);
-
- String id = getAttributeOrChildElement(service, ID_ATTR);
- if (isValidID(id))
- {
- ServiceSettings serviceSettings = config.getServiceSettings(id);
- if (serviceSettings == null)
- {
- serviceSettings = new ServiceSettings(id);
- serviceSettings.setSourceFile(getSourceFileOf(service));
- config.addServiceSettings(serviceSettings);
- }
- else
- {
- // Duplicate service definition '{0}'.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(DUPLICATE_SERVICE_ERROR, new Object[]{id});
- throw e;
- }
-
- // Service Class Name
- String className = getAttributeOrChildElement(service, CLASS_ATTR);
- if (className.length() > 0)
- {
- serviceSettings.setClassName(className);
-
- // Sniff for AdvancedMessagingSupport.
- if (className.equals("flex.messaging.services.AdvancedMessagingSupport"))
- advancedMessagingSupportRegistered = true;
- }
- else
- {
- // Class not specified for {SERVICE_ELEMENT} '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(CLASS_NOT_SPECIFIED, new Object[]{SERVICE_ELEMENT, id});
- throw ex;
- }
-
- // Service Message Types - deprecated
-
- // Service Properties
- NodeList properties = selectNodeList(service, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(service));
- serviceSettings.addProperties(map);
- }
-
- // Default Channels
- Node defaultChannels = selectSingleNode(service, DEFAULT_CHANNELS_ELEMENT);
- if (defaultChannels != null)
- {
- allowedChildElements(defaultChannels, DEFAULT_CHANNELS_CHILDREN);
- NodeList channels = selectNodeList(defaultChannels, CHANNEL_ELEMENT);
- for (int c = 0; c < channels.getLength(); c++)
- {
- Node chan = channels.item(c);
- allowedAttributes(chan, new String[] {REF_ATTR});
- defaultChannel(chan, serviceSettings);
- }
- }
- // Fall back on application's default channels
- else if (config.getDefaultChannels().size() > 0)
- {
- for (Iterator iter = config.getDefaultChannels().iterator(); iter.hasNext();)
- {
- String channelId = (String)iter.next();
- ChannelSettings channel = config.getChannelSettings(channelId);
- serviceSettings.addDefaultChannel(channel);
- }
- }
-
- // Default Security Constraint
- Node defaultSecurityConstraint = selectSingleNode(service, DEFAULT_SECURITY_CONSTRAINT_ELEMENT);
- if (defaultSecurityConstraint != null)
- {
- // Validation
- requiredAttributesOrElements(defaultSecurityConstraint, new String[] {REF_ATTR});
- allowedAttributesOrElements(defaultSecurityConstraint, new String[] {REF_ATTR});
-
- String ref = getAttributeOrChildElement(defaultSecurityConstraint, REF_ATTR);
- if (ref.length() > 0)
- {
- SecurityConstraint sc = ((MessagingConfiguration)config).getSecuritySettings().getConstraint(ref);
- if (sc == null)
- {
- // {SECURITY_CONSTRAINT_DEFINITION_ELEMENT} not found for reference '{ref}'.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(REF_NOT_FOUND, new Object[]{SECURITY_CONSTRAINT_DEFINITION_ELEMENT, ref});
- throw e;
- }
- serviceSettings.setConstraint(sc);
- }
- else
- {
- //Invalid default-security-constraint reference ''{0}'' in service ''{1}''.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_SECURITY_CONSTRAINT_REF, new Object[]{ref, id});
- throw ex;
- }
- }
-
- // Adapter Definitions
- Node adapters = selectSingleNode(service, ADAPTERS_ELEMENT);
- if (adapters != null)
- {
- allowedChildElements(adapters, ADAPTERS_CHILDREN);
- NodeList serverAdapters = selectNodeList(adapters, ADAPTER_DEFINITION_ELEMENT);
- for (int a = 0; a < serverAdapters.getLength(); a++)
- {
- Node adapter = serverAdapters.item(a);
- adapterDefinition(adapter, serviceSettings);
- }
- NodeList adapterIncludes = selectNodeList(adapters, ADAPTER_INCLUDE_ELEMENT);
- for (int a = 0; a < adapterIncludes.getLength(); a++)
- {
- Node include = adapterIncludes.item(a);
- adapterInclude(include, serviceSettings);
- }
- }
-
- // Destinations
- NodeList list = selectNodeList(service, DESTINATION_ELEMENT);
- for (int i = 0; i < list.getLength(); i++)
- {
- Node dest = list.item(i);
- destination(dest, serviceSettings);
- }
-
- // Destination Includes
- list = selectNodeList(service, DESTINATION_INCLUDE_ELEMENT);
- for (int i = 0; i < list.getLength(); i++)
- {
- Node dest = list.item(i);
- destinationInclude(dest, serviceSettings);
- }
- }
- else
- {
- //Invalid {SERVICE_ELEMENT} id '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_ID, new Object[]{SERVICE_ELEMENT, id});
- throw ex;
- }
- }
-
- /**
- * A Flex application can declare default channels for its services. If a
- * service specifies its own list of channels it overrides these defaults.
- * <p>
- * <default-channels><br/>
- * <channel ref="channel-id"/><br/>
- * <default-channels>
- * </p>
- * @param chan the channel node
- */
- private void defaultChannel(Node chan)
- {
- String ref = getAttributeOrChildElement(chan, REF_ATTR);
-
- if (ref.length() > 0)
- {
- ChannelSettings channel = config.getChannelSettings(ref);
- if (channel != null)
- {
- config.addDefaultChannel(channel.getId());
- }
- else
- {
- // {0} not found for reference '{1}'
- ConfigurationException e = new ConfigurationException();
- e.setMessage(REF_NOT_FOUND, new Object[]{CHANNEL_ELEMENT, ref});
- throw e;
- }
- }
- else
- {
- //A default channel was specified without a reference for service '{0}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_DEFAULT_CHANNEL, new Object[]{"MessageBroker"});
- throw ex;
- }
- }
-
- /**
- * A service can declare default channels for its destinations. If a destination
- * specifies its own list of channels it overrides these defaults.
- * <p>
- * <default-channels><br/>
- * <channel ref="channel-id"/><br/>
- * <default-channels>
- * </p>
- * @param chan the channel node
- * @param serviceSettings service settings
- */
- private void defaultChannel(Node chan, ServiceSettings serviceSettings)
- {
- String ref = getAttributeOrChildElement(chan, REF_ATTR);
-
- if (ref.length() > 0)
- {
- ChannelSettings channel = config.getChannelSettings(ref);
- if (channel != null)
- {
- serviceSettings.addDefaultChannel(channel);
- }
- else
- {
- // {0} not found for reference '{1}'
- ConfigurationException e = new ConfigurationException();
- e.setMessage(REF_NOT_FOUND, new Object[]{CHANNEL_ELEMENT, ref});
- throw e;
- }
- }
- else
- {
- //A default channel was specified without a reference for service '{0}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_DEFAULT_CHANNEL, new Object[]{serviceSettings.getId()});
- throw ex;
- }
- }
-
- private void adapterDefinition(Node adapter, ServiceSettings serviceSettings)
- {
- // Validation
- requiredAttributesOrElements(adapter, ADAPTER_DEFINITION_REQ_CHILDREN);
- allowedChildElements(adapter, ADAPTER_DEFINITION_CHILDREN);
-
- String serviceId = serviceSettings.getId();
-
- String id = getAttributeOrChildElement(adapter, ID_ATTR);
- if (isValidID(id))
- {
- AdapterSettings adapterSettings = new AdapterSettings(id);
- adapterSettings.setSourceFile(getSourceFileOf(adapter));
- String className = getAttributeOrChildElement(adapter, CLASS_ATTR);
-
- if (className.length() > 0)
- {
- adapterSettings.setClassName(className);
-
- // Default Adapter Check
- boolean isDefault = Boolean.valueOf(getAttributeOrChildElement(adapter, DEFAULT_ATTR));
- if (isDefault)
- {
- adapterSettings.setDefault(isDefault);
-
- AdapterSettings defaultAdapter;
- defaultAdapter = serviceSettings.getDefaultAdapter();
-
- if (defaultAdapter != null)
- {
- // Duplicate default adapter '{0}' in service '{1}'. '{2}' has already been selected as the default.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(DUPLICATE_DEFAULT_ADAPTER, new Object[]{id, serviceId, defaultAdapter.getId()});
- throw ex;
- }
- }
-
- serviceSettings.addAdapterSettings(adapterSettings);
-
- // Adapter Properties
- NodeList properties = selectNodeList(adapter, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(adapter));
- adapterSettings.addProperties(map);
- }
- }
- else
- {
- // Class not specified for {ADAPTER_DEFINITION_ELEMENT} '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(CLASS_NOT_SPECIFIED, new Object[]{ADAPTER_DEFINITION_ELEMENT, id});
- throw ex;
- }
- }
- else
- {
- //Invalid {ADAPTER_DEFINITION_ELEMENT} id '{id}' for service '{serviceId}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_ID_IN_SERVICE, new Object[]{ADAPTER_DEFINITION_ELEMENT, id, serviceId});
- throw ex;
- }
- }
-
- private void adapterInclude(Node adapterInclude, ServiceSettings serviceSettings)
- {
- // Validation
- allowedAttributesOrElements(adapterInclude, ADAPTER_INCLUDE_CHILDREN);
-
- String src = getAttributeOrChildElement(adapterInclude, SRC_ATTR);
- String dir = getAttributeOrChildElement(adapterInclude, DIRECTORY_ATTR);
- if (src.length() > 0)
- {
- adapterIncludeFile(serviceSettings, src);
- }
- else if (dir.length() > 0)
- {
- adapterIncludeDirectory(serviceSettings, dir);
- }
- else
- {
- // Attribute '{0}' must be specified for element '{1}'
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{adapterInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
- throw ex;
- }
- }
-
- private void adapterIncludeDirectory(ServiceSettings serviceSettings, String dir)
- {
- List files = fileResolver.getFiles(dir);
- for (int i = 0; i < files.size(); i++)
- {
- String src = (String) files.get(i);
- adapterIncludeFile(serviceSettings, src);
- }
- }
-
- private void adapterIncludeFile(ServiceSettings serviceSettings, String src)
- {
- Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
- doc.getDocumentElement().normalize();
-
- // Check for multiple adapters defined in file wrapped in an <adapters> element
- Node adaptersNode = selectSingleNode(doc, ADAPTERS_ELEMENT);
- if (adaptersNode != null)
- {
- allowedChildElements(adaptersNode, ADAPTERS_CHILDREN);
- NodeList adapters = selectNodeList(adaptersNode, ADAPTER_DEFINITION_ELEMENT);
- for (int a = 0; a < adapters.getLength(); a++)
- {
- Node adapter = adapters.item(a);
- adapterDefinition(adapter, serviceSettings);
- }
- fileResolver.popIncludedFile();
- }
- else // Check for single adapter
- {
- Node adapter = selectSingleNode(doc, "/" + ADAPTER_DEFINITION_ELEMENT);
- if (adapter != null)
- {
- adapterDefinition(adapter, serviceSettings);
- fileResolver.popIncludedFile();
- }
- else
- {
- // The {0} root element in file {1} must be ''{2}'' or ''{3}''.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{ADAPTER_INCLUDE_ELEMENT, src, ADAPTERS_ELEMENT, ADAPTER_DEFINITION_ELEMENT});
- throw ex;
- }
- }
- }
-
- private void destinationInclude(Node destInclude, ServiceSettings serviceSettings)
- {
- // Validation
- allowedAttributesOrElements(destInclude, DESTINATION_INCLUDE_CHILDREN);
-
- String src = getAttributeOrChildElement(destInclude, SRC_ATTR);
- String dir = getAttributeOrChildElement(destInclude, DIRECTORY_ATTR);
- if (src.length() > 0)
- {
- destinationIncludeFile(serviceSettings, src);
- }
- else if (dir.length() > 0)
- {
- destinationIncludeDirectory(serviceSettings, dir);
- }
- else
- {
- // The include element ''{0}'' must specify either the ''{1}'' or ''{2}'' attribute.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(MISSING_INCLUDE_ATTRIBUTES, new Object[]{destInclude.getNodeName(), SRC_ATTR, DIRECTORY_ATTR});
- throw ex;
- }
- }
-
- private void destinationIncludeDirectory(ServiceSettings serviceSettings, String dir)
- {
- List files = fileResolver.getFiles(dir);
- for (int i = 0; i < files.size(); i++)
- {
- String src = (String) files.get(i);
- destinationIncludeFile(serviceSettings, src);
- }
- }
-
- private void destinationIncludeFile(ServiceSettings serviceSettings, String src)
- {
- Document doc = loadDocument(src, fileResolver.getIncludedFile(src));
- doc.getDocumentElement().normalize();
-
- // Check for multiple destination defined in file.
- Node destinationsNode = selectSingleNode(doc, DESTINATIONS_ELEMENT);
- if (destinationsNode != null)
- {
- allowedChildElements(destinationsNode, DESTINATIONS_CHILDREN);
- NodeList destinations = selectNodeList(destinationsNode, DESTINATION_ELEMENT);
- for (int a = 0; a < destinations.getLength(); a++)
- {
- Node dest = destinations.item(a);
- destination(dest, serviceSettings);
- }
- fileResolver.popIncludedFile();
- }
- else // Check for single destination definition.
- {
- Node dest = selectSingleNode(doc, "/" + DESTINATION_ELEMENT);
- if (dest != null)
- {
- destination(dest, serviceSettings);
- fileResolver.popIncludedFile();
- }
- else
- {
- // The {0} root element in file {1} must be ''{2}'' or ''{3}''.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_INCLUDE_ROOT, new Object[]{DESTINATION_INCLUDE_ELEMENT, src, DESTINATIONS_ELEMENT, DESTINATION_ELEMENT});
- throw ex;
- }
- }
- }
-
- private void destination(Node dest, ServiceSettings serviceSettings)
- {
- // Validation
- requiredAttributesOrElements(dest, DESTINATION_REQ_CHILDREN);
- allowedAttributes(dest, DESTINATION_ATTR);
- allowedChildElements(dest, DESTINATION_CHILDREN);
-
- String serviceId = serviceSettings.getId();
-
- DestinationSettings destinationSettings;
- String id = getAttributeOrChildElement(dest, ID_ATTR);
- if (isValidID(id))
- {
- destinationSettings = (DestinationSettings)serviceSettings.getDestinationSettings().get(id);
- if (destinationSettings != null)
- {
- // Duplicate destination definition '{id}' in service '{serviceId}'.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(DUPLICATE_DESTINATION_ERROR, new Object[]{id, serviceId});
- throw e;
- }
-
- destinationSettings = new DestinationSettings(id);
- destinationSettings.setSourceFile(getSourceFileOf(dest));
- serviceSettings.addDestinationSettings(destinationSettings);
- }
- else
- {
- //Invalid {DESTINATION_ELEMENT} id '{id}' for service '{serviceId}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_ID_IN_SERVICE, new Object[]{DESTINATION_ELEMENT, id, serviceId});
- throw ex;
- }
-
- // Destination Properties
- NodeList properties = selectNodeList(dest, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(dest));
- destinationSettings.addProperties(map);
-
- // Sniff for <network><reliable>true|false</reliable></network> setting.
- // Also sniff for inbound and outbound throttle policies of buffer and conflate.
- // All these features are only supported when advanced messaging support is enabled.
- if (!verifyAdvancedMessagingSupport)
- {
- ConfigMap networkSettings = map.getPropertyAsMap(NetworkSettings.NETWORK_ELEMENT, null);
- if (networkSettings != null)
- {
- String reliable = networkSettings.getPropertyAsString(NetworkSettings.RELIABLE_ELEMENT, null);
- if (reliable != null && Boolean.valueOf(reliable))
- {
- verifyAdvancedMessagingSupport = true;
- }
- else
- {
- ConfigMap inbound = networkSettings.getPropertyAsMap(ThrottleSettings.ELEMENT_INBOUND, null);
- if (inbound != null)
- {
- String policy = inbound.getPropertyAsString(ThrottleSettings.ELEMENT_POLICY, null);
- if (policy != null && (Policy.BUFFER.toString().equalsIgnoreCase(policy)
- || Policy.CONFLATE.toString().equalsIgnoreCase(policy)))
- verifyAdvancedMessagingSupport = true;
- }
- if (!verifyAdvancedMessagingSupport)
- {
- ConfigMap outbound = networkSettings.getPropertyAsMap(ThrottleSettings.ELEMENT_OUTBOUND, null);
- if (outbound != null)
- {
- String policy = outbound.getPropertyAsString(ThrottleSettings.ELEMENT_POLICY, null);
- if (policy != null && (Policy.BUFFER.toString().equalsIgnoreCase(policy)
- || Policy.CONFLATE.toString().equalsIgnoreCase(policy)))
- verifyAdvancedMessagingSupport = true;
- }
- }
- }
- }
- }
- }
-
- // Channels
- destinationChannels(dest, destinationSettings, serviceSettings);
-
- // Security
- destinationSecurity(dest, destinationSettings, serviceSettings);
-
- // Service Adapter
- destinationAdapter(dest, destinationSettings, serviceSettings);
- }
-
- private void destinationChannels(Node dest, DestinationSettings destinationSettings, ServiceSettings serviceSettings)
- {
- String destId = destinationSettings.getId();
-
- // Channels attribute
- String channelsList = evaluateExpression(dest, "@" + CHANNELS_ATTR).toString().trim();
- if (channelsList.length() > 0)
- {
- StringTokenizer st = new StringTokenizer(channelsList, LIST_DELIMITERS);
- while (st.hasMoreTokens())
- {
- String ref = st.nextToken().trim();
- ChannelSettings channel = config.getChannelSettings(ref);
- if (channel != null)
- {
- destinationSettings.addChannelSettings(channel);
- }
- else
- {
- // {CHANNEL_ELEMENT} not found for reference '{ref}' in destination '{destId}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(REF_NOT_FOUND_IN_DEST, new Object[]{CHANNEL_ELEMENT, ref, destId});
- throw ex;
- }
- }
- }
- else
- {
- // Channels element
- Node channelsNode = selectSingleNode(dest, CHANNELS_ELEMENT);
- if (channelsNode != null)
- {
- allowedChildElements(channelsNode, DESTINATION_CHANNELS_CHILDREN);
- NodeList channels = selectNodeList(channelsNode, CHANNEL_ELEMENT);
- for (int c = 0; c < channels.getLength(); c++)
- {
- Node chan = channels.item(c);
-
- // Validation
- requiredAttributesOrElements(chan, DESTINATION_CHANNEL_REQ_CHILDREN);
-
- String ref = getAttributeOrChildElement(chan, REF_ATTR);
- if (ref.length() > 0)
- {
- ChannelSettings channel = config.getChannelSettings(ref);
- if (channel != null)
- {
- destinationSettings.addChannelSettings(channel);
- }
- else
- {
- // {CHANNEL_ELEMENT} not found for reference '{ref}' in destination '{destId}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(REF_NOT_FOUND_IN_DEST, new Object[]{CHANNEL_ELEMENT, ref, destId});
- throw ex;
- }
- }
- else
- {
- //Invalid {0} ref '{1}' in destination '{2}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_REF_IN_DEST, new Object[]{CHANNEL_ELEMENT, ref, destId});
- throw ex;
- }
- }
- }
- else
- {
- // Finally, we fall back to the service's default channels
- List defaultChannels = serviceSettings.getDefaultChannels();
- Iterator it = defaultChannels.iterator();
- while (it.hasNext())
- {
- ChannelSettings channel = (ChannelSettings)it.next();
- destinationSettings.addChannelSettings(channel);
- }
- }
- }
-
- if (destinationSettings.getChannelSettings().size() <= 0)
- {
- // Destination '{id}' must specify at least one channel.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(DEST_NEEDS_CHANNEL, new Object[]{destId});
- throw ex;
- }
- }
-
- private void destinationSecurity(Node dest, DestinationSettings destinationSettings, ServiceSettings serviceSettings)
- {
- String destId = destinationSettings.getId();
-
- // Security-constraint short-cut attribute
- String ref = evaluateExpression(dest, "@" + SECURITY_CONSTRAINT_ATTR).toString().trim();
- if (ref.length() > 0)
- {
- SecurityConstraint sc = ((MessagingConfiguration)config).getSecuritySettings().getConstraint(ref);
- if (sc != null)
- {
- destinationSettings.setConstraint(sc);
- }
- else
- {
- // {SECURITY_CONSTRAINT_ELEMENT} not found for reference '{ref}' in destination '{destId}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(REF_NOT_FOUND_IN_DEST, new Object[]{SECURITY_CONSTRAINT_ATTR, ref, destId});
- throw ex;
- }
- }
- else
- {
- // Inline security element
- Node security = selectSingleNode(dest, SECURITY_ELEMENT);
- if (security != null)
- {
- allowedChildElements(security, EMBEDDED_SECURITY_CHILDREN);
- Node constraint = selectSingleNode(security, SECURITY_CONSTRAINT_ELEMENT);
- if (constraint != null)
- {
- SecurityConstraint sc = securityConstraint(constraint, true);
- destinationSettings.setConstraint(sc);
- }
- }
- else
- {
- // Finally, we fall back to the service's default security constraint
- SecurityConstraint sc = serviceSettings.getConstraint();
- if (sc != null)
- {
- destinationSettings.setConstraint(sc);
- }
- }
- }
- }
-
- private void destinationAdapter(Node dest, DestinationSettings destinationSettings, ServiceSettings serviceSettings)
- {
- String destId = destinationSettings.getId();
-
- // Adapter attribute
- String ref = evaluateExpression(dest, "@" + ADAPTER_ATTR).toString().trim();
- if (ref.length() > 0)
- {
- adapterReference(ref, destinationSettings, serviceSettings);
- }
- else
- {
- Node adapter = selectSingleNode(dest, ADAPTER_ELEMENT);
-
- // Adapter element
- if (adapter != null)
- {
- allowedAttributesOrElements(adapter, DESTINATION_ADAPTER_CHILDREN);
- ref = getAttributeOrChildElement(adapter, REF_ATTR);
- adapterReference(ref, destinationSettings, serviceSettings);
- }
- else
- {
- // Default Adapter (optionally set at the service level)
- AdapterSettings adapterSettings = serviceSettings.getDefaultAdapter();
- if (adapterSettings != null)
- {
- destinationSettings.setAdapterSettings(adapterSettings);
- }
- }
- }
-
- if (destinationSettings.getAdapterSettings() == null)
- {
- // Destination '{id}' must specify at least one adapter.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(DEST_NEEDS_ADAPTER, new Object[]{destId});
- throw ex;
- }
- }
-
- private void adapterReference(String ref, DestinationSettings destinationSettings, ServiceSettings serviceSettings)
- {
- String destId = destinationSettings.getId();
- if (ref.length() > 0)
- {
- AdapterSettings adapterSettings = serviceSettings.getAdapterSettings(ref);
- if (adapterSettings != null)
- {
- destinationSettings.setAdapterSettings(adapterSettings);
- }
- else
- {
- // {ADAPTER_ELEMENT} not found for reference '{ref}' in destination '{destId}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(REF_NOT_FOUND_IN_DEST, new Object[]{ADAPTER_ELEMENT, ref, destId});
- throw ex;
- }
- }
- else
- {
- //Invalid {ADAPTER_ELEMENT} ref '{ref}' in destination '{destId}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_REF_IN_DEST, new Object[]{ADAPTER_ELEMENT, ref, destId});
- throw ex;
- }
- }
-
- private void logging(Node root)
- {
- Node logging = selectSingleNode(root, LOGGING_ELEMENT);
- if (logging != null)
- {
- // Validation
- allowedAttributesOrElements(logging, LOGGING_CHILDREN);
-
- LoggingSettings settings = new LoggingSettings();
-
- // Log Properties
- NodeList properties = selectNodeList(logging, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(logging));
- settings.addProperties(map);
- }
-
- NodeList targets = selectNodeList(logging, TARGET_ELEMENT);
- for (int i = 0; i < targets.getLength(); i++)
- {
- Node targetNode = targets.item(i);
-
- // Target Validation
- requiredAttributesOrElements(targetNode, TARGET_REQ_CHILDREN);
- allowedAttributesOrElements(targetNode, TARGET_CHILDREN);
-
- String className = getAttributeOrChildElement(targetNode, CLASS_ATTR);
-
- if (className.length() > 0)
- {
- TargetSettings targetSettings = new TargetSettings(className);
- String targetLevel = getAttributeOrChildElement(targetNode, LEVEL_ATTR);
-
- if (targetLevel.length() > 0)
- targetSettings.setLevel(targetLevel);
-
- // Filters
- Node filtersNode = selectSingleNode(targetNode, FILTERS_ELEMENT);
- if (filtersNode != null)
- {
- allowedChildElements(filtersNode, FILTERS_CHILDREN);
- NodeList filters = selectNodeList(filtersNode, PATTERN_ELEMENT);
- for (int f = 0; f < filters.getLength(); f++)
- {
- Node pattern = filters.item(f);
- String filter = evaluateExpression(pattern, ".").toString().trim();
- targetSettings.addFilter(filter);
- }
- }
-
- // Target Properties
- properties = selectNodeList(targetNode, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(targetNode));
- targetSettings.addProperties(map);
- }
-
- settings.addTarget(targetSettings);
- }
- }
-
- config.setLoggingSettings(settings);
- }
- }
-
- private void system(Node root)
- {
- Node system = selectSingleNode(root, SYSTEM_ELEMENT);
- if (system == null)
- {
- // Create a default instance of SystemSettings which by default has setManagable as true
- // and has setRedeployEnabled as false.
- ((MessagingConfiguration)config).setSystemSettings(new SystemSettings());
- return;
- }
-
- allowedAttributesOrElements(system, SYSTEM_CHILDREN);
-
- SystemSettings settings = new SystemSettings();
-
- settings.setEnforceEndpointValidation(getAttributeOrChildElement(system, ENFORCE_ENDOINT_VALIDATION));
- locale(system, settings);
- settings.setManageable(getAttributeOrChildElement(system, MANAGEABLE_ELEMENT));
- settings.setDotNetFrameworkVersion(getAttributeOrChildElement(system, DOTNET_FRAMEWORK_VERSION));
- redeploy(system, settings);
- uuidGenerator(system, settings);
-
- ((MessagingConfiguration)config).setSystemSettings(settings);
- }
-
- private void redeploy(Node system, SystemSettings settings)
- {
- Node redeployNode = selectSingleNode(system, REDEPLOY_ELEMENT);
- if (redeployNode == null)
- return;
-
- allowedAttributesOrElements(redeployNode, REDEPLOY_CHILDREN);
-
- String enabled = getAttributeOrChildElement(redeployNode, ENABLED_ELEMENT);
- settings.setRedeployEnabled(enabled);
-
- String interval = getAttributeOrChildElement(redeployNode, WATCH_INTERVAL_ELEMENT);
- if (interval.length() > 0)
- {
- settings.setWatchInterval(interval);
- }
-
- NodeList watches = selectNodeList(redeployNode, WATCH_FILE_ELEMENT);
- for (int i = 0; i < watches.getLength(); i++)
- {
- Node watchNode = watches.item(i);
- String watch = evaluateExpression(watchNode, ".").toString().trim();
- if (watch.length() > 0)
- {
- settings.addWatchFile(watch);
- }
- }
-
- NodeList touches = selectNodeList(redeployNode, TOUCH_FILE_ELEMENT);
- for (int i = 0; i < touches.getLength(); i++)
- {
- Node touchNode = touches.item(i);
- String touch = evaluateExpression(touchNode, ".").toString().trim();
- if (touch.length() > 0)
- {
- settings.addTouchFile(touch);
- }
- }
- }
-
- private void locale(Node system, SystemSettings settings)
- {
- Node localeNode = selectSingleNode(system, LOCALE_ELEMENT);
- if (localeNode == null)
- return;
-
- allowedAttributesOrElements(localeNode, LOCALE_CHILDREN);
-
- String defaultLocaleString = getAttributeOrChildElement(localeNode, DEFAULT_LOCALE_ELEMENT);
- Locale defaultLocale = defaultLocaleString.length() > 0? LocaleUtils.buildLocale(defaultLocaleString) : LocaleUtils.buildLocale(null);
- settings.setDefaultLocale(defaultLocale);
- }
-
- private void uuidGenerator(Node system, SystemSettings settings)
- {
- Node uuidGenerator = selectSingleNode(system, UUID_GENERATOR_ELEMENT);
- if (uuidGenerator == null)
- return;
-
- requiredAttributesOrElements(uuidGenerator, UUID_GENERATOR_REQ_CHILDREN);
-
- String className = getAttributeOrChildElement(uuidGenerator, CLASS_ATTR);
- if (className.length() == 0)
- {
- // Class not specified for {UUID_GENERATOR_ELEMENT} '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(CLASS_NOT_SPECIFIED, new Object[]{UUID_GENERATOR_ELEMENT, ""});
- throw ex;
- }
-
- settings.setUUIDGeneratorClassName(className);
- }
-
- private void flexClient(Node root)
- {
- Node flexClient = selectSingleNode(root, FLEX_CLIENT_ELEMENT);
- if (flexClient != null)
- {
- // Validation
- allowedChildElements(flexClient, FLEX_CLIENT_CHILDREN);
-
- FlexClientSettings flexClientSettings = new FlexClientSettings();
-
- // Timeout
- String timeout = getAttributeOrChildElement(flexClient, FLEX_CLIENT_TIMEOUT_MINUTES_ELEMENT);
- if (timeout.length() > 0)
- {
- try
- {
- long timeoutMinutes = Long.parseLong(timeout);
- if (timeoutMinutes < 0)
- {
- // Invalid timeout minutes value ''{0}'' in the <flex-client> configuration section. Please specify a positive value or leave the element undefined in which case flex client instances on the server will be timed out when all associated sessions/connections have shut down.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(INVALID_FLEX_CLIENT_TIMEOUT, new Object[]{timeout});
- throw e;
- }
- flexClientSettings.setTimeoutMinutes(timeoutMinutes);
- }
- catch (NumberFormatException nfe)
- {
- // Invalid timeout minutes value ''{0}'' in the <flex-client> configuration section. Please specify a positive value or leave the element undefined in which case flex client instances on the server will be timed out when all associated sessions/connections have shut down.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(INVALID_FLEX_CLIENT_TIMEOUT, new Object[]{timeout});
- throw e;
- }
- }
- else
- {
- flexClientSettings.setTimeoutMinutes(0); // Default to 0; in this case FlexClients are invalidated when all associated sessions have been invalidated.
- }
-
- // Flex client queue processor
- Node outboundQueueProcessor = selectSingleNode(flexClient, FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_ELEMENT);
- if (outboundQueueProcessor != null)
- {
- // Validation
- requiredAttributesOrElements(outboundQueueProcessor, FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_REQ_CHILDREN);
-
- // Flex client queue processor class
- String outboundQueueProcessClass = getAttributeOrChildElement(outboundQueueProcessor, CLASS_ATTR);
- if (outboundQueueProcessClass.length() > 0)
- {
- flexClientSettings.setFlexClientOutboundQueueProcessorClassName(outboundQueueProcessClass);
- }
- else
- {
- // Class not specified for {FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_ELEMENT} '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(CLASS_NOT_SPECIFIED, new Object[]{FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_ELEMENT, ""});
- throw ex;
- }
-
- // Flex client queue processor properties
- NodeList properties = selectNodeList(outboundQueueProcessor, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(outboundQueueProcessor));
- flexClientSettings.setFlexClientOutboundQueueProcessorProperties(map);
- // Sniff for adaptive-frequency which requires advanced messaging support.
- boolean adaptiveFrequency = map.getPropertyAsBoolean(ADAPTIVE_FREQUENCY, false);
- if (adaptiveFrequency)
- verifyAdvancedMessagingSupport = true;
- }
- }
- ((MessagingConfiguration)config).setFlexClientSettings(flexClientSettings);
- }
- }
-
- private void factories(Node root)
- {
- Node factories = selectSingleNode(root, FACTORIES_ELEMENT);
- if (factories != null)
- {
- // Validation
- allowedAttributesOrElements(factories, FACTORIES_CHILDREN);
-
- NodeList factoryList = selectNodeList(factories, FACTORY_ELEMENT);
- for (int i = 0; i < factoryList.getLength(); i++)
- {
- Node factory = factoryList.item(i);
- factory(factory);
- }
- }
- }
-
- private void factory(Node factory)
- {
- // Validation
- requiredAttributesOrElements(factory, FACTORY_REQ_CHILDREN);
-
- String id = getAttributeOrChildElement(factory, ID_ATTR);
- String className = getAttributeOrChildElement(factory, CLASS_ATTR);
- if (isValidID(id))
- {
- FactorySettings factorySettings = new FactorySettings(id, className);
-
- // Factory Properties
- NodeList properties = selectNodeList(factory, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(factory));
- factorySettings.addProperties(map);
- }
- ((MessagingConfiguration)config).addFactorySettings(id, factorySettings);
- }
- else
- {
- // Invalid {FACTORY_ELEMENT} id '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_ID, new Object[]{FACTORY_ELEMENT, id});
- ex.setDetails(INVALID_ID);
- throw ex;
- }
- }
-
- private void messageFilters(Node root)
- {
- typedMessageFilters(root, ASYNC_MESSAGE_FILTERS_ELEMENT, ASYNC_MESSAGE_FILTERS_ELEMENT_CHILDREN);
- typedMessageFilters(root, SYNC_MESSAGE_FILTERS_ELEMENT, SYNC_MESSAGE_FILTERS_ELEMENT_CHILDREN);
- }
-
- private void typedMessageFilters(Node root, String filterTypeElement, String[] childrenElements)
- {
- Node messageFiltersNode = selectSingleNode(root, filterTypeElement);
- if (messageFiltersNode == null)
- return;
-
- // Validation
- allowedChildElements(messageFiltersNode, childrenElements);
-
- // Message filter
- NodeList messageFilters = selectNodeList(messageFiltersNode, FILTER_ELEMENT);
- for (int i = 0; i < messageFilters.getLength(); i++)
- {
- Node messageFilter = messageFilters.item(i);
- messageFilter(messageFilter, filterTypeElement);
- }
- }
-
- private void messageFilter(Node messageFilter, String filterType)
- {
- // Validation
- requiredAttributesOrElements(messageFilter, FILTER_REQ_CHILDREN);
- allowedAttributesOrElements(messageFilter, FILTER_CHILDREN);
-
- String id = getAttributeOrChildElement(messageFilter, ID_ATTR);
- if (isValidID(id))
- {
- // Message filter class name
- String className = getAttributeOrChildElement(messageFilter, CLASS_ATTR);
- if (className.length() > 0)
- {
- MessageFilterSettings messageFilterSettings = new MessageFilterSettings();
- messageFilterSettings.setId(id);
- messageFilterSettings.setClassName(className);
- // Record type of filter.
- MessageFilterSettings.FilterType type = filterType.equals(ASYNC_MESSAGE_FILTERS_ELEMENT) ?
- MessageFilterSettings.FilterType.ASYNC :
- MessageFilterSettings.FilterType.SYNC;
- messageFilterSettings.setFilterType(type);
- // Custom server properties.
- NodeList properties = selectNodeList(messageFilter, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(messageFilter));
- messageFilterSettings.addProperties(map);
- }
- ((MessagingConfiguration)config).addMessageFilterSettings(messageFilterSettings);
- }
- else
- {
- // Class not specified for {FILTER_ELEMENT} '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(CLASS_NOT_SPECIFIED, new Object[]{FILTER_ELEMENT, id});
- throw ex;
- }
- }
- }
-
- private void validators(Node root)
- {
- Node validatorsNode = selectSingleNode(root, VALIDATORS_ELEMENT);
- if (validatorsNode == null)
- return;
-
- // Validation
- allowedChildElements(validatorsNode, VALIDATORS_CHILDREN);
-
- // Validator
- NodeList validators = selectNodeList(validatorsNode, VALIDATOR_ELEMENT);
- for (int i = 0; i < validators.getLength(); i++)
- {
- Node validator = validators.item(i);
- validator(validator);
- }
- }
-
- private void validator(Node validator)
- {
- // Validation
- requiredAttributesOrElements(validator, VALIDATOR_REQ_CHILDREN);
- allowedAttributesOrElements(validator, VALIDATOR_CHILDREN);
-
- ValidatorSettings validatorSettings = new ValidatorSettings();
-
- // Validator class name
- String className = getAttributeOrChildElement(validator, CLASS_ATTR);
- if (className.length() > 0)
- {
- validatorSettings.setClassName(className);
- }
- else
- {
- // Class not specified for {VALIDATOR_ELEMENT} '{id}'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(CLASS_NOT_SPECIFIED, new Object[]{VALIDATOR_ELEMENT, ""});
- throw ex;
- }
-
- // Validator type
- String type = getAttributeOrChildElement(validator, TYPE_ATTR);
- if (type.length() > 0)
- validatorSettings.setType(type);
-
- // Validator properties
- NodeList properties = selectNodeList(validator, PROPERTIES_ELEMENT + "/*");
- if (properties.getLength() > 0)
- {
- ConfigMap map = properties(properties, getSourceFileOf(validator));
- validatorSettings.addProperties(map);
- }
-
- ((MessagingConfiguration)config).addValidatorSettings(validatorSettings);
- }
-}
+/*
+ * 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.config;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import flex.messaging.config.ThrottleSettings.Policy;
+import flex.messaging.util.LocaleUtils;
+
+/**
+ * Processes DOM representation of a messaging configuration file.
+ * <p>
+ * Note: Since reference ids are used between elements, certain
+ * sections of the document need to be parsed first.
+ * </p>
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public abstract class ServerConfigurationParser extends AbstractConfigurationParser
+{
+ /**
+ * Used to verify that advanced messaging support has been registered if necessary.
+ * If other configuration requires it, but it was not registered a ConfigurationException is thrown.
+ */
+ private boolean verifyAdvancedMessagingSupport = false;
+ private boolean advancedMessagingSupportRegistered = false;
+
+ @Override
+ protected void parseTopLevelConfig(Document doc)
+ {
+ Node root = selectSingleNode(doc, "/" + SERVICES_CONFIG_ELEMENT);
+
+ if (root != null)
+ {
+ allowedChildElements(root, SERVICES_CONFIG_CHILDREN);
+
+ securitySection(root); // Parse security before channels.
+
+ serversSection(root);
+
+ channelsSection(root);
+
+ services(root);
+
+ clusters(root);
+
+ logging(root);
+
+ system(root);
+
+ flexClient(root);
+
+ factories(root);
+
+ messageFilters(root);
+
+ validators(root);
+
+ // Validate that any dependencies on advanced messaging support can be satisified at runtime.
+ if (verifyAdvancedMessagingSupport && !advancedMessagingSupportRegistered)
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(REQUIRE_ADVANCED_MESSAGING_SUPPORT);
+ throw e;
+ }
+ }
+ else
+ {
+ // The services configuration root element must be '{SERVICES_CONFIG_ELEMENT}'.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(INVALID_SERVICES_ROOT, new Object[]{SERVICES_CONFIG_ELEMENT});
+ throw e;
+ }
+ }
+
+ private void clusters(Node root)
+ {
+ Node clusteringNode = selectSingleNode(root, CLUSTERS_ELEMENT);
+ if (clusteringNode != null)
+ {
+ allowedAttributesOrElements(clusteringNode, CLUSTERING_CHILDREN);
+
+ NodeList clusters = selectNodeList(clusteringNode, CLUSTER_DEFINITION_ELEMENT);
+ for (int i = 0; i < clusters.getLength(); i++)
+ {
+ Node cluster = clusters.item(i);
+ requiredAttributesOrElements(cluster, CLUSTER_DEFINITION_CHILDREN);
+ String clusterName = getAttributeOrChildElement(cluster, ID_ATTR);
+ if (!isValidID(clusterName))
+ continue;
+
+ String propsFileName = getAttributeOrChildElement(cluster, CLUSTER_PROPERTIES_ATTR);
+ ClusterSettings clusterSettings = new ClusterSettings();
+ clusterSettings.setClusterName(clusterName);
+ clusterSettings.setPropsFileName(propsFileName);
+ String className = getAttributeOrChildElement(cluster, CLASS_ATTR);
+ if (className != null && className.length() > 0)
+ clusterSettings.setImplementationClass(className);
+
+ String defaultValue = getAttributeOrChildElement(cluster, ClusterSettings.DEFAULT_ELEMENT);
+ if (defaultValue != null && defaultValue.length() > 0)
+ {
+ if (defaultValue.equalsIgnoreCase(TRUE_STRING))
+ clusterSettings.setDefault(true);
+ else if (!defaultValue.equalsIgnoreCase(FALSE_STRING))
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(10215, new Object[] {clusterName, defaultValue});
+ throw e;
+ }
+ }
+ String ulb = getAttributeOrChildElement(cluster, ClusterSettings.URL_LOAD_BALANCING);
+ if (ulb != null && ulb.length() > 0)
+ {
+ if (ulb.equalsIgnoreCase(FALSE_STRING))
+ {
+ clusterSettings.setURLLoadBalancing(false);
+ }
+ else if (!ulb.equalsIgnoreCase(TRUE_STRING))
+ {
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(10216, new Object[] {clusterName, ulb});
+ throw e;
+ }
+ }
+
+ NodeList properties = selectNodeList(cluster, PROPERTIES_ELEMENT + "/*");
+ if (properties.getLength() > 0)
+ {
+ ConfigMap map = properties(properties, getSourceFileOf(cluster));
+ clusterSettings.addProperties(map);
+ }
+
+ ((MessagingConfiguration)config).addClusterSettings(clusterSettings);
+
+ }
+ }
+ }
+
+
+ private void securitySection(Node root)
+ {
+ Node security = selectSingleNode(root, SECURITY_ELEMENT);
+
+ if (security == null)
+ return;
+
+ allowedChildElements(security, SECURITY_CHILDREN);
+
+ NodeList list = selectNodeList(security, SECURITY_CONSTRAINT_DEFINITION_ELEMENT);
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node constraint = list.item(i);
+ securityConstraint(constraint, false);
+ }
+
+ list = selectNodeList(security, CONSTRAINT_INCLUDE_ELEMENT);
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node include = list.item(i);
+ securityConstraintInclude(include);
+ }
+
+ list = selectNodeList(security, LOGIN_COMMAND_ELEMENT);
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node login = list.item(i);
+ LoginCommandSettings loginCommandSettings= new LoginCommandSettings();
+
<TRUNCATED>
[24/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/MessageClientListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/MessageClientListener.java b/modules/core/src/flex/messaging/MessageClientListener.java
old mode 100755
new mode 100644
index e77b31d..7cfdb90
--- a/modules/core/src/flex/messaging/MessageClientListener.java
+++ b/modules/core/src/flex/messaging/MessageClientListener.java
@@ -1,40 +1,40 @@
-/*
- * 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;
-
-/**
- * Interface to be notified when a MessageClient is created or destroyed. Implementations of this interface
- * may add themselves as listeners statically via <code>MessageClient.addMessageClientCreatedListener()</code>.
- * To listen for MessageClient destruction, the implementation class instance must add itself as a listener to
- * a specific MessageClient instance via the <code>addMessageClientDestroyedListener()</code> method.
- */
-public interface MessageClientListener
-{
- /**
- * Notification that a MessageClient was created.
- *
- * @param messageClient The MessageClient that was created.
- */
- void messageClientCreated(MessageClient messageClient);
-
- /**
- * Notification that a MessageClient is about to be destroyed.
- *
- * @param messageClient The MessageClient that will be destroyed.
- */
- void messageClientDestroyed(MessageClient messageClient);
-}
+/*
+ * 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;
+
+/**
+ * Interface to be notified when a MessageClient is created or destroyed. Implementations of this interface
+ * may add themselves as listeners statically via <code>MessageClient.addMessageClientCreatedListener()</code>.
+ * To listen for MessageClient destruction, the implementation class instance must add itself as a listener to
+ * a specific MessageClient instance via the <code>addMessageClientDestroyedListener()</code> method.
+ */
+public interface MessageClientListener
+{
+ /**
+ * Notification that a MessageClient was created.
+ *
+ * @param messageClient The MessageClient that was created.
+ */
+ void messageClientCreated(MessageClient messageClient);
+
+ /**
+ * Notification that a MessageClient is about to be destroyed.
+ *
+ * @param messageClient The MessageClient that will be destroyed.
+ */
+ void messageClientDestroyed(MessageClient messageClient);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/MessageDestination.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/MessageDestination.java b/modules/core/src/flex/messaging/MessageDestination.java
old mode 100755
new mode 100644
index 5552b7a..bd80b41
--- a/modules/core/src/flex/messaging/MessageDestination.java
+++ b/modules/core/src/flex/messaging/MessageDestination.java
@@ -1,491 +1,491 @@
-/*
- * 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;
-
-import flex.management.runtime.messaging.MessageDestinationControl;
-import flex.management.runtime.messaging.services.messaging.SubscriptionManagerControl;
-import flex.management.runtime.messaging.services.messaging.ThrottleManagerControl;
-import flex.messaging.config.ConfigurationConstants;
-import flex.messaging.config.ConfigurationException;
-import flex.messaging.config.DestinationSettings;
-import flex.messaging.config.ThrottleSettings;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.NetworkSettings;
-import flex.messaging.config.ServerSettings;
-import flex.messaging.config.ThrottleSettings.Policy;
-import flex.messaging.log.LogCategories;
-import flex.messaging.services.MessageService;
-import flex.messaging.services.Service;
-import flex.messaging.services.messaging.SubscriptionManager;
-import flex.messaging.services.messaging.RemoteSubscriptionManager;
-import flex.messaging.services.messaging.ThrottleManager;
-import flex.messaging.services.messaging.MessagingConstants;
-import flex.messaging.util.ClassUtil;
-
-/**
- * A logical reference to a MessageDestination.
- */
-public class MessageDestination extends FactoryDestination
-{
- static final long serialVersionUID = -2016911808141319012L;
-
- /** Log category for <code>MessageDestination</code>.*/
- public static final String LOG_CATEGORY = LogCategories.SERVICE_MESSAGE;
-
- // Errors
- private static final int UNSUPPORTED_POLICY = 10124;
-
- // Destination properties
- private transient ServerSettings serverSettings;
-
- // Destination internal
- private transient SubscriptionManager subscriptionManager;
- private transient RemoteSubscriptionManager remoteSubscriptionManager;
- private transient ThrottleManager throttleManager;
-
- private transient MessageDestinationControl controller;
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>MessageDestination</code> instance.
- */
- public MessageDestination()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>MessageDestination</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>MessageDestination</code>
- * is manageable; otherwise <code>false</code>.
- */
- public MessageDestination(boolean enableManagement)
- {
- super(enableManagement);
-
- serverSettings = new ServerSettings();
-
- // Managers
- subscriptionManager = new SubscriptionManager(this);
- remoteSubscriptionManager = new RemoteSubscriptionManager(this);
- }
-
- //--------------------------------------------------------------------------
- //
- // Initialize, validate, start, and stop methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes the <code>MessageDestination</code> with the properties.
- * If subclasses override, they must call <code>super.initialize()</code>.
- *
- * @param id The id of the destination.
- * @param properties Properties for the <code>MessageDestination</code>.
- */
- @Override
- public void initialize(String id, ConfigMap properties)
- {
- super.initialize(id, properties);
-
- if (properties == null || properties.size() == 0)
- return;
-
- // Network properties
- network(properties);
-
- // Server properties
- server(properties);
- }
-
- /**
- * Sets up the throttle manager before it starts.
- */
- @Override
- public void start()
- {
- // Create the throttle manager, only if needed.
- if (networkSettings.getThrottleSettings() != null)
- {
- ThrottleSettings settings = networkSettings.getThrottleSettings();
- if (settings.isClientThrottleEnabled() || settings.isDestinationThrottleEnabled())
- {
- settings.setDestinationName(getId());
- throttleManager = createThrottleManager();
- throttleManager.setThrottleSettings(settings);
- throttleManager.start();
- }
- }
- super.start();
- }
-
- /**
- * Stops the subscription, remote subscription, and throttle managers and
- * then calls super class's stop.
- */
- @Override
- public void stop()
- {
- if (isStarted())
- {
- subscriptionManager.stop();
- remoteSubscriptionManager.stop();
- if (throttleManager != null)
- throttleManager.stop();
- }
- super.stop();
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Getters and Setters for Destination properties
- //
- //--------------------------------------------------------------------------
-
- /**
- * Sets the <code>NetworkSettings</code> of the <code>MessageDestination</code>.
- *
- * @param networkSettings The <code>NetworkSettings</code> of the <code>MessageDestination</code>
- */
- @Override
- public void setNetworkSettings(NetworkSettings networkSettings)
- {
- super.setNetworkSettings(networkSettings);
-
- // Set the subscription manager settings if needed.
- if (networkSettings.getSubscriptionTimeoutMinutes() > 0)
- {
- long subscriptionTimeoutMillis = networkSettings.getSubscriptionTimeoutMinutes() * 60L * 1000L; // Convert to millis.
- subscriptionManager.setSubscriptionTimeoutMillis(subscriptionTimeoutMillis);
- }
- }
-
- /**
- * Returns the <code>ServerSettings</code> of the <code>MessageDestination</code>.
- *
- * @return The <code>ServerSettings</code> of the <code>MessageDestination</code>.
- */
- public ServerSettings getServerSettings()
- {
- return serverSettings;
- }
-
- /**
- * Sets the <code>ServerSettings</code> of the <code>MessageDestination</code>.
- *
- * @param serverSettings The <code>ServerSettings</code> of the <code>MessageDestination</code>
- */
- public void setServerSettings(ServerSettings serverSettings)
- {
- this.serverSettings = serverSettings;
- }
-
- /**
- * Casts the <code>Service</code> into <code>MessageService</code>
- * and calls super.setService.
- *
- * @param service The <code>Service</code> managing this <code>Destination</code>.
- */
- @Override
- public void setService(Service service)
- {
- MessageService messageService = (MessageService)service;
- super.setService(messageService);
- }
-
- //--------------------------------------------------------------------------
- //
- // Other Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * Returns a <tt>ConfigMap</tt> of destination properties that the client
- * needs. This includes properties from <code>super{@link #describeDestination(boolean)}</code>
- * and it also includes outbound throttling policy that the edge server might need.
- *
- * @param onlyReliable Determines whether only reliable destination configuration should be returned.
- * @return A <tt>ConfigMap</tt> of destination properties that the client needs.
- */
- @Override
- public ConfigMap describeDestination(boolean onlyReliable)
- {
- ConfigMap destinationConfig = super.describeDestination(onlyReliable);
- if (destinationConfig == null)
- return null;
-
- if (throttleManager == null)
- return destinationConfig;
-
- Policy outboundPolicy = throttleManager.getOutboundPolicy();
- if (outboundPolicy == null || outboundPolicy == Policy.NONE)
- return destinationConfig;
-
- // Add the outbound throttle policy to network properties section as appropriate.
- ConfigMap properties = destinationConfig.getPropertyAsMap(ConfigurationConstants.PROPERTIES_ELEMENT, null);
- if (properties == null)
- {
- properties = new ConfigMap();
- destinationConfig.addProperty(ConfigurationConstants.PROPERTIES_ELEMENT, properties);
- }
-
- ConfigMap network = properties.getPropertyAsMap(NetworkSettings.NETWORK_ELEMENT, null);
- if (network == null)
- {
- network = new ConfigMap();
- properties.addProperty(NetworkSettings.NETWORK_ELEMENT, network);
- }
-
- ConfigMap throttleOutbound = new ConfigMap();
- throttleOutbound.addProperty(ThrottleSettings.ELEMENT_POLICY, throttleManager.getOutboundPolicy().toString());
- network.addProperty(ThrottleSettings.ELEMENT_OUTBOUND, throttleOutbound);
-
- return destinationConfig;
- }
-
- /** @exclude */
- public SubscriptionManager getSubscriptionManager()
- {
- return subscriptionManager;
- }
-
- /** @exclude */
- public RemoteSubscriptionManager getRemoteSubscriptionManager()
- {
- return remoteSubscriptionManager;
- }
-
- /** @exclude */
- public ThrottleManager getThrottleManager()
- {
- return throttleManager;
- }
-
- /** @exclude **/
- @Override
- public boolean equals(Object o)
- {
- if (o instanceof Destination)
- {
- Destination d = (Destination)o;
- String serviceType1 = d.getServiceType();
- String serviceType2 = getServiceType();
- if ((serviceType1 == null && serviceType2 == null) || (serviceType1 != null && serviceType1.equals(serviceType2)))
- {
- String id1 = d.getId();
- String id2 = getId();
- if ((id1 == null && id2 == null) || (id1 != null && id1.equals(id2)))
- return true;
- }
- }
- return false;
- }
-
- /** @exclude **/
- @Override
- public int hashCode()
- {
- return (getServiceType() == null ? 0 : getServiceType().hashCode()) * 100003 +
- (getId() == null ? 0 : getId().hashCode());
- }
-
- /** @exclude **/
- @Override
- public String toString()
- {
- return getServiceType() + "#" + getId();
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected/Private Methods
- //
- //--------------------------------------------------------------------------
-
- protected ThrottleManager createThrottleManager()
- {
- Service service = getService();
- if (service == null || service.getMessageBroker() == null)
- return new ThrottleManager(); // Return the default.
-
- try
- {
- Class<? extends ThrottleManager> throttleManagerClass = service.getMessageBroker().getThrottleManagerClass();
- Object instance = ClassUtil.createDefaultInstance(throttleManagerClass, null);
- if (instance instanceof ThrottleManager)
- return (ThrottleManager)instance;
- }
- catch (Throwable t)
- {
- // NOWARN
- }
-
- return new ThrottleManager(); // Return the default.
- }
-
- protected void network(ConfigMap properties)
- {
- ConfigMap network = properties.getPropertyAsMap(NetworkSettings.NETWORK_ELEMENT, null);
- if (network == null)
- return;
-
- // Get implementation specific network settings, including subclasses!
- NetworkSettings ns = getNetworkSettings();
-
- // Subscriber timeout; first check for subscription-timeout-minutes and fallback to legacy session-timeout.
- int useLegacyPropertyToken = -999999;
- int subscriptionTimeoutMinutes = network.getPropertyAsInt(NetworkSettings.SUBSCRIPTION_TIMEOUT_MINUTES, useLegacyPropertyToken);
- if (subscriptionTimeoutMinutes == useLegacyPropertyToken)
- subscriptionTimeoutMinutes = network.getPropertyAsInt(NetworkSettings.SESSION_TIMEOUT, NetworkSettings.DEFAULT_TIMEOUT);
- ns.setSubscriptionTimeoutMinutes(subscriptionTimeoutMinutes);
-
- // Throttle Settings
- ThrottleSettings ts = ns.getThrottleSettings();
- ts.setDestinationName(getId());
- throttle(ts, network);
-
- setNetworkSettings(ns);
- }
-
- protected void throttle(ThrottleSettings ts, ConfigMap network)
- {
- ConfigMap inbound = network.getPropertyAsMap(ThrottleSettings.ELEMENT_INBOUND, null);
- if (inbound != null)
- {
- ThrottleSettings.Policy policy = getPolicyFromThrottleSettings(inbound);
- ts.setInboundPolicy(policy);
- int destFreq = inbound.getPropertyAsInt(ThrottleSettings.ELEMENT_DEST_FREQ, 0);
- ts.setIncomingDestinationFrequency(destFreq);
- int clientFreq = inbound.getPropertyAsInt(ThrottleSettings.ELEMENT_CLIENT_FREQ, 0);
- ts.setIncomingClientFrequency(clientFreq);
- }
-
- ConfigMap outbound = network.getPropertyAsMap(ThrottleSettings.ELEMENT_OUTBOUND, null);
- if (outbound != null)
- {
- ThrottleSettings.Policy policy = getPolicyFromThrottleSettings(outbound);
- ts.setOutboundPolicy(policy);
- int destFreq = outbound.getPropertyAsInt(ThrottleSettings.ELEMENT_DEST_FREQ, 0);
- ts.setOutgoingDestinationFrequency(destFreq);
- int clientFreq = outbound.getPropertyAsInt(ThrottleSettings.ELEMENT_CLIENT_FREQ, 0);
- ts.setOutgoingClientFrequency(clientFreq);
- }
- }
-
- private ThrottleSettings.Policy getPolicyFromThrottleSettings(ConfigMap settings)
- {
- String policyString = settings.getPropertyAsString(ThrottleSettings.ELEMENT_POLICY, null);
- ThrottleSettings.Policy policy = ThrottleSettings.Policy.NONE;
- if (policyString == null)
- return policy;
- try
- {
- policy = ThrottleSettings.parsePolicy(policyString);
- }
- catch (ConfigurationException exception)
- {
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(UNSUPPORTED_POLICY, new Object[] {getId(), policyString});
- throw ce;
- }
- return policy;
- }
-
- protected void server(ConfigMap properties)
- {
- ConfigMap server = properties.getPropertyAsMap(DestinationSettings.SERVER_ELEMENT, null);
- if (server == null)
- return;
-
- long ttl = server.getPropertyAsLong(MessagingConstants.TIME_TO_LIVE_ELEMENT, -1);
- serverSettings.setMessageTTL(ttl);
-
- boolean durable = server.getPropertyAsBoolean(MessagingConstants.IS_DURABLE_ELEMENT, false);
- serverSettings.setDurable(durable);
-
- boolean allowSubtopics = server.getPropertyAsBoolean(MessagingConstants.ALLOW_SUBTOPICS_ELEMENT, false);
- serverSettings.setAllowSubtopics(allowSubtopics);
-
- boolean disallowWildcardSubtopics = server.getPropertyAsBoolean(MessagingConstants.DISALLOW_WILDCARD_SUBTOPICS_ELEMENT, false);
- serverSettings.setDisallowWildcardSubtopics(disallowWildcardSubtopics);
-
- int priority = server.getPropertyAsInt(MessagingConstants.MESSAGE_PRIORITY, -1);
- if (priority != -1)
- serverSettings.setPriority(priority);
-
- String subtopicSeparator = server.getPropertyAsString(MessagingConstants.SUBTOPIC_SEPARATOR_ELEMENT, MessagingConstants.DEFAULT_SUBTOPIC_SEPARATOR);
- serverSettings.setSubtopicSeparator(subtopicSeparator);
-
- String routingMode = server.getPropertyAsString(MessagingConstants.CLUSTER_MESSAGE_ROUTING, "server-to-server");
- serverSettings.setBroadcastRoutingMode(routingMode);
- }
-
- /**
- * Returns the log category of the <code>MessageDestination</code>.
- *
- * @return The log category of the component.
- */
- @Override
- protected String getLogCategory()
- {
- return LOG_CATEGORY;
- }
-
- /**
- * Invoked automatically to allow the <code>MessageDestination</code> to setup its corresponding
- * MBean control.
- *
- * @param service The <code>Service</code> that manages this <code>MessageDestination</code>.
- */
- @Override
- protected void setupDestinationControl(Service service)
- {
- controller = new MessageDestinationControl(this, service.getControl());
- controller.register();
- setControl(controller);
- setupThrottleManagerControl(controller);
- setupSubscriptionManagerControl(controller);
- }
-
- protected void setupThrottleManagerControl(MessageDestinationControl destinationControl)
- {
- if (throttleManager != null)
- {
- ThrottleManagerControl throttleManagerControl = new ThrottleManagerControl(throttleManager, destinationControl);
- throttleManagerControl.register();
- throttleManager.setControl(throttleManagerControl);
- throttleManager.setManaged(true);
- destinationControl.setThrottleManager(throttleManagerControl.getObjectName());
- }
- }
-
- private void setupSubscriptionManagerControl(MessageDestinationControl destinationControl)
- {
- SubscriptionManagerControl subscriptionManagerControl = new SubscriptionManagerControl(getSubscriptionManager(), destinationControl);
- subscriptionManagerControl.register();
- getSubscriptionManager().setControl(subscriptionManagerControl);
- getSubscriptionManager().setManaged(true);
- destinationControl.setSubscriptionManager(subscriptionManagerControl.getObjectName());
- }
-}
+/*
+ * 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;
+
+import flex.management.runtime.messaging.MessageDestinationControl;
+import flex.management.runtime.messaging.services.messaging.SubscriptionManagerControl;
+import flex.management.runtime.messaging.services.messaging.ThrottleManagerControl;
+import flex.messaging.config.ConfigurationConstants;
+import flex.messaging.config.ConfigurationException;
+import flex.messaging.config.DestinationSettings;
+import flex.messaging.config.ThrottleSettings;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.NetworkSettings;
+import flex.messaging.config.ServerSettings;
+import flex.messaging.config.ThrottleSettings.Policy;
+import flex.messaging.log.LogCategories;
+import flex.messaging.services.MessageService;
+import flex.messaging.services.Service;
+import flex.messaging.services.messaging.SubscriptionManager;
+import flex.messaging.services.messaging.RemoteSubscriptionManager;
+import flex.messaging.services.messaging.ThrottleManager;
+import flex.messaging.services.messaging.MessagingConstants;
+import flex.messaging.util.ClassUtil;
+
+/**
+ * A logical reference to a MessageDestination.
+ */
+public class MessageDestination extends FactoryDestination
+{
+ static final long serialVersionUID = -2016911808141319012L;
+
+ /** Log category for <code>MessageDestination</code>.*/
+ public static final String LOG_CATEGORY = LogCategories.SERVICE_MESSAGE;
+
+ // Errors
+ private static final int UNSUPPORTED_POLICY = 10124;
+
+ // Destination properties
+ private transient ServerSettings serverSettings;
+
+ // Destination internal
+ private transient SubscriptionManager subscriptionManager;
+ private transient RemoteSubscriptionManager remoteSubscriptionManager;
+ private transient ThrottleManager throttleManager;
+
+ private transient MessageDestinationControl controller;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>MessageDestination</code> instance.
+ */
+ public MessageDestination()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>MessageDestination</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>MessageDestination</code>
+ * is manageable; otherwise <code>false</code>.
+ */
+ public MessageDestination(boolean enableManagement)
+ {
+ super(enableManagement);
+
+ serverSettings = new ServerSettings();
+
+ // Managers
+ subscriptionManager = new SubscriptionManager(this);
+ remoteSubscriptionManager = new RemoteSubscriptionManager(this);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Initialize, validate, start, and stop methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes the <code>MessageDestination</code> with the properties.
+ * If subclasses override, they must call <code>super.initialize()</code>.
+ *
+ * @param id The id of the destination.
+ * @param properties Properties for the <code>MessageDestination</code>.
+ */
+ @Override
+ public void initialize(String id, ConfigMap properties)
+ {
+ super.initialize(id, properties);
+
+ if (properties == null || properties.size() == 0)
+ return;
+
+ // Network properties
+ network(properties);
+
+ // Server properties
+ server(properties);
+ }
+
+ /**
+ * Sets up the throttle manager before it starts.
+ */
+ @Override
+ public void start()
+ {
+ // Create the throttle manager, only if needed.
+ if (networkSettings.getThrottleSettings() != null)
+ {
+ ThrottleSettings settings = networkSettings.getThrottleSettings();
+ if (settings.isClientThrottleEnabled() || settings.isDestinationThrottleEnabled())
+ {
+ settings.setDestinationName(getId());
+ throttleManager = createThrottleManager();
+ throttleManager.setThrottleSettings(settings);
+ throttleManager.start();
+ }
+ }
+ super.start();
+ }
+
+ /**
+ * Stops the subscription, remote subscription, and throttle managers and
+ * then calls super class's stop.
+ */
+ @Override
+ public void stop()
+ {
+ if (isStarted())
+ {
+ subscriptionManager.stop();
+ remoteSubscriptionManager.stop();
+ if (throttleManager != null)
+ throttleManager.stop();
+ }
+ super.stop();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Getters and Setters for Destination properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Sets the <code>NetworkSettings</code> of the <code>MessageDestination</code>.
+ *
+ * @param networkSettings The <code>NetworkSettings</code> of the <code>MessageDestination</code>
+ */
+ @Override
+ public void setNetworkSettings(NetworkSettings networkSettings)
+ {
+ super.setNetworkSettings(networkSettings);
+
+ // Set the subscription manager settings if needed.
+ if (networkSettings.getSubscriptionTimeoutMinutes() > 0)
+ {
+ long subscriptionTimeoutMillis = networkSettings.getSubscriptionTimeoutMinutes() * 60L * 1000L; // Convert to millis.
+ subscriptionManager.setSubscriptionTimeoutMillis(subscriptionTimeoutMillis);
+ }
+ }
+
+ /**
+ * Returns the <code>ServerSettings</code> of the <code>MessageDestination</code>.
+ *
+ * @return The <code>ServerSettings</code> of the <code>MessageDestination</code>.
+ */
+ public ServerSettings getServerSettings()
+ {
+ return serverSettings;
+ }
+
+ /**
+ * Sets the <code>ServerSettings</code> of the <code>MessageDestination</code>.
+ *
+ * @param serverSettings The <code>ServerSettings</code> of the <code>MessageDestination</code>
+ */
+ public void setServerSettings(ServerSettings serverSettings)
+ {
+ this.serverSettings = serverSettings;
+ }
+
+ /**
+ * Casts the <code>Service</code> into <code>MessageService</code>
+ * and calls super.setService.
+ *
+ * @param service The <code>Service</code> managing this <code>Destination</code>.
+ */
+ @Override
+ public void setService(Service service)
+ {
+ MessageService messageService = (MessageService)service;
+ super.setService(messageService);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Other Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @exclude
+ * Returns a <tt>ConfigMap</tt> of destination properties that the client
+ * needs. This includes properties from <code>super{@link #describeDestination(boolean)}</code>
+ * and it also includes outbound throttling policy that the edge server might need.
+ *
+ * @param onlyReliable Determines whether only reliable destination configuration should be returned.
+ * @return A <tt>ConfigMap</tt> of destination properties that the client needs.
+ */
+ @Override
+ public ConfigMap describeDestination(boolean onlyReliable)
+ {
+ ConfigMap destinationConfig = super.describeDestination(onlyReliable);
+ if (destinationConfig == null)
+ return null;
+
+ if (throttleManager == null)
+ return destinationConfig;
+
+ Policy outboundPolicy = throttleManager.getOutboundPolicy();
+ if (outboundPolicy == null || outboundPolicy == Policy.NONE)
+ return destinationConfig;
+
+ // Add the outbound throttle policy to network properties section as appropriate.
+ ConfigMap properties = destinationConfig.getPropertyAsMap(ConfigurationConstants.PROPERTIES_ELEMENT, null);
+ if (properties == null)
+ {
+ properties = new ConfigMap();
+ destinationConfig.addProperty(ConfigurationConstants.PROPERTIES_ELEMENT, properties);
+ }
+
+ ConfigMap network = properties.getPropertyAsMap(NetworkSettings.NETWORK_ELEMENT, null);
+ if (network == null)
+ {
+ network = new ConfigMap();
+ properties.addProperty(NetworkSettings.NETWORK_ELEMENT, network);
+ }
+
+ ConfigMap throttleOutbound = new ConfigMap();
+ throttleOutbound.addProperty(ThrottleSettings.ELEMENT_POLICY, throttleManager.getOutboundPolicy().toString());
+ network.addProperty(ThrottleSettings.ELEMENT_OUTBOUND, throttleOutbound);
+
+ return destinationConfig;
+ }
+
+ /** @exclude */
+ public SubscriptionManager getSubscriptionManager()
+ {
+ return subscriptionManager;
+ }
+
+ /** @exclude */
+ public RemoteSubscriptionManager getRemoteSubscriptionManager()
+ {
+ return remoteSubscriptionManager;
+ }
+
+ /** @exclude */
+ public ThrottleManager getThrottleManager()
+ {
+ return throttleManager;
+ }
+
+ /** @exclude **/
+ @Override
+ public boolean equals(Object o)
+ {
+ if (o instanceof Destination)
+ {
+ Destination d = (Destination)o;
+ String serviceType1 = d.getServiceType();
+ String serviceType2 = getServiceType();
+ if ((serviceType1 == null && serviceType2 == null) || (serviceType1 != null && serviceType1.equals(serviceType2)))
+ {
+ String id1 = d.getId();
+ String id2 = getId();
+ if ((id1 == null && id2 == null) || (id1 != null && id1.equals(id2)))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /** @exclude **/
+ @Override
+ public int hashCode()
+ {
+ return (getServiceType() == null ? 0 : getServiceType().hashCode()) * 100003 +
+ (getId() == null ? 0 : getId().hashCode());
+ }
+
+ /** @exclude **/
+ @Override
+ public String toString()
+ {
+ return getServiceType() + "#" + getId();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected/Private Methods
+ //
+ //--------------------------------------------------------------------------
+
+ protected ThrottleManager createThrottleManager()
+ {
+ Service service = getService();
+ if (service == null || service.getMessageBroker() == null)
+ return new ThrottleManager(); // Return the default.
+
+ try
+ {
+ Class<? extends ThrottleManager> throttleManagerClass = service.getMessageBroker().getThrottleManagerClass();
+ Object instance = ClassUtil.createDefaultInstance(throttleManagerClass, null);
+ if (instance instanceof ThrottleManager)
+ return (ThrottleManager)instance;
+ }
+ catch (Throwable t)
+ {
+ // NOWARN
+ }
+
+ return new ThrottleManager(); // Return the default.
+ }
+
+ protected void network(ConfigMap properties)
+ {
+ ConfigMap network = properties.getPropertyAsMap(NetworkSettings.NETWORK_ELEMENT, null);
+ if (network == null)
+ return;
+
+ // Get implementation specific network settings, including subclasses!
+ NetworkSettings ns = getNetworkSettings();
+
+ // Subscriber timeout; first check for subscription-timeout-minutes and fallback to legacy session-timeout.
+ int useLegacyPropertyToken = -999999;
+ int subscriptionTimeoutMinutes = network.getPropertyAsInt(NetworkSettings.SUBSCRIPTION_TIMEOUT_MINUTES, useLegacyPropertyToken);
+ if (subscriptionTimeoutMinutes == useLegacyPropertyToken)
+ subscriptionTimeoutMinutes = network.getPropertyAsInt(NetworkSettings.SESSION_TIMEOUT, NetworkSettings.DEFAULT_TIMEOUT);
+ ns.setSubscriptionTimeoutMinutes(subscriptionTimeoutMinutes);
+
+ // Throttle Settings
+ ThrottleSettings ts = ns.getThrottleSettings();
+ ts.setDestinationName(getId());
+ throttle(ts, network);
+
+ setNetworkSettings(ns);
+ }
+
+ protected void throttle(ThrottleSettings ts, ConfigMap network)
+ {
+ ConfigMap inbound = network.getPropertyAsMap(ThrottleSettings.ELEMENT_INBOUND, null);
+ if (inbound != null)
+ {
+ ThrottleSettings.Policy policy = getPolicyFromThrottleSettings(inbound);
+ ts.setInboundPolicy(policy);
+ int destFreq = inbound.getPropertyAsInt(ThrottleSettings.ELEMENT_DEST_FREQ, 0);
+ ts.setIncomingDestinationFrequency(destFreq);
+ int clientFreq = inbound.getPropertyAsInt(ThrottleSettings.ELEMENT_CLIENT_FREQ, 0);
+ ts.setIncomingClientFrequency(clientFreq);
+ }
+
+ ConfigMap outbound = network.getPropertyAsMap(ThrottleSettings.ELEMENT_OUTBOUND, null);
+ if (outbound != null)
+ {
+ ThrottleSettings.Policy policy = getPolicyFromThrottleSettings(outbound);
+ ts.setOutboundPolicy(policy);
+ int destFreq = outbound.getPropertyAsInt(ThrottleSettings.ELEMENT_DEST_FREQ, 0);
+ ts.setOutgoingDestinationFrequency(destFreq);
+ int clientFreq = outbound.getPropertyAsInt(ThrottleSettings.ELEMENT_CLIENT_FREQ, 0);
+ ts.setOutgoingClientFrequency(clientFreq);
+ }
+ }
+
+ private ThrottleSettings.Policy getPolicyFromThrottleSettings(ConfigMap settings)
+ {
+ String policyString = settings.getPropertyAsString(ThrottleSettings.ELEMENT_POLICY, null);
+ ThrottleSettings.Policy policy = ThrottleSettings.Policy.NONE;
+ if (policyString == null)
+ return policy;
+ try
+ {
+ policy = ThrottleSettings.parsePolicy(policyString);
+ }
+ catch (ConfigurationException exception)
+ {
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(UNSUPPORTED_POLICY, new Object[] {getId(), policyString});
+ throw ce;
+ }
+ return policy;
+ }
+
+ protected void server(ConfigMap properties)
+ {
+ ConfigMap server = properties.getPropertyAsMap(DestinationSettings.SERVER_ELEMENT, null);
+ if (server == null)
+ return;
+
+ long ttl = server.getPropertyAsLong(MessagingConstants.TIME_TO_LIVE_ELEMENT, -1);
+ serverSettings.setMessageTTL(ttl);
+
+ boolean durable = server.getPropertyAsBoolean(MessagingConstants.IS_DURABLE_ELEMENT, false);
+ serverSettings.setDurable(durable);
+
+ boolean allowSubtopics = server.getPropertyAsBoolean(MessagingConstants.ALLOW_SUBTOPICS_ELEMENT, false);
+ serverSettings.setAllowSubtopics(allowSubtopics);
+
+ boolean disallowWildcardSubtopics = server.getPropertyAsBoolean(MessagingConstants.DISALLOW_WILDCARD_SUBTOPICS_ELEMENT, false);
+ serverSettings.setDisallowWildcardSubtopics(disallowWildcardSubtopics);
+
+ int priority = server.getPropertyAsInt(MessagingConstants.MESSAGE_PRIORITY, -1);
+ if (priority != -1)
+ serverSettings.setPriority(priority);
+
+ String subtopicSeparator = server.getPropertyAsString(MessagingConstants.SUBTOPIC_SEPARATOR_ELEMENT, MessagingConstants.DEFAULT_SUBTOPIC_SEPARATOR);
+ serverSettings.setSubtopicSeparator(subtopicSeparator);
+
+ String routingMode = server.getPropertyAsString(MessagingConstants.CLUSTER_MESSAGE_ROUTING, "server-to-server");
+ serverSettings.setBroadcastRoutingMode(routingMode);
+ }
+
+ /**
+ * Returns the log category of the <code>MessageDestination</code>.
+ *
+ * @return The log category of the component.
+ */
+ @Override
+ protected String getLogCategory()
+ {
+ return LOG_CATEGORY;
+ }
+
+ /**
+ * Invoked automatically to allow the <code>MessageDestination</code> to setup its corresponding
+ * MBean control.
+ *
+ * @param service The <code>Service</code> that manages this <code>MessageDestination</code>.
+ */
+ @Override
+ protected void setupDestinationControl(Service service)
+ {
+ controller = new MessageDestinationControl(this, service.getControl());
+ controller.register();
+ setControl(controller);
+ setupThrottleManagerControl(controller);
+ setupSubscriptionManagerControl(controller);
+ }
+
+ protected void setupThrottleManagerControl(MessageDestinationControl destinationControl)
+ {
+ if (throttleManager != null)
+ {
+ ThrottleManagerControl throttleManagerControl = new ThrottleManagerControl(throttleManager, destinationControl);
+ throttleManagerControl.register();
+ throttleManager.setControl(throttleManagerControl);
+ throttleManager.setManaged(true);
+ destinationControl.setThrottleManager(throttleManagerControl.getObjectName());
+ }
+ }
+
+ private void setupSubscriptionManagerControl(MessageDestinationControl destinationControl)
+ {
+ SubscriptionManagerControl subscriptionManagerControl = new SubscriptionManagerControl(getSubscriptionManager(), destinationControl);
+ subscriptionManagerControl.register();
+ getSubscriptionManager().setControl(subscriptionManagerControl);
+ getSubscriptionManager().setManaged(true);
+ destinationControl.setSubscriptionManager(subscriptionManagerControl.getObjectName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/MessageException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/MessageException.java b/modules/core/src/flex/messaging/MessageException.java
old mode 100755
new mode 100644
index f11c59a..9ebf0c2
--- a/modules/core/src/flex/messaging/MessageException.java
+++ b/modules/core/src/flex/messaging/MessageException.java
@@ -1,443 +1,443 @@
-/*
- * 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;
-
-import java.util.Map;
-
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.log.LogEvent;
-import flex.messaging.messages.ErrorMessage;
-import flex.messaging.messages.Message;
-import flex.messaging.util.ExceptionUtil;
-import flex.messaging.util.PropertyStringResourceLoader;
-import flex.messaging.util.ResourceLoader;
-import flex.messaging.util.StringUtils;
-
-/**
- * The MessageException class is the basic exception type used throughout
- * the server. This class is extended to support more specific exception types.
- */
-public class MessageException extends LocalizedException
-{
- //--------------------------------------------------------------------------
- //
- // Static Constants
- //
- //--------------------------------------------------------------------------
-
- // Message exception code strings.
- public static final String CODE_SERVER_RESOURCE_UNAVAILABLE = "Server.ResourceUnavailable";
-
- /** @exclude **/
- static final long serialVersionUID = 3310842114461162689L;
-
- //--------------------------------------------------------------------------
- //
- // Constructors
- //
- //--------------------------------------------------------------------------
-
- /**
- * Default constructor.
- */
- public MessageException()
- {
- }
-
- /**
- * Construct a message specifying a ResourceLoader to be used to load localized strings.
- *
- * @param loader
- */
- public MessageException(ResourceLoader loader)
- {
- super(loader);
- }
-
- /**
- * Constructor with a message.
- *
- * @param message The detailed message for the exception.
- */
- public MessageException(String message)
- {
- setMessage(message);
- }
-
- /**
- * Constructs a new exception with the specified message and the <code>Throwable</code> as the root cause.
- *
- * @param message The detailed message for the exception.
- * @param t The root cause of the exception.
- */
- public MessageException(String message, Throwable t)
- {
- setMessage(message);
- setRootCause(t);
- }
-
- /**
- * Constructs a new exception with the specified <code>Throwable</code> as the root cause.
- *
- * @param t The root cause of the exception.
- */
- public MessageException(Throwable t)
- {
- String rootMessage = t.getMessage();
- if (rootMessage == null)
- rootMessage = t.toString();
- setMessage(rootMessage);
- setRootCause(t);
- }
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // code
- //----------------------------------
-
- /** @exclude **/
- protected String code;
-
- /**
- * Returns the code of the exception.
- *
- * @return Code of the exception.
- */
- public String getCode()
- {
- return code;
- }
-
- /**
- * Sets the code of the exception.
- *
- * @param code Code of the exception.
- */
- public void setCode(String code)
- {
- this.code = code;
- }
-
- //----------------------------------
- // defaultLogMessageIntro
- //----------------------------------
-
- /**
- * Returns the default initial text for use in the log output generated by <code>logAtHingePoint()</code>.
- */
- public String getDefaultLogMessageIntro()
- {
- return "Error handling message: ";
- }
-
- //----------------------------------
- // extendedData
- //----------------------------------
-
- /** @exclude **/
- protected Map extendedData;
-
- /**
- * Returns the extended data of the exception.
- *
- * @return The extended data of the exception.
- */
- public Map getExtendedData()
- {
- return extendedData;
- }
-
- /**
- * Sets the extended data of the exception.
- *
- * @param extendedData The extended data of the exception.
- */
- public void setExtendedData(Map extendedData)
- {
- this.extendedData = extendedData;
- }
-
- //----------------------------------
- // errorMessage
- //----------------------------------
-
- /** @exclude **/
- protected ErrorMessage errorMessage;
-
- /**
- * Returns the error message of the exception.
- *
- * @return The error message of the exception.
- */
- public ErrorMessage getErrorMessage()
- {
- if (errorMessage == null)
- {
- errorMessage = createErrorMessage();
- }
- return errorMessage;
- }
-
- /**
- * Sets the error message of the exception.
- *
- * @param errorMessage The error message of the exception.
- */
- public void setErrorMessage(ErrorMessage errorMessage)
- {
- this.errorMessage = errorMessage;
- }
-
- //----------------------------------
- // logStackTraceEnabled
- //----------------------------------
-
- /**
- * Indicates whether logging of this exception should include a full stack trace or not.
- * Default is true.
- *
- * @see #logAtHingePoint(Message, ErrorMessage, String)
- */
- public boolean isLogStackTraceEnabled()
- {
- return true;
- }
-
- //----------------------------------
- // logged
- //----------------------------------
-
- protected boolean logged;
-
- /**
- * Indicates whether this exception has already been logged
- * by a call to <code>logAtHingPoint()</code>.
- * Manual logging for an exception can use <code>setLogged(true)</code>
- * to suppress any further automatic logging of the exception.
- *
- * @return true if the exception has been logged; otherwise false.
- */
- public boolean isLogged()
- {
- return logged;
- }
-
- /**
- * Records whether this exception has been logged.
- *
- * @param value true if the exception has been logged; otherwise false.
- */
- public void setLogged(boolean value)
- {
- logged = value;
- }
-
- //----------------------------------
- // peferredLogLevel
- //----------------------------------
-
- /**
- * Returns the preferred log level for this exception instance.
- * The default value is <code>LogEvent.ERROR</code>.
- *
- * @see #logAtHingePoint(Message, ErrorMessage, String)
- */
- public short getPreferredLogLevel()
- {
- return LogEvent.ERROR;
- }
-
- //----------------------------------
- // resourceLoader
- //----------------------------------
-
- /**
- * Returns the <code>ResourceLoader</code> used to load localized strings.
- *
- * @return The <code>ResourceLoader</code> used to load localized strings.
- */
- @Override protected ResourceLoader getResourceLoader()
- {
- if (resourceLoader == null)
- {
- try
- {
- MessageBroker broker = FlexContext.getMessageBroker();
- resourceLoader = broker != null? broker.getSystemSettings().getResourceLoader()
- : new PropertyStringResourceLoader();
- }
- catch (NoClassDefFoundError exception) // Could happen in client mode.
- {
- return new PropertyStringResourceLoader();
- }
- }
-
- return resourceLoader;
- }
-
- //----------------------------------
- // rootCauseErrorMessage
- //----------------------------------
-
- /** @exclude **/
- public Object getRootCauseErrorMessage()
- {
- if (rootCause == null)
- return null;
-
- // FIXME: serialize number field.
- return rootCause instanceof MessageException?
- ((MessageException)rootCause).createErrorMessage() : rootCause;
- }
-
- //----------------------------------
- // statusCode
- //----------------------------------
-
- protected int statusCode;
-
- /**
- * Returns the HTTP status code of the exception.
- *
- * @return The HTTP status code of the exception.
- */
- public int getStatusCode()
- {
- return statusCode;
- }
-
- /**
- * Sets the HTTP status code of the exception.
- *
- * @param statusCode The HTTP status code of the exception.
- */
- public void setStatusCode(int statusCode)
- {
- this.statusCode = statusCode;
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Creates an error message from the exception.
- *
- * @return The error message.
- */
- public ErrorMessage createErrorMessage()
- {
- ErrorMessage msg = new ErrorMessage();
- msg.faultCode = code != null? code : "Server.Processing";
- msg.faultString = message;
- msg.faultDetail = details;
- msg.rootCause = getRootCauseErrorMessage();
- if (extendedData != null)
- msg.extendedData = extendedData;
- if (statusCode != 0)
- msg.setHeader(Message.STATUS_CODE_HEADER, statusCode);
- return msg;
- }
-
- /**
- * Invoked at hinge-points in server processing where catch-all exception logging is performed.
- * This method uses <code>isLogged()</code> and <code>setLogged()</code> to avoid repeat logging
- * of the same exception and uses <code>getPreferredLogLevel()</code> which may be
- * overridden in subclasses to control the log level that the logging is output at.
- * The underlying exception stack traces are also conditionally included in log output
- * if the exception class allows it and this is determined by invoking <code>isLogStackTraceEnabled()</code>
- *
- * @param inboundMessage The inbound message that triggered an exception during processing.
- * @param outboundMessage The outbound <code>ErrorMessage</code>, which may be null depending on whether it has been generated
- * or not at the point this method is invoked.
- * @param logMessageIntro The beginning text for the log message, which may be null; default value is returned by <code>getDefaultLogMessageIntro()</code>.
- */
- public void logAtHingePoint(Message inboundMessage, ErrorMessage outboundMessage, String logMessageIntro)
- {
- if (!isLogged())
- {
- setLogged(true);
-
- short preferredLevel = getPreferredLogLevel();
- // If the preferred level is less than the current Log level; return early.
- if (preferredLevel < Log.getTargetLevel())
- return;
-
- // Construct core log output.
- StringBuffer output = new StringBuffer();
- output.append((logMessageIntro != null) ? logMessageIntro : getDefaultLogMessageIntro());
- output.append(this.toString());
- output.append(StringUtils.NEWLINE);
- output.append(" incomingMessage: ");
- output.append(inboundMessage);
- output.append(StringUtils.NEWLINE);
- if (outboundMessage != null)
- {
- output.append(" errorReply: ");
- output.append(outboundMessage);
- output.append(StringUtils.NEWLINE);
- }
- if (isLogStackTraceEnabled())
- {
- output.append(ExceptionUtil.exceptionFollowedByRootCausesToString(this));
- output.append(StringUtils.NEWLINE);
- }
-
- switch (preferredLevel)
- {
- case LogEvent.FATAL:
- {
- Log.getLogger(LogCategories.MESSAGE_GENERAL).fatal(output.toString());
- break;
- }
- case LogEvent.ERROR:
- {
- Log.getLogger(LogCategories.MESSAGE_GENERAL).error(output.toString());
- break;
- }
- case LogEvent.WARN:
- {
- Log.getLogger(LogCategories.MESSAGE_GENERAL).warn(output.toString());
- break;
- }
- case LogEvent.INFO:
- {
- Log.getLogger(LogCategories.MESSAGE_GENERAL).info(output.toString());
- break;
- }
- case LogEvent.DEBUG:
- {
- Log.getLogger(LogCategories.MESSAGE_GENERAL).debug(output.toString());
- break;
- }
- default:
- {
- Log.getLogger(LogCategories.MESSAGE_GENERAL).fatal("Failed to log exception for handling message due to an invalid preferred log level: " + preferredLevel);
- break;
- }
- }
- }
- }
-}
+/*
+ * 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;
+
+import java.util.Map;
+
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.log.LogEvent;
+import flex.messaging.messages.ErrorMessage;
+import flex.messaging.messages.Message;
+import flex.messaging.util.ExceptionUtil;
+import flex.messaging.util.PropertyStringResourceLoader;
+import flex.messaging.util.ResourceLoader;
+import flex.messaging.util.StringUtils;
+
+/**
+ * The MessageException class is the basic exception type used throughout
+ * the server. This class is extended to support more specific exception types.
+ */
+public class MessageException extends LocalizedException
+{
+ //--------------------------------------------------------------------------
+ //
+ // Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ // Message exception code strings.
+ public static final String CODE_SERVER_RESOURCE_UNAVAILABLE = "Server.ResourceUnavailable";
+
+ /** @exclude **/
+ static final long serialVersionUID = 3310842114461162689L;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructors
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Default constructor.
+ */
+ public MessageException()
+ {
+ }
+
+ /**
+ * Construct a message specifying a ResourceLoader to be used to load localized strings.
+ *
+ * @param loader
+ */
+ public MessageException(ResourceLoader loader)
+ {
+ super(loader);
+ }
+
+ /**
+ * Constructor with a message.
+ *
+ * @param message The detailed message for the exception.
+ */
+ public MessageException(String message)
+ {
+ setMessage(message);
+ }
+
+ /**
+ * Constructs a new exception with the specified message and the <code>Throwable</code> as the root cause.
+ *
+ * @param message The detailed message for the exception.
+ * @param t The root cause of the exception.
+ */
+ public MessageException(String message, Throwable t)
+ {
+ setMessage(message);
+ setRootCause(t);
+ }
+
+ /**
+ * Constructs a new exception with the specified <code>Throwable</code> as the root cause.
+ *
+ * @param t The root cause of the exception.
+ */
+ public MessageException(Throwable t)
+ {
+ String rootMessage = t.getMessage();
+ if (rootMessage == null)
+ rootMessage = t.toString();
+ setMessage(rootMessage);
+ setRootCause(t);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // code
+ //----------------------------------
+
+ /** @exclude **/
+ protected String code;
+
+ /**
+ * Returns the code of the exception.
+ *
+ * @return Code of the exception.
+ */
+ public String getCode()
+ {
+ return code;
+ }
+
+ /**
+ * Sets the code of the exception.
+ *
+ * @param code Code of the exception.
+ */
+ public void setCode(String code)
+ {
+ this.code = code;
+ }
+
+ //----------------------------------
+ // defaultLogMessageIntro
+ //----------------------------------
+
+ /**
+ * Returns the default initial text for use in the log output generated by <code>logAtHingePoint()</code>.
+ */
+ public String getDefaultLogMessageIntro()
+ {
+ return "Error handling message: ";
+ }
+
+ //----------------------------------
+ // extendedData
+ //----------------------------------
+
+ /** @exclude **/
+ protected Map extendedData;
+
+ /**
+ * Returns the extended data of the exception.
+ *
+ * @return The extended data of the exception.
+ */
+ public Map getExtendedData()
+ {
+ return extendedData;
+ }
+
+ /**
+ * Sets the extended data of the exception.
+ *
+ * @param extendedData The extended data of the exception.
+ */
+ public void setExtendedData(Map extendedData)
+ {
+ this.extendedData = extendedData;
+ }
+
+ //----------------------------------
+ // errorMessage
+ //----------------------------------
+
+ /** @exclude **/
+ protected ErrorMessage errorMessage;
+
+ /**
+ * Returns the error message of the exception.
+ *
+ * @return The error message of the exception.
+ */
+ public ErrorMessage getErrorMessage()
+ {
+ if (errorMessage == null)
+ {
+ errorMessage = createErrorMessage();
+ }
+ return errorMessage;
+ }
+
+ /**
+ * Sets the error message of the exception.
+ *
+ * @param errorMessage The error message of the exception.
+ */
+ public void setErrorMessage(ErrorMessage errorMessage)
+ {
+ this.errorMessage = errorMessage;
+ }
+
+ //----------------------------------
+ // logStackTraceEnabled
+ //----------------------------------
+
+ /**
+ * Indicates whether logging of this exception should include a full stack trace or not.
+ * Default is true.
+ *
+ * @see #logAtHingePoint(Message, ErrorMessage, String)
+ */
+ public boolean isLogStackTraceEnabled()
+ {
+ return true;
+ }
+
+ //----------------------------------
+ // logged
+ //----------------------------------
+
+ protected boolean logged;
+
+ /**
+ * Indicates whether this exception has already been logged
+ * by a call to <code>logAtHingPoint()</code>.
+ * Manual logging for an exception can use <code>setLogged(true)</code>
+ * to suppress any further automatic logging of the exception.
+ *
+ * @return true if the exception has been logged; otherwise false.
+ */
+ public boolean isLogged()
+ {
+ return logged;
+ }
+
+ /**
+ * Records whether this exception has been logged.
+ *
+ * @param value true if the exception has been logged; otherwise false.
+ */
+ public void setLogged(boolean value)
+ {
+ logged = value;
+ }
+
+ //----------------------------------
+ // peferredLogLevel
+ //----------------------------------
+
+ /**
+ * Returns the preferred log level for this exception instance.
+ * The default value is <code>LogEvent.ERROR</code>.
+ *
+ * @see #logAtHingePoint(Message, ErrorMessage, String)
+ */
+ public short getPreferredLogLevel()
+ {
+ return LogEvent.ERROR;
+ }
+
+ //----------------------------------
+ // resourceLoader
+ //----------------------------------
+
+ /**
+ * Returns the <code>ResourceLoader</code> used to load localized strings.
+ *
+ * @return The <code>ResourceLoader</code> used to load localized strings.
+ */
+ @Override protected ResourceLoader getResourceLoader()
+ {
+ if (resourceLoader == null)
+ {
+ try
+ {
+ MessageBroker broker = FlexContext.getMessageBroker();
+ resourceLoader = broker != null? broker.getSystemSettings().getResourceLoader()
+ : new PropertyStringResourceLoader();
+ }
+ catch (NoClassDefFoundError exception) // Could happen in client mode.
+ {
+ return new PropertyStringResourceLoader();
+ }
+ }
+
+ return resourceLoader;
+ }
+
+ //----------------------------------
+ // rootCauseErrorMessage
+ //----------------------------------
+
+ /** @exclude **/
+ public Object getRootCauseErrorMessage()
+ {
+ if (rootCause == null)
+ return null;
+
+ // FIXME: serialize number field.
+ return rootCause instanceof MessageException?
+ ((MessageException)rootCause).createErrorMessage() : rootCause;
+ }
+
+ //----------------------------------
+ // statusCode
+ //----------------------------------
+
+ protected int statusCode;
+
+ /**
+ * Returns the HTTP status code of the exception.
+ *
+ * @return The HTTP status code of the exception.
+ */
+ public int getStatusCode()
+ {
+ return statusCode;
+ }
+
+ /**
+ * Sets the HTTP status code of the exception.
+ *
+ * @param statusCode The HTTP status code of the exception.
+ */
+ public void setStatusCode(int statusCode)
+ {
+ this.statusCode = statusCode;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Creates an error message from the exception.
+ *
+ * @return The error message.
+ */
+ public ErrorMessage createErrorMessage()
+ {
+ ErrorMessage msg = new ErrorMessage();
+ msg.faultCode = code != null? code : "Server.Processing";
+ msg.faultString = message;
+ msg.faultDetail = details;
+ msg.rootCause = getRootCauseErrorMessage();
+ if (extendedData != null)
+ msg.extendedData = extendedData;
+ if (statusCode != 0)
+ msg.setHeader(Message.STATUS_CODE_HEADER, statusCode);
+ return msg;
+ }
+
+ /**
+ * Invoked at hinge-points in server processing where catch-all exception logging is performed.
+ * This method uses <code>isLogged()</code> and <code>setLogged()</code> to avoid repeat logging
+ * of the same exception and uses <code>getPreferredLogLevel()</code> which may be
+ * overridden in subclasses to control the log level that the logging is output at.
+ * The underlying exception stack traces are also conditionally included in log output
+ * if the exception class allows it and this is determined by invoking <code>isLogStackTraceEnabled()</code>
+ *
+ * @param inboundMessage The inbound message that triggered an exception during processing.
+ * @param outboundMessage The outbound <code>ErrorMessage</code>, which may be null depending on whether it has been generated
+ * or not at the point this method is invoked.
+ * @param logMessageIntro The beginning text for the log message, which may be null; default value is returned by <code>getDefaultLogMessageIntro()</code>.
+ */
+ public void logAtHingePoint(Message inboundMessage, ErrorMessage outboundMessage, String logMessageIntro)
+ {
+ if (!isLogged())
+ {
+ setLogged(true);
+
+ short preferredLevel = getPreferredLogLevel();
+ // If the preferred level is less than the current Log level; return early.
+ if (preferredLevel < Log.getTargetLevel())
+ return;
+
+ // Construct core log output.
+ StringBuffer output = new StringBuffer();
+ output.append((logMessageIntro != null) ? logMessageIntro : getDefaultLogMessageIntro());
+ output.append(this.toString());
+ output.append(StringUtils.NEWLINE);
+ output.append(" incomingMessage: ");
+ output.append(inboundMessage);
+ output.append(StringUtils.NEWLINE);
+ if (outboundMessage != null)
+ {
+ output.append(" errorReply: ");
+ output.append(outboundMessage);
+ output.append(StringUtils.NEWLINE);
+ }
+ if (isLogStackTraceEnabled())
+ {
+ output.append(ExceptionUtil.exceptionFollowedByRootCausesToString(this));
+ output.append(StringUtils.NEWLINE);
+ }
+
+ switch (preferredLevel)
+ {
+ case LogEvent.FATAL:
+ {
+ Log.getLogger(LogCategories.MESSAGE_GENERAL).fatal(output.toString());
+ break;
+ }
+ case LogEvent.ERROR:
+ {
+ Log.getLogger(LogCategories.MESSAGE_GENERAL).error(output.toString());
+ break;
+ }
+ case LogEvent.WARN:
+ {
+ Log.getLogger(LogCategories.MESSAGE_GENERAL).warn(output.toString());
+ break;
+ }
+ case LogEvent.INFO:
+ {
+ Log.getLogger(LogCategories.MESSAGE_GENERAL).info(output.toString());
+ break;
+ }
+ case LogEvent.DEBUG:
+ {
+ Log.getLogger(LogCategories.MESSAGE_GENERAL).debug(output.toString());
+ break;
+ }
+ default:
+ {
+ Log.getLogger(LogCategories.MESSAGE_GENERAL).fatal("Failed to log exception for handling message due to an invalid preferred log level: " + preferredLevel);
+ break;
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/MessageRoutedEvent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/MessageRoutedEvent.java b/modules/core/src/flex/messaging/MessageRoutedEvent.java
old mode 100755
new mode 100644
index 2cf0628..cc31778
--- a/modules/core/src/flex/messaging/MessageRoutedEvent.java
+++ b/modules/core/src/flex/messaging/MessageRoutedEvent.java
@@ -1,54 +1,54 @@
-/*
- * 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;
-
-import flex.messaging.messages.Message;
-
-import java.util.EventObject;
-
-/**
- * @exclude
- * This event indicates that the source message has been routed to the outbound message queues
- * for all target clients.
- * This can be used as the trigger for performing optimized IO to flush these queued messages to
- * remote hosts over the network.
- */
-public class MessageRoutedEvent extends EventObject
-{
- /**
- * @exclude
- */
- private static final long serialVersionUID = -3063794416424805005L;
-
- /**
- * Constructs a new <tt>MessageRoutedEvent</tt> using the supplied source <tt>Message</tt>.
- *
- * @param message The message that has been routed.
- */
- public MessageRoutedEvent(Message message)
- {
- super(message);
- }
-
- /**
- * Returns the message that has been routed.
- */
- public Message getMessage()
- {
- return (Message)getSource();
- }
-}
+/*
+ * 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;
+
+import flex.messaging.messages.Message;
+
+import java.util.EventObject;
+
+/**
+ * @exclude
+ * This event indicates that the source message has been routed to the outbound message queues
+ * for all target clients.
+ * This can be used as the trigger for performing optimized IO to flush these queued messages to
+ * remote hosts over the network.
+ */
+public class MessageRoutedEvent extends EventObject
+{
+ /**
+ * @exclude
+ */
+ private static final long serialVersionUID = -3063794416424805005L;
+
+ /**
+ * Constructs a new <tt>MessageRoutedEvent</tt> using the supplied source <tt>Message</tt>.
+ *
+ * @param message The message that has been routed.
+ */
+ public MessageRoutedEvent(Message message)
+ {
+ super(message);
+ }
+
+ /**
+ * Returns the message that has been routed.
+ */
+ public Message getMessage()
+ {
+ return (Message)getSource();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/MessageRoutedListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/MessageRoutedListener.java b/modules/core/src/flex/messaging/MessageRoutedListener.java
old mode 100755
new mode 100644
index 4a04267..223cd3c
--- a/modules/core/src/flex/messaging/MessageRoutedListener.java
+++ b/modules/core/src/flex/messaging/MessageRoutedListener.java
@@ -1,35 +1,35 @@
-/*
- * 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;
-
-import java.util.EventListener;
-
-/**
- * @exclude
- * Provides notification for multicast message routing events to support optimized
- * asynchronous IO to the target remote hosts.
- */
-public interface MessageRoutedListener extends EventListener
-{
- /**
- * Invoked when a message has been routed to the outbound queues for all target
- * clients.
- *
- * @param event The event containing the source message.
- */
- void messageRouted(MessageRoutedEvent event);
-}
+/*
+ * 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;
+
+import java.util.EventListener;
+
+/**
+ * @exclude
+ * Provides notification for multicast message routing events to support optimized
+ * asynchronous IO to the target remote hosts.
+ */
+public interface MessageRoutedListener extends EventListener
+{
+ /**
+ * Invoked when a message has been routed to the outbound queues for all target
+ * clients.
+ *
+ * @param event The event containing the source message.
+ */
+ void messageRouted(MessageRoutedEvent event);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/MessageRoutedNotifier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/MessageRoutedNotifier.java b/modules/core/src/flex/messaging/MessageRoutedNotifier.java
old mode 100755
new mode 100644
index c2107ba..ef27b32
--- a/modules/core/src/flex/messaging/MessageRoutedNotifier.java
+++ b/modules/core/src/flex/messaging/MessageRoutedNotifier.java
@@ -1,120 +1,120 @@
-/*
- * 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;
-
-import flex.messaging.messages.Message;
-
-import java.util.ArrayList;
-
-/**
- * @exclude
- * Supports registration and notification of <tt>MessageRoutedListener</tt>s.
- * An instance of this class is exposed by <tt>FlexContext</tt> while a message is
- * being routed, and once routing of the message to the outbound messages queues for
- * target clients and registered listeners are notified.
- * This class performs no synchronization because it is only used within the context
- * of a single Thread, and only during the routing of a single message.
- */
-public class MessageRoutedNotifier
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs a <tt>MessageRoutedNotifier</tt> for the supplied source message.
- *
- * @param The source message being routed.
- */
- public MessageRoutedNotifier(Message message)
- {
- this.message = message;
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * The source message being routed.
- */
- private final Message message;
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // messageRoutedListeners
- //----------------------------------
-
- private ArrayList listeners;
-
- /**
- * Adds a <tt>MessageRoutedListener</tt>.
- */
- public void addMessageRoutedListener(MessageRoutedListener listener)
- {
- if (listener != null)
- {
- // Lazy-init only if necessary.
- if (listeners == null)
- listeners = new ArrayList();
-
- // Add if absent.
- if (!listeners.contains(listener))
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a <tt>MessageRoutedListener</tt>.
- */
- public void removeMessageRoutedListener(MessageRoutedListener listener)
- {
- if ((listener != null) && (listeners != null))
- listeners.remove(listener);
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Notifies registered listeners of a routed message.
- *
- * @param message The message that has been routed.
- */
- public void notifyMessageRouted()
- {
- if ((listeners != null) && !listeners.isEmpty())
- {
- MessageRoutedEvent event = new MessageRoutedEvent(message);
- int n = listeners.size();
- for (int i = 0; i < n; ++i)
- ((MessageRoutedListener)listeners.get(i)).messageRouted(event);
- }
- }
-}
+/*
+ * 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;
+
+import flex.messaging.messages.Message;
+
+import java.util.ArrayList;
+
+/**
+ * @exclude
+ * Supports registration and notification of <tt>MessageRoutedListener</tt>s.
+ * An instance of this class is exposed by <tt>FlexContext</tt> while a message is
+ * being routed, and once routing of the message to the outbound messages queues for
+ * target clients and registered listeners are notified.
+ * This class performs no synchronization because it is only used within the context
+ * of a single Thread, and only during the routing of a single message.
+ */
+public class MessageRoutedNotifier
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs a <tt>MessageRoutedNotifier</tt> for the supplied source message.
+ *
+ * @param The source message being routed.
+ */
+ public MessageRoutedNotifier(Message message)
+ {
+ this.message = message;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The source message being routed.
+ */
+ private final Message message;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // messageRoutedListeners
+ //----------------------------------
+
+ private ArrayList listeners;
+
+ /**
+ * Adds a <tt>MessageRoutedListener</tt>.
+ */
+ public void addMessageRoutedListener(MessageRoutedListener listener)
+ {
+ if (listener != null)
+ {
+ // Lazy-init only if necessary.
+ if (listeners == null)
+ listeners = new ArrayList();
+
+ // Add if absent.
+ if (!listeners.contains(listener))
+ listeners.add(listener);
+ }
+ }
+
+ /**
+ * Removes a <tt>MessageRoutedListener</tt>.
+ */
+ public void removeMessageRoutedListener(MessageRoutedListener listener)
+ {
+ if ((listener != null) && (listeners != null))
+ listeners.remove(listener);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Notifies registered listeners of a routed message.
+ *
+ * @param message The message that has been routed.
+ */
+ public void notifyMessageRouted()
+ {
+ if ((listeners != null) && !listeners.isEmpty())
+ {
+ MessageRoutedEvent event = new MessageRoutedEvent(message);
+ int n = listeners.size();
+ for (int i = 0; i < n; ++i)
+ ((MessageRoutedListener)listeners.get(i)).messageRouted(event);
+ }
+ }
+}
[19/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
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;
+}
[39/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/MBeanServerLocatorFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/MBeanServerLocatorFactory.java b/modules/core/src/flex/management/MBeanServerLocatorFactory.java
old mode 100755
new mode 100644
index f69da6d..e465a9b
--- a/modules/core/src/flex/management/MBeanServerLocatorFactory.java
+++ b/modules/core/src/flex/management/MBeanServerLocatorFactory.java
@@ -1,125 +1,125 @@
-/*
- * 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.management;
-
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.util.ClassUtil;
-
-/**
- * Factory to get a <code>MBeanServerLocator</code>.
- *
- * @author shodgson
- */
-public class MBeanServerLocatorFactory
-{
- //--------------------------------------------------------------------------
- //
- // Private Static Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * The MBeanServerLocator impl to use; lazily init'ed on first access.
- */
- private static MBeanServerLocator locator;
-
- //--------------------------------------------------------------------------
- //
- // Public Static Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Returns a <code>MBeanServerLocator</code> that exposes the <code>MBeanServer</code> to register MBeans with.
- *
- * @return The <code>MBeanServerLocator</code> that exposes the <code>MBeanServer</code> to register MBeans with.
- */
- public static synchronized MBeanServerLocator getMBeanServerLocator()
- {
- if (locator == null)
- {
- // Try app-server specific locators.
- // WebSphere provides access to its MBeanServer via a custom admin API.
- instantiateLocator("flex.management.WebSphereMBeanServerLocator", new String[] {"com.ibm.websphere.management.AdminServiceFactory"});
-
- // Sun JRE 1.5 based implementation
- if (locator == null)
- locator = new PlatformMBeanServerLocator();
-
- if (Log.isDebug())
- Log.getLogger(LogCategories.MANAGEMENT_GENERAL).debug("Using MBeanServerLocator: " + locator.getClass().getName());
- }
- return locator;
- }
-
- /**
- * Release static MBeanServerLocator
- * Called on MessageBroker shutdown.
- */
- public static void clear()
- {
- locator = null;
- }
-
- //--------------------------------------------------------------------------
- //
- // Private Static Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Helper method that attempts to load a specific MBeanServerLocator.
- *
- * @param locatorClassName The classname of the desired MBeanServerLocator.
- * @param dependencyClassNames Any additional dependent classnames that the desired locator depends upon
- * that should also be tested for availability.
- */
- private static void instantiateLocator(String locatorClassName, String[] dependencyClassNames)
- {
- try
- {
- if (dependencyClassNames != null)
- {
- for (int i = 0; i < dependencyClassNames.length; i++)
- ClassUtil.createClass(dependencyClassNames[i]);
- }
-
- Class locatorClass = ClassUtil.createClass(locatorClassName);
- locator = (MBeanServerLocator)locatorClass.newInstance();
- }
- catch (Throwable t)
- {
- if (Log.isDebug())
- Log.getLogger(LogCategories.MANAGEMENT_MBEANSERVER).debug("Not using MBeanServerLocator: " + locatorClassName + ". Reason: " + t.getMessage());
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Direct instantiation is not allowed.
- * Use <code>getMBeanServerLocator()</code> to obtain a <code>MBeanServerLocator</code>
- * instance to lookup the proper MBean server to use.
- */
- private MBeanServerLocatorFactory() {}
-
+/*
+ * 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.management;
+
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.util.ClassUtil;
+
+/**
+ * Factory to get a <code>MBeanServerLocator</code>.
+ *
+ * @author shodgson
+ */
+public class MBeanServerLocatorFactory
+{
+ //--------------------------------------------------------------------------
+ //
+ // Private Static Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The MBeanServerLocator impl to use; lazily init'ed on first access.
+ */
+ private static MBeanServerLocator locator;
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Static Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns a <code>MBeanServerLocator</code> that exposes the <code>MBeanServer</code> to register MBeans with.
+ *
+ * @return The <code>MBeanServerLocator</code> that exposes the <code>MBeanServer</code> to register MBeans with.
+ */
+ public static synchronized MBeanServerLocator getMBeanServerLocator()
+ {
+ if (locator == null)
+ {
+ // Try app-server specific locators.
+ // WebSphere provides access to its MBeanServer via a custom admin API.
+ instantiateLocator("flex.management.WebSphereMBeanServerLocator", new String[] {"com.ibm.websphere.management.AdminServiceFactory"});
+
+ // Sun JRE 1.5 based implementation
+ if (locator == null)
+ locator = new PlatformMBeanServerLocator();
+
+ if (Log.isDebug())
+ Log.getLogger(LogCategories.MANAGEMENT_GENERAL).debug("Using MBeanServerLocator: " + locator.getClass().getName());
+ }
+ return locator;
+ }
+
+ /**
+ * Release static MBeanServerLocator
+ * Called on MessageBroker shutdown.
+ */
+ public static void clear()
+ {
+ locator = null;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Static Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Helper method that attempts to load a specific MBeanServerLocator.
+ *
+ * @param locatorClassName The classname of the desired MBeanServerLocator.
+ * @param dependencyClassNames Any additional dependent classnames that the desired locator depends upon
+ * that should also be tested for availability.
+ */
+ private static void instantiateLocator(String locatorClassName, String[] dependencyClassNames)
+ {
+ try
+ {
+ if (dependencyClassNames != null)
+ {
+ for (int i = 0; i < dependencyClassNames.length; i++)
+ ClassUtil.createClass(dependencyClassNames[i]);
+ }
+
+ Class locatorClass = ClassUtil.createClass(locatorClassName);
+ locator = (MBeanServerLocator)locatorClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ if (Log.isDebug())
+ Log.getLogger(LogCategories.MANAGEMENT_MBEANSERVER).debug("Not using MBeanServerLocator: " + locatorClassName + ". Reason: " + t.getMessage());
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Direct instantiation is not allowed.
+ * Use <code>getMBeanServerLocator()</code> to obtain a <code>MBeanServerLocator</code>
+ * instance to lookup the proper MBean server to use.
+ */
+ private MBeanServerLocatorFactory() {}
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/Manageable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/Manageable.java b/modules/core/src/flex/management/Manageable.java
old mode 100755
new mode 100644
index 0da2890..162501d
--- a/modules/core/src/flex/management/Manageable.java
+++ b/modules/core/src/flex/management/Manageable.java
@@ -1,55 +1,55 @@
-/*
- * 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.management;
-
-/**
- * Manageability of a class is enabled by implementing this interface. The
- * specific level of manageability is defined by the relationship between
- * a manageable component and its corresponding control.
- *
- * @author shodgson
- */
-public interface Manageable
-{
- /**
- * Returns <code>true</code> if the component is enabled for management.
- *
- * @return <code>true</code> if the component is enabled for management.
- */
- boolean isManaged();
-
- /**
- * Enables or disables management for the component.
- *
- * @param enableManagement <code>true</code> to enable management, <code>false</code> to disable management.
- */
- void setManaged(boolean enableManagement);
-
- /**
- * Returns the control MBean used to manage the component.
- *
- * @return The control MBean used to manage the component.
- */
- BaseControl getControl();
-
- /**
- * Set the control MBean used to manage the component.
- *
- * @param control The <code>BaseControl</code> MBean used to manage the component.
- */
- void setControl(BaseControl control);
-}
+/*
+ * 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.management;
+
+/**
+ * Manageability of a class is enabled by implementing this interface. The
+ * specific level of manageability is defined by the relationship between
+ * a manageable component and its corresponding control.
+ *
+ * @author shodgson
+ */
+public interface Manageable
+{
+ /**
+ * Returns <code>true</code> if the component is enabled for management.
+ *
+ * @return <code>true</code> if the component is enabled for management.
+ */
+ boolean isManaged();
+
+ /**
+ * Enables or disables management for the component.
+ *
+ * @param enableManagement <code>true</code> to enable management, <code>false</code> to disable management.
+ */
+ void setManaged(boolean enableManagement);
+
+ /**
+ * Returns the control MBean used to manage the component.
+ *
+ * @return The control MBean used to manage the component.
+ */
+ BaseControl getControl();
+
+ /**
+ * Set the control MBean used to manage the component.
+ *
+ * @param control The <code>BaseControl</code> MBean used to manage the component.
+ */
+ void setControl(BaseControl control);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/ManageableComponent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/ManageableComponent.java b/modules/core/src/flex/management/ManageableComponent.java
old mode 100755
new mode 100644
index 71d07de..af27b6c
--- a/modules/core/src/flex/management/ManageableComponent.java
+++ b/modules/core/src/flex/management/ManageableComponent.java
@@ -1,421 +1,421 @@
-/*
- * 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.management;
-
-import java.util.Date;
-
-import flex.messaging.FlexComponent;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.ConfigurationException;
-import flex.messaging.log.Log;
-
-/**
- * An abstract base class that implements the <code>Manageable</code> and <code>FlexComponent</code> interfaces.
- * This is an excellent starting point for a server component that may be instantiated, initialized, started and
- * stopped, as well as exposing an optional management interface via a peer MBean.
- * <p>Support for changing component properties while the component is
- * started should be determined on a per-property basis, and the started property is volatile to ensure consistent
- * reads of the start state of the component across threads. This class performs no synchronization and is not safe for modification by multiple concurrent threads
- * in the absence of external synchronization.
- * </p>
- */
-public abstract class ManageableComponent implements Manageable, FlexComponent
-{
- //--------------------------------------------------------------------------
- //
- // Protected Static Constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * Error code for attempting to change a property after starting.
- */
- protected static final int PROPERTY_CHANGE_AFTER_STARTUP = 11115;
-
- /**
- * Error code to alert the user that a required component property is null.
- */
- protected static final int NULL_COMPONENT_PROPERTY = 11116;
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs a <code>ManageableComponent</code> instance, specifying
- * whether to enable management.
- * Enabling management will trigger the creation of a peer MBean that exposes the
- * management interface for this component.
- *
- * @param enableManagement <code>true</code> to enable management, <code>false</code> to disable
- * management.
- */
- public ManageableComponent(boolean enableManagement)
- {
- setManaged(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // control
- //----------------------------------
-
- /**
- * The peer MBean of the <code>ManageableComponent</code> that exposes a management interface.
- */
- protected BaseControl control;
-
- /**
- * (non-JavaDoc)
- * @see Manageable#getControl()
- */
- public BaseControl getControl()
- {
- return control;
- }
-
- /**
- * (non-JavaDoc)
- * @see Manageable#setControl(BaseControl)
- */
- public void setControl(BaseControl control)
- {
- this.control = control;
- }
-
- //----------------------------------
- // id
- //----------------------------------
-
- /**
- * The internal id value of the <code>ManageableComponent</code>.
- */
- protected String id;
-
- /**
- * Returns the id of the <code>ManageableComponent</code>.
- *
- * @return The id of the <code>ManageableComponent</code>.
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * Sets the id of the <code>ManageableComponent</code>. The id cannot be
- * null and it cannot be changed after startup.
- *
- * @param id The id of the <code>ManageableComponent</code>.
- */
- public void setId(String id)
- {
- if (isStarted())
- {
- blockAssignmentWhileStarted("id");
- }
- if (id == null)
- {
- // Id of a component cannot be null.
- blockNullAssignment("id");
- }
- this.id = id;
- }
-
- //----------------------------------
- // managed
- //----------------------------------
-
- /**
- * The internal managed flag of the <code>ManageableComponent</code>.
- */
- protected volatile boolean managed;
-
- /**
- * (non-JavaDoc)
- * @see Manageable#isManaged()
- */
- public boolean isManaged()
- {
- return managed;
- }
-
- /**
- * Enables or disables management for the component. Management cannot be
- * changed once the component is started and management cannot be
- * <code>true</code> if the parent of the component is not managed.
- *
- * @param enableManagement <code>true</code> to enable management, <code>false</code> to disable management.
- */
- public void setManaged(boolean enableManagement)
- {
- if (isStarted() && control != null)
- {
- blockAssignmentWhileStarted("managed");
- }
- if (enableManagement && parent != null && !parent.isManaged())
- {
- if (Log.isWarn())
- {
- Log.getLogger(getLogCategory()).warn("Component: '" + id + "' cannot be managed" +
- " since its parent is unmanaged.");
- }
- return;
- }
- managed = enableManagement;
- }
-
- //----------------------------------
- // parent
- //----------------------------------
-
- /**
- * The internal reference to the parent component (if any) of the <code>ManageableComponent</code>.
- */
- protected Manageable parent;
-
- /**
- * Returns the parent of the component.
- *
- * @return The parent of the component.
- */
- public Manageable getParent()
- {
- return parent;
- }
-
- /**
- * Sets the parent of the component. The parent cannot be changed
- * after component startup and it cannot be null.
- *
- * @param parent The parent of the component.
- */
- public void setParent(Manageable parent)
- {
- if (isStarted())
- {
- blockAssignmentWhileStarted("parent");
- }
- if (parent == null)
- {
- // Parent of a component cannot be null.
- blockNullAssignment("parent");
- }
- if (!parent.isManaged() && isManaged())
- {
- if (Log.isWarn())
- {
- Log.getLogger(getLogCategory()).warn("Component: '" + id + "' cannot be managed" +
- " since its parent is unmanaged.");
- }
- setManaged(false);
- }
- this.parent = parent;
- }
-
- //----------------------------------
- // started
- //----------------------------------
-
- /**
- * The internal started flag of the <code>ManageableComponent</code>.
- */
- protected volatile boolean started;
-
- /**
- * Returns if the component is started or not.
- *
- * @return <code>true</code> if the component is started.
- */
- public boolean isStarted()
- {
- return started;
- }
-
- /**
- * Sets if the component is started.
- *
- * @param started
- */
- protected void setStarted(boolean started)
- {
- if (this.started != started)
- {
- this.started = started;
- if (started && control != null)
- {
- control.setStartTimestamp(new Date());
- }
- }
- }
-
- //----------------------------------
- // valid
- //----------------------------------
-
- /**
- * The internal valid flag of the <code>ManageableComponent</code>.
- */
- protected boolean valid;
-
- /**
- * Returns if the component is valid.
- *
- * @return <code>true</code> if the component is valid.
- */
- public boolean isValid()
- {
- return valid;
- }
-
- /**
- * Sets if the component is valid.
- *
- * @param valid
- */
- protected void setValid(boolean valid)
- {
- this.valid = valid;
- }
-
- //----------------------------------
- // logCategory
- //----------------------------------
-
- /**
- * Returns the log category of the component. Subclasses must provide an
- * implementation that returns their desired log category.
- *
- * @return The log category of the component.
- */
- protected abstract String getLogCategory();
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Invoked to initialize the <code>ManageableComponent</code>.
- * This base implementation calls <code>setId()</code> passing the provided
- * id and ignores the properties map argument.
- * Subclasses should call <code>super.initialize()</code>.
- *
- * @param id Id of the <code>ManageableComponent</code>.
- * @param properties Properties for the <code>ManageableComponent</code>.
- */
- public void initialize(String id, ConfigMap properties)
- {
- setId(id);
- }
-
- /**
- * Validates and starts the component.
- *
- * Subclasses should call <code>super.start()</code>.
- */
- public void start()
- {
- validate();
- setStarted(true);
- }
-
- /**
- * Invalidates and stops the component.
- *
- * Subclasses should call <code>super.stop()</code>.
- */
- public void stop()
- {
- invalidate();
- setStarted(false);
- }
-
- //--------------------------------------------------------------------------
- //
- // Protocted Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Convenience method that may be used to generate and throw an Exception for an attempt to set the specified property if the
- * component is started.
- *
- * @param propertyName The name of the property being incorrectly assigned; included in the Exception message.
- */
- protected void blockAssignmentWhileStarted(String propertyName)
- {
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(PROPERTY_CHANGE_AFTER_STARTUP, new Object[]{propertyName});
- throw ce;
- }
-
- /**
- * Convenience method that may be used to generate and throw an Exception for an attempt to assign a null value to a property that
- * requires non-null values.
- *
- * @param propertyName The name of the property being incorrectly assigned.
- */
- protected void blockNullAssignment(String propertyName)
- {
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(NULL_COMPONENT_PROPERTY, new Object[]{propertyName});
- throw ce;
- }
-
- /**
- * Invoked from within the <code>stop()</code> method to invalidate the component as part of shutdown.
- * This base implementation sets the valid property to false.
- * Subclasses should call <code>super.invalidate()</code>.
- */
- protected void invalidate()
- {
- setValid(false);
- }
-
- /**
- * Hook method invoked from within the <code>start()</code> method to validate that the component is in a
- * startable state.
- * This base implementation validates the component by ensuring it has an id and a parent and then sets
- * the valid property to true.
- * If the component is not in a valid, startable state an Exception is thrown.
- * Subclasses should call <code>super.validate()</code>.
- */
- protected void validate()
- {
- if (getId() == null)
- {
- // Id of a component cannot be null.
- blockNullAssignment("id");
- }
- if (getParent() == null)
- {
- // Parent of a component cannot be null.
- blockNullAssignment("parent");
- }
- setValid(true);
- }
-
-}
+/*
+ * 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.management;
+
+import java.util.Date;
+
+import flex.messaging.FlexComponent;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.ConfigurationException;
+import flex.messaging.log.Log;
+
+/**
+ * An abstract base class that implements the <code>Manageable</code> and <code>FlexComponent</code> interfaces.
+ * This is an excellent starting point for a server component that may be instantiated, initialized, started and
+ * stopped, as well as exposing an optional management interface via a peer MBean.
+ * <p>Support for changing component properties while the component is
+ * started should be determined on a per-property basis, and the started property is volatile to ensure consistent
+ * reads of the start state of the component across threads. This class performs no synchronization and is not safe for modification by multiple concurrent threads
+ * in the absence of external synchronization.
+ * </p>
+ */
+public abstract class ManageableComponent implements Manageable, FlexComponent
+{
+ //--------------------------------------------------------------------------
+ //
+ // Protected Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Error code for attempting to change a property after starting.
+ */
+ protected static final int PROPERTY_CHANGE_AFTER_STARTUP = 11115;
+
+ /**
+ * Error code to alert the user that a required component property is null.
+ */
+ protected static final int NULL_COMPONENT_PROPERTY = 11116;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs a <code>ManageableComponent</code> instance, specifying
+ * whether to enable management.
+ * Enabling management will trigger the creation of a peer MBean that exposes the
+ * management interface for this component.
+ *
+ * @param enableManagement <code>true</code> to enable management, <code>false</code> to disable
+ * management.
+ */
+ public ManageableComponent(boolean enableManagement)
+ {
+ setManaged(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // control
+ //----------------------------------
+
+ /**
+ * The peer MBean of the <code>ManageableComponent</code> that exposes a management interface.
+ */
+ protected BaseControl control;
+
+ /**
+ * (non-JavaDoc)
+ * @see Manageable#getControl()
+ */
+ public BaseControl getControl()
+ {
+ return control;
+ }
+
+ /**
+ * (non-JavaDoc)
+ * @see Manageable#setControl(BaseControl)
+ */
+ public void setControl(BaseControl control)
+ {
+ this.control = control;
+ }
+
+ //----------------------------------
+ // id
+ //----------------------------------
+
+ /**
+ * The internal id value of the <code>ManageableComponent</code>.
+ */
+ protected String id;
+
+ /**
+ * Returns the id of the <code>ManageableComponent</code>.
+ *
+ * @return The id of the <code>ManageableComponent</code>.
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Sets the id of the <code>ManageableComponent</code>. The id cannot be
+ * null and it cannot be changed after startup.
+ *
+ * @param id The id of the <code>ManageableComponent</code>.
+ */
+ public void setId(String id)
+ {
+ if (isStarted())
+ {
+ blockAssignmentWhileStarted("id");
+ }
+ if (id == null)
+ {
+ // Id of a component cannot be null.
+ blockNullAssignment("id");
+ }
+ this.id = id;
+ }
+
+ //----------------------------------
+ // managed
+ //----------------------------------
+
+ /**
+ * The internal managed flag of the <code>ManageableComponent</code>.
+ */
+ protected volatile boolean managed;
+
+ /**
+ * (non-JavaDoc)
+ * @see Manageable#isManaged()
+ */
+ public boolean isManaged()
+ {
+ return managed;
+ }
+
+ /**
+ * Enables or disables management for the component. Management cannot be
+ * changed once the component is started and management cannot be
+ * <code>true</code> if the parent of the component is not managed.
+ *
+ * @param enableManagement <code>true</code> to enable management, <code>false</code> to disable management.
+ */
+ public void setManaged(boolean enableManagement)
+ {
+ if (isStarted() && control != null)
+ {
+ blockAssignmentWhileStarted("managed");
+ }
+ if (enableManagement && parent != null && !parent.isManaged())
+ {
+ if (Log.isWarn())
+ {
+ Log.getLogger(getLogCategory()).warn("Component: '" + id + "' cannot be managed" +
+ " since its parent is unmanaged.");
+ }
+ return;
+ }
+ managed = enableManagement;
+ }
+
+ //----------------------------------
+ // parent
+ //----------------------------------
+
+ /**
+ * The internal reference to the parent component (if any) of the <code>ManageableComponent</code>.
+ */
+ protected Manageable parent;
+
+ /**
+ * Returns the parent of the component.
+ *
+ * @return The parent of the component.
+ */
+ public Manageable getParent()
+ {
+ return parent;
+ }
+
+ /**
+ * Sets the parent of the component. The parent cannot be changed
+ * after component startup and it cannot be null.
+ *
+ * @param parent The parent of the component.
+ */
+ public void setParent(Manageable parent)
+ {
+ if (isStarted())
+ {
+ blockAssignmentWhileStarted("parent");
+ }
+ if (parent == null)
+ {
+ // Parent of a component cannot be null.
+ blockNullAssignment("parent");
+ }
+ if (!parent.isManaged() && isManaged())
+ {
+ if (Log.isWarn())
+ {
+ Log.getLogger(getLogCategory()).warn("Component: '" + id + "' cannot be managed" +
+ " since its parent is unmanaged.");
+ }
+ setManaged(false);
+ }
+ this.parent = parent;
+ }
+
+ //----------------------------------
+ // started
+ //----------------------------------
+
+ /**
+ * The internal started flag of the <code>ManageableComponent</code>.
+ */
+ protected volatile boolean started;
+
+ /**
+ * Returns if the component is started or not.
+ *
+ * @return <code>true</code> if the component is started.
+ */
+ public boolean isStarted()
+ {
+ return started;
+ }
+
+ /**
+ * Sets if the component is started.
+ *
+ * @param started
+ */
+ protected void setStarted(boolean started)
+ {
+ if (this.started != started)
+ {
+ this.started = started;
+ if (started && control != null)
+ {
+ control.setStartTimestamp(new Date());
+ }
+ }
+ }
+
+ //----------------------------------
+ // valid
+ //----------------------------------
+
+ /**
+ * The internal valid flag of the <code>ManageableComponent</code>.
+ */
+ protected boolean valid;
+
+ /**
+ * Returns if the component is valid.
+ *
+ * @return <code>true</code> if the component is valid.
+ */
+ public boolean isValid()
+ {
+ return valid;
+ }
+
+ /**
+ * Sets if the component is valid.
+ *
+ * @param valid
+ */
+ protected void setValid(boolean valid)
+ {
+ this.valid = valid;
+ }
+
+ //----------------------------------
+ // logCategory
+ //----------------------------------
+
+ /**
+ * Returns the log category of the component. Subclasses must provide an
+ * implementation that returns their desired log category.
+ *
+ * @return The log category of the component.
+ */
+ protected abstract String getLogCategory();
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Invoked to initialize the <code>ManageableComponent</code>.
+ * This base implementation calls <code>setId()</code> passing the provided
+ * id and ignores the properties map argument.
+ * Subclasses should call <code>super.initialize()</code>.
+ *
+ * @param id Id of the <code>ManageableComponent</code>.
+ * @param properties Properties for the <code>ManageableComponent</code>.
+ */
+ public void initialize(String id, ConfigMap properties)
+ {
+ setId(id);
+ }
+
+ /**
+ * Validates and starts the component.
+ *
+ * Subclasses should call <code>super.start()</code>.
+ */
+ public void start()
+ {
+ validate();
+ setStarted(true);
+ }
+
+ /**
+ * Invalidates and stops the component.
+ *
+ * Subclasses should call <code>super.stop()</code>.
+ */
+ public void stop()
+ {
+ invalidate();
+ setStarted(false);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protocted Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Convenience method that may be used to generate and throw an Exception for an attempt to set the specified property if the
+ * component is started.
+ *
+ * @param propertyName The name of the property being incorrectly assigned; included in the Exception message.
+ */
+ protected void blockAssignmentWhileStarted(String propertyName)
+ {
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(PROPERTY_CHANGE_AFTER_STARTUP, new Object[]{propertyName});
+ throw ce;
+ }
+
+ /**
+ * Convenience method that may be used to generate and throw an Exception for an attempt to assign a null value to a property that
+ * requires non-null values.
+ *
+ * @param propertyName The name of the property being incorrectly assigned.
+ */
+ protected void blockNullAssignment(String propertyName)
+ {
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(NULL_COMPONENT_PROPERTY, new Object[]{propertyName});
+ throw ce;
+ }
+
+ /**
+ * Invoked from within the <code>stop()</code> method to invalidate the component as part of shutdown.
+ * This base implementation sets the valid property to false.
+ * Subclasses should call <code>super.invalidate()</code>.
+ */
+ protected void invalidate()
+ {
+ setValid(false);
+ }
+
+ /**
+ * Hook method invoked from within the <code>start()</code> method to validate that the component is in a
+ * startable state.
+ * This base implementation validates the component by ensuring it has an id and a parent and then sets
+ * the valid property to true.
+ * If the component is not in a valid, startable state an Exception is thrown.
+ * Subclasses should call <code>super.validate()</code>.
+ */
+ protected void validate()
+ {
+ if (getId() == null)
+ {
+ // Id of a component cannot be null.
+ blockNullAssignment("id");
+ }
+ if (getParent() == null)
+ {
+ // Parent of a component cannot be null.
+ blockNullAssignment("parent");
+ }
+ setValid(true);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/ManagementException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/ManagementException.java b/modules/core/src/flex/management/ManagementException.java
old mode 100755
new mode 100644
index 93157ed..5d4e730
--- a/modules/core/src/flex/management/ManagementException.java
+++ b/modules/core/src/flex/management/ManagementException.java
@@ -1,32 +1,32 @@
-/*
- * 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.management;
-
-import flex.messaging.MessageException;
-
-/**
- * This exception type is thrown when errors occur generating
- * <code>ObjectName</code>s for MBeans, or when registering them or
- * accessing them via the MBean server.
- *
- * @author shodgson
- */
-public class ManagementException extends MessageException
-{
- // Inherits all functionality from MessageException.
- static final long serialVersionUID = 1296149563830613956L;
-}
+/*
+ * 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.management;
+
+import flex.messaging.MessageException;
+
+/**
+ * This exception type is thrown when errors occur generating
+ * <code>ObjectName</code>s for MBeans, or when registering them or
+ * accessing them via the MBean server.
+ *
+ * @author shodgson
+ */
+public class ManagementException extends MessageException
+{
+ // Inherits all functionality from MessageException.
+ static final long serialVersionUID = 1296149563830613956L;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/PlatformMBeanServerLocator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/PlatformMBeanServerLocator.java b/modules/core/src/flex/management/PlatformMBeanServerLocator.java
old mode 100755
new mode 100644
index ae7f528..073b7da
--- a/modules/core/src/flex/management/PlatformMBeanServerLocator.java
+++ b/modules/core/src/flex/management/PlatformMBeanServerLocator.java
@@ -1,39 +1,39 @@
-/*
- * 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.management;
-
-import java.lang.management.ManagementFactory;
-import javax.management.MBeanServer;
-
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-
-/**
- * The platform implementation of an MBeanServerLocator for Java 1.5+.
- * This locator exposes the platform MBeanServer.
- *
- * @author shodgson
- */
-public class PlatformMBeanServerLocator implements MBeanServerLocator
-{
- /** {@inheritDoc} */
- public synchronized MBeanServer getMBeanServer()
- {
- return ManagementFactory.getPlatformMBeanServer();
- }
-
+/*
+ * 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.management;
+
+import java.lang.management.ManagementFactory;
+import javax.management.MBeanServer;
+
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+
+/**
+ * The platform implementation of an MBeanServerLocator for Java 1.5+.
+ * This locator exposes the platform MBeanServer.
+ *
+ * @author shodgson
+ */
+public class PlatformMBeanServerLocator implements MBeanServerLocator
+{
+ /** {@inheritDoc} */
+ public synchronized MBeanServer getMBeanServer()
+ {
+ return ManagementFactory.getPlatformMBeanServer();
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/jmx/Attribute.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/jmx/Attribute.java b/modules/core/src/flex/management/jmx/Attribute.java
old mode 100755
new mode 100644
index f4cce01..d2d9df6
--- a/modules/core/src/flex/management/jmx/Attribute.java
+++ b/modules/core/src/flex/management/jmx/Attribute.java
@@ -1,63 +1,63 @@
-/*
- * 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.management.jmx;
-
-/**
- * Remotable <code>Attribute</code> class that complies with Flash serialization requirements.
- *
- * @author shodgson
- */
-public class Attribute
-{
- /**
- * The name of the attribute.
- */
- public String name;
-
- /**
- * The value of the attribute.
- */
- public Object value;
-
- /**
- * Constructs an empty <code>Attribute</code> instance.
- *
- */
- public Attribute()
- {}
-
- /**
- * Constructs an <code>Attribute</code> instance based upon a <code>javax.management.Attribute</code> instance.
- *
- * @param attribute The JMX <code>Attribute</code> to base this instance on.
- */
- public Attribute(javax.management.Attribute attribute)
- {
- name = attribute.getName();
- value = attribute.getValue();
- }
-
- /**
- * Utility method to convert this <code>Attribute</code> instance to a <code>javax.management.Attribute</code> instance.
- *
- * @return A JMX <code>Attribute</code> based upon this instance.
- */
- public javax.management.Attribute toAttribute()
- {
- return new javax.management.Attribute(name, value);
- }
-}
+/*
+ * 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.management.jmx;
+
+/**
+ * Remotable <code>Attribute</code> class that complies with Flash serialization requirements.
+ *
+ * @author shodgson
+ */
+public class Attribute
+{
+ /**
+ * The name of the attribute.
+ */
+ public String name;
+
+ /**
+ * The value of the attribute.
+ */
+ public Object value;
+
+ /**
+ * Constructs an empty <code>Attribute</code> instance.
+ *
+ */
+ public Attribute()
+ {}
+
+ /**
+ * Constructs an <code>Attribute</code> instance based upon a <code>javax.management.Attribute</code> instance.
+ *
+ * @param attribute The JMX <code>Attribute</code> to base this instance on.
+ */
+ public Attribute(javax.management.Attribute attribute)
+ {
+ name = attribute.getName();
+ value = attribute.getValue();
+ }
+
+ /**
+ * Utility method to convert this <code>Attribute</code> instance to a <code>javax.management.Attribute</code> instance.
+ *
+ * @return A JMX <code>Attribute</code> based upon this instance.
+ */
+ public javax.management.Attribute toAttribute()
+ {
+ return new javax.management.Attribute(name, value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/jmx/MBeanAttributeInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/jmx/MBeanAttributeInfo.java b/modules/core/src/flex/management/jmx/MBeanAttributeInfo.java
old mode 100755
new mode 100644
index a60937e..a87425d
--- a/modules/core/src/flex/management/jmx/MBeanAttributeInfo.java
+++ b/modules/core/src/flex/management/jmx/MBeanAttributeInfo.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 flex.management.jmx;
-
-/**
- * Remotable <code>MBeanAttributeInfo</code> class that complies with Flash serialization requirements.
- * The <code>isIs</code> property is not named <code>is</code> because <code>is</code> is
- * an ActionScript keyword.
- *
- * @author shodgson
- */
-public class MBeanAttributeInfo
-{
- /**
- * The name of the attribute.
- */
- public String name;
-
- /**
- * The class name of the attribute.
- */
- public String type;
-
- /**
- * The description of the attribute.
- */
- public String description;
-
- /**
- * Whether the attribute can be read.
- */
- public boolean readable;
-
- /**
- * Whether the attribute can be written.
- */
- public boolean writable;
-
- /**
- * Whether the attribute has an "is" getter.
- */
- public boolean isIs;
-
- /**
- * Constructs an empty <code>MBeanAttributeInfo</code> instance.
- */
- public MBeanAttributeInfo()
- {}
-
- /**
- * Constructs a <code>MBeanAttributeInfo</code> instance based upon a
- * <code>javax.management.MBeanAttributeInfo</code> instance.
- *
- * @param mbeanAttributeInfo The JMX <code>MBeanAttributeInfo</code> instance to base this instance on.
- */
- public MBeanAttributeInfo(javax.management.MBeanAttributeInfo mbeanAttributeInfo)
- {
- name = mbeanAttributeInfo.getName();
- type = mbeanAttributeInfo.getType();
- description = mbeanAttributeInfo.getDescription();
- readable = mbeanAttributeInfo.isReadable();
- writable = mbeanAttributeInfo.isWritable();
- isIs = mbeanAttributeInfo.isIs();
- }
-
- /**
- * Utility method to convert this <code>MBeanAttributeInfo</code> to a
- * <code>javax.management.MBeanAttributeInfo</code> instance.
- *
- * @return A JMX <code>MBeanAttributeInfo</code> based upon this instance.
- */
- public javax.management.MBeanAttributeInfo toMBeanAttributeInfo()
- {
- return new javax.management.MBeanAttributeInfo(name,
- type,
- description,
- readable,
- writable,
- isIs);
- }
-
-}
+/*
+ * 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.management.jmx;
+
+/**
+ * Remotable <code>MBeanAttributeInfo</code> class that complies with Flash serialization requirements.
+ * The <code>isIs</code> property is not named <code>is</code> because <code>is</code> is
+ * an ActionScript keyword.
+ *
+ * @author shodgson
+ */
+public class MBeanAttributeInfo
+{
+ /**
+ * The name of the attribute.
+ */
+ public String name;
+
+ /**
+ * The class name of the attribute.
+ */
+ public String type;
+
+ /**
+ * The description of the attribute.
+ */
+ public String description;
+
+ /**
+ * Whether the attribute can be read.
+ */
+ public boolean readable;
+
+ /**
+ * Whether the attribute can be written.
+ */
+ public boolean writable;
+
+ /**
+ * Whether the attribute has an "is" getter.
+ */
+ public boolean isIs;
+
+ /**
+ * Constructs an empty <code>MBeanAttributeInfo</code> instance.
+ */
+ public MBeanAttributeInfo()
+ {}
+
+ /**
+ * Constructs a <code>MBeanAttributeInfo</code> instance based upon a
+ * <code>javax.management.MBeanAttributeInfo</code> instance.
+ *
+ * @param mbeanAttributeInfo The JMX <code>MBeanAttributeInfo</code> instance to base this instance on.
+ */
+ public MBeanAttributeInfo(javax.management.MBeanAttributeInfo mbeanAttributeInfo)
+ {
+ name = mbeanAttributeInfo.getName();
+ type = mbeanAttributeInfo.getType();
+ description = mbeanAttributeInfo.getDescription();
+ readable = mbeanAttributeInfo.isReadable();
+ writable = mbeanAttributeInfo.isWritable();
+ isIs = mbeanAttributeInfo.isIs();
+ }
+
+ /**
+ * Utility method to convert this <code>MBeanAttributeInfo</code> to a
+ * <code>javax.management.MBeanAttributeInfo</code> instance.
+ *
+ * @return A JMX <code>MBeanAttributeInfo</code> based upon this instance.
+ */
+ public javax.management.MBeanAttributeInfo toMBeanAttributeInfo()
+ {
+ return new javax.management.MBeanAttributeInfo(name,
+ type,
+ description,
+ readable,
+ writable,
+ isIs);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/jmx/MBeanConstructorInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/jmx/MBeanConstructorInfo.java b/modules/core/src/flex/management/jmx/MBeanConstructorInfo.java
old mode 100755
new mode 100644
index 105a25f..06e33d6
--- a/modules/core/src/flex/management/jmx/MBeanConstructorInfo.java
+++ b/modules/core/src/flex/management/jmx/MBeanConstructorInfo.java
@@ -1,106 +1,106 @@
-/*
- * 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.management.jmx;
-
-/**
- * Remotable <code>MBeanConstructorInfo</code> class that complies with Flash serialization requirements.
- *
- * @author shodgson
- */
-public class MBeanConstructorInfo
-{
- /**
- * The name of the constructor.
- */
- public String name;
-
- /**
- * The description of the constructor.
- */
- public String description;
-
- /**
- * The constructor's parameter signature.
- */
- public MBeanParameterInfo[] signature;
-
- /**
- * Constructs an empty <code>MBeanConstructorInfo</code> instance.
- *
- */
- public MBeanConstructorInfo()
- {}
-
- /**
- * Constructs a <code>MBeanConstructorInfo</code> instance based upon a
- * <code>javax.management.MBeanConstructorInfo</code> instance.
- *
- * @param mbeanConstructorInfo The <code>javax.management.MBeanConstructorInfo</code> to base this instance on.
- */
- public MBeanConstructorInfo(javax.management.MBeanConstructorInfo mbeanConstructorInfo)
- {
- name = mbeanConstructorInfo.getName();
- description = mbeanConstructorInfo.getDescription();
- signature = convertSignature(mbeanConstructorInfo.getSignature());
- }
-
- /**
- * Utility method to convert this <code>MBeanConstructorInfo</code> instance to a
- * <code>javax.management.MBeanConstructorInfo</code> instance.
- *
- * @return A JMX <code>MBeanConstructorInfo</code> based upon this instance.
- */
- public javax.management.MBeanConstructorInfo toMBeanConstructorInfo()
- {
- return new javax.management.MBeanConstructorInfo(name,
- description,
- convertSignature(signature));
- }
-
- /**
- * Utility method to convert the JMX constructor signature to our Flash friendly param type.
- *
- * @param source The JMX constructor signature params.
- * @return Flash friendly signature params.
- */
- private MBeanParameterInfo[] convertSignature(javax.management.MBeanParameterInfo[] source)
- {
- MBeanParameterInfo[] signature = new MBeanParameterInfo[source.length];
- for (int i = 0; i < source.length; i++)
- {
- signature[i] = new MBeanParameterInfo(source[i]);
- }
- return signature;
- }
-
- /**
- * Utility method to convert a Flash friendly construtor param signature to the JMX params.
- *
- * @param source The Flash friendly signature params.
- * @return The JMX constructor signature params.
- */
- private javax.management.MBeanParameterInfo[] convertSignature(MBeanParameterInfo[] source)
- {
- javax.management.MBeanParameterInfo[] signature = new javax.management.MBeanParameterInfo[source.length];
- for (int i = 0; i < source.length; i++)
- {
- signature[i] = source[i].toMBeanParameterInfo();
- }
- return signature;
- }
-
-}
+/*
+ * 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.management.jmx;
+
+/**
+ * Remotable <code>MBeanConstructorInfo</code> class that complies with Flash serialization requirements.
+ *
+ * @author shodgson
+ */
+public class MBeanConstructorInfo
+{
+ /**
+ * The name of the constructor.
+ */
+ public String name;
+
+ /**
+ * The description of the constructor.
+ */
+ public String description;
+
+ /**
+ * The constructor's parameter signature.
+ */
+ public MBeanParameterInfo[] signature;
+
+ /**
+ * Constructs an empty <code>MBeanConstructorInfo</code> instance.
+ *
+ */
+ public MBeanConstructorInfo()
+ {}
+
+ /**
+ * Constructs a <code>MBeanConstructorInfo</code> instance based upon a
+ * <code>javax.management.MBeanConstructorInfo</code> instance.
+ *
+ * @param mbeanConstructorInfo The <code>javax.management.MBeanConstructorInfo</code> to base this instance on.
+ */
+ public MBeanConstructorInfo(javax.management.MBeanConstructorInfo mbeanConstructorInfo)
+ {
+ name = mbeanConstructorInfo.getName();
+ description = mbeanConstructorInfo.getDescription();
+ signature = convertSignature(mbeanConstructorInfo.getSignature());
+ }
+
+ /**
+ * Utility method to convert this <code>MBeanConstructorInfo</code> instance to a
+ * <code>javax.management.MBeanConstructorInfo</code> instance.
+ *
+ * @return A JMX <code>MBeanConstructorInfo</code> based upon this instance.
+ */
+ public javax.management.MBeanConstructorInfo toMBeanConstructorInfo()
+ {
+ return new javax.management.MBeanConstructorInfo(name,
+ description,
+ convertSignature(signature));
+ }
+
+ /**
+ * Utility method to convert the JMX constructor signature to our Flash friendly param type.
+ *
+ * @param source The JMX constructor signature params.
+ * @return Flash friendly signature params.
+ */
+ private MBeanParameterInfo[] convertSignature(javax.management.MBeanParameterInfo[] source)
+ {
+ MBeanParameterInfo[] signature = new MBeanParameterInfo[source.length];
+ for (int i = 0; i < source.length; i++)
+ {
+ signature[i] = new MBeanParameterInfo(source[i]);
+ }
+ return signature;
+ }
+
+ /**
+ * Utility method to convert a Flash friendly construtor param signature to the JMX params.
+ *
+ * @param source The Flash friendly signature params.
+ * @return The JMX constructor signature params.
+ */
+ private javax.management.MBeanParameterInfo[] convertSignature(MBeanParameterInfo[] source)
+ {
+ javax.management.MBeanParameterInfo[] signature = new javax.management.MBeanParameterInfo[source.length];
+ for (int i = 0; i < source.length; i++)
+ {
+ signature[i] = source[i].toMBeanParameterInfo();
+ }
+ return signature;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/jmx/MBeanInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/jmx/MBeanInfo.java b/modules/core/src/flex/management/jmx/MBeanInfo.java
old mode 100755
new mode 100644
index bc3eb44..8c7befd
--- a/modules/core/src/flex/management/jmx/MBeanInfo.java
+++ b/modules/core/src/flex/management/jmx/MBeanInfo.java
@@ -1,186 +1,186 @@
-/*
- * 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.management.jmx;
-
-/**
- * Remotable MBeanInfo class that complies with Flash serialization requirements.
- * MBean Notifications are not currently supported.
- *
- * @author shodgson
- */
-public class MBeanInfo
-{
- /**
- * The Java class name for the MBean object.
- */
- public String className;
-
- /**
- * The description of the MBean.
- */
- public String description;
-
- /**
- * The attributes exposed for management.
- */
- public MBeanAttributeInfo[] attributes;
-
- /**
- * The public constructors for the MBean.
- */
- public MBeanConstructorInfo[] constructors;
-
- /**
- * The operations exposed by the MBean.
- */
- public MBeanOperationInfo[] operations;
-
- /**
- * Constructs an empty <code>MBeanInfo</code> instance.
- */
- public MBeanInfo()
- {}
-
- /**
- * Constructs a <code>MBeanInfo</code> instance based upon a
- * <code>javax.management.MBeanInfo</code> instance.
- *
- * @param mbeanInfo The JMX <code>MBeanInfo</code> instance to base this instance on.
- */
- public MBeanInfo(javax.management.MBeanInfo mbeanInfo)
- {
- className = mbeanInfo.getClassName();
- description = mbeanInfo.getDescription();
- attributes = convertAttributes(mbeanInfo.getAttributes());
- constructors = convertConstructors(mbeanInfo.getConstructors());
- operations = convertOperations(mbeanInfo.getOperations());
- }
-
- /**
- * Utility method to convert this <code>MBeanInfo</code> to a
- * <code>javax.management.MBeanInfo</code> instance.
- *
- * @return A JMX <code>MBeanInfo</code> based upon this instance.
- */
- public javax.management.MBeanInfo toMBeanInfo()
- {
- return new javax.management.MBeanInfo(className,
- description,
- convertAttributes(attributes),
- convertConstructors(constructors),
- convertOperations(operations),
- null);
- }
-
- /**
- * Utility method to convert JMX attribute info instances to Flash friendly instances.
- *
- * @param source JMX attribute info instances.
- * @return Flash friendly attribute info instances.
- */
- private MBeanAttributeInfo[] convertAttributes(javax.management.MBeanAttributeInfo[] source)
- {
- MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[source.length];
- for (int i = 0; i < source.length; i++)
- {
- attributes[i] = new MBeanAttributeInfo(source[i]);
- }
- return attributes;
- }
-
- /**
- * Utility method to convert Flash friendly attribute info instances to JMX attribute info instances.
- *
- * @param source Flash friendly attribute info instances.
- * @return JMX attribute info instances.
- */
- private javax.management.MBeanAttributeInfo[] convertAttributes(MBeanAttributeInfo[] source)
- {
- javax.management.MBeanAttributeInfo[] attributes = new javax.management.MBeanAttributeInfo[source.length];
- for (int i = 0; i < source.length; i++)
- {
- attributes[i] = source[i].toMBeanAttributeInfo();
- }
- return attributes;
- }
-
- /**
- * Utility method to convert JMX constructor info instances to Flash friendly constructor info
- * instances.
- *
- * @param source JMX constructor info instances.
- * @return Flash friendly constructor info instances.
- */
- private MBeanConstructorInfo[] convertConstructors(javax.management.MBeanConstructorInfo[] source)
- {
- MBeanConstructorInfo[] constructors = new MBeanConstructorInfo[source.length];
- for (int i = 0; i < source.length; i++)
- {
- constructors[i] = new MBeanConstructorInfo(source[i]);
- }
- return constructors;
- }
-
- /**
- * Utility method to convert Flash friendly constructor info instances to JMX constructor info instances.
- *
- * @param source Flash friendly constructor info instances.
- * @return JMX constructor info instances.
- */
- private javax.management.MBeanConstructorInfo[] convertConstructors(MBeanConstructorInfo[] source)
- {
- javax.management.MBeanConstructorInfo[] constructors = new javax.management.MBeanConstructorInfo[source.length];
- for (int i = 0; i < source.length; i++)
- {
- constructors[i] = source[i].toMBeanConstructorInfo();
- }
- return constructors;
- }
-
- /**
- * Utility method to convert JMX operation info instances to Flash friendly operation info instances.
- *
- * @param source JMX opereration info instances.
- * @return Flash friendly operation info instances.
- */
- private MBeanOperationInfo[] convertOperations(javax.management.MBeanOperationInfo[] source)
- {
- MBeanOperationInfo[] operations = new MBeanOperationInfo[source.length];
- for (int i = 0; i < source.length; i++)
- {
- operations[i] = new MBeanOperationInfo(source[i]);
- }
- return operations;
- }
-
- /**
- * Utility method to convert Flash friendly operation info instances to JMX operation info instances.
- *
- * @param source Flash friendly operation info instances.
- * @return JMX operation info instances.
- */
- private javax.management.MBeanOperationInfo[] convertOperations(MBeanOperationInfo[] source)
- {
- javax.management.MBeanOperationInfo[] operations = new javax.management.MBeanOperationInfo[source.length];
- for (int i = 0; i < source.length; i++)
- {
- operations[i] = source[i].toMBeanOperationInfo();
- }
- return operations;
- }
-
-}
+/*
+ * 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.management.jmx;
+
+/**
+ * Remotable MBeanInfo class that complies with Flash serialization requirements.
+ * MBean Notifications are not currently supported.
+ *
+ * @author shodgson
+ */
+public class MBeanInfo
+{
+ /**
+ * The Java class name for the MBean object.
+ */
+ public String className;
+
+ /**
+ * The description of the MBean.
+ */
+ public String description;
+
+ /**
+ * The attributes exposed for management.
+ */
+ public MBeanAttributeInfo[] attributes;
+
+ /**
+ * The public constructors for the MBean.
+ */
+ public MBeanConstructorInfo[] constructors;
+
+ /**
+ * The operations exposed by the MBean.
+ */
+ public MBeanOperationInfo[] operations;
+
+ /**
+ * Constructs an empty <code>MBeanInfo</code> instance.
+ */
+ public MBeanInfo()
+ {}
+
+ /**
+ * Constructs a <code>MBeanInfo</code> instance based upon a
+ * <code>javax.management.MBeanInfo</code> instance.
+ *
+ * @param mbeanInfo The JMX <code>MBeanInfo</code> instance to base this instance on.
+ */
+ public MBeanInfo(javax.management.MBeanInfo mbeanInfo)
+ {
+ className = mbeanInfo.getClassName();
+ description = mbeanInfo.getDescription();
+ attributes = convertAttributes(mbeanInfo.getAttributes());
+ constructors = convertConstructors(mbeanInfo.getConstructors());
+ operations = convertOperations(mbeanInfo.getOperations());
+ }
+
+ /**
+ * Utility method to convert this <code>MBeanInfo</code> to a
+ * <code>javax.management.MBeanInfo</code> instance.
+ *
+ * @return A JMX <code>MBeanInfo</code> based upon this instance.
+ */
+ public javax.management.MBeanInfo toMBeanInfo()
+ {
+ return new javax.management.MBeanInfo(className,
+ description,
+ convertAttributes(attributes),
+ convertConstructors(constructors),
+ convertOperations(operations),
+ null);
+ }
+
+ /**
+ * Utility method to convert JMX attribute info instances to Flash friendly instances.
+ *
+ * @param source JMX attribute info instances.
+ * @return Flash friendly attribute info instances.
+ */
+ private MBeanAttributeInfo[] convertAttributes(javax.management.MBeanAttributeInfo[] source)
+ {
+ MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[source.length];
+ for (int i = 0; i < source.length; i++)
+ {
+ attributes[i] = new MBeanAttributeInfo(source[i]);
+ }
+ return attributes;
+ }
+
+ /**
+ * Utility method to convert Flash friendly attribute info instances to JMX attribute info instances.
+ *
+ * @param source Flash friendly attribute info instances.
+ * @return JMX attribute info instances.
+ */
+ private javax.management.MBeanAttributeInfo[] convertAttributes(MBeanAttributeInfo[] source)
+ {
+ javax.management.MBeanAttributeInfo[] attributes = new javax.management.MBeanAttributeInfo[source.length];
+ for (int i = 0; i < source.length; i++)
+ {
+ attributes[i] = source[i].toMBeanAttributeInfo();
+ }
+ return attributes;
+ }
+
+ /**
+ * Utility method to convert JMX constructor info instances to Flash friendly constructor info
+ * instances.
+ *
+ * @param source JMX constructor info instances.
+ * @return Flash friendly constructor info instances.
+ */
+ private MBeanConstructorInfo[] convertConstructors(javax.management.MBeanConstructorInfo[] source)
+ {
+ MBeanConstructorInfo[] constructors = new MBeanConstructorInfo[source.length];
+ for (int i = 0; i < source.length; i++)
+ {
+ constructors[i] = new MBeanConstructorInfo(source[i]);
+ }
+ return constructors;
+ }
+
+ /**
+ * Utility method to convert Flash friendly constructor info instances to JMX constructor info instances.
+ *
+ * @param source Flash friendly constructor info instances.
+ * @return JMX constructor info instances.
+ */
+ private javax.management.MBeanConstructorInfo[] convertConstructors(MBeanConstructorInfo[] source)
+ {
+ javax.management.MBeanConstructorInfo[] constructors = new javax.management.MBeanConstructorInfo[source.length];
+ for (int i = 0; i < source.length; i++)
+ {
+ constructors[i] = source[i].toMBeanConstructorInfo();
+ }
+ return constructors;
+ }
+
+ /**
+ * Utility method to convert JMX operation info instances to Flash friendly operation info instances.
+ *
+ * @param source JMX opereration info instances.
+ * @return Flash friendly operation info instances.
+ */
+ private MBeanOperationInfo[] convertOperations(javax.management.MBeanOperationInfo[] source)
+ {
+ MBeanOperationInfo[] operations = new MBeanOperationInfo[source.length];
+ for (int i = 0; i < source.length; i++)
+ {
+ operations[i] = new MBeanOperationInfo(source[i]);
+ }
+ return operations;
+ }
+
+ /**
+ * Utility method to convert Flash friendly operation info instances to JMX operation info instances.
+ *
+ * @param source Flash friendly operation info instances.
+ * @return JMX operation info instances.
+ */
+ private javax.management.MBeanOperationInfo[] convertOperations(MBeanOperationInfo[] source)
+ {
+ javax.management.MBeanOperationInfo[] operations = new javax.management.MBeanOperationInfo[source.length];
+ for (int i = 0; i < source.length; i++)
+ {
+ operations[i] = source[i].toMBeanOperationInfo();
+ }
+ return operations;
+ }
+
+}
[29/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexSessionConnectivityEvent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexSessionConnectivityEvent.java b/modules/core/src/flex/messaging/FlexSessionConnectivityEvent.java
old mode 100755
new mode 100644
index 523b61d..cb4f84d
--- a/modules/core/src/flex/messaging/FlexSessionConnectivityEvent.java
+++ b/modules/core/src/flex/messaging/FlexSessionConnectivityEvent.java
@@ -1,50 +1,50 @@
-/*
- * 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;
-
-import java.util.EventObject;
-
-/**
- * An event dispatched when the connection state for a session changes.
- */
-public class FlexSessionConnectivityEvent extends EventObject
-{
- /**
- * @exclude
- */
- private static final long serialVersionUID = 8622680412552475829L;
-
- /**
- * Constructs a new <tt>FlexSessionConnectivityEvent</tt> using the supplied source <tt>ConnectionAwareSession</tt>.
- *
- * @param session The session whose connection state has changed.
- */
- public FlexSessionConnectivityEvent(ConnectionAwareSession session)
- {
- super(session);
- }
-
- /**
- * Returns the session whose connection state has changed.
- *
- * @return The session whose connection state has changed.
- */
- public ConnectionAwareSession getFlexSession()
- {
- return (ConnectionAwareSession)getSource();
- }
-}
+/*
+ * 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;
+
+import java.util.EventObject;
+
+/**
+ * An event dispatched when the connection state for a session changes.
+ */
+public class FlexSessionConnectivityEvent extends EventObject
+{
+ /**
+ * @exclude
+ */
+ private static final long serialVersionUID = 8622680412552475829L;
+
+ /**
+ * Constructs a new <tt>FlexSessionConnectivityEvent</tt> using the supplied source <tt>ConnectionAwareSession</tt>.
+ *
+ * @param session The session whose connection state has changed.
+ */
+ public FlexSessionConnectivityEvent(ConnectionAwareSession session)
+ {
+ super(session);
+ }
+
+ /**
+ * Returns the session whose connection state has changed.
+ *
+ * @return The session whose connection state has changed.
+ */
+ public ConnectionAwareSession getFlexSession()
+ {
+ return (ConnectionAwareSession)getSource();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexSessionConnectivityListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexSessionConnectivityListener.java b/modules/core/src/flex/messaging/FlexSessionConnectivityListener.java
old mode 100755
new mode 100644
index a5b0be6..2fc1137
--- a/modules/core/src/flex/messaging/FlexSessionConnectivityListener.java
+++ b/modules/core/src/flex/messaging/FlexSessionConnectivityListener.java
@@ -1,38 +1,38 @@
-/*
- * 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;
-
-/**
- * The listener interface for receiving FlexSession connectivity events.
- */
-
-public interface FlexSessionConnectivityListener
-{
- /**
- * Invoked when the session has connected to the remote host.
- *
- * @param event The <tt>FlexSessionConnectivityEvent</tt> for the connect event.
- */
- void sessionConnected(FlexSessionConnectivityEvent event);
-
- /**
- * Invoked when the session has disconnected from or lost connectivity to the remote host.
- *
- * @param event The <tt>FlexSessionConnectivityEvent</tt> for the disconnect event.
- */
- void sessionDisconnected(FlexSessionConnectivityEvent event);
-}
+/*
+ * 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;
+
+/**
+ * The listener interface for receiving FlexSession connectivity events.
+ */
+
+public interface FlexSessionConnectivityListener
+{
+ /**
+ * Invoked when the session has connected to the remote host.
+ *
+ * @param event The <tt>FlexSessionConnectivityEvent</tt> for the connect event.
+ */
+ void sessionConnected(FlexSessionConnectivityEvent event);
+
+ /**
+ * Invoked when the session has disconnected from or lost connectivity to the remote host.
+ *
+ * @param event The <tt>FlexSessionConnectivityEvent</tt> for the disconnect event.
+ */
+ void sessionDisconnected(FlexSessionConnectivityEvent event);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexSessionListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexSessionListener.java b/modules/core/src/flex/messaging/FlexSessionListener.java
old mode 100755
new mode 100644
index e27cbba..b9058d5
--- a/modules/core/src/flex/messaging/FlexSessionListener.java
+++ b/modules/core/src/flex/messaging/FlexSessionListener.java
@@ -1,40 +1,40 @@
-/*
- * 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;
-
-/**
- * Interface to be notified when a FlexSession is created or destroyed. Implementations of this interface
- * may add themselves as session created listeners statically via <code>FlexSession.addSessionCreatedListener()</code>.
- * To listen for FlexSession destruction, the implementation class instance must add itself as a listener to
- * a specific FlexSession instance via the <code>addSessionDestroyedListener()</code> method.
- */
-public interface FlexSessionListener
-{
- /**
- * Notification that a FlexSession was created.
- *
- * @param session The FlexSession that was created.
- */
- void sessionCreated(FlexSession session);
-
- /**
- * Notification that a FlexSession is about to be destroyed.
- *
- * @param session The FlexSession that will be destroyed.
- */
- void sessionDestroyed(FlexSession session);
-}
+/*
+ * 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;
+
+/**
+ * Interface to be notified when a FlexSession is created or destroyed. Implementations of this interface
+ * may add themselves as session created listeners statically via <code>FlexSession.addSessionCreatedListener()</code>.
+ * To listen for FlexSession destruction, the implementation class instance must add itself as a listener to
+ * a specific FlexSession instance via the <code>addSessionDestroyedListener()</code> method.
+ */
+public interface FlexSessionListener
+{
+ /**
+ * Notification that a FlexSession was created.
+ *
+ * @param session The FlexSession that was created.
+ */
+ void sessionCreated(FlexSession session);
+
+ /**
+ * Notification that a FlexSession is about to be destroyed.
+ *
+ * @param session The FlexSession that will be destroyed.
+ */
+ void sessionDestroyed(FlexSession session);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexSessionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexSessionManager.java b/modules/core/src/flex/messaging/FlexSessionManager.java
old mode 100755
new mode 100644
index 22a776d..d7f246f
--- a/modules/core/src/flex/messaging/FlexSessionManager.java
+++ b/modules/core/src/flex/messaging/FlexSessionManager.java
@@ -1,299 +1,299 @@
-/*
- * 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;
-
-import flex.management.ManageableComponent;
-import flex.messaging.log.LogCategories;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * @exclude
- * Manages FlexSession instances for a MessageBroker.
- */
-public class FlexSessionManager extends ManageableComponent
-{
- public static final String TYPE = "FlexSessionManager";
-
- private static final long MILLIS_IN_HOUR = 3600000;
-
- //--------------------------------------------------------------------------
- //
- // Constructors
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * Constructs a <tt>FlexSessionManager</tt> for the passed <tt>MessageBroker</tt>.
- *
- * @param broker The root <tt>MessageBroker</tt> using this <tt>FlexSessionManager</tt>.
- */
- public FlexSessionManager(MessageBroker broker)
- {
- this(false, broker);
- }
-
- /**
- * @exclude
- * Constructs a <tt>FlexSessionManager</tt> for the passed <tt>MessageBroker</tt> and optionally enables management.
- *
- * @param enableManagement <code>true</code> if the <tt>FlexSessionManager</tt>
- * is manageable; otherwise <code>false</code>.
- */
- public FlexSessionManager(boolean enableManagement, MessageBroker broker)
- {
- super(enableManagement);
-
- super.setId(TYPE);
-
- this.broker = broker;
-
- this.setParent(broker);
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Instance-level lock.
- */
- private final Object lock = new Object();
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // logCategory
- //----------------------------------
-
- /**
- * Returns the log category for this component.
- *
- * @return The log category for this component.
- */
- @Override
- protected String getLogCategory()
- {
- return LogCategories.ENDPOINT_FLEXSESSION;
- }
-
- //----------------------------------
- // flexSessionCount
- //----------------------------------
-
- private int flexSessionCount;
-
- /**
- * Returns the total count of active FlexSessions.
- *
- * @return The total count of active FlexSessions.
- */
- public int getFlexSessionCount()
- {
- synchronized (lock)
- {
- return flexSessionCount;
- }
- }
-
- //----------------------------------
- // flexSessionProviders
- //----------------------------------
-
- private final ConcurrentHashMap<Class<? extends FlexSession>, AbstractFlexSessionProvider> providers = new ConcurrentHashMap<Class<? extends FlexSession>, AbstractFlexSessionProvider>();
-
- /**
- * Returns the registered <tt>FlexSessionProvider</tt> implementation for the specified <tt>FlexSession</tt> type.
- *
- * @param sessionClass The specific <tt>FlexSession</tt> type to get a provider for.
- * @return The registered <tt>FlexSessionProvider</tt> or <code>null</code> if no provider is registered.
- */
- public AbstractFlexSessionProvider getFlexSessionProvider(Class<? extends FlexSession> sessionClass)
- {
- return providers.get(sessionClass);
- }
-
- /**
- * Registers a <tt>FlexSessionProvider</tt> implementation for a specified <tt>FlexSession</tt> type.
- *
- * @param sessionClass The specific <tt>FlexSession</tt> type to register a provider for.
- * @param provider The corresponding <tt>FlexSessionProvider</tt> to register.
- * @return The previously registered provider, or <code>null</code> if no provider was registered for this session type.
- */
- public AbstractFlexSessionProvider registerFlexSessionProvider(Class<? extends FlexSession> sessionClass, AbstractFlexSessionProvider provider)
- {
- provider.setFlexSessionManager(this);
- AbstractFlexSessionProvider previousProvider = providers.putIfAbsent(sessionClass, provider);
-
- if (previousProvider != null)
- {
- previousProvider.stop();
- previousProvider.setFlexSessionManager(null);
- }
-
- if (isStarted())
- provider.start();
-
- return previousProvider;
- }
-
- /**
- * Unregisters a <tt>FlexSessionProvider</tt> implementation for a specified <tt>FlexSession</tt> type.
- *
- * @param sessionClass The specific <tt>FlexSession</tt> type to unregister a provider for.
- */
- public void unregisterFlexSessionProvider(Class<? extends FlexSession> sessionClass)
- {
- AbstractFlexSessionProvider provider = providers.remove(sessionClass);
- if (provider != null)
- {
- provider.stop();
- provider.setFlexSessionManager(null);
- }
- }
-
- //----------------------------------
- // flexSessions
- //----------------------------------
-
- /**
- * Registers a new <tt>FlexSession</tt> with the <tt>FlexSessionManager</tt>.
- *
- * @param session The new <tt>FlexSession</tt>.
- */
- public void registerFlexSession(FlexSession session)
- {
- synchronized (lock)
- {
- ++flexSessionCount;
- resetMaxFlexSessionsInCurrentHour(flexSessionCount);
- }
- }
-
- /**
- * Unregisters an invalidated <tt>FlexSession</tt> from the <tt>FlexSessionManager</tt>.
- *
- * @param session The invalidated <tt>FlexSession</tt>.
- */
- public void unregisterFlexSession(FlexSession session)
- {
- synchronized (lock)
- {
- --flexSessionCount;
- resetMaxFlexSessionsInCurrentHour(flexSessionCount);
- }
- }
-
- //----------------------------------
- // maxFlexSessionsInCurrentHour
- //----------------------------------
-
- private int maxSessionCountInCurrentHour;
- private long currentHourStartTimestamp = System.currentTimeMillis();
-
- public int getMaxFlexSessionsInCurrentHour()
- {
- synchronized (lock)
- {
- // Make sure we report the correct value if the system has been idle across an hour transition.
- resetMaxFlexSessionsInCurrentHour(flexSessionCount);
-
- return maxSessionCountInCurrentHour;
- }
- }
-
- /* Must be called within a synchronized block. */
- private void resetMaxFlexSessionsInCurrentHour(int currentCount)
- {
- long offset = (System.currentTimeMillis() - currentHourStartTimestamp) / MILLIS_IN_HOUR;
- if (offset > 0) // Shift to the current hour and reset to the current session count.
- {
- currentHourStartTimestamp += (MILLIS_IN_HOUR * offset);
- maxSessionCountInCurrentHour = currentCount;
- }
- else if (maxSessionCountInCurrentHour < currentCount)
- {
- maxSessionCountInCurrentHour = currentCount;
- }
- }
-
- //----------------------------------
- // messageBroker
- //----------------------------------
-
- private final MessageBroker broker;
-
- /**
- * Returns the <tt>MessageBroker</tt> instance that owns this <tt>FlexSessionManager</tt>.
- *
- * @return The parent <tt>MessageBroker</tt> instance.
- */
- public MessageBroker getMessageBroker()
- {
- return broker;
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Starts the <tt>FlexSessionManager</tt>.
- * Any registered <tt>FlexSession</tt>s providers are also started.
- */
- @Override
- public void start()
- {
- if (isStarted())
- return;
-
- for (AbstractFlexSessionProvider provider : providers.values())
- {
- if (!provider.isStarted())
- provider.start();
- }
-
- super.start();
- }
-
- /**
- * Stops the <tt>FlexSessionManager</tt>.
- * Any registered <tt>FlexSession</tt> providers are stopped and unregistered.
- */
- @Override
- public void stop()
- {
- if (!isStarted())
- return;
-
- super.stop();
-
- for (Class<? extends FlexSession> sessionClass : providers.keySet())
- {
- unregisterFlexSessionProvider(sessionClass);
- }
- providers.clear();
- }
-}
+/*
+ * 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;
+
+import flex.management.ManageableComponent;
+import flex.messaging.log.LogCategories;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @exclude
+ * Manages FlexSession instances for a MessageBroker.
+ */
+public class FlexSessionManager extends ManageableComponent
+{
+ public static final String TYPE = "FlexSessionManager";
+
+ private static final long MILLIS_IN_HOUR = 3600000;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructors
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @exclude
+ * Constructs a <tt>FlexSessionManager</tt> for the passed <tt>MessageBroker</tt>.
+ *
+ * @param broker The root <tt>MessageBroker</tt> using this <tt>FlexSessionManager</tt>.
+ */
+ public FlexSessionManager(MessageBroker broker)
+ {
+ this(false, broker);
+ }
+
+ /**
+ * @exclude
+ * Constructs a <tt>FlexSessionManager</tt> for the passed <tt>MessageBroker</tt> and optionally enables management.
+ *
+ * @param enableManagement <code>true</code> if the <tt>FlexSessionManager</tt>
+ * is manageable; otherwise <code>false</code>.
+ */
+ public FlexSessionManager(boolean enableManagement, MessageBroker broker)
+ {
+ super(enableManagement);
+
+ super.setId(TYPE);
+
+ this.broker = broker;
+
+ this.setParent(broker);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Instance-level lock.
+ */
+ private final Object lock = new Object();
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // logCategory
+ //----------------------------------
+
+ /**
+ * Returns the log category for this component.
+ *
+ * @return The log category for this component.
+ */
+ @Override
+ protected String getLogCategory()
+ {
+ return LogCategories.ENDPOINT_FLEXSESSION;
+ }
+
+ //----------------------------------
+ // flexSessionCount
+ //----------------------------------
+
+ private int flexSessionCount;
+
+ /**
+ * Returns the total count of active FlexSessions.
+ *
+ * @return The total count of active FlexSessions.
+ */
+ public int getFlexSessionCount()
+ {
+ synchronized (lock)
+ {
+ return flexSessionCount;
+ }
+ }
+
+ //----------------------------------
+ // flexSessionProviders
+ //----------------------------------
+
+ private final ConcurrentHashMap<Class<? extends FlexSession>, AbstractFlexSessionProvider> providers = new ConcurrentHashMap<Class<? extends FlexSession>, AbstractFlexSessionProvider>();
+
+ /**
+ * Returns the registered <tt>FlexSessionProvider</tt> implementation for the specified <tt>FlexSession</tt> type.
+ *
+ * @param sessionClass The specific <tt>FlexSession</tt> type to get a provider for.
+ * @return The registered <tt>FlexSessionProvider</tt> or <code>null</code> if no provider is registered.
+ */
+ public AbstractFlexSessionProvider getFlexSessionProvider(Class<? extends FlexSession> sessionClass)
+ {
+ return providers.get(sessionClass);
+ }
+
+ /**
+ * Registers a <tt>FlexSessionProvider</tt> implementation for a specified <tt>FlexSession</tt> type.
+ *
+ * @param sessionClass The specific <tt>FlexSession</tt> type to register a provider for.
+ * @param provider The corresponding <tt>FlexSessionProvider</tt> to register.
+ * @return The previously registered provider, or <code>null</code> if no provider was registered for this session type.
+ */
+ public AbstractFlexSessionProvider registerFlexSessionProvider(Class<? extends FlexSession> sessionClass, AbstractFlexSessionProvider provider)
+ {
+ provider.setFlexSessionManager(this);
+ AbstractFlexSessionProvider previousProvider = providers.putIfAbsent(sessionClass, provider);
+
+ if (previousProvider != null)
+ {
+ previousProvider.stop();
+ previousProvider.setFlexSessionManager(null);
+ }
+
+ if (isStarted())
+ provider.start();
+
+ return previousProvider;
+ }
+
+ /**
+ * Unregisters a <tt>FlexSessionProvider</tt> implementation for a specified <tt>FlexSession</tt> type.
+ *
+ * @param sessionClass The specific <tt>FlexSession</tt> type to unregister a provider for.
+ */
+ public void unregisterFlexSessionProvider(Class<? extends FlexSession> sessionClass)
+ {
+ AbstractFlexSessionProvider provider = providers.remove(sessionClass);
+ if (provider != null)
+ {
+ provider.stop();
+ provider.setFlexSessionManager(null);
+ }
+ }
+
+ //----------------------------------
+ // flexSessions
+ //----------------------------------
+
+ /**
+ * Registers a new <tt>FlexSession</tt> with the <tt>FlexSessionManager</tt>.
+ *
+ * @param session The new <tt>FlexSession</tt>.
+ */
+ public void registerFlexSession(FlexSession session)
+ {
+ synchronized (lock)
+ {
+ ++flexSessionCount;
+ resetMaxFlexSessionsInCurrentHour(flexSessionCount);
+ }
+ }
+
+ /**
+ * Unregisters an invalidated <tt>FlexSession</tt> from the <tt>FlexSessionManager</tt>.
+ *
+ * @param session The invalidated <tt>FlexSession</tt>.
+ */
+ public void unregisterFlexSession(FlexSession session)
+ {
+ synchronized (lock)
+ {
+ --flexSessionCount;
+ resetMaxFlexSessionsInCurrentHour(flexSessionCount);
+ }
+ }
+
+ //----------------------------------
+ // maxFlexSessionsInCurrentHour
+ //----------------------------------
+
+ private int maxSessionCountInCurrentHour;
+ private long currentHourStartTimestamp = System.currentTimeMillis();
+
+ public int getMaxFlexSessionsInCurrentHour()
+ {
+ synchronized (lock)
+ {
+ // Make sure we report the correct value if the system has been idle across an hour transition.
+ resetMaxFlexSessionsInCurrentHour(flexSessionCount);
+
+ return maxSessionCountInCurrentHour;
+ }
+ }
+
+ /* Must be called within a synchronized block. */
+ private void resetMaxFlexSessionsInCurrentHour(int currentCount)
+ {
+ long offset = (System.currentTimeMillis() - currentHourStartTimestamp) / MILLIS_IN_HOUR;
+ if (offset > 0) // Shift to the current hour and reset to the current session count.
+ {
+ currentHourStartTimestamp += (MILLIS_IN_HOUR * offset);
+ maxSessionCountInCurrentHour = currentCount;
+ }
+ else if (maxSessionCountInCurrentHour < currentCount)
+ {
+ maxSessionCountInCurrentHour = currentCount;
+ }
+ }
+
+ //----------------------------------
+ // messageBroker
+ //----------------------------------
+
+ private final MessageBroker broker;
+
+ /**
+ * Returns the <tt>MessageBroker</tt> instance that owns this <tt>FlexSessionManager</tt>.
+ *
+ * @return The parent <tt>MessageBroker</tt> instance.
+ */
+ public MessageBroker getMessageBroker()
+ {
+ return broker;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Starts the <tt>FlexSessionManager</tt>.
+ * Any registered <tt>FlexSession</tt>s providers are also started.
+ */
+ @Override
+ public void start()
+ {
+ if (isStarted())
+ return;
+
+ for (AbstractFlexSessionProvider provider : providers.values())
+ {
+ if (!provider.isStarted())
+ provider.start();
+ }
+
+ super.start();
+ }
+
+ /**
+ * Stops the <tt>FlexSessionManager</tt>.
+ * Any registered <tt>FlexSession</tt> providers are stopped and unregistered.
+ */
+ @Override
+ public void stop()
+ {
+ if (!isStarted())
+ return;
+
+ super.stop();
+
+ for (Class<? extends FlexSession> sessionClass : providers.keySet())
+ {
+ unregisterFlexSessionProvider(sessionClass);
+ }
+ providers.clear();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/HttpFlexSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/HttpFlexSession.java b/modules/core/src/flex/messaging/HttpFlexSession.java
old mode 100755
new mode 100644
index f305fb9..372e1ed
--- a/modules/core/src/flex/messaging/HttpFlexSession.java
+++ b/modules/core/src/flex/messaging/HttpFlexSession.java
@@ -1,666 +1,666 @@
-/*
- * 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;
-
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionAttributeListener;
-import javax.servlet.http.HttpSessionBindingEvent;
-import javax.servlet.http.HttpSessionBindingListener;
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.security.Principal;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * FlexSession implementation for use with HTTP-based channels.
- *
- * @author shodgson
- */
-public class HttpFlexSession extends FlexSession
- implements HttpSessionBindingListener, HttpSessionListener, HttpSessionAttributeListener, Serializable
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * Not for public use. This constructor is used to create an instance of this class that
- * will operate as a javax.servlet.http.HttpSessionListener registered in web.xml.
- */
- public HttpFlexSession()
- {}
-
- /**
- * @exclude
- * Not for public use. Constructs new instances that effectively wrap pre-existing JEE HttpSession instances.
- */
- public HttpFlexSession(HttpFlexSessionProvider provider)
- {
- super(provider);
- }
-
- //--------------------------------------------------------------------------
- //
- // Constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * Serializable version uid.
- */
- private static final long serialVersionUID = -1260409488935306147L;
-
- /**
- * Attribute name that HttpFlexSession is stored under in the HttpSession.
- */
- /* package-private */ static final String SESSION_ATTRIBUTE = "__flexSession";
-
- /**
- * This attribute is set on the request associated with a Flex Session when
- * a logout command is being processed. The reason that this is necessary is
- * that a single HttpServletRequest may contain more than one Flex command/message.
- * In this case, every message following a "logout" command should behave as if the
- * user has logged out. However, since in getUserPrincipal, we check the request
- * object if the Session has no principal, if the current request object
- * has a principal object associated with it (as it does on Tomcat/JBoss),
- * messages following a "logout" will use this principal. We thus need to
- * invalidate the user principal in the request on logout. Since the field
- * is read-only we do so using this attribute.
- */
- private static final String INVALIDATED_REQUEST = "__flexInvalidatedRequest";
-
- public static final String SESSION_MAP = "LCDS_HTTP_TO_FLEX_SESSION_MAP";
-
- /**
- * Internal flag indicating whether we are a registered listener in web.xml.
- */
- /* package-private */ static volatile boolean isHttpSessionListener;
-
- /**
- * Flag to indicate whether we've logged a warning if we weren't registered in web.xml and
- * can't redispatch attribute and binding events to Flex listeners.
- */
- /* package-private */ static volatile boolean warnedNoEventRedispatch;
-
- /**
- * The log category to send the warning for no event redispatch to.
- */
- /* package-private */ static String WARN_LOG_CATEGORY = LogCategories.CONFIGURATION;
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Reference to the HttpSession allows us to invalidate it and use it for attribute management.
- */
- /* package-private */ HttpSession httpSession;
-
- /**
- * @exclude
- * Static lock for creating httpSessionToFlexSession map
- */
- public static final Object mapLock = new Object();
-
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * HttpSessionAttributeListener callback; processes the addition of an attribute to an HttpSession.
- *
- * NOTE: Callback is not made against an HttpFlexSession associated with a request
- * handling thread.
- * @param event the HttpSessionBindingEvent
- */
- public void attributeAdded(HttpSessionBindingEvent event)
- {
- if (!event.getName().equals(SESSION_ATTRIBUTE))
- {
- // Accessing flexSession via map because it may have already been unbound from httpSession.
- Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(event.getSession());
- HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.get(event.getSession().getId());
- if (flexSession != null)
- {
- String name = event.getName();
- Object value = event.getValue();
- flexSession.notifyAttributeBound(name, value);
- flexSession.notifyAttributeAdded(name, value);
- }
- }
- }
-
- /**
- * HttpSessionAttributeListener callback; processes the removal of an attribute from an HttpSession.
- *
- * NOTE: Callback is not made against an HttpFlexSession associated with a request
- * handling thread.
- * @param event the HttpSessionBindingEvent
- */
- public void attributeRemoved(HttpSessionBindingEvent event)
- {
- if (!event.getName().equals(SESSION_ATTRIBUTE))
- {
- // Accessing flexSession via map because it may have already been unbound from httpSession.
- Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(event.getSession());
- HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.get(event.getSession().getId());
- if (flexSession != null)
- {
- String name = event.getName();
- Object value = event.getValue();
- flexSession.notifyAttributeUnbound(name, value);
- flexSession.notifyAttributeRemoved(name, value);
- }
- }
- }
-
- /**
- * HttpSessionAttributeListener callback; processes the replacement of an attribute in an HttpSession.
- *
- * NOTE: Callback is not made against an HttpFlexSession associated with a request
- * handling thread.
- * @param event the HttpSessionBindingEvent
- */
- public void attributeReplaced(HttpSessionBindingEvent event)
- {
- if (!event.getName().equals(SESSION_ATTRIBUTE))
- {
- // Accessing flexSession via map because it may have already been unbound from httpSession.
- Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(event.getSession());
- HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.get(event.getSession().getId());
- if (flexSession != null)
- {
- String name = event.getName();
- Object value = event.getValue();
- Object newValue = flexSession.getAttribute(name);
- flexSession.notifyAttributeUnbound(name, value);
- flexSession.notifyAttributeReplaced(name, value);
- flexSession.notifyAttributeBound(name, newValue);
- }
- }
- }
-
- /**
- * Creates or retrieves a FlexSession for the current Http request.
- * The HttpFlexSession wraps the underlying J2EE HttpSession.
- * Not intended for public use.
- *
- * @param req The Http request.
- *
- * @return The HttpFlexSession.
- *
- * @deprecated This method has been deprecated in favor of session providers registered with a <tt>MessageBroker</tt>.
- * @see flex.messaging.FlexSessionManager
- * @see flex.messaging.HttpFlexSessionProvider
- */
- public static HttpFlexSession getFlexSession(HttpServletRequest req)
- {
- HttpFlexSession flexSession;
- HttpSession httpSession = req.getSession(true);
-
- if (!isHttpSessionListener && !warnedNoEventRedispatch)
- {
- warnedNoEventRedispatch = true;
- if (Log.isWarn())
- Log.getLogger(WARN_LOG_CATEGORY).warn("HttpFlexSession has not been registered as a listener in web.xml for this application so no events will be dispatched to FlexSessionAttributeListeners or FlexSessionBindingListeners. To correct this, register flex.messaging.HttpFlexSession as a listener in web.xml.");
- }
-
- boolean isNew = false;
- synchronized (httpSession)
- {
- flexSession = (HttpFlexSession)httpSession.getAttribute(HttpFlexSession.SESSION_ATTRIBUTE);
- if (flexSession == null)
- {
- flexSession = new HttpFlexSession();
- // Correlate this FlexSession to the HttpSession before triggering any listeners.
- FlexContext.setThreadLocalSession(flexSession);
- httpSession.setAttribute(SESSION_ATTRIBUTE, flexSession);
- flexSession.setHttpSession(httpSession);
- isNew = true;
- }
- else
- {
- FlexContext.setThreadLocalSession(flexSession);
- if (flexSession.httpSession == null)
- {
- // httpSession is null if the instance is new or is from
- // serialization.
- flexSession.setHttpSession(httpSession);
- isNew = true;
- }
- }
- }
-
- if (isNew)
- {
- flexSession.notifyCreated();
-
- if (Log.isDebug())
- Log.getLogger(FLEX_SESSION_LOG_CATEGORY).debug("FlexSession created with id '" + flexSession.getId() + "' for an Http-based client connection.");
- }
-
- return flexSession;
- }
-
- /**
- * Returns the user principal associated with the session. This will
- * be null if the user has not authenticated.
- *
- * @return The Principal associated with the session.
- */
- public Principal getUserPrincipal()
- {
- Principal p = super.getUserPrincipal();
- if (p == null)
- {
- HttpServletRequest req = FlexContext.getHttpRequest();
- if (req != null && req.getAttribute(INVALIDATED_REQUEST) == null)
- p = req.getUserPrincipal();
- }
- return p;
- }
-
- /**
- * Invalidates the session.
- */
- public void invalidate()
- {
- // If the HttpFlexSession is the current active FlexSession for the thread
- // we'll invalidate it but we need to recreate a new HttpFlexSession because
- // the client's HttpSession is still active.
- boolean recreate = FlexContext.getFlexSession() == this;
- invalidate(recreate);
- }
-
- /**
- * @exclude
- * Used by Http endpoints when they receive notification from a client that it has
- * disconnected its channel.
- * Supports invalidating the HttpFlexSession and underlying JEE HttpSession without
- * triggering session recreation.
- */
- public void invalidate(boolean recreate)
- {
- synchronized (httpSession)
- {
- try
- {
- // Invalidating the HttpSession will trigger invalidation of the HttpFlexSession
- // either via the sessionDestroyed() event if registration as an HttpSession listener worked
- // or via the valueUnbound() event if it didn't.
- httpSession.invalidate();
- }
- catch (IllegalStateException e)
- {
- // Make sure any related mapping is removed.
- try
- {
- Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(httpSession);
- httpSessionToFlexSessionMap.remove(httpSession.getId());
- }
- catch (Exception ignore)
- {
- // NOWARN
- }
-
- // And invalidate this FlexSession.
- super.invalidate();
- }
- }
- if (recreate)
- {
- HttpServletRequest req = FlexContext.getHttpRequest();
-
- if (req != null)
- {
- // Set an attribute on the request denoting that the userPrincipal in the request
- // is now invalid.
- req.setAttribute(INVALIDATED_REQUEST, "true");
-
- AbstractFlexSessionProvider sessionProvider = getFlexSessionProvider();
-
- // BLZ-531: When using spring integration getting a null pointer exception when calling invalidate
- // on a FlexSession twice
- // If originally the HttpFlexSession was created using the deprecated HttpFlexSession.getFlexSession(request) API,
- // it does not have an associated AbstractFlexSessionProvider. Invoking invalidate(true) on such a session
- // results in the "recreated" FlexSession being NULL. To prevent this from happening, in case session provider
- // is NULL, we create the session using the deprecated HttpFlexSession.getFlexSession(request) API.
- FlexSession session = sessionProvider == null ?
- getFlexSession(req) : ((HttpFlexSessionProvider)sessionProvider).getOrCreateSession(req);
-
- FlexContext.setThreadLocalObjects(FlexContext.getFlexClient(),
- session, FlexContext.getMessageBroker(), req,
- FlexContext.getHttpResponse(), FlexContext.getServletConfig());
- }
- // else, the session was invalidated outside of a request being processed.
- }
- }
-
- /**
- * Returns the attribute bound to the specified name in the session, or null
- * if no attribute is bound under the name.
- *
- * @param name The name the target attribute is bound to.
- * @return The attribute bound to the specified name.
- */
- public Object getAttribute(String name)
- {
- return httpSession.getAttribute(name);
- }
-
- /**
- * Returns the names of all attributes bound to the session.
- *
- * @return The names of all attributes bound to the session.
- */
- public Enumeration getAttributeNames()
- {
- return httpSession.getAttributeNames();
- }
-
- /**
- * Returns the Id for the session.
- *
- * @return The Id for the session.
- */
- public String getId()
- {
- return httpSession.getId();
- }
-
- /**
- * @exclude
- * FlexClient invokes this to determine whether the session can be used to push messages
- * to the client.
- *
- * @return true if the FlexSession supports direct push; otherwise false (polling is assumed).
- */
- public boolean isPushSupported()
- {
- return false;
- }
-
- /**
- * Removes the attribute bound to the specified name in the session.
- *
- * @param name The name of the attribute to remove.
- */
- public void removeAttribute(String name)
- {
- httpSession.removeAttribute(name);
- }
-
- /**
- * Implements HttpSessionListener.
- * HttpSession created events are handled by setting an internal flag indicating that registration
- * as an HttpSession listener was successful and we will be notified of session attribute changes and
- * session destruction.
- * NOTE: This method is not invoked against an HttpFlexSession associated with a request
- * handling thread.
- * @param event the HttpSessionEvent
- */
- public void sessionCreated(HttpSessionEvent event)
- {
- isHttpSessionListener = true;
- }
-
- /**
- * Implements HttpSessionListener.
- * When an HttpSession is destroyed, the associated HttpFlexSession is also destroyed.
- * NOTE: This method is not invoked against an HttpFlexSession associated with a request
- * handling thread.
- * @param event the HttpSessionEvent
- */
- public void sessionDestroyed(HttpSessionEvent event)
- {
- HttpSession session = event.getSession();
- Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(session);
- HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.remove(session.getId());
- if (flexSession != null)
- {
- // invalidate the flex session
- flexSession.superInvalidate();
-
- // Send notifications to attribute listeners if needed.
- // This may send extra notifications if attributeRemoved is called first by the server,
- // but Java servlet 2.4 says session destroy is first, then attributes.
- // Guard against pre-2.4 containers that dispatch events in an incorrect order,
- // meaning skip attribute processing here if the underlying session state is no longer valid.
- try
- {
- for (Enumeration e = session.getAttributeNames(); e.hasMoreElements(); )
- {
- String name = (String) e.nextElement();
- if (name.equals(SESSION_ATTRIBUTE))
- continue;
- Object value = session.getAttribute(name);
- if (value != null)
- {
- flexSession.notifyAttributeUnbound(name, value);
- flexSession.notifyAttributeRemoved(name, value);
- }
- }
- }
- catch (IllegalStateException ignore)
- {
- // NOWARN
- // Old servlet container that dispatches events out of order.
- }
- }
- }
-
- /**
- * Binds an attribute to the session under the specified name.
- *
- * @param name The name to bind the attribute under.
- *
- * @param value The attribute value.
- */
- public void setAttribute(String name, Object value)
- {
- httpSession.setAttribute(name, value);
- }
-
- /**
- * Implements HttpSessionBindingListener.
- * This is a no-op.
- * NOTE: This method is not invoked against an HttpFlexSession associated with a request
- * handling thread.
- * @param event the HttpSessionBindingEvent
- */
- public void valueBound(HttpSessionBindingEvent event)
- {
- // No-op.
- }
-
- /**
- * Implements HttpSessionBindingListener.
- * This callback will destroy the HttpFlexSession upon being unbound, only in the
- * case where we haven't been registered as an HttpSessionListener in web.xml and
- * can't shut down based on the HttpSession being invalidated.
- * NOTE: This method is not invoked against an HttpFlexSession associated with a request
- * handling thread.
- * @param event the HttpSessionBindingEvent
- */
- public void valueUnbound(HttpSessionBindingEvent event)
- {
- if (!isHttpSessionListener)
- {
- Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(event.getSession());
- HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.remove(event.getSession().getId());
- if (flexSession != null)
- flexSession.superInvalidate();
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * We don't need to do anything here other than log out some info about the session that's shutting down.
- */
- protected void internalInvalidate()
- {
- if (Log.isDebug())
- Log.getLogger(FLEX_SESSION_LOG_CATEGORY).debug("FlexSession with id '" + getId() + "' for an Http-based client connection has been invalidated.");
- }
-
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Associates a HttpSession with the FlexSession.
- *
- * @param httpSession The HttpSession to associate with the FlexSession.
- */
- /* package-private */ void setHttpSession(HttpSession httpSession)
- {
- synchronized (lock)
- {
- this.httpSession = httpSession;
- // Update lookup table for event redispatch.
- Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(httpSession);
- httpSessionToFlexSessionMap.put(httpSession.getId(), this);
- }
- }
-
- /**
- * @exclude
- * Invoked by HttpSessionListener or binding listener on HttpSession invalidation to invalidate the wrapping
- * FlexSession.
- */
- private void superInvalidate()
- {
- super.invalidate();
- }
-
- /**
- * Implements Serializable; only the Principal needs to be serialized as all
- * attribute storage is delegated to the associated HttpSession.
- *
- * @param stream The stream to read instance state from.
- */
- private void writeObject(ObjectOutputStream stream)
- {
- try
- {
- Principal principal = super.getUserPrincipal();
- if (principal != null && principal instanceof Serializable)
- stream.writeObject(principal);
- }
- catch (IOException e)
- {
- // Principal was Serializable and non-null; if this happens there's nothing we can do.
- // The user will need to reauthenticate if necessary.
- }
- catch (LocalizedException ignore)
- {
- // This catch block added for bug 194144.
- // On BEA WebLogic, writeObject() is sometimes invoked on invalidated session instances
- // and in this case the checkValid() invocation in super.getUserPrincipal() throws.
- // Ignore this exception.
- }
- }
-
- /**
- * Implements Serializable; only the Principal needs to be serialized as all
- * attribute storage is delegated to the associated HttpSession.
- *
- * @param stream The stream to write instance state to.
- */
- private void readObject(ObjectInputStream stream)
- {
- try
- {
- setUserPrincipal((Principal)stream.readObject());
- }
- catch (Exception e)
- {
- // Principal was not serialized or failed to serialize; ignore.
- // The user will need to reauthenticate if necessary.
- }
- }
-
- /**
- * Map of HttpSession Ids to FlexSessions. We need this when registered as a listener
- * in web.xml in order to trigger the destruction of a FlexSession when its associated HttpSession
- * is invalidated/destroyed. The Servlet spec prior to version 2.4 defined the session destruction event
- * to be dispatched after attributes are unbound from the session so when we receive notification that
- * an HttpSession is destroyed there's no way to get to the associated FlexSession attribute because it
- * has already been unbound... Additionally, we need it to handle attribute removal events that happen
- * during HttpSession destruction because the FlexSession can be unbound from the session before the
- * other attributes we receive notification for.
- *
- * Because of this, it's simplest to just maintain this lookup table and use it for all HttpSession
- * related event handling.
- *
- * The table is maintained on the servlet context instead of statically in order to prevent collisions
- * across web-apps.
- */
- private Map getHttpSessionToFlexSessionMap(HttpSession session)
- {
- try
- {
- ServletContext context = session.getServletContext();
- Map map = (Map)context.getAttribute(SESSION_MAP);
-
- if(map==null){
- // map should never be null here as it is created during MessageBrokerServlet start-up
- if (Log.isError())
- Log.getLogger(FLEX_SESSION_LOG_CATEGORY).error("HttpSession to FlexSession map not created in message broker for "
- + session.getId());
- MessageException me = new MessageException();
- me.setMessage(10032, new Object[] {session.getId()});
- throw me;
- }
- return map;
- }
- catch(Exception e)
- {
- if (Log.isDebug())
- Log.getLogger(FLEX_SESSION_LOG_CATEGORY).debug("Unable to get HttpSession to FlexSession map for "
- + session.getId() + " " + e.toString());
- return new ConcurrentHashMap();
- }
- }
-
-}
+/*
+ * 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;
+
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionBindingListener;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * FlexSession implementation for use with HTTP-based channels.
+ *
+ * @author shodgson
+ */
+public class HttpFlexSession extends FlexSession
+ implements HttpSessionBindingListener, HttpSessionListener, HttpSessionAttributeListener, Serializable
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @exclude
+ * Not for public use. This constructor is used to create an instance of this class that
+ * will operate as a javax.servlet.http.HttpSessionListener registered in web.xml.
+ */
+ public HttpFlexSession()
+ {}
+
+ /**
+ * @exclude
+ * Not for public use. Constructs new instances that effectively wrap pre-existing JEE HttpSession instances.
+ */
+ public HttpFlexSession(HttpFlexSessionProvider provider)
+ {
+ super(provider);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Serializable version uid.
+ */
+ private static final long serialVersionUID = -1260409488935306147L;
+
+ /**
+ * Attribute name that HttpFlexSession is stored under in the HttpSession.
+ */
+ /* package-private */ static final String SESSION_ATTRIBUTE = "__flexSession";
+
+ /**
+ * This attribute is set on the request associated with a Flex Session when
+ * a logout command is being processed. The reason that this is necessary is
+ * that a single HttpServletRequest may contain more than one Flex command/message.
+ * In this case, every message following a "logout" command should behave as if the
+ * user has logged out. However, since in getUserPrincipal, we check the request
+ * object if the Session has no principal, if the current request object
+ * has a principal object associated with it (as it does on Tomcat/JBoss),
+ * messages following a "logout" will use this principal. We thus need to
+ * invalidate the user principal in the request on logout. Since the field
+ * is read-only we do so using this attribute.
+ */
+ private static final String INVALIDATED_REQUEST = "__flexInvalidatedRequest";
+
+ public static final String SESSION_MAP = "LCDS_HTTP_TO_FLEX_SESSION_MAP";
+
+ /**
+ * Internal flag indicating whether we are a registered listener in web.xml.
+ */
+ /* package-private */ static volatile boolean isHttpSessionListener;
+
+ /**
+ * Flag to indicate whether we've logged a warning if we weren't registered in web.xml and
+ * can't redispatch attribute and binding events to Flex listeners.
+ */
+ /* package-private */ static volatile boolean warnedNoEventRedispatch;
+
+ /**
+ * The log category to send the warning for no event redispatch to.
+ */
+ /* package-private */ static String WARN_LOG_CATEGORY = LogCategories.CONFIGURATION;
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Reference to the HttpSession allows us to invalidate it and use it for attribute management.
+ */
+ /* package-private */ HttpSession httpSession;
+
+ /**
+ * @exclude
+ * Static lock for creating httpSessionToFlexSession map
+ */
+ public static final Object mapLock = new Object();
+
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * HttpSessionAttributeListener callback; processes the addition of an attribute to an HttpSession.
+ *
+ * NOTE: Callback is not made against an HttpFlexSession associated with a request
+ * handling thread.
+ * @param event the HttpSessionBindingEvent
+ */
+ public void attributeAdded(HttpSessionBindingEvent event)
+ {
+ if (!event.getName().equals(SESSION_ATTRIBUTE))
+ {
+ // Accessing flexSession via map because it may have already been unbound from httpSession.
+ Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(event.getSession());
+ HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.get(event.getSession().getId());
+ if (flexSession != null)
+ {
+ String name = event.getName();
+ Object value = event.getValue();
+ flexSession.notifyAttributeBound(name, value);
+ flexSession.notifyAttributeAdded(name, value);
+ }
+ }
+ }
+
+ /**
+ * HttpSessionAttributeListener callback; processes the removal of an attribute from an HttpSession.
+ *
+ * NOTE: Callback is not made against an HttpFlexSession associated with a request
+ * handling thread.
+ * @param event the HttpSessionBindingEvent
+ */
+ public void attributeRemoved(HttpSessionBindingEvent event)
+ {
+ if (!event.getName().equals(SESSION_ATTRIBUTE))
+ {
+ // Accessing flexSession via map because it may have already been unbound from httpSession.
+ Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(event.getSession());
+ HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.get(event.getSession().getId());
+ if (flexSession != null)
+ {
+ String name = event.getName();
+ Object value = event.getValue();
+ flexSession.notifyAttributeUnbound(name, value);
+ flexSession.notifyAttributeRemoved(name, value);
+ }
+ }
+ }
+
+ /**
+ * HttpSessionAttributeListener callback; processes the replacement of an attribute in an HttpSession.
+ *
+ * NOTE: Callback is not made against an HttpFlexSession associated with a request
+ * handling thread.
+ * @param event the HttpSessionBindingEvent
+ */
+ public void attributeReplaced(HttpSessionBindingEvent event)
+ {
+ if (!event.getName().equals(SESSION_ATTRIBUTE))
+ {
+ // Accessing flexSession via map because it may have already been unbound from httpSession.
+ Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(event.getSession());
+ HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.get(event.getSession().getId());
+ if (flexSession != null)
+ {
+ String name = event.getName();
+ Object value = event.getValue();
+ Object newValue = flexSession.getAttribute(name);
+ flexSession.notifyAttributeUnbound(name, value);
+ flexSession.notifyAttributeReplaced(name, value);
+ flexSession.notifyAttributeBound(name, newValue);
+ }
+ }
+ }
+
+ /**
+ * Creates or retrieves a FlexSession for the current Http request.
+ * The HttpFlexSession wraps the underlying J2EE HttpSession.
+ * Not intended for public use.
+ *
+ * @param req The Http request.
+ *
+ * @return The HttpFlexSession.
+ *
+ * @deprecated This method has been deprecated in favor of session providers registered with a <tt>MessageBroker</tt>.
+ * @see flex.messaging.FlexSessionManager
+ * @see flex.messaging.HttpFlexSessionProvider
+ */
+ public static HttpFlexSession getFlexSession(HttpServletRequest req)
+ {
+ HttpFlexSession flexSession;
+ HttpSession httpSession = req.getSession(true);
+
+ if (!isHttpSessionListener && !warnedNoEventRedispatch)
+ {
+ warnedNoEventRedispatch = true;
+ if (Log.isWarn())
+ Log.getLogger(WARN_LOG_CATEGORY).warn("HttpFlexSession has not been registered as a listener in web.xml for this application so no events will be dispatched to FlexSessionAttributeListeners or FlexSessionBindingListeners. To correct this, register flex.messaging.HttpFlexSession as a listener in web.xml.");
+ }
+
+ boolean isNew = false;
+ synchronized (httpSession)
+ {
+ flexSession = (HttpFlexSession)httpSession.getAttribute(HttpFlexSession.SESSION_ATTRIBUTE);
+ if (flexSession == null)
+ {
+ flexSession = new HttpFlexSession();
+ // Correlate this FlexSession to the HttpSession before triggering any listeners.
+ FlexContext.setThreadLocalSession(flexSession);
+ httpSession.setAttribute(SESSION_ATTRIBUTE, flexSession);
+ flexSession.setHttpSession(httpSession);
+ isNew = true;
+ }
+ else
+ {
+ FlexContext.setThreadLocalSession(flexSession);
+ if (flexSession.httpSession == null)
+ {
+ // httpSession is null if the instance is new or is from
+ // serialization.
+ flexSession.setHttpSession(httpSession);
+ isNew = true;
+ }
+ }
+ }
+
+ if (isNew)
+ {
+ flexSession.notifyCreated();
+
+ if (Log.isDebug())
+ Log.getLogger(FLEX_SESSION_LOG_CATEGORY).debug("FlexSession created with id '" + flexSession.getId() + "' for an Http-based client connection.");
+ }
+
+ return flexSession;
+ }
+
+ /**
+ * Returns the user principal associated with the session. This will
+ * be null if the user has not authenticated.
+ *
+ * @return The Principal associated with the session.
+ */
+ public Principal getUserPrincipal()
+ {
+ Principal p = super.getUserPrincipal();
+ if (p == null)
+ {
+ HttpServletRequest req = FlexContext.getHttpRequest();
+ if (req != null && req.getAttribute(INVALIDATED_REQUEST) == null)
+ p = req.getUserPrincipal();
+ }
+ return p;
+ }
+
+ /**
+ * Invalidates the session.
+ */
+ public void invalidate()
+ {
+ // If the HttpFlexSession is the current active FlexSession for the thread
+ // we'll invalidate it but we need to recreate a new HttpFlexSession because
+ // the client's HttpSession is still active.
+ boolean recreate = FlexContext.getFlexSession() == this;
+ invalidate(recreate);
+ }
+
+ /**
+ * @exclude
+ * Used by Http endpoints when they receive notification from a client that it has
+ * disconnected its channel.
+ * Supports invalidating the HttpFlexSession and underlying JEE HttpSession without
+ * triggering session recreation.
+ */
+ public void invalidate(boolean recreate)
+ {
+ synchronized (httpSession)
+ {
+ try
+ {
+ // Invalidating the HttpSession will trigger invalidation of the HttpFlexSession
+ // either via the sessionDestroyed() event if registration as an HttpSession listener worked
+ // or via the valueUnbound() event if it didn't.
+ httpSession.invalidate();
+ }
+ catch (IllegalStateException e)
+ {
+ // Make sure any related mapping is removed.
+ try
+ {
+ Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(httpSession);
+ httpSessionToFlexSessionMap.remove(httpSession.getId());
+ }
+ catch (Exception ignore)
+ {
+ // NOWARN
+ }
+
+ // And invalidate this FlexSession.
+ super.invalidate();
+ }
+ }
+ if (recreate)
+ {
+ HttpServletRequest req = FlexContext.getHttpRequest();
+
+ if (req != null)
+ {
+ // Set an attribute on the request denoting that the userPrincipal in the request
+ // is now invalid.
+ req.setAttribute(INVALIDATED_REQUEST, "true");
+
+ AbstractFlexSessionProvider sessionProvider = getFlexSessionProvider();
+
+ // BLZ-531: When using spring integration getting a null pointer exception when calling invalidate
+ // on a FlexSession twice
+ // If originally the HttpFlexSession was created using the deprecated HttpFlexSession.getFlexSession(request) API,
+ // it does not have an associated AbstractFlexSessionProvider. Invoking invalidate(true) on such a session
+ // results in the "recreated" FlexSession being NULL. To prevent this from happening, in case session provider
+ // is NULL, we create the session using the deprecated HttpFlexSession.getFlexSession(request) API.
+ FlexSession session = sessionProvider == null ?
+ getFlexSession(req) : ((HttpFlexSessionProvider)sessionProvider).getOrCreateSession(req);
+
+ FlexContext.setThreadLocalObjects(FlexContext.getFlexClient(),
+ session, FlexContext.getMessageBroker(), req,
+ FlexContext.getHttpResponse(), FlexContext.getServletConfig());
+ }
+ // else, the session was invalidated outside of a request being processed.
+ }
+ }
+
+ /**
+ * Returns the attribute bound to the specified name in the session, or null
+ * if no attribute is bound under the name.
+ *
+ * @param name The name the target attribute is bound to.
+ * @return The attribute bound to the specified name.
+ */
+ public Object getAttribute(String name)
+ {
+ return httpSession.getAttribute(name);
+ }
+
+ /**
+ * Returns the names of all attributes bound to the session.
+ *
+ * @return The names of all attributes bound to the session.
+ */
+ public Enumeration getAttributeNames()
+ {
+ return httpSession.getAttributeNames();
+ }
+
+ /**
+ * Returns the Id for the session.
+ *
+ * @return The Id for the session.
+ */
+ public String getId()
+ {
+ return httpSession.getId();
+ }
+
+ /**
+ * @exclude
+ * FlexClient invokes this to determine whether the session can be used to push messages
+ * to the client.
+ *
+ * @return true if the FlexSession supports direct push; otherwise false (polling is assumed).
+ */
+ public boolean isPushSupported()
+ {
+ return false;
+ }
+
+ /**
+ * Removes the attribute bound to the specified name in the session.
+ *
+ * @param name The name of the attribute to remove.
+ */
+ public void removeAttribute(String name)
+ {
+ httpSession.removeAttribute(name);
+ }
+
+ /**
+ * Implements HttpSessionListener.
+ * HttpSession created events are handled by setting an internal flag indicating that registration
+ * as an HttpSession listener was successful and we will be notified of session attribute changes and
+ * session destruction.
+ * NOTE: This method is not invoked against an HttpFlexSession associated with a request
+ * handling thread.
+ * @param event the HttpSessionEvent
+ */
+ public void sessionCreated(HttpSessionEvent event)
+ {
+ isHttpSessionListener = true;
+ }
+
+ /**
+ * Implements HttpSessionListener.
+ * When an HttpSession is destroyed, the associated HttpFlexSession is also destroyed.
+ * NOTE: This method is not invoked against an HttpFlexSession associated with a request
+ * handling thread.
+ * @param event the HttpSessionEvent
+ */
+ public void sessionDestroyed(HttpSessionEvent event)
+ {
+ HttpSession session = event.getSession();
+ Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(session);
+ HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.remove(session.getId());
+ if (flexSession != null)
+ {
+ // invalidate the flex session
+ flexSession.superInvalidate();
+
+ // Send notifications to attribute listeners if needed.
+ // This may send extra notifications if attributeRemoved is called first by the server,
+ // but Java servlet 2.4 says session destroy is first, then attributes.
+ // Guard against pre-2.4 containers that dispatch events in an incorrect order,
+ // meaning skip attribute processing here if the underlying session state is no longer valid.
+ try
+ {
+ for (Enumeration e = session.getAttributeNames(); e.hasMoreElements(); )
+ {
+ String name = (String) e.nextElement();
+ if (name.equals(SESSION_ATTRIBUTE))
+ continue;
+ Object value = session.getAttribute(name);
+ if (value != null)
+ {
+ flexSession.notifyAttributeUnbound(name, value);
+ flexSession.notifyAttributeRemoved(name, value);
+ }
+ }
+ }
+ catch (IllegalStateException ignore)
+ {
+ // NOWARN
+ // Old servlet container that dispatches events out of order.
+ }
+ }
+ }
+
+ /**
+ * Binds an attribute to the session under the specified name.
+ *
+ * @param name The name to bind the attribute under.
+ *
+ * @param value The attribute value.
+ */
+ public void setAttribute(String name, Object value)
+ {
+ httpSession.setAttribute(name, value);
+ }
+
+ /**
+ * Implements HttpSessionBindingListener.
+ * This is a no-op.
+ * NOTE: This method is not invoked against an HttpFlexSession associated with a request
+ * handling thread.
+ * @param event the HttpSessionBindingEvent
+ */
+ public void valueBound(HttpSessionBindingEvent event)
+ {
+ // No-op.
+ }
+
+ /**
+ * Implements HttpSessionBindingListener.
+ * This callback will destroy the HttpFlexSession upon being unbound, only in the
+ * case where we haven't been registered as an HttpSessionListener in web.xml and
+ * can't shut down based on the HttpSession being invalidated.
+ * NOTE: This method is not invoked against an HttpFlexSession associated with a request
+ * handling thread.
+ * @param event the HttpSessionBindingEvent
+ */
+ public void valueUnbound(HttpSessionBindingEvent event)
+ {
+ if (!isHttpSessionListener)
+ {
+ Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(event.getSession());
+ HttpFlexSession flexSession = (HttpFlexSession)httpSessionToFlexSessionMap.remove(event.getSession().getId());
+ if (flexSession != null)
+ flexSession.superInvalidate();
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * We don't need to do anything here other than log out some info about the session that's shutting down.
+ */
+ protected void internalInvalidate()
+ {
+ if (Log.isDebug())
+ Log.getLogger(FLEX_SESSION_LOG_CATEGORY).debug("FlexSession with id '" + getId() + "' for an Http-based client connection has been invalidated.");
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Associates a HttpSession with the FlexSession.
+ *
+ * @param httpSession The HttpSession to associate with the FlexSession.
+ */
+ /* package-private */ void setHttpSession(HttpSession httpSession)
+ {
+ synchronized (lock)
+ {
+ this.httpSession = httpSession;
+ // Update lookup table for event redispatch.
+ Map httpSessionToFlexSessionMap = getHttpSessionToFlexSessionMap(httpSession);
+ httpSessionToFlexSessionMap.put(httpSession.getId(), this);
+ }
+ }
+
+ /**
+ * @exclude
+ * Invoked by HttpSessionListener or binding listener on HttpSession invalidation to invalidate the wrapping
+ * FlexSession.
+ */
+ private void superInvalidate()
+ {
+ super.invalidate();
+ }
+
+ /**
+ * Implements Serializable; only the Principal needs to be serialized as all
+ * attribute storage is delegated to the associated HttpSession.
+ *
+ * @param stream The stream to read instance state from.
+ */
+ private void writeObject(ObjectOutputStream stream)
+ {
+ try
+ {
+ Principal principal = super.getUserPrincipal();
+ if (principal != null && principal instanceof Serializable)
+ stream.writeObject(principal);
+ }
+ catch (IOException e)
+ {
+ // Principal was Serializable and non-null; if this happens there's nothing we can do.
+ // The user will need to reauthenticate if necessary.
+ }
+ catch (LocalizedException ignore)
+ {
+ // This catch block added for bug 194144.
+ // On BEA WebLogic, writeObject() is sometimes invoked on invalidated session instances
+ // and in this case the checkValid() invocation in super.getUserPrincipal() throws.
+ // Ignore this exception.
+ }
+ }
+
+ /**
+ * Implements Serializable; only the Principal needs to be serialized as all
+ * attribute storage is delegated to the associated HttpSession.
+ *
+ * @param stream The stream to write instance state to.
+ */
+ private void readObject(ObjectInputStream stream)
+ {
+ try
+ {
+ setUserPrincipal((Principal)stream.readObject());
+ }
+ catch (Exception e)
+ {
+ // Principal was not serialized or failed to serialize; ignore.
+ // The user will need to reauthenticate if necessary.
+ }
+ }
+
+ /**
+ * Map of HttpSession Ids to FlexSessions. We need this when registered as a listener
+ * in web.xml in order to trigger the destruction of a FlexSession when its associated HttpSession
+ * is invalidated/destroyed. The Servlet spec prior to version 2.4 defined the session destruction event
+ * to be dispatched after attributes are unbound from the session so when we receive notification that
+ * an HttpSession is destroyed there's no way to get to the associated FlexSession attribute because it
+ * has already been unbound... Additionally, we need it to handle attribute removal events that happen
+ * during HttpSession destruction because the FlexSession can be unbound from the session before the
+ * other attributes we receive notification for.
+ *
+ * Because of this, it's simplest to just maintain this lookup table and use it for all HttpSession
+ * related event handling.
+ *
+ * The table is maintained on the servlet context instead of statically in order to prevent collisions
+ * across web-apps.
+ */
+ private Map getHttpSessionToFlexSessionMap(HttpSession session)
+ {
+ try
+ {
+ ServletContext context = session.getServletContext();
+ Map map = (Map)context.getAttribute(SESSION_MAP);
+
+ if(map==null){
+ // map should never be null here as it is created during MessageBrokerServlet start-up
+ if (Log.isError())
+ Log.getLogger(FLEX_SESSION_LOG_CATEGORY).error("HttpSession to FlexSession map not created in message broker for "
+ + session.getId());
+ MessageException me = new MessageException();
+ me.setMessage(10032, new Object[] {session.getId()});
+ throw me;
+ }
+ return map;
+ }
+ catch(Exception e)
+ {
+ if (Log.isDebug())
+ Log.getLogger(FLEX_SESSION_LOG_CATEGORY).debug("Unable to get HttpSession to FlexSession map for "
+ + session.getId() + " " + e.toString());
+ return new ConcurrentHashMap();
+ }
+ }
+
+}
[45/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ServicesDependencies.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ServicesDependencies.java b/modules/common/src/flex/messaging/config/ServicesDependencies.java
old mode 100755
new mode 100644
index cfdaa16..487e9ed
--- a/modules/common/src/flex/messaging/config/ServicesDependencies.java
+++ b/modules/common/src/flex/messaging/config/ServicesDependencies.java
@@ -1,747 +1,747 @@
-/*
- * 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.config;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import flex.messaging.LocalizedException;
-
-/**
- * Flex MXMLC compiler uses the result of the client configuration parser
- * to generate mixin initialization source code to be added to the SWF by
- * PreLink. It also requires a list of channel classes to be added as
- * dependencies.
- *
- * @exclude
- */
-public class ServicesDependencies
-{
- private static final String ADVANCED_CHANNELSET_CLASS = "mx.messaging.AdvancedChannelSet";
- private static final String ADVANCED_MESSAGING_SUPPORT_CLASS = "flex.messaging.services.AdvancedMessagingSupport";
- private static final String REDIRECT_URL = "redirect-url";
-
- private boolean containsClientLoadBalancing;
- private String xmlInit = "";
- private StringBuffer imports = new StringBuffer();
- private StringBuffer references = new StringBuffer();
- private List channelClasses;
- private Map configPaths;
- private Map lazyAssociations;
-
- private static final List channel_excludes = new ArrayList();
- static
- {
- channel_excludes.add(REDIRECT_URL);
- }
-
- public static final boolean traceConfig = (System.getProperty("trace.config") != null);
-
- public ServicesDependencies(String path, String parserClass, String contextRoot)
- {
- ClientConfiguration config = getClientConfiguration(path, parserClass);
-
- if (config != null)
- {
- Map importMap = new HashMap();
- lazyAssociations = new HashMap();
- configPaths = config.getConfigPaths();
- xmlInit = codegenXmlInit(config, contextRoot, importMap);
- codegenServiceImportsAndReferences(importMap, imports, references);
- channelClasses = listChannelClasses(config);
- }
- }
-
- public Set getLazyAssociations(String destination)
- {
- if (lazyAssociations == null)
- {
- lazyAssociations = new HashMap();
- }
-
- return (Set)lazyAssociations.get(destination);
- }
-
- public void addLazyAssociation(String destination, String associationProp)
- {
- Set la = getLazyAssociations(destination);
- if (la == null)
- {
- la = new HashSet();
- lazyAssociations.put(destination, la);
- }
- la.add(associationProp);
- }
-
- public String getServerConfigXmlInit()
- {
- return xmlInit;
- }
-
- public String getImports()
- {
- return imports.toString();
- }
-
- public String getReferences()
- {
- return references.toString();
- }
-
- public List getChannelClasses()
- {
- return channelClasses;
- }
-
- public void addChannelClass(String className)
- {
- channelClasses.add(className);
- }
-
- public void addConfigPath(String path, long modified)
- {
- configPaths.put(path, new Long(modified));
- }
-
- public Map getConfigPaths()
- {
- return configPaths;
- }
-
- /**
- * Gets ActionScript source file for a class. The class will be compiled as
- * a mixin and initialize Flex at runtime.
- *
- * @param packageName - the package compiled into the generated source.
- * @param className - the class name of the generated source.
- * @return A String that represents an ActionScript Source file.
- */
- public String getServicesInitSource(String packageName, String className)
- {
- StringBuilder sb = new StringBuilder(2048);
-
- sb.append("package ").append(packageName).append("\n");
- sb.append("{\n\n");
- sb.append("import mx.core.IFlexModuleFactory;\n");
- sb.append("import flash.net.registerClassAlias;\n");
- sb.append("import flash.net.getClassByAlias;\n");
-
- // generated imports
- sb.append(getImports());
-
- sb.append("\n[Mixin]\n");
- sb.append("public class ").append(className).append("\n");
- sb.append("{\n");
- sb.append(" public function ").append(className).append("()\n");
- sb.append(" {\n");
- sb.append(" super();\n");
- sb.append(" }\n\n");
- sb.append(" public static function init(fbs:IFlexModuleFactory):void\n");
- sb.append(" {\n");
-
- // code for init
- sb.append(getServerConfigXmlInit());
- sb.append(" }\n\n");
-
- // generated variables to create references
- sb.append(getReferences());
- sb.append("}\n");
- sb.append("}\n");
-
- return sb.toString();
- }
-
- public static ClientConfiguration getClientConfiguration(String path, String parserClass)
- {
- ClientConfiguration config = new ClientConfiguration();
-
- ConfigurationParser parser = getConfigurationParser(parserClass);
-
- if (parser == null)
- {
- // "Unable to create a parser to load messaging configuration."
- LocalizedException lme = new LocalizedException();
- lme.setMessage(10138);
- throw lme;
- }
-
- LocalFileResolver local = new LocalFileResolver();
- parser.parse(path, local, config);
-
- config.addConfigPath(path, new File(path).lastModified());
-
- return config;
- }
-
- static ConfigurationParser getConfigurationParser(String className)
- {
- ConfigurationParser parser = null;
- Class parserClass = null;
-
- // Check for Custom Parser Specification
- if (className != null)
- {
- try
- {
- parserClass = Class.forName(className);
- parser = (ConfigurationParser)parserClass.newInstance();
- }
- catch (Throwable t)
- {
- if (traceConfig)
- {
- System.out.println("Could not load services configuration parser as: " + className);
- }
- }
- }
-
- // Try Sun JRE 1.4 / Apache Xalan Based Implementation
- if (parser == null)
- {
- try
- {
- Class.forName("org.apache.xpath.CachedXPathAPI");
- className = "flex.messaging.config.ApacheXPathClientConfigurationParser";
- parserClass = Class.forName(className);
- parser = (ConfigurationParser)parserClass.newInstance();
- }
- catch (Throwable t)
- {
- if (traceConfig)
- {
- System.out.println("Could not load configuration parser as: " + className);
- }
- }
- }
-
- // Try Sun JRE 1.5 Based Implementation
- if (parser == null)
- {
- try
- {
- className = "flex.messaging.config.XPathClientConfigurationParser";
- parserClass = Class.forName(className);
- // double-check, on some systems the above loads but the import classes don't
- Class.forName("javax.xml.xpath.XPathExpressionException");
-
- parser = (ConfigurationParser)parserClass.newInstance();
- }
- catch (Throwable t)
- {
- if (traceConfig)
- {
- System.out.println("Could not load configuration parser as: " + className);
- }
- }
- }
-
- if (traceConfig && parser != null)
- {
- System.out.println("Services Configuration Parser: " + parser.getClass().getName());
- }
-
- return parser;
- }
-
- private static List listChannelClasses(ServicesConfiguration config)
- {
- List channelList = new ArrayList();
- Iterator it = config.getAllChannelSettings().values().iterator();
- while (it.hasNext())
- {
- ChannelSettings settings = (ChannelSettings)it.next();
- if (!settings.serverOnly)
- {
- String clientType = settings.getClientType();
- channelList.add(clientType);
- }
- }
-
- return channelList;
- }
-
- /**
- * Emits source code declaration of public var xml:XML (unnamed package), containing ServicesConfiguration as e4x.
- */
- private String codegenXmlInit(ServicesConfiguration config, String contextRoot, Map serviceImportMap)
- {
- StringBuffer e4x = new StringBuffer();
- String channelSetImplToImport = null;
-
- e4x.append("<services>\n");
-
- // Add default channels of the application
- if (config.getDefaultChannels().size() > 0)
- {
- e4x.append("\t<default-channels>\n");
- for (Iterator chanIter = config.getDefaultChannels().iterator(); chanIter.hasNext();)
- {
- String id = (String)chanIter.next();
- e4x.append("\t\t<channel ref=\"" + id + "\"/>\n");
- }
- e4x.append("\t</default-channels>\n");
- }
-
- ClusterSettings defaultCluster = config.getDefaultCluster();
- // Do not add the cluster tag if the default cluster does not have
- // client side load balancing.
- if (defaultCluster != null && !defaultCluster.getURLLoadBalancing())
- defaultCluster = null;
-
- for (Iterator servIter = config.getAllServiceSettings().iterator(); servIter.hasNext();)
- {
- ServiceSettings entry = (ServiceSettings)servIter.next();
-
- // FIXME: Need to find another way to skip BootstrapServices
- // Skip services with no message types
- /*
- String messageTypes = entry.getMessageTypesString();
- if (messageTypes == null)
- continue;
- */
-
- String serviceType = entry.getId();
- e4x.append("\t<service id=\"");
- e4x.append(serviceType);
- e4x.append("\"");
- e4x.append(">\n");
-
- String serviceClass = entry.getClassName();
- if (ADVANCED_MESSAGING_SUPPORT_CLASS.equals(serviceClass))
- channelSetImplToImport = ADVANCED_CHANNELSET_CLASS;
-
- String useTransactionsStr = entry.getProperties().getPropertyAsString("use-transactions", null);
- if (useTransactionsStr != null)
- {
- e4x.append("\t\t<properties>\n\t\t\t<use-transactions>" + useTransactionsStr + "</use-transactions>\n");
- e4x.append("\t\t</properties>\n");
- }
-
- for (Iterator destIter = entry.getDestinationSettings().values().iterator(); destIter.hasNext();)
- {
- DestinationSettings dest = (DestinationSettings) destIter.next();
- String destination = dest.getId();
- e4x.append("\t\t<destination id=\"" + destination + "\">\n");
-
- // add in the identity properties
- ConfigMap metadata = dest.getProperties().getPropertyAsMap("metadata", null);
- boolean closePropTag = false;
- if (metadata != null)
- {
- e4x.append("\t\t\t<properties>\n\t\t\t\t<metadata\n");
- String extendsStr = metadata.getPropertyAsString("extends", null);
- if (extendsStr != null)
- {
- e4x.append(" extends=\"");
- e4x.append(extendsStr);
- e4x.append("\"");
- }
- e4x.append(">");
- closePropTag = true;
- List identities = metadata.getPropertyAsList("identity", null);
- if (identities != null)
- {
- Iterator it = identities.iterator();
- while (it.hasNext())
- {
- Object o = it.next();
- String identityName = null;
- String undefinedValue = null;
- if (o instanceof String)
- {
- identityName = (String) o;
- }
- else if (o instanceof ConfigMap)
- {
- identityName = ((ConfigMap) o).getPropertyAsString("property", null);
- undefinedValue = ((ConfigMap) o).getPropertyAsString("undefined-value", null);
- }
-
- if (identityName != null)
- {
- e4x.append("\t\t\t\t\t<identity property=\"");
- e4x.append(identityName);
- e4x.append("\"");
- if (undefinedValue != null)
- {
- e4x.append(" undefined-value=\"");
- e4x.append(undefinedValue);
- e4x.append("\"");
- }
- e4x.append("/>\n");
- }
- }
- }
- // add associations which reference other data service destinations
- codegenServiceAssociations(metadata, e4x, destination, "one-to-many");
- codegenServiceAssociations(metadata, e4x, destination, "many-to-many");
- codegenServiceAssociations(metadata, e4x, destination, "one-to-one");
- codegenServiceAssociations(metadata, e4x, destination, "many-to-one");
-
- e4x.append("\t\t\t\t</metadata>\n");
- }
-
- String itemClass = dest.getProperties().getPropertyAsString("item-class", null);
- if (itemClass != null)
- {
- if (!closePropTag)
- {
- e4x.append("\t\t\t<properties>\n");
- closePropTag = true;
- }
-
- e4x.append("\t\t\t\t<item-class>");
- e4x.append(itemClass);
- e4x.append("</item-class>\n");
- }
-
- // add in sub-set of network-related destination properties
- ConfigMap network = dest.getProperties().getPropertyAsMap("network", null);
- ConfigMap clusterInfo = null;
- ConfigMap pagingInfo = null;
- ConfigMap reconnectInfo = null;
- if (network != null || defaultCluster != null)
- {
- if (!closePropTag)
- {
- e4x.append("\t\t\t<properties>\n");
- closePropTag = true;
- }
- e4x.append("\t\t\t\t<network>\n");
-
- if (network != null)
- pagingInfo = network.getPropertyAsMap("paging", null);
- if (pagingInfo != null)
- {
- String enabled = pagingInfo.getPropertyAsString("enabled", "false");
- e4x.append("\t\t\t\t\t<paging enabled=\"");
- e4x.append(enabled);
- e4x.append("\"");
- // Always put page size even if it is disabled as we can
- // end up using this for nested properties with lazy="true".
- // supporting pageSize for backwards compatibility but config options are not camelCase in general.
- String size = pagingInfo.getPropertyAsString("page-size", pagingInfo.getPropertyAsString("pageSize", null));
- if (size != null)
- {
- e4x.append(" page-size=\"");
- e4x.append(size);
- e4x.append("\"");
-
- // Included so that newer compilers can work with older clients
- e4x.append(" pageSize=\"");
- e4x.append(size);
- e4x.append("\"");
- }
- e4x.append("/>\n");
- }
-
- if (network != null)
- reconnectInfo = network.getPropertyAsMap("reconnect", null);
- if (reconnectInfo != null)
- {
- String fetchOption = reconnectInfo.getPropertyAsString("fetch", "IDENTITY");
- e4x.append("\t\t\t\t\t<reconnect fetch=\"");
- e4x.append(fetchOption.toUpperCase());
- e4x.append("\" />\n");
- }
-
- if (network != null)
- {
- String reliable = network.getPropertyAsString("reliable", "false");
- if (Boolean.valueOf(reliable).booleanValue()) // No need the default value for the setting.
- {
- e4x.append("\t\t\t\t\t<reliable>");
- e4x.append(reliable);
- e4x.append("</reliable>\n");
- }
- }
-
- if (network != null)
- clusterInfo = network.getPropertyAsMap("cluster", null);
- if (clusterInfo != null)
- {
- String clusterId = clusterInfo.getPropertyAsString("ref", null);
-
- ClusterSettings clusterSettings = config.getClusterSettings(clusterId);
- if (clusterSettings != null &&
- clusterSettings.getURLLoadBalancing())
- {
- e4x.append("\t\t\t\t\t<cluster ref=\"");
- e4x.append(clusterId);
- e4x.append("\"/>\n");
- }
- }
- else if (defaultCluster != null)
- {
- e4x.append("\t\t\t\t\t<cluster");
- if (defaultCluster.getClusterName() != null)
- {
- e4x.append(" ref=\"");
- e4x.append(defaultCluster.getClusterName());
- e4x.append("\"");
- }
- e4x.append("/>\n");
- }
- e4x.append("\t\t\t\t</network>\n");
- }
-
- String useTransactions = dest.getProperties().getPropertyAsString("use-transactions", null);
-
- if (useTransactions !=null)
- {
- if (!closePropTag)
- {
- e4x.append("\t\t\t<properties>\n");
- closePropTag = true;
- }
- e4x.append("\t\t\t\t<use-transactions>" + useTransactions + "</use-transactions>\n");
- }
-
- String autoSyncEnabled = dest.getProperties().getPropertyAsString("auto-sync-enabled", "true");
-
- if (autoSyncEnabled.equalsIgnoreCase("false"))
- {
- if (!closePropTag)
- {
- e4x.append("\t\t\t<properties>\n");
- closePropTag = true;
- }
- e4x.append("\t\t\t\t<auto-sync-enabled>false</auto-sync-enabled>\n");
- }
-
- if (closePropTag)
- {
- e4x.append("\t\t\t</properties>\n");
- }
-
- e4x.append("\t\t\t<channels>\n");
- for (Iterator chanIter = dest.getChannelSettings().iterator(); chanIter.hasNext();)
- {
- e4x.append("\t\t\t\t<channel ref=\"" + ((ChannelSettings) chanIter.next()).getId() + "\"/>\n");
- }
- e4x.append("\t\t\t</channels>\n");
- e4x.append("\t\t</destination>\n");
- }
- e4x.append("\t</service>\n");
- }
- // channels
- e4x.append("\t<channels>\n");
- String channelType;
- for (Iterator chanIter = config.getAllChannelSettings().values().iterator(); chanIter.hasNext();)
- {
- ChannelSettings chan = (ChannelSettings) chanIter.next();
- if (chan.getServerOnly()) // Skip server-only channels.
- continue;
- channelType = chan.getClientType();
- serviceImportMap.put(channelType, channelType);
- e4x.append("\t\t<channel id=\"" + chan.getId() + "\" type=\"" + channelType + "\">\n");
- StringBuffer channelProps = new StringBuffer();
- containsClientLoadBalancing = false;
- channelProperties(chan.getProperties(), channelProps, "\t\t\t\t");
- if (!containsClientLoadBalancing) // Add the uri, only when there is no client-load-balancing defined.
- e4x.append("\t\t\t<endpoint uri=\"" + chan.getClientParsedUri(contextRoot) + "\"/>\n");
- containsClientLoadBalancing = false;
- e4x.append("\t\t\t<properties>\n");
- e4x.append(channelProps);
- e4x.append("\t\t\t</properties>\n");
- e4x.append("\t\t</channel>\n");
- }
- e4x.append("\t</channels>\n");
- FlexClientSettings flexClientSettings = (config instanceof ClientConfiguration) ? ((ClientConfiguration)config).getFlexClientSettings() : null;
- if (flexClientSettings != null && flexClientSettings.getHeartbeatIntervalMillis() > 0)
- {
- e4x.append("\t<flex-client>\n");
- e4x.append("\t\t<heartbeat-interval-millis>");
- e4x.append(flexClientSettings.getHeartbeatIntervalMillis());
- e4x.append("</heartbeat-interval-millis>");
- e4x.append("\t</flex-client>\n");
- }
- e4x.append("</services>");
-
- StringBuffer advancedMessagingSupport = new StringBuffer();
- if (channelSetImplToImport != null)
- {
- serviceImportMap.put("ChannelSetImpl", channelSetImplToImport);
-
- // Codegen same class alias registration as is done by flex2.tools.Prelink#codegenRemoteClassAliases(Map<String,String>).
- // This codegen isn't processed by PreLink.
- String alias = "flex.messaging.messages.ReliabilityMessage";
- String className = "mx.messaging.messages.ReliabilityMessage";
- advancedMessagingSupport.append(" ServerConfig.channelSetFactory = AdvancedChannelSet;\n");
- advancedMessagingSupport.append(" try {\n");
- advancedMessagingSupport.append(" if (flash.net.getClassByAlias(\"" + alias + "\") == null){\n");
- advancedMessagingSupport.append(" flash.net.registerClassAlias(\"" + alias + "\", " + className + ");}\n");
- advancedMessagingSupport.append(" } catch (e:Error) {\n");
- advancedMessagingSupport.append(" flash.net.registerClassAlias(\"" + alias + "\", " + className + "); }\n");
- if (flexClientSettings != null && flexClientSettings.getReliableReconnectDurationMillis() > 0)
- {
- advancedMessagingSupport.append(" AdvancedChannelSet.reliableReconnectDuration =");
- advancedMessagingSupport.append(flexClientSettings.getReliableReconnectDurationMillis());
- advancedMessagingSupport.append(";\n");
- }
- }
- String generatedChunk = "\n ServerConfig.xml =\n" + e4x.toString() + ";\n" + advancedMessagingSupport.toString();
-
- return generatedChunk;
- }
-
- /**
- * Process channel properties recursively.
- */
- private void channelProperties(ConfigMap properties, StringBuffer buf, String indent)
- {
- for (Iterator nameIter = properties.propertyNames().iterator(); nameIter.hasNext();)
- {
- String name = (String)nameIter.next();
- Object value = properties.get(name);
- if (value instanceof String)
- {
- addStringProperty(buf, indent, name, (String)value);
- }
- else if (value instanceof List)
- {
- List children = (List)value;
- for (Iterator childrenIter = children.iterator(); childrenIter.hasNext();)
- addStringProperty(buf, indent, name, (String)childrenIter.next());;
- }
- else if (value instanceof ConfigMap)
- {
- ConfigMap childProperties = (ConfigMap)value;
- buf.append(indent);
- buf.append("<" + name + ">\n");
- if (ConfigurationConstants.CLIENT_LOAD_BALANCING_ELEMENT.equals(name))
- containsClientLoadBalancing = true;
- channelProperties(childProperties, buf, indent + "\t");
- buf.append(indent);
- buf.append("</" + name + ">\n");
- }
- }
- }
-
- private void addStringProperty(StringBuffer buf, String indent, String name, String value)
- {
- if (!channel_excludes.contains(name))
- {
- buf.append(indent);
- buf.append("<" + name + ">" + value + "</" + name + ">\n");
- }
- }
-
- /**
- * Analyze code gen service associations.
- * @param metadata the ConfigMap object
- * @param e4x the buffer object
- * @param destination the current destination
- * @param relation the relationship
- */
- public void codegenServiceAssociations(ConfigMap metadata, StringBuffer e4x, String destination, String relation)
- {
- List references = metadata.getPropertyAsList(relation, null);
- if (references != null)
- {
- Iterator it = references.iterator();
- while (it.hasNext())
- {
- Object ref = it.next();
- if (ref instanceof ConfigMap)
- {
- ConfigMap refMap = (ConfigMap) ref;
- String name = refMap.getPropertyAsString("property", null);
- String associatedDestination = refMap.getPropertyAsString("destination", null);
- String lazy = refMap.getPropertyAsString("lazy", null);
- String loadOnDemand = refMap.getPropertyAsString("load-on-demand", null);
- String hierarchicalEvents = refMap.getPropertyAsString("hierarchical-events", null);
- String pageSize = refMap.getPropertyAsString("page-size", refMap.getPropertyAsString("pageSize", null));
- String pagedUpdates = refMap.getPropertyAsString("paged-updates", null);
- String cascade = refMap.getPropertyAsString("cascade", null);
- String ordered = refMap.getPropertyAsString("ordered", null);
- e4x.append("\t\t\t\t\t<");
- e4x.append(relation);
- if (lazy != null)
- {
- e4x.append(" lazy=\"");
- e4x.append(lazy);
- e4x.append("\"");
-
- if (Boolean.valueOf(lazy.toLowerCase().trim()).booleanValue())
- {
- addLazyAssociation(destination, name);
- }
- }
- e4x.append(" property=\"");
- e4x.append(name);
- e4x.append("\" destination=\"");
- e4x.append(associatedDestination);
- e4x.append("\"");
- String readOnly = refMap.getPropertyAsString("read-only", null);
- if (readOnly != null && readOnly.equalsIgnoreCase("true"))
- {
- e4x.append(" read-only=\"true\"");
- }
- if (loadOnDemand != null && loadOnDemand.equalsIgnoreCase("true"))
- e4x.append(" load-on-demand=\"true\"");
- if (hierarchicalEvents != null && hierarchicalEvents.equalsIgnoreCase("true"))
- e4x.append(" hierarchical-events=\"true\"");
- if (pagedUpdates != null)
- e4x.append(" paged-updates=\"" + pagedUpdates + "\"");
- if (pageSize != null)
- e4x.append(" page-size=\"" + pageSize + "\"");
- if (cascade != null)
- e4x.append(" cascade=\"" + cascade + "\"");
- if (ordered != null)
- e4x.append(" ordered=\"" + ordered + "\"");
- e4x.append("/>\n");
- }
- }
- }
- }
-
- /**
- * This method will return an import and variable reference for channels specified in the map.
- * @param map HashMap containing the client side channel type to be used, typically of the form
- * "mx.messaging.channels.XXXXChannel", where the key and value are equal.
- * @param imports StringBuffer of the imports needed for the given channel definitions
- * @param references StringBuffer of the required references so that these classes will be linked in.
- */
- public static void codegenServiceImportsAndReferences(Map map, StringBuffer imports, StringBuffer references)
- {
- String channelSetImplType = (String)map.remove("ChannelSetImpl");
- String type;
- imports.append("import mx.messaging.config.ServerConfig;\n");
- references.append(" // static references for configured channels\n");
- for (Iterator chanIter = map.values().iterator(); chanIter.hasNext();)
- {
- type = (String)chanIter.next();
- imports.append("import ");
- imports.append(type);
- imports.append(";\n");
- references.append(" private static var ");
- references.append(type.replace('.', '_'));
- references.append("_ref:");
- references.append(type.substring(type.lastIndexOf(".") +1) +";\n");
- }
- if (channelSetImplType != null)
- imports.append("import mx.messaging.AdvancedChannelSet;\nimport mx.messaging.messages.ReliabilityMessage;\n");
- }
-}
+/*
+ * 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.config;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import flex.messaging.LocalizedException;
+
+/**
+ * Flex MXMLC compiler uses the result of the client configuration parser
+ * to generate mixin initialization source code to be added to the SWF by
+ * PreLink. It also requires a list of channel classes to be added as
+ * dependencies.
+ *
+ * @exclude
+ */
+public class ServicesDependencies
+{
+ private static final String ADVANCED_CHANNELSET_CLASS = "mx.messaging.AdvancedChannelSet";
+ private static final String ADVANCED_MESSAGING_SUPPORT_CLASS = "flex.messaging.services.AdvancedMessagingSupport";
+ private static final String REDIRECT_URL = "redirect-url";
+
+ private boolean containsClientLoadBalancing;
+ private String xmlInit = "";
+ private StringBuffer imports = new StringBuffer();
+ private StringBuffer references = new StringBuffer();
+ private List channelClasses;
+ private Map configPaths;
+ private Map lazyAssociations;
+
+ private static final List channel_excludes = new ArrayList();
+ static
+ {
+ channel_excludes.add(REDIRECT_URL);
+ }
+
+ public static final boolean traceConfig = (System.getProperty("trace.config") != null);
+
+ public ServicesDependencies(String path, String parserClass, String contextRoot)
+ {
+ ClientConfiguration config = getClientConfiguration(path, parserClass);
+
+ if (config != null)
+ {
+ Map importMap = new HashMap();
+ lazyAssociations = new HashMap();
+ configPaths = config.getConfigPaths();
+ xmlInit = codegenXmlInit(config, contextRoot, importMap);
+ codegenServiceImportsAndReferences(importMap, imports, references);
+ channelClasses = listChannelClasses(config);
+ }
+ }
+
+ public Set getLazyAssociations(String destination)
+ {
+ if (lazyAssociations == null)
+ {
+ lazyAssociations = new HashMap();
+ }
+
+ return (Set)lazyAssociations.get(destination);
+ }
+
+ public void addLazyAssociation(String destination, String associationProp)
+ {
+ Set la = getLazyAssociations(destination);
+ if (la == null)
+ {
+ la = new HashSet();
+ lazyAssociations.put(destination, la);
+ }
+ la.add(associationProp);
+ }
+
+ public String getServerConfigXmlInit()
+ {
+ return xmlInit;
+ }
+
+ public String getImports()
+ {
+ return imports.toString();
+ }
+
+ public String getReferences()
+ {
+ return references.toString();
+ }
+
+ public List getChannelClasses()
+ {
+ return channelClasses;
+ }
+
+ public void addChannelClass(String className)
+ {
+ channelClasses.add(className);
+ }
+
+ public void addConfigPath(String path, long modified)
+ {
+ configPaths.put(path, new Long(modified));
+ }
+
+ public Map getConfigPaths()
+ {
+ return configPaths;
+ }
+
+ /**
+ * Gets ActionScript source file for a class. The class will be compiled as
+ * a mixin and initialize Flex at runtime.
+ *
+ * @param packageName - the package compiled into the generated source.
+ * @param className - the class name of the generated source.
+ * @return A String that represents an ActionScript Source file.
+ */
+ public String getServicesInitSource(String packageName, String className)
+ {
+ StringBuilder sb = new StringBuilder(2048);
+
+ sb.append("package ").append(packageName).append("\n");
+ sb.append("{\n\n");
+ sb.append("import mx.core.IFlexModuleFactory;\n");
+ sb.append("import flash.net.registerClassAlias;\n");
+ sb.append("import flash.net.getClassByAlias;\n");
+
+ // generated imports
+ sb.append(getImports());
+
+ sb.append("\n[Mixin]\n");
+ sb.append("public class ").append(className).append("\n");
+ sb.append("{\n");
+ sb.append(" public function ").append(className).append("()\n");
+ sb.append(" {\n");
+ sb.append(" super();\n");
+ sb.append(" }\n\n");
+ sb.append(" public static function init(fbs:IFlexModuleFactory):void\n");
+ sb.append(" {\n");
+
+ // code for init
+ sb.append(getServerConfigXmlInit());
+ sb.append(" }\n\n");
+
+ // generated variables to create references
+ sb.append(getReferences());
+ sb.append("}\n");
+ sb.append("}\n");
+
+ return sb.toString();
+ }
+
+ public static ClientConfiguration getClientConfiguration(String path, String parserClass)
+ {
+ ClientConfiguration config = new ClientConfiguration();
+
+ ConfigurationParser parser = getConfigurationParser(parserClass);
+
+ if (parser == null)
+ {
+ // "Unable to create a parser to load messaging configuration."
+ LocalizedException lme = new LocalizedException();
+ lme.setMessage(10138);
+ throw lme;
+ }
+
+ LocalFileResolver local = new LocalFileResolver();
+ parser.parse(path, local, config);
+
+ config.addConfigPath(path, new File(path).lastModified());
+
+ return config;
+ }
+
+ static ConfigurationParser getConfigurationParser(String className)
+ {
+ ConfigurationParser parser = null;
+ Class parserClass = null;
+
+ // Check for Custom Parser Specification
+ if (className != null)
+ {
+ try
+ {
+ parserClass = Class.forName(className);
+ parser = (ConfigurationParser)parserClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ if (traceConfig)
+ {
+ System.out.println("Could not load services configuration parser as: " + className);
+ }
+ }
+ }
+
+ // Try Sun JRE 1.4 / Apache Xalan Based Implementation
+ if (parser == null)
+ {
+ try
+ {
+ Class.forName("org.apache.xpath.CachedXPathAPI");
+ className = "flex.messaging.config.ApacheXPathClientConfigurationParser";
+ parserClass = Class.forName(className);
+ parser = (ConfigurationParser)parserClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ if (traceConfig)
+ {
+ System.out.println("Could not load configuration parser as: " + className);
+ }
+ }
+ }
+
+ // Try Sun JRE 1.5 Based Implementation
+ if (parser == null)
+ {
+ try
+ {
+ className = "flex.messaging.config.XPathClientConfigurationParser";
+ parserClass = Class.forName(className);
+ // double-check, on some systems the above loads but the import classes don't
+ Class.forName("javax.xml.xpath.XPathExpressionException");
+
+ parser = (ConfigurationParser)parserClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ if (traceConfig)
+ {
+ System.out.println("Could not load configuration parser as: " + className);
+ }
+ }
+ }
+
+ if (traceConfig && parser != null)
+ {
+ System.out.println("Services Configuration Parser: " + parser.getClass().getName());
+ }
+
+ return parser;
+ }
+
+ private static List listChannelClasses(ServicesConfiguration config)
+ {
+ List channelList = new ArrayList();
+ Iterator it = config.getAllChannelSettings().values().iterator();
+ while (it.hasNext())
+ {
+ ChannelSettings settings = (ChannelSettings)it.next();
+ if (!settings.serverOnly)
+ {
+ String clientType = settings.getClientType();
+ channelList.add(clientType);
+ }
+ }
+
+ return channelList;
+ }
+
+ /**
+ * Emits source code declaration of public var xml:XML (unnamed package), containing ServicesConfiguration as e4x.
+ */
+ private String codegenXmlInit(ServicesConfiguration config, String contextRoot, Map serviceImportMap)
+ {
+ StringBuffer e4x = new StringBuffer();
+ String channelSetImplToImport = null;
+
+ e4x.append("<services>\n");
+
+ // Add default channels of the application
+ if (config.getDefaultChannels().size() > 0)
+ {
+ e4x.append("\t<default-channels>\n");
+ for (Iterator chanIter = config.getDefaultChannels().iterator(); chanIter.hasNext();)
+ {
+ String id = (String)chanIter.next();
+ e4x.append("\t\t<channel ref=\"" + id + "\"/>\n");
+ }
+ e4x.append("\t</default-channels>\n");
+ }
+
+ ClusterSettings defaultCluster = config.getDefaultCluster();
+ // Do not add the cluster tag if the default cluster does not have
+ // client side load balancing.
+ if (defaultCluster != null && !defaultCluster.getURLLoadBalancing())
+ defaultCluster = null;
+
+ for (Iterator servIter = config.getAllServiceSettings().iterator(); servIter.hasNext();)
+ {
+ ServiceSettings entry = (ServiceSettings)servIter.next();
+
+ // FIXME: Need to find another way to skip BootstrapServices
+ // Skip services with no message types
+ /*
+ String messageTypes = entry.getMessageTypesString();
+ if (messageTypes == null)
+ continue;
+ */
+
+ String serviceType = entry.getId();
+ e4x.append("\t<service id=\"");
+ e4x.append(serviceType);
+ e4x.append("\"");
+ e4x.append(">\n");
+
+ String serviceClass = entry.getClassName();
+ if (ADVANCED_MESSAGING_SUPPORT_CLASS.equals(serviceClass))
+ channelSetImplToImport = ADVANCED_CHANNELSET_CLASS;
+
+ String useTransactionsStr = entry.getProperties().getPropertyAsString("use-transactions", null);
+ if (useTransactionsStr != null)
+ {
+ e4x.append("\t\t<properties>\n\t\t\t<use-transactions>" + useTransactionsStr + "</use-transactions>\n");
+ e4x.append("\t\t</properties>\n");
+ }
+
+ for (Iterator destIter = entry.getDestinationSettings().values().iterator(); destIter.hasNext();)
+ {
+ DestinationSettings dest = (DestinationSettings) destIter.next();
+ String destination = dest.getId();
+ e4x.append("\t\t<destination id=\"" + destination + "\">\n");
+
+ // add in the identity properties
+ ConfigMap metadata = dest.getProperties().getPropertyAsMap("metadata", null);
+ boolean closePropTag = false;
+ if (metadata != null)
+ {
+ e4x.append("\t\t\t<properties>\n\t\t\t\t<metadata\n");
+ String extendsStr = metadata.getPropertyAsString("extends", null);
+ if (extendsStr != null)
+ {
+ e4x.append(" extends=\"");
+ e4x.append(extendsStr);
+ e4x.append("\"");
+ }
+ e4x.append(">");
+ closePropTag = true;
+ List identities = metadata.getPropertyAsList("identity", null);
+ if (identities != null)
+ {
+ Iterator it = identities.iterator();
+ while (it.hasNext())
+ {
+ Object o = it.next();
+ String identityName = null;
+ String undefinedValue = null;
+ if (o instanceof String)
+ {
+ identityName = (String) o;
+ }
+ else if (o instanceof ConfigMap)
+ {
+ identityName = ((ConfigMap) o).getPropertyAsString("property", null);
+ undefinedValue = ((ConfigMap) o).getPropertyAsString("undefined-value", null);
+ }
+
+ if (identityName != null)
+ {
+ e4x.append("\t\t\t\t\t<identity property=\"");
+ e4x.append(identityName);
+ e4x.append("\"");
+ if (undefinedValue != null)
+ {
+ e4x.append(" undefined-value=\"");
+ e4x.append(undefinedValue);
+ e4x.append("\"");
+ }
+ e4x.append("/>\n");
+ }
+ }
+ }
+ // add associations which reference other data service destinations
+ codegenServiceAssociations(metadata, e4x, destination, "one-to-many");
+ codegenServiceAssociations(metadata, e4x, destination, "many-to-many");
+ codegenServiceAssociations(metadata, e4x, destination, "one-to-one");
+ codegenServiceAssociations(metadata, e4x, destination, "many-to-one");
+
+ e4x.append("\t\t\t\t</metadata>\n");
+ }
+
+ String itemClass = dest.getProperties().getPropertyAsString("item-class", null);
+ if (itemClass != null)
+ {
+ if (!closePropTag)
+ {
+ e4x.append("\t\t\t<properties>\n");
+ closePropTag = true;
+ }
+
+ e4x.append("\t\t\t\t<item-class>");
+ e4x.append(itemClass);
+ e4x.append("</item-class>\n");
+ }
+
+ // add in sub-set of network-related destination properties
+ ConfigMap network = dest.getProperties().getPropertyAsMap("network", null);
+ ConfigMap clusterInfo = null;
+ ConfigMap pagingInfo = null;
+ ConfigMap reconnectInfo = null;
+ if (network != null || defaultCluster != null)
+ {
+ if (!closePropTag)
+ {
+ e4x.append("\t\t\t<properties>\n");
+ closePropTag = true;
+ }
+ e4x.append("\t\t\t\t<network>\n");
+
+ if (network != null)
+ pagingInfo = network.getPropertyAsMap("paging", null);
+ if (pagingInfo != null)
+ {
+ String enabled = pagingInfo.getPropertyAsString("enabled", "false");
+ e4x.append("\t\t\t\t\t<paging enabled=\"");
+ e4x.append(enabled);
+ e4x.append("\"");
+ // Always put page size even if it is disabled as we can
+ // end up using this for nested properties with lazy="true".
+ // supporting pageSize for backwards compatibility but config options are not camelCase in general.
+ String size = pagingInfo.getPropertyAsString("page-size", pagingInfo.getPropertyAsString("pageSize", null));
+ if (size != null)
+ {
+ e4x.append(" page-size=\"");
+ e4x.append(size);
+ e4x.append("\"");
+
+ // Included so that newer compilers can work with older clients
+ e4x.append(" pageSize=\"");
+ e4x.append(size);
+ e4x.append("\"");
+ }
+ e4x.append("/>\n");
+ }
+
+ if (network != null)
+ reconnectInfo = network.getPropertyAsMap("reconnect", null);
+ if (reconnectInfo != null)
+ {
+ String fetchOption = reconnectInfo.getPropertyAsString("fetch", "IDENTITY");
+ e4x.append("\t\t\t\t\t<reconnect fetch=\"");
+ e4x.append(fetchOption.toUpperCase());
+ e4x.append("\" />\n");
+ }
+
+ if (network != null)
+ {
+ String reliable = network.getPropertyAsString("reliable", "false");
+ if (Boolean.valueOf(reliable).booleanValue()) // No need the default value for the setting.
+ {
+ e4x.append("\t\t\t\t\t<reliable>");
+ e4x.append(reliable);
+ e4x.append("</reliable>\n");
+ }
+ }
+
+ if (network != null)
+ clusterInfo = network.getPropertyAsMap("cluster", null);
+ if (clusterInfo != null)
+ {
+ String clusterId = clusterInfo.getPropertyAsString("ref", null);
+
+ ClusterSettings clusterSettings = config.getClusterSettings(clusterId);
+ if (clusterSettings != null &&
+ clusterSettings.getURLLoadBalancing())
+ {
+ e4x.append("\t\t\t\t\t<cluster ref=\"");
+ e4x.append(clusterId);
+ e4x.append("\"/>\n");
+ }
+ }
+ else if (defaultCluster != null)
+ {
+ e4x.append("\t\t\t\t\t<cluster");
+ if (defaultCluster.getClusterName() != null)
+ {
+ e4x.append(" ref=\"");
+ e4x.append(defaultCluster.getClusterName());
+ e4x.append("\"");
+ }
+ e4x.append("/>\n");
+ }
+ e4x.append("\t\t\t\t</network>\n");
+ }
+
+ String useTransactions = dest.getProperties().getPropertyAsString("use-transactions", null);
+
+ if (useTransactions !=null)
+ {
+ if (!closePropTag)
+ {
+ e4x.append("\t\t\t<properties>\n");
+ closePropTag = true;
+ }
+ e4x.append("\t\t\t\t<use-transactions>" + useTransactions + "</use-transactions>\n");
+ }
+
+ String autoSyncEnabled = dest.getProperties().getPropertyAsString("auto-sync-enabled", "true");
+
+ if (autoSyncEnabled.equalsIgnoreCase("false"))
+ {
+ if (!closePropTag)
+ {
+ e4x.append("\t\t\t<properties>\n");
+ closePropTag = true;
+ }
+ e4x.append("\t\t\t\t<auto-sync-enabled>false</auto-sync-enabled>\n");
+ }
+
+ if (closePropTag)
+ {
+ e4x.append("\t\t\t</properties>\n");
+ }
+
+ e4x.append("\t\t\t<channels>\n");
+ for (Iterator chanIter = dest.getChannelSettings().iterator(); chanIter.hasNext();)
+ {
+ e4x.append("\t\t\t\t<channel ref=\"" + ((ChannelSettings) chanIter.next()).getId() + "\"/>\n");
+ }
+ e4x.append("\t\t\t</channels>\n");
+ e4x.append("\t\t</destination>\n");
+ }
+ e4x.append("\t</service>\n");
+ }
+ // channels
+ e4x.append("\t<channels>\n");
+ String channelType;
+ for (Iterator chanIter = config.getAllChannelSettings().values().iterator(); chanIter.hasNext();)
+ {
+ ChannelSettings chan = (ChannelSettings) chanIter.next();
+ if (chan.getServerOnly()) // Skip server-only channels.
+ continue;
+ channelType = chan.getClientType();
+ serviceImportMap.put(channelType, channelType);
+ e4x.append("\t\t<channel id=\"" + chan.getId() + "\" type=\"" + channelType + "\">\n");
+ StringBuffer channelProps = new StringBuffer();
+ containsClientLoadBalancing = false;
+ channelProperties(chan.getProperties(), channelProps, "\t\t\t\t");
+ if (!containsClientLoadBalancing) // Add the uri, only when there is no client-load-balancing defined.
+ e4x.append("\t\t\t<endpoint uri=\"" + chan.getClientParsedUri(contextRoot) + "\"/>\n");
+ containsClientLoadBalancing = false;
+ e4x.append("\t\t\t<properties>\n");
+ e4x.append(channelProps);
+ e4x.append("\t\t\t</properties>\n");
+ e4x.append("\t\t</channel>\n");
+ }
+ e4x.append("\t</channels>\n");
+ FlexClientSettings flexClientSettings = (config instanceof ClientConfiguration) ? ((ClientConfiguration)config).getFlexClientSettings() : null;
+ if (flexClientSettings != null && flexClientSettings.getHeartbeatIntervalMillis() > 0)
+ {
+ e4x.append("\t<flex-client>\n");
+ e4x.append("\t\t<heartbeat-interval-millis>");
+ e4x.append(flexClientSettings.getHeartbeatIntervalMillis());
+ e4x.append("</heartbeat-interval-millis>");
+ e4x.append("\t</flex-client>\n");
+ }
+ e4x.append("</services>");
+
+ StringBuffer advancedMessagingSupport = new StringBuffer();
+ if (channelSetImplToImport != null)
+ {
+ serviceImportMap.put("ChannelSetImpl", channelSetImplToImport);
+
+ // Codegen same class alias registration as is done by flex2.tools.Prelink#codegenRemoteClassAliases(Map<String,String>).
+ // This codegen isn't processed by PreLink.
+ String alias = "flex.messaging.messages.ReliabilityMessage";
+ String className = "mx.messaging.messages.ReliabilityMessage";
+ advancedMessagingSupport.append(" ServerConfig.channelSetFactory = AdvancedChannelSet;\n");
+ advancedMessagingSupport.append(" try {\n");
+ advancedMessagingSupport.append(" if (flash.net.getClassByAlias(\"" + alias + "\") == null){\n");
+ advancedMessagingSupport.append(" flash.net.registerClassAlias(\"" + alias + "\", " + className + ");}\n");
+ advancedMessagingSupport.append(" } catch (e:Error) {\n");
+ advancedMessagingSupport.append(" flash.net.registerClassAlias(\"" + alias + "\", " + className + "); }\n");
+ if (flexClientSettings != null && flexClientSettings.getReliableReconnectDurationMillis() > 0)
+ {
+ advancedMessagingSupport.append(" AdvancedChannelSet.reliableReconnectDuration =");
+ advancedMessagingSupport.append(flexClientSettings.getReliableReconnectDurationMillis());
+ advancedMessagingSupport.append(";\n");
+ }
+ }
+ String generatedChunk = "\n ServerConfig.xml =\n" + e4x.toString() + ";\n" + advancedMessagingSupport.toString();
+
+ return generatedChunk;
+ }
+
+ /**
+ * Process channel properties recursively.
+ */
+ private void channelProperties(ConfigMap properties, StringBuffer buf, String indent)
+ {
+ for (Iterator nameIter = properties.propertyNames().iterator(); nameIter.hasNext();)
+ {
+ String name = (String)nameIter.next();
+ Object value = properties.get(name);
+ if (value instanceof String)
+ {
+ addStringProperty(buf, indent, name, (String)value);
+ }
+ else if (value instanceof List)
+ {
+ List children = (List)value;
+ for (Iterator childrenIter = children.iterator(); childrenIter.hasNext();)
+ addStringProperty(buf, indent, name, (String)childrenIter.next());;
+ }
+ else if (value instanceof ConfigMap)
+ {
+ ConfigMap childProperties = (ConfigMap)value;
+ buf.append(indent);
+ buf.append("<" + name + ">\n");
+ if (ConfigurationConstants.CLIENT_LOAD_BALANCING_ELEMENT.equals(name))
+ containsClientLoadBalancing = true;
+ channelProperties(childProperties, buf, indent + "\t");
+ buf.append(indent);
+ buf.append("</" + name + ">\n");
+ }
+ }
+ }
+
+ private void addStringProperty(StringBuffer buf, String indent, String name, String value)
+ {
+ if (!channel_excludes.contains(name))
+ {
+ buf.append(indent);
+ buf.append("<" + name + ">" + value + "</" + name + ">\n");
+ }
+ }
+
+ /**
+ * Analyze code gen service associations.
+ * @param metadata the ConfigMap object
+ * @param e4x the buffer object
+ * @param destination the current destination
+ * @param relation the relationship
+ */
+ public void codegenServiceAssociations(ConfigMap metadata, StringBuffer e4x, String destination, String relation)
+ {
+ List references = metadata.getPropertyAsList(relation, null);
+ if (references != null)
+ {
+ Iterator it = references.iterator();
+ while (it.hasNext())
+ {
+ Object ref = it.next();
+ if (ref instanceof ConfigMap)
+ {
+ ConfigMap refMap = (ConfigMap) ref;
+ String name = refMap.getPropertyAsString("property", null);
+ String associatedDestination = refMap.getPropertyAsString("destination", null);
+ String lazy = refMap.getPropertyAsString("lazy", null);
+ String loadOnDemand = refMap.getPropertyAsString("load-on-demand", null);
+ String hierarchicalEvents = refMap.getPropertyAsString("hierarchical-events", null);
+ String pageSize = refMap.getPropertyAsString("page-size", refMap.getPropertyAsString("pageSize", null));
+ String pagedUpdates = refMap.getPropertyAsString("paged-updates", null);
+ String cascade = refMap.getPropertyAsString("cascade", null);
+ String ordered = refMap.getPropertyAsString("ordered", null);
+ e4x.append("\t\t\t\t\t<");
+ e4x.append(relation);
+ if (lazy != null)
+ {
+ e4x.append(" lazy=\"");
+ e4x.append(lazy);
+ e4x.append("\"");
+
+ if (Boolean.valueOf(lazy.toLowerCase().trim()).booleanValue())
+ {
+ addLazyAssociation(destination, name);
+ }
+ }
+ e4x.append(" property=\"");
+ e4x.append(name);
+ e4x.append("\" destination=\"");
+ e4x.append(associatedDestination);
+ e4x.append("\"");
+ String readOnly = refMap.getPropertyAsString("read-only", null);
+ if (readOnly != null && readOnly.equalsIgnoreCase("true"))
+ {
+ e4x.append(" read-only=\"true\"");
+ }
+ if (loadOnDemand != null && loadOnDemand.equalsIgnoreCase("true"))
+ e4x.append(" load-on-demand=\"true\"");
+ if (hierarchicalEvents != null && hierarchicalEvents.equalsIgnoreCase("true"))
+ e4x.append(" hierarchical-events=\"true\"");
+ if (pagedUpdates != null)
+ e4x.append(" paged-updates=\"" + pagedUpdates + "\"");
+ if (pageSize != null)
+ e4x.append(" page-size=\"" + pageSize + "\"");
+ if (cascade != null)
+ e4x.append(" cascade=\"" + cascade + "\"");
+ if (ordered != null)
+ e4x.append(" ordered=\"" + ordered + "\"");
+ e4x.append("/>\n");
+ }
+ }
+ }
+ }
+
+ /**
+ * This method will return an import and variable reference for channels specified in the map.
+ * @param map HashMap containing the client side channel type to be used, typically of the form
+ * "mx.messaging.channels.XXXXChannel", where the key and value are equal.
+ * @param imports StringBuffer of the imports needed for the given channel definitions
+ * @param references StringBuffer of the required references so that these classes will be linked in.
+ */
+ public static void codegenServiceImportsAndReferences(Map map, StringBuffer imports, StringBuffer references)
+ {
+ String channelSetImplType = (String)map.remove("ChannelSetImpl");
+ String type;
+ imports.append("import mx.messaging.config.ServerConfig;\n");
+ references.append(" // static references for configured channels\n");
+ for (Iterator chanIter = map.values().iterator(); chanIter.hasNext();)
+ {
+ type = (String)chanIter.next();
+ imports.append("import ");
+ imports.append(type);
+ imports.append(";\n");
+ references.append(" private static var ");
+ references.append(type.replace('.', '_'));
+ references.append("_ref:");
+ references.append(type.substring(type.lastIndexOf(".") +1) +";\n");
+ }
+ if (channelSetImplType != null)
+ imports.append("import mx.messaging.AdvancedChannelSet;\nimport mx.messaging.messages.ReliabilityMessage;\n");
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/TargetSettings.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/TargetSettings.java b/modules/common/src/flex/messaging/config/TargetSettings.java
old mode 100755
new mode 100644
index 9fb11d5..2382b49
--- a/modules/common/src/flex/messaging/config/TargetSettings.java
+++ b/modules/common/src/flex/messaging/config/TargetSettings.java
@@ -1,79 +1,79 @@
-/*
- * 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.config;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import flex.messaging.log.LogCategories;
-
-/**
- * A logging target must specify the class name
- * of the implementation, the level of logging events
- * it will accept, a list of filters for logging
- * categories it is interested in, and a collection of
- * properties required to initialize the target.
- *
- * @author Peter Farland
- * @exclude
- */
-public class TargetSettings extends PropertiesSettings
-{
- private String className;
- private String level;
- private List filters;
-
- public TargetSettings(String className)
- {
- this.className = className;
- }
-
- public String getClassName()
- {
- return className;
- }
-
- public String getLevel()
- {
- return level;
- }
-
- public void setLevel(String level)
- {
- this.level = level;
- }
-
- public List getFilters()
- {
- return filters;
- }
-
- public void addFilter(String filter)
- {
- if (filters == null)
- filters = new ArrayList();
-
- // Replace DataService with Service.Data for backwards compatibility,
- // excluding DataService.coldfusion.
- if (filter.startsWith("DataService") && !filter.equals("DataService.coldfusion"))
- filter = filter.replaceFirst("DataService", LogCategories.SERVICE_DATA);
-
- filters.add(filter);
- }
-
-
-}
+/*
+ * 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.config;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import flex.messaging.log.LogCategories;
+
+/**
+ * A logging target must specify the class name
+ * of the implementation, the level of logging events
+ * it will accept, a list of filters for logging
+ * categories it is interested in, and a collection of
+ * properties required to initialize the target.
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public class TargetSettings extends PropertiesSettings
+{
+ private String className;
+ private String level;
+ private List filters;
+
+ public TargetSettings(String className)
+ {
+ this.className = className;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public String getLevel()
+ {
+ return level;
+ }
+
+ public void setLevel(String level)
+ {
+ this.level = level;
+ }
+
+ public List getFilters()
+ {
+ return filters;
+ }
+
+ public void addFilter(String filter)
+ {
+ if (filters == null)
+ filters = new ArrayList();
+
+ // Replace DataService with Service.Data for backwards compatibility,
+ // excluding DataService.coldfusion.
+ if (filter.startsWith("DataService") && !filter.equals("DataService.coldfusion"))
+ filter = filter.replaceFirst("DataService", LogCategories.SERVICE_DATA);
+
+ filters.add(filter);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/TokenReplacer.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/TokenReplacer.java b/modules/common/src/flex/messaging/config/TokenReplacer.java
old mode 100755
new mode 100644
index c628051..c01f99e
--- a/modules/common/src/flex/messaging/config/TokenReplacer.java
+++ b/modules/common/src/flex/messaging/config/TokenReplacer.java
@@ -1,202 +1,202 @@
-/*
- * 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.config;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.util.StringUtils;
-
-/**
- * This class is used by configuration parser to replace tokens of the format
- * {...} with actual values. The value can either come from a JVM property
- * (eg. -Dmy.channel.id=my-amf) or from a token properties file specified via
- * token.file JVM property (eg. -Dtoken.file=/usr/local/tokens.properties) where
- * the token key and value are specified in the property file.
- *
- * If a token value is both specified as a JVM property and inside the token.file,
- * JVM property takes precedence.
- *
- * @exclude
- */
-public class TokenReplacer
-{
- private static final String TOKEN_FILE = "token.file";
- private static final Pattern pattern = Pattern.compile("\\{(.*?)\\}");
-
- private final Map replacedTokens;
- private Properties tokenProperties;
- private String tokenPropertiesFilename;
-
- /**
- * Default constructor.
- */
- public TokenReplacer()
- {
- replacedTokens = new LinkedHashMap();
- loadTokenProperties();
- }
-
- /**
- * Replace any tokens in the value of the node or the text child of the node.
- *
- * @param node The node whose value will be searched for tokens.
- * @param sourceFileName The source file where the node came from.
- */
- public void replaceToken(Node node, String sourceFileName)
- {
- // Exit if we are attempting to replace one of the forbidden nodes - nodes
- // that may have curly brackets as part of their syntax
- if (ConfigurationConstants.IP_ADDRESS_PATTERN.equals(node.getNodeName()))
- return;
-
- // ReplacementNode is either the original node if it has a value or the text
- // child of the node if it does not have a value
- Node replacementNode;
- if (node.getNodeValue() == null)
- {
- if (node.getChildNodes().getLength() == 1 && node.getFirstChild() instanceof Text)
- replacementNode = node.getFirstChild();
- else
- return;
- }
- else
- {
- replacementNode = node;
- }
-
- String nodeValue = replacementNode.getNodeValue();
- Matcher matcher = pattern.matcher(nodeValue);
- while (matcher.find()) // Means the node value has token(s)
- {
- String tokenWithCurlyBraces = matcher.group();
- String tokenWithoutCurlyBraces = matcher.group(1);
- String propertyValue = getPropertyValue(tokenWithoutCurlyBraces);
- if (propertyValue != null)
- {
- nodeValue = StringUtils.substitute(nodeValue, tokenWithCurlyBraces, propertyValue);
- replacedTokens.put(tokenWithCurlyBraces, propertyValue);
- }
- // context-path, server-name and server-port tokens can be replaced
- // later, therefore, no warning is necessary if they cannot be replaced
- // at this point.
- else if (!ConfigurationConstants.CONTEXT_PATH_TOKEN.equals(tokenWithCurlyBraces)
- && !ConfigurationConstants.CONTEXT_PATH_ALT_TOKEN.equals(tokenWithCurlyBraces)
- && !ConfigurationConstants.SERVER_NAME_TOKEN.equals(tokenWithCurlyBraces)
- && !ConfigurationConstants.SERVER_PORT_TOKEN.equals(tokenWithCurlyBraces))
- {
- // Token ''{0}'' in ''{1}'' was not replaced. Either supply a value to this token with a JVM option, or remove it from the configuration.
- ConfigurationException ex = new ConfigurationException();
- Object[] args = {tokenWithCurlyBraces, sourceFileName};
- ex.setMessage(ConfigurationConstants.IRREPLACABLE_TOKEN, args);
- throw ex;
- }
- }
- replacementNode.setNodeValue(nodeValue);
- }
-
- /**
- * See if the token have a value either provided as a JVM property or as
- * part of the token property file. JVM property takes precedence on the token
- * property file.
- */
- private String getPropertyValue(String tokenWithoutCurlyBraces)
- {
- String propertyValue = System.getProperty(tokenWithoutCurlyBraces);
- if (propertyValue != null)
- return propertyValue;
-
- if (tokenProperties != null)
- propertyValue = tokenProperties.getProperty(tokenWithoutCurlyBraces);
-
- return propertyValue;
- }
-
- /**
- * Used by the parser to report the replaced tokens once logging is setup.
- */
- public void reportTokens()
- {
- if (Log.isWarn())
- {
- if (tokenProperties != null && Log.isDebug())
- Log.getLogger(LogCategories.CONFIGURATION).debug("Token replacer is using the token file '" + tokenPropertiesFilename + "'");
-
- for (Iterator iter = replacedTokens.entrySet().iterator(); iter.hasNext();)
- {
- Map.Entry entry = (Map.Entry)iter.next();
- String tokenWithParanthesis = (String)entry.getKey();
- String propertyValue = (String)entry.getValue();
- // Issue a special warning for context.root replacements,
- if (ConfigurationConstants.CONTEXT_PATH_TOKEN.equals(tokenWithParanthesis)
- || ConfigurationConstants.CONTEXT_PATH_ALT_TOKEN.equals(tokenWithParanthesis))
- {
- Log.getLogger(LogCategories.CONFIGURATION).warn("Token '{0}' was replaced with '{1}'. Note that this will apply to all applications on the JVM",
- new Object[]{tokenWithParanthesis, propertyValue});
- }
- else if (Log.isDebug())
- {
- Log.getLogger(LogCategories.CONFIGURATION).debug("Token '{0}' was replaced with '{1}'", new Object[]{tokenWithParanthesis, propertyValue});
- }
- }
- }
- }
-
- /**
- * Given a String, determines whether the string contains tokens.
- *
- * @param value The String to check.
- * @return True if the String contains tokens.
- */
- public static boolean containsTokens(String value)
- {
- return (value != null && value.length() > 0)? pattern.matcher(value).find() : false;
- }
-
- private void loadTokenProperties()
- {
- tokenPropertiesFilename = System.getProperty(TOKEN_FILE);
- if (tokenPropertiesFilename == null)
- return;
-
- tokenProperties = new Properties();
- try
- {
- tokenProperties.load(new FileInputStream(tokenPropertiesFilename));
- }
- catch (FileNotFoundException e)
- {
- tokenProperties = null;
- }
- catch (IOException e)
- {
- tokenProperties = null;
- }
- }
-}
+/*
+ * 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.config;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.util.StringUtils;
+
+/**
+ * This class is used by configuration parser to replace tokens of the format
+ * {...} with actual values. The value can either come from a JVM property
+ * (eg. -Dmy.channel.id=my-amf) or from a token properties file specified via
+ * token.file JVM property (eg. -Dtoken.file=/usr/local/tokens.properties) where
+ * the token key and value are specified in the property file.
+ *
+ * If a token value is both specified as a JVM property and inside the token.file,
+ * JVM property takes precedence.
+ *
+ * @exclude
+ */
+public class TokenReplacer
+{
+ private static final String TOKEN_FILE = "token.file";
+ private static final Pattern pattern = Pattern.compile("\\{(.*?)\\}");
+
+ private final Map replacedTokens;
+ private Properties tokenProperties;
+ private String tokenPropertiesFilename;
+
+ /**
+ * Default constructor.
+ */
+ public TokenReplacer()
+ {
+ replacedTokens = new LinkedHashMap();
+ loadTokenProperties();
+ }
+
+ /**
+ * Replace any tokens in the value of the node or the text child of the node.
+ *
+ * @param node The node whose value will be searched for tokens.
+ * @param sourceFileName The source file where the node came from.
+ */
+ public void replaceToken(Node node, String sourceFileName)
+ {
+ // Exit if we are attempting to replace one of the forbidden nodes - nodes
+ // that may have curly brackets as part of their syntax
+ if (ConfigurationConstants.IP_ADDRESS_PATTERN.equals(node.getNodeName()))
+ return;
+
+ // ReplacementNode is either the original node if it has a value or the text
+ // child of the node if it does not have a value
+ Node replacementNode;
+ if (node.getNodeValue() == null)
+ {
+ if (node.getChildNodes().getLength() == 1 && node.getFirstChild() instanceof Text)
+ replacementNode = node.getFirstChild();
+ else
+ return;
+ }
+ else
+ {
+ replacementNode = node;
+ }
+
+ String nodeValue = replacementNode.getNodeValue();
+ Matcher matcher = pattern.matcher(nodeValue);
+ while (matcher.find()) // Means the node value has token(s)
+ {
+ String tokenWithCurlyBraces = matcher.group();
+ String tokenWithoutCurlyBraces = matcher.group(1);
+ String propertyValue = getPropertyValue(tokenWithoutCurlyBraces);
+ if (propertyValue != null)
+ {
+ nodeValue = StringUtils.substitute(nodeValue, tokenWithCurlyBraces, propertyValue);
+ replacedTokens.put(tokenWithCurlyBraces, propertyValue);
+ }
+ // context-path, server-name and server-port tokens can be replaced
+ // later, therefore, no warning is necessary if they cannot be replaced
+ // at this point.
+ else if (!ConfigurationConstants.CONTEXT_PATH_TOKEN.equals(tokenWithCurlyBraces)
+ && !ConfigurationConstants.CONTEXT_PATH_ALT_TOKEN.equals(tokenWithCurlyBraces)
+ && !ConfigurationConstants.SERVER_NAME_TOKEN.equals(tokenWithCurlyBraces)
+ && !ConfigurationConstants.SERVER_PORT_TOKEN.equals(tokenWithCurlyBraces))
+ {
+ // Token ''{0}'' in ''{1}'' was not replaced. Either supply a value to this token with a JVM option, or remove it from the configuration.
+ ConfigurationException ex = new ConfigurationException();
+ Object[] args = {tokenWithCurlyBraces, sourceFileName};
+ ex.setMessage(ConfigurationConstants.IRREPLACABLE_TOKEN, args);
+ throw ex;
+ }
+ }
+ replacementNode.setNodeValue(nodeValue);
+ }
+
+ /**
+ * See if the token have a value either provided as a JVM property or as
+ * part of the token property file. JVM property takes precedence on the token
+ * property file.
+ */
+ private String getPropertyValue(String tokenWithoutCurlyBraces)
+ {
+ String propertyValue = System.getProperty(tokenWithoutCurlyBraces);
+ if (propertyValue != null)
+ return propertyValue;
+
+ if (tokenProperties != null)
+ propertyValue = tokenProperties.getProperty(tokenWithoutCurlyBraces);
+
+ return propertyValue;
+ }
+
+ /**
+ * Used by the parser to report the replaced tokens once logging is setup.
+ */
+ public void reportTokens()
+ {
+ if (Log.isWarn())
+ {
+ if (tokenProperties != null && Log.isDebug())
+ Log.getLogger(LogCategories.CONFIGURATION).debug("Token replacer is using the token file '" + tokenPropertiesFilename + "'");
+
+ for (Iterator iter = replacedTokens.entrySet().iterator(); iter.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)iter.next();
+ String tokenWithParanthesis = (String)entry.getKey();
+ String propertyValue = (String)entry.getValue();
+ // Issue a special warning for context.root replacements,
+ if (ConfigurationConstants.CONTEXT_PATH_TOKEN.equals(tokenWithParanthesis)
+ || ConfigurationConstants.CONTEXT_PATH_ALT_TOKEN.equals(tokenWithParanthesis))
+ {
+ Log.getLogger(LogCategories.CONFIGURATION).warn("Token '{0}' was replaced with '{1}'. Note that this will apply to all applications on the JVM",
+ new Object[]{tokenWithParanthesis, propertyValue});
+ }
+ else if (Log.isDebug())
+ {
+ Log.getLogger(LogCategories.CONFIGURATION).debug("Token '{0}' was replaced with '{1}'", new Object[]{tokenWithParanthesis, propertyValue});
+ }
+ }
+ }
+ }
+
+ /**
+ * Given a String, determines whether the string contains tokens.
+ *
+ * @param value The String to check.
+ * @return True if the String contains tokens.
+ */
+ public static boolean containsTokens(String value)
+ {
+ return (value != null && value.length() > 0)? pattern.matcher(value).find() : false;
+ }
+
+ private void loadTokenProperties()
+ {
+ tokenPropertiesFilename = System.getProperty(TOKEN_FILE);
+ if (tokenPropertiesFilename == null)
+ return;
+
+ tokenProperties = new Properties();
+ try
+ {
+ tokenProperties.load(new FileInputStream(tokenPropertiesFilename));
+ }
+ catch (FileNotFoundException e)
+ {
+ tokenProperties = null;
+ }
+ catch (IOException e)
+ {
+ tokenProperties = null;
+ }
+ }
+}
[15/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/NetworkSettings.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/NetworkSettings.java b/modules/core/src/flex/messaging/config/NetworkSettings.java
old mode 100755
new mode 100644
index 916ada0..8cf22b6
--- a/modules/core/src/flex/messaging/config/NetworkSettings.java
+++ b/modules/core/src/flex/messaging/config/NetworkSettings.java
@@ -1,165 +1,165 @@
-/*
- * 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.config;
-
-/**
- * Network policy settings for a MessageDestination.
- *
- * @author neville
- */
-public class NetworkSettings
-{
- protected String clusterId;
- protected ThrottleSettings throttleSettings;
- protected int subscriptionTimeoutMinutes;
- // This is the more common case so make it the default
- protected boolean sharedBackend = true;
- private boolean sharedBackendSet = false;
- private boolean reliable;
-
- public static final String NETWORK_ELEMENT = "network";
- public static final String RELIABLE_ELEMENT = "reliable";
- public static final String SUBSCRIPTION_TIMEOUT_MINUTES = "subscription-timeout-minutes";
- public static final String SESSION_TIMEOUT = "session-timeout"; // Deprecated - renamed to subscription-timeout-minutes; retained for legacy config support.
- public static final int DEFAULT_TIMEOUT = 0; // Defaults to being invalidated when the associated FlexSession shuts down.
-
- /**
- * Constructs a default <code>NetworkSettings</code> instance with
- * default session timeout.
- */
- public NetworkSettings()
- {
- throttleSettings = new ThrottleSettings();
- subscriptionTimeoutMinutes = DEFAULT_TIMEOUT;
- }
-
- /**
- * Returns the cluster id.
- *
- * @return The cluster id.
- */
- public String getClusterId()
- {
- return clusterId;
- }
-
- /**
- * Sets the cluster id.
- *
- * @param id The cluster id.
- */
- public void setClusterId(String id)
- {
- this.clusterId = id;
- }
-
- /**
- * Returns the <code>reliable</code> setting.
- *
- * @return The <code>reliable</code> setting.
- */
- public boolean isReliable()
- {
- return reliable;
- }
-
- /**
- * Sets the <code>reliable</code> setting.
- *
- * @param value The value to set the <code>reliable</code> setting to.
- */
- public void setReliable(boolean value)
- {
- reliable = value;
- }
-
- /**
- * Returns the <code>subscription-timeout-minutes</code> property.
- *
- * @return the <code>subscription-timeout-minutes</code> property.
- */
- public int getSubscriptionTimeoutMinutes()
- {
- return subscriptionTimeoutMinutes;
- }
-
- /**
- * Sets the <code>subscription-timeout-minutes</code> property which is the idle time in
- * minutes before a subscriber that no messages are being pushed to will be unsubscribed.
- * A value of 0 will cause subscriptions to be kept alive as long as the associated FlexSession
- * they are created over is active.
- *
- * @param value The value to set the <code>subscription-timeout-minutes</code> property to.
- */
- public void setSubscriptionTimeoutMinutes(int value)
- {
- subscriptionTimeoutMinutes = value;
- }
-
- /**
- * Returns the <code>shared-backend</code> property.
- *
- * @return the <code>shared-backend</code> property.
- */
- public boolean isSharedBackend()
- {
- return sharedBackend;
- }
-
- /**
- * Sets the <code>shared-backend</code> property.
- *
- * @param sharedBackend The value to set the <code>shared-backend</code> property to.
- */
- public void setSharedBackend(boolean sharedBackend)
- {
- this.sharedBackend = sharedBackend;
- this.sharedBackendSet = true;
- }
-
- /**
- * Returns true if the shared backend has been set or false if it is
- * still using the default.
- *
- * @return <code>true</code> if the shared backend has been set; <code>false</code> otherwise.
- */
- public boolean isSharedBackendSet()
- {
- return sharedBackendSet;
- }
-
- /**
- * Returns the <code>ThrottleSettings</code> property.
- *
- * @return the <code>ThrottleSettings</code> property.
- */
- public ThrottleSettings getThrottleSettings()
- {
- return throttleSettings;
- }
-
- /**
- * Sets the <code>ThrottleSettings</code> property.
- *
- * @param value The value to set the <code>ThrottleSettings</code> property to.
- */
- public void setThrottleSettings(ThrottleSettings value)
- {
- throttleSettings = value;
- }
-
-}
+/*
+ * 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.config;
+
+/**
+ * Network policy settings for a MessageDestination.
+ *
+ * @author neville
+ */
+public class NetworkSettings
+{
+ protected String clusterId;
+ protected ThrottleSettings throttleSettings;
+ protected int subscriptionTimeoutMinutes;
+ // This is the more common case so make it the default
+ protected boolean sharedBackend = true;
+ private boolean sharedBackendSet = false;
+ private boolean reliable;
+
+ public static final String NETWORK_ELEMENT = "network";
+ public static final String RELIABLE_ELEMENT = "reliable";
+ public static final String SUBSCRIPTION_TIMEOUT_MINUTES = "subscription-timeout-minutes";
+ public static final String SESSION_TIMEOUT = "session-timeout"; // Deprecated - renamed to subscription-timeout-minutes; retained for legacy config support.
+ public static final int DEFAULT_TIMEOUT = 0; // Defaults to being invalidated when the associated FlexSession shuts down.
+
+ /**
+ * Constructs a default <code>NetworkSettings</code> instance with
+ * default session timeout.
+ */
+ public NetworkSettings()
+ {
+ throttleSettings = new ThrottleSettings();
+ subscriptionTimeoutMinutes = DEFAULT_TIMEOUT;
+ }
+
+ /**
+ * Returns the cluster id.
+ *
+ * @return The cluster id.
+ */
+ public String getClusterId()
+ {
+ return clusterId;
+ }
+
+ /**
+ * Sets the cluster id.
+ *
+ * @param id The cluster id.
+ */
+ public void setClusterId(String id)
+ {
+ this.clusterId = id;
+ }
+
+ /**
+ * Returns the <code>reliable</code> setting.
+ *
+ * @return The <code>reliable</code> setting.
+ */
+ public boolean isReliable()
+ {
+ return reliable;
+ }
+
+ /**
+ * Sets the <code>reliable</code> setting.
+ *
+ * @param value The value to set the <code>reliable</code> setting to.
+ */
+ public void setReliable(boolean value)
+ {
+ reliable = value;
+ }
+
+ /**
+ * Returns the <code>subscription-timeout-minutes</code> property.
+ *
+ * @return the <code>subscription-timeout-minutes</code> property.
+ */
+ public int getSubscriptionTimeoutMinutes()
+ {
+ return subscriptionTimeoutMinutes;
+ }
+
+ /**
+ * Sets the <code>subscription-timeout-minutes</code> property which is the idle time in
+ * minutes before a subscriber that no messages are being pushed to will be unsubscribed.
+ * A value of 0 will cause subscriptions to be kept alive as long as the associated FlexSession
+ * they are created over is active.
+ *
+ * @param value The value to set the <code>subscription-timeout-minutes</code> property to.
+ */
+ public void setSubscriptionTimeoutMinutes(int value)
+ {
+ subscriptionTimeoutMinutes = value;
+ }
+
+ /**
+ * Returns the <code>shared-backend</code> property.
+ *
+ * @return the <code>shared-backend</code> property.
+ */
+ public boolean isSharedBackend()
+ {
+ return sharedBackend;
+ }
+
+ /**
+ * Sets the <code>shared-backend</code> property.
+ *
+ * @param sharedBackend The value to set the <code>shared-backend</code> property to.
+ */
+ public void setSharedBackend(boolean sharedBackend)
+ {
+ this.sharedBackend = sharedBackend;
+ this.sharedBackendSet = true;
+ }
+
+ /**
+ * Returns true if the shared backend has been set or false if it is
+ * still using the default.
+ *
+ * @return <code>true</code> if the shared backend has been set; <code>false</code> otherwise.
+ */
+ public boolean isSharedBackendSet()
+ {
+ return sharedBackendSet;
+ }
+
+ /**
+ * Returns the <code>ThrottleSettings</code> property.
+ *
+ * @return the <code>ThrottleSettings</code> property.
+ */
+ public ThrottleSettings getThrottleSettings()
+ {
+ return throttleSettings;
+ }
+
+ /**
+ * Sets the <code>ThrottleSettings</code> property.
+ *
+ * @param value The value to set the <code>ThrottleSettings</code> property to.
+ */
+ public void setThrottleSettings(ThrottleSettings value)
+ {
+ throttleSettings = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/SecuritySettings.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/SecuritySettings.java b/modules/core/src/flex/messaging/config/SecuritySettings.java
old mode 100755
new mode 100644
index eec6179..22ca8b5
--- a/modules/core/src/flex/messaging/config/SecuritySettings.java
+++ b/modules/core/src/flex/messaging/config/SecuritySettings.java
@@ -1,104 +1,104 @@
-/*
- * 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.config;
-
-import flex.messaging.security.SecurityException;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Peter Farland
- * @exclude
- */
-public class SecuritySettings
-{
- // Exception/error message numbers.
- private static final int NO_SEC_CONSTRAINT = 10062;
-
- private String serverInfo;
- private Map loginCommandSettings;
- private Map constraints;
- private boolean recreateHttpSessionAfterLogin;
-
- public SecuritySettings()
- {
- constraints = new HashMap();
- loginCommandSettings = new HashMap();
- }
-
- public void addConstraint(SecurityConstraint sc)
- {
- constraints.put(sc.getId(), sc);
- }
-
- public SecurityConstraint getConstraint(String ref)
- {
- // If an attempt is made to use a constraint that we do not know about,
- // do not let the authorization succeed
- if (constraints.get(ref) == null)
- {
- // Security constraint {0} is not defined.
- SecurityException se = new SecurityException();
- se.setMessage(NO_SEC_CONSTRAINT, new Object[] {ref});
- throw se;
- }
- return (SecurityConstraint)constraints.get(ref);
- }
-
- public void addLoginCommandSettings(LoginCommandSettings lcs)
- {
- loginCommandSettings.put(lcs.getServer(), lcs);
- }
-
- public Map getLoginCommands()
- {
- return loginCommandSettings;
- }
-
- /**
- * Returns a read-only set of constraints.
- *
- * @return the set of security constraints
- */
- public Collection<SecurityConstraint> getConstraints()
- {
- return Collections.unmodifiableCollection(constraints.values());
- }
-
- public void setServerInfo(String s)
- {
- serverInfo = s;
- }
-
- public String getServerInfo()
- {
- return serverInfo;
- }
-
- public boolean isRecreateHttpSessionAfterLogin()
- {
- return recreateHttpSessionAfterLogin;
- }
-
- public void setRecreateHttpSessionAfterLogin(boolean value)
- {
- recreateHttpSessionAfterLogin = value;
- }
-}
+/*
+ * 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.config;
+
+import flex.messaging.security.SecurityException;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Peter Farland
+ * @exclude
+ */
+public class SecuritySettings
+{
+ // Exception/error message numbers.
+ private static final int NO_SEC_CONSTRAINT = 10062;
+
+ private String serverInfo;
+ private Map loginCommandSettings;
+ private Map constraints;
+ private boolean recreateHttpSessionAfterLogin;
+
+ public SecuritySettings()
+ {
+ constraints = new HashMap();
+ loginCommandSettings = new HashMap();
+ }
+
+ public void addConstraint(SecurityConstraint sc)
+ {
+ constraints.put(sc.getId(), sc);
+ }
+
+ public SecurityConstraint getConstraint(String ref)
+ {
+ // If an attempt is made to use a constraint that we do not know about,
+ // do not let the authorization succeed
+ if (constraints.get(ref) == null)
+ {
+ // Security constraint {0} is not defined.
+ SecurityException se = new SecurityException();
+ se.setMessage(NO_SEC_CONSTRAINT, new Object[] {ref});
+ throw se;
+ }
+ return (SecurityConstraint)constraints.get(ref);
+ }
+
+ public void addLoginCommandSettings(LoginCommandSettings lcs)
+ {
+ loginCommandSettings.put(lcs.getServer(), lcs);
+ }
+
+ public Map getLoginCommands()
+ {
+ return loginCommandSettings;
+ }
+
+ /**
+ * Returns a read-only set of constraints.
+ *
+ * @return the set of security constraints
+ */
+ public Collection<SecurityConstraint> getConstraints()
+ {
+ return Collections.unmodifiableCollection(constraints.values());
+ }
+
+ public void setServerInfo(String s)
+ {
+ serverInfo = s;
+ }
+
+ public String getServerInfo()
+ {
+ return serverInfo;
+ }
+
+ public boolean isRecreateHttpSessionAfterLogin()
+ {
+ return recreateHttpSessionAfterLogin;
+ }
+
+ public void setRecreateHttpSessionAfterLogin(boolean value)
+ {
+ recreateHttpSessionAfterLogin = value;
+ }
+}
[42/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/log/LogCategories.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/log/LogCategories.java b/modules/common/src/flex/messaging/log/LogCategories.java
old mode 100755
new mode 100644
index 3f6945b..5267ba2
--- a/modules/common/src/flex/messaging/log/LogCategories.java
+++ b/modules/common/src/flex/messaging/log/LogCategories.java
@@ -1,112 +1,112 @@
-/*
- * 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.log;
-
-/**
- * @exclude
- *
- * This class contains all the log categories used in our classes. When adding
- * a new log category, make sure the sample configuration file is updated
- * as well.
- *
- */
-public interface LogCategories
-{
- String CLIENT_FLEXCLIENT = "Client.FlexClient";
- String CLIENT_FLEXCLIENT_ADAPTIVE = "Client.FlexClient.Adaptive";
- String CLIENT_MESSAGECLIENT = "Client.MessageClient";
-
- String CONFIGURATION = "Configuration";
- String CONFIGURATION_SPRING = "Configuration.Spring";
-
- String ENDPOINT_GENERAL = "Endpoint.General";
- String ENDPOINT_AMF = "Endpoint.AMF";
- String ENDPOINT_NIO_AMF = "Endpoint.NIOAMF";
- String ENDPOINT_FLEXSESSION = "Endpoint.FlexSession";
- String ENDPOINT_GATEWAY = "Endpoint.Gateway";
- String ENDPOINT_HTTP = "Endpoint.HTTP";
- String ENDPOINT_NIO_HTTP = "Endpoint.NIOHTTP";
- String ENDPOINT_RTMP = "Endpoint.RTMP";
- String ENDPOINT_STREAMING_AMF = "Endpoint.StreamingAMF";
- String ENDPOINT_STREAMING_NIO_AMF = "Endpoint.StreamingNIOAMF";
- String ENDPOINT_STREAMING_HTTP = "Endpoint.StreamingHTTP";
- String ENDPOINT_STREAMING_NIO_HTTP = "Endpoint.StreamingNIOHTTP";
- String ENDPOINT_WEBSOCKET_NIO_AMF = "Endpoint.WebSocketNIOAMF";
- String ENDPOINT_TYPE = "Endpoint.Type";
-
- String EXECUTOR = "Executor";
-
- String MANAGEMENT_GENERAL = "Management.General";
- String MANAGEMENT_MBEANSERVER = "Management.MBeanServer";
-
- String MESSAGE_GENERAL = "Message.General";
- String MESSAGE_COMMAND = "Message.Command";
- String MESSAGE_DATA = "Message.Data";
- String MESSAGE_FILTER = "Message.Filter";
- String MESSAGE_REMOTING = "Message.Remoting";
- String MESSAGE_RPC = "Message.RPC";
- String MESSAGE_SELECTOR = "Message.Selector";
- String MESSAGE_TIMING = "Message.Timing";
-
- String PROTOCOL_AMFSOCKET = "Protocol.AMFSocket";
- String PROTOCOL_HTTP = "Protocol.HTTP";
- String PROTOCOL_RTMP = "Protocol.RTMP";
- String PROTOCOL_RTMPT = "Protocol.RTMPT";
-
- String RESOURCE = "Resource";
-
- String SERVICE_GENERAL = "Service.General";
- String SERVICE_CLUSTER = "Service.Cluster";
- String SERVICE_COLLABORATION = "Service.Collaboration";
- String SERVICE_DATA = "Service.Data"; // Not a category but used by TargetSettings to replace DataService
- String SERVICE_DATA_GENERAL = "Service.Data.General";
- String SERVICE_DATA_HIBERNATE = "Service.Data.Hibernate";
- String SERVICE_DATA_SQL = "Service.Data.SQL";
- String SERVICE_DATA_TRANSACTION = "Service.Data.Transaction";
- String SERVICE_ADVANCED_MESSAGING = "Service.AdvancedMessaging";
- String SERVICE_NOTIFICATION = "Service.Notification";
- String SERVICE_GATEWAY = "Service.Gateway";
- String SERVICE_GATEWAY_CONNECTOR = "Service.Gateway.Connector";
- String SERVICE_HTTP = "Service.HTTP";
- String SERVICE_MESSAGE = "Service.Message";
- String SERVICE_MESSAGE_JMS = "Service.Message.JMS";
- String SERVICE_REMOTING = "Service.Remoting";
-
- String SECURITY = "Security";
-
- String SOCKET_SERVER_GENERAL = "SocketServer.General";
- String SOCKET_SERVER_BYTE_BUFFER_MANAGEMENT = "SocketServer.ByteBufferManagement";
-
- String SSL = "SSL";
-
- String STARTUP_MESSAGEBROKER = "Startup.MessageBroker";
- String STARTUP_SERVICE = "Startup.Service";
- String STARTUP_DESTINATION = "Startup.Destination";
-
- String TIMEOUT = "Timeout";
-
- String TRANSPORT_RELIABLE = "Transport.Reliable";
- String TRANSPORT_THROTTLE = "Transport.Throttle";
- String TRANSPORT_THROTTLE_BUFFER = "Transport.Throttle.Buffer";
- String TRANSPORT_THROTTLE_CONFLATE = "Transport.Throttle.Conflate";
-
- String WSRP_GENERAL = "WSRP.General";
-
- String RDS = "RDS";
-
- String FBSERVICES_INTROSPECTION = "FBServices.Introspection";
-}
+/*
+ * 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.log;
+
+/**
+ * @exclude
+ *
+ * This class contains all the log categories used in our classes. When adding
+ * a new log category, make sure the sample configuration file is updated
+ * as well.
+ *
+ */
+public interface LogCategories
+{
+ String CLIENT_FLEXCLIENT = "Client.FlexClient";
+ String CLIENT_FLEXCLIENT_ADAPTIVE = "Client.FlexClient.Adaptive";
+ String CLIENT_MESSAGECLIENT = "Client.MessageClient";
+
+ String CONFIGURATION = "Configuration";
+ String CONFIGURATION_SPRING = "Configuration.Spring";
+
+ String ENDPOINT_GENERAL = "Endpoint.General";
+ String ENDPOINT_AMF = "Endpoint.AMF";
+ String ENDPOINT_NIO_AMF = "Endpoint.NIOAMF";
+ String ENDPOINT_FLEXSESSION = "Endpoint.FlexSession";
+ String ENDPOINT_GATEWAY = "Endpoint.Gateway";
+ String ENDPOINT_HTTP = "Endpoint.HTTP";
+ String ENDPOINT_NIO_HTTP = "Endpoint.NIOHTTP";
+ String ENDPOINT_RTMP = "Endpoint.RTMP";
+ String ENDPOINT_STREAMING_AMF = "Endpoint.StreamingAMF";
+ String ENDPOINT_STREAMING_NIO_AMF = "Endpoint.StreamingNIOAMF";
+ String ENDPOINT_STREAMING_HTTP = "Endpoint.StreamingHTTP";
+ String ENDPOINT_STREAMING_NIO_HTTP = "Endpoint.StreamingNIOHTTP";
+ String ENDPOINT_WEBSOCKET_NIO_AMF = "Endpoint.WebSocketNIOAMF";
+ String ENDPOINT_TYPE = "Endpoint.Type";
+
+ String EXECUTOR = "Executor";
+
+ String MANAGEMENT_GENERAL = "Management.General";
+ String MANAGEMENT_MBEANSERVER = "Management.MBeanServer";
+
+ String MESSAGE_GENERAL = "Message.General";
+ String MESSAGE_COMMAND = "Message.Command";
+ String MESSAGE_DATA = "Message.Data";
+ String MESSAGE_FILTER = "Message.Filter";
+ String MESSAGE_REMOTING = "Message.Remoting";
+ String MESSAGE_RPC = "Message.RPC";
+ String MESSAGE_SELECTOR = "Message.Selector";
+ String MESSAGE_TIMING = "Message.Timing";
+
+ String PROTOCOL_AMFSOCKET = "Protocol.AMFSocket";
+ String PROTOCOL_HTTP = "Protocol.HTTP";
+ String PROTOCOL_RTMP = "Protocol.RTMP";
+ String PROTOCOL_RTMPT = "Protocol.RTMPT";
+
+ String RESOURCE = "Resource";
+
+ String SERVICE_GENERAL = "Service.General";
+ String SERVICE_CLUSTER = "Service.Cluster";
+ String SERVICE_COLLABORATION = "Service.Collaboration";
+ String SERVICE_DATA = "Service.Data"; // Not a category but used by TargetSettings to replace DataService
+ String SERVICE_DATA_GENERAL = "Service.Data.General";
+ String SERVICE_DATA_HIBERNATE = "Service.Data.Hibernate";
+ String SERVICE_DATA_SQL = "Service.Data.SQL";
+ String SERVICE_DATA_TRANSACTION = "Service.Data.Transaction";
+ String SERVICE_ADVANCED_MESSAGING = "Service.AdvancedMessaging";
+ String SERVICE_NOTIFICATION = "Service.Notification";
+ String SERVICE_GATEWAY = "Service.Gateway";
+ String SERVICE_GATEWAY_CONNECTOR = "Service.Gateway.Connector";
+ String SERVICE_HTTP = "Service.HTTP";
+ String SERVICE_MESSAGE = "Service.Message";
+ String SERVICE_MESSAGE_JMS = "Service.Message.JMS";
+ String SERVICE_REMOTING = "Service.Remoting";
+
+ String SECURITY = "Security";
+
+ String SOCKET_SERVER_GENERAL = "SocketServer.General";
+ String SOCKET_SERVER_BYTE_BUFFER_MANAGEMENT = "SocketServer.ByteBufferManagement";
+
+ String SSL = "SSL";
+
+ String STARTUP_MESSAGEBROKER = "Startup.MessageBroker";
+ String STARTUP_SERVICE = "Startup.Service";
+ String STARTUP_DESTINATION = "Startup.Destination";
+
+ String TIMEOUT = "Timeout";
+
+ String TRANSPORT_RELIABLE = "Transport.Reliable";
+ String TRANSPORT_THROTTLE = "Transport.Throttle";
+ String TRANSPORT_THROTTLE_BUFFER = "Transport.Throttle.Buffer";
+ String TRANSPORT_THROTTLE_CONFLATE = "Transport.Throttle.Conflate";
+
+ String WSRP_GENERAL = "WSRP.General";
+
+ String RDS = "RDS";
+
+ String FBSERVICES_INTROSPECTION = "FBServices.Introspection";
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/log/LogEvent.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/log/LogEvent.java b/modules/common/src/flex/messaging/log/LogEvent.java
old mode 100755
new mode 100644
index 04a168b..1eccc58
--- a/modules/common/src/flex/messaging/log/LogEvent.java
+++ b/modules/common/src/flex/messaging/log/LogEvent.java
@@ -1,116 +1,116 @@
-/*
- * 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.log;
-
-/**
- * @exclude
- */
-public class LogEvent
-{
- public static final short NONE = 2000;
- public static final short FATAL = 1000;
- public static final short ERROR = 8;
- public static final short WARN = 6;
- public static final short INFO = 4;
- public static final short DEBUG = 2;
- public static final short ALL = 0;
-
- /**
- * Provides access to the level for this log event.
- * Valid values are:
- * <ul>
- * <li><code>LogEvent.DEBUG</code> designates informational
- * level messages that are fine grained and most helpful when
- * debugging an application.</li>
- *
- * <li><code>LogEvent.INFO</code> designates informational messages
- * that highlight the progress of the application at
- * coarse-grained level.</li>
- *
- * <li><code>LogEvent.WARN</code> designates events that could be
- * harmful to the application operation.</li>
- *
- * <li><code>LogEvent.ERROR</code> designates error events that might
- * still allow the application to continue running.</li>
- *
- * <li><code>LogEvent.FATAL</code> designates events that are very
- * harmful and will eventually lead to application failure.</li>
- *
- * </ul>
- */
- public short level;
-
- /**
- * Provides access to the message that was logged.
- */
- public String message;
-
- /**
- * Logger instance that raised the log event.
- */
- public Logger logger;
-
- /**
- * Related exception, if applicable.
- */
- public Throwable throwable;
-
- /**
- * Constructor.
- *
- * @param lgr Logger instance that raised the log event.
- * @param msg Message that was logged.
- * @param lvl The level for the log event.
- * @param t Related exception, if applicable.
- */
- public LogEvent(Logger lgr, String msg, short lvl, Throwable t)
- {
- logger = lgr;
- message = msg;
- level = lvl;
- throwable = t;
- }
-
- /**
- * Returns a string value representing the level specified.
- *
- * @param value the level a string is desired for.
- * @return the level specified in english
- */
- public static String getLevelString(short value)
- {
- switch (value)
- {
- case NONE:
- return ("NONE");
- case FATAL:
- return ("FATAL");
- case ERROR:
- return ("ERROR");
- case WARN:
- return ("WARN");
- case INFO:
- return ("INFO");
- case DEBUG:
- return ("DEBUG");
- case ALL:
- return ("ALL");
- default:
- return ("UNKNOWN");
- }
- }
-}
+/*
+ * 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.log;
+
+/**
+ * @exclude
+ */
+public class LogEvent
+{
+ public static final short NONE = 2000;
+ public static final short FATAL = 1000;
+ public static final short ERROR = 8;
+ public static final short WARN = 6;
+ public static final short INFO = 4;
+ public static final short DEBUG = 2;
+ public static final short ALL = 0;
+
+ /**
+ * Provides access to the level for this log event.
+ * Valid values are:
+ * <ul>
+ * <li><code>LogEvent.DEBUG</code> designates informational
+ * level messages that are fine grained and most helpful when
+ * debugging an application.</li>
+ *
+ * <li><code>LogEvent.INFO</code> designates informational messages
+ * that highlight the progress of the application at
+ * coarse-grained level.</li>
+ *
+ * <li><code>LogEvent.WARN</code> designates events that could be
+ * harmful to the application operation.</li>
+ *
+ * <li><code>LogEvent.ERROR</code> designates error events that might
+ * still allow the application to continue running.</li>
+ *
+ * <li><code>LogEvent.FATAL</code> designates events that are very
+ * harmful and will eventually lead to application failure.</li>
+ *
+ * </ul>
+ */
+ public short level;
+
+ /**
+ * Provides access to the message that was logged.
+ */
+ public String message;
+
+ /**
+ * Logger instance that raised the log event.
+ */
+ public Logger logger;
+
+ /**
+ * Related exception, if applicable.
+ */
+ public Throwable throwable;
+
+ /**
+ * Constructor.
+ *
+ * @param lgr Logger instance that raised the log event.
+ * @param msg Message that was logged.
+ * @param lvl The level for the log event.
+ * @param t Related exception, if applicable.
+ */
+ public LogEvent(Logger lgr, String msg, short lvl, Throwable t)
+ {
+ logger = lgr;
+ message = msg;
+ level = lvl;
+ throwable = t;
+ }
+
+ /**
+ * Returns a string value representing the level specified.
+ *
+ * @param value the level a string is desired for.
+ * @return the level specified in english
+ */
+ public static String getLevelString(short value)
+ {
+ switch (value)
+ {
+ case NONE:
+ return ("NONE");
+ case FATAL:
+ return ("FATAL");
+ case ERROR:
+ return ("ERROR");
+ case WARN:
+ return ("WARN");
+ case INFO:
+ return ("INFO");
+ case DEBUG:
+ return ("DEBUG");
+ case ALL:
+ return ("ALL");
+ default:
+ return ("UNKNOWN");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/log/Logger.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/log/Logger.java b/modules/common/src/flex/messaging/log/Logger.java
old mode 100755
new mode 100644
index e8f622f..a424437
--- a/modules/common/src/flex/messaging/log/Logger.java
+++ b/modules/common/src/flex/messaging/log/Logger.java
@@ -1,402 +1,402 @@
-/*
- * 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.log;
-
-import flex.messaging.util.PrettyPrinter;
-import flex.messaging.util.StringUtils;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-/**
- * The <code>Logger</code> class is used to log out information. It provides named
- * methods to log information out at the desired level. Each <code>Logger</code>
- * will log information out for a log category that is settable.
- *
- * @exclude
- */
-public class Logger
-{
- /**
- * The category this logger send messages for.
- */
- private volatile String category;
-
- /**
- * The list of targets that this logger will dispatch log events to.
- */
- private final ArrayList targets;
-
- /**
- * Constructs a <code>Logger</code> instance that will log
- * information out to the specified category.
- *
- * @param category The category to log information for.
- */
- public Logger(String category)
- {
- this.category = category;
- targets = new ArrayList();
- }
-
- /**
- * Returns the category this <code>Logger</code> logs information for.
- *
- * @return The category this <code>Logger</code> logs information for.
- */
- public String getCategory()
- {
- return category;
- }
-
- /**
- * Determines whether the <code>Logger</code> has at least one target.
- *
- * @return True if the <code>Logger</code> has one or more targets.
- */
- public boolean hasTarget()
- {
- synchronized (targets)
- {
- return !targets.isEmpty();
- }
- }
- /**
- * Adds a <code>Target</code> that will format and output log events
- * generated by this <code>Logger</code>.
- *
- * @param target The <code>Target</code> to add.
- */
- void addTarget(Target target)
- {
- synchronized (targets)
- {
- if (!targets.contains(target))
- targets.add(target);
- }
- }
-
- /**
- * Removes a <code>Target</code> from this <code>Logger</code>.
- *
- * @param target The <code>Target</code> to remove.
- */
- void removeTarget(Target target)
- {
- synchronized (targets)
- {
- targets.remove(target);
- }
- }
-
- /*
- * DEBUG
- */
- /**
- * Logs out a debug message.
- *
- * @param message The message to log.
- */
- public void debug(String message)
- {
- log(LogEvent.DEBUG, message, null, null);
- }
-
- /**
- * Logs out a debug message associated with a <code>Throwable</code>.
- *
- * @param message The message to log.
- * @param t The associated <code>Throwable</code>.
- */
- public void debug(String message, Throwable t)
- {
- log(LogEvent.DEBUG, message, null, t);
- }
-
- /**
- * Logs out a debug message supporting positional parameter substitutions.
- *
- * @param message The message to log.
- * @param parameters Parameters to substitute into the message.
- */
- public void debug(String message, Object[] parameters)
- {
- log(LogEvent.DEBUG, message, parameters, null);
- }
-
- /**
- * Logs out a debug message supporting positional parameter substitutions and an
- * associated <code>Throwable</code>.
- *
- * @param message The message to log.
- * @param parameters Parameters to substitute into the message.
- * @param t The associated <code>Throwable</code>.
- */
- public void debug(String message, Object[] parameters, Throwable t)
- {
- log(LogEvent.DEBUG, message, parameters, t);
- }
-
- /*
- * INFO
- */
- /**
- * Logs out an info message.
- *
- * @param message The message to log.
- */
- public void info(String message)
- {
- log(LogEvent.INFO, message, null, null);
- }
-
- /**
- * Logs out an info message associated with a <code>Throwable</code>.
- *
- * @param message The message to log.
- * @param t The associated <code>Throwable</code>.
- */
- public void info(String message, Throwable t)
- {
- log(LogEvent.INFO, message, null, t);
- }
-
- /**
- * Logs out an info message supporting positional parameter substitutions.
- *
- * @param message The message to log.
- * @param parameters Parameters to substitute into the message.
- */
- public void info(String message, Object[] parameters)
- {
- log(LogEvent.INFO, message, parameters, null);
- }
-
- /**
- * Logs out an info message supporting positional parameter substitutions and an
- * associated <code>Throwable</code>.
- *
- * @param message The message to log.
- * @param parameters Parameters to substitute into the message.
- * @param t The associated <code>Throwable</code>.
- */
- public void info(String message, Object[] parameters, Throwable t)
- {
- log(LogEvent.INFO, message, parameters, t);
- }
-
- /*
- * WARN
- */
- /**
- * Logs out a warn message.
- *
- * @param message The message to log.
- */
- public void warn(String message)
- {
- log(LogEvent.WARN, message, null, null);
- }
-
- /**
- * Logs out a warn message associated with a <code>Throwable</code>.
- *
- * @param message The message to log.
- * @param t The associated <code>Throwable</code>.
- */
- public void warn(String message, Throwable t)
- {
- log(LogEvent.WARN, message, null, t);
- }
-
- /**
- * Logs out a warn message supporting positional parameter substitutions.
- *
- * @param message The message to log.
- * @param parameters Parameters to substitute into the message.
- */
- public void warn(String message, Object[] parameters)
- {
- log(LogEvent.WARN, message, parameters, null);
- }
-
- /**
- * Logs out a warn message supporting positional parameter substitutions and an
- * associated <code>Throwable</code>.
- *
- * @param message The message to log.
- * @param parameters Parameters to substitute into the message.
- * @param t The associated <code>Throwable</code>.
- */
- public void warn(String message, Object[] parameters, Throwable t)
- {
- log(LogEvent.WARN, message, parameters, t);
- }
-
- /*
- * ERROR
- */
- /**
- * Logs out an error message.
- *
- * @param message The message to log.
- */
- public void error(String message)
- {
- log(LogEvent.ERROR, message, null, null);
- }
-
- /**
- * Logs out an error message associated with a <code>Throwable</code>.
- *
- * @param message The message to log.
- * @param t The associated <code>Throwable</code>.
- */
- public void error(String message, Throwable t)
- {
- log(LogEvent.ERROR, message, null, t);
- }
-
- /**
- * Logs out an error message supporting positional parameter substitutions.
- *
- * @param message The message to log.
- * @param parameters Parameters to substitute into the message.
- */
- public void error(String message, Object[] parameters)
- {
- log(LogEvent.ERROR, message, parameters, null);
- }
-
- /**
- * Logs out an error message supporting positional parameter substitutions and an
- * associated <code>Throwable</code>.
- *
- * @param message The message to log.
- * @param parameters Parameters to substitute into the message.
- * @param t The associated <code>Throwable</code>.
- */
- public void error(String message, Object[] parameters, Throwable t)
- {
- log(LogEvent.ERROR, message, parameters, t);
- }
-
- /*
- * FATAL
- */
- /**
- * Logs out a fatal message.
- *
- * @param message The message to log.
- */
- public void fatal(String message)
- {
- log(LogEvent.FATAL, message, null, null);
- }
-
- /**
- * Logs out a fatal message associated with a <code>Throwable</code>.
- *
- * @param message The message to log.
- * @param t The associated <code>Throwable</code>.
- */
- public void fatal(String message, Throwable t)
- {
- log(LogEvent.FATAL, message, null, t);
- }
-
- /**
- * Logs out a fatal message supporting positional parameter substitutions.
- *
- * @param message The message to log.
- * @param parameters Parameters to substitute into the message.
- */
- public void fatal(String message, Object[] parameters)
- {
- log(LogEvent.FATAL, message, parameters, null);
- }
-
- /**
- * Logs out a fatal message supporting positional parameter substitutions and an
- * associated <code>Throwable</code>.
- *
- * @param message The message to log.
- * @param parameters Parameters to substitute into the message.
- * @param t The associated <code>Throwable</code>.
- */
- public void fatal(String message, Object[] parameters, Throwable t)
- {
- log(LogEvent.FATAL, message, parameters, t);
- }
-
- /**
- * @exclude
- * The methods named according to log level delegate to this method to log.
- *
- * @param level The log level.
- * @param message The message to log.
- * @param parameters Substitution parameters (may be null).
- * @param t The associated <code>Throwable</code> (may be null).
- */
- public void log(short level, String message, Object[] parameters, Throwable t)
- {
- log(level, message, parameters, t, true);
- }
-
- /**
- * @exclude
- * Logs a passed message if its level verifies as high enough.
- *
- * @param level The log level.
- * @param message The message to log.
- * @param parameters Substitution parameters (may be null).
- * @param t The associated <code>Throwable</code>.
- * @param verifyLevel <code>true</code> to verify the log level; otherwise log without verifying the level.
- */
- public void log(short level, String message, Object[] parameters, Throwable t, boolean verifyLevel)
- {
- if (targets.size() > 0 && (!verifyLevel || (level >= Log.getTargetLevel())))
- {
- if (parameters != null)
- {
- PrettyPrinter prettyPrinter = Log.getPrettyPrinter();
-
- // replace all of the parameters in the msg string
- for(int i = 0; i < parameters.length; i++)
- {
- String replacement = parameters[i] != null ? prettyPrinter.prettify(parameters[i]) : "null";
-
- //this guy runs into problems if the replacement has a \ or $ in it
- //message = message.replaceAll("\\{" + i + "\\}", replacement);
- message = StringUtils.substitute(message, "{" + i + "}", replacement);
- }
- }
- LogEvent event = new LogEvent(this, message, level, t);
- Target tgt;
- synchronized (targets)
- {
- for (Iterator iter = targets.iterator(); iter.hasNext();)
- {
- tgt = (Target) iter.next();
- if (!verifyLevel || (level >= tgt.getLevel()))
- tgt.logEvent(event);
- }
- }
- }
- }
-
-}
+/*
+ * 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.log;
+
+import flex.messaging.util.PrettyPrinter;
+import flex.messaging.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * The <code>Logger</code> class is used to log out information. It provides named
+ * methods to log information out at the desired level. Each <code>Logger</code>
+ * will log information out for a log category that is settable.
+ *
+ * @exclude
+ */
+public class Logger
+{
+ /**
+ * The category this logger send messages for.
+ */
+ private volatile String category;
+
+ /**
+ * The list of targets that this logger will dispatch log events to.
+ */
+ private final ArrayList targets;
+
+ /**
+ * Constructs a <code>Logger</code> instance that will log
+ * information out to the specified category.
+ *
+ * @param category The category to log information for.
+ */
+ public Logger(String category)
+ {
+ this.category = category;
+ targets = new ArrayList();
+ }
+
+ /**
+ * Returns the category this <code>Logger</code> logs information for.
+ *
+ * @return The category this <code>Logger</code> logs information for.
+ */
+ public String getCategory()
+ {
+ return category;
+ }
+
+ /**
+ * Determines whether the <code>Logger</code> has at least one target.
+ *
+ * @return True if the <code>Logger</code> has one or more targets.
+ */
+ public boolean hasTarget()
+ {
+ synchronized (targets)
+ {
+ return !targets.isEmpty();
+ }
+ }
+ /**
+ * Adds a <code>Target</code> that will format and output log events
+ * generated by this <code>Logger</code>.
+ *
+ * @param target The <code>Target</code> to add.
+ */
+ void addTarget(Target target)
+ {
+ synchronized (targets)
+ {
+ if (!targets.contains(target))
+ targets.add(target);
+ }
+ }
+
+ /**
+ * Removes a <code>Target</code> from this <code>Logger</code>.
+ *
+ * @param target The <code>Target</code> to remove.
+ */
+ void removeTarget(Target target)
+ {
+ synchronized (targets)
+ {
+ targets.remove(target);
+ }
+ }
+
+ /*
+ * DEBUG
+ */
+ /**
+ * Logs out a debug message.
+ *
+ * @param message The message to log.
+ */
+ public void debug(String message)
+ {
+ log(LogEvent.DEBUG, message, null, null);
+ }
+
+ /**
+ * Logs out a debug message associated with a <code>Throwable</code>.
+ *
+ * @param message The message to log.
+ * @param t The associated <code>Throwable</code>.
+ */
+ public void debug(String message, Throwable t)
+ {
+ log(LogEvent.DEBUG, message, null, t);
+ }
+
+ /**
+ * Logs out a debug message supporting positional parameter substitutions.
+ *
+ * @param message The message to log.
+ * @param parameters Parameters to substitute into the message.
+ */
+ public void debug(String message, Object[] parameters)
+ {
+ log(LogEvent.DEBUG, message, parameters, null);
+ }
+
+ /**
+ * Logs out a debug message supporting positional parameter substitutions and an
+ * associated <code>Throwable</code>.
+ *
+ * @param message The message to log.
+ * @param parameters Parameters to substitute into the message.
+ * @param t The associated <code>Throwable</code>.
+ */
+ public void debug(String message, Object[] parameters, Throwable t)
+ {
+ log(LogEvent.DEBUG, message, parameters, t);
+ }
+
+ /*
+ * INFO
+ */
+ /**
+ * Logs out an info message.
+ *
+ * @param message The message to log.
+ */
+ public void info(String message)
+ {
+ log(LogEvent.INFO, message, null, null);
+ }
+
+ /**
+ * Logs out an info message associated with a <code>Throwable</code>.
+ *
+ * @param message The message to log.
+ * @param t The associated <code>Throwable</code>.
+ */
+ public void info(String message, Throwable t)
+ {
+ log(LogEvent.INFO, message, null, t);
+ }
+
+ /**
+ * Logs out an info message supporting positional parameter substitutions.
+ *
+ * @param message The message to log.
+ * @param parameters Parameters to substitute into the message.
+ */
+ public void info(String message, Object[] parameters)
+ {
+ log(LogEvent.INFO, message, parameters, null);
+ }
+
+ /**
+ * Logs out an info message supporting positional parameter substitutions and an
+ * associated <code>Throwable</code>.
+ *
+ * @param message The message to log.
+ * @param parameters Parameters to substitute into the message.
+ * @param t The associated <code>Throwable</code>.
+ */
+ public void info(String message, Object[] parameters, Throwable t)
+ {
+ log(LogEvent.INFO, message, parameters, t);
+ }
+
+ /*
+ * WARN
+ */
+ /**
+ * Logs out a warn message.
+ *
+ * @param message The message to log.
+ */
+ public void warn(String message)
+ {
+ log(LogEvent.WARN, message, null, null);
+ }
+
+ /**
+ * Logs out a warn message associated with a <code>Throwable</code>.
+ *
+ * @param message The message to log.
+ * @param t The associated <code>Throwable</code>.
+ */
+ public void warn(String message, Throwable t)
+ {
+ log(LogEvent.WARN, message, null, t);
+ }
+
+ /**
+ * Logs out a warn message supporting positional parameter substitutions.
+ *
+ * @param message The message to log.
+ * @param parameters Parameters to substitute into the message.
+ */
+ public void warn(String message, Object[] parameters)
+ {
+ log(LogEvent.WARN, message, parameters, null);
+ }
+
+ /**
+ * Logs out a warn message supporting positional parameter substitutions and an
+ * associated <code>Throwable</code>.
+ *
+ * @param message The message to log.
+ * @param parameters Parameters to substitute into the message.
+ * @param t The associated <code>Throwable</code>.
+ */
+ public void warn(String message, Object[] parameters, Throwable t)
+ {
+ log(LogEvent.WARN, message, parameters, t);
+ }
+
+ /*
+ * ERROR
+ */
+ /**
+ * Logs out an error message.
+ *
+ * @param message The message to log.
+ */
+ public void error(String message)
+ {
+ log(LogEvent.ERROR, message, null, null);
+ }
+
+ /**
+ * Logs out an error message associated with a <code>Throwable</code>.
+ *
+ * @param message The message to log.
+ * @param t The associated <code>Throwable</code>.
+ */
+ public void error(String message, Throwable t)
+ {
+ log(LogEvent.ERROR, message, null, t);
+ }
+
+ /**
+ * Logs out an error message supporting positional parameter substitutions.
+ *
+ * @param message The message to log.
+ * @param parameters Parameters to substitute into the message.
+ */
+ public void error(String message, Object[] parameters)
+ {
+ log(LogEvent.ERROR, message, parameters, null);
+ }
+
+ /**
+ * Logs out an error message supporting positional parameter substitutions and an
+ * associated <code>Throwable</code>.
+ *
+ * @param message The message to log.
+ * @param parameters Parameters to substitute into the message.
+ * @param t The associated <code>Throwable</code>.
+ */
+ public void error(String message, Object[] parameters, Throwable t)
+ {
+ log(LogEvent.ERROR, message, parameters, t);
+ }
+
+ /*
+ * FATAL
+ */
+ /**
+ * Logs out a fatal message.
+ *
+ * @param message The message to log.
+ */
+ public void fatal(String message)
+ {
+ log(LogEvent.FATAL, message, null, null);
+ }
+
+ /**
+ * Logs out a fatal message associated with a <code>Throwable</code>.
+ *
+ * @param message The message to log.
+ * @param t The associated <code>Throwable</code>.
+ */
+ public void fatal(String message, Throwable t)
+ {
+ log(LogEvent.FATAL, message, null, t);
+ }
+
+ /**
+ * Logs out a fatal message supporting positional parameter substitutions.
+ *
+ * @param message The message to log.
+ * @param parameters Parameters to substitute into the message.
+ */
+ public void fatal(String message, Object[] parameters)
+ {
+ log(LogEvent.FATAL, message, parameters, null);
+ }
+
+ /**
+ * Logs out a fatal message supporting positional parameter substitutions and an
+ * associated <code>Throwable</code>.
+ *
+ * @param message The message to log.
+ * @param parameters Parameters to substitute into the message.
+ * @param t The associated <code>Throwable</code>.
+ */
+ public void fatal(String message, Object[] parameters, Throwable t)
+ {
+ log(LogEvent.FATAL, message, parameters, t);
+ }
+
+ /**
+ * @exclude
+ * The methods named according to log level delegate to this method to log.
+ *
+ * @param level The log level.
+ * @param message The message to log.
+ * @param parameters Substitution parameters (may be null).
+ * @param t The associated <code>Throwable</code> (may be null).
+ */
+ public void log(short level, String message, Object[] parameters, Throwable t)
+ {
+ log(level, message, parameters, t, true);
+ }
+
+ /**
+ * @exclude
+ * Logs a passed message if its level verifies as high enough.
+ *
+ * @param level The log level.
+ * @param message The message to log.
+ * @param parameters Substitution parameters (may be null).
+ * @param t The associated <code>Throwable</code>.
+ * @param verifyLevel <code>true</code> to verify the log level; otherwise log without verifying the level.
+ */
+ public void log(short level, String message, Object[] parameters, Throwable t, boolean verifyLevel)
+ {
+ if (targets.size() > 0 && (!verifyLevel || (level >= Log.getTargetLevel())))
+ {
+ if (parameters != null)
+ {
+ PrettyPrinter prettyPrinter = Log.getPrettyPrinter();
+
+ // replace all of the parameters in the msg string
+ for(int i = 0; i < parameters.length; i++)
+ {
+ String replacement = parameters[i] != null ? prettyPrinter.prettify(parameters[i]) : "null";
+
+ //this guy runs into problems if the replacement has a \ or $ in it
+ //message = message.replaceAll("\\{" + i + "\\}", replacement);
+ message = StringUtils.substitute(message, "{" + i + "}", replacement);
+ }
+ }
+ LogEvent event = new LogEvent(this, message, level, t);
+ Target tgt;
+ synchronized (targets)
+ {
+ for (Iterator iter = targets.iterator(); iter.hasNext();)
+ {
+ tgt = (Target) iter.next();
+ if (!verifyLevel || (level >= tgt.getLevel()))
+ tgt.logEvent(event);
+ }
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/log/Target.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/log/Target.java b/modules/common/src/flex/messaging/log/Target.java
old mode 100755
new mode 100644
index c5c8224..7a39fb5
--- a/modules/common/src/flex/messaging/log/Target.java
+++ b/modules/common/src/flex/messaging/log/Target.java
@@ -1,112 +1,112 @@
-/*
- * 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.log;
-
-import java.util.List;
-
-import flex.messaging.config.ConfigMap;
-
-/**
- * All logger target implementations within the logging framework must
- * implement this interface. <code>Target</code> implementations receive log events
- * and output information from these events to the appropriate output
- * destination which may be a console, log file or some other custom
- * destination.
- */
-public interface Target
-{
- /**
- * Initializes the target with id and properties.
- *
- * @param id id for the target.
- * @param properties ConfigMap of properties for the target.
- */
- void initialize(String id, ConfigMap properties);
-
- /**
- * Returns the category filters defined for the <code>Target</code>.
- *
- * @return The category filters defined for the <code>Target</code>.
- */
- List getFilters();
-
- /**
- * Sets the category filters that the <code>Target</code> will process
- * log events for.
- *
- * @param value The category filters that the <code>Target</code> will process
- */
- void setFilters(List value);
-
- /**
- * Adds the category filteer that the <code>Target</code> will process
- * log events for.
- *
- * @param value The new category filter to add to the <code>Target</code>'s list of filters.
- */
- void addFilter(String value);
-
- /**
- * Removes a category filter from the list of filters the <code>Target</code> will
- * process log events for.
- *
- * @param value The category filter to remove from the <code>Target</code>'s list of filters.
- */
- void removeFilter(String value);
-
- /**
- * Returns the log level that the <code>Target</code> will process log
- * events for. Log events at this level, or at a higher priority level
- * will be processed.
- *
- * @return The log level that the <code>Target</code> will process log events for.
- */
- short getLevel();
-
- /**
- * Sets the log level that the <code>Target</code> will process log events
- * for. Log events at this level, or at a higher priority level will be
- * processed.
- *
- * @param value The log level that the <code>Target</code> will process log events for.
- */
- void setLevel(short value);
-
- /**
- * Adds a <code>Logger</code> whose category matches the filters list for
- * the <code>Target</code>. The <code>Logger</code> will dispatch log events
- * to this <code>Target</code> to be output.
- *
- * @param logger The <code>Logger</code> to add.
- */
- void addLogger(Logger logger);
-
- /**
- * Removes a <code>Logger</code> from the <code>Target</code>.
- *
- * @param logger The <code>Logger</code> to remove.
- */
- void removeLogger(Logger logger);
-
- /**
- * Logs a log event out to the <code>Target</code>s output destination,
- * which may be the console or a log file.
- *
- * @param event The <code>LogEvent</code> containing the information to output.
- */
- void logEvent(LogEvent event);
-}
+/*
+ * 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.log;
+
+import java.util.List;
+
+import flex.messaging.config.ConfigMap;
+
+/**
+ * All logger target implementations within the logging framework must
+ * implement this interface. <code>Target</code> implementations receive log events
+ * and output information from these events to the appropriate output
+ * destination which may be a console, log file or some other custom
+ * destination.
+ */
+public interface Target
+{
+ /**
+ * Initializes the target with id and properties.
+ *
+ * @param id id for the target.
+ * @param properties ConfigMap of properties for the target.
+ */
+ void initialize(String id, ConfigMap properties);
+
+ /**
+ * Returns the category filters defined for the <code>Target</code>.
+ *
+ * @return The category filters defined for the <code>Target</code>.
+ */
+ List getFilters();
+
+ /**
+ * Sets the category filters that the <code>Target</code> will process
+ * log events for.
+ *
+ * @param value The category filters that the <code>Target</code> will process
+ */
+ void setFilters(List value);
+
+ /**
+ * Adds the category filteer that the <code>Target</code> will process
+ * log events for.
+ *
+ * @param value The new category filter to add to the <code>Target</code>'s list of filters.
+ */
+ void addFilter(String value);
+
+ /**
+ * Removes a category filter from the list of filters the <code>Target</code> will
+ * process log events for.
+ *
+ * @param value The category filter to remove from the <code>Target</code>'s list of filters.
+ */
+ void removeFilter(String value);
+
+ /**
+ * Returns the log level that the <code>Target</code> will process log
+ * events for. Log events at this level, or at a higher priority level
+ * will be processed.
+ *
+ * @return The log level that the <code>Target</code> will process log events for.
+ */
+ short getLevel();
+
+ /**
+ * Sets the log level that the <code>Target</code> will process log events
+ * for. Log events at this level, or at a higher priority level will be
+ * processed.
+ *
+ * @param value The log level that the <code>Target</code> will process log events for.
+ */
+ void setLevel(short value);
+
+ /**
+ * Adds a <code>Logger</code> whose category matches the filters list for
+ * the <code>Target</code>. The <code>Logger</code> will dispatch log events
+ * to this <code>Target</code> to be output.
+ *
+ * @param logger The <code>Logger</code> to add.
+ */
+ void addLogger(Logger logger);
+
+ /**
+ * Removes a <code>Logger</code> from the <code>Target</code>.
+ *
+ * @param logger The <code>Logger</code> to remove.
+ */
+ void removeLogger(Logger logger);
+
+ /**
+ * Logs a log event out to the <code>Target</code>s output destination,
+ * which may be the console or a log file.
+ *
+ * @param event The <code>LogEvent</code> containing the information to output.
+ */
+ void logEvent(LogEvent event);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/BasicPrettyPrinter.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/BasicPrettyPrinter.java b/modules/common/src/flex/messaging/util/BasicPrettyPrinter.java
old mode 100755
new mode 100644
index 6abc550..9ac7c6d
--- a/modules/common/src/flex/messaging/util/BasicPrettyPrinter.java
+++ b/modules/common/src/flex/messaging/util/BasicPrettyPrinter.java
@@ -1,164 +1,164 @@
-/*
- * 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.util;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Map;
-
-/**
- * Prettifies the representation of an Object as a String. Complex
- * types are not traversed.
- *
- * @exclude
- */
-public class BasicPrettyPrinter implements PrettyPrinter
-{
- protected ObjectTrace trace;
-
- public BasicPrettyPrinter()
- {
- }
-
- /**
- * Prettifies the representation of an Object as a String.
- * <ul>
- * <li>Simple types are simply toString'ed.</li>
- * <li>XML strings are formatted with line feeds and indentations.</li>
- * <li>Complex types report their class names.</li>
- * <li>Collections, Maps and native Arrays also report their size/length.</li>
- * </ul>
- * @return A prettified version of an Object as a String.
- */
- public String prettify(Object o)
- {
- try
- {
- trace = new ObjectTrace();
- internalPrettify(o);
- return trace.toString();
- }
- catch (Throwable t)
- {
- return trace.toString();
- }
- finally
- {
- trace = null;
- }
- }
-
- protected void internalPrettify(Object o)
- {
- if (o == null)
- {
- trace.writeNull();
- }
- else if (o instanceof String)
- {
- String string = (String)o;
- if (string.startsWith("<?xml"))
- {
- trace.write(StringUtils.prettifyXML(string));
- }
- else
- {
- trace.write(string);
- }
- }
- else if (o instanceof Number || o instanceof Boolean || o instanceof Date
- || o instanceof Calendar || o instanceof Character)
- {
- trace.write(o);
- }
- else
- {
- prettifyComplexType(o);
- }
- }
-
- protected void prettifyComplexType(Object o)
- {
- StringBuffer header = new StringBuffer();
-
- if (o instanceof PrettyPrintable)
- {
- PrettyPrintable pp = (PrettyPrintable)o;
- header.append(pp.toStringHeader());
- }
-
- Class c = o.getClass();
- String className = c.getName();
-
- if (o instanceof Collection)
- {
- header.append(className).append(" (Collection size:").append(((Collection)o).size()).append(")");
- }
- else if (o instanceof Map)
- {
- header.append(className).append(" (Map size:").append(((Map)o).size()).append(")");
- }
- else if (c.isArray() && c.getComponentType() != null)
- {
- Class componentType = c.getComponentType();
- className = componentType.getName();
- header.append(className).append("[] (Array length:").append(Array.getLength(o)).append(")");
- }
- else
- {
- header.append(className);
- }
-
- trace.startObject(header.toString());
- trace.endObject();
- }
-
- /**
- * If the definition of toString is not from java.lang.Object or any class in the
- * java.util.* package then we consider it a custom implementation in which case
- * we'll use it instead of introspecting the class.
- *
- * @param c The class to check for a custom toString definition.
- * @return Whether this class declares a custom toString() method.
- */
- protected boolean hasCustomToStringMethod(Class c)
- {
- try
- {
- Method toStringMethod = c.getMethod("toString", (Class[])null);
- Class declaringClass = toStringMethod.getDeclaringClass();
- if (declaringClass != Object.class
- && !declaringClass.getName().startsWith("java.util"))
- {
- return true;
- }
- }
- catch (Throwable t)
- {
- }
-
- return false;
- }
-
- public Object copy()
- {
- return new BasicPrettyPrinter();
- }
-}
+/*
+ * 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.util;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * Prettifies the representation of an Object as a String. Complex
+ * types are not traversed.
+ *
+ * @exclude
+ */
+public class BasicPrettyPrinter implements PrettyPrinter
+{
+ protected ObjectTrace trace;
+
+ public BasicPrettyPrinter()
+ {
+ }
+
+ /**
+ * Prettifies the representation of an Object as a String.
+ * <ul>
+ * <li>Simple types are simply toString'ed.</li>
+ * <li>XML strings are formatted with line feeds and indentations.</li>
+ * <li>Complex types report their class names.</li>
+ * <li>Collections, Maps and native Arrays also report their size/length.</li>
+ * </ul>
+ * @return A prettified version of an Object as a String.
+ */
+ public String prettify(Object o)
+ {
+ try
+ {
+ trace = new ObjectTrace();
+ internalPrettify(o);
+ return trace.toString();
+ }
+ catch (Throwable t)
+ {
+ return trace.toString();
+ }
+ finally
+ {
+ trace = null;
+ }
+ }
+
+ protected void internalPrettify(Object o)
+ {
+ if (o == null)
+ {
+ trace.writeNull();
+ }
+ else if (o instanceof String)
+ {
+ String string = (String)o;
+ if (string.startsWith("<?xml"))
+ {
+ trace.write(StringUtils.prettifyXML(string));
+ }
+ else
+ {
+ trace.write(string);
+ }
+ }
+ else if (o instanceof Number || o instanceof Boolean || o instanceof Date
+ || o instanceof Calendar || o instanceof Character)
+ {
+ trace.write(o);
+ }
+ else
+ {
+ prettifyComplexType(o);
+ }
+ }
+
+ protected void prettifyComplexType(Object o)
+ {
+ StringBuffer header = new StringBuffer();
+
+ if (o instanceof PrettyPrintable)
+ {
+ PrettyPrintable pp = (PrettyPrintable)o;
+ header.append(pp.toStringHeader());
+ }
+
+ Class c = o.getClass();
+ String className = c.getName();
+
+ if (o instanceof Collection)
+ {
+ header.append(className).append(" (Collection size:").append(((Collection)o).size()).append(")");
+ }
+ else if (o instanceof Map)
+ {
+ header.append(className).append(" (Map size:").append(((Map)o).size()).append(")");
+ }
+ else if (c.isArray() && c.getComponentType() != null)
+ {
+ Class componentType = c.getComponentType();
+ className = componentType.getName();
+ header.append(className).append("[] (Array length:").append(Array.getLength(o)).append(")");
+ }
+ else
+ {
+ header.append(className);
+ }
+
+ trace.startObject(header.toString());
+ trace.endObject();
+ }
+
+ /**
+ * If the definition of toString is not from java.lang.Object or any class in the
+ * java.util.* package then we consider it a custom implementation in which case
+ * we'll use it instead of introspecting the class.
+ *
+ * @param c The class to check for a custom toString definition.
+ * @return Whether this class declares a custom toString() method.
+ */
+ protected boolean hasCustomToStringMethod(Class c)
+ {
+ try
+ {
+ Method toStringMethod = c.getMethod("toString", (Class[])null);
+ Class declaringClass = toStringMethod.getDeclaringClass();
+ if (declaringClass != Object.class
+ && !declaringClass.getName().startsWith("java.util"))
+ {
+ return true;
+ }
+ }
+ catch (Throwable t)
+ {
+ }
+
+ return false;
+ }
+
+ public Object copy()
+ {
+ return new BasicPrettyPrinter();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/ExceptionUtil.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/ExceptionUtil.java b/modules/common/src/flex/messaging/util/ExceptionUtil.java
old mode 100755
new mode 100644
index f787859..966628d
--- a/modules/common/src/flex/messaging/util/ExceptionUtil.java
+++ b/modules/common/src/flex/messaging/util/ExceptionUtil.java
@@ -1,246 +1,246 @@
-/*
- * 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.util;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-
-/**
- * @exclude
- */
-public class ExceptionUtil
-{
- /**
- * List of no-arg methods that are known to return a wrapped throwable.
- **/
- public static String[] unwrapMethods = { "getRootCause", "getTargetException",
- "getTargetError", "getException",
- "getCausedByException", "getLinkedException" };
-
- /**
- * Get the wrapped Exception object from the Throwable object.
- * @param t the Throwable object
- * @return Throwable the wrapped exception object if any
- */
- public static Throwable wrappedException(Throwable t)
- {
- // Handle these statically since they are core to Java
- return (t instanceof InvocationTargetException)?
- ((InvocationTargetException)t).getTargetException() : getRootCauseWithReflection(t);
- }
-
- /**
- * Get to the base exception (if any).
- * @param t the Throwable object
- * @return the base Exception object
- */
- public static Throwable baseException(Throwable t)
- {
- Throwable wrapped = wrappedException(t);
- return wrapped != null? baseException(wrapped) : t;
- }
-
- /**
- * Return the stack trace in a String.
- * @param t the Throwable object
- * @return String the String presentation of the Throwable object
- */
- public static String toString(Throwable t)
- {
- StringWriter strWrt = new StringWriter();
- t.printStackTrace(new PrintWriter(strWrt));
-
- return strWrt.toString();
- }
-
- /**
- * Return the stack trace up to the first line that starts with prefix.
- *
- * <p>Example: ExceptionUtil.getStackTraceUpTo(exception, "jrunx.");</p>
- * @param t the Throwable object
- * @param prefix the prefix message that we are looking for
- * @return String the String of stack trace lines till the prefix message is located
- */
- public static String getStackTraceUpTo(Throwable t, String prefix)
- {
- StringTokenizer tokens = new StringTokenizer(toString(t), "\n\r");
- StringBuffer trace = new StringBuffer();
- boolean done = false;
-
- String lookingFor = "at " + prefix;
- while (!done && tokens.hasMoreElements())
- {
- String token = tokens.nextToken();
- if (token.indexOf(lookingFor) == -1)
- trace.append(token);
- else
- done = true;
- trace.append(StringUtils.NEWLINE);
- }
-
- return trace.toString();
- }
-
- /**
- * return the top n lines of this stack trace.
- *
- * <p>Example: ExceptionUtil.getStackTraceLines(exception, 10);</p>
- * @param t the Throwable object
- * @param numLines number of lines we should trace down
- * @return String the String of stack trace lines
- */
- public static String getStackTraceLines(Throwable t, int numLines)
- {
- StringTokenizer tokens = new StringTokenizer(toString(t), "\n\r");
-
- StringBuffer trace = new StringBuffer();
-
- for (int i=0; i<numLines; i++)
- {
- String token = tokens.nextToken();
- trace.append(token);
- trace.append(StringUtils.NEWLINE);
- }
-
- return trace.toString();
- }
-
- /**
- * Return the "nth" method call from the stack trace of "t", where 0 is
- * the top.
- * @param t the Throwable object
- * @param nth the line number of the message should we skip
- * @return String the callAt String
- */
- public static String getCallAt(Throwable t, int nth)
- {
- StringTokenizer tokens = new StringTokenizer(toString(t), "\n\r");
- try
- {
- // Skip the first line - the exception message
- for(int i = 0; i <= nth; ++i)
- tokens.nextToken();
-
- // get the method name from the next token
- String token = tokens.nextToken();
- int index1 = token.indexOf(' ');
- int index2 = token.indexOf('(');
- StringBuffer call = new StringBuffer();
- call.append(token.substring(index1 < 0 ? 0 : index1 + 1, index2 < 0 ? call.length() : index2));
-
- int index3 = token.indexOf(':', index2 < 0 ? 0 : index2);
- if(index3 >= 0)
- {
- int index4 = token.indexOf(')', index3);
- call.append(token.substring(index3, index4 < 0 ? token.length() : index4));
- }
- return call.toString();
- }
- catch(NoSuchElementException e) {}
-
- return "unknown";
- }
-
-
- /**
- * Utility method for converting an exception into a string. This
- * method unwinds all wrapped exceptions
- * @param t The throwable exception
- * @return The printable exception
- */
- public static String exceptionToString(Throwable t)
- {
- StringWriter sw = new StringWriter();
- PrintWriter out = new PrintWriter(sw);
-
- //print out the exception stack.
- printExceptionStack(t, out, 0);
- return sw.toString();
- }
-
- /**
- * Utility method for converting an exception and all chained root causes into a
- * string. Unlike <code>exceptionToString(Throwable)</code> which prints the chain
- * from most nested root cause down to the top-level exception, this method prints
- * from the top-level exception down to the most nested root cause.
- *
- * @param t The throwable exception.
- * @return The printable exception.
- */
- public static String exceptionFollowedByRootCausesToString(Throwable t)
- {
- StringBuffer output = new StringBuffer();
- Throwable root = t;
- while (root != null)
- {
- output.append((root == t) ? ((root instanceof Exception) ? " Exception: " : " Error: ") : " Root cause: ");
- output.append(ExceptionUtil.toString(root));
- // Do not recurse if the root cause has already been printed; this will have happened if the root cause has
- // been assigned to the current Throwable via initCause() or as a constructor argument.
- Throwable cause = root.getCause();
- root = ExceptionUtil.wrappedException(root);
- if (cause == root)
- break;
- }
- return output.toString();
- }
-
- /**
- * Recursively prints out a stack of wrapped exceptions.
- */
- protected static void printExceptionStack(Throwable th, PrintWriter out, int depth){
- //only print the stack depth if the depth is greater than 0
- boolean printStackDepth = depth>0;
-
- Throwable wrappedException = ExceptionUtil.wrappedException(th);
- if (wrappedException != null)
- {
- printStackDepth = true;
- printExceptionStack(wrappedException, out, depth + 1);
- }
-
- if(printStackDepth){
- out.write("[" + depth + "]");
- }
-
- th.printStackTrace(out);
- }
-
- private static Throwable getRootCauseWithReflection(Throwable t)
- {
- for(int i = 0; i < unwrapMethods.length; i++)
- {
- Method m = null;
-
- try
- {
- m = t.getClass().getMethod(unwrapMethods[i], (Class[])null);
- return (Throwable) m.invoke(t, (Object[])null);
- }
- catch(Exception nsme)
- {
- // ignore
- }
- }
-
- return null;
- }
-}
+/*
+ * 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.util;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
+
+/**
+ * @exclude
+ */
+public class ExceptionUtil
+{
+ /**
+ * List of no-arg methods that are known to return a wrapped throwable.
+ **/
+ public static String[] unwrapMethods = { "getRootCause", "getTargetException",
+ "getTargetError", "getException",
+ "getCausedByException", "getLinkedException" };
+
+ /**
+ * Get the wrapped Exception object from the Throwable object.
+ * @param t the Throwable object
+ * @return Throwable the wrapped exception object if any
+ */
+ public static Throwable wrappedException(Throwable t)
+ {
+ // Handle these statically since they are core to Java
+ return (t instanceof InvocationTargetException)?
+ ((InvocationTargetException)t).getTargetException() : getRootCauseWithReflection(t);
+ }
+
+ /**
+ * Get to the base exception (if any).
+ * @param t the Throwable object
+ * @return the base Exception object
+ */
+ public static Throwable baseException(Throwable t)
+ {
+ Throwable wrapped = wrappedException(t);
+ return wrapped != null? baseException(wrapped) : t;
+ }
+
+ /**
+ * Return the stack trace in a String.
+ * @param t the Throwable object
+ * @return String the String presentation of the Throwable object
+ */
+ public static String toString(Throwable t)
+ {
+ StringWriter strWrt = new StringWriter();
+ t.printStackTrace(new PrintWriter(strWrt));
+
+ return strWrt.toString();
+ }
+
+ /**
+ * Return the stack trace up to the first line that starts with prefix.
+ *
+ * <p>Example: ExceptionUtil.getStackTraceUpTo(exception, "jrunx.");</p>
+ * @param t the Throwable object
+ * @param prefix the prefix message that we are looking for
+ * @return String the String of stack trace lines till the prefix message is located
+ */
+ public static String getStackTraceUpTo(Throwable t, String prefix)
+ {
+ StringTokenizer tokens = new StringTokenizer(toString(t), "\n\r");
+ StringBuffer trace = new StringBuffer();
+ boolean done = false;
+
+ String lookingFor = "at " + prefix;
+ while (!done && tokens.hasMoreElements())
+ {
+ String token = tokens.nextToken();
+ if (token.indexOf(lookingFor) == -1)
+ trace.append(token);
+ else
+ done = true;
+ trace.append(StringUtils.NEWLINE);
+ }
+
+ return trace.toString();
+ }
+
+ /**
+ * return the top n lines of this stack trace.
+ *
+ * <p>Example: ExceptionUtil.getStackTraceLines(exception, 10);</p>
+ * @param t the Throwable object
+ * @param numLines number of lines we should trace down
+ * @return String the String of stack trace lines
+ */
+ public static String getStackTraceLines(Throwable t, int numLines)
+ {
+ StringTokenizer tokens = new StringTokenizer(toString(t), "\n\r");
+
+ StringBuffer trace = new StringBuffer();
+
+ for (int i=0; i<numLines; i++)
+ {
+ String token = tokens.nextToken();
+ trace.append(token);
+ trace.append(StringUtils.NEWLINE);
+ }
+
+ return trace.toString();
+ }
+
+ /**
+ * Return the "nth" method call from the stack trace of "t", where 0 is
+ * the top.
+ * @param t the Throwable object
+ * @param nth the line number of the message should we skip
+ * @return String the callAt String
+ */
+ public static String getCallAt(Throwable t, int nth)
+ {
+ StringTokenizer tokens = new StringTokenizer(toString(t), "\n\r");
+ try
+ {
+ // Skip the first line - the exception message
+ for(int i = 0; i <= nth; ++i)
+ tokens.nextToken();
+
+ // get the method name from the next token
+ String token = tokens.nextToken();
+ int index1 = token.indexOf(' ');
+ int index2 = token.indexOf('(');
+ StringBuffer call = new StringBuffer();
+ call.append(token.substring(index1 < 0 ? 0 : index1 + 1, index2 < 0 ? call.length() : index2));
+
+ int index3 = token.indexOf(':', index2 < 0 ? 0 : index2);
+ if(index3 >= 0)
+ {
+ int index4 = token.indexOf(')', index3);
+ call.append(token.substring(index3, index4 < 0 ? token.length() : index4));
+ }
+ return call.toString();
+ }
+ catch(NoSuchElementException e) {}
+
+ return "unknown";
+ }
+
+
+ /**
+ * Utility method for converting an exception into a string. This
+ * method unwinds all wrapped exceptions
+ * @param t The throwable exception
+ * @return The printable exception
+ */
+ public static String exceptionToString(Throwable t)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter out = new PrintWriter(sw);
+
+ //print out the exception stack.
+ printExceptionStack(t, out, 0);
+ return sw.toString();
+ }
+
+ /**
+ * Utility method for converting an exception and all chained root causes into a
+ * string. Unlike <code>exceptionToString(Throwable)</code> which prints the chain
+ * from most nested root cause down to the top-level exception, this method prints
+ * from the top-level exception down to the most nested root cause.
+ *
+ * @param t The throwable exception.
+ * @return The printable exception.
+ */
+ public static String exceptionFollowedByRootCausesToString(Throwable t)
+ {
+ StringBuffer output = new StringBuffer();
+ Throwable root = t;
+ while (root != null)
+ {
+ output.append((root == t) ? ((root instanceof Exception) ? " Exception: " : " Error: ") : " Root cause: ");
+ output.append(ExceptionUtil.toString(root));
+ // Do not recurse if the root cause has already been printed; this will have happened if the root cause has
+ // been assigned to the current Throwable via initCause() or as a constructor argument.
+ Throwable cause = root.getCause();
+ root = ExceptionUtil.wrappedException(root);
+ if (cause == root)
+ break;
+ }
+ return output.toString();
+ }
+
+ /**
+ * Recursively prints out a stack of wrapped exceptions.
+ */
+ protected static void printExceptionStack(Throwable th, PrintWriter out, int depth){
+ //only print the stack depth if the depth is greater than 0
+ boolean printStackDepth = depth>0;
+
+ Throwable wrappedException = ExceptionUtil.wrappedException(th);
+ if (wrappedException != null)
+ {
+ printStackDepth = true;
+ printExceptionStack(wrappedException, out, depth + 1);
+ }
+
+ if(printStackDepth){
+ out.write("[" + depth + "]");
+ }
+
+ th.printStackTrace(out);
+ }
+
+ private static Throwable getRootCauseWithReflection(Throwable t)
+ {
+ for(int i = 0; i < unwrapMethods.length; i++)
+ {
+ Method m = null;
+
+ try
+ {
+ m = t.getClass().getMethod(unwrapMethods[i], (Class[])null);
+ return (Throwable) m.invoke(t, (Object[])null);
+ }
+ catch(Exception nsme)
+ {
+ // ignore
+ }
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/FileUtils.java b/modules/common/src/flex/messaging/util/FileUtils.java
old mode 100755
new mode 100644
index 8f7146a..3292491
--- a/modules/common/src/flex/messaging/util/FileUtils.java
+++ b/modules/common/src/flex/messaging/util/FileUtils.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 flex.messaging.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * @exclude
- */
-public class FileUtils
-{
- public static final String UTF_8 = "UTF-8";
- public static final String UTF_16 = "UTF-16";
-
- /**
- * Sets a mark in the InputStream for 3 bytes to check for a BOM. If the BOM
- * stands for UTF-8 encoded content then the stream will not be reset, otherwise
- * for UTF-16 with a BOM or any other encoding situation the stream is reset to the
- * mark (as for UTF-16 the parser will handle the BOM).
- *
- * @param in InputStream containing BOM and must support mark().
- * @param default_encoding The default character set encoding. null or "" => system default
- * @return The file character set encoding.
- * @throws IOException
- */
- public static final String consumeBOM(InputStream in, String default_encoding) throws IOException
- {
- in.mark(3);
-
- // Determine file encoding...
- // ASCII - no header (use the supplied encoding)
- // UTF8 - EF BB BF
- // UTF16 - FF FE or FE FF (decoder chooses endian-ness)
- if (in.read() == 0xef && in.read() == 0xbb && in.read() == 0xbf)
- {
- // UTF-8 reader does not consume BOM, so do not reset
- if (System.getProperty("flex.platform.CLR") != null)
- {
- return "UTF8";
- }
- else
- {
- return UTF_8;
- }
- }
- else
- {
- in.reset();
- int b0 = in.read();
- int b1 = in.read();
- if (b0 == 0xff && b1 == 0xfe || b0 == 0xfe && b1 == 0xff)
- {
- in.reset();
- // UTF-16 reader will consume BOM
- if (System.getProperty("flex.platform.CLR") != null)
- {
- return "UTF16";
- }
- else
- {
- return UTF_16;
- }
- }
- else
- {
- // no BOM found
- in.reset();
- if (default_encoding != null && default_encoding.length() != 0)
- {
- return default_encoding;
- }
- else
- {
- return System.getProperty("file.encoding");
- }
- }
- }
- }
-
-}
+/*
+ * 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.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @exclude
+ */
+public class FileUtils
+{
+ public static final String UTF_8 = "UTF-8";
+ public static final String UTF_16 = "UTF-16";
+
+ /**
+ * Sets a mark in the InputStream for 3 bytes to check for a BOM. If the BOM
+ * stands for UTF-8 encoded content then the stream will not be reset, otherwise
+ * for UTF-16 with a BOM or any other encoding situation the stream is reset to the
+ * mark (as for UTF-16 the parser will handle the BOM).
+ *
+ * @param in InputStream containing BOM and must support mark().
+ * @param default_encoding The default character set encoding. null or "" => system default
+ * @return The file character set encoding.
+ * @throws IOException
+ */
+ public static final String consumeBOM(InputStream in, String default_encoding) throws IOException
+ {
+ in.mark(3);
+
+ // Determine file encoding...
+ // ASCII - no header (use the supplied encoding)
+ // UTF8 - EF BB BF
+ // UTF16 - FF FE or FE FF (decoder chooses endian-ness)
+ if (in.read() == 0xef && in.read() == 0xbb && in.read() == 0xbf)
+ {
+ // UTF-8 reader does not consume BOM, so do not reset
+ if (System.getProperty("flex.platform.CLR") != null)
+ {
+ return "UTF8";
+ }
+ else
+ {
+ return UTF_8;
+ }
+ }
+ else
+ {
+ in.reset();
+ int b0 = in.read();
+ int b1 = in.read();
+ if (b0 == 0xff && b1 == 0xfe || b0 == 0xfe && b1 == 0xff)
+ {
+ in.reset();
+ // UTF-16 reader will consume BOM
+ if (System.getProperty("flex.platform.CLR") != null)
+ {
+ return "UTF16";
+ }
+ else
+ {
+ return UTF_16;
+ }
+ }
+ else
+ {
+ // no BOM found
+ in.reset();
+ if (default_encoding != null && default_encoding.length() != 0)
+ {
+ return default_encoding;
+ }
+ else
+ {
+ return System.getProperty("file.encoding");
+ }
+ }
+ }
+ }
+
+}
[18/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/cluster/ClusterManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/cluster/ClusterManager.java b/modules/core/src/flex/messaging/cluster/ClusterManager.java
old mode 100755
new mode 100644
index d3a4196..0e88fe1
--- a/modules/core/src/flex/messaging/cluster/ClusterManager.java
+++ b/modules/core/src/flex/messaging/cluster/ClusterManager.java
@@ -1,673 +1,673 @@
-/*
- * 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.io.InputStream;
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Collections;
-import java.util.TreeSet;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import flex.messaging.Destination;
-import flex.messaging.MessageBroker;
-import flex.messaging.config.ClusterSettings;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.endpoints.Endpoint;
-import flex.messaging.util.ClassUtil;
-
-/**
- * @exclude
- * The manager of all clusters defined in services-config.xml, and the broker
- * for the clusters created for clustered destinations.
- */
-public class ClusterManager
-{
- /**
- * Supported operations.
- */
- public static final String OPERATION_ADD_ENDPOINT_FOR_CHANNEL = "addEndpointForChannel";
- public static final String OPERATION_SEND_ENDPOINT_URL = "sendEndpointUrl";
- public static final String OPERATION_RECEIVE_ENDPOINT_URL = "receiveEndpointUrl";
-
- public static final String OPERATION_PUSH_MESSAGE_FROM_PEER = "pushMessageFromPeer";
- public static final String OPERATION_PEER_SYNC_AND_PUSH = "peerSyncAndPush";
- public static final String OPERATION_REQUEST_ADAPTER_STATE = "requestAdapterState";
- public static final String OPERATION_RECEIVE_ADAPTER_STATE = "receiveAdapterState";
- public static final String OPERATION_SEND_SUBSCRIPTIONS = "sendSubscriptions";
- public static final String OPERATION_RECEIVE_SUBSCRIPTIONS = "receiveSubscriptions";
- public static final String OPERATION_SUBSCRIBE_FROM_PEER = "subscribeFromPeer";
- public static final String OPERATION_PUSH_MESSAGE_FROM_PEER_TO_PEER = "pushMessageFromPeerToPeer";
- public static final String OPERATION_PEER_SYNC_AND_PUSH_ONE_TO_PEER = "peerSyncAndPushOneToPeer";
-
- /**
- * A link to the MessageBroker.
- */
- private MessageBroker broker;
-
- /**
- * A mapping between the cluster ids and the Cluster instances.
- * name=clusterId value=clusterInstance
- */
- private LinkedHashMap<String,Cluster> clusters;
-
- /**
- * A mapping between destinations and the Cluster instances.
- */
- private Map<String, Cluster> clustersForDestination;
-
- /**
- * A mapping between cluster ids and their configuration files.
- * name=clusterId value=propsFile
- */
- private Map<String, Element> clusterConfig;
-
- /**
- * A mapping between cluster ids and ClusterSettings instances.
- * name=clusterId value=ClusterSettings
- */
- private Map<String, ClusterSettings> clusterSettings;
-
- /**
- * A mapped between destinations and a boolean representing
- * whether or not the backend for the destination is shared.
- */
- private Map<String, Boolean> backendSharedForDestination;
-
- /**
- * The default cluster when the cluster id for the destination
- * is unspecified.
- */
- private Cluster defaultCluster;
-
- /**
- * The id of the default cluster.
- */
- private String defaultClusterId;
-
- /**
- * The manager of all clusters defined in services-config.xml, and the broker
- * for the clusters created for clustered destinations. This class provides
- * an entry point and abstraction to the logical cluster implementation as
- * well as the specific cluster implementation.
- * @param broker the message broker which uses the cluster manager
- */
- public ClusterManager(MessageBroker broker)
- {
- this.broker = broker;
- clusters = new LinkedHashMap<String,Cluster>();
- clusterConfig = new HashMap<String, Element>();
- clusterSettings = new HashMap<String, ClusterSettings>();
- clustersForDestination = new HashMap<String,Cluster>();
- backendSharedForDestination = new HashMap<String, Boolean>();
- }
-
- /**
- * The MessageBroker for this cluster.
- *
- * @return The defined MessageBroker.
- */
- public MessageBroker getMessageBroker()
- {
- return broker;
- }
-
- /**
- * The default cluster when the cluster id for the destination
- * is unspecified.
- * @return Cluster the default Cluster to use
- */
- public Cluster getDefaultCluster()
- {
- return defaultCluster;
- }
-
- /**
- * The id of the default cluster.
- * @return String the default cluster ID
- */
- public String getDefaultClusterId()
- {
- return defaultClusterId;
- }
-
- /**
- * Invoke an endpoint operation across the cluster.
- * <p>
- * NOTE: Endpoints don't reference a specific cluster so the default cluster is used for the broadcast.
- * If no default cluster is defined the operation is broadcast over all defined clusters.
- * </p>
- *
- * @param endpointId The id of the remote endpoint across the cluster to invoke an operation on.
- * @param operationName The name of the operation to invoke.
- * @param params The arguments to use for operation invocation.
- */
- public void invokeEndpointOperation(String endpointId, String operationName, Object[] params)
- {
- Object[] arguments = new Object[2 + params.length];
- arguments[0] = endpointId;
- arguments[1] = operationName;
- int n = params.length;
- for (int i = 2, j = 0; j < n; ++i, ++j)
- arguments[i] = params[j];
-
- if (defaultCluster != null)
- {
- defaultCluster.broadcastServiceOperation(operationName, arguments);
- }
- else
- {
- for (Cluster cluster : clusters.values())
- cluster.broadcastServiceOperation(operationName, arguments);
- }
- }
-
- /**
- * Invoke an endpoint operation on a specific peer within the cluster.
- * <p>
- * NOTE: Endpoints don't reference a specific cluster so the default cluster is used for the broadcast.
- * If no default cluster is defined the operation is broadcast over all defined clusters.
- * </p>
- *
- * @param endpointId The id of the remote endpoint across the cluster to invoke an operation on.
- * @param operationName The name of the operation to invoke.
- * @param params The arguments to use for operation invocation.
- * @param targetAddress The peer node that the operation should be invoked on.
- */
- public void invokePeerToPeerEndpointOperation(String endpointId, String operationName, Object[] params, Object targetAddress)
- {
- Object[] arguments = new Object[2 + params.length];
- arguments[0] = endpointId;
- arguments[1] = operationName;
- int n = params.length;
- for (int i = 2, j = 0; j < n; ++i, ++j)
- arguments[i] = params[j];
-
- if (defaultCluster != null)
- {
- defaultCluster.sendPointToPointServiceOperation(operationName, arguments, targetAddress);
- }
- else
- {
- for (Cluster cluster : clusters.values())
- {
- cluster.sendPointToPointServiceOperation(operationName, arguments, targetAddress);
- }
- }
- }
-
- /**
- * Invoke 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. Invoke the service operation for the cluster, identified by
- * serviceType and destinationName.
- *
- * @param serviceType The name for the service for this destination.
- * @param destinationName The name of the destination.
- * @param operationName The name of the service operation to invoke.
- * @param params Parameters needed for the service operation.
- */
- public void invokeServiceOperation(String serviceType, String destinationName,
- String operationName, Object[] params)
- {
- Cluster c = getCluster(serviceType,destinationName);
- ArrayList newParams = new ArrayList(Arrays.asList(params));
- newParams.add(0, serviceType);
- newParams.add(1, destinationName);
- c.broadcastServiceOperation(operationName, newParams.toArray());
- }
-
- /**
- * Send a service-related operation in point-to-point fashion to one and only one member of the cluster.
- * This is similar to the invokeServiceOperation except that this invocation is sent to the node,
- * identified by targetAddress.
- *
- * @param serviceType The name for the service for this destination.
- * @param destinationName The name of the destination.
- * @param operationName The name of the service operation to invoke.
- * @param params Parameters needed for the service operation.
- * @param targetAddress The node that the operation should be passed to.
- */
- public void invokePeerToPeerOperation(String serviceType, String destinationName,
- String operationName, Object[] params, Object targetAddress)
- {
- Cluster c = getCluster(serviceType,destinationName);
- ArrayList newParams = new ArrayList(Arrays.asList(params));
- newParams.add(0, serviceType);
- newParams.add(1, destinationName);
- c.sendPointToPointServiceOperation(operationName, newParams.toArray(), targetAddress);
- }
-
- /**
- * Determines whether the given destination is clustered.
- *
- * @param serviceType The name for the service for this destination.
- * @param destinationName The name of the destination.
- * @return Whether the destination is a clustered destination.
- */
- public boolean isDestinationClustered(String serviceType, String destinationName)
- {
- return getCluster(serviceType, destinationName) != null;
- }
-
- /**
- * Checks whether the give destination is configured for a shared backend.
- *
- * @param serviceType The name of the service for this destination.
- * @param destinationName The name of the destination.
- * @return Whether the destination is configured for shared backend.
- */
- public boolean isBackendShared(String serviceType, String destinationName)
- {
- String destKey = Cluster.getClusterDestinationKey(serviceType, destinationName);
- Boolean shared = backendSharedForDestination.get(destKey);
- return shared != null? shared.booleanValue() : false;
- }
-
- /**
- * Retrieves a list of cluster nodes for the given cluster.
- *
- * @param serviceType The name of the service for the clustered destination.
- * @param destinationName The name of the destination.
- * @return List of cluster nodes for the given cluster.
- */
- public List getClusterMemberAddresses(String serviceType, String destinationName)
- {
- Cluster c= getCluster(serviceType, destinationName);
- return c != null? c.getMemberAddresses() : Collections.EMPTY_LIST;
- }
-
- /**
- * Used for targeted endpoint operation invocations across the cluster.
- * If a default cluster is defined, its list of member addresses is returned.
- * Otherwise, a de-duped list of all member addresses from all registered clusters is returned.
- *
- * @return The list of cluster nodes that endpoint operation invocations can be issued against.
- */
- public List getClusterMemberAddresses()
- {
- if (defaultCluster != null)
- return defaultCluster.getMemberAddresses();
-
- TreeSet uniqueAddresses = new TreeSet();
- for (Cluster cluster : clusters.values())
- uniqueAddresses.addAll(cluster.getMemberAddresses());
-
- return new ArrayList(uniqueAddresses);
- }
-
- /**
- * Find the properties file in the given cluster settings. Read the XML based
- * cluster configuration file and save the settings and configuration for the
- * given cluster for retrieval later.
- *
- * @param settings The cluster settings for a specific cluster.
- */
- public void prepareCluster(ClusterSettings settings)
- {
- String propsFileName = settings.getPropsFileName();
-
- checkForNullPropertiesFile(settings.getClusterName(), propsFileName);
-
- InputStream propsFile = resolveInternalPath(propsFileName);
-
- if( propsFile == null )
- propsFile = resolveExternalPath(propsFileName);
-
- if (propsFile == null)
- throwClusterException(10208, new Object[] {propsFileName}, null);
-
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(false);
- factory.setValidating(false);
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(propsFile);
- if (settings.isDefault())
- defaultClusterId = settings.getClusterName();
- clusterConfig.put(settings.getClusterName(), doc.getDocumentElement());
- clusterSettings.put(settings.getClusterName(), settings);
- }
- catch (Exception ex)
- {
- throwClusterException(10213, new Object[] {propsFileName}, ex);
- }
- }
-
- /**
- * Retrieve the local address for the specified clustered destination.
- *
- * @param serviceType The service type of the clustered destination.
- * @param destinationName The name of the clustered destination.
- * @return The local address of the clustered destination.
- */
- public Object getLocalAddress(String serviceType, String destinationName)
- {
- Cluster c = getCluster(serviceType, destinationName);
- return c != null? c.getLocalAddress() : null;
- }
-
- /**
- * Retrieve the local address for the default cluster or if no default cluster is defined
- * return the local address derived from the first cluster of any defined.
- *
- * @return The local address for this cluster node, or <code>null</code> if this node
- * is not a member of any cluster.
- */
- public Object getLocalAddress()
- {
- if (defaultCluster != null)
- return defaultCluster.getLocalAddress();
-
- // Else, use first defined cluster.
- for (Entry<String,Cluster> entry : clusters.entrySet())
- return entry.getValue().getLocalAddress();
-
- return null; // No cluster defined.
- }
-
- /**
- * Find the cluster for the specified cluster id.
- *
- * @param clusterId the cluster ID
- * @return The cluster identified by the given id.
- */
- public Cluster getClusterById(String clusterId)
- {
- return clusters.get(clusterId);
- }
-
- /**
- * Find the cluster identified by the service type and destination name.
- *
- * @param serviceType The service type of the clustered destination.
- * @param destinationName The name of the clustered destination.
- * @return The cluster identified by the serviec type and destination naem.
- */
- public Cluster getCluster(String serviceType, String destinationName)
- {
- Cluster cluster = null;
- try
- {
- String destKey = Cluster.getClusterDestinationKey(serviceType, destinationName);
-
- cluster = clustersForDestination.get(destKey);
-
- if (cluster == null)
- cluster = defaultCluster;
- }
- catch (NoClassDefFoundError nex)
- {
- ClusterException cx = new ClusterException();
- cx.setMessage(10202, new Object[] { destinationName });
- cx.setRootCause(nex);
- throw cx;
- }
- return cluster;
- }
-
- /**
- * Call destroy on each of the managed clusters.
- */
- public void destroyClusters()
- {
- for (Iterator<Cluster> iter=clusters.values().iterator(); iter.hasNext(); )
- {
- Cluster cluster = iter.next();
- cluster.destroy();
- iter.remove();
- }
- }
-
- /**
- * Add the specified destination to the cluster, identitied by clusterId if available. If the cluster
- * is not currently defined, create the cluster. Also, setup the load balancing urls and shared
- * backend information for this clustered destination and endpoint.
- *
- * @param clusterId The cluster id that this destination wants to be associated with.
- * @param serviceType The service type for the clustered destination.
- * @param destinationName The name of the clustered destination.
- * @param channelId The channel id that should be added to the cluster load balancing.
- * @param endpointUrl The endpoint url that should be added to the cluster load balancing.
- * @param endpointPort The endpoint port that should be added to the cluster load balancing.
- * @param sharedBackend Whether the destination has shared backend set to true or not.
- */
- public void clusterDestinationChannel(String clusterId, String serviceType, String destinationName,
- String channelId, String endpointUrl, int endpointPort, boolean sharedBackend)
- {
- Cluster cluster = getClusterById(clusterId);
- String destKey = Cluster.getClusterDestinationKey(serviceType, destinationName);
- if (cluster == null)
- {
- if (!clusterConfig.containsKey(clusterId))
- {
- ClusterException cx = new ClusterException();
- cx.setMessage(10207, new Object[] { destinationName, clusterId });
- throw cx;
- }
- cluster = createCluster(clusterId, serviceType, destinationName);
- }
- else
- {
- clustersForDestination.put(destKey, cluster);
- }
- backendSharedForDestination.put(destKey, sharedBackend ? Boolean.TRUE : Boolean.FALSE);
-
- if (cluster.getURLLoadBalancing())
- cluster.addLocalEndpointForChannel(serviceType, destinationName,
- channelId, endpointUrl, endpointPort);
- }
-
- /**
- * Adds the destination to the cluster. The settings for the clustered destination are
- * available from the <code>Destination</code> object.
- *
- * @param destination The destination to be clustered.
- */
- public void clusterDestination(Destination destination)
- {
- String clusterId = destination.getNetworkSettings().getClusterId();
- if (clusterId == null)
- clusterId = getDefaultClusterId();
-
- ClusterSettings cls = clusterSettings.get(clusterId);
- if (cls == null)
- {
- ClusterException ce = new ClusterException();
- ce.setMessage(10217, new Object[] {destination.getId(), clusterId});
- throw ce;
- }
-
- for (String channelId : destination.getChannels())
- {
- Endpoint endpoint = broker.getEndpoint(channelId);
- String endpointUrl = endpoint.getUrl();
- int endpointPort = endpoint.getPort();
-
- // This is only an error if we are using client side url-based load balancing. If
- // there is a HW load balancer, then we can assume the server.name served up by the
- // SWF can be used to access the cluster members. With client side load balancing,
- // the clients need the direct URLs of all of the servers.
- if (cls.getURLLoadBalancing())
- {
- // Ensure that the endpoint URI does not contain any replacement tokens.
- int tokenStart = endpointUrl.indexOf('{');
- if (tokenStart != -1)
- {
- int tokenEnd = endpointUrl.indexOf('}', tokenStart);
- if (tokenEnd == -1)
- tokenEnd = endpointUrl.length();
- else
- tokenEnd++;
-
- ClusterException ce = new ClusterException();
- ce.setMessage(10209, new Object[] {destination.getId(), channelId, endpointUrl.substring(tokenStart, tokenEnd)});
- throw ce;
- }
- }
-
- clusterDestinationChannel(clusterId, destination.getServiceType(),
- destination.getId(), channelId, endpointUrl, endpointPort, destination.getNetworkSettings().isSharedBackend());
- }
- }
-
- /**
- * Get a list of endpoints for the destination.
- * @param serviceType the service type
- * @param destinationName destination name
- * @return List the list endpoints that the destination can use
- */
- public List getEndpointsForDestination(String serviceType, String destinationName)
- {
- Cluster c = getCluster(serviceType, destinationName);
- return c != null? c.getAllEndpoints(serviceType, destinationName) : null;
- }
-
-
- private void checkForNullPropertiesFile(String clusterName, String propsFileName)
- {
- if (propsFileName == null)
- throwClusterException(10201, new Object[] {clusterName, propsFileName}, null);
- }
-
- /**
- * Create the cluster based on the cluster settings already available. The cluster
- * is added to the cluster managers list of clusters indexed by the cluster id.
- * The cluster is also associated with the specified service type and destination
- * name. The cluster id is unique across all clusters managed by this cluster
- * manager. The cluster may be associated with more than one cluster destination.
- *
- * @param clusterId The cluster id.
- * @param serviceType The service type of the clustered destination.
- * @param destinationName The destination name for the clustered destination.
- * @return The new cluster.
- */
- private Cluster createCluster(String clusterId, String serviceType, String destinationName)
- {
- String destKey = Cluster.getClusterDestinationKey(serviceType, destinationName);
- Element propsFile = clusterConfig.get(clusterId);
- ClusterSettings cls = clusterSettings.get(clusterId);
- Cluster cluster = null;
- Class clusterClass = ClassUtil.createClass(cls.getImplementationClass());
- Constructor clusterConstructor = null;
- try
- {
- clusterConstructor = clusterClass.getConstructor(new Class[] {ClusterManager.class});
- }
- catch (Exception e)
- {
- ClusterException cx = new ClusterException();
- cx.setMessage(10210);
- cx.setRootCause(e);
- throw cx;
- }
- try
- {
- cluster = (Cluster)clusterConstructor.newInstance(new Object[] {this});
- cluster.setClusterPropertiesFile(propsFile);
- cluster.setURLLoadBalancing(cls.getURLLoadBalancing());
- cluster.initialize(clusterId, cls.getProperties());
- }
- catch (Exception e)
- {
- ClusterException cx = new ClusterException();
- cx.setMessage(10211);
- cx.setRootCause(e);
- throw cx;
- }
- clustersForDestination.put(destKey, cluster);
- clusters.put(clusterId, cluster);
-
- if (defaultClusterId != null && defaultClusterId.equals(clusterId))
- defaultCluster = cluster;
-
- return cluster;
- }
-
- private InputStream resolveExternalPath(String propsFileName)
- {
- try
- {
- return broker.resolveExternalPath(propsFileName);
- }
- catch (Throwable t)
- {
- throwClusterException(10208, new Object[] {propsFileName}, t);
- }
- return null;
- }
-
- private InputStream resolveInternalPath(String propsFileName)
- {
- try
- {
- return broker.resolveInternalPath(propsFileName);
- }
- catch (Throwable t)
- {
- throwClusterException(10208, new Object[] {propsFileName}, t);
- }
- return null;
- }
-
- private void throwClusterException(int number, Object[] args, Throwable t)
- {
- ClusterException cx = new ClusterException();
- cx.setMessage(number, args);
- if (t != null)
- cx.setRootCause(t);
- throw cx;
- }
-
- /**
- * Return a {@link ConfigMap} describing the clusters that have been added to the cluster manager
- *
- * @return a ConfigMap of the clusters
- */
- public ConfigMap describeClusters()
- {
- ConfigMap result = new ConfigMap();
- for (Entry<String, Cluster> entry: clusters.entrySet())
- {
- Cluster cluster = entry.getValue();
- ConfigMap clusterMap = new ConfigMap();
- clusterMap.put("id", entry.getKey());
- ClusterSettings settings = clusterSettings.get(entry.getKey());
- clusterMap.put("properties", settings.getPropsFileName());
- if (settings.isDefault())
- {
- clusterMap.put("default", "true");
- }
- clusterMap.put("class", cluster.getClass().getCanonicalName());
-
- result.addProperty("cluster", clusterMap);
- }
- return result;
- }
+/*
+ * 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.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Collections;
+import java.util.TreeSet;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import flex.messaging.Destination;
+import flex.messaging.MessageBroker;
+import flex.messaging.config.ClusterSettings;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.endpoints.Endpoint;
+import flex.messaging.util.ClassUtil;
+
+/**
+ * @exclude
+ * The manager of all clusters defined in services-config.xml, and the broker
+ * for the clusters created for clustered destinations.
+ */
+public class ClusterManager
+{
+ /**
+ * Supported operations.
+ */
+ public static final String OPERATION_ADD_ENDPOINT_FOR_CHANNEL = "addEndpointForChannel";
+ public static final String OPERATION_SEND_ENDPOINT_URL = "sendEndpointUrl";
+ public static final String OPERATION_RECEIVE_ENDPOINT_URL = "receiveEndpointUrl";
+
+ public static final String OPERATION_PUSH_MESSAGE_FROM_PEER = "pushMessageFromPeer";
+ public static final String OPERATION_PEER_SYNC_AND_PUSH = "peerSyncAndPush";
+ public static final String OPERATION_REQUEST_ADAPTER_STATE = "requestAdapterState";
+ public static final String OPERATION_RECEIVE_ADAPTER_STATE = "receiveAdapterState";
+ public static final String OPERATION_SEND_SUBSCRIPTIONS = "sendSubscriptions";
+ public static final String OPERATION_RECEIVE_SUBSCRIPTIONS = "receiveSubscriptions";
+ public static final String OPERATION_SUBSCRIBE_FROM_PEER = "subscribeFromPeer";
+ public static final String OPERATION_PUSH_MESSAGE_FROM_PEER_TO_PEER = "pushMessageFromPeerToPeer";
+ public static final String OPERATION_PEER_SYNC_AND_PUSH_ONE_TO_PEER = "peerSyncAndPushOneToPeer";
+
+ /**
+ * A link to the MessageBroker.
+ */
+ private MessageBroker broker;
+
+ /**
+ * A mapping between the cluster ids and the Cluster instances.
+ * name=clusterId value=clusterInstance
+ */
+ private LinkedHashMap<String,Cluster> clusters;
+
+ /**
+ * A mapping between destinations and the Cluster instances.
+ */
+ private Map<String, Cluster> clustersForDestination;
+
+ /**
+ * A mapping between cluster ids and their configuration files.
+ * name=clusterId value=propsFile
+ */
+ private Map<String, Element> clusterConfig;
+
+ /**
+ * A mapping between cluster ids and ClusterSettings instances.
+ * name=clusterId value=ClusterSettings
+ */
+ private Map<String, ClusterSettings> clusterSettings;
+
+ /**
+ * A mapped between destinations and a boolean representing
+ * whether or not the backend for the destination is shared.
+ */
+ private Map<String, Boolean> backendSharedForDestination;
+
+ /**
+ * The default cluster when the cluster id for the destination
+ * is unspecified.
+ */
+ private Cluster defaultCluster;
+
+ /**
+ * The id of the default cluster.
+ */
+ private String defaultClusterId;
+
+ /**
+ * The manager of all clusters defined in services-config.xml, and the broker
+ * for the clusters created for clustered destinations. This class provides
+ * an entry point and abstraction to the logical cluster implementation as
+ * well as the specific cluster implementation.
+ * @param broker the message broker which uses the cluster manager
+ */
+ public ClusterManager(MessageBroker broker)
+ {
+ this.broker = broker;
+ clusters = new LinkedHashMap<String,Cluster>();
+ clusterConfig = new HashMap<String, Element>();
+ clusterSettings = new HashMap<String, ClusterSettings>();
+ clustersForDestination = new HashMap<String,Cluster>();
+ backendSharedForDestination = new HashMap<String, Boolean>();
+ }
+
+ /**
+ * The MessageBroker for this cluster.
+ *
+ * @return The defined MessageBroker.
+ */
+ public MessageBroker getMessageBroker()
+ {
+ return broker;
+ }
+
+ /**
+ * The default cluster when the cluster id for the destination
+ * is unspecified.
+ * @return Cluster the default Cluster to use
+ */
+ public Cluster getDefaultCluster()
+ {
+ return defaultCluster;
+ }
+
+ /**
+ * The id of the default cluster.
+ * @return String the default cluster ID
+ */
+ public String getDefaultClusterId()
+ {
+ return defaultClusterId;
+ }
+
+ /**
+ * Invoke an endpoint operation across the cluster.
+ * <p>
+ * NOTE: Endpoints don't reference a specific cluster so the default cluster is used for the broadcast.
+ * If no default cluster is defined the operation is broadcast over all defined clusters.
+ * </p>
+ *
+ * @param endpointId The id of the remote endpoint across the cluster to invoke an operation on.
+ * @param operationName The name of the operation to invoke.
+ * @param params The arguments to use for operation invocation.
+ */
+ public void invokeEndpointOperation(String endpointId, String operationName, Object[] params)
+ {
+ Object[] arguments = new Object[2 + params.length];
+ arguments[0] = endpointId;
+ arguments[1] = operationName;
+ int n = params.length;
+ for (int i = 2, j = 0; j < n; ++i, ++j)
+ arguments[i] = params[j];
+
+ if (defaultCluster != null)
+ {
+ defaultCluster.broadcastServiceOperation(operationName, arguments);
+ }
+ else
+ {
+ for (Cluster cluster : clusters.values())
+ cluster.broadcastServiceOperation(operationName, arguments);
+ }
+ }
+
+ /**
+ * Invoke an endpoint operation on a specific peer within the cluster.
+ * <p>
+ * NOTE: Endpoints don't reference a specific cluster so the default cluster is used for the broadcast.
+ * If no default cluster is defined the operation is broadcast over all defined clusters.
+ * </p>
+ *
+ * @param endpointId The id of the remote endpoint across the cluster to invoke an operation on.
+ * @param operationName The name of the operation to invoke.
+ * @param params The arguments to use for operation invocation.
+ * @param targetAddress The peer node that the operation should be invoked on.
+ */
+ public void invokePeerToPeerEndpointOperation(String endpointId, String operationName, Object[] params, Object targetAddress)
+ {
+ Object[] arguments = new Object[2 + params.length];
+ arguments[0] = endpointId;
+ arguments[1] = operationName;
+ int n = params.length;
+ for (int i = 2, j = 0; j < n; ++i, ++j)
+ arguments[i] = params[j];
+
+ if (defaultCluster != null)
+ {
+ defaultCluster.sendPointToPointServiceOperation(operationName, arguments, targetAddress);
+ }
+ else
+ {
+ for (Cluster cluster : clusters.values())
+ {
+ cluster.sendPointToPointServiceOperation(operationName, arguments, targetAddress);
+ }
+ }
+ }
+
+ /**
+ * Invoke 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. Invoke the service operation for the cluster, identified by
+ * serviceType and destinationName.
+ *
+ * @param serviceType The name for the service for this destination.
+ * @param destinationName The name of the destination.
+ * @param operationName The name of the service operation to invoke.
+ * @param params Parameters needed for the service operation.
+ */
+ public void invokeServiceOperation(String serviceType, String destinationName,
+ String operationName, Object[] params)
+ {
+ Cluster c = getCluster(serviceType,destinationName);
+ ArrayList newParams = new ArrayList(Arrays.asList(params));
+ newParams.add(0, serviceType);
+ newParams.add(1, destinationName);
+ c.broadcastServiceOperation(operationName, newParams.toArray());
+ }
+
+ /**
+ * Send a service-related operation in point-to-point fashion to one and only one member of the cluster.
+ * This is similar to the invokeServiceOperation except that this invocation is sent to the node,
+ * identified by targetAddress.
+ *
+ * @param serviceType The name for the service for this destination.
+ * @param destinationName The name of the destination.
+ * @param operationName The name of the service operation to invoke.
+ * @param params Parameters needed for the service operation.
+ * @param targetAddress The node that the operation should be passed to.
+ */
+ public void invokePeerToPeerOperation(String serviceType, String destinationName,
+ String operationName, Object[] params, Object targetAddress)
+ {
+ Cluster c = getCluster(serviceType,destinationName);
+ ArrayList newParams = new ArrayList(Arrays.asList(params));
+ newParams.add(0, serviceType);
+ newParams.add(1, destinationName);
+ c.sendPointToPointServiceOperation(operationName, newParams.toArray(), targetAddress);
+ }
+
+ /**
+ * Determines whether the given destination is clustered.
+ *
+ * @param serviceType The name for the service for this destination.
+ * @param destinationName The name of the destination.
+ * @return Whether the destination is a clustered destination.
+ */
+ public boolean isDestinationClustered(String serviceType, String destinationName)
+ {
+ return getCluster(serviceType, destinationName) != null;
+ }
+
+ /**
+ * Checks whether the give destination is configured for a shared backend.
+ *
+ * @param serviceType The name of the service for this destination.
+ * @param destinationName The name of the destination.
+ * @return Whether the destination is configured for shared backend.
+ */
+ public boolean isBackendShared(String serviceType, String destinationName)
+ {
+ String destKey = Cluster.getClusterDestinationKey(serviceType, destinationName);
+ Boolean shared = backendSharedForDestination.get(destKey);
+ return shared != null? shared.booleanValue() : false;
+ }
+
+ /**
+ * Retrieves a list of cluster nodes for the given cluster.
+ *
+ * @param serviceType The name of the service for the clustered destination.
+ * @param destinationName The name of the destination.
+ * @return List of cluster nodes for the given cluster.
+ */
+ public List getClusterMemberAddresses(String serviceType, String destinationName)
+ {
+ Cluster c= getCluster(serviceType, destinationName);
+ return c != null? c.getMemberAddresses() : Collections.EMPTY_LIST;
+ }
+
+ /**
+ * Used for targeted endpoint operation invocations across the cluster.
+ * If a default cluster is defined, its list of member addresses is returned.
+ * Otherwise, a de-duped list of all member addresses from all registered clusters is returned.
+ *
+ * @return The list of cluster nodes that endpoint operation invocations can be issued against.
+ */
+ public List getClusterMemberAddresses()
+ {
+ if (defaultCluster != null)
+ return defaultCluster.getMemberAddresses();
+
+ TreeSet uniqueAddresses = new TreeSet();
+ for (Cluster cluster : clusters.values())
+ uniqueAddresses.addAll(cluster.getMemberAddresses());
+
+ return new ArrayList(uniqueAddresses);
+ }
+
+ /**
+ * Find the properties file in the given cluster settings. Read the XML based
+ * cluster configuration file and save the settings and configuration for the
+ * given cluster for retrieval later.
+ *
+ * @param settings The cluster settings for a specific cluster.
+ */
+ public void prepareCluster(ClusterSettings settings)
+ {
+ String propsFileName = settings.getPropsFileName();
+
+ checkForNullPropertiesFile(settings.getClusterName(), propsFileName);
+
+ InputStream propsFile = resolveInternalPath(propsFileName);
+
+ if( propsFile == null )
+ propsFile = resolveExternalPath(propsFileName);
+
+ if (propsFile == null)
+ throwClusterException(10208, new Object[] {propsFileName}, null);
+
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(false);
+ factory.setValidating(false);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(propsFile);
+ if (settings.isDefault())
+ defaultClusterId = settings.getClusterName();
+ clusterConfig.put(settings.getClusterName(), doc.getDocumentElement());
+ clusterSettings.put(settings.getClusterName(), settings);
+ }
+ catch (Exception ex)
+ {
+ throwClusterException(10213, new Object[] {propsFileName}, ex);
+ }
+ }
+
+ /**
+ * Retrieve the local address for the specified clustered destination.
+ *
+ * @param serviceType The service type of the clustered destination.
+ * @param destinationName The name of the clustered destination.
+ * @return The local address of the clustered destination.
+ */
+ public Object getLocalAddress(String serviceType, String destinationName)
+ {
+ Cluster c = getCluster(serviceType, destinationName);
+ return c != null? c.getLocalAddress() : null;
+ }
+
+ /**
+ * Retrieve the local address for the default cluster or if no default cluster is defined
+ * return the local address derived from the first cluster of any defined.
+ *
+ * @return The local address for this cluster node, or <code>null</code> if this node
+ * is not a member of any cluster.
+ */
+ public Object getLocalAddress()
+ {
+ if (defaultCluster != null)
+ return defaultCluster.getLocalAddress();
+
+ // Else, use first defined cluster.
+ for (Entry<String,Cluster> entry : clusters.entrySet())
+ return entry.getValue().getLocalAddress();
+
+ return null; // No cluster defined.
+ }
+
+ /**
+ * Find the cluster for the specified cluster id.
+ *
+ * @param clusterId the cluster ID
+ * @return The cluster identified by the given id.
+ */
+ public Cluster getClusterById(String clusterId)
+ {
+ return clusters.get(clusterId);
+ }
+
+ /**
+ * Find the cluster identified by the service type and destination name.
+ *
+ * @param serviceType The service type of the clustered destination.
+ * @param destinationName The name of the clustered destination.
+ * @return The cluster identified by the serviec type and destination naem.
+ */
+ public Cluster getCluster(String serviceType, String destinationName)
+ {
+ Cluster cluster = null;
+ try
+ {
+ String destKey = Cluster.getClusterDestinationKey(serviceType, destinationName);
+
+ cluster = clustersForDestination.get(destKey);
+
+ if (cluster == null)
+ cluster = defaultCluster;
+ }
+ catch (NoClassDefFoundError nex)
+ {
+ ClusterException cx = new ClusterException();
+ cx.setMessage(10202, new Object[] { destinationName });
+ cx.setRootCause(nex);
+ throw cx;
+ }
+ return cluster;
+ }
+
+ /**
+ * Call destroy on each of the managed clusters.
+ */
+ public void destroyClusters()
+ {
+ for (Iterator<Cluster> iter=clusters.values().iterator(); iter.hasNext(); )
+ {
+ Cluster cluster = iter.next();
+ cluster.destroy();
+ iter.remove();
+ }
+ }
+
+ /**
+ * Add the specified destination to the cluster, identitied by clusterId if available. If the cluster
+ * is not currently defined, create the cluster. Also, setup the load balancing urls and shared
+ * backend information for this clustered destination and endpoint.
+ *
+ * @param clusterId The cluster id that this destination wants to be associated with.
+ * @param serviceType The service type for the clustered destination.
+ * @param destinationName The name of the clustered destination.
+ * @param channelId The channel id that should be added to the cluster load balancing.
+ * @param endpointUrl The endpoint url that should be added to the cluster load balancing.
+ * @param endpointPort The endpoint port that should be added to the cluster load balancing.
+ * @param sharedBackend Whether the destination has shared backend set to true or not.
+ */
+ public void clusterDestinationChannel(String clusterId, String serviceType, String destinationName,
+ String channelId, String endpointUrl, int endpointPort, boolean sharedBackend)
+ {
+ Cluster cluster = getClusterById(clusterId);
+ String destKey = Cluster.getClusterDestinationKey(serviceType, destinationName);
+ if (cluster == null)
+ {
+ if (!clusterConfig.containsKey(clusterId))
+ {
+ ClusterException cx = new ClusterException();
+ cx.setMessage(10207, new Object[] { destinationName, clusterId });
+ throw cx;
+ }
+ cluster = createCluster(clusterId, serviceType, destinationName);
+ }
+ else
+ {
+ clustersForDestination.put(destKey, cluster);
+ }
+ backendSharedForDestination.put(destKey, sharedBackend ? Boolean.TRUE : Boolean.FALSE);
+
+ if (cluster.getURLLoadBalancing())
+ cluster.addLocalEndpointForChannel(serviceType, destinationName,
+ channelId, endpointUrl, endpointPort);
+ }
+
+ /**
+ * Adds the destination to the cluster. The settings for the clustered destination are
+ * available from the <code>Destination</code> object.
+ *
+ * @param destination The destination to be clustered.
+ */
+ public void clusterDestination(Destination destination)
+ {
+ String clusterId = destination.getNetworkSettings().getClusterId();
+ if (clusterId == null)
+ clusterId = getDefaultClusterId();
+
+ ClusterSettings cls = clusterSettings.get(clusterId);
+ if (cls == null)
+ {
+ ClusterException ce = new ClusterException();
+ ce.setMessage(10217, new Object[] {destination.getId(), clusterId});
+ throw ce;
+ }
+
+ for (String channelId : destination.getChannels())
+ {
+ Endpoint endpoint = broker.getEndpoint(channelId);
+ String endpointUrl = endpoint.getUrl();
+ int endpointPort = endpoint.getPort();
+
+ // This is only an error if we are using client side url-based load balancing. If
+ // there is a HW load balancer, then we can assume the server.name served up by the
+ // SWF can be used to access the cluster members. With client side load balancing,
+ // the clients need the direct URLs of all of the servers.
+ if (cls.getURLLoadBalancing())
+ {
+ // Ensure that the endpoint URI does not contain any replacement tokens.
+ int tokenStart = endpointUrl.indexOf('{');
+ if (tokenStart != -1)
+ {
+ int tokenEnd = endpointUrl.indexOf('}', tokenStart);
+ if (tokenEnd == -1)
+ tokenEnd = endpointUrl.length();
+ else
+ tokenEnd++;
+
+ ClusterException ce = new ClusterException();
+ ce.setMessage(10209, new Object[] {destination.getId(), channelId, endpointUrl.substring(tokenStart, tokenEnd)});
+ throw ce;
+ }
+ }
+
+ clusterDestinationChannel(clusterId, destination.getServiceType(),
+ destination.getId(), channelId, endpointUrl, endpointPort, destination.getNetworkSettings().isSharedBackend());
+ }
+ }
+
+ /**
+ * Get a list of endpoints for the destination.
+ * @param serviceType the service type
+ * @param destinationName destination name
+ * @return List the list endpoints that the destination can use
+ */
+ public List getEndpointsForDestination(String serviceType, String destinationName)
+ {
+ Cluster c = getCluster(serviceType, destinationName);
+ return c != null? c.getAllEndpoints(serviceType, destinationName) : null;
+ }
+
+
+ private void checkForNullPropertiesFile(String clusterName, String propsFileName)
+ {
+ if (propsFileName == null)
+ throwClusterException(10201, new Object[] {clusterName, propsFileName}, null);
+ }
+
+ /**
+ * Create the cluster based on the cluster settings already available. The cluster
+ * is added to the cluster managers list of clusters indexed by the cluster id.
+ * The cluster is also associated with the specified service type and destination
+ * name. The cluster id is unique across all clusters managed by this cluster
+ * manager. The cluster may be associated with more than one cluster destination.
+ *
+ * @param clusterId The cluster id.
+ * @param serviceType The service type of the clustered destination.
+ * @param destinationName The destination name for the clustered destination.
+ * @return The new cluster.
+ */
+ private Cluster createCluster(String clusterId, String serviceType, String destinationName)
+ {
+ String destKey = Cluster.getClusterDestinationKey(serviceType, destinationName);
+ Element propsFile = clusterConfig.get(clusterId);
+ ClusterSettings cls = clusterSettings.get(clusterId);
+ Cluster cluster = null;
+ Class clusterClass = ClassUtil.createClass(cls.getImplementationClass());
+ Constructor clusterConstructor = null;
+ try
+ {
+ clusterConstructor = clusterClass.getConstructor(new Class[] {ClusterManager.class});
+ }
+ catch (Exception e)
+ {
+ ClusterException cx = new ClusterException();
+ cx.setMessage(10210);
+ cx.setRootCause(e);
+ throw cx;
+ }
+ try
+ {
+ cluster = (Cluster)clusterConstructor.newInstance(new Object[] {this});
+ cluster.setClusterPropertiesFile(propsFile);
+ cluster.setURLLoadBalancing(cls.getURLLoadBalancing());
+ cluster.initialize(clusterId, cls.getProperties());
+ }
+ catch (Exception e)
+ {
+ ClusterException cx = new ClusterException();
+ cx.setMessage(10211);
+ cx.setRootCause(e);
+ throw cx;
+ }
+ clustersForDestination.put(destKey, cluster);
+ clusters.put(clusterId, cluster);
+
+ if (defaultClusterId != null && defaultClusterId.equals(clusterId))
+ defaultCluster = cluster;
+
+ return cluster;
+ }
+
+ private InputStream resolveExternalPath(String propsFileName)
+ {
+ try
+ {
+ return broker.resolveExternalPath(propsFileName);
+ }
+ catch (Throwable t)
+ {
+ throwClusterException(10208, new Object[] {propsFileName}, t);
+ }
+ return null;
+ }
+
+ private InputStream resolveInternalPath(String propsFileName)
+ {
+ try
+ {
+ return broker.resolveInternalPath(propsFileName);
+ }
+ catch (Throwable t)
+ {
+ throwClusterException(10208, new Object[] {propsFileName}, t);
+ }
+ return null;
+ }
+
+ private void throwClusterException(int number, Object[] args, Throwable t)
+ {
+ ClusterException cx = new ClusterException();
+ cx.setMessage(number, args);
+ if (t != null)
+ cx.setRootCause(t);
+ throw cx;
+ }
+
+ /**
+ * Return a {@link ConfigMap} describing the clusters that have been added to the cluster manager
+ *
+ * @return a ConfigMap of the clusters
+ */
+ public ConfigMap describeClusters()
+ {
+ ConfigMap result = new ConfigMap();
+ for (Entry<String, Cluster> entry: clusters.entrySet())
+ {
+ Cluster cluster = entry.getValue();
+ ConfigMap clusterMap = new ConfigMap();
+ clusterMap.put("id", entry.getKey());
+ ClusterSettings settings = clusterSettings.get(entry.getKey());
+ clusterMap.put("properties", settings.getPropsFileName());
+ if (settings.isDefault())
+ {
+ clusterMap.put("default", "true");
+ }
+ clusterMap.put("class", cluster.getClass().getCanonicalName());
+
+ result.addProperty("cluster", clusterMap);
+ }
+ return result;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/cluster/ClusterMembershipListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/cluster/ClusterMembershipListener.java b/modules/core/src/flex/messaging/cluster/ClusterMembershipListener.java
old mode 100755
new mode 100644
index aa38e11..fd5b70d
--- a/modules/core/src/flex/messaging/cluster/ClusterMembershipListener.java
+++ b/modules/core/src/flex/messaging/cluster/ClusterMembershipListener.java
@@ -1,138 +1,138 @@
-/*
- * 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.List;
-import java.util.Vector;
-
-import org.jgroups.Address;
-import org.jgroups.MembershipListener;
-import org.jgroups.View;
-
-/**
- * @exclude
- * Clusters employ this Listener in order to respond to nodes which
- * join and abandon it. This class bridges the low-level protocol layer
- * to the more abstract logical cluster.
- */
-class ClusterMembershipListener implements MembershipListener
-{
- /**
- * The cluster implementation that owns this listener.
- */
- // TODO: The missing class JGroupsCluster seems to extend Cluster, but is missing from the repository.
-// private JGroupsCluster cluster;
-
- /**
- * The list of current cluster members as we know it.
- */
- private List<Address> members;
-
- /**
- * The list of cluster members that are not currently active.
- */
- private List<Address> zombies;
-
- /**
- * Our implementation of cluster membership listener.
- *
- * @param cluster The logical cluster implementation.
- */
- public ClusterMembershipListener(Cluster cluster)
- {
-// this.cluster = (JGroupsCluster)cluster;
- this.members = new ArrayList<Address>();
- this.zombies = new ArrayList<Address>();
- }
-
- /**
- * This method is invoked by the cluster infrastructure whenever
- * a member joins or abandons the cluster group.
- *
- * @param membershipView Snapshot of members of the cluster.
- */
- public void viewAccepted(View membershipView)
- {
- synchronized(this)
- {
- Vector<Address> currentMemberList = membershipView.getMembers();
- handleArrivingMembers(currentMemberList);
- handleDepartedMembers(membershipView, currentMemberList);
- }
- }
-
- /**
- * This method is invoked by the cluster infrastructure whenever
- * a member appears to have left the cluster, but before it has
- * been removed from the active member list. The Cluster treats
- * these addresses as zombies and will not use their channel and
- * endpoint information.
- *
- * @param zombieAddress The address of the suspect node.
- */
- public void suspect(Address zombieAddress)
- {
- synchronized(this)
- {
- zombies.add(zombieAddress);
- }
- }
-
- /**
- * This method from the core MembershipListener is a no-op for
- * the Flex destination Cluster.
- */
- public void block()
- {
- // No-op.
- }
-
- /**
- * Allow the Cluster to determine whether a given physical address
- * is a zombie.
- *
- * @param address The node to check.
- * @return True, if the given address is a zombie.
- */
- public boolean isZombie(Address address)
- {
- return zombies.contains(address);
- }
-
- private void handleDepartedMembers(View membershipView, Vector<Address> currentMemberList)
- {
- for (Address member : members)
- {
- if (!membershipView.containsMember(member))
- {
-// cluster.removeClusterNode(member);
- zombies.remove(member);
- }
- }
- members = currentMemberList;
- }
-
- private void handleArrivingMembers(Vector<Address> currentMemberList)
- {
- for (Address member : currentMemberList)
- {
-/* if (!cluster.getLocalAddress().equals(member) && !members.contains(member))
- cluster.addClusterNode(member);*/
- }
- }
+/*
+ * 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.List;
+import java.util.Vector;
+
+import org.jgroups.Address;
+import org.jgroups.MembershipListener;
+import org.jgroups.View;
+
+/**
+ * @exclude
+ * Clusters employ this Listener in order to respond to nodes which
+ * join and abandon it. This class bridges the low-level protocol layer
+ * to the more abstract logical cluster.
+ */
+class ClusterMembershipListener implements MembershipListener
+{
+ /**
+ * The cluster implementation that owns this listener.
+ */
+ // TODO: The missing class JGroupsCluster seems to extend Cluster, but is missing from the repository.
+// private JGroupsCluster cluster;
+
+ /**
+ * The list of current cluster members as we know it.
+ */
+ private List<Address> members;
+
+ /**
+ * The list of cluster members that are not currently active.
+ */
+ private List<Address> zombies;
+
+ /**
+ * Our implementation of cluster membership listener.
+ *
+ * @param cluster The logical cluster implementation.
+ */
+ public ClusterMembershipListener(Cluster cluster)
+ {
+// this.cluster = (JGroupsCluster)cluster;
+ this.members = new ArrayList<Address>();
+ this.zombies = new ArrayList<Address>();
+ }
+
+ /**
+ * This method is invoked by the cluster infrastructure whenever
+ * a member joins or abandons the cluster group.
+ *
+ * @param membershipView Snapshot of members of the cluster.
+ */
+ public void viewAccepted(View membershipView)
+ {
+ synchronized(this)
+ {
+ Vector<Address> currentMemberList = membershipView.getMembers();
+ handleArrivingMembers(currentMemberList);
+ handleDepartedMembers(membershipView, currentMemberList);
+ }
+ }
+
+ /**
+ * This method is invoked by the cluster infrastructure whenever
+ * a member appears to have left the cluster, but before it has
+ * been removed from the active member list. The Cluster treats
+ * these addresses as zombies and will not use their channel and
+ * endpoint information.
+ *
+ * @param zombieAddress The address of the suspect node.
+ */
+ public void suspect(Address zombieAddress)
+ {
+ synchronized(this)
+ {
+ zombies.add(zombieAddress);
+ }
+ }
+
+ /**
+ * This method from the core MembershipListener is a no-op for
+ * the Flex destination Cluster.
+ */
+ public void block()
+ {
+ // No-op.
+ }
+
+ /**
+ * Allow the Cluster to determine whether a given physical address
+ * is a zombie.
+ *
+ * @param address The node to check.
+ * @return True, if the given address is a zombie.
+ */
+ public boolean isZombie(Address address)
+ {
+ return zombies.contains(address);
+ }
+
+ private void handleDepartedMembers(View membershipView, Vector<Address> currentMemberList)
+ {
+ for (Address member : members)
+ {
+ if (!membershipView.containsMember(member))
+ {
+// cluster.removeClusterNode(member);
+ zombies.remove(member);
+ }
+ }
+ members = currentMemberList;
+ }
+
+ private void handleArrivingMembers(Vector<Address> currentMemberList)
+ {
+ for (Address member : currentMemberList)
+ {
+/* if (!cluster.getLocalAddress().equals(member) && !members.contains(member))
+ cluster.addClusterNode(member);*/
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/cluster/ClusterNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/cluster/ClusterNode.java b/modules/core/src/flex/messaging/cluster/ClusterNode.java
old mode 100755
new mode 100644
index 945867a..6fdd67e
--- a/modules/core/src/flex/messaging/cluster/ClusterNode.java
+++ b/modules/core/src/flex/messaging/cluster/ClusterNode.java
@@ -1,172 +1,172 @@
-/*
- * 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.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * @exclude
- * ClusterNode is an encapsulation for pairing a physical host and a logical
- * software group, which is in effect a mapping between a physical address used
- * by the cluster infrastructure and a service destination used by the message
- * infrastructure.
- *
- * This class is specific to the <code>JGroupsCluster</code> implementation.
- */
-public class ClusterNode
-{
- /**
- * The name of the host for this cluster node.
- */
- private final String host;
-
- /**
- * Mapping between clustered destinations and the
- * clustered endpoint.
- * key = destination key (String)
- * value = Map of channel-id to endpoint-url mappings.
- */
- private final Map<String,Map<String,String>> destKeyToChannelMap;
-
- /**
- * Constructor.
- */
- ClusterNode(String host)
- {
- this.host = host;
- destKeyToChannelMap = new HashMap<String,Map<String,String>>();
- }
-
- /**
- * Returns the name of the host for this cluster node.
- *
- * @return The name of the host.
- */
- String getHost()
- {
- return host;
- }
-
- /**
- * Returns a map of clustered destination to clustered
- * endpoint mappings.
- *
- * @return Map of clustered destination to clustered
- * endpoint mappings.
- */
- Map<String,Map<String,String>> getDestKeyToChannelMap()
- {
- return destKeyToChannelMap;
- }
-
- /**
- * Returns a map of clustered endpoints for the specified
- * clustered destination. If there is not currently a
- * map for the destination, an empty mapping is created
- * and returned.
- *
- * The endpoint map is indexed by channel id.
- * The endpoint map contains endpoint urls.
- *
- * @param serviceType The service type of the clustered destination.
- * @param destName The destination name of the clustered destination.
- * @return Map of clustered endpoints.
- */
- Map<String,String> getEndpoints(String serviceType, String destName)
- {
- String destKey = serviceType + ":" + destName;
- synchronized (destKeyToChannelMap)
- {
- Map<String,String> channelEndpoints = destKeyToChannelMap.get(destKey);
- if (channelEndpoints == null)
- {
- channelEndpoints = new HashMap<String,String>();
- destKeyToChannelMap.put(destKey, channelEndpoints);
- }
- return channelEndpoints;
- }
- }
-
- /**
- * This method adds an endpoint to the list of endpoints for the clustered
- * destination, identified by service type and destination name.
- *
- * @param serviceType The service type of the clustered destination.
- * @param destName The destination name of the clustered destination.
- * @param channelId The channel id to be added to the channel endpoint mapping.
- * @param endpointUrl The endpoint url to be added to the endpoint url mapping.
- */
- void addEndpoint(String serviceType, String destName, String channelId, String endpointUrl)
- {
- synchronized (destKeyToChannelMap)
- {
- Map<String,String> channelEndpoints = getEndpoints(serviceType, destName);
- channelEndpoints.put(channelId, endpointUrl);
- }
- }
-
- /**
- * Returns whether the endpoint, specified by channel id and endpoint url,
- * is included in the list of endpoints in the clustered destination.
- *
- * @param serviceType The service type of the clustered destination.
- * @param destName The destination name of the clustered destination.
- * @param channelId The channel id to find in the list of endpoints.
- * @param endpointUrl The endpoint url to find in the list of endpoints.
- * @return Whether the endpoint is included in the list for the clustered destination.
- */
- boolean containsEndpoint(String serviceType, String destName, String channelId, String endpointUrl)
- {
- Map<String,String> channelEndpoints = getEndpoints(serviceType, destName);
- return channelEndpoints.containsKey(channelId) && channelEndpoints.get(channelId).equals(endpointUrl);
- }
-
- /**
- * Returns a description of the clustered node including details
- * on the mapping between the clustered destinations on this node
- * and their endpoint mappings.
- *
- * @return Description of the clustered node.
- */
- public String toString()
- {
- StringBuffer sb = new StringBuffer("ClusterNode[");
- synchronized (destKeyToChannelMap)
- {
- for (Map.Entry<String,Map<String,String>> entry : destKeyToChannelMap.entrySet())
- {
- sb.append(" channels for ");
- sb.append(entry.getKey());
- sb.append('(');
- for (Iterator<Map.Entry<String,String>> iter = entry.getValue().entrySet().iterator(); iter.hasNext();)
- {
- Map.Entry<String,String> channelMapEntry = iter.next();
- sb.append(channelMapEntry.getKey());
- sb.append('=');
- sb.append(channelMapEntry.getValue());
- if (iter.hasNext())
- sb.append(", ");
- }
- sb.append(')');
- }
- }
- sb.append(" ]");
- return sb.toString();
- }
-}
+/*
+ * 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.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @exclude
+ * ClusterNode is an encapsulation for pairing a physical host and a logical
+ * software group, which is in effect a mapping between a physical address used
+ * by the cluster infrastructure and a service destination used by the message
+ * infrastructure.
+ *
+ * This class is specific to the <code>JGroupsCluster</code> implementation.
+ */
+public class ClusterNode
+{
+ /**
+ * The name of the host for this cluster node.
+ */
+ private final String host;
+
+ /**
+ * Mapping between clustered destinations and the
+ * clustered endpoint.
+ * key = destination key (String)
+ * value = Map of channel-id to endpoint-url mappings.
+ */
+ private final Map<String,Map<String,String>> destKeyToChannelMap;
+
+ /**
+ * Constructor.
+ */
+ ClusterNode(String host)
+ {
+ this.host = host;
+ destKeyToChannelMap = new HashMap<String,Map<String,String>>();
+ }
+
+ /**
+ * Returns the name of the host for this cluster node.
+ *
+ * @return The name of the host.
+ */
+ String getHost()
+ {
+ return host;
+ }
+
+ /**
+ * Returns a map of clustered destination to clustered
+ * endpoint mappings.
+ *
+ * @return Map of clustered destination to clustered
+ * endpoint mappings.
+ */
+ Map<String,Map<String,String>> getDestKeyToChannelMap()
+ {
+ return destKeyToChannelMap;
+ }
+
+ /**
+ * Returns a map of clustered endpoints for the specified
+ * clustered destination. If there is not currently a
+ * map for the destination, an empty mapping is created
+ * and returned.
+ *
+ * The endpoint map is indexed by channel id.
+ * The endpoint map contains endpoint urls.
+ *
+ * @param serviceType The service type of the clustered destination.
+ * @param destName The destination name of the clustered destination.
+ * @return Map of clustered endpoints.
+ */
+ Map<String,String> getEndpoints(String serviceType, String destName)
+ {
+ String destKey = serviceType + ":" + destName;
+ synchronized (destKeyToChannelMap)
+ {
+ Map<String,String> channelEndpoints = destKeyToChannelMap.get(destKey);
+ if (channelEndpoints == null)
+ {
+ channelEndpoints = new HashMap<String,String>();
+ destKeyToChannelMap.put(destKey, channelEndpoints);
+ }
+ return channelEndpoints;
+ }
+ }
+
+ /**
+ * This method adds an endpoint to the list of endpoints for the clustered
+ * destination, identified by service type and destination name.
+ *
+ * @param serviceType The service type of the clustered destination.
+ * @param destName The destination name of the clustered destination.
+ * @param channelId The channel id to be added to the channel endpoint mapping.
+ * @param endpointUrl The endpoint url to be added to the endpoint url mapping.
+ */
+ void addEndpoint(String serviceType, String destName, String channelId, String endpointUrl)
+ {
+ synchronized (destKeyToChannelMap)
+ {
+ Map<String,String> channelEndpoints = getEndpoints(serviceType, destName);
+ channelEndpoints.put(channelId, endpointUrl);
+ }
+ }
+
+ /**
+ * Returns whether the endpoint, specified by channel id and endpoint url,
+ * is included in the list of endpoints in the clustered destination.
+ *
+ * @param serviceType The service type of the clustered destination.
+ * @param destName The destination name of the clustered destination.
+ * @param channelId The channel id to find in the list of endpoints.
+ * @param endpointUrl The endpoint url to find in the list of endpoints.
+ * @return Whether the endpoint is included in the list for the clustered destination.
+ */
+ boolean containsEndpoint(String serviceType, String destName, String channelId, String endpointUrl)
+ {
+ Map<String,String> channelEndpoints = getEndpoints(serviceType, destName);
+ return channelEndpoints.containsKey(channelId) && channelEndpoints.get(channelId).equals(endpointUrl);
+ }
+
+ /**
+ * Returns a description of the clustered node including details
+ * on the mapping between the clustered destinations on this node
+ * and their endpoint mappings.
+ *
+ * @return Description of the clustered node.
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("ClusterNode[");
+ synchronized (destKeyToChannelMap)
+ {
+ for (Map.Entry<String,Map<String,String>> entry : destKeyToChannelMap.entrySet())
+ {
+ sb.append(" channels for ");
+ sb.append(entry.getKey());
+ sb.append('(');
+ for (Iterator<Map.Entry<String,String>> iter = entry.getValue().entrySet().iterator(); iter.hasNext();)
+ {
+ Map.Entry<String,String> channelMapEntry = iter.next();
+ sb.append(channelMapEntry.getKey());
+ sb.append('=');
+ sb.append(channelMapEntry.getValue());
+ if (iter.hasNext())
+ sb.append(", ");
+ }
+ sb.append(')');
+ }
+ }
+ sb.append(" ]");
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/cluster/RemoveNodeListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/cluster/RemoveNodeListener.java b/modules/core/src/flex/messaging/cluster/RemoveNodeListener.java
old mode 100755
new mode 100644
index 5d23721..fd8778d
--- a/modules/core/src/flex/messaging/cluster/RemoveNodeListener.java
+++ b/modules/core/src/flex/messaging/cluster/RemoveNodeListener.java
@@ -1,35 +1,35 @@
-/*
- * 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;
-
-
-/**
- * @exclude
- * Called when a node leaves the cluster. Note that for JGroups at least, this
- * callback should not execute any "long running" operations. This is indirectly
- * called from the MembershipListener interface in JGroups.
- */
-public interface RemoveNodeListener
-{
- /**
- * Callback that the clustering subsystem uses to notify that a
- * node has been removed from the cluster.
- *
- * @address The node that was removed from the cluster.
- */
- void removeClusterNode(Object address);
-}
+/*
+ * 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;
+
+
+/**
+ * @exclude
+ * Called when a node leaves the cluster. Note that for JGroups at least, this
+ * callback should not execute any "long running" operations. This is indirectly
+ * called from the MembershipListener interface in JGroups.
+ */
+public interface RemoveNodeListener
+{
+ /**
+ * Callback that the clustering subsystem uses to notify that a
+ * node has been removed from the cluster.
+ *
+ * @address The node that was removed from the cluster.
+ */
+ void removeClusterNode(Object address);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/cluster/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/cluster/package-info.java b/modules/core/src/flex/messaging/cluster/package-info.java
old mode 100755
new mode 100644
index 5ff0444..0bbec3a
--- a/modules/core/src/flex/messaging/cluster/package-info.java
+++ b/modules/core/src/flex/messaging/cluster/package-info.java
@@ -1,19 +1,19 @@
-/*
- * 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.cluster;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/ApacheXPathServerConfigurationParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/ApacheXPathServerConfigurationParser.java b/modules/core/src/flex/messaging/config/ApacheXPathServerConfigurationParser.java
old mode 100755
new mode 100644
index 2eeac88..1eae53e
--- a/modules/core/src/flex/messaging/config/ApacheXPathServerConfigurationParser.java
+++ b/modules/core/src/flex/messaging/config/ApacheXPathServerConfigurationParser.java
@@ -1,89 +1,89 @@
-/*
- * 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.config;
-
-import org.apache.xpath.CachedXPathAPI;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import javax.xml.transform.TransformerException;
-
-/**
- * Uses Apache XPath on a DOM representation of a messaging configuration
- * file.
- * <p>
- * Note: Since reference ids are used between elements, certain
- * sections of the document need to be parsed first.
- * </p>
- *
- * @author Peter Farland
- * @exclude
- */
-public class ApacheXPathServerConfigurationParser extends ServerConfigurationParser
-{
- private CachedXPathAPI xpath;
-
- protected void initializeExpressionQuery()
- {
- this.xpath = new CachedXPathAPI();
- }
-
- protected Node selectSingleNode(Node source, String expression)
- {
- try
- {
- return xpath.selectSingleNode(source, expression);
- }
- catch (TransformerException transformerException)
- {
- throw wrapException(transformerException);
- }
- }
-
- protected NodeList selectNodeList(Node source, String expression)
- {
- try
- {
- return xpath.selectNodeList(source, expression);
- }
- catch (TransformerException transformerException)
- {
- throw wrapException(transformerException);
- }
- }
-
- protected Object evaluateExpression(Node source, String expression)
- {
- try
- {
- return xpath.eval(source, expression);
- }
- catch (TransformerException transformerException)
- {
- throw wrapException(transformerException);
- }
- }
-
- private ConfigurationException wrapException(TransformerException exception)
- {
- ConfigurationException result = new ConfigurationException();
- result.setDetails(PARSER_INTERNAL_ERROR);
- result.setRootCause(exception);
- return result;
- }
-
-
-}
+/*
+ * 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.config;
+
+import org.apache.xpath.CachedXPathAPI;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import javax.xml.transform.TransformerException;
+
+/**
+ * Uses Apache XPath on a DOM representation of a messaging configuration
+ * file.
+ * <p>
+ * Note: Since reference ids are used between elements, certain
+ * sections of the document need to be parsed first.
+ * </p>
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public class ApacheXPathServerConfigurationParser extends ServerConfigurationParser
+{
+ private CachedXPathAPI xpath;
+
+ protected void initializeExpressionQuery()
+ {
+ this.xpath = new CachedXPathAPI();
+ }
+
+ protected Node selectSingleNode(Node source, String expression)
+ {
+ try
+ {
+ return xpath.selectSingleNode(source, expression);
+ }
+ catch (TransformerException transformerException)
+ {
+ throw wrapException(transformerException);
+ }
+ }
+
+ protected NodeList selectNodeList(Node source, String expression)
+ {
+ try
+ {
+ return xpath.selectNodeList(source, expression);
+ }
+ catch (TransformerException transformerException)
+ {
+ throw wrapException(transformerException);
+ }
+ }
+
+ protected Object evaluateExpression(Node source, String expression)
+ {
+ try
+ {
+ return xpath.eval(source, expression);
+ }
+ catch (TransformerException transformerException)
+ {
+ throw wrapException(transformerException);
+ }
+ }
+
+ private ConfigurationException wrapException(TransformerException exception)
+ {
+ ConfigurationException result = new ConfigurationException();
+ result.setDetails(PARSER_INTERNAL_ERROR);
+ result.setRootCause(exception);
+ return result;
+ }
+
+
+}
[12/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/AMFEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/AMFEndpoint.java b/modules/core/src/flex/messaging/endpoints/AMFEndpoint.java
old mode 100755
new mode 100644
index 2910270..1f94c4b
--- a/modules/core/src/flex/messaging/endpoints/AMFEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/AMFEndpoint.java
@@ -1,152 +1,152 @@
-/*
- * 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.endpoints;
-
-import flex.management.runtime.messaging.endpoints.AMFEndpointControl;
-import flex.messaging.MessageBroker;
-import flex.messaging.io.MessageIOConstants;
-import flex.messaging.endpoints.amf.AMFFilter;
-import flex.messaging.endpoints.amf.BatchProcessFilter;
-import flex.messaging.endpoints.amf.LegacyFilter;
-import flex.messaging.endpoints.amf.MessageBrokerFilter;
-import flex.messaging.endpoints.amf.SerializationFilter;
-import flex.messaging.endpoints.amf.SessionFilter;
-import flex.messaging.log.LogCategories;
-
-/**
- * AMF based endpoint for Flex Messaging. Based on the Flash Remoting gateway servlet.
- */
-public class AMFEndpoint extends BasePollingHTTPEndpoint
-{
- /**
- * The log category for this endpoint.
- */
- public static final String LOG_CATEGORY = LogCategories.ENDPOINT_AMF;
-
- //--------------------------------------------------------------------------
- //
- // Constructors
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>AMFEndpoint</code>.
- */
- public AMFEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs an <code>AMFEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>AMFEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public AMFEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected/Private Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Create the gateway filters that transform action requests
- * and responses.
- */
- @Override protected AMFFilter createFilterChain()
- {
- AMFFilter serializationFilter = new SerializationFilter(getLogCategory());
- AMFFilter batchFilter = new BatchProcessFilter();
- AMFFilter sessionFilter = sessionRewritingEnabled? new SessionFilter() : null;
- AMFFilter envelopeFilter = new LegacyFilter(this);
- AMFFilter messageBrokerFilter = new MessageBrokerFilter(this);
-
- serializationFilter.setNext(batchFilter);
- if (sessionFilter != null)
- {
- batchFilter.setNext(sessionFilter);
- sessionFilter.setNext(envelopeFilter);
- }
- else
- {
- batchFilter.setNext(envelopeFilter);
- }
- envelopeFilter.setNext(messageBrokerFilter);
-
- return serializationFilter;
- }
-
- /**
- * Returns MessageIOConstants.AMF_CONTENT_TYPE.
- *
- * @return MessageIOConstants.AMF_CONTENT_TYPE
- */
- @Override protected String getResponseContentType()
- {
- return MessageIOConstants.AMF_CONTENT_TYPE;
- }
-
- /**
- * Returns the log category of the endpoint.
- *
- * @return The log category of the endpoint.
- */
- @Override protected String getLogCategory()
- {
- return LOG_CATEGORY;
- }
-
- /**
- * Returns the deserializer class name used by the endpoint.
- *
- * @return The deserializer class name used by the endpoint.
- */
- @Override protected String getDeserializerClassName()
- {
- return "flex.messaging.io.amf.AmfMessageDeserializer";
- }
-
- /**
- * Returns the serializer class name used by the endpoint.
- *
- * @return The serializer class name used by the endpoint.
- */
- @Override protected String getSerializerClassName()
- {
- return "flex.messaging.io.amf.AmfMessageSerializer";
- }
-
-
- /**
- * Invoked automatically to allow the <code>AMFEndpoint</code> to setup its
- * corresponding MBean control.
- *
- * @param broker The <code>MessageBroker</code> that manages this
- * <code>AMFEndpoint</code>.
- */
- @Override protected void setupEndpointControl(MessageBroker broker)
- {
- controller = new AMFEndpointControl(this, broker.getControl());
- controller.register();
- setControl(controller);
- }
-}
+/*
+ * 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.endpoints;
+
+import flex.management.runtime.messaging.endpoints.AMFEndpointControl;
+import flex.messaging.MessageBroker;
+import flex.messaging.io.MessageIOConstants;
+import flex.messaging.endpoints.amf.AMFFilter;
+import flex.messaging.endpoints.amf.BatchProcessFilter;
+import flex.messaging.endpoints.amf.LegacyFilter;
+import flex.messaging.endpoints.amf.MessageBrokerFilter;
+import flex.messaging.endpoints.amf.SerializationFilter;
+import flex.messaging.endpoints.amf.SessionFilter;
+import flex.messaging.log.LogCategories;
+
+/**
+ * AMF based endpoint for Flex Messaging. Based on the Flash Remoting gateway servlet.
+ */
+public class AMFEndpoint extends BasePollingHTTPEndpoint
+{
+ /**
+ * The log category for this endpoint.
+ */
+ public static final String LOG_CATEGORY = LogCategories.ENDPOINT_AMF;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructors
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>AMFEndpoint</code>.
+ */
+ public AMFEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs an <code>AMFEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>AMFEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public AMFEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected/Private Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Create the gateway filters that transform action requests
+ * and responses.
+ */
+ @Override protected AMFFilter createFilterChain()
+ {
+ AMFFilter serializationFilter = new SerializationFilter(getLogCategory());
+ AMFFilter batchFilter = new BatchProcessFilter();
+ AMFFilter sessionFilter = sessionRewritingEnabled? new SessionFilter() : null;
+ AMFFilter envelopeFilter = new LegacyFilter(this);
+ AMFFilter messageBrokerFilter = new MessageBrokerFilter(this);
+
+ serializationFilter.setNext(batchFilter);
+ if (sessionFilter != null)
+ {
+ batchFilter.setNext(sessionFilter);
+ sessionFilter.setNext(envelopeFilter);
+ }
+ else
+ {
+ batchFilter.setNext(envelopeFilter);
+ }
+ envelopeFilter.setNext(messageBrokerFilter);
+
+ return serializationFilter;
+ }
+
+ /**
+ * Returns MessageIOConstants.AMF_CONTENT_TYPE.
+ *
+ * @return MessageIOConstants.AMF_CONTENT_TYPE
+ */
+ @Override protected String getResponseContentType()
+ {
+ return MessageIOConstants.AMF_CONTENT_TYPE;
+ }
+
+ /**
+ * Returns the log category of the endpoint.
+ *
+ * @return The log category of the endpoint.
+ */
+ @Override protected String getLogCategory()
+ {
+ return LOG_CATEGORY;
+ }
+
+ /**
+ * Returns the deserializer class name used by the endpoint.
+ *
+ * @return The deserializer class name used by the endpoint.
+ */
+ @Override protected String getDeserializerClassName()
+ {
+ return "flex.messaging.io.amf.AmfMessageDeserializer";
+ }
+
+ /**
+ * Returns the serializer class name used by the endpoint.
+ *
+ * @return The serializer class name used by the endpoint.
+ */
+ @Override protected String getSerializerClassName()
+ {
+ return "flex.messaging.io.amf.AmfMessageSerializer";
+ }
+
+
+ /**
+ * Invoked automatically to allow the <code>AMFEndpoint</code> to setup its
+ * corresponding MBean control.
+ *
+ * @param broker The <code>MessageBroker</code> that manages this
+ * <code>AMFEndpoint</code>.
+ */
+ @Override protected void setupEndpointControl(MessageBroker broker)
+ {
+ controller = new AMFEndpointControl(this, broker.getControl());
+ controller.register();
+ setControl(controller);
+ }
+}
[11/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java b/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java
old mode 100755
new mode 100644
index 71a9a58..27784fb
--- a/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java
@@ -1,1508 +1,1508 @@
-/*
- * 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.endpoints;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import flex.management.ManageableComponent;
-import flex.management.runtime.messaging.MessageBrokerControl;
-import flex.management.runtime.messaging.endpoints.EndpointControl;
-import flex.messaging.FlexContext;
-import flex.messaging.FlexSession;
-import flex.messaging.MessageBroker;
-import flex.messaging.MessageException;
-import flex.messaging.Server;
-import flex.messaging.client.FlexClient;
-import flex.messaging.client.FlexClientOutboundQueueProcessor;
-import flex.messaging.client.FlushResult;
-import flex.messaging.client.PollFlushResult;
-import flex.messaging.client.UserAgentSettings;
-import flex.messaging.config.ChannelSettings;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.ConfigurationConstants;
-import flex.messaging.config.ConfigurationException;
-import flex.messaging.config.SecurityConstraint;
-import flex.messaging.io.ClassAliasRegistry;
-import flex.messaging.io.SerializationContext;
-import flex.messaging.io.TypeMarshaller;
-import flex.messaging.io.TypeMarshallingContext;
-import flex.messaging.io.amf.translator.ASTranslator;
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.log.Logger;
-import flex.messaging.messages.AcknowledgeMessage;
-import flex.messaging.messages.AcknowledgeMessageExt;
-import flex.messaging.messages.AsyncMessage;
-import flex.messaging.messages.AsyncMessageExt;
-import flex.messaging.messages.CommandMessage;
-import flex.messaging.messages.CommandMessageExt;
-import flex.messaging.messages.Message;
-import flex.messaging.messages.SmallMessage;
-import flex.messaging.security.SecurityException;
-import flex.messaging.util.ClassUtil;
-import flex.messaging.util.StringUtils;
-import flex.messaging.util.UserAgentManager;
-import flex.messaging.validators.DeserializationValidator;
-
-/**
- * This is the default implementation of Endpoint, which provides a convenient
- * base for behavior and associations common to all endpoints.
- *
- * These properties that appear in the endpoint configuration are only used by the
- * client, therefore they have to be set on the appropriate client classes: connect-timeout-seconds set on Channel.
- *
- * @see flex.messaging.endpoints.Endpoint
- */
-public abstract class AbstractEndpoint extends ManageableComponent
- implements Endpoint2, ConfigurationConstants
-{
- /** Log category for <code>AbstractEndpoint</code>. */
- public static final String LOG_CATEGORY = LogCategories.ENDPOINT_GENERAL;
-
- /**
- * HTTP header field names.
- */
- public static final String HEADER_NAME_CACHE_CONTROL = "Cache-Control";
- public static final String HEADER_NAME_EXPIRES = "Expires";
- public static final String HEADER_NAME_PRAGMA = "Pragma";
-
- // Errors
- private static final int NONSECURE_PROTOCOL = 10066;
- private static final int REQUIRES_FLEXCLIENT_SUPPORT = 10030;
- private static final int ERR_MSG_INVALID_URL_SCHEME = 11100;
-
- // XML Configuration Properties
- private static final String SERIALIZATION = "serialization";
- private static final String CREATE_ASOBJECT_FOR_MISSING_TYPE = "create-asobject-for-missing-type";
- private static final String CUSTOM_DESERIALIZER = "custom-deserializer";
- private static final String CUSTOM_SERIALIZER = "custom-serializer";
- private static final String ENABLE_SMALL_MESSAGES = "enable-small-messages";
- private static final String TYPE_MARSHALLER = "type-marshaller";
- private static final String RESTORE_REFERENCES = "restore-references";
- private static final String INSTANTIATE_TYPES = "instantiate-types";
- private static final String SUPPORT_REMOTE_CLASS = "support-remote-class";
- private static final String LEGACY_COLLECTION = "legacy-collection";
- private static final String LEGACY_DICTIONARY = "legacy-dictionary";
- private static final String LEGACY_MAP = "legacy-map";
- private static final String LEGACY_XML = "legacy-xml";
- private static final String LEGACY_XML_NAMESPACES = "legacy-xml-namespaces";
- private static final String LEGACY_THROWABLE = "legacy-throwable";
- private static final String LEGACY_BIG_NUMBERS = "legacy-big-numbers";
- private static final String LEGACY_EXTERNALIZABLE = "legacy-externalizable";
- private static final String LOG_PROPERTY_ERRORS = "log-property-errors";
- private static final String IGNORE_PROPERTY_ERRORS = "ignore-property-errors";
- private static final String INCLUDE_READ_ONLY = "include-read-only";
- private static final String GLOBAL_INCLUDE_READ_ONLY = "global-include-read-only";
- private static final String FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR = "flex-client-outbound-queue-processor";
- private static final String SHOW_STACKTRACES = "show-stacktraces";
- private static final String MAX_OBJECT_NEST_LEVEL = "max-object-nest-level";
- private static final String MAX_COLLECTION_NEST_LEVEL = "max-collection-nest-level";
- private static final String PREFER_VECTORS = "prefer-vectors";
-
- // Endpoint properties
- protected Set<String> clientLoadBalancingUrls;
- protected String clientType;
- protected int connectTimeoutSeconds;
- protected int requestTimeoutSeconds;
- protected FlexClientOutboundQueueProcessor flexClientOutboundQueueProcessor;
- protected SerializationContext serializationContext;
- protected Class<?> deserializerClass;
- protected Class<?> serializerClass;
- protected TypeMarshaller typeMarshaller;
- protected int port;
- private SecurityConstraint securityConstraint;
- protected String url;
- protected boolean recordMessageSizes;
- protected boolean recordMessageTimes;
- protected boolean remote;
- protected Server server;
- protected boolean serverOnly;
-
- // Endpoint internal
- protected String parsedUrl;
- // Keeps track of what context path parsedUrl has been parsed for. If it is
- // null, means parsedUrl has not been parsed already.
- protected String parsedForContext;
- protected boolean clientContextParsed;
- protected String parsedClientUrl;
- protected Logger log;
-
- protected Class<?> flexClientOutboundQueueProcessClass;
- protected ConfigMap flexClientOutboundQueueProcessorConfig;
-
- // Supported messaging version
- protected double messagingVersion = 1.0;
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>AbstractEndpoint</code>.
- */
- public AbstractEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs an <code>AbstractEndpoint</code> with the indicated management.
- *
- * @param enableManagement <code>true</code> if the <code>AbstractEndpoint</code>
- * is manageable; <code>false</code> otherwise.
- */
- public AbstractEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- this.log = Log.getLogger(getLogCategory());
- serializationContext = new SerializationContext();
- }
-
- //--------------------------------------------------------------------------
- //
- // Initialize, validate, start, and stop methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes the <code>Endpoint</code> with the properties.
- * If subclasses override this method, they must call <code>super.initialize()</code>.
- *
- * @param id The ID of the <code>Endpoint</code>.
- * @param properties Properties for the <code>Endpoint</code>.
- */
- @Override
- public void initialize(String id, ConfigMap properties)
- {
- super.initialize(id, properties);
-
- if (properties == null || properties.size() == 0)
- return;
-
- // Client-targeted <client-load-balancing>
- initializeClientLoadBalancing(id, properties);
-
- // Client-targeted <connect-timeout-seconds/>
- connectTimeoutSeconds = properties.getPropertyAsInt(CONNECT_TIMEOUT_SECONDS_ELEMENT, 0);
-
- // Client-targeted <request-timeout-seconds/>
- requestTimeoutSeconds = properties.getPropertyAsInt(REQUEST_TIMEOUT_SECONDS_ELEMENT, 0);
-
- // Check for a custom FlexClient outbound queue processor.
- ConfigMap outboundQueueConfig = properties.getPropertyAsMap(FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR, null);
- if (outboundQueueConfig != null)
- {
- // Get nested props for the processor.
- flexClientOutboundQueueProcessorConfig = outboundQueueConfig.getPropertyAsMap(PROPERTIES_ELEMENT, null);
-
- String pClassName = outboundQueueConfig.getPropertyAsString(CLASS_ATTR, null);
- if (pClassName != null)
- {
- try
- {
- flexClientOutboundQueueProcessClass = createClass(pClassName);
- // And now create an instance and initialize to make sure the properties are valid.
- setFlexClientOutboundQueueProcessorConfig(flexClientOutboundQueueProcessorConfig);
- }
- catch (Throwable t)
- {
- if (Log.isWarn())
- log.warn("Cannot register custom FlexClient outbound queue processor class {0}", new Object[]{pClassName}, t);
- }
- }
- }
-
- ConfigMap serialization = properties.getPropertyAsMap(SERIALIZATION, null);
- if (serialization != null)
- {
- // Custom deserializers
- List<?> deserializers = serialization.getPropertyAsList(CUSTOM_DESERIALIZER, null);
- if (deserializers != null && Log.isWarn())
- log.warn("Endpoint <custom-deserializer> functionality is no longer available. Please remove this entry from your configuration.");
-
- // Custom serializers
- List<?> serializers = serialization.getPropertyAsList(CUSTOM_SERIALIZER, null);
- if (serializers != null && Log.isWarn())
- log.warn("Endpoint <custom-serializer> functionality is no longer available. Please remove this entry from your configuration.");
-
- // Type Marshaller implementation
- String typeMarshallerClassName = serialization.getPropertyAsString(TYPE_MARSHALLER, null);
- if (typeMarshallerClassName != null && typeMarshallerClassName.length() > 0)
- {
- try
- {
- Class<?> tmc = createClass(typeMarshallerClassName);
- typeMarshaller = (TypeMarshaller)ClassUtil.createDefaultInstance(tmc, TypeMarshaller.class);
- }
- catch (Throwable t)
- {
- if (Log.isWarn())
- log.warn("Cannot register custom type marshaller for type {0}", new Object[]{typeMarshallerClassName}, t);
- }
- }
-
- // Boolean Serialization Flags
- serializationContext.createASObjectForMissingType = serialization.getPropertyAsBoolean(CREATE_ASOBJECT_FOR_MISSING_TYPE, false);
- serializationContext.enableSmallMessages = serialization.getPropertyAsBoolean(ENABLE_SMALL_MESSAGES, true);
- serializationContext.instantiateTypes = serialization.getPropertyAsBoolean(INSTANTIATE_TYPES, true);
- serializationContext.supportRemoteClass = serialization.getPropertyAsBoolean(SUPPORT_REMOTE_CLASS, false);
- serializationContext.legacyCollection = serialization.getPropertyAsBoolean(LEGACY_COLLECTION, false);
- serializationContext.legacyDictionary = serialization.getPropertyAsBoolean(LEGACY_DICTIONARY, false);
- serializationContext.legacyMap = serialization.getPropertyAsBoolean(LEGACY_MAP, false);
- serializationContext.legacyXMLDocument = serialization.getPropertyAsBoolean(LEGACY_XML, false);
- serializationContext.legacyXMLNamespaces = serialization.getPropertyAsBoolean(LEGACY_XML_NAMESPACES, false);
- serializationContext.legacyThrowable = serialization.getPropertyAsBoolean(LEGACY_THROWABLE, false);
- serializationContext.legacyBigNumbers = serialization.getPropertyAsBoolean(LEGACY_BIG_NUMBERS, false);
- serializationContext.legacyExternalizable = serialization.getPropertyAsBoolean(LEGACY_EXTERNALIZABLE, false);
- serializationContext.maxObjectNestLevel = (int)serialization.getPropertyAsLong(MAX_OBJECT_NEST_LEVEL, 512);
- serializationContext.maxCollectionNestLevel = (int)serialization.getPropertyAsLong(MAX_COLLECTION_NEST_LEVEL, 15);
- serializationContext.preferVectors = serialization.getPropertyAsBoolean(PREFER_VECTORS, false);
-
- boolean showStacktraces = serialization.getPropertyAsBoolean(SHOW_STACKTRACES, false);
- if (showStacktraces && Log.isWarn())
- log.warn("The " + SHOW_STACKTRACES + " configuration option is deprecated and non-functional. Please remove this from your configuration file.");
- serializationContext.restoreReferences = serialization.getPropertyAsBoolean(RESTORE_REFERENCES, false);
- serializationContext.logPropertyErrors = serialization.getPropertyAsBoolean(LOG_PROPERTY_ERRORS, false);
- serializationContext.ignorePropertyErrors = serialization.getPropertyAsBoolean(IGNORE_PROPERTY_ERRORS, true);
- serializationContext.includeReadOnly = serialization.getPropertyAsBoolean(INCLUDE_READ_ONLY, false);
- }
-
- recordMessageSizes = properties.getPropertyAsBoolean(ConfigurationConstants.RECORD_MESSAGE_SIZES_ELEMENT, false);
-
- if (recordMessageSizes && Log.isWarn())
- log.warn("Setting <record-message-sizes> to true affects application performance and should only be used for debugging");
-
- recordMessageTimes = properties.getPropertyAsBoolean(ConfigurationConstants.RECORD_MESSAGE_TIMES_ELEMENT, false);
- }
-
- /**
- * Starts the endpoint if its associated <code>MessageBroker</code> is started,
- * and if the endpoint is not already running. If subclasses override this method,
- * they must call <code>super.start()</code>.
- */
- @Override
- public void start()
- {
- if (isStarted())
- return;
-
- // Check if the MessageBroker is started
- MessageBroker broker = getMessageBroker();
- if (!broker.isStarted())
- {
- if (Log.isWarn())
- {
- Log.getLogger(getLogCategory()).warn("Endpoint with id '{0}' cannot be started" +
- " when the MessageBroker is not started.",
- new Object[]{getId()});
- }
- return;
- }
-
- // Set up management
- if (isManaged() && broker.isManaged())
- {
- setupEndpointControl(broker);
- MessageBrokerControl controller = (MessageBrokerControl)broker.getControl();
- if (getControl() != null)
- controller.addEndpoint(this);
- }
-
- // Setup Deserializer and Serializer for the SerializationContext
- if (deserializerClass == null)
- deserializerClass = createClass(getDeserializerClassName());
-
- if (serializerClass == null)
- serializerClass = createClass(getSerializerClassName());
-
- serializationContext.setDeserializerClass(deserializerClass);
- serializationContext.setSerializerClass(serializerClass);
-
- // Setup endpoint features
- ClassAliasRegistry registry = ClassAliasRegistry.getRegistry();
- registry.registerAlias(AsyncMessageExt.CLASS_ALIAS, AsyncMessageExt.class.getName());
- registry.registerAlias(AcknowledgeMessageExt.CLASS_ALIAS, AcknowledgeMessageExt.class.getName());
- registry.registerAlias(CommandMessageExt.CLASS_ALIAS, CommandMessageExt.class.getName());
- super.start();
- }
-
- /**
- * Stops the endpoint if it is running. If subclasses override this method, they must
- * call <code>super.stop()</code>.
- */
- @Override
- public void stop()
- {
- if (!isStarted())
- return;
-
- super.stop();
-
- // Remove management
- if (isManaged() && getMessageBroker().isManaged())
- {
- if (getControl() != null)
- {
- getControl().unregister();
- setControl(null);
- }
- setManaged(false);
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Getters and Setters for AbstractEndpoint properties
- //
- //--------------------------------------------------------------------------
-
- /**
- * Adds a client-load-balancing URL.
- *
- * @param url A client-load-balancing URL.
- * @return <code>false</code> if the set already contains the URL, <code>true</code> otherwise.
- *
- */
- public boolean addClientLoadBalancingUrl(String url)
- {
- if (clientLoadBalancingUrls == null)
- clientLoadBalancingUrls = new HashSet<String>();
-
- if (url == null || url.length() == 0)
- {
- // Invalid {0} configuration for endpoint ''{1}''; cannot add empty url.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(ERR_MSG_EMTPY_CLIENT_LOAD_BALACNING_URL, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, getId()});
- throw ce;
- }
-
- return clientLoadBalancingUrls.add(url);
- }
-
- /**
- * Removes the client-load-balancing URL.
- *
- * @param url The URL to remove.
- * @return <code>true</code> if the set contained the URL, <code>false</code> otherwise.
- */
- public boolean removeClientLoadBalancingUrl(String url)
- {
- if (clientLoadBalancingUrls != null)
- return clientLoadBalancingUrls.remove(url);
- return false;
- }
-
- /**
- * Retrieves a snapshot of the current client-load-balancing URLs.
- *
- * @return A snapshot of the current client-load-balancing URLs, or <code>null</code> if
- * no URL exists.
- */
- public Set<String> getClientLoadBalancingUrls()
- {
- return clientLoadBalancingUrls == null? null : new HashSet<String>(clientLoadBalancingUrls);
- }
-
- /**
- * Retrieves the corresponding client channel type for the endpoint.
- *
- * @return The corresponding client channel type for the endpoint.
- */
- public String getClientType()
- {
- return clientType;
- }
-
- /**
- * Sets the corresponding client channel type for the endpoint.
- *
- * @param type The corresponding client channel type for the endpoint.
- */
- public void setClientType(String type)
- {
- this.clientType = type;
- }
-
- /**
- * Retrieves the <code>FlexClientOutboundQueueProcessorClass</code> of the endpoint.
- *
- * @return The <code>FlexClientOutboundQueueProcessorClass</code> of the endpoint.
- */
- public Class<?> getFlexClientOutboundQueueProcessorClass()
- {
- return flexClientOutboundQueueProcessClass;
- }
-
- /**
- * Sets the the <code>FlexClientOutboundQueueProcessor</code> of the endpoint.
- *
- * @param flexClientOutboundQueueProcessorClass the Class of the Flex client outbound queue processor.
- */
- public void setFlexClientOutboundQueueProcessorClass(Class<?> flexClientOutboundQueueProcessorClass)
- {
- this.flexClientOutboundQueueProcessClass = flexClientOutboundQueueProcessorClass;
- if (flexClientOutboundQueueProcessClass != null && flexClientOutboundQueueProcessorConfig != null)
- {
- FlexClientOutboundQueueProcessor processor = (FlexClientOutboundQueueProcessor)ClassUtil.createDefaultInstance(flexClientOutboundQueueProcessClass, null);
- processor.initialize(flexClientOutboundQueueProcessorConfig);
- }
- }
-
- /**
- * Retrieves the properties for the <code>FlexClientOutboundQueueProcessor</code> of the endpoint.
- *
- * @return The properties for the <code>FlexClientOutboundQueueProcessor</code> of the endpoint.
- */
- public ConfigMap getFlexClientOutboundQueueProcessorConfig()
- {
- return flexClientOutboundQueueProcessorConfig;
- }
-
- /**
- * Sets the properties for the <code>FlexClientOutboundQueueProcessor</code> of the endpoint.
- *
- * @param flexClientOutboundQueueProcessorConfig The configuration map.
- */
- public void setFlexClientOutboundQueueProcessorConfig(ConfigMap flexClientOutboundQueueProcessorConfig)
- {
- this.flexClientOutboundQueueProcessorConfig = flexClientOutboundQueueProcessorConfig;
- if (flexClientOutboundQueueProcessorConfig != null && flexClientOutboundQueueProcessClass != null)
- {
- FlexClientOutboundQueueProcessor processor = (FlexClientOutboundQueueProcessor)ClassUtil.createDefaultInstance(flexClientOutboundQueueProcessClass, null);
- processor.initialize(flexClientOutboundQueueProcessorConfig);
- }
- }
-
- /**
- * Sets the ID of the <code>AbstractEndpoint</code>. If the <code>AbstractEndpoint</code>
- * has a <code>MessageBroker</code> assigned, it also updates the ID in the
- * <code>MessageBroker</code>.
- * <p/>
- * @param id The endpoint ID.
- */
- @Override
- public void setId(String id)
- {
- String oldId = getId();
-
- if (oldId != null && oldId.equals(id))
- return;
-
- super.setId(id);
-
- // Update the endpoint id in the broker
- MessageBroker broker = getMessageBroker();
- if (broker != null)
- {
- // broker must have the endpoint then
- broker.removeEndpoint(oldId);
- broker.addEndpoint(this);
- }
- }
-
- /**
- * Retrieves the <code>MessageBroker</code> of the <code>AbstractEndpoint</code>.
- *
- * @return The <code>MessageBroker</code> of the <code>AbstractEndpoint</code>.
- */
- public MessageBroker getMessageBroker()
- {
- return (MessageBroker)getParent();
- }
-
- /**
- * Sets the <code>MessageBroker</code> of the <code>AbstractEndpoint</code>.
- * Removes the <code>AbstractEndpoint</code> from the old broker
- * (if there was one) and adds to the list of endpoints in the new broker.
- *
- * @param broker The <code>MessageBroker</code> of the <code>AbstractEndpoint</code>.
- */
- public void setMessageBroker(MessageBroker broker)
- {
- MessageBroker oldBroker = getMessageBroker();
-
- setParent(broker);
-
- if (oldBroker != null)
- oldBroker.removeEndpoint(getId());
-
- // Add endpoint to the new broker if needed
- if (broker.getEndpoint(getId()) != this)
- broker.addEndpoint(this);
- }
-
- /**
- * Return the highest messaging version currently available via this
- * endpoint.
- * @return double the messaging version
- */
- public double getMessagingVersion()
- {
- return messagingVersion;
- }
-
- /**
- * Retrieves the port of the URL of the endpoint.
- * A return value of 0 denotes no port in the channel URL.
- *
- * @return The port of the URL of the endpoint, or 0 if the URL does not contain
- * a port number.
- */
- public int getPort()
- {
- return port;
- }
-
- /**
- * Determines whether the endpoint is secure.
- *
- * @return <code>false</code> by default.
- */
- public boolean isSecure()
- {
- return false;
- }
-
- /**
- * Determines if the endpoint clients connect to directly is mirrored and running
- * on a remote host, in which case this local instance is not started and will service no direct
- * client connections.
- *
- * @return <code>true</code> if this endpoint will not process direct client connections and is just
- * a local representation of a symmetric endpoint on a remote host that will, <code>false</code> otherwise.
- */
- public boolean isRemote()
- {
- return remote;
- }
-
- /**
- * Sets the remote status for this endpoint.
- *
- * @param value <code>true</code> if this endpoint will not process direct client connections and is just
- * a local representation of a symmetric endpoint on a remote host that will, <code>false</code> otherwise.
- */
- public void setRemote(boolean value)
- {
- remote = value;
- }
-
- /**
- * Retrieves the <tt>Server</tt> that the endpoint is using, or <code>null</code> if
- * no server has been assigned.
- * @return Server The Server object the endpoint is using.
- */
- public Server getServer()
- {
- return server;
- }
-
- /**
- * Sets the <tt>Server</tt> that the endpoint will use.
- * @param server The Server object.
- */
- public void setServer(Server server)
- {
- this.server = server;
- }
-
- /**
- * Determines whether the endpoint is server only.
- *
- * @return <code>true</code> if the endpoint is server only, <code>false</code> otherwise.
- */
- public boolean getServerOnly()
- {
- return serverOnly;
- }
-
- /**
- * Sets whether the endpoint is server only.
- *
- * @param serverOnly <code>true</code> if the endpoint is server only, <code>false</code> otherwise.
- */
- public void setServerOnly(boolean serverOnly)
- {
- this.serverOnly = serverOnly;
- }
-
- /**
- * Retrieves the <code>SecurityConstraint</code> of the <code>Endpoint</code>.
- *
- * @return The <code>SecurityConstraint</code> of the <code>Endpoint</code>.
- */
- public SecurityConstraint getSecurityConstraint()
- {
- return securityConstraint;
- }
-
- /**
- * Sets the <code>SecurityConstraint</code> of the <code>Endpoint</code>.
- *
- * @param securityConstraint The SecurityContraint object.
- */
- public void setSecurityConstraint(SecurityConstraint securityConstraint)
- {
- this.securityConstraint = securityConstraint;
- }
-
- /**
- * Retrieves the <code>SerializationContext</code> of the endpoint.
- *
- * @return The <code>SerializationContext</code> of the endpoint.
- */
- public SerializationContext getSerializationContext()
- {
- return serializationContext;
- }
-
- /**
- * Sets the <code>SerializationContext</code> of the endpoint.
- *
- * @param serializationContext The SerializationContext object.
- */
- public void setSerializationContext(SerializationContext serializationContext)
- {
- this.serializationContext = serializationContext;
- }
-
- /**
- * Retrieves the <code>TypeMarshaller</code> of the endpoint.
- *
- * @return The <code>TypeMarshaller</code> of the endpoint.
- */
- public TypeMarshaller getTypeMarshaller()
- {
- if (typeMarshaller == null)
- typeMarshaller = new ASTranslator();
-
- return typeMarshaller;
- }
-
- /**
- * Sets the <code>TypeMarshaller</code> of the endpoint.
- *
- * @param typeMarshaller The TypeMarshaller object.
- */
- public void setTypeMarshaller(TypeMarshaller typeMarshaller)
- {
- this.typeMarshaller = typeMarshaller;
- }
-
- /**
- * Retrieves the URL of the endpoint.
- *
- * @return The URL of the endpoint.
- */
- public String getUrl()
- {
- return url;
- }
-
- /**
- * Sets the URL of the endpoint.
- *
- * @param url The URL of the endpoint.
- */
- public void setUrl(String url)
- {
- this.url = url;
- port = internalParsePort(url);
- parsedForContext = null;
- clientContextParsed = false;
- }
-
- /**
- * @exclude
- * Returns the url of the endpoint parsed for the client.
- *
- * @return The url of the endpoint parsed for the client.
- */
- public String getUrlForClient()
- {
- if (!clientContextParsed)
- {
- HttpServletRequest req = FlexContext.getHttpRequest();
- if (req != null)
- {
- String contextPath = req.getContextPath();
- parseClientUrl(contextPath);
- }
- else
- {
- return url;
- }
- }
- return parsedClientUrl;
- }
-
- /**
- * @exclude
- * Returns the total throughput for the endpoint.
- *
- * @return The total throughput for the endpoint.
- */
- public long getThroughput()
- {
- EndpointControl control = (EndpointControl)getControl();
-
- return control.getBytesDeserialized().longValue() + control.getBytesSerialized().longValue();
- }
-
- //--------------------------------------------------------------------------
- //
- // Other Public APIs
- //
- //--------------------------------------------------------------------------
-
- /** @exclude **/
- public static void addNoCacheHeaders(HttpServletRequest req, HttpServletResponse res)
- {
- String userAgent = req.getHeader(UserAgentManager.USER_AGENT_HEADER_NAME);
-
- // For MSIE over HTTPS, set additional Cache-Control values.
- if (req.isSecure() && userAgent != null && userAgent.indexOf(UserAgentSettings.USER_AGENT_MSIE) != -1)
- res.addHeader(HEADER_NAME_CACHE_CONTROL, "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-transform, private");
- else // For the rest, set no-cache header value only.
- res.addHeader(HEADER_NAME_CACHE_CONTROL, "no-cache");
-
- // Set an expiration date in the past as well.
- res.setDateHeader(HEADER_NAME_EXPIRES, 946080000000L); //Approx Jan 1, 2000
-
- // Set Pragma no-cache header if we're not MSIE over HTTPS
- if (!(req.isSecure() && userAgent != null && userAgent.indexOf(UserAgentSettings.USER_AGENT_MSIE) != -1))
- res.setHeader(HEADER_NAME_PRAGMA, "no-cache");
- }
-
- /**
- * @exclude
- */
- public Message convertToSmallMessage(Message message)
- {
- if (message instanceof SmallMessage)
- {
- Message smallMessage = ((SmallMessage)message).getSmallMessage();
- if (smallMessage != null)
- message = smallMessage;
- }
-
- return message;
- }
-
- /**
- * Retrieves a <code>ConfigMap</code> of the endpoint properties the client
- * needs. Subclasses should add additional properties to <code>super.describeDestination</code>,
- * or return <code>null</code> if they must not send their properties to the client.
- * <p/>
- * @return ConfigMap The ConfigMap object.
- */
- public ConfigMap describeEndpoint()
- {
- ConfigMap channelConfig = new ConfigMap();
-
- if (serverOnly) // Client does not need server only endpoints.
- return channelConfig;
-
- channelConfig.addProperty(ID_ATTR, getId());
- channelConfig.addProperty(TYPE_ATTR, getClientType());
-
- ConfigMap properties = new ConfigMap();
-
- boolean containsClientLoadBalancing = clientLoadBalancingUrls != null && !clientLoadBalancingUrls.isEmpty();
- if (containsClientLoadBalancing)
- {
- ConfigMap clientLoadBalancing = new ConfigMap();
- for (Iterator<String> iterator = clientLoadBalancingUrls.iterator(); iterator.hasNext();)
- {
- ConfigMap url = new ConfigMap();
- // Adding as a value rather than attribute to the parent.
- url.addProperty(EMPTY_STRING, iterator.next());
- clientLoadBalancing.addProperty(URL_ATTR, url);
- }
- properties.addProperty(CLIENT_LOAD_BALANCING_ELEMENT, clientLoadBalancing);
- }
-
- // Add endpoint uri only if no client-load-balancing urls are defined.
- if (!containsClientLoadBalancing)
- {
- ConfigMap endpointConfig = new ConfigMap();
- endpointConfig.addProperty(URI_ATTR, getUrlForClient());
- channelConfig.addProperty(ENDPOINT_ELEMENT, endpointConfig);
- }
-
- if (connectTimeoutSeconds > 0)
- {
- ConfigMap connectTimeoutConfig = new ConfigMap();
- connectTimeoutConfig.addProperty(EMPTY_STRING, String.valueOf(connectTimeoutSeconds));
- properties.addProperty(CONNECT_TIMEOUT_SECONDS_ELEMENT, connectTimeoutConfig);
- }
-
- if (requestTimeoutSeconds > 0)
- {
- ConfigMap requestTimeoutSeconds = new ConfigMap();
- requestTimeoutSeconds.addProperty(EMPTY_STRING, String.valueOf(requestTimeoutSeconds));
- properties.addProperty(REQUEST_TIMEOUT_SECONDS_ELEMENT, requestTimeoutSeconds);
- }
-
- if (recordMessageTimes)
- {
- ConfigMap recordMessageTimesMap = new ConfigMap();
- // Adding as a value rather than attribute to the parent
- recordMessageTimesMap.addProperty(EMPTY_STRING, TRUE_STRING);
- properties.addProperty(RECORD_MESSAGE_TIMES_ELEMENT, recordMessageTimesMap);
- }
-
- if (recordMessageSizes)
- {
- ConfigMap recordMessageSizesMap = new ConfigMap();
- // Adding as a value rather than attribute to the parent
- recordMessageSizesMap.addProperty(EMPTY_STRING, TRUE_STRING);
- properties.addProperty(RECORD_MESSAGE_SIZES_ELEMENT, recordMessageSizesMap);
- }
-
- ConfigMap serialization = new ConfigMap();
- serialization.addProperty(ENABLE_SMALL_MESSAGES_ELEMENT, Boolean.toString(serializationContext.enableSmallMessages));
- properties.addProperty(SERIALIZATION_ELEMENT, serialization);
-
- if (properties.size() > 0)
- channelConfig.addProperty(PROPERTIES_ELEMENT, properties);
-
- return channelConfig;
- }
-
- /**
- * @exclude
- * Make sure this matches with ChannelSettings.getParsedUri.
- */
- public String getParsedUrl(String contextPath)
- {
- parseUrl(contextPath);
- return parsedUrl;
- }
-
- /**
- * @exclude
- */
- public void handleClientMessagingVersion(Number version)
- {
- if (version != null)
- {
- boolean clientSupportsSmallMessages = version.doubleValue() >= messagingVersion;
- if (clientSupportsSmallMessages && getSerializationContext().enableSmallMessages)
- {
- FlexSession session = FlexContext.getFlexSession();
- if (session != null)
- session.setUseSmallMessages(true);
- }
- }
- }
-
- /**
- * Default implementation of the Endpoint <code>service</code> method.
- * Subclasses should call <code>super.service</code> before their custom
- * code.
- * <p/>
- * @param req The HttpServletRequest object.
- * @param res The HttpServletResponse object.
- */
- public void service(HttpServletRequest req, HttpServletResponse res)
- {
- validateRequestProtocol(req);
- }
-
- /**
- * Typically invoked by subclasses, this method transforms decoded message data
- * into the appropriate Message object and routes the Message to the endpoint's broker.
- * <p/>
- * @param message The decoded message data.
- * @return Message The transformed message.
- */
- public Message serviceMessage(Message message)
- {
- if (isManaged())
- {
- ((EndpointControl) getControl()).incrementServiceMessageCount();
- }
-
- try
- {
- FlexContext.setThreadLocalEndpoint(this);
- Message ack = null;
-
- // Make sure this message is timestamped.
- if (message.getTimestamp() == 0)
- {
- message.setTimestamp(System.currentTimeMillis());
- }
-
- // Reset the endpoint header for inbound messages to the id for this endpoint
- // to guarantee that it's correct. Don't allow clients to spoof this.
- // However, if the endpoint id is passed as null we need to tag the message to
- // skip channel/endpoint validation at the destination level (MessageBroker.inspectChannel()).
- if (message.getHeader(Message.ENDPOINT_HEADER) != null)
- message.setHeader(Message.VALIDATE_ENDPOINT_HEADER, Boolean.TRUE);
- message.setHeader(Message.ENDPOINT_HEADER, getId());
-
- if (message instanceof CommandMessage)
- {
- CommandMessage command = (CommandMessage)message;
-
- // Apply channel endpoint level constraint; always allow login commands through.
- int operation = command.getOperation();
- if (operation != CommandMessage.LOGIN_OPERATION)
- checkSecurityConstraint(message);
-
- // Handle general (not Consumer specific) poll requests here.
- // We need to fetch all outbound messages for client subscriptions over this endpoint.
- // We identify these general poll messages by their operation and a null clientId.
- if (operation == CommandMessage.POLL_OPERATION && message.getClientId() == null)
- {
- verifyFlexClientSupport(command);
-
-
- FlexClient flexClient = FlexContext.getFlexClient();
- ack = handleFlexClientPollCommand(flexClient, command);
- }
- else if (operation == CommandMessage.DISCONNECT_OPERATION)
- {
- ack = handleChannelDisconnect(command);
- }
- else if (operation == CommandMessage.TRIGGER_CONNECT_OPERATION)
- {
- ack = new AcknowledgeMessage();
- ((AcknowledgeMessage)ack).setCorrelationId(message.getMessageId());
-
- boolean needsConfig = false;
- if (command.getHeader(CommandMessage.NEEDS_CONFIG_HEADER) != null)
- needsConfig = ((Boolean)(command.getHeader(CommandMessage.NEEDS_CONFIG_HEADER)));
-
- // Send configuration information only if the client requested.
- if (needsConfig)
- {
- ConfigMap serverConfig = getMessageBroker().describeServices(this);
- if (serverConfig.size() > 0)
- ack.setBody(serverConfig);
- }
- }
- else
- {
- // Block a subset of commands for legacy clients that need to be recompiled to
- // interop with a 2.5+ server.
- if (operation == CommandMessage.SUBSCRIBE_OPERATION || operation == CommandMessage.POLL_OPERATION)
- verifyFlexClientSupport(command);
-
- ack = getMessageBroker().routeCommandToService((CommandMessage) message, this);
-
- // Look for client advertised features on initial connect.
- if (operation == CommandMessage.CLIENT_PING_OPERATION || operation == CommandMessage.LOGIN_OPERATION)
- {
- Number clientVersion = (Number)command.getHeader(CommandMessage.MESSAGING_VERSION);
- handleClientMessagingVersion(clientVersion);
-
- // Also respond by advertising the messaging version on the
- // acknowledgement.
- ack.setHeader(CommandMessage.MESSAGING_VERSION, new Double(messagingVersion));
- }
- }
- }
- else
- {
- // Block any AsyncMessages from a legacy client.
- if (message instanceof AsyncMessage)
- verifyFlexClientSupport(message);
-
- // Apply channel endpoint level constraint.
- checkSecurityConstraint(message);
-
- ack = getMessageBroker().routeMessageToService(message, this);
- }
-
- return ack;
- }
- finally
- {
- FlexContext.setThreadLocalEndpoint(null);
- }
- }
-
- /**
- * Utility method that endpoint implementations (or associated classes)
- * should invoke when they receive an incoming message from a client but before
- * servicing it. This method looks up or creates the proper FlexClient instance
- * based upon the client the message came from and places it in the FlexContext.
- *
- * @param message The incoming message to process.
- *
- * @return The FlexClient, or <code>null</code> if the message did not contain a FlexClient ID value.
- */
- public FlexClient setupFlexClient(Message message)
- {
- FlexClient flexClient = null;
- if (message.getHeaders().containsKey(Message.FLEX_CLIENT_ID_HEADER))
- {
- String id = (String)message.getHeaders().get(Message.FLEX_CLIENT_ID_HEADER);
- // If the id is null, reset to the special token value that let's us differentiate
- // between legacy clients and 2.5+ clients.
- if (id == null)
- id = FlexClient.NULL_FLEXCLIENT_ID;
- flexClient = setupFlexClient(id);
- }
- return flexClient;
- }
-
- /**
- * Utility method that endpoint implementations (or associated classes)
- * should invoke when they receive an incoming message from a client but before
- * servicing it. This method looks up or creates the proper FlexClient instance
- * based upon the FlexClient ID value received from the client.
- * It also associates this FlexClient instance with the current FlexSession.
- *
- * @param id The FlexClient ID value from the client.
- *
- * @return The FlexClient or null if the provided ID was <code>null</code>.
- */
- public FlexClient setupFlexClient(String id)
- {
- FlexClient flexClient = null;
- if (id != null)
- {
- // This indicates that we're dealing with a non-legacy client that hasn't been
- // assigned a FlexClient Id yet. Reset to null to generate a fresh Id.
- if (id.equals(FlexClient.NULL_FLEXCLIENT_ID))
- id = null;
-
- flexClient = getMessageBroker().getFlexClientManager().getFlexClient(id);
- // Make sure the FlexClient and FlexSession are associated.
- FlexSession session = FlexContext.getFlexSession();
- flexClient.registerFlexSession(session);
- // And place the FlexClient in FlexContext for this request.
- FlexContext.setThreadLocalFlexClient(flexClient);
- }
- return flexClient;
- }
-
- /**
- * @exclude
- * Performance metrics gathering property
- */
- public boolean isRecordMessageSizes()
- {
- return recordMessageSizes;
- }
-
- /**
- * @exclude
- * Performance metrics gathering property
- */
- public boolean isRecordMessageTimes()
- {
- return recordMessageTimes;
- }
-
- /**
- * @exclude
- */
- public void setThreadLocals()
- {
- if (serializationContext != null)
- {
- SerializationContext context = (SerializationContext)serializationContext.clone();
- // Get the latest deserialization validator from the broker.
- MessageBroker broker = getMessageBroker();
- DeserializationValidator validator = broker == null? null : broker.getDeserializationValidator();
- context.setDeserializationValidator(validator);
- SerializationContext.setSerializationContext(context);
- }
-
- TypeMarshallingContext.setTypeMarshaller(getTypeMarshaller());
- }
-
- /**
- * @exclude
- */
- public void clearThreadLocals()
- {
- SerializationContext.clearThreadLocalObjects();
- TypeMarshallingContext.clearThreadLocalObjects();
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected/private methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Returns the log category of the <code>AbstractEndpoint</code>. Subclasses
- * can override to provide a more specific logging category.
- *
- * @return The log category.
- */
- @Override
- protected String getLogCategory()
- {
- return LOG_CATEGORY;
- }
-
- /**
- * Hook method invoked when a disconnect command is received from a client channel.
- * The response returned by this method is not guaranteed to get to the client, which
- * is free to terminate its physical connection at any point.
- *
- * @param disconnectCommand The disconnect command.
- * @return The response; by default an empty <tt>AcknowledgeMessage</tt>.
- */
- protected Message handleChannelDisconnect(CommandMessage disconnectCommand)
- {
- return new AcknowledgeMessage();
- }
-
- /**
- * Hook method for varying poll reply strategies for synchronous endpoints.
- * The default behavior performs a non-waited, synchronous poll for the FlexClient
- * and if any messages are currently queued they are returned immediately. If no
- * messages are queued an empty response is returned immediately.
- *
- * @param flexClient The FlexClient that issued the poll request.
- * @param pollCommand The poll command from the client.
- * @return The FlushResult response.
- */
- protected FlushResult handleFlexClientPoll(FlexClient flexClient, CommandMessage pollCommand)
- {
- return flexClient.poll(getId());
- }
-
- /**
- * Handles a general poll request from a FlexClient to this endpoint.
- * Subclasses may override to implement different poll handling strategies.
- *
- * @param flexClient The FlexClient that issued the poll request.
- * @param pollCommand The poll command from the client.
- * @return The poll response message; either for success or fault.
- */
- protected Message handleFlexClientPollCommand(FlexClient flexClient, CommandMessage pollCommand)
- {
- if (Log.isDebug())
- Log.getLogger(getMessageBroker().getLogCategory(pollCommand)).debug(
- "Before handling general client poll request. " + StringUtils.NEWLINE +
- " incomingMessage: " + pollCommand + StringUtils.NEWLINE);
-
- FlushResult flushResult = handleFlexClientPoll(flexClient, pollCommand);
- Message pollResponse = null;
-
- // Generate a no-op poll response if necessary; prevents a single client from busy polling when the server
- // is doing wait()-based long-polls.
- if ((flushResult instanceof PollFlushResult) && ((PollFlushResult)flushResult).isClientProcessingSuppressed())
- {
- pollResponse = new CommandMessage(CommandMessage.CLIENT_SYNC_OPERATION);
- pollResponse.setHeader(CommandMessage.NO_OP_POLL_HEADER, Boolean.TRUE);
- }
-
- if (pollResponse == null)
- {
- List<Message> messagesToReturn = (flushResult != null) ? flushResult.getMessages() : null;
- if (messagesToReturn != null && !messagesToReturn.isEmpty())
- {
- pollResponse = new CommandMessage(CommandMessage.CLIENT_SYNC_OPERATION);
- pollResponse.setBody(messagesToReturn.toArray());
- }
- else
- {
- pollResponse = new AcknowledgeMessage();
- }
- }
-
- // Set the adaptive poll wait time if necessary.
- if (flushResult != null)
- {
- int nextFlushWaitTime = flushResult.getNextFlushWaitTimeMillis();
- if (nextFlushWaitTime > 0)
- pollResponse.setHeader(CommandMessage.POLL_WAIT_HEADER, new Integer(nextFlushWaitTime));
- }
-
- if (Log.isDebug())
- {
- String debugPollResult = Log.getPrettyPrinter().prettify(pollResponse);
- Log.getLogger(getMessageBroker().getLogCategory(pollCommand)).debug(
- "After handling general client poll request. " + StringUtils.NEWLINE +
- " reply: " + debugPollResult + StringUtils.NEWLINE);
- }
-
- return pollResponse;
- }
-
- /**
- * Initializes the <code>Endpoint</code> with the client-load-balancing urls.
- *
- * @param id Id of the <code>Endpoint</code>.
- * @param properties Properties for the <code>Endpoint</code>.
- */
-
- protected void initializeClientLoadBalancing(String id, ConfigMap properties)
- {
- if (!properties.containsKey(CLIENT_LOAD_BALANCING_ELEMENT))
- return;
-
- ConfigMap clientLoadBalancing = properties.getPropertyAsMap(CLIENT_LOAD_BALANCING_ELEMENT, null);
- if (clientLoadBalancing == null)
- {
- // Invalid {0} configuration for endpoint ''{1}''; no urls defined.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(ERR_MSG_EMPTY_CLIENT_LOAD_BALANCING_ELEMENT, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, getId()});
- throw ce;
- }
-
- @SuppressWarnings("unchecked")
- List<String> urls = clientLoadBalancing.getPropertyAsList(URL_ATTR, null);
- if (urls == null || urls.isEmpty())
- {
- // Invalid {0} configuration for endpoint ''{1}''; no urls defined.
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(ERR_MSG_EMPTY_CLIENT_LOAD_BALANCING_ELEMENT, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, getId()});
- throw ce;
- }
-
- for (Iterator<String> iterator = urls.iterator(); iterator.hasNext();)
- {
- String url = iterator.next();
- if (!addClientLoadBalancingUrl(url) && Log.isWarn())
- log.warn("Endpoint '{0}' is ignoring the url '{1}' as it's already in the set of client-load-balancing urls.", new Object[]{id, url});
- }
- }
-
- protected void checkSecurityConstraint(Message message)
- {
- if (securityConstraint != null)
- {
- getMessageBroker().getLoginManager().checkConstraint(securityConstraint);
- }
- }
-
- /**
- * Returns the deserializer class name used by the endpoint.
- *
- * @return The deserializer class name used by the endpoint.
- */
- protected abstract String getDeserializerClassName();
-
- /**
- * Returns the serializer class name used by the endpoint.
- *
- * @return The serializer class name used by the endpoint.
- */
- protected abstract String getSerializerClassName();
-
- /**
- * Returns the secure protocol scheme for the endpoint.
- *
- * @return The secure protocol scheme for the endpoint.
- */
- protected abstract String getSecureProtocolScheme();
-
- /**
- * Returns the insecure protocol scheme for the endpoint.
- *
- * @return The insecure protocol scheme for the endpoint.
- */
- protected abstract String getInsecureProtocolScheme();
-
- /**
- * Invoked automatically to allow the <code>AbstractEndpoint</code> to setup
- * its corresponding MBean control. Subclasses should override to setup and
- * register their MBean control. Manageable subclasses should override this
- * template method.
- *
- * @param broker The <code>MessageBroker</code> that manages this
- * <code>AbstractEndpoint</code>.
- */
- protected abstract void setupEndpointControl(MessageBroker broker);
-
- /**
- * Validates the endpoint url scheme.
- */
- protected void validateEndpointProtocol()
- {
- String scheme = isSecure()? getSecureProtocolScheme() : getInsecureProtocolScheme();
- if (!url.startsWith(scheme))
- {
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(ERR_MSG_INVALID_URL_SCHEME, new Object[] {url, scheme});
- throw ce;
- }
- }
-
- protected void validateRequestProtocol(HttpServletRequest req)
- {
- // Secure url can talk to secure or non-secure endpoint.
- // Non-secure url can only talk to non-secure endpoint.
- boolean secure = req.isSecure();
- if (!secure && isSecure())
- {
- // Secure endpoints must be contacted via a secure protocol.
- String endpointPath = req.getServletPath() + req.getPathInfo();
- SecurityException se = new SecurityException();
- se.setMessage(NONSECURE_PROTOCOL, new Object[]{endpointPath});
- throw se;
- }
- }
-
- /**
- * @exclude
- * Verifies that the remote client supports the FlexClient API.
- * Legacy clients that do not support this receive a message fault for any messages they send.
- *
- * @param message The message to verify.
- */
- protected void verifyFlexClientSupport(Message message)
- {
- if (FlexContext.getFlexClient() == null)
- {
- MessageException me = new MessageException();
- me.setMessage(REQUIRES_FLEXCLIENT_SUPPORT, new Object[] {message.getDestination()});
- throw me;
- }
- }
-
- /**
- * @exclude
- */
- protected Class<?> createClass(String className)
- {
- return ClassUtil.createClass(className, FlexContext.getMessageBroker() == null ? null :
- FlexContext.getMessageBroker().getClassLoader());
- }
-
- // This should match with ChannelSetting.parseClientUri
- private void parseClientUrl(String contextPath)
- {
- if (!clientContextParsed)
- {
- String channelEndpoint = url.trim();
-
- // either {context-root} or {context.root} is legal
- channelEndpoint = StringUtils.substitute(channelEndpoint, "{context-root}", ConfigurationConstants.CONTEXT_PATH_TOKEN);
-
- if ((contextPath == null) && (channelEndpoint.indexOf(ConfigurationConstants.CONTEXT_PATH_TOKEN) != -1))
- {
- // context root must be specified before it is used
- ConfigurationException e = new ConfigurationException();
- e.setMessage(ConfigurationConstants.UNDEFINED_CONTEXT_ROOT, new Object[]{getId()});
- throw e;
- }
-
- // simplify the number of combinations to test by ensuring our
- // context path always starts with a slash
- if (contextPath != null && !contextPath.startsWith("/"))
- {
- contextPath = "/" + contextPath;
- }
-
- // avoid double-slashes from context root by replacing /{context.root}
- // in a single replacement step
- if (channelEndpoint.indexOf(ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN) != -1)
- {
- // but avoid double-slash for /{context.root}/etc when we have
- // the default context root
- if ("/".equals(contextPath) && !ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN.equals(channelEndpoint))
- contextPath = "";
-
- channelEndpoint = StringUtils.substitute(channelEndpoint, ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN, contextPath);
- }
- // otherwise we have something like {server.name}:{server.port}{context.root}...
- else
- {
- // but avoid double-slash for {context.root}/etc when we have
- // the default context root
- if ("/".equals(contextPath) && !ConfigurationConstants.CONTEXT_PATH_TOKEN.equals(channelEndpoint))
- contextPath = "";
-
- channelEndpoint = StringUtils.substitute(channelEndpoint, ConfigurationConstants.CONTEXT_PATH_TOKEN, contextPath);
- }
-
- parsedClientUrl = channelEndpoint;
- clientContextParsed = true;
- }
- }
-
- private int internalParsePort(String url)
- {
- int port = ChannelSettings.parsePort(url);
- // If there is no specified port, log an info message as urls without ports are supported
- if (port == 0 && Log.isInfo())
- log.info("No port specified in channel URL: {0}", new Object[]{url});
-
- return port == -1? 0 : port; // Replace -1 with 0.
- }
-
- private void parseUrl(String contextPath)
- {
- // Parse again only if never parsed before or parsed for a different contextPath.
- if (parsedForContext == null || !parsedForContext.equals(contextPath))
- {
- String channelEndpoint = url.toLowerCase().trim();
-
- // Remove protocol and host info
- String insecureProtocol = getInsecureProtocolScheme() + "://";
- String secureProtocol = getSecureProtocolScheme() + "://";
- if (channelEndpoint.startsWith(secureProtocol) || channelEndpoint.startsWith(insecureProtocol))
- {
- int nextSlash = channelEndpoint.indexOf('/', 8);
- if (nextSlash > 0)
- {
- channelEndpoint = channelEndpoint.substring(nextSlash);
- }
- }
-
- // either {context-root} or {context.root} is legal
- channelEndpoint = StringUtils.substitute(channelEndpoint, "{context-root}", ConfigurationConstants.CONTEXT_PATH_TOKEN);
-
- // Remove context path info
- if (channelEndpoint.startsWith(ConfigurationConstants.CONTEXT_PATH_TOKEN))
- {
- channelEndpoint = channelEndpoint.substring(ConfigurationConstants.CONTEXT_PATH_TOKEN.length());
- }
- else if (channelEndpoint.startsWith(ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN))
- {
- channelEndpoint = channelEndpoint.substring(ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN.length());
- }
- else if (contextPath.length() > 0)
- {
- if (channelEndpoint.startsWith(contextPath.toLowerCase()))
- {
- channelEndpoint = channelEndpoint.substring(contextPath.length());
- }
- }
-
- // We also don't match on trailing slashes
- if (channelEndpoint.endsWith("/"))
- {
- channelEndpoint = channelEndpoint.substring(0, channelEndpoint.length() - 1);
- }
-
- parsedUrl = channelEndpoint;
- parsedForContext = contextPath;
- }
- }
-}
+/*
+ * 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.endpoints;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import flex.management.ManageableComponent;
+import flex.management.runtime.messaging.MessageBrokerControl;
+import flex.management.runtime.messaging.endpoints.EndpointControl;
+import flex.messaging.FlexContext;
+import flex.messaging.FlexSession;
+import flex.messaging.MessageBroker;
+import flex.messaging.MessageException;
+import flex.messaging.Server;
+import flex.messaging.client.FlexClient;
+import flex.messaging.client.FlexClientOutboundQueueProcessor;
+import flex.messaging.client.FlushResult;
+import flex.messaging.client.PollFlushResult;
+import flex.messaging.client.UserAgentSettings;
+import flex.messaging.config.ChannelSettings;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.ConfigurationConstants;
+import flex.messaging.config.ConfigurationException;
+import flex.messaging.config.SecurityConstraint;
+import flex.messaging.io.ClassAliasRegistry;
+import flex.messaging.io.SerializationContext;
+import flex.messaging.io.TypeMarshaller;
+import flex.messaging.io.TypeMarshallingContext;
+import flex.messaging.io.amf.translator.ASTranslator;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.log.Logger;
+import flex.messaging.messages.AcknowledgeMessage;
+import flex.messaging.messages.AcknowledgeMessageExt;
+import flex.messaging.messages.AsyncMessage;
+import flex.messaging.messages.AsyncMessageExt;
+import flex.messaging.messages.CommandMessage;
+import flex.messaging.messages.CommandMessageExt;
+import flex.messaging.messages.Message;
+import flex.messaging.messages.SmallMessage;
+import flex.messaging.security.SecurityException;
+import flex.messaging.util.ClassUtil;
+import flex.messaging.util.StringUtils;
+import flex.messaging.util.UserAgentManager;
+import flex.messaging.validators.DeserializationValidator;
+
+/**
+ * This is the default implementation of Endpoint, which provides a convenient
+ * base for behavior and associations common to all endpoints.
+ *
+ * These properties that appear in the endpoint configuration are only used by the
+ * client, therefore they have to be set on the appropriate client classes: connect-timeout-seconds set on Channel.
+ *
+ * @see flex.messaging.endpoints.Endpoint
+ */
+public abstract class AbstractEndpoint extends ManageableComponent
+ implements Endpoint2, ConfigurationConstants
+{
+ /** Log category for <code>AbstractEndpoint</code>. */
+ public static final String LOG_CATEGORY = LogCategories.ENDPOINT_GENERAL;
+
+ /**
+ * HTTP header field names.
+ */
+ public static final String HEADER_NAME_CACHE_CONTROL = "Cache-Control";
+ public static final String HEADER_NAME_EXPIRES = "Expires";
+ public static final String HEADER_NAME_PRAGMA = "Pragma";
+
+ // Errors
+ private static final int NONSECURE_PROTOCOL = 10066;
+ private static final int REQUIRES_FLEXCLIENT_SUPPORT = 10030;
+ private static final int ERR_MSG_INVALID_URL_SCHEME = 11100;
+
+ // XML Configuration Properties
+ private static final String SERIALIZATION = "serialization";
+ private static final String CREATE_ASOBJECT_FOR_MISSING_TYPE = "create-asobject-for-missing-type";
+ private static final String CUSTOM_DESERIALIZER = "custom-deserializer";
+ private static final String CUSTOM_SERIALIZER = "custom-serializer";
+ private static final String ENABLE_SMALL_MESSAGES = "enable-small-messages";
+ private static final String TYPE_MARSHALLER = "type-marshaller";
+ private static final String RESTORE_REFERENCES = "restore-references";
+ private static final String INSTANTIATE_TYPES = "instantiate-types";
+ private static final String SUPPORT_REMOTE_CLASS = "support-remote-class";
+ private static final String LEGACY_COLLECTION = "legacy-collection";
+ private static final String LEGACY_DICTIONARY = "legacy-dictionary";
+ private static final String LEGACY_MAP = "legacy-map";
+ private static final String LEGACY_XML = "legacy-xml";
+ private static final String LEGACY_XML_NAMESPACES = "legacy-xml-namespaces";
+ private static final String LEGACY_THROWABLE = "legacy-throwable";
+ private static final String LEGACY_BIG_NUMBERS = "legacy-big-numbers";
+ private static final String LEGACY_EXTERNALIZABLE = "legacy-externalizable";
+ private static final String LOG_PROPERTY_ERRORS = "log-property-errors";
+ private static final String IGNORE_PROPERTY_ERRORS = "ignore-property-errors";
+ private static final String INCLUDE_READ_ONLY = "include-read-only";
+ private static final String GLOBAL_INCLUDE_READ_ONLY = "global-include-read-only";
+ private static final String FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR = "flex-client-outbound-queue-processor";
+ private static final String SHOW_STACKTRACES = "show-stacktraces";
+ private static final String MAX_OBJECT_NEST_LEVEL = "max-object-nest-level";
+ private static final String MAX_COLLECTION_NEST_LEVEL = "max-collection-nest-level";
+ private static final String PREFER_VECTORS = "prefer-vectors";
+
+ // Endpoint properties
+ protected Set<String> clientLoadBalancingUrls;
+ protected String clientType;
+ protected int connectTimeoutSeconds;
+ protected int requestTimeoutSeconds;
+ protected FlexClientOutboundQueueProcessor flexClientOutboundQueueProcessor;
+ protected SerializationContext serializationContext;
+ protected Class<?> deserializerClass;
+ protected Class<?> serializerClass;
+ protected TypeMarshaller typeMarshaller;
+ protected int port;
+ private SecurityConstraint securityConstraint;
+ protected String url;
+ protected boolean recordMessageSizes;
+ protected boolean recordMessageTimes;
+ protected boolean remote;
+ protected Server server;
+ protected boolean serverOnly;
+
+ // Endpoint internal
+ protected String parsedUrl;
+ // Keeps track of what context path parsedUrl has been parsed for. If it is
+ // null, means parsedUrl has not been parsed already.
+ protected String parsedForContext;
+ protected boolean clientContextParsed;
+ protected String parsedClientUrl;
+ protected Logger log;
+
+ protected Class<?> flexClientOutboundQueueProcessClass;
+ protected ConfigMap flexClientOutboundQueueProcessorConfig;
+
+ // Supported messaging version
+ protected double messagingVersion = 1.0;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>AbstractEndpoint</code>.
+ */
+ public AbstractEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs an <code>AbstractEndpoint</code> with the indicated management.
+ *
+ * @param enableManagement <code>true</code> if the <code>AbstractEndpoint</code>
+ * is manageable; <code>false</code> otherwise.
+ */
+ public AbstractEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ this.log = Log.getLogger(getLogCategory());
+ serializationContext = new SerializationContext();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Initialize, validate, start, and stop methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes the <code>Endpoint</code> with the properties.
+ * If subclasses override this method, they must call <code>super.initialize()</code>.
+ *
+ * @param id The ID of the <code>Endpoint</code>.
+ * @param properties Properties for the <code>Endpoint</code>.
+ */
+ @Override
+ public void initialize(String id, ConfigMap properties)
+ {
+ super.initialize(id, properties);
+
+ if (properties == null || properties.size() == 0)
+ return;
+
+ // Client-targeted <client-load-balancing>
+ initializeClientLoadBalancing(id, properties);
+
+ // Client-targeted <connect-timeout-seconds/>
+ connectTimeoutSeconds = properties.getPropertyAsInt(CONNECT_TIMEOUT_SECONDS_ELEMENT, 0);
+
+ // Client-targeted <request-timeout-seconds/>
+ requestTimeoutSeconds = properties.getPropertyAsInt(REQUEST_TIMEOUT_SECONDS_ELEMENT, 0);
+
+ // Check for a custom FlexClient outbound queue processor.
+ ConfigMap outboundQueueConfig = properties.getPropertyAsMap(FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR, null);
+ if (outboundQueueConfig != null)
+ {
+ // Get nested props for the processor.
+ flexClientOutboundQueueProcessorConfig = outboundQueueConfig.getPropertyAsMap(PROPERTIES_ELEMENT, null);
+
+ String pClassName = outboundQueueConfig.getPropertyAsString(CLASS_ATTR, null);
+ if (pClassName != null)
+ {
+ try
+ {
+ flexClientOutboundQueueProcessClass = createClass(pClassName);
+ // And now create an instance and initialize to make sure the properties are valid.
+ setFlexClientOutboundQueueProcessorConfig(flexClientOutboundQueueProcessorConfig);
+ }
+ catch (Throwable t)
+ {
+ if (Log.isWarn())
+ log.warn("Cannot register custom FlexClient outbound queue processor class {0}", new Object[]{pClassName}, t);
+ }
+ }
+ }
+
+ ConfigMap serialization = properties.getPropertyAsMap(SERIALIZATION, null);
+ if (serialization != null)
+ {
+ // Custom deserializers
+ List<?> deserializers = serialization.getPropertyAsList(CUSTOM_DESERIALIZER, null);
+ if (deserializers != null && Log.isWarn())
+ log.warn("Endpoint <custom-deserializer> functionality is no longer available. Please remove this entry from your configuration.");
+
+ // Custom serializers
+ List<?> serializers = serialization.getPropertyAsList(CUSTOM_SERIALIZER, null);
+ if (serializers != null && Log.isWarn())
+ log.warn("Endpoint <custom-serializer> functionality is no longer available. Please remove this entry from your configuration.");
+
+ // Type Marshaller implementation
+ String typeMarshallerClassName = serialization.getPropertyAsString(TYPE_MARSHALLER, null);
+ if (typeMarshallerClassName != null && typeMarshallerClassName.length() > 0)
+ {
+ try
+ {
+ Class<?> tmc = createClass(typeMarshallerClassName);
+ typeMarshaller = (TypeMarshaller)ClassUtil.createDefaultInstance(tmc, TypeMarshaller.class);
+ }
+ catch (Throwable t)
+ {
+ if (Log.isWarn())
+ log.warn("Cannot register custom type marshaller for type {0}", new Object[]{typeMarshallerClassName}, t);
+ }
+ }
+
+ // Boolean Serialization Flags
+ serializationContext.createASObjectForMissingType = serialization.getPropertyAsBoolean(CREATE_ASOBJECT_FOR_MISSING_TYPE, false);
+ serializationContext.enableSmallMessages = serialization.getPropertyAsBoolean(ENABLE_SMALL_MESSAGES, true);
+ serializationContext.instantiateTypes = serialization.getPropertyAsBoolean(INSTANTIATE_TYPES, true);
+ serializationContext.supportRemoteClass = serialization.getPropertyAsBoolean(SUPPORT_REMOTE_CLASS, false);
+ serializationContext.legacyCollection = serialization.getPropertyAsBoolean(LEGACY_COLLECTION, false);
+ serializationContext.legacyDictionary = serialization.getPropertyAsBoolean(LEGACY_DICTIONARY, false);
+ serializationContext.legacyMap = serialization.getPropertyAsBoolean(LEGACY_MAP, false);
+ serializationContext.legacyXMLDocument = serialization.getPropertyAsBoolean(LEGACY_XML, false);
+ serializationContext.legacyXMLNamespaces = serialization.getPropertyAsBoolean(LEGACY_XML_NAMESPACES, false);
+ serializationContext.legacyThrowable = serialization.getPropertyAsBoolean(LEGACY_THROWABLE, false);
+ serializationContext.legacyBigNumbers = serialization.getPropertyAsBoolean(LEGACY_BIG_NUMBERS, false);
+ serializationContext.legacyExternalizable = serialization.getPropertyAsBoolean(LEGACY_EXTERNALIZABLE, false);
+ serializationContext.maxObjectNestLevel = (int)serialization.getPropertyAsLong(MAX_OBJECT_NEST_LEVEL, 512);
+ serializationContext.maxCollectionNestLevel = (int)serialization.getPropertyAsLong(MAX_COLLECTION_NEST_LEVEL, 15);
+ serializationContext.preferVectors = serialization.getPropertyAsBoolean(PREFER_VECTORS, false);
+
+ boolean showStacktraces = serialization.getPropertyAsBoolean(SHOW_STACKTRACES, false);
+ if (showStacktraces && Log.isWarn())
+ log.warn("The " + SHOW_STACKTRACES + " configuration option is deprecated and non-functional. Please remove this from your configuration file.");
+ serializationContext.restoreReferences = serialization.getPropertyAsBoolean(RESTORE_REFERENCES, false);
+ serializationContext.logPropertyErrors = serialization.getPropertyAsBoolean(LOG_PROPERTY_ERRORS, false);
+ serializationContext.ignorePropertyErrors = serialization.getPropertyAsBoolean(IGNORE_PROPERTY_ERRORS, true);
+ serializationContext.includeReadOnly = serialization.getPropertyAsBoolean(INCLUDE_READ_ONLY, false);
+ }
+
+ recordMessageSizes = properties.getPropertyAsBoolean(ConfigurationConstants.RECORD_MESSAGE_SIZES_ELEMENT, false);
+
+ if (recordMessageSizes && Log.isWarn())
+ log.warn("Setting <record-message-sizes> to true affects application performance and should only be used for debugging");
+
+ recordMessageTimes = properties.getPropertyAsBoolean(ConfigurationConstants.RECORD_MESSAGE_TIMES_ELEMENT, false);
+ }
+
+ /**
+ * Starts the endpoint if its associated <code>MessageBroker</code> is started,
+ * and if the endpoint is not already running. If subclasses override this method,
+ * they must call <code>super.start()</code>.
+ */
+ @Override
+ public void start()
+ {
+ if (isStarted())
+ return;
+
+ // Check if the MessageBroker is started
+ MessageBroker broker = getMessageBroker();
+ if (!broker.isStarted())
+ {
+ if (Log.isWarn())
+ {
+ Log.getLogger(getLogCategory()).warn("Endpoint with id '{0}' cannot be started" +
+ " when the MessageBroker is not started.",
+ new Object[]{getId()});
+ }
+ return;
+ }
+
+ // Set up management
+ if (isManaged() && broker.isManaged())
+ {
+ setupEndpointControl(broker);
+ MessageBrokerControl controller = (MessageBrokerControl)broker.getControl();
+ if (getControl() != null)
+ controller.addEndpoint(this);
+ }
+
+ // Setup Deserializer and Serializer for the SerializationContext
+ if (deserializerClass == null)
+ deserializerClass = createClass(getDeserializerClassName());
+
+ if (serializerClass == null)
+ serializerClass = createClass(getSerializerClassName());
+
+ serializationContext.setDeserializerClass(deserializerClass);
+ serializationContext.setSerializerClass(serializerClass);
+
+ // Setup endpoint features
+ ClassAliasRegistry registry = ClassAliasRegistry.getRegistry();
+ registry.registerAlias(AsyncMessageExt.CLASS_ALIAS, AsyncMessageExt.class.getName());
+ registry.registerAlias(AcknowledgeMessageExt.CLASS_ALIAS, AcknowledgeMessageExt.class.getName());
+ registry.registerAlias(CommandMessageExt.CLASS_ALIAS, CommandMessageExt.class.getName());
+ super.start();
+ }
+
+ /**
+ * Stops the endpoint if it is running. If subclasses override this method, they must
+ * call <code>super.stop()</code>.
+ */
+ @Override
+ public void stop()
+ {
+ if (!isStarted())
+ return;
+
+ super.stop();
+
+ // Remove management
+ if (isManaged() && getMessageBroker().isManaged())
+ {
+ if (getControl() != null)
+ {
+ getControl().unregister();
+ setControl(null);
+ }
+ setManaged(false);
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Getters and Setters for AbstractEndpoint properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Adds a client-load-balancing URL.
+ *
+ * @param url A client-load-balancing URL.
+ * @return <code>false</code> if the set already contains the URL, <code>true</code> otherwise.
+ *
+ */
+ public boolean addClientLoadBalancingUrl(String url)
+ {
+ if (clientLoadBalancingUrls == null)
+ clientLoadBalancingUrls = new HashSet<String>();
+
+ if (url == null || url.length() == 0)
+ {
+ // Invalid {0} configuration for endpoint ''{1}''; cannot add empty url.
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(ERR_MSG_EMTPY_CLIENT_LOAD_BALACNING_URL, new Object[]{CLIENT_LOAD_BALANCING_ELEMENT, getId()});
+ throw ce;
+ }
+
+ return clientLoadBalancingUrls.add(url);
+ }
+
+ /**
+ * Removes the client-load-balancing URL.
+ *
+ * @param url The URL to remove.
+ * @return <code>true</code> if the set contained the URL, <code>false</code> otherwise.
+ */
+ public boolean removeClientLoadBalancingUrl(String url)
+ {
+ if (clientLoadBalancingUrls != null)
+ return clientLoadBalancingUrls.remove(url);
+ return false;
+ }
+
+ /**
+ * Retrieves a snapshot of the current client-load-balancing URLs.
+ *
+ * @return A snapshot of the current client-load-balancing URLs, or <code>null</code> if
+ * no URL exists.
+ */
+ public Set<String> getClientLoadBalancingUrls()
+ {
+ return clientLoadBalancingUrls == null? null : new HashSet<String>(clientLoadBalancingUrls);
+ }
+
+ /**
+ * Retrieves the corresponding client channel type for the endpoint.
+ *
+ * @return The corresponding client channel type for the endpoint.
+ */
+ public String getClientType()
+ {
+ return clientType;
+ }
+
+ /**
+ * Sets the corresponding client channel type for the endpoint.
+ *
+ * @param type The corresponding client channel type for the endpoint.
+ */
+ public void setClientType(String type)
+ {
+ this.clientType = type;
+ }
+
+ /**
+ * Retrieves the <code>FlexClientOutboundQueueProcessorClass</code> of the endpoint.
+ *
+ * @return The <code>FlexClientOutboundQueueProcessorClass</code> of the endpoint.
+ */
+ public Class<?> getFlexClientOutboundQueueProcessorClass()
+ {
+ return flexClientOutboundQueueProcessClass;
+ }
+
+ /**
+ * Sets the the <code>FlexClientOutboundQueueProcessor</code> of the endpoint.
+ *
+ * @param flexClientOutboundQueueProcessorClass the Class of the Flex client outbound queue processor.
+ */
+ public void setFlexClientOutboundQueueProcessorClass(Class<?> flexClientOutboundQueueProcessorClass)
+ {
+ this.flexClientOutboundQueueProcessClass = flexClientOutboundQueueProcessorClass;
+ if (flexClientOutboundQueueProcessClass != null && flexClientOutboundQueueProcessorConfig != null)
+ {
+ FlexClientOutboundQueueProcessor processor = (FlexClientOutboundQueueProcessor)ClassUtil.createDefaultInstance(flexClientOutboundQueueProcessClass, null);
+ processor.initialize(flexClientOutboundQueueProcessorConfig);
+ }
+ }
+
+ /**
+ * Retrieves the properties for the <code>FlexClientOutboundQueueProcessor</code> of the endpoint.
+ *
+ * @return The properties for the <code>FlexClientOutboundQueueProcessor</code> of the endpoint.
+ */
+ public ConfigMap getFlexClientOutboundQueueProcessorConfig()
+ {
+ return flexClientOutboundQueueProcessorConfig;
+ }
+
+ /**
+ * Sets the properties for the <code>FlexClientOutboundQueueProcessor</code> of the endpoint.
+ *
+ * @param flexClientOutboundQueueProcessorConfig The configuration map.
+ */
+ public void setFlexClientOutboundQueueProcessorConfig(ConfigMap flexClientOutboundQueueProcessorConfig)
+ {
+ this.flexClientOutboundQueueProcessorConfig = flexClientOutboundQueueProcessorConfig;
+ if (flexClientOutboundQueueProcessorConfig != null && flexClientOutboundQueueProcessClass != null)
+ {
+ FlexClientOutboundQueueProcessor processor = (FlexClientOutboundQueueProcessor)ClassUtil.createDefaultInstance(flexClientOutboundQueueProcessClass, null);
+ processor.initialize(flexClientOutboundQueueProcessorConfig);
+ }
+ }
+
+ /**
+ * Sets the ID of the <code>AbstractEndpoint</code>. If the <code>AbstractEndpoint</code>
+ * has a <code>MessageBroker</code> assigned, it also updates the ID in the
+ * <code>MessageBroker</code>.
+ * <p/>
+ * @param id The endpoint ID.
+ */
+ @Override
+ public void setId(String id)
+ {
+ String oldId = getId();
+
+ if (oldId != null && oldId.equals(id))
+ return;
+
+ super.setId(id);
+
+ // Update the endpoint id in the broker
+ MessageBroker broker = getMessageBroker();
+ if (broker != null)
+ {
+ // broker must have the endpoint then
+ broker.removeEndpoint(oldId);
+ broker.addEndpoint(this);
+ }
+ }
+
+ /**
+ * Retrieves the <code>MessageBroker</code> of the <code>AbstractEndpoint</code>.
+ *
+ * @return The <code>MessageBroker</code> of the <code>AbstractEndpoint</code>.
+ */
+ public MessageBroker getMessageBroker()
+ {
+ return (MessageBroker)getParent();
+ }
+
+ /**
+ * Sets the <code>MessageBroker</code> of the <code>AbstractEndpoint</code>.
+ * Removes the <code>AbstractEndpoint</code> from the old broker
+ * (if there was one) and adds to the list of endpoints in the new broker.
+ *
+ * @param broker The <code>MessageBroker</code> of the <code>AbstractEndpoint</code>.
+ */
+ public void setMessageBroker(MessageBroker broker)
+ {
+ MessageBroker oldBroker = getMessageBroker();
+
+ setParent(broker);
+
+ if (oldBroker != null)
+ oldBroker.removeEndpoint(getId());
+
+ // Add endpoint to the new broker if needed
+ if (broker.getEndpoint(getId()) != this)
+ broker.addEndpoint(this);
+ }
+
+ /**
+ * Return the highest messaging version currently available via this
+ * endpoint.
+ * @return double the messaging version
+ */
+ public double getMessagingVersion()
+ {
+ return messagingVersion;
+ }
+
+ /**
+ * Retrieves the port of the URL of the endpoint.
+ * A return value of 0 denotes no port in the channel URL.
+ *
+ * @return The port of the URL of the endpoint, or 0 if the URL does not contain
+ * a port number.
+ */
+ public int getPort()
+ {
+ return port;
+ }
+
+ /**
+ * Determines whether the endpoint is secure.
+ *
+ * @return <code>false</code> by default.
+ */
+ public boolean isSecure()
+ {
+ return false;
+ }
+
+ /**
+ * Determines if the endpoint clients connect to directly is mirrored and running
+ * on a remote host, in which case this local instance is not started and will service no direct
+ * client connections.
+ *
+ * @return <code>true</code> if this endpoint will not process direct client connections and is just
+ * a local representation of a symmetric endpoint on a remote host that will, <code>false</code> otherwise.
+ */
+ public boolean isRemote()
+ {
+ return remote;
+ }
+
+ /**
+ * Sets the remote status for this endpoint.
+ *
+ * @param value <code>true</code> if this endpoint will not process direct client connections and is just
+ * a local representation of a symmetric endpoint on a remote host that will, <code>false</code> otherwise.
+ */
+ public void setRemote(boolean value)
+ {
+ remote = value;
+ }
+
+ /**
+ * Retrieves the <tt>Server</tt> that the endpoint is using, or <code>null</code> if
+ * no server has been assigned.
+ * @return Server The Server object the endpoint is using.
+ */
+ public Server getServer()
+ {
+ return server;
+ }
+
+ /**
+ * Sets the <tt>Server</tt> that the endpoint will use.
+ * @param server The Server object.
+ */
+ public void setServer(Server server)
+ {
+ this.server = server;
+ }
+
+ /**
+ * Determines whether the endpoint is server only.
+ *
+ * @return <code>true</code> if the endpoint is server only, <code>false</code> otherwise.
+ */
+ public boolean getServerOnly()
+ {
+ return serverOnly;
+ }
+
+ /**
+ * Sets whether the endpoint is server only.
+ *
+ * @param serverOnly <code>true</code> if the endpoint is server only, <code>false</code> otherwise.
+ */
+ public void setServerOnly(boolean serverOnly)
+ {
+ this.serverOnly = serverOnly;
+
<TRUNCATED>
[17/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/ClasspathResourceResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/ClasspathResourceResolver.java b/modules/core/src/flex/messaging/config/ClasspathResourceResolver.java
new file mode 100644
index 0000000..aa8be3f
--- /dev/null
+++ b/modules/core/src/flex/messaging/config/ClasspathResourceResolver.java
@@ -0,0 +1,52 @@
+/*
+ * 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.config;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Stack;
+
+/**
+ * @author Christofer Dutz
+ */
+public class ClasspathResourceResolver implements ConfigurationFileResolver {
+
+ private String baseConfigFileDirectory;
+
+ @Override
+ public InputStream getConfigurationFile(String path) {
+ final String cpPath = path.substring("classpath:".length());
+ baseConfigFileDirectory = cpPath.substring(0, cpPath.lastIndexOf("/"));
+ return this.getClass().getResourceAsStream(cpPath);
+ }
+
+ @Override
+ public InputStream getIncludedFile(String path) {
+ final String cpPath = baseConfigFileDirectory + "/" + path;
+ return this.getClass().getResourceAsStream(cpPath);
+ }
+
+ @Override
+ public void popIncludedFile() {
+ }
+
+ @Override
+ public List getFiles(String dir) {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/ConfigurationManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/ConfigurationManager.java b/modules/core/src/flex/messaging/config/ConfigurationManager.java
old mode 100755
new mode 100644
index 70b8cc6..86a83d3
--- a/modules/core/src/flex/messaging/config/ConfigurationManager.java
+++ b/modules/core/src/flex/messaging/config/ConfigurationManager.java
@@ -1,40 +1,40 @@
-/*
- * 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.config;
-
-import javax.servlet.ServletConfig;
-
-import flex.messaging.log.LogCategories;
-
-/**
- * ConfigurationManager interface
- *
- * The default implementation of the configuration manager is
- * FlexConfigurationManager. However, this value be specified in
- * a servlet init-param "services.configuration.manager"
- * to the MessageBrokerServlet.
- *
- * @exclude
- */
-public interface ConfigurationManager
-{
- String LOG_CATEGORY = LogCategories.CONFIGURATION;
-
- MessagingConfiguration getMessagingConfiguration(ServletConfig servletConfig);
-
- void reportTokens();
-}
+/*
+ * 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.config;
+
+import javax.servlet.ServletConfig;
+
+import flex.messaging.log.LogCategories;
+
+/**
+ * ConfigurationManager interface
+ *
+ * The default implementation of the configuration manager is
+ * FlexConfigurationManager. However, this value be specified in
+ * a servlet init-param "services.configuration.manager"
+ * to the MessageBrokerServlet.
+ *
+ * @exclude
+ */
+public interface ConfigurationManager
+{
+ String LOG_CATEGORY = LogCategories.CONFIGURATION;
+
+ MessagingConfiguration getMessagingConfiguration(ServletConfig servletConfig);
+
+ void reportTokens();
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/FactorySettings.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/FactorySettings.java b/modules/core/src/flex/messaging/config/FactorySettings.java
old mode 100755
new mode 100644
index 384feba..948ab3d
--- a/modules/core/src/flex/messaging/config/FactorySettings.java
+++ b/modules/core/src/flex/messaging/config/FactorySettings.java
@@ -1,82 +1,82 @@
-/*
- * 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.config;
-
-import flex.messaging.FlexFactory;
-import flex.messaging.util.ClassUtil;
-
-/**
- * The factory configuration defines a single factory in the flex
- * configuration file.
- *
- * @author Jeff Vroom
- * @exclude
- */
-public class FactorySettings extends PropertiesSettings
-{
- protected String id;
- protected String className;
-
- public FactorySettings(String id, String className)
- {
- this.id = id;
- this.className = className;
- }
-
- public String getId()
- {
- return id;
- }
-
- public String getClassName()
- {
- return className;
- }
-
- public FlexFactory createFactory()
- {
- return createFactory(null);
- }
-
- public FlexFactory createFactory(ClassLoader cl)
- {
- try
- {
- Class c = ClassUtil.createClass(className, cl);
- Object f = ClassUtil.createDefaultInstance(c, FlexFactory.class);
- if (f instanceof FlexFactory)
- {
- FlexFactory ff = (FlexFactory) f;
- ff.initialize(getId(), getProperties());
- return ff;
- }
- else
- {
- ConfigurationException cx = new ConfigurationException();
- cx.setMessage(11101, new Object[] { className });
- throw cx;
- }
- }
- catch (Throwable th)
- {
- ConfigurationException cx = new ConfigurationException();
- cx.setMessage(11102, new Object[] { className, th.toString() });
- cx.setRootCause(th);
- throw cx;
- }
- }
-}
+/*
+ * 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.config;
+
+import flex.messaging.FlexFactory;
+import flex.messaging.util.ClassUtil;
+
+/**
+ * The factory configuration defines a single factory in the flex
+ * configuration file.
+ *
+ * @author Jeff Vroom
+ * @exclude
+ */
+public class FactorySettings extends PropertiesSettings
+{
+ protected String id;
+ protected String className;
+
+ public FactorySettings(String id, String className)
+ {
+ this.id = id;
+ this.className = className;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public FlexFactory createFactory()
+ {
+ return createFactory(null);
+ }
+
+ public FlexFactory createFactory(ClassLoader cl)
+ {
+ try
+ {
+ Class c = ClassUtil.createClass(className, cl);
+ Object f = ClassUtil.createDefaultInstance(c, FlexFactory.class);
+ if (f instanceof FlexFactory)
+ {
+ FlexFactory ff = (FlexFactory) f;
+ ff.initialize(getId(), getProperties());
+ return ff;
+ }
+ else
+ {
+ ConfigurationException cx = new ConfigurationException();
+ cx.setMessage(11101, new Object[] { className });
+ throw cx;
+ }
+ }
+ catch (Throwable th)
+ {
+ ConfigurationException cx = new ConfigurationException();
+ cx.setMessage(11102, new Object[] { className, th.toString() });
+ cx.setRootCause(th);
+ throw cx;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/FlexConfigurationManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/FlexConfigurationManager.java b/modules/core/src/flex/messaging/config/FlexConfigurationManager.java
old mode 100755
new mode 100644
index 8d1ae34..130a4d1
--- a/modules/core/src/flex/messaging/config/FlexConfigurationManager.java
+++ b/modules/core/src/flex/messaging/config/FlexConfigurationManager.java
@@ -1,319 +1,318 @@
-/*
- * 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.config;
-
-import flex.messaging.LocalizedException;
-import flex.messaging.util.Trace;
-import flex.messaging.util.ClassUtil;
-
-import javax.servlet.ServletConfig;
-import java.io.File;
-
-/**
- * Manages which ConfigurationParser implementation will be
- * used to read in the services configuration file and determines
- * where the configuration file is located.
- * <p>
- * The default location of the configuration file is
- * /WEB-INF/flex/services-config.xml, however this value can
- * be specified in a servlet init-param "services.configuration.file"
- * to the MessageBrokerServlet.
- * </p>
- * <p>
- * The ConfigurationParser implementation can also be specified in
- * a servlet init-param "services.configuration.parser" to
- * the MessageBrokerServlet.
- * </p>
- *
- * @author Peter Farland
- * @see ConfigurationParser
- * @exclude
- */
-public class FlexConfigurationManager implements ConfigurationManager
-{
- static final String DEFAULT_CONFIG_PATH = "/WEB-INF/flex/services-config.xml";
-
- protected String configurationPath = null;
- protected ConfigurationFileResolver configurationResolver = null;
- protected ConfigurationParser parser = null;
-
- public MessagingConfiguration getMessagingConfiguration(ServletConfig servletConfig)
- {
- MessagingConfiguration config = new MessagingConfiguration();
-
- if (servletConfig != null)
- {
- String serverInfo = servletConfig.getServletContext().getServerInfo();
- config.getSecuritySettings().setServerInfo(serverInfo);
- }
-
- verifyMinimumJavaVersion();
-
- parser = getConfigurationParser(servletConfig);
-
- if (parser == null)
- {
- // "Unable to create a parser to load messaging configuration."
- LocalizedException lme = new LocalizedException();
- lme.setMessage(10138);
- throw lme;
- }
-
- setupConfigurationPathAndResolver(servletConfig);
- parser.parse(configurationPath, configurationResolver, config);
-
- if (servletConfig != null)
- {
- config.getSystemSettings().setPaths(servletConfig.getServletContext());
- }
-
- return config;
- }
-
- public void reportTokens()
- {
- parser.reportTokens();
- }
-
- protected ConfigurationParser getConfigurationParser(ServletConfig servletConfig)
- {
- ConfigurationParser parser = null;
- Class parserClass = null;
- String className = null;
-
- // Check for Custom Parser Specification
- if (servletConfig != null)
- {
- String p = servletConfig.getInitParameter("services.configuration.parser");
- if (p != null)
- {
- className = p.trim();
- try
- {
- parserClass = ClassUtil.createClass(className);
- parser = (ConfigurationParser)parserClass.newInstance();
- }
- catch (Throwable t)
- {
- if (Trace.config)
- {
- Trace.trace("Could not load configuration parser as: " + className);
- }
- }
- }
- }
-
- // Always try Sun JRE 1.4 / Apache Xalan Based Implementation first to
- // avoid performance problems with Sun JRE 1.5 Based Implementation
- if (parser == null)
- {
- try
- {
- ClassUtil.createClass("org.apache.xpath.CachedXPathAPI");
- className = "flex.messaging.config.ApacheXPathServerConfigurationParser";
- parserClass = ClassUtil.createClass(className);
- parser = (ConfigurationParser)parserClass.newInstance();
- }
- catch (Throwable t)
- {
- if (Trace.config)
- {
- Trace.trace("Could not load configuration parser as: " + className);
- }
- }
- }
-
- // Try Sun JRE 1.5 Based Implementation
- if (parser == null)
- {
- try
- {
- className = "flex.messaging.config.XPathServerConfigurationParser";
- parserClass = ClassUtil.createClass(className);
- // double-check, on some systems the above loads but the import classes don't
- ClassUtil.createClass("javax.xml.xpath.XPathExpressionException");
-
- parser = (ConfigurationParser)parserClass.newInstance();
- }
- catch (Throwable t)
- {
- if (Trace.config)
- {
- Trace.trace("Could not load configuration parser as: " + className);
- }
- }
- }
-
- if (Trace.config && parser != null)
- {
- Trace.trace("Services Configuration Parser: " + parser.getClass().getName());
- }
-
- return parser;
- }
-
- /**
- * Sets up the configuration path and resolver objects.
- * If no entry is specified in web.xml, assumed services-config.xml in the web application.
- * If an entry is specified for windows starting with '/', it's assumed to be in the web application.
- * If an entry is specified for windows not starting with '\', it's assumed to be on the local file system.
- * If an entry is specified for non-windows starting with '/', we will first look in the web application
- * then the the local file system.
- *
- * @param servletConfig configuration
- */
- protected void setupConfigurationPathAndResolver(ServletConfig servletConfig)
- {
- if (servletConfig != null)
- {
- String p = servletConfig.getInitParameter("services.configuration.file");
- if ((p == null) || (p.trim().length() == 0))
- {
- // no entry specified in web.xml, always use default and ServletResourceResolver
- configurationPath = DEFAULT_CONFIG_PATH;
- configurationResolver = new ServletResourceResolver(servletConfig.getServletContext());
- }
- else
- {
- // an entry was specified in web.xml,
- configurationPath = p.trim();
-
- // on windows, all paths starting with '/' should be available via the servlet resource resolver
- // on other systems, you're not sure so try the servlet resource loader first it but don't throw an error,
- // after that try using LocalFileResolver
- boolean isWindows = File.separator.equals("\\");
- boolean isServletResource = isWindows && configurationPath.startsWith("/");
- if (isServletResource || !isWindows)
- {
- ServletResourceResolver resolver = new ServletResourceResolver(servletConfig.getServletContext());
- boolean available = resolver.isAvailable(configurationPath, isServletResource);
- if (available)
- {
- // it's available via the servlet resource loader
- configurationResolver = (ConfigurationFileResolver)resolver;
- }
- else
- {
- // it wasn't available via the servlet resource loader
- configurationResolver = new LocalFileResolver(LocalFileResolver.SERVER);
- }
- }
- else
- {
- // it's windows but seems to be specified as a file
- configurationResolver = new LocalFileResolver(LocalFileResolver.SERVER);
- }
- }
- }
-
- // no entry specified in web.xml
- else
- {
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage("missing ServletConfig object");
- throw ce;
- }
-
-
- }
-
- protected void verifyMinimumJavaVersion() throws ConfigurationException
- {
- try
- {
- boolean minimum = false;
- String version = System.getProperty("java.version");
- String vendor = System.getProperty("java.vendor");
-
- version = version.replace('.', ':');
- version = version.replace('_', ':');
- String[] split = version.split(":");
-
- int first = Integer.parseInt(split[0]);
- if (first > 1)
- {
- minimum = true;
- }
- else if (first == 1)
- {
- int second = Integer.parseInt(split[1]);
- if (second > 4)
- {
- minimum = true;
- }
- else if (second == 4)
- {
- int third = Integer.parseInt(split[2]);
- if (third > 2)
- {
- minimum = true;
- }
- else if (third == 2)
- {
- if ((vendor != null) && (vendor.indexOf("Sun") != -1))
- {
- // test at least 1.4.2_06 on Sun
- int fourth = Integer.parseInt(split[3]);
- if (fourth >= 6)
- {
- minimum = true;
- }
- }
- else
- {
- // test at least 1.4.2 on non-Sun
- minimum = true;
- }
- }
- }
- }
-
- if (!minimum)
- {
- ConfigurationException cx = new ConfigurationException();
-
- if ((vendor != null) && (vendor.indexOf("Sun") != -1))
- {
- // The minimum required Java version was not found. Please install JDK 1.4.2_06 or above. Current version is XX.
- cx.setMessage(10139, new Object[] { System.getProperty("java.version")});
- }
- else
- {
- // The minimum required Java version was not found. Please install JDK 1.4.2 or above. Current version is XX.
- cx.setMessage(10140, new Object[] { System.getProperty("java.version")});
- }
-
- throw cx;
- }
- }
- catch (Throwable t)
- {
- if (t instanceof ConfigurationException)
- {
- throw ((ConfigurationException)t);
- }
- else
- {
- if (Trace.config)
- {
- Trace.trace("Could not verified required java version. version=" + System.getProperty("java.version"));
- }
- }
- }
- }
-
-}
+/*
+ * 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.config;
+
+import flex.messaging.LocalizedException;
+import flex.messaging.util.Trace;
+import flex.messaging.util.ClassUtil;
+
+import javax.servlet.ServletConfig;
+import java.io.File;
+
+/**
+ * Manages which ConfigurationParser implementation will be
+ * used to read in the services configuration file and determines
+ * where the configuration file is located.
+ * <p>
+ * The default location of the configuration file is
+ * /WEB-INF/flex/services-config.xml, however this value can
+ * be specified in a servlet init-param "services.configuration.file"
+ * to the MessageBrokerServlet.
+ * </p>
+ * <p>
+ * The ConfigurationParser implementation can also be specified in
+ * a servlet init-param "services.configuration.parser" to
+ * the MessageBrokerServlet.
+ * </p>
+ *
+ * @author Peter Farland
+ * @see ConfigurationParser
+ * @exclude
+ */
+public class FlexConfigurationManager implements ConfigurationManager
+{
+ static final String DEFAULT_CONFIG_PATH = "/WEB-INF/flex/services-config.xml";
+
+ protected String configurationPath = null;
+ protected ConfigurationFileResolver configurationResolver = null;
+ protected ConfigurationParser parser = null;
+
+ public MessagingConfiguration getMessagingConfiguration(ServletConfig servletConfig)
+ {
+ MessagingConfiguration config = new MessagingConfiguration();
+
+ if (servletConfig != null)
+ {
+ String serverInfo = servletConfig.getServletContext().getServerInfo();
+ config.getSecuritySettings().setServerInfo(serverInfo);
+ }
+
+ verifyMinimumJavaVersion();
+
+ parser = getConfigurationParser(servletConfig);
+
+ if (parser == null)
+ {
+ // "Unable to create a parser to load messaging configuration."
+ LocalizedException lme = new LocalizedException();
+ lme.setMessage(10138);
+ throw lme;
+ }
+
+ setupConfigurationPathAndResolver(servletConfig);
+ parser.parse(configurationPath, configurationResolver, config);
+
+ if (servletConfig != null)
+ {
+ config.getSystemSettings().setPaths(servletConfig.getServletContext());
+ }
+
+ return config;
+ }
+
+ public void reportTokens()
+ {
+ parser.reportTokens();
+ }
+
+ protected ConfigurationParser getConfigurationParser(ServletConfig servletConfig)
+ {
+ ConfigurationParser parser = null;
+ Class parserClass = null;
+ String className = null;
+
+ // Check for Custom Parser Specification
+ if (servletConfig != null)
+ {
+ String p = servletConfig.getInitParameter("services.configuration.parser");
+ if (p != null)
+ {
+ className = p.trim();
+ try
+ {
+ parserClass = ClassUtil.createClass(className);
+ parser = (ConfigurationParser)parserClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ if (Trace.config)
+ {
+ Trace.trace("Could not load configuration parser as: " + className);
+ }
+ }
+ }
+ }
+
+ // Always try Sun JRE 1.4 / Apache Xalan Based Implementation first to
+ // avoid performance problems with Sun JRE 1.5 Based Implementation
+ if (parser == null)
+ {
+ try
+ {
+ ClassUtil.createClass("org.apache.xpath.CachedXPathAPI");
+ className = "flex.messaging.config.ApacheXPathServerConfigurationParser";
+ parserClass = ClassUtil.createClass(className);
+ parser = (ConfigurationParser)parserClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ if (Trace.config)
+ {
+ Trace.trace("Could not load configuration parser as: " + className);
+ }
+ }
+ }
+
+ // Try Sun JRE 1.5 Based Implementation
+ if (parser == null)
+ {
+ try
+ {
+ className = "flex.messaging.config.XPathServerConfigurationParser";
+ parserClass = ClassUtil.createClass(className);
+ // double-check, on some systems the above loads but the import classes don't
+ ClassUtil.createClass("javax.xml.xpath.XPathExpressionException");
+
+ parser = (ConfigurationParser)parserClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ if (Trace.config)
+ {
+ Trace.trace("Could not load configuration parser as: " + className);
+ }
+ }
+ }
+
+ if (Trace.config && parser != null)
+ {
+ Trace.trace("Services Configuration Parser: " + parser.getClass().getName());
+ }
+
+ return parser;
+ }
+
+ /**
+ * Sets up the configuration path and resolver objects.
+ * If no entry is specified in web.xml, assumed services-config.xml in the web application.
+ * If an entry is specified for windows starting with '/', it's assumed to be in the web application.
+ * If an entry is specified for windows not starting with '\', it's assumed to be on the local file system.
+ * If an entry is specified for non-windows starting with '/', we will first look in the web application
+ * then the the local file system.
+ *
+ * @param servletConfig configuration
+ */
+ protected void setupConfigurationPathAndResolver(ServletConfig servletConfig)
+ {
+ if (servletConfig != null)
+ {
+ String p = servletConfig.getInitParameter("services.configuration.file");
+ if ((p == null) || (p.trim().length() == 0))
+ {
+ // no entry specified in web.xml, always use default and ServletResourceResolver
+ configurationPath = DEFAULT_CONFIG_PATH;
+ configurationResolver = new ServletResourceResolver(servletConfig.getServletContext());
+ }
+ else
+ {
+ // an entry was specified in web.xml,
+ configurationPath = p.trim();
+
+ // If the uri starts with "classpath:" we need to use a different resolver.
+ if(configurationPath.startsWith("classpath:")) {
+ configurationResolver = new ClasspathResourceResolver();
+ } else {
+ // on windows, all paths starting with '/' should be available via the servlet resource resolver
+ // on other systems, you're not sure so try the servlet resource loader first it but don't throw an error,
+ // after that try using LocalFileResolver
+ boolean isWindows = File.separator.equals("\\");
+ boolean isServletResource = isWindows && configurationPath.startsWith("/");
+ if (isServletResource || !isWindows) {
+ ServletResourceResolver resolver = new ServletResourceResolver(servletConfig.getServletContext());
+ boolean available = resolver.isAvailable(configurationPath, isServletResource);
+ if (available) {
+ // it's available via the servlet resource loader
+ configurationResolver = (ConfigurationFileResolver) resolver;
+ } else {
+ // it wasn't available via the servlet resource loader
+ configurationResolver = new LocalFileResolver(LocalFileResolver.SERVER);
+ }
+ } else {
+ // it's windows but seems to be specified as a file
+ configurationResolver = new LocalFileResolver(LocalFileResolver.SERVER);
+ }
+ }
+ }
+ }
+
+ // no entry specified in web.xml
+ else
+ {
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage("missing ServletConfig object");
+ throw ce;
+ }
+
+
+ }
+
+ protected void verifyMinimumJavaVersion() throws ConfigurationException
+ {
+ try
+ {
+ boolean minimum = false;
+ String version = System.getProperty("java.version");
+ String vendor = System.getProperty("java.vendor");
+
+ version = version.replace('.', ':');
+ version = version.replace('_', ':');
+ String[] split = version.split(":");
+
+ int first = Integer.parseInt(split[0]);
+ if (first > 1)
+ {
+ minimum = true;
+ }
+ else if (first == 1)
+ {
+ int second = Integer.parseInt(split[1]);
+ if (second > 4)
+ {
+ minimum = true;
+ }
+ else if (second == 4)
+ {
+ int third = Integer.parseInt(split[2]);
+ if (third > 2)
+ {
+ minimum = true;
+ }
+ else if (third == 2)
+ {
+ if ((vendor != null) && (vendor.indexOf("Sun") != -1))
+ {
+ // test at least 1.4.2_06 on Sun
+ int fourth = Integer.parseInt(split[3]);
+ if (fourth >= 6)
+ {
+ minimum = true;
+ }
+ }
+ else
+ {
+ // test at least 1.4.2 on non-Sun
+ minimum = true;
+ }
+ }
+ }
+ }
+
+ if (!minimum)
+ {
+ ConfigurationException cx = new ConfigurationException();
+
+ if ((vendor != null) && (vendor.indexOf("Sun") != -1))
+ {
+ // The minimum required Java version was not found. Please install JDK 1.4.2_06 or above. Current version is XX.
+ cx.setMessage(10139, new Object[] { System.getProperty("java.version")});
+ }
+ else
+ {
+ // The minimum required Java version was not found. Please install JDK 1.4.2 or above. Current version is XX.
+ cx.setMessage(10140, new Object[] { System.getProperty("java.version")});
+ }
+
+ throw cx;
+ }
+ }
+ catch (Throwable t)
+ {
+ if (t instanceof ConfigurationException)
+ {
+ throw ((ConfigurationException)t);
+ }
+ else
+ {
+ if (Trace.config)
+ {
+ Trace.trace("Could not verified required java version. version=" + System.getProperty("java.version"));
+ }
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/MessageFilterSettings.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/MessageFilterSettings.java b/modules/core/src/flex/messaging/config/MessageFilterSettings.java
old mode 100755
new mode 100644
index b4c2092..c58bc25
--- a/modules/core/src/flex/messaging/config/MessageFilterSettings.java
+++ b/modules/core/src/flex/messaging/config/MessageFilterSettings.java
@@ -1,99 +1,99 @@
-/*
- * 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.config;
-
-/**
- * Settings class for message filters.
- *
- * @exclude
- */
-public class MessageFilterSettings extends PropertiesSettings
-{
- /**
- * Filters belong to one of two types; those that filter messages
- * asynchronously and those that filter messages synchronously.
- */
- public enum FilterType { ASYNC, SYNC };
-
- private String id;
-
- /**
- * Returns the id.
- *
- * @return The id.
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * Sets the id.
- *
- * @param value The id.
- */
- public void setId(String value)
- {
- id = value;
- }
-
- private String className;
-
- /**
- * Returns the class name.
- *
- * @return The class name.
- */
- public String getClassName()
- {
- return className;
- }
-
- /**
- * Sets the class name.
- *
- * @param value The class name.
- */
- public void setClassName(String value)
- {
- className = value;
- }
-
- private FilterType filterType;
-
- /**
- * Returns the filter type.
- * @see FilterType
- *
- * @return The filter type.
- */
- public FilterType getFilterType()
- {
- return filterType;
- }
-
- /**
- * Sets the filter type.
- * @see FilterType
- *
- * @param value The filter type.
- */
- public void setFilterType(FilterType value)
- {
- filterType = value;
- }
-}
+/*
+ * 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.config;
+
+/**
+ * Settings class for message filters.
+ *
+ * @exclude
+ */
+public class MessageFilterSettings extends PropertiesSettings
+{
+ /**
+ * Filters belong to one of two types; those that filter messages
+ * asynchronously and those that filter messages synchronously.
+ */
+ public enum FilterType { ASYNC, SYNC };
+
+ private String id;
+
+ /**
+ * Returns the id.
+ *
+ * @return The id.
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Sets the id.
+ *
+ * @param value The id.
+ */
+ public void setId(String value)
+ {
+ id = value;
+ }
+
+ private String className;
+
+ /**
+ * Returns the class name.
+ *
+ * @return The class name.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Sets the class name.
+ *
+ * @param value The class name.
+ */
+ public void setClassName(String value)
+ {
+ className = value;
+ }
+
+ private FilterType filterType;
+
+ /**
+ * Returns the filter type.
+ * @see FilterType
+ *
+ * @return The filter type.
+ */
+ public FilterType getFilterType()
+ {
+ return filterType;
+ }
+
+ /**
+ * Sets the filter type.
+ * @see FilterType
+ *
+ * @param value The filter type.
+ */
+ public void setFilterType(FilterType value)
+ {
+ filterType = value;
+ }
+}
[21/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/FlexClientAttributeListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/FlexClientAttributeListener.java b/modules/core/src/flex/messaging/client/FlexClientAttributeListener.java
old mode 100755
new mode 100644
index 9481bc2..2d83d0b
--- a/modules/core/src/flex/messaging/client/FlexClientAttributeListener.java
+++ b/modules/core/src/flex/messaging/client/FlexClientAttributeListener.java
@@ -1,47 +1,47 @@
-/*
- * 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;
-
-/**
- * Interface for FlexClient attribute listeners.
- */
-public interface FlexClientAttributeListener
-{
- /**
- * Callback invoked after an attribute is added to the FlexClient.
- *
- * @param event The event containing the associated FlexClient and attribute
- * information.
- */
- void attributeAdded(FlexClientBindingEvent event);
-
- /**
- * Callback invoked after an attribute is removed from the FlexClient.
- *
- * @param event The event containing the associated FlexClient and attribute
- * information.
- */
- void attributeReplaced(FlexClientBindingEvent event);
-
- /**
- * Callback invoked after an attribute has been replaced with a new value.
- *
- * @param event The event containing the associated FlexClient and attribute
- * information.
- */
- void attributeRemoved(FlexClientBindingEvent event);
-}
+/*
+ * 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;
+
+/**
+ * Interface for FlexClient attribute listeners.
+ */
+public interface FlexClientAttributeListener
+{
+ /**
+ * Callback invoked after an attribute is added to the FlexClient.
+ *
+ * @param event The event containing the associated FlexClient and attribute
+ * information.
+ */
+ void attributeAdded(FlexClientBindingEvent event);
+
+ /**
+ * Callback invoked after an attribute is removed from the FlexClient.
+ *
+ * @param event The event containing the associated FlexClient and attribute
+ * information.
+ */
+ void attributeReplaced(FlexClientBindingEvent event);
+
+ /**
+ * Callback invoked after an attribute has been replaced with a new value.
+ *
+ * @param event The event containing the associated FlexClient and attribute
+ * information.
+ */
+ void attributeRemoved(FlexClientBindingEvent event);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/FlexClientBindingEvent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/FlexClientBindingEvent.java b/modules/core/src/flex/messaging/client/FlexClientBindingEvent.java
old mode 100755
new mode 100644
index 236f70a..3fa20de
--- a/modules/core/src/flex/messaging/client/FlexClientBindingEvent.java
+++ b/modules/core/src/flex/messaging/client/FlexClientBindingEvent.java
@@ -1,115 +1,115 @@
-/*
- * 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;
-
-/**
- * Event used to notify FlexClientAttributeListeners of changes to FlexClient
- * attributes.
- */
-public class FlexClientBindingEvent
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an event for an attribute that is bound or unbound from a FlexClient.
- *
- * @param client The FlexClient.
- * @param name The attribute name.
- */
- public FlexClientBindingEvent(FlexClient client, String name)
- {
- this.client = client;
- this.name = name;
- }
-
-
- /**
- * Constructs an event for an attribute that is added to a FlexClient or
- * replaced by a new value.
- *
- * @param client The FlexClient.
- * @param name The attribute name.
- * @param value The attribute value.
- */
- public FlexClientBindingEvent(FlexClient client, String name, Object value)
- {
- this.client = client;
- this.name = name;
- this.value = value;
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * The FlexClient that generated the event.
- */
- private FlexClient client;
-
- /**
- * The name of the attribute associated with the event.
- */
- private String name;
-
- /**
- * The value of the attribute associated with the event.
- */
- private Object value;
-
- //--------------------------------------------------------------------------
- //
- // Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Returns the FlexClient that generated the event.
- *
- * @return The FlexClient that generated the event.
- */
- public FlexClient getClient()
- {
- return client;
- }
-
- /**
- * Returns the name of the attribute associated with the event.
- *
- * @return The name of the attribute associated with the event.
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Returns the value of the attribute associated with the event.
- *
- * @return The value of the attribute associated with the event.
- */
- public Object getValue()
- {
- return value;
- }
-}
+/*
+ * 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;
+
+/**
+ * Event used to notify FlexClientAttributeListeners of changes to FlexClient
+ * attributes.
+ */
+public class FlexClientBindingEvent
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an event for an attribute that is bound or unbound from a FlexClient.
+ *
+ * @param client The FlexClient.
+ * @param name The attribute name.
+ */
+ public FlexClientBindingEvent(FlexClient client, String name)
+ {
+ this.client = client;
+ this.name = name;
+ }
+
+
+ /**
+ * Constructs an event for an attribute that is added to a FlexClient or
+ * replaced by a new value.
+ *
+ * @param client The FlexClient.
+ * @param name The attribute name.
+ * @param value The attribute value.
+ */
+ public FlexClientBindingEvent(FlexClient client, String name, Object value)
+ {
+ this.client = client;
+ this.name = name;
+ this.value = value;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The FlexClient that generated the event.
+ */
+ private FlexClient client;
+
+ /**
+ * The name of the attribute associated with the event.
+ */
+ private String name;
+
+ /**
+ * The value of the attribute associated with the event.
+ */
+ private Object value;
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns the FlexClient that generated the event.
+ *
+ * @return The FlexClient that generated the event.
+ */
+ public FlexClient getClient()
+ {
+ return client;
+ }
+
+ /**
+ * Returns the name of the attribute associated with the event.
+ *
+ * @return The name of the attribute associated with the event.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the value of the attribute associated with the event.
+ *
+ * @return The value of the attribute associated with the event.
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/FlexClientBindingListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/FlexClientBindingListener.java b/modules/core/src/flex/messaging/client/FlexClientBindingListener.java
old mode 100755
new mode 100644
index d1fb36b..50c319f
--- a/modules/core/src/flex/messaging/client/FlexClientBindingListener.java
+++ b/modules/core/src/flex/messaging/client/FlexClientBindingListener.java
@@ -1,39 +1,39 @@
-/*
- * 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;
-
-/**
- * Interface to be notified when the implementing object is bound or unbound from the FlexClient.
- */
-public interface FlexClientBindingListener
-{
- /**
- * Callback invoked when the object is bound to a FlexClient.
- *
- * @param event The event containing the FlexClient and attribute
- * information.
- */
- void valueBound(FlexClientBindingEvent event);
-
- /**
- * Callback invoked when the object is unbound from a FlexClient.
- *
- * @param event The event containing the FlexClient and attribute
- * information.
- */
- void valueUnbound(FlexClientBindingEvent event);
-}
+/*
+ * 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;
+
+/**
+ * Interface to be notified when the implementing object is bound or unbound from the FlexClient.
+ */
+public interface FlexClientBindingListener
+{
+ /**
+ * Callback invoked when the object is bound to a FlexClient.
+ *
+ * @param event The event containing the FlexClient and attribute
+ * information.
+ */
+ void valueBound(FlexClientBindingEvent event);
+
+ /**
+ * Callback invoked when the object is unbound from a FlexClient.
+ *
+ * @param event The event containing the FlexClient and attribute
+ * information.
+ */
+ void valueUnbound(FlexClientBindingEvent event);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/FlexClientListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/FlexClientListener.java b/modules/core/src/flex/messaging/client/FlexClientListener.java
old mode 100755
new mode 100644
index 49dc24a..7c8cd3d
--- a/modules/core/src/flex/messaging/client/FlexClientListener.java
+++ b/modules/core/src/flex/messaging/client/FlexClientListener.java
@@ -1,40 +1,40 @@
-/*
- * 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;
-
-/**
- * Interface to be notified when a FlexClient is created or destroyed. Implementations of this interface
- * may add themselves as created listeners statically via <code>FlexClient.addClientCreatedListener()</code>.
- * To listen for FlexClient destruction, the implementation instance must add itself as a listener to
- * a specific FlexClient instance via the <code>addClientDestroyedListener()</code> method.
- */
-public interface FlexClientListener
-{
- /**
- * Notification that a FlexClient was created.
- *
- * @param client The FlexClient that was created.
- */
- void clientCreated(FlexClient client);
-
- /**
- * Notification that a FlexClient is about to be destroyed.
- *
- * @param client The FlexClient that will be destroyed.
- */
- void clientDestroyed(FlexClient client);
-}
+/*
+ * 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;
+
+/**
+ * Interface to be notified when a FlexClient is created or destroyed. Implementations of this interface
+ * may add themselves as created listeners statically via <code>FlexClient.addClientCreatedListener()</code>.
+ * To listen for FlexClient destruction, the implementation instance must add itself as a listener to
+ * a specific FlexClient instance via the <code>addClientDestroyedListener()</code> method.
+ */
+public interface FlexClientListener
+{
+ /**
+ * Notification that a FlexClient was created.
+ *
+ * @param client The FlexClient that was created.
+ */
+ void clientCreated(FlexClient client);
+
+ /**
+ * Notification that a FlexClient is about to be destroyed.
+ *
+ * @param client The FlexClient that will be destroyed.
+ */
+ void clientDestroyed(FlexClient client);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/FlexClientManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/FlexClientManager.java b/modules/core/src/flex/messaging/client/FlexClientManager.java
old mode 100755
new mode 100644
index d1e7a1e..05c7d2c
--- a/modules/core/src/flex/messaging/client/FlexClientManager.java
+++ b/modules/core/src/flex/messaging/client/FlexClientManager.java
@@ -1,519 +1,519 @@
-/*
- * 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;
-
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ThreadFactory;
-
-import flex.management.ManageableComponent;
-import flex.management.runtime.messaging.client.FlexClientManagerControl;
-import flex.messaging.FlexContext;
-import flex.messaging.MessageBroker;
-import flex.messaging.MessageException;
-import flex.messaging.config.FlexClientSettings;
-import flex.messaging.endpoints.AbstractEndpoint;
-import flex.messaging.endpoints.Endpoint;
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.util.ClassUtil;
-import flex.messaging.util.TimeoutAbstractObject;
-import flex.messaging.util.TimeoutManager;
-
-/**
- * @exclude
- * Manages FlexClient instances for a MessageBroker.
- */
-public class FlexClientManager extends ManageableComponent
-{
- public static final String TYPE = "FlexClientManager";
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- */
- public FlexClientManager()
- {
- this(MessageBroker.getMessageBroker(null));
- }
- /**
- * Constructs a FlexClientManager for the passed MessageBroker.
- *
- * @param broker The MessageBroker that the Flex client manager is associated with.
- */
- public FlexClientManager(MessageBroker broker)
- {
- this(broker.isManaged(), broker);
- }
-
- /**
- * @exclude
- */
- public FlexClientManager(boolean enableManagement, MessageBroker mbroker)
- {
- super(enableManagement);
-
- super.setId(TYPE);
-
- // Ensure that we have a message broker:
- broker = (mbroker != null) ? mbroker : MessageBroker.getMessageBroker(null);
-
- FlexClientSettings flexClientSettings = broker.getFlexClientSettings();
- if (flexClientSettings != null && flexClientSettings.getTimeoutMinutes() != -1)
- {
- // Convert from minutes to millis.
- setFlexClientTimeoutMillis(flexClientSettings.getTimeoutMinutes()*60*1000);
- }
-
- this.setParent(broker);
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * The MessageBroker that owns this manager.
- */
- private final MessageBroker broker;
-
- /**
- * The Mbean controller for this manager.
- */
- private FlexClientManagerControl controller;
-
- /**
- * Table to store FlexClients by id.
- */
- private final Map<String,FlexClient> flexClients = new ConcurrentHashMap<String,FlexClient>();
-
-
- /**
- * Manages time outs for FlexClients.
- * This currently includes timeout of FlexClient instances, timeouts for async
- * long-poll handling, and scheduling delayed flushes of outbound messages.
- */
- private volatile TimeoutManager flexClientTimeoutManager;
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // clientIds
- //----------------------------------
-
- /**
- * Returns a string array of the client IDs.
- *
- * @return A string array of the client IDs.
- */
- public String[] getClientIds()
- {
- String[] ids = new String[flexClients.size()];
- ArrayList<String> idList = new ArrayList<String>(flexClients.keySet());
-
- for (int i = 0; i < flexClients.size(); i++)
- ids[i] = idList.get(i);
-
- return ids;
- }
-
- //----------------------------------
- // flexClientCount
- //----------------------------------
-
- /**
- * Returns the number of FlexClients in use.
- *
- * @return The number of FlexClients in use.
- */
- public int getFlexClientCount()
- {
- return flexClients.size();
- }
-
- //----------------------------------
- // flexClientTimeoutMillis
- //----------------------------------
-
- private volatile long flexClientTimeoutMillis;
-
- /**
- * Returns the idle timeout in milliseconds to apply to new FlexClient instances.
- *
- * @return The idle timeout in milliseconds to apply to new FlexClient instances.
- */
- public long getFlexClientTimeoutMillis()
- {
- return flexClientTimeoutMillis;
- }
-
- /**
- * Sets the idle timeout in milliseconds to apply to new FlexClient instances.
- *
- * @param value The idle timeout in milliseconds to apply to new FlexClient instances.
- */
- public void setFlexClientTimeoutMillis(long value)
- {
- if (value < 1)
- value = 0;
-
- synchronized (this)
- {
- flexClientTimeoutMillis = value;
- }
- }
-
- //----------------------------------
- // messageBroker
- //----------------------------------
-
- /**
- * Returns the MessageBroker instance that owns this FlexClientManager.
- *
- * @return The parent MessageBroker instance.
- */
- public MessageBroker getMessageBroker()
- {
- return broker;
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Get FlexClient with the specified id or a new one will be created.
- * This method will return a valid existing FlexClient for the specific Id,
- * or a new FlexClient will created
- * @param id The id of the Flex client.
- * @return FlexClient the FlexClient with the specified id
- */
- public FlexClient getFlexClient(String id)
- {
- return getFlexClient(id, true);
- }
-
- /**
- * Get the FlexClient with the specified id.
- *
- * @param id The id of the Flex client.
- * @param createNewIfNotExist if true, a new FlexClient will be created if not exist
- * @return FlexClient the FlexClient with the specified id
- */
- public FlexClient getFlexClient(String id, boolean createNewIfNotExist)
- {
- FlexClient flexClient = null;
- // Try to lookup an existing instance if we receive an id.
- if (id != null)
- {
- flexClient = flexClients.get(id);
- if (flexClient != null)
- {
- if (flexClient.isValid() && !flexClient.invalidating)
- {
- flexClient.updateLastUse();
- return flexClient;
- }
- // Invalid, remove it - it will be replaced below.
- flexClients.remove(id);
- }
- }
- // Use a manager-level lock (this) when creating/recreating a new FlexClient.
- synchronized (this)
- {
- if (id != null)
- {
- flexClient = flexClients.get(id);
- if (flexClient != null)
- {
- flexClient.updateLastUse();
- return flexClient;
- }
- else
- {
- if (!createNewIfNotExist)
- {
- return null;
- }
- }
- }
-
- flexClient = createFlexClient(id);
- checkForNullAndDuplicateId(flexClient.getId());
- flexClients.put(flexClient.getId(), flexClient);
- if (flexClientTimeoutMillis > 0)
- flexClientTimeoutManager.scheduleTimeout(flexClient);
- flexClient.notifyCreated();
- return flexClient;
- }
- }
-
- /**
- * Creates a FlexClientOutboundQueueProcessor instance and hooks it up to the passed
- * FlexClient.
- *
- * @param flexClient The FlexClient to equip with a queue processor.
- * @param endpointId The Id of the endpoint the queue processor is used for.
- * @return The FlexClient with a configured queue processor.
- */
- public FlexClientOutboundQueueProcessor createOutboundQueueProcessor(FlexClient flexClient, String endpointId)
- {
- // First, try to create a custom outbound queue processor, if one exists.
- FlexClientOutboundQueueProcessor processor = createCustomOutboundQueueProcessor(flexClient, endpointId);
-
- // If no custom processor, then try to create default queue processor.
- if (processor == null)
- processor = createDefaultOutboundQueueProcessor(flexClient, endpointId);
-
- // If MessageBroker's default queue processor fails, use the default processor.
- if (processor == null)
- {
- processor = new FlexClientOutboundQueueProcessor();
- processor.setFlexClient(flexClient);
- processor.setEndpointId(endpointId);
- }
-
- return processor;
- }
-
- /**
- * @exclude
- * Monitors an async poll for a FlexClient for timeout.
- *
- * @param asyncPollTimeout The async poll task to monitor for timeout.
- */
- public void monitorAsyncPollTimeout(TimeoutAbstractObject asyncPollTimeout)
- {
- flexClientTimeoutManager.scheduleTimeout(asyncPollTimeout);
- }
-
- /**
- * @exclude
- * Monitors a scheduled flush for a FlexClient for timeout.
- *
- * @param scheduledFlushTimeout The schedule flush task to monitor for timeout.
- */
- public void monitorScheduledFlush(TimeoutAbstractObject scheduledFlushTimeout)
- {
- flexClientTimeoutManager.scheduleTimeout(scheduledFlushTimeout);
- }
-
- /**
- * Starts the Flex client manager.
- *
- * @see flex.management.ManageableComponent#start()
- */
- @Override
- public void start()
- {
- if (isManaged())
- {
- controller = new FlexClientManagerControl(getParent().getControl(), this);
- setControl(controller);
- controller.register();
- }
-
- final String baseId = getId();
- flexClientTimeoutManager = new TimeoutManager(new ThreadFactory()
- {
- int counter = 1;
- public synchronized Thread newThread(Runnable runnable)
- {
- Thread t = new Thread(runnable);
- t.setName(baseId + "-FlexClientTimeoutThread-" + counter++);
- return t;
- }
- });
- }
-
- /**
- * @see flex.management.ManageableComponent#stop()
- */
- public void stop()
- {
- if (controller != null)
- {
- controller.unregister();
- }
-
- if (flexClientTimeoutManager != null)
- flexClientTimeoutManager.shutdown();
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Hook method invoked when a new <tt>FlexClient</tt> instance is created.
- *
- * @param id The id the client provided, which was previously assigned by this server,
- * or another server in a cluster. New clients will pass a <code>null</code>
- * value in which case this server must generate a unique id.
- */
- protected FlexClient createFlexClient(String id)
- {
- return (id == null) ? new FlexClient(this) : new FlexClient(this, id);
- }
-
- /* (non-Javadoc)
- * @see flex.management.ManageableComponent#getLogCategory()
- */
- protected String getLogCategory()
- {
- return LogCategories.CLIENT_FLEXCLIENT;
- }
-
- /**
- * @exclude
- * Removes a FlexClient from being managed by this manager.
- * This method is invoked by FlexClients when they are invalidated.
- *
- * @param flexClient The id of the FlexClient being invalidated.
- */
- protected void removeFlexClient(FlexClient flexClient)
- {
- if (flexClient != null)
- {
- String id = flexClient.getId();
- synchronized (id)
- {
- FlexClient storedClient = flexClients.get(id);
- // If the stored instance is the same as the invalidating instance based upon identity,
- // remove it.
- if (storedClient == flexClient)
- flexClients.remove(id);
- }
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
-
- private void checkForNullAndDuplicateId(String id)
- {
- if (id == null)
- {
- // Cannot create ''{0}'' with null id.
- MessageException me = new MessageException();
- me.setMessage(10039, new Object[]{"FlexClient"});
- me.setCode("Server.Processing.NullId");
- throw me;
- }
-
- if (flexClients.containsKey(id))
- {
- // Cannot create ''{0}'' with id ''{1}''; another ''{0}'' is already registered with the same id.
- MessageException me = new MessageException();
- me.setMessage(10040, new Object[]{"FlexClient", id});
- me.setCode("Server.Processing.DuplicateId");
- throw me;
- }
- }
-
- private FlexClientOutboundQueueProcessor createDefaultOutboundQueueProcessor(
- FlexClient flexClient, String endpointId)
- {
- FlexClientSettings flexClientSettings = broker.getFlexClientSettings();
- if (flexClientSettings == null)
- return null;
-
- String queueProcessorClassName = flexClientSettings.getFlexClientOutboundQueueProcessorClassName();
- if (queueProcessorClassName == null)
- return null;
-
- FlexClientOutboundQueueProcessor processor = null;
- try
- {
- Class queueProcessorClass = createClass(queueProcessorClassName);
- Object instance = ClassUtil.createDefaultInstance(queueProcessorClass, null);
- processor = (FlexClientOutboundQueueProcessor)instance;
- processor.setFlexClient(flexClient);
- processor.setEndpointId(endpointId);
- processor.initialize(flexClientSettings.getFlexClientOutboundQueueProcessorProperties());
- }
- catch (Throwable t)
- {
- String message = "Failed to create MessageBroker's outbound queue processor for FlexClient with id '" + flexClient.getId() + "'.";
- if (Log.isWarn())
- Log.getLogger(FlexClient.FLEX_CLIENT_LOG_CATEGORY).warn(message, t);
-
- MessageException me = new MessageException(message, t);
- throw me;
- }
-
- return processor;
- }
-
- private FlexClientOutboundQueueProcessor createCustomOutboundQueueProcessor(
- FlexClient flexClient, String endpointId)
- {
- FlexClientOutboundQueueProcessor processor = null;
- Endpoint endpoint = broker.getEndpoint(endpointId);
- if (endpoint instanceof AbstractEndpoint)
- {
- Class processorClass = ((AbstractEndpoint)endpoint).getFlexClientOutboundQueueProcessorClass();
- if (processorClass != null)
- {
- try
- {
- Object instance = ClassUtil.createDefaultInstance(processorClass, null);
- if (instance instanceof FlexClientOutboundQueueProcessor)
- {
- processor = (FlexClientOutboundQueueProcessor)instance;
- processor.setFlexClient(flexClient);
- processor.setEndpointId(endpointId);
- processor.initialize(((AbstractEndpoint)endpoint).getFlexClientOutboundQueueProcessorConfig());
- }
- }
- catch (Throwable t)
- {
- if (Log.isWarn())
- Log.getLogger(FlexClient.FLEX_CLIENT_LOG_CATEGORY).warn("Failed to create custom outbound queue processor for FlexClient with id '" + flexClient.getId() + "'. Using MessageBroker's default queue processor.", t);
- }
- }
- }
- return processor;
- }
-
- private Class createClass(String className)
- {
- Class c = ClassUtil.createClass(className, FlexContext.getMessageBroker() == null ? null :
- FlexContext.getMessageBroker().getClassLoader());
-
- return c;
- }
-}
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ThreadFactory;
+
+import flex.management.ManageableComponent;
+import flex.management.runtime.messaging.client.FlexClientManagerControl;
+import flex.messaging.FlexContext;
+import flex.messaging.MessageBroker;
+import flex.messaging.MessageException;
+import flex.messaging.config.FlexClientSettings;
+import flex.messaging.endpoints.AbstractEndpoint;
+import flex.messaging.endpoints.Endpoint;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.util.ClassUtil;
+import flex.messaging.util.TimeoutAbstractObject;
+import flex.messaging.util.TimeoutManager;
+
+/**
+ * @exclude
+ * Manages FlexClient instances for a MessageBroker.
+ */
+public class FlexClientManager extends ManageableComponent
+{
+ public static final String TYPE = "FlexClientManager";
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @exclude
+ */
+ public FlexClientManager()
+ {
+ this(MessageBroker.getMessageBroker(null));
+ }
+ /**
+ * Constructs a FlexClientManager for the passed MessageBroker.
+ *
+ * @param broker The MessageBroker that the Flex client manager is associated with.
+ */
+ public FlexClientManager(MessageBroker broker)
+ {
+ this(broker.isManaged(), broker);
+ }
+
+ /**
+ * @exclude
+ */
+ public FlexClientManager(boolean enableManagement, MessageBroker mbroker)
+ {
+ super(enableManagement);
+
+ super.setId(TYPE);
+
+ // Ensure that we have a message broker:
+ broker = (mbroker != null) ? mbroker : MessageBroker.getMessageBroker(null);
+
+ FlexClientSettings flexClientSettings = broker.getFlexClientSettings();
+ if (flexClientSettings != null && flexClientSettings.getTimeoutMinutes() != -1)
+ {
+ // Convert from minutes to millis.
+ setFlexClientTimeoutMillis(flexClientSettings.getTimeoutMinutes()*60*1000);
+ }
+
+ this.setParent(broker);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The MessageBroker that owns this manager.
+ */
+ private final MessageBroker broker;
+
+ /**
+ * The Mbean controller for this manager.
+ */
+ private FlexClientManagerControl controller;
+
+ /**
+ * Table to store FlexClients by id.
+ */
+ private final Map<String,FlexClient> flexClients = new ConcurrentHashMap<String,FlexClient>();
+
+
+ /**
+ * Manages time outs for FlexClients.
+ * This currently includes timeout of FlexClient instances, timeouts for async
+ * long-poll handling, and scheduling delayed flushes of outbound messages.
+ */
+ private volatile TimeoutManager flexClientTimeoutManager;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // clientIds
+ //----------------------------------
+
+ /**
+ * Returns a string array of the client IDs.
+ *
+ * @return A string array of the client IDs.
+ */
+ public String[] getClientIds()
+ {
+ String[] ids = new String[flexClients.size()];
+ ArrayList<String> idList = new ArrayList<String>(flexClients.keySet());
+
+ for (int i = 0; i < flexClients.size(); i++)
+ ids[i] = idList.get(i);
+
+ return ids;
+ }
+
+ //----------------------------------
+ // flexClientCount
+ //----------------------------------
+
+ /**
+ * Returns the number of FlexClients in use.
+ *
+ * @return The number of FlexClients in use.
+ */
+ public int getFlexClientCount()
+ {
+ return flexClients.size();
+ }
+
+ //----------------------------------
+ // flexClientTimeoutMillis
+ //----------------------------------
+
+ private volatile long flexClientTimeoutMillis;
+
+ /**
+ * Returns the idle timeout in milliseconds to apply to new FlexClient instances.
+ *
+ * @return The idle timeout in milliseconds to apply to new FlexClient instances.
+ */
+ public long getFlexClientTimeoutMillis()
+ {
+ return flexClientTimeoutMillis;
+ }
+
+ /**
+ * Sets the idle timeout in milliseconds to apply to new FlexClient instances.
+ *
+ * @param value The idle timeout in milliseconds to apply to new FlexClient instances.
+ */
+ public void setFlexClientTimeoutMillis(long value)
+ {
+ if (value < 1)
+ value = 0;
+
+ synchronized (this)
+ {
+ flexClientTimeoutMillis = value;
+ }
+ }
+
+ //----------------------------------
+ // messageBroker
+ //----------------------------------
+
+ /**
+ * Returns the MessageBroker instance that owns this FlexClientManager.
+ *
+ * @return The parent MessageBroker instance.
+ */
+ public MessageBroker getMessageBroker()
+ {
+ return broker;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Get FlexClient with the specified id or a new one will be created.
+ * This method will return a valid existing FlexClient for the specific Id,
+ * or a new FlexClient will created
+ * @param id The id of the Flex client.
+ * @return FlexClient the FlexClient with the specified id
+ */
+ public FlexClient getFlexClient(String id)
+ {
+ return getFlexClient(id, true);
+ }
+
+ /**
+ * Get the FlexClient with the specified id.
+ *
+ * @param id The id of the Flex client.
+ * @param createNewIfNotExist if true, a new FlexClient will be created if not exist
+ * @return FlexClient the FlexClient with the specified id
+ */
+ public FlexClient getFlexClient(String id, boolean createNewIfNotExist)
+ {
+ FlexClient flexClient = null;
+ // Try to lookup an existing instance if we receive an id.
+ if (id != null)
+ {
+ flexClient = flexClients.get(id);
+ if (flexClient != null)
+ {
+ if (flexClient.isValid() && !flexClient.invalidating)
+ {
+ flexClient.updateLastUse();
+ return flexClient;
+ }
+ // Invalid, remove it - it will be replaced below.
+ flexClients.remove(id);
+ }
+ }
+ // Use a manager-level lock (this) when creating/recreating a new FlexClient.
+ synchronized (this)
+ {
+ if (id != null)
+ {
+ flexClient = flexClients.get(id);
+ if (flexClient != null)
+ {
+ flexClient.updateLastUse();
+ return flexClient;
+ }
+ else
+ {
+ if (!createNewIfNotExist)
+ {
+ return null;
+ }
+ }
+ }
+
+ flexClient = createFlexClient(id);
+ checkForNullAndDuplicateId(flexClient.getId());
+ flexClients.put(flexClient.getId(), flexClient);
+ if (flexClientTimeoutMillis > 0)
+ flexClientTimeoutManager.scheduleTimeout(flexClient);
+ flexClient.notifyCreated();
+ return flexClient;
+ }
+ }
+
+ /**
+ * Creates a FlexClientOutboundQueueProcessor instance and hooks it up to the passed
+ * FlexClient.
+ *
+ * @param flexClient The FlexClient to equip with a queue processor.
+ * @param endpointId The Id of the endpoint the queue processor is used for.
+ * @return The FlexClient with a configured queue processor.
+ */
+ public FlexClientOutboundQueueProcessor createOutboundQueueProcessor(FlexClient flexClient, String endpointId)
+ {
+ // First, try to create a custom outbound queue processor, if one exists.
+ FlexClientOutboundQueueProcessor processor = createCustomOutboundQueueProcessor(flexClient, endpointId);
+
+ // If no custom processor, then try to create default queue processor.
+ if (processor == null)
+ processor = createDefaultOutboundQueueProcessor(flexClient, endpointId);
+
+ // If MessageBroker's default queue processor fails, use the default processor.
+ if (processor == null)
+ {
+ processor = new FlexClientOutboundQueueProcessor();
+ processor.setFlexClient(flexClient);
+ processor.setEndpointId(endpointId);
+ }
+
+ return processor;
+ }
+
+ /**
+ * @exclude
+ * Monitors an async poll for a FlexClient for timeout.
+ *
+ * @param asyncPollTimeout The async poll task to monitor for timeout.
+ */
+ public void monitorAsyncPollTimeout(TimeoutAbstractObject asyncPollTimeout)
+ {
+ flexClientTimeoutManager.scheduleTimeout(asyncPollTimeout);
+ }
+
+ /**
+ * @exclude
+ * Monitors a scheduled flush for a FlexClient for timeout.
+ *
+ * @param scheduledFlushTimeout The schedule flush task to monitor for timeout.
+ */
+ public void monitorScheduledFlush(TimeoutAbstractObject scheduledFlushTimeout)
+ {
+ flexClientTimeoutManager.scheduleTimeout(scheduledFlushTimeout);
+ }
+
+ /**
+ * Starts the Flex client manager.
+ *
+ * @see flex.management.ManageableComponent#start()
+ */
+ @Override
+ public void start()
+ {
+ if (isManaged())
+ {
+ controller = new FlexClientManagerControl(getParent().getControl(), this);
+ setControl(controller);
+ controller.register();
+ }
+
+ final String baseId = getId();
+ flexClientTimeoutManager = new TimeoutManager(new ThreadFactory()
+ {
+ int counter = 1;
+ public synchronized Thread newThread(Runnable runnable)
+ {
+ Thread t = new Thread(runnable);
+ t.setName(baseId + "-FlexClientTimeoutThread-" + counter++);
+ return t;
+ }
+ });
+ }
+
+ /**
+ * @see flex.management.ManageableComponent#stop()
+ */
+ public void stop()
+ {
+ if (controller != null)
+ {
+ controller.unregister();
+ }
+
+ if (flexClientTimeoutManager != null)
+ flexClientTimeoutManager.shutdown();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Hook method invoked when a new <tt>FlexClient</tt> instance is created.
+ *
+ * @param id The id the client provided, which was previously assigned by this server,
+ * or another server in a cluster. New clients will pass a <code>null</code>
+ * value in which case this server must generate a unique id.
+ */
+ protected FlexClient createFlexClient(String id)
+ {
+ return (id == null) ? new FlexClient(this) : new FlexClient(this, id);
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.ManageableComponent#getLogCategory()
+ */
+ protected String getLogCategory()
+ {
+ return LogCategories.CLIENT_FLEXCLIENT;
+ }
+
+ /**
+ * @exclude
+ * Removes a FlexClient from being managed by this manager.
+ * This method is invoked by FlexClients when they are invalidated.
+ *
+ * @param flexClient The id of the FlexClient being invalidated.
+ */
+ protected void removeFlexClient(FlexClient flexClient)
+ {
+ if (flexClient != null)
+ {
+ String id = flexClient.getId();
+ synchronized (id)
+ {
+ FlexClient storedClient = flexClients.get(id);
+ // If the stored instance is the same as the invalidating instance based upon identity,
+ // remove it.
+ if (storedClient == flexClient)
+ flexClients.remove(id);
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Methods
+ //
+ //--------------------------------------------------------------------------
+
+ private void checkForNullAndDuplicateId(String id)
+ {
+ if (id == null)
+ {
+ // Cannot create ''{0}'' with null id.
+ MessageException me = new MessageException();
+ me.setMessage(10039, new Object[]{"FlexClient"});
+ me.setCode("Server.Processing.NullId");
+ throw me;
+ }
+
+ if (flexClients.containsKey(id))
+ {
+ // Cannot create ''{0}'' with id ''{1}''; another ''{0}'' is already registered with the same id.
+ MessageException me = new MessageException();
+ me.setMessage(10040, new Object[]{"FlexClient", id});
+ me.setCode("Server.Processing.DuplicateId");
+ throw me;
+ }
+ }
+
+ private FlexClientOutboundQueueProcessor createDefaultOutboundQueueProcessor(
+ FlexClient flexClient, String endpointId)
+ {
+ FlexClientSettings flexClientSettings = broker.getFlexClientSettings();
+ if (flexClientSettings == null)
+ return null;
+
+ String queueProcessorClassName = flexClientSettings.getFlexClientOutboundQueueProcessorClassName();
+ if (queueProcessorClassName == null)
+ return null;
+
+ FlexClientOutboundQueueProcessor processor = null;
+ try
+ {
+ Class queueProcessorClass = createClass(queueProcessorClassName);
+ Object instance = ClassUtil.createDefaultInstance(queueProcessorClass, null);
+ processor = (FlexClientOutboundQueueProcessor)instance;
+ processor.setFlexClient(flexClient);
+ processor.setEndpointId(endpointId);
+ processor.initialize(flexClientSettings.getFlexClientOutboundQueueProcessorProperties());
+ }
+ catch (Throwable t)
+ {
+ String message = "Failed to create MessageBroker's outbound queue processor for FlexClient with id '" + flexClient.getId() + "'.";
+ if (Log.isWarn())
+ Log.getLogger(FlexClient.FLEX_CLIENT_LOG_CATEGORY).warn(message, t);
+
+ MessageException me = new MessageException(message, t);
+ throw me;
+ }
+
+ return processor;
+ }
+
+ private FlexClientOutboundQueueProcessor createCustomOutboundQueueProcessor(
+ FlexClient flexClient, String endpointId)
+ {
+ FlexClientOutboundQueueProcessor processor = null;
+ Endpoint endpoint = broker.getEndpoint(endpointId);
+ if (endpoint instanceof AbstractEndpoint)
+ {
+ Class processorClass = ((AbstractEndpoint)endpoint).getFlexClientOutboundQueueProcessorClass();
+ if (processorClass != null)
+ {
+ try
+ {
+ Object instance = ClassUtil.createDefaultInstance(processorClass, null);
+ if (instance instanceof FlexClientOutboundQueueProcessor)
+ {
+ processor = (FlexClientOutboundQueueProcessor)instance;
+ processor.setFlexClient(flexClient);
+ processor.setEndpointId(endpointId);
+ processor.initialize(((AbstractEndpoint)endpoint).getFlexClientOutboundQueueProcessorConfig());
+ }
+ }
+ catch (Throwable t)
+ {
+ if (Log.isWarn())
+ Log.getLogger(FlexClient.FLEX_CLIENT_LOG_CATEGORY).warn("Failed to create custom outbound queue processor for FlexClient with id '" + flexClient.getId() + "'. Using MessageBroker's default queue processor.", t);
+ }
+ }
+ }
+ return processor;
+ }
+
+ private Class createClass(String className)
+ {
+ Class c = ClassUtil.createClass(className, FlexContext.getMessageBroker() == null ? null :
+ FlexContext.getMessageBroker().getClassLoader());
+
+ return c;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/FlexClientNotSubscribedException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/FlexClientNotSubscribedException.java b/modules/core/src/flex/messaging/client/FlexClientNotSubscribedException.java
old mode 100755
new mode 100644
index 629405d..54d7a33
--- a/modules/core/src/flex/messaging/client/FlexClientNotSubscribedException.java
+++ b/modules/core/src/flex/messaging/client/FlexClientNotSubscribedException.java
@@ -1,73 +1,73 @@
-/*
- * 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;
-
-import flex.messaging.MessageException;
-import flex.messaging.log.LogEvent;
-
-/**
- * @exclude
- */
-public class FlexClientNotSubscribedException extends MessageException
-{
- /**
- * @exclude
- */
- private static final long serialVersionUID = 773524927178340950L;
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // defaultLogMessageIntro
- //----------------------------------
-
- /**
- * Overrides the intro text for the log message.
- */
- public String getDefaultLogMessageIntro()
- {
- return "FlexClient not subscribed: ";
- }
-
- //----------------------------------
- // logStackTraceEnabled
- //----------------------------------
-
- /**
- * Override to disable stack trace logging.
- */
- public boolean isLogStackTraceEnabled()
- {
- return false;
- }
-
- //----------------------------------
- // peferredLogLevel
- //----------------------------------
-
- /**
- * Override to lower the preferred log level to debug.
- */
- public short getPreferredLogLevel()
- {
- return LogEvent.DEBUG;
- }
-}
+/*
+ * 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;
+
+import flex.messaging.MessageException;
+import flex.messaging.log.LogEvent;
+
+/**
+ * @exclude
+ */
+public class FlexClientNotSubscribedException extends MessageException
+{
+ /**
+ * @exclude
+ */
+ private static final long serialVersionUID = 773524927178340950L;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // defaultLogMessageIntro
+ //----------------------------------
+
+ /**
+ * Overrides the intro text for the log message.
+ */
+ public String getDefaultLogMessageIntro()
+ {
+ return "FlexClient not subscribed: ";
+ }
+
+ //----------------------------------
+ // logStackTraceEnabled
+ //----------------------------------
+
+ /**
+ * Override to disable stack trace logging.
+ */
+ public boolean isLogStackTraceEnabled()
+ {
+ return false;
+ }
+
+ //----------------------------------
+ // peferredLogLevel
+ //----------------------------------
+
+ /**
+ * Override to lower the preferred log level to debug.
+ */
+ public short getPreferredLogLevel()
+ {
+ return LogEvent.DEBUG;
+ }
+}
[38/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/jmx/MBeanOperationInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/jmx/MBeanOperationInfo.java b/modules/core/src/flex/management/jmx/MBeanOperationInfo.java
old mode 100755
new mode 100644
index a514ba5..7cd7ecd
--- a/modules/core/src/flex/management/jmx/MBeanOperationInfo.java
+++ b/modules/core/src/flex/management/jmx/MBeanOperationInfo.java
@@ -1,119 +1,119 @@
-/*
- * 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.management.jmx;
-
-/**
- * Remotable MBeanOperationInfo class that complies with Flash serialization requirements.
- *
- * @author shodgson
- */
-public class MBeanOperationInfo
-{
- /**
- * The operation name.
- */
- public String name;
-
- /**
- * The operation description.
- */
- public String description;
-
- /**
- * The operation's argument signature.
- */
- public MBeanParameterInfo[] signature;
-
- /**
- * The operation's return type.
- */
- public String returnType;
-
- /**
- * The impact of the operation; one of <code>INFO, ACTION, ACTION_INFO, UNKNOWN</code>.
- */
- public int impact;
-
- /**
- * Constructs an empty <code>MBeanOperationInfo</code> instance.
- */
- public MBeanOperationInfo()
- {}
-
- /**
- * Constructs a <code>MBeanOperationInfo</code> instance based upon a
- * <code>javax.management.MBeanOperationInfo</code> instance.
- *
- * @param mbeanOperationInfo The JMX <code>MBeanOperationInfo</code> instance to base this instance on.
- */
- public MBeanOperationInfo(javax.management.MBeanOperationInfo mbeanOperationInfo)
- {
- name = mbeanOperationInfo.getName();
- description = mbeanOperationInfo.getDescription();
- signature = convertSignature(mbeanOperationInfo.getSignature());
- returnType = mbeanOperationInfo.getReturnType();
- impact = mbeanOperationInfo.getImpact();
- }
-
- /**
- * Utility method to convert this <code>MBeanOperationInfo</code> to a
- * <code>javax.management.MBeanOperationInfo</code> instance.
- *
- * @return A JMX <code>MBeanOperationInfo</code> based upon this instance.
- */
- public javax.management.MBeanOperationInfo toMBeanOperationInfo()
- {
- return new javax.management.MBeanOperationInfo(name,
- description,
- convertSignature(signature),
- returnType,
- impact);
- }
-
- /**
- * Utility method to convert JMX parameter info instances to Flash friendly parameter info instances.
- *
- * @param source JMX parameter info instances.
- * @return Flash friendly parameter info instances.
- */
- private MBeanParameterInfo[] convertSignature(javax.management.MBeanParameterInfo[] source)
- {
- MBeanParameterInfo[] signature = new MBeanParameterInfo[source.length];
- for (int i = 0; i < source.length; i++)
- {
- signature[i] = new MBeanParameterInfo(source[i]);
- }
- return signature;
- }
-
- /**
- * Utility method to convert Flash friendly parameter info instances to JMX parameter info instances.
- *
- * @param source Flash friendly parameter info instances.
- * @return JMX parameter info instances.
- */
- private javax.management.MBeanParameterInfo[] convertSignature(MBeanParameterInfo[] source)
- {
- javax.management.MBeanParameterInfo[] signature = new javax.management.MBeanParameterInfo[source.length];
- for (int i = 0; i < source.length; i++)
- {
- signature[i] = source[i].toMBeanParameterInfo();
- }
- return signature;
- }
-
-}
+/*
+ * 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.management.jmx;
+
+/**
+ * Remotable MBeanOperationInfo class that complies with Flash serialization requirements.
+ *
+ * @author shodgson
+ */
+public class MBeanOperationInfo
+{
+ /**
+ * The operation name.
+ */
+ public String name;
+
+ /**
+ * The operation description.
+ */
+ public String description;
+
+ /**
+ * The operation's argument signature.
+ */
+ public MBeanParameterInfo[] signature;
+
+ /**
+ * The operation's return type.
+ */
+ public String returnType;
+
+ /**
+ * The impact of the operation; one of <code>INFO, ACTION, ACTION_INFO, UNKNOWN</code>.
+ */
+ public int impact;
+
+ /**
+ * Constructs an empty <code>MBeanOperationInfo</code> instance.
+ */
+ public MBeanOperationInfo()
+ {}
+
+ /**
+ * Constructs a <code>MBeanOperationInfo</code> instance based upon a
+ * <code>javax.management.MBeanOperationInfo</code> instance.
+ *
+ * @param mbeanOperationInfo The JMX <code>MBeanOperationInfo</code> instance to base this instance on.
+ */
+ public MBeanOperationInfo(javax.management.MBeanOperationInfo mbeanOperationInfo)
+ {
+ name = mbeanOperationInfo.getName();
+ description = mbeanOperationInfo.getDescription();
+ signature = convertSignature(mbeanOperationInfo.getSignature());
+ returnType = mbeanOperationInfo.getReturnType();
+ impact = mbeanOperationInfo.getImpact();
+ }
+
+ /**
+ * Utility method to convert this <code>MBeanOperationInfo</code> to a
+ * <code>javax.management.MBeanOperationInfo</code> instance.
+ *
+ * @return A JMX <code>MBeanOperationInfo</code> based upon this instance.
+ */
+ public javax.management.MBeanOperationInfo toMBeanOperationInfo()
+ {
+ return new javax.management.MBeanOperationInfo(name,
+ description,
+ convertSignature(signature),
+ returnType,
+ impact);
+ }
+
+ /**
+ * Utility method to convert JMX parameter info instances to Flash friendly parameter info instances.
+ *
+ * @param source JMX parameter info instances.
+ * @return Flash friendly parameter info instances.
+ */
+ private MBeanParameterInfo[] convertSignature(javax.management.MBeanParameterInfo[] source)
+ {
+ MBeanParameterInfo[] signature = new MBeanParameterInfo[source.length];
+ for (int i = 0; i < source.length; i++)
+ {
+ signature[i] = new MBeanParameterInfo(source[i]);
+ }
+ return signature;
+ }
+
+ /**
+ * Utility method to convert Flash friendly parameter info instances to JMX parameter info instances.
+ *
+ * @param source Flash friendly parameter info instances.
+ * @return JMX parameter info instances.
+ */
+ private javax.management.MBeanParameterInfo[] convertSignature(MBeanParameterInfo[] source)
+ {
+ javax.management.MBeanParameterInfo[] signature = new javax.management.MBeanParameterInfo[source.length];
+ for (int i = 0; i < source.length; i++)
+ {
+ signature[i] = source[i].toMBeanParameterInfo();
+ }
+ return signature;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/jmx/MBeanParameterInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/jmx/MBeanParameterInfo.java b/modules/core/src/flex/management/jmx/MBeanParameterInfo.java
old mode 100755
new mode 100644
index d56b941..96db81a
--- a/modules/core/src/flex/management/jmx/MBeanParameterInfo.java
+++ b/modules/core/src/flex/management/jmx/MBeanParameterInfo.java
@@ -1,73 +1,73 @@
-/*
- * 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.management.jmx;
-
-/**
- * Remotable MBeanParameterInfo class that complies with Flash serialization requirements.
- *
- * @author shodgson
- */
-public class MBeanParameterInfo
-{
- /**
- * The name of the parameter.
- */
- public String name;
-
- /**
- * The Java type for the parameter.
- */
- public String type;
-
- /**
- * The description for the parameter.
- */
- public String description;
-
- /**
- * Constructs an empty <code>MBeanParameterInfo</code> instance.
- */
- public MBeanParameterInfo()
- {}
-
- /**
- * Constructs a <code>MBeanParameterInfo</code> instance based upon a
- * <code>javax.management.MBeanParameterInfo</code> instance.
- *
- * @param mbeanParameterInfo The JMX <code>MBeanParameterInfo</code> instance to base this instance on.
- */
- public MBeanParameterInfo(javax.management.MBeanParameterInfo mbeanParameterInfo)
- {
- name = mbeanParameterInfo.getName();
- type = mbeanParameterInfo.getType();
- description = mbeanParameterInfo.getDescription();
- }
-
- /**
- * Utility method to convert this <code>MBeanParameterInfo</code> to a
- * <code>javax.management.MBeanParameterInfo</code> instance.
- *
- * @return A JMX <code>MBeanParameterInfo</code> based upon this instance.
- */
- public javax.management.MBeanParameterInfo toMBeanParameterInfo()
- {
- return new javax.management.MBeanParameterInfo(name,
- type,
- description);
- }
-
-}
+/*
+ * 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.management.jmx;
+
+/**
+ * Remotable MBeanParameterInfo class that complies with Flash serialization requirements.
+ *
+ * @author shodgson
+ */
+public class MBeanParameterInfo
+{
+ /**
+ * The name of the parameter.
+ */
+ public String name;
+
+ /**
+ * The Java type for the parameter.
+ */
+ public String type;
+
+ /**
+ * The description for the parameter.
+ */
+ public String description;
+
+ /**
+ * Constructs an empty <code>MBeanParameterInfo</code> instance.
+ */
+ public MBeanParameterInfo()
+ {}
+
+ /**
+ * Constructs a <code>MBeanParameterInfo</code> instance based upon a
+ * <code>javax.management.MBeanParameterInfo</code> instance.
+ *
+ * @param mbeanParameterInfo The JMX <code>MBeanParameterInfo</code> instance to base this instance on.
+ */
+ public MBeanParameterInfo(javax.management.MBeanParameterInfo mbeanParameterInfo)
+ {
+ name = mbeanParameterInfo.getName();
+ type = mbeanParameterInfo.getType();
+ description = mbeanParameterInfo.getDescription();
+ }
+
+ /**
+ * Utility method to convert this <code>MBeanParameterInfo</code> to a
+ * <code>javax.management.MBeanParameterInfo</code> instance.
+ *
+ * @return A JMX <code>MBeanParameterInfo</code> based upon this instance.
+ */
+ public javax.management.MBeanParameterInfo toMBeanParameterInfo()
+ {
+ return new javax.management.MBeanParameterInfo(name,
+ type,
+ description);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/jmx/MBeanServerGateway.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/jmx/MBeanServerGateway.java b/modules/core/src/flex/management/jmx/MBeanServerGateway.java
old mode 100755
new mode 100644
index f522dec..9747748
--- a/modules/core/src/flex/management/jmx/MBeanServerGateway.java
+++ b/modules/core/src/flex/management/jmx/MBeanServerGateway.java
@@ -1,909 +1,909 @@
-/*
- * 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.management.jmx;
-
-import flex.management.BaseControl;
-import flex.management.MBeanServerLocatorFactory;
-import flex.management.ManagementException;
-
-import java.util.Iterator;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.MalformedObjectNameException;
-import javax.management.MBeanException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-
-/**
- * Remoting gateway to the MBean server that hosts Flex MBeans.
- * <p>
- * Some base javax.management.MBeanServer methods are unimplemented due to the
- * fact that we're interacting with the MBean server from remote Flash clients.
- * Some methods have been modified to better suite remote Flash clients. Other
- * methods are additive, serving as a convenience for Flex applications.
- * </p><p>
- * Unimplemented methods from the base MBeanServer API:
- * <ul>
- * <li>getDomains() - JMX 1.2</li>
- * <li>addNotificationListener()/removeNotificationListener() - Flash objects
- * cannot listen directly for MBean notifications.</li>
- * <li>instantiate() - returns a reference to a Java object that is not useful
- * to a remote Flash client.</li>
- * <li>deserialize() - deprecated.</li>
- * <li>getClassLoaderFor() - meaningless to a Flash client.</li>
- * <li>getClassLoader() - meaningless to a Flash client.</li>
- * <li>getClassLoaderRepository() - meaningless to a Flash client.</li>
- * </ul>
- * </p><p>
- * Modifications to the base MBeanServer API:
- * <ul>
- * <li>* All ObjectName arguments are typed as String because serialization in either
- * direction doesn't support ObjectNames that are patterns. This does not effect
- * ObjectNames that are not patterns that are returned to the client.</li>
- * <li>queryMBeans() - returns an Array of ObjectInstances rather than a java.util.Set
- * and does not currently support the QueryExp argument.</li>
- * <li>queryNames() returns an Array of ObjectNames rather than a java.util.Set
- * and does not currently support the QueryExp argument.</li>
- * <li>getAttributes() returns an Array of Attributes rather than an AttributeList.</li>
- * <li>setAttributes() accepts and returns Arrays of Attributes rather than AttributeLists.</li>
- * </ul>
- * </p><p>
- * Additonal Flex-specific methods:
- * <ul>
- * <li>getFlexMBeanCount()</li>
- * <li>getFlexDomains()</li>
- * <li>getFlexMBeanObjectNames()</li>
- * </ul>
- * </p>
- *
- * @author shodgson
- */
-public class MBeanServerGateway
-{
- // Error string constants.
- private static final int MALFORMED_OBJECTNAME = 10400;
- private static final int GETINFO_INTROSPECTION_ERR = 10406;
- private static final int MBEAN_NOTFOUND = 10407;
- private static final int GETINFO_REFLECT_ERR = 10408;
- private static final int ATTRIB_NOTFOUND = 10409;
- private static final int GETATTRIB_EXCEPTION = 10410;
- private static final int GETATTRIB_REFLECT_ERR = 10411;
- private static final int GETATTRIB_NULL_ARGUMENT = 10412;
- private static final int GETATTRIBS_REFLECT_ERR = 10413;
- private static final int GETATTRIBS_NULL_ARGUMENT = 10414;
- private static final int INVOKE_REFLECT_ERR = 10415;
- private static final int INVOKE_ERR = 10416;
- private static final int CREATE_ERR = 10417;
- private static final int INSTANCE_EXISTS = 10418;
- private static final int NOT_COMPLIANT = 10419;
- private static final int MBEAN_PREREG_ERR = 10420;
- private static final int MBEAN_PREDEREG_ERR = 10421;
- private static final int SETATTRIB_REFLECT_ERR = 10422;
- private static final int SETATTRIB_EXCEPTION = 10423;
- private static final int INVALID_ATTRIB_VALUE = 10424;
- private static final int SETATTRIBS_REFLECT_ERR = 10425;
-
- private MBeanServer server;
-
- /**
- * Constructs a new MBeanServerGateway. The gateway exposes the MBean server
- * that Flex MBean are registered with in a remoting-friendly fashion.
- */
- public MBeanServerGateway()
- {
- server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer();
- }
-
- /////////////////////////////////////
- //
- // Core MBeanServer API
- //
- /////////////////////////////////////
-
- /**
- * Instantiates and registers an MBean with the MBean server.
- *
- * @param className The class name for the MBean to instantiate.
- * @param objectName The object name of the MBean.
- * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean.
- */
- public ObjectInstance createMBean(String className, String objectName)
- {
- javax.management.ObjectName name = null;
- if (objectName != null)
- name = validateObjectName(objectName);
- try
- {
- return new ObjectInstance(server.createMBean(className, name));
- }
- catch (ReflectionException re)
- {
- ManagementException me = new ManagementException();
- me.setMessage(CREATE_ERR, new Object[] {name});
- me.setRootCause(re);
- throw me;
- }
- catch (InstanceAlreadyExistsException iaee)
- {
- ManagementException me = new ManagementException();
- me.setMessage(INSTANCE_EXISTS, new Object[] {name});
- me.setRootCause(iaee);
- throw me;
- }
- catch (MBeanException mbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(CREATE_ERR, new Object[] {name});
- me.setRootCause(mbe);
- throw me;
- }
- catch (NotCompliantMBeanException ncmbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(NOT_COMPLIANT, new Object[] {className});
- me.setRootCause(ncmbe);
- throw me;
- }
- }
-
- /**
- * Instantiates and registers an MBean with the MBean server. The class loader
- * to use to load the MBean class is identified by its ObjectName.
- *
- * @param className The class name for the MBean to instantiate.
- * @param objectName The object name of the MBean.
- * @param loaderName The object name of the desired class loader.
- * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean.
- */
- public ObjectInstance createMBean(String className, String objectName, String loaderName)
- {
- javax.management.ObjectName name = null;
- javax.management.ObjectName loader = null;
- if (objectName != null)
- name = validateObjectName(objectName);
- if (loaderName != null)
- loader = validateObjectName(loaderName);
- try
- {
- return new ObjectInstance(server.createMBean(className, name, loader));
- }
- catch (ReflectionException re)
- {
- ManagementException me = new ManagementException();
- me.setMessage(CREATE_ERR, new Object[] {name});
- me.setRootCause(re);
- throw me;
- }
- catch (InstanceAlreadyExistsException iaee)
- {
- ManagementException me = new ManagementException();
- me.setMessage(INSTANCE_EXISTS, new Object[] {name});
- me.setRootCause(iaee);
- throw me;
- }
- catch (MBeanException mbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(CREATE_ERR, new Object[] {name});
- me.setRootCause(mbe);
- throw me;
- }
- catch (NotCompliantMBeanException ncmbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(NOT_COMPLIANT, new Object[] {className});
- me.setRootCause(ncmbe);
- throw me;
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
- me.setRootCause(infe);
- throw me;
- }
- }
-
- /**
- * Instantiates and registers an MBean with the MBean server.
- *
- * @param className The class name for the MBean to instantiate.
- * @param objectName The object name of the MBean.
- * @param params An array of parameters to pass to the MBean constructor.
- * @param signature An array containing the type signature for the constructor to invoke.
- * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean.
- */
- public ObjectInstance createMBean(String className, String objectName, Object[] params, String[] signature)
- {
- javax.management.ObjectName name = null;
- if (objectName != null)
- name = validateObjectName(objectName);
- try
- {
- return new ObjectInstance(server.createMBean(className, name, params, signature));
- }
- catch (ReflectionException re)
- {
- ManagementException me = new ManagementException();
- me.setMessage(CREATE_ERR, new Object[] {name});
- me.setRootCause(re);
- throw me;
- }
- catch (InstanceAlreadyExistsException iaee)
- {
- ManagementException me = new ManagementException();
- me.setMessage(INSTANCE_EXISTS, new Object[] {name});
- me.setRootCause(iaee);
- throw me;
- }
- catch (MBeanException mbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(CREATE_ERR, new Object[] {name});
- me.setRootCause(mbe);
- throw me;
- }
- catch (NotCompliantMBeanException ncmbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(NOT_COMPLIANT, new Object[] {className});
- me.setRootCause(ncmbe);
- throw me;
- }
- }
-
- /**
- * Instantiates and registers an MBean with the MBean server. The class loader
- * to use to load the MBean class is identified by its ObjectName.
- *
- * @param className The class name for the MBean to instantiate.
- * @param objectName The object name of the MBean.
- * @param loaderName The object name of the desired class loader.
- * @param params An array of parameters to pass to the MBean constructor.
- * @param signature An array containing the type signature for the constructor to invoke.
- * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean.
- */
- public ObjectInstance createMBean(String className, String objectName, String loaderName, Object[] params, String[] signature)
- {
- javax.management.ObjectName name = null;
- javax.management.ObjectName loader = null;
- if (objectName != null)
- name = validateObjectName(objectName);
- if (loaderName != null)
- loader = validateObjectName(loaderName);
- try
- {
- return new ObjectInstance(server.createMBean(className, name, loader, params, signature));
- }
- catch (ReflectionException re)
- {
- ManagementException me = new ManagementException();
- me.setMessage(CREATE_ERR, new Object[] {name});
- me.setRootCause(re);
- throw me;
- }
- catch (InstanceAlreadyExistsException iaee)
- {
- ManagementException me = new ManagementException();
- me.setMessage(INSTANCE_EXISTS, new Object[] {name});
- me.setRootCause(iaee);
- throw me;
- }
- catch (MBeanException mbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(CREATE_ERR, new Object[] {name});
- me.setRootCause(mbe);
- throw me;
- }
- catch (NotCompliantMBeanException ncmbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(NOT_COMPLIANT, new Object[] {className});
- me.setRootCause(ncmbe);
- throw me;
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
- me.setRootCause(infe);
- throw me;
- }
- }
-
- /**
- * Registers a pre-existing object as an MBean with the MBean server.
- *
- * @param object The object to register as an MBean.
- * @param objectName The object name for the MBean.
- * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean.
- */
- public ObjectInstance registerMBean(Object object, String objectName)
- {
- javax.management.ObjectName name = null;
- if (objectName != null)
- name = validateObjectName(objectName);
- try
- {
- return new ObjectInstance(server.registerMBean(object, name));
- }
- catch (InstanceAlreadyExistsException iaee)
- {
- ManagementException me = new ManagementException();
- me.setMessage(INSTANCE_EXISTS, new Object[] {name});
- me.setRootCause(iaee);
- throw me;
- }
- catch (NotCompliantMBeanException ncmbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(NOT_COMPLIANT, new Object[] {object.getClass().getName()});
- me.setRootCause(ncmbe);
- throw me;
- }
- catch (MBeanRegistrationException mbre)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_PREREG_ERR, new Object[] {name});
- me.setRootCause(mbre);
- throw me;
- }
- }
-
- /**
- * Unregisters an MBean from the MBean server.
- *
- * @param objectName The object name of the MBean to unregister.
- */
- public void unregisterMBean(String objectName)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- try
- {
- server.unregisterMBean(name);
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
- me.setRootCause(infe);
- throw me;
- }
- catch (MBeanRegistrationException mbre)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_PREDEREG_ERR, new Object[] {name});
- me.setRootCause(mbre);
- throw me;
- }
- }
-
- /**
- * Gets the ObjectInstance for the specified MBean registered with the
- * MBean server.
- *
- * @param objectName The object name of the MBean.
- * @return An ObjectInstance containing the ObjectName and Java class name of the MBean.
- */
- public ObjectInstance getObjectInstance(String objectName)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- try
- {
- return new ObjectInstance(server.getObjectInstance(name));
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
- me.setRootCause(infe);
- throw me;
- }
- }
-
- /**
- * Gets MBeans controlled by the MBean server. This method allows the following to be obtained:
- * All MBeans, or a set of MBeans specified by pattern matching on the ObjectName, or a specific
- * MBean.
- * <p>
- * This method does not support a QueryExp argument for additional filtering of the queried set.
- * </p>
- *
- * @param objectName The object name pattern identifying the MBeans to retrieve.
- * @return A set of ObjectInstances for the selected MBeans.
- */
- public ObjectInstance[] queryMBeans(String objectName)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- Set result = server.queryMBeans(name, null);
- int n = result.size();
- if (n > 0)
- {
- ObjectInstance[] toReturn = new ObjectInstance[n];
- int i = 0;
- for (Iterator iter = result.iterator(); iter.hasNext();)
- {
- toReturn[i++] = new ObjectInstance((javax.management.ObjectInstance)iter.next());
- }
- return toReturn;
- }
- else
- {
- return new ObjectInstance[0];
- }
- }
-
- /**
- * Gets the names of MBeans controlled by the MBean server. This method allows the following to be
- * obtained: The names of all MBeans, the names of the set of MBeans matching the ObjectName pattern,
- * a specific MBean name.
- * <p>
- * This method does not support a QueryExp argument for additional filtering of the queried set.
- * </p>
- *
- * @param objectName The object name pattern identifying the MBean names to retrieve.
- * @return A set of ObjectNames for the selected MBeans.
- */
- public ObjectName[] queryNames(String objectName)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- Set result = server.queryNames(name, null);
- int n = result.size();
- if (n > 0)
- {
- ObjectName[] toReturn = new ObjectName[n];
- int i = 0;
- for (Iterator iter = result.iterator(); iter.hasNext();)
- {
- toReturn[i++] = new ObjectName((javax.management.ObjectName)iter.next());
- }
- return toReturn;
- }
- else
- {
- return new ObjectName[0];
- }
- }
-
- /**
- * Checks whether an MBean, identified by its object name, is already registered with the MBean server.
- *
- * @param objectName The object name of the MBean to be checked.
- * @return True if the MBean is already registered in the MBean server, false otherwise.
- */
- public boolean isRegistered(String objectName)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- return server.isRegistered(name);
- }
-
- /**
- * Returns the total number of beans registered in the MBean server.
- *
- * @return The number of registered MBeans.
- */
- public Integer getMBeanCount()
- {
- return server.getMBeanCount();
- }
-
- /**
- * Gets the value of a specific attribute of a named MBean. The MBean is identified by its object name.
- *
- * @param objectName The object name of the MBean from which the attribute is to be retrieved.
- * @param attribute The name of the attribute to be retrieved.
- * @return The value of the retrieved attribute.
- */
- public Object getAttribute(String objectName, String attribute)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- try
- {
- return server.getAttribute(name, attribute);
- }
- catch (AttributeNotFoundException anfe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(ATTRIB_NOTFOUND, new Object[] {attribute, name});
- me.setRootCause(anfe);
- throw me;
- }
- catch (MBeanException mbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(GETATTRIB_EXCEPTION, new Object[] {attribute, name});
- me.setRootCause(mbe);
- throw me;
- }
- catch (ReflectionException re)
- {
- ManagementException me = new ManagementException();
- me.setMessage(GETATTRIB_REFLECT_ERR, new Object[] {attribute, name});
- me.setRootCause(re);
- throw me;
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
- me.setRootCause(infe);
- throw me;
- }
- catch (RuntimeOperationsException roe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(GETATTRIB_NULL_ARGUMENT);
- me.setRootCause(roe);
- throw me;
- }
- }
-
- /**
- * Gets the values of several attributes of a named MBean.
- *
- * @param objectName The object name of the MBean to get attribute values from.
- * @param attributes The names of the attributes to get values for.
- * @return The attributes, each containing their name and value.
- */
- public Attribute[] getAttributes(String objectName, String[] attributes)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- try
- {
- AttributeList result = server.getAttributes(name, attributes);
- Attribute[] values = new Attribute[result.size()];
- for (int i = 0; i < result.size(); i++)
- {
- values[i] = new Attribute((javax.management.Attribute)result.get(i));
- }
- return values;
- }
- catch (ReflectionException re)
- {
- ManagementException me = new ManagementException();
- me.setMessage(GETATTRIBS_REFLECT_ERR, new Object[] {name});
- me.setRootCause(re);
- throw me;
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
- me.setRootCause(infe);
- throw me;
- }
- catch (RuntimeOperationsException roe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(GETATTRIBS_NULL_ARGUMENT);
- me.setRootCause(roe);
- throw me;
- }
- }
-
- /**
- * Sets the value of the attribute for the specified MBean.
- *
- * @param objectName The name of the MBean.
- * @param attribute The attribute to set.
- */
- public void setAttribute(String objectName, Attribute attribute)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- javax.management.Attribute attrib = validateAttribute(attribute);
- try
- {
- server.setAttribute(name, attrib);
- }
- catch (ReflectionException re)
- {
- ManagementException me = new ManagementException();
- me.setMessage(SETATTRIB_REFLECT_ERR, new Object[] {attrib.getName(), name});
- me.setRootCause(re);
- throw me;
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
- me.setRootCause(infe);
- throw me;
- }
- catch (AttributeNotFoundException anfe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(ATTRIB_NOTFOUND, new Object[] {attrib.getName(), name});
- me.setRootCause(anfe);
- throw me;
- }
- catch (MBeanException mbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(SETATTRIB_EXCEPTION, new Object[] {attrib.getName(), name});
- me.setRootCause(mbe);
- throw me;
- }
- catch (InvalidAttributeValueException iave)
- {
- ManagementException me = new ManagementException();
- me.setMessage(INVALID_ATTRIB_VALUE, new Object[] {attrib.getValue(), attrib.getName(), name});
- me.setRootCause(iave);
- throw me;
- }
- }
-
- /**
- * Sets the values for several attributes of the specified MBean.
- *
- * @param objectName The object name for the MBean.
- * @param attributes The attributes to set.
- * @return The attributes that were set with their new values.
- */
- public Attribute[] setAttributes(String objectName, Attribute[] attributes)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- AttributeList attribList = new AttributeList();
- for (int i = 0; i < attributes.length; i++)
- {
- attribList.add(attributes[i].toAttribute());
- }
- try
- {
- AttributeList result = server.setAttributes(name, attribList);
- Attribute[] values = new Attribute[result.size()];
- for (int i = 0; i < result.size(); i++)
- {
- values[i] = new Attribute((javax.management.Attribute)result.get(i));
- }
- return values;
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
- me.setRootCause(infe);
- throw me;
- }
- catch (ReflectionException re)
- {
- ManagementException me = new ManagementException();
- me.setMessage(SETATTRIBS_REFLECT_ERR, new Object[] {name});
- me.setRootCause(re);
- throw me;
- }
- }
-
- /**
- * Invokes an operation on an MBean.
- *
- * @param objectName The object name of the MBean to invoke the operation on.
- * @param operationName The operation to invoke.
- * @param params The parameters for the operation invocation.
- * @param signature The parameter signature for the operation.
- * @return The object returned by the operation invocation.
- */
- public Object invoke(String objectName, String operationName, Object[] params, String[] signature)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- try
- {
- return server.invoke(name, operationName, params, signature);
- }
- catch (ReflectionException re)
- {
- ManagementException me = new ManagementException();
- me.setMessage(INVOKE_REFLECT_ERR, new Object[] {operationName, objectName});
- me.setRootCause(re);
- throw me;
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {objectName});
- me.setRootCause(infe);
- throw me;
- }
- catch (MBeanException mbe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(INVOKE_ERR, new Object[] {operationName, objectName});
- me.setRootCause(mbe);
- throw me;
- }
- }
-
- /**
- * Returns the default domain used for naming MBeans.
- *
- * @return The default domain.
- */
- public String getDefaultDomain()
- {
- return server.getDefaultDomain();
- }
-
- /**
- * This method discovers the attributes and operations that an MBean exposes for management
- * by a Flash client.
- *
- * @param objectName The name of the MBean to get metadata for.
- * @return An MBeanInfo instance that describes the MBean.
- */
- public flex.management.jmx.MBeanInfo getMBeanInfo(String objectName)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- try
- {
- return new MBeanInfo(server.getMBeanInfo(name));
- }
- catch (IntrospectionException ie)
- {
- ManagementException me = new ManagementException();
- me.setMessage(GETINFO_INTROSPECTION_ERR, new Object[] {objectName});
- me.setRootCause(ie);
- throw me;
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {objectName});
- me.setRootCause(infe);
- throw me;
- }
- catch (ReflectionException re)
- {
- ManagementException me = new ManagementException();
- me.setMessage(GETINFO_REFLECT_ERR, new Object[] {objectName});
- me.setRootCause(re);
- throw me;
- }
- }
-
-
- /**
- * Returns true if the specified MBean is an instance of the specified class; otherwise false.
- *
- * @param objectName The object name of the MBean.
- * @param className The name of the class.
- * @return true if the specified MBean is an instance of the specified class; otherwise false.
- */
- public boolean isInstanceOf(String objectName, String className)
- {
- javax.management.ObjectName name = validateObjectName(objectName);
- try
- {
- return server.isInstanceOf(name, className);
- }
- catch (InstanceNotFoundException infe)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MBEAN_NOTFOUND, new Object[] {objectName});
- me.setRootCause(infe);
- throw me;
- }
- }
-
- ////////////////////////////////
- //
- // Additive Flex-specific API
- //
- ////////////////////////////////
-
- /**
- * Returns all the object names for Flex related MBeans.
- *
- * @return The object names for all Flex related MBeans.
- */
- public ObjectName[] getFlexMBeanObjectNames()
- {
- javax.management.ObjectName pattern = validateObjectName(BaseControl.DOMAIN_PREFIX + "*:*");
- Set result = server.queryNames(pattern, null);
- ObjectName[] names = new ObjectName[result.size()];
- int i = 0;
- for (Iterator iter = result.iterator(); iter.hasNext(); )
- {
- names[i++] = new ObjectName((javax.management.ObjectName)iter.next());
- }
- return names;
- }
-
- /**
- * Returns the number of narrowed Flex MBeans registered in the MBean server.
- *
- * @return The number of narrowed Flex MBeans registered in the MBean server.
- */
- public Integer getFlexMBeanCount()
- {
- return new Integer(getFlexMBeanObjectNames().length);
- }
-
- /**
- * Returns the narrowed list of Flex domains in which any MBean is currently registered.
- * The domains are returned in naturally sorted order.
- *
- * @return The narrowed list of Flex domains in which any MBean is currently registered.
- */
- public String[] getFlexDomains()
- {
- ObjectName[] names = getFlexMBeanObjectNames();
- Set domains = new TreeSet();
- String name;
- String domain;
- if (names.length > 0)
- {
- for (int i = 0; i < names.length; ++i)
- {
- name = names[i].canonicalName;
- domain = name.substring(0, name.indexOf(':'));
- if (!domains.contains(domain))
- {
- domains.add(domain);
- }
- }
- }
- return (String[])domains.toArray(new String[domains.size()]);
- }
-
- ///////////////////////////////
- //
- // Internal helper methods
- //
- ///////////////////////////////
-
- /**
- * Helper method to validate that we have a well-formed ObjectName string.
- *
- * @param objectName The object name to validate.
- * @return The valid ObjectName.
- */
- private javax.management.ObjectName validateObjectName(String objectName)
- {
- try
- {
- return new javax.management.ObjectName(objectName);
- }
- catch (MalformedObjectNameException mone)
- {
- ManagementException me = new ManagementException();
- me.setMessage(MALFORMED_OBJECTNAME, new Object[] {objectName});
- throw me;
- }
- }
-
- /**
- * Helper method to validate that we have a well-formed Attribute.
- *
- * @param attribute The attribute to validate.
- * @return The valid Attribute.
- */
- private javax.management.Attribute validateAttribute(Attribute attribute)
- {
- return attribute.toAttribute();
- }
-
-}
+/*
+ * 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.management.jmx;
+
+import flex.management.BaseControl;
+import flex.management.MBeanServerLocatorFactory;
+import flex.management.ManagementException;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
+import javax.management.InvalidAttributeValueException;
+import javax.management.MalformedObjectNameException;
+import javax.management.MBeanException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ReflectionException;
+import javax.management.RuntimeOperationsException;
+
+/**
+ * Remoting gateway to the MBean server that hosts Flex MBeans.
+ * <p>
+ * Some base javax.management.MBeanServer methods are unimplemented due to the
+ * fact that we're interacting with the MBean server from remote Flash clients.
+ * Some methods have been modified to better suite remote Flash clients. Other
+ * methods are additive, serving as a convenience for Flex applications.
+ * </p><p>
+ * Unimplemented methods from the base MBeanServer API:
+ * <ul>
+ * <li>getDomains() - JMX 1.2</li>
+ * <li>addNotificationListener()/removeNotificationListener() - Flash objects
+ * cannot listen directly for MBean notifications.</li>
+ * <li>instantiate() - returns a reference to a Java object that is not useful
+ * to a remote Flash client.</li>
+ * <li>deserialize() - deprecated.</li>
+ * <li>getClassLoaderFor() - meaningless to a Flash client.</li>
+ * <li>getClassLoader() - meaningless to a Flash client.</li>
+ * <li>getClassLoaderRepository() - meaningless to a Flash client.</li>
+ * </ul>
+ * </p><p>
+ * Modifications to the base MBeanServer API:
+ * <ul>
+ * <li>* All ObjectName arguments are typed as String because serialization in either
+ * direction doesn't support ObjectNames that are patterns. This does not effect
+ * ObjectNames that are not patterns that are returned to the client.</li>
+ * <li>queryMBeans() - returns an Array of ObjectInstances rather than a java.util.Set
+ * and does not currently support the QueryExp argument.</li>
+ * <li>queryNames() returns an Array of ObjectNames rather than a java.util.Set
+ * and does not currently support the QueryExp argument.</li>
+ * <li>getAttributes() returns an Array of Attributes rather than an AttributeList.</li>
+ * <li>setAttributes() accepts and returns Arrays of Attributes rather than AttributeLists.</li>
+ * </ul>
+ * </p><p>
+ * Additonal Flex-specific methods:
+ * <ul>
+ * <li>getFlexMBeanCount()</li>
+ * <li>getFlexDomains()</li>
+ * <li>getFlexMBeanObjectNames()</li>
+ * </ul>
+ * </p>
+ *
+ * @author shodgson
+ */
+public class MBeanServerGateway
+{
+ // Error string constants.
+ private static final int MALFORMED_OBJECTNAME = 10400;
+ private static final int GETINFO_INTROSPECTION_ERR = 10406;
+ private static final int MBEAN_NOTFOUND = 10407;
+ private static final int GETINFO_REFLECT_ERR = 10408;
+ private static final int ATTRIB_NOTFOUND = 10409;
+ private static final int GETATTRIB_EXCEPTION = 10410;
+ private static final int GETATTRIB_REFLECT_ERR = 10411;
+ private static final int GETATTRIB_NULL_ARGUMENT = 10412;
+ private static final int GETATTRIBS_REFLECT_ERR = 10413;
+ private static final int GETATTRIBS_NULL_ARGUMENT = 10414;
+ private static final int INVOKE_REFLECT_ERR = 10415;
+ private static final int INVOKE_ERR = 10416;
+ private static final int CREATE_ERR = 10417;
+ private static final int INSTANCE_EXISTS = 10418;
+ private static final int NOT_COMPLIANT = 10419;
+ private static final int MBEAN_PREREG_ERR = 10420;
+ private static final int MBEAN_PREDEREG_ERR = 10421;
+ private static final int SETATTRIB_REFLECT_ERR = 10422;
+ private static final int SETATTRIB_EXCEPTION = 10423;
+ private static final int INVALID_ATTRIB_VALUE = 10424;
+ private static final int SETATTRIBS_REFLECT_ERR = 10425;
+
+ private MBeanServer server;
+
+ /**
+ * Constructs a new MBeanServerGateway. The gateway exposes the MBean server
+ * that Flex MBean are registered with in a remoting-friendly fashion.
+ */
+ public MBeanServerGateway()
+ {
+ server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer();
+ }
+
+ /////////////////////////////////////
+ //
+ // Core MBeanServer API
+ //
+ /////////////////////////////////////
+
+ /**
+ * Instantiates and registers an MBean with the MBean server.
+ *
+ * @param className The class name for the MBean to instantiate.
+ * @param objectName The object name of the MBean.
+ * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean.
+ */
+ public ObjectInstance createMBean(String className, String objectName)
+ {
+ javax.management.ObjectName name = null;
+ if (objectName != null)
+ name = validateObjectName(objectName);
+ try
+ {
+ return new ObjectInstance(server.createMBean(className, name));
+ }
+ catch (ReflectionException re)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(CREATE_ERR, new Object[] {name});
+ me.setRootCause(re);
+ throw me;
+ }
+ catch (InstanceAlreadyExistsException iaee)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(INSTANCE_EXISTS, new Object[] {name});
+ me.setRootCause(iaee);
+ throw me;
+ }
+ catch (MBeanException mbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(CREATE_ERR, new Object[] {name});
+ me.setRootCause(mbe);
+ throw me;
+ }
+ catch (NotCompliantMBeanException ncmbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(NOT_COMPLIANT, new Object[] {className});
+ me.setRootCause(ncmbe);
+ throw me;
+ }
+ }
+
+ /**
+ * Instantiates and registers an MBean with the MBean server. The class loader
+ * to use to load the MBean class is identified by its ObjectName.
+ *
+ * @param className The class name for the MBean to instantiate.
+ * @param objectName The object name of the MBean.
+ * @param loaderName The object name of the desired class loader.
+ * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean.
+ */
+ public ObjectInstance createMBean(String className, String objectName, String loaderName)
+ {
+ javax.management.ObjectName name = null;
+ javax.management.ObjectName loader = null;
+ if (objectName != null)
+ name = validateObjectName(objectName);
+ if (loaderName != null)
+ loader = validateObjectName(loaderName);
+ try
+ {
+ return new ObjectInstance(server.createMBean(className, name, loader));
+ }
+ catch (ReflectionException re)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(CREATE_ERR, new Object[] {name});
+ me.setRootCause(re);
+ throw me;
+ }
+ catch (InstanceAlreadyExistsException iaee)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(INSTANCE_EXISTS, new Object[] {name});
+ me.setRootCause(iaee);
+ throw me;
+ }
+ catch (MBeanException mbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(CREATE_ERR, new Object[] {name});
+ me.setRootCause(mbe);
+ throw me;
+ }
+ catch (NotCompliantMBeanException ncmbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(NOT_COMPLIANT, new Object[] {className});
+ me.setRootCause(ncmbe);
+ throw me;
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
+ me.setRootCause(infe);
+ throw me;
+ }
+ }
+
+ /**
+ * Instantiates and registers an MBean with the MBean server.
+ *
+ * @param className The class name for the MBean to instantiate.
+ * @param objectName The object name of the MBean.
+ * @param params An array of parameters to pass to the MBean constructor.
+ * @param signature An array containing the type signature for the constructor to invoke.
+ * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean.
+ */
+ public ObjectInstance createMBean(String className, String objectName, Object[] params, String[] signature)
+ {
+ javax.management.ObjectName name = null;
+ if (objectName != null)
+ name = validateObjectName(objectName);
+ try
+ {
+ return new ObjectInstance(server.createMBean(className, name, params, signature));
+ }
+ catch (ReflectionException re)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(CREATE_ERR, new Object[] {name});
+ me.setRootCause(re);
+ throw me;
+ }
+ catch (InstanceAlreadyExistsException iaee)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(INSTANCE_EXISTS, new Object[] {name});
+ me.setRootCause(iaee);
+ throw me;
+ }
+ catch (MBeanException mbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(CREATE_ERR, new Object[] {name});
+ me.setRootCause(mbe);
+ throw me;
+ }
+ catch (NotCompliantMBeanException ncmbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(NOT_COMPLIANT, new Object[] {className});
+ me.setRootCause(ncmbe);
+ throw me;
+ }
+ }
+
+ /**
+ * Instantiates and registers an MBean with the MBean server. The class loader
+ * to use to load the MBean class is identified by its ObjectName.
+ *
+ * @param className The class name for the MBean to instantiate.
+ * @param objectName The object name of the MBean.
+ * @param loaderName The object name of the desired class loader.
+ * @param params An array of parameters to pass to the MBean constructor.
+ * @param signature An array containing the type signature for the constructor to invoke.
+ * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean.
+ */
+ public ObjectInstance createMBean(String className, String objectName, String loaderName, Object[] params, String[] signature)
+ {
+ javax.management.ObjectName name = null;
+ javax.management.ObjectName loader = null;
+ if (objectName != null)
+ name = validateObjectName(objectName);
+ if (loaderName != null)
+ loader = validateObjectName(loaderName);
+ try
+ {
+ return new ObjectInstance(server.createMBean(className, name, loader, params, signature));
+ }
+ catch (ReflectionException re)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(CREATE_ERR, new Object[] {name});
+ me.setRootCause(re);
+ throw me;
+ }
+ catch (InstanceAlreadyExistsException iaee)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(INSTANCE_EXISTS, new Object[] {name});
+ me.setRootCause(iaee);
+ throw me;
+ }
+ catch (MBeanException mbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(CREATE_ERR, new Object[] {name});
+ me.setRootCause(mbe);
+ throw me;
+ }
+ catch (NotCompliantMBeanException ncmbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(NOT_COMPLIANT, new Object[] {className});
+ me.setRootCause(ncmbe);
+ throw me;
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
+ me.setRootCause(infe);
+ throw me;
+ }
+ }
+
+ /**
+ * Registers a pre-existing object as an MBean with the MBean server.
+ *
+ * @param object The object to register as an MBean.
+ * @param objectName The object name for the MBean.
+ * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean.
+ */
+ public ObjectInstance registerMBean(Object object, String objectName)
+ {
+ javax.management.ObjectName name = null;
+ if (objectName != null)
+ name = validateObjectName(objectName);
+ try
+ {
+ return new ObjectInstance(server.registerMBean(object, name));
+ }
+ catch (InstanceAlreadyExistsException iaee)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(INSTANCE_EXISTS, new Object[] {name});
+ me.setRootCause(iaee);
+ throw me;
+ }
+ catch (NotCompliantMBeanException ncmbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(NOT_COMPLIANT, new Object[] {object.getClass().getName()});
+ me.setRootCause(ncmbe);
+ throw me;
+ }
+ catch (MBeanRegistrationException mbre)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_PREREG_ERR, new Object[] {name});
+ me.setRootCause(mbre);
+ throw me;
+ }
+ }
+
+ /**
+ * Unregisters an MBean from the MBean server.
+ *
+ * @param objectName The object name of the MBean to unregister.
+ */
+ public void unregisterMBean(String objectName)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ try
+ {
+ server.unregisterMBean(name);
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
+ me.setRootCause(infe);
+ throw me;
+ }
+ catch (MBeanRegistrationException mbre)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_PREDEREG_ERR, new Object[] {name});
+ me.setRootCause(mbre);
+ throw me;
+ }
+ }
+
+ /**
+ * Gets the ObjectInstance for the specified MBean registered with the
+ * MBean server.
+ *
+ * @param objectName The object name of the MBean.
+ * @return An ObjectInstance containing the ObjectName and Java class name of the MBean.
+ */
+ public ObjectInstance getObjectInstance(String objectName)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ try
+ {
+ return new ObjectInstance(server.getObjectInstance(name));
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
+ me.setRootCause(infe);
+ throw me;
+ }
+ }
+
+ /**
+ * Gets MBeans controlled by the MBean server. This method allows the following to be obtained:
+ * All MBeans, or a set of MBeans specified by pattern matching on the ObjectName, or a specific
+ * MBean.
+ * <p>
+ * This method does not support a QueryExp argument for additional filtering of the queried set.
+ * </p>
+ *
+ * @param objectName The object name pattern identifying the MBeans to retrieve.
+ * @return A set of ObjectInstances for the selected MBeans.
+ */
+ public ObjectInstance[] queryMBeans(String objectName)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ Set result = server.queryMBeans(name, null);
+ int n = result.size();
+ if (n > 0)
+ {
+ ObjectInstance[] toReturn = new ObjectInstance[n];
+ int i = 0;
+ for (Iterator iter = result.iterator(); iter.hasNext();)
+ {
+ toReturn[i++] = new ObjectInstance((javax.management.ObjectInstance)iter.next());
+ }
+ return toReturn;
+ }
+ else
+ {
+ return new ObjectInstance[0];
+ }
+ }
+
+ /**
+ * Gets the names of MBeans controlled by the MBean server. This method allows the following to be
+ * obtained: The names of all MBeans, the names of the set of MBeans matching the ObjectName pattern,
+ * a specific MBean name.
+ * <p>
+ * This method does not support a QueryExp argument for additional filtering of the queried set.
+ * </p>
+ *
+ * @param objectName The object name pattern identifying the MBean names to retrieve.
+ * @return A set of ObjectNames for the selected MBeans.
+ */
+ public ObjectName[] queryNames(String objectName)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ Set result = server.queryNames(name, null);
+ int n = result.size();
+ if (n > 0)
+ {
+ ObjectName[] toReturn = new ObjectName[n];
+ int i = 0;
+ for (Iterator iter = result.iterator(); iter.hasNext();)
+ {
+ toReturn[i++] = new ObjectName((javax.management.ObjectName)iter.next());
+ }
+ return toReturn;
+ }
+ else
+ {
+ return new ObjectName[0];
+ }
+ }
+
+ /**
+ * Checks whether an MBean, identified by its object name, is already registered with the MBean server.
+ *
+ * @param objectName The object name of the MBean to be checked.
+ * @return True if the MBean is already registered in the MBean server, false otherwise.
+ */
+ public boolean isRegistered(String objectName)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ return server.isRegistered(name);
+ }
+
+ /**
+ * Returns the total number of beans registered in the MBean server.
+ *
+ * @return The number of registered MBeans.
+ */
+ public Integer getMBeanCount()
+ {
+ return server.getMBeanCount();
+ }
+
+ /**
+ * Gets the value of a specific attribute of a named MBean. The MBean is identified by its object name.
+ *
+ * @param objectName The object name of the MBean from which the attribute is to be retrieved.
+ * @param attribute The name of the attribute to be retrieved.
+ * @return The value of the retrieved attribute.
+ */
+ public Object getAttribute(String objectName, String attribute)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ try
+ {
+ return server.getAttribute(name, attribute);
+ }
+ catch (AttributeNotFoundException anfe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(ATTRIB_NOTFOUND, new Object[] {attribute, name});
+ me.setRootCause(anfe);
+ throw me;
+ }
+ catch (MBeanException mbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(GETATTRIB_EXCEPTION, new Object[] {attribute, name});
+ me.setRootCause(mbe);
+ throw me;
+ }
+ catch (ReflectionException re)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(GETATTRIB_REFLECT_ERR, new Object[] {attribute, name});
+ me.setRootCause(re);
+ throw me;
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
+ me.setRootCause(infe);
+ throw me;
+ }
+ catch (RuntimeOperationsException roe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(GETATTRIB_NULL_ARGUMENT);
+ me.setRootCause(roe);
+ throw me;
+ }
+ }
+
+ /**
+ * Gets the values of several attributes of a named MBean.
+ *
+ * @param objectName The object name of the MBean to get attribute values from.
+ * @param attributes The names of the attributes to get values for.
+ * @return The attributes, each containing their name and value.
+ */
+ public Attribute[] getAttributes(String objectName, String[] attributes)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ try
+ {
+ AttributeList result = server.getAttributes(name, attributes);
+ Attribute[] values = new Attribute[result.size()];
+ for (int i = 0; i < result.size(); i++)
+ {
+ values[i] = new Attribute((javax.management.Attribute)result.get(i));
+ }
+ return values;
+ }
+ catch (ReflectionException re)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(GETATTRIBS_REFLECT_ERR, new Object[] {name});
+ me.setRootCause(re);
+ throw me;
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
+ me.setRootCause(infe);
+ throw me;
+ }
+ catch (RuntimeOperationsException roe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(GETATTRIBS_NULL_ARGUMENT);
+ me.setRootCause(roe);
+ throw me;
+ }
+ }
+
+ /**
+ * Sets the value of the attribute for the specified MBean.
+ *
+ * @param objectName The name of the MBean.
+ * @param attribute The attribute to set.
+ */
+ public void setAttribute(String objectName, Attribute attribute)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ javax.management.Attribute attrib = validateAttribute(attribute);
+ try
+ {
+ server.setAttribute(name, attrib);
+ }
+ catch (ReflectionException re)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(SETATTRIB_REFLECT_ERR, new Object[] {attrib.getName(), name});
+ me.setRootCause(re);
+ throw me;
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
+ me.setRootCause(infe);
+ throw me;
+ }
+ catch (AttributeNotFoundException anfe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(ATTRIB_NOTFOUND, new Object[] {attrib.getName(), name});
+ me.setRootCause(anfe);
+ throw me;
+ }
+ catch (MBeanException mbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(SETATTRIB_EXCEPTION, new Object[] {attrib.getName(), name});
+ me.setRootCause(mbe);
+ throw me;
+ }
+ catch (InvalidAttributeValueException iave)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(INVALID_ATTRIB_VALUE, new Object[] {attrib.getValue(), attrib.getName(), name});
+ me.setRootCause(iave);
+ throw me;
+ }
+ }
+
+ /**
+ * Sets the values for several attributes of the specified MBean.
+ *
+ * @param objectName The object name for the MBean.
+ * @param attributes The attributes to set.
+ * @return The attributes that were set with their new values.
+ */
+ public Attribute[] setAttributes(String objectName, Attribute[] attributes)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ AttributeList attribList = new AttributeList();
+ for (int i = 0; i < attributes.length; i++)
+ {
+ attribList.add(attributes[i].toAttribute());
+ }
+ try
+ {
+ AttributeList result = server.setAttributes(name, attribList);
+ Attribute[] values = new Attribute[result.size()];
+ for (int i = 0; i < result.size(); i++)
+ {
+ values[i] = new Attribute((javax.management.Attribute)result.get(i));
+ }
+ return values;
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {name});
+ me.setRootCause(infe);
+ throw me;
+ }
+ catch (ReflectionException re)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(SETATTRIBS_REFLECT_ERR, new Object[] {name});
+ me.setRootCause(re);
+ throw me;
+ }
+ }
+
+ /**
+ * Invokes an operation on an MBean.
+ *
+ * @param objectName The object name of the MBean to invoke the operation on.
+ * @param operationName The operation to invoke.
+ * @param params The parameters for the operation invocation.
+ * @param signature The parameter signature for the operation.
+ * @return The object returned by the operation invocation.
+ */
+ public Object invoke(String objectName, String operationName, Object[] params, String[] signature)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ try
+ {
+ return server.invoke(name, operationName, params, signature);
+ }
+ catch (ReflectionException re)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(INVOKE_REFLECT_ERR, new Object[] {operationName, objectName});
+ me.setRootCause(re);
+ throw me;
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {objectName});
+ me.setRootCause(infe);
+ throw me;
+ }
+ catch (MBeanException mbe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(INVOKE_ERR, new Object[] {operationName, objectName});
+ me.setRootCause(mbe);
+ throw me;
+ }
+ }
+
+ /**
+ * Returns the default domain used for naming MBeans.
+ *
+ * @return The default domain.
+ */
+ public String getDefaultDomain()
+ {
+ return server.getDefaultDomain();
+ }
+
+ /**
+ * This method discovers the attributes and operations that an MBean exposes for management
+ * by a Flash client.
+ *
+ * @param objectName The name of the MBean to get metadata for.
+ * @return An MBeanInfo instance that describes the MBean.
+ */
+ public flex.management.jmx.MBeanInfo getMBeanInfo(String objectName)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ try
+ {
+ return new MBeanInfo(server.getMBeanInfo(name));
+ }
+ catch (IntrospectionException ie)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(GETINFO_INTROSPECTION_ERR, new Object[] {objectName});
+ me.setRootCause(ie);
+ throw me;
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {objectName});
+ me.setRootCause(infe);
+ throw me;
+ }
+ catch (ReflectionException re)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(GETINFO_REFLECT_ERR, new Object[] {objectName});
+ me.setRootCause(re);
+ throw me;
+ }
+ }
+
+
+ /**
+ * Returns true if the specified MBean is an instance of the specified class; otherwise false.
+ *
+ * @param objectName The object name of the MBean.
+ * @param className The name of the class.
+ * @return true if the specified MBean is an instance of the specified class; otherwise false.
+ */
+ public boolean isInstanceOf(String objectName, String className)
+ {
+ javax.management.ObjectName name = validateObjectName(objectName);
+ try
+ {
+ return server.isInstanceOf(name, className);
+ }
+ catch (InstanceNotFoundException infe)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MBEAN_NOTFOUND, new Object[] {objectName});
+ me.setRootCause(infe);
+ throw me;
+ }
+ }
+
+ ////////////////////////////////
+ //
+ // Additive Flex-specific API
+ //
+ ////////////////////////////////
+
+ /**
+ * Returns all the object names for Flex related MBeans.
+ *
+ * @return The object names for all Flex related MBeans.
+ */
+ public ObjectName[] getFlexMBeanObjectNames()
+ {
+ javax.management.ObjectName pattern = validateObjectName(BaseControl.DOMAIN_PREFIX + "*:*");
+ Set result = server.queryNames(pattern, null);
+ ObjectName[] names = new ObjectName[result.size()];
+ int i = 0;
+ for (Iterator iter = result.iterator(); iter.hasNext(); )
+ {
+ names[i++] = new ObjectName((javax.management.ObjectName)iter.next());
+ }
+ return names;
+ }
+
+ /**
+ * Returns the number of narrowed Flex MBeans registered in the MBean server.
+ *
+ * @return The number of narrowed Flex MBeans registered in the MBean server.
+ */
+ public Integer getFlexMBeanCount()
+ {
+ return new Integer(getFlexMBeanObjectNames().length);
+ }
+
+ /**
+ * Returns the narrowed list of Flex domains in which any MBean is currently registered.
+ * The domains are returned in naturally sorted order.
+ *
+ * @return The narrowed list of Flex domains in which any MBean is currently registered.
+ */
+ public String[] getFlexDomains()
+ {
+ ObjectName[] names = getFlexMBeanObjectNames();
+ Set domains = new TreeSet();
+ String name;
+ String domain;
+ if (names.length > 0)
+ {
+ for (int i = 0; i < names.length; ++i)
+ {
+ name = names[i].canonicalName;
+ domain = name.substring(0, name.indexOf(':'));
+ if (!domains.contains(domain))
+ {
+ domains.add(domain);
+ }
+ }
+ }
+ return (String[])domains.toArray(new String[domains.size()]);
+ }
+
+ ///////////////////////////////
+ //
+ // Internal helper methods
+ //
+ ///////////////////////////////
+
+ /**
+ * Helper method to validate that we have a well-formed ObjectName string.
+ *
+ * @param objectName The object name to validate.
+ * @return The valid ObjectName.
+ */
+ private javax.management.ObjectName validateObjectName(String objectName)
+ {
+ try
+ {
+ return new javax.management.ObjectName(objectName);
+ }
+ catch (MalformedObjectNameException mone)
+ {
+ ManagementException me = new ManagementException();
+ me.setMessage(MALFORMED_OBJECTNAME, new Object[] {objectName});
+ throw me;
+ }
+ }
+
+ /**
+ * Helper method to validate that we have a well-formed Attribute.
+ *
+ * @param attribute The attribute to validate.
+ * @return The valid Attribute.
+ */
+ private javax.management.Attribute validateAttribute(Attribute attribute)
+ {
+ return attribute.toAttribute();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/jmx/ObjectInstance.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/jmx/ObjectInstance.java b/modules/core/src/flex/management/jmx/ObjectInstance.java
old mode 100755
new mode 100644
index 03e81a0..ccd8b44
--- a/modules/core/src/flex/management/jmx/ObjectInstance.java
+++ b/modules/core/src/flex/management/jmx/ObjectInstance.java
@@ -1,67 +1,67 @@
-/*
- * 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.management.jmx;
-
-import javax.management.MalformedObjectNameException;
-
-/**
- * Remotable ObjectInstance representation that complies with Flash serialization requirements.
- *
- * @author shodgson
- */
-public class ObjectInstance
-{
- /**
- * The object name part of the <code>ObjectInstance</code>.
- */
- public ObjectName objectName;
-
- /**
- * The class name part of the <code>ObjectInstance</code>.
- */
- public String className;
-
- /**
- * Constructs an empty <code>ObjectInstance</code> instance.
- *
- */
- public ObjectInstance()
- {}
-
- /**
- * Constructs a <code>ObjectInstance</code> instance based upon a
- * <code>javax.management.ObjectInstance</code> instance.
- *
- * @param objectInstance The JMX <code>ObjectInstance</code> instance to base this instance on.
- */
- public ObjectInstance(javax.management.ObjectInstance objectInstance)
- {
- objectName = new ObjectName(objectInstance.getObjectName());
- className = objectInstance.getClassName();
- }
-
- /**
- * Utility method to convert this <code>ObjectInstance</code> to a
- * <code>javax.management.ObjectInstance</code> instance.
- *
- * @return A JMX <code>ObjectInstance</code> based upon this instance.
- */
- public javax.management.ObjectInstance toObjectInstance() throws MalformedObjectNameException
- {
- return new javax.management.ObjectInstance(objectName.toObjectName(), className);
- }
-}
+/*
+ * 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.management.jmx;
+
+import javax.management.MalformedObjectNameException;
+
+/**
+ * Remotable ObjectInstance representation that complies with Flash serialization requirements.
+ *
+ * @author shodgson
+ */
+public class ObjectInstance
+{
+ /**
+ * The object name part of the <code>ObjectInstance</code>.
+ */
+ public ObjectName objectName;
+
+ /**
+ * The class name part of the <code>ObjectInstance</code>.
+ */
+ public String className;
+
+ /**
+ * Constructs an empty <code>ObjectInstance</code> instance.
+ *
+ */
+ public ObjectInstance()
+ {}
+
+ /**
+ * Constructs a <code>ObjectInstance</code> instance based upon a
+ * <code>javax.management.ObjectInstance</code> instance.
+ *
+ * @param objectInstance The JMX <code>ObjectInstance</code> instance to base this instance on.
+ */
+ public ObjectInstance(javax.management.ObjectInstance objectInstance)
+ {
+ objectName = new ObjectName(objectInstance.getObjectName());
+ className = objectInstance.getClassName();
+ }
+
+ /**
+ * Utility method to convert this <code>ObjectInstance</code> to a
+ * <code>javax.management.ObjectInstance</code> instance.
+ *
+ * @return A JMX <code>ObjectInstance</code> based upon this instance.
+ */
+ public javax.management.ObjectInstance toObjectInstance() throws MalformedObjectNameException
+ {
+ return new javax.management.ObjectInstance(objectName.toObjectName(), className);
+ }
+}
[22/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/client/FlexClient.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/client/FlexClient.java b/modules/core/src/flex/messaging/client/FlexClient.java
old mode 100755
new mode 100644
index 3e0c7d2..f6a4b59
--- a/modules/core/src/flex/messaging/client/FlexClient.java
+++ b/modules/core/src/flex/messaging/client/FlexClient.java
@@ -1,2240 +1,2240 @@
-/*
- * 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;
-
-import flex.messaging.ConnectionAwareSession;
-import flex.messaging.FlexContext;
-import flex.messaging.FlexSession;
-import flex.messaging.FlexSessionListener;
-import flex.messaging.HttpFlexSession;
-import flex.messaging.MessageClient;
-import flex.messaging.MessageClientListener;
-import flex.messaging.MessageException;
-import flex.messaging.endpoints.Endpoint;
-import flex.messaging.log.Log;
-import flex.messaging.log.LogCategories;
-import flex.messaging.messages.CommandMessage;
-import flex.messaging.messages.Message;
-import flex.messaging.services.MessageService;
-import flex.messaging.util.StringUtils;
-import flex.messaging.util.TimeoutAbstractObject;
-
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * Represents a Flex client application instance on the server.
- */
-public class FlexClient extends TimeoutAbstractObject implements FlexSessionListener, MessageClientListener
-{
- //--------------------------------------------------------------------------
- //
- // Public Static Constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * Log category for FlexClient related messages.
- */
- public static final String FLEX_CLIENT_LOG_CATEGORY = LogCategories.CLIENT_FLEXCLIENT;
-
- /**
- * This value is passed to the server in an initial client connect to
- * indicate that the client needs a server-assigned FlexClient Id.
- * @exclude
- */
- public static final String NULL_FLEXCLIENT_ID = "nil";
-
- //--------------------------------------------------------------------------
- //
- // Private Static Constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * Error string constants.
- */
- private static final int FLEX_CLIENT_INVALIDATED = 10027;
- private static final int ENDPOINT_PUSH_HANDLER_ALREADY_REGISTERED = 10033;
-
- private static final String POLL_WAIT_THREAD_NAME_EXTENSION = "-in-poll-wait";
-
- //--------------------------------------------------------------------------
- //
- // Private Static Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * List of registered FlexClient created listeners.
- */
- private static final CopyOnWriteArrayList<FlexClientListener> createdListeners = new CopyOnWriteArrayList<FlexClientListener>();
-
- //--------------------------------------------------------------------------
- //
- // Public Static Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Adds a create listener that will be notified when new FlexClients
- * are created.
- *
- * @see flex.messaging.client.FlexClientListener
- *
- * @param listener The listener to add.
- */
- public static void addClientCreatedListener(FlexClientListener listener)
- {
- if (listener != null)
- createdListeners.addIfAbsent(listener);
- }
-
- /**
- * Removes a FlexClient created listener.
- *
- * @see flex.messaging.client.FlexClientListener
- *
- * @param listener The listener to remove.
- */
- public static void removeClientCreatedListener(FlexClientListener listener)
- {
- if (listener != null)
- createdListeners.remove(listener);
- }
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * Constructs a new FlexClient instance.
- *
- * @param manager The FlexClientManager managing this instance.
- */
- public FlexClient(FlexClientManager manager)
- {
- this(manager, FlexContext.getMessageBroker().createUUID());
- }
-
- /**
- * @exclude
- * Constructs a new FlexClient instance having the specified Id.
- *
- * @param manager The FlexClientManager managing this instance.
- * @param id The Id for this instance.
- */
- public FlexClient(FlexClientManager manager, String id)
- {
- this.id = id;
- flexClientManager = manager;
- updateLastUse();
- valid = true;
-
- if (Log.isDebug())
- Log.getLogger(FLEX_CLIENT_LOG_CATEGORY).debug("FlexClient created with id '" + this.id + "'.");
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Storage for custom attributes.
- */
- private volatile Map<String, Object> attributes;
-
- /**
- * List of registered FlexClient attribute listeners.
- */
- private volatile CopyOnWriteArrayList<FlexClientAttributeListener> attributeListeners;
-
- /**
- * List of registered FlexClient destroyed listeners.
- */
- private volatile CopyOnWriteArrayList<FlexClientListener> destroyedListeners;
-
- /**
- * The manager for the FlexClient.
- */
- final FlexClientManager flexClientManager;
-
- /**
- * The unique Id for the instance.
- */
- private final String id;
-
- /**
- * Flag used to break cycles during invalidation.
- */
- /* package visibility for FlexClientManager */ volatile boolean invalidating;
-
- /**
- * Instance level lock to sync for state changes.
- */
- final Object lock = new Object();
-
- /**
- * MessageClient subscriptions for this MessageClient.
- */
- private volatile CopyOnWriteArrayList<MessageClient> messageClients;
-
- /**
- * Queues of outbound messages to push to the client keyed by endpoint id.
- * Map(String endpointId, EndpointQueue queue).
- */
- private final Map<String, EndpointQueue> outboundQueues = new ConcurrentHashMap<String, EndpointQueue>(1);
-
- /**
- * EndpointPushHandlers keyed by endpointId that the FlexClient
- * can use to push messages to remote clients.
- * NOTE: these can't be added to the EndpointQueue data type because the existence of queues depends
- * upon client subscription state whereas endpoints that support push will generally set up their push
- * handling before any subscriptions have been created.
- */
- private Map<String, EndpointPushHandler> endpointPushHandlers;
-
- /**
- * Associated FlexSessions that represent the connections the FlexClient makes to the server.
- */
- private final CopyOnWriteArrayList<FlexSession> sessions = new CopyOnWriteArrayList<FlexSession>(); // We always have at least one session.
-
- /**
- * Flag indicating whether the instance is valid; once invalidated this flag is
- * set to false.
- */
- boolean valid;
-
- /**
- * The principal associated with this client. Only used when perClientAuthentication
- * is being used.
- */
- private Principal userPrincipal;
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Adds a FlexClient attribute listener that will be notified when an
- * attribute is added, removed or changed. If the attribute implements
- * FlexClientBindingListener, it will be notified before any
- * FlexClientAttributeListeners are notified.
- *
- * @param listener The listener to add.
- */
- public void addClientAttributeListener(FlexClientAttributeListener listener)
- {
- if (listener != null)
- {
- checkValid();
-
- synchronized (lock)
- {
- if (attributeListeners == null)
- attributeListeners = new CopyOnWriteArrayList<FlexClientAttributeListener>();
- }
-
- attributeListeners.addIfAbsent(listener);
- }
- }
-
- /**
- * Adds a destroy listener that will be notified when the FlexClient
- * is destroyed. Listeners are notified after all attributes
- * have been unbound from the FlexClient and any FlexClientBindingListeners
- * and FlexClientAttributeListeners have been notified.
- *
- * @see flex.messaging.client.FlexClientListener
- *
- * @param listener The listener to add.
- */
- public void addClientDestroyedListener(FlexClientListener listener)
- {
- if (listener != null)
- {
- checkValid();
-
- synchronized (lock)
- {
- if (destroyedListeners == null)
- destroyedListeners = new CopyOnWriteArrayList<FlexClientListener>();
- }
-
- destroyedListeners.addIfAbsent(listener);
- }
- }
-
- /**
- * Returns the attribute bound to the specified name for the FlexClient, or null
- * if no attribute is bound under the name.
- *
- * @param name The name the attribute is bound to.
- * @return The attribute bound to the specified name.
- */
- public Object getAttribute(String name)
- {
- synchronized (lock)
- {
- checkValid();
-
- updateLastUse();
-
- return (attributes == null) ? null : attributes.get(name);
- }
- }
-
- /**
- * Returns a snapshot of the names of all attributes bound to the FlexClient.
- *
- * @return A snapshot of the names of all attributes bound to the FlexClient.
- */
- public Enumeration<String> getAttributeNames()
- {
- synchronized (lock)
- {
- checkValid();
-
- updateLastUse();
-
- if (attributes == null)
- return Collections.enumeration(Collections.<String>emptyList());
-
- // Return a copy so we do not run into concurrent modification problems if
- // someone adds to the attributes while iterating through the returned enumeration.
- return Collections.enumeration(new ArrayList<String>(attributes.keySet()));
- }
- }
-
- /**
- * @exclude
- * Returns the push handler registered with the FlexClient with the supplied
- * endpoint id, or null if no push handler was registered with the FlexClient
- * for that endpoint.
- *
- * @return The push handler registered with the FlexClient with the supplied
- * endpoint id, or null if no push handler was registered with the FlexClient
- * for that endpoint.
- */
- public EndpointPushHandler getEndpointPushHandler(String endpointId)
- {
- synchronized (lock)
- {
- if (endpointPushHandlers != null && endpointPushHandlers.containsKey(endpointId))
- return endpointPushHandlers.get(endpointId);
- return null;
- }
- }
-
- /**
- * @exclude
- * Returns the queue processor registered with the FlexClient with the supplied
- * endpoint id, or null if no queue processor was registered with the FlexClient
- * for that endpoint.
- *
- * @param endpointId The endpoint id.
- * @return The queue processor registered with the FlexClient.
- */
- public FlexClientOutboundQueueProcessor getOutboundQueueProcessor(String endpointId)
- {
- EndpointQueue queue = outboundQueues.get(endpointId);
- return (queue != null)? queue.processor : null;
- }
-
- /**
- * @exclude
- * Returns the endpoint queue registered with the FlexClient with the supplied
- * endpoint id, or null if no endpoint queue was registered with the FlexClient
- * for that endpoint.
- *
- * @param endpointId The endpoint id.
- * @return The endpoint queue registered with the FlexClient.
- */
- public EndpointQueue getEndpointQueue(String endpointId)
- {
- return outboundQueues.get(endpointId);
- }
-
- /**
- * Override {@link flex.messaging.util.TimeoutAbstractObject#getLastUse()} to make timeout
- * dependent upon FlexClient inactivity but also upon the presence of an active push-enabled session,
- * async or waited poll, or registered endpoint push handler (all of which indicate that a client has
- * an active, open connection to the server).
- *
- * @return The 'last use' timestamp for the FlexClient, which may be the current system time if the FlexClient
- * has been idle but an open connection from the client to the server exists.
- */
- @Override
- public long getLastUse()
- {
- synchronized (lock)
- {
- long currentLastUse = super.getLastUse();
- long idleTime = System.currentTimeMillis() - currentLastUse;
- if (idleTime < flexClientManager.getFlexClientTimeoutMillis())
- return currentLastUse; // Not timed out; this will trigger the timeout to be rescheduled.
-
- // Check for async long-polls or endpoint streaming connections, if found, keep alive.
- if (!outboundQueues.isEmpty())
- {
- for (EndpointQueue queue : outboundQueues.values())
- {
- if (queue.asyncPoll != null)
- return System.currentTimeMillis();
-
- if (endpointPushHandlers != null && endpointPushHandlers.containsKey(queue.endpointId))
- return System.currentTimeMillis();
- }
- }
-
- // Check for connected sessions, or a session holding a (non-async) long poll and if found, keep alive.
- for (FlexSession session : sessions)
- {
- if (session instanceof ConnectionAwareSession)
- {
- if (((ConnectionAwareSession)session).isConnected())
- return System.currentTimeMillis();
- }
- // Otherwise, check for a long-poll.
- if (session.waitMonitor != null)
- {
- for (EndpointQueue queue : session.waitMonitor.values())
- {
- if (queue.flexClient.equals(this))
- return System.currentTimeMillis();
- }
- }
- }
- return currentLastUse; // Allow the FlexClient to timeout.
- }
- }
-
- /**
- * Returns the attribute bound to the specified name for the current FlexSession
- * associated with the FlexClient. If the attribute does not exist in the current
- * FlexSession, this method iterates through all the other FlexSessions associated with
- * the FlexClient and either returns the attribute bound, or null if no attribute is bound
- * under the name.
- *
- * @param name The name the attribute is bound to.
- * @return The attribute bound to the specified name.
- */
- public Object getSessionAttribute(String name)
- {
- Object attributeValue = getSessionAttributeInCurrentSession(name);
- if (attributeValue != null)
- return attributeValue;
-
- return getSessionAttributeInOtherSessions(name);
- }
-
- /**
- * Returns a snapshot of the names of all attributes bound to all the FlexSessions
- * associated with the FlexClient.
- *
- * @return A snapshot of the names of all attributes bound to all the FlexSessions
- * associated with the FlexClient.
- */
- public Enumeration<String> getSessionAttributeNames()
- {
- Set<String> attributeNames = new HashSet<String>();
- for (FlexSession session : sessions)
- attributeNames.addAll(getSessionAttributeNames(session));
- return Collections.enumeration(attributeNames);
- }
-
- /**
- * @exclude
- *
- * Returns the principal associated with this client. If the client has not
- * authenticated the principal will be null. Should only be called from FlexContext
- * and only if perClientAuthentication is used. Not available to users.
- *
- * @return The principal associated with the session.
- */
- public Principal getUserPrincipal()
- {
- synchronized (lock)
- {
- checkValid();
- return userPrincipal;
- }
- }
-
- /**
- * @exclude
- *
- * Should only be called from FlexContext and only if perClientAuthentication is used.
- * Not available to users.
- *
- * @param userPrincipal The principal to associate with the session.
- */
- public void setUserPrincipal(Principal userPrincipal)
- {
- synchronized (lock)
- {
- checkValid();
- this.userPrincipal = userPrincipal;
- }
- }
-
- /**
- * Invalidates the FlexClient.
- */
- public void invalidate()
- {
- synchronized (lock)
- {
- if (!valid || invalidating)
- return; // Already shutting down.
-
- invalidating = true; // This thread gets to shut the FlexClient down.
- flexClientManager.removeFlexClient(this);
- cancelTimeout();
- }
-
- // Unregister from all FlexSessions.
- if (!sessions.isEmpty())
- {
- for (FlexSession session : sessions)
- unregisterFlexSession(session);
- }
-
- // Invalidate associated MessageClient subscriptions.
- if (messageClients != null && !messageClients.isEmpty())
- {
- for (MessageClient messageClient : messageClients)
- {
- messageClient.removeMessageClientDestroyedListener(this);
- messageClient.invalidate();
- }
- messageClients.clear();
- }
-
- // Notify destroy listeners that we're shutting the FlexClient down.
- if (destroyedListeners != null && !destroyedListeners.isEmpty())
- {
- for (FlexClientListener destroyListener : destroyedListeners)
- {
- destroyListener.clientDestroyed(this);
- }
- destroyedListeners.clear();
- }
-
- // Unbind all attributes.
- if (attributes != null && !attributes.isEmpty())
- {
- Set<String> keySet = attributes.keySet();
- String[] keys = keySet.toArray(new String[keySet.size()]);
- for (String key : keys)
- removeAttribute(key);
- }
-
- // Close any registered push handlers.
- if (endpointPushHandlers != null && !endpointPushHandlers.isEmpty())
- {
- for (EndpointPushHandler handler : endpointPushHandlers.values())
- {
- handler.close(true /* notify Channel of disconnect */);
- }
- endpointPushHandlers = null;
- }
-
- synchronized (lock)
- {
- valid = false;
- invalidating = false;
- }
-
- if (Log.isDebug())
- Log.getLogger(FLEX_CLIENT_LOG_CATEGORY).debug("FlexClient with id '" + this.id + "' has been invalidated.");
- }
-
- /**
- * Returns true if the FlexClient is valid; false if it has been invalidated.
- *
- * @return true if the FlexClient is valid; otherwise false.
- */
- public boolean isValid()
- {
- synchronized (lock)
- {
- return valid;
- }
- }
-
- /**
- * Returns a snapshot of the FlexSessions associated with the FlexClient
- * when this method is invoked.
- * This list is not guaranteed to remain consistent with the actual list
- * of active FlexSessions associated with the FlexClient over time.
- *
- * @return A snapshot of the current list of FlexSessions associated with the FlexClient.
- */
- public List<FlexSession> getFlexSessions()
- {
- List<FlexSession> currentSessions;
- synchronized (lock)
- {
- checkValid();
-
- updateLastUse();
-
- currentSessions = new ArrayList<FlexSession>(sessions); // Make a copy of the current list to return.
- }
- return currentSessions;
- }
-
- /**
- * Return the session count.
- *
- * @return The number of sessions associated with this FlexClient.
- */
- public int getSessionCount()
- {
- int sessionCount;
- synchronized (lock)
- {
- sessionCount = (sessions != null) ? sessions.size() : 0; // Make a copy of the current list to return.
- }
- return sessionCount;
- }
-
- /**
- * Return the subscription count.
- *
- * @return The number of subscriptions associated with this FlexClient.
- */
- public int getSubscriptionCount()
- {
- int count = 0;
- synchronized (lock)
- {
-
- if (messageClients != null && !messageClients.isEmpty())
- {
- for (MessageClient messageClient : messageClients)
- count += messageClient.getSubscriptionCount();
- }
-
- }
- return count;
- }
-
- /**
- * Returns the message client registered with the FlexClient with the supplied
- * client id, or null if no message client was registered with the FlexClient
- * with that client id.
- *
- * @param clientId The client id.
- * @return The message client registered with the FlexClient.
- */
- public MessageClient getMessageClient(String clientId)
- {
- synchronized (lock)
- {
- if (messageClients != null && !messageClients.isEmpty())
- {
- for (MessageClient messageClient : messageClients)
- {
- if (messageClient.getClientId().equals(clientId))
- return messageClient;
- }
- }
- }
- return null;
- }
-
- /**
- * Returns a snapshot of the MessageClients (subscriptions) associated with the FlexClient
- * when this method is invoked.
- * This list is not guaranteed to remain consistent with the actual list
- * of active MessageClients associated with the FlexClient over time.
- *
- * @return A snapshot of the current list of MessageClients associated with the FlexClient.
- */
- public List<MessageClient> getMessageClients()
- {
- List<MessageClient> currentMessageClients;
- synchronized (lock)
- {
- checkValid();
-
- updateLastUse();
-
- currentMessageClients = (messageClients != null) ? new ArrayList<MessageClient>(messageClients) // Make a copy of the current list to return.
- : Collections.<MessageClient>emptyList(); // Return an empty list.
- }
- return currentMessageClients;
- }
-
- /**
- * Returns the unique Id for the FlexClient.
- *
- * @return The unique Id for the FlexClient.
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * @exclude
- * Implements TimeoutCapable.
- * Determine the time, in milliseconds, that this object is allowed to idle
- * before having its timeout method invoked.
- */
- @Override
- public long getTimeoutPeriod()
- {
- return flexClientManager.getFlexClientTimeoutMillis();
- }
-
- /**
- * @exclude
- * Implements MessageClientListener.
- * Handling created events is a no-op.
- *
- * @param messageClient The new MessageClient.
- */
- public void messageClientCreated(MessageClient messageClient) {}
-
- /**
- * @exclude
- * Implements MessageClientListener.
- * Notification that an associated FlexSession was destroyed.
- *
- * @param messageClient The MessageClient that was destroyed.
- */
- public void messageClientDestroyed(MessageClient messageClient)
- {
- unregisterMessageClient(messageClient);
- }
-
- /**
- * @exclude
- * Poll for outbound messages for the FlexClient.
- * This method is only invoked by internal code while processing a client poll request; it
- * is not intended for general public use.
- * Poll requests that trigger this method come from client-side polling channels and the request
- * is not specific to a single Consumer/MessageClient instance so process any queued messages for
- * the specified endpoint across all subscriptions.
- *
- * @param endpointId The Id of the endpoint that received the poll request.
- * @return The flush result including messages to return in the poll response and
- * an optional wait time for the next poll/flush.
- */
- public FlushResult poll(String endpointId)
- {
- EndpointQueue queue = null;
- synchronized (lock)
- {
- checkValid();
-
- queue = outboundQueues.get(endpointId);
-
- if (queue != null)
- return internalPoll(queue);
- }
-
- if (queue == null)
- {
- // Otherwise, the client is not subscribed.
- throwNotSubscribedException(endpointId);
- }
-
- return null;
- }
-
- /**
- * @exclude
- * Poll for outbound messages for the FlexClient and if no messages are available
- * immediately, store a reference to the passed async handler and call back when messages arrive.
- *
- * @param endpointId The Id of the endpoint that received the poll request.
- * @param handler The handler to callback when messages arrive.
- * @param waitIntervalMillis The wait interval in milliseconds for the poll to wait for data to arrive
- * before returning an empty poll response.
- *
- * @return A <tt>TimeoutAbstractObject</tt> representing the asynchronous poll, or <code>null</code>
- * if the poll request was handled immediately because data was available to return.
- */
- public TimeoutAbstractObject pollAsync(String endpointId, AsyncPollHandler handler, long waitIntervalMillis)
- {
- EndpointQueue queue;
- TimeoutAbstractObject asyncPollTask = null;
-
- synchronized (lock)
- {
- checkValid();
-
- queue = outboundQueues.get(endpointId);
-
- // If the queue exists and is not empty, flush immediately.
- if (queue != null)
- {
- if (!queue.messages.isEmpty())
- {
- handler.asyncPollComplete(internalFlush(queue));
- }
- else // Set up an async long-poll.
- {
- // Avoid monopolizing user agent connections.
- FlexSession session = FlexContext.getFlexSession();
- synchronized (session)
- {
- if (session.asyncPollMap != null)
- {
- AsyncPollWithTimeout parkedPoll = session.asyncPollMap.get(endpointId);
- if (parkedPoll != null)
- {
- // If the poll is from the same client for this endpoint, treat it as a no-op.
- if (parkedPoll.getFlexClient().equals(this))
- {
- PollFlushResult result = new PollFlushResult();
- result.setClientProcessingSuppressed(true);
- handler.asyncPollComplete(result);
- }
- else // If the poll is for a different client on the same session, swap their waits.
- {
- PollFlushResult result = new PollFlushResult();
- result.setAvoidBusyPolling(true);
- completeAsyncPoll(parkedPoll, result);
- }
- }
- }
- AsyncPollWithTimeout asyncPoll = new AsyncPollWithTimeout(this, session, queue, handler, waitIntervalMillis, endpointId);
- synchronized (session)
- {
- if (session.asyncPollMap == null)
- session.asyncPollMap = new HashMap<String, AsyncPollWithTimeout>();
- session.asyncPollMap.put(endpointId, asyncPoll);
- }
- queue.asyncPoll = asyncPoll;
- asyncPollTask = asyncPoll;
- }
- }
- }
- }
- if (queue == null)
- {
- // The queue was null; let the client know that there are no active subscriptions.
- throwNotSubscribedException(endpointId);
- }
- return asyncPollTask;
- }
-
- /**
- * @exclude
- * Poll for outbound messages for the FlexClient and if no messages are available
- * immediately, put processing into a wait state until messages arrive.
- * This method is only invoked by internal code while processing a client poll request; it
- * is not intended for general public use.
- * Poll requests that trigger this method come from client-side polling channels and the request
- * is not specific to a single Consumer/MessageClient instance so process any queued messages for
- * the specified endpoint across all subscriptions.
- *
- * @param endpointId The Id of the endpoint that received the poll request.
- * @param session The FlexSession associated with this waitable poll request.
- * @param listener The listener to notify before a wait begins and as soon as one completes.
- * @param waitIntervalMillis The maximum amount of time to wait for messages in milliseconds.
- * @return The flush result including messages to return in the poll response and
- * an optional wait time for the next poll/flush.
- */
- public FlushResult pollWithWait(String endpointId, FlexSession session, PollWaitListener listener, long waitIntervalMillis)
- {
- EndpointQueue queue;
- synchronized (lock)
- {
- checkValid();
-
- queue = outboundQueues.get(endpointId);
-
- // If the queue exists and is not empty there's no reason to wait; flush immediately.
- if (queue != null)
- {
- FlushResult flushResult = internalPoll(queue);
- if (flushResult != null)
- return flushResult;
- }
- }
-
- // The queue exists but it was empty; we can try to wait for messages.
- if (queue != null)
- {
- synchronized (session)
- {
- // Set up the waitMonitor on the session; this is a reference to the queue that the
- // current poll request targets and we use it as a wait/notify monitor.
- // This also lets us prevent busy polling cycles from a single client. If we already have a waited
- // poll request a subsequent poll request is treated as a no-op.
- if (session.waitMonitor != null)
- {
- final EndpointQueue waitingQueue = session.waitMonitor.get(endpointId);
- // If the poll is from the same client swf, and the same endpoint, treat it as a no-op poll.
- if (waitingQueue != null && waitingQueue.flexClient.equals(this))
- {
- PollFlushResult result = new PollFlushResult();
- result.setClientProcessingSuppressed(true);
- return result;
- }
- }
- else
- {
- session.waitMonitor = new HashMap<String, EndpointQueue>();
- }
-
- // Set the waitMonitor for the session to the queue
- // for this poll request before releasing the lock.
- session.waitMonitor.put(endpointId, queue);
- }
-
- // Now that the session references the wait monitor this thread will use to wait we can enter
- // the wait state.
- // -1 wait-interval actually means wait until notified.
- waitIntervalMillis = (waitIntervalMillis == -1) ? 0 : waitIntervalMillis;
- String threadName = Thread.currentThread().getName();
- try
- {
- boolean didWait = false;
- boolean avoidBusyPolling = false;
- synchronized (queue)
- {
- // If the message queue is still empty, wait for a message to be added before invoking flush.
- if (queue.messages.isEmpty())
- {
- reportStatusIfDebug("waiting for new messages to arrive");
-
- didWait = true;
-
- // Tag thread name during the wait.
- Thread currentThread = Thread.currentThread();
- currentThread.setName(threadName + POLL_WAIT_THREAD_NAME_EXTENSION);
-
- if (listener != null)
- listener.waitStart(queue);
-
- queue.waitPoll = true; // Mark the queue as waiting.
-
- queue.wait(waitIntervalMillis);
-
- queue.waitPoll = false; // Unmark the queue as waiting.
-
- // Reset thread name now that the wait is over.
- currentThread.setName(threadName);
-
- if (listener != null)
- listener.waitEnd(queue);
-
- if (queue.avoidBusyPolling)
- {
- avoidBusyPolling = true;
- queue.avoidBusyPolling = false;
- }
- }
- }
-
- synchronized (session)
- {
- if (session.waitMonitor != null)
- {
- session.waitMonitor.remove(endpointId);
- }
- }
-
- if (Log.isDebug())
- {
- if (didWait)
- reportStatusIfDebug("done waiting for new messages to arrive and is flushing the outbound queue");
- else
- reportStatusIfDebug("didn't need to wait and is flushing the outbound queue");
- }
-
- // We need to hold the FlexClient lock to invoke flush.
- FlushResult result;
- synchronized (lock)
- {
- result = internalFlush(queue);
- }
- if (avoidBusyPolling)
- {
- PollFlushResult swappedPollResult = new PollFlushResult();
- if (result != null)
- {
- swappedPollResult.setMessages(result.getMessages());
- swappedPollResult.setNextFlushWaitTimeMillis(result.getNextFlushWaitTimeMillis());
- }
- swappedPollResult.setAvoidBusyPolling(true);
- result = swappedPollResult;
- }
- return result;
- }
- catch (InterruptedException e)
- {
- if (Log.isWarn())
- Log.getLogger(FLEX_CLIENT_LOG_CATEGORY).warn("Poll wait thread '" + threadName + "' for FlexClient with id '" + this.id +
- "' could not finish waiting for new messages to arrive " +
- "because it was interrupted: " + e.toString());
- }
- }
- else
- {
- // The queue was null; let the client know that there are no active subscriptions.
- throwNotSubscribedException(endpointId);
- }
- return null;
- }
-
- private void reportStatusIfDebug(String message)
- {
- String threadName = Thread.currentThread().getName();
- if (Log.isDebug())
- Log.getLogger(FLEX_CLIENT_LOG_CATEGORY).debug("Poll wait thread '" + threadName + "' for FlexClient with id '" + this.id + "' is " + message);
- }
-
- /**
- * @exclude
- * Poll for outbound messages for a specific MessageClient/Consumer.
- * This overload of poll() is only invoked when handling a Consumer.receive() request.
- *
- * @param client The specific MessageClient instance to poll for messages for.
- * @return The flush result including messages to return in the poll response.
- * The nextFlushWaitTimeMillis value is always forced to a value of 0 because
- * Consumer.receive() calls are driven by client code and this setting has no meaning.
- */
- public FlushResult poll(MessageClient client)
- {
- FlushResult flushResult = null;
- String endpointId = client.getEndpointId();
- EndpointQueue queue = null;
- synchronized (lock)
- {
- checkValid();
-
- queue = outboundQueues.get(endpointId);
- if (queue != null)
- {
- try
- {
- flushResult = internalFlush(queue, client);
- }
- catch (RuntimeException e)
- {
- if (Log.isError())
- Log.getLogger(FLEX_CLIENT_LOG_CATEGORY).error("Failed to flush an outbound queue for MessageClient '" + client.getClientId() + "' for FlexClient '" + getId() + "'.", e);
- throw e;
- }
- if (flushResult != null)
- flushResult.setNextFlushWaitTimeMillis(0); // Force to 0.
- }
- }
- if (queue == null)
- {
- throwNotSubscribedException(endpointId);
- }
- return flushResult;
- }
-
- /**
- * @exclude
- * Push a message to the FlexClient.
- * The message is added to the outbound queue of messages for the client and
- * will be pushed if possible or retrieved via a client poll request.
- *
- * @param message The Message to push.
- * @param messageClient The MessageClient subscription that this message targets.
- */
- public void push(Message message, MessageClient messageClient)
- {
- // We should check the message client is valid or not
- if (!isValid())
- return;
-
- // Route this message to the proper per-endpoint outbound queue.
- EndpointQueue queue = outboundQueues.get(messageClient.getEndpointId());
-
- // This queue may be null if all corresponding subscriptions have been invalidated.
- if (queue == null)
- return;
-
- boolean empty;
-
- // We need to obtain the lock here
- // Maintain the pattern of using the FlexClient.lock and ensure that order of locks should always start with the FlexClient.lock
- // This is critical to prevent deadlock cases, see Watson bug 2724938
- synchronized (lock)
- {
- synchronized (queue) // To protect the list during the add and allow for notification.
- {
- // Let the processor add the message to the queue.
- try
- {
- queue.processor.add(queue.messages, message);
- empty = queue.messages.isEmpty();
-
- if (Log.isDebug())
- Log.getLogger(LogCategories.MESSAGE_GENERAL).debug(
- "Queuing message: " + message.getMessageId() +
- StringUtils.NEWLINE +
- " to send to MessageClient: " + messageClient.getClientId() +
- StringUtils.NEWLINE +
- " for FlexClient: " + messageClient.getFlexClient().getId() +
- StringUtils.NEWLINE +
- " via endpoint: " + queue.endpointId +
- StringUtils.NEWLINE +
- " client outbound queue size: " + queue.messages.size());
- }
- catch (RuntimeException e)
- {
- if (Log.isError())
- Log.getLogger(FLEX_CLIENT_LOG_CATEGORY).error("Failed to add a message to an outbound queue for FlexClient '" + getId() + "'.", e);
- throw e;
- }
- // And notify any threads that may be in a poll wait state.
- if (!empty && queue.waitPoll)
- {
- // TODO This updateLastUse call is added here because there used to be a call
- // at the beginning of the push method but not convinced that it is needed.
- updateLastUse();
- queue.notifyAll();
- }
- }
-
- if (!empty)
- {
- if (queue.asyncPoll != null)
- {
- completeAsyncPoll(queue.asyncPoll, internalFlush(queue));
- }
- else if (!empty && queue.flushTask == null &&
- (queue.pushSession != null || (endpointPushHandlers != null && endpointPushHandlers.containsKey(queue.endpointId))))
- {
- // If a delayed flush is not scheduled and we have a push-enabled session associated with the queue
- // or a push-enabled endpoint, try a direct push to the client.
- // Once again we should acquire the lock for queue, otherwise a potential dead lock could happen, see Watson bug 2724936
- // By acquiring the queue lock again, we break the cycle by acquiring the queue before holding FlexClient.lock object
- synchronized (queue)
- {
- directFlush(queue);
- }
- }
- }
- }
- }
-
- /**
- * @exclude
- * Registers an <tt>EndpointPushHandler</tt> for the specified endpoint to handle pushing messages
- * to remote clients.
- *
- * @param handler The <tt>EndpointPushHandler</tt> to register.
- * @param endpointId The endpoint to register for.
- */
- public void registerEndpointPushHandler(EndpointPushHandler handler, String endpointId)
- {
- synchronized (lock)
- {
- if (endpointPushHandlers == null)
- endpointPushHandlers = new HashMap<String, EndpointPushHandler>(1);
-
- if (endpointPushHandlers.containsKey(endpointId))
- {
- MessageException me = new MessageException();
- me.setMessage(ENDPOINT_PUSH_HANDLER_ALREADY_REGISTERED, new Object[] {getId(), endpointId});
- throw me;
- }
-
- endpointPushHandlers.put(endpointId, handler);
- }
- }
-
- /**
- * @exclude
- * Used internally to associate a FlexSession with this FlexClient.
- *
- * @param session The FlexSession to associate with this FlexClient.
- */
- public void registerFlexSession(FlexSession session)
- {
- if (sessions.addIfAbsent(session))
- {
- session.addSessionDestroyedListener(this);
- session.registerFlexClient(this);
- }
- }
-
- /**
- * @exclude
- * Used internally to associate a MessageClient with this FlexClient.
- *
- * @param messageClient The MessageClient to associate with this FlexClient.
- */
- public void registerMessageClient(MessageClient messageClient)
- {
- synchronized (lock)
- {
- if (messageClients == null)
- messageClients = new CopyOnWriteArrayList<MessageClient>();
- }
-
- if (messageClients.addIfAbsent(messageClient))
- {
- messageClient.addMessageClientDestroyedListener(this);
- String endpointId = messageClient.getEndpointId();
- // Manage the outbound queue this MessageClient's subscription(s) will use
- // and associate the MessageClient with an EndpointPushHandler if one exists for the
- // endpoint the subscription was made over; this allows the shut-down of a
- // push connection to invalidate any subscriptions that are using it.
- synchronized (lock)
- {
- getOrCreateEndpointQueueAndRegisterSubscription(messageClient, endpointId);
- if (endpointPushHandlers != null)
- {
- EndpointPushHandler handler = endpointPushHandlers.get(endpointId);
- if (handler != null)
- handler.registerMessageClient(messageClient);
- }
- }
- }
- }
-
- /**
- * Removes the attribute bound to the specified name for the FlexClient.
- *
- * @param name The name of the attribute to remove.
- */
- public void removeAttribute(String name)
- {
- Object value; // Used for event dispatch after the attribute is removed.
-
- synchronized (lock)
- {
- checkValid();
-
- updateLastUse();
-
- value = (attributes != null) ? attributes.remove(name) : null;
- }
-
- // If no value was bound under this name it's a no-op.
- if (value == null)
- return;
-
- notifyAttributeUnbound(name, value);
- notifyAttributeRemoved(name, value);
- }
-
- /**
- * Removes a FlexClient attribute listener.
- *
- * @param listener The listener to remove.
- */
- public void removeClientAttributeListener(FlexClientAttributeListener listener)
- {
- // No need to check validity; removing a listener is always ok.
- if (listener != null && attributeListeners != null)
- attributeListeners.remove(listener);
- }
-
- /**
- * Removes a FlexClient destroyed listener.
- *
- * @see flex.messaging.client.FlexClientListener
- *
- * @param listener The listener to remove.
- */
- public void removeClientDestroyedListener(FlexClientListener listener)
- {
- // No need to check validity; removing a listener is always ok.
- if (listener != null && destroyedListeners != null)
- destroyedListeners.remove(listener);
- }
-
- /**
- * Removes the attribute bound to the specified name for all the FlexSessions
- * associated with the FlexClient.
- *
- * @param name The name of the attribute to remove.
- */
- public void removeSessionAttribute(String name)
- {
- for (FlexSession session : sessions)
- session.removeAttribute(name);
- }
-
- /**
- * @exclude
- * Implements FlexSessionListener interface.
- * Notification that a FlexSession was created.
- * This is a no-op because the FlexClient is never added as a static FlexSession created listener
- * but this method is required by the interface. We only listen for the destroyed event from
- * associated FlexSessions.
- *
- * @param session The FlexSession that was created.
- */
- public void sessionCreated(FlexSession session) {}
-
- /**
- * @exclude
- * Implements FlexSessionListener interface.
- * Notification that an associated FlexSession was destroyed.
- *
- * @param session The FlexSession that was destroyed.
- */
- public void sessionDestroyed(FlexSession session)
- {
- unregisterFlexSession(session);
- }
-
- /**
- * Binds an attribute value for the FlexClient under the specified name.
- *
- * @param name The name to bind the attribute under.
- * @param value The value of the attribute.
- */
- public void setAttribute(String name, Object value)
- {
- // Null value set is the same as removeAttribute().
- if (value == null)
- {
- removeAttribute(name);
- return;
- }
-
- Object oldValue; // Used to determine which events to dispatch after the set is performed.
-
- // Only synchronize for the attribute mutation; event dispatch doesn't require it.
- synchronized (lock)
- {
- checkValid();
-
- updateLastUse();
-
- if (attributes == null)
- attributes = new HashMap<String, Object>();
-
- oldValue = attributes.put(name, value);
- }
-
- if (oldValue == null)
- {
- notifyAttributeBound(name, value);
- notifyAttributeAdded(name, value);
- }
- else
- {
- notifyAttributeUnbound(name, oldValue);
- notifyAttributeReplaced(name, oldValue);
- notifyAttributeBound(name, value);
- }
- }
-
- /**
- * Binds an attribute value for the current FlexSession associated with the
- * FlexClient under the specified name. If the current FlexSession is NIO-based
- * (NIOHTTPFlexSession or RTMPFlexSession), and if the FlexClient is associated
- * with a Servlet-based session (HttpFlexSession) as well, the attribute is bound
- * on the Servlet-based session too to make it available to the underlying J2EE HttpSession.
- *
- * @param name The name to bind the attribute under.
- * @param value The value of the attribute.
- */
- public void setSessionAttribute(String name, Object value)
- {
- setSessionAttributeInCurrentSession(name, value);
- if (!isCurrentSessionServletBased())
- setSessionAttributeInServletBasedSession(name, value);
- }
-
- /**
- * @exclude
- * Implements TimeoutCapable.
- * Inform the object that it has timed out.
- */
- public void timeout()
- {
- invalidate();
- }
-
- /**
- * @exclude
- * Unregisters an <tt>EndpointPushHandler</tt> from the specified endpoint.
- *
- * @param handler The <tt>EndpointPushHandler</tt> to unregister.
- * @param endpointId The endpoint to unregister from.
- */
- public void unregisterEndpointPushHandler(EndpointPushHandler handler, String endpointId)
- {
- synchronized (lock)
- {
- if (endpointPushHandlers == null)
- return; // No-op.
-
- if (endpointPushHandlers.get(endpointId).equals(handler))
- endpointPushHandlers.remove(endpointId);
- }
- }
-
- /**
- * @exclude
- * Used internally to disassociate a FlexSession from this FlexClient.
- *
- * @param session The FlexSession to disassociate from this FlexClient.
- */
- public void unregisterFlexSession(FlexSession session)
- {
- if (sessions.remove(session))
- {
- session.removeSessionDestroyedListener(this);
- session.unregisterFlexClient(this);
- // Once all client sessions/connections terminate; shut down.
- if (sessions.isEmpty())
- invalidate();
- }
- }
-
- /**
- * @exclude
- * Used internally to disassociate a MessageClient (subscription) from a FlexClient.
- *
- * @param messageClient The MessageClient to disassociate from the FlexClient.
- */
- public void unregisterMessageClient(MessageClient messageClient)
- {
- if (messageClients != null && messageClients.remove(messageClient))
- {
- messageClient.removeMessageClientDestroyedListener(this);
- String endpointId = messageClient.getEndpointId();
- // Manage the outbound queue that this subscription uses.
- synchronized (lock)
- {
- EndpointQueue queue = outboundQueues.get(endpointId);
- if (queue != null)
- {
- // Decrement the ref count of MessageClients using this queue.
- queue.messageClientRefCount--;
-
- // Unregister the message client from the outbound throttle
- // manager (if one exists).
- OutboundQueueThrottleManager tm = queue.processor.getOutboundQueueThrottleManager();
- if (tm != null)
- tm.unregisterAllSubscriptions(messageClient.getDestinationId());
-
- // If we're not attempting to notify the remote client that this MessageClient has
- // been invalidated, remove any associated messages from the queue.
- if (!messageClient.isAttemptingInvalidationClientNotification())
- {
- Object messageClientId = messageClient.getClientId();
- for (Iterator<Message> iter = queue.messages.iterator(); iter.hasNext(); )
- {
- Message message = iter.next();
- if (message.getClientId().equals(messageClientId))
- iter.remove();
- }
- }
-
- // If no active subscriptions require the queue, clean it up if possible.
- if (queue.messageClientRefCount == 0)
- {
- if (queue.messages.isEmpty() || messageClient.isClientChannelDisconnected())
- {
- if (queue.asyncPoll != null) // Close out async long-poll if one is registered.
- {
- FlushResult flushResult = internalFlush(queue);
- // If the MessageClient isn't attempting client notification, override
- // and do so in this case to suppress the next poll request from the remote client
- // which will fail triggering an unnecessary channel disconnect on the client.
- if (!messageClient.isAttemptingInvalidationClientNotification())
- {
- CommandMessage msg = new CommandMessage();
- msg.setClientId(messageClient.getClientId());
- msg.setOperation(CommandMessage.SUBSCRIPTION_INVALIDATE_OPERATION);
- List<Message> messages = flushResult.getMessages();
- if (messages == null)
- messages = new ArrayList<Message>(1);
- messages.add(msg);
- }
- completeAsyncPoll(queue.asyncPoll, flushResult);
- }
-
- // Remove the empty, unused queue.
- outboundQueues.remove(endpointId);
- }
- // Otherwise, the queue is being used by a polling client or contains messages
- // that will be written by a delayed flush.
- // Leave it in place. Once the next poll request or delayed flush occurs the
- // queue will be cleaned up at that point. See internalFlush() and shutdownQueue().
- }
-
- // Make sure to notify any threads waiting on this queue that may be associated
- // with the subscription that's gone away.
- synchronized (queue)
- {
- queue.notifyAll();
- }
- }
- // And if this subscription was associated with an endpoint push handler, unregister it.
- if (endpointPushHandlers != null)
- {
- EndpointPushHandler handler = endpointPushHandlers.get(endpointId);
- if (handler != null)
- handler.unregisterMessageClient(messageClient);
- }
- }
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Utility method that tests validity and throws an exception if the instance
- * has been invalidated.
- */
- protected void checkValid()
- {
- synchronized (lock)
- {
- if (!valid)
- {
- MessageException e = new MessageException();
- e.setMessage(FLEX_CLIENT_INVALIDATED);
- throw e;
- }
- }
- }
-
- /**
- * Invoked to clean up a timed out or closed async poll.
- *
- * @param asyncPoll The async poll to complete.
- * @param result The FlushResult for the poll response.
- */
- protected void completeAsyncPoll(AsyncPollWithTimeout asyncPoll, FlushResult result)
- {
- synchronized (lock)
- {
- asyncPoll.cancelTimeout();
- EndpointQueue queue = asyncPoll.getEndpointQueue();
- if (queue.asyncPoll.equals(asyncPoll))
- queue.asyncPoll = null;
- FlexSession session = asyncPoll.getFlexSession();
- synchronized (session)
- {
- if (session.asyncPollMap != null)
- session.asyncPollMap.remove(asyncPoll.getEndpointId());
- }
- asyncPoll.getHandler().asyncPollComplete(result);
- }
- }
-
- /**
- * Invoked to flush queued outbound messages to a client directly using a session
- * that supports real-time push.
- * Called by push() or delayed flush tasks for push-enabled sessions/connections.
- */
- protected void directFlush(EndpointQueue queue)
- {
- synchronized (lock)
- {
- // No need to invoke flush if the FlexClient has been invalidated.
- if (!valid)
- return;
-
- // If this invocation is a callback from a flush task, null out the task ref on
- // the queue to allow a subsequent delayed flush to be scheduled.
- if (queue.flushTask != null)
- queue.flushTask = null;
-
- FlushResult flushResult = internalFlush(queue, null, false /* updateLastUse */);
- if (flushResult == null) // If there's no flush result, return.
- return;
-
- // Pass any messages that are ready to flush off to the network layer.
- List<Message> messages = flushResult.getMessages();
- if (messages != null && !messages.isEmpty())
- {
- if (queue.pushSession != null)
- {
- if (queue.pushSession instanceof ConnectionAwareSession)
- {
- // Update last use only if we're actually writing back to the client.
- if ( ((ConnectionAwareSession)queue.pushSession).isConnected() )
- updateLastUse();
- }
- for (Message msg : messages)
- queue.pushSession.push(msg);
- }
- else if (endpointPushHandlers != null)
- {
- updateLastUse();
- EndpointPushHandler handler = endpointPushHandlers.get(queue.endpointId);
- handler.pushMessages(messages);
- }
- }
-
- // Schedule a delayed flush if necessary.
- int flushWaitTime = flushResult.getNextFlushWaitTimeMillis();
- if (flushWaitTime > 0) // Set up and schedule the delayed flush task.
- queue.flushTask = new FlexClientScheduledFlushForPush(queue, flushWaitTime);
- }
- }
-
- /**
- * Utility method to initialize an EndpointQueue (if necessary) and associate a subscription (MessageClient) with it.
- */
- protected EndpointQueue getOrCreateEndpointQueueAndRegisterSubscription(MessageClient messageClient, String endpointId)
- {
- EndpointQueue newQueue;
- if (!outboundQueues.containsKey(endpointId))
- {
- newQueue = new EndpointQueue();
- newQueue.flexClient = this;
- newQueue.endpointId = endpointId;
- newQueue.endpoint = flexClientManager.getMessageBroker().getEndpoint(endpointId);
- newQueue.messages = new ArrayList<Message>(); /* Default size of 10 is fine */
- FlexSession session = messageClient.getFlexSession();
- if (session.isPushSupported())
- newQueue.pushSession = session;
- newQueue.processor = flexClientManager.createOutboundQueueProcessor(this, endpointId);
- newQueue.messageClientRefCount = 1;
-
- outboundQueues.put(endpointId, newQueue);
- }
- else
- {
- newQueue = outboundQueues.get(endpointId);
- newQueue.messageClientRefCount++;
- // Resubscribes as a result of network connectivity issues may arrive over the same
- // endpoint but use a new session.
- FlexSession session = messageClient.getFlexSession();
- if (session.isPushSupported())
- newQueue.pushSession = session;
- }
- return newQueue;
- }
-
- /**
- * Utility method to flush the outbound queue and log any problems.
- * Any exceptions are logged and then rethrown.
- *
- * @param queue The outbound queue to flush.
- */
- protected FlushResult internalFlush(EndpointQueue queue)
- {
- return internalFlush(queue, null);
- }
-
- /**
- * Utility method to flush the outbound queue and log any problems.
- * If a specific client is passed, we need to invoke a client-specific flush.
- * If the passed client is null, we do a general flush of the queue.
- * Any exceptions are logged and then rethrown.
- *
- * @param queue The outbound queue to flush.
- * @param client The client to flush for.
- */
- protected FlushResult internalFlush(EndpointQueue queue, MessageClient client)
- {
- return internalFlush(queue, null, true);
- }
-
- /**
- * Utility method to flush the outbound queue and log any problems.
- * If a specific client is passed, we need to invoke a client-specific flush.
- * If the passed client is null, we do a general flush of the queue.
- * Any exceptions are logged and then rethrown.
- *
- * @param queue The outbound queue to flush.
- * @param client The client to flush for.
- * @param updateLastUse Whether the last-use timestamp of the FlexClient should
- * be updated.
- */
- protected FlushResult internalFlush(EndpointQueue queue, MessageClient client,
- boolean updateLastUse)
- {
- FlushResult flushResult;
- try
- {
- synchronized (queue)
- {
- flushResult = queue.processor.flush(client, queue.messages);
- shutdownQueue(queue);
- }
-
- if (updateLastUse)
- updateLastUseIfNecessary(flushResult);
- }
- catch (RuntimeException e)
- {
- if (Log.isError())
- Log.getLogger(FLEX_CLIENT_LOG_CATEGORY).error("Failed to flush an outbound queue for FlexClient '" + getId() + "'.", e);
- throw e;
- }
- return flushResult;
- }
-
- /**
- * Utility method to flush messages in response to a poll request with
- * regular and wait poll.
- *
- * @param queue The endpoint queue to flush messages for.
- * @return The flush result with messages, or null if there are no messages.
- */
- protected FlushResult internalPoll(EndpointQueue queue)
- {
- List<Message> allMessages = new ArrayList<Message>();
-
- // First, add the previously flushed messages.
- if (queue.flushedMessagesBetweenPolls != null && queue.flushedMessagesBetweenPolls.size() > 0)
- {
- allMessages.addAll(queue.flushedMessagesBetweenPolls);
- queue.flushedMessagesBetweenPolls.clear();
- }
-
- // Then, check for regularly queued messages. We call internalFlush
- // even if the queue is empty so the queue processor could know
- // about the incoming poll request regardless.
- FlushResult internalFlushResult = internalFlush(queue);
- List<Message> flushedMessages = internalFlushResult.getMessages();
- if (flushedMessages != null && !flushedMessages.isEmpty())
- allMessages.addAll(flushedMessages);
-
- // Schedule a delayed flush, if necessary.
- int flushWaitTime = internalFlushResult.getNextFlushWaitTimeMillis();
- if (flushWaitTime > 0)
- queue.flushTask = new FlexClientScheduledFlushForPoll(queue, flushWaitTime);
-
- if (allMessages.size() > 0) // Flush, if there are messages.
- {
- FlushResult flushResult = new FlushResult();
- flushResult.setMessages(allMessages);
- return flushResult;
- }
- return null;
- }
-
- /**
- * Notify attribute listeners that an attribute has been added.
- *
- * @param name The name of the attribute.
- *
- * @param value The new value of the attribute.
- */
- protected void notifyAttributeAdded(String name, Object value)
- {
- if (attributeListeners != null && !attributeListeners.isEmpty())
- {
- FlexClientBindingEvent event = new FlexClientBindingEvent(this, name, value);
- // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
- for (FlexClientAttributeListener attribListener : attributeListeners)
- attribListener.attributeAdded(event);
- }
- }
-
- /**
- * Notify binding listener that it has been bound to the FlexClient.
- *
- * @param name The attribute name.
- *
- * @param value The attribute that has been bound.
- */
- protected void notifyAttributeBound(String name, Object value)
- {
- if ((value != null) && (value instanceof FlexClientBindingListener))
- {
- FlexClientBindingEvent bindingEvent = new FlexClientBindingEvent(this, name);
- ((FlexClientBindingListener)value).valueBound(bindingEvent);
- }
- }
-
- /**
- * Notify attribute listeners that an attribute has been removed.
- *
- * @param name The name of the attribute.
- *
- * @param value The previous value of the attribute.
- */
- protected void notifyAttributeRemoved(String name, Object value)
- {
- if (attributeListeners != null && !attributeListeners.isEmpty())
- {
- FlexClientBindingEvent event = new FlexClientBindingEvent(this, name, value);
- // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
- for (FlexClientAttributeListener attribListener : attributeListeners)
- attribListener.attributeRemoved(event);
- }
- }
-
- /**
- * Notify attribute listeners that an attribute has been replaced.
- *
- * @param name The name of the attribute.
- *
- * @param value The previous value of the attribute.
- */
- protected void notifyAttributeReplaced(String name, Object value)
- {
- if (attributeListeners != null && !attributeListeners.isEmpty())
- {
- FlexClientBindingEvent event = new FlexClientBindingEvent(this, name, value);
- // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
- for (FlexClientAttributeListener attribListener : attributeListeners)
- attribListener.attributeReplaced(event);
- }
- }
-
- /**
- * Notify binding listener that it has been unbound from the FlexClient.
- *
- * @param name The attribute name.
- *
- * @param value The attribute that has been unbound.
- */
- protected void notifyAttributeUnbound(String name, Object value)
- {
- if ((value != null) && (value instanceof FlexClientBindingListener))
- {
- FlexClientBindingEvent bindingEvent = new FlexClientBindingEvent(this, name);
- ((FlexClientBindingListener)value).valueUnbound(bindingEvent);
- }
- }
-
- /**
- * Invoked by FlexClientManager after this new FlexClient has been constructed and
- * is fully configured.
- */
- protected void notifyCreated()
- {
- if (!createdListeners.isEmpty())
- {
- // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
- for (FlexClientListener createListener : createdListeners)
- createListener.clientCreated(this);
- }
- }
-
- /**
- * Utility method used to shutdown endpoint queues accessed via polling channels
- * that have no more active subscriptions and no more pending outbound messages.
- *
- * @param queue The queue to potentially shutdown.
- * @return true if the queue was cleaned up/removed; otherwise false.
- */
- protected boolean shutdownQueue(EndpointQueue queue)
- {
- // If no more subscriptions are using the queue and it is empty, shut it down.
- if (queue.messageClientRefCount == 0 && queue.messages.isEmpty())
- {
- outboundQueues.remove(queue.endpointId);
- // Notify any threads waiting on this queue.
- synchronized (queue)
- {
- queue.notifyAll();
- }
- return true;
- }
- return false;
- }
-
- /**
- * Utility method to throw a not subscribed exception back to the client
- * if they issue a poll request to an endpoint that they haven't subscribed over.
- * <p/>
- * This method should not be called when you hold an internal thread lock. It iterates
- * over all the FlexClients in the current session and will not work if two or more
- * FlexClients in the same session call it simultaneously.
- *
- * @param endpointId The endpoint Id.
- */
- protected void throwNotSubscribedException(String endpointId)
- {
- // Pre-3.1 versions of the client library did not handle URL session tokens properly
- // and may incorrectly issue a poll, after subscribing, that does not contain the proper
- // FlexClient id.
- // This scenario looks like a poll from a client that is not subscribed, but it is not,
- // and deserves a more useful error message.
- // We determine this by checking for an (orphaned) FlexClient instance associated with the
- // current session that has a subscription established through the target endpoint.
- List<FlexClient> flexClients = FlexContext.getFlexSession().getFlexClients();
- for (FlexClient otherClient : flexClients)
- {
- if (!otherClient.equals(this))
- {
- List<MessageClient> otherSubs = otherClient.getMessageClients();
- for (MessageClient otherSub : otherSubs)
- {
- if (otherSub.getEndpointId().equals(endpointId))
- {
- // Throw not-subscribed exception with extra guidance.
- FlexClientNotSubscribedException e = new FlexClientNotSubscribedException();
- e.setMessage(10036, new Object[]{endpointId});
- e.setCode(MessageService.NOT_SUBSCRIBED_CODE);
- throw e;
- }
- }
- }
- }
-
- // Throw general not-subscribed exception.
- FlexClientNotSubscribedException e = new FlexClientNotSubscribedException();
- e.setMessage(10028, new Object[]{endpointId});
- e.setCode(MessageService.NOT_SUBSCRIBED_CODE);
- throw e;
- }
-
- /**
- * Updates the last-use timestamp if there are messages in the flush result.
- *
- * @param flushResult The flush result.
- */
- protected void updateLastUseIfNecessary(FlushResult flushResult)
- {
- List<Message> messages = flushResult != null ? flushResult.getMessages() : null;
- if (messages != null && !messages.isEmpty())
- updateLastUse();
- }
-
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
-
- private Set<String> getSessionAttributeNames(FlexSession session)
- {
- Set<String> attributeNames = new HashSet<String>();
- Enumeration<String> currentAttributeNames = session.getAttributeNames();
- while (currentAttributeNames.hasMoreElements())
- attributeNames.add(currentAttributeNames.nextElement());
- return attributeNames;
- }
-
- private Object getSessionAttributeInCurrentSession(String name)
- {
- return FlexContext.getFlexSession().getAttribute(name);
- }
-
- private Object getSessionAttributeInOtherSessions(String name)
- {
- FlexSession currentSession = FlexContext.getFlexSession();
- for (FlexSession session : sessions)
- {
- if (session == currentSession)
- continue;
-
- Object attributeValue = session.getAttribute(name);
- if (attributeValue != null)
- return attributeValue;
- }
- return null;
- }
-
- private void setSessionAttributeInCurrentSession(String name, Object value)
- {
- FlexContext.getFlexSession().setAttribute(name, value);
- }
-
- private void setSessionAttributeInServletBasedSession(String name, Object value)
- {
- for (FlexSession session : sessions)
- {
- if (isServletBasedSession(session))
- {
- session.setAttribute(name, value);
- return;
- }
- }
- }
-
- private boolean isCurrentSessionServletBased()
- {
- return isServletBasedSession(FlexContext.getFlexSession());
- }
-
- private boolean isServletBasedSession(FlexSession session)
- {
- return session instanceof HttpFlexSession;
- }
-
- //--------------------------------------------------------------------------
- //
- // Inner Classes
- //
- //--------------------------------------------------------------------------
-
- /**
- * Helper class for handling async poll requests. This class allows the response for an async poll
- * to be delayed until data arrives to return to the client or the specified wait interval elapses.
- * Wait timeouts are monitored by the <tt>FlexClientManager</tt> which contains a <tt>TimeoutManager</tt>
- * instance that is started and stopped during application bootstrap and shutdown. Managing timeouts
- * locally or statically isn't a good option because they lack a useful shutdown hook that's necessary
- * in order to close down the timeout manager cleanly.
- */
- public class AsyncPollWithTimeout extends TimeoutAbstractObject
- {
- /**
- * Constructor.
- *
- * @param flexClient flex client
- * @param session flex session
- * @param queue endpoint queue
- * @param handler poll handler
- * @param waitIntervalMillis wait interval
- * @param endpointId endpoint
- */
- public AsyncPollWithTimeout(FlexClient flexClient, FlexSession session, EndpointQueue queue, AsyncPollHandler handler, long waitIntervalMillis, String endpointId)
- {
- this.flexClient = flexClient;
- this.session = session;
- this.queue = queue;
- this.handler = handler;
- setTimeoutPeriod(waitIntervalMillis);
- flexClientManager.monitorAsyncPollTimeout(this);
- this.endpointId = endpointId;
- }
-
- private final FlexClient flexClient;
-
- /**
- * Return client.
- *
- * @return flex client
- */
- public FlexClient getFlexClient()
- {
- return flexClient;
- }
-
- private final FlexSession session;
-
- /**
- * Return session.
- * @return flex session
- */
- public FlexSession getFlexSession()
- {
- return session;
- }
-
- private final EndpointQueue queue;
-
- /**
- * Return endpoint queue.
- * @return the queue
- */
- public EndpointQueue getEndpointQueue()
- {
- return queue;
- }
-
- private final AsyncPollHandler handler;
-
- /**
- * Return handler.
- * @return the handler
- */
- public AsyncPollHandler getHandler()
- {
- return handler;
- }
-
- private final String endpointId;
-
- /**
- * Return endpoint ID.
- * @return the id
- */
- public String getEndpointId()
- {
- return endpointId;
- }
-
- /**
- * Trigger a timeout.
- */
- public void timeout()
- {
- completeAsyncPoll(this, null /* nothing to return */);
- }
- }
-
- /**
- * Helper class to flush a FlexClient's outbound queue after a specified delay.
- * Delayed flushes are handled by the <tt>FlexClientManager</tt>
- * using <tt>TimeoutManager</tt>.
- */
- abstract class FlexClientScheduledFlush extends TimeoutAbstractObject
- {
- final EndpointQueue queue;
-
- public FlexClientScheduledFlush(EndpointQueue queue, long waitIntervalMillis)
- {
- this.queue = queue;
- setTimeoutPeriod(waitIntervalMillis);
- flexClientManager.monitorScheduledFlush(this);
- }
-
- abstract void performFlushTask();
-
- public void timeout()
- {
- FlexContext.setThreadLocalFlexClient(FlexClient.this);
- performFlushTask();
- FlexContext.setThreadLocalFlexClient(null);
- }
- }
-
- /**
- * Helper class for push channels to directly flush a FlexClient's outbound
- * queue after a specified delay.
- */
- class FlexClientScheduledFlushForPush extends FlexClientScheduledFlush
- {
- public FlexClientScheduledFlushForPush(EndpointQueue queue, long waitIntervalMillis)
- {
- super(queue, waitIntervalMillis);
- }
-
- @Override
- void performFlushTask()
- {
- synchronized (lock)
- {
- synchronized (queue)
- {
- directFlush(queue);
- }
- }
- }
-
- }
-
- /**
- * Helper class for polling channels to flush a FlexClient's outbound
- * queue to flushedMessagesBetweenPolls queue after a specified delay.
- * When the next poll happens, the flushedMessagesBetweenPolls will be
- * drained first.
- */
- class FlexClientScheduledFlushForPoll extends FlexClientScheduledFlush
- {
- public FlexClientScheduledFlushForPoll(EndpointQueue queue, long waitIntervalMillis)
- {
- super(queue, waitIntervalMillis);
- }
-
- @Override
- void performFlushTask()
- {
- synchronized (lock)
- {
- // No need to invoke flush if the FlexClient has been invalidated.
- if (!valid)
- return;
-
- // If this invocation is a callback from a flush task, null out the task ref on
- // the queue to allow a subsequent delayed flush to be scheduled.
- if (queue.flushTask != null)
- queue.flushTask = null;
-
- FlushResult flushResult = internalFlush(queue);
- if (flushResult == null)
- return;
-
- List<Message> messages = flushResult.getMessages();
- if (messages != null && messages.size() > 0)
- {
- if (queue.asyncPoll != null)
- {
- completeAsyncPoll(queue.asyncPoll, flushResult);
- }
- else
- {
- if (queue.flushedMessagesBetweenPolls == null)
- queue.flushedMessagesBetweenPolls = new ArrayList<Message>();
- queue.flushedMessagesBetweenPolls.addAll(messages);
- }
- }
-
- // Schedule a delayed flush, if necessary.
- int flushWaitTime = flushResult.getNextFlushWaitTimeMillis();
- if (flushWaitTime > 0)
- queue.flushTask = new FlexClientScheduledFlushForPoll(queue, flushWaitTime);
- }
- }
- }
-
- /**
- * @exclude
- * Helper class that stores per-endpoint outbound queue state including:
- * <ul>
- * <li>flexClient - The <tt>FlexClient</tt> the queue is used by.</li>
- * <li>messages - The outbound queue of messages for the endpoint.</li>
- * <li>flushedMessagesBetweenPolls - Keeps track of flushed (more precisely
- * drained buffered) messages between polls. A seperate list is needed
- * from messages list to avoid regular flush handling.</li>
- * <li>flushedMessagesBetweenPolls - Keeps track of flushed messages between polls.</li>
- * <li>processor - The processor that handles adding messages to the queue as well as flushing
- * them to the network.</li>
- * <li>asyncPoll - The async poll to timeout or callback when messages arrive
- * (null if the endpoint or session supports direct push).</li>
- * <li>pushSession - A reference to a pushSession to use for direct writes to the
- * client (null if the endpoint uses polling or handles push directly).</li>
- *
- * <li>flushTask - A reference to a pending flush task that will perform a delayed flush of the queue;
- * null if no delayed flush has been scheduled.</li>
- * <li>messageClientRefCount - A reference count of MessageClients subcribed over this endpoint.
- * Once all MessageClients unsubscribe this queue can be shut down.</li>
- * <li>avoidBusyPolling - Used to signal poll result generation for the queue to avoid busy polling.</li>
- * </ul>
- */
- public static class EndpointQueue
- {
- public FlexClient flexClient;
- public String endpointId;
- public Endpoint endpoint;
- public List<Message> messages;
- public List<Message> flushedMessagesBetweenPolls;
- public FlexClientOutboundQueueProcessor processor;
- public AsyncPollWithTimeout asyncPoll;
- public boolean waitPoll;
- public FlexSession pushSession;
- public TimeoutAbstractObject flushTask;
- public int messageClientRefCount;
- public boolean avoidBusyPolling;
- }
-}
+/*
+ * 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;
+
+import flex.messaging.ConnectionAwareSession;
+import flex.messaging.FlexContext;
+import flex.messaging.FlexSession;
+import flex.messaging.FlexSessionListener;
+import flex.messaging.HttpFlexSession;
+import flex.messaging.MessageClient;
+import flex.messaging.MessageClientListener;
+import flex.messaging.MessageException;
+import flex.messaging.endpoints.Endpoint;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.messages.CommandMessage;
+import flex.
<TRUNCATED>
[10/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/endpoints/BaseHTTPEndpoint.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/endpoints/BaseHTTPEndpoint.java b/modules/core/src/flex/messaging/endpoints/BaseHTTPEndpoint.java
old mode 100755
new mode 100644
index 71fb829..5dbf48f
--- a/modules/core/src/flex/messaging/endpoints/BaseHTTPEndpoint.java
+++ b/modules/core/src/flex/messaging/endpoints/BaseHTTPEndpoint.java
@@ -1,636 +1,636 @@
-/*
- * 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.endpoints;
-
-import flex.management.runtime.messaging.endpoints.EndpointControl;
-import flex.messaging.FlexContext;
-import flex.messaging.FlexSession;
-import flex.messaging.HttpFlexSession;
-import flex.messaging.MessageClient;
-import flex.messaging.client.FlexClient;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.ConfigurationConstants;
-import flex.messaging.endpoints.amf.AMFFilter;
-import flex.messaging.io.MessageIOConstants;
-import flex.messaging.io.amf.ActionContext;
-import flex.messaging.log.HTTPRequestLog;
-import flex.messaging.messages.CommandMessage;
-import flex.messaging.messages.Message;
-import flex.messaging.util.SettingsReplaceUtil;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Abstract base class for all the HTTP-based endpoints.
- */
-public abstract class BaseHTTPEndpoint extends AbstractEndpoint
-{
- //--------------------------------------------------------------------------
- //
- // Public Static Constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * The secure and insecure URL schemes for the HTTP endpoint.
- */
- public static final String HTTP_PROTOCOL_SCHEME = "http";
- public static final String HTTPS_PROTOCOL_SCHEME = "https";
-
- //--------------------------------------------------------------------------
- //
- // Private Static Constants
- //
- //--------------------------------------------------------------------------
-
- private static final String ADD_NO_CACHE_HEADERS = "add-no-cache-headers";
- private static final String REDIRECT_URL = "redirect-url";
- private static final String INVALIDATE_SESSION_ON_DISCONNECT = "invalidate-session-on-disconnect";
- private static final String HTTP_RESPONSE_HEADERS = "http-response-headers";
- private static final String HEADER_ATTR = "header";
-
- private static final String HEADER_NAME_ORIGIN = "Origin";
- private static final String ACCESS_CONTROL = "Access-Control-";
- private static final String SESSION_REWRITING_ENABLED = "session-rewriting-enabled";
-
- private static final int ERR_MSG_DUPLICATE_SESSIONS_DETECTED = 10035;
- private static final String REQUEST_ATTR_DUPLICATE_SESSION_FLAG = "flex.messaging.request.DuplicateSessionDetected";
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an unmanaged <code>BaseHTTPEndpoint</code>.
- */
- public BaseHTTPEndpoint()
- {
- this(false);
- }
-
- /**
- * Constructs a <code>BaseHTTPEndpoint</code> with the specified management setting.
- *
- * @param enableManagement <code>true</code> if the <code>BaseHTTPEndpoint</code>
- * is manageable; otherwise <code>false</code>.
- */
- public BaseHTTPEndpoint(boolean enableManagement)
- {
- super(enableManagement);
- }
-
- //--------------------------------------------------------------------------
- //
- // Initialize, validate, start, and stop methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes the <code>Endpoint</code> with the properties.
- * If subclasses override this method, they must call <code>super.initialize()</code>.
- *
- * @param id The ID of the <code>Endpoint</code>.
- * @param properties Properties for the <code>Endpoint</code>.
- */
- @Override public void initialize(String id, ConfigMap properties)
- {
- super.initialize(id, properties);
-
- if (properties == null || properties.size() == 0)
- return;
-
- // General HTTP props.
- addNoCacheHeaders = properties.getPropertyAsBoolean(ADD_NO_CACHE_HEADERS, true);
- redirectURL = properties.getPropertyAsString(REDIRECT_URL, null);
- invalidateSessionOnDisconnect = properties.getPropertyAsBoolean(INVALIDATE_SESSION_ON_DISCONNECT, false);
- loginAfterDisconnect = properties.getPropertyAsBoolean(ConfigurationConstants.LOGIN_AFTER_DISCONNECT_ELEMENT, false);
- sessionRewritingEnabled = properties.getPropertyAsBoolean(SESSION_REWRITING_ENABLED, true);
- initializeHttpResponseHeaders(properties);
- validateEndpointProtocol();
- }
-
- /**
- * Starts the <code>Endpoint</code> by creating a filter chain and setting
- * up serializers and deserializers.
- */
- @Override public void start()
- {
- if (isStarted())
- return;
-
- super.start();
-
- filterChain = createFilterChain();
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Controller used to manage this endpoint.
- */
- protected EndpointControl controller;
-
- /**
- * AMF processing filter chain used by this endpoint.
- */
- protected AMFFilter filterChain;
-
- /**
- * Headers to add to the HTTP response.
- */
- protected List<HttpHeader> httpResponseHeaders;
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // addNoCacheHeaders
- //----------------------------------
-
- protected boolean addNoCacheHeaders = true;
-
- /**
- * Retrieves the <code>add-no-cache-headers</code> property.
- *
- * @return <code>true</code> if <code>add-no-cache-headers</code> is enabled;
- * <code>false</code> otherwise.
- */
- public boolean isAddNoCacheHeaders()
- {
- return addNoCacheHeaders;
- }
-
- /**
- * Sets the <code>add-no-cache-headers</code> property.
- *
- * @param addNoCacheHeaders The <code>add-no-cache-headers</code> property.
- */
- public void setAddNoCacheHeaders(boolean addNoCacheHeaders)
- {
- this.addNoCacheHeaders = addNoCacheHeaders;
- }
-
- //----------------------------------
- // loginAfterDisconnect
- //----------------------------------
-
- /**
- * @exclude
- * This is a property used on the client.
- */
- protected boolean loginAfterDisconnect;
-
- //----------------------------------
- // invalidateSessionOnDisconnect
- //----------------------------------
-
- protected boolean invalidateSessionOnDisconnect;
-
- /**
- * Indicates whether the server session will be invalidated
- * when a client channel disconnects.
- * The default is <code>false</code>.
- *
- * @return <code>true</code> if the server session will be invalidated
- * when a client channel disconnects, <code>false</code> otherwise.
- */
- public boolean isInvalidateSessionOnDisconnect()
- {
- return invalidateSessionOnDisconnect;
- }
-
- /**
- * Determines whether to invalidate the server session for a client
- * that disconnects its channel.
- * The default is <code>false</code>.
- *
- * @param value <code>true</code> to invalidate the server session for a client
- * that disconnects its channel, <code>false</code> otherwise.
- */
- public void setInvalidateSessionOnDisconnect(boolean value)
- {
- invalidateSessionOnDisconnect = value;
- }
-
- //----------------------------------
- // redirectURL
- //----------------------------------
-
- protected String redirectURL;
-
- /**
- * Retrieves the <code>redirect-url</code> property.
- *
- * @return The <code>redirect-url</code> property.
- */
- public String getRedirectURL()
- {
- return redirectURL;
- }
-
- /**
- * Sets the <code>redirect-url</code> property.
- *
- * @param redirectURL The <code>redirect-url</code> property.
- */
- public void setRedirectURL(String redirectURL)
- {
- this.redirectURL = redirectURL;
- }
-
- //----------------------------------
- // sessionRewritingEnabled
- //----------------------------------
-
- protected boolean sessionRewritingEnabled = true;
-
- /**
- * Indicates whether the server will fall back on rewriting URLs to include
- * session identifiers in the URL when HTTP session cookies are not allowed
- * on the client. The default is <code>true</code>.
- *
- * @return <code>true</code> if the session rewriting is enabled.
- */
- public boolean isSessionRewritingEnabled()
- {
- return sessionRewritingEnabled;
- }
-
- /**
- * Sets whether the session rewriting is enabled.
- *
- * @param value The session writing enabled value.
- */
- public void setSessionRewritingEnabled(boolean value)
- {
- sessionRewritingEnabled = value;
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Handle AMF/AMFX encoded messages sent over HTTP.
- *
- * @param req The original servlet request.
- * @param res The active servlet response.
- */
- @Override
- public void service(HttpServletRequest req, HttpServletResponse res)
- {
- super.service(req, res);
-
- try
- {
- // Setup serialization and type marshalling contexts
- setThreadLocals();
-
- // Create a context for this request
- ActionContext context = new ActionContext();
-
- // Pass endpoint's mpi settings to the context so that it knows what level of
- // performance metrics should be gathered during serialization/deserialization
- context.setRecordMessageSizes(isRecordMessageSizes());
- context.setRecordMessageTimes(isRecordMessageTimes());
-
- // Send invocation through filter chain, which ends at the MessageBroker
- filterChain.invoke(context);
-
- // After serialization completes, increment endpoint byte counters,
- // if the endpoint is managed
- if (isManaged())
- {
- controller.addToBytesDeserialized(context.getDeserializedBytes());
- controller.addToBytesSerialized(context.getSerializedBytes());
- }
-
- if (context.getStatus() != MessageIOConstants.STATUS_NOTAMF)
- {
- if (addNoCacheHeaders)
- addNoCacheHeaders(req, res);
-
- addHeadersToResponse(req, res);
-
- ByteArrayOutputStream outBuffer = context.getResponseOutput();
-
- res.setContentType(getResponseContentType());
-
- res.setContentLength(outBuffer.size());
- outBuffer.writeTo(res.getOutputStream());
- res.flushBuffer();
- }
- else
- {
- // Not an AMF request, probably viewed in a browser
- if (redirectURL != null)
- {
- try
- {
- //Check for redirect URL context-root token
- redirectURL = SettingsReplaceUtil.replaceContextPath(redirectURL, req.getContextPath());
- res.sendRedirect(redirectURL);
- }
- catch (IllegalStateException alreadyFlushed)
- {
- // ignore
- }
- }
- }
- }
- catch (IOException ioe)
- {
- // This happens when client closes the connection, log it at info level
- log.info(ioe.getMessage());
- // Store exception information for latter logging
- req.setAttribute(HTTPRequestLog.HTTP_ERROR_INFO, ioe.toString());
- }
- catch (Throwable t)
- {
- log.error(t.getMessage(), t);
- // Store exception information for latter logging
- req.setAttribute(HTTPRequestLog.HTTP_ERROR_INFO, t.toString());
- }
- finally
- {
- clearThreadLocals();
- }
- }
-
-
- /**
- * @exclude
- * Returns a <code>ConfigMap</code> of endpoint properties that the client
- * needs. This includes properties from <code>super.describeEndpoint</code>
- * and additional <code>BaseHTTPEndpoint</code> specific properties under
- * "properties" key.
- */
- @Override
- public ConfigMap describeEndpoint()
- {
- ConfigMap endpointConfig = super.describeEndpoint();
-
- if (loginAfterDisconnect)
- {
- ConfigMap loginAfterDisconnect = new ConfigMap();
- // Adding as a value rather than attribute to the parent
- loginAfterDisconnect.addProperty(EMPTY_STRING, TRUE_STRING);
-
- ConfigMap properties = endpointConfig.getPropertyAsMap(PROPERTIES_ELEMENT, null);
- if (properties == null)
- {
- properties = new ConfigMap();
- endpointConfig.addProperty(PROPERTIES_ELEMENT, properties);
- }
- properties.addProperty(ConfigurationConstants.LOGIN_AFTER_DISCONNECT_ELEMENT, loginAfterDisconnect);
- }
-
- return endpointConfig;
- }
-
- /**
- * Overrides to guard against duplicate HTTP-based sessions for the same FlexClient
- * which will occur if the remote host has disabled session cookies.
- *
- * @see AbstractEndpoint#setupFlexClient(String)
- */
- @Override
- public FlexClient setupFlexClient(String id)
- {
- FlexClient flexClient = super.setupFlexClient(id);
-
- // Scan for duplicate HTTP-sessions and if found, invalidate them and throw a MessageException.
- // A request attribute is used to deal with batched AMF messages that arrive in a single request by trigger multiple passes through this method.
- boolean duplicateSessionDetected = (FlexContext.getHttpRequest().getAttribute(REQUEST_ATTR_DUPLICATE_SESSION_FLAG) != null);
-
- List<FlexSession> sessions = null;
- if (!duplicateSessionDetected)
- {
- sessions = flexClient.getFlexSessions();
- int n = sessions.size();
- if (n > 1)
- {
- List<HttpFlexSession> httpFlexSessions = new ArrayList<HttpFlexSession>();
- for (int i = 0; i < n; i++)
- {
- FlexSession currentSession = sessions.get(i);
- if (currentSession instanceof HttpFlexSession)
- httpFlexSessions.add((HttpFlexSession)currentSession);
- if (httpFlexSessions.size() > 1)
- {
- FlexContext.getHttpRequest().setAttribute(REQUEST_ATTR_DUPLICATE_SESSION_FLAG, httpFlexSessions);
- duplicateSessionDetected = true;
- break;
- }
- }
- }
- }
-
- // If more than one was found, remote host isn't using session cookies. Kill all duplicate sessions and return an error.
- // Simplest to just re-scan the list given that it will be very short, but use an iterator for concurrent modification.
- if (duplicateSessionDetected)
- {
- Object attributeValue = FlexContext.getHttpRequest().getAttribute(REQUEST_ATTR_DUPLICATE_SESSION_FLAG);
- String newSessionId = null;
- String oldSessionId = null;
- if (attributeValue != null)
- {
- @SuppressWarnings("unchecked")
- List<HttpFlexSession> httpFlexSessions = (List<HttpFlexSession>)attributeValue;
- oldSessionId = httpFlexSessions.get(0).getId();
- newSessionId = httpFlexSessions.get(1).getId();
- }
-
- if (sessions != null)
- {
- for (FlexSession session : sessions)
- {
- if (session instanceof HttpFlexSession)
- {
- session.invalidate();
- }
- }
- }
-
- // Return an error to the client.
-
- DuplicateSessionException e = new DuplicateSessionException();
- // Duplicate HTTP-based FlexSession error: A request for FlexClient ''{0}'' arrived over a new FlexSession ''{1}'', but FlexClient is already associated with FlexSession ''{2}'', therefore it cannot be associated with the new session.
- e.setMessage(ERR_MSG_DUPLICATE_SESSIONS_DETECTED, new Object[]{flexClient.getId(), newSessionId, oldSessionId});
- throw e;
- }
-
- return flexClient;
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Adds custom headers specified in the config to the HTTP response. The only
- * exception is that access control headers (Access-Control-*) are sent only
- * if there is an Origin header in the request.
- *
- * @param request The HTTP request.
- * @param response The HTTP response.
- */
- protected void addHeadersToResponse(HttpServletRequest request, HttpServletResponse response)
- {
- if (httpResponseHeaders == null || httpResponseHeaders.isEmpty())
- return;
-
- String origin = request.getHeader(HEADER_NAME_ORIGIN);
- boolean originHeaderExists = origin != null && origin.length() != 0;
-
- for (HttpHeader header : httpResponseHeaders)
- {
- if (header.name.startsWith(ACCESS_CONTROL) && !originHeaderExists)
- continue;
-
- response.addHeader(header.name, header.value);
- }
- }
-
- /**
- * Create the gateway filters that transform action requests
- * and responses.
- */
- protected abstract AMFFilter createFilterChain();
-
- /**
- * Returns the content type used by the connection handler to set on the
- * HTTP response. Subclasses should either return MessageIOConstants.AMF_CONTENT_TYPE
- * or MessageIOConstants.XML_CONTENT_TYPE.
- */
- protected abstract String getResponseContentType();
-
- /**
- * Returns https which is the secure protocol scheme for the endpoint.
- *
- * @return https.
- */
- @Override protected String getSecureProtocolScheme()
- {
- return HTTPS_PROTOCOL_SCHEME;
- }
-
- /**
- * Returns http which is the insecure protocol scheme for the endpoint.
- *
- * @return http.
- */
- @Override protected String getInsecureProtocolScheme()
- {
- return HTTP_PROTOCOL_SCHEME;
- }
-
- /**
- * @see flex.messaging.endpoints.AbstractEndpoint#handleChannelDisconnect(CommandMessage)
- */
- @Override protected Message handleChannelDisconnect(CommandMessage disconnectCommand)
- {
- HttpFlexSession session = (HttpFlexSession)FlexContext.getFlexSession();
- FlexClient flexClient = FlexContext.getFlexClient();
-
- // Shut down any subscriptions established over this channel/endpoint
- // for this specific FlexClient.
- if (flexClient.isValid())
- {
- String endpointId = getId();
- List<MessageClient> messageClients = flexClient.getMessageClients();
- for (MessageClient messageClient : messageClients)
- {
- if (messageClient.getEndpointId().equals(endpointId))
- {
- messageClient.setClientChannelDisconnected(true);
- messageClient.invalidate();
- }
- }
- }
-
- // And optionally invalidate the session.
- if (session.isValid() && isInvalidateSessionOnDisconnect())
- session.invalidate(false /* don't recreate */);
-
- return super.handleChannelDisconnect(disconnectCommand);
- }
-
- protected void initializeHttpResponseHeaders(ConfigMap properties)
- {
- if (!properties.containsKey(HTTP_RESPONSE_HEADERS))
- return;
-
- ConfigMap httpResponseHeaders = properties.getPropertyAsMap(HTTP_RESPONSE_HEADERS, null);
- if (httpResponseHeaders == null)
- return;
-
- @SuppressWarnings("unchecked")
- List<String> headers = httpResponseHeaders.getPropertyAsList(HEADER_ATTR, null);
- if (headers == null || headers.isEmpty())
- return;
-
- if (this.httpResponseHeaders == null)
- this.httpResponseHeaders = new ArrayList<HttpHeader>();
-
- for (String header : headers)
- {
- int colonIndex = header.indexOf(":");
- String name = header.substring(0, colonIndex).trim();
- String value = header.substring(colonIndex + 1).trim();
- this.httpResponseHeaders.add(new HttpHeader(name, value));
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Nested Classes
- //
- //--------------------------------------------------------------------------
-
- /**
- * Helper class used for headers in the HTTP request/response.
- */
- static class HttpHeader
- {
- public HttpHeader(String name, String value)
- {
- this.name = name;
- this.value = value;
- }
- public final String name;
- public final String value;
- }
+/*
+ * 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.endpoints;
+
+import flex.management.runtime.messaging.endpoints.EndpointControl;
+import flex.messaging.FlexContext;
+import flex.messaging.FlexSession;
+import flex.messaging.HttpFlexSession;
+import flex.messaging.MessageClient;
+import flex.messaging.client.FlexClient;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.ConfigurationConstants;
+import flex.messaging.endpoints.amf.AMFFilter;
+import flex.messaging.io.MessageIOConstants;
+import flex.messaging.io.amf.ActionContext;
+import flex.messaging.log.HTTPRequestLog;
+import flex.messaging.messages.CommandMessage;
+import flex.messaging.messages.Message;
+import flex.messaging.util.SettingsReplaceUtil;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Abstract base class for all the HTTP-based endpoints.
+ */
+public abstract class BaseHTTPEndpoint extends AbstractEndpoint
+{
+ //--------------------------------------------------------------------------
+ //
+ // Public Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The secure and insecure URL schemes for the HTTP endpoint.
+ */
+ public static final String HTTP_PROTOCOL_SCHEME = "http";
+ public static final String HTTPS_PROTOCOL_SCHEME = "https";
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ private static final String ADD_NO_CACHE_HEADERS = "add-no-cache-headers";
+ private static final String REDIRECT_URL = "redirect-url";
+ private static final String INVALIDATE_SESSION_ON_DISCONNECT = "invalidate-session-on-disconnect";
+ private static final String HTTP_RESPONSE_HEADERS = "http-response-headers";
+ private static final String HEADER_ATTR = "header";
+
+ private static final String HEADER_NAME_ORIGIN = "Origin";
+ private static final String ACCESS_CONTROL = "Access-Control-";
+ private static final String SESSION_REWRITING_ENABLED = "session-rewriting-enabled";
+
+ private static final int ERR_MSG_DUPLICATE_SESSIONS_DETECTED = 10035;
+ private static final String REQUEST_ATTR_DUPLICATE_SESSION_FLAG = "flex.messaging.request.DuplicateSessionDetected";
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an unmanaged <code>BaseHTTPEndpoint</code>.
+ */
+ public BaseHTTPEndpoint()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructs a <code>BaseHTTPEndpoint</code> with the specified management setting.
+ *
+ * @param enableManagement <code>true</code> if the <code>BaseHTTPEndpoint</code>
+ * is manageable; otherwise <code>false</code>.
+ */
+ public BaseHTTPEndpoint(boolean enableManagement)
+ {
+ super(enableManagement);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Initialize, validate, start, and stop methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes the <code>Endpoint</code> with the properties.
+ * If subclasses override this method, they must call <code>super.initialize()</code>.
+ *
+ * @param id The ID of the <code>Endpoint</code>.
+ * @param properties Properties for the <code>Endpoint</code>.
+ */
+ @Override public void initialize(String id, ConfigMap properties)
+ {
+ super.initialize(id, properties);
+
+ if (properties == null || properties.size() == 0)
+ return;
+
+ // General HTTP props.
+ addNoCacheHeaders = properties.getPropertyAsBoolean(ADD_NO_CACHE_HEADERS, true);
+ redirectURL = properties.getPropertyAsString(REDIRECT_URL, null);
+ invalidateSessionOnDisconnect = properties.getPropertyAsBoolean(INVALIDATE_SESSION_ON_DISCONNECT, false);
+ loginAfterDisconnect = properties.getPropertyAsBoolean(ConfigurationConstants.LOGIN_AFTER_DISCONNECT_ELEMENT, false);
+ sessionRewritingEnabled = properties.getPropertyAsBoolean(SESSION_REWRITING_ENABLED, true);
+ initializeHttpResponseHeaders(properties);
+ validateEndpointProtocol();
+ }
+
+ /**
+ * Starts the <code>Endpoint</code> by creating a filter chain and setting
+ * up serializers and deserializers.
+ */
+ @Override public void start()
+ {
+ if (isStarted())
+ return;
+
+ super.start();
+
+ filterChain = createFilterChain();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Controller used to manage this endpoint.
+ */
+ protected EndpointControl controller;
+
+ /**
+ * AMF processing filter chain used by this endpoint.
+ */
+ protected AMFFilter filterChain;
+
+ /**
+ * Headers to add to the HTTP response.
+ */
+ protected List<HttpHeader> httpResponseHeaders;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // addNoCacheHeaders
+ //----------------------------------
+
+ protected boolean addNoCacheHeaders = true;
+
+ /**
+ * Retrieves the <code>add-no-cache-headers</code> property.
+ *
+ * @return <code>true</code> if <code>add-no-cache-headers</code> is enabled;
+ * <code>false</code> otherwise.
+ */
+ public boolean isAddNoCacheHeaders()
+ {
+ return addNoCacheHeaders;
+ }
+
+ /**
+ * Sets the <code>add-no-cache-headers</code> property.
+ *
+ * @param addNoCacheHeaders The <code>add-no-cache-headers</code> property.
+ */
+ public void setAddNoCacheHeaders(boolean addNoCacheHeaders)
+ {
+ this.addNoCacheHeaders = addNoCacheHeaders;
+ }
+
+ //----------------------------------
+ // loginAfterDisconnect
+ //----------------------------------
+
+ /**
+ * @exclude
+ * This is a property used on the client.
+ */
+ protected boolean loginAfterDisconnect;
+
+ //----------------------------------
+ // invalidateSessionOnDisconnect
+ //----------------------------------
+
+ protected boolean invalidateSessionOnDisconnect;
+
+ /**
+ * Indicates whether the server session will be invalidated
+ * when a client channel disconnects.
+ * The default is <code>false</code>.
+ *
+ * @return <code>true</code> if the server session will be invalidated
+ * when a client channel disconnects, <code>false</code> otherwise.
+ */
+ public boolean isInvalidateSessionOnDisconnect()
+ {
+ return invalidateSessionOnDisconnect;
+ }
+
+ /**
+ * Determines whether to invalidate the server session for a client
+ * that disconnects its channel.
+ * The default is <code>false</code>.
+ *
+ * @param value <code>true</code> to invalidate the server session for a client
+ * that disconnects its channel, <code>false</code> otherwise.
+ */
+ public void setInvalidateSessionOnDisconnect(boolean value)
+ {
+ invalidateSessionOnDisconnect = value;
+ }
+
+ //----------------------------------
+ // redirectURL
+ //----------------------------------
+
+ protected String redirectURL;
+
+ /**
+ * Retrieves the <code>redirect-url</code> property.
+ *
+ * @return The <code>redirect-url</code> property.
+ */
+ public String getRedirectURL()
+ {
+ return redirectURL;
+ }
+
+ /**
+ * Sets the <code>redirect-url</code> property.
+ *
+ * @param redirectURL The <code>redirect-url</code> property.
+ */
+ public void setRedirectURL(String redirectURL)
+ {
+ this.redirectURL = redirectURL;
+ }
+
+ //----------------------------------
+ // sessionRewritingEnabled
+ //----------------------------------
+
+ protected boolean sessionRewritingEnabled = true;
+
+ /**
+ * Indicates whether the server will fall back on rewriting URLs to include
+ * session identifiers in the URL when HTTP session cookies are not allowed
+ * on the client. The default is <code>true</code>.
+ *
+ * @return <code>true</code> if the session rewriting is enabled.
+ */
+ public boolean isSessionRewritingEnabled()
+ {
+ return sessionRewritingEnabled;
+ }
+
+ /**
+ * Sets whether the session rewriting is enabled.
+ *
+ * @param value The session writing enabled value.
+ */
+ public void setSessionRewritingEnabled(boolean value)
+ {
+ sessionRewritingEnabled = value;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Handle AMF/AMFX encoded messages sent over HTTP.
+ *
+ * @param req The original servlet request.
+ * @param res The active servlet response.
+ */
+ @Override
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ {
+ super.service(req, res);
+
+ try
+ {
+ // Setup serialization and type marshalling contexts
+ setThreadLocals();
+
+ // Create a context for this request
+ ActionContext context = new ActionContext();
+
+ // Pass endpoint's mpi settings to the context so that it knows what level of
+ // performance metrics should be gathered during serialization/deserialization
+ context.setRecordMessageSizes(isRecordMessageSizes());
+ context.setRecordMessageTimes(isRecordMessageTimes());
+
+ // Send invocation through filter chain, which ends at the MessageBroker
+ filterChain.invoke(context);
+
+ // After serialization completes, increment endpoint byte counters,
+ // if the endpoint is managed
+ if (isManaged())
+ {
+ controller.addToBytesDeserialized(context.getDeserializedBytes());
+ controller.addToBytesSerialized(context.getSerializedBytes());
+ }
+
+ if (context.getStatus() != MessageIOConstants.STATUS_NOTAMF)
+ {
+ if (addNoCacheHeaders)
+ addNoCacheHeaders(req, res);
+
+ addHeadersToResponse(req, res);
+
+ ByteArrayOutputStream outBuffer = context.getResponseOutput();
+
+ res.setContentType(getResponseContentType());
+
+ res.setContentLength(outBuffer.size());
+ outBuffer.writeTo(res.getOutputStream());
+ res.flushBuffer();
+ }
+ else
+ {
+ // Not an AMF request, probably viewed in a browser
+ if (redirectURL != null)
+ {
+ try
+ {
+ //Check for redirect URL context-root token
+ redirectURL = SettingsReplaceUtil.replaceContextPath(redirectURL, req.getContextPath());
+ res.sendRedirect(redirectURL);
+ }
+ catch (IllegalStateException alreadyFlushed)
+ {
+ // ignore
+ }
+ }
+ }
+ }
+ catch (IOException ioe)
+ {
+ // This happens when client closes the connection, log it at info level
+ log.info(ioe.getMessage());
+ // Store exception information for latter logging
+ req.setAttribute(HTTPRequestLog.HTTP_ERROR_INFO, ioe.toString());
+ }
+ catch (Throwable t)
+ {
+ log.error(t.getMessage(), t);
+ // Store exception information for latter logging
+ req.setAttribute(HTTPRequestLog.HTTP_ERROR_INFO, t.toString());
+ }
+ finally
+ {
+ clearThreadLocals();
+ }
+ }
+
+
+ /**
+ * @exclude
+ * Returns a <code>ConfigMap</code> of endpoint properties that the client
+ * needs. This includes properties from <code>super.describeEndpoint</code>
+ * and additional <code>BaseHTTPEndpoint</code> specific properties under
+ * "properties" key.
+ */
+ @Override
+ public ConfigMap describeEndpoint()
+ {
+ ConfigMap endpointConfig = super.describeEndpoint();
+
+ if (loginAfterDisconnect)
+ {
+ ConfigMap loginAfterDisconnect = new ConfigMap();
+ // Adding as a value rather than attribute to the parent
+ loginAfterDisconnect.addProperty(EMPTY_STRING, TRUE_STRING);
+
+ ConfigMap properties = endpointConfig.getPropertyAsMap(PROPERTIES_ELEMENT, null);
+ if (properties == null)
+ {
+ properties = new ConfigMap();
+ endpointConfig.addProperty(PROPERTIES_ELEMENT, properties);
+ }
+ properties.addProperty(ConfigurationConstants.LOGIN_AFTER_DISCONNECT_ELEMENT, loginAfterDisconnect);
+ }
+
+ return endpointConfig;
+ }
+
+ /**
+ * Overrides to guard against duplicate HTTP-based sessions for the same FlexClient
+ * which will occur if the remote host has disabled session cookies.
+ *
+ * @see AbstractEndpoint#setupFlexClient(String)
+ */
+ @Override
+ public FlexClient setupFlexClient(String id)
+ {
+ FlexClient flexClient = super.setupFlexClient(id);
+
+ // Scan for duplicate HTTP-sessions and if found, invalidate them and throw a MessageException.
+ // A request attribute is used to deal with batched AMF messages that arrive in a single request by trigger multiple passes through this method.
+ boolean duplicateSessionDetected = (FlexContext.getHttpRequest().getAttribute(REQUEST_ATTR_DUPLICATE_SESSION_FLAG) != null);
+
+ List<FlexSession> sessions = null;
+ if (!duplicateSessionDetected)
+ {
+ sessions = flexClient.getFlexSessions();
+ int n = sessions.size();
+ if (n > 1)
+ {
+ List<HttpFlexSession> httpFlexSessions = new ArrayList<HttpFlexSession>();
+ for (int i = 0; i < n; i++)
+ {
+ FlexSession currentSession = sessions.get(i);
+ if (currentSession instanceof HttpFlexSession)
+ httpFlexSessions.add((HttpFlexSession)currentSession);
+ if (httpFlexSessions.size() > 1)
+ {
+ FlexContext.getHttpRequest().setAttribute(REQUEST_ATTR_DUPLICATE_SESSION_FLAG, httpFlexSessions);
+ duplicateSessionDetected = true;
+ break;
+ }
+ }
+ }
+ }
+
+ // If more than one was found, remote host isn't using session cookies. Kill all duplicate sessions and return an error.
+ // Simplest to just re-scan the list given that it will be very short, but use an iterator for concurrent modification.
+ if (duplicateSessionDetected)
+ {
+ Object attributeValue = FlexContext.getHttpRequest().getAttribute(REQUEST_ATTR_DUPLICATE_SESSION_FLAG);
+ String newSessionId = null;
+ String oldSessionId = null;
+ if (attributeValue != null)
+ {
+ @SuppressWarnings("unchecked")
+ List<HttpFlexSession> httpFlexSessions = (List<HttpFlexSession>)attributeValue;
+ oldSessionId = httpFlexSessions.get(0).getId();
+ newSessionId = httpFlexSessions.get(1).getId();
+ }
+
+ if (sessions != null)
+ {
+ for (FlexSession session : sessions)
+ {
+ if (session instanceof HttpFlexSession)
+ {
+ session.invalidate();
+ }
+ }
+ }
+
+ // Return an error to the client.
+
+ DuplicateSessionException e = new DuplicateSessionException();
+ // Duplicate HTTP-based FlexSession error: A request for FlexClient ''{0}'' arrived over a new FlexSession ''{1}'', but FlexClient is already associated with FlexSession ''{2}'', therefore it cannot be associated with the new session.
+ e.setMessage(ERR_MSG_DUPLICATE_SESSIONS_DETECTED, new Object[]{flexClient.getId(), newSessionId, oldSessionId});
+ throw e;
+ }
+
+ return flexClient;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Adds custom headers specified in the config to the HTTP response. The only
+ * exception is that access control headers (Access-Control-*) are sent only
+ * if there is an Origin header in the request.
+ *
+ * @param request The HTTP request.
+ * @param response The HTTP response.
+ */
+ protected void addHeadersToResponse(HttpServletRequest request, HttpServletResponse response)
+ {
+ if (httpResponseHeaders == null || httpResponseHeaders.isEmpty())
+ return;
+
+ String origin = request.getHeader(HEADER_NAME_ORIGIN);
+ boolean originHeaderExists = origin != null && origin.length() != 0;
+
+ for (HttpHeader header : httpResponseHeaders)
+ {
+ if (header.name.startsWith(ACCESS_CONTROL) && !originHeaderExists)
+ continue;
+
+ response.addHeader(header.name, header.value);
+ }
+ }
+
+ /**
+ * Create the gateway filters that transform action requests
+ * and responses.
+ */
+ protected abstract AMFFilter createFilterChain();
+
+ /**
+ * Returns the content type used by the connection handler to set on the
+ * HTTP response. Subclasses should either return MessageIOConstants.AMF_CONTENT_TYPE
+ * or MessageIOConstants.XML_CONTENT_TYPE.
+ */
+ protected abstract String getResponseContentType();
+
+ /**
+ * Returns https which is the secure protocol scheme for the endpoint.
+ *
+ * @return https.
+ */
+ @Override protected String getSecureProtocolScheme()
+ {
+ return HTTPS_PROTOCOL_SCHEME;
+ }
+
+ /**
+ * Returns http which is the insecure protocol scheme for the endpoint.
+ *
+ * @return http.
+ */
+ @Override protected String getInsecureProtocolScheme()
+ {
+ return HTTP_PROTOCOL_SCHEME;
+ }
+
+ /**
+ * @see flex.messaging.endpoints.AbstractEndpoint#handleChannelDisconnect(CommandMessage)
+ */
+ @Override protected Message handleChannelDisconnect(CommandMessage disconnectCommand)
+ {
+ HttpFlexSession session = (HttpFlexSession)FlexContext.getFlexSession();
+ FlexClient flexClient = FlexContext.getFlexClient();
+
+ // Shut down any subscriptions established over this channel/endpoint
+ // for this specific FlexClient.
+ if (flexClient.isValid())
+ {
+ String endpointId = getId();
+ List<MessageClient> messageClients = flexClient.getMessageClients();
+ for (MessageClient messageClient : messageClients)
+ {
+ if (messageClient.getEndpointId().equals(endpointId))
+ {
+ messageClient.setClientChannelDisconnected(true);
+ messageClient.invalidate();
+ }
+ }
+ }
+
+ // And optionally invalidate the session.
+ if (session.isValid() && isInvalidateSessionOnDisconnect())
+ session.invalidate(false /* don't recreate */);
+
+ return super.handleChannelDisconnect(disconnectCommand);
+ }
+
+ protected void initializeHttpResponseHeaders(ConfigMap properties)
+ {
+ if (!properties.containsKey(HTTP_RESPONSE_HEADERS))
+ return;
+
+ ConfigMap httpResponseHeaders = properties.getPropertyAsMap(HTTP_RESPONSE_HEADERS, null);
+ if (httpResponseHeaders == null)
+ return;
+
+ @SuppressWarnings("unchecked")
+ List<String> headers = httpResponseHeaders.getPropertyAsList(HEADER_ATTR, null);
+ if (headers == null || headers.isEmpty())
+ return;
+
+ if (this.httpResponseHeaders == null)
+ this.httpResponseHeaders = new ArrayList<HttpHeader>();
+
+ for (String header : headers)
+ {
+ int colonIndex = header.indexOf(":");
+ String name = header.substring(0, colonIndex).trim();
+ String value = header.substring(colonIndex + 1).trim();
+ this.httpResponseHeaders.add(new HttpHeader(name, value));
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Nested Classes
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Helper class used for headers in the HTTP request/response.
+ */
+ static class HttpHeader
+ {
+ public HttpHeader(String name, String value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+ public final String name;
+ public final String value;
+ }
}
\ No newline at end of file
[25/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/MessageClient.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/MessageClient.java b/modules/core/src/flex/messaging/MessageClient.java
old mode 100755
new mode 100644
index e9c8ccc..ea19eda
--- a/modules/core/src/flex/messaging/MessageClient.java
+++ b/modules/core/src/flex/messaging/MessageClient.java
@@ -1,1144 +1,1144 @@
-/*
- * 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;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-import flex.messaging.client.FlexClient;
-import flex.messaging.client.FlexClientOutboundQueueProcessor;
-import flex.messaging.client.OutboundQueueThrottleManager;
-import flex.messaging.config.ThrottleSettings;
-import flex.messaging.config.ThrottleSettings.Policy;
-import flex.messaging.log.LogCategories;
-import flex.messaging.log.Log;
-import flex.messaging.messages.AsyncMessage;
-import flex.messaging.messages.CommandMessage;
-import flex.messaging.messages.Message;
-import flex.messaging.services.MessageService;
-import flex.messaging.services.messaging.Subtopic;
-import flex.messaging.services.messaging.selector.JMSSelector;
-import flex.messaging.services.messaging.selector.JMSSelectorException;
-import flex.messaging.util.ExceptionUtil;
-import flex.messaging.util.TimeoutAbstractObject;
-import flex.messaging.util.StringUtils;
-
-/**
- * Represents a client-side MessageAgent instance.
- * Currently a server-side MessageClient is only created if its client-side counterpart has subscribed
- * to a destination for pushed data (e.g. Consumer). Client-side Producers do not result in the creation of
- * corresponding server-side MessageClient instances.
- *
- * Client-side MessageAgents communicate with the server over a Channel that corresponds to a FlexSession.
- * Server-side MessageClient instances are always created in the context of a FlexSession and when the FlexSession
- * is invalidated any associated MessageClients are invalidated as well.
- *
- * MessageClients may also be timed out on a per-destination basis and this is based on subscription inactivity.
- * If no messages are pushed to the MessageClient within the destination's subscription timeout period the
- * MessageClient will be shutdown even if the associated FlexSession is still active and connected.
- * Per-destination subscription timeout is an optional configuration setting, and should only be used when inactive
- * subscriptions should be shut down opportunistically to preserve server resources.
- */
-public class MessageClient extends TimeoutAbstractObject implements Serializable
-{
- //--------------------------------------------------------------------------
- //
- // Public Static Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Log category for MessageClient related messages.
- */
- public static final String MESSAGE_CLIENT_LOG_CATEGORY = LogCategories.CLIENT_MESSAGECLIENT;
-
- //--------------------------------------------------------------------------
- //
- // Static Constants
- //
- //--------------------------------------------------------------------------
-
- /**
- * Serializable to support broadcasting subscription state across the cluster for
- * optimized message routing.
- */
- static final long serialVersionUID = 3730240451524954453L;
-
- //--------------------------------------------------------------------------
- //
- // Static Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * The list of MessageClient created listeners.
- */
- private static final CopyOnWriteArrayList<MessageClientListener> createdListeners = new CopyOnWriteArrayList<MessageClientListener>();
-
- //--------------------------------------------------------------------------
- //
- // Static Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Adds a MessageClient created listener.
- *
- * @see flex.messaging.MessageClientListener
- *
- * @param listener The listener to add.
- */
- public static void addMessageClientCreatedListener(MessageClientListener listener)
- {
- if (listener != null)
- createdListeners.addIfAbsent(listener);
- }
-
- /**
- * Removes a MessageClient created listener.
- *
- * @see flex.messaging.MessageClientListener
- *
- * @param listener The listener to remove.
- */
- public static void removeMessageClientCreatedListener(MessageClientListener listener)
- {
- if (listener != null)
- createdListeners.remove(listener);
- }
-
- //--------------------------------------------------------------------------
- //
- // Private Static Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Utility method.
- */
- private static boolean equalStrings(String a, String b)
- {
- return a == b || (a != null && a.equals(b));
- }
-
- /**
- * Utility method.
- */
- static int compareStrings(String a, String b)
- {
- if (a == b)
- return 0;
-
- if (a != null && b != null)
- return a.compareTo(b);
-
- if (a == null)
- return -1;
-
- return 1;
- }
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * Constructs a new MessageClient for local use.
- *
- * @param clientId The clientId for the MessageClient.
- * @param destination The destination the MessageClient is subscribed to.
- * @param endpointId The Id of the endpoint this MessageClient subscription was created over.
- */
- public MessageClient(Object clientId, Destination destination, String endpointId)
- {
- this(clientId, destination, endpointId, true);
- }
-
- /**
- * @exclude
- * Constructs a new MessageClient.
- *
- * @param clientId The clientId for the MessageClient.
- * @param destination The destination the MessageClient is subscribed to.
- * @param endpointId The Id of the endpoint this MessageClient subscription was created over.
- * @param useSession RemoteMessageClient instances should not be associated with a FlexSession (pass false).
- */
- public MessageClient(Object clientId, Destination destination, String endpointId, boolean useSession)
- {
- valid = true;
- this.clientId = clientId;
- this.destination = destination;
- this.endpointId = endpointId;
- destinationId = destination.getId();
- updateLastUse(); // Initialize last use timestamp to construct time.
-
- /* If this is for a remote server, we do not associate with the session. */
- if (useSession)
- {
- flexSession = FlexContext.getFlexSession();
- flexSession.registerMessageClient(this);
-
- flexClient = FlexContext.getFlexClient();
- flexClient.registerMessageClient(this);
-
- // SubscriptionManager will notify the created listeners, once
- // subscription state is setup completely.
- // notifyCreatedListeners();
- }
- else
- {
- flexClient = null;
- flexSession = null;
- // Use an instance level lock.
- lock = new Object();
- // On a remote server we don't notify created listeners.
- }
-
- if (Log.isDebug())
- Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).debug("MessageClient created with clientId '" + this.clientId + "' for destination '" + destinationId + "'.");
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * This flag is set to true when the client channel that this subscription was
- * established over is disconnected.
- * It supports cleaning up per-endpoint outbound queues maintained by the FlexClient.
- * If the client notifies the server that its channel is disconnecting, the FlexClient
- * does not need to maintain an outbound queue containing a subscription invalidation
- * message for this MessageClient to send to the client.
- */
- private volatile boolean clientChannelDisconnected;
-
- /**
- * The clientId for the MessageClient.
- * This value is specified by the client directly or is autogenerated on the client.
- */
- protected final Object clientId;
-
- /**
- * Internal reference to the associated Destination; don't expose this in the public API.
- */
- protected final Destination destination;
-
- /**
- * The destination the MessageClient is subscribed to.
- */
- protected final String destinationId;
-
- /**
- * The set of session destroy listeners to notify when the session is destroyed.
- */
- private transient volatile CopyOnWriteArrayList destroyedListeners;
-
- /**
- * The Id for the endpoint this MessageClient subscription was created over.
- */
- private String endpointId;
-
- /**
- * The FlexClient associated with the MessageClient.
- */
- private final transient FlexClient flexClient;
-
- /**
- * The FlexSession associated with the MessageClient.
- * Not final because this needs to be reset if the subscription fails over to a new endpoint.
- */
- private transient FlexSession flexSession;
-
- /**
- * Flag used to break cycles during invalidation.
- */
- private boolean invalidating;
-
- /**
- * The lock to use to guard all state changes for the MessageClient.
- */
- protected Object lock = new Object();
-
- /**
- * Flag indicating whether the MessageClient is attempting to notify the remote client of
- * its invalidation.
- */
- private volatile boolean attemptingInvalidationClientNotification;
-
- /**
- * A counter used to control invalidation for a MessageClient that has multiple
- * subscriptions to its destination.
- * Unsubscribing from one will not invalidate the MessageClient as long as other
- * subscriptions remain active.
- */
- private transient int numReferences;
-
- /**
- * A set of all of the subscriptions managed by this message client.
- */
- protected final Set<SubscriptionInfo> subscriptions = new CopyOnWriteArraySet<SubscriptionInfo>();
-
- /**
- * Flag indicating whether this client is valid or not.
- */
- protected boolean valid;
-
- /**
- * Flag that indicates whether the MessageClient has a per-destination subscription timeout.
- * If false, the MessageClient will remain valid until its associated FlexSession is invalidated.
- */
- private volatile boolean willTimeout;
-
- /**
- * Has anyone explicitly registered this message client. This indicates that
- * there is a reference to this MessageClient which is not an explicit subscription.
- * This is a hook for FDMS and other adapters which want to use pushMessageToClients
- * with clientIds but that do not want the subscription manager to manage subscriptions
- * for them.
- */
- private volatile boolean registered = false;
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Returns the clientId for the MessageClient.
- *
- * @return The clientId for the MessageClient.
- */
- public Object getClientId()
- {
- return clientId; // Field is final; no need to sync.
- }
-
- /**
- * Returns the destination the MessageClient is subscribed to.
- *
- * @return The destination the MessageClient is subscribed to.
- */
- public Destination getDestination()
- {
- return destination; // Field is final; no need to sync.
- }
-
- /**
- * Returns the id of the destination the MessageClient is subscribed to.
- *
- * @return The id of the destination the MessageClient is subscribed to.
- */
- public String getDestinationId()
- {
- return destinationId; // Field is final; no need to sync.
- }
-
- /**
- * Returns the Id for the endpoint the MessageClient subscription was created over.
- *
- * @return The Id for the endpoint the MessageClient subscription was created over.
- */
- public String getEndpointId()
- {
- return endpointId; // Field is final; no need to sync.
- }
-
- /**
- * Returns the FlexClient associated with this MessageClient.
- *
- * @return The FlexClient assocaited with this MessageClient.
- */
- public FlexClient getFlexClient()
- {
- return flexClient; // Field is final; no need to sync.
- }
-
- /**
- * Returns the FlexSession associated with this MessageClient.
- *
- * @return The FlexSession associated with this MessageClient.
- */
- public FlexSession getFlexSession()
- {
- synchronized (lock)
- {
- return flexSession;
- }
- }
-
- /**
- * Returns the number of subscriptions associated with this MessageClient.
- *
- * @return The number of subscriptions associated with this MessageClient.
- */
- public int getSubscriptionCount()
- {
- int count;
-
- synchronized (lock)
- {
- count = subscriptions != null? subscriptions.size() : 0;
- }
-
- return count;
- }
-
- /**
- * @exclude
- * This is used for FlexClient outbound queue management. When a MessageClient is invalidated
- * if it is attempting to notify the client, then we must leave the outbound queue containing
- * the notification in place. Otherwise, any messages queued for the subscription may be
- * removed from the queue and possibly shut down immediately.
- */
- public boolean isAttemptingInvalidationClientNotification()
- {
- return attemptingInvalidationClientNotification;
- }
-
- /**
- * @exclude
- * This is set to true when the MessageClient is invalidated due to the client
- * channel the subscription was established over disconnecting.
- * It allows the FlexClient class to cleanup the outbound queue for the channel's
- * corresponding server endpoint for the remote client, because we know that no
- * currently queued messages need to be retained for delivery.
- */
- public void setClientChannelDisconnected(boolean value)
- {
- clientChannelDisconnected = value;
- }
-
- /**
- * @exclude
- */
- public boolean isClientChannelDisconnected()
- {
- return clientChannelDisconnected;
- }
-
- /**
- * @exclude
- * This is true when some code other than the SubscriptionManager
- * is maintaining subscriptions for this message client. It ensures
- * that we have this MessageClient kept around until the session
- * expires.
- */
- public void setRegistered(boolean reg)
- {
- registered = reg;
- }
-
- /**
- * @exclude
- */
- public boolean isRegistered()
- {
- return registered;
- }
-
- /**
- * Adds a MessageClient destroy listener.
- *
- * @see flex.messaging.MessageClientListener
- *
- * @param listener The listener to add.
- */
- public void addMessageClientDestroyedListener(MessageClientListener listener)
- {
- if (listener != null)
- {
- checkValid();
-
- if (destroyedListeners == null)
- {
- synchronized (lock)
- {
- if (destroyedListeners == null)
- destroyedListeners = new CopyOnWriteArrayList();
- }
- }
-
- destroyedListeners.addIfAbsent(listener);
- }
- }
-
- /**
- * Removes a MessageClient destroyed listener.
- *
- * @see flex.messaging.MessageClientListener
- *
- * @param listener The listener to remove.
- */
- public void removeMessageClientDestroyedListener(MessageClientListener listener)
- {
- // No need to check validity; removing a listener is always ok.
- if (listener != null && destroyedListeners != null)
- destroyedListeners.remove(listener);
- }
-
- /**
- * @exclude
- * Adds a subscription to the subscription set for this MessageClient.
- *
- * @param selector The selector expression used for the subscription.
- * @param subtopic The subtopic used for the subscription.
- * @param maxFrequency The maximum number of messages the client wants to
- * receive per second (0 disables this limit).
- */
- public void addSubscription(String selector, String subtopic, int maxFrequency)
- {
- synchronized (lock)
- {
- checkValid();
-
- incrementReferences();
-
- // Create and add the subscription to the subscriptions set.
- SubscriptionInfo si = new SubscriptionInfo(selector, subtopic, maxFrequency);
- subscriptions.add(si);
-
- registerSubscriptionWithThrottleManager(si);
- }
- }
-
- /**
- * @exclude
- * Registers the subscription with the outbound queue processor's throttle
- * manager, if one exists.
- *
- * @param si The subscription info object.
- */
- public void registerSubscriptionWithThrottleManager(SubscriptionInfo si)
- {
- // Register the destination that will setup client level outbound throttling.
- ThrottleSettings ts = destination.getNetworkSettings().getThrottleSettings();
- if (ts.getOutboundPolicy() != Policy.NONE && (ts.isOutboundClientThrottleEnabled() || si.maxFrequency > 0))
- {
- // Setup the client level outbound throttling, and register the destination
- // only if the policy is not NONE, and a throttling limit is specified
- // either at the destination or by consumer.
- OutboundQueueThrottleManager throttleManager = getThrottleManager(true);
- if (throttleManager != null)
- throttleManager.registerDestination(destinationId, ts.getOutgoingClientFrequency(), ts.getOutboundPolicy());
- }
- else if (si.maxFrequency > 0) // Let the client know that maxFrequency will be ignored.
- {
- if (Log.isWarn())
- Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).warn("MessageClient with clientId '"
- + clientId + "' for destination '" + destinationId
- + "' specified a maxFrequency value of '" + si.maxFrequency
- + "' but the destination does not define a throttling policy. This value will be ignored.");
- }
-
- // Now, register the subscription.
- OutboundQueueThrottleManager throttleManager = getThrottleManager(false);
- if (throttleManager != null)
- throttleManager.registerSubscription(destinationId, si);
- }
-
- /**
- * @exclude
- * Removes a subscription from the subscription set for this MessageClient.
- *
- * @param selector The selector expression for the subscription.
- * @param subtopic The subtopic for the subscription.
- * @return true if no subscriptions remain for this MessageClient; otherwise false.
- */
- public boolean removeSubscription(String selector, String subtopic)
- {
- synchronized (lock)
- {
- SubscriptionInfo si = new SubscriptionInfo(selector, subtopic);
- if (subscriptions.remove(si))
- {
- unregisterSubscriptionWithThrottleManager(si);
- return decrementReferences();
- }
- else if (Log.isError())
- {
- Log.getLogger(MessageService.LOG_CATEGORY).error("Error - unable to find subscription to remove for MessageClient: "
- + clientId + " selector: " + selector + " subtopic: " + subtopic);
- }
- return numReferences == 0;
- }
- }
-
- /**
- * @exclude
- * We use the same MessageClient for more than one subscription with different
- * selection criteria. This tracks the number of subscriptions that are active
- * so that we know when we are finished.
- */
- public void incrementReferences()
- {
- synchronized (lock)
- {
- numReferences++;
- }
- }
-
- /**
- * @exclude
- * Decrements the numReferences variable and returns true if this was the last reference.
- */
- public boolean decrementReferences()
- {
- synchronized (lock)
- {
- if (--numReferences == 0)
- {
- cancelTimeout();
- if (destination instanceof MessageDestination)
- {
- MessageDestination msgDestination = (MessageDestination)destination;
- if (msgDestination.getThrottleManager() != null)
- msgDestination.getThrottleManager().removeClientThrottleMark(clientId);
- }
- return true;
- }
- return false;
- }
- }
-
- /**
- * @exclude
- * Invoked by SubscriptionManager once the subscription state is setup completely
- * for the MessageClient..
- */
- public void notifyCreatedListeners()
- {
- // Notify MessageClient created listeners.
- if (!createdListeners.isEmpty())
- {
- // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
- for (Iterator iter = createdListeners.iterator(); iter.hasNext();)
- ((MessageClientListener)iter.next()).messageClientCreated(this);
- }
- }
-
- /**
- * @exclude
- * Invoked by SubscriptionManager while handling a subscribe request.
- * If the request is updating an existing subscription the 'push' state in the associated FlexClient
- * may need to be updated to ensure that the correct endpoint is used for this subscription.
- *
- * @param newEndpointId The id for the new endpoint that the subscription may have failed over to.
- */
- public void resetEndpoint(String newEndpointId)
- {
- String oldEndpointId = null;
- FlexSession oldSession = null;
- FlexSession newSession = FlexContext.getFlexSession();
- synchronized (lock)
- {
- // If anything is null, or nothing has changed, no need for a reset.
- if (endpointId == null || newEndpointId == null || flexSession == null || newSession == null || (endpointId.equals(newEndpointId) && flexSession.equals(newSession)))
- return;
-
- oldEndpointId = endpointId;
- endpointId = newEndpointId;
-
- oldSession = flexSession;
- flexSession = newSession;
- }
-
- // Unregister in order to reset the proper push settings in the re-registration below once the session association has been patched.
- if (flexClient != null)
- flexClient.unregisterMessageClient(this);
-
- // Clear out any reference to this subscription that the previously associated session has.
- if (oldSession != null)
- oldSession.unregisterMessageClient(this);
-
- // Associate the current session with this subscription.
- if (flexSession != null)
- flexSession.registerMessageClient(this);
-
- // Reset proper push settings.
- if (flexClient != null)
- flexClient.registerMessageClient(this);
-
- if (Log.isDebug())
- {
- String msg = "MessageClient with clientId '" + clientId + "' for destination '" + destinationId + "' has been reset as a result of a resubscribe.";
- if (oldEndpointId != null && !oldEndpointId.equals(newEndpointId))
- msg += " Endpoint change [" + oldEndpointId + " -> " + newEndpointId + "]";
- if ((oldSession != null) && (newSession != null) && (oldSession != newSession)) // Test identity.
- msg += " FlexSession change [" + oldSession.getClass().getName() + ":" + oldSession.getId() + " -> " + newSession.getClass().getName() + ":" + newSession.getId() + "]";
-
- Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).debug(msg);
- }
- }
-
- /**
- * @exclude
- * Used to test whether this client should receive this message
- * based on the list of subscriptions we have recorded for it.
- * It must match both the subtopic and the selector expression.
- * Usually this is done by the subscription manager - this logic is
- * only here to maintain api compatibility with one of the variants
- * of the pushMessageToClients which has subscriberIds and an evalSelector
- * property.
- *
- * @param message The message to test.
- */
- public boolean testMessage(Message message, MessageDestination destination)
- {
- String subtopic = (String) message.getHeader(AsyncMessage.SUBTOPIC_HEADER_NAME);
- String subtopicSeparator = destination.getServerSettings().getSubtopicSeparator();
- synchronized (lock)
- {
- for (SubscriptionInfo si : subscriptions)
- {
- if (si.matches(message, subtopic, subtopicSeparator))
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns true if the MessageClient is valid; false if it has been invalidated.
- *
- * @return true if the MessageClient is valid; otherwise false.
- */
- public boolean isValid()
- {
- synchronized (lock)
- {
- return valid;
- }
- }
-
- /**
- * Invalidates the MessageClient.
- */
- public void invalidate()
- {
- invalidate(false /* don't attempt to notify the client */);
- }
-
- /**
- * Invalidates the MessageClient, and optionally attempts to notify the client that
- * this subscription has been invalidated.
- * This overload is used when a subscription is timed out while the client is still
- * actively connected to the server but should also be used by any custom code on the server
- * that invalidates MessageClients but wishes to notify the client cleanly.
- *
- * @param notifyClient <code>true</code> to notify the client that its subscription has been
- * invalidated.
- */
- public void invalidate(boolean notifyClient)
- {
- synchronized (lock)
- {
- if (!valid || invalidating)
- return; // Already shutting down.
-
- invalidating = true; // This thread gets to shut the MessageClient down.
- cancelTimeout();
- }
-
- // Record whether we're attempting to notify the client or not.
- attemptingInvalidationClientNotification = notifyClient;
-
- // Build a subscription invalidation message and push to the client if it is still valid.
- if (notifyClient && flexClient != null && flexClient.isValid())
- {
- CommandMessage msg = new CommandMessage();
- msg.setDestination(destination.getId());
- msg.setClientId(clientId);
- msg.setOperation(CommandMessage.SUBSCRIPTION_INVALIDATE_OPERATION);
- Set subscriberIds = new TreeSet();
- subscriberIds.add(clientId);
- try
- {
- if (destination instanceof MessageDestination)
- {
- MessageDestination msgDestination = (MessageDestination)destination;
- ((MessageService)msgDestination.getService()).pushMessageToClients(msgDestination, subscriberIds, msg, false /* don't eval selector */);
- }
- }
- catch (MessageException ignore) {}
- }
-
- // Notify messageClientDestroyed listeners that we're being invalidated.
- if (destroyedListeners != null && !destroyedListeners.isEmpty())
- {
- for (Iterator iter = destroyedListeners.iterator(); iter.hasNext();)
- {
- ((MessageClientListener)iter.next()).messageClientDestroyed(this);
- }
- destroyedListeners.clear();
- }
-
- // And generate unsubscribe messages for all of the MessageClient's subscriptions and
- // route them to the destination this MessageClient is subscribed to.
- // The reason we send a message to the service rather than just going straight to the SubscriptionManager
- // is that some adapters manage their own subscription state (i.e. JMS) in addition to us keeping track of
- // things with our SubscriptionManager.
- ArrayList<CommandMessage> unsubMessages = new ArrayList<CommandMessage>();
- synchronized (lock)
- {
- for (SubscriptionInfo subInfo : subscriptions)
- {
- CommandMessage unsubMessage = new CommandMessage();
- unsubMessage.setDestination(destination.getId());
- unsubMessage.setClientId(clientId);
- unsubMessage.setOperation(CommandMessage.UNSUBSCRIBE_OPERATION);
- unsubMessage.setHeader(CommandMessage.SUBSCRIPTION_INVALIDATED_HEADER, Boolean.TRUE);
- unsubMessage.setHeader(CommandMessage.SELECTOR_HEADER, subInfo.selector);
- unsubMessage.setHeader(AsyncMessage.SUBTOPIC_HEADER_NAME, subInfo.subtopic);
- unsubMessages.add(unsubMessage);
- }
- }
- // Release the lock and send the unsub messages.
- for (CommandMessage unsubMessage : unsubMessages)
- {
- try
- {
- destination.getService().serviceCommand(unsubMessage);
- }
- catch (MessageException me)
- {
- if (Log.isDebug())
- Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).debug("MessageClient: " + getClientId() + " issued an unsubscribe message during invalidation that was not processed but will continue with invalidation. Reason: " + ExceptionUtil.toString(me));
- }
- }
-
- synchronized (lock)
- {
- // If we didn't clean up all subscriptions log an error and continue with shutdown.
- int remainingSubscriptionCount = subscriptions.size();
- if (remainingSubscriptionCount > 0 && Log.isError())
- Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).error("MessageClient: " + getClientId() + " failed to remove " + remainingSubscriptionCount + " subscription(s) during invalidation");
- }
-
- // If someone registered this message client, invalidating it will free
- // their reference which will typically also remove this message client.
- if (registered && destination instanceof MessageDestination)
- ((MessageDestination)destination).getSubscriptionManager().releaseMessageClient(this);
-
- synchronized (lock)
- {
- valid = false;
- invalidating = false;
- }
-
- if (Log.isDebug())
- Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).debug("MessageClient with clientId '" + clientId + "' for destination '" + destinationId + "' has been invalidated.");
- }
-
- /**
- * Pushes the supplied message and then invalidates the MessageClient.
- *
- * @param message The message to push to the client before invalidating.
- * When message is null, MessageClient is invalidated silently.
- */
- public void invalidate(Message message)
- {
- if (message != null)
- {
- message.setDestination(destination.getId());
- message.setClientId(clientId);
-
- Set subscriberIds = new TreeSet();
- subscriberIds.add(clientId);
- try
- {
- if (destination instanceof MessageDestination)
- {
- MessageDestination msgDestination = (MessageDestination)destination;
- ((MessageService)msgDestination.getService()).pushMessageToClients(msgDestination, subscriberIds, message, false /* don't eval selector */);
- }
- }
- catch (MessageException ignore) {}
-
- invalidate(true /* attempt to notify remote client */);
- }
- else
- {
- invalidate();
- }
- }
-
- /**
- * @exclude
- * Compares this MessageClient to the specified object. The result is true if
- * the argument is not null and is a MessageClient instance with a matching
- * clientId value.
- *
- * @param o The object to compare this MessageClient to.
- * @return true if the MessageClient is equal; otherwise false.
- */
- public boolean equals(Object o)
- {
- if (o instanceof MessageClient)
- {
- MessageClient c = (MessageClient) o;
- if (c != null && c.getClientId().equals(clientId))
- return true;
- }
- return false;
- }
-
- /**
- * @exclude
- * Returns the hash code for this MessageClient. The returned value is
- * the hash code for the MessageClient's clientId property.
- *
- * @return The hash code value for this MessageClient.
- */
- @Override
- public int hashCode()
- {
- return getClientId().hashCode();
- }
-
- /**
- * @exclude
- * The String representation of this MessageClient is returned (its clientId value).
- *
- * @return The clientId value for this MessageClient.
- */
- @Override
- public String toString()
- {
- return String.valueOf(clientId);
- }
-
- //----------------------------------
- // TimeoutAbstractObject overrides
- //----------------------------------
-
- /**
- * @exclude
- * Implements TimeoutCapable.
- * This method returns the timeout value configured for the MessageClient's destination.
- */
- @Override
- public long getTimeoutPeriod()
- {
- return (destination instanceof MessageDestination) ?
- ((MessageDestination)destination).getSubscriptionManager().getSubscriptionTimeoutMillis() : 0;
- }
-
- /**
- * @exclude
- * Implements TimeoutCapable.
- * This method is invoked when the MessageClient has timed out and it
- * invalidates the MessageClient.
- */
- public void timeout()
- {
- invalidate(true /* notify client */);
- }
-
- /**
- * @exclude
- * Returns true if a timeout task is running for this MessageClient.
- */
- public boolean isTimingOut()
- {
- return willTimeout;
- }
-
- /**
- * @exclude
- * Records whether a timeout task is running for this MessageClient.
- */
- public void setTimingOut(boolean value)
- {
- willTimeout = value;
- }
-
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Utility method that tests validity and throws an exception if the instance
- * has been invalidated.
- */
- private void checkValid()
- {
- synchronized (lock)
- {
- if (!valid)
- {
- throw new RuntimeException("MessageClient has been invalidated."); // TODO - localize
- }
- }
- }
-
- private OutboundQueueThrottleManager getThrottleManager(boolean create)
- {
- if (flexClient != null)
- {
- FlexClientOutboundQueueProcessor processor = flexClient.getOutboundQueueProcessor(endpointId);
- if (processor != null)
- return create? processor.getOrCreateOutboundQueueThrottleManager() : processor.getOutboundQueueThrottleManager();
- }
- return null;
- }
-
- private void unregisterSubscriptionWithThrottleManager(SubscriptionInfo si)
- {
- OutboundQueueThrottleManager throttleManager = getThrottleManager(false);
- if (throttleManager != null)
- throttleManager.unregisterSubscription(destinationId, si);
- }
-
- //--------------------------------------------------------------------------
- //
- // Nested Classes
- //
- //--------------------------------------------------------------------------
-
- /**
- * Represents a MessageClient's subscription to a destination.
- * It captures the optional selector expression and subtopic for the
- * subscription.
- */
- public static class SubscriptionInfo implements Comparable
- {
- public String selector, subtopic;
- public int maxFrequency; // maxFrequency per subscription. Not used in BlazeDS.
-
- public SubscriptionInfo(String sel, String sub)
- {
- this(sel, sub, 0);
- }
-
- public SubscriptionInfo(String sel, String sub, int maxFrequency)
- {
- this.selector = sel;
- this.subtopic = sub;
- this.maxFrequency = maxFrequency;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (o instanceof SubscriptionInfo)
- {
- SubscriptionInfo other = (SubscriptionInfo) o;
- return equalStrings(other.selector, selector) &&
- equalStrings(other.subtopic, subtopic);
- }
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return (selector == null ? 0 : selector.hashCode()) +
- (subtopic == null ? 1 : subtopic.hashCode());
- }
-
- /**
- * Compares the two subscription infos (being careful to
- * ensure we compare in a consistent way if the arguments
- * are switched).
- * @param o the object to compare
- * @return int the compare result
- */
- public int compareTo(Object o)
- {
- SubscriptionInfo other = (SubscriptionInfo) o;
- int result;
-
- if ((result = compareStrings(other.selector, selector)) != 0)
- return result;
- else if ((result = compareStrings(other.subtopic, subtopic)) != 0)
- return result;
-
- return 0;
- }
-
- /**
- * Check whether the message matches with selected subtopic.
- * @param message current message
- * @param subtopicToMatch subtopc string
- * @param subtopicSeparator suptopic separator
- * @return true if the message matches the subtopic
- */
- public boolean matches(Message message, String subtopicToMatch, String subtopicSeparator)
- {
- if ((subtopicToMatch == null && subtopic != null) || (subtopicToMatch != null && subtopic == null))
- return false; // If either defines a subtopic, they both must define one.
-
- // If both define a subtopic, they must match.
- if (subtopicToMatch != null && subtopic != null)
- {
- Subtopic consumerSubtopic = new Subtopic(subtopic, subtopicSeparator);
- Subtopic messageSubtopic = new Subtopic(subtopicToMatch, subtopicSeparator);
- if (!consumerSubtopic.matches(messageSubtopic))
- return false; // Not a match.
- }
-
- if (selector == null)
- return true;
-
- JMSSelector jmsSelector = new JMSSelector(selector);
- try
- {
- if (jmsSelector.match(message))
- return true;
- }
- catch (JMSSelectorException jmse)
- {
- // Log a warning for this client's selector and continue
- if (Log.isWarn())
- {
- Log.getLogger(JMSSelector.LOG_CATEGORY).warn("Error processing message selector: " +
- jmse.toString() + StringUtils.NEWLINE +
- " incomingMessage: " + message + StringUtils.NEWLINE +
- " selector: " + selector + StringUtils.NEWLINE);
- }
- }
- return false;
- }
-
- /**
- * Returns a String representation of the subscription info.
- * @return String the string representation of the subscription info
- */
- public String toString()
- {
- StringBuffer sb = new StringBuffer();
- sb.append("Subtopic: " + subtopic + StringUtils.NEWLINE);
- sb.append("Selector: " + selector + StringUtils.NEWLINE);
- if (maxFrequency > 0)
- sb.append("maxFrequency: " + maxFrequency);
- return sb.toString();
- }
- }
-}
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import flex.messaging.client.FlexClient;
+import flex.messaging.client.FlexClientOutboundQueueProcessor;
+import flex.messaging.client.OutboundQueueThrottleManager;
+import flex.messaging.config.ThrottleSettings;
+import flex.messaging.config.ThrottleSettings.Policy;
+import flex.messaging.log.LogCategories;
+import flex.messaging.log.Log;
+import flex.messaging.messages.AsyncMessage;
+import flex.messaging.messages.CommandMessage;
+import flex.messaging.messages.Message;
+import flex.messaging.services.MessageService;
+import flex.messaging.services.messaging.Subtopic;
+import flex.messaging.services.messaging.selector.JMSSelector;
+import flex.messaging.services.messaging.selector.JMSSelectorException;
+import flex.messaging.util.ExceptionUtil;
+import flex.messaging.util.TimeoutAbstractObject;
+import flex.messaging.util.StringUtils;
+
+/**
+ * Represents a client-side MessageAgent instance.
+ * Currently a server-side MessageClient is only created if its client-side counterpart has subscribed
+ * to a destination for pushed data (e.g. Consumer). Client-side Producers do not result in the creation of
+ * corresponding server-side MessageClient instances.
+ *
+ * Client-side MessageAgents communicate with the server over a Channel that corresponds to a FlexSession.
+ * Server-side MessageClient instances are always created in the context of a FlexSession and when the FlexSession
+ * is invalidated any associated MessageClients are invalidated as well.
+ *
+ * MessageClients may also be timed out on a per-destination basis and this is based on subscription inactivity.
+ * If no messages are pushed to the MessageClient within the destination's subscription timeout period the
+ * MessageClient will be shutdown even if the associated FlexSession is still active and connected.
+ * Per-destination subscription timeout is an optional configuration setting, and should only be used when inactive
+ * subscriptions should be shut down opportunistically to preserve server resources.
+ */
+public class MessageClient extends TimeoutAbstractObject implements Serializable
+{
+ //--------------------------------------------------------------------------
+ //
+ // Public Static Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Log category for MessageClient related messages.
+ */
+ public static final String MESSAGE_CLIENT_LOG_CATEGORY = LogCategories.CLIENT_MESSAGECLIENT;
+
+ //--------------------------------------------------------------------------
+ //
+ // Static Constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Serializable to support broadcasting subscription state across the cluster for
+ * optimized message routing.
+ */
+ static final long serialVersionUID = 3730240451524954453L;
+
+ //--------------------------------------------------------------------------
+ //
+ // Static Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The list of MessageClient created listeners.
+ */
+ private static final CopyOnWriteArrayList<MessageClientListener> createdListeners = new CopyOnWriteArrayList<MessageClientListener>();
+
+ //--------------------------------------------------------------------------
+ //
+ // Static Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Adds a MessageClient created listener.
+ *
+ * @see flex.messaging.MessageClientListener
+ *
+ * @param listener The listener to add.
+ */
+ public static void addMessageClientCreatedListener(MessageClientListener listener)
+ {
+ if (listener != null)
+ createdListeners.addIfAbsent(listener);
+ }
+
+ /**
+ * Removes a MessageClient created listener.
+ *
+ * @see flex.messaging.MessageClientListener
+ *
+ * @param listener The listener to remove.
+ */
+ public static void removeMessageClientCreatedListener(MessageClientListener listener)
+ {
+ if (listener != null)
+ createdListeners.remove(listener);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Static Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Utility method.
+ */
+ private static boolean equalStrings(String a, String b)
+ {
+ return a == b || (a != null && a.equals(b));
+ }
+
+ /**
+ * Utility method.
+ */
+ static int compareStrings(String a, String b)
+ {
+ if (a == b)
+ return 0;
+
+ if (a != null && b != null)
+ return a.compareTo(b);
+
+ if (a == null)
+ return -1;
+
+ return 1;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @exclude
+ * Constructs a new MessageClient for local use.
+ *
+ * @param clientId The clientId for the MessageClient.
+ * @param destination The destination the MessageClient is subscribed to.
+ * @param endpointId The Id of the endpoint this MessageClient subscription was created over.
+ */
+ public MessageClient(Object clientId, Destination destination, String endpointId)
+ {
+ this(clientId, destination, endpointId, true);
+ }
+
+ /**
+ * @exclude
+ * Constructs a new MessageClient.
+ *
+ * @param clientId The clientId for the MessageClient.
+ * @param destination The destination the MessageClient is subscribed to.
+ * @param endpointId The Id of the endpoint this MessageClient subscription was created over.
+ * @param useSession RemoteMessageClient instances should not be associated with a FlexSession (pass false).
+ */
+ public MessageClient(Object clientId, Destination destination, String endpointId, boolean useSession)
+ {
+ valid = true;
+ this.clientId = clientId;
+ this.destination = destination;
+ this.endpointId = endpointId;
+ destinationId = destination.getId();
+ updateLastUse(); // Initialize last use timestamp to construct time.
+
+ /* If this is for a remote server, we do not associate with the session. */
+ if (useSession)
+ {
+ flexSession = FlexContext.getFlexSession();
+ flexSession.registerMessageClient(this);
+
+ flexClient = FlexContext.getFlexClient();
+ flexClient.registerMessageClient(this);
+
+ // SubscriptionManager will notify the created listeners, once
+ // subscription state is setup completely.
+ // notifyCreatedListeners();
+ }
+ else
+ {
+ flexClient = null;
+ flexSession = null;
+ // Use an instance level lock.
+ lock = new Object();
+ // On a remote server we don't notify created listeners.
+ }
+
+ if (Log.isDebug())
+ Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).debug("MessageClient created with clientId '" + this.clientId + "' for destination '" + destinationId + "'.");
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * This flag is set to true when the client channel that this subscription was
+ * established over is disconnected.
+ * It supports cleaning up per-endpoint outbound queues maintained by the FlexClient.
+ * If the client notifies the server that its channel is disconnecting, the FlexClient
+ * does not need to maintain an outbound queue containing a subscription invalidation
+ * message for this MessageClient to send to the client.
+ */
+ private volatile boolean clientChannelDisconnected;
+
+ /**
+ * The clientId for the MessageClient.
+ * This value is specified by the client directly or is autogenerated on the client.
+ */
+ protected final Object clientId;
+
+ /**
+ * Internal reference to the associated Destination; don't expose this in the public API.
+ */
+ protected final Destination destination;
+
+ /**
+ * The destination the MessageClient is subscribed to.
+ */
+ protected final String destinationId;
+
+ /**
+ * The set of session destroy listeners to notify when the session is destroyed.
+ */
+ private transient volatile CopyOnWriteArrayList destroyedListeners;
+
+ /**
+ * The Id for the endpoint this MessageClient subscription was created over.
+ */
+ private String endpointId;
+
+ /**
+ * The FlexClient associated with the MessageClient.
+ */
+ private final transient FlexClient flexClient;
+
+ /**
+ * The FlexSession associated with the MessageClient.
+ * Not final because this needs to be reset if the subscription fails over to a new endpoint.
+ */
+ private transient FlexSession flexSession;
+
+ /**
+ * Flag used to break cycles during invalidation.
+ */
+ private boolean invalidating;
+
+ /**
+ * The lock to use to guard all state changes for the MessageClient.
+ */
+ protected Object lock = new Object();
+
+ /**
+ * Flag indicating whether the MessageClient is attempting to notify the remote client of
+ * its invalidation.
+ */
+ private volatile boolean attemptingInvalidationClientNotification;
+
+ /**
+ * A counter used to control invalidation for a MessageClient that has multiple
+ * subscriptions to its destination.
+ * Unsubscribing from one will not invalidate the MessageClient as long as other
+ * subscriptions remain active.
+ */
+ private transient int numReferences;
+
+ /**
+ * A set of all of the subscriptions managed by this message client.
+ */
+ protected final Set<SubscriptionInfo> subscriptions = new CopyOnWriteArraySet<SubscriptionInfo>();
+
+ /**
+ * Flag indicating whether this client is valid or not.
+ */
+ protected boolean valid;
+
+ /**
+ * Flag that indicates whether the MessageClient has a per-destination subscription timeout.
+ * If false, the MessageClient will remain valid until its associated FlexSession is invalidated.
+ */
+ private volatile boolean willTimeout;
+
+ /**
+ * Has anyone explicitly registered this message client. This indicates that
+ * there is a reference to this MessageClient which is not an explicit subscription.
+ * This is a hook for FDMS and other adapters which want to use pushMessageToClients
+ * with clientIds but that do not want the subscription manager to manage subscriptions
+ * for them.
+ */
+ private volatile boolean registered = false;
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns the clientId for the MessageClient.
+ *
+ * @return The clientId for the MessageClient.
+ */
+ public Object getClientId()
+ {
+ return clientId; // Field is final; no need to sync.
+ }
+
+ /**
+ * Returns the destination the MessageClient is subscribed to.
+ *
+ * @return The destination the MessageClient is subscribed to.
+ */
+ public Destination getDestination()
+ {
+ return destination; // Field is final; no need to sync.
+ }
+
+ /**
+ * Returns the id of the destination the MessageClient is subscribed to.
+ *
+ * @return The id of the destination the MessageClient is subscribed to.
+ */
+ public String getDestinationId()
+ {
+ return destinationId; // Field is final; no need to sync.
+ }
+
+ /**
+ * Returns the Id for the endpoint the MessageClient subscription was created over.
+ *
+ * @return The Id for the endpoint the MessageClient subscription was created over.
+ */
+ public String getEndpointId()
+ {
+ return endpointId; // Field is final; no need to sync.
+ }
+
+ /**
+ * Returns the FlexClient associated with this MessageClient.
+ *
+ * @return The FlexClient assocaited with this MessageClient.
+ */
+ public FlexClient getFlexClient()
+ {
+ return flexClient; // Field is final; no need to sync.
+ }
+
+ /**
+ * Returns the FlexSession associated with this MessageClient.
+ *
+ * @return The FlexSession associated with this MessageClient.
+ */
+ public FlexSession getFlexSession()
+ {
+ synchronized (lock)
+ {
+ return flexSession;
+ }
+ }
+
+ /**
+ * Returns the number of subscriptions associated with this MessageClient.
+ *
+ * @return The number of subscriptions associated with this MessageClient.
+ */
+ public int getSubscriptionCount()
+ {
+ int count;
+
+ synchronized (lock)
+ {
+ count = subscriptions != null? subscriptions.size() : 0;
+ }
+
+ return count;
+ }
+
+ /**
+ * @exclude
+ * This is used for FlexClient outbound queue management. When a MessageClient is invalidated
+ * if it is attempting to notify the client, then we must leave the outbound queue containing
+ * the notification in place. Otherwise, any messages queued for the subscription may be
+ * removed from the queue and possibly shut down immediately.
+ */
+ public boolean isAttemptingInvalidationClientNotification()
+ {
+ return attemptingInvalidationClientNotification;
+ }
+
+ /**
+ * @exclude
+ * This is set to true when the MessageClient is invalidated due to the client
+ * channel the subscription was established over disconnecting.
+ * It allows the FlexClient class to cleanup the outbound queue for the channel's
+ * corresponding server endpoint for the remote client, because we know that no
+ * currently queued messages need to be retained for delivery.
+ */
+ public void setClientChannelDisconnected(boolean value)
+ {
+ clientChannelDisconnected = value;
+ }
+
+ /**
+ * @exclude
+ */
+ public boolean isClientChannelDisconnected()
+ {
+ return clientChannelDisconnected;
+ }
+
+ /**
+ * @exclude
+ * This is true when some code other than the SubscriptionManager
+ * is maintaining subscriptions for this message client. It ensures
+ * that we have this MessageClient kept around until the session
+ * expires.
+ */
+ public void setRegistered(boolean reg)
+ {
+ registered = reg;
+ }
+
+ /**
+ * @exclude
+ */
+ public boolean isRegistered()
+ {
+ return registered;
+ }
+
+ /**
+ * Adds a MessageClient destroy listener.
+ *
+ * @see flex.messaging.MessageClientListener
+ *
+ * @param listener The listener to add.
+ */
+ public void addMessageClientDestroyedListener(MessageClientListener listener)
+ {
+ if (listener != null)
+ {
+ checkValid();
+
+ if (destroyedListeners == null)
+ {
+ synchronized (lock)
+ {
+ if (destroyedListeners == null)
+ destroyedListeners = new CopyOnWriteArrayList();
+ }
+ }
+
+ destroyedListeners.addIfAbsent(listener);
+ }
+ }
+
+ /**
+ * Removes a MessageClient destroyed listener.
+ *
+ * @see flex.messaging.MessageClientListener
+ *
+ * @param listener The listener to remove.
+ */
+ public void removeMessageClientDestroyedListener(MessageClientListener listener)
+ {
+ // No need to check validity; removing a listener is always ok.
+ if (listener != null && destroyedListeners != null)
+ destroyedListeners.remove(listener);
+ }
+
+ /**
+ * @exclude
+ * Adds a subscription to the subscription set for this MessageClient.
+ *
+ * @param selector The selector expression used for the subscription.
+ * @param subtopic The subtopic used for the subscription.
+ * @param maxFrequency The maximum number of messages the client wants to
+ * receive per second (0 disables this limit).
+ */
+ public void addSubscription(String selector, String subtopic, int maxFrequency)
+ {
+ synchronized (lock)
+ {
+ checkValid();
+
+ incrementReferences();
+
+ // Create and add the subscription to the subscriptions set.
+ SubscriptionInfo si = new SubscriptionInfo(selector, subtopic, maxFrequency);
+ subscriptions.add(si);
+
+ registerSubscriptionWithThrottleManager(si);
+ }
+ }
+
+ /**
+ * @exclude
+ * Registers the subscription with the outbound queue processor's throttle
+ * manager, if one exists.
+ *
+ * @param si The subscription info object.
+ */
+ public void registerSubscriptionWithThrottleManager(SubscriptionInfo si)
+ {
+ // Register the destination that will setup client level outbound throttling.
+ ThrottleSettings ts = destination.getNetworkSettings().getThrottleSettings();
+ if (ts.getOutboundPolicy() != Policy.NONE && (ts.isOutboundClientThrottleEnabled() || si.maxFrequency > 0))
+ {
+ // Setup the client level outbound throttling, and register the destination
+ // only if the policy is not NONE, and a throttling limit is specified
+ // either at the destination or by consumer.
+ OutboundQueueThrottleManager throttleManager = getThrottleManager(true);
+ if (throttleManager != null)
+ throttleManager.registerDestination(destinationId, ts.getOutgoingClientFrequency(), ts.getOutboundPolicy());
+ }
+ else if (si.maxFrequency > 0) // Let the client know that maxFrequency will be ignored.
+ {
+ if (Log.isWarn())
+ Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).warn("MessageClient with clientId '"
+ + clientId + "' for destination '" + destinationId
+ + "' specified a maxFrequency value of '" + si.maxFrequency
+ + "' but the destination does not define a throttling policy. This value will be ignored.");
+ }
+
+ // Now, register the subscription.
+ OutboundQueueThrottleManager throttleManager = getThrottleManager(false);
+ if (throttleManager != null)
+ throttleManager.registerSubscription(destinationId, si);
+ }
+
+ /**
+ * @exclude
+ * Removes a subscription from the subscription set for this MessageClient.
+ *
+ * @param selector The selector expression for the subscription.
+ * @param subtopic The subtopic for the subscription.
+ * @return true if no subscriptions remain for this MessageClient; otherwise false.
+ */
+ public boolean removeSubscription(String selector, String subtopic)
+ {
+ synchronized (lock)
+ {
+ SubscriptionInfo si = new SubscriptionInfo(selector, subtopic);
+ if (subscriptions.remove(si))
+ {
+ unregisterSubscriptionWithThrottleManager(si);
+ return decrementReferences();
+ }
+ else if (Log.isError())
+ {
+ Log.getLogger(MessageService.LOG_CATEGORY).error("Error - unable to find subscription to remove for MessageClient: "
+ + clientId + " selector: " + selector + " subtopic: " + subtopic);
+ }
+ return numReferences == 0;
+ }
+ }
+
+ /**
+ * @exclude
+ * We use the same MessageClient for more than one subscription with different
+ * selection criteria. This tracks the number of subscriptions that are active
+ * so that we know when we are finished.
+ */
+ public void incrementReferences()
+ {
+ synchronized (lock)
+ {
+ numReferences++;
+ }
+ }
+
+ /**
+ * @exclude
+ * Decrements the numReferences variable and returns true if this was the last reference.
+ */
+ public boolean decrementReferences()
+ {
+ synchronized (lock)
+ {
+ if (--numReferences == 0)
+ {
+ cancelTimeout();
+ if (destination instanceof MessageDestination)
+ {
+ MessageDestination msgDestination = (MessageDestination)destination;
+ if (msgDestination.getThrottleManager() != null)
+ msgDestination.getThrottleManager().removeClientThrottleMark(clientId);
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /**
+ * @exclude
+ * Invoked by SubscriptionManager once the subscription state is setup completely
+ * for the MessageClient..
+ */
+ public void notifyCreatedListeners()
+ {
+ // Notify MessageClient created listeners.
+ if (!createdListeners.isEmpty())
+ {
+ // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
+ for (Iterator iter = createdListeners.iterator(); iter.hasNext();)
+ ((MessageClientListener)iter.next()).messageClientCreated(this);
+ }
+ }
+
+ /**
+ * @exclude
+ * Invoked by SubscriptionManager while handling a subscribe request.
+ * If the request is updating an existing subscription the 'push' state in the associated FlexClient
+ * may need to be updated to ensure that the correct endpoint is used for this subscription.
+ *
+ * @param newEndpointId The id for the new endpoint that the subscription may have failed over to.
+ */
+ public void resetEndpoint(String newEndpointId)
+ {
+ String oldEndpointId = null;
+ FlexSession oldSession = null;
+ FlexSession newSession = FlexContext.getFlexSession();
+ synchronized (lock)
+ {
+ // If anything is null, or nothing has changed, no need for a reset.
+ if (endpointId == null || newEndpointId == null || flexSession == null || newSession == null || (endpointId.equals(newEndpointId) && flexSession.equals(newSession)))
+ return;
+
+ oldEndpointId = endpointId;
+ endpointId = newEndpointId;
+
+ oldSession = flexSession;
+ flexSession = newSession;
+ }
+
+ // Unregister in order to reset the proper push settings in the re-registration below once the session association has been patched.
+ if (flexClient != null)
+ flexClient.unregisterMessageClient(this);
+
+ // Clear out any reference to this subscription that the previously associated session has.
+ if (oldSession != null)
+ oldSession.unregisterMessageClient(this);
+
+ // Associate the current session with this subscription.
+ if (flexSession != null)
+ flexSession.registerMessageClient(this);
+
+ // Reset proper push settings.
+ if (flexClient != null)
+ flexClient.registerMessageClient(this);
+
+ if (Log.isDebug())
+ {
+ String msg = "MessageClient with clientId '" + clientId + "' for destination '" + destinationId + "' has been reset as a result of a resubscribe.";
+ if (oldEndpointId != null && !oldEndpointId.equals(newEndpointId))
+ msg += " Endpoint change [" + oldEndpointId + " -> " + newEndpointId + "]";
+ if ((oldSession != null) && (newSession != null) && (oldSession != newSession)) // Test identity.
+ msg += " FlexSession change [" + oldSession.getClass().getName() + ":" + oldSession.getId() + " -> " + newSession.getClass().getName() + ":" + newSession.getId() + "]";
+
+ Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).debug(msg);
+ }
+ }
+
+ /**
+ * @exclude
+ * Used to test whether this client should receive this message
+ * based on the list of subscriptions we have recorded for it.
+ * It must match both the subtopic and the selector expression.
+ * Usually this is done by the subscription manager - this logic is
+ * only here to maintain api compatibility with one of the variants
+ * of the pushMessageToClients which has subscriberIds and an evalSelector
+ * property.
+ *
+ * @param message The message to test.
+ */
+ public boolean testMessage(Message message, MessageDestination destination)
+ {
+ String subtopic = (String) message.getHeader(AsyncMessage.SUBTOPIC_HEADER_NAME);
+ String subtopicSeparator = destination.getServerSettings().getSubtopicSeparator();
+ synchronized (lock)
+ {
+ for (SubscriptionInfo si : subscriptions)
+ {
+ if (si.matches(message, subtopic, subtopicSeparator))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if the MessageClient is valid; false if it has been invalidated.
+ *
+ * @return true if the MessageClient is valid; otherwise false.
+ */
+ public boolean isValid()
+ {
+ synchronized (lock)
+ {
+ return valid;
+ }
+ }
+
+ /**
+ * Invalidates the MessageClient.
+ */
+ public void invalidate()
+ {
+ invalidate(false /* don't attempt to notify the client */);
+ }
+
+ /**
+ * Invalidates the MessageClient, and optionally attempts to notify the client that
+ * this subscription has been invalidated.
+ * This overload is used when a subscription is timed out while the client is still
+ * actively connected to the server but should also be used by any custom code on the server
+ * that invalidates MessageClients but wishes to notify the client cleanly.
+ *
+ * @param notifyClient <code>true</code> to notify the client that its subscription has been
+ * invalidated.
+ */
+ public void invalidate(boolean notifyClient)
+ {
+ synchronized (lock)
+ {
+ if (!valid || invalidating)
+ return; // Already shutting down.
+
+ invalidating = true; // This thread gets to shut the MessageClient down.
+ cancelTimeout();
+ }
+
+ // Record whether we're attempting to notify the client or not.
+ attemptingInvalidationClientNotification = notifyClient;
+
+ // Build a subscription invalidation message and push to the client if it is still valid.
+ if (notifyClient && flexClient != null && flexClient.isValid())
+ {
+ CommandMessage msg = new CommandMessage();
+ msg.setDestination(destination.getId());
+ msg.setClientId(clientId);
+ msg.setOperation(CommandMessage.SUBSCRIPTION_INVALIDATE_OPERATION);
+ Set subscriberIds = new TreeSet();
+ subscriberIds.add(clientId);
+ try
+ {
+ if (destination instanceof MessageDestination)
+ {
+ MessageDestination msgDestination = (MessageDestination)destination;
+ ((MessageService)msgDestination.getService()).pushMessageToClients(msgDestination, subscriberIds, msg, false /* don't eval selector */);
+ }
+ }
+ catch (MessageException ignore) {}
+ }
+
+ // Notify messageClientDestroyed listeners that we're being invalidated.
+ if (destroyedListeners != null && !destroyedListeners.isEmpty())
+ {
+ for (Iterator iter = destroyedListeners.iterator(); iter.hasNext();)
+ {
+ ((MessageClientListener)iter.next()).messageClientDestroyed(this);
+ }
+ destroyedListeners.clear();
+ }
+
+ // And generate unsubscribe messages for all of the MessageClient's subscriptions and
+ // route them to the destination this MessageClient is subscribed to.
+ // The reason we send a message to the service rather than just going straight to the SubscriptionManager
+ // is that some adapters manage their own subscription state (i.e. JMS) in addition to us keeping track of
+ // things with our SubscriptionManager.
+ ArrayList<CommandMessage> unsubMessages = new ArrayList<CommandMessage>();
+ synchronized (lock)
+ {
+ for (SubscriptionInfo subInfo : subscriptions)
+ {
+ CommandMessage unsubMessage = new CommandMessage();
+ unsubMessage.setDestination(destination.getId());
+ unsubMessage.setClientId(clientId);
+ unsubMessage.setOperation(CommandMessage.UNSUBSCRIBE_OPERATION);
+ unsubMessage.setHeader(CommandMessage.SUBSCRIPTION_INVALIDATED_HEADER, Boolean.TRUE);
+ unsubMessage.setHeader(CommandMessage.SELECTOR_HEADER, subInfo.selector);
+ unsubMessage.setHeader(AsyncMessage.SUBTOPIC_HEADER_NAME, subInfo.subtopic);
+ unsubMessages.add(unsubMessage);
+ }
+ }
+ // Release the lock and send the unsub messages.
+ for (CommandMessage unsubMessage : unsubMessages)
+ {
+ try
+ {
+ destination.getService().serviceCommand(unsubMessage);
+ }
+ catch (MessageException me)
+ {
+ if (Log.isDebug())
+ Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).debug("MessageClient: " + getClientId() + " issued an unsubscribe message during invalidation that was not processed but will continue with invalidation. Reason: " + ExceptionUtil.toString(me));
+ }
+ }
+
+ synchronized (lock)
+ {
+ // If we didn't clean up all subscriptions log an error and continue with shutdown.
+ int remainingSubscriptionCount = subscriptions.size();
+ if (remainingSubscriptionCount > 0 && Log.isError())
+ Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).error("MessageClient: " + getClientId() + " failed to remove " + remainingSubscriptionCount + " subscription(s) during invalidation");
+ }
+
+ // If someone registered this message client, invalidating it will free
+ // their reference which will typically also remove this message client.
+ if (registered && destination instanceof MessageDestination)
+ ((MessageDestination)destination).getSubscriptionManager().releaseMessageClient(this);
+
+ synchronized (lock)
+ {
+ valid = false;
+ invalidating = false;
+ }
+
+ if (Log.isDebug())
+ Log.getLogger(MESSAGE_CLIENT_LOG_CATEGORY).debug("MessageClient with clientId '" + clientId + "' for destination '" + destinationId + "' has been invalidated.");
+ }
+
+ /**
+ * Pushes the supplied message and then invalidates the MessageClient.
+ *
+ * @param message The message to push to the client before invalidating.
+ * When message is null, MessageClient is invalidated silently.
+ */
+ public void invalidate(Message message)
+ {
+ if (message != null)
+ {
+ message.setDestination(destination.getId());
+ message.setClientId(clientId);
+
+ Set subscriberIds = new TreeSet();
+ subscriberIds.add(clientId);
+ try
+ {
+ if (destination instanceof MessageDestination)
+ {
+ MessageDestination msgDestination = (MessageDestination)destination;
+ ((MessageService)msgDestination.getService()).pushMessageToClients(msgDestination, subscriberIds, message, false /* don't eval selector */);
+ }
+ }
+ catch (MessageException ignore) {}
+
+ invalidate(true /* attempt to notify remote client */);
+ }
+ else
+ {
+ invalidate();
+ }
+ }
+
+ /**
+ * @exclude
+ * Compares this MessageClient to the specified object. The result is true if
+ * the argument is not null and is a MessageClient instance with a matching
+ * clientId value.
+ *
+ * @param o The object to compare this MessageClient to.
+ * @return true if the MessageClient is equal; otherwise false.
+ */
+ public boolean equals(Object o)
+ {
+ if (o instanceof MessageClient)
+ {
+ MessageClient c = (MessageClient) o;
+ if (c != null && c.getClientId().equals(clientId))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @exclude
+ * Returns the hash code for this MessageClient. The returned value is
+ * the hash code for the MessageClient's clientId property.
+ *
+ * @return The hash code value for this MessageClient.
+ */
+ @Override
+ public int hashCode()
+ {
+ return getClientId().hashCode();
+ }
+
+ /**
+ * @exclude
+ * The String representation of this MessageClient is returned (its clientId value).
+ *
+ * @return The clientId value for this MessageClient.
+ */
+ @Override
+ public String toString()
+ {
+ return String.valueOf(clientId);
+ }
+
+ //----------------------------------
+ // TimeoutAbstractObject overrides
+ //----------------------------------
+
+ /**
+ * @exclude
+ * Implements TimeoutCapable.
+ * This method returns the timeout value configured for the MessageClient's destination.
+ */
+ @Override
+ public long getTimeoutPeriod()
+ {
+ return (destination instanceof MessageDestination) ?
+ ((MessageDestination)destination).getSubscriptionManager().getSubscriptionTimeoutMillis() : 0;
+ }
+
+ /**
+ * @exclude
+ * Implements TimeoutCapable.
+ * This method is invoked when the MessageClient has timed out and it
+ * invalidates the MessageClient.
+ */
+ public void timeout()
+ {
+ invalidate(true /* notify client */);
+ }
+
+ /**
+ * @exclude
+ * Returns true if a timeout task is running for this MessageClient.
+ */
+ public boolean isTimingOut()
+ {
+ return willTimeout;
+ }
+
+ /**
+ * @exclude
+ * Records whether a timeout task is running for this MessageClient.
+ */
+ public void setTimingOut(boolean value)
+ {
+ willTimeout = value;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Utility method that tests validity and throws an exception if the instance
+ * has been invalidated.
+ */
+ private void checkValid()
+ {
+ synchronized (lock)
+ {
+ if (!valid)
+ {
+ throw new RuntimeException("MessageClient has been invalidated."); // TODO - localize
+ }
+ }
+ }
+
+ private OutboundQueueThrottleManager getThrottleManager(boolean create)
+ {
+ if (flexClient != null)
+ {
+ FlexClientOutboundQueueProcessor processor = flexClient.getOutboundQueueProcessor(endpointId);
+ if (processor != null)
+ return create? processor.getOrCreateOutboundQueueThrottleManager() : processor.getOutboundQueueThrottleManager();
+ }
+ return null;
+ }
+
+ private void unregisterSubscriptionWithThrottleManager(SubscriptionInfo si)
+ {
+ OutboundQueueThrottleManager throttleManager = getThrottleManager(false);
+ if (throttleManager != null)
+ throttleManager.unregisterSubscription(destinationId, si);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Nested Classes
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Represents a MessageClient's subscription to a destination.
+ * It captures the optional selector expression and subtopic for the
+ * subscription.
+ */
+ public static class SubscriptionInfo implements Comparable
+ {
+ public String selector, subtopic;
+ public int maxFrequency; // maxFrequency per subscription. Not used in BlazeDS.
+
+ public SubscriptionInfo(String sel, String sub)
+ {
+ this(sel, sub, 0);
+ }
+
+ public SubscriptionInfo(String sel, String sub, int maxFrequency)
+ {
+ this.selector = sel;
+ this.subtopic = sub;
+ this.maxFrequency = maxFrequency;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (o instanceof SubscriptionInfo)
+ {
+ SubscriptionInfo other = (SubscriptionInfo) o;
+ return equalStrings(other.selector, selector) &&
+ equalStrings(other.subtopic, subtopic);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return (selector == null ? 0 : selector.hashCode()) +
+ (subtopic == null ? 1 : subtopic.hashCode());
+ }
+
+ /**
+ * Compares the two subscription infos (being careful to
+ * ensure we compare in a consistent way if the arguments
+ * are switched).
+ * @param o the object to compare
+ * @return int the compare result
+ */
+ public int compareTo(Object o)
+ {
+ SubscriptionInfo other = (SubscriptionInfo) o;
+ int result;
+
+ if ((result = compareStrings(other.selector, selector)) != 0)
+ return result;
+ else if ((result = compareStrings(other.subtopic, subtopic)) != 0)
+ return result;
+
+ return 0;
+ }
+
+ /**
+ * Check whether the message matches with selected subtopic.
+ * @param message current message
+ * @param subtopicToMatch subtopc string
+ * @param subtopicSeparator suptopic separator
+ * @return true if the message matches the subtopic
+ */
+ public boolean matches(Message message, String subtopicToMatch, String subtopicSeparator)
+ {
+ if ((subtopicToMatch == null && subtopic != null) || (subtopicToMatch != null && subtopic == null))
+ return false; // If either defines a subtopic, they both must define one.
+
+ // If both define a subtopic, they must match.
+ if (subtopicToMatch != null && subtopic != null)
+ {
+ Subtopic consumerSubtopic = new Subtopic(subtopic, subtopicSeparator);
+ Subtopic messageSubtopic = new Subtopic(subtopicToMatch, subtopicSeparator);
+ if (!consumerSubtopic.matches(messageSubtopic))
+ return false; // Not a match.
+ }
+
+ if (selector == null)
+ return true;
+
+ JMSSelector jmsSelector = new JMSSelector(selector);
+ try
+ {
+ if (jmsSelector.match(message))
+ return true;
+ }
+ catch (JMSSelectorException jmse)
+ {
+ // Log a warning for this client's selector and continue
+ if (Log.isWarn())
+ {
+ Log.getLogger(JMSSelector.LOG_CATEGORY).warn("Error processing message selector: " +
+ jmse.toString() + StringUtils.NEWLINE +
+ " incomingMessage: " + message + StringUtils.NEWLINE +
+ " selector: " + selector + StringUtils.NEWLINE);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns a String representation of the subscription info.
+ * @return String the string representation of the subscription info
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Subtopic: " + subtopic + StringUtils.NEWLINE);
+ sb.append("Selector: " + selector + StringUtils.NEWLINE);
+ if (maxFrequency > 0)
+ sb.append("maxFrequency: " + maxFrequency);
+ return sb.toString();
+ }
+ }
+}
[13/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/ServerSettings.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/ServerSettings.java b/modules/core/src/flex/messaging/config/ServerSettings.java
old mode 100755
new mode 100644
index d61229f..77f61e9
--- a/modules/core/src/flex/messaging/config/ServerSettings.java
+++ b/modules/core/src/flex/messaging/config/ServerSettings.java
@@ -1,231 +1,231 @@
-/*
- * 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.config;
-
-import flex.messaging.services.messaging.MessagingConstants;
-
-/**
- * Server settings for a message destination.
- */
-public class ServerSettings
-{
- // Errors
- private static final int INVALID_CLUSTER_MESSAGE_ROUTING = 11121;
-
- private boolean allowSubtopics;
- private boolean disallowWildcardSubtopics;
- private long messageTTL = -1; //We need to keep track of uninitialized value
- private boolean isDurable;
- private int priority = -1;
- private String subtopicSeparator;
- private RoutingMode routingMode = RoutingMode.SERVER_TO_SERVER;
-
- public static enum RoutingMode {NONE,BROADCAST,SERVER_TO_SERVER};
-
- /**
- * Creates a default <code>ServerSettings</code> instance.
- */
- public ServerSettings()
- {
- isDurable = false;
- subtopicSeparator = MessagingConstants.DEFAULT_SUBTOPIC_SEPARATOR;
- }
-
- /**
- * Returns <code>allow-subtopics</code> property.
- *
- * @return a boolean specifying whether or not the server has the <code>allow-subtopics</code> property.
- */
- public boolean getAllowSubtopics()
- {
- return allowSubtopics;
- }
-
- /**
- * Sets <code>allow-subtopics</code> property.
- *
- * @param value The value for <code>allow-subtopics</code> property.
- */
- public void setAllowSubtopics(boolean value)
- {
- allowSubtopics = value;
- }
-
- /**
- * Returns <code>cluster-message-routing</code> property.
- *
- * @return a boolean specifying whether or not the server has the <code>cluster-message-routing</code> property.
- */
- public boolean isBroadcastRoutingMode()
- {
- return routingMode == RoutingMode.BROADCAST;
- }
-
- /**
- * Returns the routing mode configured.
- *
- * @return The configured routing mode.
- */
- public RoutingMode getRoutingMode()
- {
- return routingMode;
- }
-
- /**
- * Sets the <code>cluster-message-routing</code> property.
- *
- * @param routingMode <code>server-to-server</code>(default)
- * or <code>broadcast</code>.
- */
- public void setBroadcastRoutingMode(String routingMode)
- {
- if (routingMode.equalsIgnoreCase("broadcast"))
- this.routingMode = RoutingMode.BROADCAST;
- else if (routingMode.equalsIgnoreCase("server-to-server"))
- this.routingMode = RoutingMode.SERVER_TO_SERVER;
- else if (routingMode.equalsIgnoreCase("none"))
- this.routingMode = RoutingMode.NONE;
- else
- {
- ConfigurationException ce = new ConfigurationException();
- ce.setMessage(INVALID_CLUSTER_MESSAGE_ROUTING, new Object[] {routingMode});
- throw ce;
- }
- }
-
- /**
- * @deprecated Not used anymore.
- */
- public int getMaxCacheSize()
- {
- return 0;
- }
-
- /**
- * @deprecated Not used anymore.
- */
- public void setMaxCacheSize(int size)
- {
- // No-op.
- }
-
- /**
- * Returns the <code>message-time-to-live</code> property.
- *
- * @return the <code>message-time-to-live</code> property.
- */
- public long getMessageTTL()
- {
- return messageTTL;
- }
-
- /**
- * Sets the <code>message-time-to-live</code> property. Default value is -1.
- *
- * @param ttl The value for <code>message-time-to-live</code> property.
- */
- public void setMessageTTL(long ttl)
- {
- messageTTL = ttl;
- }
-
- /**
- * Returns true if wildcard subtopics are disallowed.
- *
- * @return true if wilcard subtopics are disallowed.
- */
- public boolean isDisallowWildcardSubtopics()
- {
- return disallowWildcardSubtopics;
- }
-
- /**
- * Sets whether the wildcard subtopics are disallowed.
- *
- * @param value Whether the wildcard subtopics are disallowed.
- */
- public void setDisallowWildcardSubtopics(boolean value)
- {
- disallowWildcardSubtopics = value;
- }
-
- /**
- * Returns whether destination is durable.
- *
- * @return <code>true</code> if destination is durable; otherwise <code>false</code>.
- */
- public boolean isDurable()
- {
- return isDurable;
- }
-
- /**
- * Sets whether destination is durable. Default value is <code>false</code>.
- *
- * @param durable The value for <code>durable</code> property.
- */
- public void setDurable(boolean durable)
- {
- isDurable = durable;
- }
-
- /**
- * Returns the default message priority for the destination which is a numerical
- * value between 0 and 9 (and -1 means no default priority).
- *
- * @return The default message priority for the destination.
- */
- public int getPriority()
- {
- return priority;
- }
-
- /**
- * Sets the default message priority of the destination which should be
- * a numerical value between 0 and 9. Values less than 0 and greater than 9
- * are treated as 0 and 9 respectively.
- *
- * @param priority The new value for the priority.
- */
- public void setPriority(int priority)
- {
- priority = priority < 0? 0 : priority > 9? 9 : priority;
- this.priority = priority;
- }
-
-
- /**
- * Returns the <code>subtopic-separator</code> property.
- *
- * @return the <code>subtopic-separator</code> property.
- */
- public String getSubtopicSeparator()
- {
- return subtopicSeparator;
- }
-
- /**
- * Sets the <code>subtopic-separator</code> property.
- * Optional; the default value is period.
- *
- * @param value The value for <code>subtopic-separator</code> property.
- */
- public void setSubtopicSeparator(String value)
- {
- subtopicSeparator = value;
- }
-}
+/*
+ * 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.config;
+
+import flex.messaging.services.messaging.MessagingConstants;
+
+/**
+ * Server settings for a message destination.
+ */
+public class ServerSettings
+{
+ // Errors
+ private static final int INVALID_CLUSTER_MESSAGE_ROUTING = 11121;
+
+ private boolean allowSubtopics;
+ private boolean disallowWildcardSubtopics;
+ private long messageTTL = -1; //We need to keep track of uninitialized value
+ private boolean isDurable;
+ private int priority = -1;
+ private String subtopicSeparator;
+ private RoutingMode routingMode = RoutingMode.SERVER_TO_SERVER;
+
+ public static enum RoutingMode {NONE,BROADCAST,SERVER_TO_SERVER};
+
+ /**
+ * Creates a default <code>ServerSettings</code> instance.
+ */
+ public ServerSettings()
+ {
+ isDurable = false;
+ subtopicSeparator = MessagingConstants.DEFAULT_SUBTOPIC_SEPARATOR;
+ }
+
+ /**
+ * Returns <code>allow-subtopics</code> property.
+ *
+ * @return a boolean specifying whether or not the server has the <code>allow-subtopics</code> property.
+ */
+ public boolean getAllowSubtopics()
+ {
+ return allowSubtopics;
+ }
+
+ /**
+ * Sets <code>allow-subtopics</code> property.
+ *
+ * @param value The value for <code>allow-subtopics</code> property.
+ */
+ public void setAllowSubtopics(boolean value)
+ {
+ allowSubtopics = value;
+ }
+
+ /**
+ * Returns <code>cluster-message-routing</code> property.
+ *
+ * @return a boolean specifying whether or not the server has the <code>cluster-message-routing</code> property.
+ */
+ public boolean isBroadcastRoutingMode()
+ {
+ return routingMode == RoutingMode.BROADCAST;
+ }
+
+ /**
+ * Returns the routing mode configured.
+ *
+ * @return The configured routing mode.
+ */
+ public RoutingMode getRoutingMode()
+ {
+ return routingMode;
+ }
+
+ /**
+ * Sets the <code>cluster-message-routing</code> property.
+ *
+ * @param routingMode <code>server-to-server</code>(default)
+ * or <code>broadcast</code>.
+ */
+ public void setBroadcastRoutingMode(String routingMode)
+ {
+ if (routingMode.equalsIgnoreCase("broadcast"))
+ this.routingMode = RoutingMode.BROADCAST;
+ else if (routingMode.equalsIgnoreCase("server-to-server"))
+ this.routingMode = RoutingMode.SERVER_TO_SERVER;
+ else if (routingMode.equalsIgnoreCase("none"))
+ this.routingMode = RoutingMode.NONE;
+ else
+ {
+ ConfigurationException ce = new ConfigurationException();
+ ce.setMessage(INVALID_CLUSTER_MESSAGE_ROUTING, new Object[] {routingMode});
+ throw ce;
+ }
+ }
+
+ /**
+ * @deprecated Not used anymore.
+ */
+ public int getMaxCacheSize()
+ {
+ return 0;
+ }
+
+ /**
+ * @deprecated Not used anymore.
+ */
+ public void setMaxCacheSize(int size)
+ {
+ // No-op.
+ }
+
+ /**
+ * Returns the <code>message-time-to-live</code> property.
+ *
+ * @return the <code>message-time-to-live</code> property.
+ */
+ public long getMessageTTL()
+ {
+ return messageTTL;
+ }
+
+ /**
+ * Sets the <code>message-time-to-live</code> property. Default value is -1.
+ *
+ * @param ttl The value for <code>message-time-to-live</code> property.
+ */
+ public void setMessageTTL(long ttl)
+ {
+ messageTTL = ttl;
+ }
+
+ /**
+ * Returns true if wildcard subtopics are disallowed.
+ *
+ * @return true if wilcard subtopics are disallowed.
+ */
+ public boolean isDisallowWildcardSubtopics()
+ {
+ return disallowWildcardSubtopics;
+ }
+
+ /**
+ * Sets whether the wildcard subtopics are disallowed.
+ *
+ * @param value Whether the wildcard subtopics are disallowed.
+ */
+ public void setDisallowWildcardSubtopics(boolean value)
+ {
+ disallowWildcardSubtopics = value;
+ }
+
+ /**
+ * Returns whether destination is durable.
+ *
+ * @return <code>true</code> if destination is durable; otherwise <code>false</code>.
+ */
+ public boolean isDurable()
+ {
+ return isDurable;
+ }
+
+ /**
+ * Sets whether destination is durable. Default value is <code>false</code>.
+ *
+ * @param durable The value for <code>durable</code> property.
+ */
+ public void setDurable(boolean durable)
+ {
+ isDurable = durable;
+ }
+
+ /**
+ * Returns the default message priority for the destination which is a numerical
+ * value between 0 and 9 (and -1 means no default priority).
+ *
+ * @return The default message priority for the destination.
+ */
+ public int getPriority()
+ {
+ return priority;
+ }
+
+ /**
+ * Sets the default message priority of the destination which should be
+ * a numerical value between 0 and 9. Values less than 0 and greater than 9
+ * are treated as 0 and 9 respectively.
+ *
+ * @param priority The new value for the priority.
+ */
+ public void setPriority(int priority)
+ {
+ priority = priority < 0? 0 : priority > 9? 9 : priority;
+ this.priority = priority;
+ }
+
+
+ /**
+ * Returns the <code>subtopic-separator</code> property.
+ *
+ * @return the <code>subtopic-separator</code> property.
+ */
+ public String getSubtopicSeparator()
+ {
+ return subtopicSeparator;
+ }
+
+ /**
+ * Sets the <code>subtopic-separator</code> property.
+ * Optional; the default value is period.
+ *
+ * @param value The value for <code>subtopic-separator</code> property.
+ */
+ public void setSubtopicSeparator(String value)
+ {
+ subtopicSeparator = value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/ServletResourceResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/ServletResourceResolver.java b/modules/core/src/flex/messaging/config/ServletResourceResolver.java
old mode 100755
new mode 100644
index d28f373..d08cfd8
--- a/modules/core/src/flex/messaging/config/ServletResourceResolver.java
+++ b/modules/core/src/flex/messaging/config/ServletResourceResolver.java
@@ -1,156 +1,156 @@
-/*
- * 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.config;
-
-import flex.messaging.io.ArrayList;
-
-import javax.servlet.ServletContext;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.Stack;
-
-/**
- * @exclude
- */
-public class ServletResourceResolver implements ConfigurationFileResolver
-{
- private ServletContext context;
- private Stack configurationPathStack = new Stack();
-
- /**
- * Constructor.
- *
- * @param context servlet context
- */
- public ServletResourceResolver(ServletContext context)
- {
- this.context = context;
- }
-
- /**
- * Is the configuration file available.
- *
- * @param path path to check
- * @param throwError true if wmethod shold throw a ConfigurationException if path no found.
- * @return true if path is available
- * @throws ConfigurationException if throwError is true and path is not available
- */
- public boolean isAvailable(String path, boolean throwError) throws ConfigurationException
- {
- boolean available = false;
- InputStream is = context.getResourceAsStream(path);
- if (is != null)
- {
- try { is.close(); } catch (IOException ignore) { /* ignore */}
- pushConfigurationFile(path);
- available = true;
- }
- else
- {
- if (throwError)
- {
- // Please specify a valid ''services.configuration.file'' in web.xml.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(11108, new Object[] {path});
- throw e;
- }
- }
-
- return available;
- }
-
- public InputStream getConfigurationFile(String path)
- {
- InputStream is = context.getResourceAsStream(path);
- if (is != null)
- {
- pushConfigurationFile(path);
- return is;
- }
- else
- {
- // Please specify a valid ''services.configuration.file'' in web.xml.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(11108, new Object[] {path});
- throw e;
- }
- }
-
- public InputStream getIncludedFile(String src)
- {
- String path = configurationPathStack.peek() + "/" + src;
- InputStream is = context.getResourceAsStream(path);
-
- if (is != null)
- {
- pushConfigurationFile(path);
- return is;
- }
- else
- {
- // Please specify a valid include file. ''{0}'' is invalid.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(11107, new Object[] {path});
- throw e;
- }
- }
-
- public void popIncludedFile()
- {
- configurationPathStack.pop();
- }
-
- /**
- * Returns the list of XML files (denoted by .xml extension) in the directory
- * relative to the current configuration file.
- */
- public List getFiles(String dir)
- {
- List result = new ArrayList();
- String prefix = configurationPathStack.peek() + "/";
- Set paths = context.getResourcePaths(prefix + dir);
- if (paths != null)
- {
- for (Object entry : paths)
- {
- String path = (String) entry;
- if (path.endsWith(".xml"))
- {
- result.add(path.substring(prefix.length()));
- }
- }
- return result;
- }
- else
- {
- // Please specify a valid include directory. ''{0}'' is invalid.
- ConfigurationException e = new ConfigurationException();
- e.setMessage(11113, new Object[]{dir});
- throw e;
- }
- }
-
- private void pushConfigurationFile(String path)
- {
- String topLevelPath = path.substring(0, path.lastIndexOf('/'));
- configurationPathStack.push(topLevelPath);
- }
-}
+/*
+ * 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.config;
+
+import flex.messaging.io.ArrayList;
+
+import javax.servlet.ServletContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.Stack;
+
+/**
+ * @exclude
+ */
+public class ServletResourceResolver implements ConfigurationFileResolver
+{
+ private ServletContext context;
+ private Stack configurationPathStack = new Stack();
+
+ /**
+ * Constructor.
+ *
+ * @param context servlet context
+ */
+ public ServletResourceResolver(ServletContext context)
+ {
+ this.context = context;
+ }
+
+ /**
+ * Is the configuration file available.
+ *
+ * @param path path to check
+ * @param throwError true if wmethod shold throw a ConfigurationException if path no found.
+ * @return true if path is available
+ * @throws ConfigurationException if throwError is true and path is not available
+ */
+ public boolean isAvailable(String path, boolean throwError) throws ConfigurationException
+ {
+ boolean available = false;
+ InputStream is = context.getResourceAsStream(path);
+ if (is != null)
+ {
+ try { is.close(); } catch (IOException ignore) { /* ignore */}
+ pushConfigurationFile(path);
+ available = true;
+ }
+ else
+ {
+ if (throwError)
+ {
+ // Please specify a valid ''services.configuration.file'' in web.xml.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(11108, new Object[] {path});
+ throw e;
+ }
+ }
+
+ return available;
+ }
+
+ public InputStream getConfigurationFile(String path)
+ {
+ InputStream is = context.getResourceAsStream(path);
+ if (is != null)
+ {
+ pushConfigurationFile(path);
+ return is;
+ }
+ else
+ {
+ // Please specify a valid ''services.configuration.file'' in web.xml.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(11108, new Object[] {path});
+ throw e;
+ }
+ }
+
+ public InputStream getIncludedFile(String src)
+ {
+ String path = configurationPathStack.peek() + "/" + src;
+ InputStream is = context.getResourceAsStream(path);
+
+ if (is != null)
+ {
+ pushConfigurationFile(path);
+ return is;
+ }
+ else
+ {
+ // Please specify a valid include file. ''{0}'' is invalid.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(11107, new Object[] {path});
+ throw e;
+ }
+ }
+
+ public void popIncludedFile()
+ {
+ configurationPathStack.pop();
+ }
+
+ /**
+ * Returns the list of XML files (denoted by .xml extension) in the directory
+ * relative to the current configuration file.
+ */
+ public List getFiles(String dir)
+ {
+ List result = new ArrayList();
+ String prefix = configurationPathStack.peek() + "/";
+ Set paths = context.getResourcePaths(prefix + dir);
+ if (paths != null)
+ {
+ for (Object entry : paths)
+ {
+ String path = (String) entry;
+ if (path.endsWith(".xml"))
+ {
+ result.add(path.substring(prefix.length()));
+ }
+ }
+ return result;
+ }
+ else
+ {
+ // Please specify a valid include directory. ''{0}'' is invalid.
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(11113, new Object[]{dir});
+ throw e;
+ }
+ }
+
+ private void pushConfigurationFile(String path)
+ {
+ String topLevelPath = path.substring(0, path.lastIndexOf('/'));
+ configurationPathStack.push(topLevelPath);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/SharedServerSettings.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/SharedServerSettings.java b/modules/core/src/flex/messaging/config/SharedServerSettings.java
old mode 100755
new mode 100644
index a8fbadd..82cac64
--- a/modules/core/src/flex/messaging/config/SharedServerSettings.java
+++ b/modules/core/src/flex/messaging/config/SharedServerSettings.java
@@ -1,65 +1,65 @@
-/*
- * 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.config;
-
-/**
- * Stores configuration settings for a shared server instance.
- * <tt>ServerConfigurationParser</tt> will generate an instance for each shared server
- * defined in the configuration file.
- * The <tt>MessagingConfiguration</tt> instance using the parser will store these and
- * use them to configure the <tt>MessageBroker</tt> with shared server instances.
- *
- * @exclude
- */
-public class SharedServerSettings extends PropertiesSettings
-{
- private String id;
-
- public String getId()
- {
- return id;
- }
-
- public void setId(String value)
- {
- id = value;
- }
-
- private String className;
-
- public String getClassName()
- {
- return className;
- }
-
- public void setClassName(String value)
- {
- className = value;
- }
-
- private String sourceFile;
-
- public String getSourceFile()
- {
- return sourceFile;
- }
-
- public void setSourceFile(String value)
- {
- sourceFile = value;
- }
-}
+/*
+ * 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.config;
+
+/**
+ * Stores configuration settings for a shared server instance.
+ * <tt>ServerConfigurationParser</tt> will generate an instance for each shared server
+ * defined in the configuration file.
+ * The <tt>MessagingConfiguration</tt> instance using the parser will store these and
+ * use them to configure the <tt>MessageBroker</tt> with shared server instances.
+ *
+ * @exclude
+ */
+public class SharedServerSettings extends PropertiesSettings
+{
+ private String id;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String value)
+ {
+ id = value;
+ }
+
+ private String className;
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName(String value)
+ {
+ className = value;
+ }
+
+ private String sourceFile;
+
+ public String getSourceFile()
+ {
+ return sourceFile;
+ }
+
+ public void setSourceFile(String value)
+ {
+ sourceFile = value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/SystemSettings.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/SystemSettings.java b/modules/core/src/flex/messaging/config/SystemSettings.java
old mode 100755
new mode 100644
index d413f5f..86619e7
--- a/modules/core/src/flex/messaging/config/SystemSettings.java
+++ b/modules/core/src/flex/messaging/config/SystemSettings.java
@@ -1,300 +1,300 @@
-/*
- * 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.config;
-
-import flex.messaging.log.Log;
-import flex.messaging.log.Logger;
-import flex.messaging.util.PropertyStringResourceLoader;
-import flex.messaging.util.ResourceLoader;
-import flex.messaging.util.WatchedObject;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.servlet.ServletContext;
-
-/**
- * @exclude
- */
-public class SystemSettings
-{
- private ResourceLoader resourceLoader;
- private Locale defaultLocale;
- private boolean enforceEndpointValidation;
- private boolean manageable;
- private boolean redeployEnabled;
- private int watchInterval;
- private List watches;
- private List touches;
- private String uuidGeneratorClassName;
- private String dotNetFrameworkVersion;
-
- public SystemSettings()
- {
- enforceEndpointValidation = false;
- manageable = true;
- redeployEnabled = false;
- resourceLoader = new PropertyStringResourceLoader();
- touches = new ArrayList();
- watches = new ArrayList();
- watchInterval = 20;
- dotNetFrameworkVersion = null;
- }
-
- public void setDefaultLocale(Locale locale)
- {
- defaultLocale = locale;
- resourceLoader.setDefaultLocale(defaultLocale);
- }
-
- public Locale getDefaultLocale()
- {
- return defaultLocale;
- }
-
- public boolean isManageable()
- {
- return manageable;
- }
-
- public void setManageable(String manageable)
- {
- manageable = manageable.toLowerCase();
- if (manageable.startsWith("f"))
- this.manageable = false;
- }
-
- public boolean isEnforceEndpointValidation()
- {
- return enforceEndpointValidation;
- }
-
- public void setEnforceEndpointValidation(String enforceEndpointValidation)
- {
- if (enforceEndpointValidation == null || enforceEndpointValidation.length() == 0)
- return;
- if (enforceEndpointValidation.toLowerCase().startsWith("t"))
- this.enforceEndpointValidation = true;
- }
-
- public ResourceLoader getResourceLoader()
- {
- return resourceLoader;
- }
-
- public void setResourceLoader(ResourceLoader resourceLoader)
- {
- this.resourceLoader = resourceLoader;
- }
-
- public void setRedeployEnabled(String enabled)
- {
- enabled = enabled.toLowerCase();
- if (enabled.startsWith("t"))
- this.redeployEnabled = true;
- }
-
- public boolean getRedeployEnabled()
- {
- return redeployEnabled;
- }
-
- public void setWatchInterval(String interval)
- {
- this.watchInterval = Integer.parseInt(interval);
- }
-
- public int getWatchInterval()
- {
- return watchInterval;
- }
-
- public void addWatchFile(String watch)
- {
- this.watches.add(watch);
- }
-
- public List getWatchFiles()
- {
- return watches;
- }
-
- public void addTouchFile(String touch)
- {
- this.touches.add(touch);
- }
-
- public List getTouchFiles()
- {
- return touches;
- }
-
- public void setPaths(ServletContext context)
- {
- if (redeployEnabled)
- {
- List resolvedWatches = new ArrayList();
- for (int i = 0; i < watches.size(); i++)
- {
- String path = (String)watches.get(i);
- String resolvedPath = null;
- if (path.startsWith("{context.root}") || path.startsWith("{context-root}"))
- {
- path = path.substring(14);
- resolvedPath = context.getRealPath(path);
-
- if (resolvedPath != null)
- {
- try
- {
- resolvedWatches.add(new WatchedObject(resolvedPath));
- }
- catch (FileNotFoundException fnfe)
- {
- Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
- if (logger != null)
- {
- logger.warn("The watch-file, " + path + ", could not be found and will be ignored.");
- }
- }
- }
- else
- {
- Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
- logger.warn("The watch-file, " + path + ", could not be resolved to a path and will be ignored.");
- }
- }
- else
- {
- try
- {
- resolvedWatches.add(new WatchedObject(path));
- }
- catch (FileNotFoundException fnfe)
- {
- Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
- if (logger != null)
- {
- logger.warn("The watch-file, " + path + ", could not be found and will be ignored.");
- }
- }
- }
- }
- watches = resolvedWatches;
-
- List resolvedTouches = new ArrayList();
- for (int i = 0; i < touches.size(); i++)
- {
- String path = (String)touches.get(i);
- String resolvedPath = null;
- if (path.startsWith("{context.root}") || path.startsWith("{context-root}"))
- {
- path = path.substring(14);
- resolvedPath = context.getRealPath(path);
-
- if (resolvedPath != null)
- {
- File file = new File(resolvedPath);
- if (!file.exists() || (!file.isFile() && !file.isDirectory()) || (!file.isAbsolute()))
- {
- Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
- logger.warn("The touch-file, " + path + ", could not be found and will be ignored.");
- }
- else
- {
- resolvedTouches.add(resolvedPath);
- }
- }
- else
- {
- Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
- logger.warn("The touch-file, " + path + ", could not be resolved to a path and will be ignored.");
- }
- }
- else
- {
- try
- {
- resolvedTouches.add(new WatchedObject(path));
- }
- catch (FileNotFoundException fnfe)
- {
- Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
- if (logger != null)
- {
- logger.warn("The touch-file, " + path + ", could not be found and will be ignored.");
- }
- }
- }
- }
- touches = resolvedTouches;
- }
- }
-
- /**
- * Returns the UUID generator class name.
- *
- * @return The UUID generator class name.
- */
- public String getUUIDGeneratorClassName()
- {
- return uuidGeneratorClassName;
- }
-
- /**
- * Sets the UUID generator class name.
- *
- * @param value The UUID generator class name.
- */
- public void setUUIDGeneratorClassName(String value)
- {
- uuidGeneratorClassName = value;
- }
-
- /**
- * Set the dotnet framework version to use.
- * @param version the configured dotnet framework version
- */
- public void setDotNetFrameworkVersion(String version)
- {
- dotNetFrameworkVersion = version;
- }
-
- /**
- * Get the dotnet framework version.
- * @return String the dotnet framework version
- */
- public String getDotNetFrameworkVersion()
- {
- return dotNetFrameworkVersion;
- }
- /**
- * Clean up static member variables.
- */
- public void clear()
- {
- resourceLoader = null;
- defaultLocale = null;
- watches = null;
- touches = null;
- dotNetFrameworkVersion = null;
- }
-
-}
+/*
+ * 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.config;
+
+import flex.messaging.log.Log;
+import flex.messaging.log.Logger;
+import flex.messaging.util.PropertyStringResourceLoader;
+import flex.messaging.util.ResourceLoader;
+import flex.messaging.util.WatchedObject;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.servlet.ServletContext;
+
+/**
+ * @exclude
+ */
+public class SystemSettings
+{
+ private ResourceLoader resourceLoader;
+ private Locale defaultLocale;
+ private boolean enforceEndpointValidation;
+ private boolean manageable;
+ private boolean redeployEnabled;
+ private int watchInterval;
+ private List watches;
+ private List touches;
+ private String uuidGeneratorClassName;
+ private String dotNetFrameworkVersion;
+
+ public SystemSettings()
+ {
+ enforceEndpointValidation = false;
+ manageable = true;
+ redeployEnabled = false;
+ resourceLoader = new PropertyStringResourceLoader();
+ touches = new ArrayList();
+ watches = new ArrayList();
+ watchInterval = 20;
+ dotNetFrameworkVersion = null;
+ }
+
+ public void setDefaultLocale(Locale locale)
+ {
+ defaultLocale = locale;
+ resourceLoader.setDefaultLocale(defaultLocale);
+ }
+
+ public Locale getDefaultLocale()
+ {
+ return defaultLocale;
+ }
+
+ public boolean isManageable()
+ {
+ return manageable;
+ }
+
+ public void setManageable(String manageable)
+ {
+ manageable = manageable.toLowerCase();
+ if (manageable.startsWith("f"))
+ this.manageable = false;
+ }
+
+ public boolean isEnforceEndpointValidation()
+ {
+ return enforceEndpointValidation;
+ }
+
+ public void setEnforceEndpointValidation(String enforceEndpointValidation)
+ {
+ if (enforceEndpointValidation == null || enforceEndpointValidation.length() == 0)
+ return;
+ if (enforceEndpointValidation.toLowerCase().startsWith("t"))
+ this.enforceEndpointValidation = true;
+ }
+
+ public ResourceLoader getResourceLoader()
+ {
+ return resourceLoader;
+ }
+
+ public void setResourceLoader(ResourceLoader resourceLoader)
+ {
+ this.resourceLoader = resourceLoader;
+ }
+
+ public void setRedeployEnabled(String enabled)
+ {
+ enabled = enabled.toLowerCase();
+ if (enabled.startsWith("t"))
+ this.redeployEnabled = true;
+ }
+
+ public boolean getRedeployEnabled()
+ {
+ return redeployEnabled;
+ }
+
+ public void setWatchInterval(String interval)
+ {
+ this.watchInterval = Integer.parseInt(interval);
+ }
+
+ public int getWatchInterval()
+ {
+ return watchInterval;
+ }
+
+ public void addWatchFile(String watch)
+ {
+ this.watches.add(watch);
+ }
+
+ public List getWatchFiles()
+ {
+ return watches;
+ }
+
+ public void addTouchFile(String touch)
+ {
+ this.touches.add(touch);
+ }
+
+ public List getTouchFiles()
+ {
+ return touches;
+ }
+
+ public void setPaths(ServletContext context)
+ {
+ if (redeployEnabled)
+ {
+ List resolvedWatches = new ArrayList();
+ for (int i = 0; i < watches.size(); i++)
+ {
+ String path = (String)watches.get(i);
+ String resolvedPath = null;
+ if (path.startsWith("{context.root}") || path.startsWith("{context-root}"))
+ {
+ path = path.substring(14);
+ resolvedPath = context.getRealPath(path);
+
+ if (resolvedPath != null)
+ {
+ try
+ {
+ resolvedWatches.add(new WatchedObject(resolvedPath));
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
+ if (logger != null)
+ {
+ logger.warn("The watch-file, " + path + ", could not be found and will be ignored.");
+ }
+ }
+ }
+ else
+ {
+ Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
+ logger.warn("The watch-file, " + path + ", could not be resolved to a path and will be ignored.");
+ }
+ }
+ else
+ {
+ try
+ {
+ resolvedWatches.add(new WatchedObject(path));
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
+ if (logger != null)
+ {
+ logger.warn("The watch-file, " + path + ", could not be found and will be ignored.");
+ }
+ }
+ }
+ }
+ watches = resolvedWatches;
+
+ List resolvedTouches = new ArrayList();
+ for (int i = 0; i < touches.size(); i++)
+ {
+ String path = (String)touches.get(i);
+ String resolvedPath = null;
+ if (path.startsWith("{context.root}") || path.startsWith("{context-root}"))
+ {
+ path = path.substring(14);
+ resolvedPath = context.getRealPath(path);
+
+ if (resolvedPath != null)
+ {
+ File file = new File(resolvedPath);
+ if (!file.exists() || (!file.isFile() && !file.isDirectory()) || (!file.isAbsolute()))
+ {
+ Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
+ logger.warn("The touch-file, " + path + ", could not be found and will be ignored.");
+ }
+ else
+ {
+ resolvedTouches.add(resolvedPath);
+ }
+ }
+ else
+ {
+ Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
+ logger.warn("The touch-file, " + path + ", could not be resolved to a path and will be ignored.");
+ }
+ }
+ else
+ {
+ try
+ {
+ resolvedTouches.add(new WatchedObject(path));
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ Logger logger = Log.getLogger(ConfigurationManager.LOG_CATEGORY);
+ if (logger != null)
+ {
+ logger.warn("The touch-file, " + path + ", could not be found and will be ignored.");
+ }
+ }
+ }
+ }
+ touches = resolvedTouches;
+ }
+ }
+
+ /**
+ * Returns the UUID generator class name.
+ *
+ * @return The UUID generator class name.
+ */
+ public String getUUIDGeneratorClassName()
+ {
+ return uuidGeneratorClassName;
+ }
+
+ /**
+ * Sets the UUID generator class name.
+ *
+ * @param value The UUID generator class name.
+ */
+ public void setUUIDGeneratorClassName(String value)
+ {
+ uuidGeneratorClassName = value;
+ }
+
+ /**
+ * Set the dotnet framework version to use.
+ * @param version the configured dotnet framework version
+ */
+ public void setDotNetFrameworkVersion(String version)
+ {
+ dotNetFrameworkVersion = version;
+ }
+
+ /**
+ * Get the dotnet framework version.
+ * @return String the dotnet framework version
+ */
+ public String getDotNetFrameworkVersion()
+ {
+ return dotNetFrameworkVersion;
+ }
+ /**
+ * Clean up static member variables.
+ */
+ public void clear()
+ {
+ resourceLoader = null;
+ defaultLocale = null;
+ watches = null;
+ touches = null;
+ dotNetFrameworkVersion = null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/ThrottleSettings.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/ThrottleSettings.java b/modules/core/src/flex/messaging/config/ThrottleSettings.java
old mode 100755
new mode 100644
index b3a7f4b..6457d1b
--- a/modules/core/src/flex/messaging/config/ThrottleSettings.java
+++ b/modules/core/src/flex/messaging/config/ThrottleSettings.java
@@ -1,373 +1,373 @@
-/*
- * 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.config;
-
-/**
- * This configuration class is derived from optional properties that
- * may be supplied in the <properties> section of a destination.
- * It exists to capture properties related to message throttling in a way
- * that simplifies the ThrottleManager's usage of the configuration.
- */
-public class ThrottleSettings
-{
- /**
- * The Policy enum.
- */
- public enum Policy
- {
- NONE,
- ERROR,
- IGNORE,
- BUFFER,
- CONFLATE
- };
-
- /** @exclude **/
- public static final String ELEMENT_INBOUND = "throttle-inbound";
- /** @exclude **/
- public static final String ELEMENT_OUTBOUND = "throttle-outbound";
- /** @exclude **/
- public static final String ELEMENT_POLICY = "policy";
- /** @exclude **/
- public static final String ELEMENT_DEST_FREQ = "max-frequency";
- /** @exclude **/
- public static final String ELEMENT_CLIENT_FREQ = "max-client-frequency";
-
- // Errors
- private static final int ERR_MSG_INVALID_INBOUND_POLICY = 11130;
- private static final int ERR_MSG_INVALID_INCOMING_CLENT_FREQ = 11131;
- private static final int ERR_MSG_INVALID_INCOMING_DEST_FREQ = 11132;
- private static final int ERR_MSG_INVALID_OUTGOING_CLIENT_FREQ = 11133;
- private static final int ERR_MSG_INVALID_OUTGOING_DEST_FREQ = 11134;
- private static final int ERR_MSG_INVALID_NEGATIVE_VALUE = 11135;
-
- private String destinationName;
- private int inClientMessagesPerSec;
- private int inDestinationMessagesPerSec;
- private int outClientMessagesPerSec;
- private int outDestinationMessagesPerSec;
- private Policy inPolicy;
- private Policy outPolicy;
-
- /**
- * Creates a <code>ThrottleSettings</code> instance with default settings.
- */
- public ThrottleSettings()
- {
- inPolicy = Policy.NONE;
- outPolicy = Policy.NONE;
- }
-
- /**
- * Parses the throttle policy out of the given string.
- *
- * @param policy The string policy to parse.
- * @return The Policy.
- */
- public static Policy parsePolicy(String policy)
- {
- if (Policy.NONE.toString().equalsIgnoreCase(policy))
- return Policy.NONE;
- else if (Policy.IGNORE.toString().equalsIgnoreCase(policy))
- return Policy.IGNORE;
- else if (Policy.ERROR.toString().equalsIgnoreCase(policy))
- return Policy.ERROR;
- else if (Policy.BUFFER.toString().equalsIgnoreCase(policy))
- return Policy.BUFFER;
- else if (Policy.CONFLATE.toString().equalsIgnoreCase(policy))
- return Policy.CONFLATE;
-
- ConfigurationException ex = new ConfigurationException();
- // Message will be set by the caller.
- throw ex;
- }
-
- /**
- * Returns true if inbound or outbound client throttling is enabled.
- *
- * @return True if the incoming client frequency or outgoing
- * client frequency is enabled; otherwise false.
- */
- public boolean isClientThrottleEnabled()
- {
- return isInboundClientThrottleEnabled() || isOutboundClientThrottleEnabled();
- }
-
- /**
- * Returns true if inbound client throttling is enabled.
- *
- * @return True if the inbound client throttling is enabled.
- */
- public boolean isInboundClientThrottleEnabled()
- {
- return inPolicy != Policy.NONE && getIncomingClientFrequency() > 0;
- }
-
- /**
- * Returns true if outbound client throttling is enabled.
- *
- * @return True if the outbound client throttling is enabled.
- */
- public boolean isOutboundClientThrottleEnabled()
- {
- return outPolicy != Policy.NONE && getOutgoingClientFrequency() > 0;
- }
-
- /**
- * Returns true if inbound or outbound destination throttling is enabled.
- *
- * @return true if incoming or outbound destination throttling is enabled;
- * otherwise false.
- */
- public boolean isDestinationThrottleEnabled()
- {
- return isInboundDestinationThrottleEnabled() || isOutboundDestinationThrottleEnabled();
- }
-
- /**
- * Returns true if inbound destination throttling is enabled.
- *
- * @return true if inbound destination throttling is enabled.
- */
- public boolean isInboundDestinationThrottleEnabled()
- {
- return inPolicy != Policy.NONE && getIncomingDestinationFrequency() > 0;
- }
-
- /**
- * Returns true if outbound destination throttling is enabled.
- *
- * @return true if outbound destination throttling is enabled.
- */
- public boolean isOutboundDestinationThrottleEnabled()
- {
- return outPolicy != Policy.NONE && getOutgoingDestinationFrequency() > 0;
- }
-
- /**
- * Returns the inbound throttle policy.
- *
- * @return the inbound throttle policy.
- */
- public Policy getInboundPolicy()
- {
- return inPolicy;
- }
-
- /**
- * Sets inbound throttle policy. The inbound policy may be NONE, ERROR, or IGNORE.
- *
- * @param inPolicy The inbound policy.
- */
- public void setInboundPolicy(Policy inPolicy)
- {
- if (inPolicy != Policy.NONE && inPolicy != Policy.ERROR && inPolicy != Policy.IGNORE)
- {
- ConfigurationException ex = new ConfigurationException();
- // Invalid inbound throttle policy ''{0}'' for destination ''{1}''. Valid values are 'NONE', 'ERROR', and 'IGNORE'.
- ex.setMessage(ERR_MSG_INVALID_INBOUND_POLICY, new Object[]{inPolicy, destinationName});
- throw ex;
- }
- this.inPolicy = inPolicy;
- }
-
- /**
- * Returns the outbound throttle policy.
- *
- * @return the outbound throttle policy.
- */
- public Policy getOutboundPolicy()
- {
- return outPolicy;
- }
-
- /**
- * Sets the outbound throttle policy. The outbound policy can be NONE, IGNORE,
- * BUFFER, or CONFLATE.
- *
- * @param outPolicy The outbound policy.
- */
- public void setOutboundPolicy(Policy outPolicy)
- {
- // Policy is checked at throttle manager.
- this.outPolicy = outPolicy;
- }
-
- /**
- * Returns the destination name for <code>ThrottleSettings</code>.
- *
- * @return the destination name for <code>ThrottleSettings</code>.
- */
- public String getDestinationName()
- {
- return destinationName;
- }
-
- /**
- * Sets the destination name for <code>ThrottleSettings</code>. This is set
- * automatically when <code>NetworkSettings</code> is assigned to a destination.
- *
- * @param destinationName The destination name.
- */
- public void setDestinationName(String destinationName)
- {
- this.destinationName = destinationName;
- }
-
- /**
- * Returns the incoming client frequency (max-client-frequency).
- *
- * @return The incoming client frequency (max-client-frequency).
- */
- public int getIncomingClientFrequency()
- {
- return inClientMessagesPerSec;
- }
-
- /**
- * Sets the incoming client frequency (max-client-frequency). Optional and the
- * default value is 0. Note that the incoming client frequency cannot be more
- * than the incoming destination frequency.
- *
- * @param n The incoming client frequency.
- */
- public void setIncomingClientFrequency(int n)
- {
- String name = "incoming client frequency";
- blockNegative(n, name);
-
- if (inDestinationMessagesPerSec > 0 && n > inDestinationMessagesPerSec)
- {
- ConfigurationException ex = new ConfigurationException();
- // Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be more than the incoming destination frequency ''{3}''.
- ex.setMessage(ERR_MSG_INVALID_INCOMING_CLENT_FREQ, new Object[]{name, destinationName,
- Integer.valueOf(n), Integer.valueOf(inDestinationMessagesPerSec)});
- throw ex;
- }
- this.inClientMessagesPerSec = n;
- }
-
- /**
- * Returns the incoming destination frequency (max-frequency).
- *
- * @return The incoming destination frequency (max-frequency).
- */
- public int getIncomingDestinationFrequency()
- {
- return inDestinationMessagesPerSec;
- }
-
- /**
- * Sets the incoming destination frequency (max-frequency). Optional and the
- * default value is 0. Note that the incoming destination frequency cannot be
- * less than the incoming client frequency.
- *
- * @param n The incoming destination frequency.
- */
- public void setIncomingDestinationFrequency(int n)
- {
- String name = "The incoming destination frequency";
- blockNegative(n, name);
-
- if (inClientMessagesPerSec > 0 && n < inClientMessagesPerSec)
- {
- ConfigurationException ex = new ConfigurationException();
- // Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be less than the incoming client frequency ''{3}''.
- ex.setMessage(ERR_MSG_INVALID_INCOMING_DEST_FREQ, new Object[]{name, destinationName,
- Integer.valueOf(n), Integer.valueOf(inClientMessagesPerSec)});
- throw ex;
- }
- this.inDestinationMessagesPerSec = n;
- }
-
- /**
- * Returns the outgoing client frequency (max-client-frequency).
- *
- * @return The outgoing client frequency (max-client-frequency).
- */
- public int getOutgoingClientFrequency()
- {
- return outClientMessagesPerSec;
- }
-
- /**
- * Sets the outgoing client frequency (max-client-frequency). Optional and the
- * default value is 0. Note that the outgoing client frequency cannot be
- * more than the outgoing destination frequency.
- *
- * @param n The outgoing client frequency.
- */
- public void setOutgoingClientFrequency(int n)
- {
- String name = "The outgoing client frequency";
- blockNegative(n, name);
-
- if (outDestinationMessagesPerSec > 0 && n > outDestinationMessagesPerSec)
- {
- ConfigurationException ex = new ConfigurationException();
- // Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be more than the outgoing destination frequency ''{3}''.
- ex.setMessage(ERR_MSG_INVALID_OUTGOING_CLIENT_FREQ, new Object[]{name, destinationName,
- Integer.valueOf(n), Integer.valueOf(outDestinationMessagesPerSec)});
- throw ex;
- }
- this.outClientMessagesPerSec = n;
- }
-
- /**
- * Returns the outgoing destination frequency (max-frequency).
- *
- * @return The outgoing destination frequency (max-frequency).
- */
- public int getOutgoingDestinationFrequency()
- {
- return outDestinationMessagesPerSec;
- }
-
- /**
- * Sets the outgoing destination frequency (max-frequency). Optional and the
- * default value is 0. Note that the outgoing destination frequency cannot
- * be less than the outgoing client frequency.
- *
- * @param n The outgoing destination frequency.
- */
- public void setOutgoingDestinationFrequency(int n)
- {
- String name = "The outgoing destination frequency";
- blockNegative(n, name);
-
- if (outClientMessagesPerSec > 0 && n < outClientMessagesPerSec)
- {
- ConfigurationException ex = new ConfigurationException();
- // Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be less than the outgoing client frequency ''{3}''.
- ex.setMessage(ERR_MSG_INVALID_OUTGOING_DEST_FREQ, new Object[]{name, destinationName, Integer.valueOf(n),
- Integer.valueOf(outClientMessagesPerSec)});
- throw ex;
- }
- this.outDestinationMessagesPerSec = n;
- }
-
- protected void blockNegative(int n, String name)
- {
- if (n < 0)
- {
- ConfigurationException ex = new ConfigurationException();
- // Invalid {0} for destination ''{1}''. {0} cannot be negative.
- ex.setMessage(ERR_MSG_INVALID_NEGATIVE_VALUE, new Object[]{name, destinationName});
- throw ex;
- }
- }
-}
+/*
+ * 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.config;
+
+/**
+ * This configuration class is derived from optional properties that
+ * may be supplied in the <properties> section of a destination.
+ * It exists to capture properties related to message throttling in a way
+ * that simplifies the ThrottleManager's usage of the configuration.
+ */
+public class ThrottleSettings
+{
+ /**
+ * The Policy enum.
+ */
+ public enum Policy
+ {
+ NONE,
+ ERROR,
+ IGNORE,
+ BUFFER,
+ CONFLATE
+ };
+
+ /** @exclude **/
+ public static final String ELEMENT_INBOUND = "throttle-inbound";
+ /** @exclude **/
+ public static final String ELEMENT_OUTBOUND = "throttle-outbound";
+ /** @exclude **/
+ public static final String ELEMENT_POLICY = "policy";
+ /** @exclude **/
+ public static final String ELEMENT_DEST_FREQ = "max-frequency";
+ /** @exclude **/
+ public static final String ELEMENT_CLIENT_FREQ = "max-client-frequency";
+
+ // Errors
+ private static final int ERR_MSG_INVALID_INBOUND_POLICY = 11130;
+ private static final int ERR_MSG_INVALID_INCOMING_CLENT_FREQ = 11131;
+ private static final int ERR_MSG_INVALID_INCOMING_DEST_FREQ = 11132;
+ private static final int ERR_MSG_INVALID_OUTGOING_CLIENT_FREQ = 11133;
+ private static final int ERR_MSG_INVALID_OUTGOING_DEST_FREQ = 11134;
+ private static final int ERR_MSG_INVALID_NEGATIVE_VALUE = 11135;
+
+ private String destinationName;
+ private int inClientMessagesPerSec;
+ private int inDestinationMessagesPerSec;
+ private int outClientMessagesPerSec;
+ private int outDestinationMessagesPerSec;
+ private Policy inPolicy;
+ private Policy outPolicy;
+
+ /**
+ * Creates a <code>ThrottleSettings</code> instance with default settings.
+ */
+ public ThrottleSettings()
+ {
+ inPolicy = Policy.NONE;
+ outPolicy = Policy.NONE;
+ }
+
+ /**
+ * Parses the throttle policy out of the given string.
+ *
+ * @param policy The string policy to parse.
+ * @return The Policy.
+ */
+ public static Policy parsePolicy(String policy)
+ {
+ if (Policy.NONE.toString().equalsIgnoreCase(policy))
+ return Policy.NONE;
+ else if (Policy.IGNORE.toString().equalsIgnoreCase(policy))
+ return Policy.IGNORE;
+ else if (Policy.ERROR.toString().equalsIgnoreCase(policy))
+ return Policy.ERROR;
+ else if (Policy.BUFFER.toString().equalsIgnoreCase(policy))
+ return Policy.BUFFER;
+ else if (Policy.CONFLATE.toString().equalsIgnoreCase(policy))
+ return Policy.CONFLATE;
+
+ ConfigurationException ex = new ConfigurationException();
+ // Message will be set by the caller.
+ throw ex;
+ }
+
+ /**
+ * Returns true if inbound or outbound client throttling is enabled.
+ *
+ * @return True if the incoming client frequency or outgoing
+ * client frequency is enabled; otherwise false.
+ */
+ public boolean isClientThrottleEnabled()
+ {
+ return isInboundClientThrottleEnabled() || isOutboundClientThrottleEnabled();
+ }
+
+ /**
+ * Returns true if inbound client throttling is enabled.
+ *
+ * @return True if the inbound client throttling is enabled.
+ */
+ public boolean isInboundClientThrottleEnabled()
+ {
+ return inPolicy != Policy.NONE && getIncomingClientFrequency() > 0;
+ }
+
+ /**
+ * Returns true if outbound client throttling is enabled.
+ *
+ * @return True if the outbound client throttling is enabled.
+ */
+ public boolean isOutboundClientThrottleEnabled()
+ {
+ return outPolicy != Policy.NONE && getOutgoingClientFrequency() > 0;
+ }
+
+ /**
+ * Returns true if inbound or outbound destination throttling is enabled.
+ *
+ * @return true if incoming or outbound destination throttling is enabled;
+ * otherwise false.
+ */
+ public boolean isDestinationThrottleEnabled()
+ {
+ return isInboundDestinationThrottleEnabled() || isOutboundDestinationThrottleEnabled();
+ }
+
+ /**
+ * Returns true if inbound destination throttling is enabled.
+ *
+ * @return true if inbound destination throttling is enabled.
+ */
+ public boolean isInboundDestinationThrottleEnabled()
+ {
+ return inPolicy != Policy.NONE && getIncomingDestinationFrequency() > 0;
+ }
+
+ /**
+ * Returns true if outbound destination throttling is enabled.
+ *
+ * @return true if outbound destination throttling is enabled.
+ */
+ public boolean isOutboundDestinationThrottleEnabled()
+ {
+ return outPolicy != Policy.NONE && getOutgoingDestinationFrequency() > 0;
+ }
+
+ /**
+ * Returns the inbound throttle policy.
+ *
+ * @return the inbound throttle policy.
+ */
+ public Policy getInboundPolicy()
+ {
+ return inPolicy;
+ }
+
+ /**
+ * Sets inbound throttle policy. The inbound policy may be NONE, ERROR, or IGNORE.
+ *
+ * @param inPolicy The inbound policy.
+ */
+ public void setInboundPolicy(Policy inPolicy)
+ {
+ if (inPolicy != Policy.NONE && inPolicy != Policy.ERROR && inPolicy != Policy.IGNORE)
+ {
+ ConfigurationException ex = new ConfigurationException();
+ // Invalid inbound throttle policy ''{0}'' for destination ''{1}''. Valid values are 'NONE', 'ERROR', and 'IGNORE'.
+ ex.setMessage(ERR_MSG_INVALID_INBOUND_POLICY, new Object[]{inPolicy, destinationName});
+ throw ex;
+ }
+ this.inPolicy = inPolicy;
+ }
+
+ /**
+ * Returns the outbound throttle policy.
+ *
+ * @return the outbound throttle policy.
+ */
+ public Policy getOutboundPolicy()
+ {
+ return outPolicy;
+ }
+
+ /**
+ * Sets the outbound throttle policy. The outbound policy can be NONE, IGNORE,
+ * BUFFER, or CONFLATE.
+ *
+ * @param outPolicy The outbound policy.
+ */
+ public void setOutboundPolicy(Policy outPolicy)
+ {
+ // Policy is checked at throttle manager.
+ this.outPolicy = outPolicy;
+ }
+
+ /**
+ * Returns the destination name for <code>ThrottleSettings</code>.
+ *
+ * @return the destination name for <code>ThrottleSettings</code>.
+ */
+ public String getDestinationName()
+ {
+ return destinationName;
+ }
+
+ /**
+ * Sets the destination name for <code>ThrottleSettings</code>. This is set
+ * automatically when <code>NetworkSettings</code> is assigned to a destination.
+ *
+ * @param destinationName The destination name.
+ */
+ public void setDestinationName(String destinationName)
+ {
+ this.destinationName = destinationName;
+ }
+
+ /**
+ * Returns the incoming client frequency (max-client-frequency).
+ *
+ * @return The incoming client frequency (max-client-frequency).
+ */
+ public int getIncomingClientFrequency()
+ {
+ return inClientMessagesPerSec;
+ }
+
+ /**
+ * Sets the incoming client frequency (max-client-frequency). Optional and the
+ * default value is 0. Note that the incoming client frequency cannot be more
+ * than the incoming destination frequency.
+ *
+ * @param n The incoming client frequency.
+ */
+ public void setIncomingClientFrequency(int n)
+ {
+ String name = "incoming client frequency";
+ blockNegative(n, name);
+
+ if (inDestinationMessagesPerSec > 0 && n > inDestinationMessagesPerSec)
+ {
+ ConfigurationException ex = new ConfigurationException();
+ // Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be more than the incoming destination frequency ''{3}''.
+ ex.setMessage(ERR_MSG_INVALID_INCOMING_CLENT_FREQ, new Object[]{name, destinationName,
+ Integer.valueOf(n), Integer.valueOf(inDestinationMessagesPerSec)});
+ throw ex;
+ }
+ this.inClientMessagesPerSec = n;
+ }
+
+ /**
+ * Returns the incoming destination frequency (max-frequency).
+ *
+ * @return The incoming destination frequency (max-frequency).
+ */
+ public int getIncomingDestinationFrequency()
+ {
+ return inDestinationMessagesPerSec;
+ }
+
+ /**
+ * Sets the incoming destination frequency (max-frequency). Optional and the
+ * default value is 0. Note that the incoming destination frequency cannot be
+ * less than the incoming client frequency.
+ *
+ * @param n The incoming destination frequency.
+ */
+ public void setIncomingDestinationFrequency(int n)
+ {
+ String name = "The incoming destination frequency";
+ blockNegative(n, name);
+
+ if (inClientMessagesPerSec > 0 && n < inClientMessagesPerSec)
+ {
+ ConfigurationException ex = new ConfigurationException();
+ // Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be less than the incoming client frequency ''{3}''.
+ ex.setMessage(ERR_MSG_INVALID_INCOMING_DEST_FREQ, new Object[]{name, destinationName,
+ Integer.valueOf(n), Integer.valueOf(inClientMessagesPerSec)});
+ throw ex;
+ }
+ this.inDestinationMessagesPerSec = n;
+ }
+
+ /**
+ * Returns the outgoing client frequency (max-client-frequency).
+ *
+ * @return The outgoing client frequency (max-client-frequency).
+ */
+ public int getOutgoingClientFrequency()
+ {
+ return outClientMessagesPerSec;
+ }
+
+ /**
+ * Sets the outgoing client frequency (max-client-frequency). Optional and the
+ * default value is 0. Note that the outgoing client frequency cannot be
+ * more than the outgoing destination frequency.
+ *
+ * @param n The outgoing client frequency.
+ */
+ public void setOutgoingClientFrequency(int n)
+ {
+ String name = "The outgoing client frequency";
+ blockNegative(n, name);
+
+ if (outDestinationMessagesPerSec > 0 && n > outDestinationMessagesPerSec)
+ {
+ ConfigurationException ex = new ConfigurationException();
+ // Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be more than the outgoing destination frequency ''{3}''.
+ ex.setMessage(ERR_MSG_INVALID_OUTGOING_CLIENT_FREQ, new Object[]{name, destinationName,
+ Integer.valueOf(n), Integer.valueOf(outDestinationMessagesPerSec)});
+ throw ex;
+ }
+ this.outClientMessagesPerSec = n;
+ }
+
+ /**
+ * Returns the outgoing destination frequency (max-frequency).
+ *
+ * @return The outgoing destination frequency (max-frequency).
+ */
+ public int getOutgoingDestinationFrequency()
+ {
+ return outDestinationMessagesPerSec;
+ }
+
+ /**
+ * Sets the outgoing destination frequency (max-frequency). Optional and the
+ * default value is 0. Note that the outgoing destination frequency cannot
+ * be less than the outgoing client frequency.
+ *
+ * @param n The outgoing destination frequency.
+ */
+ public void setOutgoingDestinationFrequency(int n)
+ {
+ String name = "The outgoing destination frequency";
+ blockNegative(n, name);
+
+ if (outClientMessagesPerSec > 0 && n < outClientMessagesPerSec)
+ {
+ ConfigurationException ex = new ConfigurationException();
+ // Invalid {0} for destination ''{1}''. {0} ''{2}'' cannot be less than the outgoing client frequency ''{3}''.
+ ex.setMessage(ERR_MSG_INVALID_OUTGOING_DEST_FREQ, new Object[]{name, destinationName, Integer.valueOf(n),
+ Integer.valueOf(outClientMessagesPerSec)});
+ throw ex;
+ }
+ this.outDestinationMessagesPerSec = n;
+ }
+
+ protected void blockNegative(int n, String name)
+ {
+ if (n < 0)
+ {
+ ConfigurationException ex = new ConfigurationException();
+ // Invalid {0} for destination ''{1}''. {0} cannot be negative.
+ ex.setMessage(ERR_MSG_INVALID_NEGATIVE_VALUE, new Object[]{name, destinationName});
+ throw ex;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/ValidatorSettings.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/ValidatorSettings.java b/modules/core/src/flex/messaging/config/ValidatorSettings.java
old mode 100755
new mode 100644
index d752cf1..ed2ab75
--- a/modules/core/src/flex/messaging/config/ValidatorSettings.java
+++ b/modules/core/src/flex/messaging/config/ValidatorSettings.java
@@ -1,68 +1,68 @@
-/*
- * 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.config;
-
-import flex.messaging.validators.DeserializationValidator;
-
-/**
- * Settings class for validators.
- */
-public class ValidatorSettings extends PropertiesSettings
-{
- private String className;
- private String type = DeserializationValidator.class.getName();
-
- /**
- * Returns the class name.
- *
- * @return The class name.
- */
- public String getClassName()
- {
- return className;
- }
-
- /**
- * Sets the class name.
- *
- * @param className The class name.
- */
- public void setClassName(String className)
- {
- this.className = className;
- }
-
- /**
- * Returns the type of the validator.
- *
- * @return The type of the validator.
- */
- public String getType()
- {
- return type;
- }
-
- /**
- * Sets the type of the validator.
- *
- * @param type The type of the validator.
- */
- public void setType(String type)
- {
- this.type = type;
- }
+/*
+ * 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.config;
+
+import flex.messaging.validators.DeserializationValidator;
+
+/**
+ * Settings class for validators.
+ */
+public class ValidatorSettings extends PropertiesSettings
+{
+ private String className;
+ private String type = DeserializationValidator.class.getName();
+
+ /**
+ * Returns the class name.
+ *
+ * @return The class name.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Sets the class name.
+ *
+ * @param className The class name.
+ */
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+ /**
+ * Returns the type of the validator.
+ *
+ * @return The type of the validator.
+ */
+ public String getType()
+ {
+ return type;
+ }
+
+ /**
+ * Sets the type of the validator.
+ *
+ * @param type The type of the validator.
+ */
+ public void setType(String type)
+ {
+ this.type = type;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/XPathServerConfigurationParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/XPathServerConfigurationParser.java b/modules/core/src/flex/messaging/config/XPathServerConfigurationParser.java
old mode 100755
new mode 100644
index 2cf0c67..2e0a04d
--- a/modules/core/src/flex/messaging/config/XPathServerConfigurationParser.java
+++ b/modules/core/src/flex/messaging/config/XPathServerConfigurationParser.java
@@ -1,94 +1,94 @@
-/*
- * 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.config;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-/**
- * Uses Sun's JDK 1.5 XPath implementation on a DOM
- * representation of a messaging configuration file.
- * <p>
- * Note: Since reference ids are used between elements, certain
- * sections of the document need to be parsed first.
- * </p>
- *
- * @author Peter Farland
- * @exclude
- */
-public class XPathServerConfigurationParser extends ServerConfigurationParser
-{
- private XPath xpath;
-
- protected void initializeExpressionQuery()
- {
- this.xpath = XPathFactory.newInstance().newXPath();
- }
-
- protected Node selectSingleNode(Node source, String expression)
- {
- try
- {
- return (Node) xpath.evaluate
- (expression, source, XPathConstants.NODE);
- }
- catch (XPathExpressionException expressionException)
- {
- throw wrapException(expressionException);
- }
- }
-
- protected NodeList selectNodeList(Node source, String expression)
- {
- try
- {
- return (NodeList) xpath.evaluate
- (expression, source, XPathConstants.NODESET);
- }
- catch (XPathExpressionException expressionException)
- {
- throw wrapException(expressionException);
- }
- }
-
- protected Object evaluateExpression(Node source, String expression)
- {
- try
- {
- return xpath.evaluate(expression, source, XPathConstants.STRING);
- }
- catch (XPathExpressionException expressionException)
- {
- throw wrapException(expressionException);
- }
- }
-
- private ConfigurationException wrapException
- (XPathExpressionException exception)
- {
- ConfigurationException result = new ConfigurationException();
- result.setDetails(PARSER_INTERNAL_ERROR);
- result.setRootCause(exception);
- return result;
- }
-
-}
+/*
+ * 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.config;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+/**
+ * Uses Sun's JDK 1.5 XPath implementation on a DOM
+ * representation of a messaging configuration file.
+ * <p>
+ * Note: Since reference ids are used between elements, certain
+ * sections of the document need to be parsed first.
+ * </p>
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public class XPathServerConfigurationParser extends ServerConfigurationParser
+{
+ private XPath xpath;
+
+ protected void initializeExpressionQuery()
+ {
+ this.xpath = XPathFactory.newInstance().newXPath();
+ }
+
+ protected Node selectSingleNode(Node source, String expression)
+ {
+ try
+ {
+ return (Node) xpath.evaluate
+ (expression, source, XPathConstants.NODE);
+ }
+ catch (XPathExpressionException expressionException)
+ {
+ throw wrapException(expressionException);
+ }
+ }
+
+ protected NodeList selectNodeList(Node source, String expression)
+ {
+ try
+ {
+ return (NodeList) xpath.evaluate
+ (expression, source, XPathConstants.NODESET);
+ }
+ catch (XPathExpressionException expressionException)
+ {
+ throw wrapException(expressionException);
+ }
+ }
+
+ protected Object evaluateExpression(Node source, String expression)
+ {
+ try
+ {
+ return xpath.evaluate(expression, source, XPathConstants.STRING);
+ }
+ catch (XPathExpressionException expressionException)
+ {
+ throw wrapException(expressionException);
+ }
+ }
+
+ private ConfigurationException wrapException
+ (XPathExpressionException exception)
+ {
+ ConfigurationException result = new ConfigurationException();
+ result.setDetails(PARSER_INTERNAL_ERROR);
+ result.setRootCause(exception);
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/config/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/config/package-info.java b/modules/core/src/flex/messaging/config/package-info.java
old mode 100755
new mode 100644
index 2a2fcd7..266fd52
--- a/modules/core/src/flex/messaging/config/package-info.java
+++ b/modules/core/src/flex/messaging/config/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.config;
\ No newline at end of file
[43/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/log/AbstractTarget.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/log/AbstractTarget.java b/modules/common/src/flex/messaging/log/AbstractTarget.java
old mode 100755
new mode 100644
index 82b455f..ec2696b
--- a/modules/common/src/flex/messaging/log/AbstractTarget.java
+++ b/modules/common/src/flex/messaging/log/AbstractTarget.java
@@ -1,268 +1,268 @@
-/*
- * 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.log;
-
-import flex.messaging.LocalizedException;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.util.UUIDUtils;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @exclude
- */
-public abstract class AbstractTarget implements Target
-{
- private static final int INVALID_FILTER_CHARS = 10016;
- private static final int INVALID_FILTER_STAR = 10017;
-
- protected final String id;
- protected List filters;
- protected volatile short level;
- protected volatile int loggerCount;
- private final Object lock = new Object();
- private boolean usingDefaultFilter = false;
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Default constructor.
- */
- public AbstractTarget()
- {
- id = UUIDUtils.createUUID();
- level = LogEvent.ERROR;
- filters = new ArrayList();
- filters.add("*");
- usingDefaultFilter = true;
- }
-
- //--------------------------------------------------------------------------
- //
- // Initialize, validate, start, and stop methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes the target with id and properties. Subclasses can overwrite.
- *
- * @param id id for the target which is ignored.
- * @param properties ConfigMap of properties for the target.
- */
- public void initialize(String id, ConfigMap properties)
- {
- // No-op
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Getters and Setters for AbstractTarget properties
- //
- //--------------------------------------------------------------------------
-
- /**
- * Return a read-only snap-shot of the current filters for this target.
- *
- * @return An unmodifiable list of filters.
- */
- public List getFilters()
- {
- return Collections.unmodifiableList(new ArrayList(filters));
- }
-
- /**
- * Adds a filter to this target.
- *
- * @param value Filter to be added.
- */
- public void addFilter(String value)
- {
- if (value != null)
- validateFilter(value);
- else // Default to "*"
- value = "*";
-
- boolean filterWasAdded = false;
- synchronized (lock)
- {
- if (!filters.contains(value))
- {
- // If the default filter is being used, remove it.
- if (usingDefaultFilter)
- {
- removeFilter("*");
- usingDefaultFilter = false;
- }
- filters.add(value);
- filterWasAdded = true;
- }
- }
- if (filterWasAdded)
- Log.processTargetFilterAdd(this, value);
- }
-
- /**
- * Removes a filter from this target.
- *
- * @param value Filter to be removed.
- */
- public void removeFilter(String value)
- {
- boolean filterWasRemoved;
- synchronized (lock)
- {
- filterWasRemoved = filters.remove(value);
- }
- if (filterWasRemoved)
- Log.processTargetFilterRemove(this, value);
- }
-
- /**
- * Sets the list of filters for this target.
- *
- * @param value List of filters.
- */
- public void setFilters(List value)
- {
- if (value != null && value.size() > 0)
- {
- // a valid filter value will be fully qualified or have a wildcard
- // in it. the wild card can only be located at the end of the
- // expression. valid examples xx*, xx.*, *
- for (int i = 0; i < value.size(); i++)
- {
- validateFilter((String) value.get(i));
- }
- }
- else
- {
- // if null was specified then default to all
- value = new ArrayList();
- value.add("*");
- }
-
- Log.removeTarget(this);
- synchronized (lock)
- {
- filters = value;
- usingDefaultFilter = false;
- }
- Log.addTarget(this);
- }
-
- /**
- * Return the log level for this target.
- */
- public short getLevel()
- {
- return level;
- }
-
- /**
- * Return the target's unique ID.
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * Sets the log level for this target. If not set, defaults to <code>LogEvent.ERROR</code>.
- */
- public void setLevel(short value)
- {
- level = value;
- Log.resetTargetLevel();
- }
-
- /**
- * Sets up this target with the specified logger.
- * This allows this target to receive log events from the specified logger.
- *
- * @param logger this target should listen to.
- */
- public void addLogger(Logger logger)
- {
- if (logger != null)
- {
- synchronized (lock)
- {
- loggerCount++;
- }
- logger.addTarget(this);
- }
- }
-
- /**
- * Stops this target from receiving events from the specified logger.
- *
- * @param logger this target should ignore.
- */
- public void removeLogger(Logger logger)
- {
- if (logger != null)
- {
- synchronized (lock)
- {
- loggerCount--;
- }
- logger.removeTarget(this);
- }
- }
-
- /**
- * @param filter category to check against the filters defined for this target
- * @return whether filter is defined
- */
- public boolean containsFilter(String filter)
- {
- return filters.contains(filter);
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected/private methods.
- //
- //--------------------------------------------------------------------------
-
- private void validateFilter(String value)
- {
- // check for invalid characters
- if (Log.hasIllegalCharacters(value))
- {
- //Error for filter '{filter}'. The following characters are not valid: {Log.INVALID_CHARS}
- LocalizedException ex = new LocalizedException();
- ex.setMessage(INVALID_FILTER_CHARS, new Object[]{value, Log.INVALID_CHARS});
- throw ex;
- }
-
- int index = value.indexOf('*');
- if ((index >= 0) && (index != (value.length() - 1)))
- {
- //Error for filter '{filter}'. '*' must be the right most character.
- LocalizedException ex = new LocalizedException();
- ex.setMessage(INVALID_FILTER_STAR, new Object[]{value});
- throw ex;
- }
- }
-}
+/*
+ * 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.log;
+
+import flex.messaging.LocalizedException;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.util.UUIDUtils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @exclude
+ */
+public abstract class AbstractTarget implements Target
+{
+ private static final int INVALID_FILTER_CHARS = 10016;
+ private static final int INVALID_FILTER_STAR = 10017;
+
+ protected final String id;
+ protected List filters;
+ protected volatile short level;
+ protected volatile int loggerCount;
+ private final Object lock = new Object();
+ private boolean usingDefaultFilter = false;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Default constructor.
+ */
+ public AbstractTarget()
+ {
+ id = UUIDUtils.createUUID();
+ level = LogEvent.ERROR;
+ filters = new ArrayList();
+ filters.add("*");
+ usingDefaultFilter = true;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Initialize, validate, start, and stop methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes the target with id and properties. Subclasses can overwrite.
+ *
+ * @param id id for the target which is ignored.
+ * @param properties ConfigMap of properties for the target.
+ */
+ public void initialize(String id, ConfigMap properties)
+ {
+ // No-op
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Getters and Setters for AbstractTarget properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Return a read-only snap-shot of the current filters for this target.
+ *
+ * @return An unmodifiable list of filters.
+ */
+ public List getFilters()
+ {
+ return Collections.unmodifiableList(new ArrayList(filters));
+ }
+
+ /**
+ * Adds a filter to this target.
+ *
+ * @param value Filter to be added.
+ */
+ public void addFilter(String value)
+ {
+ if (value != null)
+ validateFilter(value);
+ else // Default to "*"
+ value = "*";
+
+ boolean filterWasAdded = false;
+ synchronized (lock)
+ {
+ if (!filters.contains(value))
+ {
+ // If the default filter is being used, remove it.
+ if (usingDefaultFilter)
+ {
+ removeFilter("*");
+ usingDefaultFilter = false;
+ }
+ filters.add(value);
+ filterWasAdded = true;
+ }
+ }
+ if (filterWasAdded)
+ Log.processTargetFilterAdd(this, value);
+ }
+
+ /**
+ * Removes a filter from this target.
+ *
+ * @param value Filter to be removed.
+ */
+ public void removeFilter(String value)
+ {
+ boolean filterWasRemoved;
+ synchronized (lock)
+ {
+ filterWasRemoved = filters.remove(value);
+ }
+ if (filterWasRemoved)
+ Log.processTargetFilterRemove(this, value);
+ }
+
+ /**
+ * Sets the list of filters for this target.
+ *
+ * @param value List of filters.
+ */
+ public void setFilters(List value)
+ {
+ if (value != null && value.size() > 0)
+ {
+ // a valid filter value will be fully qualified or have a wildcard
+ // in it. the wild card can only be located at the end of the
+ // expression. valid examples xx*, xx.*, *
+ for (int i = 0; i < value.size(); i++)
+ {
+ validateFilter((String) value.get(i));
+ }
+ }
+ else
+ {
+ // if null was specified then default to all
+ value = new ArrayList();
+ value.add("*");
+ }
+
+ Log.removeTarget(this);
+ synchronized (lock)
+ {
+ filters = value;
+ usingDefaultFilter = false;
+ }
+ Log.addTarget(this);
+ }
+
+ /**
+ * Return the log level for this target.
+ */
+ public short getLevel()
+ {
+ return level;
+ }
+
+ /**
+ * Return the target's unique ID.
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Sets the log level for this target. If not set, defaults to <code>LogEvent.ERROR</code>.
+ */
+ public void setLevel(short value)
+ {
+ level = value;
+ Log.resetTargetLevel();
+ }
+
+ /**
+ * Sets up this target with the specified logger.
+ * This allows this target to receive log events from the specified logger.
+ *
+ * @param logger this target should listen to.
+ */
+ public void addLogger(Logger logger)
+ {
+ if (logger != null)
+ {
+ synchronized (lock)
+ {
+ loggerCount++;
+ }
+ logger.addTarget(this);
+ }
+ }
+
+ /**
+ * Stops this target from receiving events from the specified logger.
+ *
+ * @param logger this target should ignore.
+ */
+ public void removeLogger(Logger logger)
+ {
+ if (logger != null)
+ {
+ synchronized (lock)
+ {
+ loggerCount--;
+ }
+ logger.removeTarget(this);
+ }
+ }
+
+ /**
+ * @param filter category to check against the filters defined for this target
+ * @return whether filter is defined
+ */
+ public boolean containsFilter(String filter)
+ {
+ return filters.contains(filter);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected/private methods.
+ //
+ //--------------------------------------------------------------------------
+
+ private void validateFilter(String value)
+ {
+ // check for invalid characters
+ if (Log.hasIllegalCharacters(value))
+ {
+ //Error for filter '{filter}'. The following characters are not valid: {Log.INVALID_CHARS}
+ LocalizedException ex = new LocalizedException();
+ ex.setMessage(INVALID_FILTER_CHARS, new Object[]{value, Log.INVALID_CHARS});
+ throw ex;
+ }
+
+ int index = value.indexOf('*');
+ if ((index >= 0) && (index != (value.length() - 1)))
+ {
+ //Error for filter '{filter}'. '*' must be the right most character.
+ LocalizedException ex = new LocalizedException();
+ ex.setMessage(INVALID_FILTER_STAR, new Object[]{value});
+ throw ex;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/log/ConsoleTarget.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/log/ConsoleTarget.java b/modules/common/src/flex/messaging/log/ConsoleTarget.java
old mode 100755
new mode 100644
index d33c1e0..b1245ce
--- a/modules/common/src/flex/messaging/log/ConsoleTarget.java
+++ b/modules/common/src/flex/messaging/log/ConsoleTarget.java
@@ -1,42 +1,42 @@
-/*
- * 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.log;
-
-/**
- * @exclude
- */
-public class ConsoleTarget extends LineFormattedTarget
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Default constructor.
- */
- public ConsoleTarget()
- {
- super();
- }
-
- protected void internalLog(String message)
- {
- System.out.println(message);
- }
-}
+/*
+ * 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.log;
+
+/**
+ * @exclude
+ */
+public class ConsoleTarget extends LineFormattedTarget
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Default constructor.
+ */
+ public ConsoleTarget()
+ {
+ super();
+ }
+
+ protected void internalLog(String message)
+ {
+ System.out.println(message);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/log/LineFormattedTarget.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/log/LineFormattedTarget.java b/modules/common/src/flex/messaging/log/LineFormattedTarget.java
old mode 100755
new mode 100644
index d72387b..a406890
--- a/modules/common/src/flex/messaging/log/LineFormattedTarget.java
+++ b/modules/common/src/flex/messaging/log/LineFormattedTarget.java
@@ -1,286 +1,286 @@
-/*
- * 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.log;
-
-import flex.messaging.config.ConfigMap;
-import flex.messaging.util.ExceptionUtil;
-import flex.messaging.util.StringUtils;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * @exclude
- */
-public class LineFormattedTarget extends AbstractTarget
-{
- /**
- * Indicates if the date should be added to the trace.
- */
- protected boolean includeDate;
-
- /**
- * Indicates if the time should be added to the trace.
- */
- protected boolean includeTime;
-
- /**
- * Indicates if the level for the event should added to the trace.
- */
- protected boolean includeLevel;
-
- /**
- * Indicates if the category for this target should added to the trace.
- */
- protected boolean includeCategory;
-
- /**
- * A prefix to prepend onto each logged message.
- */
- protected String prefix = null;
-
- /**
- * The formatter to write the date as part of the logging statement.
- * Defaults to MM/dd/yyyy format.
- */
- protected DateFormat dateFormater = new SimpleDateFormat("MM/dd/yyyy");
-
- /**
- * The formatter to write the time as part of the logging statement.
- * Defaults to HH:mm:ss.SSS format.
- */
- protected DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss.SSS");
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Default constructor.
- */
- public LineFormattedTarget()
- {
- super();
- }
-
- //--------------------------------------------------------------------------
- //
- // Initialize, validate, start, and stop methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes the target with id and properties. Subclasses can overwrite.
- *
- * @param id id for the target which is ignored.
- * @param properties ConfigMap of properties for the target.
- */
- public void initialize(String id, ConfigMap properties)
- {
- super.initialize(id, properties);
-
- includeTime = properties.getPropertyAsBoolean("includeTime", false);
- includeDate = properties.getPropertyAsBoolean("includeDate", false);
- includeCategory = properties.getPropertyAsBoolean("includeCategory", false);
- includeLevel = properties.getPropertyAsBoolean("includeLevel", false);
- prefix = properties.getPropertyAsString("prefix", null);
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Getters and Setters for AbstractService properties
- //
- //--------------------------------------------------------------------------
-
- /**
- * Returns includeCategory property.
- *
- * @return <code>true</code> if category is included; <code>false</code> otherwise.
- */
- public boolean isIncludeCategory()
- {
- return includeCategory;
- }
-
- /**
- * Sets includeCategory property.
- *
- * @param includeCategory the include category
- */
- public void setIncludeCategory(boolean includeCategory)
- {
- this.includeCategory = includeCategory;
- }
-
- /**
- * Returns includeDate property.
- *
- * @return <code>true</code> if date is included; <code>false</code> otherwise.
- */
- public boolean isIncludeDate()
- {
- return includeDate;
- }
-
- /**
- * Sets includeDate property.
- *
- * @param includeDate the include date
- */
- public void setIncludeDate(boolean includeDate)
- {
- this.includeDate = includeDate;
- }
-
- /**
- * Returns includeLevel property.
- *
- * @return <code>true</code> if level is included; <code>false</code> otherwise.
- */
- public boolean isIncludeLevel()
- {
- return includeLevel;
- }
-
- /**
- * Sets includeLevel property.
- *
- * @param includeLevel the include level
- */
- public void setIncludeLevel(boolean includeLevel)
- {
- this.includeLevel = includeLevel;
- }
-
- /**
- * Returns includeTime property.
- *
- * @return <code>true</code> if time is included; <code>false</code> otherwise.
- */
- public boolean isIncludeTime()
- {
- return includeTime;
- }
-
- /**
- * Sets includeTime property.
- *
- * @param includeTime the include time
- */
- public void setIncludeTime(boolean includeTime)
- {
- this.includeTime = includeTime;
- }
-
- /**
- * Returns prefix property.
- *
- * @return The prefix for log messages.
- */
- public String getPrefix()
- {
- return prefix;
- }
-
- /**
- * Sets prefix property.
- *
- * @param prefix the prefix string
- */
- public void setPrefix(String prefix)
- {
- this.prefix = prefix;
- }
-
- /**
- * This method handles a <code>LogEvent</code> from an associated logger.
- * A target uses this method to translate the event into the appropriate
- * format for transmission, storage, or display.
- * This method will be called only if the event's level is in range of the
- * target's level.
- * @param event the log event
- */
- public void logEvent(LogEvent event)
- {
- String pre = "";
- if (prefix != null)
- {
- pre = prefix + " "; // any space is stripped from config
- }
-
- String date = "";
- if (includeDate || includeTime)
- {
- StringBuffer buffer = new StringBuffer();
- Date d = new Date();
- if (includeDate)
- {
- buffer.append(dateFormater.format(d));
- buffer.append(" ");
- }
- if (includeTime)
- {
- buffer.append(timeFormatter.format(d));
- buffer.append(" ");
- }
- date = buffer.toString();
- }
-
- String cat = includeCategory ?
- ("[" + event.logger.getCategory() + "] ") : "";
- String level = "";
- if (includeLevel)
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("[");
- buffer.append(LogEvent.getLevelString(event.level));
- buffer.append("]");
- buffer.append(" ");
- level = buffer.toString();
- }
- StringBuffer result = new StringBuffer(pre);
- result.append(date).append(level).append(cat).append(event.message);
-
- if (event.throwable != null)
- result.append(StringUtils.NEWLINE).append(ExceptionUtil.toString(event.throwable));
-
- internalLog(result.toString());
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected/private methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Descendants of this class should override this method to direct the
- * specified message to the desired output.
- *
- * @param message String containing preprocessed log message which may
- * include time, date, category, etc. based on property settings,
- * such as <code>includeDate</code>, <code>includeCategory</code>,
- * etc.
- */
- protected void internalLog(String message)
- {
- // override this method to perform the redirection to the desired output
- }
-}
+/*
+ * 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.log;
+
+import flex.messaging.config.ConfigMap;
+import flex.messaging.util.ExceptionUtil;
+import flex.messaging.util.StringUtils;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @exclude
+ */
+public class LineFormattedTarget extends AbstractTarget
+{
+ /**
+ * Indicates if the date should be added to the trace.
+ */
+ protected boolean includeDate;
+
+ /**
+ * Indicates if the time should be added to the trace.
+ */
+ protected boolean includeTime;
+
+ /**
+ * Indicates if the level for the event should added to the trace.
+ */
+ protected boolean includeLevel;
+
+ /**
+ * Indicates if the category for this target should added to the trace.
+ */
+ protected boolean includeCategory;
+
+ /**
+ * A prefix to prepend onto each logged message.
+ */
+ protected String prefix = null;
+
+ /**
+ * The formatter to write the date as part of the logging statement.
+ * Defaults to MM/dd/yyyy format.
+ */
+ protected DateFormat dateFormater = new SimpleDateFormat("MM/dd/yyyy");
+
+ /**
+ * The formatter to write the time as part of the logging statement.
+ * Defaults to HH:mm:ss.SSS format.
+ */
+ protected DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss.SSS");
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Default constructor.
+ */
+ public LineFormattedTarget()
+ {
+ super();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Initialize, validate, start, and stop methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes the target with id and properties. Subclasses can overwrite.
+ *
+ * @param id id for the target which is ignored.
+ * @param properties ConfigMap of properties for the target.
+ */
+ public void initialize(String id, ConfigMap properties)
+ {
+ super.initialize(id, properties);
+
+ includeTime = properties.getPropertyAsBoolean("includeTime", false);
+ includeDate = properties.getPropertyAsBoolean("includeDate", false);
+ includeCategory = properties.getPropertyAsBoolean("includeCategory", false);
+ includeLevel = properties.getPropertyAsBoolean("includeLevel", false);
+ prefix = properties.getPropertyAsString("prefix", null);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Getters and Setters for AbstractService properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns includeCategory property.
+ *
+ * @return <code>true</code> if category is included; <code>false</code> otherwise.
+ */
+ public boolean isIncludeCategory()
+ {
+ return includeCategory;
+ }
+
+ /**
+ * Sets includeCategory property.
+ *
+ * @param includeCategory the include category
+ */
+ public void setIncludeCategory(boolean includeCategory)
+ {
+ this.includeCategory = includeCategory;
+ }
+
+ /**
+ * Returns includeDate property.
+ *
+ * @return <code>true</code> if date is included; <code>false</code> otherwise.
+ */
+ public boolean isIncludeDate()
+ {
+ return includeDate;
+ }
+
+ /**
+ * Sets includeDate property.
+ *
+ * @param includeDate the include date
+ */
+ public void setIncludeDate(boolean includeDate)
+ {
+ this.includeDate = includeDate;
+ }
+
+ /**
+ * Returns includeLevel property.
+ *
+ * @return <code>true</code> if level is included; <code>false</code> otherwise.
+ */
+ public boolean isIncludeLevel()
+ {
+ return includeLevel;
+ }
+
+ /**
+ * Sets includeLevel property.
+ *
+ * @param includeLevel the include level
+ */
+ public void setIncludeLevel(boolean includeLevel)
+ {
+ this.includeLevel = includeLevel;
+ }
+
+ /**
+ * Returns includeTime property.
+ *
+ * @return <code>true</code> if time is included; <code>false</code> otherwise.
+ */
+ public boolean isIncludeTime()
+ {
+ return includeTime;
+ }
+
+ /**
+ * Sets includeTime property.
+ *
+ * @param includeTime the include time
+ */
+ public void setIncludeTime(boolean includeTime)
+ {
+ this.includeTime = includeTime;
+ }
+
+ /**
+ * Returns prefix property.
+ *
+ * @return The prefix for log messages.
+ */
+ public String getPrefix()
+ {
+ return prefix;
+ }
+
+ /**
+ * Sets prefix property.
+ *
+ * @param prefix the prefix string
+ */
+ public void setPrefix(String prefix)
+ {
+ this.prefix = prefix;
+ }
+
+ /**
+ * This method handles a <code>LogEvent</code> from an associated logger.
+ * A target uses this method to translate the event into the appropriate
+ * format for transmission, storage, or display.
+ * This method will be called only if the event's level is in range of the
+ * target's level.
+ * @param event the log event
+ */
+ public void logEvent(LogEvent event)
+ {
+ String pre = "";
+ if (prefix != null)
+ {
+ pre = prefix + " "; // any space is stripped from config
+ }
+
+ String date = "";
+ if (includeDate || includeTime)
+ {
+ StringBuffer buffer = new StringBuffer();
+ Date d = new Date();
+ if (includeDate)
+ {
+ buffer.append(dateFormater.format(d));
+ buffer.append(" ");
+ }
+ if (includeTime)
+ {
+ buffer.append(timeFormatter.format(d));
+ buffer.append(" ");
+ }
+ date = buffer.toString();
+ }
+
+ String cat = includeCategory ?
+ ("[" + event.logger.getCategory() + "] ") : "";
+ String level = "";
+ if (includeLevel)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("[");
+ buffer.append(LogEvent.getLevelString(event.level));
+ buffer.append("]");
+ buffer.append(" ");
+ level = buffer.toString();
+ }
+ StringBuffer result = new StringBuffer(pre);
+ result.append(date).append(level).append(cat).append(event.message);
+
+ if (event.throwable != null)
+ result.append(StringUtils.NEWLINE).append(ExceptionUtil.toString(event.throwable));
+
+ internalLog(result.toString());
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected/private methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Descendants of this class should override this method to direct the
+ * specified message to the desired output.
+ *
+ * @param message String containing preprocessed log message which may
+ * include time, date, category, etc. based on property settings,
+ * such as <code>includeDate</code>, <code>includeCategory</code>,
+ * etc.
+ */
+ protected void internalLog(String message)
+ {
+ // override this method to perform the redirection to the desired output
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/log/Log.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/log/Log.java b/modules/common/src/flex/messaging/log/Log.java
old mode 100755
new mode 100644
index 4ae4d20..5e14048
--- a/modules/common/src/flex/messaging/log/Log.java
+++ b/modules/common/src/flex/messaging/log/Log.java
@@ -1,704 +1,704 @@
-/*
- * 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.log;
-
-import flex.messaging.LocalizedException;
-import flex.messaging.config.ConfigMap;
-import flex.messaging.util.PrettyPrinter;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.HashSet;
-
-/**
- * @exclude
- */
-public class Log
-{
-
- /** @exclude **/
- public static final String INVALID_CHARS = "[]~$^&\\/(){}<>+=`!#%?,:;\'\"@";
-
- // Errors
- private static final int INVALID_TARGET = 10013;
- private static final int INVALID_CATEGORY = 10014;
- private static final int INVALID_CATEGORY_CHARS = 10015;
-
- private static Log log;
- private static PrettyPrinter prettyPrinter;
- private static String prettyPrinterClass = "BasicPrettyPrinter";
-
- private static final HashSet excludedProperties = new HashSet();
- /** @exclude **/
- public static final String VALUE_SUPRESSED = "** [Value Suppressed] **";
-
- private volatile short targetLevel;
- private final Map loggers;
- private final List targets;
- private final Map targetMap;
- private static final Object staticLock = new Object();
-
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Private constructor.
- */
- private Log()
- {
- targetLevel = LogEvent.NONE;
- loggers = new HashMap();
- targets = new ArrayList();
- targetMap = new LinkedHashMap();
- }
-
-
- /**
- * Creates the log on first access, returns already created log on
- * subsequent calls.
- *
- * @return log.
- */
- public static Log createLog()
- {
- synchronized (staticLock)
- {
- if (log == null)
- log = new Log();
-
- return log;
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Initialize, validate, start, and stop methods.
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes Log with id and properties.
- *
- * @param id Id for the Log which is ignored, though is used by the ManageableComponent superclass
- * @param properties ConfigMap of properties for the Log.
- */
- public static synchronized void initialize(String id, ConfigMap properties)
- {
- String value = properties.getPropertyAsString("pretty-printer", null);
- if (value != null)
- prettyPrinterClass = value;
-
- // Create a HashSet with the properties that we want to exclude from the
- // list of properties given by 'getPropertiesAsList'
- ConfigMap excludeMap = properties.getPropertyAsMap("exclude-properties", null);
- if (excludeMap != null)
- {
- if (excludeMap.getPropertyAsList("property", null) != null)
- excludedProperties.addAll(excludeMap.getPropertyAsList("property", null));
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Getters and Setters for Log properties
- //
- //--------------------------------------------------------------------------
-
- /**
- * Indicates whether a fatal level log event will be processed by a log target.
- * @return boolean true if it is Fatal level
- */
- public static boolean isFatal()
- {
- return log == null ? false : log.targetLevel <= LogEvent.FATAL;
- }
-
- /**
- * Indicates whether an error level log event will be processed by a log target.
- * @return boolean true if it is Error level
- */
- public static boolean isError()
- {
- return log == null ? false : log.targetLevel <= LogEvent.ERROR;
- }
-
- /**
- * Indicates whether a warn level log event will be processed by a log target.
- * @return boolean true if it is Warn level
- */
- public static boolean isWarn()
- {
- return log == null ? false : log.targetLevel <= LogEvent.WARN;
- }
-
- /**
- * Indicates whether an info level log event will be processed by a log target.
- * @return boolean true if it is Info level
- */
- public static boolean isInfo()
- {
- return log == null ? false : log.targetLevel <= LogEvent.INFO;
- }
-
- /**
- * Indicates whether a debug level log event will be processed by a log target.
- * @return boolean true if it is debug level
- */
- public static boolean isDebug()
- {
- return log == null ? false : log.targetLevel <= LogEvent.DEBUG;
- }
-
- /**
- * Indicates whether a log property should be excluded.
- * @param property the property to check
- * @return boolean true if the property should be excluded
- */
- public static boolean isExcludedProperty(String property)
- {
- return !excludedProperties.isEmpty() && excludedProperties.contains(property);
- }
-
-
- /**
- * Given a category, returns the logger associated with the category.
- *
- * @param category Categogry for the logger.
- * @return Logger associated with the category.
- */
- public static Logger getLogger(String category)
- {
- if (log != null)
- return getLogger(log, category);
-
- // Return a dummy logger?
- return new Logger(category);
- }
-
- /**
- * @exclude
- */
- public static Logger getLogger(Log log, String category)
- {
- checkCategory(category);
-
- synchronized (staticLock)
- {
- Logger result = (Logger) log.loggers.get(category);
- if (result == null)
- {
- result = new Logger(category);
-
- // Check to see if there are any targets for this logger.
- for (Iterator iter = log.targets.iterator(); iter.hasNext();)
- {
- Target target = (Target) iter.next();
- if (categoryMatchInFilterList(category, target.getFilters()))
- target.addLogger(result);
- }
-
- log.loggers.put(category, result);
- }
- return result;
- }
- }
-
- /**
- * Returns an unmodifiable snapshot of the targets registered with this Log when the
- * method is invoked.
- * @return List the list of targets
- */
- public static List getTargets()
- {
- if (log != null)
- {
- List currentTargets;
- // Snapshot the current target list (shallow copy) and return it.
- synchronized (staticLock)
- {
- currentTargets = Collections.unmodifiableList(new ArrayList(log.targets));
- }
- return currentTargets;
- }
- return null;
- }
-
- /**
- * Return the Log's map of targets keyed on their human-readable ids (e.g. ConsoleTarget0, ConsoleTarget1, etc.)
- * @return Map the target map
- */
- public static Map getTargetMap()
- {
- if (log != null)
- {
- Map currentTargets;
- synchronized (staticLock)
- {
- currentTargets = new LinkedHashMap(log.targetMap);
- }
- return currentTargets;
- }
- return null;
- }
-
- /**
- * Returns the target associated with the unique ID searchId. Returns null if no
- * such target exists.
- * @param searchId the search ID
- * @return Target the associated target
- */
- public static Target getTarget(String searchId)
- {
- if (log != null)
- {
- synchronized (staticLock)
- {
- return (Target) log.targetMap.get(searchId);
- }
- }
-
- return null;
- }
-
- /**
- * Return the categories for all of the loggers
- * @return String[] the categories for all of the loggers
- */
- public String[] getLoggers()
- {
- String[] currentCategories;
- if (log != null)
- {
- synchronized (staticLock)
- {
- Object[] currentCategoryObjects = loggers.keySet().toArray();
- currentCategories = new String[currentCategoryObjects.length];
- for (int i = 0; i < currentCategoryObjects.length; i++)
- {
- currentCategories[i] = (String)(currentCategoryObjects[i]);
- }
- }
- }
- else
- {
- currentCategories = new String[0];
- }
-
- return currentCategories;
- }
-
- /**
- * Adds a target to the log.
- *
- * @param target Target to be added.
- */
- public static void addTarget(Target target)
- {
- if (log != null)
- {
- if (target != null)
- {
- synchronized (staticLock)
- {
- List filters = target.getFilters();
-
- // need to find what filters this target matches and set the specified
- // target as a listener for that logger.
- Iterator it = log.loggers.keySet().iterator();
- while (it.hasNext())
- {
- String key = (String) it.next();
- if (categoryMatchInFilterList(key, filters))
- target.addLogger((Logger) log.loggers.get(key));
- }
- // if we found a match all is good, otherwise we need to
- // put the target in a waiting queue in the event that a logger
- // is created that this target cares about.
- if (!log.targets.contains(target))
- log.targets.add(target);
-
- if (!log.targetMap.containsValue(target))
- {
- String name = target.getClass().getName();
-
- if (name.indexOf(".") > -1)
- {
- String[] classes = name.split("\\.");
- name = classes[classes.length - 1];
- }
-
- log.targetMap.put(new String(name + log.targetMap.size()), target);
- }
-
- // update our global target log level if this target is more verbose.
- short targetLevel = target.getLevel();
- if (log.targetLevel == LogEvent.NONE)
- log.targetLevel = targetLevel;
- else if (targetLevel < log.targetLevel)
- {
- log.targetLevel = targetLevel;
- }
- }
- }
- else
- {
- // Invalid target specified. Target must not be null.
- LocalizedException ex = new LocalizedException();
- ex.setMessage(INVALID_TARGET);
- throw ex;
- }
- }
- }
-
- /**
- * Removes a target from the log.
- *
- * @param target The target to be removed.
- */
- public static void removeTarget(Target target)
- {
- if (log != null)
- {
- if (target != null)
- {
- synchronized (staticLock)
- {
- // Remove the target from any associated loggers.
- List filters = target.getFilters();
- Iterator it = log.loggers.keySet().iterator();
- while (it.hasNext())
- {
- String key = (String) it.next();
- if (categoryMatchInFilterList(key, filters))
- target.removeLogger((Logger) log.loggers.get(key));
- }
- // Remove the target from the Log set.
- log.targets.remove(target);
- resetTargetLevel();
- }
- }
- else
- {
- // Invalid target specified. Target must not be null.
- LocalizedException ex = new LocalizedException();
- ex.setMessage(INVALID_TARGET);
- throw ex;
- }
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Other Public APIs
- //
- //--------------------------------------------------------------------------
-
- /**
- * This method removes all of the current loggers and targets from the cache.
- * and resets target level.
- */
- public static synchronized void reset()
- {
- flush();
- }
-
- /**
- * @exclude
- */
- public static void flush()
- {
- if (log != null)
- {
- log.loggers.clear();
- log.targets.clear();
- log.targetLevel = LogEvent.NONE;
- }
- }
-
- /**
- * @exclude
- */
- public static short readLevel(String l)
- {
- short lvl = LogEvent.ERROR;
- if ((l != null) && (l.length() > 0))
- {
- l = l.trim().toLowerCase();
- char c = l.charAt(0);
- switch (c)
- {
- case 'n':
- lvl = LogEvent.NONE;
- break;
- case 'e':
- lvl = LogEvent.ERROR;
- break;
- case 'w':
- lvl = LogEvent.WARN;
- break;
- case 'i':
- lvl = LogEvent.INFO;
- break;
- case 'd':
- lvl = LogEvent.DEBUG;
- break;
- case 'a':
- lvl = LogEvent.ALL;
- break;
- default:
- lvl = LogEvent.ERROR;
- }
- }
-
- return lvl;
- }
-
- /**
- * @exclude
- * This method checks the specified string value for illegal characters.
- *
- * @param value to check for illegal characters.
- * The following characters are not valid:
- * []~$^&\/(){}<>+=`!#%?,:;'"&#64;
- * @return <code>true</code> if there are any illegal characters found,
- * <code>false</code> otherwise
- */
- public static boolean hasIllegalCharacters(String value)
- {
- char[] chars = value.toCharArray();
- for (int i = 0; i < chars.length; i++)
- {
- char c = chars[i];
- if (INVALID_CHARS.indexOf(c) != -1)
- {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * @exclude
- * Returns the PrettyPrinter used by the Log.
- */
- public static PrettyPrinter getPrettyPrinter()
- {
- if (prettyPrinter == null ||
- !prettyPrinter.getClass().getName().equals(prettyPrinterClass))
- {
- try
- {
- Class c = Class.forName(prettyPrinterClass);
- prettyPrinter = (PrettyPrinter)c.newInstance();
- }
- catch (Throwable t)
- {
- }
- }
- return (PrettyPrinter)prettyPrinter.copy();
- }
-
- /**
- * @exclude
- * Returns the current target level for the Log.
- */
- public static short getTargetLevel()
- {
- return log == null ? LogEvent.NONE : log.targetLevel;
- }
-
- /**
- * @exclude
- * Sets the pretty printer class name used by the log.
- *
- * @param value Name of the pretty printer class.
- */
- public static void setPrettyPrinterClass(String value)
- {
- prettyPrinterClass = value;
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected/private methods.
- //
- //--------------------------------------------------------------------------
-
- /* package */ static void resetTargetLevel()
- {
- if (log != null)
- {
- synchronized (staticLock)
- {
- short maxTargetLevel = LogEvent.NONE;
- for (Iterator iter = log.targets.iterator(); iter.hasNext();)
- {
- short targetLevel = ((Target) iter.next()).getLevel();
- if (maxTargetLevel == LogEvent.NONE || targetLevel < maxTargetLevel)
- maxTargetLevel = targetLevel;
- }
- log.targetLevel = maxTargetLevel;
- }
- }
- }
-
- /* package */ static void processTargetFilterAdd(Target target, String filter)
- {
- if (log != null)
- {
- synchronized (staticLock)
- {
- List filters = new ArrayList();
- filters.add(filter);
-
- // Find the loggers this target matches and add the
- // target as a listener for log events from these loggers.
- Iterator it = log.loggers.keySet().iterator();
- while (it.hasNext())
- {
- String key = (String) it.next();
- if (categoryMatchInFilterList(key, filters))
- target.addLogger((Logger) log.loggers.get(key));
- }
- }
- }
- }
-
- /* package */ static void processTargetFilterRemove(Target target, String filter)
- {
- if (log != null)
- {
- synchronized (staticLock)
- {
- // Remove the target from any matching loggers.
- List filters = new ArrayList();
- filters.add(filter);
- Iterator it = log.loggers.keySet().iterator();
- while (it.hasNext())
- {
- String key = (String) it.next();
- if (categoryMatchInFilterList(key, filters))
- target.removeLogger((Logger) log.loggers.get(key));
- }
- }
- }
- }
-
- /**
- * This method checks that the specified category matches any of the filter
- * expressions provided in the filters array.
- *
- * @param category to match against
- * @param filters - list of strings to check category against.
- * @return <code>true</code> if the specified category matches any of the
- * filter expressions found in the filters list, <code>false</code>
- * otherwise.
- */
- private static boolean categoryMatchInFilterList(String category, List filters)
- {
- if (filters == null)
- return false;
-
- for (int i = 0; i < filters.size(); i++)
- {
- String filter = (String) filters.get(i);
- // match category to filter based on the presence of a wildcard
- if (checkFilterToCategory(filter,category))
- return true;
- }
- return false;
- }
-
- /**
- * Check whether the category match with the filter.
- * @param filter The filter string to check against a specific category
- * @param category The category which the filter could match
- * @return whether the filter matches a specific category
- */
- public static boolean checkFilterToCategory(String filter, String category)
- {
- int index = -1;
- index = filter.indexOf("*");
-
- if (index == 0) // match all
- {
- return true;
- }
- else if (index < 0) // match full category to filter
- {
- if (category.equals(filter))
- {
- return true;
- }
- }
- else // match partial category to filter
- {
- if ((category.length() >= index) && category.substring(0, index).equals(filter.substring(0, index)))
- {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * This method will ensure that a valid category string has been specified.
- * If the category is not valid an exception will be thrown.
- *
- * Categories can not contain any blanks or any of the following characters:
- * []`*~,!#$%^&()]{}+=\|'";?><./&#64; or be less than 1 character in length.
- */
- private static void checkCategory(String category)
- {
- if (category == null || category.length() == 0)
- {
- // Categories must be at least one character in length.
- LocalizedException ex = new LocalizedException();
- ex.setMessage(INVALID_CATEGORY);
- throw ex;
- }
-
- if (hasIllegalCharacters(category) || (category.indexOf("*") != -1))
- {
- // Categories can not contain any of the following characters: 'INVALID_CHARS'
- LocalizedException ex = new LocalizedException();
- ex.setMessage(INVALID_CATEGORY_CHARS, new Object[]{INVALID_CHARS});
- throw ex;
- }
- }
-
- /**
- * Clean up static member variables.
- */
- public static void clear()
- {
- log = null;
- prettyPrinter = null;
- }
-
-}
+/*
+ * 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.log;
+
+import flex.messaging.LocalizedException;
+import flex.messaging.config.ConfigMap;
+import flex.messaging.util.PrettyPrinter;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.HashSet;
+
+/**
+ * @exclude
+ */
+public class Log
+{
+
+ /** @exclude **/
+ public static final String INVALID_CHARS = "[]~$^&\\/(){}<>+=`!#%?,:;\'\"@";
+
+ // Errors
+ private static final int INVALID_TARGET = 10013;
+ private static final int INVALID_CATEGORY = 10014;
+ private static final int INVALID_CATEGORY_CHARS = 10015;
+
+ private static Log log;
+ private static PrettyPrinter prettyPrinter;
+ private static String prettyPrinterClass = "BasicPrettyPrinter";
+
+ private static final HashSet excludedProperties = new HashSet();
+ /** @exclude **/
+ public static final String VALUE_SUPRESSED = "** [Value Suppressed] **";
+
+ private volatile short targetLevel;
+ private final Map loggers;
+ private final List targets;
+ private final Map targetMap;
+ private static final Object staticLock = new Object();
+
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Private constructor.
+ */
+ private Log()
+ {
+ targetLevel = LogEvent.NONE;
+ loggers = new HashMap();
+ targets = new ArrayList();
+ targetMap = new LinkedHashMap();
+ }
+
+
+ /**
+ * Creates the log on first access, returns already created log on
+ * subsequent calls.
+ *
+ * @return log.
+ */
+ public static Log createLog()
+ {
+ synchronized (staticLock)
+ {
+ if (log == null)
+ log = new Log();
+
+ return log;
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Initialize, validate, start, and stop methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes Log with id and properties.
+ *
+ * @param id Id for the Log which is ignored, though is used by the ManageableComponent superclass
+ * @param properties ConfigMap of properties for the Log.
+ */
+ public static synchronized void initialize(String id, ConfigMap properties)
+ {
+ String value = properties.getPropertyAsString("pretty-printer", null);
+ if (value != null)
+ prettyPrinterClass = value;
+
+ // Create a HashSet with the properties that we want to exclude from the
+ // list of properties given by 'getPropertiesAsList'
+ ConfigMap excludeMap = properties.getPropertyAsMap("exclude-properties", null);
+ if (excludeMap != null)
+ {
+ if (excludeMap.getPropertyAsList("property", null) != null)
+ excludedProperties.addAll(excludeMap.getPropertyAsList("property", null));
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Getters and Setters for Log properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Indicates whether a fatal level log event will be processed by a log target.
+ * @return boolean true if it is Fatal level
+ */
+ public static boolean isFatal()
+ {
+ return log == null ? false : log.targetLevel <= LogEvent.FATAL;
+ }
+
+ /**
+ * Indicates whether an error level log event will be processed by a log target.
+ * @return boolean true if it is Error level
+ */
+ public static boolean isError()
+ {
+ return log == null ? false : log.targetLevel <= LogEvent.ERROR;
+ }
+
+ /**
+ * Indicates whether a warn level log event will be processed by a log target.
+ * @return boolean true if it is Warn level
+ */
+ public static boolean isWarn()
+ {
+ return log == null ? false : log.targetLevel <= LogEvent.WARN;
+ }
+
+ /**
+ * Indicates whether an info level log event will be processed by a log target.
+ * @return boolean true if it is Info level
+ */
+ public static boolean isInfo()
+ {
+ return log == null ? false : log.targetLevel <= LogEvent.INFO;
+ }
+
+ /**
+ * Indicates whether a debug level log event will be processed by a log target.
+ * @return boolean true if it is debug level
+ */
+ public static boolean isDebug()
+ {
+ return log == null ? false : log.targetLevel <= LogEvent.DEBUG;
+ }
+
+ /**
+ * Indicates whether a log property should be excluded.
+ * @param property the property to check
+ * @return boolean true if the property should be excluded
+ */
+ public static boolean isExcludedProperty(String property)
+ {
+ return !excludedProperties.isEmpty() && excludedProperties.contains(property);
+ }
+
+
+ /**
+ * Given a category, returns the logger associated with the category.
+ *
+ * @param category Categogry for the logger.
+ * @return Logger associated with the category.
+ */
+ public static Logger getLogger(String category)
+ {
+ if (log != null)
+ return getLogger(log, category);
+
+ // Return a dummy logger?
+ return new Logger(category);
+ }
+
+ /**
+ * @exclude
+ */
+ public static Logger getLogger(Log log, String category)
+ {
+ checkCategory(category);
+
+ synchronized (staticLock)
+ {
+ Logger result = (Logger) log.loggers.get(category);
+ if (result == null)
+ {
+ result = new Logger(category);
+
+ // Check to see if there are any targets for this logger.
+ for (Iterator iter = log.targets.iterator(); iter.hasNext();)
+ {
+ Target target = (Target) iter.next();
+ if (categoryMatchInFilterList(category, target.getFilters()))
+ target.addLogger(result);
+ }
+
+ log.loggers.put(category, result);
+ }
+ return result;
+ }
+ }
+
+ /**
+ * Returns an unmodifiable snapshot of the targets registered with this Log when the
+ * method is invoked.
+ * @return List the list of targets
+ */
+ public static List getTargets()
+ {
+ if (log != null)
+ {
+ List currentTargets;
+ // Snapshot the current target list (shallow copy) and return it.
+ synchronized (staticLock)
+ {
+ currentTargets = Collections.unmodifiableList(new ArrayList(log.targets));
+ }
+ return currentTargets;
+ }
+ return null;
+ }
+
+ /**
+ * Return the Log's map of targets keyed on their human-readable ids (e.g. ConsoleTarget0, ConsoleTarget1, etc.)
+ * @return Map the target map
+ */
+ public static Map getTargetMap()
+ {
+ if (log != null)
+ {
+ Map currentTargets;
+ synchronized (staticLock)
+ {
+ currentTargets = new LinkedHashMap(log.targetMap);
+ }
+ return currentTargets;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the target associated with the unique ID searchId. Returns null if no
+ * such target exists.
+ * @param searchId the search ID
+ * @return Target the associated target
+ */
+ public static Target getTarget(String searchId)
+ {
+ if (log != null)
+ {
+ synchronized (staticLock)
+ {
+ return (Target) log.targetMap.get(searchId);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Return the categories for all of the loggers
+ * @return String[] the categories for all of the loggers
+ */
+ public String[] getLoggers()
+ {
+ String[] currentCategories;
+ if (log != null)
+ {
+ synchronized (staticLock)
+ {
+ Object[] currentCategoryObjects = loggers.keySet().toArray();
+ currentCategories = new String[currentCategoryObjects.length];
+ for (int i = 0; i < currentCategoryObjects.length; i++)
+ {
+ currentCategories[i] = (String)(currentCategoryObjects[i]);
+ }
+ }
+ }
+ else
+ {
+ currentCategories = new String[0];
+ }
+
+ return currentCategories;
+ }
+
+ /**
+ * Adds a target to the log.
+ *
+ * @param target Target to be added.
+ */
+ public static void addTarget(Target target)
+ {
+ if (log != null)
+ {
+ if (target != null)
+ {
+ synchronized (staticLock)
+ {
+ List filters = target.getFilters();
+
+ // need to find what filters this target matches and set the specified
+ // target as a listener for that logger.
+ Iterator it = log.loggers.keySet().iterator();
+ while (it.hasNext())
+ {
+ String key = (String) it.next();
+ if (categoryMatchInFilterList(key, filters))
+ target.addLogger((Logger) log.loggers.get(key));
+ }
+ // if we found a match all is good, otherwise we need to
+ // put the target in a waiting queue in the event that a logger
+ // is created that this target cares about.
+ if (!log.targets.contains(target))
+ log.targets.add(target);
+
+ if (!log.targetMap.containsValue(target))
+ {
+ String name = target.getClass().getName();
+
+ if (name.indexOf(".") > -1)
+ {
+ String[] classes = name.split("\\.");
+ name = classes[classes.length - 1];
+ }
+
+ log.targetMap.put(new String(name + log.targetMap.size()), target);
+ }
+
+ // update our global target log level if this target is more verbose.
+ short targetLevel = target.getLevel();
+ if (log.targetLevel == LogEvent.NONE)
+ log.targetLevel = targetLevel;
+ else if (targetLevel < log.targetLevel)
+ {
+ log.targetLevel = targetLevel;
+ }
+ }
+ }
+ else
+ {
+ // Invalid target specified. Target must not be null.
+ LocalizedException ex = new LocalizedException();
+ ex.setMessage(INVALID_TARGET);
+ throw ex;
+ }
+ }
+ }
+
+ /**
+ * Removes a target from the log.
+ *
+ * @param target The target to be removed.
+ */
+ public static void removeTarget(Target target)
+ {
+ if (log != null)
+ {
+ if (target != null)
+ {
+ synchronized (staticLock)
+ {
+ // Remove the target from any associated loggers.
+ List filters = target.getFilters();
+ Iterator it = log.loggers.keySet().iterator();
+ while (it.hasNext())
+ {
+ String key = (String) it.next();
+ if (categoryMatchInFilterList(key, filters))
+ target.removeLogger((Logger) log.loggers.get(key));
+ }
+ // Remove the target from the Log set.
+ log.targets.remove(target);
+ resetTargetLevel();
+ }
+ }
+ else
+ {
+ // Invalid target specified. Target must not be null.
+ LocalizedException ex = new LocalizedException();
+ ex.setMessage(INVALID_TARGET);
+ throw ex;
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Other Public APIs
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * This method removes all of the current loggers and targets from the cache.
+ * and resets target level.
+ */
+ public static synchronized void reset()
+ {
+ flush();
+ }
+
+ /**
+ * @exclude
+ */
+ public static void flush()
+ {
+ if (log != null)
+ {
+ log.loggers.clear();
+ log.targets.clear();
+ log.targetLevel = LogEvent.NONE;
+ }
+ }
+
+ /**
+ * @exclude
+ */
+ public static short readLevel(String l)
+ {
+ short lvl = LogEvent.ERROR;
+ if ((l != null) && (l.length() > 0))
+ {
+ l = l.trim().toLowerCase();
+ char c = l.charAt(0);
+ switch (c)
+ {
+ case 'n':
+ lvl = LogEvent.NONE;
+ break;
+ case 'e':
+ lvl = LogEvent.ERROR;
+ break;
+ case 'w':
+ lvl = LogEvent.WARN;
+ break;
+ case 'i':
+ lvl = LogEvent.INFO;
+ break;
+ case 'd':
+ lvl = LogEvent.DEBUG;
+ break;
+ case 'a':
+ lvl = LogEvent.ALL;
+ break;
+ default:
+ lvl = LogEvent.ERROR;
+ }
+ }
+
+ return lvl;
+ }
+
+ /**
+ * @exclude
+ * This method checks the specified string value for illegal characters.
+ *
+ * @param value to check for illegal characters.
+ * The following characters are not valid:
+ * []~$^&\/(){}<>+=`!#%?,:;'"&#64;
+ * @return <code>true</code> if there are any illegal characters found,
+ * <code>false</code> otherwise
+ */
+ public static boolean hasIllegalCharacters(String value)
+ {
+ char[] chars = value.toCharArray();
+ for (int i = 0; i < chars.length; i++)
+ {
+ char c = chars[i];
+ if (INVALID_CHARS.indexOf(c) != -1)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @exclude
+ * Returns the PrettyPrinter used by the Log.
+ */
+ public static PrettyPrinter getPrettyPrinter()
+ {
+ if (prettyPrinter == null ||
+ !prettyPrinter.getClass().getName().equals(prettyPrinterClass))
+ {
+ try
+ {
+ Class c = Class.forName(prettyPrinterClass);
+ prettyPrinter = (PrettyPrinter)c.newInstance();
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ return (PrettyPrinter)prettyPrinter.copy();
+ }
+
+ /**
+ * @exclude
+ * Returns the current target level for the Log.
+ */
+ public static short getTargetLevel()
+ {
+ return log == null ? LogEvent.NONE : log.targetLevel;
+ }
+
+ /**
+ * @exclude
+ * Sets the pretty printer class name used by the log.
+ *
+ * @param value Name of the pretty printer class.
+ */
+ public static void setPrettyPrinterClass(String value)
+ {
+ prettyPrinterClass = value;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected/private methods.
+ //
+ //--------------------------------------------------------------------------
+
+ /* package */ static void resetTargetLevel()
+ {
+ if (log != null)
+ {
+ synchronized (staticLock)
+ {
+ short maxTargetLevel = LogEvent.NONE;
+ for (Iterator iter = log.targets.iterator(); iter.hasNext();)
+ {
+ short targetLevel = ((Target) iter.next()).getLevel();
+ if (maxTargetLevel == LogEvent.NONE || targetLevel < maxTargetLevel)
+ maxTargetLevel = targetLevel;
+ }
+ log.targetLevel = maxTargetLevel;
+ }
+ }
+ }
+
+ /* package */ static void processTargetFilterAdd(Target target, String filter)
+ {
+ if (log != null)
+ {
+ synchronized (staticLock)
+ {
+ List filters = new ArrayList();
+ filters.add(filter);
+
+ // Find the loggers this target matches and add the
+ // target as a listener for log events from these loggers.
+ Iterator it = log.loggers.keySet().iterator();
+ while (it.hasNext())
+ {
+ String key = (String) it.next();
+ if (categoryMatchInFilterList(key, filters))
+ target.addLogger((Logger) log.loggers.get(key));
+ }
+ }
+ }
+ }
+
+ /* package */ static void processTargetFilterRemove(Target target, String filter)
+ {
+ if (log != null)
+ {
+ synchronized (staticLock)
+ {
+ // Remove the target from any matching loggers.
+ List filters = new ArrayList();
+ filters.add(filter);
+ Iterator it = log.loggers.keySet().iterator();
+ while (it.hasNext())
+ {
+ String key = (String) it.next();
+ if (categoryMatchInFilterList(key, filters))
+ target.removeLogger((Logger) log.loggers.get(key));
+ }
+ }
+ }
+ }
+
+ /**
+ * This method checks that the specified category matches any of the filter
+ * expressions provided in the filters array.
+ *
+ * @param category to match against
+ * @param filters - list of strings to check category against.
+ * @return <code>true</code> if the specified category matches any of the
+ * filter expressions found in the filters list, <code>false</code>
+ * otherwise.
+ */
+ private static boolean categoryMatchInFilterList(String category, List filters)
+ {
+ if (filters == null)
+ return false;
+
+ for (int i = 0; i < filters.size(); i++)
+ {
+ String filter = (String) filters.get(i);
+ // match category to filter based on the presence of a wildcard
+ if (checkFilterToCategory(filter,category))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check whether the category match with the filter.
+ * @param filter The filter string to check against a specific category
+ * @param category The category which the filter could match
+ * @return whether the filter matches a specific category
+ */
+ public static boolean checkFilterToCategory(String filter, String category)
+ {
+ int index = -1;
+ index = filter.indexOf("*");
+
+ if (index == 0) // match all
+ {
+ return true;
+ }
+ else if (index < 0) // match full category to filter
+ {
+ if (category.equals(filter))
+ {
+ return true;
+ }
+ }
+ else // match partial category to filter
+ {
+ if ((category.length() >= index) && category.substring(0, index).equals(filter.substring(0, index)))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * This method will ensure that a valid category string has been specified.
+ * If the category is not valid an exception will be thrown.
+ *
+ * Categories can not contain any blanks or any of the following characters:
+ * []`*~,!#$%^&()]{}+=\|'";?><./&#64; or be less than 1 character in length.
+ */
+ private static void checkCategory(String category)
+ {
+ if (category == null || category.length() == 0)
+ {
+ // Categories must be at least one character in length.
+ LocalizedException ex = new LocalizedException();
+ ex.setMessage(INVALID_CATEGORY);
+ throw ex;
+ }
+
+ if (hasIllegalCharacters(category) || (category.indexOf("*") != -1))
+ {
+ // Categories can not contain any of the following characters: 'INVALID_CHARS'
+ LocalizedException ex = new LocalizedException();
+ ex.setMessage(INVALID_CATEGORY_CHARS, new Object[]{INVALID_CHARS});
+ throw ex;
+ }
+ }
+
+ /**
+ * Clean up static member variables.
+ */
+ public static void clear()
+ {
+ log = null;
+ prettyPrinter = null;
+ }
+
+}
[33/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/JMSAdapterControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/JMSAdapterControl.java b/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/JMSAdapterControl.java
old mode 100755
new mode 100644
index 5776d87..235a455
--- a/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/JMSAdapterControl.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/JMSAdapterControl.java
@@ -1,119 +1,119 @@
-/*
- * 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.management.runtime.messaging.services.messaging.adapters;
-
-import flex.management.BaseControl;
-import flex.management.runtime.messaging.services.ServiceAdapterControl;
-import flex.messaging.services.messaging.adapters.JMSAdapter;
-
-/**
- * The <code>JMSAdapterControl</code> class is the MBean implemenation
- * for monitoring and managing <code>JMSAdapter</code>s at runtime.
- *
- * @author shodgson
- */
-public class JMSAdapterControl extends ServiceAdapterControl implements
- JMSAdapterControlMBean
-{
- private static final String TYPE = "JMSAdapter";
- private JMSAdapter jmsAdapter;
-
- /**
- * Constructs a <code>JMSAdapterControl</code>, assigning its id, managed
- * <code>JMSAdapter</code> and parent MBean.
- *
- * @param serviceAdapter The <code>JMSAdapter</code> managed by this MBean.
- * @param parent The parent MBean in the management hierarchy.
- */
- public JMSAdapterControl(JMSAdapter serviceAdapter, BaseControl parent)
- {
- super(serviceAdapter, parent);
- jmsAdapter = serviceAdapter;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.BaseControlMBean#getType()
- */
- public String getType()
- {
- return TYPE;
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.JMSAdapterControlMBean#getTopicProducerCount()
- */
- public Integer getTopicProducerCount()
- {
- return new Integer(jmsAdapter.getTopicProducerCount());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.JMSAdapterControlMBean#getTopicConsumerCount()
- */
- public Integer getTopicConsumerCount()
- {
- return new Integer(jmsAdapter.getTopicConsumerCount());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.JMSAdapterControlMBean#getTopicConsumerIds()
- */
- public String[] getTopicConsumerIds()
- {
- return jmsAdapter.getTopicConsumerIds();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.JMSAdapterControlMBean#getQueueProducerCount()
- */
- public Integer getQueueProducerCount()
- {
- return new Integer(jmsAdapter.getQueueProducerCount());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.JMSAdapterControlMBean#getQueueConsumerCount()
- */
- public Integer getQueueConsumerCount()
- {
- return new Integer(jmsAdapter.getQueueConsumerCount());
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.JMSAdapterControlMBean#getQueueConsumerIds()
- */
- public String[] getQueueConsumerIds()
- {
- return jmsAdapter.getQueueConsumerIds();
- }
-
- /*
- * (non-Javadoc)
- * @see flex.management.runtime.JMSAdapterControlMBean#removeConsumer(java.lang.String)
- */
- public void removeConsumer(String consumerId)
- {
- jmsAdapter.removeConsumer(consumerId);
- }
-}
+/*
+ * 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.management.runtime.messaging.services.messaging.adapters;
+
+import flex.management.BaseControl;
+import flex.management.runtime.messaging.services.ServiceAdapterControl;
+import flex.messaging.services.messaging.adapters.JMSAdapter;
+
+/**
+ * The <code>JMSAdapterControl</code> class is the MBean implemenation
+ * for monitoring and managing <code>JMSAdapter</code>s at runtime.
+ *
+ * @author shodgson
+ */
+public class JMSAdapterControl extends ServiceAdapterControl implements
+ JMSAdapterControlMBean
+{
+ private static final String TYPE = "JMSAdapter";
+ private JMSAdapter jmsAdapter;
+
+ /**
+ * Constructs a <code>JMSAdapterControl</code>, assigning its id, managed
+ * <code>JMSAdapter</code> and parent MBean.
+ *
+ * @param serviceAdapter The <code>JMSAdapter</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public JMSAdapterControl(JMSAdapter serviceAdapter, BaseControl parent)
+ {
+ super(serviceAdapter, parent);
+ jmsAdapter = serviceAdapter;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getType()
+ */
+ public String getType()
+ {
+ return TYPE;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.JMSAdapterControlMBean#getTopicProducerCount()
+ */
+ public Integer getTopicProducerCount()
+ {
+ return new Integer(jmsAdapter.getTopicProducerCount());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.JMSAdapterControlMBean#getTopicConsumerCount()
+ */
+ public Integer getTopicConsumerCount()
+ {
+ return new Integer(jmsAdapter.getTopicConsumerCount());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.JMSAdapterControlMBean#getTopicConsumerIds()
+ */
+ public String[] getTopicConsumerIds()
+ {
+ return jmsAdapter.getTopicConsumerIds();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.JMSAdapterControlMBean#getQueueProducerCount()
+ */
+ public Integer getQueueProducerCount()
+ {
+ return new Integer(jmsAdapter.getQueueProducerCount());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.JMSAdapterControlMBean#getQueueConsumerCount()
+ */
+ public Integer getQueueConsumerCount()
+ {
+ return new Integer(jmsAdapter.getQueueConsumerCount());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.JMSAdapterControlMBean#getQueueConsumerIds()
+ */
+ public String[] getQueueConsumerIds()
+ {
+ return jmsAdapter.getQueueConsumerIds();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.JMSAdapterControlMBean#removeConsumer(java.lang.String)
+ */
+ public void removeConsumer(String consumerId)
+ {
+ jmsAdapter.removeConsumer(consumerId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/JMSAdapterControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/JMSAdapterControlMBean.java b/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/JMSAdapterControlMBean.java
old mode 100755
new mode 100644
index 33b4fc2..aa85177
--- a/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/JMSAdapterControlMBean.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/JMSAdapterControlMBean.java
@@ -1,85 +1,85 @@
-/*
- * 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.management.runtime.messaging.services.messaging.adapters;
-
-import java.io.IOException;
-
-import flex.management.runtime.messaging.services.ServiceAdapterControlMBean;
-
-/**
- * Defines the runtime monitoring and management interface for managed JMS adapters.
- *
- * @author shodgson
- */
-public interface JMSAdapterControlMBean extends ServiceAdapterControlMBean
-{
- /**
- * Returns the number of topic producers for the adapter.
- *
- * @return The number of topic producers for the adapter.
- * @throws IOException Throws IOException.
- */
- Integer getTopicProducerCount() throws IOException;
-
- /**
- * Returns the number of topic consumers for the adapter.
- *
- * @return The number of topic consumers for the adapter.
- * @throws IOException Throws IOException.
- */
- Integer getTopicConsumerCount() throws IOException;
-
- /**
- * Returns the ids of all topic consumers.
- *
- * @return The ids of all topic consumers.
- * @throws IOException Throws IOException.
- */
- String[] getTopicConsumerIds() throws IOException;
-
- /**
- * Returns the number of queue producers for the adapter.
- *
- * @return The number of queue producers for the adapter.
- * @throws IOException Throws IOException.
- */
- Integer getQueueProducerCount() throws IOException;
-
- /**
- * Returns the number of queue consumers for the adapter.
- *
- * @return The number of queue consumers for the adapter.
- * @throws IOException Throws IOException.
- */
- Integer getQueueConsumerCount() throws IOException;
-
- /**
- * Returns the ids of all queue consumers.
- *
- * @return The ids of all queue consumers.
- * @throws IOException Throws IOException.
- */
- String[] getQueueConsumerIds() throws IOException;
-
- /**
- * Unsubscribes the consumer (for either a topic or queue).
- *
- * @param consumerId The id of the consumer to unsubscribe.
- * @throws IOException Throws IOException.
- */
- void removeConsumer(String consumerId) throws IOException;
-}
+/*
+ * 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.management.runtime.messaging.services.messaging.adapters;
+
+import java.io.IOException;
+
+import flex.management.runtime.messaging.services.ServiceAdapterControlMBean;
+
+/**
+ * Defines the runtime monitoring and management interface for managed JMS adapters.
+ *
+ * @author shodgson
+ */
+public interface JMSAdapterControlMBean extends ServiceAdapterControlMBean
+{
+ /**
+ * Returns the number of topic producers for the adapter.
+ *
+ * @return The number of topic producers for the adapter.
+ * @throws IOException Throws IOException.
+ */
+ Integer getTopicProducerCount() throws IOException;
+
+ /**
+ * Returns the number of topic consumers for the adapter.
+ *
+ * @return The number of topic consumers for the adapter.
+ * @throws IOException Throws IOException.
+ */
+ Integer getTopicConsumerCount() throws IOException;
+
+ /**
+ * Returns the ids of all topic consumers.
+ *
+ * @return The ids of all topic consumers.
+ * @throws IOException Throws IOException.
+ */
+ String[] getTopicConsumerIds() throws IOException;
+
+ /**
+ * Returns the number of queue producers for the adapter.
+ *
+ * @return The number of queue producers for the adapter.
+ * @throws IOException Throws IOException.
+ */
+ Integer getQueueProducerCount() throws IOException;
+
+ /**
+ * Returns the number of queue consumers for the adapter.
+ *
+ * @return The number of queue consumers for the adapter.
+ * @throws IOException Throws IOException.
+ */
+ Integer getQueueConsumerCount() throws IOException;
+
+ /**
+ * Returns the ids of all queue consumers.
+ *
+ * @return The ids of all queue consumers.
+ * @throws IOException Throws IOException.
+ */
+ String[] getQueueConsumerIds() throws IOException;
+
+ /**
+ * Unsubscribes the consumer (for either a topic or queue).
+ *
+ * @param consumerId The id of the consumer to unsubscribe.
+ * @throws IOException Throws IOException.
+ */
+ void removeConsumer(String consumerId) throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/package-info.java b/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/package-info.java
old mode 100755
new mode 100644
index dbfa228..d94216b
--- a/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/package-info.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/messaging/adapters/package-info.java
@@ -1,17 +1,17 @@
-/*
- * 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.management.runtime.messaging.services.messaging.adapters;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/messaging/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/messaging/package-info.java b/modules/core/src/flex/management/runtime/messaging/services/messaging/package-info.java
old mode 100755
new mode 100644
index e96d8dd..3e0f105
--- a/modules/core/src/flex/management/runtime/messaging/services/messaging/package-info.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/messaging/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.management.runtime.messaging.services.messaging;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/messaging/services/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/services/package-info.java b/modules/core/src/flex/management/runtime/messaging/services/package-info.java
old mode 100755
new mode 100644
index bc0bad4..e9cdb22
--- a/modules/core/src/flex/management/runtime/messaging/services/package-info.java
+++ b/modules/core/src/flex/management/runtime/messaging/services/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.management.runtime.messaging.services;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/runtime/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/package-info.java b/modules/core/src/flex/management/runtime/package-info.java
old mode 100755
new mode 100644
index e3a8bc7..5bbb1f7
--- a/modules/core/src/flex/management/runtime/package-info.java
+++ b/modules/core/src/flex/management/runtime/package-info.java
@@ -1,17 +1,17 @@
-/*
- * 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.management.runtime;
+/*
+ * 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.management.runtime;
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/AbstractConnectionAwareSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/AbstractConnectionAwareSession.java b/modules/core/src/flex/messaging/AbstractConnectionAwareSession.java
old mode 100755
new mode 100644
index ad48501..95bed9b
--- a/modules/core/src/flex/messaging/AbstractConnectionAwareSession.java
+++ b/modules/core/src/flex/messaging/AbstractConnectionAwareSession.java
@@ -1,171 +1,171 @@
-/*
- * 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;
-
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * @exclude
- * Abstract base class for <tt>ConnectionAwareSession</tt> implementations.
- * Provides support for registering <tt>FlexSessionConnectivityListener</tt>s
- * along with protected methods to notify registered listeners of <tt>FlexSessionConnectivityEvent</tt>s.
- */
-public abstract class AbstractConnectionAwareSession extends FlexSession implements ConnectionAwareSession
-{
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * Constructs a new instance.
- *
- * @param sessionProvider The provider that instantiated this instance.
- */
- public AbstractConnectionAwareSession(AbstractFlexSessionProvider sessionProvider)
- {
- super(sessionProvider);
- }
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // connected
- //----------------------------------
-
- /**
- * Connected flag for the session.
- */
- private boolean connected;
-
- /**
- * Returns whether the session is connected.
- *
- * @return true if the session is connected; otherwise false.
- */
- public boolean isConnected()
- {
- synchronized (lock)
- {
- return connected;
- }
- }
-
- /**
- * Sets the connected state for the session.
- *
- * @param value true for a connected session; false for a disconnected session.
- */
- public void setConnected(boolean value)
- {
- boolean notify = false;
- synchronized (lock)
- {
- if (connected != value)
- {
- connected = value;
- notify = true;
- }
- }
- if (notify)
- {
- if (!value)
- notifySessionDisconnected();
- else
- notifySessionConnected();
- }
- }
-
- //----------------------------------
- // connectivityListeners
- //----------------------------------
-
- /**
- * The list of connectivity listeners for the session.
- */
- private volatile CopyOnWriteArrayList<FlexSessionConnectivityListener> connectivityListeners;
-
- /**
- * (non-JavaDoc)
- * @see flex.messaging.ConnectionAwareSession#addConnectivityListener(FlexSessionConnectivityListener)
- */
- public void addConnectivityListener(FlexSessionConnectivityListener listener)
- {
- if (connectivityListeners == null)
- {
- synchronized (lock)
- {
- if (connectivityListeners == null)
- connectivityListeners = new CopyOnWriteArrayList<FlexSessionConnectivityListener>();
- }
- }
- if (connectivityListeners.addIfAbsent(listener) && isConnected())
- {
- // If the listener is added when the session has already connected, notify it at add time.
- FlexSessionConnectivityEvent event = new FlexSessionConnectivityEvent(this);
- listener.sessionConnected(event);
- }
- }
-
- /**
- * (non-JavaDoc)
- * @see flex.messaging.ConnectionAwareSession#removeConnectivityListener(FlexSessionConnectivityListener)
- */
- public void removeConnectivityListener(FlexSessionConnectivityListener listener)
- {
- if (connectivityListeners == null) return;
- connectivityListeners.remove(listener);
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Notifies registered <tt>FlexSessionConnectivityListener</tt>s that the session has connected.
- */
- protected void notifySessionConnected()
- {
- if (connectivityListeners != null)
- {
- FlexSessionConnectivityEvent event = new FlexSessionConnectivityEvent(this);
- for (FlexSessionConnectivityListener listener : connectivityListeners)
- listener.sessionDisconnected(event);
- }
- }
-
- /**
- * Notifies registered <tt>FlexSessionConnectivityListener</tt>s that the session has disconnected.
- */
- protected void notifySessionDisconnected()
- {
- if (connectivityListeners != null)
- {
- FlexSessionConnectivityEvent event = new FlexSessionConnectivityEvent(this);
- for (FlexSessionConnectivityListener listener : connectivityListeners)
- listener.sessionDisconnected(event);
- }
- }
+/*
+ * 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;
+
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * @exclude
+ * Abstract base class for <tt>ConnectionAwareSession</tt> implementations.
+ * Provides support for registering <tt>FlexSessionConnectivityListener</tt>s
+ * along with protected methods to notify registered listeners of <tt>FlexSessionConnectivityEvent</tt>s.
+ */
+public abstract class AbstractConnectionAwareSession extends FlexSession implements ConnectionAwareSession
+{
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @exclude
+ * Constructs a new instance.
+ *
+ * @param sessionProvider The provider that instantiated this instance.
+ */
+ public AbstractConnectionAwareSession(AbstractFlexSessionProvider sessionProvider)
+ {
+ super(sessionProvider);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // connected
+ //----------------------------------
+
+ /**
+ * Connected flag for the session.
+ */
+ private boolean connected;
+
+ /**
+ * Returns whether the session is connected.
+ *
+ * @return true if the session is connected; otherwise false.
+ */
+ public boolean isConnected()
+ {
+ synchronized (lock)
+ {
+ return connected;
+ }
+ }
+
+ /**
+ * Sets the connected state for the session.
+ *
+ * @param value true for a connected session; false for a disconnected session.
+ */
+ public void setConnected(boolean value)
+ {
+ boolean notify = false;
+ synchronized (lock)
+ {
+ if (connected != value)
+ {
+ connected = value;
+ notify = true;
+ }
+ }
+ if (notify)
+ {
+ if (!value)
+ notifySessionDisconnected();
+ else
+ notifySessionConnected();
+ }
+ }
+
+ //----------------------------------
+ // connectivityListeners
+ //----------------------------------
+
+ /**
+ * The list of connectivity listeners for the session.
+ */
+ private volatile CopyOnWriteArrayList<FlexSessionConnectivityListener> connectivityListeners;
+
+ /**
+ * (non-JavaDoc)
+ * @see flex.messaging.ConnectionAwareSession#addConnectivityListener(FlexSessionConnectivityListener)
+ */
+ public void addConnectivityListener(FlexSessionConnectivityListener listener)
+ {
+ if (connectivityListeners == null)
+ {
+ synchronized (lock)
+ {
+ if (connectivityListeners == null)
+ connectivityListeners = new CopyOnWriteArrayList<FlexSessionConnectivityListener>();
+ }
+ }
+ if (connectivityListeners.addIfAbsent(listener) && isConnected())
+ {
+ // If the listener is added when the session has already connected, notify it at add time.
+ FlexSessionConnectivityEvent event = new FlexSessionConnectivityEvent(this);
+ listener.sessionConnected(event);
+ }
+ }
+
+ /**
+ * (non-JavaDoc)
+ * @see flex.messaging.ConnectionAwareSession#removeConnectivityListener(FlexSessionConnectivityListener)
+ */
+ public void removeConnectivityListener(FlexSessionConnectivityListener listener)
+ {
+ if (connectivityListeners == null) return;
+ connectivityListeners.remove(listener);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Notifies registered <tt>FlexSessionConnectivityListener</tt>s that the session has connected.
+ */
+ protected void notifySessionConnected()
+ {
+ if (connectivityListeners != null)
+ {
+ FlexSessionConnectivityEvent event = new FlexSessionConnectivityEvent(this);
+ for (FlexSessionConnectivityListener listener : connectivityListeners)
+ listener.sessionDisconnected(event);
+ }
+ }
+
+ /**
+ * Notifies registered <tt>FlexSessionConnectivityListener</tt>s that the session has disconnected.
+ */
+ protected void notifySessionDisconnected()
+ {
+ if (connectivityListeners != null)
+ {
+ FlexSessionConnectivityEvent event = new FlexSessionConnectivityEvent(this);
+ for (FlexSessionConnectivityListener listener : connectivityListeners)
+ listener.sessionDisconnected(event);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/AbstractFlexSessionProvider.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/AbstractFlexSessionProvider.java b/modules/core/src/flex/messaging/AbstractFlexSessionProvider.java
old mode 100755
new mode 100644
index 3dfdc12..4b57518
--- a/modules/core/src/flex/messaging/AbstractFlexSessionProvider.java
+++ b/modules/core/src/flex/messaging/AbstractFlexSessionProvider.java
@@ -1,146 +1,146 @@
-/*
- * 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;
-
-import flex.messaging.config.ConfigMap;
-
-/**
- * @exclude
- * Base for FlexSessionProvider implementations.
- * Providers are protocol-specific factories for concrete FlexSession implementations.
- * They are registered with a FlexSessionManager, which acts as the central point of control
- * for tracking all active FlexSessions and for dispatching creation events to FlexSessionListeners.
- */
-public abstract class AbstractFlexSessionProvider implements FlexComponent
-{
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Instance lock.
- */
- protected final Object lock = new Object();
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // flexSessionManager
- //----------------------------------
-
- private volatile FlexSessionManager flexSessionManager;
-
- /**
- * Returns the <tt>FlexSessionManager</tt> this provider is currently registered to.
- *
- * @return The <tt>FlexSessionManager</tt> this provider is currently registered to.
- */
- public FlexSessionManager getFlexSessionManager()
- {
- return flexSessionManager;
- }
-
- /**
- * Sets the <tt>FlexSessionManager</tt> this provider is registered to.
- *
- * @param value The <tt>FlexSessionManager</tt> this provider is registered to.
- */
- public void setFlexSessionManager(final FlexSessionManager value)
- {
- flexSessionManager = value;
- }
-
- //----------------------------------
- // logCategory
- //----------------------------------
-
- private boolean started;
-
- /**
- * Indicates whether the component is started and running.
- *
- * @return <code>true</code> if the component has started;
- * otherwise <code>false</code>.
- */
- public boolean isStarted()
- {
- synchronized (lock)
- {
- return started;
- }
- }
-
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Initializes the component with configuration information.
- *
- * @param id The id of the component.
- * @param configMap The properties for configuring component.
- */
- public void initialize(final String id, final ConfigMap configMap)
- {
- // No-op.
- }
-
- /**
- * Removes a <tt>FlexSession</tt> created by this provider.
- * This callback is invoked by <tt>FlexSession</tt>s when they are invalidated.
- *
- * @param session The <tt>FlexSession</tt> being invalidated.
- */
- public void removeFlexSession(final FlexSession session)
- {
- FlexSessionManager manager = getFlexSessionManager();
- if (manager != null)
- manager.unregisterFlexSession(session);
- }
-
- /**
- * Invoked to start the component.
- * This base implementation changes the components state such that {@link #isStarted()} returns true.
- */
- public void start()
- {
- synchronized (lock)
- {
- started = true;
- }
- }
-
- /**
- * Invoked to stop the component.
- * This base implementation changes the components state such that {@link #isStarted()} returns false.
- */
- public void stop()
- {
- synchronized (lock)
- {
- started = false;
- }
- }
-}
+/*
+ * 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;
+
+import flex.messaging.config.ConfigMap;
+
+/**
+ * @exclude
+ * Base for FlexSessionProvider implementations.
+ * Providers are protocol-specific factories for concrete FlexSession implementations.
+ * They are registered with a FlexSessionManager, which acts as the central point of control
+ * for tracking all active FlexSessions and for dispatching creation events to FlexSessionListeners.
+ */
+public abstract class AbstractFlexSessionProvider implements FlexComponent
+{
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Instance lock.
+ */
+ protected final Object lock = new Object();
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // flexSessionManager
+ //----------------------------------
+
+ private volatile FlexSessionManager flexSessionManager;
+
+ /**
+ * Returns the <tt>FlexSessionManager</tt> this provider is currently registered to.
+ *
+ * @return The <tt>FlexSessionManager</tt> this provider is currently registered to.
+ */
+ public FlexSessionManager getFlexSessionManager()
+ {
+ return flexSessionManager;
+ }
+
+ /**
+ * Sets the <tt>FlexSessionManager</tt> this provider is registered to.
+ *
+ * @param value The <tt>FlexSessionManager</tt> this provider is registered to.
+ */
+ public void setFlexSessionManager(final FlexSessionManager value)
+ {
+ flexSessionManager = value;
+ }
+
+ //----------------------------------
+ // logCategory
+ //----------------------------------
+
+ private boolean started;
+
+ /**
+ * Indicates whether the component is started and running.
+ *
+ * @return <code>true</code> if the component has started;
+ * otherwise <code>false</code>.
+ */
+ public boolean isStarted()
+ {
+ synchronized (lock)
+ {
+ return started;
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Initializes the component with configuration information.
+ *
+ * @param id The id of the component.
+ * @param configMap The properties for configuring component.
+ */
+ public void initialize(final String id, final ConfigMap configMap)
+ {
+ // No-op.
+ }
+
+ /**
+ * Removes a <tt>FlexSession</tt> created by this provider.
+ * This callback is invoked by <tt>FlexSession</tt>s when they are invalidated.
+ *
+ * @param session The <tt>FlexSession</tt> being invalidated.
+ */
+ public void removeFlexSession(final FlexSession session)
+ {
+ FlexSessionManager manager = getFlexSessionManager();
+ if (manager != null)
+ manager.unregisterFlexSession(session);
+ }
+
+ /**
+ * Invoked to start the component.
+ * This base implementation changes the components state such that {@link #isStarted()} returns true.
+ */
+ public void start()
+ {
+ synchronized (lock)
+ {
+ started = true;
+ }
+ }
+
+ /**
+ * Invoked to stop the component.
+ * This base implementation changes the components state such that {@link #isStarted()} returns false.
+ */
+ public void stop()
+ {
+ synchronized (lock)
+ {
+ started = false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/ConnectionAwareSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/ConnectionAwareSession.java b/modules/core/src/flex/messaging/ConnectionAwareSession.java
old mode 100755
new mode 100644
index 573b506..41132f2
--- a/modules/core/src/flex/messaging/ConnectionAwareSession.java
+++ b/modules/core/src/flex/messaging/ConnectionAwareSession.java
@@ -1,63 +1,63 @@
-/*
- * 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;
-
-/**
- * Sessions that directly track their connection state support notifying interested
- * listeners of connectivity changes.
- */
-public interface ConnectionAwareSession
-{
- //----------------------------------
- // connected
- //----------------------------------
-
- /**
- * Returns true if the session is connected; otherwise false.
- *
- * @return true if the session is connected; otherwise false.
- */
- boolean isConnected();
-
- /**
- * Sets the connected state for the session.
- *
- * @param value true if the session is connected; false if disconnected.
- */
- void setConnected(boolean value);
-
- //----------------------------------
- // connectivityListeners
- //----------------------------------
-
- /**
- * Registers a session connectivity listener with the session.
- * This listener will be notified when the session acquires or looses connectivity
- * to the remote host.
- *
- * @param listener The <tt>FlexSessionConnectivityListener</tt> to register with the session.
- */
- void addConnectivityListener(FlexSessionConnectivityListener listener);
-
- /**
- * Unregisters a session connectivity listener from the session.
- * The unregistered listener will no longer be notified of session connectivity changes.
- *
- * @param listener The <tt>FlexSessionConnectivityListener</tt> to unregister from the session.
- */
- void removeConnectivityListener(FlexSessionConnectivityListener listener);
-}
+/*
+ * 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;
+
+/**
+ * Sessions that directly track their connection state support notifying interested
+ * listeners of connectivity changes.
+ */
+public interface ConnectionAwareSession
+{
+ //----------------------------------
+ // connected
+ //----------------------------------
+
+ /**
+ * Returns true if the session is connected; otherwise false.
+ *
+ * @return true if the session is connected; otherwise false.
+ */
+ boolean isConnected();
+
+ /**
+ * Sets the connected state for the session.
+ *
+ * @param value true if the session is connected; false if disconnected.
+ */
+ void setConnected(boolean value);
+
+ //----------------------------------
+ // connectivityListeners
+ //----------------------------------
+
+ /**
+ * Registers a session connectivity listener with the session.
+ * This listener will be notified when the session acquires or looses connectivity
+ * to the remote host.
+ *
+ * @param listener The <tt>FlexSessionConnectivityListener</tt> to register with the session.
+ */
+ void addConnectivityListener(FlexSessionConnectivityListener listener);
+
+ /**
+ * Unregisters a session connectivity listener from the session.
+ * The unregistered listener will no longer be notified of session connectivity changes.
+ *
+ * @param listener The <tt>FlexSessionConnectivityListener</tt> to unregister from the session.
+ */
+ void removeConnectivityListener(FlexSessionConnectivityListener listener);
+}
[49/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ChannelSettings.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ChannelSettings.java b/modules/common/src/flex/messaging/config/ChannelSettings.java
old mode 100755
new mode 100644
index b1ee664..a47c864
--- a/modules/common/src/flex/messaging/config/ChannelSettings.java
+++ b/modules/common/src/flex/messaging/config/ChannelSettings.java
@@ -1,335 +1,335 @@
-/*
- * 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.config;
-import flex.messaging.util.StringUtils;
-
-/**
- * The channel configuration is intentionally generic so that
- * other channels can be added in the future. This format also allows
- * server-endpoint specific and client code-generation specific settings
- * to be modified without affecting needing to update the configuration
- * parser.
- *
- * @author Peter Farland
- * @exclude
- */
-public class ChannelSettings extends PropertiesSettings
-{
- protected String id;
- protected boolean remote;
- protected String serverId;
- private String sourceFile;
-
- protected SecurityConstraint constraint;
-
- // ENDPOINT
- protected String uri;
- protected int port;
- protected String endpointType;
- protected String clientType;
- protected boolean serverOnly;
-
- protected String parsedUri;
- protected boolean contextParsed;
- protected String parsedClientUri;
- protected boolean clientContextParsed;
-
- public ChannelSettings(String id)
- {
- this.id = id;
- }
-
- public String getId()
- {
- return id;
- }
-
- public boolean isRemote()
- {
- return remote;
- }
-
- public void setRemote(boolean value)
- {
- remote = value;
- }
-
- public String getServerId()
- {
- return serverId;
- }
-
- public void setServerId(String value)
- {
- serverId = value;
- }
-
- public String getClientType()
- {
- return clientType;
- }
-
- public void setClientType(String type)
- {
- this.clientType = type;
- }
-
- public boolean getServerOnly()
- {
- return serverOnly;
- }
-
- public void setServerOnly(boolean serverOnly)
- {
- this.serverOnly = serverOnly;
- }
-
- String getSourceFile()
- {
- return sourceFile;
- }
-
- void setSourceFile(String sourceFile)
- {
- this.sourceFile = sourceFile;
- }
-
- /**
- * A return value of 0 denotes no port in channel url.
- *
- * @return the port number for this channel
- * or 0 if channel url does not contain a port number
- */
- public int getPort()
- {
- return port;
- }
-
- public String getUri()
- {
- return uri;
- }
-
- public void setUri(String uri)
- {
- this.uri = uri;
- port = parsePort(uri);
- port = (port == -1)? 0 : port; // Replace -1 with 0.
- contextParsed = false;
- clientContextParsed = false;
- }
-
- public String getClientParsedUri(String contextPath)
- {
- if (!clientContextParsed)
- parseClientUri(this, contextPath);
-
- return parsedClientUri;
- }
-
- public String getEndpointType()
- {
- return endpointType;
- }
-
- public void setEndpointType(String type)
- {
- this.endpointType = type;
- }
-
- public SecurityConstraint getConstraint()
- {
- return constraint;
- }
-
- public void setConstraint(SecurityConstraint constraint)
- {
- this.constraint = constraint;
- }
-
- /**
- * In this client version of the URI parser we're just looking to
- * replace the context root tokens.
- */
- private static void parseClientUri(ChannelSettings cs, String contextPath)
- {
- if (!cs.clientContextParsed)
- {
- String channelEndpoint = cs.getUri().trim();
-
- // either {context-root} or {context.root} is legal
- channelEndpoint = StringUtils.substitute(channelEndpoint, "{context-root}", ConfigurationConstants.CONTEXT_PATH_TOKEN);
-
- if ((contextPath == null) && (channelEndpoint.indexOf(ConfigurationConstants.CONTEXT_PATH_TOKEN) != -1))
- {
- // context root must be specified before it is used
- ConfigurationException e = new ConfigurationException();
- e.setMessage(ConfigurationConstants.UNDEFINED_CONTEXT_ROOT, new Object[]{cs.getId()});
- throw e;
- }
-
- // simplify the number of combinations to test by ensuring our
- // context path always starts with a slash
- if (contextPath != null && !contextPath.startsWith("/"))
- {
- contextPath = "/" + contextPath;
- }
-
- // avoid double-slashes from context root by replacing /{context.root}
- // in a single replacement step
- if (channelEndpoint.indexOf(ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN) != -1)
- {
- // but avoid double-slash for /{context.root}/etc when we have
- // the default context root
- if ("/".equals(contextPath) && !ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN.equals(channelEndpoint))
- contextPath = "";
-
- channelEndpoint = StringUtils.substitute(channelEndpoint, ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN, contextPath);
- }
- // otherwise we have something like {server.name}:{server.port}{context.root}...
- else
- {
- // but avoid double-slash for {context.root}/etc when we have
- // the default context root
- if ("/".equals(contextPath) && !ConfigurationConstants.CONTEXT_PATH_TOKEN.equals(channelEndpoint))
- contextPath = "";
-
- channelEndpoint = StringUtils.substitute(channelEndpoint, ConfigurationConstants.CONTEXT_PATH_TOKEN, contextPath);
- }
-
- cs.parsedClientUri = channelEndpoint;
- cs.clientContextParsed = true;
- }
- }
-
- /**
- * Returns the host name in the URL, or an empty <tt>String</tt> if the URL does not contain a host name.
- *
- * @param url The URL to parse for a host name.
- * @return The host name or an empty <tt>String</tt> if the URL does not contain a host name.
- */
- // The reason for this method, rather than just using java.net.URL, is that the Java class
- // doesn't recognize many of our protocol types/schemes (e.g. rtmp, amfsocket, etc.)
- public static String parseHost(String url)
- {
- int start = url.indexOf(":/");
- if (start == -1)
- return "";
-
- start = start + 3; // Advance past all of '://' to beginning of host name.
- int end = url.indexOf('/', start);
- String hostnameWithPort = end == -1 ? url.substring(start) : url.substring(start, end);
-
- // IPv6 hostnames may contain ':' but the full value is wrapped in [] - skip past if necessary.
- int delim = hostnameWithPort.indexOf(']');
- delim = (delim != -1) ? hostnameWithPort.indexOf(':', delim) : hostnameWithPort.indexOf(':');
- if (delim == -1) // No port.
- return hostnameWithPort;
- else
- return hostnameWithPort.substring(0, delim);
- }
-
- /**
- * Returns the port number specified in the URL, or 0 if the URL
- * does not contain a port number, or -1 if the URL contains a server.port
- * token.
- *
- * @param url The URL to parse for a contained port number.
- * @return the port number in the URL, or 0 if the URL does not
- * contain a port number, or -1 if the URL contains a server.port token.
- */
- // The reason for this method, rather than just using java.net.URL, is that the Java class
- // doesn't recognize many of our protocol types/schemes (e.g. rtmp, amfsocket, etc.)
- public static int parsePort(String url)
- {
- // rtmp://localhost:2035/foo/bar
- // Find first slash with colon
- int start = url.indexOf(":/");
- if (start == -1)
- return 0;
-
- // Second slash should be +1, so start 3 after for ://
- start = start + 3;
- int end = url.indexOf('/', start);
-
- // take everything up until the next slash for servername:port
- String snp = end == -1 ? url.substring(start) : url.substring(start, end);
-
- // If IPv6 is in use, start looking after the square bracket.
- int delim = snp.indexOf(']');
- delim = (delim > -1)? snp.indexOf(':', delim) : snp.indexOf(':');
- if (delim == -1)
- return 0;
-
- int port = 0;
- try
- {
- int p = Integer.parseInt(snp.substring(delim + 1));
- port = (p > 0)? p : 0;
- }
- catch (Throwable t)
- {
- port = -1; // To denote that the url contained server.port token.
- }
- return port;
- }
-
- /**
- * Remove protocol, host, port and context-root from a given url.
- * Unlike parseClientUri, this method does not check if the channel
- * setting has been parsed before.
- *
- * @param url Original url.
- * @return Url with protocol, host, port and context-root removed.
- */
- public static String removeTokens(String url)
- {
- String channelEndpoint = url.toLowerCase().trim();
-
- // remove protocol and host info
- if (channelEndpoint.startsWith("http://") ||
- channelEndpoint.startsWith("https://") ||
- channelEndpoint.startsWith("rtmp://") ||
- channelEndpoint.startsWith("rtmps://")) {
- int nextSlash = channelEndpoint.indexOf('/', 8);
- // Check to see if there is a 'next slash', and also that the next
- // slash isn't the last character
- if ((nextSlash > 0) && (nextSlash != channelEndpoint.length()-1))
- channelEndpoint = channelEndpoint.substring(nextSlash);
- }
-
- // either {context-root} or {context.root} is legal
- channelEndpoint = StringUtils.substitute(channelEndpoint, "{context-root}", ConfigurationConstants.CONTEXT_PATH_TOKEN);
-
- // Remove context path info
- if (channelEndpoint.startsWith(ConfigurationConstants.CONTEXT_PATH_TOKEN))
- {
- channelEndpoint = channelEndpoint.substring(ConfigurationConstants.CONTEXT_PATH_TOKEN.length());
- }
- else if (channelEndpoint.startsWith(ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN))
- {
- channelEndpoint = channelEndpoint.substring(ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN.length());
- }
-
- // We also don't match on trailing slashes
- if (channelEndpoint.endsWith("/"))
- {
- channelEndpoint = channelEndpoint.substring(0, channelEndpoint.length() - 1);
- }
- return channelEndpoint;
- }
-}
+/*
+ * 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.config;
+import flex.messaging.util.StringUtils;
+
+/**
+ * The channel configuration is intentionally generic so that
+ * other channels can be added in the future. This format also allows
+ * server-endpoint specific and client code-generation specific settings
+ * to be modified without affecting needing to update the configuration
+ * parser.
+ *
+ * @author Peter Farland
+ * @exclude
+ */
+public class ChannelSettings extends PropertiesSettings
+{
+ protected String id;
+ protected boolean remote;
+ protected String serverId;
+ private String sourceFile;
+
+ protected SecurityConstraint constraint;
+
+ // ENDPOINT
+ protected String uri;
+ protected int port;
+ protected String endpointType;
+ protected String clientType;
+ protected boolean serverOnly;
+
+ protected String parsedUri;
+ protected boolean contextParsed;
+ protected String parsedClientUri;
+ protected boolean clientContextParsed;
+
+ public ChannelSettings(String id)
+ {
+ this.id = id;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public boolean isRemote()
+ {
+ return remote;
+ }
+
+ public void setRemote(boolean value)
+ {
+ remote = value;
+ }
+
+ public String getServerId()
+ {
+ return serverId;
+ }
+
+ public void setServerId(String value)
+ {
+ serverId = value;
+ }
+
+ public String getClientType()
+ {
+ return clientType;
+ }
+
+ public void setClientType(String type)
+ {
+ this.clientType = type;
+ }
+
+ public boolean getServerOnly()
+ {
+ return serverOnly;
+ }
+
+ public void setServerOnly(boolean serverOnly)
+ {
+ this.serverOnly = serverOnly;
+ }
+
+ String getSourceFile()
+ {
+ return sourceFile;
+ }
+
+ void setSourceFile(String sourceFile)
+ {
+ this.sourceFile = sourceFile;
+ }
+
+ /**
+ * A return value of 0 denotes no port in channel url.
+ *
+ * @return the port number for this channel
+ * or 0 if channel url does not contain a port number
+ */
+ public int getPort()
+ {
+ return port;
+ }
+
+ public String getUri()
+ {
+ return uri;
+ }
+
+ public void setUri(String uri)
+ {
+ this.uri = uri;
+ port = parsePort(uri);
+ port = (port == -1)? 0 : port; // Replace -1 with 0.
+ contextParsed = false;
+ clientContextParsed = false;
+ }
+
+ public String getClientParsedUri(String contextPath)
+ {
+ if (!clientContextParsed)
+ parseClientUri(this, contextPath);
+
+ return parsedClientUri;
+ }
+
+ public String getEndpointType()
+ {
+ return endpointType;
+ }
+
+ public void setEndpointType(String type)
+ {
+ this.endpointType = type;
+ }
+
+ public SecurityConstraint getConstraint()
+ {
+ return constraint;
+ }
+
+ public void setConstraint(SecurityConstraint constraint)
+ {
+ this.constraint = constraint;
+ }
+
+ /**
+ * In this client version of the URI parser we're just looking to
+ * replace the context root tokens.
+ */
+ private static void parseClientUri(ChannelSettings cs, String contextPath)
+ {
+ if (!cs.clientContextParsed)
+ {
+ String channelEndpoint = cs.getUri().trim();
+
+ // either {context-root} or {context.root} is legal
+ channelEndpoint = StringUtils.substitute(channelEndpoint, "{context-root}", ConfigurationConstants.CONTEXT_PATH_TOKEN);
+
+ if ((contextPath == null) && (channelEndpoint.indexOf(ConfigurationConstants.CONTEXT_PATH_TOKEN) != -1))
+ {
+ // context root must be specified before it is used
+ ConfigurationException e = new ConfigurationException();
+ e.setMessage(ConfigurationConstants.UNDEFINED_CONTEXT_ROOT, new Object[]{cs.getId()});
+ throw e;
+ }
+
+ // simplify the number of combinations to test by ensuring our
+ // context path always starts with a slash
+ if (contextPath != null && !contextPath.startsWith("/"))
+ {
+ contextPath = "/" + contextPath;
+ }
+
+ // avoid double-slashes from context root by replacing /{context.root}
+ // in a single replacement step
+ if (channelEndpoint.indexOf(ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN) != -1)
+ {
+ // but avoid double-slash for /{context.root}/etc when we have
+ // the default context root
+ if ("/".equals(contextPath) && !ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN.equals(channelEndpoint))
+ contextPath = "";
+
+ channelEndpoint = StringUtils.substitute(channelEndpoint, ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN, contextPath);
+ }
+ // otherwise we have something like {server.name}:{server.port}{context.root}...
+ else
+ {
+ // but avoid double-slash for {context.root}/etc when we have
+ // the default context root
+ if ("/".equals(contextPath) && !ConfigurationConstants.CONTEXT_PATH_TOKEN.equals(channelEndpoint))
+ contextPath = "";
+
+ channelEndpoint = StringUtils.substitute(channelEndpoint, ConfigurationConstants.CONTEXT_PATH_TOKEN, contextPath);
+ }
+
+ cs.parsedClientUri = channelEndpoint;
+ cs.clientContextParsed = true;
+ }
+ }
+
+ /**
+ * Returns the host name in the URL, or an empty <tt>String</tt> if the URL does not contain a host name.
+ *
+ * @param url The URL to parse for a host name.
+ * @return The host name or an empty <tt>String</tt> if the URL does not contain a host name.
+ */
+ // The reason for this method, rather than just using java.net.URL, is that the Java class
+ // doesn't recognize many of our protocol types/schemes (e.g. rtmp, amfsocket, etc.)
+ public static String parseHost(String url)
+ {
+ int start = url.indexOf(":/");
+ if (start == -1)
+ return "";
+
+ start = start + 3; // Advance past all of '://' to beginning of host name.
+ int end = url.indexOf('/', start);
+ String hostnameWithPort = end == -1 ? url.substring(start) : url.substring(start, end);
+
+ // IPv6 hostnames may contain ':' but the full value is wrapped in [] - skip past if necessary.
+ int delim = hostnameWithPort.indexOf(']');
+ delim = (delim != -1) ? hostnameWithPort.indexOf(':', delim) : hostnameWithPort.indexOf(':');
+ if (delim == -1) // No port.
+ return hostnameWithPort;
+ else
+ return hostnameWithPort.substring(0, delim);
+ }
+
+ /**
+ * Returns the port number specified in the URL, or 0 if the URL
+ * does not contain a port number, or -1 if the URL contains a server.port
+ * token.
+ *
+ * @param url The URL to parse for a contained port number.
+ * @return the port number in the URL, or 0 if the URL does not
+ * contain a port number, or -1 if the URL contains a server.port token.
+ */
+ // The reason for this method, rather than just using java.net.URL, is that the Java class
+ // doesn't recognize many of our protocol types/schemes (e.g. rtmp, amfsocket, etc.)
+ public static int parsePort(String url)
+ {
+ // rtmp://localhost:2035/foo/bar
+ // Find first slash with colon
+ int start = url.indexOf(":/");
+ if (start == -1)
+ return 0;
+
+ // Second slash should be +1, so start 3 after for ://
+ start = start + 3;
+ int end = url.indexOf('/', start);
+
+ // take everything up until the next slash for servername:port
+ String snp = end == -1 ? url.substring(start) : url.substring(start, end);
+
+ // If IPv6 is in use, start looking after the square bracket.
+ int delim = snp.indexOf(']');
+ delim = (delim > -1)? snp.indexOf(':', delim) : snp.indexOf(':');
+ if (delim == -1)
+ return 0;
+
+ int port = 0;
+ try
+ {
+ int p = Integer.parseInt(snp.substring(delim + 1));
+ port = (p > 0)? p : 0;
+ }
+ catch (Throwable t)
+ {
+ port = -1; // To denote that the url contained server.port token.
+ }
+ return port;
+ }
+
+ /**
+ * Remove protocol, host, port and context-root from a given url.
+ * Unlike parseClientUri, this method does not check if the channel
+ * setting has been parsed before.
+ *
+ * @param url Original url.
+ * @return Url with protocol, host, port and context-root removed.
+ */
+ public static String removeTokens(String url)
+ {
+ String channelEndpoint = url.toLowerCase().trim();
+
+ // remove protocol and host info
+ if (channelEndpoint.startsWith("http://") ||
+ channelEndpoint.startsWith("https://") ||
+ channelEndpoint.startsWith("rtmp://") ||
+ channelEndpoint.startsWith("rtmps://")) {
+ int nextSlash = channelEndpoint.indexOf('/', 8);
+ // Check to see if there is a 'next slash', and also that the next
+ // slash isn't the last character
+ if ((nextSlash > 0) && (nextSlash != channelEndpoint.length()-1))
+ channelEndpoint = channelEndpoint.substring(nextSlash);
+ }
+
+ // either {context-root} or {context.root} is legal
+ channelEndpoint = StringUtils.substitute(channelEndpoint, "{context-root}", ConfigurationConstants.CONTEXT_PATH_TOKEN);
+
+ // Remove context path info
+ if (channelEndpoint.startsWith(ConfigurationConstants.CONTEXT_PATH_TOKEN))
+ {
+ channelEndpoint = channelEndpoint.substring(ConfigurationConstants.CONTEXT_PATH_TOKEN.length());
+ }
+ else if (channelEndpoint.startsWith(ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN))
+ {
+ channelEndpoint = channelEndpoint.substring(ConfigurationConstants.SLASH_CONTEXT_PATH_TOKEN.length());
+ }
+
+ // We also don't match on trailing slashes
+ if (channelEndpoint.endsWith("/"))
+ {
+ channelEndpoint = channelEndpoint.substring(0, channelEndpoint.length() - 1);
+ }
+ return channelEndpoint;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/config/ClientConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/config/ClientConfiguration.java b/modules/common/src/flex/messaging/config/ClientConfiguration.java
old mode 100755
new mode 100644
index 43cefbd..2e38eaa
--- a/modules/common/src/flex/messaging/config/ClientConfiguration.java
+++ b/modules/common/src/flex/messaging/config/ClientConfiguration.java
@@ -1,192 +1,192 @@
-/*
- * 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.config;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @exclude
- */
-public class ClientConfiguration implements ServicesConfiguration
-{
- protected final Map channelSettings;
- protected final List defaultChannels;
- protected final List serviceSettings;
- protected LoggingSettings loggingSettings;
- protected Map configPaths;
- protected final Map clusterSettings;
- protected FlexClientSettings flexClientSettings;
-
- public ClientConfiguration()
- {
- channelSettings = new HashMap();
- defaultChannels = new ArrayList(4);
- clusterSettings = new HashMap();
- serviceSettings = new ArrayList();
- configPaths = new HashMap();
- }
-
- /*
- * CHANNEL CONFIGURATION
- */
-
- public void addChannelSettings(String id, ChannelSettings settings)
- {
- channelSettings.put(id, settings);
- }
-
- public ChannelSettings getChannelSettings(String ref)
- {
- return (ChannelSettings)channelSettings.get(ref);
- }
-
- public Map getAllChannelSettings()
- {
- return channelSettings;
- }
-
- /*
- * DEFAULT CHANNELS CONFIGURATION
- */
- public void addDefaultChannel(String id)
- {
- defaultChannels.add(id);
- }
-
- public List getDefaultChannels()
- {
- return defaultChannels;
- }
-
- /*
- * SERVICE CONFIGURATION
- */
-
- public void addServiceSettings(ServiceSettings settings)
- {
- serviceSettings.add(settings);
- }
-
- public ServiceSettings getServiceSettings(String serviceType)
- {
- for (Iterator iter = serviceSettings.iterator(); iter.hasNext();)
- {
- ServiceSettings serviceSettings = (ServiceSettings) iter.next();
- if (serviceSettings.getId().equals(serviceType))
- return serviceSettings;
- }
- return null;
- }
-
- public List getAllServiceSettings()
- {
- return serviceSettings;
- }
-
- /*
- * CLUSTER CONFIGURATION
- */
-
- public void addClusterSettings(ClusterSettings settings)
- {
- if (settings.isDefault())
- {
- for (Iterator it = clusterSettings.values().iterator(); it.hasNext(); )
- {
- ClusterSettings cs = (ClusterSettings) it.next();
-
- if (cs.isDefault())
- {
- ConfigurationException cx = new ConfigurationException();
- cx.setMessage(10214, new Object[] { settings.getClusterName(), cs.getClusterName() });
- throw cx;
- }
- }
- }
- if (clusterSettings.containsKey(settings.getClusterName()))
- {
- ConfigurationException cx = new ConfigurationException();
- cx.setMessage(10206, new Object[] { settings.getClusterName() });
- throw cx;
- }
- clusterSettings.put(settings.getClusterName(), settings);
- }
-
- public ClusterSettings getClusterSettings(String clusterId)
- {
- for (Iterator it = clusterSettings.values().iterator(); it.hasNext(); )
- {
- ClusterSettings cs = (ClusterSettings) it.next();
- if (cs.getClusterName() == null && clusterId == null)
- return cs; // handle null case
- if (cs.getClusterName() != null && cs.getClusterName().equals(clusterId))
- return cs;
- }
- return null;
- }
-
- public ClusterSettings getDefaultCluster()
- {
- for (Iterator it = clusterSettings.values().iterator(); it.hasNext(); )
- {
- ClusterSettings cs = (ClusterSettings) it.next();
- if (cs.isDefault())
- return cs;
- }
- return null;
- }
-
- /*
- * LOGGING CONFIGURATION
- */
- public void setLoggingSettings(LoggingSettings settings)
- {
- loggingSettings = settings;
- }
-
- public LoggingSettings getLoggingSettings()
- {
- return loggingSettings;
- }
-
-
- public void addConfigPath(String path, long modified)
- {
- configPaths.put(path, new Long(modified));
- }
-
- public Map getConfigPaths()
- {
- return configPaths;
- }
-
- public void setFlexClientSettings(FlexClientSettings value)
- {
- flexClientSettings = value;
- }
-
- public FlexClientSettings getFlexClientSettings()
- {
- return flexClientSettings;
- }
-
-}
+/*
+ * 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.config;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @exclude
+ */
+public class ClientConfiguration implements ServicesConfiguration
+{
+ protected final Map channelSettings;
+ protected final List defaultChannels;
+ protected final List serviceSettings;
+ protected LoggingSettings loggingSettings;
+ protected Map configPaths;
+ protected final Map clusterSettings;
+ protected FlexClientSettings flexClientSettings;
+
+ public ClientConfiguration()
+ {
+ channelSettings = new HashMap();
+ defaultChannels = new ArrayList(4);
+ clusterSettings = new HashMap();
+ serviceSettings = new ArrayList();
+ configPaths = new HashMap();
+ }
+
+ /*
+ * CHANNEL CONFIGURATION
+ */
+
+ public void addChannelSettings(String id, ChannelSettings settings)
+ {
+ channelSettings.put(id, settings);
+ }
+
+ public ChannelSettings getChannelSettings(String ref)
+ {
+ return (ChannelSettings)channelSettings.get(ref);
+ }
+
+ public Map getAllChannelSettings()
+ {
+ return channelSettings;
+ }
+
+ /*
+ * DEFAULT CHANNELS CONFIGURATION
+ */
+ public void addDefaultChannel(String id)
+ {
+ defaultChannels.add(id);
+ }
+
+ public List getDefaultChannels()
+ {
+ return defaultChannels;
+ }
+
+ /*
+ * SERVICE CONFIGURATION
+ */
+
+ public void addServiceSettings(ServiceSettings settings)
+ {
+ serviceSettings.add(settings);
+ }
+
+ public ServiceSettings getServiceSettings(String serviceType)
+ {
+ for (Iterator iter = serviceSettings.iterator(); iter.hasNext();)
+ {
+ ServiceSettings serviceSettings = (ServiceSettings) iter.next();
+ if (serviceSettings.getId().equals(serviceType))
+ return serviceSettings;
+ }
+ return null;
+ }
+
+ public List getAllServiceSettings()
+ {
+ return serviceSettings;
+ }
+
+ /*
+ * CLUSTER CONFIGURATION
+ */
+
+ public void addClusterSettings(ClusterSettings settings)
+ {
+ if (settings.isDefault())
+ {
+ for (Iterator it = clusterSettings.values().iterator(); it.hasNext(); )
+ {
+ ClusterSettings cs = (ClusterSettings) it.next();
+
+ if (cs.isDefault())
+ {
+ ConfigurationException cx = new ConfigurationException();
+ cx.setMessage(10214, new Object[] { settings.getClusterName(), cs.getClusterName() });
+ throw cx;
+ }
+ }
+ }
+ if (clusterSettings.containsKey(settings.getClusterName()))
+ {
+ ConfigurationException cx = new ConfigurationException();
+ cx.setMessage(10206, new Object[] { settings.getClusterName() });
+ throw cx;
+ }
+ clusterSettings.put(settings.getClusterName(), settings);
+ }
+
+ public ClusterSettings getClusterSettings(String clusterId)
+ {
+ for (Iterator it = clusterSettings.values().iterator(); it.hasNext(); )
+ {
+ ClusterSettings cs = (ClusterSettings) it.next();
+ if (cs.getClusterName() == null && clusterId == null)
+ return cs; // handle null case
+ if (cs.getClusterName() != null && cs.getClusterName().equals(clusterId))
+ return cs;
+ }
+ return null;
+ }
+
+ public ClusterSettings getDefaultCluster()
+ {
+ for (Iterator it = clusterSettings.values().iterator(); it.hasNext(); )
+ {
+ ClusterSettings cs = (ClusterSettings) it.next();
+ if (cs.isDefault())
+ return cs;
+ }
+ return null;
+ }
+
+ /*
+ * LOGGING CONFIGURATION
+ */
+ public void setLoggingSettings(LoggingSettings settings)
+ {
+ loggingSettings = settings;
+ }
+
+ public LoggingSettings getLoggingSettings()
+ {
+ return loggingSettings;
+ }
+
+
+ public void addConfigPath(String path, long modified)
+ {
+ configPaths.put(path, new Long(modified));
+ }
+
+ public Map getConfigPaths()
+ {
+ return configPaths;
+ }
+
+ public void setFlexClientSettings(FlexClientSettings value)
+ {
+ flexClientSettings = value;
+ }
+
+ public FlexClientSettings getFlexClientSettings()
+ {
+ return flexClientSettings;
+ }
+
+}
[31/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FactoryInstance.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FactoryInstance.java b/modules/core/src/flex/messaging/FactoryInstance.java
old mode 100755
new mode 100644
index 8b01292..1e80655
--- a/modules/core/src/flex/messaging/FactoryInstance.java
+++ b/modules/core/src/flex/messaging/FactoryInstance.java
@@ -1,179 +1,179 @@
-/*
- * 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;
-
-import flex.messaging.config.ConfigMap;
-import flex.messaging.config.ConfigurationException;
-
-/**
- * This class is used by the FlexFactory to store the configuration
- * for an instance created by the factory. There is one of these for
- * each destination currently since only destinations create these components.
- *
- * @see flex.messaging.FlexFactory
- */
-public class FactoryInstance
-{
- private static final int INVALID_SCOPE = 10653;
-
- private FlexFactory factory;
- private String id;
- private String scope = FlexFactory.SCOPE_REQUEST;
- private String source;
- private ConfigMap properties;
-
- /**
- * Normally FactoryInstances are constructed by Data Services during startup so you
- * do not need to use this method. It is typically called from the
- * FlexFactory.createFactoryInstance method as Data Services is parsing
- * the destination configuration information for a given destination.
- * You can override this method to extract additional configuration for
- * your component from the properties argument.
- *
- * @param factory the FlexFactory this FactoryInstance is created from
- * @param id the Destination's id
- * @param properties the configuration properties for this destination.
- *
- * @see flex.messaging.config.ConfigMap
- */
- public FactoryInstance(FlexFactory factory, String id, ConfigMap properties)
- {
- this.factory = factory;
- this.id = id;
- this.properties = properties;
- }
-
- /**
- * Get the factory instance ID.
- * @return The destination's id that this FactoryInstance is associated with.
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * Since many factories may provide components in different
- * scopes, this is abstracted in the base factory instance class.
- * @param scope the scope
- */
- public void setScope(String scope)
- {
- this.scope = scope;
-
- if (!FlexFactory.SCOPE_SESSION.equals(scope)
- && !FlexFactory.SCOPE_APPLICATION.equals(scope)
- && !FlexFactory.SCOPE_REQUEST.equals(scope))
- {
- // Invalid scope setting for RemotingService destination '{id}'.
- // Valid options are 'request', 'session', or 'application'.
- ConfigurationException ex = new ConfigurationException();
- ex.setMessage(INVALID_SCOPE, new Object[] {id, "\'request\', \'session\', or \'application\'"});
- throw ex;
- }
-
- }
-
- /**
- * Get the scope.
- * @return String the scope
- */
- public String getScope()
- {
- return scope;
- }
-
- /**
- * This is by convention the main property for the defining the
- * instance we create with this factory. It may be the class name
- * for the JavaFactory or the id for a factory that uses ids.
- */
- public void setSource(String source)
- {
- this.source = source;
- }
-
- /**
- * Get the source.
- * @return String the source string
- */
- public String getSource()
- {
- return source;
- }
-
- /**
- * If possible, returns the class for the underlying configuration.
- * This method can return null if the class is not known until the lookup
- * method is called. The goal is so the factories which know the class
- * at startup time can provide earlier error detection. If the class is not
- * known, this method can return null and validation will wait until the
- * first lookup call.
- *
- * @return the class for this configured instance or null if the class
- * is not known until lookup time.
- */
- public Class getInstanceClass()
- {
- return null;
- }
-
- /**
- * Returns the ConfigMap that this factory instance was created with. You can
- * use this ConfigMap to retrieve additional properties which this factory
- * instance is configured with. For example, if you are defining a remote object
- * destination, your FactoryInstance can be configured with additional XML tags
- * underneath the properties tag for your destination. It is important that
- * if you expect additional properties that you access in the ConfigMap or call
- * allowProperty on that property when the FactoryInstance is created. Otherwise,
- * these properties can generate warnings about "unexpected" configuration.
- * @return ConfigMap the ConfigMap that this factory was created with
- * @see flex.messaging.config.ConfigMap
- */
- public ConfigMap getProperties()
- {
- return properties;
- }
-
- /**
- * Return an instance as appropriate for this instance of the given
- * factory. This just calls the lookup method on the factory that this
- * instance was created on. You override this method to return the
- * specific component for this destination.
- * @return Object the object lookup
- */
- public Object lookup()
- {
- return factory.lookup(this);
- }
-
- /**
- * When the caller is done with the instance, this method is called. For
- * session scoped components, this gives you the opportunity to update
- * any state modified in the instance in a remote persistence store.
- * This method is not called when the object should be destroyed.
- * To get a destroy notification, you should register for the appropriate
- * events via the FlexContext.
- *
- * @param instance the instance returned via the lookup method for this
- * destination for this operation.
- */
- public void operationComplete(Object instance)
- {
- }
-}
+/*
+ * 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;
+
+import flex.messaging.config.ConfigMap;
+import flex.messaging.config.ConfigurationException;
+
+/**
+ * This class is used by the FlexFactory to store the configuration
+ * for an instance created by the factory. There is one of these for
+ * each destination currently since only destinations create these components.
+ *
+ * @see flex.messaging.FlexFactory
+ */
+public class FactoryInstance
+{
+ private static final int INVALID_SCOPE = 10653;
+
+ private FlexFactory factory;
+ private String id;
+ private String scope = FlexFactory.SCOPE_REQUEST;
+ private String source;
+ private ConfigMap properties;
+
+ /**
+ * Normally FactoryInstances are constructed by Data Services during startup so you
+ * do not need to use this method. It is typically called from the
+ * FlexFactory.createFactoryInstance method as Data Services is parsing
+ * the destination configuration information for a given destination.
+ * You can override this method to extract additional configuration for
+ * your component from the properties argument.
+ *
+ * @param factory the FlexFactory this FactoryInstance is created from
+ * @param id the Destination's id
+ * @param properties the configuration properties for this destination.
+ *
+ * @see flex.messaging.config.ConfigMap
+ */
+ public FactoryInstance(FlexFactory factory, String id, ConfigMap properties)
+ {
+ this.factory = factory;
+ this.id = id;
+ this.properties = properties;
+ }
+
+ /**
+ * Get the factory instance ID.
+ * @return The destination's id that this FactoryInstance is associated with.
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Since many factories may provide components in different
+ * scopes, this is abstracted in the base factory instance class.
+ * @param scope the scope
+ */
+ public void setScope(String scope)
+ {
+ this.scope = scope;
+
+ if (!FlexFactory.SCOPE_SESSION.equals(scope)
+ && !FlexFactory.SCOPE_APPLICATION.equals(scope)
+ && !FlexFactory.SCOPE_REQUEST.equals(scope))
+ {
+ // Invalid scope setting for RemotingService destination '{id}'.
+ // Valid options are 'request', 'session', or 'application'.
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(INVALID_SCOPE, new Object[] {id, "\'request\', \'session\', or \'application\'"});
+ throw ex;
+ }
+
+ }
+
+ /**
+ * Get the scope.
+ * @return String the scope
+ */
+ public String getScope()
+ {
+ return scope;
+ }
+
+ /**
+ * This is by convention the main property for the defining the
+ * instance we create with this factory. It may be the class name
+ * for the JavaFactory or the id for a factory that uses ids.
+ */
+ public void setSource(String source)
+ {
+ this.source = source;
+ }
+
+ /**
+ * Get the source.
+ * @return String the source string
+ */
+ public String getSource()
+ {
+ return source;
+ }
+
+ /**
+ * If possible, returns the class for the underlying configuration.
+ * This method can return null if the class is not known until the lookup
+ * method is called. The goal is so the factories which know the class
+ * at startup time can provide earlier error detection. If the class is not
+ * known, this method can return null and validation will wait until the
+ * first lookup call.
+ *
+ * @return the class for this configured instance or null if the class
+ * is not known until lookup time.
+ */
+ public Class getInstanceClass()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the ConfigMap that this factory instance was created with. You can
+ * use this ConfigMap to retrieve additional properties which this factory
+ * instance is configured with. For example, if you are defining a remote object
+ * destination, your FactoryInstance can be configured with additional XML tags
+ * underneath the properties tag for your destination. It is important that
+ * if you expect additional properties that you access in the ConfigMap or call
+ * allowProperty on that property when the FactoryInstance is created. Otherwise,
+ * these properties can generate warnings about "unexpected" configuration.
+ * @return ConfigMap the ConfigMap that this factory was created with
+ * @see flex.messaging.config.ConfigMap
+ */
+ public ConfigMap getProperties()
+ {
+ return properties;
+ }
+
+ /**
+ * Return an instance as appropriate for this instance of the given
+ * factory. This just calls the lookup method on the factory that this
+ * instance was created on. You override this method to return the
+ * specific component for this destination.
+ * @return Object the object lookup
+ */
+ public Object lookup()
+ {
+ return factory.lookup(this);
+ }
+
+ /**
+ * When the caller is done with the instance, this method is called. For
+ * session scoped components, this gives you the opportunity to update
+ * any state modified in the instance in a remote persistence store.
+ * This method is not called when the object should be destroyed.
+ * To get a destroy notification, you should register for the appropriate
+ * events via the FlexContext.
+ *
+ * @param instance the instance returned via the lookup method for this
+ * destination for this operation.
+ */
+ public void operationComplete(Object instance)
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexComponent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexComponent.java b/modules/core/src/flex/messaging/FlexComponent.java
old mode 100755
new mode 100644
index f37856c..8f76444
--- a/modules/core/src/flex/messaging/FlexComponent.java
+++ b/modules/core/src/flex/messaging/FlexComponent.java
@@ -1,48 +1,48 @@
-/*
- * 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;
-
-/**
- * Defines the lifecycle interface for FlexComponents, allowing
- * the server to manage the running state of server components
- * through a consistent interface.
- */
-public interface FlexComponent extends FlexConfigurable
-{
- /**
- * Invoked to start the component.
- * The {@link FlexConfigurable#initialize(String, flex.messaging.config.ConfigMap)} method inherited
- * from the {@link FlexConfigurable} interface must be invoked before this method is invoked.
- * Once this method returns, {@link #isStarted()} must return true.
- */
- void start();
-
- /**
- * Invoked to stop the component.
- * Once this method returns, {@link #isStarted()} must return false.
- */
- void stop();
-
- /**
- * Indicates whether the component is started and running.
- *
- * @return <code>true</code> if the component has started;
- * otherwise <code>false</code>.
- */
- boolean isStarted();
-}
+/*
+ * 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;
+
+/**
+ * Defines the lifecycle interface for FlexComponents, allowing
+ * the server to manage the running state of server components
+ * through a consistent interface.
+ */
+public interface FlexComponent extends FlexConfigurable
+{
+ /**
+ * Invoked to start the component.
+ * The {@link FlexConfigurable#initialize(String, flex.messaging.config.ConfigMap)} method inherited
+ * from the {@link FlexConfigurable} interface must be invoked before this method is invoked.
+ * Once this method returns, {@link #isStarted()} must return true.
+ */
+ void start();
+
+ /**
+ * Invoked to stop the component.
+ * Once this method returns, {@link #isStarted()} must return false.
+ */
+ void stop();
+
+ /**
+ * Indicates whether the component is started and running.
+ *
+ * @return <code>true</code> if the component has started;
+ * otherwise <code>false</code>.
+ */
+ boolean isStarted();
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexConfigurable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexConfigurable.java b/modules/core/src/flex/messaging/FlexConfigurable.java
old mode 100755
new mode 100644
index 881b068..402d3c3
--- a/modules/core/src/flex/messaging/FlexConfigurable.java
+++ b/modules/core/src/flex/messaging/FlexConfigurable.java
@@ -1,35 +1,35 @@
-/*
- * 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;
-
-import flex.messaging.config.ConfigMap;
-
-/**
- * Components created in the Flex configuration environment can implement
- * the FlexConfigurable interface to get access to the configuration
- * properties like a regular component in the system.
- */
-public interface FlexConfigurable
-{
- /**
- * Initializes the component with configuration information.
- *
- * @param id The id of the component.
- * @param configMap The properties for configuring component.
- */
- void initialize(String id, ConfigMap configMap);
-}
+/*
+ * 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;
+
+import flex.messaging.config.ConfigMap;
+
+/**
+ * Components created in the Flex configuration environment can implement
+ * the FlexConfigurable interface to get access to the configuration
+ * properties like a regular component in the system.
+ */
+public interface FlexConfigurable
+{
+ /**
+ * Initializes the component with configuration information.
+ *
+ * @param id The id of the component.
+ * @param configMap The properties for configuring component.
+ */
+ void initialize(String id, ConfigMap configMap);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexContext.java b/modules/core/src/flex/messaging/FlexContext.java
old mode 100755
new mode 100644
index d7645b5..eb8e42f
--- a/modules/core/src/flex/messaging/FlexContext.java
+++ b/modules/core/src/flex/messaging/FlexContext.java
@@ -1,473 +1,473 @@
-/*
- * 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;
-
-import flex.messaging.client.FlexClient;
-import flex.messaging.endpoints.Endpoint;
-import flex.messaging.io.TypeMarshallingContext;
-import flex.messaging.security.LoginManager;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.security.Principal;
-
-/**
- * The <tt>FlexContext</tt> is a utility class that exposes the current execution context.
- * It provides access to <tt>FlexSession</tt> and <tt>FlexClient</tt> instances associated
- * with the current message being processed, as well as global context via the <tt>MessageBroker</tt>,
- * <tt>ServletContext</tt> and <tt>ServletConfig</tt> for the application.
- * Any, or all, of the properties exposed by this class may be <code>null</code> depending upon
- * the current execution context so test for that before attempting to interact with them.
- */
-public class FlexContext
-{
- private static ThreadLocal<FlexClient> flexClients = new ThreadLocal<FlexClient>();
- private static ThreadLocal<FlexSession> sessions = new ThreadLocal<FlexSession>();
- private static ThreadLocal<MessageBroker> messageBrokers = new ThreadLocal<MessageBroker>();
- private static ThreadLocal<Endpoint> endpoints = new ThreadLocal<Endpoint>();
- private static ThreadLocal<HttpServletResponse> responses = new ThreadLocal<HttpServletResponse>();
- private static ThreadLocal<HttpServletRequest> requests = new ThreadLocal<HttpServletRequest>();
- private static ThreadLocal<HttpServletRequest> tunnelRequests = new ThreadLocal<HttpServletRequest>();
- private static ThreadLocal<ServletConfig> servletConfigs = new ThreadLocal<ServletConfig>();
- private static ThreadLocal<Boolean> messageFromPeer = new ThreadLocal<Boolean>();
- private static ThreadLocal<MessageRoutedNotifier> messageRoutedNotifiers = new ThreadLocal<MessageRoutedNotifier>();
- private static ServletConfig lastGoodServletConfig;
-
- private FlexContext()
- {
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setThreadLocalObjects(FlexClient flexClient,
- FlexSession session,
- MessageBroker broker,
- HttpServletRequest request,
- HttpServletResponse response,
- ServletConfig servletConfig)
- {
- if (flexClients == null) // In case releaseThreadLocalObjects has been called.
- return;
-
- flexClients.set(flexClient);
- sessions.set(session);
- messageBrokers.set(broker);
- requests.set(request);
- responses.set(response);
- setThreadLocalServletConfig(servletConfig);
- messageFromPeer.set(Boolean.FALSE);
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setThreadLocalObjects(FlexClient flexClient, FlexSession session, MessageBroker broker)
- {
- setThreadLocalObjects(flexClient, session, broker, null, null, null);
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void clearThreadLocalObjects()
- {
- if (flexClients == null) // In case releaseThreadLocalObjects has been called.
- return;
-
- flexClients.remove();
- sessions.remove();
- messageBrokers.remove();
- endpoints.remove();
- requests.remove();
- responses.remove();
- tunnelRequests.remove();
- servletConfigs.remove();
- messageFromPeer.remove();
- messageRoutedNotifiers.remove();
-
- TypeMarshallingContext.clearThreadLocalObjects();
- }
-
- /**
- * The HttpServletResponse for the current request if the request is via HTTP.
- * Returns null if the client is using a non-HTTP channel.
- * Available for users.
- * @return HttpServletRequest current HttpServletRequest object
- */
- public static HttpServletRequest getHttpRequest()
- {
- return requests != null? requests.get() : null;
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setThreadLocalHttpRequest(HttpServletRequest value)
- {
- if (requests == null)
- return;
-
- if (value == null)
- requests.remove();
- else
- requests.set(value);
- }
-
- /**
- * The HttpServletResponse for the current request if the request is via HTTP.
- * Returns null if the using an non-HTTP channel.
- * Available for users.
- * @return HttpServletResponse current HttpServletResponse object
- */
- public static HttpServletResponse getHttpResponse()
- {
- return responses != null? responses.get() : null;
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setThreadLocalHttpResponse(HttpServletResponse value)
- {
- if (responses == null)
- return;
-
- if (value == null)
- responses.remove();
- else
- responses.set(value);
- }
-
- /**
- * The HttpServletRequest for the current request if it is transporting a tunneled protocol.
- * Returns null if the current request protocol it not tunneled.
- * Available for users.
- * @return HttpServletRequest tunnel HttpServletRequest object
- */
- public static HttpServletRequest getTunnelHttpRequest()
- {
- return tunnelRequests != null? tunnelRequests.get() : null;
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setThreadLocalTunnelHttpRequest(HttpServletRequest value)
- {
- if (tunnelRequests == null)
- return;
-
- if (value == null)
- tunnelRequests.remove();
- else
- tunnelRequests.set(value);
- }
-
- /**
- * The ServletConfig for the current request, uses the last known ServletConfig
- * when the request is not via HTTP. Available for users.
- * @return ServletConfig current ServletConfig object
- */
- public static ServletConfig getServletConfig()
- {
- if (servletConfigs != null && servletConfigs.get() != null)
- {
- return servletConfigs.get();
- }
- return lastGoodServletConfig;
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setThreadLocalServletConfig(ServletConfig value)
- {
- if (servletConfigs == null)
- return;
-
- if (value == null)
- {
- servletConfigs.remove();
- }
- else
- {
- servletConfigs.set(value);
- lastGoodServletConfig = value;
- }
- }
-
- /**
- * The ServletContext for the current web application.
- * @return ServletContext current ServletContext object
- */
- public static ServletContext getServletContext()
- {
- return getServletConfig() != null? getServletConfig().getServletContext() : null;
- }
-
- /**
- * The FlexClient for the current request. Available for users.
- * @return FlexClient the current FlexClient object
- */
- public static FlexClient getFlexClient()
- {
- return flexClients != null? flexClients.get() : null;
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setThreadLocalFlexClient(FlexClient flexClient)
- {
- if (flexClients == null)
- return;
-
- if (flexClient == null)
- flexClients.remove();
- else
- flexClients.set(flexClient);
- }
-
- /**
- * The FlexSession for the current request. Available for users.
- * @return FlexSession the current FlexSession object
- */
- public static FlexSession getFlexSession()
- {
- return sessions != null? sessions.get() : null;
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setThreadLocalSession(FlexSession session)
- {
- if (sessions == null)
- return;
-
- if (session == null)
- sessions.remove();
- else
- sessions.set(session);
- }
-
- /**
- * The MessageBroker for the current request. Not available for users.
- *
- * @exclude
- */
- public static MessageBroker getMessageBroker()
- {
- return messageBrokers != null? messageBrokers.get() : null;
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setThreadLocalMessageBroker(MessageBroker value)
- {
- // This is a special case because MessageBroker is sometimes accessed by
- // services, destinations, adapters during shutdown so it needs to be set
- // on the context even if a previous MessageBrokerServlet#destroy called
- // releaseThreadLocalObjects.
- if (messageBrokers == null)
- messageBrokers = new ThreadLocal<MessageBroker>();
-
- if (value == null)
- messageBrokers.remove();
- else
- messageBrokers.set(value);
- }
-
- /**
- * The Endpoint for the current message. Not available for users.
- * @exclude
- */
- public static Endpoint getEndpoint()
- {
- return endpoints != null? endpoints.get() : null;
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setThreadLocalEndpoint(Endpoint value)
- {
- if (endpoints == null)
- return;
-
- if (value == null)
- endpoints.remove();
- else
- endpoints.set(value);
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static MessageRoutedNotifier getMessageRoutedNotifier()
- {
- return messageRoutedNotifiers != null? messageRoutedNotifiers.get() : null;
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static void setMessageRoutedNotifier(MessageRoutedNotifier value)
- {
- if (messageRoutedNotifiers == null)
- return;
-
- if (value == null)
- messageRoutedNotifiers.remove();
- else
- messageRoutedNotifiers.set(value);
- }
-
- /**
- * Indicates whether the current message being processed came from a server peer
- * in a cluster.
- *
- * @return true if message from a peer
- */
- public static boolean isMessageFromPeer()
- {
- return messageFromPeer != null? messageFromPeer.get() : false;
- }
-
- /**
- * Sets a thread local indicating whether the message being processed came from
- * a server peer in a cluster.
- *
- * @param value True if the message came from a peer; otherwise false.
- *
- * @exclude
- */
- public static void setMessageFromPeer(boolean value)
- {
- if (messageFromPeer == null)
- return;
-
- messageFromPeer.set(value);
- }
-
- /**
- * Users should not call this.
- * @exclude
- */
- public static boolean isPerClientAuthentication()
- {
- MessageBroker messageBroker = getMessageBroker();
- if (messageBroker == null)
- return false;
-
- LoginManager loginManager = messageBroker.getLoginManager();
- return loginManager == null? false : loginManager.isPerClientAuthentication();
- }
-
- /**
- * Returns the principal associated with the session or client depending on whether
- * perClientauthentication is being used. If the client has not
- * authenticated the principal will be null.
- *
- * @return The principal associated with the session.
- */
- public static Principal getUserPrincipal()
- {
- if (isPerClientAuthentication())
- {
- FlexClient client = getFlexClient();
- return client != null? client.getUserPrincipal() : null;
- }
-
- FlexSession session = getFlexSession();
- return session != null? session.getUserPrincipal() : null;
- }
-
- /**
- * Sets the Principal on either the current FlexClient or FlexSession depending upon whether
- * perClientAuthentication is in use.
- *
- * @param userPrincipal The principal to associate with the FlexClient or FlexSession
- * depending upon whether perClientAuthentication is in use.
- */
- public static void setUserPrincipal(Principal userPrincipal)
- {
- if (isPerClientAuthentication())
- getFlexClient().setUserPrincipal(userPrincipal);
- else
- getFlexSession().setUserPrincipal(userPrincipal);
- }
-
- /**
- * @exclude
- * Create the static thread local storage.
- */
- public static void createThreadLocalObjects()
- {
- if (flexClients == null) // Allocate if needed.
- {
- flexClients = new ThreadLocal<FlexClient>();
- sessions = new ThreadLocal<FlexSession>();
- messageBrokers = new ThreadLocal<MessageBroker>();
- endpoints = new ThreadLocal<Endpoint>();
- responses = new ThreadLocal<HttpServletResponse>();
- requests = new ThreadLocal<HttpServletRequest>();
- tunnelRequests = new ThreadLocal<HttpServletRequest>();
- servletConfigs = new ThreadLocal<ServletConfig>();
- messageFromPeer = new ThreadLocal<Boolean>();
- messageRoutedNotifiers = new ThreadLocal<MessageRoutedNotifier>();
- }
- }
-
- /**
- * @exclude
- * Destroy the static thread local storage.
- * Call ONLY on shutdown
- */
- public static void releaseThreadLocalObjects()
- {
- clearThreadLocalObjects();
-
- flexClients = null;
- sessions = null;
- messageBrokers = null;
- endpoints = null;
- responses = null;
- requests = null;
- tunnelRequests = null;
- servletConfigs = null;
- messageFromPeer = null;
- messageRoutedNotifiers = null;
- }
-}
+/*
+ * 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;
+
+import flex.messaging.client.FlexClient;
+import flex.messaging.endpoints.Endpoint;
+import flex.messaging.io.TypeMarshallingContext;
+import flex.messaging.security.LoginManager;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.security.Principal;
+
+/**
+ * The <tt>FlexContext</tt> is a utility class that exposes the current execution context.
+ * It provides access to <tt>FlexSession</tt> and <tt>FlexClient</tt> instances associated
+ * with the current message being processed, as well as global context via the <tt>MessageBroker</tt>,
+ * <tt>ServletContext</tt> and <tt>ServletConfig</tt> for the application.
+ * Any, or all, of the properties exposed by this class may be <code>null</code> depending upon
+ * the current execution context so test for that before attempting to interact with them.
+ */
+public class FlexContext
+{
+ private static ThreadLocal<FlexClient> flexClients = new ThreadLocal<FlexClient>();
+ private static ThreadLocal<FlexSession> sessions = new ThreadLocal<FlexSession>();
+ private static ThreadLocal<MessageBroker> messageBrokers = new ThreadLocal<MessageBroker>();
+ private static ThreadLocal<Endpoint> endpoints = new ThreadLocal<Endpoint>();
+ private static ThreadLocal<HttpServletResponse> responses = new ThreadLocal<HttpServletResponse>();
+ private static ThreadLocal<HttpServletRequest> requests = new ThreadLocal<HttpServletRequest>();
+ private static ThreadLocal<HttpServletRequest> tunnelRequests = new ThreadLocal<HttpServletRequest>();
+ private static ThreadLocal<ServletConfig> servletConfigs = new ThreadLocal<ServletConfig>();
+ private static ThreadLocal<Boolean> messageFromPeer = new ThreadLocal<Boolean>();
+ private static ThreadLocal<MessageRoutedNotifier> messageRoutedNotifiers = new ThreadLocal<MessageRoutedNotifier>();
+ private static ServletConfig lastGoodServletConfig;
+
+ private FlexContext()
+ {
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setThreadLocalObjects(FlexClient flexClient,
+ FlexSession session,
+ MessageBroker broker,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ ServletConfig servletConfig)
+ {
+ if (flexClients == null) // In case releaseThreadLocalObjects has been called.
+ return;
+
+ flexClients.set(flexClient);
+ sessions.set(session);
+ messageBrokers.set(broker);
+ requests.set(request);
+ responses.set(response);
+ setThreadLocalServletConfig(servletConfig);
+ messageFromPeer.set(Boolean.FALSE);
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setThreadLocalObjects(FlexClient flexClient, FlexSession session, MessageBroker broker)
+ {
+ setThreadLocalObjects(flexClient, session, broker, null, null, null);
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void clearThreadLocalObjects()
+ {
+ if (flexClients == null) // In case releaseThreadLocalObjects has been called.
+ return;
+
+ flexClients.remove();
+ sessions.remove();
+ messageBrokers.remove();
+ endpoints.remove();
+ requests.remove();
+ responses.remove();
+ tunnelRequests.remove();
+ servletConfigs.remove();
+ messageFromPeer.remove();
+ messageRoutedNotifiers.remove();
+
+ TypeMarshallingContext.clearThreadLocalObjects();
+ }
+
+ /**
+ * The HttpServletResponse for the current request if the request is via HTTP.
+ * Returns null if the client is using a non-HTTP channel.
+ * Available for users.
+ * @return HttpServletRequest current HttpServletRequest object
+ */
+ public static HttpServletRequest getHttpRequest()
+ {
+ return requests != null? requests.get() : null;
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setThreadLocalHttpRequest(HttpServletRequest value)
+ {
+ if (requests == null)
+ return;
+
+ if (value == null)
+ requests.remove();
+ else
+ requests.set(value);
+ }
+
+ /**
+ * The HttpServletResponse for the current request if the request is via HTTP.
+ * Returns null if the using an non-HTTP channel.
+ * Available for users.
+ * @return HttpServletResponse current HttpServletResponse object
+ */
+ public static HttpServletResponse getHttpResponse()
+ {
+ return responses != null? responses.get() : null;
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setThreadLocalHttpResponse(HttpServletResponse value)
+ {
+ if (responses == null)
+ return;
+
+ if (value == null)
+ responses.remove();
+ else
+ responses.set(value);
+ }
+
+ /**
+ * The HttpServletRequest for the current request if it is transporting a tunneled protocol.
+ * Returns null if the current request protocol it not tunneled.
+ * Available for users.
+ * @return HttpServletRequest tunnel HttpServletRequest object
+ */
+ public static HttpServletRequest getTunnelHttpRequest()
+ {
+ return tunnelRequests != null? tunnelRequests.get() : null;
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setThreadLocalTunnelHttpRequest(HttpServletRequest value)
+ {
+ if (tunnelRequests == null)
+ return;
+
+ if (value == null)
+ tunnelRequests.remove();
+ else
+ tunnelRequests.set(value);
+ }
+
+ /**
+ * The ServletConfig for the current request, uses the last known ServletConfig
+ * when the request is not via HTTP. Available for users.
+ * @return ServletConfig current ServletConfig object
+ */
+ public static ServletConfig getServletConfig()
+ {
+ if (servletConfigs != null && servletConfigs.get() != null)
+ {
+ return servletConfigs.get();
+ }
+ return lastGoodServletConfig;
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setThreadLocalServletConfig(ServletConfig value)
+ {
+ if (servletConfigs == null)
+ return;
+
+ if (value == null)
+ {
+ servletConfigs.remove();
+ }
+ else
+ {
+ servletConfigs.set(value);
+ lastGoodServletConfig = value;
+ }
+ }
+
+ /**
+ * The ServletContext for the current web application.
+ * @return ServletContext current ServletContext object
+ */
+ public static ServletContext getServletContext()
+ {
+ return getServletConfig() != null? getServletConfig().getServletContext() : null;
+ }
+
+ /**
+ * The FlexClient for the current request. Available for users.
+ * @return FlexClient the current FlexClient object
+ */
+ public static FlexClient getFlexClient()
+ {
+ return flexClients != null? flexClients.get() : null;
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setThreadLocalFlexClient(FlexClient flexClient)
+ {
+ if (flexClients == null)
+ return;
+
+ if (flexClient == null)
+ flexClients.remove();
+ else
+ flexClients.set(flexClient);
+ }
+
+ /**
+ * The FlexSession for the current request. Available for users.
+ * @return FlexSession the current FlexSession object
+ */
+ public static FlexSession getFlexSession()
+ {
+ return sessions != null? sessions.get() : null;
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setThreadLocalSession(FlexSession session)
+ {
+ if (sessions == null)
+ return;
+
+ if (session == null)
+ sessions.remove();
+ else
+ sessions.set(session);
+ }
+
+ /**
+ * The MessageBroker for the current request. Not available for users.
+ *
+ * @exclude
+ */
+ public static MessageBroker getMessageBroker()
+ {
+ return messageBrokers != null? messageBrokers.get() : null;
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setThreadLocalMessageBroker(MessageBroker value)
+ {
+ // This is a special case because MessageBroker is sometimes accessed by
+ // services, destinations, adapters during shutdown so it needs to be set
+ // on the context even if a previous MessageBrokerServlet#destroy called
+ // releaseThreadLocalObjects.
+ if (messageBrokers == null)
+ messageBrokers = new ThreadLocal<MessageBroker>();
+
+ if (value == null)
+ messageBrokers.remove();
+ else
+ messageBrokers.set(value);
+ }
+
+ /**
+ * The Endpoint for the current message. Not available for users.
+ * @exclude
+ */
+ public static Endpoint getEndpoint()
+ {
+ return endpoints != null? endpoints.get() : null;
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setThreadLocalEndpoint(Endpoint value)
+ {
+ if (endpoints == null)
+ return;
+
+ if (value == null)
+ endpoints.remove();
+ else
+ endpoints.set(value);
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static MessageRoutedNotifier getMessageRoutedNotifier()
+ {
+ return messageRoutedNotifiers != null? messageRoutedNotifiers.get() : null;
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static void setMessageRoutedNotifier(MessageRoutedNotifier value)
+ {
+ if (messageRoutedNotifiers == null)
+ return;
+
+ if (value == null)
+ messageRoutedNotifiers.remove();
+ else
+ messageRoutedNotifiers.set(value);
+ }
+
+ /**
+ * Indicates whether the current message being processed came from a server peer
+ * in a cluster.
+ *
+ * @return true if message from a peer
+ */
+ public static boolean isMessageFromPeer()
+ {
+ return messageFromPeer != null? messageFromPeer.get() : false;
+ }
+
+ /**
+ * Sets a thread local indicating whether the message being processed came from
+ * a server peer in a cluster.
+ *
+ * @param value True if the message came from a peer; otherwise false.
+ *
+ * @exclude
+ */
+ public static void setMessageFromPeer(boolean value)
+ {
+ if (messageFromPeer == null)
+ return;
+
+ messageFromPeer.set(value);
+ }
+
+ /**
+ * Users should not call this.
+ * @exclude
+ */
+ public static boolean isPerClientAuthentication()
+ {
+ MessageBroker messageBroker = getMessageBroker();
+ if (messageBroker == null)
+ return false;
+
+ LoginManager loginManager = messageBroker.getLoginManager();
+ return loginManager == null? false : loginManager.isPerClientAuthentication();
+ }
+
+ /**
+ * Returns the principal associated with the session or client depending on whether
+ * perClientauthentication is being used. If the client has not
+ * authenticated the principal will be null.
+ *
+ * @return The principal associated with the session.
+ */
+ public static Principal getUserPrincipal()
+ {
+ if (isPerClientAuthentication())
+ {
+ FlexClient client = getFlexClient();
+ return client != null? client.getUserPrincipal() : null;
+ }
+
+ FlexSession session = getFlexSession();
+ return session != null? session.getUserPrincipal() : null;
+ }
+
+ /**
+ * Sets the Principal on either the current FlexClient or FlexSession depending upon whether
+ * perClientAuthentication is in use.
+ *
+ * @param userPrincipal The principal to associate with the FlexClient or FlexSession
+ * depending upon whether perClientAuthentication is in use.
+ */
+ public static void setUserPrincipal(Principal userPrincipal)
+ {
+ if (isPerClientAuthentication())
+ getFlexClient().setUserPrincipal(userPrincipal);
+ else
+ getFlexSession().setUserPrincipal(userPrincipal);
+ }
+
+ /**
+ * @exclude
+ * Create the static thread local storage.
+ */
+ public static void createThreadLocalObjects()
+ {
+ if (flexClients == null) // Allocate if needed.
+ {
+ flexClients = new ThreadLocal<FlexClient>();
+ sessions = new ThreadLocal<FlexSession>();
+ messageBrokers = new ThreadLocal<MessageBroker>();
+ endpoints = new ThreadLocal<Endpoint>();
+ responses = new ThreadLocal<HttpServletResponse>();
+ requests = new ThreadLocal<HttpServletRequest>();
+ tunnelRequests = new ThreadLocal<HttpServletRequest>();
+ servletConfigs = new ThreadLocal<ServletConfig>();
+ messageFromPeer = new ThreadLocal<Boolean>();
+ messageRoutedNotifiers = new ThreadLocal<MessageRoutedNotifier>();
+ }
+ }
+
+ /**
+ * @exclude
+ * Destroy the static thread local storage.
+ * Call ONLY on shutdown
+ */
+ public static void releaseThreadLocalObjects()
+ {
+ clearThreadLocalObjects();
+
+ flexClients = null;
+ sessions = null;
+ messageBrokers = null;
+ endpoints = null;
+ responses = null;
+ requests = null;
+ tunnelRequests = null;
+ servletConfigs = null;
+ messageFromPeer = null;
+ messageRoutedNotifiers = null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexFactory.java b/modules/core/src/flex/messaging/FlexFactory.java
old mode 100755
new mode 100644
index 3a762c5..2633460
--- a/modules/core/src/flex/messaging/FlexFactory.java
+++ b/modules/core/src/flex/messaging/FlexFactory.java
@@ -1,87 +1,87 @@
-/*
- * 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;
-
-import flex.messaging.config.ConfigMap;
-
-/**
- * The FlexFactory interface is implemented by factory components that provide
- * instances to the Flex messaging framework. You can implement this interface
- * if you want to tie together Flex Data Services with another system which maintains
- * component instances (often called the "services layer" in a typical enterprise
- * architecture). By implementing FlexFactory, you can configure a Flex
- * RemoteObject destination or a Flex Data Management Services assembler which
- * uses a Java object instance in your services layer rather than having Data Services
- * create a new component instance. In some cases, this means you avoid writing
- * glue code for each service you want to expose to flex clients.
- */
-public interface FlexFactory extends FlexConfigurable
-{
- /** Request scope string. */
- String SCOPE_REQUEST = "request";
- /** Session scope string. */
- String SCOPE_SESSION = "session";
- /** Application scope string .*/
- String SCOPE_APPLICATION = "application";
- /** Scope string. */
- String SCOPE = "scope";
- /** Source string. */
- String SOURCE = "source";
-
- /**
- * Called when the
- * definition of an instance that this factory looks up is initialized.
- * It should validate that
- * the properties supplied are valid to define an instance
- * and returns an instance of the type FactoryInstance
- * that contains all configuration necessary to construct
- * an instance of this object. If the instance is application
- * scoped, the FactoryInstance may contain a reference to the
- * instance directly.
- * <p>
- * Any valid properties used for this configuration
- * must be accessed to avoid warnings about unused configuration
- * elements. If your factory is only used for application
- * scoped components, you do not need to implement
- * this method as the lookup method itself can be used
- * to validate its configuration.
- * </p><p>
- * The id property is used as a name to help you identify
- * this factory instance for any errors it might generate.
- * </p>
- *
- */
- FactoryInstance createFactoryInstance(String id, ConfigMap properties);
-
- /**
- * This method is called by the default implementation of FactoryInstance.lookup.
- * When Data Services wants an instance of a given factory destination, it calls the
- * FactoryInstance.lookup to retrieve that instance. That method in turn
- * calls this method by default.
- *
- * For simple FlexFactory implementations which do not need to
- * add additional configuration properties or logic to the FactoryInstance class,
- * by implementing this method you can avoid having to add an additional subclass of
- * FactoryInstance for your factory. If you do extend FactoryInstance, it is
- * recommended that you just override FactoryInstance.lookup and put your logic
- * there to avoid the extra level of indirection.
- *
- * @param instanceInfo The FactoryInstance for this destination
- * @return the Object instance to use for the given operation for this destination.
- */
- Object lookup(FactoryInstance instanceInfo);
-}
+/*
+ * 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;
+
+import flex.messaging.config.ConfigMap;
+
+/**
+ * The FlexFactory interface is implemented by factory components that provide
+ * instances to the Flex messaging framework. You can implement this interface
+ * if you want to tie together Flex Data Services with another system which maintains
+ * component instances (often called the "services layer" in a typical enterprise
+ * architecture). By implementing FlexFactory, you can configure a Flex
+ * RemoteObject destination or a Flex Data Management Services assembler which
+ * uses a Java object instance in your services layer rather than having Data Services
+ * create a new component instance. In some cases, this means you avoid writing
+ * glue code for each service you want to expose to flex clients.
+ */
+public interface FlexFactory extends FlexConfigurable
+{
+ /** Request scope string. */
+ String SCOPE_REQUEST = "request";
+ /** Session scope string. */
+ String SCOPE_SESSION = "session";
+ /** Application scope string .*/
+ String SCOPE_APPLICATION = "application";
+ /** Scope string. */
+ String SCOPE = "scope";
+ /** Source string. */
+ String SOURCE = "source";
+
+ /**
+ * Called when the
+ * definition of an instance that this factory looks up is initialized.
+ * It should validate that
+ * the properties supplied are valid to define an instance
+ * and returns an instance of the type FactoryInstance
+ * that contains all configuration necessary to construct
+ * an instance of this object. If the instance is application
+ * scoped, the FactoryInstance may contain a reference to the
+ * instance directly.
+ * <p>
+ * Any valid properties used for this configuration
+ * must be accessed to avoid warnings about unused configuration
+ * elements. If your factory is only used for application
+ * scoped components, you do not need to implement
+ * this method as the lookup method itself can be used
+ * to validate its configuration.
+ * </p><p>
+ * The id property is used as a name to help you identify
+ * this factory instance for any errors it might generate.
+ * </p>
+ *
+ */
+ FactoryInstance createFactoryInstance(String id, ConfigMap properties);
+
+ /**
+ * This method is called by the default implementation of FactoryInstance.lookup.
+ * When Data Services wants an instance of a given factory destination, it calls the
+ * FactoryInstance.lookup to retrieve that instance. That method in turn
+ * calls this method by default.
+ *
+ * For simple FlexFactory implementations which do not need to
+ * add additional configuration properties or logic to the FactoryInstance class,
+ * by implementing this method you can avoid having to add an additional subclass of
+ * FactoryInstance for your factory. If you do extend FactoryInstance, it is
+ * recommended that you just override FactoryInstance.lookup and put your logic
+ * there to avoid the extra level of indirection.
+ *
+ * @param instanceInfo The FactoryInstance for this destination
+ * @return the Object instance to use for the given operation for this destination.
+ */
+ Object lookup(FactoryInstance instanceInfo);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexRemoteCredentials.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexRemoteCredentials.java b/modules/core/src/flex/messaging/FlexRemoteCredentials.java
old mode 100755
new mode 100644
index bd0f695..99a927b
--- a/modules/core/src/flex/messaging/FlexRemoteCredentials.java
+++ b/modules/core/src/flex/messaging/FlexRemoteCredentials.java
@@ -1,93 +1,93 @@
-/*
- * 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;
-
-/**
- * A wrapper object used for holding onto remote credentials. When you are using
- * the proxy service, the remote credentials are used for authenticating against
- * the proxy server. The remote credentials are distinct from the local credentials
- * used to authenticate against the local server. You use this class along with
- * the FlexSession methods getRemoteCredentials and putRemoteCredentials to associate
- * the remote credentials with a specific destination.
- */
-public class FlexRemoteCredentials
-{
- private String service;
-
- private String destination;
-
- private String username;
-
- private Object credentials;
-
- /**
- * Normally you do not have to create the FlexRemoteCredentials as they are
- * created automatically when the client specifies them via the setRemoteCredentials
- * method in ActionScript. You'd use this if you wanted to set your remote credentials
- * on the server and not have them specified on the client.
- * @param service the service id
- * @param destination the destination id
- * @param username the user name
- * @param credentials the user credentials
- */
- public FlexRemoteCredentials(String service, String destination,
- String username, Object credentials)
- {
- super();
- this.service = service;
- this.destination = destination;
- this.username = username;
- this.credentials = credentials;
- }
-
- /**
- * Returns the user name from the remote credentials.
- * @return String the user name
- */
- public String getUsername()
- {
- return username;
- }
-
- /**
- * Returns the credentials themselves (usually a password).
- * @return Object the credentials object
- */
- public Object getCredentials()
- {
- return credentials;
- }
-
- /**
- * Returns the id of the service these credentials are registered for.
- * @return String the service id
- */
- public String getService()
- {
- return service;
- }
-
- /**
- * Returns the destination for the service.
- * @return String the destination id
- */
- public String getDestination()
- {
- return destination;
- }
-}
+/*
+ * 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;
+
+/**
+ * A wrapper object used for holding onto remote credentials. When you are using
+ * the proxy service, the remote credentials are used for authenticating against
+ * the proxy server. The remote credentials are distinct from the local credentials
+ * used to authenticate against the local server. You use this class along with
+ * the FlexSession methods getRemoteCredentials and putRemoteCredentials to associate
+ * the remote credentials with a specific destination.
+ */
+public class FlexRemoteCredentials
+{
+ private String service;
+
+ private String destination;
+
+ private String username;
+
+ private Object credentials;
+
+ /**
+ * Normally you do not have to create the FlexRemoteCredentials as they are
+ * created automatically when the client specifies them via the setRemoteCredentials
+ * method in ActionScript. You'd use this if you wanted to set your remote credentials
+ * on the server and not have them specified on the client.
+ * @param service the service id
+ * @param destination the destination id
+ * @param username the user name
+ * @param credentials the user credentials
+ */
+ public FlexRemoteCredentials(String service, String destination,
+ String username, Object credentials)
+ {
+ super();
+ this.service = service;
+ this.destination = destination;
+ this.username = username;
+ this.credentials = credentials;
+ }
+
+ /**
+ * Returns the user name from the remote credentials.
+ * @return String the user name
+ */
+ public String getUsername()
+ {
+ return username;
+ }
+
+ /**
+ * Returns the credentials themselves (usually a password).
+ * @return Object the credentials object
+ */
+ public Object getCredentials()
+ {
+ return credentials;
+ }
+
+ /**
+ * Returns the id of the service these credentials are registered for.
+ * @return String the service id
+ */
+ public String getService()
+ {
+ return service;
+ }
+
+ /**
+ * Returns the destination for the service.
+ * @return String the destination id
+ */
+ public String getDestination()
+ {
+ return destination;
+ }
+}
[28/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/HttpFlexSessionProvider.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/HttpFlexSessionProvider.java b/modules/core/src/flex/messaging/HttpFlexSessionProvider.java
old mode 100755
new mode 100644
index 9a077b9..abdcb4c
--- a/modules/core/src/flex/messaging/HttpFlexSessionProvider.java
+++ b/modules/core/src/flex/messaging/HttpFlexSessionProvider.java
@@ -1,94 +1,94 @@
-/*
- * 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;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import flex.messaging.log.Log;
-
-/**
- * Provider implementation for <code>HttpFlexSession</code>s.
- * Not intended for public use.
- */
-public class HttpFlexSessionProvider extends AbstractFlexSessionProvider
-{
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Factory method to get an existing <tt>HttpFlexSession</tt> for the current request,
- * or create and return a new <code>HttpFlexSession</code> if necessary.
- * The <code>HttpFlexSession</code> wraps the underlying J2EE <code>HttpSession</code>.
- * Not intended for public use.
- *
- * @param request The current <tt>HttpServletRequest</tt>.
- * @return A <tt>HttpFlexSession</tt>.
- */
- public HttpFlexSession getOrCreateSession(HttpServletRequest request)
- {
- HttpFlexSession flexSession;
- HttpSession httpSession = request.getSession(true);
-
- if (!HttpFlexSession.isHttpSessionListener && !HttpFlexSession.warnedNoEventRedispatch)
- {
- HttpFlexSession.warnedNoEventRedispatch = true;
- if (Log.isWarn())
- Log.getLogger(HttpFlexSession.WARN_LOG_CATEGORY).warn("HttpFlexSession has not been registered as a listener in web.xml for this application so no events will be dispatched to FlexSessionAttributeListeners or FlexSessionBindingListeners. To correct this, register flex.messaging.HttpFlexSession as a listener in web.xml.");
- }
-
- boolean isNew = false;
- synchronized (httpSession)
- {
- flexSession = (HttpFlexSession)httpSession.getAttribute(HttpFlexSession.SESSION_ATTRIBUTE);
- if (flexSession == null)
- {
- flexSession = new HttpFlexSession(this);
- // Correlate this FlexSession to the HttpSession before triggering any listeners.
- FlexContext.setThreadLocalSession(flexSession);
- httpSession.setAttribute(HttpFlexSession.SESSION_ATTRIBUTE, flexSession);
- flexSession.setHttpSession(httpSession);
- isNew = true;
- }
- else
- {
- FlexContext.setThreadLocalSession(flexSession);
- if (flexSession.httpSession == null)
- {
- // httpSession is null if the instance is new or is from
- // serialization.
- flexSession.setHttpSession(httpSession);
- isNew = true;
- }
- }
- }
-
- if (isNew)
- {
- getFlexSessionManager().registerFlexSession(flexSession);
- flexSession.notifyCreated();
-
- if (Log.isDebug())
- Log.getLogger(HttpFlexSession.FLEX_SESSION_LOG_CATEGORY).debug("FlexSession created with id '" + flexSession.getId() + "' for an Http-based client connection.");
- }
-
- return flexSession;
- }
- }
+/*
+ * 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;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import flex.messaging.log.Log;
+
+/**
+ * Provider implementation for <code>HttpFlexSession</code>s.
+ * Not intended for public use.
+ */
+public class HttpFlexSessionProvider extends AbstractFlexSessionProvider
+{
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Factory method to get an existing <tt>HttpFlexSession</tt> for the current request,
+ * or create and return a new <code>HttpFlexSession</code> if necessary.
+ * The <code>HttpFlexSession</code> wraps the underlying J2EE <code>HttpSession</code>.
+ * Not intended for public use.
+ *
+ * @param request The current <tt>HttpServletRequest</tt>.
+ * @return A <tt>HttpFlexSession</tt>.
+ */
+ public HttpFlexSession getOrCreateSession(HttpServletRequest request)
+ {
+ HttpFlexSession flexSession;
+ HttpSession httpSession = request.getSession(true);
+
+ if (!HttpFlexSession.isHttpSessionListener && !HttpFlexSession.warnedNoEventRedispatch)
+ {
+ HttpFlexSession.warnedNoEventRedispatch = true;
+ if (Log.isWarn())
+ Log.getLogger(HttpFlexSession.WARN_LOG_CATEGORY).warn("HttpFlexSession has not been registered as a listener in web.xml for this application so no events will be dispatched to FlexSessionAttributeListeners or FlexSessionBindingListeners. To correct this, register flex.messaging.HttpFlexSession as a listener in web.xml.");
+ }
+
+ boolean isNew = false;
+ synchronized (httpSession)
+ {
+ flexSession = (HttpFlexSession)httpSession.getAttribute(HttpFlexSession.SESSION_ATTRIBUTE);
+ if (flexSession == null)
+ {
+ flexSession = new HttpFlexSession(this);
+ // Correlate this FlexSession to the HttpSession before triggering any listeners.
+ FlexContext.setThreadLocalSession(flexSession);
+ httpSession.setAttribute(HttpFlexSession.SESSION_ATTRIBUTE, flexSession);
+ flexSession.setHttpSession(httpSession);
+ isNew = true;
+ }
+ else
+ {
+ FlexContext.setThreadLocalSession(flexSession);
+ if (flexSession.httpSession == null)
+ {
+ // httpSession is null if the instance is new or is from
+ // serialization.
+ flexSession.setHttpSession(httpSession);
+ isNew = true;
+ }
+ }
+ }
+
+ if (isNew)
+ {
+ getFlexSessionManager().registerFlexSession(flexSession);
+ flexSession.notifyCreated();
+
+ if (Log.isDebug())
+ Log.getLogger(HttpFlexSession.FLEX_SESSION_LOG_CATEGORY).debug("FlexSession created with id '" + flexSession.getId() + "' for an Http-based client connection.");
+ }
+
+ return flexSession;
+ }
+ }
[30/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexSession.java b/modules/core/src/flex/messaging/FlexSession.java
old mode 100755
new mode 100644
index 2aa3e9c..e570b16
--- a/modules/core/src/flex/messaging/FlexSession.java
+++ b/modules/core/src/flex/messaging/FlexSession.java
@@ -1,1062 +1,1062 @@
-/*
- * 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;
-
-import flex.messaging.client.FlexClient;
-import flex.messaging.client.FlexClientListener;
-import flex.messaging.log.LogCategories;
-import flex.messaging.messages.Message;
-import flex.messaging.util.TimeoutAbstractObject;
-
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * The base for FlexSession implementations.
- */
-public abstract class FlexSession extends TimeoutAbstractObject implements FlexClientListener, MessageClientListener
-{
- //--------------------------------------------------------------------------
- //
- // Public Static Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Log category for FlexSession related messages.
- */
- public static final String FLEX_SESSION_LOG_CATEGORY = LogCategories.ENDPOINT_FLEXSESSION;
-
- /**
- * @exclude
- */
- public static final int MAX_CONNECTIONS_PER_SESSION_UNLIMITED = -1;
-
- //--------------------------------------------------------------------------
- //
- // Private Static Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * The set of session created listeners to notify upon a new session creation.
- */
- private static final CopyOnWriteArrayList<FlexSessionListener> createdListeners = new CopyOnWriteArrayList<FlexSessionListener>();
-
- /**
- * Error string constants.
- */
- private static final int FLEX_SESSION_INVALIDATED = 10019;
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * @exclude
- * @deprecated Post 2.6.1 releases require use of the constructor that takes an <tt>AbstractFlexSessionProvider</tt> argument.
- */
- public FlexSession()
- {
- this(null);
- }
-
- /**
- * @exclude
- * Constructs a new FlexSession instance.
- *
- * @param sessionProvider The provider that instantiated this instance.
- */
- public FlexSession(AbstractFlexSessionProvider sessionProvider)
- {
- this.sessionProvider = sessionProvider;
- }
-
- //--------------------------------------------------------------------------
- //
- // Static Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Adds a session created listener that will be notified when new sessions
- * are created.
- *
- * @see flex.messaging.FlexSessionListener
- *
- * @param listener The listener to add.
- */
- public static void addSessionCreatedListener(FlexSessionListener listener)
- {
- if (listener != null)
- createdListeners.addIfAbsent(listener);
- }
-
- /**
- * Removes a session created listener.
- *
- * @see flex.messaging.FlexSessionListener
- *
- * @param listener The listener to remove.
- */
- public static void removeSessionCreatedListener(FlexSessionListener listener)
- {
- if (listener != null)
- createdListeners.remove(listener);
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * Flag used to break cycles during invalidation.
- */
- protected boolean invalidating;
-
- /**
- * Instance level lock to sync for state changes.
- */
- protected final Object lock = new Object();
-
- /**
- * Flag indicated whether the session has been invalidated/destroyed.
- */
- protected boolean valid = true;
-
- /**
- * The attributes associated with this session.
- */
- private Map<String, Object> attributes;
-
- /**
- * Registered attribute listeners for the session.
- */
- private volatile CopyOnWriteArrayList<FlexSessionAttributeListener> attributeListeners;
-
- /**
- * Flag indicating whether creation notification has been completed.
- */
- private boolean creationNotified;
-
- /**
- * The set of session destroy listeners to notify when the session is destroyed.
- */
- private volatile CopyOnWriteArrayList<FlexSessionListener> destroyedListeners;
-
- /**
- * The associated FlexClients.
- */
- private final CopyOnWriteArrayList<FlexClient> flexClients = new CopyOnWriteArrayList<FlexClient>();
-
- /**
- * List of associated MessageClients created while this session was active (thread local).
- */
- private volatile CopyOnWriteArrayList<MessageClient> messageClients;
-
- /**
- * Storage for remote credentials associated with the session; used by the HTTPProxyService
- * when requests are made to a secured remote endpoint.
- */
- private volatile Map remoteCredentials;
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
- //----------------------------------
- // asyncPollMap
- //----------------------------------
-
- /**
- * @exclude
- * Used internally to manage async long-polls; not for public use.
- *
- * A map of endpoint to async poll objects that keeps track of what
- * client is parked on a long-poll with what endpoint.
- * We only want an endpoint to have a single connection to a client.
- * Normally, the server leaves an async long-poll in place until
- * data arrives to push to the client or a timeout is reached.
- * However, if two or more browser tabs/windows are sharing the same server session and are both attempting
- * async long-polling, we alternate their parked requests to avoid locking up the browser process by holding too many
- * Http connections open at once.
- * This also aids with closing out 'orphaned' long polls following a browser page reload.
- * Generically typed as <code>Object</code>; using this reference is left up to async poll
- * implementation code.
- */
- public volatile HashMap<String, FlexClient.AsyncPollWithTimeout> asyncPollMap;
-
- //----------------------------------
- // flexSessionProvider
- //----------------------------------
-
- private final AbstractFlexSessionProvider sessionProvider;
-
- /**
- * @exclude
- * Returns the session provider that created this instance.
- *
- * @return The session provider that created this instance.
- */
- public AbstractFlexSessionProvider getFlexSessionProvider()
- {
- return sessionProvider;
- }
-
- //----------------------------------
- // principal
- //----------------------------------
-
- /**
- * The principal associated with the session.
- */
- private Principal userPrincipal;
-
- /**
- * This method should be called on FlexContext and not on this class. Keeping
- * this method for backwards compatibility. This method will produce
- * correct results when perClientAuthentication is false. However, it will
- * not return correct results when perClientAuthentication is true.
- *
- * Returns the principal associated with the session. If the client has not
- * authenticated the principal will be null.
- *
- * @return The principal associated with the session.
- */
- public Principal getUserPrincipal()
- {
- synchronized (lock)
- {
- checkValid();
- return userPrincipal;
- }
- }
-
- /**
- * This method should be called on FlexContext and not on this class. Keeping
- * this method for backwards compatibility. Calling this when perClientAuthentication
- * is true will not correctly set the UserPrincipal.
- *
- * @param userPrincipal The principal to associate with the session.
- */
- public void setUserPrincipal(Principal userPrincipal)
- {
- synchronized (lock)
- {
- checkValid();
- this.userPrincipal = userPrincipal;
- }
- }
-
- //----------------------------------
- // canStream
- //----------------------------------
-
- /**
- * @exclude
- * Used internally by streaming endpoints to enforce session level streaming
- * connection limits; not for public use.
- * This flag is volatile to allow for consistent reads across thread without
- * needing to pay the cost for a synchronized lock for each read.
- */
- public volatile boolean canStream = true;
-
- //----------------------------------
- // maxConnectionsPerSession
- //----------------------------------
-
- /**
- * @exclude
- * Used internally by streaming and long polling endpoints to enforce session
- * level streaming connection limits; not for public use. Default value is -1
- * (limitless)
- */
- public int maxConnectionsPerSession = MAX_CONNECTIONS_PER_SESSION_UNLIMITED;
-
- //----------------------------------
- // streamingClientsCount
- //----------------------------------
-
- /**
- * @exclude
- * Used internally by streaming and long polling endpoints to enforce
- * session level streaming connection limits; not for public use.
- *
- * Some browsers put limits on the number of connections per session. For
- * example, Firefox has network.http.max-connections-per-server=8 limit which
- * limits the number of streaming connections per session to 7. Similarly,
- * IE has a limit of 2 per session.
- *
- * This variable is used by streaming and long polling endpoint to keep
- * track of open connections per session and disallow them when needed.
- *
- */
- public int streamingConnectionsCount;
-
- //----------------------------------
- // useSmallMessages
- //----------------------------------
-
- /**
- * @exclude
- */
- private boolean useSmallMessages;
-
- /**
- * @exclude
- * Determines whether the server can attempt to send small messages
- * for those messages that have a small form. This setting can be overridden
- * by an endpoint's enableSmallMessages switch which controls whether
- * small messages should be sent, even if they are supported.
- *
- * The default is false.
- */
- public boolean useSmallMessages()
- {
- return useSmallMessages;
- }
-
- /**
- * @exclude
- */
- public void setUseSmallMessages(boolean value)
- {
- useSmallMessages = value;
- }
-
- //----------------------------------
- // waitMonitor
- //----------------------------------
-
- /**
- * @exclude
- * Used internally to manage wait()-based long-polls; not for public use.
- *
- * This is the monitor that a request handling thread associated with this
- * FlexSession is waiting on. Normally, the waiting request handling thread will wait until
- * a new message arrives that can be returned in a poll response or its wait interval times out.
- * This also aids with closing out 'orphaned' long polls following a browser page reload.
- */
- public volatile HashMap<String, FlexClient.EndpointQueue> waitMonitor;
-
- //--------------------------------------------------------------------------
- //
- // Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Adds a session attribute listener that will be notified when an
- * attribute is added, removed or changed.
- *
- * @param listener The listener to add.
- */
- public void addSessionAttributeListener(FlexSessionAttributeListener listener)
- {
- if (listener != null)
- {
- checkValid();
-
- if (attributeListeners == null)
- {
- synchronized (lock)
- {
- if (attributeListeners == null)
- attributeListeners = new CopyOnWriteArrayList<FlexSessionAttributeListener>();
- }
- }
-
- attributeListeners.addIfAbsent(listener);
- }
- }
-
- /**
- * Adds a session destroy listener that will be notified when the session
- * is destroyed. Session destroy listeners are notified after all attributes
- * have been unbound from the session and any FlexSessionBindingListeners
- * and FlexSessionAttributeListeners have been notified.
- *
- * @see flex.messaging.FlexSessionListener
- *
- * @param listener The listener to add.
- */
- public void addSessionDestroyedListener(FlexSessionListener listener)
- {
- if (listener != null)
- {
- checkValid();
-
- if (destroyedListeners == null)
- {
- synchronized (lock)
- {
- if (destroyedListeners == null)
- destroyedListeners = new CopyOnWriteArrayList<FlexSessionListener>();
- }
- }
-
- destroyedListeners.addIfAbsent(listener);
- }
- }
-
- /**
- * Returns the attribute bound to the specified name in the session, or null
- * if no attribute is bound under the name.
- *
- * @param name The name the target attribute is bound to.
- * @return The attribute bound to the specified name.
- */
- public Object getAttribute(String name)
- {
- synchronized (lock)
- {
- checkValid();
-
- return (attributes == null) ? null : attributes.get(name);
- }
- }
-
- /**
- * Returns a snapshot of the names of all attributes bound to the session.
- *
- * @return A snapshot of the names of all attributes bound to the session.
- */
- public Enumeration<String> getAttributeNames()
- {
- synchronized (lock)
- {
- checkValid();
-
- if (attributes == null)
- return Collections.enumeration(Collections.<String>emptyList());
-
- // Return a copy so we do not run into concurrent modification problems if
- // someone adds to the attributes while iterating through the returned enumeration.
- return Collections.enumeration(new ArrayList<String>(attributes.keySet()));
- }
- }
-
- /**
- * @exclude
- * Implements MessageClientListener.
- * Handling created events is a no-op.
- *
- * @messageClient The new MessageClient.
- */
- public void messageClientCreated(MessageClient messageClient) {}
-
- /**
- * @exclude
- * Implements MessageClientListener.
- * Notification that an associated MessageClient was destroyed.
- *
- * @param messageClient The MessageClient that was destroyed.
- */
- public void messageClientDestroyed(MessageClient messageClient)
- {
- unregisterMessageClient(messageClient);
- }
-
- /**
- * @exclude
- * FlexClient invokes this to determine whether the session can be used to push messages
- * to the client.
- *
- * @return true if the FlexSession supports direct push; otherwise false (polling is assumed).
- */
- public abstract boolean isPushSupported();
-
- /**
- * @exclude
- * FlexClient invokes this to push a message to a remote client.
- *
- * @param message The message to push.
- */
- public void push(Message message)
- {
- throw new UnsupportedOperationException("Push not supported.");
- }
-
- /**
- * Removes the attribute bound to the specified name in the session.
- *
- * @param name The name of the attribute to remove.
- */
- public void removeAttribute(String name)
- {
- Object value; // Used for event dispatch after the attribute is removed.
-
- synchronized (lock)
- {
- checkValid(); // Re-enters lock but should be fast because we're already holding it.
-
- value = (attributes != null) ? attributes.remove(name) : null;
- }
-
- // If no value was bound under this name it's a no-op.
- if (value == null)
- return;
-
- notifyAttributeUnbound(name, value);
- notifyAttributeRemoved(name, value);
- }
-
- /**
- * Removes a session attribute listener.
- *
- * @param listener The listener to remove.
- */
- public void removeSessionAttributeListener(FlexSessionAttributeListener listener)
- {
- // No need to check validity; removing a listener is always ok.
- if (listener != null && attributeListeners != null)
- attributeListeners.remove(listener);
- }
-
- /**
- * Removes a session destroy listener.
- *
- * @see flex.messaging.FlexSessionListener
- *
- * @param listener The listener to remove.
- */
- public void removeSessionDestroyedListener(FlexSessionListener listener)
- {
- // No need to check validity; removing a listener is always ok.
- if (listener != null && destroyedListeners != null)
- destroyedListeners.remove(listener);
- }
-
- /**
- * Binds an attribute value to the session under the specified name.
- *
- * @param name The name to bind the attribute under.
- * @param value The value of the attribute.
- */
- public void setAttribute(String name, Object value)
- {
- // Null value is the same as removeAttribute().
- if (value == null)
- {
- removeAttribute(name);
- return;
- }
-
- Object oldValue; // Used to determine which events to dispatch after the set is performed.
-
- // Only synchronize for the attribute mutation; event dispatch doesn't require it.
- synchronized (lock)
- {
- checkValid(); // Re-enters lock but should be fast because we're already holding it.
-
- if (attributes == null)
- attributes = new HashMap<String, Object>();
-
- oldValue = attributes.put(name, value);
- }
-
- if (oldValue == null)
- {
- notifyAttributeBound(name, value);
- notifyAttributeAdded(name, value);
- }
- else
- {
- notifyAttributeUnbound(name, oldValue);
- notifyAttributeReplaced(name, oldValue);
- notifyAttributeBound(name, value);
- }
- }
-
- /**
- * Stores remote credentials in the session for proxied calls to remote systems.
- *
- * @param credentials The remote credentials.
- */
- public void putRemoteCredentials(FlexRemoteCredentials credentials)
- {
- if (credentials != null)
- {
- // We only need to hold the lock to lazy-init the remoteCredentials variable.
- if (remoteCredentials == null)
- {
- synchronized (lock)
- {
- // Init size to 4 because that's the number of shipping service types
- // (messaging, remoting, proxy, data management).
- if (remoteCredentials == null)
- remoteCredentials = new HashMap(4);
- }
- }
- synchronized (remoteCredentials)
- {
- Map serviceMap = (Map)remoteCredentials.get(credentials.getService());
- if (serviceMap == null)
- {
- // Init size to half the normal number of buckets; most services won't have a large
- // number of destinations with remote credentials.
- serviceMap = new HashMap(7);
- remoteCredentials.put(credentials.getService(), serviceMap);
- }
- serviceMap.put(credentials.getDestination(), credentials);
- }
- }
- }
-
- /**
- * Returns the remote credentials stored in the session for the specified service destination.
- *
- * @param serviceId The service id.
- * @param destinationId The destination id.
- * @return The stored remote credentials for the specified service destination.
- */
- public FlexRemoteCredentials getRemoteCredentials(String serviceId, String destinationId)
- {
- if (serviceId != null && destinationId != null)
- {
- if (remoteCredentials == null)
- return null;
- synchronized (remoteCredentials)
- {
- Map serviceMap = (Map)remoteCredentials.get(serviceId);
- return (serviceMap != null) ? (FlexRemoteCredentials)serviceMap.get(destinationId) : null;
- }
- }
- return null;
- }
-
- /**
- * Clears any stored remote credentials from the session for the specified service destination.
- *
- * @param serviceId The service Id.
- * @param destinationId The destination Id.
- */
- public void clearRemoteCredentials(String serviceId, String destinationId)
- {
- if (serviceId != null && destinationId != null)
- {
- if (remoteCredentials == null)
- return;
- synchronized (remoteCredentials)
- {
- Map serviceMap = (Map)remoteCredentials.get(serviceId);
- if (serviceMap != null)
- {
- serviceMap.put(destinationId, null);
- }
- }
- }
- }
-
- /**
- * Invalidates the FlexSession.
- */
- public void invalidate()
- {
- synchronized (lock)
- {
- if (!valid || invalidating)
- return; // Already shutting down.
-
- invalidating = true; // This thread gets to shut the FlexSession down.
- cancelTimeout();
- if (sessionProvider != null)
- sessionProvider.removeFlexSession(this);
- }
-
- // Unregister all FlexClients.
- if (!flexClients.isEmpty())
- {
- for (FlexClient flexClient : flexClients)
- unregisterFlexClient(flexClient);
- }
-
- // Invalidate associated MessageClient subscriptions.
- if (messageClients != null && !messageClients.isEmpty())
- {
- for (Iterator<MessageClient> iter = messageClients.iterator(); iter.hasNext();)
- {
- MessageClient messageClient = iter.next();
- messageClient.removeMessageClientDestroyedListener(this);
- messageClient.invalidate();
- }
- messageClients.clear();
- }
-
-
- // Notify destroy listeners that we're shutting the FlexSession down.
- if (destroyedListeners != null && !destroyedListeners.isEmpty())
- {
- for (FlexSessionListener destroyListener : destroyedListeners)
- {
- destroyListener.sessionDestroyed(this);
- }
- destroyedListeners.clear();
- }
-
- // Unbind all attributes.
- if (attributes != null && !attributes.isEmpty())
- {
- Set<String> keySet = attributes.keySet();
- String[] keys = keySet.toArray(new String[keySet.size()]);
- for (String key : keys)
- removeAttribute(key);
-
- attributes = null;
- }
-
- internalInvalidate();
-
- synchronized (lock)
- {
- valid = false;
- invalidating = false;
- }
-
- // Notify any waiting threads.
- if (waitMonitor != null)
- {
- for (FlexClient.EndpointQueue endpointQueue : waitMonitor.values())
- {
- synchronized (endpointQueue)
- {
- endpointQueue.notifyAll();
- }
- }
- }
- }
-
- /**
- * Hook for subclasses to perform any custom shutdown.
- * Invoked after the FlexSession has performed generic shutdown but right before the session's valid
- * property flips to false.
- */
- protected void internalInvalidate() {}
-
- /**
- * Returns a snapshot of the FlexClients associated with the FlexSession
- * when this method is invoked.
- * This list is not guaranteed to remain consistent with the actual list
- * of active FlexClients associated with the FlexSession over time.
- *
- * @return A snapshot of the current list of FlexSessions associated with the FlexClient.
- */
- public List<FlexClient> getFlexClients()
- {
- List<FlexClient> currentFlexClients = null;
- synchronized (lock)
- {
- checkValid(); // Re-enters lock but should be fast because we're already holding it.
-
- currentFlexClients = new ArrayList<FlexClient>(flexClients); // Make a copy of the current list to return.
- }
- return currentFlexClients;
- }
-
- /**
- * Returns a snapshot of the MessageClients (subscriptions) associated with the FlexSession
- * when this method is invoked.
- * This list is not guaranteed to remain consistent with the actual list
- * of active MessageClients associated with the FlexSession over time.
- *
- * @return A snapshot of the current list of MessageClients associated with the FlexSession.
- */
- public List<MessageClient> getMessageClients()
- {
- List<MessageClient> currentMessageClients = null;
- synchronized (lock)
- {
- checkValid(); // Re-enters lock but should be fast because we're already holding it.
-
- currentMessageClients = (messageClients != null) ? new ArrayList<MessageClient>(messageClients) // Make a copy of the current list to return.
- : new ArrayList<MessageClient>(); // Return an empty list.
- }
- return currentMessageClients;
- }
-
- /**
- * Returns the Id for the session.
- *
- * @return The Id for the session.
- */
- public abstract String getId();
-
- /**
- * Returns whether the current user is in the specified role.
- *
- * @param role The role to test.
- * @return true if the user is in the role; otherwise false.
- */
- public boolean isUserInRole(String role)
- {
- ArrayList list = new ArrayList();
- list.add(role);
- return FlexContext.getMessageBroker().getLoginManager().checkRoles(userPrincipal, list);
- }
-
- /**
- * Returns whether the session is valid.
- *
- * @return true if the session is valid; otherwise false.
- */
- public boolean isValid()
- {
- synchronized (lock)
- {
- return valid;
- }
- }
-
- /**
- * @exclude
- * Implements FlexClientListener interface.
- * Notification that a FlexClient was created.
- * This is a no-op because the FlexSession is never added as a static FlexClient created listener
- * but this method is required by the interface. We only listen for the destroyed event from
- * associated FlexClients.
- *
- * @param flexClient The FlexClient that was created.
- */
- public void clientCreated(FlexClient flexClient) {}
-
- /**
- * @exclude
- * Implements FlexClientListener interface.
- * Notification that an associated FlexClient was destroyed.
- *
- * @param flexClient The FlexClient that was destroyed.
- */
- public void clientDestroyed(FlexClient flexClient)
- {
- unregisterFlexClient(flexClient);
- }
-
- /**
- * @exclude
- * Used internally to associate a FlexClient with the FlexSession.
- *
- * @param flexClient The FlexClient to assocaite with the session.
- */
- public void registerFlexClient(FlexClient flexClient)
- {
- if (flexClients.addIfAbsent(flexClient))
- {
- flexClient.addClientDestroyedListener(this);
- flexClient.registerFlexSession(this);
- }
- }
-
- /**
- * @exclude
- * Used internally to disassociate a FlexClient from the FlexSession.
- *
- * @param flexClient The FlexClient to disassociate from the session.
- */
- public void unregisterFlexClient(FlexClient flexClient)
- {
- if (flexClients.remove(flexClient))
- {
- flexClient.removeClientDestroyedListener(this);
- flexClient.unregisterFlexSession(this);
- }
- }
-
- /**
- * @exclude
- * Used internally to associate a MessagClient (subscription) with the FlexSession.
- *
- * @param messageClient The MessageClient to associate with the session.
- */
- public void registerMessageClient(MessageClient messageClient)
- {
- if (messageClients == null)
- {
- synchronized (lock)
- {
- if (messageClients == null)
- messageClients = new CopyOnWriteArrayList<MessageClient>();
- }
- }
-
- if (messageClients.addIfAbsent(messageClient))
- messageClient.addMessageClientDestroyedListener(this);
- }
-
- /**
- * @exclude
- * Used internally to disassociate a MessageClient (subscription) from a FlexSession.
- *
- * @param messageClient The MessageClient to disassociate from the session.
- */
- public void unregisterMessageClient(MessageClient messageClient)
- {
- if (messageClients != null && messageClients.remove(messageClient))
- messageClient.removeMessageClientDestroyedListener(this);
- }
-
- /**
- * Default implementation invokes <code>invalidate()</code> upon timeout.
- *
- * @see flex.messaging.util.TimeoutCapable#timeout()
- */
- public void timeout()
- {
- invalidate();
- }
-
- //--------------------------------------------------------------------------
- //
- // Protected Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Ensures that the session has not been invalidated.
- */
- protected void checkValid()
- {
- synchronized (lock)
- {
- if (!valid)
- {
- LocalizedException e = new LocalizedException();
- e.setMessage(FLEX_SESSION_INVALIDATED);
- throw e;
- }
- }
- }
-
- /**
- * Notify attribute listeners that an attribute has been added.
- *
- * @param name The name of the attribute.
- * @param value The new value of the attribute.
- */
- protected void notifyAttributeAdded(String name, Object value)
- {
- if (attributeListeners != null && !attributeListeners.isEmpty())
- {
- FlexSessionBindingEvent event = new FlexSessionBindingEvent(this, name, value);
- // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
- for (FlexSessionAttributeListener attribListener : attributeListeners)
- attribListener.attributeAdded(event);
- }
- }
-
- /**
- * Notify binding listener that it has been bound to the session.
- *
- * @param name The attribute name.
- * @param value The attribute that has been bound.
- */
- protected void notifyAttributeBound(String name, Object value)
- {
- if ((value != null) && (value instanceof FlexSessionBindingListener))
- {
- FlexSessionBindingEvent bindingEvent = new FlexSessionBindingEvent(this, name);
- ((FlexSessionBindingListener)value).valueBound(bindingEvent);
- }
- }
-
- /**
- * Notify attribute listeners that an attribute has been removed.
- *
- * @param name The name of the attribute.
- * @param value The previous value of the attribute.
- */
- protected void notifyAttributeRemoved(String name, Object value)
- {
- if (attributeListeners != null && !attributeListeners.isEmpty())
- {
- FlexSessionBindingEvent event = new FlexSessionBindingEvent(this, name, value);
- // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
- for (FlexSessionAttributeListener attribListener : attributeListeners)
- attribListener.attributeRemoved(event);
- }
- }
-
- /**
- * Notify attribute listeners that an attribute has been replaced.
- *
- * @param name The name of the attribute.
- * @param value The previous value of the attribute.
- */
- protected void notifyAttributeReplaced(String name, Object value)
- {
- if (attributeListeners != null && !attributeListeners.isEmpty())
- {
- FlexSessionBindingEvent event = new FlexSessionBindingEvent(this, name, value);
- // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
- for (FlexSessionAttributeListener attribListener : attributeListeners)
- attribListener.attributeReplaced(event);
- }
- }
-
- /**
- * Notify binding listener that it has been unbound from the session.
- *
- * @param name The attribute name.
- * @param value The attribute that has been unbound.
- */
- protected void notifyAttributeUnbound(String name, Object value)
- {
- if ((value != null) && (value instanceof FlexSessionBindingListener))
- {
- FlexSessionBindingEvent bindingEvent = new FlexSessionBindingEvent(this, name);
- ((FlexSessionBindingListener)value).valueUnbound(bindingEvent);
- }
- }
-
- /**
- * Invoked by subclass upon session creation to notify all registered
- * session create listeners of the event.
- * This method must be invoked in the subclass constructor.
- */
- protected void notifyCreated()
- {
- // This guard is here only to prevent duplicate notifications if there's a coding error
- // in the subclass. Not likely..
- synchronized (lock)
- {
- if (creationNotified)
- return;
-
- creationNotified = true;
- }
-
- if (!createdListeners.isEmpty())
- {
- // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
- for (Iterator<FlexSessionListener> iter = createdListeners.iterator(); iter.hasNext();)
- iter.next().sessionCreated(this);
- }
- }
-}
+/*
+ * 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;
+
+import flex.messaging.client.FlexClient;
+import flex.messaging.client.FlexClientListener;
+import flex.messaging.log.LogCategories;
+import flex.messaging.messages.Message;
+import flex.messaging.util.TimeoutAbstractObject;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * The base for FlexSession implementations.
+ */
+public abstract class FlexSession extends TimeoutAbstractObject implements FlexClientListener, MessageClientListener
+{
+ //--------------------------------------------------------------------------
+ //
+ // Public Static Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Log category for FlexSession related messages.
+ */
+ public static final String FLEX_SESSION_LOG_CATEGORY = LogCategories.ENDPOINT_FLEXSESSION;
+
+ /**
+ * @exclude
+ */
+ public static final int MAX_CONNECTIONS_PER_SESSION_UNLIMITED = -1;
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Static Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The set of session created listeners to notify upon a new session creation.
+ */
+ private static final CopyOnWriteArrayList<FlexSessionListener> createdListeners = new CopyOnWriteArrayList<FlexSessionListener>();
+
+ /**
+ * Error string constants.
+ */
+ private static final int FLEX_SESSION_INVALIDATED = 10019;
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @exclude
+ * @deprecated Post 2.6.1 releases require use of the constructor that takes an <tt>AbstractFlexSessionProvider</tt> argument.
+ */
+ public FlexSession()
+ {
+ this(null);
+ }
+
+ /**
+ * @exclude
+ * Constructs a new FlexSession instance.
+ *
+ * @param sessionProvider The provider that instantiated this instance.
+ */
+ public FlexSession(AbstractFlexSessionProvider sessionProvider)
+ {
+ this.sessionProvider = sessionProvider;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Static Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Adds a session created listener that will be notified when new sessions
+ * are created.
+ *
+ * @see flex.messaging.FlexSessionListener
+ *
+ * @param listener The listener to add.
+ */
+ public static void addSessionCreatedListener(FlexSessionListener listener)
+ {
+ if (listener != null)
+ createdListeners.addIfAbsent(listener);
+ }
+
+ /**
+ * Removes a session created listener.
+ *
+ * @see flex.messaging.FlexSessionListener
+ *
+ * @param listener The listener to remove.
+ */
+ public static void removeSessionCreatedListener(FlexSessionListener listener)
+ {
+ if (listener != null)
+ createdListeners.remove(listener);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Flag used to break cycles during invalidation.
+ */
+ protected boolean invalidating;
+
+ /**
+ * Instance level lock to sync for state changes.
+ */
+ protected final Object lock = new Object();
+
+ /**
+ * Flag indicated whether the session has been invalidated/destroyed.
+ */
+ protected boolean valid = true;
+
+ /**
+ * The attributes associated with this session.
+ */
+ private Map<String, Object> attributes;
+
+ /**
+ * Registered attribute listeners for the session.
+ */
+ private volatile CopyOnWriteArrayList<FlexSessionAttributeListener> attributeListeners;
+
+ /**
+ * Flag indicating whether creation notification has been completed.
+ */
+ private boolean creationNotified;
+
+ /**
+ * The set of session destroy listeners to notify when the session is destroyed.
+ */
+ private volatile CopyOnWriteArrayList<FlexSessionListener> destroyedListeners;
+
+ /**
+ * The associated FlexClients.
+ */
+ private final CopyOnWriteArrayList<FlexClient> flexClients = new CopyOnWriteArrayList<FlexClient>();
+
+ /**
+ * List of associated MessageClients created while this session was active (thread local).
+ */
+ private volatile CopyOnWriteArrayList<MessageClient> messageClients;
+
+ /**
+ * Storage for remote credentials associated with the session; used by the HTTPProxyService
+ * when requests are made to a secured remote endpoint.
+ */
+ private volatile Map remoteCredentials;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // asyncPollMap
+ //----------------------------------
+
+ /**
+ * @exclude
+ * Used internally to manage async long-polls; not for public use.
+ *
+ * A map of endpoint to async poll objects that keeps track of what
+ * client is parked on a long-poll with what endpoint.
+ * We only want an endpoint to have a single connection to a client.
+ * Normally, the server leaves an async long-poll in place until
+ * data arrives to push to the client or a timeout is reached.
+ * However, if two or more browser tabs/windows are sharing the same server session and are both attempting
+ * async long-polling, we alternate their parked requests to avoid locking up the browser process by holding too many
+ * Http connections open at once.
+ * This also aids with closing out 'orphaned' long polls following a browser page reload.
+ * Generically typed as <code>Object</code>; using this reference is left up to async poll
+ * implementation code.
+ */
+ public volatile HashMap<String, FlexClient.AsyncPollWithTimeout> asyncPollMap;
+
+ //----------------------------------
+ // flexSessionProvider
+ //----------------------------------
+
+ private final AbstractFlexSessionProvider sessionProvider;
+
+ /**
+ * @exclude
+ * Returns the session provider that created this instance.
+ *
+ * @return The session provider that created this instance.
+ */
+ public AbstractFlexSessionProvider getFlexSessionProvider()
+ {
+ return sessionProvider;
+ }
+
+ //----------------------------------
+ // principal
+ //----------------------------------
+
+ /**
+ * The principal associated with the session.
+ */
+ private Principal userPrincipal;
+
+ /**
+ * This method should be called on FlexContext and not on this class. Keeping
+ * this method for backwards compatibility. This method will produce
+ * correct results when perClientAuthentication is false. However, it will
+ * not return correct results when perClientAuthentication is true.
+ *
+ * Returns the principal associated with the session. If the client has not
+ * authenticated the principal will be null.
+ *
+ * @return The principal associated with the session.
+ */
+ public Principal getUserPrincipal()
+ {
+ synchronized (lock)
+ {
+ checkValid();
+ return userPrincipal;
+ }
+ }
+
+ /**
+ * This method should be called on FlexContext and not on this class. Keeping
+ * this method for backwards compatibility. Calling this when perClientAuthentication
+ * is true will not correctly set the UserPrincipal.
+ *
+ * @param userPrincipal The principal to associate with the session.
+ */
+ public void setUserPrincipal(Principal userPrincipal)
+ {
+ synchronized (lock)
+ {
+ checkValid();
+ this.userPrincipal = userPrincipal;
+ }
+ }
+
+ //----------------------------------
+ // canStream
+ //----------------------------------
+
+ /**
+ * @exclude
+ * Used internally by streaming endpoints to enforce session level streaming
+ * connection limits; not for public use.
+ * This flag is volatile to allow for consistent reads across thread without
+ * needing to pay the cost for a synchronized lock for each read.
+ */
+ public volatile boolean canStream = true;
+
+ //----------------------------------
+ // maxConnectionsPerSession
+ //----------------------------------
+
+ /**
+ * @exclude
+ * Used internally by streaming and long polling endpoints to enforce session
+ * level streaming connection limits; not for public use. Default value is -1
+ * (limitless)
+ */
+ public int maxConnectionsPerSession = MAX_CONNECTIONS_PER_SESSION_UNLIMITED;
+
+ //----------------------------------
+ // streamingClientsCount
+ //----------------------------------
+
+ /**
+ * @exclude
+ * Used internally by streaming and long polling endpoints to enforce
+ * session level streaming connection limits; not for public use.
+ *
+ * Some browsers put limits on the number of connections per session. For
+ * example, Firefox has network.http.max-connections-per-server=8 limit which
+ * limits the number of streaming connections per session to 7. Similarly,
+ * IE has a limit of 2 per session.
+ *
+ * This variable is used by streaming and long polling endpoint to keep
+ * track of open connections per session and disallow them when needed.
+ *
+ */
+ public int streamingConnectionsCount;
+
+ //----------------------------------
+ // useSmallMessages
+ //----------------------------------
+
+ /**
+ * @exclude
+ */
+ private boolean useSmallMessages;
+
+ /**
+ * @exclude
+ * Determines whether the server can attempt to send small messages
+ * for those messages that have a small form. This setting can be overridden
+ * by an endpoint's enableSmallMessages switch which controls whether
+ * small messages should be sent, even if they are supported.
+ *
+ * The default is false.
+ */
+ public boolean useSmallMessages()
+ {
+ return useSmallMessages;
+ }
+
+ /**
+ * @exclude
+ */
+ public void setUseSmallMessages(boolean value)
+ {
+ useSmallMessages = value;
+ }
+
+ //----------------------------------
+ // waitMonitor
+ //----------------------------------
+
+ /**
+ * @exclude
+ * Used internally to manage wait()-based long-polls; not for public use.
+ *
+ * This is the monitor that a request handling thread associated with this
+ * FlexSession is waiting on. Normally, the waiting request handling thread will wait until
+ * a new message arrives that can be returned in a poll response or its wait interval times out.
+ * This also aids with closing out 'orphaned' long polls following a browser page reload.
+ */
+ public volatile HashMap<String, FlexClient.EndpointQueue> waitMonitor;
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Adds a session attribute listener that will be notified when an
+ * attribute is added, removed or changed.
+ *
+ * @param listener The listener to add.
+ */
+ public void addSessionAttributeListener(FlexSessionAttributeListener listener)
+ {
+ if (listener != null)
+ {
+ checkValid();
+
+ if (attributeListeners == null)
+ {
+ synchronized (lock)
+ {
+ if (attributeListeners == null)
+ attributeListeners = new CopyOnWriteArrayList<FlexSessionAttributeListener>();
+ }
+ }
+
+ attributeListeners.addIfAbsent(listener);
+ }
+ }
+
+ /**
+ * Adds a session destroy listener that will be notified when the session
+ * is destroyed. Session destroy listeners are notified after all attributes
+ * have been unbound from the session and any FlexSessionBindingListeners
+ * and FlexSessionAttributeListeners have been notified.
+ *
+ * @see flex.messaging.FlexSessionListener
+ *
+ * @param listener The listener to add.
+ */
+ public void addSessionDestroyedListener(FlexSessionListener listener)
+ {
+ if (listener != null)
+ {
+ checkValid();
+
+ if (destroyedListeners == null)
+ {
+ synchronized (lock)
+ {
+ if (destroyedListeners == null)
+ destroyedListeners = new CopyOnWriteArrayList<FlexSessionListener>();
+ }
+ }
+
+ destroyedListeners.addIfAbsent(listener);
+ }
+ }
+
+ /**
+ * Returns the attribute bound to the specified name in the session, or null
+ * if no attribute is bound under the name.
+ *
+ * @param name The name the target attribute is bound to.
+ * @return The attribute bound to the specified name.
+ */
+ public Object getAttribute(String name)
+ {
+ synchronized (lock)
+ {
+ checkValid();
+
+ return (attributes == null) ? null : attributes.get(name);
+ }
+ }
+
+ /**
+ * Returns a snapshot of the names of all attributes bound to the session.
+ *
+ * @return A snapshot of the names of all attributes bound to the session.
+ */
+ public Enumeration<String> getAttributeNames()
+ {
+ synchronized (lock)
+ {
+ checkValid();
+
+ if (attributes == null)
+ return Collections.enumeration(Collections.<String>emptyList());
+
+ // Return a copy so we do not run into concurrent modification problems if
+ // someone adds to the attributes while iterating through the returned enumeration.
+ return Collections.enumeration(new ArrayList<String>(attributes.keySet()));
+ }
+ }
+
+ /**
+ * @exclude
+ * Implements MessageClientListener.
+ * Handling created events is a no-op.
+ *
+ * @messageClient The new MessageClient.
+ */
+ public void messageClientCreated(MessageClient messageClient) {}
+
+ /**
+ * @exclude
+ * Implements MessageClientListener.
+ * Notification that an associated MessageClient was destroyed.
+ *
+ * @param messageClient The MessageClient that was destroyed.
+ */
+ public void messageClientDestroyed(MessageClient messageClient)
+ {
+ unregisterMessageClient(messageClient);
+ }
+
+ /**
+ * @exclude
+ * FlexClient invokes this to determine whether the session can be used to push messages
+ * to the client.
+ *
+ * @return true if the FlexSession supports direct push; otherwise false (polling is assumed).
+ */
+ public abstract boolean isPushSupported();
+
+ /**
+ * @exclude
+ * FlexClient invokes this to push a message to a remote client.
+ *
+ * @param message The message to push.
+ */
+ public void push(Message message)
+ {
+ throw new UnsupportedOperationException("Push not supported.");
+ }
+
+ /**
+ * Removes the attribute bound to the specified name in the session.
+ *
+ * @param name The name of the attribute to remove.
+ */
+ public void removeAttribute(String name)
+ {
+ Object value; // Used for event dispatch after the attribute is removed.
+
+ synchronized (lock)
+ {
+ checkValid(); // Re-enters lock but should be fast because we're already holding it.
+
+ value = (attributes != null) ? attributes.remove(name) : null;
+ }
+
+ // If no value was bound under this name it's a no-op.
+ if (value == null)
+ return;
+
+ notifyAttributeUnbound(name, value);
+ notifyAttributeRemoved(name, value);
+ }
+
+ /**
+ * Removes a session attribute listener.
+ *
+ * @param listener The listener to remove.
+ */
+ public void removeSessionAttributeListener(FlexSessionAttributeListener listener)
+ {
+ // No need to check validity; removing a listener is always ok.
+ if (listener != null && attributeListeners != null)
+ attributeListeners.remove(listener);
+ }
+
+ /**
+ * Removes a session destroy listener.
+ *
+ * @see flex.messaging.FlexSessionListener
+ *
+ * @param listener The listener to remove.
+ */
+ public void removeSessionDestroyedListener(FlexSessionListener listener)
+ {
+ // No need to check validity; removing a listener is always ok.
+ if (listener != null && destroyedListeners != null)
+ destroyedListeners.remove(listener);
+ }
+
+ /**
+ * Binds an attribute value to the session under the specified name.
+ *
+ * @param name The name to bind the attribute under.
+ * @param value The value of the attribute.
+ */
+ public void setAttribute(String name, Object value)
+ {
+ // Null value is the same as removeAttribute().
+ if (value == null)
+ {
+ removeAttribute(name);
+ return;
+ }
+
+ Object oldValue; // Used to determine which events to dispatch after the set is performed.
+
+ // Only synchronize for the attribute mutation; event dispatch doesn't require it.
+ synchronized (lock)
+ {
+ checkValid(); // Re-enters lock but should be fast because we're already holding it.
+
+ if (attributes == null)
+ attributes = new HashMap<String, Object>();
+
+ oldValue = attributes.put(name, value);
+ }
+
+ if (oldValue == null)
+ {
+ notifyAttributeBound(name, value);
+ notifyAttributeAdded(name, value);
+ }
+ else
+ {
+ notifyAttributeUnbound(name, oldValue);
+ notifyAttributeReplaced(name, oldValue);
+ notifyAttributeBound(name, value);
+ }
+ }
+
+ /**
+ * Stores remote credentials in the session for proxied calls to remote systems.
+ *
+ * @param credentials The remote credentials.
+ */
+ public void putRemoteCredentials(FlexRemoteCredentials credentials)
+ {
+ if (credentials != null)
+ {
+ // We only need to hold the lock to lazy-init the remoteCredentials variable.
+ if (remoteCredentials == null)
+ {
+ synchronized (lock)
+ {
+ // Init size to 4 because that's the number of shipping service types
+ // (messaging, remoting, proxy, data management).
+ if (remoteCredentials == null)
+ remoteCredentials = new HashMap(4);
+ }
+ }
+ synchronized (remoteCredentials)
+ {
+ Map serviceMap = (Map)remoteCredentials.get(credentials.getService());
+ if (serviceMap == null)
+ {
+ // Init size to half the normal number of buckets; most services won't have a large
+ // number of destinations with remote credentials.
+ serviceMap = new HashMap(7);
+ remoteCredentials.put(credentials.getService(), serviceMap);
+ }
+ serviceMap.put(credentials.getDestination(), credentials);
+ }
+ }
+ }
+
+ /**
+ * Returns the remote credentials stored in the session for the specified service destination.
+ *
+ * @param serviceId The service id.
+ * @param destinationId The destination id.
+ * @return The stored remote credentials for the specified service destination.
+ */
+ public FlexRemoteCredentials getRemoteCredentials(String serviceId, String destinationId)
+ {
+ if (serviceId != null && destinationId != null)
+ {
+ if (remoteCredentials == null)
+ return null;
+ synchronized (remoteCredentials)
+ {
+ Map serviceMap = (Map)remoteCredentials.get(serviceId);
+ return (serviceMap != null) ? (FlexRemoteCredentials)serviceMap.get(destinationId) : null;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Clears any stored remote credentials from the session for the specified service destination.
+ *
+ * @param serviceId The service Id.
+ * @param destinationId The destination Id.
+ */
+ public void clearRemoteCredentials(String serviceId, String destinationId)
+ {
+ if (serviceId != null && destinationId != null)
+ {
+ if (remoteCredentials == null)
+ return;
+ synchronized (remoteCredentials)
+ {
+ Map serviceMap = (Map)remoteCredentials.get(serviceId);
+ if (serviceMap != null)
+ {
+ serviceMap.put(destinationId, null);
+ }
+ }
+ }
+ }
+
+ /**
+ * Invalidates the FlexSession.
+ */
+ public void invalidate()
+ {
+ synchronized (lock)
+ {
+ if (!valid || invalidating)
+ return; // Already shutting down.
+
+ invalidating = true; // This thread gets to shut the FlexSession down.
+ cancelTimeout();
+ if (sessionProvider != null)
+ sessionProvider.removeFlexSession(this);
+ }
+
+ // Unregister all FlexClients.
+ if (!flexClients.isEmpty())
+ {
+ for (FlexClient flexClient : flexClients)
+ unregisterFlexClient(flexClient);
+ }
+
+ // Invalidate associated MessageClient subscriptions.
+ if (messageClients != null && !messageClients.isEmpty())
+ {
+ for (Iterator<MessageClient> iter = messageClients.iterator(); iter.hasNext();)
+ {
+ MessageClient messageClient = iter.next();
+ messageClient.removeMessageClientDestroyedListener(this);
+ messageClient.invalidate();
+ }
+ messageClients.clear();
+ }
+
+
+ // Notify destroy listeners that we're shutting the FlexSession down.
+ if (destroyedListeners != null && !destroyedListeners.isEmpty())
+ {
+ for (FlexSessionListener destroyListener : destroyedListeners)
+ {
+ destroyListener.sessionDestroyed(this);
+ }
+ destroyedListeners.clear();
+ }
+
+ // Unbind all attributes.
+ if (attributes != null && !attributes.isEmpty())
+ {
+ Set<String> keySet = attributes.keySet();
+ String[] keys = keySet.toArray(new String[keySet.size()]);
+ for (String key : keys)
+ removeAttribute(key);
+
+ attributes = null;
+ }
+
+ internalInvalidate();
+
+ synchronized (lock)
+ {
+ valid = false;
+ invalidating = false;
+ }
+
+ // Notify any waiting threads.
+ if (waitMonitor != null)
+ {
+ for (FlexClient.EndpointQueue endpointQueue : waitMonitor.values())
+ {
+ synchronized (endpointQueue)
+ {
+ endpointQueue.notifyAll();
+ }
+ }
+ }
+ }
+
+ /**
+ * Hook for subclasses to perform any custom shutdown.
+ * Invoked after the FlexSession has performed generic shutdown but right before the session's valid
+ * property flips to false.
+ */
+ protected void internalInvalidate() {}
+
+ /**
+ * Returns a snapshot of the FlexClients associated with the FlexSession
+ * when this method is invoked.
+ * This list is not guaranteed to remain consistent with the actual list
+ * of active FlexClients associated with the FlexSession over time.
+ *
+ * @return A snapshot of the current list of FlexSessions associated with the FlexClient.
+ */
+ public List<FlexClient> getFlexClients()
+ {
+ List<FlexClient> currentFlexClients = null;
+ synchronized (lock)
+ {
+ checkValid(); // Re-enters lock but should be fast because we're already holding it.
+
+ currentFlexClients = new ArrayList<FlexClient>(flexClients); // Make a copy of the current list to return.
+ }
+ return currentFlexClients;
+ }
+
+ /**
+ * Returns a snapshot of the MessageClients (subscriptions) associated with the FlexSession
+ * when this method is invoked.
+ * This list is not guaranteed to remain consistent with the actual list
+ * of active MessageClients associated with the FlexSession over time.
+ *
+ * @return A snapshot of the current list of MessageClients associated with the FlexSession.
+ */
+ public List<MessageClient> getMessageClients()
+ {
+ List<MessageClient> currentMessageClients = null;
+ synchronized (lock)
+ {
+ checkValid(); // Re-enters lock but should be fast because we're already holding it.
+
+ currentMessageClients = (messageClients != null) ? new ArrayList<MessageClient>(messageClients) // Make a copy of the current list to return.
+ : new ArrayList<MessageClient>(); // Return an empty list.
+ }
+ return currentMessageClients;
+ }
+
+ /**
+ * Returns the Id for the session.
+ *
+ * @return The Id for the session.
+ */
+ public abstract String getId();
+
+ /**
+ * Returns whether the current user is in the specified role.
+ *
+ * @param role The role to test.
+ * @return true if the user is in the role; otherwise false.
+ */
+ public boolean isUserInRole(String role)
+ {
+ ArrayList list = new ArrayList();
+ list.add(role);
+ return FlexContext.getMessageBroker().getLoginManager().checkRoles(userPrincipal, list);
+ }
+
+ /**
+ * Returns whether the session is valid.
+ *
+ * @return true if the session is valid; otherwise false.
+ */
+ public boolean isValid()
+ {
+ synchronized (lock)
+ {
+ return valid;
+ }
+ }
+
+ /**
+ * @exclude
+ * Implements FlexClientListener interface.
+ * Notification that a FlexClient was created.
+ * This is a no-op because the FlexSession is never added as a static FlexClient created listener
+ * but this method is required by the interface. We only listen for the destroyed event from
+ * associated FlexClients.
+ *
+ * @param flexClient The FlexClient that was created.
+ */
+ public void clientCreated(FlexClient flexClient) {}
+
+ /**
+ * @exclude
+ * Implements FlexClientListener interface.
+ * Notification that an associated FlexClient was destroyed.
+ *
+ * @param flexClient The FlexClient that was destroyed.
+ */
+ public void clientDestroyed(FlexClient flexClient)
+ {
+ unregisterFlexClient(flexClient);
+ }
+
+ /**
+ * @exclude
+ * Used internally to associate a FlexClient with the FlexSession.
+ *
+ * @param flexClient The FlexClient to assocaite with the session.
+ */
+ public void registerFlexClient(FlexClient flexClient)
+ {
+ if (flexClients.addIfAbsent(flexClient))
+ {
+ flexClient.addClientDestroyedListener(this);
+ flexClient.registerFlexSession(this);
+ }
+ }
+
+ /**
+ * @exclude
+ * Used internally to disassociate a FlexClient from the FlexSession.
+ *
+ * @param flexClient The FlexClient to disassociate from the session.
+ */
+ public void unregisterFlexClient(FlexClient flexClient)
+ {
+ if (flexClients.remove(flexClient))
+ {
+ flexClient.removeClientDestroyedListener(this);
+ flexClient.unregisterFlexSession(this);
+ }
+ }
+
+ /**
+ * @exclude
+ * Used internally to associate a MessagClient (subscription) with the FlexSession.
+ *
+ * @param messageClient The MessageClient to associate with the session.
+ */
+ public void registerMessageClient(MessageClient messageClient)
+ {
+ if (messageClients == null)
+ {
+ synchronized (lock)
+ {
+ if (messageClients == null)
+ messageClients = new CopyOnWriteArrayList<MessageClient>();
+ }
+ }
+
+ if (messageClients.addIfAbsent(messageClient))
+ messageClient.addMessageClientDestroyedListener(this);
+ }
+
+ /**
+ * @exclude
+ * Used internally to disassociate a MessageClient (subscription) from a FlexSession.
+ *
+ * @param messageClient The MessageClient to disassociate from the session.
+ */
+ public void unregisterMessageClient(MessageClient messageClient)
+ {
+ if (messageClients != null && messageClients.remove(messageClient))
+ messageClient.removeMessageClientDestroyedListener(this);
+ }
+
+ /**
+ * Default implementation invokes <code>invalidate()</code> upon timeout.
+ *
+ * @see flex.messaging.util.TimeoutCapable#timeout()
+ */
+ public void timeout()
+ {
+ invalidate();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Protected Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Ensures that the session has not been invalidated.
+ */
+ protected void checkValid()
+ {
+ synchronized (lock)
+ {
+ if (!valid)
+ {
+ LocalizedException e = new LocalizedException();
+ e.setMessage(FLEX_SESSION_INVALIDATED);
+ throw e;
+ }
+ }
+ }
+
+ /**
+ * Notify attribute listeners that an attribute has been added.
+ *
+ * @param name The name of the attribute.
+ * @param value The new value of the attribute.
+ */
+ protected void notifyAttributeAdded(String name, Object value)
+ {
+ if (attributeListeners != null && !attributeListeners.isEmpty())
+ {
+ FlexSessionBindingEvent event = new FlexSessionBindingEvent(this, name, value);
+ // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
+ for (FlexSessionAttributeListener attribListener : attributeListeners)
+ attribListener.attributeAdded(event);
+ }
+ }
+
+ /**
+ * Notify binding listener that it has been bound to the session.
+ *
+ * @param name The attribute name.
+ * @param value The attribute that has been bound.
+ */
+ protected void notifyAttributeBound(String name, Object value)
+ {
+ if ((value != null) && (value instanceof FlexSessionBindingListener))
+ {
+ FlexSessionBindingEvent bindingEvent = new FlexSessionBindingEvent(this, name);
+ ((FlexSessionBindingListener)value).valueBound(bindingEvent);
+ }
+ }
+
+ /**
+ * Notify attribute listeners that an attribute has been removed.
+ *
+ * @param name The name of the attribute.
+ * @param value The previous value of the attribute.
+ */
+ protected void notifyAttributeRemoved(String name, Object value)
+ {
+ if (attributeListeners != null && !attributeListeners.isEmpty())
+ {
+ FlexSessionBindingEvent event = new FlexSessionBindingEvent(this, name, value);
+ // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
+ for (FlexSessionAttributeListener attribListener : attributeListeners)
+ attribListener.attributeRemoved(event);
+ }
+ }
+
+ /**
+ * Notify attribute listeners that an attribute has been replaced.
+ *
+ * @param name The name of the attribute.
+ * @param value The previous value of the attribute.
+ */
+ protected void notifyAttributeReplaced(String name, Object value)
+ {
+ if (attributeListeners != null && !attributeListeners.isEmpty())
+ {
+ FlexSessionBindingEvent event = new FlexSessionBindingEvent(this, name, value);
+ // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
+ for (FlexSessionAttributeListener attribListener : attributeListeners)
+ attribListener.attributeReplaced(event);
+ }
+ }
+
+ /**
+ * Notify binding listener that it has been unbound from the session.
+ *
+ * @param name The attribute name.
+ * @param value The attribute that has been unbound.
+ */
+ protected void notifyAttributeUnbound(String name, Object value)
+ {
+ if ((value != null) && (value instanceof FlexSessionBindingListener))
+ {
+ FlexSessionBindingEvent bindingEvent = new FlexSessionBindingEvent(this, name);
+ ((FlexSessionBindingListener)value).valueUnbound(bindingEvent);
+ }
+ }
+
+ /**
+ * Invoked by subclass upon session creation to notify all registered
+ * session create listeners of the event.
+ * This method must be invoked in the subclass constructor.
+ */
+ protected void notifyCreated()
+ {
+ // This guard is here only to prevent duplicate notifications if there's a coding error
+ // in the subclass. Not likely..
+ synchronized (lock)
+ {
+ if (creationNotified)
+ return;
+
+ creationNotified = true;
+ }
+
+ if (!createdListeners.isEmpty())
+ {
+ // CopyOnWriteArrayList is iteration-safe from ConcurrentModificationExceptions.
+ for (Iterator<FlexSessionListener> iter = createdListeners.iterator(); iter.hasNext();)
+ iter.next().sessionCreated(this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexSessionAttributeListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexSessionAttributeListener.java b/modules/core/src/flex/messaging/FlexSessionAttributeListener.java
old mode 100755
new mode 100644
index b889d67..feba243
--- a/modules/core/src/flex/messaging/FlexSessionAttributeListener.java
+++ b/modules/core/src/flex/messaging/FlexSessionAttributeListener.java
@@ -1,47 +1,47 @@
-/*
- * 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;
-
-/**
- * Interface for Flex session attribute listeners.
- */
-public interface FlexSessionAttributeListener
-{
- /**
- * Callback invoked after an attribute is added to the session.
- *
- * @param event The event containing the associated session and attribute
- * information.
- */
- void attributeAdded(FlexSessionBindingEvent event);
-
- /**
- * Callback invoked after an attribute is removed from the session.
- *
- * @param event The event containing the associated session and attribute
- * information.
- */
- void attributeRemoved(FlexSessionBindingEvent event);
-
- /**
- * Callback invoked after an attribute has been replaced with a new value.
- *
- * @param event The event containing the associated session and attribute
- * information.
- */
- void attributeReplaced(FlexSessionBindingEvent event);
-}
+/*
+ * 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;
+
+/**
+ * Interface for Flex session attribute listeners.
+ */
+public interface FlexSessionAttributeListener
+{
+ /**
+ * Callback invoked after an attribute is added to the session.
+ *
+ * @param event The event containing the associated session and attribute
+ * information.
+ */
+ void attributeAdded(FlexSessionBindingEvent event);
+
+ /**
+ * Callback invoked after an attribute is removed from the session.
+ *
+ * @param event The event containing the associated session and attribute
+ * information.
+ */
+ void attributeRemoved(FlexSessionBindingEvent event);
+
+ /**
+ * Callback invoked after an attribute has been replaced with a new value.
+ *
+ * @param event The event containing the associated session and attribute
+ * information.
+ */
+ void attributeReplaced(FlexSessionBindingEvent event);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexSessionBindingEvent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexSessionBindingEvent.java b/modules/core/src/flex/messaging/FlexSessionBindingEvent.java
old mode 100755
new mode 100644
index 872fa9c..512c7a9
--- a/modules/core/src/flex/messaging/FlexSessionBindingEvent.java
+++ b/modules/core/src/flex/messaging/FlexSessionBindingEvent.java
@@ -1,114 +1,114 @@
-/*
- * 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;
-
-/**
- * Event used to notify FlexSessionAttributeListeners of changes to session
- * attributes.
- */
-public class FlexSessionBindingEvent
-{
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructs an event for an attribute that is bound or unbound from a session.
- *
- * @param session The associated session.
- * @param name The attribute name.
- */
- public FlexSessionBindingEvent(FlexSession session, String name)
- {
- this.session = session;
- this.name = name;
- }
-
- /**
- * Constructs an event for an attribute that is added to a session or
- * replaced by a new value.
- *
- * @param session The associated session.
- * @param name The attribute name.
- * @param value The attribute value.
- */
- public FlexSessionBindingEvent(FlexSession session, String name, Object value)
- {
- this.session = session;
- this.name = name;
- this.value = value;
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * The session that generated the event.
- */
- private FlexSession session;
-
- /**
- * The name of the attribute associated with the event.
- */
- private String name;
-
- /**
- * The value of the attribute associated with the event.
- */
- private Object value;
-
- //--------------------------------------------------------------------------
- //
- // Methods
- //
- //--------------------------------------------------------------------------
-
- /**
- * Returns the Flex session that generated the event.
- *
- * @return The Flex session that generated the event.
- */
- public FlexSession getSession()
- {
- return session;
- }
-
- /**
- * Returns the name of the attribute associated with the event.
- *
- * @return The name of the attribute associated with the event.
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Returns the value of the attribute associated with the event.
- *
- * @return The value of the attribute associated with the event.
- */
- public Object getValue()
- {
- return value;
- }
-}
+/*
+ * 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;
+
+/**
+ * Event used to notify FlexSessionAttributeListeners of changes to session
+ * attributes.
+ */
+public class FlexSessionBindingEvent
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructs an event for an attribute that is bound or unbound from a session.
+ *
+ * @param session The associated session.
+ * @param name The attribute name.
+ */
+ public FlexSessionBindingEvent(FlexSession session, String name)
+ {
+ this.session = session;
+ this.name = name;
+ }
+
+ /**
+ * Constructs an event for an attribute that is added to a session or
+ * replaced by a new value.
+ *
+ * @param session The associated session.
+ * @param name The attribute name.
+ * @param value The attribute value.
+ */
+ public FlexSessionBindingEvent(FlexSession session, String name, Object value)
+ {
+ this.session = session;
+ this.name = name;
+ this.value = value;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The session that generated the event.
+ */
+ private FlexSession session;
+
+ /**
+ * The name of the attribute associated with the event.
+ */
+ private String name;
+
+ /**
+ * The value of the attribute associated with the event.
+ */
+ private Object value;
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns the Flex session that generated the event.
+ *
+ * @return The Flex session that generated the event.
+ */
+ public FlexSession getSession()
+ {
+ return session;
+ }
+
+ /**
+ * Returns the name of the attribute associated with the event.
+ *
+ * @return The name of the attribute associated with the event.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the value of the attribute associated with the event.
+ *
+ * @return The value of the attribute associated with the event.
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/FlexSessionBindingListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/FlexSessionBindingListener.java b/modules/core/src/flex/messaging/FlexSessionBindingListener.java
old mode 100755
new mode 100644
index 426f852..3c9b98e
--- a/modules/core/src/flex/messaging/FlexSessionBindingListener.java
+++ b/modules/core/src/flex/messaging/FlexSessionBindingListener.java
@@ -1,40 +1,40 @@
-/*
- * 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;
-
-/**
- * Interface to be notified when the object is bound or unbound from the Flex
- * session.
- */
-public interface FlexSessionBindingListener
-{
- /**
- * Callback invoked when the object is bound to a Flex session.
- *
- * @param event The event containing the associated session and attribute
- * information.
- */
- void valueBound(FlexSessionBindingEvent event);
-
- /**
- * Callback invoked when the object is unbound from a Flex session.
- *
- * @param event The event containing the associated session and attribute
- * information.
- */
- void valueUnbound(FlexSessionBindingEvent event);
-}
+/*
+ * 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;
+
+/**
+ * Interface to be notified when the object is bound or unbound from the Flex
+ * session.
+ */
+public interface FlexSessionBindingListener
+{
+ /**
+ * Callback invoked when the object is bound to a Flex session.
+ *
+ * @param event The event containing the associated session and attribute
+ * information.
+ */
+ void valueBound(FlexSessionBindingEvent event);
+
+ /**
+ * Callback invoked when the object is unbound from a Flex session.
+ *
+ * @param event The event containing the associated session and attribute
+ * information.
+ */
+ void valueUnbound(FlexSessionBindingEvent event);
+}
[03/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run
on Windows machines - Added some mkdir commands to the ANT Build.java - Did
some fine-tuning to resolve some compile errors
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/BeanProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/BeanProxy.java b/modules/core/src/flex/messaging/io/BeanProxy.java
old mode 100755
new mode 100644
index f15c642..1774b69
--- a/modules/core/src/flex/messaging/io/BeanProxy.java
+++ b/modules/core/src/flex/messaging/io/BeanProxy.java
@@ -1,940 +1,940 @@
-/*
- * 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.io;
-
-import flex.messaging.MessageException;
-import flex.messaging.io.amf.ASObject;
-import flex.messaging.log.Log;
-import flex.messaging.log.Logger;
-import flex.messaging.util.ClassUtil;
-import flex.messaging.util.ExceptionUtil;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.io.File;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.AbstractCollection;
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.IdentityHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-/**
- * Uses Bean introspection to collect the properties for a given instance.
- *
- * @author Peter Farland
- */
-public class BeanProxy extends AbstractProxy
-{
- static final long serialVersionUID = 7365078101695257715L;
-
- private static final int FAILED_PROPERTY_READ_ERROR = 10021;
- private static final int FAILED_PROPERTY_WRITE_ERROR = 10022;
- private static final int NON_READABLE_PROPERTY_ERROR = 10023;
- private static final int NON_WRITABLE_PROPERTY_ERROR = 10024;
- private static final int UNKNOWN_PROPERTY_ERROR = 10025;
-
- protected static final Map<Class, List<String>> rwPropertyNamesCache = new IdentityHashMap<Class, List<String>>();
- protected static final Map<Class, Map<String, BeanProperty>> rwBeanPropertyCache = new IdentityHashMap<Class, Map<String, BeanProperty>>();
- protected static final Map<Class, PropertyDescriptorCacheEntry> rwPropertyDescriptorCache = new IdentityHashMap<Class, PropertyDescriptorCacheEntry>();
-
- protected static final Map<Class, List<String>> roPropertyNamesCache = new IdentityHashMap<Class, List<String>>();
- protected static final Map<Class, Map<String, BeanProperty>> roBeanPropertyCache = new IdentityHashMap<Class, Map<String, BeanProperty>>();
- protected static final Map<Class, PropertyDescriptorCacheEntry> roPropertyDescriptorCache = new IdentityHashMap<Class, PropertyDescriptorCacheEntry>();
-
- protected boolean cacheProperties = true;
- protected boolean cachePropertiesDescriptors = true;
- protected Class stopClass = Object.class;
-
- protected static final Map ignoreProperties = new HashMap();
- static
- {
- initializeIgnoreProperties();
- }
-
- private static void initializeIgnoreProperties()
- {
- addIgnoreProperty(AbstractMap.class, "empty");
- addIgnoreProperty(AbstractCollection.class, "empty");
- addIgnoreProperty(ASObject.class, "type");
- addIgnoreProperty(Throwable.class, "stackTrace");
- addIgnoreProperty(File.class, "parentFile");
- addIgnoreProperty(File.class, "canonicalFile");
- addIgnoreProperty(File.class, "absoluteFile");
- }
-
- /**
- * Constructor.
- */
- public BeanProxy()
- {
- this(null);
- }
-
- /**
- * Construct a new BeanProxy with the provided default instance.
- *
- * @param defaultInstance defines the alias if provided
- */
- public BeanProxy(Object defaultInstance)
- {
- super(defaultInstance);
-
- // Override default behavior here... standard Map implementations
- // are treated as anonymous Objects, i.e. without an alias.
- if (defaultInstance != null)
- alias = getClassName(defaultInstance);
- }
-
- /** {@inheritDoc} */
- public String getAlias(Object instance)
- {
- return getClassName(instance);
- }
-
- /** {@inheritDoc} */
- public List getPropertyNames(Object instance)
- {
- if (instance == null)
- return null;
-
- Class c = instance.getClass();
- List<String> propertyNames = null;
-
- // Look up property names in cache if we don't have a custom serialization descriptor
- if (descriptor == null)
- {
- if (getIncludeReadOnly())
- {
- synchronized (roPropertyNamesCache)
- {
- propertyNames = roPropertyNamesCache.get(c);
- }
- }
- else
- {
- synchronized (rwPropertyNamesCache)
- {
- propertyNames = rwPropertyNamesCache.get(c);
- }
- }
- }
-
- if (propertyNames != null)
- return propertyNames;
-
- // Make a copy of the property names to return
- propertyNames = new ArrayList<String>(getBeanProperties(instance).keySet());
-
- // Store property names in cache if we are caching properties
- // and we don't have a custom serialization descriptor
- if (cacheProperties && descriptor == null)
- {
- if (getIncludeReadOnly())
- {
- synchronized (roPropertyNamesCache)
- {
- roPropertyNamesCache.put(c, propertyNames);
- }
- }
- else
- {
- synchronized (rwPropertyNamesCache)
- {
- rwPropertyNamesCache.put(c, propertyNames);
- }
- }
- }
- return propertyNames;
- }
-
-
- /** {@inheritDoc} */
- public Class getType(Object instance, String propertyName)
- {
- if (instance == null || propertyName == null)
- return null;
-
- BeanProperty bp = getBeanProperty(instance, propertyName);
- return bp == null? null : bp.getType();
- }
-
- /** {@inheritDoc} */
- public Object getValue(Object instance, String propertyName)
- {
- if (instance == null || propertyName == null)
- return null;
-
- BeanProperty bp = getBeanProperty(instance, propertyName);
- if (bp != null)
- return getBeanValue(instance, bp);
-
- SerializationContext context = getSerializationContext();
- if (!ignorePropertyErrors(context))
- {
- // Property '{propertyName}' not found on class '{alias}'.
- MessageException ex = new MessageException();
- ex.setMessage(UNKNOWN_PROPERTY_ERROR, new Object[] {propertyName, getAlias(instance)});
- throw ex;
- }
- return null;
- }
-
- /**
- * Gets the value specified by the BeanProperty.
- * @param instance Object to get the value from
- * @param bp the property to get
- * @return the value of the property if it exists
- */
- protected final Object getBeanValue(Object instance, BeanProperty bp)
- {
- String propertyName = bp.getName();
- if (bp.isRead())
- {
- try
- {
- Object value = bp.get(instance);
- if (value != null && descriptor != null)
- {
- SerializationDescriptor subDescriptor = (SerializationDescriptor)descriptor.get(propertyName);
- if (subDescriptor != null)
- {
- PropertyProxy subProxy = PropertyProxyRegistry.getProxyAndRegister(value);
- subProxy = (PropertyProxy)subProxy.clone();
- subProxy.setDescriptor(subDescriptor);
- subProxy.setDefaultInstance(value);
- value = subProxy;
- }
- }
- return value;
- }
- catch (Exception e)
- {
- SerializationContext context = getSerializationContext();
-
- // Log failed property set errors
- if (Log.isWarn() && logPropertyErrors(context))
- {
- Logger log = Log.getLogger(LOG_CATEGORY);
- log.warn("Failed to get property {0} on type {1}.",
- new Object[] {propertyName, getAlias(instance)}, e);
- }
-
- if (!ignorePropertyErrors(context))
- {
- // Failed to get property '{propertyName}' on type '{className}'.
- MessageException ex = new MessageException();
- ex.setMessage(FAILED_PROPERTY_READ_ERROR, new Object[] {propertyName, getAlias(instance)});
- ex.setRootCause(e);
- throw ex;
- }
- }
- }
- else
- {
- SerializationContext context = getSerializationContext();
- if (!ignorePropertyErrors(context))
- {
- //Property '{propertyName}' not readable from class '{alias}'.
- MessageException ex = new MessageException();
- ex.setMessage(NON_READABLE_PROPERTY_ERROR, new Object[] {propertyName, getAlias(instance)});
- throw ex;
- }
- }
- return null;
- }
-
- /** {@inheritDoc} */
- public void setValue(Object instance, String propertyName, Object value)
- {
- BeanProperty bp = getBeanProperty(instance, propertyName);
-
- if (bp != null)
- {
- if (bp.isWrite())
- {
- try
- {
- Class desiredPropClass = bp.getType();
- TypeMarshaller marshaller = TypeMarshallingContext.getTypeMarshaller();
- value = marshaller.convert(value, desiredPropClass);
- ClassUtil.validateAssignment(instance, propertyName, value);
- bp.set(instance, value);
- }
- catch (Exception e)
- {
- SerializationContext context = getSerializationContext();
-
- // Log ignore failed property set errors
- if (Log.isWarn() && logPropertyErrors(context))
- {
- Logger log = Log.getLogger(LOG_CATEGORY);
- log.warn("Failed to set property {0} on type {1}.",
- new Object[] {propertyName, getAlias(instance)}, e);
- }
-
- if (!ignorePropertyErrors(context))
- {
- // Failed to get property '{propertyName}' on type '{className}'.
- MessageException ex = new MessageException();
- ex.setMessage(FAILED_PROPERTY_WRITE_ERROR, new Object[] {propertyName, getAlias(instance)});
- ex.setRootCause(e);
- throw ex;
- }
- }
- }
- else
- {
- SerializationContext context = getSerializationContext();
-
- if (Log.isWarn() && logPropertyErrors(context))
- {
- Logger log = Log.getLogger(LOG_CATEGORY);
- log.warn("Property {0} not writable on class {1}",
- new Object[] {propertyName, getAlias(instance)});
- }
-
- if (!ignorePropertyErrors(context))
- {
- //Property '{propertyName}' not writable on class '{alias}'.
- MessageException ex = new MessageException();
- ex.setMessage(NON_WRITABLE_PROPERTY_ERROR, new Object[] {propertyName, getAlias(instance)});
- throw ex;
- }
- }
- }
- else
- {
- SerializationContext context = getSerializationContext();
-
- if (Log.isWarn() && logPropertyErrors(context))
- {
- Logger log = Log.getLogger(LOG_CATEGORY);
- log.warn("Ignoring set property {0} for type {1} as a setter could not be found.",
- new Object[] {propertyName, getAlias(instance)});
- }
-
- if (!ignorePropertyErrors(context))
- {
- // Property '{propertyName}' not found on class '{alias}'.
- MessageException ex = new MessageException();
- ex.setMessage(UNKNOWN_PROPERTY_ERROR, new Object[] {propertyName, getAlias(instance)});
- throw ex;
- }
- }
- }
-
- /**
- * Are we ignoring property errors?
- * @param context serialization paramters.
- * @return true if ignoring property errors.
- */
- protected boolean ignorePropertyErrors(SerializationContext context)
- {
- return context.ignorePropertyErrors;
- }
-
- /**
- * Should we log property errors?
- * @param context serialization parameters.
- * @return true if we should log property errors.
- */
- protected boolean logPropertyErrors(SerializationContext context)
- {
- return context.logPropertyErrors;
- }
-
- /**
- * Determins the classname for both normal types via Class.getName() and
- * virtual types via ASObject.getType(). Virtual types starting
- * with the special ">" token are also handled and the underlying
- * className is returned.
- *
- * @param instance the object to examine.
- * @return the classname to use for instances of this type
- */
- protected String getClassName(Object instance)
- {
- String className;
-
- if (instance instanceof ASObject)
- {
- className = ((ASObject)instance).getType();
- }
- else if (instance instanceof ClassAlias)
- {
- className = ((ClassAlias)instance).getAlias();
- }
- else
- {
- className = instance.getClass().getName();
- // If there's an alias, use that as the class name.
- ClassAliasRegistry registry = ClassAliasRegistry.getRegistry();
- String aliasedClass = registry.getClassName(className);
- className = (aliasedClass == null)? className : aliasedClass;
- }
-
- return className;
- }
-
- /**
- * Return a map of properties for a object.
- * @param instance object to examine.
- * @return a map of Strings to BeanProperty objects.
- */
- protected Map<String, BeanProperty> getBeanProperties(Object instance)
- {
- Class c = instance.getClass();
- Map<String, BeanProperty> props;
-
- // look up instance class in cache if we don't have a custom descriptor.
- if (descriptor == null)
- {
- if (getIncludeReadOnly())
- {
- synchronized (roBeanPropertyCache)
- {
- props = roBeanPropertyCache.get(c);
- }
- }
- else
- {
- synchronized (rwBeanPropertyCache)
- {
- props = roBeanPropertyCache.get(c);
-
- }
- }
- if (props != null)
- return props;
- }
-
- props = new HashMap<String, BeanProperty>();
- PropertyDescriptor[] pds = getPropertyDescriptors(c);
- if (pds == null)
- return null;
-
- List excludes = null;
- if (descriptor != null)
- {
- excludes = descriptor.getExcludesForInstance(instance);
- if (excludes == null) // For compatibility with older implementations
- excludes = descriptor.getExcludes();
- }
-
- // Add standard bean properties first
- for (PropertyDescriptor pd : pds)
- {
- String propertyName = pd.getName();
- Method readMethod = pd.getReadMethod();
- Method writeMethod = pd.getWriteMethod();
-
- // If there's a public read method but no writeMethod and includeReadOnly
- // flag is off, then skip the property.
- if (readMethod != null && isPublicAccessor(readMethod.getModifiers()) && !getIncludeReadOnly() && writeMethod == null)
- continue;
-
- // Skip excluded and ignored properties as well.
- if ((excludes != null && excludes.contains(propertyName)) || isPropertyIgnored(c, propertyName))
- continue;
-
- // Ensure we don't include Object getClass() property, possibly returned (incorrectly) by custom BeanInfos
- if (getIncludeReadOnly() && writeMethod == null && "class".equals(propertyName))
- continue;
-
- // Skip any classloader properties
- final Class<?> type = pd.getPropertyType();
- if (type != null && ClassLoader.class.isAssignableFrom(type))
- continue;
-
- props.put(propertyName, new BeanProperty(propertyName, pd.getPropertyType(),
- readMethod, writeMethod, null));
- }
-
- // Then add public fields to list if property does not already exist
- Field[] fields = instance.getClass().getFields();
- for (Field field : fields)
- {
- String propertyName = field.getName();
- int modifiers = field.getModifiers();
- if (isPublicField(modifiers) && !props.containsKey(propertyName))
- {
- // Skip excluded and ignored properties.
- if ((excludes != null && excludes.contains(propertyName)) || isPropertyIgnored(c, propertyName))
- continue;
-
- props.put(propertyName, new BeanProperty(propertyName, field.getType(), null, null, field));
- }
- }
-
- // Update the cache if we don't have a custom serialization descriptor and we are caching.
- if (descriptor == null && cacheProperties)
- {
- if (getIncludeReadOnly())
- {
- synchronized (roBeanPropertyCache)
- {
- roBeanPropertyCache.put(c, props);
- }
- }
- else
- {
- synchronized (rwBeanPropertyCache)
- {
- roBeanPropertyCache.put(c, props);
-
- }
- }
- }
-
- return props;
- }
-
- /**
- * Return true if this property is write only, which means we cannot get a value for it.
- *
- * @param instance the instance
- * @param propertyName the property name
- * @return true if there is a way to write but not read the property
- */
- public boolean isWriteOnly(Object instance, String propertyName)
- {
- if (instance == null || propertyName == null)
- return false;
-
- BeanProperty bp = getBeanProperty(instance, propertyName);
- return bp != null && bp.isWrite() && !bp.isRead();
- }
-
- /**
- * Return a specific property descriptor for a named property.
- * @param instance the object to use.
- * @param propertyName the property to get.
- * @return a descriptor for the property.
- */
- protected final BeanProperty getBeanProperty(Object instance, String propertyName)
- {
- Class c = instance.getClass();
- Map props;
-
- // It is faster to use the BeanProperty cache if we are going to cache it.
- if (descriptor == null && cacheProperties)
- {
- props = getBeanProperties(instance);
- return props == null? null : (BeanProperty)props.get(propertyName);
- }
-
- // Otherwise, just build up the property we are asked for
- PropertyDescriptorCacheEntry pce = getPropertyDescriptorCacheEntry(c);
- if (pce == null)
- return null;
-
- Object pType = pce.propertiesByName.get(propertyName);
- if (pType == null)
- return null;
-
- List excludes = null;
- if (descriptor != null)
- {
- excludes = descriptor.getExcludesForInstance(instance);
- if (excludes == null) // For compatibility with older implementations
- excludes = descriptor.getExcludes();
- }
-
- if (pType instanceof PropertyDescriptor)
- {
- PropertyDescriptor pd = (PropertyDescriptor) pType;
-
- Method readMethod = pd.getReadMethod();
- Method writeMethod = pd.getWriteMethod();
-
- // If there's a public read method but no writeMethod and includeReadOnly
- // flag is off, then skip the property.
- if (readMethod != null && isPublicAccessor(readMethod.getModifiers()) && !getIncludeReadOnly() && writeMethod == null)
- return null;
-
- // Skip excluded and ignored properties as well.
- if ((excludes != null && excludes.contains(propertyName)) || isPropertyIgnored(c, propertyName))
- return null;
-
- return new BeanProperty(propertyName, pd.getPropertyType(), readMethod, writeMethod, null);
- }
- else if (pType instanceof Field)
- {
- Field field = (Field) pType;
-
- String pName = field.getName();
- int modifiers = field.getModifiers();
- if (isPublicField(modifiers) && pName.equals(propertyName))
- {
- // Skip excluded and ignored properties.
- return ((excludes != null && excludes.contains(propertyName)) || isPropertyIgnored(c, propertyName))?
- null : new BeanProperty(propertyName, field.getType(), null, null, field);
- }
- }
-
- return null;
- }
-
- /**
- * Return an array of JavaBean property descriptors for a class.
- * @param c the class to examine.
- * @return an array ot JavaBean PropertyDescriptors.
- */
- private PropertyDescriptor [] getPropertyDescriptors(Class c)
- {
- PropertyDescriptorCacheEntry pce = getPropertyDescriptorCacheEntry(c);
- return pce == null? null : pce.propertyDescriptors;
- }
-
- /**
- * Return an entry from the property descriptor cache for a class.
- * @param c the class
- * @return a descriptor cache entry or null
- */
- private PropertyDescriptorCacheEntry getPropertyDescriptorCacheEntry(Class c)
- {
- PropertyDescriptorCacheEntry pce;
- if (getIncludeReadOnly())
- {
- synchronized (roPropertyDescriptorCache)
- {
- pce = roPropertyDescriptorCache.get(c);
- }
- }
- else
- {
- synchronized (rwPropertyDescriptorCache)
- {
- pce = rwPropertyDescriptorCache.get(c);
- }
- }
-
- try
- {
- if (pce == null)
- {
- BeanInfo beanInfo = Introspector.getBeanInfo(c, stopClass);
- pce = new PropertyDescriptorCacheEntry();
- pce.propertyDescriptors = beanInfo.getPropertyDescriptors();
- pce.propertiesByName = createPropertiesByNameMap(pce.propertyDescriptors, c.getFields());
- if (cachePropertiesDescriptors)
- {
- if (getIncludeReadOnly())
- {
- synchronized (roPropertyDescriptorCache)
- {
- roPropertyDescriptorCache.put(c, pce);
- }
- }
- else
- {
- synchronized (rwPropertyDescriptorCache)
- {
- rwPropertyDescriptorCache.put(c, pce);
- }
- }
- }
- }
- }
- catch (IntrospectionException ex)
- {
- // Log failed property set errors
- if (Log.isError())
- {
- Logger log = Log.getLogger(LOG_CATEGORY);
- log.error("Failed to introspect object of type: " + c + " error: " + ExceptionUtil.toString(ex));
- }
-
- // Return an empty descriptor rather than crashing
- pce = new PropertyDescriptorCacheEntry();
- pce.propertyDescriptors = new PropertyDescriptor[0];
- pce.propertiesByName = new TreeMap();
- }
- return pce;
- }
-
- private Map createPropertiesByNameMap(PropertyDescriptor [] pds, Field [] fields)
- {
- Map m = new HashMap(pds.length);
- for (PropertyDescriptor pd : pds)
- {
- Method readMethod = pd.getReadMethod();
- if (readMethod != null && isPublicAccessor(readMethod.getModifiers()) &&
- (getIncludeReadOnly() || pd.getWriteMethod() != null))
- m.put(pd.getName(), pd);
- }
- for (Field field : fields)
- {
- if (isPublicField(field.getModifiers()) && !m.containsKey(field.getName()))
- m.put(field.getName(), field);
- }
- return m;
- }
-
- /**
- * Is this property on the ignore list for this class?
- * @param c the class.
- * @param propertyName the property name.
- * @return true if we should ignore this property.
- */
- public static boolean isPropertyIgnored(Class c, String propertyName)
- {
- boolean result = false;
- Set propertyOwners = (Set)ignoreProperties.get(propertyName);
- if (propertyOwners != null)
- {
- while (c != null)
- {
- if (propertyOwners.contains(c))
- {
- result = true;
- break;
- }
- c = c.getSuperclass();
- }
- }
- return result;
- }
-
- /**
- * Add a property to the ignore list for this class.
- * @param c the class.
- * @param propertyName the property to ignore.
- */
- public static void addIgnoreProperty(Class c, String propertyName)
- {
- synchronized(ignoreProperties)
- {
- Set propertyOwners = (Set)ignoreProperties.get(propertyName);
- if (propertyOwners == null)
- {
- propertyOwners = new HashSet();
- ignoreProperties.put(propertyName, propertyOwners);
- }
- propertyOwners.add(c);
- }
- }
-
- /**
- * Do the provided modifiers indicate that this is public?
- * @param modifiers the flags to check
- * @return true if public but not final, static or transient.
- */
- public static boolean isPublicField(int modifiers)
- {
- return (Modifier.isPublic(modifiers) && !Modifier.isFinal(modifiers)
- && !Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers));
- }
-
- /**
- * Do the provided modifiers indicate that this is public?
- * @param modifiers the flags to check
- * @return true if public but not static.
- */
- public static boolean isPublicAccessor(int modifiers)
- {
- return (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers));
- }
-
- /**
- * A class that holds information about a bean property.
- */
- protected static class BeanProperty
- {
- private String name;
- private Class type;
- private Method readMethod, writeMethod;
- private Field field;
-
- protected BeanProperty(String name, Class type, Method read, Method write, Field field)
- {
- this.name = name;
- this.type = type;
- this.writeMethod = write;
- this.readMethod = read;
- this.field = field;
- }
-
- /**
- * The name of the property..
- * @return the name.
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * The type of the property.
- * @return the type
- */
- public Class getType()
- {
- return type;
- }
-
- /**
- * Is there a setter for this property?
- * @return true if there is a write method.
- */
- public boolean isWrite()
- {
- return writeMethod != null || field != null;
- }
-
- /**
- * Is there a getter for this property?
- * @return true if there is a read method.
- */
- public boolean isRead()
- {
- return readMethod != null || field != null;
- }
-
- /**
- * Returns the Class object that declared the public field or getter function.
- * @return an object of the declaring class for the read method or null if the read method is undefined.
- */
- public Class getReadDeclaringClass()
- {
- if (readMethod != null)
- return readMethod.getDeclaringClass();
- if (field != null)
- return field.getDeclaringClass();
- return null;
- }
-
- /**
- * Return a class that represents the type of the property.
- * @return the type of the property or null if there is no read method defined.
- */
- public Class getReadType()
- {
- if (readMethod != null)
- return readMethod.getReturnType();
- if (field != null)
- return field.getType();
- return null;
- }
-
- /**
- *
- * Returns a string indicating the setter or field name of the property.
- * The setter is prefixed by 'method ', or the field is prefixed by 'field '.
- * @return A string suitable for debugging.
- */
- public String getWriteName()
- {
- if (writeMethod != null)
- return "method " + writeMethod.getName();
- if (field != null)
- return "field " + field.getName();
- return null;
- }
-
- /**
- * Set the property of the object to the specified value.
- * @param bean the bean to set the property on.
- * @param value the value to set.
- * @throws IllegalAccessException if no access.
- * @throws InvocationTargetException if the setter throws an exception.
- */
- public void set(Object bean, Object value) throws IllegalAccessException,
- InvocationTargetException
- {
- if (writeMethod != null)
- writeMethod.invoke(bean, value);
- else if (field != null)
- field.set(bean, value);
- else
- throw new MessageException("Setter not found for property " + name);
- }
-
- /**
- * Get the value of this property from the specified object.
- * @param bean the object to retrieve the value from
- * @return the value of the property.
- * @throws IllegalAccessException if no access.
- * @throws InvocationTargetException if the getter throws an exception.
- */
- public Object get(Object bean) throws IllegalAccessException, InvocationTargetException
- {
- Object obj = null;
- if (readMethod != null)
- obj = readMethod.invoke(bean, (Object[])null);
- else if (field != null)
- obj = field.get(bean);
- return obj;
- }
- }
-
- /**
- * Clears all static caches.
- */
- public static void clear()
- {
- synchronized(ignoreProperties)
- {
- ignoreProperties.clear();
- initializeIgnoreProperties(); // reset to original state
- }
- synchronized(rwPropertyNamesCache)
- {
- rwPropertyNamesCache.clear();
- }
- synchronized(rwBeanPropertyCache)
- {
- rwBeanPropertyCache.clear();
- }
- synchronized(rwPropertyDescriptorCache)
- {
- rwPropertyDescriptorCache.clear();
- }
- synchronized(roPropertyNamesCache)
- {
- roPropertyNamesCache.clear();
- }
- synchronized(roBeanPropertyCache)
- {
- roBeanPropertyCache.clear();
- }
- synchronized(roPropertyDescriptorCache)
- {
- roPropertyDescriptorCache.clear();
- }
- }
-
- /**
- * A cache entry.
- */
- protected static class PropertyDescriptorCacheEntry
- {
- PropertyDescriptor [] propertyDescriptors;
- Map propertiesByName;
- }
-}
+/*
+ * 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.io;
+
+import flex.messaging.MessageException;
+import flex.messaging.io.amf.ASObject;
+import flex.messaging.log.Log;
+import flex.messaging.log.Logger;
+import flex.messaging.util.ClassUtil;
+import flex.messaging.util.ExceptionUtil;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.File;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.AbstractCollection;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * Uses Bean introspection to collect the properties for a given instance.
+ *
+ * @author Peter Farland
+ */
+public class BeanProxy extends AbstractProxy
+{
+ static final long serialVersionUID = 7365078101695257715L;
+
+ private static final int FAILED_PROPERTY_READ_ERROR = 10021;
+ private static final int FAILED_PROPERTY_WRITE_ERROR = 10022;
+ private static final int NON_READABLE_PROPERTY_ERROR = 10023;
+ private static final int NON_WRITABLE_PROPERTY_ERROR = 10024;
+ private static final int UNKNOWN_PROPERTY_ERROR = 10025;
+
+ protected static final Map<Class, List<String>> rwPropertyNamesCache = new IdentityHashMap<Class, List<String>>();
+ protected static final Map<Class, Map<String, BeanProperty>> rwBeanPropertyCache = new IdentityHashMap<Class, Map<String, BeanProperty>>();
+ protected static final Map<Class, PropertyDescriptorCacheEntry> rwPropertyDescriptorCache = new IdentityHashMap<Class, PropertyDescriptorCacheEntry>();
+
+ protected static final Map<Class, List<String>> roPropertyNamesCache = new IdentityHashMap<Class, List<String>>();
+ protected static final Map<Class, Map<String, BeanProperty>> roBeanPropertyCache = new IdentityHashMap<Class, Map<String, BeanProperty>>();
+ protected static final Map<Class, PropertyDescriptorCacheEntry> roPropertyDescriptorCache = new IdentityHashMap<Class, PropertyDescriptorCacheEntry>();
+
+ protected boolean cacheProperties = true;
+ protected boolean cachePropertiesDescriptors = true;
+ protected Class stopClass = Object.class;
+
+ protected static final Map ignoreProperties = new HashMap();
+ static
+ {
+ initializeIgnoreProperties();
+ }
+
+ private static void initializeIgnoreProperties()
+ {
+ addIgnoreProperty(AbstractMap.class, "empty");
+ addIgnoreProperty(AbstractCollection.class, "empty");
+ addIgnoreProperty(ASObject.class, "type");
+ addIgnoreProperty(Throwable.class, "stackTrace");
+ addIgnoreProperty(File.class, "parentFile");
+ addIgnoreProperty(File.class, "canonicalFile");
+ addIgnoreProperty(File.class, "absoluteFile");
+ }
+
+ /**
+ * Constructor.
+ */
+ public BeanProxy()
+ {
+ this(null);
+ }
+
+ /**
+ * Construct a new BeanProxy with the provided default instance.
+ *
+ * @param defaultInstance defines the alias if provided
+ */
+ public BeanProxy(Object defaultInstance)
+ {
+ super(defaultInstance);
+
+ // Override default behavior here... standard Map implementations
+ // are treated as anonymous Objects, i.e. without an alias.
+ if (defaultInstance != null)
+ alias = getClassName(defaultInstance);
+ }
+
+ /** {@inheritDoc} */
+ public String getAlias(Object instance)
+ {
+ return getClassName(instance);
+ }
+
+ /** {@inheritDoc} */
+ public List getPropertyNames(Object instance)
+ {
+ if (instance == null)
+ return null;
+
+ Class c = instance.getClass();
+ List<String> propertyNames = null;
+
+ // Look up property names in cache if we don't have a custom serialization descriptor
+ if (descriptor == null)
+ {
+ if (getIncludeReadOnly())
+ {
+ synchronized (roPropertyNamesCache)
+ {
+ propertyNames = roPropertyNamesCache.get(c);
+ }
+ }
+ else
+ {
+ synchronized (rwPropertyNamesCache)
+ {
+ propertyNames = rwPropertyNamesCache.get(c);
+ }
+ }
+ }
+
+ if (propertyNames != null)
+ return propertyNames;
+
+ // Make a copy of the property names to return
+ propertyNames = new ArrayList<String>(getBeanProperties(instance).keySet());
+
+ // Store property names in cache if we are caching properties
+ // and we don't have a custom serialization descriptor
+ if (cacheProperties && descriptor == null)
+ {
+ if (getIncludeReadOnly())
+ {
+ synchronized (roPropertyNamesCache)
+ {
+ roPropertyNamesCache.put(c, propertyNames);
+ }
+ }
+ else
+ {
+ synchronized (rwPropertyNamesCache)
+ {
+ rwPropertyNamesCache.put(c, propertyNames);
+ }
+ }
+ }
+ return propertyNames;
+ }
+
+
+ /** {@inheritDoc} */
+ public Class getType(Object instance, String propertyName)
+ {
+ if (instance == null || propertyName == null)
+ return null;
+
+ BeanProperty bp = getBeanProperty(instance, propertyName);
+ return bp == null? null : bp.getType();
+ }
+
+ /** {@inheritDoc} */
+ public Object getValue(Object instance, String propertyName)
+ {
+ if (instance == null || propertyName == null)
+ return null;
+
+ BeanProperty bp = getBeanProperty(instance, propertyName);
+ if (bp != null)
+ return getBeanValue(instance, bp);
+
+ SerializationContext context = getSerializationContext();
+ if (!ignorePropertyErrors(context))
+ {
+ // Property '{propertyName}' not found on class '{alias}'.
+ MessageException ex = new MessageException();
+ ex.setMessage(UNKNOWN_PROPERTY_ERROR, new Object[] {propertyName, getAlias(instance)});
+ throw ex;
+ }
+ return null;
+ }
+
+ /**
+ * Gets the value specified by the BeanProperty.
+ * @param instance Object to get the value from
+ * @param bp the property to get
+ * @return the value of the property if it exists
+ */
+ protected final Object getBeanValue(Object instance, BeanProperty bp)
+ {
+ String propertyName = bp.getName();
+ if (bp.isRead())
+ {
+ try
+ {
+ Object value = bp.get(instance);
+ if (value != null && descriptor != null)
+ {
+ SerializationDescriptor subDescriptor = (SerializationDescriptor)descriptor.get(propertyName);
+ if (subDescriptor != null)
+ {
+ PropertyProxy subProxy = PropertyProxyRegistry.getProxyAndRegister(value);
+ subProxy = (PropertyProxy)subProxy.clone();
+ subProxy.setDescriptor(subDescriptor);
+ subProxy.setDefaultInstance(value);
+ value = subProxy;
+ }
+ }
+ return value;
+ }
+ catch (Exception e)
+ {
+ SerializationContext context = getSerializationContext();
+
+ // Log failed property set errors
+ if (Log.isWarn() && logPropertyErrors(context))
+ {
+ Logger log = Log.getLogger(LOG_CATEGORY);
+ log.warn("Failed to get property {0} on type {1}.",
+ new Object[] {propertyName, getAlias(instance)}, e);
+ }
+
+ if (!ignorePropertyErrors(context))
+ {
+ // Failed to get property '{propertyName}' on type '{className}'.
+ MessageException ex = new MessageException();
+ ex.setMessage(FAILED_PROPERTY_READ_ERROR, new Object[] {propertyName, getAlias(instance)});
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+ }
+ else
+ {
+ SerializationContext context = getSerializationContext();
+ if (!ignorePropertyErrors(context))
+ {
+ //Property '{propertyName}' not readable from class '{alias}'.
+ MessageException ex = new MessageException();
+ ex.setMessage(NON_READABLE_PROPERTY_ERROR, new Object[] {propertyName, getAlias(instance)});
+ throw ex;
+ }
+ }
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ public void setValue(Object instance, String propertyName, Object value)
+ {
+ BeanProperty bp = getBeanProperty(instance, propertyName);
+
+ if (bp != null)
+ {
+ if (bp.isWrite())
+ {
+ try
+ {
+ Class desiredPropClass = bp.getType();
+ TypeMarshaller marshaller = TypeMarshallingContext.getTypeMarshaller();
+ value = marshaller.convert(value, desiredPropClass);
+ ClassUtil.validateAssignment(instance, propertyName, value);
+ bp.set(instance, value);
+ }
+ catch (Exception e)
+ {
+ SerializationContext context = getSerializationContext();
+
+ // Log ignore failed property set errors
+ if (Log.isWarn() && logPropertyErrors(context))
+ {
+ Logger log = Log.getLogger(LOG_CATEGORY);
+ log.warn("Failed to set property {0} on type {1}.",
+ new Object[] {propertyName, getAlias(instance)}, e);
+ }
+
+ if (!ignorePropertyErrors(context))
+ {
+ // Failed to get property '{propertyName}' on type '{className}'.
+ MessageException ex = new MessageException();
+ ex.setMessage(FAILED_PROPERTY_WRITE_ERROR, new Object[] {propertyName, getAlias(instance)});
+ ex.setRootCause(e);
+ throw ex;
+ }
+ }
+ }
+ else
+ {
+ SerializationContext context = getSerializationContext();
+
+ if (Log.isWarn() && logPropertyErrors(context))
+ {
+ Logger log = Log.getLogger(LOG_CATEGORY);
+ log.warn("Property {0} not writable on class {1}",
+ new Object[] {propertyName, getAlias(instance)});
+ }
+
+ if (!ignorePropertyErrors(context))
+ {
+ //Property '{propertyName}' not writable on class '{alias}'.
+ MessageException ex = new MessageException();
+ ex.setMessage(NON_WRITABLE_PROPERTY_ERROR, new Object[] {propertyName, getAlias(instance)});
+ throw ex;
+ }
+ }
+ }
+ else
+ {
+ SerializationContext context = getSerializationContext();
+
+ if (Log.isWarn() && logPropertyErrors(context))
+ {
+ Logger log = Log.getLogger(LOG_CATEGORY);
+ log.warn("Ignoring set property {0} for type {1} as a setter could not be found.",
+ new Object[] {propertyName, getAlias(instance)});
+ }
+
+ if (!ignorePropertyErrors(context))
+ {
+ // Property '{propertyName}' not found on class '{alias}'.
+ MessageException ex = new MessageException();
+ ex.setMessage(UNKNOWN_PROPERTY_ERROR, new Object[] {propertyName, getAlias(instance)});
+ throw ex;
+ }
+ }
+ }
+
+ /**
+ * Are we ignoring property errors?
+ * @param context serialization paramters.
+ * @return true if ignoring property errors.
+ */
+ protected boolean ignorePropertyErrors(SerializationContext context)
+ {
+ return context.ignorePropertyErrors;
+ }
+
+ /**
+ * Should we log property errors?
+ * @param context serialization parameters.
+ * @return true if we should log property errors.
+ */
+ protected boolean logPropertyErrors(SerializationContext context)
+ {
+ return context.logPropertyErrors;
+ }
+
+ /**
+ * Determins the classname for both normal types via Class.getName() and
+ * virtual types via ASObject.getType(). Virtual types starting
+ * with the special ">" token are also handled and the underlying
+ * className is returned.
+ *
+ * @param instance the object to examine.
+ * @return the classname to use for instances of this type
+ */
+ protected String getClassName(Object instance)
+ {
+ String className;
+
+ if (instance instanceof ASObject)
+ {
+ className = ((ASObject)instance).getType();
+ }
+ else if (instance instanceof ClassAlias)
+ {
+ className = ((ClassAlias)instance).getAlias();
+ }
+ else
+ {
+ className = instance.getClass().getName();
+ // If there's an alias, use that as the class name.
+ ClassAliasRegistry registry = ClassAliasRegistry.getRegistry();
+ String aliasedClass = registry.getClassName(className);
+ className = (aliasedClass == null)? className : aliasedClass;
+ }
+
+ return className;
+ }
+
+ /**
+ * Return a map of properties for a object.
+ * @param instance object to examine.
+ * @return a map of Strings to BeanProperty objects.
+ */
+ protected Map<String, BeanProperty> getBeanProperties(Object instance)
+ {
+ Class c = instance.getClass();
+ Map<String, BeanProperty> props;
+
+ // look up instance class in cache if we don't have a custom descriptor.
+ if (descriptor == null)
+ {
+ if (getIncludeReadOnly())
+ {
+ synchronized (roBeanPropertyCache)
+ {
+ props = roBeanPropertyCache.get(c);
+ }
+ }
+ else
+ {
+ synchronized (rwBeanPropertyCache)
+ {
+ props = roBeanPropertyCache.get(c);
+
+ }
+ }
+ if (props != null)
+ return props;
+ }
+
+ props = new HashMap<String, BeanProperty>();
+ PropertyDescriptor[] pds = getPropertyDescriptors(c);
+ if (pds == null)
+ return null;
+
+ List excludes = null;
+ if (descriptor != null)
+ {
+ excludes = descriptor.getExcludesForInstance(instance);
+ if (excludes == null) // For compatibility with older implementations
+ excludes = descriptor.getExcludes();
+ }
+
+ // Add standard bean properties first
+ for (PropertyDescriptor pd : pds)
+ {
+ String propertyName = pd.getName();
+ Method readMethod = pd.getReadMethod();
+ Method writeMethod = pd.getWriteMethod();
+
+ // If there's a public read method but no writeMethod and includeReadOnly
+ // flag is off, then skip the property.
+ if (readMethod != null && isPublicAccessor(readMethod.getModifiers()) && !getIncludeReadOnly() && writeMethod == null)
+ continue;
+
+ // Skip excluded and ignored properties as well.
+ if ((excludes != null && excludes.contains(propertyName)) || isPropertyIgnored(c, propertyName))
+ continue;
+
+ // Ensure we don't include Object getClass() property, possibly returned (incorrectly) by custom BeanInfos
+ if (getIncludeReadOnly() && writeMethod == null && "class".equals(propertyName))
+ continue;
+
+ // Skip any classloader properties
+ final Class<?> type = pd.getPropertyType();
+ if (type != null && ClassLoader.class.isAssignableFrom(type))
+ continue;
+
+ props.put(propertyName, new BeanProperty(propertyName, pd.getPropertyType(),
+ readMethod, writeMethod, null));
+ }
+
+ // Then add public fields to list if property does not already exist
+ Field[] fields = instance.getClass().getFields();
+ for (Field field : fields)
+ {
+ String propertyName = field.getName();
+ int modifiers = field.getModifiers();
+ if (isPublicField(modifiers) && !props.containsKey(propertyName))
+ {
+ // Skip excluded and ignored properties.
+ if ((excludes != null && excludes.contains(propertyName)) || isPropertyIgnored(c, propertyName))
+ continue;
+
+ props.put(propertyName, new BeanProperty(propertyName, field.getType(), null, null, field));
+ }
+ }
+
+ // Update the cache if we don't have a custom serialization descriptor and we are caching.
+ if (descriptor == null && cacheProperties)
+ {
+ if (getIncludeReadOnly())
+ {
+ synchronized (roBeanPropertyCache)
+ {
+ roBeanPropertyCache.put(c, props);
+ }
+ }
+ else
+ {
+ synchronized (rwBeanPropertyCache)
+ {
+ roBeanPropertyCache.put(c, props);
+
+ }
+ }
+ }
+
+ return props;
+ }
+
+ /**
+ * Return true if this property is write only, which means we cannot get a value for it.
+ *
+ * @param instance the instance
+ * @param propertyName the property name
+ * @return true if there is a way to write but not read the property
+ */
+ public boolean isWriteOnly(Object instance, String propertyName)
+ {
+ if (instance == null || propertyName == null)
+ return false;
+
+ BeanProperty bp = getBeanProperty(instance, propertyName);
+ return bp != null && bp.isWrite() && !bp.isRead();
+ }
+
+ /**
+ * Return a specific property descriptor for a named property.
+ * @param instance the object to use.
+ * @param propertyName the property to get.
+ * @return a descriptor for the property.
+ */
+ protected final BeanProperty getBeanProperty(Object instance, String propertyName)
+ {
+ Class c = instance.getClass();
+ Map props;
+
+ // It is faster to use the BeanProperty cache if we are going to cache it.
+ if (descriptor == null && cacheProperties)
+ {
+ props = getBeanProperties(instance);
+ return props == null? null : (BeanProperty)props.get(propertyName);
+ }
+
+ // Otherwise, just build up the property we are asked for
+ PropertyDescriptorCacheEntry pce = getPropertyDescriptorCacheEntry(c);
+ if (pce == null)
+ return null;
+
+ Object pType = pce.propertiesByName.get(propertyName);
+ if (pType == null)
+ return null;
+
+ List excludes = null;
+ if (descriptor != null)
+ {
+ excludes = descriptor.getExcludesForInstance(instance);
+ if (excludes == null) // For compatibility with older implementations
+ excludes = descriptor.getExcludes();
+ }
+
+ if (pType instanceof PropertyDescriptor)
+ {
+ PropertyDescriptor pd = (PropertyDescriptor) pType;
+
+ Method readMethod = pd.getReadMethod();
+ Method writeMethod = pd.getWriteMethod();
+
+ // If there's a public read method but no writeMethod and includeReadOnly
+ // flag is off, then skip the property.
+ if (readMethod != null && isPublicAccessor(readMethod.getModifiers()) && !getIncludeReadOnly() && writeMethod == null)
+ return null;
+
+ // Skip excluded and ignored properties as well.
+ if ((excludes != null && excludes.contains(propertyName)) || isPropertyIgnored(c, propertyName))
+ return null;
+
+ return new BeanProperty(propertyName, pd.getPropertyType(), readMethod, writeMethod, null);
+ }
+ else if (pType instanceof Field)
+ {
+ Field field = (Field) pType;
+
+ String pName = field.getName();
+ int modifiers = field.getModifiers();
+ if (isPublicField(modifiers) && pName.equals(propertyName))
+ {
+ // Skip excluded and ignored properties.
+ return ((excludes != null && excludes.contains(propertyName)) || isPropertyIgnored(c, propertyName))?
+ null : new BeanProperty(propertyName, field.getType(), null, null, field);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Return an array of JavaBean property descriptors for a class.
+ * @param c the class to examine.
+ * @return an array ot JavaBean PropertyDescriptors.
+ */
+ private PropertyDescriptor [] getPropertyDescriptors(Class c)
+ {
+ PropertyDescriptorCacheEntry pce = getPropertyDescriptorCacheEntry(c);
+ return pce == null? null : pce.propertyDescriptors;
+ }
+
+ /**
+ * Return an entry from the property descriptor cache for a class.
+ * @param c the class
+ * @return a descriptor cache entry or null
+ */
+ private PropertyDescriptorCacheEntry getPropertyDescriptorCacheEntry(Class c)
+ {
+ PropertyDescriptorCacheEntry pce;
+ if (getIncludeReadOnly())
+ {
+ synchronized (roPropertyDescriptorCache)
+ {
+ pce = roPropertyDescriptorCache.get(c);
+ }
+ }
+ else
+ {
+ synchronized (rwPropertyDescriptorCache)
+ {
+ pce = rwPropertyDescriptorCache.get(c);
+ }
+ }
+
+ try
+ {
+ if (pce == null)
+ {
+ BeanInfo beanInfo = Introspector.getBeanInfo(c, stopClass);
+ pce = new PropertyDescriptorCacheEntry();
+ pce.propertyDescriptors = beanInfo.getPropertyDescriptors();
+ pce.propertiesByName = createPropertiesByNameMap(pce.propertyDescriptors, c.getFields());
+ if (cachePropertiesDescriptors)
+ {
+ if (getIncludeReadOnly())
+ {
+ synchronized (roPropertyDescriptorCache)
+ {
+ roPropertyDescriptorCache.put(c, pce);
+ }
+ }
+ else
+ {
+ synchronized (rwPropertyDescriptorCache)
+ {
+ rwPropertyDescriptorCache.put(c, pce);
+ }
+ }
+ }
+ }
+ }
+ catch (IntrospectionException ex)
+ {
+ // Log failed property set errors
+ if (Log.isError())
+ {
+ Logger log = Log.getLogger(LOG_CATEGORY);
+ log.error("Failed to introspect object of type: " + c + " error: " + ExceptionUtil.toString(ex));
+ }
+
+ // Return an empty descriptor rather than crashing
+ pce = new PropertyDescriptorCacheEntry();
+ pce.propertyDescriptors = new PropertyDescriptor[0];
+ pce.propertiesByName = new TreeMap();
+ }
+ return pce;
+ }
+
+ private Map createPropertiesByNameMap(PropertyDescriptor [] pds, Field [] fields)
+ {
+ Map m = new HashMap(pds.length);
+ for (PropertyDescriptor pd : pds)
+ {
+ Method readMethod = pd.getReadMethod();
+ if (readMethod != null && isPublicAccessor(readMethod.getModifiers()) &&
+ (getIncludeReadOnly() || pd.getWriteMethod() != null))
+ m.put(pd.getName(), pd);
+ }
+ for (Field field : fields)
+ {
+ if (isPublicField(field.getModifiers()) && !m.containsKey(field.getName()))
+ m.put(field.getName(), field);
+ }
+ return m;
+ }
+
+ /**
+ * Is this property on the ignore list for this class?
+ * @param c the class.
+ * @param propertyName the property name.
+ * @return true if we should ignore this property.
+ */
+ public static boolean isPropertyIgnored(Class c, String propertyName)
+ {
+ boolean result = false;
+ Set propertyOwners = (Set)ignoreProperties.get(propertyName);
+ if (propertyOwners != null)
+ {
+ while (c != null)
+ {
+ if (propertyOwners.contains(c))
+ {
+ result = true;
+ break;
+ }
+ c = c.getSuperclass();
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Add a property to the ignore list for this class.
+ * @param c the class.
+ * @param propertyName the property to ignore.
+ */
+ public static void addIgnoreProperty(Class c, String propertyName)
+ {
+ synchronized(ignoreProperties)
+ {
+ Set propertyOwners = (Set)ignoreProperties.get(propertyName);
+ if (propertyOwners == null)
+ {
+ propertyOwners = new HashSet();
+ ignoreProperties.put(propertyName, propertyOwners);
+ }
+ propertyOwners.add(c);
+ }
+ }
+
+ /**
+ * Do the provided modifiers indicate that this is public?
+ * @param modifiers the flags to check
+ * @return true if public but not final, static or transient.
+ */
+ public static boolean isPublicField(int modifiers)
+ {
+ return (Modifier.isPublic(modifiers) && !Modifier.isFinal(modifiers)
+ && !Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers));
+ }
+
+ /**
+ * Do the provided modifiers indicate that this is public?
+ * @param modifiers the flags to check
+ * @return true if public but not static.
+ */
+ public static boolean isPublicAccessor(int modifiers)
+ {
+ return (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers));
+ }
+
+ /**
+ * A class that holds information about a bean property.
+ */
+ protected static class BeanProperty
+ {
+ private String name;
+ private Class type;
+ private Method readMethod, writeMethod;
+ private Field field;
+
+ protected BeanProperty(String name, Class type, Method read, Method write, Field field)
+ {
+ this.name = name;
+ this.type = type;
+ this.writeMethod = write;
+ this.readMethod = read;
+ this.field = field;
+ }
+
+ /**
+ * The name of the property..
+ * @return the name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * The type of the property.
+ * @return the type
+ */
+ public Class getType()
+ {
+ return type;
+ }
+
+ /**
+ * Is there a setter for this property?
+ * @return true if there is a write method.
+ */
+ public boolean isWrite()
+ {
+ return writeMethod != null || field != null;
+ }
+
+ /**
+ * Is there a getter for this property?
+ * @return true if there is a read method.
+ */
+ public boolean isRead()
+ {
+ return readMethod != null || field != null;
+ }
+
+ /**
+ * Returns the Class object that declared the public field or getter function.
+ * @return an object of the declaring class for the read method or null if the read method is undefined.
+ */
+ public Class getReadDeclaringClass()
+ {
+ if (readMethod != null)
+ return readMethod.getDeclaringClass();
+ if (field != null)
+ return field.getDeclaringClass();
+ return null;
+ }
+
+ /**
+ * Return a class that represents the type of the property.
+ * @return the type of the property or null if there is no read method defined.
+ */
+ public Class getReadType()
+ {
+ if (readMethod != null)
+ return readMethod.getReturnType();
+ if (field != null)
+ return field.getType();
+ return null;
+ }
+
+ /**
+ *
+ * Returns a string indicating the setter or field name of the property.
+ * The setter is prefixed by 'method ', or the field is prefixed by 'field '.
+ * @return A string suitable for debugging.
+ */
+ public String getWriteName()
+ {
+ if (writeMethod != null)
+ return "method " + writeMethod.getName();
+ if (field != null)
+ return "field " + field.getName();
+ return null;
+ }
+
+ /**
+ * Set the property of the object to the specified value.
+ * @param bean the bean to set the property on.
+ * @param value the value to set.
+ * @throws IllegalAccessException if no access.
+ * @throws InvocationTargetException if the setter throws an exception.
+ */
+ public void set(Object bean, Object value) throws IllegalAccessException,
+ InvocationTargetException
+ {
+ if (writeMethod != null)
+ writeMethod.invoke(bean, value);
+ else if (field != null)
+ field.set(bean, value);
+ else
+ throw new MessageException("Setter not found for property " + name);
+ }
+
+ /**
+ * Get the value of this property from the specified object.
+ * @param bean the object to retrieve the value from
+ * @return the value of the property.
+ * @throws IllegalAccessException if no access.
+ * @throws InvocationTargetException if the getter throws an exception.
+ */
+ public Object get(Object bean) throws IllegalAccessException, InvocationTargetException
+ {
+ Object obj = null;
+ if (readMethod != null)
+ obj = readMethod.invoke(bean, (Object[])null);
+ else if (field != null)
+ obj = field.get(bean);
+ return obj;
+ }
+ }
+
+ /**
+ * Clears all static caches.
+ */
+ public static void clear()
+ {
+ synchronized(ignoreProperties)
+ {
+ ignoreProperties.clear();
+ initializeIgnoreProperties(); // reset to original state
+ }
+ synchronized(rwPropertyNamesCache)
+ {
+ rwPropertyNamesCache.clear();
+ }
+ synchronized(rwBeanPropertyCache)
+ {
+ rwBeanPropertyCache.clear();
+ }
+ synchronized(rwPropertyDescriptorCache)
+ {
+ rwPropertyDescriptorCache.clear();
+ }
+ synchronized(roPropertyNamesCache)
+ {
+ roPropertyNamesCache.clear();
+ }
+ synchronized(roBeanPropertyCache)
+ {
+ roBeanPropertyCache.clear();
+ }
+ synchronized(roPropertyDescriptorCache)
+ {
+ roPropertyDescriptorCache.clear();
+ }
+ }
+
+ /**
+ * A cache entry.
+ */
+ protected static class PropertyDescriptorCacheEntry
+ {
+ PropertyDescriptor [] propertyDescriptors;
+ Map propertiesByName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/ClassAlias.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/ClassAlias.java b/modules/core/src/flex/messaging/io/ClassAlias.java
old mode 100755
new mode 100644
index 6bc9407..5bf8cdc
--- a/modules/core/src/flex/messaging/io/ClassAlias.java
+++ b/modules/core/src/flex/messaging/io/ClassAlias.java
@@ -1,29 +1,29 @@
-/*
- * 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.io;
-
-/**
- * A Class can implement this interface to customize the alias reported by
- * a BeanProxy when describing a complex object's traits.
- */
-public interface ClassAlias
-{
- /**
- * The alias to use for this instance.
- */
- public String getAlias();
-}
+/*
+ * 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.io;
+
+/**
+ * A Class can implement this interface to customize the alias reported by
+ * a BeanProxy when describing a complex object's traits.
+ */
+public interface ClassAlias
+{
+ /**
+ * The alias to use for this instance.
+ */
+ public String getAlias();
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/ClassAliasRegistry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/ClassAliasRegistry.java b/modules/core/src/flex/messaging/io/ClassAliasRegistry.java
old mode 100755
new mode 100644
index 3a6fa80..b97eaaa
--- a/modules/core/src/flex/messaging/io/ClassAliasRegistry.java
+++ b/modules/core/src/flex/messaging/io/ClassAliasRegistry.java
@@ -1,98 +1,98 @@
-/*
- * 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.io;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A simple registry that maps an alias to a concrete class name. This registry
- * mimics the ActionScript 3 flash.net.registerClassAlias() functionality
- * of the Flash Player. The registry is checked when deserializing AMF object
- * types.
- */
-public class ClassAliasRegistry
-{
- private Map aliasRegistry = new HashMap();
- private static final ClassAliasRegistry registry = new ClassAliasRegistry();
-
- /**
- * Constructs an empty registry.
- */
- private ClassAliasRegistry()
- {
- }
-
- /**
- * Returns the registry singleton.
- */
- public static ClassAliasRegistry getRegistry()
- {
- return registry;
- }
-
- /**
- * Looks for a concrete class name for an alias.
- *
- * @param alias The alias used to search the registry.
- * @return a concrete class name, if registered for this alias, otherwise
- * null.
- */
- public String getClassName(String alias)
- {
- return (String)aliasRegistry.get(alias);
- }
-
- /**
- * Clears all items from the registry.
- */
- public void clear()
- {
- synchronized(aliasRegistry)
- {
- aliasRegistry.clear();
- }
- }
-
- /**
- * Registers a custom alias for a class name.
- *
- * @param alias The alias for the class name.
- * @param className The concrete class name.
- */
- public void registerAlias(String alias, String className)
- {
- synchronized(aliasRegistry)
- {
- aliasRegistry.put(alias, className);
- }
- }
-
- /**
- * Removes a class alias from the registry.
- *
- * @param alias The alias to be removed from the registry.
- */
- public void unregisterAlias(String alias)
- {
- synchronized(aliasRegistry)
- {
- aliasRegistry.remove(alias);
- }
- }
-}
+/*
+ * 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.io;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A simple registry that maps an alias to a concrete class name. This registry
+ * mimics the ActionScript 3 flash.net.registerClassAlias() functionality
+ * of the Flash Player. The registry is checked when deserializing AMF object
+ * types.
+ */
+public class ClassAliasRegistry
+{
+ private Map aliasRegistry = new HashMap();
+ private static final ClassAliasRegistry registry = new ClassAliasRegistry();
+
+ /**
+ * Constructs an empty registry.
+ */
+ private ClassAliasRegistry()
+ {
+ }
+
+ /**
+ * Returns the registry singleton.
+ */
+ public static ClassAliasRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ /**
+ * Looks for a concrete class name for an alias.
+ *
+ * @param alias The alias used to search the registry.
+ * @return a concrete class name, if registered for this alias, otherwise
+ * null.
+ */
+ public String getClassName(String alias)
+ {
+ return (String)aliasRegistry.get(alias);
+ }
+
+ /**
+ * Clears all items from the registry.
+ */
+ public void clear()
+ {
+ synchronized(aliasRegistry)
+ {
+ aliasRegistry.clear();
+ }
+ }
+
+ /**
+ * Registers a custom alias for a class name.
+ *
+ * @param alias The alias for the class name.
+ * @param className The concrete class name.
+ */
+ public void registerAlias(String alias, String className)
+ {
+ synchronized(aliasRegistry)
+ {
+ aliasRegistry.put(alias, className);
+ }
+ }
+
+ /**
+ * Removes a class alias from the registry.
+ *
+ * @param alias The alias to be removed from the registry.
+ */
+ public void unregisterAlias(String alias)
+ {
+ synchronized(aliasRegistry)
+ {
+ aliasRegistry.remove(alias);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/messaging/io/DictionaryProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/messaging/io/DictionaryProxy.java b/modules/core/src/flex/messaging/io/DictionaryProxy.java
old mode 100755
new mode 100644
index e579963..8a44bd3
--- a/modules/core/src/flex/messaging/io/DictionaryProxy.java
+++ b/modules/core/src/flex/messaging/io/DictionaryProxy.java
@@ -1,112 +1,112 @@
-/*
- * 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.io;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * Proxies serialization of a Dictionary and considers all keys as String based property
- * names. Additionally, bean properties from the instance are also included and override
- * any Dictionary entries with the same name.
- *
- * @author Peter Farland
- */
-public class DictionaryProxy extends BeanProxy
-{
- static final long serialVersionUID = 1501461889185692712L;
-
- public DictionaryProxy()
- {
- super();
- //dynamic = true;
- }
-
- public DictionaryProxy(Dictionary defaultInstance)
- {
- super(defaultInstance);
- }
-
- public List getPropertyNames(Object instance)
- {
- if (instance == null)
- return null;
-
- List propertyNames = null;
- List excludes = null;
-
- if (descriptor != null)
- {
- excludes = descriptor.getExcludesForInstance(instance);
- if (excludes == null)
- excludes = descriptor.getExcludes();
- }
-
- // Add all Dictionary keys as properties
- if (instance instanceof Dictionary)
- {
- Dictionary dictionary = (Dictionary)instance;
-
- propertyNames = new ArrayList(dictionary.size());
-
- Enumeration keys = dictionary.keys();
- while (keys.hasMoreElements())
- {
- Object key = keys.nextElement();
- if (key != null)
- {
- if (excludes != null && excludes.contains(key))
- continue;
-
- propertyNames.add(key.toString());
- }
- }
- }
-
- // Then, check for bean properties
- List beanProperties = super.getPropertyNames(instance);
- if (propertyNames == null)
- {
- propertyNames = beanProperties;
- }
- else
- {
- propertyNames.addAll(beanProperties);
- }
-
- return propertyNames;
- }
-
- public Object getValue(Object instance, String propertyName)
- {
- if (instance == null || propertyName == null)
- return null;
-
- // First, check for bean property
- Object value = super.getValue(instance, propertyName);
-
- // Then check for Dictionary entry
- if (value == null && instance instanceof Dictionary)
- {
- Dictionary dictionary = (Dictionary)instance;
- value = dictionary.get(propertyName);
- }
-
- return value;
- }
-}
+/*
+ * 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.io;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ * Proxies serialization of a Dictionary and considers all keys as String based property
+ * names. Additionally, bean properties from the instance are also included and override
+ * any Dictionary entries with the same name.
+ *
+ * @author Peter Farland
+ */
+public class DictionaryProxy extends BeanProxy
+{
+ static final long serialVersionUID = 1501461889185692712L;
+
+ public DictionaryProxy()
+ {
+ super();
+ //dynamic = true;
+ }
+
+ public DictionaryProxy(Dictionary defaultInstance)
+ {
+ super(defaultInstance);
+ }
+
+ public List getPropertyNames(Object instance)
+ {
+ if (instance == null)
+ return null;
+
+ List propertyNames = null;
+ List excludes = null;
+
+ if (descriptor != null)
+ {
+ excludes = descriptor.getExcludesForInstance(instance);
+ if (excludes == null)
+ excludes = descriptor.getExcludes();
+ }
+
+ // Add all Dictionary keys as properties
+ if (instance instanceof Dictionary)
+ {
+ Dictionary dictionary = (Dictionary)instance;
+
+ propertyNames = new ArrayList(dictionary.size());
+
+ Enumeration keys = dictionary.keys();
+ while (keys.hasMoreElements())
+ {
+ Object key = keys.nextElement();
+ if (key != null)
+ {
+ if (excludes != null && excludes.contains(key))
+ continue;
+
+ propertyNames.add(key.toString());
+ }
+ }
+ }
+
+ // Then, check for bean properties
+ List beanProperties = super.getPropertyNames(instance);
+ if (propertyNames == null)
+ {
+ propertyNames = beanProperties;
+ }
+ else
+ {
+ propertyNames.addAll(beanProperties);
+ }
+
+ return propertyNames;
+ }
+
+ public Object getValue(Object instance, String propertyName)
+ {
+ if (instance == null || propertyName == null)
+ return null;
+
+ // First, check for bean property
+ Object value = super.getValue(instance, propertyName);
+
+ // Then check for Dictionary entry
+ if (value == null && instance instanceof Dictionary)
+ {
+ Dictionary dictionary = (Dictionary)instance;
+ value = dictionary.get(propertyName);
+ }
+
+ return value;
+ }
+}