Closed ChrisChurch closed 7 years ago
Actually I didn't port it, not understanding its purpose ;) I'll update mid-next week.
Thanks for reporting.
With the latest release 0.12.0, I've exposed the method through the DriverInterface.
Can you try this and let me know if it worked:
First update with update you composer deps to "soluble/japha": "^0.12.0"
then run composer update
and be sure it downloads the 0.12.0 version, then
use Soluble\Japha\Bridge\Adapter as BridgeAdapter;
$adapter = new BridgeAdapter([
'driver' => 'Pjb62',
'servlet_address' => 'xxx.yy.zz.251:8080/JavaBridge'
]);
$servletContext = $adapter->getDriver()->getJavaContext()->getServlet();
$servletContext->doSomething();
Thanks a lot
I have it working now:
php: $servletContext = $ba->getDriver()->getJavaContext()->getServlet(); $xx = $servletContext->hello("Test", "1"); echo $xx;
java: public class MyScheduler extends HttpServlet {
public String hello(String type, String id) {
return "hello from MyServlet:" + type + id;
}
results in:
"hello from MyServlet:Test1"
Great, thanks
Great,
@ChrisChurch , I'm suddently regretting the name of the method $ba->getDriver()->getJavaContext()
...
I would like to rename it as $ba->getDriver()->getServerContext()
or $ba->getDriver()->getContext()
in the next release '0.13.0'... Is it a problem for you ? and have you any preferences, for me JavaContext() is too wide, the getContext() version would be more understandable ? What do you think ?
Thanks,
Sen
With reference to the servlet spec (e.g. tomcat) a webapp is named a context, so I think the:
$ba->getDriver()->getContext() is appropriate. Not a problem for me to change it.
C
Thanks Chris, I've released a new version with the rename into getContext()
, as it's a breaking change here's the link in the CHANGELOG
Please upgrade to 0.13.0 and thanks again.
Hi Sebastion
I have tested in working with the changed function name, but am a little surprised as I thought it would be:
$servletContext = $ba->getDriver()->getContext();
not
$servletContext = $ba->getDriver()->getContext()->getServlet();
as the servlet name is already specified in the options and context 'means' webapp., e.g:
$options = [ 'driver' => 'Pjb62', 'servlet_address' => 'xxxx-amazonaws.com:8080/Quartz/scheduler' ];
But I am still looking at how you have designed/coded it so not an authority...
Chris
Hi Chris,
Good point, but I realized the original client was returning a php.java.bridge.http.Context
object, so I kept the behaviour like it was. Mostly because my java/servlet expertise is really basic ;)
I've just generated an api doc where you can have a look to the Context doc. I hope it can bring a better picture about possibilties. It's maybe contains the answer to your comment ?
In the meantime, I try to figure out what I can improve in the bridge install process. I forked the original CVS repository here on github. If you see improvements that can be done, let me know.
Thanks,
Seb
Connecting to a servlet based on JavaBridge you can do in php with Java.inc included:
$java_context()->getServlet()->doSomething($x)
where doSomething is a function like:
public String hello(String mytype, String id) {
is there an equivalent in soluble-jalpha, I can see that you can get java objects etc but how to get a context or class created by me?
Can I get a class like below and execute functions in it
public class MyScheduler extends HttpServlet {
public String hello(String mytype, String id) {