Search in sources :

Example 1 with NamingContext

use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.

the class AlarmSystemCorbaServer method getNamingContext.

/**
	 * Get the {@link NamingContext}
	 * 
	 * @return The {@link NamingContext}
	 */
private NamingContext getNamingContext() throws InvalidName {
    org.omg.CORBA.Object obj = null;
    Properties props = System.getProperties();
    String nameServiceCorbaLoc = props.getProperty("ORBInitRef.NameService");
    if (nameServiceCorbaLoc != null) {
        obj = orb.string_to_object(nameServiceCorbaLoc);
    }
    if (obj == null) {
        obj = orb.resolve_initial_references("NameService");
    }
    if (obj == null) {
        throw new NullPointerException("Error getting the reference to the NameService");
    }
    NamingContext context = NamingContextExtHelper.narrow(obj);
    if (context == null) {
        throw new NullPointerException("Got a null NamingContext while narrowing");
    }
    return context;
}
Also used : Object(org.omg.CORBA.Object) Properties(java.util.Properties) NamingContext(org.omg.CosNaming.NamingContext)

Example 2 with NamingContext

use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.

the class AlarmSystemCorbaServer method unregisterToNamingService.

/**
     * Unregister the AlarmService name to the Naming Service.
     * <P>
     * The name to unregister is taken from the IDL interface.
     */
private void unregisterToNamingService() throws Exception {
    String name = alma.alarmsystem.AlarmServiceName.value;
    m_logger.log(AcsLogLevel.DEBUG, "Unregistering " + name + " from the naming service");
    NamingContext context = getNamingContext();
    NameComponent[] nameComponent = new NameComponent[1];
    nameComponent[0] = new NameComponent(name, "");
    context.unbind(nameComponent);
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) NamingContext(org.omg.CosNaming.NamingContext)

Example 3 with NamingContext

use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.

the class AlarmSystemCorbaServer method getCDB.

/**
	 * Get a reference to the DAL.
	 * 
	 * @return The DAL
	 * @throws Exception In case of error getting the DAL
	 */
private DAL getCDB() throws Exception {
    NamingContext context = getNamingContext();
    NameComponent[] nameCom = new NameComponent[1];
    nameCom[0] = new NameComponent("CDB", "");
    Object obj = context.resolve(nameCom);
    return DALHelper.narrow(obj);
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) Object(org.omg.CORBA.Object) NamingContext(org.omg.CosNaming.NamingContext)

Example 4 with NamingContext

use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.

the class AlarmSystemCorbaServer method registerToNamingService.

/**
     * Register the AlarmService name to the Naming Service.
     * <P>
     * The name to register is taken from the IDL interface.
     * 
     * @param laserObject The CORBA object to bind to the name
     */
private void registerToNamingService(org.omg.CORBA.Object laserObject) throws Exception {
    String name = alma.alarmsystem.AlarmServiceName.value;
    m_logger.log(AcsLogLevel.DEBUG, "Registering into the naming service with name " + name);
    NamingContext context = getNamingContext();
    NameComponent[] nameComponent = new NameComponent[1];
    nameComponent[0] = new NameComponent(name, "");
    context.rebind(nameComponent, laserObject);
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) NamingContext(org.omg.CosNaming.NamingContext)

Example 5 with NamingContext

use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.

the class AlarmServiceUtils method getNamingContext.

/**
	 * Get the {@link NamingContext}
	 * 
	 * @return The {@link NamingContext}
	 */
private NamingContext getNamingContext() throws InvalidName {
    org.omg.CORBA.Object obj = orb.resolve_initial_references("NameService");
    NamingContext context = NamingContextExtHelper.narrow(obj);
    if (context == null) {
        throw new NullPointerException("Got a null NamingContext");
    }
    return context;
}
Also used : Object(org.omg.CORBA.Object) NamingContext(org.omg.CosNaming.NamingContext)

Aggregations

NamingContext (org.omg.CosNaming.NamingContext)27 NameComponent (org.omg.CosNaming.NameComponent)14 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)4 Object (org.omg.CORBA.Object)4 PrintWriter (java.io.PrintWriter)3 Properties (java.util.Properties)3 CannotProceedException (javax.naming.CannotProceedException)3 NameNotFoundException (javax.naming.NameNotFoundException)3 NamingException (javax.naming.NamingException)3 BAD_PARAM (org.omg.CORBA.BAD_PARAM)3 NotFound (org.omg.CosNaming.NamingContextPackage.NotFound)3 AcsORBProfilerImplBase (alma.acs.profiling.orb.AcsORBProfilerImplBase)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 FileReader (java.io.FileReader)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 LineNumberReader (java.io.LineNumberReader)2 NotContextException (javax.naming.NotContextException)2 AcsORBProfiler (org.jacorb.orb.acs.AcsORBProfiler)2