Better method of design question

Before starting another project, I thought I'd check opinion on the most efficient design and processing of the forms.
It's an extremely simple application that needs to track 7 different types of meetings, their dates, and the people in attendance.
Originally, I was going to create 3 separate tables, one for the meetings with TYPE,DATE & PRIMARY_KEY field from a sequence, another table for personnel of the type PRESIDENT with PRES_NAME & FOREIGN KEY fields populating FOREIGN_KEY with MEETINGS SEQUENCE, and a third table for personnel called VICE_PRES with VICE_NAME & FOREIGN_KEY fields also populated with MEETINGS SEQUENCE.
There are times when there will only be 1 president and 5 vice, other times there will be 2 presidents and 6 vice. So I figured a separate table for PRES and VICE would ensure that every column entered into the table would have data in it rather than creating one table with TYPE, DATE, AUTOID, 2 PRES and 6 VICE and have several empty columns per record.
After creating the 3 tables I've now run into more complex processing that I have in the past. I now need to display additional PRES and VICE fields when a radio element indicates Y and submits. I also only let this radio display when the meeting type select list is VIS and submits.
The display issues appear to be correct at this point. The major problem I have is how to process multiple rows into 3 separate tables with one submit.
How would one go about adding 2 PRES and 6 VICE names as separate rows at one time? This would be simple if I had used poor table design and just put everything into one table, but now that I have 3 tables to insert data into at the same time, and considering I have to add multiple records into one table at the same time I've run into more of a challenge than in the past.
In addition, I've searched for how to process a form with blank items into a table without entering the nulls and haven't had much luck. This problem comes into play when I have 2 PRES items and 6 VICE items but only enter 1 PRES and 5 VICE. How to process multiple rows into the same tables and remove any null values from that process.
Also, I may have the wrong idea as to how to link the 3 tables personnel records with the meeting records using one sequence and putting that number into all the tables, sometimes into multiple records at the same time. If I do, please do tell me about it. It seemd the most logical way of keying across tables.
Thanks for any help on this thing!
Jacob

Took a couple days off... I made a quick page indicating the items on the page. It's at link http://htmldb.oracle.com/pls/otn/f?p=15398:1
Originally I wanted 3 tables for this. 1 stores the meeting type& date. 1 stores the PRESIDENT name and his COMPANY. 1 stores the VICE president name and COMPANY. This way, I won't be accumulating a ton of null values in one larger table.
I need these items to submit to their respective tables with 1 submit. Additionally, if there is only one value for PRES and one for VICE, I would need to submit only those items that are not NULL so I'm not loading up the null values in the tables.
This has to be simple, I just don't immediately see how to accomplish this.
Thanks 2 anyone.

