Got an interesting email with questions regarding Java EE restrictions. Some answers:>"I have installed Glassfish 3.0.1 and am using NetBeans 6.9.1 for implementing stuff"
Congrats - you saved about 5h :-).
- I have a web service running on Glassfish. What can I do now to access an RMI based server? Can I do this:
HelloWorldRMI hdl = (HelloWorldRMI) Naming.lookup("rmi://localhost:2000/HelloWorldRMI");
String helloString = hdl.sayHello("WS");
Yes you can. It works perfectly with all servers I know. This is what I do with greenfire.dev.java.net to access the native driver.
- Can I also open a socket from the same web service to another C++ based server?
You can open client sockets, but not server sockets. I did it in the past with JBoss, Glassfish and WLS. The spec is a bit fluffy here.
- Can I write something to a file?
It will work on most application servers, but it isn't compliant. It is also problematic regarding consistency and concurrency.
You could write a JCA connector for transactional file access. It is easier, than you may think. I wrote a JCA-File connector in my book Real World Java EE Patterns - Rethinking Best Practices See page 181 - Generic JCA connector. My transactional example is comprised of ...4 classes and one XML file.
- Can I create my own classloader and load classes through there?
It will mostly work, but is not compliant."...Allowing the enterprise bean to access information about other classes and to access the classes in a manner that is normally disallowed by the Java programming language could compromise security..."
- Can I dynamically create classes like this:
MyClass myClass = (MyClass) Class.forName("...my.MyClass").newInstance();
String returnString = myClass.sayHello(className);
This is perfect - except obtaining EJBs and CDI managed beans that way :-)
airhacks.fm the podcast:
Stay in touch: airhacks.news.