Skip to content
Permalink
Browse files
Introduce ModelElement.init() - use it for gathering idl_name
  • Loading branch information
ngmr committed Mar 18, 2016
1 parent 6e0a282 commit b53b251db47615efad3e533025be62141d39b1b5
Showing 18 changed files with 52 additions and 41 deletions.
@@ -18,7 +18,7 @@

package org.apache.yoko.rmi.impl;

class BooleanDescriptor extends SimpleDescriptor {
final class BooleanDescriptor extends SimpleDescriptor {
BooleanDescriptor(TypeRepository repository) {
super(Boolean.TYPE, repository, "boolean",
org.omg.CORBA.TCKind.tk_boolean);
@@ -18,7 +18,7 @@

package org.apache.yoko.rmi.impl;

class ByteDescriptor extends SimpleDescriptor {
final class ByteDescriptor extends SimpleDescriptor {
ByteDescriptor(TypeRepository repository) {
super(Byte.TYPE, repository, "octet", org.omg.CORBA.TCKind.tk_octet);
}
@@ -18,7 +18,7 @@

package org.apache.yoko.rmi.impl;

class CharDescriptor extends SimpleDescriptor {
final class CharDescriptor extends SimpleDescriptor {
CharDescriptor(TypeRepository repository) {
super(Character.TYPE, repository, "wchar",
org.omg.CORBA.TCKind.tk_wchar);
@@ -18,7 +18,7 @@

package org.apache.yoko.rmi.impl;

class DoubleDescriptor extends SimpleDescriptor {
final class DoubleDescriptor extends SimpleDescriptor {
DoubleDescriptor(TypeRepository repository) {
super(Double.TYPE, repository, "double", org.omg.CORBA.TCKind.tk_double);
}
@@ -47,7 +47,7 @@ protected FieldDescriptor(Class owner, Class type, String name,
java.lang.reflect.Field f, TypeRepository repo) {
super(repo, name);
this.type = type;
setIDLName(name);
init();
declaringClass = owner;

if (f != null) {
@@ -61,6 +61,11 @@ protected FieldDescriptor(Class owner, Class type, String name,
}
}

@Override
protected final String genIDLName() {
return java_name;
}

ValueMember getValueMember(TypeRepository rep) {
if (valuemember == null) {
TypeDescriptor desc = rep.getDescriptor(type);
@@ -134,6 +139,13 @@ static FieldDescriptor get(Class declaringClass, ObjectStreamField field, TypeRe
}

static FieldDescriptor get(Class owner, Class type, String name,
java.lang.reflect.Field f, TypeRepository repository) {
FieldDescriptor desc = get0(owner, type, name, f, repository);
desc.init();
return desc;
}

private static FieldDescriptor get0(Class owner, Class type, String name,
java.lang.reflect.Field f, TypeRepository repository) {

if (type.isPrimitive()) {
@@ -18,7 +18,7 @@

package org.apache.yoko.rmi.impl;

class FloatDescriptor extends SimpleDescriptor {
final class FloatDescriptor extends SimpleDescriptor {
FloatDescriptor(TypeRepository repository) {
super(Float.TYPE, repository, "float", org.omg.CORBA.TCKind.tk_float);
}
@@ -18,7 +18,7 @@

package org.apache.yoko.rmi.impl;

class IntegerDescriptor extends SimpleDescriptor {
final class IntegerDescriptor extends SimpleDescriptor {
IntegerDescriptor(TypeRepository repository) {
super(Integer.TYPE, repository, "long", org.omg.CORBA.TCKind.tk_long);
}
@@ -18,7 +18,7 @@

package org.apache.yoko.rmi.impl;

class LongDescriptor extends SimpleDescriptor {
final class LongDescriptor extends SimpleDescriptor {
LongDescriptor(TypeRepository repository) {
super(Long.TYPE, repository, "long_long",
org.omg.CORBA.TCKind.tk_longlong);
@@ -347,10 +347,11 @@ public void init() {
}

parameter_count = param_types.length;
generateIDLName();
super.init();
}

void generateIDLName() {
@Override
protected String genIDLName() {
String idl_name = null;

if (isSetterMethod()) {
@@ -368,8 +369,7 @@ void generateIDLName() {
if (isOverloaded) {
idl_name = transformOverloading(idl_name);
}

setIDLName(idl_name);
return idl_name;
}

private String attributeName() {
@@ -20,19 +20,27 @@

abstract class ModelElement {
protected final TypeRepository repo;
protected final String java_name; // the java name of the type
private String idl_name; // fully resolved package name
protected final String java_name; // the java name of the type
private String idl_name; // fully resolved package name
private volatile boolean notInit = true;

protected ModelElement(TypeRepository repo, String java_name) {
this.repo = repo;
this.java_name = java_name;
}

protected void setIDLName(String name) {
idl_name = name;
protected void init() {
idl_name = genIDLName();
notInit = false;
}

protected abstract String genIDLName();

final void checkInit() {
if (notInit) throw new IllegalStateException("Not initialized");
}

public String getIDLName() {
checkInit();
return idl_name;
}
}
@@ -27,8 +27,4 @@ public String getRepositoryID() {
RemoteClassDescriptor(Class type, TypeRepository repository) {
super(type, repository);
}

public void init() {
super.init();
}
}
@@ -140,9 +140,6 @@ public MethodDescriptor getMethod(Method refl_method) {
super(type, repository);
}

public void init() {
}

public MethodDescriptor[] getMethods() {
if (operations == null) {
init_methods();
@@ -22,9 +22,4 @@ class RemoteInterfaceDescriptor extends RemoteDescriptor {
RemoteInterfaceDescriptor(Class type, TypeRepository repository) {
super(type, repository);
}

public void init() {
super.init();
}

}
@@ -18,7 +18,7 @@

package org.apache.yoko.rmi.impl;

class ShortDescriptor extends SimpleDescriptor {
final class ShortDescriptor extends SimpleDescriptor {
ShortDescriptor(TypeRepository repository) {
super(Short.TYPE, repository, "short", org.omg.CORBA.TCKind.tk_short);
}
@@ -19,10 +19,11 @@
package org.apache.yoko.rmi.impl;

abstract class SimpleDescriptor extends TypeDescriptor {
private final String idl_name;
SimpleDescriptor(Class type, TypeRepository repository, String idl_name,
org.omg.CORBA.TCKind tc) {
super(type, repository);
setIDLName(idl_name);
this.idl_name = idl_name;
// the simple type name is the same as the IDL name. The
// package name is null
setTypeName(idl_name);
@@ -32,6 +33,11 @@ abstract class SimpleDescriptor extends TypeDescriptor {
_type_code = orb.get_primitive_tc(tc);
}

@Override
protected String genIDLName() {
return idl_name;
}

org.omg.CORBA.TypeCode getTypeCode() {
return _type_code;
}
@@ -30,10 +30,6 @@ public String getIDLName() {
setPackageName("CORBA");
}

public void init() {
super.init();
}

/** Read an instance of this value from a CDR stream */
public Object read(org.omg.CORBA.portable.InputStream in) {
return org.omg.CORBA.WStringValueHelper.read(in);
@@ -30,7 +30,7 @@
abstract class TypeDescriptor extends ModelElement {
static Logger logger = Logger.getLogger(TypeDescriptor.class.getName());

protected final Class _java_class;
private final Class _java_class;

protected String _repid;

@@ -125,7 +125,6 @@ protected TypeDescriptor(Class type, TypeRepository repository) {
super(repository, type.getName());
_java_class = type;
String typeName = type.getName();
setIDLName(typeName.replace('.', '_'));
// break up the simple type and package
int idx = typeName.lastIndexOf('.');
// if we have a package, split it into the component parts
@@ -140,6 +139,11 @@ protected TypeDescriptor(Class type, TypeRepository repository) {
}
}

@Override
protected String genIDLName() {
return java_name.replace('.', '_');
}

public String getRepositoryID() {
if (_repid == null)
_repid = "RMI:" + getJavaClass().getName() + ":0000000000000000";
@@ -162,9 +166,6 @@ void setRemoteInterface(RemoteInterfaceDescriptor desc) {
public abstract void write(org.omg.CORBA.portable.OutputStream out,
Object val);

public void init() {
}

public boolean isCustomMarshalled() {
return false;
}
@@ -18,7 +18,7 @@

package org.apache.yoko.rmi.impl;

class VoidDescriptor extends SimpleDescriptor {
final class VoidDescriptor extends SimpleDescriptor {
VoidDescriptor(TypeRepository repository) {
super(Void.TYPE, repository, "void", org.omg.CORBA.TCKind.tk_void);
}

0 comments on commit b53b251

Please sign in to comment.