Similar Messages

  • Design question: methods returning objects

    I have a general design question. When, in general (and why), should you have a method alter an object via it's methods but not return the object as opposed to doing the same operation in a method and then return it.
    Consider the two below methods which do basically the same thing. When is one desireable over the other, and why?
    Cheers--
    public void setMyIntField(SomeObject pObj){
    pObj.setSomeInt(5);
    public SomeObject setMyIntField(SomeObject pObj){
    pObj.setSomeInt(5);
    return pObj;
    }

    Let me give a better example:
    class FruitWorker{
      private void someMethod(){
        HashMap myCitrus = new HashMap();
        HashMap myTropicals = new Hashmap();
        // use my no return obj method
        addFruitProps1(myCitrus,
                       "tartnes",
                       new FruitProperty("very!" ));
        // use my return object method
        myTropicals =  addFruitProps2(myCitrus,
                                      "sweetness",
                                       new FruitProperty("little bit" ));
      }// end method
      private void addFruitProperties1(HashMap pFruitProps,
                                       String pProp
                                       FruitProperty pVal){
        pFruitProps.add( pProp,pVal);
      }// end method
      private HashMap addFruitProperties2(HashMap pFruitProps,
                                       String pProp
                                       FruitProperty pVal){
        pFruitProps.add( pProp,pVal);
        return pFruitProps;
      }// end method
    }// end class

  • Method design question...and passing object as parameter to webserice

    I am new to webservice...one design question
    i am writing a webservice to check whether a user is valid user or not. The users are categorized as Member, Admin and Professional. For each user type I have to hit different data source to verify.
    I can get this user type as parameter. What is the best approach to define the method?
    Having one single method �isValidUser � and all the client web service can always call this method and provide user type or should I define method for each type like isValidMember, isValidAdmin ?
    One more thing...in future the requirement may change for professional to have more required field in that case the parameter need to have more attribute. But on client side not much change if I have a single isValidUser method...all they have to do is pass additional values
    isValidUser(String username, String usertype, String[] userAttributes){
    if usertype == member
    call member code
    else if usertype = professional
    call professional code
    else if usertype = admin
    call admin code
    else
    throw error
    or
    isValidMember(String username, String[] userAttributes){
    call member code
    One last question, can the parameter be passed as object in web service like USER object.

    First of all, here is my code
    CREATE OR REPLACE
    TYPE USERCONTEXT AS OBJECT
    user_login varchar2,
    user_id integer,
    CONSTRUCTOR FUNCTION USERCONTEXT (
    P_LOGIN IN INTEGER
    P_ID_ID IN INTEGER
    ) RETURN SELF AS RESULT
    Either your type wont be compiled or this is not the real code..

  • BC4J + Struts: Design questions!

    OK, I'm wanting to use Struts with BC4J and have a design question for you BC4J users and gurus.
    Here's how I think things would work:
    1. User requests page
    2. Struts ActionServlet calls perform() on Struts ActionForm
    3. Struts ActionForm instantiates BC4J AppModule and calls business method
    4. BC4J AppModule instantiates necessary BC4J ViewObjects and performs business operations which return data
    5. Struts ActionForm receives value objects from BC4J AppModule
    6. Struts ActionForm populates Struts FormBean
    7. Struts ActionForm forwards to Struts JSP which displays Struts FormBean
    I prefixed the components with Struts/BC4J to keep things clear where things belong.
    Now, here are my questions:
    In step 3, what's the best method of doing this? Do I need to do JNDI lookups every time? What's the performance overhead of this? Anyone have any best-practice code that does this?
    Is this the accepted way of doing things? Is there a better way of designing this system?
    Thanks!

    In Step3 you should use the ApplicationModule pooling framework, especially if you are trying to work in stateful mode because the pooling automatically handle the AM activation/passivation.
    There are different way to go at it.
    If you are using the BC4J custom tag library and have an ApplicationModule tag in your jsp, the pooling is already initialize. By the time your action is trigger you just need to retrieve the am using the application id:
    in your jsp:
    <jbo:ApplicationModule id="myAM" ... />
    in your Action implementation:
    HttpContainer container = HttpContainer.getInstanceFromSession(request.getSession());
    SessionCookie cookie = container.getSessionCookie("myAM");
    ApplicationModule am = null;
    if (cookie != null)
    am cookie.useApplicationModule();
    This AM id can be passed as URL parameter...
    If you do have a JSP with an AM tag you need to create the pool with findSessionCookie call.
    For more info about AM pooling look at the end of this thread for Steve resources:
    http://forums.oracle.com/forums/message.jsp?id=912431&gid=513211
    This is what we are currently doing for to provide support for BC4J in Struts for our next release.
    Charles.

  • EJB Design Question

    Hi All,
    I have 2 tables in the DB, namely Product and Inventory. And I have create a Product Bean, which is related to the Product Table. Now I am wondering should I create an Inventory Bean to reflect the Inventory Table? or just to add some operation in the Product Bean to insert/delete/update the Inventory Table?
    Which one is a better choice?

    Greetings,
    Hi All,
    I have 2 tables in the DB, namely Product and
    Inventory. And I have create a Product Bean, which is
    related to the Product Table. Now I am wondering
    should I create an Inventory Bean to reflect the
    Inventory Table? or just to add some operation in the
    Product Bean to insert/delete/update the Inventory
    Table?
    Which one is a better choice?Your question is fundamental to understanding the nature and role of Entity Beans. Entity Beans have a direct association with the 'entities' they represent. An 'entity' is one piece/record of enterprise data like A database tuple (in it's simplest form a table row) - though EBs can represent data from any accessible source (such as naming/directory services, message queues, URLs, legacy systems, object databases, other distributed components, etc...). Through their design contract, EBs provide an object-oriented view of the data they represent (you might think of them as being 'proxies' or 'agents' for a particular piece of information) - and this is absolutely important to understand: EBs map to ENTITIES, NOT to data sources (if you want a data source interface use a Session Bean)! With this in mind:
    * An EB should be written for every entity (specific piece of information) that needs OO representation in your application where appropriate (simply accessing a database does not automatically warrant EBs as the design choice - there are many times/situations where a Session Bean, JavaBean, client-direct-access, etc. is more appropriate)
    * While finders ("SELECT" statements) can map to multiple entities ('multi-row finders' - a finder's ONLY purpose is to return keys for located entities), an EBs ejbCreate ("INSERT"), ejbStore ("UPDATE"), ejbLoad (non-finder "SELECT"), and ejbRemove ("DELETE"), methods should all handle one-and-only-one - as identified by it's primary key - entity/record/row/... (and yes, such a record may be represented throughout multiple tables by way of joins, cascading foreign keys, manual mapping [*not* recomended], etc.).
    * Persistence Management model (BMP vs. CMP) relates only to the locality of the data source access code. All EB state-synchronizatoin (the real 'persistence' in 'persistence management'), management is always at the discretion of the container. A BMP bean coder simply provides the access code for the container to do it's job.
    I hope this is helpful.
    Regards,
    Tony "Vee Schade" Cook

  • Design question: Link data between JFrames

    Dear all,
    I have a design question. I have this form in a JFrame where you can set an icon as a property. To achieve this, I have a "Set" button on the form which will open a new window with all the available icons. When you click an icon, I want the "icon" frame to be closed and the selected icon to be send to the original form. This is the way I do it now:
    Interface :
    public interface IconUpdate
    public void updateIcon(Icon icon);
    }Main frame with the "Set" button:
    public class Test extends JFrame implements IconUpdate, ActionListener
        private Icon icon = null;
        public Test()
            // add button and actionlistener and that kind of stuff
        public void actionPerformed(ActionEvent e)
            if(e.getSource() == btnSetIcon)
                new IconFrame(this);
        public void updateIcon(Icon icon)
            this.icon = icon;
    }The Icon frame:
    public class IconFrame extends JFrame implements ActionListener
        IconUpdate parent = null;
        public IconFrame(IconUpdate parent)
            this.parent = parent;
            // Initialize table,"Pick" button etc.
        public void actionPerformed(ActionEvent e)
            if(e.getSource() == btnPick)
                parent.updateIcon((Icon)list.getSelectedValue());
                this.dispose();
    }Maybe I made some spelling faults, but this is the way I implement it. Now my question is: is there another way to achieve my goal? If I have to create an interface for every "popup choose dialog" in my program, I have to create many of them. I know using a combobox in the main frame is an option, but I just want to use it this way. Can anyone tell me how I can rewrite this code to make it better / more professional?
    Tx in advance!!!
    Peter

    I can think of a couple options:
    1) Let IconFrame's constructor accept a Test parameter, instead of creating an interface.
    2) Make IconFrame into a modal dialog & have it store the user's selection in a variable. Then when you show the dialog, your action listener will block until the user selects an icon. Then you can call "getSelectedIcon()" to retrieve his/her selection. This would be much like the JOptionPane.showXXX() methods, and probably the cleaner solution.

  • Design question for database connection in multithreaded socket-server

    Dear community,
    I am programming a multithreaded socket server. The server creates a new thread for each connection.
    The threads and several objects witch are instanced by each thread have to access database-connectivity. Therefore I implemented factory class which administer database connection in a pool. At this point I have a design question.
    How should I access the connections from the threads? There are two options:
    a) Should I implement in my server class a new method like "getDatabaseConnection" which calls the factory class and returns a pooled connection to the database? In this case each object has to know the server-object and have to call this method in order to get a database connection. That could become very complex as I have to safe a instance of the server object in each object ...
    b) Should I develop a static method in my factory class so that each thread could get a database connection by calling the static method of the factory?
    Thank you very much for your answer!
    Kind regards,
    Dak
    Message was edited by:
    dakger

    So your suggestion is to use a static method from a
    central class. But those static-methods are not realy
    object oriented, are they?There's only one static method, and that's getInstance
    If I use singleton pattern, I only create one
    instance of the database pooling class in order to
    cionfigure it (driver, access data to database and so
    on). The threads use than a static method of this
    class to get database connection?They use a static method to get the pool instance, getConnection is not static.
    Kaj

  • Workflow design questions: FM vs WF to call FM

    Hereu2019s a couple of workflow design questions.
    1. We have Workitem 123 that allow user to navigate to a custom transaction TX1. User can make changes in TX1.  At save or at user command of TX1, the program will call a FM (FM1) to delete WI 123 and create a new WI to send to a different agent. 
    Since Workitem 123 is still open and lock, the FM1 cannot delete it immediately, it has to use a DO loop to check if the Workitem 123 is dequeued before performing the WI delete.
    Alternative: instead of calling the FM1, the program can raise an event which calls a new workflow, which has 1 step/task/new method which call the FM1.  Even with this alternative, the Workitem 123 can still be locked when the new workflowu2019s task/method calls the FM1.
    I do not like the alternative, which calls the same FM1 indirectly via a new workflow/step/task/method.
    2. When an application object changes, the user exit will call a FMx which is related to workflow.  The ABAP developer do not want to call the FMx directly, she wants to raise an event which call a workflow .. step .. task .. method .. FMx indirectly.  This way any commit that happens in the FMx will not affect the application objectu2019s COMMIT.
    My recommendation is to call the FMx using u2018in Update tasku2019 so that the FMx is only called after the COMMIT of the application object.
    Any recommendation?
    Amy

    Mike,
    Yes, in my first design, the TX can 1. raise a terminating event for the existing workitem/workflow and then 2. raise another event to call another workflow.   Both 1 and 2 will be in FM1. 
    Then the design question is: Should the FM1 be called from TX directly or should the TX raise an event to call a new workflow which has 1 step/task, which calls a method in the Business object, and the method calls the FM1?
    In my second design question, when an application object changes, the user exit will call a FMx which is related to workflow.  The ABAP developer do not want to call the FMx directly, she wants to raise an event which call a workflow, which has 1 step/task, which calls a method, which calls the FMx indirectly.  This way any commit that happens in the FMx will not affect the application objectu2019s COMMIT.
    My recommendation is either call the FMx using u2018in Update tasku2019 so that the FMx is only called after the COMMIT of the application object or raise an event to call a receiver FM (FMx).
    Thanks.
    Amy

  • OSPF Area Addition - Design Question

    Hello,
    I have a design question regarding OSPF. I am looking to add a new ospf area (1). The area will live on two Core routers and two Distribution routers. Can you please look at the attached Pics and tell me which design is better.
    I would like to be able to connect Core-01 to Dist-01 and Core-02 to Dist-02 with a connection between Dist-01 and Dist-02, but this will result in a discontiguous area, correct?
    Thanks,
    Lee

    I would say that the more common design is to have just backbone area links between the core routers. But there is no real issue with having an area 1 link between them...
    If I were you, I would not make the area a totally NSSA. Here are my reasons for that:
    - you will get sub-optimal routing out of the area since you have two ABRs and each distribution router will pick the closest one of them to get out to the backbone even though it may be more optimal to use the other one
    - in an NSSA case, one of the two ABRs will be designated as the NSSA translator, which means that if you are doing summarisation on the ABRs, all traffic destined for these summarised routes will be drawn to the area through that one ABR.
    Paresh

  • WLPI Design Question

    I've got a bit of a design question for Process Integrator. Currently I'm building
    a prototype for an exception handling system using Process Integrator. The application
    has to be web based and I'm using the Front Controller design pattern that is
    described in the J2EE Blueprint docs.
    I've come across a bit of a design problem. Should I design the application so
    that all the user actions in a task are accessed via the api set or should I build
    this functionality into the template. For example, a user will action a task which
    requires the user to update some variables in the template. In the template definition
    should use a Send XML to Client action and then use the taskExecute method on
    the worklist, or should I do it all programatically?
    Also if I do use the Send XML to Client should I then mark the task done using
    the APIs or using the Studio. I have noticed that if I mark the task done wihtin
    the studio after sending the xml, the task becomes available for the next user,
    even if the variables haven't been updated yet.
    Sorry about the rambling nature of this post.
    Thanks in advance.
    Preyesh

    If you want to write code that's easier for you to write, you do whatever the hell you want.
    If you want to write good code, retain the ID.

  • An XML design question.

    I have read the tomcat-users.xml file.
    <?xml version='1.0' encoding='utf-8'?>
    <tomcat-users>
      <role rolename="tomcat"/>
      <role rolename="role1"/>
      <role rolename="manager"/>
      <role rolename="admin"/>
      <user username="tomcat" password="tomcat" roles="tomcat"/>
      <user username="both" password="tomcat" roles="tomcat,role1"/>
      <user username="role1" password="tomcat" roles="role1"/>
      <user username="admin" password="admin" roles="admin,manager"/>
    </tomcat-users>There are some question about the disign of the xml.
    1.Why the xml file don't have a DTD, I think that the username,rolename should be an "ID" so as to be identical?So i think it should have a DTD to constrain them.
    2.Why the "rolename","username","password" are designed as attributes,not as element children? Which is better if i design them as element children?

    1. DTDs are not necessay for XML files. If a small and easy-to-understand XML file like this one is created, it doesn't really need a DTD to go with it. You could write a DTD to go with this file. It will look like this:
    <!---- A DTD for the tomcat-users XML File --->
    <!ELEMENT tomcat-users (role+, user+)>
    <!ELEMENT role EMPTY>
    <!ATTLIST role
    rolename (tomcat | role1 | manager | admin) #REQUIRED>
    <!ELEMENT user EMPTY>
    <!ATTLIST user
    username (tomacat | both | role1 | admin) #REQUIRED
    password (tomcat | admin) #REQUIRED
    roles CDATA #REQUIRED>
    You would have to add a tag in the XML file to reference such a DTD.
    I disagree that rolename and username should be merged. How would you explain the function of the username "Both"? You need to have the username belong to a separate element than the role to reference it in some attribute ( in this case, the "roles" attribute of the "user" element ).
    2. I have began answering part 2 in the first part. It would be useless to have "rolename", "username" and "password" as children element. First, that would mean that the elements "role" and "user" wouldn't have any meaning anymore, they would only be top elements sitting and doing nothing. Second, the way the document is written suggests that although the role and the user are closely related, they should be separated to define roles independently of what users are assigned.
    Hope that was helpful, please let me know if you have further questions.

  • DB Design Question From A Novice

    I need help in structuring the code for a javabean that I'm writing. Basically, I want to have the bean run several different types of DB queries (e.g. "check username and password", "list the groups that the player is in", "list player attributes", etc).
    The approach I started taking (out of simplicity) was to write a new method for each type of query I wanted to run. In other words, I wrote one method to "check username and password" and another to "list the groups that the player is in", etc. However, I noticed that this caused a lot of repeating in the code (e.g. con.createStatement(); and stmt.executeQuery() for all these methods). I posted this question on a different forum and someone suggested writing a generic method (that takes a String parameter containing a database query) and putting the output into a Vector object and returning that to the calling method. My question is: "is this the 'common' way of doing things?" Another question is, "are both approaches acceptable?" Personally, I think it seems a little easier to use the approach I started using but, I have to admit, all the repeating code troubles me. I'm learning this on my own so I don't really have someone to ask in person about this. I'm looking for the advice of someone with some experience in these matters. Thanks in advance for any help you can provide.

    My question is: "is this
    the 'common' way of doing things?" Basically yes. There are variations but the general idea is the same.
    You might want to look at this...
    http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
    And this....
    http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html
    Another question
    is, "are both approaches acceptable?" Your original approach would become unmangeable in a larger application. But other than that yes.
    Personally, I
    think it seems a little easier to use the approach I
    started using but, I have to admit, all the repeating
    code troubles me. And the repeating code, from the perspective of learning, is probably a good thing to a certain extent. It allows you to recognize patterns and thus question alternatives. And then when you move on to something else more sophisticated you will understand why it better/appropriate as opposed to someone who just does it one way without ever understanding why. (And for small applications you do use exactly the method you are doing rather than using more sophisticated and thus complex solutions.) Additionally you are more likely to be able to more quickly debug applications because you will be able to seperate out core problems relating to the database versus problems that are related to the intermediate layers.

  • Architecture/Design Question with best practices ?

    Architecture/Design Question with best practices ?
    Should I have separate webserver, weblogic for application and for IAM ?
    If yes than how this both will communicate, for example should I have webgate at both the server which will communicate each other?
    Any reference which help in deciding how to design and if I have separate weblogic one for application and one for IAM than how session management will occur etc
    How is general design happens in IAM Project ?
    Help Appreciated.

    The standard answer: it depends!
    From a technical point of view, it sounds better to use the same "midleware infrastructure", BUT then the challenge is to find the lastest weblogic version that is certified by both the IAM applications and the enterprise applications. This will pull down the version of weblogic, since the IAM application stack is certified with older version of weblogic.
    From a security point of view (access, availability): do you have the same security policy for the enterprise applications and the IAM applications (component of your security architecture)?
    From a organisation point of view: who is the owner of weblogic, enterprise applications and IAM applications. In one of my customer, application and infrastructure/security are in to different departments. Having a common weblogic domain didn't feet in the organization.
    My short answer would be: keep it separated, this will save you a lot of technical and political challenges.
    Didier.

  • Design questions on using JMX

    I have been reading about JMX and trying to understand it
    I have some specific design realted questions and wanted some opinions to validate my understanding
    Assume a simple j2ee application that exposes 2 webservices .
    I would like to find out how many times each service is called and the total number of success/faults/errors
    encountered for each service along with params like starttime etc
    From what I have understood , I will have to first create a Bean , say "StatsCollector"
    and then creae a StatsCollectorMBean interface.
    The StatsCollector will provide the methods to set/update the above values and those will also be exposed by the StatsCollectorMBean interface
    1) I have trouble understanding how to create and maintain the MBean Resource...
    Shouldnt there be always 1 instance of this resource ? ie shouldnt there be only one StatsCollector ?
    Most of the examples create a simple class "Hello implements HelloMBean" and that makes it a MBean
    but they create Hello hello = new Hello() and then register it with the MBean server
    What if we create multiple objects of Hello? Wouldnt that defeat the porpose of the MBean ?
    I think that we need to make sure that this resource is always created once only.
    Is that correct ?
    2) Is it the right practice to separate your MBean and your "managed" resource ?
    ie in the above case , should there be a Singleton StatsCollector POJO that stores the Appliction
    statistics and another StatsMBean that will be the MBean that will access the POJO ? This makes sure that your Resource does not have
    dependency management classes.
    3) How does the application update the values in the MBean ?
    In the above example , how do you update the success and failure counts in the MBean from the application ?
    Can I update the singleton StatsCollector directly or do I have to go through the MBean Server to update
    any value in the MBean ?
    If I update them directly , will they be "visible" thru the MBean server ?
    4) Assuming that the above app gets deployed in a appserver like WebSphere and in a Clustered environment ,
    how to ensure that statisitcs are collected for all the services on all servers cummulativly ?
    Is this something that the appserver should provide ? Do we register the MBean with the Appserver
    MBean server ?
    Any ideas/suggestions will be helpful !
    thanks
    Pat

    Hello pat,
    very interesting questions. You are covering the main JMX design questions there.
    You should have a look (if you not already did) to the JMX best practices : http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/best-practices.jsp
    This document summarize common JMX design patterns.
    Answers to your questions:
    1) The resources you want to manage/monitor are Web Services. The life cycle of these services is handled by the J2EE container itself. As you say, the tricky part is to link the WebService resource life cycle to the MBean resource
    The MBean leaves inside its own container, the MBeanServer.
    You should identify an initialization phase in which you create your MBeans and register them inside the MBeanServer once.
    In your case, you can go for a single collector that monitors the 2 Web Services or a collector per Web Service. It seems that you want to track each service independently. Having 2 MBeans should offer a more flexible solution.
    If you go for 1 MBean, you should name it "<your management domain>:type=StatsCollector". This name identify an MBean for which you have a single instance. Once the collector registered with this name, the MBeanServer will guarantee that no MBean with the same name can be registered.
    If you go for 2 MBeans, you should add the Web Service name to each MBean ObjectName. For example:
    MBean 1 : "<your management domain>:type=StatsCollector,name=MyWebService1"
    MBean 2 : "<your management domain>:type=StatsCollector,name=MyWebService2"
    Example of MBean creation and registration code :
    StatsCollector collector1 = new StatsCollector();
    ManagementFactory.getPlatformMBeanServer().registerMBean(collector1,
    new ObjectName("com.foo.bar:type=StatsCollector,name=WebService1");
    At this point you have an MBean registered inside the platform MBeanServer.
    2) A Standard MBean is formed of a java interface and a class. Generally the interface and the class are not separated. They could be but I don't see a strong reason in your case to have the POJO and interface not being the same object.
    3) You shouldn't expose the methods to set the values in your MBean interface. Only getters should be visible. It means that you will have to keep a direct reference to the collectors to update the statistics. During your initialization phase, you could use JNDI to register the collector instances. The WebServices will then use JNDI to retrieve the collectors.
    An example of a simplified StatsCollector class and StatsCollectorMBean interface
    public interface StatsCollectorMBean {
    public int getNumRequests();
    public class StatsCollector implements StatsCollectorMBean {
    private int numRequests.
    public int getNumRequests() {
    return average;
    public serviceCalled() {
    numRequests++;
    In the above example, serviceCalled is not part of the management interface and is called by the Web Service.
    4) Difficult question for which I can't provide you with a reply. JMX doesn't offer such cumulative service in a standard way. In some appserver (glassfish for instance), MBeans are cascaded inside the domain server. There is no cumulative representation offered, but you could implement your own by defining new MBeans linked to the StatsCollector ones.
    To conclude, Appservers are offering some "out of the box" management and monitoring features . For example glassfish relies on the AMX framework (that is JMX based) . AMX (https://glassfish.dev.java.net/javaee5/amx/) allows you to monitor and manage your services. A possible solution would be to rely on this infrastructure to build your own management and monitoring.
    Hope this help.
    Regards.
    Jean-Francois Denise

  • Database Connection design question

    Hello, I have a design question. Awhile back I needed to create a database connection to SQL Server, so I created a class to do it
    import java.sql.*;
    import java.io.*;
    import java.net.MalformedURLException;
    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    public class SQLServerConnection
         private static Connection connection = null;
         public SQLServerConnection(String user, String password, String dbName) throws java.sql.SQLException
              getDBConnection(user, password, dbName);
         public SQLServerConnection(String configFileName) throws java.sql.SQLException
              getDBConnection(configFileName);
         private void getDBConnection(String user, String password, String dbName) throws java.sql.SQLException
             DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
             connection = DriverManager.getConnection(
                  "jdbc:microsoft:sqlserver:" + dbName, user, password);              
         private void getDBConnection(String configFileName) throws java.sql.SQLException
              String user;
              String password;
              String dbName;
              try
                   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder db = factory.newDocumentBuilder();
                   Document doc = db.parse(configFileName);
                   doc.getDocumentElement().normalize();
                   // get the configuration information
                   password = getConfigParameter("password", doc);
                   user = getConfigParameter("username", doc);
                   dbName = getConfigParameter("databasename", doc);
                   getDBConnection(user, password, dbName);
              catch (MalformedURLException murle)
                   System.out.println("Unable to connect to: " + configFileName + " -- " + murle);
                   System.exit(1);
              catch (FileNotFoundException fnfe)
                   System.out.println("Configuration file " + configFileName + " not found.");
                   System.exit(1);
              catch (IOException ioe)
                   System.out.println("IOException: " + ioe);
                   System.exit(1);
              catch (javax.xml.parsers.ParserConfigurationException pce)
                   System.out.println ("Parser Configuration Error: " + pce);
              catch (SAXException saxe)
                   System.out.println ("SAXException: " + saxe);
         private String getConfigParameter(String paramName, org.w3c.dom.Document doc)
              NodeList nl = doc.getElementsByTagName(paramName);
              if(nl != null)
                   Node n = null;
                   for (int i = 0; i < nl.getLength(); i++)
                        n = nl.item(i);          
                        if(n.hasChildNodes())
                             NodeList children = n.getChildNodes();
                             return ((Node)children.item(0)).getNodeValue();
              else
                   System.out.println ("nl is null");
              return "";          
         public void setCatalog(String catalogName) throws java.sql.SQLException
              connection.setCatalog(catalogName);
         public Connection getConnection()
              return connection;
         public void closeConnection()
              try
                   connection.close();
              catch(java.sql.SQLException sqle)
                   System.err.println ("SQL Server Connection failed to close: " + sqle);
    }Later on, I needed to do the same thing for MySQL, so I created a class for that, MySQLServerConnection which is exactly the same as above, except for:
    private void getDBConnection(String user, String password, String dbName) throws java.sql.SQLException
              try
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
                   connection = DriverManager.getConnection(dbName, user, password);     
              catch(java.lang.ClassNotFoundException cnfe)
                   System.out.println (cnfe);
              catch(java.lang.InstantiationException ie)
                   System.out.println (ie);
              catch(java.lang.IllegalAccessException iae)
                   System.out.println (iae);
         }Later, on, I did the same thing with OracleServerConnection. My question is, I know this is probably not optimal code. For example, I didn't originally have a close connection method, so I had to go in and code one for all 3. I'm assuming that an interface would be a good idea so that if I have to code another database connection class I make sure and include all of the appropriate methods. I'm also assuming that it would have been smart to have a master class, maybe something like DatabaseConnection and extended these classes from that. Am I on the right track? Totally offbase?

    @nclow - I will work on trying the Factory Pattern for this over the weekend and post when I finish to see what you think.
    @abillconsl - just to make sure I understand, you're saying that I just try to connect and it will cycle through the different database connection possibilities and connect when it finds the right one? If it fails all 3, log an appropriate message. One question I have about this is, I thought I was being object oriented by separating the different types of db connections (Oracle, SQL Server, MySql) into different classes. Am I missing the point of OOP by what I was/am trying to accomplish? Going overboard? Also, does your way try and connect to all 3 even if I connected to one already?
    Thx, Grantarchy
    Edited by: grantarchy on May 9, 2008 9:50 PM

Maybe you are looking for

  • Converting seconds to Days,Hours,mins and secs

    Hi gurus, I have a metric in seconds , which is a box uptime . I want to convert that into Days,hours , mins and secs .How can I do that ? For example , If I have 433500 secs , I should show it as 5days 00:25:00 or in some meaningful format . Can any

  • Ease in/Ease out is clunky for pan/zooms

    I'm using FCP 5 with 10.5.6. When panning and zooming around in a still image (photo), I just can't get an easy landing or stop at the end of the motion, no matter how I adjust the ease in/ease out speed. After choosing Ease in/ Ease out on a keyfram

  • Controls on headphones freeze up in cold weather

    This has been troubling me since the beginning of winter and it's only getting worse. Everytime i go outside and try to use the click controls on the headset they don't work as they they should. They don't click or compress, and it's near impossible

  • IDoc2File Error

    Hi , I am testing my scenerio Idoc2File from R3 side using we19,Idoc is getting generated successfully and sent to XI but there I am finding error as below <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/

  • Using checkbox in sharing dialogue

    The latest version of Acrobat.com has a checkbox similar to the previous version giving the option not to send an email when sharing. In the latest version the checkbox appears to be disabled, it can not be checked. I had found this a useful facility