client for ctx lookup
This commit is contained in:
@@ -5,6 +5,7 @@ import test3_persistence.store_class;
|
||||
import test3_persistence.test_class;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
@@ -35,8 +36,7 @@ import java.util.Set;
|
||||
public class Servlettest3 extends HttpServlet {
|
||||
|
||||
|
||||
@Inject
|
||||
store_class s;
|
||||
@EJB store_class s;
|
||||
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
@@ -120,6 +120,9 @@ public class Servlettest3 extends HttpServlet {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
}
|
||||
|
||||
45
test3_client/client.java
Normal file
45
test3_client/client.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package test3_client;
|
||||
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import java.util.Properties;
|
||||
import test3_persistence.store_class_remote_interface;
|
||||
|
||||
/**
|
||||
* Created by Giovanni on 17/05/2015.
|
||||
*/
|
||||
public class client {
|
||||
|
||||
public static void main (String[] args) {
|
||||
|
||||
Properties props=new Properties();
|
||||
/*
|
||||
props.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
|
||||
props.put("java.naming.provider.url","iiop://localhost:3700");
|
||||
*/
|
||||
|
||||
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
|
||||
props.setProperty(Context.PROVIDER_URL, "corbaname:iiop:localhost:3700");
|
||||
|
||||
Context ctx = null;
|
||||
try {
|
||||
ctx =new InitialContext(props);
|
||||
} catch (NamingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Object foo = null;
|
||||
try {
|
||||
foo = ctx.lookup("java:/global/web/store_class!test3_persistence.store_class_remote_interface");
|
||||
|
||||
} catch (NamingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package test3_persistence;
|
||||
|
||||
import javax.ejb.LocalBean;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.Query;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -16,7 +18,8 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
|
||||
@Stateless
|
||||
public class store_class {
|
||||
@LocalBean
|
||||
public class store_class implements Serializable,store_class_remote_interface {
|
||||
|
||||
@Inject
|
||||
Logger l;
|
||||
|
||||
13
test3_persistence/store_class_remote_interface.java
Normal file
13
test3_persistence/store_class_remote_interface.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package test3_persistence;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
/**
|
||||
* Created by Giovanni on 17/05/2015.
|
||||
*/
|
||||
@Remote
|
||||
public interface store_class_remote_interface {
|
||||
|
||||
test_class find (Long n);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user