| 1 |
/* |
| 2 |
* |
| 3 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 4 |
* or more contributor license agreements. See the NOTICE file |
| 5 |
* distributed with this work for additional information |
| 6 |
* regarding copyright ownership. The ASF licenses this file |
| 7 |
* to you under the Apache License, Version 2.0 (the |
| 8 |
* "License"); you may not use this file except in compliance |
| 9 |
* with the License. You may obtain a copy of the License at |
| 10 |
* |
| 11 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 12 |
* |
| 13 |
* Unless required by applicable law or agreed to in writing, |
| 14 |
* software distributed under the License is distributed on an |
| 15 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 |
* KIND, either express or implied. See the License for the |
| 17 |
* specific language governing permissions and limitations |
| 18 |
* under the License. |
| 19 |
* |
| 20 |
*/ |
| 21 |
package org.apache.qpid.proton; |
| 22 |
|
| 23 |
import java.io.IOException; |
| 24 |
|
| 25 |
import org.apache.qpid.proton.amqp.messaging.ApplicationProperties; |
| 26 |
import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations; |
| 27 |
import org.apache.qpid.proton.amqp.messaging.Footer; |
| 28 |
import org.apache.qpid.proton.amqp.messaging.Header; |
| 29 |
import org.apache.qpid.proton.amqp.messaging.MessageAnnotations; |
| 30 |
import org.apache.qpid.proton.amqp.messaging.Properties; |
| 31 |
import org.apache.qpid.proton.amqp.messaging.Section; |
| 32 |
import org.apache.qpid.proton.codec.Codec; |
| 33 |
import org.apache.qpid.proton.codec.Data; |
| 34 |
import org.apache.qpid.proton.engine.Collector; |
| 35 |
import org.apache.qpid.proton.engine.Connection; |
| 36 |
import org.apache.qpid.proton.engine.Engine; |
| 37 |
import org.apache.qpid.proton.engine.Handler; |
| 38 |
import org.apache.qpid.proton.engine.SslDomain; |
| 39 |
import org.apache.qpid.proton.engine.SslPeerDetails; |
| 40 |
import org.apache.qpid.proton.engine.Transport; |
| 41 |
import org.apache.qpid.proton.message.Message; |
| 42 |
import org.apache.qpid.proton.reactor.Reactor; |
| 43 |
import org.apache.qpid.proton.reactor.ReactorOptions; |
| 44 |
|
| 45 |
public final class Proton |
| 46 |
{ |
| 47 |
|
| 48 |
private Proton() |
| 49 |
{ |
| 50 |
} |
| 51 |
|
| 52 |
public static Collector collector() |
| 53 |
{ |
| 54 |
return Engine.collector(); |
| 55 |
} |
| 56 |
|
| 57 |
public static Connection connection() |
| 58 |
{ |
| 59 |
return Engine.connection(); |
| 60 |
} |
| 61 |
|
| 62 |
public static Transport transport() |
| 63 |
{ |
| 64 |
return Engine.transport(); |
| 65 |
} |
| 66 |
|
| 67 |
public static SslDomain sslDomain() |
| 68 |
{ |
| 69 |
return Engine.sslDomain(); |
| 70 |
} |
| 71 |
|
| 72 |
public static SslPeerDetails sslPeerDetails(String hostname, int port) |
| 73 |
{ |
| 74 |
return Engine.sslPeerDetails(hostname, port); |
| 75 |
} |
| 76 |
|
| 77 |
public static Data data(long capacity) |
| 78 |
{ |
| 79 |
return Codec.data(capacity); |
| 80 |
} |
| 81 |
|
| 82 |
public static Message message() |
| 83 |
{ |
| 84 |
return Message.Factory.create(); |
| 85 |
} |
| 86 |
|
| 87 |
public static Message message(Header header, |
| 88 |
DeliveryAnnotations deliveryAnnotations, MessageAnnotations messageAnnotations, |
| 89 |
Properties properties, ApplicationProperties applicationProperties, |
| 90 |
Section body, Footer footer) |
| 91 |
{ |
| 92 |
return Message.Factory.create(header, deliveryAnnotations, |
| 93 |
messageAnnotations, properties, |
| 94 |
applicationProperties, body, footer); |
| 95 |
} |
| 96 |
|
| 97 |
public static Reactor reactor() throws IOException |
| 98 |
{ |
| 99 |
return Reactor.Factory.create(); |
| 100 |
} |
| 101 |
|
| 102 |
public static Reactor reactor(Handler... handlers) throws IOException |
| 103 |
{ |
| 104 |
Reactor reactor = Reactor.Factory.create(); |
| 105 |
for (Handler handler : handlers) { |
| 106 |
reactor.getHandler().add(handler); |
| 107 |
} |
| 108 |
return reactor; |
| 109 |
} |
| 110 |
|
| 111 |
public static Reactor reactor(ReactorOptions options) throws IOException |
| 112 |
{ |
| 113 |
return Reactor.Factory.create(options); |
| 114 |
} |
| 115 |
|
| 116 |
public static Reactor reactor(ReactorOptions options, Handler... handlers) throws IOException |
| 117 |
{ |
| 118 |
Reactor reactor = Reactor.Factory.create(options); |
| 119 |
for (Handler handler : handlers) { |
| 120 |
reactor.getHandler().add(handler); |
| 121 |
} |
| 122 |
return reactor; |
| 123 |
} |
| 124 |
} |