Correct way to AddOrUpdate Property of Class in a ConcurrentDictionary?

I have a ConcurrentDictionary we'll call ParamaterList.  And a class named Parameter. 
Class parameter{
public string Username = string.Empty;
public string FirstName = string.Empty;
public string LastName = string.Empty;       
public bool enabled = false;
ConcurrentDictionary<string, parameter> ParameterList = new ConcurrentDictionary<string, parameter>;
I want to confirm that I'm doing this correctly and there isn't a better way.  To update a class I am doing this:
ParameterList.AddOrUpdate("username", true, (k, v) => {v.enabled = true; return v;});
Is that the correct approach or is there a 'correct' way to update a property of v directly without returning a full 'new' class? My classes are small now but I would like to learn best practices for concurrentDictionaries. 

1) TryGetValue is thread safe.  If someone is trying to modify the collection while you're retrieving it then they will block until you have the value.
2) Yes another thread could remove the item after you get it but there is no concurrent collection that guarantees otherwise. A concurrent collection simply guarantees that while a particular method on the collection is being executed that no other
thread will cause changes that will cause it to fail.  Once the method returns another thread can do whatever it wants.  90% of the time that is perfectly fine and expected.  In the few cases where you need to ensure an item remains in a collection
for some fixed period of time then you'll have to use a lock instead.  But after the lock is released the item can still be removed. 
Removing an item from the collection does not invalidate your copy of that item.  You still have a reference to the item and it'll exist and be usable as long as you hold onto it.  Whether it is in the collection or not doesn't matter.  In
general multiple writers to a collection is not a good thing to have so you'll want to consider modifying your code to have a single writer but any # of readers.  This will simplify your code and make it easier to maintain.
3) If you want to update an item if it exists or create a new one if it doesn't then you have to make some decisions.  TryAddUpdate would be the way to go if you want to recreate the item each time whether it is already there or not. If you only want
to create it if it doesn't exist then use TryGetValue and if that fails then use TryAdd to add a new one. However a concurrent collection doesn't prevent modifications between these calls so between the time you get the value and update/add it somebody else
could remove it, add it or both.  If you need a gurantee that the collection does not change during these calls then you have to use a lock because the collection itself doesn't provide a long enough lock. 
If you do decide to use TryAddUpdate note that each time you will add a new object to the collection and this will cause problems for other threads.  For example another thread may use TryGetValue to get the object and then set one of the properties. 
But if another thread calls TryAddUpdate during this time a new object is created and added to the collection so the original thread's changes are lost and they are none the wiser.  However if you use TryGetValue first and only call TryAdd if the item
doesn't exist yet then you will always be working against the same object across threads and by using the return value of the methods you can determine whether you got a value or successfully added it.  This is the cost of using multiple writers.
4) The collections are thread-safe, not the objects in them.  There is no guarantees around the thread safety of the objects in the collection. If you need thread safety on the objects themselves then either the object type needs to be thread safe or
you have to use a lock.  For the case of a single writer, multiple readers then you are better off using a ReaderWriterLock instead of a concurrent dictionary.

