Class instance vs. class name in filter params

I wonder if using a Class type in parameters of the ClassFilter, MethodFilter and FieldFilter is actually make sense.
Let's say we have globally deployed aspect on a pointcut pointing to some library, deployed multiple times withing several web applications (ear's or war's) on the same J2EE app server. With Class type as params we have to load these classes first, which means strong typing, but additional confusion and an extra class loading because those web app class loaders aren't exist at the advice deployment time.
It looks like the same applies to the params with Method type...

ClassFilter/MethodFilter etc are more efficient but their expressiveness is more limited. They mainly allow to:
- match on a strongly defined type (ie a xxx.class) and possibly its subtypes
- match on simple name patterns (startswith)
UserDefinedFilter will be invoked (if you provide one) by the VM to further decide on the matching. It allows you to define places to match based on rich information and indeed will likely be used for complex scenarios.
We don't want to tie the VM with any pointcut styled grammar but instead provide a reasonably rich API while still providing 100% custom matching.
If you have idea on how to have better expressiveness for the MethodFilter/ClassFilter please let us know.
CatchSubscription and FieldSubscription are not implemented in the prototype and their API is indeed not yet consistent with MethodSubscription.

Similar Messages

  • Any way to for a class instance to ask what its instance name is?

    Hey. I have a class which needs to create a movie clip on the
    stage. Since each instance of the class will only ever have 1 movie
    clip on the stage at a time, it seems reasonable that I have the
    instance create a movie clip with its own name, prefixed with "mc_"
    or something of the sort.
    Here's where I don't know quite what to do... How do I get at
    this information? For instance, when you a dealing with an XMLNode,
    you can simply use...
    the_answer = xmlNodeInstance.nodeName;
    ...I know the analogy fails, but hopefully you know what I'm
    looking for.
    Thanks!

    hu....
    and when you create your movie clip, (assuming you don't just
    build it at authoring time) you specify an instance id through the
    createEmptyMovieClip function....
    taking a cue from this, I'm guessing that my answer is to
    change the structure of what I'm doing a little... instantiate my
    object with an instance name as a parameter given to the Class
    Constructor... that way the class can have it's own name on file.
    I guess my only concern there is how do I keep the "name"
    variable from being just completely arbitrary...?
    I guess I'm getting away from application (becaust I don't
    know when I'd do this...) and into theory.... but for instance,
    let's say I create my class like this:
    var instanceReference:mySuperCoolClass = new
    mySuperCoolClass("instanceName");
    So. I have my class instance... ideally, the class would
    exist on the stage as "instanceName", with "instanceReference"
    being another way to reference the instance. That would be ideal...
    but how do I make that happen? Because in the scenario of what I've
    just done, I see the class instance existing on the stage as
    "instanceReference", and I've just passed it a fun, but meaningless
    bit of data called "instanceName"...
    I suppose I could have the class go back to "_parent" and
    create it's own object.... but here again I'm getting into
    territory that feels a lot like i have no idea what I'm doing...
    haha!
    I guess I have enough info to get back to coding for now...
    But I'm deffinately open to more tips... I feel like I'm still
    missing how a lot of this works.
    (I'm at that awkward place where I can easily explain what
    OOP is, but I'm far from experienced in how to implement it... I've
    only written about half a dozen classes so far... so I still have a
    lot to learn. Thanks for your patience, all of you!)

  • Instancing a class whose classname is a variable

    I'm currently working on building a rudimentary 2D game engine and development kit program for building objects and I've run into an interesting problem. Here's what I want to do
    1. User creates new object which extends one of my other types of objects with user-defined name
    2. User defines constructor parameters and can alter the code of the object
    3. User hits save button, program writes new file with <user-defined name>.java as it's name
    4. Program compiles the objects
    (This is where I am right now)
    5. Program instances new object whose class is the newly created user defined class
    6. Program saves newly instanced object (easy since they'll be serializable eventually)
    7. Separate program opens the instanced object and uses it
    Now then this poses 2 questions. 1, is there a better way to do this sort of thing? By this sort of thing I mean created a new java class, saving it, instancing it, and using it in a separate program. 2, the main question is, is this even possible? Is it possible to instance a class whose name is determined at runtime? Something tells me it's not possible, simply because that would make it really easy to write dynamic code that changes at runtime and since that's often talked about as a difficult thing I doubt there's any other why to do it. I have another possibility, but it would make loading these objects insanely difficult and since I want them to be editable that means I'd much rather use a different method. Also the other method has some other problems that are hard to explain without getting into what the program does.
    I also would like to throw another question in.
    What's the best (easiest to write) way to detect (at runtime) if one of your programs is performing an infinite recursion? I've been working on a very stupid recursion based pathfinding AI for the same program, it was originally loop based but I realized recursion would cut the code down by a lot and make it smarter. However recursion also introduced an infinite loop problem because the AI works by picking two paths when it hits an object, right and left, then examining those recursively. So when I hit an object, go right, and hit another object the AI tests going back the way it came and gets stuck. Any suggestions would be most appreciated, my current method is to pass each recursive call a list of the points already visited and check if the destination for that call is the same as any of those points then simply cancel going that way however that's not working too well.
    Thanks for any help.

    Jverd - I know right now what constructor I'm calling and what arguments it takes...right now. That's subject to change and I would rather not dig through my code to find where I hard-coded it if another option is available.
    Here's what I have right now, it's giving me an error that newInstance() cannot be applied to newInstance(Object[]). If I try to do newInstance(params[0], params[1]) etc based on the length of params it gives me the same error except it changes newInstance(Object[]) to newInstance(Object, Object) etc
    Object[] params = new Object[textFields.size()];
    for (int i=0; i<textFields.size(); i++)
         if (parameters.get(i) == "int")
              params[i] = Integer.parseInt(textFields.get(i).getText());
         else if (parameters.get(i) == "String")
                 params[i] = textFields.get(i).getText();
         else
              params[i] = null;
    obj = obj.newInstance(params);I know I'm making a stupid mistake but I've never worked with that varargs thing before and so I don't know what stupid mistake I'm making. And in case it helps the constructor I'm trying to call at the moment is for my Item class which looks like this
    public RoNItem(boolean isGrenade, boolean isMedpac, boolean isObjective, int weight, int numberOfItems, String pictureLocation, String name, String description, String soundClipLocation)
    it takes 2 booleans (which I just noticed, so I guess my constructors take ints, Strings and booleans), 2 ints, and 4 strings right now. One of those strings was added yesterday, which is why I'd like to write some code that can adapt. The parameters the user is typing in are already loading from the file so the user will always enter the proper number and type of parameters, I just need to worry about how to pass those.

  • Trying to access methods from a .class file by creating instance of class

    Hey all,
    I'm hoping you can help. I've been given a file "Input.class" with methods such as readInt(), readString(), etc. I have tried creating instances of this class to make use of it, but I receive the error "cannot find symbol : class Input".
    If you could help at all, I would greatly appreciate it.
    Here's my code. The first is the base program, the second is the driver.
    import java.util.*;
    public class CarObject
         private String makeType = "";
         private String modelType = "";
         private int yearOfRelease = 0;
         private double numOfMiles = 0.0;
         public void setFilmTitle(String make)
              makeType = make;
         public void setMediaType(String model)
              modelType = model;
         public void setYearOfRelease(int year)
              yearOfRelease = year;
         public void setNumOfMiles(double miles)
              numOfMiles = miles;
         public String getMakeType()
              return makeType;
         public String getModelType()
              return modelType;
         public int getYearOfRelease()
              return yearOfRelease;
         public double getNumOfMiles()
              return numOfMiles;
    The program is used by a rental car company and the object takes on desired attributes.
    import java.util.*;
    public class TestCarObject
         static Scanner keyboard = new Scanner(System.in);
         public static void main(String[] args)
              System.out.println("Please answer the following questions regarding your rental car order.");
              Input carinput = new Input();
              String makeType = carinput.readString("Enter your desired make of car: ");          
              String modelType = carinput.readString("Enter your desired model of car: ");
              int yearOfRelease = carinput.readInt("Enter the oldest acceptable year of release to rent: ");
              double numOfMiles = carinput.readDouble("Enter the highest acceptable number of miles: ");
              System.out.println("Make: " + makeType);
              System.out.println("Model: " + makeType);
              System.out.println("Year: " + makeType);
              System.out.println("Mileage: " + makeType);
    }

    No, I don't know the package name....Is there a way
    to import the Input.class by itself without importing
    the entire packge?
    I tried extending the driver program too...It didn't
    work either...
    Message was edited by:
    BoxMan56How do you know you have a class called Input.class ?
    You got a jar file which contains it ? or just a simple .class file ?
    You have to set the classpath in either case.
    But for the former, you should also need to explicitly telling which package containing the class file you looking for (i.e. Input.class)
    e.g. java.util.Vector which is a class called Vector inside java.util package.
    You don't have to import the whole package, but you should tell which package this class belongs to.

  • Address instance of class with webserviceconnector

    Hi,
    what am I missing here?
    I'd like to create a movieclip which has linkage to a class.
    The class should have a function that calls a webservice that
    returns some data.
    The movieclip itself has an instance - i_checkHolder - which
    just is a graphic box,
    Now to my, I guess novice, problem:
    How do I address the "i_checkholder" of the current instance
    of this class ?
    I can not obviously use _this_ since that is the
    webserviceconnector itself.
    Cut code:
    import flash.events.*;
    import mx.data.components.WebServiceConnector;
    class AwcGroup extends MovieClip {
    function initChecks():Void {
    var wsConn:WebServiceConnector = new WebServiceConnector();
    wsConn.addEventListener("result", renderChecks(groupId));
    wsConn.WSDLURL = "
    http://sestivex01d/monitorws/amon.asmx?wsdl";
    wsConn.operation = "GetMonitorGroupChecks";
    wsConn.params = [groupId, false];
    wsConn.suppressInvalidCalls = true;
    wsConn.trigger();
    function renderChecks(evt:Object) {
    this["i_checkholder"]._alpha = 40; // I know this is wrong
    I would be grateful for any reply,
    Thanks

    Thanks so much, Bruce. (Oh my goodness, how would I have ever come up with that on my own?)
    So in summary
    This doesn't compile:
          classarg = (Class<CompoundObject<String,String>>)CompoundObject.class;but these do compile:
          classarg = (Class<CompoundObject<String,String>>)(Class)CompoundObject.class;or
          Class coclass = (Class)CompoundObject.class;
          classarg = (Class<CompoundObject<String,String>>)coclass;And this doesn't compile:
           classarg = proto.getClass().asSubclass(proto.getClass());but this does:
           Class tmp1 = proto.getClass();
           classarg = tmp1.asSubclass(tmp1);

  • Getting Class instance of a class

    Dear Friends,
    I need to get Class instance of a class in my project. Inorder to use the reflection API 's the package name of the class is needed , but it may not be available Only available thing is the name of the class file and the location where that file is existing .
    Please suggest some method to get Class instance in this situation.
    Shaiju.P

    You can create a ClassLoader of your own. There's a simplified example in this thread (reply number 6):
    http://forum.java.sun.com/thread.jsp?thread=538836&forum=31

  • [svn:osmf:] 13083: Updated MASTAdapter class with new trait names and events.

    Revision: 13083
    Revision: 13083
    Author:   [email protected]
    Date:     2009-12-17 16:10:05 -0800 (Thu, 17 Dec 2009)
    Log Message:
    Updated MASTAdapter class with new trait names and events.
    Modified Paths:
        osmf/trunk/plugins/MASTPlugin/org/osmf/mast/adapter/MASTAdapter.as
        osmf/trunk/plugins/MASTPluginIntegrationTest/src/org/osmf/test/mast/TestMASTPluginInfo.as
        osmf/trunk/plugins/MASTPluginIntegrationTest/src/org/osmf/test/mast/adapter/TestMASTAdapt er.as

    Silviu!
    I'm really sorry, but as all the office is trying to fix the problem, someone replaced the url content with the stuff that was pointing to the local machine.
    I've fix it, and the video player is available here again: http://pp.player.webtv.flumotion.com/params/apiKey/5PzLR2ULL3z2rumJ/videoId/60
    If there are other references to the localhost, please do not bother with them, as they do not affect player functionality.
    The stream that it uses is an RTMPE, so i'm afraid it will only works with this player. Anyway, the stream url is as follows: rtmpe://87.248.205.81/a4349/e2/veo7/ondemandrtmpe/mp4/med/first-person-mario-4d8741aa.mp4
    I really appreciate your help!
    Thank you!

  • Creating custom class instances for XML nodes

    Hi guys,
    I'm trying to load an external XML document in my application
    and create an instance of a custom class for each node in the XML
    based on the value of some of their elements. The instances created
    will eventually end up in a DataGrid by the way. The problem I'm
    having is there seems to be many ways of doing small parts of this
    and I have no idea how to make them all gel. Initially I'm using
    HTTPService to load the XML file but I've seen people just use an
    XML object. Then, after that, I initially set the loaded XML to an
    ArrayCollection but others have used XMLList or XMLListCollection.
    I've no idea what's the best way to do this.
    Eventually, when I've created all of these instances by
    looping over the XML and creating them how will I make them
    bindable to the data grid? I'm guessing I'll have to group them
    somehow...
    Any help would be greatly appreciated. Thanks

    Hey Tracy,
    That is exactly what I was talking about in a previous post
    you replied to
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1344350
    Anyhow, Below is some code I created to do what your saying
    somewhat dynamically. The idea being you can have many different
    object types that you may want to populate with data from XML. In
    my case I am using e4x as the result type from my web services. At
    present I have about 6 different classes that call this function.
    I'd love to get some opinions on the function. Good bad or
    ???? Any improvements etc????
    package . . . .
    import flash.utils.describeType;
    import flash.utils.getDefinitionByName;
    import flash.utils.getQualifiedClassName;
    import mx.utils.ObjectUtil;
    * Utility class to convert xml based Objects to class
    instances.
    * Takes a value object as the destination and an xmlList of
    data
    * Look through all the items in the value object. Note we
    are using classInfo..accessor since
    * our objects are bound all variables become getter /
    setter's or accessors.
    * Also note, we can handle custom objects, arrays and
    arrayCollections.
    * History
    * 03.11.2008 - Steven Rieger : Created class
    public final class XMLToInstance
    public static function xmlToInstance( destinationObject :
    Object, sourceXMLList : XMLList ) : void
    // Get the class definition in XML, from the passed in
    object ( introspection so to speak )
    var classInfo : XML = describeType( destinationObject );
    // Loop through each variable defined in the class.
    for each ( var aVar : XML in classInfo..accessor )
    // If this is String, Number, etc. . . Just copy the data
    into the destination object.
    if( isSimple( aVar.@type ) )
    destinationObject[aVar.@name] = sourceXMLList[aVar.@name];
    else
    // Dynamically create a class of the appropriate type
    var className : String = aVar.@type;
    var ObjectClass : Class = getDefinitionByName( className )
    as Class;
    var newDestObject : Object = Object( new ObjectClass());
    // If this is a custom type
    if( isCustomType( className ) && ObjectClass != null
    // Recursively call itself passing in the custom data type
    and the data to store in it.
    // I haven't tested nested objects more than one level. I
    suppose it should work.
    // Note to self. Check.
    xmlToInstance( newDestObject, sourceXMLList[aVar.@name] );
    else
    // Must be some sort of Array, Array Collection . . .
    if( ObjectClass != null )
    var anXMLList : XMLList = new XMLList(
    sourceXMLList[aVar.@name] );
    for each( var anItem : XML in anXMLList )
    // I'm sure there are more types, just not using any of them
    yet.
    if( newDestObject is Array )
    newDestObject.push( anItem )
    else
    newDestObject.addItem( anItem );
    // Add the data to the destination object. . . .
    destinationObject[aVar.@name] = newDestObject;
    } // end function objectToInstance
    public static function isSimple( dataType : String ) :
    Boolean
    * This function is pretty self explanatory.
    * Check to see if this is a simple data type. Did I miss
    any?
    * History
    * 03.11.2008 - Steven Rieger : Created function
    switch( dataType.toLowerCase() )
    case "number":
    case "string":
    case "boolean":
    return true;
    return false;
    } // end isSimple
    public static function isCustomType( className : String ) :
    Boolean
    * This function is pretty self explanatory.
    * Check to see if this is a custom data type. Add them here
    as you need. . .
    * History
    * 03.11.2008 - Steven Rieger : Created function
    var aClassName : String = className.replace( "::", "."
    ).toLowerCase();
    aClassName = aClassName.substr( aClassName.lastIndexOf( "."
    ) + 1, aClassName.length - aClassName.lastIndexOf( "." ) );
    switch( aClassName )
    case "ndatetimevo":
    case "expenselineitemvo":
    return true;
    return false;
    } // end isCustomType
    } // end class
    } // end package

  • Class Instance access

    Is it possible to make an instance of a class available for
    reading / writing to on all documents in an application? If so, how
    is it done?
    I have an application written that asks a user to login. When
    the user enters their information (email / password), information
    including their name, email address, date of last login, etc. is
    pulled from my database and a class instance is populated on the
    current page (lower level page). I would like to reference
    different parts of this class instance on multiple documents. For
    example, I would like to display a label that has a text property
    of "Hello, Jack", where 'Jack' is a variable held in the class
    instance on another page at the same level as the current
    page.

    You need to have a look at the Singleton Pattern. Here is a
    link that might help you
    http://flexrays.wordpress.com/2007/06/20/singleton-pattern/

  • The difference between class, instances and object?

    I've been reading a JAVA book and i've come accross terms such as class, instances and object. What I don't understand is why after creating a class, we have to create an object and then create instances? What's an object and instance anyway? I don't really understand the term. Can anyone pls help and explain it to me in an easier way to understand?
    Thanks a lot.

    A Class defines what attributes (properties) and methods a particular item will have.
    Ex. You have a class person
    public class Person
    public void walk()
    String name;
    int age;
    }An instance and Object are the same. When you create an instance of a class, you get an object of that class.
    Person kevonline = new Person();You can then set kev's name, age, make him walk, etc... since these are defined in the class Person.
    HTH,
    Dewang

  • An error occurred while getting property "userId" from an instance of class

    Running application SRDemo (Tutorial Chapter 6 Implementing Login Security)
    After logging, the List page popped up. But no data returned. Get Error
    JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: java.lang.RuntimeException, msg=javax.servlet.jsp.el.ELException: An error occurred while getting property "userId" from an instance of class oracle.srdemo.view.UserInfo.
    Questions:
    1. What are possible reasons to cause the getting property "userId" problem?[
    2. Why the Login page asked User Name and Password and the program used the query with "WHERE (EMAIL = 'sking')"
    The Log file shows the select statement:
    SELECT USER_ID, FIRST_NAME, LAST_NAME, CITY, POSTAL_CODE, EMAIL, STATE_PROVINCE, COUNTRY_ID, STREET_ADDRESS, USER_ROLE FROM USERS WHERE (EMAIL = 'sking')
    [TopLink Info]: 2006.11.08 11:07:09.468--ServerSession(1235)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--SRDemoSession login successful
    [TopLink Finer]: 2006.11.08 11:07:09.468--ServerSession(1235)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--client acquired
    [TopLink Fine]: 2006.11.08 11:07:09.500--ServerSession(1235)--Connection(1925)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--SELECT USER_ID, FIRST_NAME, LAST_NAME, CITY, POSTAL_CODE, EMAIL, STATE_PROVINCE, COUNTRY_ID, STREET_ADDRESS, USER_ROLE FROM USERS WHERE (EMAIL = 'sking')
    [TopLink Finer]: 2006.11.08 11:07:09.578--ClientSession(2021)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--client released
    [TopLink Finer]: 2006.11.08 11:07:09.625--ServerSession(1235)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--client acquired
    [TopLink Fine]: 2006.11.08 11:07:09.625--ServerSession(1235)--Connection(1922)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--SELECT USER_ID, FIRST_NAME, LAST_NAME, CITY, POSTAL_CODE, EMAIL, STATE_PROVINCE, COUNTRY_ID, STREET_ADDRESS, USER_ROLE FROM USERS WHERE (EMAIL = 'sking')
    [TopLink Finer]: 2006.11.08 11:07:09.625--ClientSession(2027)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--client released
    2006-11-08 11:07:09.640 WARNING JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: java.lang.RuntimeException, msg=javax.servlet.jsp.el.ELException: An error occurred while getting property "userId" from an instance of class oracle.srdemo.view.UserInfo
    2006-11-08 11:07:09.640 WARNING JBO-29000: Unexpected exception caught: java.lang.RuntimeException, msg=javax.servlet.jsp.el.ELException: An error occurred while getting property "userId" from an instance of class oracle.srdemo.view.UserInfo
    2006-11-08 11:07:09.640 WARNING javax.servlet.jsp.el.ELException: An error occurred while getting property "userId" from an instance of class oracle.srdemo.view.UserInfo
    2006-11-08 11:07:11.515 WARNING rowIterator is null
    2006-11-08 11:07:11.515 WARNING rowIterator is null
    Process exited.

    Hi,
    I got the answer to my question. The tables were not populated. So I ran the script - populateSchemaTables.sql, and got the data into the tables. The error is gone!
    Lin

  • Error building project using kXML2 - "Class loading error: Wrong name"

    Hi,
    I'm testing the XML-Parser KXML2 and downloaded the latest package, but the minimal version (kxml2-min.zip). I put this file into the directory "%j2mewtk%\apps\KxmlTest\lib" and wrote the lines
    import org.kxml2.io.*;
    import org.xmlpull.v1.*;
    When I try to build the project with the Wireless Toolkit (v1.04) it spits out the following error:
    Error preverifying class kxml2.io.KXmlParser
    Class loading error: Wrong name
    com.sun.kvem.ktools.ExecutionException: Preverifier returned 1
    Build failed
    I also tried the full package "kxml2.zip" but the same error occurs.
    How can I get rid of this? Thanks in advance!

    Okay, finally worked it out (hopefully). I unpacked the archive to a directory (say "%J2MEWTK%\apps\KxmlTest\tmpclasses") and then preverified them "manually":
    %J2SDK%\bin\preverify.exe -classpath "%J2MEWTK%\apps\KxmlTest\tmpclasses";"%J2MEWTK%\lib\midpapi.zip" org.kxml2.io.KXmlParser
    %J2SDK%\bin\preverify.exe -classpath "%J2MEWTK%\apps\KxmlTest\tmpclasses";"%J2MEWTK%\lib\midpapi.zip" org.xmlpull.v1.XmlPullParser
    %J2SDK%\bin\preverify.exe -classpath "%J2MEWTK%\apps\KxmlTest\tmpclasses";"%J2MEWTK%\lib\midpapi.zip" org.xmlpull.v1.XmlPullParserException
    Then I packed them again to a jar-file:
    %J2SDK%\bin\jar.exe -cvf kxml2-min.jar %J2MEWTK%\apps\KxmlTest\tmpclasses\output\.
    That was all!

  • Error creating instance of class from same package

    When I try to create an instance of a class that is in the same package, my IDE indicates that the constructor can not be found. Can anyone tell me what is wrong? Thanks. Below are the codes for both classes:
    package com.practice;
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    public class WebProject extends Applet{
         public void init(){
                    // The following line is where the IDE indicates there is an error
              UserInterface gui = new UserInterface();
         } // end init()
         public void start(){
         } // end start()
         public void stop(){
         } // end stop()
         public void destroy(){
         } // end destory()
    } // end class
    package com.practice;
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    public class UserInterface extends Applet{
         JPanel menuPanel = new JPanel();
         JPanel contentPanel = new JPanel();
         JPanel savePanel = new JPanel();
         ImageIcon saveIcon = new ImageIcon("workspace/images/toolbarButtongraphics/general/Save24");
         JButton saveButton = new JButton("Save", saveIcon);
         public UserInterface(){
              savePanel.add(saveButton);
              setLayout(new BorderLayout());
              add(menuPanel, BorderLayout.NORTH);
              add(contentPanel, BorderLayout.CENTER);
              add(savePanel, BorderLayout.SOUTH);
    } // end UserInterface class

    Thanks for the explanation and example. At first, I didn't understand what you were getting at, but after reading "Using Top-Level Containers" and "How to Use Root Panes" java tutorials it made much more sense. Unfortunately, the books I've read up to this point, did not cover those topics at all. The books simply stated that the first step in creating a Swing gui was to extend the JFrame, or JApplet, or etc.
    Unfortunately, my original problem persists. I continue to get compile-time errors such as:
    TestUserInterface.java:5: cannot find symbol
    symbol: class UserInterface
    location: class projects.web.TestUserInterface
                          UserInterface ui = new UserInterface(); Anyone know why?
    Both the classes are in the same named packaged. Below is my code:
    package projects.web;
    import java.awt.*;
    import javax.swing.*;
    public class UserInterface extends JFrame{
         JPanel menuPanel = new JPanel();
         JPanel contentPanel = new JPanel();
         JPanel selectionPanel = new JPanel();
         JButton save = new JButton("Save");
         JButton addFiles = new JButton("Add");
         public UserInterface(){
         super("File Upload");
         setSize(500, 500);
         menuPanel.add(addFiles);
         selectionPanel.add(save);
         setLayout(new BorderLayout());
         add(menuPanel, BorderLayout.NORTH);
         add(contentPanel, BorderLayout.CENTER);
         add(selectionPanel, BorderLayout.SOUTH);
         } // end constructor
    } // end UserInterface class
    package projects.web;
    public class TestUserInterface{
         public static void main(String[] args){
              UserInterface ui = new UserInterface();
    } // end TestUserInterface class

  • Automatic Generation of classes with required attribute names

    Hi ,
    I am new to XML technologies ...I am having a problem in deciding whether I
    should use JAXB or Castor for data binding.
    The problem is the attributes I am to use are named differently as that found in
    the DTD.I have creted my own classes using the required attribute names and the
    n mapped them using the Castor mapping with the attributes.
    I was wondering how should I achieve --"automatic generation of classes" with th
    e specified attribute names?
    I understand that JAXB can be used to automatically generate classes ,but this
    uses the same default names as that of the XML file ..is there a way of forcing
    JAXB to generate classes that use my name attributes rather than that of the XM
    L dtd
    If I use Castor ..is there a way to do the same.Generate Classes with the specif
    id attributes

    Hi ,
    I am new to XML technologies ...I am having a problem in deciding whether I
    should use JAXB or Castor for data binding.
    The problem is the attributes I am to use are named differently as that found in
    the DTD.I have creted my own classes using the required attribute names and the
    n mapped them using the Castor mapping with the attributes.
    I was wondering how should I achieve --"automatic generation of classes" with th
    e specified attribute names?
    I understand that JAXB can be used to automatically generate classes ,but this
    uses the same default names as that of the XML file ..is there a way of forcing
    JAXB to generate classes that use my name attributes rather than that of the XM
    L dtd
    If I use Castor ..is there a way to do the same.Generate Classes with the specif
    id attributes

  • How to get instance of Class with its type parameters

    Hi,
    Have any of you folks been dealing with generics long enough to show me how this should be written? Or point me to the answer (I have searched as well as I could).
    I boiled down my situation to the included sample code, which is long only because of the inserted comments. And while boiling I accidentally came across a surprise solution (a bug?), but would obviously prefer a smoother solution.
    My Questions (referred to in the code comments):
    #1. Is there a way to get my parameterized type (classarg) without resorting to using the bogus (proto) object?
    #2. Can anyone understand why the "C" and "D" attempts are different? (All I did was use an intermediate variable????) Is this a bug?
    Thanks so much for any input.
    /Mel
    class GenericWeird
       /* a generic class -- just an example */
       static class CompoundObject<T1,T2>
          CompoundObject(T1 primaryObject, T2 secondaryObject)
       /* another generic class -- its main point is that its constr requires its type class */
       static class TypedThing<ValueType>
          TypedThing(Class<ValueType> valuetypeclass)
       // here I just try to create a couple of TypedThings
       public static void main(String[] args)
          // take it for granted that I need to instantiate these two objects:
          TypedThing<String>                        stringTypedThing = null;
          TypedThing<CompoundObject<String,String>> stringstringTypedThing = null;
          // To instantiate stringTypedThing is easy...
          stringTypedThing = new TypedThing<String>(String.class);
          // ...but to instantiate stringstringTypedThing is more difficult to call the constructor
          Class<CompoundObject<String,String>> classarg = null;
          // classarg has got to be declared to this type
          //    otherwise there will rightfully be compiler error about the constructor call below
          // This method body illustrates my questions
          classarg = exploringHowToGetTheArg();
          // the constructor call
          stringstringTypedThing = new TypedThing<CompoundObject<String,String>>(classarg);
       } // end main method
       // try compiling this method with only one of A,B,C,D sections uncommented at a time
       private static Class<CompoundObject<String,String>> exploringHowToGetTheArg()
          Class<CompoundObject<String,String>> classarg = null;
          /* Exhibit A: */
      ////     classarg = CompoundObject.class;
             results in compiler error "incompatible types"
             found   : java.lang.Class<GenericWeird.CompoundObject>
             required: java.lang.Class<GenericWeird.CompoundObject<java.lang.String,java.lang.String>>
                   classarg = CompoundObject.class;
                                            ^
             I understand this.  But how to get the type information?
          /* It's obnoxious, but it looks like I will have to construct a temporary
              prototype instance of type
                 CompoundObject<String,String>
              in order to get an instance of
                 Class<CompoundObject<String,String>>
              (see my Question #1) */
          CompoundObject<String,String> proto = new CompoundObject<String,String>("foo", "fum");
          /* Exhibit B: */
      ////     classarg = proto.getClass();
             results in compiler error: "incompatible types"
             found   : java.lang.Class<capture of ? extends GenericWeird.CompoundObject>
             required: java.lang.Class<GenericWeird.CompoundObject<java.lang.String,java.lang.String>>
                   classarg = proto.getClass();
                                            ^
          /* Exhibit C: */
      ////     classarg = proto.getClass().asSubclass(proto.getClass());
             results in compiler error: "incompatible types"
             found   : java.lang.Class<capture of ? extends capture of ? extends GenericWeird.CompoundObject>
             required: java.lang.Class<GenericWeird.CompoundObject<java.lang.String,java.lang.String>>
                   classarg = proto.getClass().asSubclass(proto.getClass());
                                                         ^
          /* Exhibit D: (notice the similarity to C!): */
      ////     Class tmp1 = proto.getClass();
      ////     classarg = tmp1.asSubclass(tmp1);
          /* It compiles (see my Question #2) */
          return classarg;
       } // end method exploringHowToGetTheArg()
    } // end class GenericWeird

    Thanks so much, Bruce. (Oh my goodness, how would I have ever come up with that on my own?)
    So in summary
    This doesn't compile:
          classarg = (Class<CompoundObject<String,String>>)CompoundObject.class;but these do compile:
          classarg = (Class<CompoundObject<String,String>>)(Class)CompoundObject.class;or
          Class coclass = (Class)CompoundObject.class;
          classarg = (Class<CompoundObject<String,String>>)coclass;And this doesn't compile:
           classarg = proto.getClass().asSubclass(proto.getClass());but this does:
           Class tmp1 = proto.getClass();
           classarg = tmp1.asSubclass(tmp1);

Maybe you are looking for