| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.apache.camel.component.rmi; |
| 18 |
|
|
| 19 |
|
import java.rmi.NotBoundException; |
| 20 |
|
import java.rmi.Remote; |
| 21 |
|
import java.rmi.RemoteException; |
| 22 |
|
import java.rmi.registry.Registry; |
| 23 |
|
|
| 24 |
|
import org.apache.camel.Exchange; |
| 25 |
|
import org.apache.camel.component.bean.BeanProcessor; |
| 26 |
|
import org.apache.camel.impl.DefaultProducer; |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
public class RmiProducer extends DefaultProducer { |
| 32 |
|
|
| 33 |
|
private final RmiEndpoint endpoint; |
| 34 |
|
private Remote remote; |
| 35 |
|
private BeanProcessor beanProcessor; |
| 36 |
|
|
| 37 |
|
public RmiProducer(RmiEndpoint endpoint) throws RemoteException, NotBoundException { |
| 38 |
1 |
super(endpoint); |
| 39 |
1 |
this.endpoint = endpoint; |
| 40 |
1 |
} |
| 41 |
|
|
| 42 |
|
public void process(Exchange exchange) throws Exception { |
| 43 |
1 |
if (beanProcessor == null) { |
| 44 |
1 |
beanProcessor = new BeanProcessor(getRemote(), getEndpoint().getContext()); |
| 45 |
|
} |
| 46 |
1 |
beanProcessor.process(exchange); |
| 47 |
1 |
} |
| 48 |
|
|
| 49 |
|
public Remote getRemote() throws RemoteException, NotBoundException { |
| 50 |
1 |
if (remote == null) { |
| 51 |
1 |
Registry registry = endpoint.getRegistry(); |
| 52 |
1 |
remote = registry.lookup(endpoint.getName()); |
| 53 |
|
} |
| 54 |
1 |
return remote; |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
} |