You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2016/03/21 17:59:37 UTC

svn commit: r1736054 [1/3] - in /felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo: api/ runtime/ runtime/activator/ runtime/threadio/

Author: gnodet
Date: Mon Mar 21 16:59:37 2016
New Revision: 1736054

URL: http://svn.apache.org/viewvc?rev=1736054&view=rev
Log:
Formatting / jdk8

Modified:
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/CommandSessionListener.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Job.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/JobListener.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Process.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Result.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/BaseTokenizer.java
    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/EOFError.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/main/java/org/apache/felix/gogo/runtime/Tokenizer.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/activator/Activator.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/activator/EventAdminListener.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/CommandSessionListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/CommandSessionListener.java?rev=1736054&r1=1736053&r2=1736054&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/CommandSessionListener.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/CommandSessionListener.java Mon Mar 21 16:59:37 2016
@@ -26,7 +26,8 @@ import org.apache.felix.service.command.
  * Such listeners must be registered in the OSGi registry and will be called
  * by the CommandProcessor when a command line is executed in a given session.
  */
-public interface CommandSessionListener {
+public interface CommandSessionListener
+{
 
     void beforeExecute(CommandSession session, CharSequence command);
 

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Job.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Job.java?rev=1736054&r1=1736053&r2=1736054&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Job.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Job.java Mon Mar 21 16:59:37 2016
@@ -22,21 +22,25 @@ import java.util.List;
 
 import org.apache.felix.service.command.CommandSession;
 
-public interface Job {
+public interface Job
+{
 
     /**
-     * Get the job running in the current thead or null.
+     * Get the job running in the current thread or null.
      */
-    static Job current() {
+    static Job current()
+    {
         Process p = Process.current();
         Job j = p != null ? p.job() : null;
-        while (j != null && j.parent() != null) {
+        while (j != null && j.parent() != null)
+        {
             j = j.parent();
         }
         return j;
     }
 
-    enum Status {
+    enum Status
+    {
         Created,
         Suspended,
         Background,

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/JobListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/JobListener.java?rev=1736054&r1=1736053&r2=1736054&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/JobListener.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/JobListener.java Mon Mar 21 16:59:37 2016
@@ -26,7 +26,8 @@ import org.apache.felix.gogo.api.Job.Sta
  * Such listeners must be registered in the OSGi registry and will be called
  * by the CommandProcessor when a command line is executed in a given session.
  */
-public interface JobListener {
+public interface JobListener
+{
 
     void jobChanged(Job job, Status previous, Status current);
 

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Process.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Process.java?rev=1736054&r1=1736053&r2=1736054&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Process.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Process.java Mon Mar 21 16:59:37 2016
@@ -23,9 +23,11 @@ import java.io.PrintStream;
 
 import org.apache.felix.gogo.runtime.Pipe;
 
-public interface Process {
+public interface Process
+{
 
-    static Process current() {
+    static Process current()
+    {
         return Pipe.getCurrentPipe();
     }
 

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Result.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Result.java?rev=1736054&r1=1736053&r2=1736054&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Result.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/api/Result.java Mon Mar 21 16:59:37 2016
@@ -18,7 +18,8 @@
  */
 package org.apache.felix.gogo.api;
 
-public interface Result {
+public interface Result
+{
 
     boolean isSuccess();
 

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/BaseTokenizer.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/BaseTokenizer.java?rev=1736054&r1=1736053&r2=1736054&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/BaseTokenizer.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/BaseTokenizer.java Mon Mar 21 16:59:37 2016
@@ -164,6 +164,7 @@ public class BaseTokenizer
         skipSpace(false);
     }
 
+    @SuppressWarnings("StatementWithEmptyBody")
     protected void skipSpace(boolean skipNewLines)
     {
         while (true)
@@ -285,12 +286,4 @@ public class BaseTokenizer
         return c;
     }
 
-    public void skip(int length)
-    {
-        while (--length >= 0)
-        {
-            getch();
-        }
-    }
-
 }

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=1736054&r1=1736053&r2=1736054&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 Mon Mar 21 16:59:37 2016
@@ -249,7 +249,7 @@ public class CommandProcessorImpl implem
         Map<Object, Integer> cmdMap = commands.get(key);
         if (cmdMap == null)
         {
-            commands.putIfAbsent(key, new LinkedHashMap<Object, Integer>());
+            commands.putIfAbsent(key, new LinkedHashMap<>());
             cmdMap = commands.get(key);
         }
         cmdMap.put(target, ranking);
@@ -284,7 +284,7 @@ public class CommandProcessorImpl implem
     private String[] getFunctions(Class<?> target)
     {
         String[] functions;
-        Set<String> list = new TreeSet<String>();
+        Set<String> list = new TreeSet<>();
         Method methods[] = target.getMethods();
         for (Method m : methods)
         {
@@ -311,7 +311,8 @@ public class CommandProcessorImpl implem
     {
         int[] cost = new int[1];
         Object ret = Reflective.coerce(session, desiredType, in, cost);
-        if (ret == Reflective.NO_MATCH) {
+        if (ret == Reflective.NO_MATCH)
+        {
             throw new IllegalArgumentException(String.format(
                     "Cannot convert %s(%s) to %s", in, in != null ? in.getClass() : "null", desiredType));
         }
@@ -400,7 +401,8 @@ public class CommandProcessorImpl implem
         }
     }
 
-    public Object expr(CommandSessionImpl session, CharSequence expr) {
+    public Object expr(CommandSessionImpl session, CharSequence expr)
+    {
         return new Expression(expr.toString()).eval(session.variables);
     }
 }

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=1736054&r1=1736053&r2=1736054&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 Mon Mar 21 16:59:37 2016
@@ -132,11 +132,13 @@ public class CommandSessionImpl implemen
         return variables;
     }
 
-    public Path currentDir() {
+    public Path currentDir()
+    {
         return currentDir;
     }
 
-    public void currentDir(Path path) {
+    public void currentDir(Path path)
+    {
         currentDir = path;
     }
 
@@ -492,20 +494,25 @@ public class CommandSessionImpl implemen
     }
 
     @Override
-    public List<Job> jobs() {
-        synchronized (jobs) {
+    public List<Job> jobs()
+    {
+        synchronized (jobs)
+        {
             return Collections.unmodifiableList(jobs);
         }
     }
 
-    public static JobImpl currentJob() {
+    public static JobImpl currentJob()
+    {
         return (JobImpl) Job.current();
     }
 
     @Override
-    public JobImpl foregroundJob() {
+    public JobImpl foregroundJob()
+    {
         List<JobImpl> jobs;
-        synchronized (this.jobs) {
+        synchronized (this.jobs)
+        {
             jobs = new ArrayList<>(this.jobs);
         }
         return jobs.stream()
@@ -515,38 +522,49 @@ public class CommandSessionImpl implemen
     }
 
     @Override
-    public void setJobListener(JobListener listener) {
-        synchronized (jobs) {
+    public void setJobListener(JobListener listener)
+    {
+        synchronized (jobs)
+        {
             jobListener = listener;
         }
     }
 
-    public JobImpl createJob(CharSequence command) {
-        synchronized (jobs) {
+    public JobImpl createJob(CharSequence command)
+    {
+        synchronized (jobs)
+        {
             int id = 1;
+
             synchronized (jobs) {
                 boolean found;
-                do {
+                do
+                {
                     found = false;
-                    for (Job job : jobs) {
-                        if (job.id() == id) {
+                    for (Job job : jobs)
+                    {
+                        if (job.id() == id)
+                        {
                             found = true;
                             id++;
                             break;
                         }
                     }
-                } while (found);
+                }
+                while (found);
             }
             JobImpl cur = currentJob();
             JobImpl job = new JobImpl(id, cur, command);
-            if (cur == null) {
+            if (cur == null)
+            {
                 jobs.add(job);
             }
             return job;
         }
     }
 
-    class JobImpl implements Job {
+    class JobImpl implements Job
+    {
         private final int id;
         private final JobImpl parent;
         private final CharSequence command;
@@ -555,129 +573,163 @@ public class CommandSessionImpl implemen
         private Future<?> future;
         private Result result;
 
-        public JobImpl(int id, JobImpl parent, CharSequence command) {
+        public JobImpl(int id, JobImpl parent, CharSequence command)
+        {
             this.id = id;
             this.parent = parent;
             this.command = command;
         }
 
-        void addPipe(Pipe pipe) {
+        void addPipe(Pipe pipe)
+        {
             pipes.add(pipe);
         }
 
         @Override
-        public int id() {
+        public int id()
+        {
             return id;
         }
 
-        public CharSequence command() {
+        public CharSequence command()
+        {
             return command;
         }
 
         @Override
-        public synchronized Status status() {
+        public synchronized Status status()
+        {
             return status;
         }
 
         @Override
-        public synchronized void suspend() {
-            if (status == Status.Done) {
+        public synchronized void suspend()
+        {
+            if (status == Status.Done)
+            {
                 throw new IllegalStateException("Job is finished");
             }
-            if (status != Status.Suspended) {
+            if (status != Status.Suspended)
+            {
                 setStatus(Status.Suspended);
             }
         }
 
         @Override
-        public synchronized void background() {
-            if (status == Status.Done) {
+        public synchronized void background()
+        {
+            if (status == Status.Done)
+            {
                 throw new IllegalStateException("Job is finished");
             }
-            if (status != Status.Background) {
+            if (status != Status.Background)
+            {
                 setStatus(Status.Background);
             }
         }
 
         @Override
-        public synchronized void foreground() {
-            if (status == Status.Done) {
+        public synchronized void foreground()
+        {
+            if (status == Status.Done)
+            {
                 throw new IllegalStateException("Job is finished");
             }
             JobImpl cr = CommandSessionImpl.currentJob();
             JobImpl fg = foregroundJob();
-            if (parent == null && fg != null && fg != this && fg != cr) {
+            if (parent == null && fg != null && fg != this && fg != cr)
+            {
                 throw new IllegalStateException("A job is already in foreground");
             }
-            if (status != Status.Foreground) {
+            if (status != Status.Foreground)
+            {
                 setStatus(Status.Foreground);
             }
         }
 
         @Override
-        public void interrupt() {
+        public void interrupt()
+        {
             Future future;
-            synchronized (this) {
+            synchronized (this)
+            {
                 future = this.future;
             }
-            if (future != null) {
+            if (future != null)
+            {
                 future.cancel(true);
             }
         }
 
-        protected synchronized void done() {
-            if (status == Status.Done) {
+        protected synchronized void done()
+        {
+            if (status == Status.Done)
+            {
                 throw new IllegalStateException("Job is finished");
             }
             setStatus(Status.Done);
         }
 
-        private void setStatus(Status newStatus) {
+        private void setStatus(Status newStatus)
+        {
             setStatus(newStatus, true);
         }
 
-        private void setStatus(Status newStatus, boolean callListeners) {
+        private void setStatus(Status newStatus, boolean callListeners)
+        {
             Status previous;
-            synchronized (this) {
+            synchronized (this)
+            {
                 previous = this.status;
                 status = newStatus;
             }
-            if (callListeners) {
+            if (callListeners)
+            {
                 JobListener listener;
-                synchronized (jobs) {
+                synchronized (jobs)
+                {
                     listener = jobListener;
-                    if (newStatus == Status.Done) {
+                    if (newStatus == Status.Done)
+                    {
                         jobs.remove(this);
                     }
                 }
-                if (listener != null) {
+                if (listener != null)
+                {
                     listener.jobChanged(this, previous, newStatus);
                 }
             }
-            synchronized (this) {
+            synchronized (this)
+            {
                 JobImpl.this.notifyAll();
             }
         }
 
         @Override
-        public synchronized Result result() {
+        public synchronized Result result()
+        {
             return result;
         }
 
         @Override
-        public Job parent() {
+        public Job parent()
+        {
             return parent;
         }
 
         @Override
-        public synchronized Result start(Status status) throws InterruptedException {
-            if (status == Status.Created || status == Status.Done) {
+        public synchronized Result start(Status status) throws InterruptedException
+        {
+            if (status == Status.Created || status == Status.Done)
+            {
                 throw new IllegalArgumentException("Illegal start status");
             }
-            if (this.status != Status.Created) {
+            if (this.status != Status.Created)
+            {
                 throw new IllegalStateException("Job already started");
             }
-            switch (status) {
+            switch (status)
+            {
                 case Suspended:
                     suspend();
                     break;
@@ -689,25 +741,30 @@ public class CommandSessionImpl implemen
                     break;
             }
             future = executor.submit(this::call);
-            while (this.status == Status.Foreground) {
+            while (this.status == Status.Foreground)
+            {
                 JobImpl.this.wait();
             }
             return result;
         }
 
-        public List<Process> processes() {
+        public List<Process> processes()
+        {
             return Collections.unmodifiableList(pipes);
         }
 
         @Override
-        public CommandSession session() {
+        public CommandSession session()
+        {
             return CommandSessionImpl.this;
         }
 
-        private Void call() throws Exception {
+        private Void call() throws Exception
+        {
             Thread thread = Thread.currentThread();
             String name = thread.getName();
-            try {
+            try
+            {
                 thread.setName("job controller " + id);
 
                 List<Callable<Result>> wrapped = pipes.stream().collect(Collectors.toList());
@@ -715,17 +772,23 @@ public class CommandSessionImpl implemen
 
                 // Get pipe exceptions
                 Exception pipeException = null;
-                for (int i = 0; i < results.size() - 1; i++) {
+                for (int i = 0; i < results.size() - 1; i++)
+                {
                     Future<Result> future = results.get(i);
                     Throwable e;
-                    try {
+                    try
+                    {
                         Result r = future.get();
                         e = r.exception;
-                    } catch (ExecutionException ee) {
+                    }
+                    catch (ExecutionException ee)
+                    {
                         e = ee.getCause();
                     }
-                    if (e != null) {
-                        if (pipeException == null) {
+                    if (e != null)
+                    {
+                        if (pipeException == null)
+                        {
                             pipeException = new Exception("Exception caught during pipe execution");
                         }
                         pipeException.addSuppressed(e);
@@ -734,7 +797,9 @@ public class CommandSessionImpl implemen
                 put(Closure.PIPE_EXCEPTION, pipeException);
 
                 result = results.get(results.size() - 1).get();
-            } finally {
+            }
+            finally
+            {
                 done();
                 thread.setName(name);
             }

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/EOFError.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/EOFError.java?rev=1736054&r1=1736053&r2=1736054&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/EOFError.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/EOFError.java Mon Mar 21 16:59:37 2016
@@ -32,7 +32,8 @@ public class EOFError extends SyntaxErro
         this.repair = repair;
     }
 
-    public String repair() {
+    public String repair()
+    {
         return repair;
     }