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; + } +}