Can RMI(JRMP) server be called by RMI IIOP? - rmi

Can RMI (JRMP) server be called by RMI IIOP?
I know that RMI IIOP is used for cross language communication using corba, But can RMI server implemented using JRMP be called by RMI IIOP client?
I'm guessing this is possible by using the IP address of RMI (JRMP) registry host.

No. The question doesn't even make sense. An RMI server is called via its stub, and the protocol is implemented by the stub, not the client.
However you can export the same object as both an RMI/JRMP remote object and an RMI/IIOP remote object, by extending neither UnicastRemoteObject nor PortableRemoteObject and calling the exportObject() methods of both those classes, and registering it in both an RMI Registry and a COSNaming service, and running both rmic (if necessary, see the preamble to UnicastRemoteObject) and rmic -iiop.
Then if you look it up via a Registry you get an RMI/JRMP stub, and if you look it up via a COSNaming service you get an RMI/IIOP stub.

Related

How to make Apache HTTP client use system settings by default

I have a machine running third party code that uses Apache HttpClient. This machine can only access the external world via https proxy. I know HttpClient allows using system properties like this
HttpClientBuilder.create().useSystemProperties().build();
But I don't have access to the source code to do this. I want to set the proxy host and port as environment variables to make the program pick it up, like it does with "-Dhttp.proxyPort" for Java HttpClient. What are my options?

How to create a HttpConnection implementation in Java ME using SocketConnection?

In the Java ME platform that I am using I have only SocketConnection class to connect to a distant server. For example I can create a connection to a server socket on the given ip using Connector.open("socket://"+ip+":"+port).
What I want is to implement an HttpConnection that will use http protocol, a url and port 80 as parameters. I imagine it will be something like Connector.open("http://www.google.com:80) to be able to send GET, POST, DELETE, PUT requests to the server afterwards.
Is there a way to get the ip via url address and then connect to this ip using http protocol? Or if it isn't supported by my platform, then I have to stick to using sockets? I know my question can seem a little abstract, so ask if you need any clarifications.
You have to stick to using sockets. If the Java ME platform that you are using have only SocketConnection, a call to Connector.open("http://www.google.com:80") will throw an exception.

How to restart operating systems with a XMPP/EJABBER server using python

I want to create a XMPP server on my network and then send message to it with python so that this server can restart the target computer on the network , now how can i set up this server and how can i do the rest of the process?
tnx
I am not sure in what context you are trying to do this, but XMPP has been used in context outside of usual chat and instant messengers (e.g. load balancers, rpc, ...).
There can be several ways of doing this. One way I can think right now is by using Jabber RPC xep-0009 which says:
This specification defines an XMPP protocol extension for
transporting XML-RPC encoded requests and responses between two XMPP entities.
The protocol supports all syntax and semantics of XML-RPC except that
it uses XMPP instead of HTTP as the underlying transport.
Workflow wise here is how you can make this work:
You will need a jabber server which is up and running say on host-A
You will need to configure a startup service on other hosts in the network (say on host-B, host-C, host-D). This startup service is nothing but a xmpp client daemon which will start in the background whenever host is started.
This xmpp client configured as startup service are special in the sense that they will accept incoming rpc calls (support for XEP-0009) and execute received commands on the host.
Received RPC commands can be synonymous to shutdown, kill -9 xxxx depending upon your specific needs.
Finally, xmpp client on host-C can send one or more commands wrapped inside an stanza to xmpp client running on host-B.
You can use one of the existing python xmpp client library and simply extend their working examples for your use case. You will also need to check details on how to configure startup service depending upon your Operating System (e.g. update-rc.d for ubuntu or sc.exe for windows)

Using Remote Method Invocation to interact with windows service? Better alternatives?

I am currently using Remote Method Invocation to interact with a windows service. As services cannot be interactive (UI) strictly from Vista and above, I cannot directly call those methods. So I am using Remote Method Invocation to access those methods. How safe is RMI?
Are there any better alternatives to using RMI? Like File channeling/ sockets and Listeners.
edit: Let me make it clear,
I have a java application which runs as a windows service. But I would like to manipulate the service and the way it works from an user interface but When I try to do that, Windows wont allow me to do that. So I am using RMI to manipulate the windows service from an user interface.(interactively).
Keep in mind that there is a reason for windows services not being able to have an UI. If you need an UI to interact with the service, what's the reason for running the program to interact with as a service anyway?
That being said, I'm using RMI to interact with the service (simply to do some configuration, poll status information; the program being executed as a service usually runs without any user interaction) - it's worked out pretty well so far.
You could of course use simple sockets (however, RMI is also built on sockets). A simple Listener won't work since you'll need some inter process communication.

Swing Client - EJB2 lookup over HTTP in JBoss 5.1

I have a swing client which connects to my ejb2 application deployed in JBoss 5.1. There is a particular requirement from Customer to make it available on internet.
The deployment architecture is as follows,
swing_client --> extranet_ip |firewall | --> iis7_machine --> jboss5.1_machine.
jndi properties in client is as follows
Context.PROVIDER_URL=http://extranet_ip:9180/invoker/JNDIFactory
Context.INITIAL_CONTEXT_FACTORY=org.jboss.naming.HttpNamingContextFactory
This configuration works fine when the client is inside intranet. But it does not work in internet (extranet).
When I tried initially I got the error 'Connection refused'
After seeing some posts in various forums, I changed the file server\deploy\http-invoker.sar\META-INF\jboss-service.xml, to reflect the extranet_ip in invokerURL.
Aftet this I am getting the following error.
org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://10.200.1.193:4546/?dataType=invocation&enableTcpNoDelay=true&marshaller=org.jboss.invocation.unified.marshall.InvocationMarshaller&unmarshaller=org.jboss.invocation.unified.marshall.InvocationUnMarshaller]
Where 10.200.1.193 is the intranet IP address of JBoss Server machine.
I tried changing the trasport parameter in remoting-jboss-beans.xml to http, but at that time client is not working in both intranet and extranet.
Please anybody suggest a way forward for this issue. Or is there any other way to implement RMI over Http in JBoss?
Update: As a solution, I had to change my deployment architecture as follows.
swing_client --> extranet_ip |firewall | --> jboss5.1_machine
where the JBoss Application Server will be directly exposed through firewall. Then update clientConnectAddress in the remoting-jboss-beans.xml to the extranet IP. Also open the ports 8080 & 4446 in the firewall for this address.
This way the swing client is working if I use the jnid properties as follows.
Context.PROVIDER_URL : http://extranet_ip:8080/invoker/JNDIFactory
Context.INITIAL_CONTEXT_FACTORY : org.jboss.naming.HttpNamingContextFactory
But still looking for a solution where there is no need to open any non-standard ports and no need to expose the Application Server directly.
After a long struggle I found a solution for my issue. The solution was to change EJB container's invoker type to http in standardjboss.xml. When the invoker is http, it will use the settings in http-invoker.sar for remote binding.