Checked exceptions design question

Hi,
I'm writing an RMI replacement which has similar semantics and I have the following design problem:
- A client invokes server.method(myList)- myList is of type List and is actually a Remote object which resides on the client code. So when the server method uses this list, it is actually communicating back with the client and sending resulting back and forth.
- The server code is defined as
public Server
  public void method(List myList)
    // A network error occurs while trying to access myList
}Ideally I'd like to throw RemoteException from the list in case of a network error, but I can't do that because RemoteException is a checked exception and cannot be added to the List interface (it would break its contract). So I was thinking maybe that the list should throw a custom Error if an I/O occurs and then my framework would catch it at the end of the method and throw RemoteException back on the client-end of things. I am uncomfortable throwing and catching an Error but I don't want the server-code to try to catch the thrown exception either. As far as I can tell, if a RemoteException occurs from inside the list, there is absolutely no way for the server code to recover. It can't request a new method argument from the client and therefore it must always simply rethrow the exception. What do you think? Do you have a better idea?
Thanks,
Gili

The term client and server is relative. Whoever is hosting the remove object I consider to be the server for that object. So if the client exports an object and sends it to the server, then in this case, the client is the host or "server" for that object.
So in this case the receiver of the object is the one that has to deal with the exception. However, the receiver can pass the exception back to the caller if it chooses. I don't see any reason for your "server" to fail because it could not successfully invoke a method on an object from your "client." If your client requests the server to do something, and the server could not, the server just tosses an exception back to the client. I may be missing your problem!?
For hibernate, handling hibernate failures is a bit different from handling remote failures. In either case, I let the client deal with it. My remote interfaces look like so
public interface INamedObject extends Remote {
     public String getName() throws RemoteException;
     public DSID getIdentifier() throws RemoteException;
     public void setName(String name) throws  RemoteException, ServerException;
    public Set<? extends IPropertyType> getPropertyKeys() throws  RemoteException, ServerException ;
    public Map<? extends IPropertyType,? extends String> getProperties() throws  RemoteException, ServerException ;
    public String getProperty(IPropertyType key) throws  RemoteException, ServerException ;
    public String setProperty(IPropertyType key, String value) throws  RemoteException, ServerException;
    public String removeProperty(IPropertyType key) throws  RemoteException, ServerException ;
}The methods that do not require any hibernate activity generally just throw RemoteExceptions. However, the ones that do hibernate stuff also throw ServerException which is my own custom exception. Its just a serializable class. When the client gets a ServerException it knows that its not a connection problem, but a problem with the server itself. Such as the db crashed or some other thing.
Note that my objects have identifiers. So if you make a call on a remote object, and it fails, you reestablish the connection to the server, then re-request that remote object using the identifier, then try the request on it again. For distributed computing you need to be able to handle this IMHO.

