| Method from org.jboss.invocation.jrmp.server.JRMPProxyFactory Detail: |
protected void createProxy(Object cacheID,
String proxyBindingName,
ClassLoader loader,
Class[] ifaces) {
GenericProxyFactory proxyFactory = new GenericProxyFactory();
theProxy = proxyFactory.createProxy(cacheID, getServiceName(), invokerName,
jndiName, proxyBindingName, interceptorClasses, loader, ifaces);
}
|
protected void destroyService() throws Exception {
interceptorClasses.clear();
}
|
public Element getClientInterceptors() {
return interceptorConfig;
}
|
public Class getExportedInterface() {
return exportedInterfaces[0];
}
|
public Class[] getExportedInterfaces() {
return exportedInterfaces;
}
|
protected ArrayList getInterceptorClasses() {
return interceptorClasses;
}
|
public boolean getInvokeTargetMethod() {
return invokeTargetMethod;
}
|
public ObjectName getInvokerName() {
return invokerName;
}
|
public String getJndiName() {
return jndiName;
}
|
public Object getProxy() {
return theProxy;
}
|
public ObjectName getTargetName() {
return targetName;
}
|
public Object invoke(Invocation mi) throws Exception {
final boolean remoteInvocation = mi instanceof MarshalledInvocation;
if(remoteInvocation)
{
((MarshalledInvocation)mi).setMethodMap(methodMap);
}
final Object result;
if(invokeTargetMethod)
{
String signature[] = (String[])signatureMap.get(mi.getMethod());
result = server.invoke(targetName, mi.getMethod().getName(), mi.getArguments(), signature);
}
else
{
result = server.invoke(targetName, "invoke", new Object[]{mi}, Invocation.INVOKE_SIGNATURE);
}
return result;
}
|
protected void rebind() throws Exception {
log.debug("(re-)Binding " + jndiName);
Util.rebind(new InitialContext(), jndiName, theProxy);
}
|
public void setClientInterceptors(Element config) throws Exception {
this.interceptorConfig = config;
Iterator interceptorElements = MetaData.getChildrenByTagName(interceptorConfig, "interceptor");
ClassLoader loader = Thread.currentThread().getContextClassLoader();
interceptorClasses.clear();
while( interceptorElements != null && interceptorElements.hasNext() )
{
Element ielement = (Element) interceptorElements.next();
String className = null;
className = MetaData.getElementContent(ielement);
Class clazz = loader.loadClass(className);
interceptorClasses.add(clazz);
log.debug("added interceptor type: "+clazz);
}
}
|
public void setExportedInterface(Class exportedInterface) {
this.exportedInterfaces = new Class[] {exportedInterface};
}
|
public void setExportedInterfaces(Class[] exportedInterfaces) {
this.exportedInterfaces = exportedInterfaces;
}
|
public void setInvokeTargetMethod(boolean invokeTargetMethod) {
this.invokeTargetMethod = invokeTargetMethod;
}
|
public void setInvokerName(ObjectName invokerName) {
this.invokerName = invokerName;
}
|
public void setJndiName(String jndiName) {
this.jndiName = jndiName;
}
|
public void setTargetName(ObjectName targetName) {
this.targetName = targetName;
}
|
protected void startService() throws Exception {
/* Create a binding between the invoker name hash and the jmx name
This is used by the JRMPInvoker to map from the Invocation ObjectName
hash value to the target JMX ObjectName.
*/
Integer nameHash = new Integer(getServiceName().hashCode());
Registry.bind(nameHash, getServiceName());
// Create the service proxy
Object cacheID = null;
String proxyBindingName = null;
Class[] ifaces = exportedInterfaces;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
createProxy(cacheID, proxyBindingName, loader, ifaces);
log.debug("Created JRMPPRoxy for service="+targetName
+", nameHash="+nameHash+", invoker="+invokerName);
if( jndiName != null )
{
InitialContext iniCtx = new InitialContext();
Util.bind(iniCtx, jndiName, theProxy);
log.debug("Bound proxy under jndiName="+jndiName);
}
for(int i = 0; i < exportedInterfaces.length; ++i)
{
final Method[] methods = exportedInterfaces[i].getMethods();
for(int j = 0; j < methods.length; ++j)
{
methodMap.put(new Long(MarshalledInvocation.calculateHash(methods[j])), methods[j]);
String signature[];
final Class[] types = methods[j].getParameterTypes();
if(types == null || types.length == 0)
{
signature = null;
}
else
{
signature = new String[types.length];
for(int typeInd = 0; typeInd < types.length; ++typeInd)
{
signature[typeInd] = types[typeInd].getName();
}
}
signatureMap.put(methods[j], signature);
}
}
}
|
protected void stopService() throws Exception {
Integer nameHash = new Integer(getServiceName().hashCode());
Registry.unbind(nameHash);
if( jndiName != null )
{
InitialContext iniCtx = new InitialContext();
Util.unbind(iniCtx, jndiName);
}
this.theProxy = null;
}
|