Author: simonetripodi
Date: Mon Jul 15 12:04:56 2013
New Revision: 1503194
URL: http://svn.apache.org/r1503194
Log:
every single component is now wired by the Injector
added the history command
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserModule.java
(with props)
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserProvider.java
(with props)
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/package-info.java
(with props)
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/DefaultConfigurationModule.java
- copied, changed from r1503150,
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/BasicConfigurationModule.java
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRepoDirProvider.java
(with props)
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRunnerDirProvider.java
(with props)
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/package-info.java
(with props)
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderModule.java
(with props)
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderProvider.java
(with props)
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/HistoryProvider.java
(with props)
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ShutdownHook.java
- copied, changed from r1503153,
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ShutdownHook.java
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/package-info.java
(with props)
Removed:
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ShutdownHook.java
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/BasicConfigurationModule.java
Modified:
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/History.java
onami/sandbox/console/src/main/resources/META-INF/services/com.google.inject.Module
Modified:
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java?rev=1503194&r1=1503193&r2=1503194&view=diff
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java
(original)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java
Mon Jul 15 12:04:56 2013
@@ -19,13 +19,10 @@ package org.apache.onami.console.command
* under the License.
*/
-import static
org.apache.onami.configuration.OnamiVariablesExpander.expandVariables;
-import static java.lang.System.err;
import static com.google.inject.Guice.createInjector;
-import static java.lang.Runtime.getRuntime;
-import static java.lang.System.getProperty;
+import static java.lang.System.err;
import static java.lang.System.setProperty;
-import static org.apache.onami.spi.core.ServiceLoader.load;
+import static
org.apache.onami.configuration.OnamiVariablesExpander.expandVariables;
import static org.apache.onami.spi.modules.GuiceServiceLoader.loadModules;
import static org.slf4j.LoggerFactory.getILoggerFactory;
import static org.slf4j.LoggerFactory.getLogger;
@@ -34,11 +31,7 @@ import io.airlift.command.Command;
import io.airlift.command.Help;
import io.airlift.command.Option;
import io.airlift.command.ParseArgumentsUnexpectedException;
-
-import java.io.File;
-
import jline.console.ConsoleReader;
-import jline.console.history.FileHistory;
import org.slf4j.Logger;
@@ -46,6 +39,7 @@ import ch.qos.logback.classic.LoggerCont
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
+import com.google.inject.Inject;
import com.google.inject.Injector;
@Command( name = "run" )
@@ -63,7 +57,16 @@ public final class ConsoleRunner
private boolean quiet;
@Option( name = { "-v", "--verbose" }, description = "Produce execution
debug output." )
- public boolean verbose;
+ private boolean verbose;
+
+ @Inject
+ private ConsoleReader consoleReader;
+
+ @Inject
+ private Cli<Runnable> gitParser;
+
+ @Inject
+ private Injector injector;
public void run()
{
@@ -84,31 +87,41 @@ public final class ConsoleRunner
logger.info( " \\_) ) /" );
logger.info( " (_/" );
- try
- {
- String appName = getProperty( "app.name" );
-
- File onamiConsoleRunnerDir = new File( getProperty( "user.home" ),
'.' + appName );
-
- ConsoleReader consoleReader = newConsoleReader(
onamiConsoleRunnerDir );
+ // setup the injector by discovering modules automatically
- // TODO plug Eclipse Aether
- File repositoryDir = new File( onamiConsoleRunnerDir, "repository"
);
+ createInjector( expandVariables( loadModules() ) )
+ .getMembersInjector( ConsoleRunner.class )
+ .injectMembers( this );
- // setup the injector by discovering modules automatically
+ // run!
- Injector injector = createInjector( expandVariables( loadModules()
) );
-
- // setup the CLI parser by discovering commands automatically
-
- Cli<Runnable> gitParser = Cli.<Runnable> builder( appName )
- .withCommands( load( Runnable.class )
)
- .withCommand( Help.class )
- .withDefaultCommand( Help.class
).build();
+ try
+ {
+ String line;
+ while ( ( line = consoleReader.readLine( PROMPT ) ) != null )
+ {
+ if ( line != null && !line.isEmpty() )
+ {
+ try
+ {
+ Runnable command = gitParser.parse( line.split(
ARGS_SEPARATOR ) );
- // run!
+ if ( command != null )
+ {
+ if ( !(command instanceof Help) )
+ {
+ injector.injectMembers( command );
+ }
- executeCommands( consoleReader, gitParser, injector );
+ command.run();
+ }
+ }
+ catch ( ParseArgumentsUnexpectedException e )
+ {
+ logger.warn( "-ocr: {}: command not found.", line );
+ }
+ }
+ }
}
catch ( Throwable t )
{
@@ -160,47 +173,4 @@ public final class ConsoleRunner
}
}
- private ConsoleReader newConsoleReader( File onamiConsoleRunnerDir )
- throws Exception
- {
- ConsoleReader consoleReader = new ConsoleReader();
-
- FileHistory fileHistory = new FileHistory( new File(
onamiConsoleRunnerDir, "history" ) );
- getRuntime().addShutdownHook( new ShutdownHook( fileHistory ) );
- consoleReader.setHistory( fileHistory );
- consoleReader.setHistoryEnabled( true );
-
- return consoleReader;
- }
-
- private void executeCommands( ConsoleReader consoleReader, Cli<Runnable>
gitParser, Injector injector )
- throws Throwable
- {
- String line;
- while ( ( line = consoleReader.readLine( PROMPT ) ) != null )
- {
- if ( line != null && !line.isEmpty() )
- {
- try
- {
- Runnable command = gitParser.parse( line.split(
ARGS_SEPARATOR ) );
-
- if ( command != null )
- {
- if ( !(command instanceof Help) )
- {
- injector.injectMembers( command );
- }
-
- command.run();
- }
- }
- catch ( ParseArgumentsUnexpectedException e )
- {
- logger.warn( "-ocr: {}: command not found.", line );
- }
- }
- }
- }
-
}
Modified:
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/History.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/commands/History.java?rev=1503194&r1=1503193&r2=1503194&view=diff
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/History.java
(original)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/History.java
Mon Jul 15 12:04:56 2013
@@ -19,14 +19,44 @@ package org.apache.onami.console.command
* under the License.
*/
+import io.airlift.command.Command;
+
+import java.util.ListIterator;
+
+import jline.console.history.History.Entry;
+
+import org.apache.onami.logging.core.InjectLogger;
+import org.kohsuke.MetaInfServices;
+import org.slf4j.Logger;
+
+import com.google.inject.Inject;
+
+@MetaInfServices
+@Command( name = "history", description = "Print commands been executed within
the running console's process." )
public final class History
implements Runnable
{
+ @InjectLogger
+ private Logger logger;
+
+ @Inject
+ private jline.console.history.History history;
+
+ public void setHistory( jline.console.history.History history )
+ {
+ this.history = history;
+ }
+
public void run()
{
- // TODO Auto-generated method stub
+ ListIterator<Entry> entries = history.entries();
+ while ( entries.hasNext() )
+ {
+ Entry entry = entries.next();
+ logger.info( "{} {}", entry.index(), entry.value() );
+ }
}
}
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserModule.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserModule.java?rev=1503194&view=auto
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserModule.java
(added)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserModule.java
Mon Jul 15 12:04:56 2013
@@ -0,0 +1,39 @@
+package org.apache.onami.console.modules.cli;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static com.google.inject.Scopes.SINGLETON;
+
+import io.airlift.command.Cli;
+
+import com.google.inject.TypeLiteral;
+import com.google.inject.AbstractModule;
+
+public final class CliParserModule
+ extends AbstractModule
+{
+
+ @Override
+ protected void configure()
+ {
+ bind( new TypeLiteral<Cli<Runnable>>(){} ).toProvider(
CliParserProvider.class ).in( SINGLETON );
+ }
+
+}
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserModule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserModule.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserModule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserProvider.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserProvider.java?rev=1503194&view=auto
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserProvider.java
(added)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserProvider.java
Mon Jul 15 12:04:56 2013
@@ -0,0 +1,52 @@
+package org.apache.onami.console.modules.cli;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.onami.spi.core.ServiceLoader.load;
+import io.airlift.command.Cli;
+import io.airlift.command.Help;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+
+public final class CliParserProvider
+ implements Provider<Cli<Runnable>>
+{
+
+ @Inject
+ @Named( "app.name" )
+ private String applicationName;
+
+ public void setApplicationName( String applicationName )
+ {
+ this.applicationName = applicationName;
+ }
+
+ public Cli<Runnable> get()
+ {
+ return Cli.<Runnable> builder( applicationName )
+ .withCommands( load( Runnable.class ) )
+ .withCommand( Help.class )
+ .withDefaultCommand( Help.class )
+ .build();
+ }
+
+}
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/CliParserProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/package-info.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/package-info.java?rev=1503194&view=auto
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/package-info.java
(added)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/package-info.java
Mon Jul 15 12:04:56 2013
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES 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.onami.console.modules.cli;
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/cli/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/DefaultConfigurationModule.java
(from r1503150,
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/BasicConfigurationModule.java)
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/DefaultConfigurationModule.java?p2=onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/DefaultConfigurationModule.java&p1=onami/sandbox/console/src/main/java/org/apache/onami/console/modules/BasicConfigurationModule.java&r1=1503150&r2=1503194&rev=1503194&view=diff
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/BasicConfigurationModule.java
(original)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/DefaultConfigurationModule.java
Mon Jul 15 12:04:56 2013
@@ -1,4 +1,4 @@
-package org.apache.onami.console.modules;
+package org.apache.onami.console.modules.config;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,19 +19,32 @@ package org.apache.onami.console.modules
* under the License.
*/
+import static com.google.inject.name.Names.named;
+import static com.google.inject.Scopes.SINGLETON;
+
+import java.io.File;
+
import org.apache.onami.configuration.ConfigurationModule;
-public final class BasicConfigurationModule
+public final class DefaultConfigurationModule
extends ConfigurationModule
{
@Override
protected void bindConfigurations()
{
+ // all shell environment variables
bindEnvironmentVariables();
+
+ // all java system properties
bindSystemProperties();
+ // the main artifact maven properties
bindProperties( getClass().getResource(
"/META-INF/maven/org.apache.onami/org.apache.onami.console/pom.properties" ) );
+
+ // OCR directories
+ bind( File.class ).annotatedWith( named( "ocr.dir" ) ).toProvider(
OnamiConsoleRunnerDirProvider.class ).in( SINGLETON );
+ bind( File.class ).annotatedWith( named( "ocr.repo.dir" )
).toProvider( OnamiConsoleRepoDirProvider.class ).in( SINGLETON );
}
}
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRepoDirProvider.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRepoDirProvider.java?rev=1503194&view=auto
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRepoDirProvider.java
(added)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRepoDirProvider.java
Mon Jul 15 12:04:56 2013
@@ -0,0 +1,46 @@
+package org.apache.onami.console.modules.config;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+
+public final class OnamiConsoleRepoDirProvider
+ implements Provider<File>
+{
+
+ @Inject
+ @Named( "ocr.dir" )
+ private File onamiConsoleRunnerDir;
+
+ public void setOnamiConsoleRunnerDir( File onamiConsoleRunnerDir )
+ {
+ this.onamiConsoleRunnerDir = onamiConsoleRunnerDir;
+ }
+
+ public File get()
+ {
+ return new File( onamiConsoleRunnerDir, "repository" );
+ }
+
+}
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRepoDirProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRepoDirProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRepoDirProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRunnerDirProvider.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRunnerDirProvider.java?rev=1503194&view=auto
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRunnerDirProvider.java
(added)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRunnerDirProvider.java
Mon Jul 15 12:04:56 2013
@@ -0,0 +1,55 @@
+package org.apache.onami.console.modules.config;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+
+public final class OnamiConsoleRunnerDirProvider
+ implements Provider<File>
+{
+
+ @Inject
+ @Named( "user.home" )
+ private String userHome;
+
+ @Inject
+ @Named( "app.name" )
+ private String applicationName;
+
+ public void setUserHome( String userHome )
+ {
+ this.userHome = userHome;
+ }
+
+ public void setApplicationName( String applicationName )
+ {
+ this.applicationName = applicationName;
+ }
+
+ public File get()
+ {
+ return new File( userHome, '.' + applicationName );
+ }
+
+}
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRunnerDirProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRunnerDirProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/OnamiConsoleRunnerDirProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/package-info.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/package-info.java?rev=1503194&view=auto
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/package-info.java
(added)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/package-info.java
Mon Jul 15 12:04:56 2013
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES 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.onami.console.modules.config;
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/config/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderModule.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderModule.java?rev=1503194&view=auto
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderModule.java
(added)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderModule.java
Mon Jul 15 12:04:56 2013
@@ -0,0 +1,39 @@
+package org.apache.onami.console.modules.console;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static com.google.inject.Scopes.SINGLETON;
+import jline.console.ConsoleReader;
+import jline.console.history.History;
+
+import com.google.inject.AbstractModule;
+
+public final class ConsoleReaderModule
+ extends AbstractModule
+{
+
+ @Override
+ protected void configure()
+ {
+ bind( History.class ).toProvider( HistoryProvider.class ).in(
SINGLETON );
+ bind( ConsoleReader.class ).toProvider( ConsoleReaderProvider.class
).in( SINGLETON );
+ }
+
+}
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderModule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderModule.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderModule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderProvider.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderProvider.java?rev=1503194&view=auto
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderProvider.java
(added)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderProvider.java
Mon Jul 15 12:04:56 2013
@@ -0,0 +1,59 @@
+package org.apache.onami.console.modules.console;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+
+import javax.inject.Inject;
+import javax.inject.Provider;
+
+import com.google.inject.ProvisionException;
+
+import jline.console.ConsoleReader;
+import jline.console.history.History;
+
+public final class ConsoleReaderProvider
+ implements Provider<ConsoleReader>
+{
+
+ @Inject
+ private History history;
+
+ public void setHistory( History history )
+ {
+ this.history = history;
+ }
+
+ public ConsoleReader get()
+ {
+ try
+ {
+ ConsoleReader consoleReader = new ConsoleReader();
+ consoleReader.setHistory( history );
+ consoleReader.setHistoryEnabled( true );
+ return consoleReader;
+ }
+ catch ( IOException e )
+ {
+ throw new ProvisionException( "Impossible to provide the
ConsoleReader, see nested errors.", e );
+ }
+ }
+
+}
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ConsoleReaderProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/HistoryProvider.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/HistoryProvider.java?rev=1503194&view=auto
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/HistoryProvider.java
(added)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/HistoryProvider.java
Mon Jul 15 12:04:56 2013
@@ -0,0 +1,62 @@
+package org.apache.onami.console.modules.console;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static java.lang.Runtime.getRuntime;
+import java.io.File;
+import java.io.IOException;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+
+import com.google.inject.ProvisionException;
+
+import jline.console.history.FileHistory;
+import jline.console.history.History;
+
+public final class HistoryProvider
+ implements Provider<History>
+{
+
+ @Inject
+ @Named( "ocr.dir" )
+ private File onamiConsoleRunnerDir;
+
+ public void setOnamiConsoleRunnerDir( File onamiConsoleRunnerDir )
+ {
+ this.onamiConsoleRunnerDir = onamiConsoleRunnerDir;
+ }
+
+ public History get()
+ {
+ try
+ {
+ FileHistory fileHistory = new FileHistory( new File(
onamiConsoleRunnerDir, "history" ) );
+ getRuntime().addShutdownHook( new ShutdownHook( fileHistory ) );
+ return fileHistory;
+ }
+ catch ( IOException e )
+ {
+ throw new ProvisionException( "Impossible to enable the console
history, see nested errors.", e );
+ }
+ }
+
+}
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/HistoryProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/HistoryProvider.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/HistoryProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ShutdownHook.java
(from r1503153,
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ShutdownHook.java)
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ShutdownHook.java?p2=onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ShutdownHook.java&p1=onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ShutdownHook.java&r1=1503153&r2=1503194&rev=1503194&view=diff
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ShutdownHook.java
(original)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/ShutdownHook.java
Mon Jul 15 12:04:56 2013
@@ -1,4 +1,4 @@
-package org.apache.onami.console.commands;
+package org.apache.onami.console.modules.console;
/*
* Licensed to the Apache Software Foundation (ASF) under one
Added:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/package-info.java
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/package-info.java?rev=1503194&view=auto
==============================================================================
---
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/package-info.java
(added)
+++
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/package-info.java
Mon Jul 15 12:04:56 2013
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Modules for internal purposes only.
+ */
+package org.apache.onami.console.modules.console;
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
onami/sandbox/console/src/main/java/org/apache/onami/console/modules/console/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
onami/sandbox/console/src/main/resources/META-INF/services/com.google.inject.Module
URL:
http://svn.apache.org/viewvc/onami/sandbox/console/src/main/resources/META-INF/services/com.google.inject.Module?rev=1503194&r1=1503193&r2=1503194&view=diff
==============================================================================
---
onami/sandbox/console/src/main/resources/META-INF/services/com.google.inject.Module
(original)
+++
onami/sandbox/console/src/main/resources/META-INF/services/com.google.inject.Module
Mon Jul 15 12:04:56 2013
@@ -17,5 +17,10 @@
# required startup modules
-org.apache.onami.console.modules.BasicConfigurationModule
+org.apache.onami.console.modules.cli.CliParserModule
+org.apache.onami.console.modules.config.DefaultConfigurationModule
+org.apache.onami.console.modules.console.ConsoleReaderModule
+
+# 3rd parts modules
+
org.apache.onami.logging.slf4j.Slf4jLoggingModule