BeanCorbaServantpublic class BeanCorbaServant extends org.omg.PortableServer.Servant implements org.omg.CORBA.portable.InvokeHandler
Fields Summary |
---|
private static final Logger | log | private final IORFactory | factory | private final org.omg.PortableServer.Current | poaCurrent | private final org.jboss.ejb3.Container | container | private final org.omg.CORBA.InterfaceDef | interfaceDef | private final String[] | repositoryIds | private org.jboss.iiop.csiv2.SASCurrent | sasCurrent | private HashMap | methodMap |
Constructors Summary |
---|
protected BeanCorbaServant(IORFactory factory, org.omg.PortableServer.Current poaCurrent, org.jboss.ejb3.Container container, org.omg.CORBA.InterfaceDef interfaceDef, org.jboss.iiop.rmi.InterfaceAnalysis interfaceAnalysis)
assert factory != null;
assert poaCurrent != null;
assert container != null;
assert container instanceof SessionContainer; // see invoke
assert interfaceDef != null;
assert interfaceAnalysis != null;
this.factory = factory;
this.poaCurrent = poaCurrent;
this.container = container;
this.interfaceDef = interfaceDef;
this.repositoryIds = interfaceAnalysis.getAllTypeIds();
try
{
this.sasCurrent = (SASCurrent) CorbaORB.getInstance().resolve_initial_references("SASCurrent");
}
catch (InvalidName e)
{
log.warn("Can't find SASCurrent");
this.sasCurrent = null;
}
this.methodMap = new HashMap<String, SkeletonStrategy>();
AttributeAnalysis[] attrs = interfaceAnalysis.getAttributes();
for (int i = 0; i < attrs.length; i++) {
OperationAnalysis op = attrs[i].getAccessorAnalysis();
log.debug(" " + op.getJavaName() + ": " + op.getIDLName());
methodMap.put(op.getIDLName(),
new SkeletonStrategy(op.getMethod()));
op = attrs[i].getMutatorAnalysis();
if (op != null) {
log.debug(" " + op.getJavaName() + ": " + op.getIDLName());
methodMap.put(op.getIDLName(),
new SkeletonStrategy(op.getMethod()));
}
}
OperationAnalysis[] ops = interfaceAnalysis.getOperations();
for (int i = 0; i < ops.length; i++) {
log.debug(" " + ops[i].getJavaName() + ": " + ops[i].getIDLName());
methodMap.put(ops[i].getIDLName(),
new SkeletonStrategy(ops[i].getMethod()));
}
|
Methods Summary |
---|
public java.lang.String[] | _all_interfaces(org.omg.PortableServer.POA poa, byte[] objectId)
return (String[]) repositoryIds.clone();
| public org.omg.CORBA.Object | _get_interface_def()Returns an IR object describing the bean's remote interface.
if (interfaceDef != null)
return interfaceDef;
else
return super._get_interface_def();
| public org.omg.CORBA.portable.OutputStream | _invoke(java.lang.String opName, org.omg.CORBA.portable.InputStream in, org.omg.CORBA.portable.ResponseHandler handler)
log.trace("invoke: " + opName);
SkeletonStrategy op = (SkeletonStrategy) methodMap.get(opName);
if (op == null)
{
log.debug("Unable to find opname '" + opName + "' valid operations:" + methodMap.keySet());
throw new BAD_OPERATION(opName);
}
org.omg.CORBA_2_3.portable.OutputStream out;
try
{
Object id = ReferenceData.extractObjectId(poaCurrent.get_object_id());
log.trace("id = " + id);
Transaction tx = TxServerInterceptor.getCurrentTransaction();
log.trace("tx = " + tx);
if(sasCurrent != null)
{
byte username[] = sasCurrent.get_incoming_username();
byte credentials[] = sasCurrent.get_incoming_password();
byte principalName[] = sasCurrent.get_incoming_principal_name();
if(username != null && username.length > 0)
{
String name = new String(username, "UTF-8");
int domainIndex = name.lastIndexOf("@");
if(domainIndex > 0)
name = name.substring(0, domainIndex);
log.debug("username = " + name);
Principal principal = new SimplePrincipal(name);
SecurityAssociation.setPrincipal(principal);
}
if(credentials != null && credentials.length > 0)
{
SecurityAssociation.setCredential(new String(credentials, "UTF-8").toCharArray());
}
if(principalName != null && principalName.length > 0)
log.warn("principalName = " + new String(principalName, "UTF-8")); // FIXME: implement principalName support
}
Object args[] = op.readParams((org.omg.CORBA_2_3.portable.InputStream) in);
Object retVal = invoke(tx, id, op.getMethod(), args);
out = (org.omg.CORBA_2_3.portable.OutputStream) handler.createReply();
if(op.isNonVoid())
op.writeRetval(out, retVal);
}
catch(Throwable t)
{
// TODO: check log level before stacktrace?
t.printStackTrace();
if(t instanceof Exception)
{
Exception e = (Exception) t;
RmiIdlUtil.rethrowIfCorbaSystemException(e);
out = (org.omg.CORBA_2_3.portable.OutputStream) handler.createExceptionReply();
op.writeException(out, e);
}
else
throw new RuntimeException("NYI");
}
return out;
| private javax.transaction.TransactionManager | getTransactionManager()
//return TxUtil.getTransactionManager();
return TransactionManagerLocator.getInstance().locate();
| private java.lang.Object | invoke(java.lang.Object id, java.lang.reflect.Method method, java.lang.Object[] args)
// TODO: Support other containers beside Stateless and Stateful?
return ((SessionContainer) container).invoke(factory, id, method, args, null);
| private java.lang.Object | invoke(javax.transaction.Transaction tx, java.lang.Object id, java.lang.reflect.Method method, java.lang.Object[] args)
if(tx == null)
return invoke(id, method, args);
// FIXME: refactor TxServerInterceptor so that it pushed the tpc into the invocation like ClientTxPropegationInterceptor
// this would require the localInvoke to be also refactored, so that it uses invocation instead of localInvoke.
TransactionManager tm = getTransactionManager();
// see TxPropagationInterceptor
if(tm.getTransaction() != null)
throw new RuntimeException("cannot import a transaction context when a transaction is already associated with the thread");
tm.resume(tx);
try
{
return invoke(id, method, args);
}
finally
{
tm.suspend();
}
|
|