Similar Messages

  • Design question: RemoteException -- checked or unchecked

    I'm working an non-RMI RPC library and a question that has come up is how to deal with RPC-induced failures (networking outages, interface clashes). I'm curious what the RMI experience was with making RemoteException a checked exception. In retrospect, was this the right choice? Or should have it been unchcked? If you prefer the checked exception, is subclassing IOException still considered the correct approach?

    I think Sun got it right in both cases myself. The rationale is given at some length in http://research.sun.com/techrep/1994/abstract-29.html.

  • Checked exception

    Hi
    What is the reason why we do not have to catch checked Exceptions in a JSP page?

    The J2EE reference implementation creates page implementation classes which enclose all scripting elements in a
    try {
    catch (Throwable t) {
      pageContext.handlePageException(t);
    }That would explain one level of "why". The larger design question is a mystery to me--I would guess that it's a convenience feature, so that one may easily pass page-level exceptions to the container for handling (e.g. to map it to your error page, or some HTTP Status 500 page).
    Is that something you found in a specification or observed in an implementation?

  • "checked" exceptions

    Hi !
    Well.. My method throws a bunch of uncheckeds.. but I would like for the compiler to check the callers code for exception handlers (i.e. catch clauses). SO THAT I DONT MISS THEM (have bugs) -> (type safety)
    ... in other words: if add a throws clause describing the possible throwing of an unchecked, does the exception become "sort of checked", despite being instance of RuntimeException ?
    Is this guaranteed by the JLS ?
    What is the default behaviour ?
    In this case I have EntityExistsException, NonUniqueResultException, NoResultException, where they signal not a programmer error, rather than expected application state. E.g. user is already registered (EntityExistsException).
    Thanks.

    javaUserMuser wrote:
    Yeah, thanks, but those semantics are obvious.Well, then what's your question?
    What I mean is, I'd love to use those uncheckeds for exceptional conditions signalling, cos the semantics they signal (e.g. in the JPA spec) for their purpose match those I implement.
    Non existent user is being signalled via EntityExistsException in my code, as well as NoResultException for no user registered with the name supplied.
    The thing is: should I define a checked variant for every unchecked exception I find useful ?There's no cut an dried answer. There are arguments in in favor of both using checked exceptions and moving away from them to strictly unchecked.
    I probably wouldn't have a 1-to-1 mapping of every unchecked exception. If you're going to define your own, whether checked or unchecked, do so in a way that is meaningful and useful to the callers of your code. So you might several exceptions, both checked and unchecked, into a single "CouldNotRetrieveException," if your code doesn't expose the details of how it does its work, and your callers aren't likely to be able to be able to use the knowledge of the specific underlying exception.
    My method contract says: throw THIS exception when THIS error, and THAT ex when THAT error.. I am simply allowing the JPA provider thrown exceptions to propagate naturally to the caller, which I find very clean and neat - no catch an exception to throw another one - for a clean API design. The problem is if I can enforce the caller of my method to catch (or supply a throws clause for) my method's thrown exceptions.You already know the answer to that, clearly, since, in your words, "those semantics are obvious."
    There is an extreme example which indicates why I dont want to introduce anymore custom exceptions indicating a given problem:
    .. what if I define an exception class for every stack trace element ? What if I catch every exception thrown by a method call, wrap it with another class then throw an instance of the latter.
    Thats very, very ugly, and a bad practice.
    On the other hand, obviously I have no choice, and define a checked exception, but should I name it e.g. NoSuchUserException, or rather NoResultCheckedException (and thus make it more general, which is the thing I am aiming at).Your call. I can't answer that without knowing more about your code than I do or care to.

  • Design question: Scheduling a Variable-timeslot Resource

    I originally posted this in general java programming, because this seemed like a more high-level design descussion. But now I see some class design questions. Please excuse me if this thread does not belong here (this is my first time using the forum, save answering a couple questions).
    Forum,
    I am having trouble determining a data structure and applicable algorithm (actually, even more general than the data structure -- the general design to use) for holding a modifiable (but more heavily read/queried than updated), variable-timeslot schedule for a given resource. Here's the situation:
    Let's, for explanation purposes, say we're scheduling a school. The school has many resources. A resource is anything that can be reserved for a given event: classroom, gym, basketball, teacher, janitor, etc.
    Ok, so maybe the school deal isn't the best example. Let's assume, for the sake of explanation, that classes can be any amount of time in length: 50 minutes, 127 minutes, 4 hours, 3 seconds, etc.
    Now, the school has a base operation schedule, e.g. they're open from 8am to 5pm MTWRF and 10am to 2pm on saturday and sunday. Events in the school can only occur during these times, obviously.
    Then, each resource has its own base operation schedule, e.g. the gym is open from noon to 5pm MTWRF and noon to 2pm on sat. and sun. The default base operation schedule for any resource is the school which "owns" the resource.
    But then there are exceptions to the base operation schedule. The school (and therefore all its resources) are closed on holidays. The gym is closed on the third friday of every month for maintenance, or something like that. There are also exceptions to the available schedule due to reservations. I've implemented reservations as exceptions with a different status code to simplify things a little bit: because the basic idea is that an exception is either an addition to or removal from the scheduleable times of that resource. Each exception (reservation, closed for maintenance, etc) can be an (effectively) unrestricted amount of time.
    Ok, enough set up. Somehow I need to be able to "flatten" all this information into a schedule that I can display to the user, query against, and update.
    The issue is complicated more by recurring events, but I think I have that handled already and can make a recurring event be transparent from the application point of view. I just need to figure out how to represent this.
    This is my current idea, and I don't like it at all:
    A TimeSlot object, holding a beginning date and ending date. A data structure that holds list of TimeSlot objects in order by date. I'd probably also hold an index of some sort that maps some constant span of time to a general area in the data structure where times around there can be found, so I avoid O(n) time searching for a given time to find whether or not it is open.
    I don't like this idea, because it requires me to call getBeginningDate() and getEndDate() for every single time slot I search.
    Anyone have any ideas?

    If I am correct, your requirement is to display a schedule, showing the occupancy of a resource (open/closed/used/free and other kind of information) on a time line.
    I do not say that your design is incorrect. What I state below is strictly my views and should be treated that way.
    I would not go by time-slot, instead, I would go by resource, for instance the gym, the class rooms (identified accordingly), the swimming pool etc. are all resources. Therefore (for the requirements you have specified), I would create a class, lets say "Resource" to represent all the resources. I would recommend two attributes at this stage ("name" & "identifier").
    The primary attribute of interest in this case would be a date (starting at 00:00hrs and ending at 24:00hrs.), a span of 24hrs broken to the smallest unit of a minute (seconds really are not very practical here).
    I would next encapsulate the availability factor, which represents the concept of availability in a class, for instance "AvailabilityStatus". The recommended attributes would be "date" and "status".
    You have mentioned different status, for instance, available, booked, closed, under-maintainance etc. Each of these is a category. Let us say, numbered from 0 to n (where n<128).
    The "date" attribute could be a java.util.Date object, representing a date. The "status", is byte array of 1440 elements (one element for each minute of the day). Each element of the byte array is populated by the number designation of the status (i.e, 0,1,2...n etc.), where the numbers represent the status of the minute.
    The "Resource" class would carry an attribute of "resourceStatus", an ordered vector of "ResourceStatus" objects.
    The object (all the objects) could be populated manually at any time, or the entire process could be automated (that is a separate area).
    The problem of representation is over. You could add any number of resources as well as any number of status categories.
    This is a simple solution, I do not address the issues of querying this information and rendering the actual schedule, which I believe is straight forward enough.
    It is recognized that there are scope for optimizations/design rationalization here, however, this is a simple and effective enough solution.
    regards
    [email protected]

  • 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

  • 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..

  • Dreamweaver design question

    Hi all. I'm new to the forum and ha da design question. My site took about 3 weeks to complete and after finishing what I though was a pretty error free website I noticed that dreamwever 8 was coming up with numerous errors that matched http://validator.w3.org's scans. My question is this. Why does dreamwever ( regardless of the release ) allow the designer of the website he/she is creating without pointing out the errors as they go along with simple instructions on how to fx them.  As an example My meta tags
    <META NAME="keywords" CONTENT="xxxxxxx">
    <META NAME="description" CONTENT="xxxxxxxx">
    <META NAME="robots" CONTENT="xxxxx">
    <META NAME="author" CONTENT="xxxxxx">
    <META NAME="copyright" CONTENT="xxxxxx">
    all had to be changed over to
    <meta name="keywords" xxxxxxxxxxxxx">
    <meta name="description" CONTENT="xxxxxxx">
    <meta name="robots" CONTENT="xxxxxx">
    <meta name="author" CONTENT="xxxxxxxx">
    <meta name="copyright" CONTENT="xxxxxxxx">
    all because dreamweaver didnt tell me that the <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    didnt fit the original design. Now my site ( if you wish to view the code ) is www.gamblingwhore.com and if you look at the page source you will see that the code has been corrected on dw 8 but still shows more than 30 errors on http://validator.w3.org. Does dreamwevaer not have the basic tool available to fix these errors without such hassle. Its not just my site either, many sites built in dreamwever can be checked with the http://validator.w3.org website only to find more than 20 -100 different errors.
    Dream weaver creators need to focus on these errors because they hinder seo and they create alot of extra work
    Thank you

    The w3c and XHTML have come a ways since the release of Dreamweaver 8 (I used it in late 2004 and 2005).
    Dreamweaver 8 will build transitional XHTML files as well as old style single tag HTML. It all depends on the personal preferences of the designer.
    Just for kicks, go to say... 20 random websites and see just how many get a green light when you validate them. If its half, you're lucky. This page doesn't even validate;
    Dreamweaver has the menu option (at least in CS3 an CS4) under the Commands menu to "Clean Up HTML" or "Clean Up XHTML" depending on what you're building. I make a point of running that command as I build along with Apply Source Formatting.
    I also use a local validator program to check my code before putting anything.
    That's why they call it WYSIWYG software.
    If it did everything perfectly for everyone every single time, good web designers would find themselves out of work.

  • 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.

  • What makes subclass of exception checked exception

    Hi
    When I make a exception class
    class TestException extends Exception{}
    This exception is a "checked exception". Understood
    But the predefined java class RunTimeException is also a subclass of Exception what makes it an unchecked exception. Does compiler treat this class differently.
    How I can make unchecked exception class when I extend my custom exception class from Exception.
    Thanks
    Abhishek

    >
    But the predefined java class RunTimeException is also a subclass of Exception what makes it an unchecked exception. Does compiler treat this class differently.
    How I can make unchecked exception class when I extend my custom exception class from Exception.
    >
    The answer to both of these questions can be found in Chapter 11.2 'Compile-Time Checking of Exceptions of the Java Language Specification. Suggest you read the entire section.
    http://docs.oracle.com/javase/specs/jls/se5.0/html/exceptions.html
    >
    The unchecked exceptions classes are the class RuntimeException and its subclasses, and the class Error and its subclasses. All other exception classes are checked exception classes.
    >
    These two other subsections give the reasons the designers of Java made the choices above
    >
    11.2.4 Why Errors are Not Checked
    11.2.5 Why Runtime Exceptions are Not Checked

  • 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

  • Design Question: Parent/Child Distribution

    Hi,
    I have what I think is a straightforward design question. I tried
    searching this forum for the answer, but struggled with what keywords
    to use in the searches. (I also struggled with what to put on the
    subject line for this post!)
    Anyhow, here is my question: Given:
    public class Pet {...}
    public class Dog extends Pet {...}
    public class Cat extends Pet {...}
    public class Pig extends Pet {...}
    Which is the better design?
    DESIGN A:
    public abstract class PetOwner {
    private Pet pet;
    PetOwner(Pet pet) {
    this.pet = pet;
    public Pet getPet() { return this.pet; }
    public class DogOwner extends PetOwner {
    public DogOwner(Dog dog) {
    super(dog);
    public class CatOwner extends PetOwner {
    public CatOwner(Cat cat) {
    super(cat);
    public class PigOwner extends PetOwner {
    public PigOwner(Pig pig) {
    super(pig);
    ===============================================
    or DESIGN B:
    public abstract class PetOwner {
    PetOwner() {
    public class DogOwner extends PetOwner {
    private Dog dog;
    public DogOwner(Dog dog) {
    super();
    this.dog = dog;
    public class CatOwner extends PetOwner {
    private Cat cat;
    public CatOwner(Cat cat) {
    super();
    this.cat = cat;
    public class PigOwner extends PetOwner {
    private Pig pig;
    public PigOwner(Pig pig) {
    super();
    this.pig = pig;
    This is a somewhat contrived example, so don't take it too literally.
    My question is where should I put the field that holds a Pet object?
    All pet owners own a pet, so should I put it in the parent class
    (Design A)? Note the constructors for the child classes (e.g.
    DogOwner) are designed so that the correct type of pet is checked
    for. Or should each child class hold its own type of pet (Design B)?
    If the answer is "it depends" (as I suspect it is), then what are
    the questions I should be asking myself in order to decide?
    Thanks very much, in advance!!
    Chris

    eg,
    import java.util.*;
    class Pet {
        private String name = null;
        public Pet( String n ) {
         this.name = n;
        public String toString() {
         return name;
    class Dog extends Pet {
        public Dog( String n ) {
         super( n );
    class Pig extends Pet {
        public Pig( String n ) {
         super( n );
    class Cat extends Pet {
        public Cat( String n ) {
         super( n );
    class PetOwner {
        private Vector pets = new Vector();
        private int dogs = 0;
        private int cats = 0;
        private int pigs = 0;
        public void add( Dog d ) {
         pets.add( d );
         dogs++;
        public void add( Cat c ) {
         pets.add( c );
         cats++;
        public void add( Pig p ) {
         pets.add( p );
         pigs++;
        public boolean isCatOwner() {
         return cats > 0;
        public boolean isDogOwner() {
         return dogs > 0;
        public boolean isPigOwner() {
         return pigs > 0;
        public int numberOfPets() {
         return pets.size();
        public String toString() {
         String s = "";
         Enumeration en = pets.elements();
         while( en.hasMoreElements() ) {
             Pet pp = (Pet) en.nextElement();
             s += pp.toString() + "\n";
         return s;
    public class Pets {
        private PetOwner po = new PetOwner();
        public Pets() {
         po.add( new Dog( "doggy" ) );
         po.add( new Cat( "catty" ) );
        public String toString() {
         String s = "";
         s += po.toString();
         s += po.isDogOwner() + "\n";
         s += po.isPigOwner() + "\n";
         s += po.isCatOwner() + "\n";
         s += po.numberOfPets();
         return s;
        public static void main( String[] args ) {
         Pets p = new Pets();
         System.out.println( p );
    }

  • Design question about instant download from

    Hi All,
    Here is a design question for you:
    Background:
    The application we built is being upgraded from time to time and we send it to our users.
    our users use it on a network so there is only one file to upgrade (and being done by the sys admin)
    We send them a �patch�; actually, it�s a new version of the application they place it in the relevant folder and continue to work with a new version.
    Problems:
    1. We send them the patch via email - sometimes it takes a while until they read their email and at they are using an �old version of the system�.
    2. Some of them are not computer savvy (when it�s not the sys admin) and we need to guide them as where exactly to place the file (there are 3 files)
    Our (conceptual never build yet) Solution:
    Build a program just like Norton antivirus (or other) that prompts the user from the task bar (next to the clock) that a new version is available and by
    clicking once it will automatically download the file and store it in the correct folder.
    Question:
    1. Did anyone try anything like this before (or something like) who can tell me about it?
    2. Do you think this kind of system will work for us?
    3. Does anyone have a better solution?
    Thanks
    Peter

    Java WebStart is the deployment technique suited for your purposes.
    The deployment will be done via a webserver running a jnlp servlet (provided).
    The applications may either run offline, or check online for automatic updates.
    You have several configuration options.
    ArgoUML and jEdit are two open source apps delivered this way.
    Your app will need to be adapted though.
    And your customers need an online browser with installed jvm.

  • MSI K8N 2 NEO Platinum with AMD 4200+ X2 Machine Check Exception

    Greetings,
    I recently bought a 4200+ x2 and when i replaced my Venice 3500+ by it i get a Machine Check Exception when windows xp Professionnel is about to load. But when i go back to my Venice everything working properly. any ideas what could cause such a trouble?
    my PSU is a ANTEC 550W, i don't think i'm in need of any more power and more i got it recently, so it's almost new and never got problem with it before.
    thanks.

    I think that you have to cleanly reinstall your Windows XP Pro operating system for it to recognize consistently dual core cpu.  What bios do you use?  Does CPU-Z say that you have one processor or two in Processor Selection at bottom of CPU Tab?  Good luck.

  • LDAP design question for multiple sites

    LDAP design question for multiple sites
    I'm planning to implement the Sun Java System Directory Server 5.2 2005Q1 for replacing the NIS.
    Currently we have 3 sites with different NIS domains.
    Since the NFS over the WAN connection is very unreliable, I would like to implement as follows:
    1. 3 LDAP servers + replica for each sites.
    2. Single username and password for every end user cross those 3 sites.
    3. Different auto_master, auto_home and auto_local maps for three sites. So when user login to different site, the password is the same but the home directory is different (local).
    So the questions are
    1. Should I need to have 3 domains for LDAP?
    2. If yes for question 1, then how can I keep the username password sync for three domains? If no for question 1, then what is the DIT (Directory Infrastructure Tree) or directory structure I should use?
    3. How to make auto map work on LDAP as well as mount local home directory?
    I really appreciate that some LDAP experta can light me up on this project.

    Thanks for your information.
    My current environment has 3 sites with 3 different NIS domainname: SiteA: A.com, SiteB:B.A.com, SiteC:C.A.com (A.com is our company domainname).
    So everytime I add a new user account and I need to create on three NIS domains separately. Also, the password is out of sync if user change the password on one site.
    I would like to migrate NIS to LDAP.
    I want to have single username and password for each user on 3 sites. However, the home directory is on local NFS filer.
    Say for userA, his home directory is /user/userA in passwd file/map. On location X, his home directory will mount FilerX:/vol/user/userA,
    On location Y, userA's home directory will mount FilerY:/vol/user/userA.
    So the mount drive is determined by auto_user map in NIS.
    In other words, there will be 3 different auto_user maps in 3 different LDAP servers.
    So userA login hostX in location X will mount home directory on local FilerX, and login hostY in location Y will mount home directory on local FilerY.
    But the username and password will be the same on three sites.
    That'd my goal.
    Some LDAP expert suggest me the MMR (Multiple-Master-Replication). But I still no quite sure how to do MMR.
    It would be appreciated if some LDAP guru can give me some guideline at start point.
    Best wishes

Maybe you are looking for

  • Minidisplay port to VGA problems.

    I just got a minidisplay port to VGA adapter and have been trying to connect it to my samsung lcd TV with no joy. What do I need to do? The TV obviously has a VGA connection on the back but in the menus it seems not to be highlighted as if there was

  • Problem in Reading  Material Long text in Sapscript

    Dear firends, I have written  following code in sapscrit to fetch the longtext of the material INCLUDE &MARA-MATNR(K)& OBJECT MATERIAL ID GURN LANGUAGE &NAST-SPRAS& Test name - material no(MARA-MATNR) object - MATERIAL text id - GURN LANGUAGE - EN bu

  • Post with No URLSessionFormat

    Is there a way you could post form and strip out all the URLSessionFormat eg check the HTTP_REFERER without the URLSessionFormat like CFID=16539&CFTOKEN=88882009&jsessionid=64301634311145628979265

  • ITunes U reports contain no data: PSM public site

    For over two months, since the Queens College public site went live on PSM, the iTunes U reports we receive have contained no data. Is any other public site on PSM having this issue? we have not been able to get a response to our inquiries regarding

  • J2ee logging approach

    hi, i am currently exploring on what approach to use for logging messages for my application. i am using the sun one appserver and stateless ejb's. may i know the best logging approach for ejb's? is there a logging software that would require less co