use of org.omg.CosNaming.Binding in project ACS by ACS-Community.
the class EventModel method discoverNotifyServicesAndChannels.
/**
* Discovers services and bindings, retrieving only once the list of all
* bindings from the naming service.
*/
private synchronized boolean discoverNotifyServicesAndChannels() {
boolean ret = true;
BindingListHolder bl = new BindingListHolder();
BindingIteratorHolder bi = new BindingIteratorHolder();
try {
// Get names of all objects bound in the naming service
nctx.list(-1, bl, bi);
// Extract the useful binding information Id and Kind
Map<String, String> bindingMap = new HashMap<String, String>();
for (Binding binding : bl.value) {
bindingMap.put(binding.binding_name[0].id, binding.binding_name[0].kind);
}
// notify services
discoverNotifyServices(bindingMap);
// channels (NCs)
discoverChannels(bindingMap);
} catch (Exception e) {
ret = false;
}
return ret;
}
use of org.omg.CosNaming.Binding in project ACS by ACS-Community.
the class Helper method getChannelTimestamp.
/**
* Returns the current channel's timestamp registered in the Naming Service.
*/
public Date getChannelTimestamp() {
Date timestamp = new Date(0);
BindingListHolder bl = new BindingListHolder();
BindingIteratorHolder bi = new BindingIteratorHolder();
String chNameAndDomain = combineChannelAndDomainName(channelName, domainName);
try {
// Get names of all objects bound in the naming service
getNamingService().list(-1, bl, bi);
// Extract the useful binding information Id and Kind
for (Binding binding : bl.value) {
if (binding.binding_name[0].kind.equals(NC_KIND_NCSUPPORT.value)) {
if (binding.binding_name[0].id.startsWith(chNameAndDomain)) {
String sts = binding.binding_name[0].id.substring(chNameAndDomain.length() + 1);
DateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
try {
timestamp = df.parse(sts);
} catch (ParseException e) {
}
}
}
}
} catch (Exception e) {
}
return timestamp;
}
use of org.omg.CosNaming.Binding in project ACS by ACS-Community.
the class ConsumerWithComponentClientTestCaseTest method namingBindingsContain.
private boolean namingBindingsContain(String firstBindingName) {
BindingListHolder blh = new BindingListHolder();
ncHelper.getNamingService().list(100, blh, new BindingIteratorHolder());
for (Binding binding : blh.value) {
if (binding.binding_name[0].id.equals(firstBindingName)) {
return true;
}
}
return false;
}
use of org.omg.CosNaming.Binding in project wildfly by wildfly.
the class CorbaNamingContext method list.
public void list(int how_many, BindingListHolder bl, BindingIteratorHolder bi) {
if (this.destroyed)
return;
Binding[] result;
this.cleanup();
int size = how_many();
Iterator<Name> names = this.names.keySet().iterator();
Iterator<Name> contexts = this.contexts.keySet().iterator();
if (how_many < size) {
// counter for copies
int how_many_ctr = how_many;
// set up an array with "how_many" bindings
result = new Binding[how_many];
for (; names.hasNext() && how_many_ctr > 0; how_many_ctr--) result[how_many_ctr - 1] = new Binding((names.next()).components(), BindingType.nobject);
for (; contexts.hasNext() && how_many_ctr > 0; how_many_ctr--) result[how_many_ctr - 1] = new Binding((contexts.next()).components(), BindingType.ncontext);
// create a new BindingIterator for the remaining arrays
size -= how_many;
Binding[] rest = new Binding[size];
for (; names.hasNext() && size > 0; size--) rest[size - 1] = new Binding((names.next()).components(), BindingType.nobject);
for (; contexts.hasNext() && size > 0; size--) rest[size - 1] = new Binding((contexts.next()).components(), BindingType.ncontext);
org.omg.CORBA.Object o;
try {
// Iterators are activated with the RootPOA (transient)
byte[] oid = rootPoa.activate_object(new BindingIteratorImpl(rest));
o = rootPoa.id_to_reference(oid);
} catch (Exception e) {
IIOPLogger.ROOT_LOGGER.logInternalError(e);
throw new INTERNAL(e.toString());
}
bi.value = BindingIteratorHelper.narrow(o);
} else {
result = new Binding[size];
for (; names.hasNext() && size > 0; size--) result[size - 1] = new Binding((names.next()).components(), BindingType.nobject);
for (; contexts.hasNext() && size > 0; size--) result[size - 1] = new Binding((contexts.next()).components(), BindingType.ncontext);
}
bl.value = result;
}
use of org.omg.CosNaming.Binding in project narayana by jbosstm.
the class NamingServiceClient method test.
@Ignore
public void test() throws InvalidName {
String[] args = new String[2];
args[0] = "-ORBInitRef";
args[1] = "NameService=corbaloc::localhost:3528/NameService";
Properties props = new Properties();
props.put("org.omg.CORBA.ORBInitialPort", "3528");
props.put("org.omg.CORBA.ORBInitialHost", "localhost");
ORB orb = ORB.init(args, props);
NamingContextExt nc = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
BindingListHolder bl = new BindingListHolder();
BindingIteratorHolder blIt = new BindingIteratorHolder();
nc.list(1000, bl, blIt);
Binding[] bindings = bl.value;
List<String> toResolve = new ArrayList<String>();
toResolve.add("TransactionManagerService");
for (int i = 0; i < bindings.length; i++) {
int lastIx = bindings[i].binding_name.length - 1;
// check to see if this is a naming context
if (bindings[i].binding_type == BindingType.ncontext) {
log.info("Context: " + bindings[i].binding_name[lastIx].id);
} else {
log.info("Object: " + bindings[i].binding_name[lastIx].id);
}
toResolve.remove(bindings[i].binding_name[lastIx].id);
}
assertTrue(toResolve.isEmpty());
}
Aggregations