You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by bf...@apache.org on 2011/10/30 08:48:20 UTC

svn commit: r1195126 - in /oodt/branches/cas-cl/src: main/java/org/apache/oodt/cas/cl/ main/java/org/apache/oodt/cas/cl/action/store/ main/java/org/apache/oodt/cas/cl/action/store/spring/ main/java/org/apache/oodt/cas/cl/option/handler/ main/java/org/a...

Author: bfoster
Date: Sun Oct 30 07:48:19 2011
New Revision: 1195126

URL: http://svn.apache.org/viewvc?rev=1195126&view=rev
Log:
- Split CmdLineStore into two class: one for options and another for actions
- Deleted CmdLineOptionBeanHandler... not longer needed ApplyToActionHandler does the job

Added:
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStore.java   (with props)
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStoreFactory.java   (with props)
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStore.java   (with props)
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStoreFactory.java   (with props)
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringSetContextInjectionType.java   (contents, props changed)
      - copied, changed from r1190721, oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringSetContextInjectionType.java
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToAction.java   (with props)
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToActionHandler.java   (contents, props changed)
      - copied, changed from r1190721, oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/StdCmdLineOptionHandler.java
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStore.java   (with props)
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStoreFactory.java   (with props)
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStore.java   (contents, props changed)
      - copied, changed from r1195118, oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringCmdLineStore.java
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStoreFactory.java   (contents, props changed)
      - copied, changed from r1190721, oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringCmdLineStoreFactory.java
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/action/
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/action/store/
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/action/store/spring/
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/action/store/spring/TestSpringCmdLineActionStore.java   (with props)
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/option/store/
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/option/store/spring/
      - copied from r1195118, oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/store/spring/
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/option/store/spring/TestSpringCmdLineOptionStore.java   (with props)
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestOutputStream.java   (contents, props changed)
      - copied, changed from r1195118, oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/store/spring/TestOutputStream.java
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestSetContextInjectTypeAction.java   (with props)
    oodt/branches/cas-cl/src/testdata/cmd-line-actions.xml   (contents, props changed)
      - copied, changed from r1195118, oodt/branches/cas-cl/src/testdata/cmd-line-action-beans.xml
    oodt/branches/cas-cl/src/testdata/cmd-line-options.xml   (contents, props changed)
      - copied, changed from r1195118, oodt/branches/cas-cl/src/testdata/cmd-line-option-beans.xml
Removed:
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/BeanInfo.java
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/CmdLineOptionBeanHandler.java
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/StdCmdLineOptionHandler.java
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/CmdLineStore.java
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/CmdLineStoreFactory.java
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/option/store/spring/TestOutputStream.java
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/option/store/spring/TestSpringCmdLineStore.java
    oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/store/spring/
    oodt/branches/cas-cl/src/testdata/cmd-line-action-beans.xml
    oodt/branches/cas-cl/src/testdata/cmd-line-config.xml
    oodt/branches/cas-cl/src/testdata/cmd-line-option-beans.xml
Modified:
    oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/CmdLineUtility.java

Modified: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/CmdLineUtility.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/CmdLineUtility.java?rev=1195126&r1=1195125&r2=1195126&view=diff
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/CmdLineUtility.java (original)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/CmdLineUtility.java Sun Oct 30 07:48:19 2011
@@ -16,6 +16,7 @@
  */
 package org.apache.oodt.cas.cl;
 
+//OODT static imports
 import static org.apache.oodt.cas.cl.util.CmdLineUtils.determineRequired;
 import static org.apache.oodt.cas.cl.util.CmdLineUtils.findActionOption;
 import static org.apache.oodt.cas.cl.util.CmdLineUtils.findHelpOption;
@@ -29,6 +30,8 @@ import java.util.Set;
 import org.apache.commons.lang.Validate;
 
 //OODT imports
+import org.apache.oodt.cas.cl.action.store.CmdLineActionStore;
+import org.apache.oodt.cas.cl.action.store.spring.SpringCmdLineActionStoreFactory;
 import org.apache.oodt.cas.cl.help.presenter.CmdLineOptionHelpPresenter;
 import org.apache.oodt.cas.cl.help.presenter.StdCmdLineOptionHelpPresenter;
 import org.apache.oodt.cas.cl.help.printer.CmdLineActionHelpPrinter;
@@ -41,10 +44,10 @@ import org.apache.oodt.cas.cl.option.Cmd
 import org.apache.oodt.cas.cl.option.CmdLineOptionInstance;
 import org.apache.oodt.cas.cl.option.HelpCmdLineOption;
 import org.apache.oodt.cas.cl.option.PrintSupportedActionsCmdLineOption;
+import org.apache.oodt.cas.cl.option.store.CmdLineOptionStore;
+import org.apache.oodt.cas.cl.option.store.spring.SpringCmdLineOptionStoreFactory;
 import org.apache.oodt.cas.cl.parser.CmdLineOptionParser;
 import org.apache.oodt.cas.cl.parser.StdCmdLineOptionParser;
