use of org.glassfish.api.invocation.InvocationManagerImpl in project Payara by payara.
the class AppTest method testBind.
@Test
public void testBind() {
GlassfishNamingManager nm = null;
try {
InvocationManager im = new InvocationManagerImpl();
InitialContext ic = newInitialContext();
nm = new GlassfishNamingManagerImpl(ic);
nm.publishObject("foo", "Hello: foo", false);
System.out.println("**lookup() ==> " + ic.lookup("foo"));
assert (true);
} catch (Exception ex) {
ex.printStackTrace();
assert (false);
} finally {
try {
nm.unpublishObject("foo");
} catch (Exception ex) {
}
}
}
use of org.glassfish.api.invocation.InvocationManagerImpl in project Payara by payara.
the class AppTest method testCachingNamingObjectFactory.
@Test
public void testCachingNamingObjectFactory() {
GlassfishNamingManagerImpl nm = null;
try {
InvocationManager im = new InvocationManagerImpl();
InitialContext ic = newInitialContext();
nm = new GlassfishNamingManagerImpl(ic);
nm.publishObject("foo", "Hello: foo", false);
System.out.println("**lookup() ==> " + ic.lookup("foo"));
NamingObjectFactory factory = new NamingObjectFactory() {
private int counter = 1;
public boolean isCreateResultCacheable() {
return true;
}
public Object create(Context ic) {
return ("FACTORY_Created: " + counter++);
}
public String toString() {
return "Huh? ";
}
};
nm.publishObject("bar", factory, false);
System.out.println("**lookup() ==> " + ic.lookup("bar"));
System.out.println("**lookup() ==> " + ic.lookup("bar"));
assert (true);
} catch (Exception ex) {
ex.printStackTrace();
assert (false);
} finally {
try {
nm.unpublishObject("foo");
nm.unpublishObject("bar");
} catch (Exception ex) {
// ignore
}
}
}
use of org.glassfish.api.invocation.InvocationManagerImpl in project Payara by payara.
the class AppTest method testEmptyJavaCompEnv.
@Test
public void testEmptyJavaCompEnv() {
GlassfishNamingManagerImpl nm = null;
InvocationManager im = new InvocationManagerImpl();
ComponentInvocation inv = null;
try {
InitialContext ic = newInitialContext();
triggerLoadingNamedProxies(ic);
nm = new GlassfishNamingManagerImpl(ic);
nm.setInvocationManager(im);
inv = new ComponentInvocation("comp1", ComponentInvocation.ComponentInvocationType.EJB_INVOCATION, null, null, null);
im.preInvoke(inv);
nm.bindToComponentNamespace("app1", "mod1", "comp1", false, new ArrayList<Binding>());
Context ctx = (Context) ic.lookup("java:comp/env");
System.out.println("**lookup(java:comp/env) ==> " + ctx);
} catch (javax.naming.NamingException nnfEx) {
nnfEx.printStackTrace();
assert (false);
}
}
use of org.glassfish.api.invocation.InvocationManagerImpl in project Payara by payara.
the class AppTest method testNonCachingNamingObjectFactory.
@Test
public void testNonCachingNamingObjectFactory() {
GlassfishNamingManagerImpl nm = null;
InvocationManager im = new InvocationManagerImpl();
ComponentInvocation inv = null;
try {
InitialContext ic = newInitialContext();
triggerLoadingNamedProxies(ic);
nm = new GlassfishNamingManagerImpl(ic);
nm.setInvocationManager(im);
List<Binding> bindings = new ArrayList<Binding>();
NamingObjectFactory intFactory = new NamingObjectFactory() {
private int counter = 1;
public boolean isCreateResultCacheable() {
return false;
}
public Object create(Context ic) {
return new Integer(++counter);
}
public String toString() {
return "Huh? ";
}
};
bindings.add(new Binding("conf/area", intFactory));
bindings.add(new Binding("conf/location", "Santa Clara"));
nm.bindToComponentNamespace("app1", "mod1", "comp1", false, bindings);
inv = new ComponentInvocation("comp1", ComponentInvocation.ComponentInvocationType.EJB_INVOCATION, null, null, null);
im.preInvoke(inv);
System.out.println("**lookup(java:comp/env/conf/area) ==> " + ic.lookup("java:comp/env/conf/area"));
System.out.println("**lookup(java:comp/env/conf/location) ==> " + ic.lookup("java:comp/env/conf/location"));
NamingObjectFactory floatFactory = new NamingObjectFactory() {
private int counter = 1;
public boolean isCreateResultCacheable() {
return false;
}
public Object create(Context ic) {
return Float.valueOf(("7" + (++counter)) + "." + 2323);
}
public String toString() {
return "Huh? ";
}
};
List<Binding> bindings2 = new ArrayList<Binding>();
bindings2.add(new Binding("conf/area", floatFactory));
bindings2.add(new Binding("conf/location", "Santa Clara[14]"));
nm.bindToComponentNamespace("app1", "mod1", "comp2", false, bindings2);
inv = new ComponentInvocation("comp2", ComponentInvocation.ComponentInvocationType.EJB_INVOCATION, null, null, null);
im.preInvoke(inv);
System.out.println("**lookup(java:comp/env/conf/area) ==> " + ic.lookup("java:comp/env/conf/area"));
System.out.println("**lookup(java:comp/env/conf/location) ==> " + ic.lookup("java:comp/env/conf/location"));
assert (true);
} catch (InvocationException inEx) {
inEx.printStackTrace();
assert (false);
} catch (Exception ex) {
ex.printStackTrace();
assert (false);
} finally {
try {
im.postInvoke(inv);
nm.unbindComponentObjects("comp1");
} catch (InvocationException inEx) {
} catch (Exception ex) {
}
}
}
Aggregations