[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnumed-devel] open-emed so far.
From: |
syan tan |
Subject: |
[Gnumed-devel] open-emed so far. |
Date: |
Sun, 21 Dec 2003 12:40:34 +1100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030313 |
While savannah is down, I've been checking out the opposition again (
aka non-gpl able probably, aka, dark side of force )
I've been browsing the open-emed source code with the eclipse
refactoring ide (this is a great ide, even with the bugs, it's better
than netbeans; for instance, it does code refactoring, auto-imports,
reads the edited source code for context help, bringing up in scope
variables, and has a grep-like search facility ;
it does take a little while to get the hang of the difference between
importing resources, putting them on the build source path, and putting
them on the
build library path ).
There was some talk about eclipse sdk being compiled with the gnu java
and java library implementation, and also the swt widget toolkit, but
apparently the swt CPL license isn't GPL compatible.
Open-emed pids:
There's only 2 sql usage tables for the identity component (identity_
and traits_).
The persistent server will persist any entries, but restarting it
doesn't reload the data from the database.
The pids client also cheats by reading from the pids.ior file stored by
the server if using the trader service fails (it doesn't try to lookup
the naming service , ??).
I did some code which , given an initial naming context object gotten
from the orb for resolve_initial_reference("NameService")
it will get all the leaf corba objects from the context.
I've used it in a for loop trying to narrow each object into the pids
server, and returning the first one that narrows.
It's a crude way to do object lookup in a directory service, but seems
to work.
to use it call parseContext() with a NamingContext object, the
ContextParser will store any objects that are found that aren't
NamingContext objects,
and recursively descend into the object list returned by objects which
are NamingContext.
then call getFoundObjects() to get back an array of
org.omg.CORBA.Objects which were found from from the inital naming context.
orb = (ORB) ORB.init(args, null);
try {
Object object = orb.resolve_initial_references("NameService");
ContextParser parser = new ContextParser();
try {
parser.parseContext(object);
Object[] oo = parser.getFoundObjects();
showObjects(oo);
} catch (BadKind e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} catch (InvalidName e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Within showObjects , the methods below are eventually called, which
try to construct a specific object out of each object in the oo array.
private void narrowObservationComponent(Object object) {
try {
observationComponent =
ObservationComponentHelper.narrow(object);
System.out.println("FOUND A ObservationComponent");
} catch (Exception e) {
// TODO: handle exception
System.err.println(e);
}
}
private void narrowIdentificationComponent(Object object) {
try {
identificationComponent =
IdentificationComponentHelper.narrow(object);
System.out.println("Found an IdentitifcationComponent");
} catch (Exception e) {
// TODO: handle exception
System.err.println(e);
}
}
/*
* Created on 20/12/2003
*
* To change the template for this generated file go to Window - Preferences -
* Java - Code Generation - Code and Comments
*/
package org.gnumed.corbamed.utility;
import java.util.ArrayList;
import java.util.List;
import org.omg.CORBA.Object;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CosNaming.BindingIteratorHolder;
import org.omg.CosNaming.BindingListHolder;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContext;
import org.omg.CosNaming.NamingContextHelper;
import org.omg.CosNaming.NamingContextPackage.CannotProceed;
import org.omg.CosNaming.NamingContextPackage.NotFound;
/**
* @author sjtan
*
* To change the template for this generated type comment go to Window -
* Preferences - Java - Code Generation - Code and Comments
*/
public class ContextParser {
List list = new ArrayList();
public Object[] getFoundObjects() {
return (Object[]) list.toArray(new Object[0]);
}
public void parseContext(Object object) throws BadKind {
NamingContext context = NamingContextHelper.narrow(object);
BindingIteratorHolder bi = new BindingIteratorHolder();
BindingListHolder bl = new BindingListHolder();
context.list(10, bl, bi);
org.omg.CosNaming.Binding[] b = bl.value;
for (int i = 0; i < b.length; ++i) {
NameComponent[] nc = b[i].binding_name;
Object object3 = null;
try {
object3 = context.resolve(nc);
} catch (NotFound e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (CannotProceed e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch
(org.omg.CosNaming.NamingContextPackage.InvalidName e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (object3 == null) {
System.err.println("UNABLE TO RESOLVE " + nc);
continue;
}
for (int j = 0; j < nc.length; ++j) {
System.out.print(nc[j].id + ", object =" +
object3);
if (j == nc.length - 1) {
System.out.println(";\n\n");
}
attemptCastToNamingContext(nc, object3, j);
}
}
}
private void attemptCastToNamingContext(
NameComponent[] nc,
Object object3,
int j) {
try {
NamingContext context2 =
NamingContextHelper.narrow(object3);
parseContext(object3);
} catch (Exception e) {
System.out.println(nc[j].id + " is not a naming
context");
list.add(object3);
}
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnumed-devel] open-emed so far.,
syan tan <=