[Design of POJO Server] - Re: JRMPProxyFactory equivalent for POJO Services
by scott.stark@jboss.org
No, its a remoting integration aspect that needs to be supplied. Its simple enough to create one as this example does. The based aspects for the client should be externalized though, and the jndi binding should be done via an aspect on this bean. I have created a jbas issue for the replacement.
http://jira.jboss.com/jira/browse/JBAS-4456
| package org.jboss.profileservice.remoting;
|
| import java.util.ArrayList;
|
| import javax.naming.InitialContext;
|
| import org.jboss.aop.Dispatcher;
| import org.jboss.aop.advice.Interceptor;
| import org.jboss.aop.proxy.Proxy;
| import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
| import org.jboss.aspects.remoting.MergeMetaDataInterceptor;
| import org.jboss.aspects.remoting.Remoting;
| import org.jboss.aspects.security.SecurityClientInterceptor;
| import org.jboss.deployers.spi.management.ManagementView;
| import org.jboss.logging.Logger;
| import org.jboss.profileservice.spi.ProfileService;
| import org.jboss.remoting.InvokerLocator;
| import org.jboss.util.naming.Util;
|
| /**
| * An aop/remoting proxy factory bean that exposes the ProfileService
| * interfaces.
| *
| * @author Scott.Stark(a)jboss.org
| * @version $Revision:$
| */
| public class ProxyFactory
| {
| private static final Logger log = Logger.getLogger(ProxyFactory.class);
| private String dispatchName = "ProfileService";
| private String jndiName = "ProfileService";
| private InvokerLocator locator;
| private ProfileService ps;
| private ManagementView mgtView;
| private Proxy psProxy;
| private Proxy mgtViewProxy;
|
| public String getDispatchName()
| {
| return dispatchName;
| }
|
| public void setDispatchName(String dispatchName)
| {
| this.dispatchName = dispatchName;
| }
|
| public String getJndiName()
| {
| return jndiName;
| }
|
| public void setJndiName(String jndiName)
| {
| this.jndiName = jndiName;
| }
|
| public InvokerLocator getLocator()
| {
| return locator;
| }
|
| public void setLocator(InvokerLocator locator)
| {
| this.locator = locator;
| }
|
| public ProfileService getProfileService()
| {
| return ps;
| }
|
| public void setProfileService(ProfileService ps)
| {
| this.ps = ps;
| }
|
| public Proxy getProfileServiceProxy()
| {
| return psProxy;
| }
|
| public ManagementView getViewManager()
| {
| return mgtView;
| }
| public void setViewManager(ManagementView mgtView)
| {
| this.mgtView = mgtView;
| }
|
| public Proxy getManagementViewProxy()
| {
| return mgtViewProxy;
| }
|
| public void start()
| throws Exception
| {
| ClassLoader loader = Thread.currentThread().getContextClassLoader();
| Class[] ifaces = {ProfileService.class};
|
| // Create the ProfileService proxy
| Dispatcher.singleton.registerTarget(dispatchName, ps);
|
| ArrayList<Interceptor> interceptors = new ArrayList<Interceptor>();
| interceptors.add(SecurityClientInterceptor.singleton);
| interceptors.add(MergeMetaDataInterceptor.singleton);
| interceptors.add(InvokeRemoteInterceptor.singleton);
|
| psProxy = Remoting.createRemoteProxy(dispatchName, loader, ifaces, locator,
| interceptors, "ProfileService");
| InitialContext ctx = new InitialContext();
| Util.bind(ctx, jndiName, psProxy);
|
| // Create the ManagementView proxy
| Class[] mvIfaces = {ManagementView.class};
| String mvDispatchName = dispatchName+".ManagementView";
| Dispatcher.singleton.registerTarget(mvDispatchName, mgtView);
| mgtViewProxy = Remoting.createRemoteProxy(mvDispatchName, loader, mvIfaces, locator,
| interceptors, "ProfileService");
| log.debug("Bound ProfileService proxy");
| }
|
| public void stop()
| throws Exception
| {
| ClassLoader loader = Thread.currentThread().getContextClassLoader();
| Dispatcher.singleton.unregisterTarget(dispatchName);
| String mvDispatchName = dispatchName+".ManagementView";
| Dispatcher.singleton.unregisterTarget(mvDispatchName);
| InitialContext ctx = new InitialContext();
| Util.unbind(ctx, jndiName);
| log.debug("Unbound ProfileService proxy");
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050299#4050299
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4050299
17 years, 6 months
[Design of JBossCache] - Re: Binding proxy to Cache in AS JNDI
by bstansberry@jboss.com
The JRMPProxyFactory does have one potentially useful config option.
If your service (say CacheJmxWrapper) exposes this method in its mbean interface:
public Object invoke(Invocation mi) throws Exception
then you can set the "InvokeTargetMethod" attribute on JRMPProxyFactory to 'false'. If configured that way, the detached invoker won't try to invoke the target method (e.g. get(fqn, key)) but rather will invoke the invoke(Invocation mi) method.
It is then the responsibility of your service to read the target method and args from the Invocation and decide how to deal with them. This is how EJB2 containers work.
In the CacheJmxWrapper case, its implementation of invoke(Invocation mi) would read the method name/args from the invocation and use reflection to invoke on the wrapped Cache.
Something like that could certainly be implemented, but not in the JBC code base. JBC does not have visibility to the Invocation class. I would have to implement it in the AS code base.
Want to find a better solution, as this seems like a general AS 5 problem -- exposing Remoting-capable proxies for POJO services.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050279#4050279
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4050279
17 years, 6 months