-import org.apache.oodt.cas.cl.store.CmdLineStore;
-import org.apache.oodt.cas.cl.store.spring.SpringCmdLineStoreFactory;
 import org.apache.oodt.cas.cl.util.Args;
 import org.apache.oodt.cas.cl.util.CmdLineUtils;
 
@@ -60,7 +63,8 @@ import org.apache.oodt.cas.cl.util.CmdLi
 public class CmdLineUtility {
 
 	private CmdLineOptionParser parser;
-	private CmdLineStore optionStore;
+	private CmdLineOptionStore optionStore;
+	private CmdLineActionStore actionStore;
 	private CmdLineOptionHelpPrinter optionHelpPrinter;
 	private CmdLineActionHelpPrinter actionHelpPrinter;
 	private CmdLineActionsHelpPrinter actionsHelpPrinter;
@@ -68,20 +72,29 @@ public class CmdLineUtility {
 	
 	public CmdLineUtility() {
 		parser = new StdCmdLineOptionParser();
-		optionStore = new SpringCmdLineStoreFactory().createStore();
+		optionStore = new SpringCmdLineOptionStoreFactory().createStore();
+		actionStore = new SpringCmdLineActionStoreFactory().createStore();
 		optionHelpPrinter = new StdCmdLineOptionHelpPrinter();
 		actionHelpPrinter = new StdCmdLineActionHelpPrinter();
 		helpPresenter = new StdCmdLineOptionHelpPresenter();
 	}
 
-	public CmdLineStore getOptionStore() {
+	public CmdLineOptionStore getOptionStore() {
 		return optionStore;
 	}
 
-	public void setOptionStore(CmdLineStore optionStore) {
+	public void setOptionStore(CmdLineOptionStore optionStore) {
 		this.optionStore = optionStore;
 	}
 
+	public CmdLineActionStore getActionStore() {
+		return actionStore;
+	}
+
+	public void setActionStore(CmdLineActionStore actionStore) {
+		this.actionStore = actionStore;
+	}
+
 	public CmdLineOptionHelpPrinter getOptionHelpPrinter() {
 		return optionHelpPrinter;
 	}
@@ -174,7 +187,7 @@ public class CmdLineUtility {
 		}
 
  		// Parse command line arguments.
-		return new CmdLineArgs(optionStore.loadSupportedActions(), validOptions, parser.parse(new Args(args), validOptions));
+		return new CmdLineArgs(actionStore.loadSupportedActions(), validOptions, parser.parse(new Args(args), validOptions));
 	}
 
 	/**

Added: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStore.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStore.java?rev=1195126&view=auto
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStore.java (added)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStore.java Sun Oct 30 07:48:19 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.action.store;
+
+//JDK imports
+import java.util.Set;
+
+//OODT imports
+import org.apache.oodt.cas.cl.action.CmdLineAction;
+
+/**
+ * Storage for loading supported {@link CmdLineAction}s.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public interface CmdLineActionStore {
+
+	public Set<CmdLineAction> loadSupportedActions();
+
+}

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStoreFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStoreFactory.java?rev=1195126&view=auto
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStoreFactory.java (added)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStoreFactory.java Sun Oct 30 07:48:19 2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.action.store;
+
+/**
+ * Factory for creating {@link CmdLineActionStore}s.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public interface CmdLineActionStoreFactory {
+
+	public CmdLineActionStore createStore();
+
+}

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/CmdLineActionStoreFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStore.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStore.java?rev=1195126&view=auto
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStore.java (added)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStore.java Sun Oct 30 07:48:19 2011
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.action.store.spring;
+
+//JDK imports
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+//OODT imports
+import org.apache.oodt.cas.cl.action.CmdLineAction;
+import org.apache.oodt.cas.cl.action.store.CmdLineActionStore;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+
+/**
+ * A Spring Framework based {@link CmdLineActionStore}.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class SpringCmdLineActionStore implements CmdLineActionStore {
+
+	private ApplicationContext appContext;
+
+	public SpringCmdLineActionStore(String springConfig) {
+		appContext = new FileSystemXmlApplicationContext(springConfig);
+		handleSpringSetContextInjectionType();
+		handleSettingNameForCmdLineActions();
+	}
+
+	public Set<CmdLineAction> loadSupportedActions() {
+		@SuppressWarnings("unchecked")
+		Map<String, CmdLineAction> actionsMap = appContext
+				.getBeansOfType(CmdLineAction.class);
+		return new HashSet<CmdLineAction>(actionsMap.values());
+	}
+
+	protected ApplicationContext getApplicationContext() {
+		return appContext;
+	}
+
+	private void handleSpringSetContextInjectionType() {
+		@SuppressWarnings("unchecked")
+		Map<String, SpringSetContextInjectionType> beans = appContext
+				.getBeansOfType(SpringSetContextInjectionType.class);
+		for (SpringSetContextInjectionType bean : beans.values()) {
+			bean.setContext(appContext);
+		}
+	}
+
+	private void handleSettingNameForCmdLineActions() {
+		@SuppressWarnings("unchecked")
+		Map<String, CmdLineAction> beans = appContext
+		.getBeansOfType(CmdLineAction.class);
+		for (Entry<String, CmdLineAction> entry : beans.entrySet()) {
+			entry.getValue().setName(entry.getKey());
+		}
+	}
+}

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStoreFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStoreFactory.java?rev=1195126&view=auto
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStoreFactory.java (added)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStoreFactory.java Sun Oct 30 07:48:19 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.action.store.spring;
+
+//OODT imports
+import org.apache.oodt.cas.cl.action.store.CmdLineActionStoreFactory;
+
+/**
+ * Factory for creating {@link SpringCmdLineActionStore}s.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class SpringCmdLineActionStoreFactory implements CmdLineActionStoreFactory {
+
+	private String config;
+
+	public SpringCmdLineActionStoreFactory() {
+		config = System.getProperty("org.apache.oodt.cas.cl.option.action.spring.config", null);
+	}
+
+	public SpringCmdLineActionStore createStore() {
+		if (config != null) {
+			return new SpringCmdLineActionStore(config); 
+		} else {
+			return null;
+		}
+	}
+}

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringCmdLineActionStoreFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringSetContextInjectionType.java (from r1190721, oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringSetContextInjectionType.java)
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringSetContextInjectionType.java?p2=oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringSetContextInjectionType.java&p1=oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringSetContextInjectionType.java&r1=1190721&r2=1195126&rev=1195126&view=diff
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringSetContextInjectionType.java (original)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringSetContextInjectionType.java Sun Oct 30 07:48:19 2011
@@ -1,7 +1,31 @@
-package org.apache.oodt.cas.cl.store.spring;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.action.store.spring;
 
+//Spring imports
 import org.springframework.context.ApplicationContext;
 
+/**
+ * Interface which if implemented will have the Spring Framework
+ * {@link ApplicationContext} injected via the setter method
+ * after loading from Spring XML configuration.
+ *
+ * @author bfoster (Brian Foster)
+ */
 public interface SpringSetContextInjectionType {
 
 	public void setContext(ApplicationContext appContext);

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/action/store/spring/SpringSetContextInjectionType.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToAction.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToAction.java?rev=1195126&view=auto
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToAction.java (added)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToAction.java Sun Oct 30 07:48:19 2011
@@ -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 org.apache.oodt.cas.cl.option.handler;
+
+/**
+ * Mapping of {@link CmdLineAction} name to its method which should be called
+ * by {@link ApplyToActionHandler} when injecting argument value.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class ApplyToAction {
+
+	private String actionName;
+	private String methodName;
+
+	public ApplyToAction() {}
+
+	public ApplyToAction(String actionName, String methodName) {
+		this.actionName = actionName;
+		this.methodName = methodName;
+	}
+
+	public String getActionName() {
+		return actionName;
+	}
+
+	public void setActionName(String actionName) {
+		this.actionName = actionName;
+	}
+
+	public String getMethodName() {
+		return methodName;
+	}
+
+	public void setMethodName(String methodName) {
+		this.methodName = methodName;
+	}
+}

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToActionHandler.java (from r1190721, oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/StdCmdLineOptionHandler.java)
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToActionHandler.java?p2=oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToActionHandler.java&p1=oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/StdCmdLineOptionHandler.java&r1=1190721&r2=1195126&rev=1195126&view=diff
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/StdCmdLineOptionHandler.java (original)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToActionHandler.java Sun Oct 30 07:48:19 2011
@@ -1,39 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.oodt.cas.cl.option.handler;
 
+//OODT static imports
 import static org.apache.oodt.cas.cl.util.CmdLineUtils.convertToType;
 
+//JDK imports
 import java.util.Arrays;
 import java.util.List;
-import java.util.Map;
 
+//Apache imports
 import org.apache.commons.lang.StringUtils;
+
+//OODT imports
 import org.apache.oodt.cas.cl.action.CmdLineAction;
 import org.apache.oodt.cas.cl.option.CmdLineOption;
 import org.apache.oodt.cas.cl.option.CmdLineOptionInstance;
 
-public class StdCmdLineOptionHandler {
+//Google imports
+import com.google.common.annotations.VisibleForTesting;
+
+/**
+ * {@link CmdLineOptionHandler} which applies {@link CmdLineOption} values
+ * to given {@link CmdLineAction}.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class ApplyToActionHandler implements CmdLineOptionHandler {
 
-	private Map<String, String> actionToMethodMap;
+	private List<ApplyToAction> applyToActions;
+
+	public void setApplyToActions(List<ApplyToAction> applyToActions) {
+		this.applyToActions = applyToActions;
+	}
 
-	public void setActionToMethodMap(Map<String, String> actionToMethodMap) {
-		this.actionToMethodMap = actionToMethodMap;
+	public List<ApplyToAction> getApplyToActions() {
+		return applyToActions;
 	}
 
-	public void handleOption(CmdLineAction action, CmdLineOptionInstance optionInstance) {
+	public void handleOption(CmdLineAction action,
+			CmdLineOptionInstance optionInstance) {
 		try {
 			Class<?> type = optionInstance.getOption().getType();
 			List<?> vals = (optionInstance.getValues().isEmpty()) ? convertToType(
 					Arrays.asList(new String[] { "true" }), type = Boolean.TYPE)
 					: convertToType(optionInstance.getValues(), type);
-			if (actionToMethodMap != null && actionToMethodMap.containsKey(action.getName())) {
+			String methodName = getMethodName(action.getName());
+			if (methodName != null) {
 				action.getClass()
-						.getMethod(actionToMethodMap.get(action.getName()), type)
+						.getMethod(methodName, type)
 						.invoke(action, vals.toArray(new Object[vals.size()]));
 			} else {
 				action
 					.getClass()
 					.getMethod(
-							"set" + StringUtils.capitalize(optionInstance.getOption().getLongOption()), type)
+							"set" + StringUtils.capitalize(
+									optionInstance.getOption().getLongOption()), type)
 					.invoke(action, vals.toArray(new Object[vals.size()]));
 			}
 		} catch (Exception e) {
@@ -41,6 +77,18 @@ public class StdCmdLineOptionHandler {
 		}
 	}
 
+	@VisibleForTesting
+	protected String getMethodName(String actionName) {
+		if (applyToActions != null) {
+			for (ApplyToAction applyToAction : applyToActions) {
+				if (applyToAction.getActionName().equals(actionName)) {
+					return applyToAction.getMethodName();
+				}
+			}
+		}
+		return null;
+	}
+
 	public String getHelp(CmdLineOption option) {
 		return "Will invoke 'set" + option.getLongOption() + "' on action selected";
 	}

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/handler/ApplyToActionHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStore.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStore.java?rev=1195126&view=auto
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStore.java (added)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStore.java Sun Oct 30 07:48:19 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.option.store;
+
+//JDK imports
+import java.util.Set;
+
+//OODT imports
+import org.apache.oodt.cas.cl.option.CmdLineOption;
+
+/**
+ * Storage for loading supported {@link CmdLineOption}s.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public interface CmdLineOptionStore {
+
+	public Set<CmdLineOption> loadSupportedOptions();
+
+}

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStoreFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStoreFactory.java?rev=1195126&view=auto
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStoreFactory.java (added)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStoreFactory.java Sun Oct 30 07:48:19 2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.option.store;
+
+/**
+ * Factory for creating {@link CmdLineOptionStore}s.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public interface CmdLineOptionStoreFactory {
+
+	public CmdLineOptionStore createStore();
+
+}

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/CmdLineOptionStoreFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStore.java (from r1195118, oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringCmdLineStore.java)
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStore.java?p2=oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStore.java&p1=oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringCmdLineStore.java&r1=1195118&r2=1195126&rev=1195126&view=diff
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringCmdLineStore.java (original)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStore.java Sun Oct 30 07:48:19 2011
@@ -1,28 +1,45 @@
-package org.apache.oodt.cas.cl.store.spring;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.option.store.spring;
 
+//JDK imports
 import java.util.HashSet;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
-import java.util.UUID;
 
-import org.apache.oodt.cas.cl.action.CmdLineAction;
-import org.apache.oodt.cas.cl.option.AdvancedCmdLineOption;
+//OODT imports
 import org.apache.oodt.cas.cl.option.CmdLineOption;
-import org.apache.oodt.cas.cl.option.validator.CmdLineOptionValidator;
-import org.apache.oodt.cas.cl.store.CmdLineStore;
+import org.apache.oodt.cas.cl.option.store.CmdLineOptionStore;
 
+//Spring imports
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.FileSystemXmlApplicationContext;
 
-public class SpringCmdLineStore implements CmdLineStore {
+/**
+ * Spring Framework based {@link CmdLineOptionStore}.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class SpringCmdLineOptionStore implements CmdLineOptionStore {
 
 	private ApplicationContext appContext;
 
-	public SpringCmdLineStore(String springConfig) {
+	public SpringCmdLineOptionStore(String springConfig) {
 		appContext = new FileSystemXmlApplicationContext(springConfig);
-		handleSpringSetContextInjectionType();
-		handleSettingNameForCmdLineActions();
 	}
 
 	public Set<CmdLineOption> loadSupportedOptions() {
@@ -32,49 +49,7 @@ public class SpringCmdLineStore implemen
 		return new HashSet<CmdLineOption>(optionsMap.values());
 	}
 
-	public Set<CmdLineAction> loadSupportedActions() {
-		@SuppressWarnings("unchecked")
-		Map<String, CmdLineAction> actionsMap = appContext
-				.getBeansOfType(CmdLineAction.class);
-		return new HashSet<CmdLineAction>(actionsMap.values());
-	}
-
 	protected ApplicationContext getApplicationContext() {
 		return appContext;
 	}
-	
-	private void handleSpringSetContextInjectionType() {
-		@SuppressWarnings("unchecked")
-		Map<String, SpringSetContextInjectionType> beans = appContext
-				.getBeansOfType(SpringSetContextInjectionType.class);
-		@SuppressWarnings("unchecked")
-		Map<String, AdvancedCmdLineOption> options = appContext
-				.getBeansOfType(AdvancedCmdLineOption.class);
-		for (AdvancedCmdLineOption option : options.values()) {
-			if (option.hasHandler()
-					&& option.getHandler() instanceof SpringSetContextInjectionType) {
-				beans.put(UUID.randomUUID().toString(),
-						(SpringSetContextInjectionType) option.getHandler());
-			} else if (!option.getValidators().isEmpty()) {
-				for (CmdLineOptionValidator validator : option.getValidators()) {
-					if (validator instanceof SpringSetContextInjectionType) {
-						beans.put(UUID.randomUUID().toString(),
-								(SpringSetContextInjectionType) validator);
-					}
-				}
-			}
-		}
-		for (SpringSetContextInjectionType bean : beans.values()) {
-			bean.setContext(appContext);
-		}
-	}
-
-	private void handleSettingNameForCmdLineActions() {
-		@SuppressWarnings("unchecked")
-		Map<String, CmdLineAction> beans = appContext
-		.getBeansOfType(CmdLineAction.class);
-		for (Entry<String, CmdLineAction> entry : beans.entrySet()) {
-			entry.getValue().setName(entry.getKey());
-		}
-	}
 }

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStoreFactory.java (from r1190721, oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringCmdLineStoreFactory.java)
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStoreFactory.java?p2=oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStoreFactory.java&p1=oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringCmdLineStoreFactory.java&r1=1190721&r2=1195126&rev=1195126&view=diff
==============================================================================
--- oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/store/spring/SpringCmdLineStoreFactory.java (original)
+++ oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStoreFactory.java Sun Oct 30 07:48:19 2011
@@ -1,25 +1,46 @@
-package org.apache.oodt.cas.cl.store.spring;
-
-import org.apache.oodt.cas.cl.store.CmdLineStore;
-import org.apache.oodt.cas.cl.store.CmdLineStoreFactory;
-
-public class SpringCmdLineStoreFactory implements CmdLineStoreFactory {
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.option.store.spring;
+
+//OODT imports
+import org.apache.oodt.cas.cl.option.store.CmdLineOptionStoreFactory;
+
+/**
+ * Factory for creating {@link SpringCmdLineOptionStore}.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class SpringCmdLineOptionStoreFactory implements CmdLineOptionStoreFactory {
 
 	private String config;
 
-	public SpringCmdLineStoreFactory() {
+	public SpringCmdLineOptionStoreFactory() {
 		config = System.getProperty("org.apache.oodt.cas.cl.option.store.spring.config", null);
 	}
 
-	public void setConfig(String config) {
-		this.config = config;
-	}
-
-	public CmdLineStore createStore() {
+	public SpringCmdLineOptionStore createStore() {
 		if (config != null) {
-			return new SpringCmdLineStore(config); 
+			return new SpringCmdLineOptionStore(config); 
 		} else {
 			return null;
 		}
 	}
+
+	public void setConfig(String config) {
+		this.config = config;
+	}
 }

Propchange: oodt/branches/cas-cl/src/main/java/org/apache/oodt/cas/cl/option/store/spring/SpringCmdLineOptionStoreFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/action/store/spring/TestSpringCmdLineActionStore.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/action/store/spring/TestSpringCmdLineActionStore.java?rev=1195126&view=auto
==============================================================================
--- oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/action/store/spring/TestSpringCmdLineActionStore.java (added)
+++ oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/action/store/spring/TestSpringCmdLineActionStore.java Sun Oct 30 07:48:19 2011
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.action.store.spring;
+
+//OODT static imports
+import static org.apache.oodt.cas.cl.util.CmdLineUtils.findAction;
+
+//JDK imports
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+//Apache imports
+import org.apache.oodt.cas.cl.action.CmdLineAction;
+import org.apache.oodt.cas.cl.action.PrintMessageAction;
+import org.apache.oodt.cas.cl.test.util.TestSetContextInjectTypeAction;
+
+//Spring imports
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Test case for {@link SpringCmdLineActionStore}.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class TestSpringCmdLineActionStore extends TestCase {
+
+	private static final String SPRING_CONFIG = "src/testdata/cmd-line-actions.xml";
+
+	public void testActionNamesAutoSet() {
+		SpringCmdLineActionStore store = new SpringCmdLineActionStore(SPRING_CONFIG);
+		ApplicationContext appContext = store.getApplicationContext();
+		@SuppressWarnings("unchecked")
+		Map<String, CmdLineAction> actionsMap = appContext.getBeansOfType(CmdLineAction.class);
+		for (Entry<String, CmdLineAction> entry : actionsMap.entrySet()) {
+			assertEquals(entry.getKey(), entry.getValue().getName());
+		}
+	}
+
+	public void testApplicationContextAutoSet() {
+		SpringCmdLineActionStore store = new SpringCmdLineActionStore(SPRING_CONFIG);
+		TestSetContextInjectTypeAction action = (TestSetContextInjectTypeAction) findAction(
+				"TestSetContextInjectAction", store.loadSupportedActions());
+		assertEquals(action.getContext(), store.getApplicationContext());
+	}
+
+	public void testLoadSupportedActions() {
+		SpringCmdLineActionStore store = new SpringCmdLineActionStore(SPRING_CONFIG);
+		Set<CmdLineAction> actions = store.loadSupportedActions();
+
+		// Check that all actions were loaded.
+		assertEquals(3, actions.size());
+
+		// Load and verify PrintMessageAction was loaded correctly.
+		CmdLineAction action = findAction("PrintMessageAction", actions);
+		assertTrue(action instanceof PrintMessageAction);
+		PrintMessageAction pma = (PrintMessageAction) action;
+		assertEquals("Prints out a given message", pma.getDescription());
+		assertNull(pma.getMessage());
+		assertEquals(System.out, pma.getOutputStream());
+
+		// Load and verify PrintHelloWorldAction was loaded correctly.
+		action = findAction("PrintHelloWorldAction", actions);
+		assertTrue(action instanceof PrintMessageAction);
+		pma = (PrintMessageAction) action;
+		assertEquals("Prints out 'Hello World'", pma.getDescription());
+		assertEquals("Hello World", pma.getMessage());
+		assertEquals(System.out, pma.getOutputStream());
+	}
+}

Propchange: oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/action/store/spring/TestSpringCmdLineActionStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/option/store/spring/TestSpringCmdLineOptionStore.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/option/store/spring/TestSpringCmdLineOptionStore.java?rev=1195126&view=auto
==============================================================================
--- oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/option/store/spring/TestSpringCmdLineOptionStore.java (added)
+++ oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/option/store/spring/TestSpringCmdLineOptionStore.java Sun Oct 30 07:48:19 2011
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.option.store.spring;
+
+//OODT static imports
+import static org.apache.oodt.cas.cl.test.util.TestUtils.createOptionInstance;
+import static org.apache.oodt.cas.cl.util.CmdLineUtils.findAction;
+import static org.apache.oodt.cas.cl.util.CmdLineUtils.getOptionByName;
+
+//JDK imports
+import java.util.Set;
+
+//OODT imports
+import org.apache.oodt.cas.cl.action.CmdLineAction;
+import org.apache.oodt.cas.cl.action.PrintMessageAction;
+import org.apache.oodt.cas.cl.action.store.spring.SpringCmdLineActionStore;
+import org.apache.oodt.cas.cl.option.AdvancedCmdLineOption;
+import org.apache.oodt.cas.cl.option.CmdLineOption;
+import org.apache.oodt.cas.cl.option.handler.ApplyToActionHandler;
+import org.apache.oodt.cas.cl.option.require.ActionDependencyRule;
+import org.apache.oodt.cas.cl.option.require.RequirementRule.Relation;
+import org.apache.oodt.cas.cl.test.util.TestOutputStream;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link SpringCmdLineOptionStore}.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class TestSpringCmdLineOptionStore extends TestCase {
+
+	private static final String SPRING_OPTION_CONFIG = "src/testdata/cmd-line-options.xml";
+	private static final String SPRING_ACTION_CONFIG = "src/testdata/cmd-line-actions.xml";
+
+	public void testLoadSupportedOptions() {
+		SpringCmdLineOptionStore optionStore = new SpringCmdLineOptionStore(
+				SPRING_OPTION_CONFIG);
+		Set<CmdLineOption> options = optionStore.loadSupportedOptions();
+		SpringCmdLineActionStore actionStore = new SpringCmdLineActionStore(
+				SPRING_ACTION_CONFIG);
+		Set<CmdLineAction> actions = actionStore.loadSupportedActions();
+		
+		// Check that all options were loaded.
+		assertEquals(2, options.size());
+
+		// Load and verify useTestOutputStream was loaded correctly.
+		CmdLineOption option = getOptionByName("outputStream", options);
+		assertTrue(option instanceof AdvancedCmdLineOption);
+		AdvancedCmdLineOption advancedOption = (AdvancedCmdLineOption) option;
+		assertEquals("utos", advancedOption.getShortOption());
+		assertEquals("outputStream", advancedOption.getLongOption());
+		assertEquals("Specify OutputStream", advancedOption.getDescription());
+		assertTrue(advancedOption.hasArgs());
+		assertEquals(1, advancedOption.getDefaultArgs().size());
+		assertEquals("org.apache.oodt.cas.cl.test.util.TestOutputStream",
+				advancedOption.getDefaultArgs().get(0));
+		assertEquals("OutputStream classpath", advancedOption.getArgsDescription());
+		assertEquals(1, advancedOption.getRequirementRules().size());
+		assertEquals("PrintMessageAction", ((ActionDependencyRule) advancedOption
+				.getRequirementRules().get(0)).getActionName());
+		assertEquals(Relation.OPTIONAL, ((ActionDependencyRule) advancedOption
+				.getRequirementRules().get(0)).getRelation());
+
+		// Load and verify printMessage was loaded correctly.
+		option = getOptionByName("printMessage", options);
+		assertTrue(option instanceof AdvancedCmdLineOption);
+		advancedOption = (AdvancedCmdLineOption) option;
+		assertEquals("pm", advancedOption.getShortOption());
+		assertEquals("printMessage", advancedOption.getLongOption());
+		assertEquals("Message to print out", advancedOption.getDescription());
+		assertEquals(true, advancedOption.hasArgs());
+		assertEquals("message", advancedOption.getArgsDescription());
+		assertEquals(1, advancedOption.getRequirementRules().size());
+		assertEquals("PrintMessageAction", ((ActionDependencyRule) advancedOption
+				.getRequirementRules().get(0)).getActionName());
+		assertEquals(Relation.REQUIRED, ((ActionDependencyRule) advancedOption
+				.getRequirementRules().get(0)).getRelation());
+		assertNotNull(advancedOption.getHandler());
+		assertTrue(advancedOption.getHandler() instanceof ApplyToActionHandler);
+		assertEquals(1, ((ApplyToActionHandler) advancedOption.getHandler())
+				.getApplyToActions().size());
+		assertEquals(
+				findAction("PrintMessageAction", actions).getName(),
+				((ApplyToActionHandler) advancedOption.getHandler())
+						.getApplyToActions().get(0).getActionName());
+		assertEquals("setMessage",
+				((ApplyToActionHandler) advancedOption.getHandler())
+						.getApplyToActions().get(0).getMethodName());
+	}
+
+	public void testHandlers() {
+		SpringCmdLineOptionStore store = new SpringCmdLineOptionStore(
+				SPRING_OPTION_CONFIG);
+		Set<CmdLineOption> options = store.loadSupportedOptions();
+		SpringCmdLineActionStore actionStore = new SpringCmdLineActionStore(
+				SPRING_ACTION_CONFIG);
+		Set<CmdLineAction> actions = actionStore.loadSupportedActions();
+
+		// Load PrintHelloWorldAction
+		PrintMessageAction printHelloWorldAction = (PrintMessageAction) findAction(
+				"PrintHelloWorldAction", actions);
+		AdvancedCmdLineOption outputStreamOption = (AdvancedCmdLineOption) getOptionByName(
+				"outputStream", options);
+		outputStreamOption.getHandler().handleOption(printHelloWorldAction,
+				createOptionInstance(outputStreamOption));
+		assertTrue(printHelloWorldAction.getOutputStream() instanceof TestOutputStream);
+		printHelloWorldAction.execute();
+		assertEquals("Hello World\n",
+				((TestOutputStream) printHelloWorldAction.getOutputStream()).getText());
+	}
+}

Propchange: oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/option/store/spring/TestSpringCmdLineOptionStore.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestOutputStream.java (from r1195118, oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/store/spring/TestOutputStream.java)
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestOutputStream.java?p2=oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestOutputStream.java&p1=oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/store/spring/TestOutputStream.java&r1=1195118&r2=1195126&rev=1195126&view=diff
==============================================================================
--- oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/store/spring/TestOutputStream.java (original)
+++ oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestOutputStream.java Sun Oct 30 07:48:19 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.oodt.cas.cl.store.spring;
+package org.apache.oodt.cas.cl.test.util;
 
 //JDK imports
 import java.io.IOException;

Propchange: oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestOutputStream.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestSetContextInjectTypeAction.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestSetContextInjectTypeAction.java?rev=1195126&view=auto
==============================================================================
--- oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestSetContextInjectTypeAction.java (added)
+++ oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestSetContextInjectTypeAction.java Sun Oct 30 07:48:19 2011
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cl.test.util;
+
+//OODT imports
+import org.apache.oodt.cas.cl.action.CmdLineAction;
+import org.apache.oodt.cas.cl.action.store.spring.SpringSetContextInjectionType;
+
+//Spring imports
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Test {@link CmdLineAction} for testing {@link SpringSetContextInjectionType}
+ * are injected with the {@link ApplicationContext} correctly.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class TestSetContextInjectTypeAction extends CmdLineAction
+		implements SpringSetContextInjectionType {
+
+	private ApplicationContext appContext;
+	
+	@Override
+	public void execute() {}
+
+	public void setContext(ApplicationContext appContext) {
+		this.appContext = appContext;
+	}
+
+	public ApplicationContext getContext() {
+		return appContext;
+	}
+}

Propchange: oodt/branches/cas-cl/src/test/org/apache/oodt/cas/cl/test/util/TestSetContextInjectTypeAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: oodt/branches/cas-cl/src/testdata/cmd-line-actions.xml (from r1195118, oodt/branches/cas-cl/src/testdata/cmd-line-action-beans.xml)
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/testdata/cmd-line-actions.xml?p2=oodt/branches/cas-cl/src/testdata/cmd-line-actions.xml&p1=oodt/branches/cas-cl/src/testdata/cmd-line-action-beans.xml&r1=1195118&r2=1195126&rev=1195126&view=diff
==============================================================================
--- oodt/branches/cas-cl/src/testdata/cmd-line-action-beans.xml (original)
+++ oodt/branches/cas-cl/src/testdata/cmd-line-actions.xml Sun Oct 30 07:48:19 2011
@@ -28,5 +28,8 @@
   <bean id="PrintHelloWorldAction" class="org.apache.oodt.cas.cl.action.PrintMessageAction">
     <property name="description" value="Prints out 'Hello World'"/>
     <property name="message" value="Hello World"/>
-  </bean>    
+  </bean>
+  <bean id="TestSetContextInjectAction" class="org.apache.oodt.cas.cl.test.util.TestSetContextInjectTypeAction">
+    <property name="description" value="Test action for testing application context injection"/>
+  </bean>
 </beans>

Propchange: oodt/branches/cas-cl/src/testdata/cmd-line-actions.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: oodt/branches/cas-cl/src/testdata/cmd-line-options.xml (from r1195118, oodt/branches/cas-cl/src/testdata/cmd-line-option-beans.xml)
URL: http://svn.apache.org/viewvc/oodt/branches/cas-cl/src/testdata/cmd-line-options.xml?p2=oodt/branches/cas-cl/src/testdata/cmd-line-options.xml&p1=oodt/branches/cas-cl/src/testdata/cmd-line-option-beans.xml&r1=1195118&r2=1195126&rev=1195126&view=diff
==============================================================================
--- oodt/branches/cas-cl/src/testdata/cmd-line-option-beans.xml (original)
+++ oodt/branches/cas-cl/src/testdata/cmd-line-options.xml Sun Oct 30 07:48:19 2011
@@ -29,7 +29,7 @@
     <property name="type" value="java.io.OutputStream" />
     <property name="defaultArgs">
       <list>
-        <value>org.apache.oodt.cas.cl.store.spring.TestOutputStream</value>
+        <value>org.apache.oodt.cas.cl.test.util.TestOutputStream</value>
       </list>
     </property>
     <property name="argsDescription" value="OutputStream classpath" />
@@ -41,11 +41,11 @@
     </property>
     <property name="handler">
       <bean
-        class="org.apache.oodt.cas.cl.option.handler.CmdLineOptionBeanHandler">
-        <property name="applyToBeans">
+        class="org.apache.oodt.cas.cl.option.handler.ApplyToActionHandler">
+        <property name="applyToActions">
           <list>
-            <bean class="org.apache.oodt.cas.cl.option.handler.BeanInfo"
-              p:bean-ref="PrintMessageAction" p:methodName="setOutputStream" />
+            <bean class="org.apache.oodt.cas.cl.option.handler.ApplyToAction"
+              p:actionName="PrintMessageAction" p:methodName="setOutputStream" />
           </list>
         </property>
       </bean>
@@ -66,11 +66,11 @@
 		</property>
 		<property name="handler">
 			<bean
-				class="org.apache.oodt.cas.cl.option.handler.CmdLineOptionBeanHandler">
-				<property name="applyToBeans">
+				class="org.apache.oodt.cas.cl.option.handler.ApplyToActionHandler">
+				<property name="applyToActions">
 					<list>
-						<bean class="org.apache.oodt.cas.cl.option.handler.BeanInfo"
-							p:bean-ref="PrintMessageAction" p:methodName="setMessage" />
+						<bean class="org.apache.oodt.cas.cl.option.handler.ApplyToAction"
+							p:actionName="PrintMessageAction" p:methodName="setMessage" />
 					</list>
 				</property>
 			</bean>

Propchange: oodt/branches/cas-cl/src/testdata/cmd-line-options.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain