You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by tj...@apache.org on 2019/02/05 15:41:31 UTC
svn commit: r1853011 - in /felix/trunk/gogo: command/
command/src/main/java/org/apache/felix/gogo/command/ gogo-parent/ jline/
runtime/ runtime/src/main/java/org/apache/felix/gogo/runtime/
runtime/src/main/java/org/apache/felix/gogo/runtime/util/ runti...
Author: tjwatson
Date: Tue Feb 5 15:41:31 2019
New Revision: 1853011
URL: http://svn.apache.org/viewvc?rev=1853011&view=rev
Log:
FELIX-6038: pull Java 7 support back in for gogo runtime,shell and console
Added:
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/BiFunction.java
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/Function.java
Modified:
felix/trunk/gogo/command/pom.xml
felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Basic.java
felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Inspect.java
felix/trunk/gogo/gogo-parent/pom.xml
felix/trunk/gogo/jline/pom.xml
felix/trunk/gogo/runtime/pom.xml
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java
felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Reflective.java
felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java
felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
felix/trunk/gogo/shell/pom.xml
felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/options/Options.java
felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java
felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Telnet.java
Modified: felix/trunk/gogo/command/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/command/pom.xml?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/command/pom.xml (original)
+++ felix/trunk/gogo/command/pom.xml Tue Feb 5 15:41:31 2019
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.felix</groupId>
<artifactId>gogo-parent</artifactId>
- <version>5</version>
+ <version>6-SNAPSHOT</version>
<relativePath>../gogo-parent/pom.xml</relativePath>
</parent>
Modified: felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Basic.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Basic.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Basic.java (original)
+++ felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Basic.java Tue Feb 5 15:41:31 2019
@@ -548,8 +548,9 @@ public class Basic
}
}
- select.forEach(e -> display(e, f));
-
+ for (LogEntry e : select) {
+ display(e,f);
+ }
Util.ungetServices(m_bc, refs);
return f.toString();
}
Modified: felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Inspect.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Inspect.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Inspect.java (original)
+++ felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Inspect.java Tue Feb 5 15:41:31 2019
@@ -21,10 +21,13 @@ package org.apache.felix.gogo.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Formatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.stream.Collectors;
import org.apache.felix.service.command.Descriptor;
@@ -147,16 +150,24 @@ public class Inspect
if ("osgi.native".equals(cap.getNamespace()))
{
f.format("%s with properties:%n", cap.getNamespace());
- cap.getAttributes().entrySet().stream().sorted(
- (e1,e2) -> e1.getKey().compareTo(e2.getKey())
- ).forEach(
- e -> f.format(" %s = %s%n", e.getKey(), e.getValue())
- );
-
+ List<Entry<String, Object>> sortedEntries =
+ new ArrayList<Entry<String, Object>>(cap.getAttributes().entrySet());
+ Collections.sort(sortedEntries, new Comparator<Entry<String, Object>>() {
+ @Override
+ public int compare(Entry<String, Object> o1, Entry<String, Object> o2) {
+ return o1.getKey().compareTo(o2.getKey());
+ }});
+
+ for (Entry<String, Object> e : sortedEntries) {
+ f.format(" %s = %s%n", e.getKey(), e.getValue());
+ }
+
if (dependents != null)
{
f.format(" required by:%n");
- dependents.forEach(wire -> f.format(" %s%n", wire.getRequirerWiring().getBundle()));
+ for (BundleWire wire : dependents) {
+ f.format(" %s%n", wire.getRequirerWiring().getBundle());
+ }
}
else
{
@@ -199,15 +210,25 @@ public class Inspect
}
private static String format(Object object) {
- if (object.getClass().isArray()) {
- return Arrays.stream((Object[])object).map(Object::toString).collect(Collectors.joining(","));
+ String retVal;
+ if (object.getClass().isArray() || object instanceof Collection) {
+ StringBuffer buffer = new StringBuffer();
+ @SuppressWarnings("rawtypes")
+ Iterable formatTarget = object.getClass().isArray() ? Arrays.asList(object) : (Iterable) object;
+ for (Object elem : formatTarget) {
+ if (buffer.length()>0) {
+ buffer.append(',');
+ }
+ buffer.append(elem.toString());
+ }
+ retVal = buffer.toString();
}
- else if (object instanceof Collection) {
- return ((Collection<?>)object).stream().map(Object::toString).collect(Collectors.joining(","));
+ else {
+ retVal = String.valueOf(object);
}
- return String.valueOf(object);
+ return retVal;
}
-
+
private static Map<BundleCapability, List<BundleWire>> aggregateCapabilities(
List<String> namespace, List<BundleWire> wires)
{
Modified: felix/trunk/gogo/gogo-parent/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/gogo-parent/pom.xml?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/gogo-parent/pom.xml (original)
+++ felix/trunk/gogo/gogo-parent/pom.xml Tue Feb 5 15:41:31 2019
@@ -38,10 +38,9 @@
</scm>
<properties>
- <animal.sniffer.skip>true</animal.sniffer.skip>
- <felix.java.version>8</felix.java.version>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
+ <felix.java.version>7</felix.java.version>
+ <maven.compiler.source>1.7</maven.compiler.source>
+ <maven.compiler.target>1.7</maven.compiler.target>
<bnd.version>4.1.0</bnd.version>
</properties>
Modified: felix/trunk/gogo/jline/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/pom.xml?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/jline/pom.xml (original)
+++ felix/trunk/gogo/jline/pom.xml Tue Feb 5 15:41:31 2019
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.felix</groupId>
<artifactId>gogo-parent</artifactId>
- <version>5</version>
+ <version>6-SNAPSHOT</version>
<relativePath>../gogo-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -36,6 +36,14 @@
<url>https://svn.apache.org/repos/asf/felix/trunk/gogo/jline/</url>
</scm>
+ <properties>
+ <animal.sniffer.skip>true</animal.sniffer.skip>
+ <felix.java.version>8</felix.java.version>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <bnd.version>4.1.0</bnd.version>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
Modified: felix/trunk/gogo/runtime/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/pom.xml?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/pom.xml (original)
+++ felix/trunk/gogo/runtime/pom.xml Tue Feb 5 15:41:31 2019
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.felix</groupId>
<artifactId>gogo-parent</artifactId>
- <version>5</version>
+ <version>6-SNAPSHOT</version>
<relativePath>../gogo-parent/pom.xml</relativePath>
</parent>
@@ -79,6 +79,7 @@
<configuration>
<instructions>
<Export-Package>
+ !org.apache.felix.gogo.runtime.util.function,
org.apache.felix.gogo.runtime.*; version=${project.version},
org.apache.felix.service.command,
org.apache.felix.service.command.annotations,
Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java Tue Feb 5 15:41:31 2019
@@ -253,7 +253,7 @@ public class CommandProcessorImpl implem
Map<Object, Integer> cmdMap = commands.get(key);
if (cmdMap == null)
{
- commands.putIfAbsent(key, new LinkedHashMap<>());
+ commands.putIfAbsent(key, new LinkedHashMap<Object, Integer>());
cmdMap = commands.get(key);
}
cmdMap.put(target, ranking);
Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java Tue Feb 5 15:41:31 2019
@@ -527,7 +527,7 @@ public class CommandSessionImpl implemen
{
synchronized (jobs)
{
- return Collections.unmodifiableList(jobs);
+ return Collections.<Job>unmodifiableList(jobs);
}
}
@@ -806,7 +806,7 @@ public class CommandSessionImpl implemen
public List<Process> processes()
{
- return Collections.unmodifiableList(pipes);
+ return Collections.unmodifiableList((List<? extends Process>)pipes);
}
@Override
@@ -823,7 +823,7 @@ public class CommandSessionImpl implemen
{
thread.setName("job controller " + id);
- List<Callable<Result>> wrapped = new ArrayList<>(pipes);
+ List<Callable<Result>> wrapped = new ArrayList<Callable<Result>>(pipes);
List<Future<Result>> results = executor.invokeAll(wrapped);
// Get pipe exceptions
Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java Tue Feb 5 15:41:31 2019
@@ -36,12 +36,13 @@ import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.function.BiFunction;
-import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import org.apache.felix.gogo.runtime.util.function.BiFunction;
+import org.apache.felix.gogo.runtime.util.function.Function;
+
public class Expander extends BaseTokenizer
{
@@ -465,7 +466,7 @@ public class Expander extends BaseTokeni
// If there's no splitting comma, expand with the braces
if (generators.size() < 2)
{
- generators = Collections.singletonList(part.toString());
+ generators = Collections.<CharSequence>singletonList(part.toString());
}
}
else
@@ -1226,31 +1227,38 @@ public class Expander extends BaseTokeni
// Map to List conversion
final boolean _flagk = flagk;
final boolean _flagv = flagv;
- final Function<Object, Object> toCollection = v -> v instanceof Map
- ? toList(asMap(v), _flagk, _flagv)
- : v != null && v.getClass().isArray()
- ? Arrays.asList((Object[]) v)
- : v;
-
+ final Function<Object, Object> toCollection = new Function<Object, Object>() {
+ @Override
+ public Object apply(Object v) {
+ return v instanceof Map
+ ? toList(asMap(v), _flagk, _flagv)
+ : v != null && v.getClass().isArray()
+ ? Arrays.asList((Object[]) v)
+ : v;
+ }
+ };
//
// String transformations
//
- final BiFunction<Function<String, String>, Object, Object> stringApplyer = (func, v) -> {
- v = toCollection.apply(v);
- if (v instanceof Collection)
- {
- List<String> l = new ArrayList<>();
- for (Object i : asCollection(v)) {
- l.add(func.apply(String.valueOf(i)));
+ final BiFunction<Function<String, String>, Object, Object> stringApplyer = new BiFunction<Function<String, String>, Object, Object>() {
+ @Override
+ public Object apply(Function<String, String> func, Object v) {
+ v = toCollection.apply(v);
+ if (v instanceof Collection)
+ {
+ List<String> l = new ArrayList<>();
+ for (Object i : asCollection(v)) {
+ l.add(func.apply(String.valueOf(i)));
+ }
+ return l;
+ }
+ else if (v != null)
+ {
+ return func.apply(v.toString());
+ }
+ else {
+ return null;
}
- return l;
- }
- else if (v != null)
- {
- return func.apply(v.toString());
- }
- else {
- return null;
}
};
@@ -1489,7 +1497,7 @@ public class Expander extends BaseTokeni
{
if (sLeft.equals("@") || sLeft.equals("*"))
{
- Object array = val;
+ final Object array = val;
List<Object> l = new AbstractList<Object>()
{
@Override
@@ -1588,7 +1596,9 @@ public class Expander extends BaseTokeni
// Character evaluation
if (flagSharp)
{
- val = stringApplyer.apply(this::sharp, val);
+ val = stringApplyer.apply(new Function<String, String>() {
+ public String apply(String s) { return Expander.this.sharp(s); };
+ }, val);
}
// Length
@@ -1645,35 +1655,66 @@ public class Expander extends BaseTokeni
val = l;
}
+ Function<String, String> toLowerCase = new Function<String, String>() {
+ @Override
+ public String apply(String t) {
+ return t.toLowerCase();
+ }
+ };
+
+ Function<String, String> toUpperCase = new Function<String, String>() {
+ @Override
+ public String apply(String t) {
+ return t.toUpperCase();
+ }
+ };
+
// Case modification
if (flagC)
{
- val = stringApplyer.apply(this::toCamelCase, val);
+ val = stringApplyer.apply(new Function<String, String>(){
+ @Override
+ public String apply(String t) {
+ return Expander.this.toCamelCase(t);
+ }}, val);
}
else if (flagL)
{
- val = stringApplyer.apply(String::toLowerCase, val);
+ val = stringApplyer.apply(toLowerCase, val);
}
else if (flagU)
{
- val = stringApplyer.apply(String::toUpperCase, val);
+ val = stringApplyer.apply(toUpperCase, val);
}
// Visibility enhancement
if (flagV)
{
- val = stringApplyer.apply(this::visible, val);
+ val = stringApplyer.apply(new Function<String, String>() {
+ @Override
+ public String apply(String t) {
+ return visible(t);
+ }}, val);
}
// Quote
if (flagq != 0)
{
final int _flagq = flagq;
- val = stringApplyer.apply(s -> quote(s, _flagq), val);
+ val = stringApplyer.apply(new Function<String, String>() {
+ @Override
+ public String apply(String s) {
+ return quote(s, _flagq);
+ }
+ }, val);
inQuote = true;
}
else if (flagQ) {
- val = stringApplyer.apply(this::unquote, val);
+ val = stringApplyer.apply(new Function<String,String>(){
+ @Override
+ public String apply(String t) {
+ return unquote(t);
+ }}, val);
}
// Uniqueness
@@ -1700,21 +1741,39 @@ public class Expander extends BaseTokeni
for (Object i : asCollection(val)) {
l.add(String.valueOf(i));
}
- l.sort((s1, s2) -> numericCompare(s1, s2, _flagi));
+ Collections.sort(l, new Comparator<String>() {
+ @Override
+ public int compare(String s1, String s2) {
+ return numericCompare(s1, s2, _flagi);
+ }
+ });
list = l;
}
else if (flaga)
{
- list = new ArrayList<>(asCollection(val));
+ list = new ArrayList<String>((Collection<? extends String>)val);
}
else
{
- Comparator<String> comparator = flagi ? String.CASE_INSENSITIVE_ORDER : String::compareTo;
+ //Comparator<String> comparator = flagi ? String.CASE_INSENSITIVE_ORDER : String::compareTo;
+ Comparator<String> comparator;
+ if (flagi) {
+ comparator = String.CASE_INSENSITIVE_ORDER;
+ }
+ else {
+ comparator = new Comparator<String>() {
+ @Override
+ public int compare(String s1, String s2) {
+ return s1.compareTo(s2);
+ }};
+ }
+
List<String> l = new ArrayList<>();
for (Object i : asCollection(val)) {
l.add(String.valueOf(i));
}
- l.sort(comparator);
+ //l.sort(comparator);
+ Collections.sort(l, comparator);
list = l;
}
if (flagO)
Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java Tue Feb 5 15:41:31 2019
@@ -1163,7 +1163,7 @@ public class Expression {
* @return The result of the expression.
*/
public Object eval() {
- return eval(new HashMap<>());
+ return eval(new HashMap<String, Object>());
}
/**
Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java Tue Feb 5 15:41:31 2019
@@ -182,7 +182,13 @@ public class Parser
}
public List<Statement> statements() {
- statements.sort(Comparator.comparingInt(o -> o.start));
+ Collections.sort(statements, new Comparator<Statement>() {
+ @Override
+ public int compare(Statement o1, Statement o2) {
+ return Integer.compare(o1.start(), o2.start());
+ }
+
+ });
return Collections.unmodifiableList(statements);
}
Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Reflective.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Reflective.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Reflective.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Reflective.java Tue Feb 5 15:41:31 2019
@@ -429,7 +429,7 @@ public final class Reflective
* to allow the "best" conversion to be determined.
* @return converted arg or NO_MATCH if no conversion possible.
*/
- public static Object coerce(CommandSession session, Class<?> type, Object arg,
+ public static Object coerce(CommandSession session, Class<?> type, final Object arg,
int[] convert)
{
if (arg == null)
Added: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/BiFunction.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/BiFunction.java?rev=1853011&view=auto
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/BiFunction.java (added)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/BiFunction.java Tue Feb 5 15:41:31 2019
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.gogo.runtime.util.function;
+
+//This interface was added to ease conversion of existing runtime bundle code
+//targeting java 8 back to target java 7.
+public interface BiFunction<T, U, R> {
+
+ R apply(T t, U u);
+}
Added: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/Function.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/Function.java?rev=1853011&view=auto
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/Function.java (added)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/util/function/Function.java Tue Feb 5 15:41:31 2019
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.gogo.runtime.util.function;
+
+// This interface was added to ease conversion of existing runtime bundle code
+// targeting java 8 back to target java 7.
+public interface Function<T, R> {
+ R apply(T t);
+
+ }
+
Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java Tue Feb 5 15:41:31 2019
@@ -42,11 +42,11 @@ public class ReflectiveTest {
@Test
public void testArrayInvocation() throws Exception {
- assertEquals(new Object[] { 1, "ab" }, invoke("test1", Arrays.asList(1, "ab")));
- assertEquals(new String[] { "1", "ab" }, invoke("test2", Arrays.asList(1, "ab")));
+ assertEquals(new Object[] { 1, "ab" }, invoke("test1", Arrays.<Object>asList(1, "ab")));
+ assertEquals(new String[] { "1", "ab" }, invoke("test2", Arrays.<Object>asList(1, "ab")));
assertEquals(new Object[] { Arrays.asList(1, 2), "ab" }, invoke("test1", Arrays.asList(Arrays.asList(1, 2), "ab")));
- assertEquals(new Object[] { new Object[] { 1, 2 }, "ab" }, invoke("test1", Arrays.asList(new Object[] { 1, 2 }, "ab")));
+ assertEquals(new Object[] { new Object[] { 1, 2 }, "ab" }, invoke("test1", Arrays.<Object>asList(new Object[] { 1, 2 }, "ab")));
}
@Test
@@ -65,7 +65,7 @@ public class ReflectiveTest {
}
};
Reflective.invoke(new CommandSessionImpl(processor, in, out, out), processor, "addConverter",
- Collections.singletonList(conv));
+ Collections.<Object>singletonList(conv));
}
static class Target {
Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java (original)
+++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser.java Tue Feb 5 15:41:31 2019
@@ -47,9 +47,12 @@ public class TestParser extends Abstract
@Test
public void testError() {
Context context = new Context();
- context.addCommand("gogo", (Function) (session, arguments) -> {
- throw new Error(arguments.get(0).toString());
- }, "error");
+ context.addCommand("gogo", new Function() {
+ @Override
+ public Object execute(CommandSession session, List<Object> arguments) throws Exception {
+ throw new Error(arguments.get(0).toString());
+ }}, "error");
+
try {
context.execute("error bar");
fail("Expected an exception");
@@ -57,7 +60,7 @@ public class TestParser extends Abstract
assertEquals("java.util.concurrent.ExecutionException: java.lang.Error: bar", t.toString());
}
}
-
+
@Test
public void testEvaluatation() throws Exception
{
Modified: felix/trunk/gogo/shell/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/shell/pom.xml?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/shell/pom.xml (original)
+++ felix/trunk/gogo/shell/pom.xml Tue Feb 5 15:41:31 2019
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.felix</groupId>
<artifactId>gogo-parent</artifactId>
- <version>5</version>
+ <version>6-SNAPSHOT</version>
<relativePath>../gogo-parent/pom.xml</relativePath>
</parent>
Modified: felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/options/Options.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/options/Options.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/options/Options.java (original)
+++ felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/options/Options.java Tue Feb 5 15:41:31 2019
@@ -469,7 +469,7 @@ public class Options implements Option
public Option parse(List<?> argv, boolean skipArg0)
{
reset();
- List<Object> args = new ArrayList<>(Arrays.asList(defArgs));
+ List<Object> args = new ArrayList<Object>(Arrays.asList(defArgs));
for (Object arg : argv)
{
if (skipArg0)
Modified: felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java (original)
+++ felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java Tue Feb 5 15:41:31 2019
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import org.apache.felix.service.command.CommandProcessor;
@@ -137,7 +138,12 @@ public class Activator implements Bundle
}
// start shell on a separate thread...
- executor = Executors.newSingleThreadExecutor(runnable -> new Thread(runnable, "Gogo shell"));
+ executor = Executors.newSingleThreadExecutor(new ThreadFactory() {
+ @Override
+ public Thread newThread(Runnable runnable) {
+ return new Thread(runnable, "Gogo shell");
+ }
+ });
shellJob = new StartShellJob(context, processor);
executor.submit(shellJob);
}
Modified: felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Telnet.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Telnet.java?rev=1853011&r1=1853010&r2=1853011&view=diff
==============================================================================
--- felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Telnet.java (original)
+++ felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Telnet.java Tue Feb 5 15:41:31 2019
@@ -138,25 +138,27 @@ public class Telnet implements Runnable
PrintStream out = new PrintStream(socket.getOutputStream());
final CommandSession session = processor.createSession(
socket.getInputStream(), out, out);
-
- Thread handler = new Thread(() -> {
- try
- {
- session.execute("gosh --login --noshutdown");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- finally
- {
- session.close();
+ Thread handler = new Thread(new Runnable() {
+ @Override
+ public void run() {
try
{
- socket.close();
+ session.execute("gosh --login --noshutdown");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
}
- catch (IOException e)
+ finally
{
+ session.close();
+ try
+ {
+ socket.close();
+ }
+ catch (IOException e)
+ {
+ }
}
}
});