Is it allowed to set bmp instance variables in ejbFindByPrimaryKey

Hello together,
one simple question to the specification gurus:
Is it allowed to set the instance variables of a Bean Managed Persistence
Entity Bean inside the ejbFindByPrimary Key method?
The Problem is:
We are using OC4J (Oracle Containers 4 J2EE) and run multi threaded clients.
In some situations it happens, that the same instance of an Entity in "pooled state"
is used for concurrent ejbFindByPrimaryKey calls by the container.
Due to the implementation of the ejbFindByPrimaryKey it sometimes happens,
that during this call the Threads are switched and the value returned by the
method, which is stored into an instance variable, is overwritten (some typical
unwanted side effect in a multithreaded environment).
So this leads to the question above!
Ciao
Stefan

As far as I'm aware you shouldn't attempt to change the state in an ejbFindByPrimaryKey method - this should simply look up the appropriate instance, not alter the state. ejbLoad seems a more appropriate place to be doing that sort of thing.
I'm not too sure, though - obviously your application will have very particular requirements.

Similar Messages

  • Setting process instance variable

    Hi,
    I've a process with a instance variable "dossierVar" of class Dossier.
    I've the following code to go through the existing processes :
    Fuego.Papi.BusinessProcess bp;
    bp.connectTo(url : Fuego.Server.directoryURL, user : "adminfonc", password : "agra2009",
    process : processName);
    Fuego.Papi.InstanceFilter instF = InstanceFilter();
    instF.create(processService : bp.processService);
    instF.searchScope = SearchScope(participantScope : ParticipantScope.ALL, statusScope : StatusScope.ONLY_INPROCESS);
    Fuego.Instance[] instances = bp.getInstancesByFilter(filter : instF);
    foreach (instance in instances) {
    I'd like to know how to set the variable "dossierVar" of these instances ?
    Thanks you for our help

    Hi,
    take a look in this post.
    Obtain an instance variable of one process from another process
    If your variable is not a separeted one, so this code works well in order to get the variables value.
    Thanks
    Marcos Chiodi Martins

  • Setting final Instance variables in Child Classes

    Hello:
    Is it possible to declare (not initialize) a final variable in an abstract parent class and set it in a non-abstract child class.
    An example for clarification.
    I have an abstract parent class (call it P) and two child classes (call them (C1 and C2). There is common processing that goes on in P. This processing uses a variable called x. C1 will set x to equal 10 and C2 will set x to equal 20. Can I declare x final in the abstract class P and set it in C1 and C2
    This is impossible right? I know some other languages allow this behavior so I just wanted to make sure that Java does not support it.
    Thanks
    Johnny

    Why don't you just try it out? Though I'm pretty sure it won't work, as it should expect all constructors of the abstract class to set it. But you could either let there be an overridden method that returns the appropriate value for the sub-class:
    abstract class P
      abstract protected int getTheValue();
    class C1 extends P
      protected int getTheValue() { return 10; }
    class C2 extends P
      protected int getTheValue() { return 20; }
    }

  • Xcode debugger not showing my instance variables!!

    I hate asking questions like this.
    I set a breakpoint in an IBAction method 'pushed:' inside FooViewController.  At runtime I pressed a GUI button and processing stopped in pushed:.
    In the data-viewing pane of xcode, I see
    {code}
    self = (FooViewController *) 0x... etc.
    {code}
    Indented under this is
    {code}
    UIViewController = (UIViewController) { ...
    {code}
    Nowhere do I see any of my instance variables!!
    Now, they were synthesized from properties, but that doesn't matter, does it?
    The code that proceeds to set some instance variables runs fine.
    Why isn't xcode displaying self's instance vars?
    Thanks,
    Chap

    Yes, yours looks like I was expecting mine to look.
    Note that viewDidLoad (below) does work correctly, producing the expected results in the simulator!
    Hangman3ViewController.h:
    @interface Hangman3ViewController : UIViewController {
    @property (         nonatomic )           NSInteger  wordLength;
    @property ( retain, nonatomic )           NSString  *alphabet;
    @property (         nonatomic )           unichar    guess;
    @property (         nonatomic )           NSInteger  guessNo;
    @property ( retain, nonatomic )           NSMutableString *board;
    @property ( retain, nonatomic ) IBOutlet  UILabel   *boardLabel;
    @property ( retain, nonatomic ) IBOutlet  UILabel   *guessNumberLabel;
    @property ( retain, nonatomic ) IBOutlet  NSArray   *keyboardButtons;
    - (IBAction)letter:(id)sender;
    - (void)showBoard;
    @end
    and, Hangman3ViewController.m:
    #import "Hangman3ViewController.h"
    @implementation Hangman3ViewController
    @synthesize wordLength       = _wordLength;  // preprocessor command to gen getter/setter and instance variable
    @synthesize boardLabel       = _boardLabel;  // preprocessor command to gen getter/setter and instance variable
    @synthesize guessNumberLabel = _guessNumberLabel;  // Guess #n
    @synthesize keyboardButtons  = _keyboardButtons;   // array of buttons
    @synthesize alphabet         = _alphabet;    // A-Z unichars
    @synthesize guess            = _guess;       // unichar
    @synthesize guessNo          = _guessNo;     // int
    @synthesize board            = _board;
    - (IBAction)letter:(id)sender
                Get letter from sender - driven when key button is pressed.
                The button's tag is an int from 0-25, identifying what letter of the alphabet it is.
                Extract that unichar from ALPHABET as 'guess'.  Then, disable the button,
                which has been defined to have its text turn white (invisible) when disabled.
        UIButton *button = (UIButton *)sender;
        self.guess = [self.alphabet characterAtIndex: button.tag];
        NSLog(@"Received keystroke: %C", self.guess);
        [button setEnabled:NO];
    - (void)showBoard
        self.boardLabel.text = self.board;
        self.guessNumberLabel.text = [NSString stringWithFormat:@"Guess #%d", self.guessNo];
    - (void)dealloc
        [_boardLabel release];
        [_guessNumberLabel release];
        [_keyboardButtons release];
        [super dealloc];
    - (void)didReceiveMemoryWarning
        // Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];
        // Release any cached data, images, etc that aren't in use.
    #pragma mark - View lifecycle
    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
    - (void)viewDidLoad
        NSLog(@"Hello from viewDidLoad");
        [super viewDidLoad];
        self.alphabet   = @"ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // unichar string
        self.wordLength = 7;  // temp - will be set from flipside later on
        self.guessNo    = 1;
        [self.board setString:@"_______"]; // actually dynamic based on wordLength
        self.board = @"_______";
        [self showBoard];
    - (void)viewDidUnload
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    @end

  • Javascript allows setting of more variables? CP7

    Hi,
    I'm running CP7 and am just getting my feet wet with javascripting. Will javascript allow me to set more variables than I can through advanced actions? I am interested in trying to manipulate the quiz score vars that report to my LMS to customize some stuff. I want to change things like cpQuizPointsscored. Wondered if it would be possible through js, or is js limited by what it can get/set the same as the limitations withing advanced actions?
    Thanks!
      Lori

    You can do anything you want with any variable that is reported to the LMS as long as you "hijack" the functions and block Captivate from reporting. You would need to add a function that you use the call any scoring functions, set a boolean variable and if that variable is not true, return out of the function, thus disabling Captivate from reporting the score.
    Based on how you set up the SCORM reporting in your Quiz Settings, Captivate will report to the LMS what you tell it to report. You can also turn off any reporting and make all of the SCORM call through JavaScript yourself. You can include the sormdriver.js file to your output html file after publishing without any reporting.
    It's much easier if you create your own SCORM file to make any calls you wish to make.
    We use our own SCORM files and control everything ourselves. You need to have a decent understanding of SCORM though to use this method.

  • Instance variable to hold the element of a tag in the xml file

    Hi I have an xml file that is handled using this parser
    <attr id="MY_NAME" >
    this parser hanled the above tag but now I want to have it handle
    <attr id="MY_NAME" desc="GOOD">
    but I need to create an instance variable to handle the desc element in the attr tag .
    Can some one help me out as this is not my file and I am having trouble to do please......
    import java.util.*;
    import java.io.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
       The SupportMatrix class provides static variables and methods to simplify
       the determination of whether or not a given attribute is supported for a
       certain object type (queue manager, channel, etc.), depending on the version
       and platform of the queue manager to which it belongs.
       The SupportMatrix class may not be instantiated. Its constructor is private.
       An instance of the class is created internally in the static initializer so
       that the XML parsing methods are available.
       A corresponding XML document, SupportMatrix.xml, is parsed to create the various
       HashMaps which contain the version/platform dependency information. A number of
       inner classes are used to represent the various elements of the XML matrix
       definition.
       Here's a sample document:
       <!-- The supportmatrix tag opens the document -->
       <supportmatrix>
         <!-- Objects are keyed by classid. "1" is the classid of a queue manager object. -->
         <object classid="1">
           <!-- Versions group attributes according to the queue manager version where they
                were introduced. The "base" cmdlevel encompasses all versions up to 5.1. -->
           <version cmdlevel="base">
             <!-- Attributes are defined by the attr tag. -->
             <attr id="MQCA_Q_MGR_NAME">
               <!-- Support elements define the platform-specific requirements for an attribute. -->
               <support platforms="UNIX,WINDOWS,OS400,VMS,NSK" maxlen="48" type="MQCFST"/>
               <support platforms="MVS" maxlen="4" type="MQCFST"/>
             </attr>
             <attr id="MQCA_Q_MGR_DESC">
               <!-- Specific attribute characteristics, most notably maximum len for string parms,
                    are defined in the support element. As shown in the following example, it may
                    apply to all platforms. -->
               <support platforms="all" maxlen="64" type="MQCFST"/>
             </attr>
             <!-- Support elements are optional. -->
             <attr id="MQIA_PLATFORM"/>
             <attr id="MQIA_COMMAND_LEVEL"/>
           </version>
           <!-- The version element may 'include' other versions. Note that object elements
                may also refer to other objects via the 'include' parm of the object tag.
                This is to allow common attributes (especially for queues and channels) to
                be shared by multiple definitions in order to reduce some of the
                redundancy. -->
           <version cmdlevel="520" include="base">
           </version>
         </object>
       </supportmatrix>
       The inner classes, and their hierarchical relationships are as follows:
         SupportObject - corresponds to the <object> element. Stored in a static HashMap, and
                         keyed by classid.
           VersionObject - corresponds to the <version> element. Stored in a HashMap instance
                           variable of the SupportObject class, keyed by cmdlevel.
             AttributeObject - corresponds to the <attr> element. Stored in a HashMap instance
                               variable of the VersionObject class, keyed by attribute name.
               PlatformObject - corresponds to the <support> element. Stored in HashMaps belonging
                                to the AttributeObjects, keyed by platform. A single PlatformObject
                                instance is created when the support tag is encountered. The
                                "platforms" attribute of the support element is then processed. For
                                each platform in the comma-delimited list, an entry is added to the
                                collection of PlatformObjects. This is to greatly simplify later
                                lookups.
       In order to support the 'include' feature of object and version elements, certain
       functions are recursive. If the attribute to be validated is not found for the passed
       cmdlevel, the 'parent' VersionObject is consulted by means of the 'include' value. If
       the chain of VersionObjects has been exhausted and the attribute in question has still not
       been located, the next SupportObject in the chain is consulted in a similar fashion.
    public class SupportMatrix extends DefaultHandler {
        /** The objects collection holds all the SupportObjects, keyed by classid. */
        private static HashMap objects;
        /** xmlFile will name the xml document to be parsed. Note that using the
            default class loader expects the string to be the path to the file. It must
            NOT begin with the '/' character. */
        private static String xmlFile =
            ResourceManager.getApplicationProperties().getProperty("SupportMatrixFile");
        private Stack stack;
        /** This static initializer allocates the static objects collection, creates an
            instance of the SupportMatrix class for xml parsing purposes, and initiates
            the parse operation to populate the collection. */
        static {
            objects = new HashMap();
            // Create a parser and process the xml doc
            SupportMatrix handler = new SupportMatrix();
            InputSource is = null;
            try {
                is = new InputSource(ClassLoader.getSystemClassLoader().getResourceAsStream(xmlFile));
                XMLReader xmlReader =
                    SAXParserFactory.newInstance().newSAXParser().getXMLReader();
                xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
                xmlReader.setContentHandler(handler);
                if (is == null) {
                    System.err.println("No input stream, dammit");
                xmlReader.parse(is);
            } catch(Exception e) {
                e.printStackTrace();
        /** Private constuctor, used only for XML parsing. */
        private SupportMatrix() {
            stack = new Stack();
        /** Add a SupportObject instance to the objects collection. */
        private void addObject(SupportObject obj) {
            String key = obj.getClassId();
            objects.put(key, obj);
        /* DefaultHandler methods                                              */
        /** Not used. */
        public void characters(char[] ch, int start, int length) {}
        /** Not used. */
        public void endDocument() {}
        /** For the version, object, and attr elements, pop the top element of the stack. */
        public void endElement(String uri, String localName, String qName) {
            if (localName.equals("version") || localName.equals("object") || localName.equals("attr")) {
                stack.pop();
        /** Not used. */
        public void setDocumentLocator(Locator locator) {}
        /** Not used. */
        public void startDocument() {}
        /** Most of the work is done here. Create the appropriate inner class instance for
            element; for object, version, and attr, push the element onto the stack so that
            child elements may be added to their collections as needed. */
        public void startElement(String uri, String localName, String qName,
                                 Attributes attributes) {
            String include = attributes.getValue("include");
            if (localName.equals("object")) {
                SupportObject obj = new SupportObject(attributes.getValue("classid"), include);
                addObject(obj);
                stack.push(obj);
            } else if ( localName.equals("version")) {
                VersionObject ver = new VersionObject(attributes.getValue("cmdlevel"), include);
                ((SupportObject)stack.peek()).addVersion(ver);
                stack.push(ver);
            } else if ( localName.equals("attr")) {
                AttributeObject a = new AttributeObject(attributes.getValue("id"));
                //String desc = StringFactory.getString(attributes.getValue("desc"));
                //if(desc != null)
                   //     a.setAttribute();
                String readonly = attributes.getValue("readonly");
                String exclude = attributes.getValue("exclude");
                if (include != null && exclude != null) {
                    Log.log(Log.ERROR, this, "include and exclude are mutually exclusive, exclude value ignored");
                    exclude = null;
                if (include != null) {
                    a.setCondition(include, true);
                if (exclude != null) {
                    a.setCondition(exclude, false);
                if (readonly != null)
                    a.setReadonly(readonly.equals("y"));
                ((VersionObject)stack.peek()).addAttr(a);
                stack.push(a);
            } else if (localName.equals("support")) {
                String platforms = attributes.getValue("platforms");
                String readonly = attributes.getValue("readonly");
                String maxlen = attributes.getValue("maxlen");
                String type = attributes.getValue("type");
                int attrType = 0;
                if (type != null) {
                    if (type.equals("MQCFIN")) {
                        attrType = CMQCFC.MQCFT_INTEGER;
                    } else if (type.equals("MQCFIL")) {
                        attrType = CMQCFC.MQCFT_INTEGER_LIST;
                    } else if (type.equals("MQCFST")) {
                        attrType = CMQCFC.MQCFT_STRING;
                    } else if (type.equals("MQCFSL")) {
                        attrType = CMQCFC.MQCFT_STRING_LIST;
                    } else if (type.equals("EXBIN")) {
                        attrType = MqcConstants.EXCFT_BINARY;
                    } else if (type.equals("EXPCF")) {
                        attrType = MqcConstants.EXCFT_PCF;
                PlatformObject p = null;
                if (readonly == null) {
                    p = new PlatformObject(platforms);
                } else {
                    p = new PlatformObject(platforms, readonly.equals("y"));
                String exclude = attributes.getValue("exclude");
                if (include != null && exclude != null) {
                    Log.log(Log.ERROR, this, "include and exclude are mutually exclusive, exclude value ignored");
                    exclude = null;
                if (include != null)
                    p.setCondition(include, true);
                if (exclude != null)
                    p.setCondition(exclude, false);
                if (attrType != 0)
                    p.setType(attrType);
                if (maxlen != null)
                    p.setLen(Integer.parseInt(maxlen));
                ((AttributeObject)stack.peek()).addPlatform(p);
        public static boolean isExported(int attribute, TopologyModelNode node) {
            String name = ResourceManager.getAttributeName(attribute);
            return isExported(name, node);
        public static boolean isExported(String attribute, TopologyModelNode node) {
            // Find the qmgr node to fetch platform and cmdlevel
            TopologyModelNode qmgr = node.getModel().getQMgrNode(node.getAddress());
            // If there's no qmgr for this node, it must be one of 'ours'.
            if (qmgr == null)
                return false;     // None of 'our' objects can be exported to MQSC.
            String classId = node.getClassId();
            String cmdLevel = qmgr.getAttributeValue("MQIA_COMMAND_LEVEL");
            String platform = qmgr.getAttributeValue("MQIA_PLATFORM");
            return isExported(attribute, classId, cmdLevel, platform, node);
        public static boolean isExported(int attribute, String classId, String cmdLevel, String platform,
                                         TopologyModelNode node) {
            String name = ResourceManager.getAttributeName(attribute);
            return isExported(name, classId, cmdLevel, platform, node);
        /** Determine if an attribute is exportable. The attribute name, the classid of the object to
            which it belongs, plus the command level and platform of the queue manager are all needed
            to make this determination.
            Start by finding the AttributeObject for the combination of attribute, classid, and
            command level. If we can't find the AttributeObject, we assume that the attribute
            is not exported. Otherwise, find out if it is exportable for the selected platform.
        public static boolean isExported(String attribute, String classId, String cmdLevel, String platform,
                                         TopologyModelNode node) {
            AttributeObject attr = getAttributeObject(attribute, classId, cmdLevel);
            if (attr == null) {
                return false;
            } else {
                return attr.isExported(platform, node);
        public static boolean isSupported(int attribute, TopologyModelNode node) {
            String name = ResourceManager.getAttributeName(attribute);
            return isSupported(name, node);
        public static boolean isSupported(String attribute, TopologyModelNode node) {
            // Find the qmgr node to fetch platform and cmdlevel
            TopologyModelNode qmgr = node.getModel().getQMgrNode(node.getAddress());
            // If there's no qmgr for this node, it must be one of 'ours'.
            if (qmgr == null)
                return true;
            String classId = node.getClassId();
            String cmdLevel = qmgr.getAttributeValue("MQIA_COMMAND_LEVEL");
            String platform = qmgr.getAttributeValue("MQIA_PLATFORM");
            return isSupported(attribute, classId, cmdLevel, platform);
        public static boolean isSupported(int attribute, String classId, String cmdLevel, String platform) {
            String name = ResourceManager.getAttributeName(attribute);
            return isSupported(name, classId, cmdLevel, platform);
        /** Determine if an attribute is supported. The attribute name, the classid of the object to
            which it belongs, plus the command level and platform of the queue manager are all needed
            to make this determination.
            Start by finding the SupportObject for the classid. If it isn't there, we make the assumption
            (for now) that the attribute is supported. The only classids for which this can occur are
            broker, agent, and the various container objects.
            Propagate the isSupported request to the chain of SupportObjects (based on 'include' values)
            until we get a 'true' result or we run out of SupportObjects. */
        public static boolean isSupported(String attribute, String classId, String cmdLevel, String platform) {
            if (attribute == null)
                return false;
            SupportObject obj = (SupportObject)objects.get(classId);
            // If the object type isn't even in the support matrix, we interpret that to
            // mean that it's a Broker or Agent, in which case all attributes are supported
            // at present.
            if (obj == null)
                return true;
            boolean result = false;
            while (result == false && obj != null) {
                result = obj.isSupported(attribute, cmdLevel, platform);
                if (result == false && obj.getInclude() != null) {
                    obj = (SupportObject)objects.get(obj.getInclude());
                } else
                    obj = null;
            return result;
        /** Locate an AttributeObject for a given attribute name, object type, and command level.
            This is a helper function for the getMaxLen and getType methods. */
        private static AttributeObject getAttributeObject(String attr, String classID, String cmdLevel) {
            AttributeObject result = null;
            SupportObject obj = (SupportObject)objects.get(classID);
            while (result == null && obj != null) {
                result = obj.getAttr(attr, cmdLevel);
                if (result == null && obj.getInclude() != null) {
                    obj = (SupportObject)objects.get(obj.getInclude());
                } else
                    obj = null;
            return result;
        /** Determine the maximum length for a given combintation of attribute name, object type,
            command level, and platform. If the AttributeObject can't be found, or if the length
            hasn't been set, return -1. */
        public static int getMaxLen(String attr, String classId, String cmdLevel, String platform) {
            AttributeObject a = getAttributeObject(attr, classId, cmdLevel);
            if (a == null)
                return -1;
            return a.getMaxLen(platform);
        /** Determine the PCF parm type for a given combintation of attribute name, object type,
            command level, and platform. If the AttributeObject can't be found, or if the length
            hasn't been set, return -1. */
        public static int getType(String attr, String classId, String cmdLevel, String platform) {
            AttributeObject a = getAttributeObject(attr, classId, cmdLevel);
            if (a == null)
                return -1;
            return a.getType(platform);
        /** Inner class to contain platform-specific info for an attribute. */
        class PlatformObject {
            /** This instance variable will contain the comma-delimited string of all
                platforms to which this object applies. */
            private String platform;
            private int maxlen;
            private String condition = null;
            private boolean include;
            private boolean readonly;
            private boolean lenSet;
            private int attrType;
            private boolean typeSet;
            public PlatformObject(String p, boolean readonly) {
                platform = p;
                this.readonly = readonly;
                lenSet = false;
                typeSet = false;
            public PlatformObject(String p) {
                this(p, false);
            public void setCondition(String condition, boolean include) {
                this.condition = condition;
                this.include = include;
            public boolean isReadonly() {
                return readonly;
            public boolean isExported(TopologyModelNode node) {
                if (condition != null) {
                    boolean test = false;
                    try {
                        test = Utilities.evaluateCondition(node, condition);
                    } catch (Exception e) {}
                    if (include ^ test)
                        return false;
                return !readonly;
            public void setLen(int len) {
                maxlen = len;
                lenSet = true;
            public void setType(int type) {
                attrType = type;
                typeSet = true;
            public String getPlatform() {
                return platform;
            public int getMaxLen() {
                if (!lenSet)
                    return -1;
                return maxlen;
            public int getType() {
                if (!typeSet)
                    return -1;
                return attrType;
        /** This class represents a specific MQSeries attribute. It can optionally contain
            instances of the PlatformObject class as needed. When the 'platforms' collection
            is empty, the attribute is supported on all platforms. It is also possible to
            include a PlatformObject for the 'all' platform, if specific attribute characteristics
            need representation. When the 'platforms' collection is non-empty, it will include one
            entry for each platform where the attribute is supported. */
        class AttributeObject {
            private String attribute;
            private String attrValue;
            private HashMap platforms;
            private String condition = null;
            private boolean include;
            private boolean readonly = false;
            public AttributeObject(String a) {
                this(a, false);
            public AttributeObject(String a, boolean readonly) {
                attribute = a;
                platforms = new HashMap();
                this.readonly = readonly;
            public void setCondition(String condition, boolean include) {
                this.condition = condition;
                this.include = include;
            public void setReadonly(boolean readonly) {
                this.readonly = readonly;
            public boolean isReadonly() {
                return readonly;
            public void addPlatform(PlatformObject p) {
                for (StringTokenizer st = new StringTokenizer(p.getPlatform(), ","); st.hasMoreTokens() ;) {
                    platforms.put(st.nextToken(), p);
            public PlatformObject getPlatform(String platform) {
                PlatformObject p = (PlatformObject)platforms.get(platform);
                if (p == null)
                    p = (PlatformObject)platforms.get("all");
                return p;
            public String getAttribute() {
                return attribute;
            public int getMaxLen(String platform) {
                PlatformObject p = getPlatform(platform);
                if (p == null)
                    return -1;
                return p.getMaxLen();
            public int getType(String platform) {
                PlatformObject p = getPlatform(platform);
                if (p == null)
                    return -1;
                return p.getType();
            public boolean isSupported(String platform) {
                if (platforms.isEmpty()) {
                    return true;
                if (platforms.containsKey(platform)) {
                    return true;
                if (platforms.containsKey("all")) {
                    return true;
                return false;
            public boolean isExported(String platform, TopologyModelNode node) {
                if (readonly) {
                    Log.log(Log.DEBUG, this, attribute + " is readonly, returning false");
                    return false;
                if (condition != null) {
                    Log.log(Log.DEBUG, this, "Testing condition = " + condition);
                    boolean test = false;
                    try {
                        test = Utilities.evaluateCondition(node, condition);
                        Log.log(Log.DEBUG, this, "Condition result is " + test);
                    } catch (Exception e) {
                        Log.log(Log.ERROR, this, "Condition through an exception");
                    if (include ^ test)
                        return false;
                if (platforms.isEmpty()) {
                    return true;
                PlatformObject p = getPlatform(platform);
                if (p == null) {
                    Log.log(Log.DEBUG, this, platform + " not found for " + attribute + ", returning false");
                    return false;
                return p.isExported(node);
        /** This class represents a specific value of a queue manager's command level. A
            given instance of this class may 'include' a 'parent' instance through its
            include instance variable. The traversal of the parent/child hierarchy is
            delegated to the SupportObject class, since that is where the collection of
            VersionObjects lives. */
        class VersionObject {
            private String cmdLevel;
            private String include;
            private HashMap attributes;
            public VersionObject(String cmdLevel, String include) {
                this.cmdLevel = cmdLevel;
                this.include = include;
                attributes = new HashMap();
            public void addAttr(AttributeObject attr) {
                attributes.put(attr.getAttribute(), attr);
            public AttributeObject getAttr(String attr) {
                return (AttributeObject)attributes.get(attr);
            public String getCmdLevel() {
                return cmdLevel;
            public String getInclude() {
                return include;
            public boolean isSupported(String attr, String platform) {
                AttributeObject obj = (AttributeObject)attributes.get(attr);
                if (obj == null) {
                    return false;
                } else
                    return obj.isSupported(platform);
        /** This class represents an MQSeries object type, as identified by its classid, e.g.
            queue manager or local queue. This class implements an include facility similar to
            that described for the VersionObject. The traversal of that hierarchy is delegated
            to the static isSupported method, because the collection of SupportObject instances
            is a static variable of the SupportMatrix class. */
        class SupportObject {
            private String classId;
            private String include;
            private HashMap versions;
            public SupportObject(String classId, String include) {
                this.classId = classId;
                this.include = include;
                versions = new HashMap();
            public void addVersion(VersionObject obj) {
                String key = obj.getCmdLevel();
                versions.put(key, obj);
            public String getClassId() {
                return classId;
            public String getInclude() {
                return include;
            public boolean isSupported(String attr, String cmdLevel, String platform) {
                boolean result = false;
                VersionObject obj = (VersionObject)versions.get(cmdLevel);
                if (obj == null)
                    obj = (VersionObject)versions.get("base");
                // I don't actually know what it means if obj is null at this point.
                // It probably can't happen.
                if (obj == null)
                    return false;
                while (result ==  false && obj != null) {
                    result = obj.isSupported(attr, platform);
                    if (result == false && obj.getInclude() != null) {
                        obj = (VersionObject)versions.get(obj.getInclude());
                    } else
                        obj = null;
                return result;
            public AttributeObject getAttr(String attr, String cmdLevel) {
                AttributeObject result = null;
                VersionObject obj = (VersionObject)versions.get(cmdLevel);
                if (obj == null)
                    obj = (VersionObject)versions.get("base");
                // I don't actually know what it means if obj is null at this point.
                // It probably can't happen.
                if (obj == null)
                    return null;
                while (result ==  null && obj != null) {
                    result = obj.getAttr(attr);
                    if (result == null && obj.getInclude() != null)
                        obj = (VersionObject)versions.get(obj.getInclude());
                    else
                        obj = null;
                return result;
    }

    Are you the one who commented out the code you're looking for ?//String desc = StringFactory.getString(attributes.getValue("desc"));You just have to modify you AttributeObject class to hold a new field : String description. And then, it's up to you to create a new constructor or a new setter method.
    Btw, this is not a Swing related question.

  • Scope of instance variables in servlets..

    Hi all,
              Sorry for asking a dumb question..
              What is the scope of instance variables in a servlet? Is the scope is
              limited to thread?
              In other words, in the following example, i am setting "testStr", in one
              request and when i tried to access the same instance variable from another
              request, i am getting it as null. Does it mean instance variable is limited
              to that particular thread/request?
              thanks in advance..
              -ramu
              

    Oops ... I had misunderstood and had the problem backwards ;-)
              > Is it known behavior? With registered servlet its working fine (a
              > instance variable is shared by all requests)
              I believe so; I typically deploy in a WAR so have not seen the problem that
              you describe. Servlets can be reloaded, so what you saw could have been
              caused bye a date/time mismatch between the .class file and the server's
              current time. On the other hand, that could be how WebLogic works.
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              +1.617.623.5782
              WebLogic Consulting Available
              "Ramu" <[email protected]> wrote in message
              news:[email protected]...
              > Hi Purdy,
              >
              > I got it. I am testing the servlet as a unregistered servlet, which is
              > creating instance for every new request!!!, which created this whole
              > confusion. Is it known behavior? With registered servlet its working fine
              (a
              > instance variable is shared by all requests)
              >
              > > What theory? ;-) Instance variables are on the object, and the object
              can
              > > be used by multiple threads, thus allowing multiple threads to access
              the
              > > same instance variables.
              > what i mean by theory here is, all instance variables in servlet should
              be
              > shared by all requests. Now i got it sir.
              >
              > Thank you..
              > -ramu
              >
              >
              > >
              > > Peace,
              > >
              > > --
              > > Cameron Purdy
              > > Tangosol, Inc.
              > > http://www.tangosol.com
              > > +1.617.623.5782
              > > WebLogic Consulting Available
              > >
              > >
              > > "Ramu" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > Hi,
              > > >
              > > > > No, an instance variable in a servlet class is not limited to a
              > thread.
              > > > There
              > > > > is exactly one copy of the servlet created in memory and all
              requests
              > > pass
              > > > > through the same instance, thus sharing any instance variables. A
              > > couple
              > > > of
              > > > > things to remember:
              > > > I totally agree with you, But i am wondering why my sample servlet(i
              am
              > > > attaching the file) is not sharing the instance variables across
              > > > threads/reqs. (in 1st request set some string to "testStr" instance
              > > > variable, in next request if you read the same instance variable, you
              > will
              > > > get null!!)
              > > > Our current code is having instance variables. But right now we are
              not
              > > > getting any problems. But as per theory, instance variables should be
              > > shared
              > > > across threads/requests..
              > > >
              > > > Any how we are changing our code to remove all instance variables.
              > > >
              > > > thanks,
              > > > -ramu
              > > >
              > > > >
              > > > > 1.) Using instance or class variables in servlets that are not
              > read-only
              > > > is not
              > > > > a good thing to do. This makes the servlet not thread-safe. To
              > > maintain
              > > > > variables across requests, sessions, etc., use the servlet-defined
              > > objects
              > > > to
              > > > > store the state (e.g., request, session, etc.).
              > > > >
              > > > > 2.) If you modify the servlet class on disk, WebLogic will reload
              the
              > > > servlet
              > > > > class thus discarding the old instance and creating a new one (of
              > > course,
              > > > this
              > > > > depends on some configuration parameters for servlet reloading).
              > > > >
              > > > > Hope this helps,
              > > > > Robert
              > > > >
              > > > > Ramu wrote:
              > > > >
              > > > > > Hi,
              > > > > > thanks for quick reply.
              > > > > > I am not at all using SingleThreadModel. See the following code.
              > > > > > In first request i am passing "abc" value to testStr. But in
              second
              > > > request,
              > > > > > I am getting null for testStr in second request. It looks like
              (for
              > > me)
              > > > for
              > > > > > non single threaded model also, scope of instance variables is
              > > limited
              > > > to
              > > > > > Thread/Request.. But as per theory, because its not single
              threaded
              > > > model,
              > > > > > only one instance should be there AND testStr(instace variables)
              > > should
              > > > be
              > > > > > shared across the all threads. But i am not able see that
              behaviour
              > > > here.
              > > > > > But if declare instance variable as static, o am able to share
              it
              > > > across
              > > > > > all threads/requests.
              > > > > >
              > > > > > note:
              > > > > > From browser i am setting testStr to "abc" with URL like
              > > > > > "localhost/test1?testStr=abc"
              > > > > > And 2nd req from browser is like "localhost/test1" (on server
              > output
              > > i
              > > > am
              > > > > > getting null for testStr)
              > > > > >
              > > > > > Any ideas?
              > > > > >
              > > > > > thanks,
              > > > > > -ravi
              > > > > >
              > > > > > import java.io.*;
              > > > > > import javax.servlet.*;
              > > > > > import javax.servlet.http.*;
              > > > > >
              > > > > > public class test1 extends HttpServlet
              > > > > > {
              > > > > > public String testStr;
              > > > > >
              > > > > > public void doGet (HttpServletRequest req, HttpServletResponse
              res)
              > > > > > throws ServletException, IOException
              > > > > > {
              > > > > > doPost(req, res);
              > > > > > }
              > > > > >
              > > > > > public void doPost (HttpServletRequest req,
              HttpServletResponse
              > > res)
              > > > > > throws ServletException, IOException
              > > > > > {
              > > > > > try {
              > > > > > res.setContentType("text/html");
              > > > > > PrintWriter out = res.getWriter();
              > > > > > if(req.getParameter("testStr") != null)
              > > > > > {
              > > > > > testStr = req.getParameter("testStr");
              > > > > > System.out.println("set testStr = " + testStr);
              > > > > > }
              > > > > > else{
              > > > > > System.out.println("get testStr = " + testStr);
              > > > > > }
              > > > > >
              > > > > > }
              > > > > > catch(Exception e){
              > > > > > e.printStackTrace();
              > > > > > }
              > > > > >
              > > > > > }
              > > > > > }
              > > > > >
              > > > > > "Cameron Purdy" <[email protected]> wrote in message
              > > > > > news:[email protected]...
              > > > > > > Yes or no, depending on if your servlet implements
              > > SingleThreadModel.
              > > > > > >
              > > > > > > See the servlet 2.2 spec for documentation on how many instances
              > of
              > > a
              > > > > > > servlet will be created. See the doc for the SingleThreadModel
              > > > interface.
              > > > > > >
              > > > > > > Peace,
              > > > > > >
              > > > > > > --
              > > > > > > Cameron Purdy
              > > > > > > Tangosol, Inc.
              > > > > > > http://www.tangosol.com
              > > > > > > +1.617.623.5782
              > > > > > > WebLogic Consulting Available
              > > > > > >
              > > > > > >
              > > > > > > "Ramu" <[email protected]> wrote in message
              > > > > > > news:[email protected]...
              > > > > > > > Hi all,
              > > > > > > >
              > > > > > > > Sorry for asking a dumb question..
              > > > > > > >
              > > > > > > > What is the scope of instance variables in a servlet? Is the
              > scope
              > > > is
              > > > > > > > limited to thread?
              > > > > > > >
              > > > > > > > In other words, in the following example, i am setting
              > "testStr",
              > > in
              > > > one
              > > > > > > > request and when i tried to access the same instance variable
              > from
              > > > > > another
              > > > > > > > request, i am getting it as null. Does it mean instance
              variable
              > > is
              > > > > > > limited
              > > > > > > > to that particular thread/request?
              > > > > > > >
              > > > > > > > thanks in advance..
              > > > > > > >
              > > > > > > > -ramu
              > > > > > > >
              > > > > > > >
              > > > > > > >
              > > > > > >
              > > > > > >
              > > > >
              > > >
              > > >
              > > >
              > >
              > >
              >
              >
              

  • When can I make instance variables public?

    I noticed that some of the in-built Java classes have public instance variables, for example in Rectangle the variables x, y, width and height are all directly accessible from outside. When is it okay to make public instance variables? Is it when they are primitive types? I thought maybe it is when they are final variables - but that can't be the case because you can directly modify the Rectangle's public instance variables.
    I've always used getter and setter methods in my objects because I was told "making instance variables public is bad". But obviously this isn't necessarily the case (unless the guys at Java are bad programmers). I think directly accessing the instance variables makes for much neater and more readable code. Is there any convention or best-practise guidelines on when I can or can not make them public?
    P.S. I also just "don't get" why you can't make them public if you're just going to provide a getter and setter method anyway... what's the difference? I suppose the theory is that the setter method should do some checking to make sure the input is valid. But what if the setter method just accepts -anything- of the appropriate type (accepts any Rectangle, for example)? What's the use of hiding the instance variables?
    teach me.
    Thanks. ;-)

    For the most part, it is true that making instance member variables other than private is not a good idea. This concept, known in OO circles as "information hiding", typically allows the greatest flexibility in internal implementation of a class, since you can change the internal structure of the class without affecting the clients that use the class.
    Let me add that Sun's programmers are a team, and teams have members of differing capabilities.
    It is also true that there may be cases where exposing instance variables is unlikely to cause problems. Simple classes, or very stable classes that will not change are some examples, but not all.
    Following a guideline blindly is not a good idea either. You need to evaluate each instance in which you decide you might want to deviate from "good programming practices". Still, best practices are best practices for a reason. It is best to understand them, and then decide if you can violate them.
    For my own part, I don't think it is "neater" to expose such variables, and I have personally had to deal with situations where a change in a class's internal structure was extremely painful because the original developer chose to make all his instance variables public.
    {?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Is there any version of Indesign that allows to open multiple instance at the same time

    I am using Indesign CS3 to generate the bulk reports automatically(programmatically) using Adobe indesign library . One of the key limitation to this tool is it allows to open only one instance at a time unlike word where multiple instances can be opened at the same time. Is there any adobe indesign too version desktop/server which allows to open multiple instances at the same time. Any help on is appreciated. Thanks.

    @PeterG
    You said "You might want to examine the End User Licensing Agreement (EULA) for  any prohibition against using these two instances at the same time with  the same license; the license does permit two installs for the same user  that are not used simultaneously." I thought that meant you had read the EULA. It's pretty unambiguous on that point.
    For everyone's edification about multiple installations and server use with a standard license here's the relevant text:
    2. Software License.
    If you obtained the Software and any required serial number(s) from Adobe or one of its authorized
    licensees and as long as you comply with the terms of this agreement, Adobe grants you a non-exclusive
    license to install and use the Software in a manner consistent with its design and Documentation and as
    further set forth below. See Section 16 for specific provisions related to the use of certain products and
    components, for example font software, Acrobat, After Effects, Adobe Presenter, Contribute, Adobe
    Device Central, Flash Player, Flash Builder, and Adobe Runtimes.
    2.1 Limited Use. The Software, or portions of the Software, may allow installation and use without a serial
    number. If so, you may install but not use such non-serialized Software on any number of Computers as
    part of an organizational deployment plan. Further, you may install and use such non-serialized Software
    on any number of Computers for demonstration, evaluation and training purposes only and only if any
    Output Files or other materials produced through such use are used only for internal, non-commercial and
    non-production purposes. You may not use such non-serialized Software after any applicable time-out
    period has ended, unless you input a valid serial number under Section 2.2. ACCESS TO AND USE OF
    ANY OUTPUT FILES CREATED WITH SUCH NON-SERIALIZED SOFTWARE IS ENTIRELY AT
    YOUR OWN RISK.
    2.2 General Use. You may install and use one copy of the Software only on the Permitted Number of your
    compatible Computers into which you enter a valid serial number.
    2.3 Distribution from Server. You may copy an image of the Software onto Computer file server(s) within
    your Internal Network for the purpose of downloading and installing the Software onto Computers within
    the same Internal Network for use as permitted by Section 2.1 and 2.2.
    2.4 Server Use. You may install the Software on Computer file server(s) within your Internal Network only
    for use of the Software initiated by an individual from a Computer within the same Internal Network only
    as permitted by Section 2.2. The total number of users (not the concurrent number of users) able to use the
    Software on such Computer file server(s) may not exceed the Permitted Number.
    By way of example, the foregoing does not permit you to install or access (either directly or through
    commands, data or instructions) the Software: (a) from or to a Computer not part of your Internal Network,
    (b) for enabling Web hosted workgroups or services available to the public, (c) by any individual or entity
    to use, download, copy or otherwise benefit from the functionality of the Software unless licensed to do so
    by Adobe, (d) as a component of a system, workflow or service accessible by more than the Permitted
    Number of users, or (e) for operations not initiated by an individual user (e.g., automated server
    processing).
    2.5 Portable or Home Computer Use. Subject to the important restrictions set forth in Section 2.6, the
    primary user of the Computer on which the Software is installed under Section 2.2 (“Primary User”) may
    install a second copy of the Software for his or her exclusive use on either a portable Computer or a
    Computer located at his or her home, provided that the Software on the portable or home Computer is not
    used at the same time as the Software on the primary Computer.
    2.6 Restrictions on Secondary Use by Volume Licensees. If the Software was obtained under an Adobe
    volume license program (currently known as Adobe Open Options) by any licensee other than an
    educational volume licensee, the second copy of the Software made under Section 2.5 must be used solely
    for the benefit and business of that volume licensee. For more information about secondary use by volume
    licensees, please visit our Web Site at http://www.adobe.com/go/open_options.
    There is also language stating that if you have a dual boot or other system capable of running more than one OS you will need a separate license for each platform if you want to run the software on more than one.

  • Binding: Instance variable loses value.

    Hi all,
    Just making my first steps into Objective-C, I've done a lot of C, C++ and C# on win & linux. Anyhow, I've been hacking away happily and discovered a peculiar behaviour, and I'm not sure if it's my code or some obscure bug in Xcode.
    1. I have a Check Box(NSButton) directly bound to a BOOL instance variable called "checkValue" using KVC. The containing class is a custom NSView subclass.
    2. I manually implemented the setter according to KVC naming rules "setCheckValue".
    3. When debugging the UI (check box) calls the setter perfectly with the correct value, which shows up in the NSLog output.
    4. I hooked up the action for the check box as well, and inside the action handler the instance variable reports the value correctly. Everything looks fine.
    5. Now here's the rub. I put a mousedown event handler into the class as well, and it is called flawlessly when I click on the custom view. However, "checkValue" does not report the correctly set value.
    So, how can a class instance variable, which is set and reports correctly elsewhere in the same scope, all of the sudden take on a nonsense value in a event handler? If a variable has a value set, it should be the same everywhere within the same scope!
    Below is simplified code extracted from the original project for clarity. It produces exactly the same behaviour as the more complex project without the distracting code.
    #import "CheckBoxHandler.h"
    @implementation CheckBoxHandler
    @synthesize checkValue;
    //Apparently this is required for binding in NSView based classes
    //The same behaviour occurs even if you remove this.
    +(void)initialize
    [self exposeBinding:@"checkValue"];
    -(id)initWithFrame:(NSRect)frameRect
    self = [super initWithFrame:frameRect];
    if(!self)
    return nil;
    [self setCheckValue:YES];
    return self;
    //manual impelementation of KVC setter
    -(void)setCheckValue:(BOOL)v
    checkValue = v;
    NSLog(@"Setter Called: checkValue is %d", checkValue);
    //The action works fine as evidenced by Log output
    //Check and uncheck the box a few times.
    -(IBAction)checkBoxAction:(id)sender
    NSLog(@"UI State:%d Ivar State: %d", [checkBox state], checkValue);
    //Mouse clicking on the view calls into this event.
    //The problem is the value reported by [self checkValue] OR checkValue directly
    //do not match the UI state. In fact it always reports some nonsense value.
    -(void)mouseDown:(NSEvent *)event
    NSLog(@"Inside Mousedown: checkValue is: %d", [self checkValue]);
    @end
    I have a workaround, but it really bends my head when something doesn't behave as expected!

    I have synthesized against "checkValue", although I manually implemented the setter so I could set a breakpoint and observe the value. I thought [self checkValue] and self.checkValue both simply call the same getter, just different syntax.
    The setting of the value using the UI checkbox happens outside of the event call chain. I can check and uncheck the checkbox and the value changes correctly. The checkbox is in a separate space on the window, so clicking it does not activate mousedown on the view, this is correct behaviour. Clicking on the view does activate the mousedown event, this is done after I've set the checkbox so the value has been set well before the mousedown event. Thus it should already have the correct value in the event.
    For completeness this is the interface file:
    #import <Cocoa/Cocoa.h>
    @interface CheckBoxHandler : NSView {
    IBOutlet NSButton *checkBox;
    BOOL checkValue;
    -(IBAction)checkBoxAction:(id)sender;
    @property (assign, readwrite) BOOL checkValue;
    @end
    I'll change everything to self.checkValue just for the excercise. Ok, done. checkValue still reports a value of 1 in the mousedown event regardless of the value set elsewhere.

  • Stateful session bean destroying instance variables?

    I'm trying to use a stateful session bean as some kind of login controller and to maintain the login id and access level across JSPs and HTMLs so that once logged in, all the JSPs can obtain the login name of the current user (String) and his access level (int).
    I use the login.jsp to login and it successfully reports logging in with the correct access level retrieved from database. However, if I go to another JSP (testlogin.jsp), these 2 EJB instance variables are always destroyed and set to null and 0 when I access them again.
    What am I missing that my stateful session bean is not saving these instance variables? Do I need to put them in some serializable value objects (create a help VO class?)
    I suspected that on different JSP, I call the MemberControllerHome.create() method, it creates a new instance or something but if I don't use the create method how do I get a handle to MemberController at all?
    MemberControllerBean.java
    public class MemberControllerBean implements SessionBean {
         //initialize in ejbCreate.
         private MemberHome memberHome;
         SessionContext context;
         //Member currentLogin;
         //Current Login
         private String loginID;
         private int accessLevel;
         // Constructor
         public MemberControllerBean() {}
    ...some code in between...
    public void login(String id, String password){
              try{
                   Member member = null;
                   member = memberHome.findByPrimaryKey(id);
                   if(member.getMPassword().equals(password)){
                        this.loginID = member.getMID();
                        this.accessLevel = member.getMAccessLevel();
                   else{
                        throw new EJBException("Login failed. Invalid member ID and/or password.");
              } catch (FinderException ex) {
                   throw new EJBException("Login failed. Invalid member ID and/or password.");
         public void logout(){
              this.loginID = null;
              this.accessLevel = 4;
         public String getLoginID(){
              return this.loginID;
         public int getLoginAccessLevel(){
              return this.accessLevel;
    login.jsp
    String mID = request.getParameter("mID");
    String mPassword = request.getParameter("mPassword");
    out.println("20:" + mID + ":" + mPassword);
    if(mID != null && mPassword != null){
         out.println("22:" + mID + ":" + mPassword);
         try{
              InitialContext ic = new InitialContext();
              MemberControllerHome home = (MemberControllerHome) ic.lookup("java:comp/env/ejb/MemberController");
              MemberController mc = home.create();
              out.println("26:Logging in as " + mID + " with " + mPassword);
              mc.login(mID, mPassword);
              out.println("28:" + mc.getLoginID() + "logged in successfully at level " +
                   mc.getLoginAccessLevel() + ".");
         } catch (NamingException ex) {
              out.println("java:comp/env/ejb/MemberController not found.");
         } catch (EJBException ex) {
              out.println(ex.getMessage());
         } catch (Exception ex) {
              out.println(ex.getMessage());
    testlogin.jsp
    <%
    try{
         InitialContext ic = new InitialContext();
         MemberControllerHome home = (MemberControllerHome) ic.lookup("java:comp/env/ejb/MemberController");
         MemberController mc = home.create();
         out.println("You are logged in as <b>" + mc.getLoginID() +
              "</b> at level <b>" + mc.getLoginAccessLevel() + "</b>.");
    } catch (NamingException ex) {
         out.println("java:comp/env/ejb/MemberController not found.");
    } catch (EJBException ex) {
         out.println(ex.getMessage());
    } catch (Exception ex) {
         out.println(ex.getMessage());
    %>

    The key to the problem is that in testlogin.jsp a new stateful session bean is created. The new bean instance of course doesn't know the log-in information you stored in the old session bean. That is why the method returns null and 0 when called.
    There are couple of ways to solve the issue. The easiest solution is to store the bean instance created in Login.jsp in the jsp's implicit HttpSession object. Because login.jsp and testlogin.jsp share the same session, the bean instance can be easily stored and retrieved.
    Here is the code you need to have:
    1. in login.jsp
    session.setAttribute("MemberControllerBeanInstance", mc);
    2. in testlogin.jsp
    MemberController mc =
    (MemberController) session.getAttribute("MemberControllerBeanInstance");
    Hope it helps.

  • Viewing Instance Variable Information for Automatic activities

    Hi,
    I have a process which is made up of all automatic activities that each do a specific set of activities and populate a few instance variables. I want to create a view so that a user can see the state and value contained in each of the instance variable at any time during the execution of the process. A example of what i want to achive in the view is shown below.. any advice on how to design such a feature
    InstVar_1 InstVar_2 InstVar_3
    1 2 3
    4 5 6
    Thanks.

    Are you the one who commented out the code you're looking for ?//String desc = StringFactory.getString(attributes.getValue("desc"));You just have to modify you AttributeObject class to hold a new field : String description. And then, it's up to you to create a new constructor or a new setter method.
    Btw, this is not a Swing related question.

  • Design question: When to use instance variables

    Looking for best practice/design advise.
    I am working my way through an exercise where I convert a zip code to a postal barcode (and back), validate the format, and validate/generate a check digit. My code works fine. I posted comments and methods below for reference. In addition to the book I am using, I also read http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html.
    My question is: In designing this class, should I have defined instance variables to hold the generated zipcode, barcode, and checkdigit and then used getter methods to get the zipcode or barcode?
    I planned on creating a user interface to ask for a zipcode or barcode and present a conversion to the user. The only methods that need to be called are "convertBarcodeToZipcode" and "convertZipcodeToBarcode". All the other methods are utility methods. The strings that are returned by these two methods are presented to the user.
    I could, easily enough, create and populate instance variables, but would I keep the return statements as well or remove them?
    Thanks, Mike
    ps: I am self-learning java, so I don't have an instructor to ask. :)
    public class PostalBarCode {
         * Constructor.
         * Set up the barcode ArrayList
        public PostalBarCode() {
                barcodeUnits.add("||:::");
                barcodeUnits.add(":::||");
                barcodeUnits.add("::|:|");
                barcodeUnits.add("::||:");
                barcodeUnits.add(":|::|");
                barcodeUnits.add(":|:|:");
                barcodeUnits.add(":||::");
                barcodeUnits.add("|:::|");
                barcodeUnits.add("|::|:");
                barcodeUnits.add("|:|::");
         * Convert a barcode to a zipcode.
         * Assumes the input format is valid. Validates the check digit
         * @param theBarcode string to be converted
         * @return the zipcode as a String of empty string for error
        public String convertBarcodeToZipcode(String theBarcode) {}
         * Convert the Zipcode to a barcode
         * @param theZipcode string to be converted
         * @return the barcode as a string
        public String convertZipcodeToBarcode(String theZipcode) {}
         * Determines if theString is a barcode
         * @param theString
         * @return true if the input is a barcode, false otherwise.
        public boolean isBarcode (String theString) {}
         * Determines of theString is a zip code
         * @param theString the string to test for 5 digits
         * @return true for a zip code, false otherwise
        public boolean isZipcode (String theString) {}
         * Convert a barcode to a zipcode.
         * Assumes the input format is valid. Validates the check digit
         * @param theBarcode string to be converted
         * @return the zipcode as a String of empty string for error
        public String convertBarcodeToZipcode(String theBarcode) {}
         * Convert the Zipcode to a barcode
         * @param theZipcode string to be converted
         * @return the barcode as a string
        public String convertZipcodeToBarcode(String theZipcode) {}
         * Calculate the check digit from the zipcode
         * @param theZipcode as a String
         * @return the the check digit or -1 for error
        public int calculateCheckDigitFromZipcode(String theZipcode) {}
         * Calculate the check digit from the barcode
         * @param theZipcode as a String
         * @return the the check digit or -1 for error
        public int calculateCheckDigitFromBarcode(String theBarcode) {}
         * Validate the format of the barcode.
         * Should be 6 blocks of 5 symbols each.
         * Also check if frame bars are present and strip them.
         * @param theBarcode
         * @return true for proper format, false for improper format
        public boolean validateBarcodeFormat (String theBarcode){}
        private  ArrayList<String> barcodeUnits = new ArrayList<String>();
    }

    These are just my two cents. The various methods that determine whether something is a zip or bar code can easily remain static. After all, you probably don't want to create an instance and then call something like isValid(), although you could do so. The various other methods could easily be instance methods. You could have a toZipCode() or toBarCode() method in each object to convert from one to the other. I would personally throw something like ValidationException rather than returning -1 for your various check-digit methods.
    - Saish

  • Renaming instance variable VS use of "this."

    Open Topic:
    Do you prefer this code?
    private var _myVar:int;
    public function myClassConstructor(value:int) {
         _myVar = value;
    or this code? (JAVA style)
    private var myVar:int;
    public function myClassConstructor(myVar:int) {
         this.myVar = myVar;
    Discuss the pros and cons, especially if performance is involved.
    You have 10 minutes... I will be collecting the papers

    Bertrand G. wrote:
    So no one is concerned about any performance issues using 'this'... I have seen somewhere that using 'this' in C++ is not as efficient as renaming the variable, because it makes an object instantiation or something like that.
    Most people will go for clarity of purpose in the code in preference to performance, simply because performance is not a critical factor for MOST purposes.
    I personally prefer using this for the setters and getters, this way I can have the same variable name for both the method parameters and the class variable.
    Just my 2 cents...
    I think the usual practice for getters and setters is to have a private variable for the instance variable and to name it with an underscore prefix to indicate that the variable is private. In that way references to the private variable are distinct to the variable name used in the setter and getter. In any event, in my setter I invariably name the parameter with the new value "newValue" or "newWhatever", some people just use "pWhatever" to indicate that variables have been passed as parameters, so the use of "this" is not required.
    I don't see the use of "this" as particularly relevant to performance, or getters and setters, and I would recommend naming private variables with an underscore prefix to indicate the use of a private instance variable, though not everyone follows this convention and may use other conventions, or indeed no convention at all.
    Paul

  • Select instance variable

    When I create a screenflow, in the pop window of selecting instance variable, it includes many variable (such as: participant, status ...) and the one I created. The tutorial let me set the in and out value to No.
    When should I set some of them to Yes?
    Edited by: YE on Apr 24, 2009 2:09 PM

    Please see this,
    Re: statspack report to a file
    Adith

Maybe you are looking for