You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2006/05/10 17:54:24 UTC
svn commit: r405785 [3/20] - in /beehive/trunk/netui: external/struts/
external/struts/legacy/jakarta-struts-1.1-lib/ src/bootstrap/
src/bootstrap/org/apache/beehive/netui/tools/tld/xdoclet/ src/compiler-apt/
src/compiler-apt/META-INF/services/ src/com...
Modified: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/CatalogFactory.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/CatalogFactory.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/CatalogFactory.java (original)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/CatalogFactory.java Wed May 10 08:49:42 2006
@@ -1,141 +1,141 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.core.chain;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.beehive.netui.core.chain.impl.CatalogFactoryBase;
-import org.apache.beehive.netui.core.chain.impl.CatalogBase;
-import org.apache.beehive.netui.core.chain.impl.ChainBase;
-import org.apache.beehive.netui.util.config.bean.CatalogConfig;
-import org.apache.beehive.netui.util.config.bean.ChainConfig;
-import org.apache.beehive.netui.util.config.bean.CommandConfig;
-import org.apache.beehive.netui.util.config.bean.CustomPropertyConfig;
-import org.apache.commons.beanutils.BeanUtils;
-
-/**
- * Abstract factory class for configuring a {@link Catalog} of {@link Command}s in a chain.
- */
-public abstract class CatalogFactory {
-
- private static Map FACTORIES = new HashMap();
-
- public abstract void setCatalog(Catalog catalog);
-
- public abstract Catalog getCatalog();
-
- public abstract Catalog getCatalog(String name);
-
- public abstract void addCatalog(String name, Catalog catalog);
-
- public static CatalogFactory getInstance() {
- CatalogFactory catalogFactory = null;
- ClassLoader classLoader = getClassLoader();
- synchronized(FACTORIES) {
- catalogFactory = (CatalogFactory)FACTORIES.get(classLoader);
- if(catalogFactory == null) {
- catalogFactory = new CatalogFactoryBase();
- FACTORIES.put(classLoader, catalogFactory);
- }
- }
- return catalogFactory;
- }
-
- public static CatalogFactory getInstance(CatalogConfig catalogConfig) {
-
- if(catalogConfig == null)
- return null;
-
- CatalogFactory catalogFactory = getInstance();
- assert catalogFactory != null;
- Catalog catalog = new CatalogBase();
- List chainConfigs = catalogConfig.getCommands();
- for(int i = 0; i < chainConfigs.size(); i++) {
- CommandConfig commandConfig = (CommandConfig)chainConfigs.get(i);
- assert commandConfig != null;
-
- if(commandConfig instanceof ChainConfig) {
- ChainConfig chainConfig = (ChainConfig)commandConfig;
- Chain chain = new ChainBase();
-
- List commandConfigs = chainConfig.getCommands();
- for(int j = 0; j < commandConfigs.size(); j++) {
- CommandConfig chainCommandConfig = (CommandConfig)commandConfigs.get(j);
- Command command = createCommand(chainCommandConfig);
- chain.addCommand(command);
- }
- catalog.addCommand(chainConfig.getName(), chain);
- }
- else {
- Command command = createCommand(commandConfig);
- catalog.addCommand(commandConfig.getId(), command);
- }
- }
- catalogFactory.setCatalog(catalog);
- return catalogFactory;
- }
-
- private static Command createCommand(CommandConfig commandConfig) {
- Command command = null;
- try {
- Class commandClass = Class.forName(commandConfig.getClassname(), true, getClassLoader());
- if (!Command.class.isAssignableFrom(commandClass))
- throw new RuntimeException("Created command that is not a command class");
-
- command = (Command) commandClass.newInstance();
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException("Problem occurred creating Chain. Cause: " + e, e);
- }
- catch (InstantiationException e) {
- throw new RuntimeException("Problem occurred creating Chain. Cause: " + e, e);
- }
- catch (ClassNotFoundException e) {
- throw new RuntimeException("Problem occurred creating Chain. Cause: " + e, e);
- }
-
- List propertyConfigs = commandConfig.getParameters();
- for(int k = 0; k < propertyConfigs.size(); k++) {
- CustomPropertyConfig customPropertyConfig = (CustomPropertyConfig)propertyConfigs.get(k);
- assert customPropertyConfig.getName() != null;
- assert customPropertyConfig.getValue() != null;
-
- try {
- BeanUtils.setProperty(command, customPropertyConfig.getName(), customPropertyConfig.getValue());
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException("Problem occurred setting property on Command. Cause: " + e, e);
- }
- catch (InvocationTargetException e) {
- throw new RuntimeException("Problem occurred setting property on Command. Cause: " + e, e);
- }
-
- }
- return command;
- }
-
- private static ClassLoader getClassLoader() {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- if(classLoader == null)
- classLoader = CatalogFactory.class.getClassLoader();
- return classLoader;
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.chain;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.beehive.netui.core.chain.impl.CatalogFactoryBase;
+import org.apache.beehive.netui.core.chain.impl.CatalogBase;
+import org.apache.beehive.netui.core.chain.impl.ChainBase;
+import org.apache.beehive.netui.util.config.bean.CatalogConfig;
+import org.apache.beehive.netui.util.config.bean.ChainConfig;
+import org.apache.beehive.netui.util.config.bean.CommandConfig;
+import org.apache.beehive.netui.util.config.bean.CustomPropertyConfig;
+import org.apache.commons.beanutils.BeanUtils;
+
+/**
+ * Abstract factory class for configuring a {@link Catalog} of {@link Command}s in a chain.
+ */
+public abstract class CatalogFactory {
+
+ private static Map FACTORIES = new HashMap();
+
+ public abstract void setCatalog(Catalog catalog);
+
+ public abstract Catalog getCatalog();
+
+ public abstract Catalog getCatalog(String name);
+
+ public abstract void addCatalog(String name, Catalog catalog);
+
+ public static CatalogFactory getInstance() {
+ CatalogFactory catalogFactory = null;
+ ClassLoader classLoader = getClassLoader();
+ synchronized(FACTORIES) {
+ catalogFactory = (CatalogFactory)FACTORIES.get(classLoader);
+ if(catalogFactory == null) {
+ catalogFactory = new CatalogFactoryBase();
+ FACTORIES.put(classLoader, catalogFactory);
+ }
+ }
+ return catalogFactory;
+ }
+
+ public static CatalogFactory getInstance(CatalogConfig catalogConfig) {
+
+ if(catalogConfig == null)
+ return null;
+
+ CatalogFactory catalogFactory = getInstance();
+ assert catalogFactory != null;
+ Catalog catalog = new CatalogBase();
+ List chainConfigs = catalogConfig.getCommands();
+ for(int i = 0; i < chainConfigs.size(); i++) {
+ CommandConfig commandConfig = (CommandConfig)chainConfigs.get(i);
+ assert commandConfig != null;
+
+ if(commandConfig instanceof ChainConfig) {
+ ChainConfig chainConfig = (ChainConfig)commandConfig;
+ Chain chain = new ChainBase();
+
+ List commandConfigs = chainConfig.getCommands();
+ for(int j = 0; j < commandConfigs.size(); j++) {
+ CommandConfig chainCommandConfig = (CommandConfig)commandConfigs.get(j);
+ Command command = createCommand(chainCommandConfig);
+ chain.addCommand(command);
+ }
+ catalog.addCommand(chainConfig.getName(), chain);
+ }
+ else {
+ Command command = createCommand(commandConfig);
+ catalog.addCommand(commandConfig.getId(), command);
+ }
+ }
+ catalogFactory.setCatalog(catalog);
+ return catalogFactory;
+ }
+
+ private static Command createCommand(CommandConfig commandConfig) {
+ Command command = null;
+ try {
+ Class commandClass = Class.forName(commandConfig.getClassname(), true, getClassLoader());
+ if (!Command.class.isAssignableFrom(commandClass))
+ throw new RuntimeException("Created command that is not a command class");
+
+ command = (Command) commandClass.newInstance();
+ }
+ catch (IllegalAccessException e) {
+ throw new RuntimeException("Problem occurred creating Chain. Cause: " + e, e);
+ }
+ catch (InstantiationException e) {
+ throw new RuntimeException("Problem occurred creating Chain. Cause: " + e, e);
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException("Problem occurred creating Chain. Cause: " + e, e);
+ }
+
+ List propertyConfigs = commandConfig.getParameters();
+ for(int k = 0; k < propertyConfigs.size(); k++) {
+ CustomPropertyConfig customPropertyConfig = (CustomPropertyConfig)propertyConfigs.get(k);
+ assert customPropertyConfig.getName() != null;
+ assert customPropertyConfig.getValue() != null;
+
+ try {
+ BeanUtils.setProperty(command, customPropertyConfig.getName(), customPropertyConfig.getValue());
+ }
+ catch (IllegalAccessException e) {
+ throw new RuntimeException("Problem occurred setting property on Command. Cause: " + e, e);
+ }
+ catch (InvocationTargetException e) {
+ throw new RuntimeException("Problem occurred setting property on Command. Cause: " + e, e);
+ }
+
+ }
+ return command;
+ }
+
+ private static ClassLoader getClassLoader() {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ if(classLoader == null)
+ classLoader = CatalogFactory.class.getClassLoader();
+ return classLoader;
+ }
+}
Propchange: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/CatalogFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Chain.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Chain.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Chain.java (original)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Chain.java Wed May 10 08:49:42 2006
@@ -1,31 +1,31 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.core.chain;
-
-/**
- * <p>
- * An implementation of the Chain of Responsibility pattern that chains {@link Command}s together.
- * </p>
- */
-public interface Chain
- extends Command {
-
- void addCommand(Command command);
-
- Command[] getCommands();
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.chain;
+
+/**
+ * <p>
+ * An implementation of the Chain of Responsibility pattern that chains {@link Command}s together.
+ * </p>
+ */
+public interface Chain
+ extends Command {
+
+ void addCommand(Command command);
+
+ Command[] getCommands();
+}
Propchange: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Chain.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Command.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Command.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Command.java (original)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Command.java Wed May 10 08:49:42 2006
@@ -1,30 +1,30 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.core.chain;
-
-/**
- * <p>
- * An encapsulation for a unit of work that needs to performed to accomplish a task.
- * A Command chooses whether to execute based on the information available to it in
- * the {@link Context}.
- * </p>
- */
-public interface Command {
-
- boolean execute(Context context) throws Exception;
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.chain;
+
+/**
+ * <p>
+ * An encapsulation for a unit of work that needs to performed to accomplish a task.
+ * A Command chooses whether to execute based on the information available to it in
+ * the {@link Context}.
+ * </p>
+ */
+public interface Command {
+
+ boolean execute(Context context) throws Exception;
+}
Propchange: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Command.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Context.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Context.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Context.java (original)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Context.java Wed May 10 08:49:42 2006
@@ -1,30 +1,30 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.core.chain;
-
-import java.util.Map;
-
-/**
- * <p>
- * Marker interface that extends {@link Map} to provide key / value pairs of contextual
- * information when executing a chain of commands.
- * </p>
- */
-public interface Context
- extends Map {
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.chain;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * Marker interface that extends {@link Map} to provide key / value pairs of contextual
+ * information when executing a chain of commands.
+ * </p>
+ */
+public interface Context
+ extends Map {
+}
Propchange: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Context.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogBase.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogBase.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogBase.java (original)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogBase.java Wed May 10 08:49:42 2006
@@ -1,58 +1,58 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.core.chain.impl;
-
-import java.util.Iterator;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.beehive.netui.core.chain.Catalog;
-import org.apache.beehive.netui.core.chain.Command;
-
-/**
- *
- */
-public class CatalogBase
- implements Catalog {
-
- private ConcurrentHashMap _commands = new ConcurrentHashMap();
-
- public void addCommand(String name, Command command) {
- _commands.put(name, command);
- }
-
- public Command getCommand(String name) {
- return (Command)_commands.get(name);
- }
-
- public Iterator getNames() {
- return _commands.keySet().iterator();
- }
-
- public String toString() {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("[").append(getClass().getName()).append(": ");
- Iterator names = _commands.keySet().iterator();
- while(names.hasNext()) {
- stringBuilder.append(names.next());
- if(names.hasNext())
- stringBuilder.append(",");
- }
- stringBuilder.append("]");
- return stringBuilder.toString();
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.chain.impl;
+
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.beehive.netui.core.chain.Catalog;
+import org.apache.beehive.netui.core.chain.Command;
+
+/**
+ *
+ */
+public class CatalogBase
+ implements Catalog {
+
+ private ConcurrentHashMap _commands = new ConcurrentHashMap();
+
+ public void addCommand(String name, Command command) {
+ _commands.put(name, command);
+ }
+
+ public Command getCommand(String name) {
+ return (Command)_commands.get(name);
+ }
+
+ public Iterator getNames() {
+ return _commands.keySet().iterator();
+ }
+
+ public String toString() {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("[").append(getClass().getName()).append(": ");
+ Iterator names = _commands.keySet().iterator();
+ while(names.hasNext()) {
+ stringBuilder.append(names.next());
+ if(names.hasNext())
+ stringBuilder.append(",");
+ }
+ stringBuilder.append("]");
+ return stringBuilder.toString();
+ }
+}
Propchange: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogFactoryBase.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogFactoryBase.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogFactoryBase.java (original)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogFactoryBase.java Wed May 10 08:49:42 2006
@@ -1,61 +1,61 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.core.chain.impl;
-
-import java.util.HashMap;
-
-import org.apache.beehive.netui.core.chain.CatalogFactory;
-import org.apache.beehive.netui.core.chain.Catalog;
-
-/**
- * <p>
- * This is a simple {@link CatalogFactory} implementation that supports a two step lifecycle
- * where {@link Catalog}s are added and can then be retrieved. Once reading of catalogs starts,
- * no more catalogs can be added. This avoids an unnecessary synchronization point
- * for every catalog access and makes Catalog lookups fast.
- * </p>
- */
-public class CatalogFactoryBase
- extends CatalogFactory {
-
- private boolean _locked = false;
- private Catalog _defaultCatalog;
- private HashMap _catalogs = new HashMap();
-
- public void setCatalog(Catalog catalog) {
- _defaultCatalog = catalog;
- }
-
- public Catalog getCatalog() {
- return _defaultCatalog;
- }
-
- public void addCatalog(String name, Catalog catalog) {
- if(_locked)
- throw new IllegalStateException();
-
- synchronized(_catalogs) {
- _catalogs.put(name, catalog);
- }
- }
-
- public Catalog getCatalog(String name) {
- _locked = true;
- return (Catalog)_catalogs.get(name);
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.chain.impl;
+
+import java.util.HashMap;
+
+import org.apache.beehive.netui.core.chain.CatalogFactory;
+import org.apache.beehive.netui.core.chain.Catalog;
+
+/**
+ * <p>
+ * This is a simple {@link CatalogFactory} implementation that supports a two step lifecycle
+ * where {@link Catalog}s are added and can then be retrieved. Once reading of catalogs starts,
+ * no more catalogs can be added. This avoids an unnecessary synchronization point
+ * for every catalog access and makes Catalog lookups fast.
+ * </p>
+ */
+public class CatalogFactoryBase
+ extends CatalogFactory {
+
+ private boolean _locked = false;
+ private Catalog _defaultCatalog;
+ private HashMap _catalogs = new HashMap();
+
+ public void setCatalog(Catalog catalog) {
+ _defaultCatalog = catalog;
+ }
+
+ public Catalog getCatalog() {
+ return _defaultCatalog;
+ }
+
+ public void addCatalog(String name, Catalog catalog) {
+ if(_locked)
+ throw new IllegalStateException();
+
+ synchronized(_catalogs) {
+ _catalogs.put(name, catalog);
+ }
+ }
+
+ public Catalog getCatalog(String name) {
+ _locked = true;
+ return (Catalog)_catalogs.get(name);
+ }
+}
Propchange: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogFactoryBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ChainBase.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ChainBase.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ChainBase.java (original)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ChainBase.java Wed May 10 08:49:42 2006
@@ -1,89 +1,89 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.core.chain.impl;
-
-import org.apache.beehive.netui.core.chain.Chain;
-import org.apache.beehive.netui.core.chain.Command;
-import org.apache.beehive.netui.core.chain.Context;
-
-/**
- *
- */
-public class ChainBase
- implements Chain {
-
- private Command[] _commands = new Command[0];
- private boolean _frozen;
-
- public ChainBase() {
- }
-
- /**
- * Add a command to the chian.
- * @param command the new command
- */
- public void addCommand(Command command) {
- if(command == null)
- throw new IllegalArgumentException();
-
- if(_frozen)
- throw new IllegalStateException();
-
- Command[] results = new Command[_commands.length + 1];
- System.arraycopy(_commands, 0, results, 0, _commands.length);
- results[_commands.length] = command;
- _commands = results;
- }
-
- public Command[] getCommands() {
- return _commands;
- }
-
- /**
- * Execute the chain using the provided {@link Context}.
- *
- * @param context
- * @return
- * @throws Exception
- */
- public boolean execute(Context context)
- throws Exception {
- if(context == null)
- throw new IllegalArgumentException();
-
- if(!_frozen)
- _frozen = true;
-
- boolean result = false;
- Exception saveException = null;
- for(int i = 0; i < _commands.length; i++) {
- try {
- result = _commands[i].execute(context);
- if(result)
- break;
- }
- catch(Exception e) {
- saveException = e;
- }
- }
-
- if(saveException != null)
- throw saveException;
- else return result;
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.chain.impl;
+
+import org.apache.beehive.netui.core.chain.Chain;
+import org.apache.beehive.netui.core.chain.Command;
+import org.apache.beehive.netui.core.chain.Context;
+
+/**
+ *
+ */
+public class ChainBase
+ implements Chain {
+
+ private Command[] _commands = new Command[0];
+ private boolean _frozen;
+
+ public ChainBase() {
+ }
+
+ /**
+ * Add a command to the chian.
+ * @param command the new command
+ */
+ public void addCommand(Command command) {
+ if(command == null)
+ throw new IllegalArgumentException();
+
+ if(_frozen)
+ throw new IllegalStateException();
+
+ Command[] results = new Command[_commands.length + 1];
+ System.arraycopy(_commands, 0, results, 0, _commands.length);
+ results[_commands.length] = command;
+ _commands = results;
+ }
+
+ public Command[] getCommands() {
+ return _commands;
+ }
+
+ /**
+ * Execute the chain using the provided {@link Context}.
+ *
+ * @param context
+ * @return
+ * @throws Exception
+ */
+ public boolean execute(Context context)
+ throws Exception {
+ if(context == null)
+ throw new IllegalArgumentException();
+
+ if(!_frozen)
+ _frozen = true;
+
+ boolean result = false;
+ Exception saveException = null;
+ for(int i = 0; i < _commands.length; i++) {
+ try {
+ result = _commands[i].execute(context);
+ if(result)
+ break;
+ }
+ catch(Exception e) {
+ saveException = e;
+ }
+ }
+
+ if(saveException != null)
+ throw saveException;
+ else return result;
+ }
+}
Propchange: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ChainBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ContextBase.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ContextBase.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ContextBase.java (original)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ContextBase.java Wed May 10 08:49:42 2006
@@ -1,34 +1,34 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.core.chain.impl;
-
-import java.util.Set;
-import java.util.HashMap;
-
-import org.apache.beehive.netui.core.chain.Context;
-
-/**
- */
-public class ContextBase
- extends HashMap
- implements Context {
-
- public Set entrySet() {
- return super.entrySet();
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.chain.impl;
+
+import java.util.Set;
+import java.util.HashMap;
+
+import org.apache.beehive.netui.core.chain.Context;
+
+/**
+ */
+public class ContextBase
+ extends HashMap
+ implements Context {
+
+ public Set entrySet() {
+ return super.entrySet();
+ }
+}
Propchange: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ContextBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/WebChainContext.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/WebChainContext.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/WebChainContext.java (original)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/WebChainContext.java Wed May 10 08:49:42 2006
@@ -1,74 +1,74 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.core.chain.web;
-
-import java.util.HashMap;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletResponse;
-import javax.servlet.ServletRequest;
-
-import org.apache.beehive.netui.core.chain.Context;
-
-/**
- *
- */
-public class WebChainContext
- extends HashMap
- implements Context {
-
- private ServletContext _servletContext;
- private ServletRequest _servletRequest;
- private ServletResponse _servletResponse;
-
- public WebChainContext() {
- }
-
- public WebChainContext(ServletContext servletContext,
- ServletRequest servletRequest,
- ServletResponse servletResponse)
- {
- _servletContext = servletContext;
- _servletRequest = servletRequest;
- _servletResponse = servletResponse;
- }
-
- public ServletContext getServletContext() {
- return _servletContext;
- }
-
- public void setServletContext(ServletContext servletContext) {
- _servletContext = servletContext;
- }
-
- public ServletRequest getServletRequest() {
- return _servletRequest;
- }
-
- public void setServletRequest(ServletRequest servletRequest) {
- _servletRequest = servletRequest;
- }
-
- public ServletResponse getServletResponse() {
- return _servletResponse;
- }
-
- public void setServletResponse(ServletResponse servletResponse) {
- _servletResponse = servletResponse;
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.core.chain.web;
+
+import java.util.HashMap;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.ServletRequest;
+
+import org.apache.beehive.netui.core.chain.Context;
+
+/**
+ *
+ */
+public class WebChainContext
+ extends HashMap
+ implements Context {
+
+ private ServletContext _servletContext;
+ private ServletRequest _servletRequest;
+ private ServletResponse _servletResponse;
+
+ public WebChainContext() {
+ }
+
+ public WebChainContext(ServletContext servletContext,
+ ServletRequest servletRequest,
+ ServletResponse servletResponse)
+ {
+ _servletContext = servletContext;
+ _servletRequest = servletRequest;
+ _servletResponse = servletResponse;
+ }
+
+ public ServletContext getServletContext() {
+ return _servletContext;
+ }
+
+ public void setServletContext(ServletContext servletContext) {
+ _servletContext = servletContext;
+ }
+
+ public ServletRequest getServletRequest() {
+ return _servletRequest;
+ }
+
+ public void setServletRequest(ServletRequest servletRequest) {
+ _servletRequest = servletRequest;
+ }
+
+ public ServletResponse getServletResponse() {
+ return _servletResponse;
+ }
+
+ public void setServletResponse(ServletResponse servletResponse) {
+ _servletResponse = servletResponse;
+ }
+}
Propchange: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/WebChainContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: beehive/trunk/netui/src/pageflow/beehive-netui-core.pom
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionFormBean.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionFormBean.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionFormBean.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionFormBean.java Wed May 10 08:49:42 2006
@@ -1,88 +1,88 @@
-/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.pageflow.config;
-
-import org.apache.struts.config.FormBeanConfig;
-import org.apache.struts.action.ActionFormBean;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionServlet;
-import org.apache.beehive.netui.pageflow.handler.ReloadableClassHandler;
-import org.apache.beehive.netui.pageflow.handler.Handlers;
-import org.apache.beehive.netui.util.logging.Logger;
-
-
-/**
- * Class to handle our extensions to the Struts <form-bean> element.
- */
-public class PageFlowActionFormBean extends ActionFormBean
-{
- private static final Logger _log = Logger.getInstance(PageFlowActionFormBean.class);
-
- private String _actualType; // applicable for non-ActionForm-derived form types
-
-
- public String getActualType()
- {
- return _actualType;
- }
-
- public void setActualType(String actualType)
- {
- _actualType = actualType;
- }
-
- /**
- * <p>
- * Create and return an <code>ActionForm</code> instance appropriate
- * to the information in this <code>FormBeanConfig</code>.
- * </p>
- * <p>
- * This is different than the base implementation in that it uses our ReloadableClassHandler
- * to load the form bean class.
- * </p>
- *
- * @param servlet The action servlet
- * @return ActionForm instance
- * @exception IllegalAccessException if the Class or the appropriate
- * constructor is not accessible
- * @exception InstantiationException if this Class represents an abstract
- * class, an array class, a primitive type, or void; or if instantiation
- * fails for some other reason
- */
- public ActionForm createActionForm(ActionServlet servlet)
- throws IllegalAccessException, InstantiationException {
-
-
- // Create a new form bean instance
- if (getDynamic()) {
- return super.createActionForm(servlet);
- }
-
- try {
- ReloadableClassHandler rch = Handlers.get(servlet.getServletContext()).getReloadableClassHandler();
- Object obj = rch.newInstance(getType());
- assert obj instanceof ActionForm : obj.getClass().getName();
- ActionForm form = (ActionForm) obj;
- form.setServlet(servlet);
- return form;
- } catch (ClassNotFoundException e) {
- _log.error("Could not find form bean class " + getType(), e);
- return null;
- }
- }
-}
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow.config;
+
+import org.apache.struts.config.FormBeanConfig;
+import org.apache.struts.action.ActionFormBean;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionServlet;
+import org.apache.beehive.netui.pageflow.handler.ReloadableClassHandler;
+import org.apache.beehive.netui.pageflow.handler.Handlers;
+import org.apache.beehive.netui.util.logging.Logger;
+
+
+/**
+ * Class to handle our extensions to the Struts <form-bean> element.
+ */
+public class PageFlowActionFormBean extends ActionFormBean
+{
+ private static final Logger _log = Logger.getInstance(PageFlowActionFormBean.class);
+
+ private String _actualType; // applicable for non-ActionForm-derived form types
+
+
+ public String getActualType()
+ {
+ return _actualType;
+ }
+
+ public void setActualType(String actualType)
+ {
+ _actualType = actualType;
+ }
+
+ /**
+ * <p>
+ * Create and return an <code>ActionForm</code> instance appropriate
+ * to the information in this <code>FormBeanConfig</code>.
+ * </p>
+ * <p>
+ * This is different than the base implementation in that it uses our ReloadableClassHandler
+ * to load the form bean class.
+ * </p>
+ *
+ * @param servlet The action servlet
+ * @return ActionForm instance
+ * @exception IllegalAccessException if the Class or the appropriate
+ * constructor is not accessible
+ * @exception InstantiationException if this Class represents an abstract
+ * class, an array class, a primitive type, or void; or if instantiation
+ * fails for some other reason
+ */
+ public ActionForm createActionForm(ActionServlet servlet)
+ throws IllegalAccessException, InstantiationException {
+
+
+ // Create a new form bean instance
+ if (getDynamic()) {
+ return super.createActionForm(servlet);
+ }
+
+ try {
+ ReloadableClassHandler rch = Handlers.get(servlet.getServletContext()).getReloadableClassHandler();
+ Object obj = rch.newInstance(getType());
+ assert obj instanceof ActionForm : obj.getClass().getName();
+ ActionForm form = (ActionForm) obj;
+ form.setServlet(servlet);
+ return form;
+ } catch (ClassNotFoundException e) {
+ _log.error("Could not find form bean class " + getType(), e);
+ return null;
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowActionFormBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalExpressionUtils.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalExpressionUtils.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalExpressionUtils.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalExpressionUtils.java Wed May 10 08:49:42 2006
@@ -1,298 +1,298 @@
-/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.pageflow.internal;
-
-import java.util.Map;
-import java.util.Enumeration;
-import java.util.HashMap;
-
-import javax.servlet.ServletContext;
-import javax.servlet.jsp.el.ExpressionEvaluator;
-import javax.servlet.jsp.el.VariableResolver;
-import javax.servlet.jsp.el.ELException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.Cookie;
-
-import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.commons.el.ExpressionEvaluatorImpl;
-import org.apache.commons.el.EnumeratedMap;
-
-/**
- * Internal class used to evaluate simple action expressions.
- *
- * todo: need to merge this down into the expression language registration infrastructure
- * todo: need to provdie an ImplicitObjectFactory that will create Maps for requestScope, sessionScope, etc.
- */
-public class InternalExpressionUtils
-{
- private static final Logger _logger = Logger.getInstance(InternalExpressionUtils.class);
-
- public static final boolean evaluateCondition(String expression,
- Object actionForm,
- HttpServletRequest request,
- ServletContext servletContext)
- throws ELException
- {
- return ((Boolean)evaluate(expression, Boolean.class, actionForm, request, servletContext)).booleanValue();
- }
-
- public static final String evaluateMessage(String expression, Object actionForm, HttpServletRequest request,
- ServletContext servletContext)
- throws ELException
- {
- return (String)evaluate(expression, String.class, actionForm, request, servletContext);
- }
-
- /* do not construct */
- private InternalExpressionUtils() {}
-
- private static final Object evaluate(String expression, Class expectedType, Object actionForm, HttpServletRequest request, ServletContext servletContext)
- throws ELException
- {
- // todo: can this be static / final?
- ExpressionEvaluator ee = getExpressionEvaluator();
- return ee.evaluate(expression, expectedType, getVariableResolver(actionForm, request, servletContext), null);
- }
-
- private static final ExpressionEvaluator getExpressionEvaluator()
- {
- return new ExpressionEvaluatorImpl();
- }
-
- private static final VariableResolver getVariableResolver(Object actionForm, HttpServletRequest request, ServletContext servletContext)
- {
- return new SimpleActionVariableResolver(actionForm, request, servletContext);
- }
-
- private static class SimpleActionVariableResolver
- implements VariableResolver
- {
- private Object _actionForm = null;
- private HttpServletRequest _request = null;
- private ServletContext _servletContext = null;
-
- private SimpleActionVariableResolver(Object actionForm, HttpServletRequest request, ServletContext servletContext)
- {
- _actionForm = actionForm;
- _request = request;
- _servletContext = servletContext;
- }
-
- public Object resolveVariable(String name)
- {
- // requestScope, sessionScope, applicationScope, param, paramValues, header, headerValues, cookie, initParam, <default>
- if(name.equals("actionForm"))
- return _actionForm;
- else if(name.equals("requestScope"))
- return buildRequestScopeMap(_request);
- else if(name.equals("sessionScope"))
- return buildSessionScopeMap(_request);
- else if(name.equals("applicationScope"))
- return buildServletContextMap(_servletContext);
- else if(name.equals("param"))
- return buildParamMap(_request);
- else if(name.equals("paramValues"))
- return buildParamsMap(_request);
- else if(name.equals("header"))
- return buildHeaderMap(_request);
- else if(name.equals("headerValues"))
- return buildHeadersMap(_request);
- else if(name.equals("cookie"))
- return buildCookieMap(_request);
- else if(name.equals("initParam"))
- return buildInitParamMap(_servletContext);
- // chain up the request > session (if exists) > application
- // note, this should handle pageFlow, globalApp, sharedFlow, and bundle if they're in the request
- // attribute map already
- else if(_request.getAttribute(name) != null)
- return _request.getAttribute(name);
- else if(_request.getSession(false) != null && _request.getSession(false).getAttribute(name) != null)
- return _request.getSession(false).getAttribute(name);
- else return _servletContext.getAttribute(name);
- }
-
- private static final Map buildCookieMap(HttpServletRequest httpServletRequest)
- {
- HttpServletRequest servletRequest = httpServletRequest;
- Map/*<String, Cookie>*/ cookieMap = new HashMap/*<String, Cookie>*/();
- Cookie[] cookies = servletRequest.getCookies();
- for(int i = 0; i < cookies.length; i++)
- {
- if(!cookieMap.containsKey(cookies[i].getName()))
- cookieMap.put(cookies[i].getName(), cookies[i]);
- }
- return cookieMap;
- }
-
- private static final Map buildHeadersMap(HttpServletRequest httpServletRequest)
- {
- final HttpServletRequest _servletRequest = httpServletRequest;
- return new EnumeratedMap()
- {
- public Enumeration enumerateKeys()
- {
- return _servletRequest.getHeaderNames();
- }
-
- public Object getValue(Object key)
- {
- return (key instanceof String ? _servletRequest.getHeaders((String)key) : null);
- }
-
- public boolean isMutable() {return false;}
- };
- }
-
- private static final Map buildHeaderMap(HttpServletRequest httpServletRequest)
- {
- final HttpServletRequest _servletRequest = httpServletRequest;
- return new EnumeratedMap()
- {
- public Enumeration enumerateKeys()
- {
- return _servletRequest.getHeaderNames();
- }
-
- public Object getValue(Object key)
- {
- return (key instanceof String ? _servletRequest.getHeader((String)key) : null);
- }
-
- public boolean isMutable() {return false;}
- };
- }
-
- private static final Map buildInitParamMap(ServletContext servletContext)
- {
- final ServletContext _servletContext = servletContext;
- return new EnumeratedMap()
- {
- public Enumeration enumerateKeys()
- {
- return _servletContext.getInitParameterNames();
- }
-
- public Object getValue(Object key)
- {
- return (key instanceof String ? _servletContext.getInitParameter((String)key) : null);
- }
-
- public boolean isMutable() {return false;}
- };
- }
-
- private static final Map buildParamsMap(HttpServletRequest servletRequest)
- {
- final HttpServletRequest _servletRequest = servletRequest;
- return new EnumeratedMap()
- {
- public Enumeration enumerateKeys()
- {
- return _servletRequest.getParameterNames();
- }
-
- public Object getValue(Object key)
- {
- return (key instanceof String ? _servletRequest.getParameterValues((String)key) : null);
- }
-
- public boolean isMutable() {return false;}
- };
- }
-
- private static final Map buildParamMap(HttpServletRequest servletRequest)
- {
- final HttpServletRequest _servletRequest = servletRequest;
- return new EnumeratedMap()
- {
- public Enumeration enumerateKeys()
- {
- return _servletRequest.getParameterNames();
- }
-
- public Object getValue(Object key)
- {
- return (key instanceof String ? _servletRequest.getParameter((String)key) : null);
- }
-
- public boolean isMutable() {return false;}
- };
- }
-
- private static final Map buildRequestScopeMap(HttpServletRequest servletRequest)
- {
- final HttpServletRequest _servletRequest = servletRequest;
- return new EnumeratedMap()
- {
- public Enumeration enumerateKeys()
- {
- return _servletRequest.getAttributeNames();
- }
-
- public Object getValue(Object key)
- {
- return (key instanceof String ? _servletRequest.getAttribute((String)key) : null);
- }
-
- public boolean isMutable() {return false;}
- };
- }
-
- private static final Map buildSessionScopeMap(HttpServletRequest servletRequest)
- {
- if(servletRequest.getSession(false) == null)
- return null;
-
- final HttpSession _session = servletRequest.getSession(false);
- return new EnumeratedMap()
- {
- public Enumeration enumerateKeys()
- {
- return _session.getAttributeNames();
- }
-
- public Object getValue(Object key)
- {
- return (key instanceof String ? _session.getAttribute((String)key) : null);
- }
-
- public boolean isMutable() {return false;}
- };
- }
-
- private static final Map buildServletContextMap(ServletContext servletContext)
- {
- final ServletContext _servletContext = servletContext;
- return new EnumeratedMap()
- {
- public Enumeration enumerateKeys()
- {
- return _servletContext.getAttributeNames();
- }
-
- public Object getValue(Object key)
- {
- return (key instanceof String ? _servletContext.getAttribute((String)key) : null);
- }
-
- public boolean isMutable() {return false;}
- };
- }
- }
-}
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow.internal;
+
+import java.util.Map;
+import java.util.Enumeration;
+import java.util.HashMap;
+
+import javax.servlet.ServletContext;
+import javax.servlet.jsp.el.ExpressionEvaluator;
+import javax.servlet.jsp.el.VariableResolver;
+import javax.servlet.jsp.el.ELException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.Cookie;
+
+import org.apache.beehive.netui.util.logging.Logger;
+import org.apache.commons.el.ExpressionEvaluatorImpl;
+import org.apache.commons.el.EnumeratedMap;
+
+/**
+ * Internal class used to evaluate simple action expressions.
+ *
+ * todo: need to merge this down into the expression language registration infrastructure
+ * todo: need to provdie an ImplicitObjectFactory that will create Maps for requestScope, sessionScope, etc.
+ */
+public class InternalExpressionUtils
+{
+ private static final Logger _logger = Logger.getInstance(InternalExpressionUtils.class);
+
+ public static final boolean evaluateCondition(String expression,
+ Object actionForm,
+ HttpServletRequest request,
+ ServletContext servletContext)
+ throws ELException
+ {
+ return ((Boolean)evaluate(expression, Boolean.class, actionForm, request, servletContext)).booleanValue();
+ }
+
+ public static final String evaluateMessage(String expression, Object actionForm, HttpServletRequest request,
+ ServletContext servletContext)
+ throws ELException
+ {
+ return (String)evaluate(expression, String.class, actionForm, request, servletContext);
+ }
+
+ /* do not construct */
+ private InternalExpressionUtils() {}
+
+ private static final Object evaluate(String expression, Class expectedType, Object actionForm, HttpServletRequest request, ServletContext servletContext)
+ throws ELException
+ {
+ // todo: can this be static / final?
+ ExpressionEvaluator ee = getExpressionEvaluator();
+ return ee.evaluate(expression, expectedType, getVariableResolver(actionForm, request, servletContext), null);
+ }
+
+ private static final ExpressionEvaluator getExpressionEvaluator()
+ {
+ return new ExpressionEvaluatorImpl();
+ }
+
+ private static final VariableResolver getVariableResolver(Object actionForm, HttpServletRequest request, ServletContext servletContext)
+ {
+ return new SimpleActionVariableResolver(actionForm, request, servletContext);
+ }
+
+ private static class SimpleActionVariableResolver
+ implements VariableResolver
+ {
+ private Object _actionForm = null;
+ private HttpServletRequest _request = null;
+ private ServletContext _servletContext = null;
+
+ private SimpleActionVariableResolver(Object actionForm, HttpServletRequest request, ServletContext servletContext)
+ {
+ _actionForm = actionForm;
+ _request = request;
+ _servletContext = servletContext;
+ }
+
+ public Object resolveVariable(String name)
+ {
+ // requestScope, sessionScope, applicationScope, param, paramValues, header, headerValues, cookie, initParam, <default>
+ if(name.equals("actionForm"))
+ return _actionForm;
+ else if(name.equals("requestScope"))
+ return buildRequestScopeMap(_request);
+ else if(name.equals("sessionScope"))
+ return buildSessionScopeMap(_request);
+ else if(name.equals("applicationScope"))
+ return buildServletContextMap(_servletContext);
+ else if(name.equals("param"))
+ return buildParamMap(_request);
+ else if(name.equals("paramValues"))
+ return buildParamsMap(_request);
+ else if(name.equals("header"))
+ return buildHeaderMap(_request);
+ else if(name.equals("headerValues"))
+ return buildHeadersMap(_request);
+ else if(name.equals("cookie"))
+ return buildCookieMap(_request);
+ else if(name.equals("initParam"))
+ return buildInitParamMap(_servletContext);
+ // chain up the request > session (if exists) > application
+ // note, this should handle pageFlow, globalApp, sharedFlow, and bundle if they're in the request
+ // attribute map already
+ else if(_request.getAttribute(name) != null)
+ return _request.getAttribute(name);
+ else if(_request.getSession(false) != null && _request.getSession(false).getAttribute(name) != null)
+ return _request.getSession(false).getAttribute(name);
+ else return _servletContext.getAttribute(name);
+ }
+
+ private static final Map buildCookieMap(HttpServletRequest httpServletRequest)
+ {
+ HttpServletRequest servletRequest = httpServletRequest;
+ Map/*<String, Cookie>*/ cookieMap = new HashMap/*<String, Cookie>*/();
+ Cookie[] cookies = servletRequest.getCookies();
+ for(int i = 0; i < cookies.length; i++)
+ {
+ if(!cookieMap.containsKey(cookies[i].getName()))
+ cookieMap.put(cookies[i].getName(), cookies[i]);
+ }
+ return cookieMap;
+ }
+
+ private static final Map buildHeadersMap(HttpServletRequest httpServletRequest)
+ {
+ final HttpServletRequest _servletRequest = httpServletRequest;
+ return new EnumeratedMap()
+ {
+ public Enumeration enumerateKeys()
+ {
+ return _servletRequest.getHeaderNames();
+ }
+
+ public Object getValue(Object key)
+ {
+ return (key instanceof String ? _servletRequest.getHeaders((String)key) : null);
+ }
+
+ public boolean isMutable() {return false;}
+ };
+ }
+
+ private static final Map buildHeaderMap(HttpServletRequest httpServletRequest)
+ {
+ final HttpServletRequest _servletRequest = httpServletRequest;
+ return new EnumeratedMap()
+ {
+ public Enumeration enumerateKeys()
+ {
+ return _servletRequest.getHeaderNames();
+ }
+
+ public Object getValue(Object key)
+ {
+ return (key instanceof String ? _servletRequest.getHeader((String)key) : null);
+ }
+
+ public boolean isMutable() {return false;}
+ };
+ }
+
+ private static final Map buildInitParamMap(ServletContext servletContext)
+ {
+ final ServletContext _servletContext = servletContext;
+ return new EnumeratedMap()
+ {
+ public Enumeration enumerateKeys()
+ {
+ return _servletContext.getInitParameterNames();
+ }
+
+ public Object getValue(Object key)
+ {
+ return (key instanceof String ? _servletContext.getInitParameter((String)key) : null);
+ }
+
+ public boolean isMutable() {return false;}
+ };
+ }
+
+ private static final Map buildParamsMap(HttpServletRequest servletRequest)
+ {
+ final HttpServletRequest _servletRequest = servletRequest;
+ return new EnumeratedMap()
+ {
+ public Enumeration enumerateKeys()
+ {
+ return _servletRequest.getParameterNames();
+ }
+
+ public Object getValue(Object key)
+ {
+ return (key instanceof String ? _servletRequest.getParameterValues((String)key) : null);
+ }
+
+ public boolean isMutable() {return false;}
+ };
+ }
+
+ private static final Map buildParamMap(HttpServletRequest servletRequest)
+ {
+ final HttpServletRequest _servletRequest = servletRequest;
+ return new EnumeratedMap()
+ {
+ public Enumeration enumerateKeys()
+ {
+ return _servletRequest.getParameterNames();
+ }
+
+ public Object getValue(Object key)
+ {
+ return (key instanceof String ? _servletRequest.getParameter((String)key) : null);
+ }
+
+ public boolean isMutable() {return false;}
+ };
+ }
+
+ private static final Map buildRequestScopeMap(HttpServletRequest servletRequest)
+ {
+ final HttpServletRequest _servletRequest = servletRequest;
+ return new EnumeratedMap()
+ {
+ public Enumeration enumerateKeys()
+ {
+ return _servletRequest.getAttributeNames();
+ }
+
+ public Object getValue(Object key)
+ {
+ return (key instanceof String ? _servletRequest.getAttribute((String)key) : null);
+ }
+
+ public boolean isMutable() {return false;}
+ };
+ }
+
+ private static final Map buildSessionScopeMap(HttpServletRequest servletRequest)
+ {
+ if(servletRequest.getSession(false) == null)
+ return null;
+
+ final HttpSession _session = servletRequest.getSession(false);
+ return new EnumeratedMap()
+ {
+ public Enumeration enumerateKeys()
+ {
+ return _session.getAttributeNames();
+ }
+
+ public Object getValue(Object key)
+ {
+ return (key instanceof String ? _session.getAttribute((String)key) : null);
+ }
+
+ public boolean isMutable() {return false;}
+ };
+ }
+
+ private static final Map buildServletContextMap(ServletContext servletContext)
+ {
+ final ServletContext _servletContext = servletContext;
+ return new EnumeratedMap()
+ {
+ public Enumeration enumerateKeys()
+ {
+ return _servletContext.getAttributeNames();
+ }
+
+ public Object getValue(Object key)
+ {
+ return (key instanceof String ? _servletContext.getAttribute((String)key) : null);
+ }
+
+ public boolean isMutable() {return false;}
+ };
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalExpressionUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/INameable.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/INameable.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/INameable.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/INameable.java Wed May 10 08:49:42 2006
@@ -1,41 +1,41 @@
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.pageflow.requeststate;
-
-/**
- * This interface defines what it means to be a namable object. The name
- * service will name an INameable object which will be unique for the life
- * time of the session.
- */
-public interface INameable
- {
- /**
- * Set the ObjectName of the INameable object. This should only
- * be set once. If it is called a second time an IllegalStateException
- * should be thrown
- * @param name the Object's name.
- * @throws IllegalStateException if this method is called more than once for an object
- */
- public void setObjectName(String name);
-
- /**
- * Returns the ObjectName of the INameable object.
- * @return the ObjectName.
- */
- public String getObjectName();
-}
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow.requeststate;
+
+/**
+ * This interface defines what it means to be a namable object. The name
+ * service will name an INameable object which will be unique for the life
+ * time of the session.
+ */
+public interface INameable
+ {
+ /**
+ * Set the ObjectName of the INameable object. This should only
+ * be set once. If it is called a second time an IllegalStateException
+ * should be thrown
+ * @param name the Object's name.
+ * @throws IllegalStateException if this method is called more than once for an object
+ */
+ public void setObjectName(String name);
+
+ /**
+ * Returns the ObjectName of the INameable object.
+ * @return the ObjectName.
+ */
+ public String getObjectName();
+}
Propchange: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/INameable.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/LazyMap.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/LazyMap.java?rev=405785&r1=405784&r2=405785&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/LazyMap.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/LazyMap.java Wed May 10 08:49:42 2006
@@ -1,115 +1,115 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Header:$
- */
-package org.apache.beehive.netui.pageflow.requeststate;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.Collection;
-import java.util.HashMap;
-
-/**
- * This class implements the <code>java.util.Map</code> interface in a lazy way. It will delegate to the
- * <code>java.util.HashMap</code> for the real implementation. The HashMap will only be created when it
- * certain methods are called such as <code>put</code>, <code>get</code>, etc.
- */
-class LazyMap implements Map
-{
- private HashMap _map;
-
- final boolean isMapCreated() {
- return (_map != null);
- }
-
- ///************************* This is the MAP interface implementation *************************
-
- final public int size() {
- return (_map == null) ? 0 : _map.size();
- }
-
- final public boolean isEmpty() {
- return (_map == null) || _map.isEmpty();
- }
-
- final public boolean containsKey(Object key) {
- return (_map != null) && _map.containsKey(key);
- }
-
- final public boolean containsValue(Object value) {
- return (_map != null) && _map.containsValue(value);
- }
-
- final public Object get(Object key) {
- Map map = getMap();
- return map.get(key);
- }
-
- final public Object put(Object key, Object value) {
- Map map = getMap();
- return map.put(key,value);
- }
-
- final public Object remove(Object key) {
- Map map = getMap();
- return map.remove(key);
- }
-
- final public void putAll(Map t) {
- Map map = getMap();
- map.putAll(t);
- }
-
- final public void clear() {
- if (_map != null)
- _map.clear();
- }
-
- final public Set keySet() {
- Map map = getMap();
- return map.keySet();
- }
-
- final public Collection values() {
- Map map = getMap();
- return map.values();
- }
-
- final public Set entrySet() {
- Map map = getMap();
- return map.entrySet();
- }
-
- /****************************************** End Map Interface **********************************************
-
- /**
- * This method will return the map. If the map hasn't been created
- * it will be created. This is done in a thread safe way.
- * @return the map implementation.
- */
- private Map getMap()
- {
- if (_map != null)
- return _map;
-
- synchronized (this) {
- if (_map != null)
- return _map;
- _map = new HashMap();
- }
- return _map;
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow.requeststate;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+import java.util.HashMap;
+
+/**
+ * This class implements the <code>java.util.Map</code> interface in a lazy way. It will delegate to the
+ * <code>java.util.HashMap</code> for the real implementation. The HashMap will only be created when it
+ * certain methods are called such as <code>put</code>, <code>get</code>, etc.
+ */
+class LazyMap implements Map
+{
+ private HashMap _map;
+
+ final boolean isMapCreated() {
+ return (_map != null);
+ }
+
+ ///************************* This is the MAP interface implementation *************************
+
+ final public int size() {
+ return (_map == null) ? 0 : _map.size();
+ }
+
+ final public boolean isEmpty() {
+ return (_map == null) || _map.isEmpty();
+ }
+
+ final public boolean containsKey(Object key) {
+ return (_map != null) && _map.containsKey(key);
+ }
+
+ final public boolean containsValue(Object value) {
+ return (_map != null) && _map.containsValue(value);
+ }
+
+ final public Object get(Object key) {
+ Map map = getMap();
+ return map.get(key);
+ }
+
+ final public Object put(Object key, Object value) {
+ Map map = getMap();
+ return map.put(key,value);
+ }
+
+ final public Object remove(Object key) {
+ Map map = getMap();
+ return map.remove(key);
+ }
+
+ final public void putAll(Map t) {
+ Map map = getMap();
+ map.putAll(t);
+ }
+
+ final public void clear() {
+ if (_map != null)
+ _map.clear();
+ }
+
+ final public Set keySet() {
+ Map map = getMap();
+ return map.keySet();
+ }
+
+ final public Collection values() {
+ Map map = getMap();
+ return map.values();
+ }
+
+ final public Set entrySet() {
+ Map map = getMap();
+ return map.entrySet();
+ }
+
+ /****************************************** End Map Interface **********************************************
+
+ /**
+ * This method will return the map. If the map hasn't been created
+ * it will be created. This is done in a thread safe way.
+ * @return the map implementation.
+ */
+ private Map getMap()
+ {
+ if (_map != null)
+ return _map;
+
+ synchronized (this) {
+ if (_map != null)
+ return _map;
+ _map = new HashMap();
+ }
+ return _map;
+ }
+}
Propchange: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/requeststate/LazyMap.java
------------------------------------------------------------------------------
svn:eol-style = native