Similar Messages

  • What is the correct way to add styling to drag-and-drop created calendars?

    I have a working instance of a rich client calendar. I generated the view with the required fields (start, stop, provider, ...), put it into the App Module, and dragged it onto a JSF page to create a calendar.
    Next I created an activityScope object in a class called CalendarBean (no inheritance)
    Class CalendarBean()
    private HashMap<Set<String>, InstanceStyles> activityColorMap;
    +..+
    +public CalendarBean() {+
    super();
    activityColorMap = new HashMap<Set<String>, InstanceStyles>();
    HashSet setEd = new HashSet<String>();
    HashSet setLen = new HashSet<String>();
    setEd.add("Work");
    setLen.add("Home");
    activityColorMap.put(setEd, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.ORANGE));
    activityColorMap.put(setLen, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.RED));
    +}+
    +}+
    Next, I linked this up as a backing bean and associated the ActivityStyles of CalendarBean to it:
    +#{backingBeanScope.calendarBean.activityColorMap}+
    I populated some records in the database with properties "Work" and "Ed', but they show default blue.
    As I understand it, I need to do something with the getTags() method of the underlying CalendarActivity class, but I'm not quite sure how to do that.
    Took a stab at creating a class, CalendarActivityBean, that extended CalendarActivity, and pointed all the CalendarActivity references I had to the new class, but it didn't seem to fire (in debug), and I got into trouble, when inserting records, with
    public void calendarActivityListener(CalendarActivityEvent calendarActivityEvent) {
    currActivity = (CalendarActivityBean) calendarActivityEvent.getCalendarActivity();
    being an illegal cast
    What is the correct way to add provider-based styling to drag-and-drop create calendars?
    Ed Schechter

    A colleague of mine was kind enough to solve this:
    The calendar has ActivityStyles property = #{calendarBean.activityStyles}
    CalendarBean looks something like this:
    package com.hub.appointmentscheduler.ui.schedule;
    import java.util.HashMap;
    import java.util.HashSet;
    import java.util.Set;
    import oracle.adf.view.rich.util.CalendarActivityRamp;
    import oracle.adf.view.rich.util.InstanceStyles;
    +public class CalendarBean {+
    private HashMap activityStyles;
    private String dummy;
    +public CalendarBean() {+
    +// Define colors+
    activityStyles = new HashMap<Set<String>, InstanceStyles>();
    HashSet setPending = new HashSet<String>();
    HashSet setArrived = new HashSet<String>();
    HashSet setApproved = new HashSet<String>();
    HashSet setCompleted = new HashSet<String>();
    setApproved.add("APPROVED");
    setPending.add("PENDING");
    setArrived.add("ARRIVED");
    setCompleted.add("COMPLETED");
    activityStyles.put(setApproved, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.GREEN));
    activityStyles.put(setPending, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.ORANGE));
    activityStyles.put(setArrived, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.PLUM));
    activityStyles.put(setCompleted, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.LAVENDAR));
    +}+
    +public void setactivityStyles(HashMap activityStyles) {+
    this.activityStyles = activityStyles;
    +}+
    +public HashMap getactivityStyles() {+
    return activityStyles;
    +}+
    +}+
    Now, go into the Bindings tab on the calendar page, double click the calendar binding, and specify the column you've defined as the calendar's Provider in the Tags dropdown.
    Should show colors.

  • Ok, does anyone know the correct way to do this

    Hi all
    would someone beable to explain the correct way of attaching dynamic text to a rotaing menu so that the text moves with the image as it rotates,
    I am now being told that in order to have dynamic text rotate/move I have to embed the font, by placing a text field on the stage outside my flash area and then set embedFonts property to true, and then apply a textformat.
    first, is this the correct way of doing it?
    second, can someone please explain(by breaking down into steps, as I am a newbie) how I go about setting embedFonts property to true and applying a textformat.
    what I have created;
    1.)I created a movieclip called 'textHolder' inside this has two dynamic text fields called 'headerText'  & 'bodyText'  <<<<< IS THIS CORRECT?
    2.)I have an xml file which will load the text in as well as the images with the rotating menu, see below;  <<<IS THIS CORRECT????
    <?xml version="1.0" encoding="utf-8"?>
    <data>
      <image name="image 1" path="img/img1.jpg"
        textHolder.headerText="Sunset"
        textHolder.bodyText="The hour of night is near, as the skies get blood-filled" />
    <data>
    3.What I am missing is what script I need for the main.as file, can anyone help here?
    so to break down.
    I have a rotating menu that is driven by xml, that loads images on the menu. I would also like to load text to the left of each image, and have the text be fixed with the image as it rotates.
    I can post the as, but I would like to know if the above is correct first, if you would like to see the main script please say.
    I have attached a jpg layout to give you an idea as to what I am trying to explain. can someone please help!!!!!!!!!
    (this is my previous post: http://forums.adobe.com/thread/463213?tstart=0  but I feel its got lost a little along the way)

    MY CURRENT SCRIPT, CAN YOU SEE HOW TO ATTACH THE TEXT WITH THE IMAGE?
    package 
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.net.URLLoaderDataFormat;
    import soulwire.ui.CircleMenu;
    public class Main extends Sprite
      //————————————————————————————————————————————— CLASS MEMBERS  VALUE
      public var circleMenu:      CircleMenu;
      public var xmlLoader:      URLLoader;
      //——————————————————————————————————————————————— CONSTRUCTOR
      public function Main()
      circleMenu = new CircleMenu( 300, 32, 14 );
      circleMenu.x = 150;
      circleMenu.y = 300;
      addChildAt( circleMenu, 0 );
      // Use URLLoader to load XML
      xmlLoader = new URLLoader();
      xmlLoader.dataFormat = URLLoaderDataFormat.TEXT;
      // Listen for the complete event
      xmlLoader.addEventListener(Event.COMPLETE, onXMLComplete);
      xmlLoader.load(new URLRequest("data.xml"));
      /*for (var i:int = 0; i < 20; i++)
        // MyMenuItem can be a symbol from your library
        // or any class which extends DisplayObject!
        var item:MyMenuItem = new MyMenuItem();
        item.txt.text = 'Menu Item ' + (i + 1);
        item.txt.mouseEnabled = false;
        item.buttonMode = true;
        item.addEventListener( MouseEvent.CLICK, onMenuItemClick );
        circleMenu.addChild( item );
      circleMenu.currentIndex = 4;*/
      // Enable the mouse wheel
      stage.addEventListener( MouseEvent.MOUSE_WHEEL, onMouseWheel );
      // Set up the UI
      ui.spacingSlider.addEventListener( Event.CHANGE, onSliderChange );
      ui.radiusSlider.addEventListener( Event.CHANGE, onSliderChange );
      ui.minAlphaSlider.addEventListener( Event.CHANGE, onSliderChange );
      ui.minScaleSlider.addEventListener( Event.CHANGE, onSliderChange );
      ui.scaleSlider.addEventListener( Event.CHANGE, onSliderChange );
      ui.itemsSlider.addEventListener( Event.CHANGE, onSliderChange );
      ui.spacingSlider.dispatchEvent( new Event( Event.CHANGE) );
      ui.radiusSlider.dispatchEvent( new Event( Event.CHANGE) );
      ui.minAlphaSlider.dispatchEvent( new Event( Event.CHANGE) );
      ui.minScaleSlider.dispatchEvent( new Event( Event.CHANGE) );
      ui.scaleSlider.dispatchEvent( new Event( Event.CHANGE) );
      ui.itemsSlider.dispatchEvent( new Event( Event.CHANGE) );
      //———————————————————————————————————————————— EVENT HANDLERS
      private function onXMLComplete(event:Event):void
      // Create an XML Object from loaded data
      var data:XML = new XML(xmlLoader.data);
      // Now we can parse it
      var images:XMLList = data.image;
      for(var i:int = 0; i < images.length(); i++)
        // Get info from XML node
        var imageName:String = images[i].@name;
        var imagePath:String = images[i].@path;
      //  var textInfo:TextInfo = new TextInfo(); 
    //      textInfo.headerText.text = images[i].@headerText; <<<<THIS IS WHAT i HAVE TRIED, GET ERRORS SO COMMENTED OUT
    //    textInfo.bodyText.text = images[i].@bodyText;
    //    addChild(textinfo);
                  //textInfo.x=120;
        //textInfo.y=300;
        var sp:Sprite=new Sprite();    <<<<<<<< THIS IS SCRIPT JUST ADDED
        var tf:TextField=new TextField();
        tf.wordWrap=true;
        tf.width=200;
        var ldr:Loader=new Loader();
        addChild(sp);
        sp.addChild(tf);
        sp.addChild(ldr);
        ldr.x=tf.width+10;
        // Load images using standard Loader
        var loader:Loader = new Loader();
        // Listen for complete so we can center the image
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImageComplete);
        loader.load(new URLRequest(imagePath));
        // Create a container for the loader (image)
        var holder:Sprite = new Sprite();
        holder.addChild(loader);
        // Same proceedure as before
        holder.buttonMode = true;
        holder.addEventListener( MouseEvent.CLICK, onMenuItemClick );
        // Add it to the menu
        circleMenu.addChild(holder);
      private function onImageComplete(event:Event):void
      var img:Loader = event.currentTarget.loader;
      img.content["smoothing"] = true;
      img.x = -(img.width/2);
      img.y = -(img.height/2);
      private function onMouseWheel( event:MouseEvent ):void
      event.delta < 0 ? circleMenu.next() : circleMenu.prev();
      private function onMenuItemClick( event:MouseEvent ):void
      circleMenu.scrollToItem( event.currentTarget as DisplayObject );
      private function onSliderChange( event:Event ):void
      switch( event.currentTarget )
        case ui.spacingSlider:
        circleMenu.angleSpacing = event.currentTarget.value;
        break;
        case ui.radiusSlider:
        circleMenu.innerRadius = event.currentTarget.value;
        break;
        case ui.minAlphaSlider:
        circleMenu.minVisibleAlpha = event.currentTarget.value;
        break;
        case ui.minScaleSlider:
        circleMenu.minVisibleScale = event.currentTarget.value;
        break;
        case ui.scaleSlider:
        circleMenu.activeItemScale = event.currentTarget.value;
        break;
        case ui.itemsSlider:
        circleMenu.visibleItems = event.currentTarget.value;
        break;

  • Is there one tell  me the correct way to access remote SQL server

    Hi
    I have tried to access a remote SQL server by many ways but all failed
    here is my trying :
    String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String url= "jdbc:microsoft:sqlserver://217.52.98.102:1433";
    Class.forName(driver);
    Connection conn = DriverManager.getConnection(url,"sa"," " );
    String selectStr = "select * from FleetWatch..table_name";
    Statement st = conn.createStatement();
    ResultSet rs = st.executeQuery(selectStr);
    DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
    // connect to the DB by using the driver.
    String connString = "217.52.98.102:1433;databasename=FleetWatch";
    String strDBConnect = "jdbc:microsoft:sqlserver://" + connString;
    conn = DriverManager.getConnection(strDBConnect, "sa", "");
    String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    Class driverClass = Class.forName(driver, true, jdbcLoader);
    Driver currDriver = (Driver)driverClass.newInstance();
    Properties prop = new Properties();
    prop.setProperty("sa", (String)paras.get("sa");
    prop.setProperty("password", (String)paras.get(" ");
    String url= "jdbc:microsoft:sqlserver://217.52.98.102:1433";
    conn = currDriver.connect((String)paras.get(url, prop);
    pls tell if you know the correct way to access a remote sql server and
    access it befor tell me its step to ensure it's connect

    String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String url= "jdbc:microsoft:sqlserver://your servername:1433";
    Class.forName(driver);
    Connection conn = DriverManager.getConnection(url,"username ","password " );
    this user name and password may be diff becoz if u have only sql authentication then u have to know that user name or it can have windows nt authentication so if it is so then no probs can use ur windows nt login..
    know the server name where ur sqlserver is connected to.
    set the classpath for the sqlserverdrivers jar files which u have downloaded where ur working on.
    then it works
    i did the same and worked for me.
    try it.

  • Correct way to obtain AppModule from ManagedBean?

    hi,
    There are many posts on this forum and others in the net with examples on how to obtain an AppModule from a ManagedBean (some of them uses depecrated methods, like using ValueBinding). But what's the correct way to do so?
    Is this the correct one ?
    HttpServletRequest request =
         (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
    HttpSession session = request.getSession(true);
    BindingContext ctx = (BindingContext)session.getAttribute("data");
    DataControl control = ctx.findDataControl("InstelAMDataControl");
    ApplicationModule appModule = (ApplicationModule)control.getDataProvider();
    Thanks!
    Roger

    Roger,
    this is one possible way to get the ApplicationModule inside a bean.
    you can do this via an EL too
                FacesContext facesContext = FacesContext.getCurrentInstance();
                Application app = facesContext.getApplication();
                ExpressionFactory elFactory = app.getExpressionFactory();
                ELContext elContext = facesContext.getELContext();
                ValueExpression valueExp =  elFactory.createValueExpression(elContext, expression, Object.class);
                ApplicationModule am = (ApplicationModule)  valueExp.getValue("#{data." + YourApplicationModuleName + ".dataProvider}");This is essential the same, but uses an EL to get the data provider.
    It's more a philosophical question if there is aright way to do it.
    Timo

  • Attn - The correct way to connect to the repository

    From iFS Product Management.
    Many people appear to be having trouble connecting to the repository and are using the wrong API calls to do. The recommended API calls changed between beta and production. For the production release here is the correct way to connect:
    1. Four pieces of information are need to connect to the repository
    1. The iFS User Name
    2. The iFS User's password
    3. The properties file to be used
    4. The database password of the user who owns the iFS Schema
    This is different from the beta where the database password was hardcoded into the properties file.
    Note that any TNSNAMES information is still containing in the databaseURL entry in the properties file.
    package ifs.demo.samples;
    import oracle.ifs.beans.*;
    import oracle.ifs.common.*;
    import java.util.Locale;
    public class ConnectionTester extends Object {
    public static LibrarySession testConnection()
    throws IfsException
    LibraryService service = new LibraryService();
    CleartextCredential me = new CleartextCredential("gking","ifs");
    ConnectOptions connect = new ConnectOptions();
    connect.setLocale(Locale.getDefault());
    connect.setServiceName("IfsDefault");
    connect.setServicePassword("manager");
    return service.connect(me,connect);
    public static void main(String[] args)
    try {
    LibrarySession ifs = testConnection();
    ifs.disconnect();
    } catch (IfsException e) {
    IfsException.setVerboseMessage(true);
    e.printStackTrace();
    Note that in this example "gking" is the iFS user name, "ifs" is the gking user's ifs password. "manager" is the password of the database user who owns the iFS Schema.
    "IfsDefault" is the server properties file that describes the ifs connection. This file is in called "IfsDefault.properties" and is located in the package oracle.ifs.server.properties". This means that the folder that contains the 'oracle' folder that is the root of this package must be referenced in the class path when running this example.
    Note, if you use the older, 3 argument form of the connect you will get an unable to connect exception as the iFS will not have the Schema Password.
    null

    When I run the example below on Solaris (after setting the CLASSPATH etc., I get a oracle.ifs.common.IfsException: IFS-21008: Login Failure
    oracle.ifs.common.IfsException: IFS-10170: Invalid name/credential.
    (I am providing all 4 pieces of information for connecting)
    When using the web interface the same userid and password work fine (system/manager).
    Please help.....
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Mark_d_Drake ():
    From iFS Product Management.
    Many people appear to be having trouble connecting to the repository and are using the wrong API calls to do. The recommended API calls changed between beta and production. For the production release here is the correct way to connect:
    1. Four pieces of information are need to connect to the repository
    1. The iFS User Name
    2. The iFS User's password
    3. The properties file to be used
    4. The database password of the user who owns the iFS Schema
    This is different from the beta where the database password was hardcoded into the properties file.
    Note that any TNSNAMES information is still containing in the databaseURL entry in the properties file.
    package ifs.demo.samples;
    import oracle.ifs.beans.*;
    import oracle.ifs.common.*;
    import java.util.Locale;
    public class ConnectionTester extends Object {
    public static LibrarySession testConnection()
    throws IfsException
    LibraryService service = new LibraryService();
    CleartextCredential me = new CleartextCredential("gking","ifs");
    ConnectOptions connect = new ConnectOptions();
    connect.setLocale(Locale.getDefault());
    connect.setServiceName("IfsDefault");
    connect.setServicePassword("manager");
    return service.connect(me,connect);
    public static void main(String[] args)
    try {
    LibrarySession ifs = testConnection();
    ifs.disconnect();
    } catch (IfsException e) {
    IfsException.setVerboseMessage(true);
    e.printStackTrace();
    Note that in this example "gking" is the iFS user name, "ifs" is the gking user's ifs password. "manager" is the password of the database user who owns the iFS Schema.
    "IfsDefault" is the server properties file that describes the ifs connection. This file is in called "IfsDefault.properties" and is located in the package oracle.ifs.server.properties". This means that the folder that contains the 'oracle' folder that is the root of this package must be referenced in the class path when running this example.
    Note, if you use the older, 3 argument form of the connect you will get an unable to connect exception as the iFS will not have the Schema Password.<HR></BLOCKQUOTE>
    null

  • The correct ways to create a helper functions in C++

    Hi there
    I have many functions which I use in my projects from different classes.
    Which is the most correct ways to create a helper functions.
    Thanks

    1) Split your project into different versatile sub-modules each handle by an object. The module should be reusable later on.
    2) Each module or class should be declared on separate .hpp and .cpp files. ( for reusability and portability ) 
    3)Make each module as much self contained as possible(independent) . That way you can reduce unnecessary linking with other files and reduce dependency on helper files. Compiling and working on only one module at a time will be easier and faster.
    4)When your code is better organize , coding will more systematic, less error prone, easy debugging and more fun in programming.
    For example in my project I create classes like
        i) CDatabaseManager - to take care of SQL database
        ii)CPlaylistManager - to deal with complex playlist
       iii)CGraphicManager - to deal with graphic overlay over video
       and so on.
    Thanks. I would like to know how organize it ? Is it right to write helper function in namespace or class ? And is it right to make
    static functions ?

  • What is the correct way to destory a Thread?

    Just wondering what is the correct way to destroy a thread? I am currently using the stop() method, but i noticed that it has been depreciated (along with other methods used to destroy a thread) when i looked at the thread documentation. Since this is so, then how can one correctly destroy a thread? Thanks in advance for the help.

    There is an awful lot of bad advice in this thread about what null does. Please in future check on your own with working code before offering up misguided and very wrong advice. Particularly when your advice contradicts that previously given.
    Please compile and run the following
    public class Test implements Runnable{
      public static void main(String args[])throws Exception{
        Test test = new Test();
        Thread t= new Thread(test);
        t.start();
        // have delay wait a few seconds to demonstrate
        Thread.sleep(3000);
        System.out.println("Setting reference to thread to null");
        t = null; // what does this do?
        // jack all
        System.out.println("Exiting main");
      public void run(){
        while(true){
          System.out.println("Hello from test thread!");
          try{ Thread.sleep(750); }catch(InterruptedException iDontCareAboutThis){}
    }This will output the following
    C:\>java Test
    Hello from test thread!
    Hello from test thread!
    Hello from test thread!
    Hello from test thread!
    Setting reference to thread to null
    Exiting main
    Hello from test thread!
    Hello from test thread!
    Hello from test thread!
    Hello from test thread!
    Hello from test thread!
    Hello from test thread!And continues on endlessly. Setting the reference to null is NOT an answer to this problem.

  • Correct way to use double type to represent money quantities

    I was assigned a project where I had to create a class that received money quantities as double numbers and that implemented a method returning a quantity of money as double. I have to use this scheme as we have no seen other data types in class.
    My question is, what can I do to make sure that the value I'm returning is a double number that looks like money. For example, I don't want my method to return 10.78889332., I want it to return 10.79. How can I do that? Is there any intended method for that?
    Can I let this issue like that and then take care of it in the test class by formating the output of the method when using it. I think this approach is not correct.
    Thanks for your time.

    See http://docs.sun.com/source/806-3568/ncg_goldberg.html
    There is no correct way to use double type to represent money quantities. You shouldn't be receiving them, you shouldn't use them, and you shouldn't return them. Floating-point is for science, not money.
    Use BIgDecimal.

  • Correct way to use AXL API with complex types css, partition, etc. involving: JAXBElement XFkType ?

    I am trying to figure out how to use the AXL API once exploded with the wsimport as explained here...
    https://developer.cisco.com/site/collaboration/management/axl/learn/how-to/axl-java-sample-application.gsp
    ...to use complex types (partition, css, etc). 
    --> What is the correct way to do it?
    Example 1: UpdatePhone
    When incorporing a complex type into the addition or update of a component, for instance RoutePartitionName, DevicePoolName or CallingSearchSpaceName.
    his function is not working:
    public void actualizarPhone(LPhone lPhone) {
            try {
                UpdatePhoneReq axlParams = new UpdatePhoneReq();
                axlParams.setName(lPhone.getName());
                axlParams.setDescription(lPhone.getDescription());
                axlParams.setDevicePoolName(lPhone.getDevicePoolName());
                axlParams.setCallingSearchSpaceName(lPhone.getCallingSearchSpaceName());
                StandardResponse response = axlPort.updatePhone(axlParams);
                //return response.getReturn()a.toString();
            } catch (Exception e) {
                logger.error(e);
                //return new ArrayList<LPhone>();
    It seems the right thing to do set as parameter for the "set" the result of the "get" in line: setDevicePoolName(lPhone.getDevicePoolName());
    but it says: "The method setDevicePoolName(JAXBElement<XFkType>) in the type UpdatePhoneReq is not applicable for the arguments (XFkType)"
    Example 2: AddLine
    I also have this problem when adding line. 
    And I've tried at least 3 approaches, no success yet:
    1)** Using factory object to obtain an R object
    ObjectFactory factory = new ObjectFactory();
    RRoutePartition rRoutePartition = factory.createRRoutePartition();
    rRoutePartition.setName("autodial");
    2) ** Trying to create the demanded object: JAXBElement<XFkType> myself.
    JAXBElement<XFkType> jaxbElement= new JAXBElement<XFkType>(new QName ("http://www.cisco.com/AXL/API/8.5","XRoutePartition"),XFkType.class,partition);
    jaxbElement.setValue(partition3);
    line.setRoutePartitionName(jaxbElement);
    3)** Using X Objects
    XCallForwardBusy fwdBusy = new XCallForwardBusy();
    fwdBusy.setForwardToVoiceMail("true");
    AddLineReq newLine = new AddLineReq();
    XLine line = new XLine();
    line.setAlertingName("ALerting Name");
    line.setAsciiAlertingName("Alerting Name ASCII");
    line.setCallForwardBusy(fwdBusy);
    line.setDescription("Description");
    line.setPattern("5555");
    I would appreciate a clean example about how to add a line setting a partition, and an explanation about how to use JAXBElement<XFkType> objects.
    regards!

    I am trying to figure out how to use the AXL API once exploded with the wsimport as explained here...
    https://developer.cisco.com/site/collaboration/management/axl/learn/how-to/axl-java-sample-application.gsp
    ...to use complex types (partition, css, etc). 
    --> What is the correct way to do it?
    Example 1: UpdatePhone
    When incorporing a complex type into the addition or update of a component, for instance RoutePartitionName, DevicePoolName or CallingSearchSpaceName.
    his function is not working:
    public void actualizarPhone(LPhone lPhone) {
            try {
                UpdatePhoneReq axlParams = new UpdatePhoneReq();
                axlParams.setName(lPhone.getName());
                axlParams.setDescription(lPhone.getDescription());
                axlParams.setDevicePoolName(lPhone.getDevicePoolName());
                axlParams.setCallingSearchSpaceName(lPhone.getCallingSearchSpaceName());
                StandardResponse response = axlPort.updatePhone(axlParams);
                //return response.getReturn()a.toString();
            } catch (Exception e) {
                logger.error(e);
                //return new ArrayList<LPhone>();
    It seems the right thing to do set as parameter for the "set" the result of the "get" in line: setDevicePoolName(lPhone.getDevicePoolName());
    but it says: "The method setDevicePoolName(JAXBElement<XFkType>) in the type UpdatePhoneReq is not applicable for the arguments (XFkType)"
    Example 2: AddLine
    I also have this problem when adding line. 
    And I've tried at least 3 approaches, no success yet:
    1)** Using factory object to obtain an R object
    ObjectFactory factory = new ObjectFactory();
    RRoutePartition rRoutePartition = factory.createRRoutePartition();
    rRoutePartition.setName("autodial");
    2) ** Trying to create the demanded object: JAXBElement<XFkType> myself.
    JAXBElement<XFkType> jaxbElement= new JAXBElement<XFkType>(new QName ("http://www.cisco.com/AXL/API/8.5","XRoutePartition"),XFkType.class,partition);
    jaxbElement.setValue(partition3);
    line.setRoutePartitionName(jaxbElement);
    3)** Using X Objects
    XCallForwardBusy fwdBusy = new XCallForwardBusy();
    fwdBusy.setForwardToVoiceMail("true");
    AddLineReq newLine = new AddLineReq();
    XLine line = new XLine();
    line.setAlertingName("ALerting Name");
    line.setAsciiAlertingName("Alerting Name ASCII");
    line.setCallForwardBusy(fwdBusy);
    line.setDescription("Description");
    line.setPattern("5555");
    I would appreciate a clean example about how to add a line setting a partition, and an explanation about how to use JAXBElement<XFkType> objects.
    regards!

  • Correct way to aqquire session on a J2EE environment

    Hi.
    I'm working on a software that uses session beans (configured with JTA) accessing TopLink through a Data Acess Object. The DAO is a sigleton (used by all session bean instances) that has private getActiveSession() method that returns the session to be used by each DAO method.
    The method is codded like bellow:
    private Server server = null; //class attribute
    ... getActiveSession(){       
    if (server == null){
    server = (Server) SessionManager.getManager().getSession(new XMLSessionConfigLoader(), mapeamento, this.getClass().getClassLoader(), true, false, true);
    return server.getActiveSession();
    Is it the correct way to work with the architecture I'm using? (holding a server Session and working with it)
    I'm having problems when a database exception is thrown and when a database connection become stale. I don't know how to solve it because some times the application recovers themselves and some times not (intermitent).
    Thanks,
    Eros

    Hello Doug. Thanks for your post.
    I'm using the Container Datasource. How I can handle the connection failures?
    Another question: This code is causing the following error in a multithread environment:
    Exception [TOPLINK-7001] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 050912)): oracle.toplink.exceptions.ValidationException
    Exception Description: You must login to the ServerSession before acquiring ClientSessions.
    Environment:
    - The toplink jar is within the APPLib OC4J instance classpath
    - The DAO is within EAR
    - The OC4J instance has 6 applications (EARs)
    - The EJB with the business rules calls the DAO singleton object to access the Database
    The error happens some times and some times not. Please Help.
    Eros

  • What is the correct way to set up a new Mac

    A friend of mine recently migrated from Windows and bought himself an iMac. He got the local Apple store to set up his iMac and migrate his data from his Windows to his iMac. I was  recently helping him set up a few a additional things on his iMac and was supprised to see how the Apple store had set up the machine.
    There was only one account set up on the iMac and all of the user data had been loaded into this admin account. Now I've only been a Mac user for about 5 years, but I was always taught create an admin account with no data on it and then set up a separate user account(s) which contain all the user data and these are used by the users to log in.
    Now my question is who is right the Apple shop or me? I would e intertested to hear any experts views on the correct way to set up an OSX machine. 

    Both of you. Either way is acceptable. However, for a single user machine there's really no need to have more than the admin account.

  • I would like to read a text file in which the decimal numbers are using dots instead of commas. Is there a way of converting this in labVIEW, or how can I get the program to enterpret the figures in the correct way?

    The program doest enterpret my figures from the text file in the correct way since the numbers contain dots instead of commas. Is there a way to fix this in labVIEW, or do I have to change the files before reading them in the program? Thanks beforehend!

    You must go in the labview option menu, you can select 'use the local
    separator' in the front side submenu (LV6i).
    If you use the "From Exponential/Fract/Eng" vi, you are able to select this
    opton (with a boolean) without changing the labview parameters.
    (sorry for my english)
    Lange Jerome
    FRANCE
    "Nina" a ecrit dans le message news:
    [email protected]..
    > I would like to read a text file in which the decimal numbers are
    > using dots instead of commas. Is there a way of converting this in
    > labVIEW, or how can I get the program to enterpret the figures in the
    > correct way?
    >
    > The program doest enterpret my figures from the text file in the
    > correct way since the numbers contain dots instea
    d of commas. Is there
    > a way to fix this in labVIEW, or do I have to change the files before
    > reading them in the program? Thanks beforehend!

  • I have a macbook air late 2010 and keep getting a warning that my hard drive is full and to delete things so I purchased a external hard drive (1TB) but I'm just not sure what the correct way to transfer and store files to the external drive is. First MAC

    I purchased a macbook air about 5 months ago and lately i keep recieving a warning that the hard drive or disk is full and that I will need to move items to trash in order to free up space on it. I purchased a external hard drive 1 TB but I'm very new to mac and ios and unsure as to how I'm suppose to transfer my files (video, pics, music etc.) from my mac over to the external hard drive in the correct way so I won't end up deleting them permenately or screwing anything up with my mac as far as the applications and programs being able to run. Am I supposed to just copy to the external hard drive and then move to and empty the trash? That's pretty much all I could come up with, but then what if i need or want to access that file again at a later time. Also, I have an i Phone and i pad so with i cloud it automatically syncs all my purcheses and if i delete something from itunes on my mac it deletes from my ipad.
    I'd appreciate any kind of input i think im just a little lost here. I have to say i love my Mac and wouldn't trade it for anything (except maybe a macbook pro w/more memory)... Is there something I'm missing???

    To free up hard drive space the best bet is to move data files that you don't need access to all the time. Likely candidates are music, video, and photos. Things like word processing and spreadsheet files can also be moved but they tend not to be very large and so don't free up much space. The problem with moving the above mentioned files is that iTunes and iPhoto need to know where the files are stored.
    Here's an article explaining how to move the iTunes folder. You can move the iPhoto library using the Finder but there is a slight complication. Start iPhoto, open the Preferences and click on the Advanced tab. The first option is "Copy items to the iPhoto Library". If this option is checked, copy the iPhoto library to your external folder (drag it from the Pictures folder to your external drive) and then delete it from your Picture folder. If this option is not checked, it is a bit more complicated and we'll need to talk a bit.

  • 1.4.2 - What is the correct way to format output in the java.io.PrintStream

    With Java 1.4.2:
    What is the correct way to format output in the java.io.PrintStream?
    The following is incorrect, even though it is still used in the The JavaTM Tutorial at: http://java.sun.com/docs/books/tutorial/essential/
    System.out.formatThis returns "cannot resolve the method 'format'"
    Any detailed suggestions or information is greatly appreciated.

    The following is incorrect, even though it is still
    used in the The JavaTM Tutorial at:
    http://java.sun.com/docs/books/tutorial/essential/
    The whole format thing has been introduced in 1.5. The tutorial also states it's been "updated to 1.5.".
    That's all I've got to say for I don't know how you can format a PrintWriter, let alone a PrintStream, prior to 1.5. I'm not really sure there is any way. Any "legacy way", that is. There almost certainly are third-party API which achieve similar results.

Maybe you are looking for

  • Changing CHARACTER SET in OracleXE

    Because this is my first post in this forum I like to say first "Hello" ! I do my first steps after installing OracleXE (OracleXEUnv.exe). In the database informations I saw that the Character Set (NLS_CHARACTERSET) is "AL32UTF8"., but I want to chan

  • How to install photoshop without disk but with serial number

    Any ideas on how to install a permission of PS if I've lost the installation disk but do have the serial number?

  • The exported mbox is way smaller than the original?

    Hi, I have a local mail account where the mbox comes in at 1,5GB. When I use the export to mbox function the resulting mbox is only 850MB. I have used the "permanently purge deleted mails" option but that didn't change anything about thos 1,5GB. Shou

  • Using Ranking on MS SQL Server 2005

    Hello, We are on BOXI3.1 base version and have a universe on top of MS SQL Server 2005. My question is regarding use of rank functions. BO guides state that You can perform a database ranking only if your database supports it. If this is not the case

  • Does anyone ever have the problem where the iPod won't go to sleep?

    i used to have a 4GB nano...and occasionally it wouldnt go to sleep...the backlight would just turn off for a few seconds...i recently got a 30GB iPod video...it is excellent might i add...but every now and then it wont turn off right away...this eve