http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java deleted file mode 100644 index cb8ceca..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.FileInputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.Pipe.SourceChannel; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.reactor.Reactor; -import org.apache.qpid.proton.reactor.Selectable; - -public class Cat extends BaseHandler { - - private class EchoHandler extends BaseHandler { - @Override - public void onSelectableInit(Event event) { - Selectable selectable = event.getSelectable(); - // We can configure a selectable with any SelectableChannel we want. - selectable.setChannel(channel); - // Ask to be notified when the channel is readable - selectable.setReading(true); - event.getReactor().update(selectable); - } - - @Override - public void onSelectableReadable(Event event) { - Selectable selectable = event.getSelectable(); - - // The onSelectableReadable event tells us that there is data - // to be read, or the end of stream has been reached. - SourceChannel channel = (SourceChannel)selectable.getChannel(); - ByteBuffer buffer = ByteBuffer.allocate(1024); - try { - while(true) { - int amount = channel.read(buffer); - if (amount < 0) { - selectable.terminate(); - selectable.getReactor().update(selectable); - } - if (amount <= 0) break; - System.out.write(buffer.array(), 0, buffer.position()); - buffer.clear(); - } - } catch(IOException ioException) { - ioException.printStackTrace(); - selectable.terminate(); - selectable.getReactor().update(selectable); - } - } - } - - private final SourceChannel channel; - - private Cat(SourceChannel channel) { - this.channel = channel; - } - - @Override - public void onReactorInit(Event event) { - Reactor reactor = event.getReactor(); - Selectable selectable = reactor.selectable(); - setHandler(selectable, new EchoHandler()); - reactor.update(selectable); - } - - public static void main(String[] args) throws IOException { - if (args.length != 1) { - System.err.println("Specify a file name as an argument."); - System.exit(1); - } - FileInputStream inFile = new FileInputStream(args[0]); - SourceChannel inChannel = EchoInputStreamWrapper.wrap(inFile); - Reactor reactor = Proton.reactor(new Cat(inChannel)); - reactor.run(); - } -}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/CountRandomly.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/CountRandomly.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/CountRandomly.java deleted file mode 100644 index 9a5a0b4..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/CountRandomly.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.reactor.Reactor; - -// Let's try to modify our counter example. In addition to counting to -// 10 in quarter second intervals, let's also print out a random number -// every half second. This is not a super easy thing to express in a -// purely sequential program, but not so difficult using events. -public class CountRandomly extends BaseHandler { - - private long startTime; - private CounterHandler counter; - - class CounterHandler extends BaseHandler { - private final int limit; - private int count; - - CounterHandler(int limit) { - this.limit = limit; - } - - @Override - public void onTimerTask(Event event) { - count += 1; - System.out.println(count); - - if (!done()) { - event.getReactor().schedule(250, this); - } - } - - // Provide a method to check for doneness - private boolean done() { - return count >= limit; - } - } - - @Override - public void onReactorInit(Event event) { - startTime = System.currentTimeMillis(); - System.out.println("Hello, World!"); - - // Save the counter instance in an attribute so we can refer to - // it later. - counter = new CounterHandler(10); - event.getReactor().schedule(250, counter); - - // Now schedule another event with a different handler. Note - // that the timer tasks go to separate handlers, and they don't - // interfere with each other. - event.getReactor().schedule(500, this); - } - - @Override - public void onTimerTask(Event event) { - // keep on shouting until we are done counting - System.out.println("Yay, " + Math.round(Math.abs((Math.random() * 110) - 10))); - if (!counter.done()) { - event.getReactor().schedule(500, this); - } - } - - @Override - public void onReactorFinal(Event event) { - long elapsedTime = System.currentTimeMillis() - startTime; - System.out.println("Goodbye, World! (after " + elapsedTime + " long milliseconds)"); - } - - public static void main(String[] args) throws IOException { - // In HelloWorld.java we said the reactor exits when there are no more - // events to process. While this is true, it's not actually complete. - // The reactor exits when there are no more events to process and no - // possibility of future events arising. For that reason the reactor - // will keep running until there are no more scheduled events and then - // exit. - Reactor reactor = Proton.reactor(new CountRandomly()); - reactor.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Counter.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Counter.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Counter.java deleted file mode 100644 index b05685a..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Counter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.reactor.Reactor; - -public class Counter extends BaseHandler { - - private long startTime; - - class CounterHandler extends BaseHandler { - private final int limit; - private int count; - - CounterHandler(int limit) { - this.limit = limit; - } - - @Override - public void onTimerTask(Event event) { - count += 1; - System.out.println(count); - if (count < limit) { - // A recurring task can be accomplished by just scheduling - // another event. - event.getReactor().schedule(250, this); - } - } - } - - @Override - public void onReactorInit(Event event) { - startTime = System.currentTimeMillis(); - System.out.println("Hello, World!"); - - // Note that unlike the previous scheduling example, we pass in - // a separate object for the handler. This means that the timer - // event we just scheduled will not be seen by the Counter - // implementation of BaseHandler as it is being handled by the - // CounterHandler instance we create. - event.getReactor().schedule(250, new CounterHandler(10)); - } - - @Override - public void onReactorFinal(Event event) { - long elapsedTime = System.currentTimeMillis() - startTime; - System.out.println("Goodbye, World! (after " + elapsedTime + " long milliseconds)"); - } - - public static void main(String[] args) throws IOException { - // In HelloWorld.java we said the reactor exits when there are no more - // events to process. While this is true, it's not actually complete. - // The reactor exits when there are no more events to process and no - // possibility of future events arising. For that reason the reactor - // will keep running until there are no more scheduled events and then - // exit. - Reactor reactor = Proton.reactor(new Counter()); - reactor.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Delegates.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Delegates.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Delegates.java deleted file mode 100644 index 7b4e36f..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Delegates.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.engine.Handler; -import org.apache.qpid.proton.reactor.Reactor; - -// Events know how to dispatch themselves to handlers. By combining -// this with on_unhandled, you can provide a kind of inheritance -/// between handlers using delegation. -public class Delegates extends BaseHandler { - - private final Handler[] handlers; - - static class Hello extends BaseHandler { - @Override - public void onReactorInit(Event e) { - System.out.println("Hello, World!"); - } - } - - static class Goodbye extends BaseHandler { - @Override - public void onReactorFinal(Event e) { - System.out.println("Goodbye, World!"); - } - } - - public Delegates(Handler... handlers) { - this.handlers = handlers; - } - - @Override - public void onUnhandled(Event event) { - for (Handler handler : handlers) { - event.dispatch(handler); - } - } - - public static void main(String[] args) throws IOException { - Reactor reactor = Proton.reactor(new Delegates(new Hello(), new Goodbye())); - reactor.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java deleted file mode 100644 index 852bf8e..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.Pipe.SourceChannel; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.reactor.Reactor; -import org.apache.qpid.proton.reactor.Selectable; - -public class Echo extends BaseHandler { - - private class EchoHandler extends BaseHandler { - @Override - public void onSelectableInit(Event event) { - Selectable selectable = event.getSelectable(); - // We can configure a selectable with any SelectableChannel we want. - selectable.setChannel(channel); - // Ask to be notified when the channel is readable - selectable.setReading(true); - event.getReactor().update(selectable); - } - - @Override - public void onSelectableReadable(Event event) { - Selectable selectable = event.getSelectable(); - - // The onSelectableReadable event tells us that there is data - // to be read, or the end of stream has been reached. - SourceChannel channel = (SourceChannel)selectable.getChannel(); - ByteBuffer buffer = ByteBuffer.allocate(1024); - try { - while(true) { - int amount = channel.read(buffer); - if (amount < 0) { - selectable.terminate(); - selectable.getReactor().update(selectable); - } - if (amount <= 0) break; - System.out.write(buffer.array(), 0, buffer.position()); - buffer.clear(); - } - } catch(IOException ioException) { - ioException.printStackTrace(); - selectable.terminate(); - selectable.getReactor().update(selectable); - } - } - } - - private final SourceChannel channel; - - private Echo(SourceChannel channel) { - this.channel = channel; - } - - @Override - public void onReactorInit(Event event) { - // Every selectable is a possible source of future events. Our - // selectable stays alive until it reads the end of stream - // marker. This will keep the whole reactor running until we - // type Control-D. - System.out.println("Type whatever you want and then use Control-D to exit:"); - Reactor reactor = event.getReactor(); - Selectable selectable = reactor.selectable(); - setHandler(selectable, new EchoHandler()); - reactor.update(selectable); - } - - public static void main(String[] args) throws IOException { - SourceChannel inChannel = EchoInputStreamWrapper.wrap(System.in); - Reactor reactor = Proton.reactor(new Echo(inChannel)); - reactor.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/EchoInputStreamWrapper.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/EchoInputStreamWrapper.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/EchoInputStreamWrapper.java deleted file mode 100644 index 2e53d09..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/EchoInputStreamWrapper.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.nio.channels.Pipe; -import java.nio.channels.Pipe.SinkChannel; -import java.nio.channels.Pipe.SourceChannel; -import java.util.concurrent.atomic.AtomicInteger; - -public class EchoInputStreamWrapper extends Thread { - - private final InputStream in; - private final SinkChannel out; - private final byte[] bufferBytes = new byte[1024]; - private final ByteBuffer buffer = ByteBuffer.wrap(bufferBytes); - private final AtomicInteger idCounter = new AtomicInteger(); - - private EchoInputStreamWrapper(InputStream in, SinkChannel out) { - this.in = in; - this.out = out; - setName(getClass().getName() + "-" + idCounter.incrementAndGet()); - setDaemon(true); - } - - @Override - public void run() { - try { - while(true) { - int amount = in.read(bufferBytes); - if (amount < 0) break; - buffer.position(0); - buffer.limit(amount); - out.write(buffer); - } - } catch(IOException ioException) { - ioException.printStackTrace(); - } finally { - try { - out.close(); - } catch(IOException ioException) { - ioException.printStackTrace(); - } - } - } - - public static SourceChannel wrap(InputStream in) throws IOException { - Pipe pipe = Pipe.open(); - new EchoInputStreamWrapper(in, pipe.sink()).start(); - SourceChannel result = pipe.source(); - result.configureBlocking(false); - return result; - } - -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GlobalLogger.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GlobalLogger.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GlobalLogger.java deleted file mode 100644 index ec56bd5..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GlobalLogger.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.reactor.Reactor; - -// Not every event goes to the reactor's event handler. If we have a -// separate handler for something like a scheduled task, then those -// events aren't logged by the logger associated with the reactor's -// handler. Sometimes this is useful if you don't want to see them, but -// sometimes you want the global picture. -public class GlobalLogger extends BaseHandler { - - static class Logger extends BaseHandler { - @Override - public void onUnhandled(Event event) { - System.out.println("LOG: " + event); - } - } - - static class Task extends BaseHandler { - @Override - public void onTimerTask(Event e) { - System.out.println("Mission accomplished!"); - } - } - - @Override - public void onReactorInit(Event event) { - System.out.println("Hello, World!"); - event.getReactor().schedule(0, new Task()); - } - - @Override - public void onReactorFinal(Event e) { - System.out.println("Goodbye, World!"); - } - - public static void main(String[] args) throws IOException { - Reactor reactor = Proton.reactor(new GlobalLogger()); - - // In addition to having a regular handler, the reactor also has a - // global handler that sees every event. By adding the Logger to the - // global handler instead of the regular handler, we can log every - // single event that occurs in the system regardless of whether or not - // there are specific handlers associated with the objects that are the - // target of those events. - reactor.getGlobalHandler().add(new Logger()); - reactor.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GoodbyeWorld.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GoodbyeWorld.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GoodbyeWorld.java deleted file mode 100644 index 6a69ba1..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/GoodbyeWorld.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.reactor.Reactor; - -// So far the reactive hello-world doesn't look too different from a -// regular old non-reactive hello-world. The onReactorInit method can -// be used roughly as a 'main' method would. A program that only uses -// that one event, however, isn't going to be very reactive. By using -// other events, we can write a fully reactive program. -public class GoodbyeWorld extends BaseHandler { - - // As before we handle the reactor init event. - @Override - public void onReactorInit(Event event) { - System.out.println("Hello, World!"); - } - - // In addition to an initial event, the reactor also produces an - // event when it is about to exit. This may not behave much - // differently than just putting the goodbye print statement inside - // onReactorInit, but as we grow our program, this piece of it - // will always be what happens last, and will always happen - // regardless of what other paths the main logic of our program - // might take. - @Override - public void onReactorFinal(Event e) { - System.out.println("Goodbye, World!");; - } - - public static void main(String[] args) throws IOException { - Reactor reactor = Proton.reactor(new GoodbyeWorld()); - reactor.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/HelloWorld.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/HelloWorld.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/HelloWorld.java deleted file mode 100644 index 39a36fb..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/HelloWorld.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.reactor.Reactor; - -/* - * The proton reactor provides a general purpose event processing - * library for writing reactive programs. A reactive program is defined - * by a set of event handlers. An event handler is just any class or - * object that extends the Handler interface. For convenience, a class - * can extend BaseHandler and only handle the events that it cares to - * implement methods for. - */ -public class HelloWorld extends BaseHandler { - - // The reactor init event is produced by the reactor itself when it - // starts. - @Override - public void onReactorInit(Event event) { - System.out.println("Hello, World!"); - } - - public static void main(String[] args) throws IOException { - - // When you construct a reactor, you can give it a handler that - // is used, by default, to receive events generated by the reactor. - Reactor reactor = Proton.reactor(new HelloWorld()); - - // When you call run, the reactor will process events. The reactor init - // event is what kicks off everything else. When the reactor has no - // more events to process, it exits. - reactor.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/README.md ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/README.md b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/README.md deleted file mode 100644 index 73fbb87..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/README.md +++ /dev/null @@ -1,31 +0,0 @@ -The examples in this directory provide a basic introduction to the -proton reactor API and are best viewed in the order presented below. - -The examples contain comments that explain things in a tutorial-style -manner. At some point soon this content will be pulled out into a -proper tutorial that references the relevant code snippets from these -examples. Until then please bear with this clumsy style of -presentation. - -This API is present in Java and Python as well. Most of these examples will -transliterate into C in a fairly straightforward way. - - - HelloWorld.java - - GoodbyeWorld.java - - - Scheduling.java - - Counter.java - - CountRandomly.java - - - Unhandled.java - - ReactorLogger.java - - GlobalLogger.java - - Delegates.java - - - Handlers.java - - - Echo.java - - Cat.java - - - Send.java - - Recv.java http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/ReactorLogger.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/ReactorLogger.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/ReactorLogger.java deleted file mode 100644 index 31c7511..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/ReactorLogger.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.reactor.Reactor; - -public class ReactorLogger extends BaseHandler { - - public static class Logger extends BaseHandler { - @Override - public void onUnhandled(Event event) { - System.out.println("LOG: " + event); - } - } - - @Override - public void onReactorInit(Event e) { - System.out.println("Hello, World!"); - } - - @Override - public void onReactorFinal(Event e) { - System.out.println("Goodbye, World!"); - } - - private static boolean loggingEnabled = false; - - public static void main(String[] args) throws IOException { - - // You can pass multiple handlers to a reactor when you construct it. - // Each of these handlers will see every event the reactor sees. By - // combining this with on_unhandled, you can log each event that goes - // to the reactor. - Reactor reactor = Proton.reactor(new ReactorLogger(), new Logger()); - reactor.run(); - - // Note that if you wanted to add the logger later, you could also - // write the above as below. All arguments to the reactor are just - // added to the default handler for the reactor. - reactor = Proton.reactor(new ReactorLogger()); - if (loggingEnabled) - reactor.getHandler().add(new Logger()); - reactor.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Recv.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Recv.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Recv.java deleted file mode 100644 index 96a348a..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Recv.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.amqp.messaging.AmqpValue; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Delivery; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.engine.Receiver; -import org.apache.qpid.proton.message.Message; -import org.apache.qpid.proton.reactor.FlowController; -import org.apache.qpid.proton.reactor.Handshaker; -import org.apache.qpid.proton.reactor.Reactor; - -public class Recv extends BaseHandler { - - private Recv() { - add(new Handshaker()); - add(new FlowController()); - } - - @Override - public void onReactorInit(Event event) { - try { - // Create an amqp acceptor. - event.getReactor().acceptor("0.0.0.0", 5672); - - // There is an optional third argument to the Reactor.acceptor - // call. Using it, we could supply a handler here that would - // become the handler for all accepted connections. If we omit - // it, the reactor simply inherits all the connection events. - } catch(IOException ioException) { - ioException.printStackTrace(); - } - } - - @Override - public void onDelivery(Event event) { - Receiver recv = (Receiver)event.getLink(); - Delivery delivery = recv.current(); - if (delivery.isReadable() && !delivery.isPartial()) { - int size = delivery.pending(); - byte[] buffer = new byte[size]; - int read = recv.recv(buffer, 0, buffer.length); - recv.advance(); - - Message msg = Proton.message(); - msg.decode(buffer, 0, read); - System.out.println(((AmqpValue)msg.getBody()).getValue()); - } - } - - public static void main(String[] args) throws IOException { - Reactor r = Proton.reactor(new Recv()); - r.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java deleted file mode 100644 index 3aed27a..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.reactor.Reactor; -import org.apache.qpid.proton.reactor.Task; - -public class Scheduling extends BaseHandler { - - private long startTime; - - @Override - public void onReactorInit(Event event) { - startTime = System.currentTimeMillis(); - System.out.println("Hello, World!"); - - // We can schedule a task event for some point in the future. - // This will cause the reactor to stick around until it has a - // chance to process the event. - - // The first argument is the delay. The second argument is the - // handler for the event. We are just using self for now, but - // we could pass in another object if we wanted. - Task task = event.getReactor().schedule(1000, this); - - // We can ignore the task if we want to, but we can also use it - // to pass stuff to the handler. - task.attachments().set("key", String.class, "Yay"); - } - - @Override - public void onTimerTask(Event event) { - Task task = event.getTask(); - System.out.println(task.attachments().get("key", String.class) + " my task is complete!"); - } - - @Override - public void onReactorFinal(Event e) { - long elapsedTime = System.currentTimeMillis() - startTime; - System.out.println("Goodbye, World! (after " + elapsedTime + " long milliseconds)"); - } - - public static void main(String[] args) throws IOException { - Reactor reactor = Proton.reactor(new Scheduling()); - reactor.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Send.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Send.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Send.java deleted file mode 100644 index 5978c45..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Send.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; -import java.nio.BufferOverflowException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.amqp.messaging.AmqpValue; -import org.apache.qpid.proton.amqp.transport.ErrorCondition; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Connection; -import org.apache.qpid.proton.engine.Delivery; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.engine.Sender; -import org.apache.qpid.proton.engine.Session; -import org.apache.qpid.proton.message.Message; -import org.apache.qpid.proton.reactor.Handshaker; -import org.apache.qpid.proton.reactor.Reactor; - -// This is a send in terms of low level AMQP events. -public class Send extends BaseHandler { - - private class SendHandler extends BaseHandler { - - private final Message message; - private int nextTag = 0; - - private SendHandler(Message message) { - this.message = message; - - // Add a child handler that performs some default handshaking - // behaviour. - add(new Handshaker()); - } - - @Override - public void onConnectionInit(Event event) { - Connection conn = event.getConnection(); - - // Every session or link could have their own handler(s) if we - // wanted simply by adding the handler to the given session - // or link - Session ssn = conn.session(); - - // If a link doesn't have an event handler, the events go to - // its parent session. If the session doesn't have a handler - // the events go to its parent connection. If the connection - // doesn't have a handler, the events go to the reactor. - Sender snd = ssn.sender("sender"); - conn.open(); - ssn.open(); - snd.open(); - } - - @Override - public void onLinkFlow(Event event) { - Sender snd = (Sender)event.getLink(); - if (snd.getCredit() > 0) { - byte[] msgData = new byte[1024]; - int length; - while(true) { - try { - length = message.encode(msgData, 0, msgData.length); - break; - } catch(BufferOverflowException e) { - msgData = new byte[msgData.length * 2]; - } - } - byte[] tag = String.valueOf(nextTag++).getBytes(); - Delivery dlv = snd.delivery(tag); - snd.send(msgData, 0, length); - dlv.settle(); - snd.advance(); - snd.close(); - snd.getSession().close(); - snd.getSession().getConnection().close(); - } - } - - @Override - public void onTransportError(Event event) { - ErrorCondition condition = event.getTransport().getCondition(); - if (condition != null) { - System.err.println("Error: " + condition.getDescription()); - } else { - System.err.println("Error (no description returned)."); - } - } - } - - private final String host; - private final int port; - private final Message message; - - private Send(String host, int port, String content) { - this.host = host; - this.port = port; - message = Proton.message(); - message.setBody(new AmqpValue(content)); - } - - @Override - public void onReactorInit(Event event) { - // You can use the connection method to create AMQP connections. - - // This connection's handler is the SendHandler object. All the events - // for this connection will go to the SendHandler object instead of - // going to the reactor. If you were to omit the SendHandler object, - // all the events would go to the reactor. - event.getReactor().connectionToHost(host, port, new SendHandler(message)); - } - - public static void main(String[] args) throws IOException { - int port = 5672; - String host = "localhost"; - if (args.length > 0) { - String[] parts = args[0].split(":", 2); - host = parts[0]; - if (parts.length > 1) { - port = Integer.parseInt(parts[1]); - } - } - String content = args.length > 1 ? args[1] : "Hello World!"; - - Reactor r = Proton.reactor(new Send(host, port, content)); - r.run(); - } - -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Unhandled.java ---------------------------------------------------------------------- diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Unhandled.java b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Unhandled.java deleted file mode 100644 index a3cc200..0000000 --- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Unhandled.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * 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.qpid.proton.example.reactor; - -import java.io.IOException; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.engine.BaseHandler; -import org.apache.qpid.proton.engine.Event; -import org.apache.qpid.proton.reactor.Reactor; - -public class Unhandled extends BaseHandler { - - // If an event occurs and its handler doesn't have an on_<event> - // method, the reactor will attempt to call the on_unhandled method - // if it exists. This can be useful not only for debugging, but for - // logging and for delegating/inheritance. - @Override - public void onUnhandled(Event event) { - System.out.println(event); - } - - public static void main(String[] args) throws IOException { - Reactor reactor = Proton.reactor(new Unhandled()); - reactor.run(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 7391713..0000000 --- a/pom.xml +++ /dev/null @@ -1,177 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <description>Proton is a library for speaking AMQP.</description> - <parent> - <groupId>org.apache</groupId> - <artifactId>apache</artifactId> - <version>12</version> - </parent> - <modelVersion>4.0.0</modelVersion> - - <groupId>org.apache.qpid</groupId> - <artifactId>proton-project</artifactId> - <version>0.17.0-SNAPSHOT</version> - <packaging>pom</packaging> - - <properties> - <junit-version>4.12</junit-version> - <mockito-version>1.10.19</mockito-version> - <doxia-module-version>1.3</doxia-module-version> - - <maven-source-plugin-version>2.2.1</maven-source-plugin-version> - <maven-bundle-plugin-version>2.5.4</maven-bundle-plugin-version> - </properties> - - <distributionManagement> - <site> - <id>proton-site-id</id> - <!-- Maven requires a site url even if you only run site:stage --> - <url>file:///tmp/proton-site</url> - </site> - </distributionManagement> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.7</source> - <target>1.7</target> - <optimize>true</optimize> - <showDeprecation>true</showDeprecation> - <showWarnings>true</showWarnings> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <dependencies> - <dependency> - <groupId>org.apache.maven.doxia</groupId> - <artifactId>doxia-module-markdown</artifactId> - <version>${doxia-module-version}</version> - </dependency> - </dependencies> - <configuration> - <inputEncoding>UTF-8</inputEncoding> - <outputEncoding>UTF-8</outputEncoding> - <siteDirectory>docs</siteDirectory> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <version>${maven-bundle-plugin-version}</version> - <extensions>true</extensions> - <configuration> - <instructions> - <Export-Package>${project.groupId}.proton.*</Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <versionRange>[2.4.0,)</versionRange> - <goals> - <goal>manifest</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore></ignore> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>${junit-version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <version>${mockito-version}</version> - <scope>test</scope> - </dependency> - </dependencies> - - <modules> - <module>proton-j</module> - <module>tests</module> - <module>examples/engine/java</module> - <module>examples/java/messenger</module> - <module>examples/java/reactor</module> - </modules> - - <url>http://qpid.apache.org/proton</url> - <scm> - <url>http://svn.apache.org/viewvc/qpid/proton/</url> - </scm> - <issueManagement> - <url>https://issues.apache.org/jira/browse/PROTON</url> - </issueManagement> - <ciManagement> - <url>https://builds.apache.org/view/M-R/view/Qpid/job/Qpid-proton-j/</url> - </ciManagement> - - <profiles> - <profile> - <id>sources</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>${maven-source-plugin-version}</version> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/proton-j/CMakeLists.txt b/proton-j/CMakeLists.txt deleted file mode 100644 index 81cb5a1..0000000 --- a/proton-j/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# -# 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. -# - -include(UseJava) -include(ProtonUseJava) -set(CMAKE_JAVA_TARGET_VERSION ${PN_VERSION}) -file(GLOB_RECURSE SOURCES_ABS "src/main/java/*.java" "../tests/*/ProtonJInterop.java") -add_jar(proton-j ${SOURCES_ABS}) -rebuild_jar(proton-j proton-j-${PN_VERSION}.jar) -set (JAVA_INSTALL_DIR ${SHARE_INSTALL_DIR}/java CACHE PATH "Installation directory for all JARs except those using JNI") -mark_as_advanced (JAVA_INSTALL_DIR) -install_jar(proton-j ${JAVA_INSTALL_DIR}) - -# add relevant CTest support -find_program (MAVEN_EXE NAMES mvn.cmd mvn DOC "Location of the maven program") -mark_as_advanced (MAVEN_EXE) -if (CMAKE_BUILD_TYPE MATCHES "Coverage") - message (STATUS "Building for coverage analysis: testing disabled for Proton-J") -elseif (MAVEN_EXE) - add_test (proton-java ${MAVEN_EXE} clean test --file ${Proton_SOURCE_DIR}/pom.xml) -else () - message (STATUS "Cannot find Maven: testing disabled for Proton-J") -endif () http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/LICENSE ---------------------------------------------------------------------- diff --git a/proton-j/LICENSE b/proton-j/LICENSE deleted file mode 100644 index 6b0b127..0000000 --- a/proton-j/LICENSE +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/pom.xml ---------------------------------------------------------------------- diff --git a/proton-j/pom.xml b/proton-j/pom.xml deleted file mode 100644 index 167bf6e..0000000 --- a/proton-j/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <parent> - <groupId>org.apache.qpid</groupId> - <artifactId>proton-project</artifactId> - <version>0.17.0-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>proton-j</artifactId> - <name>proton-j</name> - <packaging>bundle</packaging> - - <scm> - <url>http://svn.apache.org/viewvc/qpid/proton/</url> - </scm> - - <dependencies> - <dependency> - <groupId>org.bouncycastle</groupId> - <artifactId>bcpkix-jdk15on</artifactId> - <version>1.53</version> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <version>${maven-bundle-plugin-version}</version> - <configuration> - <instructions> - <Import-Package> - javax.net.ssl*;resolution:=optional,* - </Import-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/InterruptException.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/InterruptException.java b/proton-j/src/main/java/org/apache/qpid/proton/InterruptException.java deleted file mode 100644 index 73c2b9d..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/InterruptException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * 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.qpid.proton; - -public class InterruptException extends ProtonException -{ - public InterruptException() - { - } - - public InterruptException(String message) - { - super(message); - } - - public InterruptException(String message, Throwable cause) - { - super(message, cause); - } - - public InterruptException(Throwable cause) - { - super(cause); - } - -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/Proton.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/Proton.java b/proton-j/src/main/java/org/apache/qpid/proton/Proton.java deleted file mode 100644 index 38f39e0..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/Proton.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * - * 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.qpid.proton; - -import java.io.IOException; - -import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; -import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations; -import org.apache.qpid.proton.amqp.messaging.Footer; -import org.apache.qpid.proton.amqp.messaging.Header; -import org.apache.qpid.proton.amqp.messaging.MessageAnnotations; -import org.apache.qpid.proton.amqp.messaging.Properties; -import org.apache.qpid.proton.amqp.messaging.Section; -import org.apache.qpid.proton.codec.Codec; -import org.apache.qpid.proton.codec.Data; -import org.apache.qpid.proton.driver.Driver; -import org.apache.qpid.proton.engine.Collector; -import org.apache.qpid.proton.engine.Connection; -import org.apache.qpid.proton.engine.Engine; -import org.apache.qpid.proton.engine.Handler; -import org.apache.qpid.proton.engine.SslDomain; -import org.apache.qpid.proton.engine.SslPeerDetails; -import org.apache.qpid.proton.engine.Transport; -import org.apache.qpid.proton.message.Message; -import org.apache.qpid.proton.messenger.Messenger; -import org.apache.qpid.proton.reactor.Reactor; - -@SuppressWarnings("deprecation") -public final class Proton -{ - - private Proton() - { - } - - public static Collector collector() - { - return Engine.collector(); - } - - public static Connection connection() - { - return Engine.connection(); - } - - public static Transport transport() - { - return Engine.transport(); - } - - public static SslDomain sslDomain() - { - return Engine.sslDomain(); - } - - public static SslPeerDetails sslPeerDetails(String hostname, int port) - { - return Engine.sslPeerDetails(hostname, port); - } - - public static Data data(long capacity) - { - return Codec.data(capacity); - } - - public static Message message() - { - return Message.Factory.create(); - } - - public static Message message(Header header, - DeliveryAnnotations deliveryAnnotations, MessageAnnotations messageAnnotations, - Properties properties, ApplicationProperties applicationProperties, - Section body, Footer footer) - { - return Message.Factory.create(header, deliveryAnnotations, - messageAnnotations, properties, - applicationProperties, body, footer); - } - - /** - * @deprecated Messenger will be removed from upcoming proton-j releases. - */ - @Deprecated - public static Messenger messenger() - { - return Messenger.Factory.create(); - } - - /** - * @deprecated Messenger will be removed from upcoming proton-j releases. - */ - @Deprecated - public static Messenger messenger(String name) - { - return Messenger.Factory.create(name); - } - - /** - * @deprecated Messenger and its driver will be removed from upcoming proton-j releases. - */ - @Deprecated - public static Driver driver() throws IOException - { - return Driver.Factory.create(); - } - - public static Reactor reactor() throws IOException - { - return Reactor.Factory.create(); - } - - public static Reactor reactor(Handler... handlers) throws IOException - { - Reactor reactor = Reactor.Factory.create(); - for (Handler handler : handlers) { - reactor.getHandler().add(handler); - } - return reactor; - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/ProtonException.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/ProtonException.java b/proton-j/src/main/java/org/apache/qpid/proton/ProtonException.java deleted file mode 100644 index 14f5e6e..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/ProtonException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * 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.qpid.proton; - -public class ProtonException extends RuntimeException -{ - public ProtonException() - { - } - - public ProtonException(String message) - { - super(message); - } - - public ProtonException(String message, Throwable cause) - { - super(message, cause); - } - - public ProtonException(Throwable cause) - { - super(cause); - } - -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java b/proton-j/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java deleted file mode 100644 index 3981646..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/ProtonUnsupportedOperationException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.qpid.proton; - -/** - * Use to indicate that a feature of the Proton API is not supported by a particular implementation - * (e.g. proton-j or proton-c-via-JNI). - */ -public class ProtonUnsupportedOperationException extends UnsupportedOperationException -{ - /** Used by the Python test layer to detect an unsupported operation */ - public static final boolean skipped = true; - - public ProtonUnsupportedOperationException() - { - } - - public ProtonUnsupportedOperationException(String message) - { - super(message); - } - - public ProtonUnsupportedOperationException(String message, Throwable cause) - { - super(message, cause); - } - - public ProtonUnsupportedOperationException(Throwable cause) - { - super(cause); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/TimeoutException.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/TimeoutException.java b/proton-j/src/main/java/org/apache/qpid/proton/TimeoutException.java deleted file mode 100644 index b94de18..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/TimeoutException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * 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.qpid.proton; - -public class TimeoutException extends ProtonException -{ - public TimeoutException() - { - } - - public TimeoutException(String message) - { - super(message); - } - - public TimeoutException(String message, Throwable cause) - { - super(message, cause); - } - - public TimeoutException(Throwable cause) - { - super(cause); - } - - public TimeoutException(long timeoutMillis, String pendingCondition) - { - this("Timed out after " + timeoutMillis + " ms waiting for condition: " + pendingCondition); - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org